Skip to content

Commit

Permalink
Merge @comet/blocks-api into @comet/cms-api (#2635)
Browse files Browse the repository at this point in the history
The dedicated `@comet/blocks-api` package was originally introduced to support projects without CMS parts.
It turned out that this is never the case, so the separation doesn't make sense anymore.
Therefore, the `@comet/blocks-api` is merged into the `@comet/cms-api` package.
  • Loading branch information
johnnyomair authored Nov 12, 2024
1 parent 93a9f1d commit bc5f831
Show file tree
Hide file tree
Showing 163 changed files with 601 additions and 1,504 deletions.
35 changes: 35 additions & 0 deletions .changeset/giant-teachers-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
"@comet/cms-api": major
---

Merge `@comet/blocks-api` into `@comet/cms-api`

The dedicated `@comet/blocks-api` package was originally introduced to support projects without CMS parts.
It turned out that this is never the case, so the separation doesn't make sense anymore.
Therefore, the `@comet/blocks-api` is merged into this package.

**Breaking changes**

- The `@comet/blocks-api` package doesn't exist anymore
- The `getFieldKeys` function has been removed from the public API
- Multiple exports that were too generic have been renamed
- `getMostSignificantPreviewImageUrlTemplate` -> `getMostSignificantPreviewImageUrlTemplateFromBlock`
- `getPreviewImageUrlTemplates` -> `getPreviewImageUrlTemplatesFromBlock`
- `getSearchText` -> `getSearchTextFromBlock`
- `inputToData` -> `blockInputToData`
- `TransformResponse` -> `TransformBlockResponse`
- `TransformResponseArray` -> `TransformBlockResponseArray`
- `transformToSave` -> `transformToBlockSave`
- `transformToSaveIndex` -> `transformToBlockSaveIndex`
- `TraversableTransformResponse` -> `TraversableTransformBlockResponse`
- `TraversableTransformResponseArray` -> `TraversableTransformBlockResponseArray`
- `typesafeMigrationPipe` -> `typeSafeBlockMigrationPipe`

**How to upgrade**

To upgrade, perform the following changes:

1. Uninstall the `@comet/blocks-api` package
2. Update all your imports from `@comet/blocks-api` to `@comet/cms-api`
3. Remove usages of `getFieldKeys` (probably none)
4. Update imports that have been renamed
1 change: 0 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ jobs:
# check for duplicate ids of formatted messages
pnpm run intl:extract
# check if schema files are up to date
pnpm --filter '@comet/blocks-api' run generate-block-meta
pnpm --filter '@comet/cms-api' run generate-block-meta
pnpm --filter '@comet/cms-api' run generate-schema
git diff --exit-code HEAD --
1 change: 0 additions & 1 deletion demo/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"start:prod": "node dist/main"
},
"dependencies": {
"@comet/blocks-api": "workspace:*",
"@comet/cms-api": "workspace:*",
"@hapi/accept": "^5.0.0",
"@kubernetes/client-node": "^0.18.0",
Expand Down
2 changes: 1 addition & 1 deletion demo/api/src/common/blocks/link-list.block.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BaseListBlockItemData, BaseListBlockItemInput, BlockField, createListBlock } from "@comet/blocks-api";
import { BaseListBlockItemData, BaseListBlockItemInput, BlockField, createListBlock } from "@comet/cms-api";
import { UserGroup } from "@src/user-groups/user-group";
import { IsEnum } from "class-validator";

Expand Down
3 changes: 1 addition & 2 deletions demo/api/src/common/blocks/linkBlock/link.block.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ExternalLinkBlock } from "@comet/blocks-api";
import { createLinkBlock, DamFileDownloadLinkBlock, EmailLinkBlock, InternalLinkBlock, PhoneLinkBlock } from "@comet/cms-api";
import { createLinkBlock, DamFileDownloadLinkBlock, EmailLinkBlock, ExternalLinkBlock, InternalLinkBlock, PhoneLinkBlock } from "@comet/cms-api";
import { NewsLinkBlock } from "@src/news/blocks/news-link.block";

