diff --git a/CHANGELOG.md b/CHANGELOG.md index 68471885..457f38f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,57 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [7.11.0](https://github.com/prismicio/prismic-client/compare/v7.10.1...v7.11.0) (2024-09-25) + +## [7.10.0-alpha.0](https://github.com/prismicio/prismic-client/compare/v7.9.0...v7.10.0-alpha.0) (2024-09-20) + + +### Chore + +* **release:** 7.10.0-alpha.0 ([c801c12](https://github.com/prismicio/prismic-client/commit/c801c12b3f2a1175530a17a0c45d414ef3412797)) + +## [7.9.0-alpha.3](https://github.com/prismicio/prismic-client/compare/v7.8.1...v7.9.0-alpha.3) (2024-09-10) + + +### Chore + +* **release:** 7.9.0-alpha.3 ([0d3fb98](https://github.com/prismicio/prismic-client/commit/0d3fb98743b79d3fc2a41dcb2fc6edfc67857478)) + +## [7.9.0-alpha.2](https://github.com/prismicio/prismic-client/compare/v7.9.0-alpha.1...v7.9.0-alpha.2) (2024-08-27) + + +### Chore + +* **release:** 7.9.0-alpha.2 ([000f146](https://github.com/prismicio/prismic-client/commit/000f146d25b84b2937c3accaffa54ab936a78de8)) +* revert previous changes ([c53de86](https://github.com/prismicio/prismic-client/commit/c53de86a7ed749f0f9d8999b9e58564d9a8efe35)) + +## [7.9.0-alpha.1](https://github.com/prismicio/prismic-client/compare/v7.9.0-alpha.0...v7.9.0-alpha.1) (2024-08-27) + + +### Features + +* use KeyTextField for link text value definition ([1a4c51a](https://github.com/prismicio/prismic-client/commit/1a4c51a389ed4d06cf69c3edcb215559ba91fe99)) + + +### Chore + +* **release:** 7.9.0-alpha.1 ([d940fcd](https://github.com/prismicio/prismic-client/commit/d940fcdb023de34765006607f7f34481de00a6ef)) +* remove changelog for alpha ([50fc797](https://github.com/prismicio/prismic-client/commit/50fc797372726c0abc575b9f1b0a56d5db939bb1)) + +## [7.9.0-alpha.0](https://github.com/prismicio/prismic-client/compare/v7.8.0...v7.9.0-alpha.0) (2024-08-14) + + +### Features + +* add text property to link models ([40d0e0b](https://github.com/prismicio/prismic-client/commit/40d0e0be3ce8038cd36e8cdf3350ffa9893ada98)) +* add text to link value models ([8459d75](https://github.com/prismicio/prismic-client/commit/8459d75608c1af8319adafd2b3bf73555569a434)) + + +### Chore + +* **release:** 7.9.0-alpha.0 ([f2021c0](https://github.com/prismicio/prismic-client/commit/f2021c053b9aac1c17b7bbd1845c91eab7b0d176)) +* update package version ([c06b383](https://github.com/prismicio/prismic-client/commit/c06b383ff41f01e253641c7852a4e9701725bdba)) + ### [7.10.1](https://github.com/prismicio/prismic-client/compare/v7.10.0...v7.10.1) (2024-09-23) diff --git a/package-lock.json b/package-lock.json index 041bce6e..ebcca48c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@prismicio/client", - "version": "7.10.1", + "version": "7.11.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@prismicio/client", - "version": "7.10.1", + "version": "7.11.0", "license": "Apache-2.0", "dependencies": { "imgix-url-builder": "^0.0.5" diff --git a/package.json b/package.json index 15a47593..3210cb9f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@prismicio/client", - "version": "7.10.1", + "version": "7.11.0", "description": "The official JavaScript + TypeScript client library for Prismic", "keywords": [ "typescript", diff --git a/src/Migration.ts b/src/Migration.ts index 0d673441..53ab719a 100644 --- a/src/Migration.ts +++ b/src/Migration.ts @@ -410,8 +410,6 @@ export class Migration { // ID needs to be 16 characters long to be considered valid by the API id: "_____broken_____", isBroken: true, - // TODO: Remove when link text PR is merged - // @ts-expect-error - Future-proofing for link text text: input.text, } } @@ -419,8 +417,6 @@ export class Migration { return { link_type: LinkType.Document, id: () => this._getByOriginalID(input.id), - // TODO: Remove when link text PR is merged - // @ts-expect-error - Future-proofing for link text text: input.text, } } @@ -429,8 +425,6 @@ export class Migration { return { link_type: LinkType.Media, id: this.createAsset(input), - // TODO: Remove when link text PR is merged - // @ts-expect-error - Future-proofing for link text text: input.text, } } diff --git a/src/types/migration/Asset.ts b/src/types/migration/Asset.ts index 8aa928a9..386eb0ce 100644 --- a/src/types/migration/Asset.ts +++ b/src/types/migration/Asset.ts @@ -75,14 +75,7 @@ export type MigrationLinkToMedia = Pick< LinkToMediaField<"filled">, "link_type" > & - Partial< - Pick< - LinkToMediaField<"filled">, - // TODO: Remove when link text PR is merged - // @ts-expect-error - Future-proofing for link text - "text" - > - > & { + Partial, "text">> & { /** * A reference to the migration asset used to resolve the link to media * field's value. @@ -95,8 +88,6 @@ export type MigrationLinkToMedia = Pick< * with the migration API. */ export type MigrationLinkToMediaField = - // TODO: Remove when link text PR is merged - // @ts-expect-error - Future-proofing for link text | Pick, "link_type" | "id" | "text"> | EmptyLinkField<"Media"> diff --git a/src/types/migration/ContentRelationship.ts b/src/types/migration/ContentRelationship.ts index 44255fc6..667836f6 100644 --- a/src/types/migration/ContentRelationship.ts +++ b/src/types/migration/ContentRelationship.ts @@ -14,14 +14,7 @@ export type MigrationContentRelationship< > = | ValueOrThunk | undefined> | (Pick & - Partial< - Pick< - FilledContentRelationshipField, - // TODO: Remove when link text PR is merged - // @ts-expect-error - Future-proofing for link text - "text" - > - > & { + Partial> & { id: ValueOrThunk< TDocuments | PrismicMigrationDocument | undefined > diff --git a/src/types/model/contentRelationship.ts b/src/types/model/contentRelationship.ts index 09f06294..4c542748 100644 --- a/src/types/model/contentRelationship.ts +++ b/src/types/model/contentRelationship.ts @@ -18,5 +18,6 @@ export interface CustomTypeModelContentRelationshipField< select: typeof CustomTypeModelLinkSelectType.Document customtypes?: readonly CustomTypeIDs[] tags?: readonly Tags[] + allowText?: boolean } } diff --git a/src/types/model/link.ts b/src/types/model/link.ts index aa29c8d0..13793999 100644 --- a/src/types/model/link.ts +++ b/src/types/model/link.ts @@ -13,6 +13,7 @@ export interface CustomTypeModelLinkField { select?: | null | (typeof CustomTypeModelLinkSelectType)[keyof typeof CustomTypeModelLinkSelectType] + allowText?: boolean allowTargetBlank?: boolean } } diff --git a/src/types/model/linkToMedia.ts b/src/types/model/linkToMedia.ts index 2b447dbd..bf4dbddc 100644 --- a/src/types/model/linkToMedia.ts +++ b/src/types/model/linkToMedia.ts @@ -13,5 +13,6 @@ export interface CustomTypeModelLinkToMediaField { label?: string | null placeholder?: string select: typeof CustomTypeModelLinkSelectType.Media + allowText?: boolean } } diff --git a/src/types/value/contentRelationship.ts b/src/types/value/contentRelationship.ts index 00438e44..18919c3a 100644 --- a/src/types/value/contentRelationship.ts +++ b/src/types/value/contentRelationship.ts @@ -44,4 +44,5 @@ export interface FilledContentRelationshipField< slug?: string isBroken?: boolean data?: DataInterface + text?: string } diff --git a/src/types/value/link.ts b/src/types/value/link.ts index 2c2439f4..870004b1 100644 --- a/src/types/value/link.ts +++ b/src/types/value/link.ts @@ -24,6 +24,7 @@ export type EmptyLinkField< Type extends (typeof LinkType)[keyof typeof LinkType] = typeof LinkType.Any, > = { link_type: Type | string + text?: string } /** @@ -33,6 +34,7 @@ export interface FilledLinkToWebField { link_type: typeof LinkType.Web url: string target?: string + text?: string } /** diff --git a/src/types/value/linkToMedia.ts b/src/types/value/linkToMedia.ts index cc43ebb6..85d1a92c 100644 --- a/src/types/value/linkToMedia.ts +++ b/src/types/value/linkToMedia.ts @@ -24,4 +24,5 @@ export interface FilledLinkToMediaField { size: string height?: string | null width?: string | null + text?: string } diff --git a/test/types/customType-link.types.ts b/test/types/customType-link.types.ts index a44fcd91..d4808957 100644 --- a/test/types/customType-link.types.ts +++ b/test/types/customType-link.types.ts @@ -60,6 +60,17 @@ expectType({ }, }) +/** + * Supports optional `text` property. + */ +expectType({ + type: prismic.CustomTypeModelFieldType.Link, + config: { + label: "string", + allowText: true, + }, +}) + /** * `@prismicio/types` extends `@prismicio/types-internal` */ diff --git a/test/types/customType-linkToMedia.types.ts b/test/types/customType-linkToMedia.types.ts index dae8e2af..168934f6 100644 --- a/test/types/customType-linkToMedia.types.ts +++ b/test/types/customType-linkToMedia.types.ts @@ -40,6 +40,18 @@ expectType({ }, }) +/** + * Supports optional `text` property. + */ +expectType({ + type: prismic.CustomTypeModelFieldType.Link, + config: { + label: "string", + select: prismic.CustomTypeModelLinkSelectType.Media, + allowText: true, + }, +}) + /** * `@prismicio/types` extends `@prismicio/types-internal` */ diff --git a/test/types/fields-contentRelationship.types.ts b/test/types/fields-contentRelationship.types.ts index 352cf78f..71f455f3 100644 --- a/test/types/fields-contentRelationship.types.ts +++ b/test/types/fields-contentRelationship.types.ts @@ -32,6 +32,7 @@ expectType({ slug: "string", isBroken: true, data: undefined, + text: "string", }) expectType>({ link_type: prismic.LinkType.Document, @@ -44,6 +45,7 @@ expectType>({ slug: "string", isBroken: true, data: undefined, + text: "string", }) expectType>({ link_type: prismic.LinkType.Document, @@ -57,6 +59,7 @@ expectType>({ slug: "string", isBroken: true, data: undefined, + text: "string", }) /** @@ -75,6 +78,25 @@ expectType>( }, ) +/** + * Empty state with text. + */ +expectType({ + link_type: prismic.LinkType.Document, + text: "string", +}) +expectType>({ + link_type: prismic.LinkType.Document, + text: "string", +}) +expectType>( + // @ts-expect-error - Filled fields cannot contain an empty value. + { + link_type: prismic.LinkType.Document, + text: "string", + }, +) + /** * Supports custom document type. */ diff --git a/test/types/fields-link.types.ts b/test/types/fields-link.types.ts index 813eea01..2f8a3a5d 100644 --- a/test/types/fields-link.types.ts +++ b/test/types/fields-link.types.ts @@ -41,6 +41,7 @@ expectType({ link_type: prismic.LinkType.Web, url: "string", target: "string", + text: "string", }) // Content relationship link expectType({ @@ -54,6 +55,7 @@ expectType({ slug: "string", isBroken: true, data: undefined, + text: "string", }) // Media link expectType({ @@ -64,17 +66,20 @@ expectType({ size: "string", height: "string", width: "string", + text: "string", }) expectType>({ link_type: prismic.LinkType.Web, url: "string", target: "string", + text: "string", }) expectType>({ link_type: prismic.LinkType.Web, // @ts-expect-error - Empty fields cannot contain a filled value. url: "string", target: "string", + text: "string", }) /** @@ -83,12 +88,82 @@ expectType>({ expectType({ link_type: prismic.LinkType.Any, }) +expectType>({ + // @ts-expect-error - Filled fields cannot contain an empty value. + link_type: prismic.LinkType.Any, +}) +expectType({ + link_type: prismic.LinkType.Web, +}) +expectType>( + // @ts-expect-error - Filled fields cannot contain an empty value. + { + link_type: prismic.LinkType.Web, + }, +) +expectType({ + link_type: prismic.LinkType.Document, +}) +expectType>( + // @ts-expect-error - Filled fields cannot contain an empty value. + { + link_type: prismic.LinkType.Document, + }, +) +expectType({ + link_type: prismic.LinkType.Media, +}) +expectType>( + // @ts-expect-error - Filled fields cannot contain an empty value. + { + link_type: prismic.LinkType.Media, + }, +) + +/** + * Empty state with text. + */ +expectType>({ + link_type: prismic.LinkType.Web, + text: "string", +}) +expectType>( + // @ts-expect-error - Filled fields cannot contain an empty value. + { + link_type: prismic.LinkType.Web, + text: "string", + }, +) +expectType>({ + link_type: prismic.LinkType.Document, + text: "string", +}) +expectType>( + // @ts-expect-error - Filled fields cannot contain an empty value. + { + link_type: prismic.LinkType.Document, + text: "string", + }, +) +expectType>({ + link_type: prismic.LinkType.Media, + text: "string", +}) +expectType>( + // @ts-expect-error - Filled fields cannot contain an empty value. + { + link_type: prismic.LinkType.Media, + text: "string", + }, +) expectType>({ link_type: prismic.LinkType.Any, + text: "string", }) expectType>({ // @ts-expect-error - Filled fields cannot contain an empty value. link_type: prismic.LinkType.Any, + text: "string", }) /** diff --git a/test/types/fields-linkToMedia.types.ts b/test/types/fields-linkToMedia.types.ts index 44a10d15..c5b63fbf 100644 --- a/test/types/fields-linkToMedia.types.ts +++ b/test/types/fields-linkToMedia.types.ts @@ -30,6 +30,7 @@ expectType({ size: "string", height: "string", width: "string", + text: "string", }) expectType>({ id: "string", @@ -40,6 +41,7 @@ expectType>({ size: "string", height: "string", width: "string", + text: "string", }) expectType>({ link_type: prismic.LinkType.Media, @@ -51,6 +53,7 @@ expectType>({ size: "string", height: "string", width: "string", + text: "string", }) /** @@ -68,3 +71,22 @@ expectType>( link_type: prismic.LinkType.Media, }, ) + +/** + * Empty state with text. + */ +expectType({ + link_type: prismic.LinkType.Media, + text: "string", +}) +expectType>({ + link_type: prismic.LinkType.Media, + text: "string", +}) +expectType>( + // @ts-expect-error - Filled fields cannot contain an empty value. + { + link_type: prismic.LinkType.Media, + text: "string", + }, +) diff --git a/test/writeClient-migrate-patch-linkToMedia.test.ts b/test/writeClient-migrate-patch-linkToMedia.test.ts index efdf0984..341cc23f 100644 --- a/test/writeClient-migrate-patch-linkToMedia.test.ts +++ b/test/writeClient-migrate-patch-linkToMedia.test.ts @@ -22,8 +22,6 @@ const assetToLinkToMedia = ( size: `${asset.size}`, height: typeof asset.height === "number" ? `${asset.height}` : undefined, width: typeof asset.width === "number" ? `${asset.width}` : undefined, - // TODO: Remove when link text PR is merged - // @ts-expect-error - Future-proofing for link text text, } }