export const LinkBlock = createLinkBlock({
Expand Down
2 changes: 1 addition & 1 deletion demo/api/src/common/blocks/rich-text.block.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createRichTextBlock } from "@comet/blocks-api";
import { createRichTextBlock } from "@comet/cms-api";

import { LinkBlock } from "./linkBlock/link.block";

Expand Down
2 changes: 1 addition & 1 deletion demo/api/src/common/blocks/space.block.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createSpaceBlock } from "@comet/blocks-api";
import { createSpaceBlock } from "@comet/cms-api";

export enum Spacing {
d150 = "d150",
Expand Down
2 changes: 1 addition & 1 deletion demo/api/src/common/blocks/text-link.block.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createTextLinkBlock } from "@comet/blocks-api";
import { createTextLinkBlock } from "@comet/cms-api";

import { LinkBlock } from "./linkBlock/link.block";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { BlocksBlockFixturesGeneratorMap, ExtractBlockInput, ExtractBlockInputFactoryProps } from "@comet/blocks-api";
import { FileInterface } from "@comet/cms-api";
import { BlocksBlockFixturesGeneratorMap, ExtractBlockInput, ExtractBlockInputFactoryProps, FileInterface } from "@comet/cms-api";
import { Config } from "@src/config/config";
import { PageContentBlock } from "@src/pages/blocks/page-content.block";
import faker from "faker";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ExtractBlockInputFactoryProps } from "@comet/blocks-api";
import { DamImageBlock, FileInterface, FocalPoint, ImageCropAreaInput } from "@comet/cms-api";
import { DamImageBlock, ExtractBlockInputFactoryProps, FileInterface, FocalPoint, ImageCropAreaInput } from "@comet/cms-api";
import faker from "faker";

export const generateImageBlock = (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ExtractBlockInputFactoryProps } from "@comet/blocks-api";
import { ExtractBlockInputFactoryProps } from "@comet/cms-api";
import { RichTextBlock } from "@src/common/blocks/rich-text.block";

export const generateRichtextBlock = (): ExtractBlockInputFactoryProps<typeof RichTextBlock> => {
Expand Down
3 changes: 1 addition & 2 deletions demo/api/src/db/fixtures/generators/blocks/seo.generator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { BlockInputInterface } from "@comet/blocks-api";
import { SitemapPageChangeFrequency, SitemapPagePriority } from "@comet/cms-api";
import { BlockInputInterface, SitemapPageChangeFrequency, SitemapPagePriority } from "@comet/cms-api";
import { SeoBlock } from "@src/pages/blocks/seo.block";

export const generateSeoBlock = (): BlockInputInterface => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ExtractBlockInputFactoryProps } from "@comet/blocks-api";
import { ExtractBlockInputFactoryProps } from "@comet/cms-api";
import { SpaceBlock, Spacing } from "@src/common/blocks/space.block";

export const generateSpaceBlock = (): ExtractBlockInputFactoryProps<typeof SpaceBlock> => ({ spacing: Spacing.d200 });
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ExtractBlockInputFactoryProps } from "@comet/blocks-api";
import { FileInterface, ImagePosition } from "@comet/cms-api";
import { ExtractBlockInputFactoryProps, FileInterface, ImagePosition } from "@comet/cms-api";
import { Config } from "@src/config/config";
import { TextImageBlock } from "@src/pages/blocks/TextImageBlock";
import faker from "faker";
Expand Down
6 changes: 3 additions & 3 deletions demo/api/src/footer/blocks/footer-content.block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import {
BlockDataInterface,
BlockField,
BlockInput,
blockInputToData,
ChildBlock,
ChildBlockInput,
createBlock,
createListBlock,
ExtractBlockInput,
inputToData,
} from "@comet/blocks-api";
} from "@comet/cms-api";
import { LinkListBlock } from "@src/common/blocks/link-list.block";
import { IsOptional, IsString } from "class-validator";

Expand Down Expand Up @@ -63,7 +63,7 @@ class FooterBlockInput extends BlockInput {
contactUs?: string;

transformToBlockData(): FooterBlockData {
return inputToData(FooterBlockData, this);
return blockInputToData(FooterBlockData, this);
}
}

Expand Down
6 changes: 3 additions & 3 deletions demo/api/src/footer/blocks/footer-link-section.block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import {
BlockDataInterface,
BlockField,
BlockInput,
blockInputToData,
ChildBlock,
ChildBlockInput,
createBlock,
ExtractBlockInput,
inputToData,
} from "@comet/blocks-api";
} from "@comet/cms-api";
import { LinkListBlock } from "@src/common/blocks/link-list.block";
import { IsOptional, IsString, ValidateNested } from "class-validator";

Expand All @@ -31,7 +31,7 @@ class FooterLinkSectionBlockInput extends BlockInput {
links: ExtractBlockInput<typeof LinkListBlock>;

transformToBlockData(): FooterLinkSectionBlockData {
return inputToData(FooterLinkSectionBlockData, this);
return blockInputToData(FooterLinkSectionBlockData, this);
}
}

Expand Down
3 changes: 1 addition & 2 deletions demo/api/src/footer/entities/footer.entity.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { BlockDataInterface, RootBlock, RootBlockEntity } from "@comet/blocks-api";
import { CrudSingleGenerator, RootBlockDataScalar, RootBlockType } from "@comet/cms-api";
import { BlockDataInterface, CrudSingleGenerator, RootBlock, RootBlockDataScalar, RootBlockEntity, RootBlockType } from "@comet/cms-api";
import { BaseEntity, Embedded, Entity, OptionalProps, PrimaryKey, Property } from "@mikro-orm/core";
import { Field, ID, ObjectType } from "@nestjs/graphql";
import { v4 as uuid } from "uuid";
Expand Down
3 changes: 1 addition & 2 deletions demo/api/src/footer/generated/dto/footer.input.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// This file has been generated by comet api-generator.
// You may choose to use this file as scaffold by moving this file out of generated folder and removing this comment.
import { BlockInputInterface, isBlockInputInterface } from "@comet/blocks-api";
import { PartialType, RootBlockInputScalar } from "@comet/cms-api";
import { BlockInputInterface, isBlockInputInterface, PartialType, RootBlockInputScalar } from "@comet/cms-api";
import { Field, InputType } from "@nestjs/graphql";
import { Transform } from "class-transformer";
import { IsNotEmpty, ValidateNested } from "class-validator";
Expand Down
3 changes: 1 addition & 2 deletions demo/api/src/links/dto/link.input.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { BlockInputInterface } from "@comet/blocks-api";
import { RootBlockInputScalar } from "@comet/cms-api";
import { BlockInputInterface, RootBlockInputScalar } from "@comet/cms-api";
import { Field, InputType } from "@nestjs/graphql";
import { LinkBlock } from "@src/common/blocks/linkBlock/link.block";
import { Transform } from "class-transformer";
Expand Down
2 changes: 1 addition & 1 deletion demo/api/src/links/entities/link.entity.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BlockDataInterface } from "@comet/blocks-api";
import {
BlockDataInterface,
DocumentInterface,
EntityInfo,
PageTreeNodeDocumentEntityInfoService,
Expand Down
3 changes: 1 addition & 2 deletions demo/api/src/menus/dto/main-menu-item.input.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { BlockInputInterface } from "@comet/blocks-api";
import { RootBlockInputScalar } from "@comet/cms-api";
import { BlockInputInterface, RootBlockInputScalar } from "@comet/cms-api";
import { Field, InputType } from "@nestjs/graphql";
import { RichTextBlock } from "@src/common/blocks/rich-text.block";
import { Transform } from "class-transformer";
Expand Down
3 changes: 1 addition & 2 deletions demo/api/src/menus/entities/main-menu-item.entity.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { BlockDataInterface, RootBlock, RootBlockEntity } from "@comet/blocks-api";
import { RootBlockDataScalar, RootBlockType } from "@comet/cms-api";
import { BlockDataInterface, RootBlock, RootBlockDataScalar, RootBlockEntity, RootBlockType } from "@comet/cms-api";
import { BaseEntity, Entity, OneToOne, OptionalProps, PrimaryKey, Property } from "@mikro-orm/core";
import { Field, ID, ObjectType } from "@nestjs/graphql";
import { RichTextBlock } from "@src/common/blocks/rich-text.block";
Expand Down
3 changes: 1 addition & 2 deletions demo/api/src/news/blocks/news-content.block.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { createBlocksBlock } from "@comet/blocks-api";
import { DamImageBlock } from "@comet/cms-api";
import { createBlocksBlock, DamImageBlock } from "@comet/cms-api";
import { RichTextBlock } from "@src/common/blocks/rich-text.block";
import { HeadlineBlock } from "@src/pages/blocks/headline.block";
import { TextImageBlock } from "@src/pages/blocks/TextImageBlock";
Expand Down
4 changes: 2 additions & 2 deletions demo/api/src/news/blocks/news-detail.block.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BlockData, BlockField, BlockIndexData, BlockInput, createBlock, inputToData } from "@comet/blocks-api";
import { BlockData, BlockField, BlockIndexData, BlockInput, blockInputToData, createBlock } from "@comet/cms-api";
import { IsOptional, IsUUID } from "class-validator";

class NewsDetailBlockData extends BlockData {
Expand Down Expand Up @@ -28,7 +28,7 @@ class NewsDetailBlockInput extends BlockInput {
id?: string;

transformToBlockData(): NewsDetailBlockData {
return inputToData(NewsDetailBlockData, this);
return blockInputToData(NewsDetailBlockData, this);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BlockTransformerServiceInterface } from "@comet/blocks-api";
import { BlockTransformerServiceInterface } from "@comet/cms-api";
import { InjectRepository } from "@mikro-orm/nestjs";
import { EntityRepository } from "@mikro-orm/postgresql";
import { Injectable } from "@nestjs/common";
Expand Down
6 changes: 3 additions & 3 deletions demo/api/src/news/blocks/news-link.block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import {
BlockField,
BlockIndexData,
BlockInput,
blockInputToData,
BlockMetaField,
BlockMetaFieldKind,
createBlock,
inputToData,
} from "@comet/blocks-api";
} from "@comet/cms-api";
import { IsOptional, IsUUID } from "class-validator";

import { NewsLinkBlockTransformerService } from "./news-link-block-transformer.service";
Expand Down Expand Up @@ -90,7 +90,7 @@ class NewsLinkBlockInput extends BlockInput {
id?: string;

transformToBlockData(): NewsLinkBlockData {
return inputToData(NewsLinkBlockData, this);
return blockInputToData(NewsLinkBlockData, this);
}
}

Expand Down
13 changes: 11 additions & 2 deletions demo/api/src/news/entities/news.entity.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import { BlockDataInterface, RootBlock, RootBlockEntity } from "@comet/blocks-api";
import { CrudField, CrudGenerator, DamImageBlock, EntityInfo, RootBlockDataScalar, RootBlockType } from "@comet/cms-api";
import {
BlockDataInterface,
CrudField,
CrudGenerator,
DamImageBlock,
EntityInfo,
RootBlock,
RootBlockDataScalar,
RootBlockEntity,
RootBlockType,
} from "@comet/cms-api";
import { BaseEntity, Collection, Embeddable, Embedded, Entity, Enum, OneToMany, OptionalProps, PrimaryKey, Property } from "@mikro-orm/core";
import { Field, ID, InputType, ObjectType, registerEnumType } from "@nestjs/graphql";
import { IsString } from "class-validator";
Expand Down
3 changes: 1 addition & 2 deletions demo/api/src/news/generated/dto/news.input.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// This file has been generated by comet api-generator.
// You may choose to use this file as scaffold by moving this file out of generated folder and removing this comment.
import { BlockInputInterface, isBlockInputInterface } from "@comet/blocks-api";
import { DamImageBlock, IsSlug, PartialType, RootBlockInputScalar } from "@comet/cms-api";
import { BlockInputInterface, DamImageBlock, isBlockInputInterface, IsSlug, PartialType, RootBlockInputScalar } from "@comet/cms-api";
import { Field, InputType } from "@nestjs/graphql";
import { Transform } from "class-transformer";
import { IsDate, IsEnum, IsNotEmpty, IsString, ValidateNested } from "class-validator";
Expand Down
3 changes: 1 addition & 2 deletions demo/api/src/pages/blocks/columns.block.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ColumnsBlockFactory, createBlocksBlock, SpaceBlock } from "@comet/blocks-api";
import { DamImageBlock } from "@comet/cms-api";
import { ColumnsBlockFactory, createBlocksBlock, DamImageBlock, SpaceBlock } from "@comet/cms-api";
import { RichTextBlock } from "@src/common/blocks/rich-text.block";

import { HeadlineBlock } from "./headline.block";
Expand Down
8 changes: 4 additions & 4 deletions demo/api/src/pages/blocks/full-width-image.block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import {
BlockData,
BlockDataInterface,
BlockInput,
blockInputToData,
ChildBlock,
ChildBlockInput,
createBlock,
createOptionalBlock,
DamImageBlock,
ExtractBlockData,
ExtractBlockInput,
inputToData,
} from "@comet/blocks-api";
import { DamImageBlock } from "@comet/cms-api";
} from "@comet/cms-api";
import { RichTextBlock } from "@src/common/blocks/rich-text.block";
import { ValidateNested } from "class-validator";

Expand All @@ -34,7 +34,7 @@ class FullWidthImageBlockInput extends BlockInput {
content: ExtractBlockInput<typeof FullWidthImageContentBlock>;

transformToBlockData(): BlockDataInterface {
return inputToData(FullWidthImageBlockData, this);
return blockInputToData(FullWidthImageBlockData, this);
}
}

Expand Down
6 changes: 3 additions & 3 deletions demo/api/src/pages/blocks/headline.block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import {
BlockDataInterface,
BlockField,
BlockInput,
blockInputToData,
ChildBlock,
ChildBlockInput,
createBlock,
ExtractBlockInput,
inputToData,
} from "@comet/blocks-api";
} from "@comet/cms-api";
import { RichTextBlock } from "@src/common/blocks/rich-text.block";
import { IsEnum, IsOptional, IsString, ValidateNested } from "class-validator";

Expand Down Expand Up @@ -47,7 +47,7 @@ class HeadlineBlockInput extends BlockInput {
level: HeadlineLevel;

transformToBlockData(): HeadlineBlockData {
return inputToData(HeadlineBlockData, this);
return blockInputToData(HeadlineBlockData, this);
}
}

Expand Down
3 changes: 1 addition & 2 deletions demo/api/src/pages/blocks/media.block.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { createOneOfBlock } from "@comet/blocks-api";
import { DamImageBlock, DamVideoBlock, VimeoVideoBlock, YouTubeVideoBlock } from "@comet/cms-api";
import { createOneOfBlock, DamImageBlock, DamVideoBlock, VimeoVideoBlock, YouTubeVideoBlock } from "@comet/cms-api";

export const MediaBlock = createOneOfBlock(
{
Expand Down
3 changes: 1 addition & 2 deletions demo/api/src/pages/blocks/page-content.block.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { BaseBlocksBlockItemData, BaseBlocksBlockItemInput, BlockField, createBlocksBlock } from "@comet/blocks-api";
import { AnchorBlock, DamImageBlock } from "@comet/cms-api";
import { AnchorBlock, BaseBlocksBlockItemData, BaseBlocksBlockItemInput, BlockField, createBlocksBlock, DamImageBlock } from "@comet/cms-api";
import { LinkListBlock } from "@src/common/blocks/link-list.block";
import { RichTextBlock } from "@src/common/blocks/rich-text.block";
import { SpaceBlock } from "@src/common/blocks/space.block";
Expand Down
8 changes: 4 additions & 4 deletions demo/api/src/pages/blocks/teaser.block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import {
BlockData,
BlockDataInterface,
BlockInput,
blockInputToData,
ChildBlock,
ChildBlockInput,
createBlock,
DamImageBlock,
ExtractBlockData,
ExtractBlockInput,
inputToData,
} from "@comet/blocks-api";
import { DamImageBlock } from "@comet/cms-api";
} from "@comet/cms-api";
import { LinkListBlock } from "@src/common/blocks/link-list.block";

import { HeadlineBlock } from "./headline.block";
Expand Down Expand Up @@ -42,7 +42,7 @@ class TeaserBlockInput extends BlockInput {
buttons: ExtractBlockInput<typeof LinkListBlock>;

transformToBlockData(): BlockDataInterface {
return inputToData(TeaserBlockData, this);
return blockInputToData(TeaserBlockData, this);
}
}

Expand Down
Loading

0 comments on commit bc5f831

Please sign in to comment.