From 2788f69d3b832394937f5a02b4e39328d4cb446e Mon Sep 17 00:00:00 2001 From: Angelo Ashmore Date: Fri, 12 May 2023 11:17:40 -1000 Subject: [PATCH 1/4] docs: stylize field names to lowercase --- src/buildQueryURL.ts | 2 +- src/createClient.ts | 52 ++++++++++++------------- src/types/api/repository.ts | 2 +- src/types/model/boolean.ts | 2 +- src/types/model/color.ts | 2 +- src/types/model/contentRelationship.ts | 2 +- src/types/model/customType.ts | 22 +++++------ src/types/model/date.ts | 2 +- src/types/model/embed.ts | 2 +- src/types/model/geoPoint.ts | 2 +- src/types/model/group.ts | 2 +- src/types/model/image.ts | 6 +-- src/types/model/integrationFields.ts | 2 +- src/types/model/keyText.ts | 2 +- src/types/model/link.ts | 4 +- src/types/model/linkToMedia.ts | 2 +- src/types/model/number.ts | 2 +- src/types/model/richText.ts | 6 +-- src/types/model/select.ts | 2 +- src/types/model/slice.ts | 2 +- src/types/model/sliceZone.ts | 4 +- src/types/model/timestamp.ts | 2 +- src/types/model/title.ts | 2 +- src/types/model/types.ts | 8 ++-- src/types/model/uid.ts | 2 +- src/types/value/boolean.ts | 2 +- src/types/value/color.ts | 2 +- src/types/value/contentRelationship.ts | 2 +- src/types/value/date.ts | 2 +- src/types/value/document.ts | 8 ++-- src/types/value/embed.ts | 2 +- src/types/value/geoPoint.ts | 2 +- src/types/value/group.ts | 2 +- src/types/value/image.ts | 8 ++-- src/types/value/integrationFields.ts | 2 +- src/types/value/keyText.ts | 2 +- src/types/value/link.ts | 4 +- src/types/value/linkToMedia.ts | 4 +- src/types/value/number.ts | 2 +- src/types/value/richText.ts | 48 +++++++++++------------ src/types/value/select.ts | 2 +- src/types/value/sharedSlice.ts | 2 +- src/types/value/sharedSliceVariation.ts | 3 ++ src/types/value/slice.ts | 2 +- src/types/value/timestamp.ts | 2 +- src/types/value/title.ts | 2 +- src/types/webhook/apiUpdate.ts | 2 +- 47 files changed, 124 insertions(+), 121 deletions(-) diff --git a/src/buildQueryURL.ts b/src/buildQueryURL.ts index 07fcaf1f..e4c482c7 100644 --- a/src/buildQueryURL.ts +++ b/src/buildQueryURL.ts @@ -53,7 +53,7 @@ export interface Ordering { */ export interface Route { /** - * The Custom Type of the document. + * The custom type of the document. */ type: string; diff --git a/src/createClient.ts b/src/createClient.ts index 5f1be367..5dd7edf2 100644 --- a/src/createClient.ts +++ b/src/createClient.ts @@ -234,7 +234,7 @@ export type ClientConfig = { ref?: RefStringOrThunk; /** - * A list of Route Resolver objects that define how a document's `url` field + * A list of Route Resolver objects that define how a document's `url` property * is resolved. * * {@link https://prismic.io/docs/route-resolver} @@ -243,8 +243,8 @@ export type ClientConfig = { /** * The `brokenRoute` option allows you to define the route populated in the - * `url` property for broken Link or Content Relationship fields. A broken - * link is a Link or Content Relationship field whose linked document has been + * `url` property for broken link or content relationship fields. A broken + * link is a link or content relationship field whose linked document has been * unpublished or deleted. * * {@link https://prismic.io/docs/route-resolver} @@ -424,8 +424,8 @@ export class Client { /** * The `brokenRoute` option allows you to define the route populated in the - * `url` property for broken Link or Content Relationship fields. A broken - * link is a Link or Content Relationship field whose linked document has been + * `url` property for broken link or content relationship fields. A broken + * link is a link or content relationship field whose linked document has been * unpublished or deleted. * * {@link https://prismic.io/docs/route-resolver} @@ -735,7 +735,7 @@ export class Client { * A document's UID is different from its ID. An ID is automatically generated * for all documents and is made available on its `id` property. A UID is * provided in the Prismic editor and is unique among all documents of its - * Custom Type. + * custom type. * @example * * ```ts @@ -765,7 +765,7 @@ export class Client { * A document's UID is different from its ID. An ID is automatically generated * for all documents and is made available on its `id` property. A UID is * provided in the Prismic editor and is unique among all documents of its - * Custom Type. + * custom type. * @example * * ```ts @@ -801,7 +801,7 @@ export class Client { * A document's UID is different from its ID. An ID is automatically generated * for all documents and is made available on its `id` property. A UID is * provided in the Prismic editor and is unique among all documents of its - * Custom Type. + * custom type. * @example * * ```ts @@ -828,13 +828,13 @@ export class Client { /** * Queries a document from the Prismic repository with a specific UID and - * Custom Type. + * custom type. * * @remarks * A document's UID is different from its ID. An ID is automatically generated * for all documents and is made available on its `id` property. A UID is * provided in the Prismic editor and is unique among all documents of its - * Custom Type. + * custom type. * @example * * ```ts @@ -842,7 +842,7 @@ export class Client { * ``` * * @typeParam TDocument - Type of the Prismic document returned. - * @param documentType - The API ID of the document's Custom Type. + * @param documentType - The API ID of the document's custom type. * @param uid - UID of the document. * @param params - Parameters to filter, sort, and paginate the results. * @@ -873,7 +873,7 @@ export class Client { * A document's UID is different from its ID. An ID is automatically generated * for all documents and is made available on its `id` property. A UID is * provided in the Prismic editor and is unique among all documents of its - * Custom Type. + * custom type. * @example * * ```ts @@ -884,7 +884,7 @@ export class Client { * ``` * * @typeParam TDocument - Type of the Prismic document returned. - * @param documentType - The API ID of the document's Custom Type. + * @param documentType - The API ID of the document's custom type. * @param uids - A list of document UIDs. * @param params - Parameters to filter, sort, and paginate the results. * @@ -909,7 +909,7 @@ export class Client { /** * Queries all documents from the Prismic repository with specific UIDs and - * Custom Type. + * custom type. * * This method may make multiple network requests to query all matching * content. @@ -918,7 +918,7 @@ export class Client { * A document's UID is different from its ID. An ID is automatically generated * for all documents and is made available on its `id` property. A UID is * provided in the Prismic editor and is unique among all documents of its - * Custom Type. + * custom type. * @example * * ```ts @@ -929,7 +929,7 @@ export class Client { * ``` * * @typeParam TDocument - Type of Prismic documents returned. - * @param documentType - The API ID of the document's Custom Type. + * @param documentType - The API ID of the document's custom type. * @param uids - A list of document UIDs. * @param params - Parameters to filter, sort, and paginate the results. * @@ -955,12 +955,12 @@ export class Client { /** * Queries a singleton document from the Prismic repository for a specific - * Custom Type. + * custom type. * * @remarks * A singleton document is one that is configured in Prismic to only allow one * instance. For example, a repository may be configured to contain just one - * Settings document. This is in contrast to a repeatable Custom Type which + * Settings document. This is in contrast to a repeatable custom type which * allows multiple instances of itself. * @example * @@ -969,10 +969,10 @@ export class Client { * ``` * * @typeParam TDocument - Type of the Prismic document returned. - * @param documentType - The API ID of the singleton Custom Type. + * @param documentType - The API ID of the singleton custom type. * @param params - Parameters to filter, sort, and paginate the results. * - * @returns The singleton document for the Custom Type, if a matching document + * @returns The singleton document for the custom type, if a matching document * exists. */ async getSingle< @@ -988,10 +988,10 @@ export class Client { } /** - * Queries documents from the Prismic repository for a specific Custom Type. + * Queries documents from the Prismic repository for a specific custom type. * * Use `getAllByType` instead if you need to query all documents for a - * specific Custom Type. + * specific custom type. * * @example * @@ -1000,10 +1000,10 @@ export class Client { * ``` * * @typeParam TDocument - Type of Prismic documents returned. - * @param documentType - The API ID of the Custom Type. + * @param documentType - The API ID of the custom type. * @param params - Parameters to filter, sort, and paginate the results. * - * @returns A paginated response containing documents of the Custom Type. + * @returns A paginated response containing documents of the custom type. */ async getByType< TDocument extends TDocuments, @@ -1031,10 +1031,10 @@ export class Client { * ``` * * @typeParam TDocument - Type of Prismic documents returned. - * @param documentType - The API ID of the Custom Type. + * @param documentType - The API ID of the custom type. * @param params - Parameters to filter, sort, and paginate the results. * - * @returns A list of all documents of the Custom Type. + * @returns A list of all documents of the custom type. */ async getAllByType< TDocument extends TDocuments, diff --git a/src/types/api/repository.ts b/src/types/api/repository.ts index b1ab8529..4db93fac 100644 --- a/src/types/api/repository.ts +++ b/src/types/api/repository.ts @@ -28,7 +28,7 @@ export interface Repository { languages: Language[]; /** - * A list of the repository's Custom Type API IDs mapped to their + * A list of the repository's custom type API IDs mapped to their * human-readable name. */ types: Record; diff --git a/src/types/model/boolean.ts b/src/types/model/boolean.ts index b91d87dd..bba71f9f 100644 --- a/src/types/model/boolean.ts +++ b/src/types/model/boolean.ts @@ -1,7 +1,7 @@ import type { CustomTypeModelFieldType } from "./types"; /** - * A Boolean Custom Type field. + * A boolean custom type field. * * More details: {@link https://prismic.io/docs/boolean} */ diff --git a/src/types/model/color.ts b/src/types/model/color.ts index 40c344f1..5cbd4dab 100644 --- a/src/types/model/color.ts +++ b/src/types/model/color.ts @@ -1,7 +1,7 @@ import type { CustomTypeModelFieldType } from "./types"; /** - * A Color Custom Type field. + * A color custom type field. * * More details: {@link https://prismic.io/docs/color} */ diff --git a/src/types/model/contentRelationship.ts b/src/types/model/contentRelationship.ts index ed39cf31..9dd54e04 100644 --- a/src/types/model/contentRelationship.ts +++ b/src/types/model/contentRelationship.ts @@ -3,7 +3,7 @@ import type { CustomTypeModelFieldType } from "./types"; import type { CustomTypeModelLinkSelectType } from "./link"; /** - * A Content Relationship Custom Type field. + * A content relationship custom type field. * * More details: * {@link https://prismic.io/docs/content-relationship} diff --git a/src/types/model/customType.ts b/src/types/model/customType.ts index 4fc865f1..9e18074d 100644 --- a/src/types/model/customType.ts +++ b/src/types/model/customType.ts @@ -1,46 +1,46 @@ import { CustomTypeModelField } from "./types"; /** - * A Prismic Custom Type model. + * A Prismic custom type model. * - * @typeParam ID - API ID of the Custom Type. - * @typeParam Definition - The Custom Type's tabs and their fields. + * @typeParam ID - API ID of the custom type. + * @typeParam Definition - The custom type's tabs and their fields. */ export interface CustomTypeModel< ID extends string = string, Definition extends CustomTypeModelDefinition = CustomTypeModelDefinition, > { /** - * The ID of the Custom Type model. + * The ID of the custom type model. */ id: ID; /** - * The human readable name of the Custom Type Model. + * The human readable name of the custom type Model. */ // TODO: Revert to `label?: string | null` if `label` can be partial in: https://github.com/prismicio/prismic-types-internal/blob/HEAD/src/customtypes/CustomType.ts#L39 label: string | null | undefined; /** - * Determines if more than one document for the Custom Type can be created. + * Determines if more than one document for the custom type can be created. */ repeatable: boolean; /** - * The Custom Type model definition. + * The custom type model definition. */ json: Definition; /** - * Determines if new documents for the Custom Type can be created. + * Determines if new documents for the custom type can be created. */ status: boolean; } /** - * A Prismic Custom Type's tabs and their fields. + * A Prismic custom type's tabs and their fields. * - * @typeParam TabName - Names of Custom Type tabs. + * @typeParam TabName - Names of custom type tabs. */ export type CustomTypeModelDefinition = Record< TabName, @@ -48,7 +48,7 @@ export type CustomTypeModelDefinition = Record< >; /** - * A Custom Type's tab. Each tab can contain any number of fields but is limited + * A custom type's tab. Each tab can contain any number of fields but is limited * to one Slice Zone. * * @typeParam FieldName - API IDs of the fields. diff --git a/src/types/model/date.ts b/src/types/model/date.ts index 056a917f..e4c7e561 100644 --- a/src/types/model/date.ts +++ b/src/types/model/date.ts @@ -1,7 +1,7 @@ import type { CustomTypeModelFieldType } from "./types"; /** - * A Date Custom Type field. + * A date custom type field. * * More details: {@link https://prismic.io/docs/date} */ diff --git a/src/types/model/embed.ts b/src/types/model/embed.ts index 9f24d79d..cb4d59e9 100644 --- a/src/types/model/embed.ts +++ b/src/types/model/embed.ts @@ -1,7 +1,7 @@ import type { CustomTypeModelFieldType } from "./types"; /** - * An Embed Custom Type field. + * An embed custom type field. * * More details: {@link https://prismic.io/docs/embed} */ diff --git a/src/types/model/geoPoint.ts b/src/types/model/geoPoint.ts index 47f3579c..b7c36f81 100644 --- a/src/types/model/geoPoint.ts +++ b/src/types/model/geoPoint.ts @@ -1,7 +1,7 @@ import type { CustomTypeModelFieldType } from "./types"; /** - * A GeoPoint Custom Type field. + * A geopoint custom type field. * * More details: {@link https://prismic.io/docs/geopoint} */ diff --git a/src/types/model/group.ts b/src/types/model/group.ts index 6f21f421..58849120 100644 --- a/src/types/model/group.ts +++ b/src/types/model/group.ts @@ -4,7 +4,7 @@ import type { } from "./types"; /** - * A Group Custom Type field. + * A group custom type field. * * More details: {@link https://prismic.io/docs/group} * diff --git a/src/types/model/image.ts b/src/types/model/image.ts index 63132886..7fe42a09 100644 --- a/src/types/model/image.ts +++ b/src/types/model/image.ts @@ -1,7 +1,7 @@ import type { CustomTypeModelFieldType } from "./types"; /** - * Dimension constraints for an Image Custom Type field. + * Dimension constraints for an image custom type field. * * More details: {@link https://prismic.io/docs/image} */ @@ -11,7 +11,7 @@ export interface CustomTypeModelImageConstraint { } /** - * A thumbnail for an Image Custom Type field. + * A thumbnail for an image custom type field. * * More details: {@link https://prismic.io/docs/image} */ @@ -21,7 +21,7 @@ export interface CustomTypeModelImageThumbnail } /** - * An Image Custom Type field. + * An image custom type field. * * More details: {@link https://prismic.io/docs/image} */ diff --git a/src/types/model/integrationFields.ts b/src/types/model/integrationFields.ts index 75e83688..b54543ca 100644 --- a/src/types/model/integrationFields.ts +++ b/src/types/model/integrationFields.ts @@ -1,7 +1,7 @@ import type { CustomTypeModelFieldType } from "./types"; /** - * An Integration Fields Custom Type field. + * An integration custom type field. * * More details: {@link https://prismic.io/docs/integration-fields} */ diff --git a/src/types/model/keyText.ts b/src/types/model/keyText.ts index 86d342cf..92f5186c 100644 --- a/src/types/model/keyText.ts +++ b/src/types/model/keyText.ts @@ -1,7 +1,7 @@ import type { CustomTypeModelFieldType } from "./types"; /** - * A Key Text Custom Type field. + * A key text custom type field. * * More details: {@link https://prismic.io/docs/key-text} */ diff --git a/src/types/model/link.ts b/src/types/model/link.ts index eb29ff51..c1491fec 100644 --- a/src/types/model/link.ts +++ b/src/types/model/link.ts @@ -1,7 +1,7 @@ import type { CustomTypeModelFieldType } from "./types"; /** - * A Link Custom Type field. + * A link custom type field. * * More details: * {@link https://prismic.io/docs/link} @@ -19,7 +19,7 @@ export interface CustomTypeModelLinkField { } /** - * Type of a Link Custom Type field. + * Type of a Link custom type field. * * More details: * {@link https://prismic.io/docs/link} diff --git a/src/types/model/linkToMedia.ts b/src/types/model/linkToMedia.ts index 086745e9..602b12f3 100644 --- a/src/types/model/linkToMedia.ts +++ b/src/types/model/linkToMedia.ts @@ -3,7 +3,7 @@ import type { CustomTypeModelFieldType } from "./types"; import type { CustomTypeModelLinkSelectType } from "./link"; /** - * A Link to Media Custom Type field. + * A link to media custom type field. * * More details: * {@link https://prismic.io/docs/media} diff --git a/src/types/model/number.ts b/src/types/model/number.ts index 3a067b91..709d56d8 100644 --- a/src/types/model/number.ts +++ b/src/types/model/number.ts @@ -1,7 +1,7 @@ import type { CustomTypeModelFieldType } from "./types"; /** - * A Number Custom Type field. + * A number custom type field. * * More details: {@link https://prismic.io/docs/number} */ diff --git a/src/types/model/richText.ts b/src/types/model/richText.ts index 51797fde..3c42ea53 100644 --- a/src/types/model/richText.ts +++ b/src/types/model/richText.ts @@ -1,7 +1,7 @@ import type { CustomTypeModelFieldType } from "./types"; /** - * A Rich Text Custom Type field. + * A rich text custom type field. * * More details: {@link https://prismic.io/docs/rich-text-title} */ @@ -10,7 +10,7 @@ export type CustomTypeModelRichTextField = | CustomTypeModelRichTextSingleField; /** - * A Rich Text Custom Type field which supports multiple blocks of content. + * A rich text custom type field which supports multiple blocks of content. * * More details: {@link https://prismic.io/docs/rich-text-title} */ @@ -25,7 +25,7 @@ export interface CustomTypeModelRichTextMultiField { } /** - * A Rich Text Custom Type field which supports one block of content. + * A rich text custom type field which supports one block of content. * * More details: {@link https://prismic.io/docs/rich-text-title} */ diff --git a/src/types/model/select.ts b/src/types/model/select.ts index cc1d22c9..053d1a30 100644 --- a/src/types/model/select.ts +++ b/src/types/model/select.ts @@ -1,7 +1,7 @@ import type { CustomTypeModelFieldType } from "./types"; /** - * A Select Custom Type field. + * A select custom type field. * * More details: {@link https://prismic.io/docs/select} * diff --git a/src/types/model/slice.ts b/src/types/model/slice.ts index 4c220e2e..e5871295 100644 --- a/src/types/model/slice.ts +++ b/src/types/model/slice.ts @@ -4,7 +4,7 @@ import type { CustomTypeModelGroupField } from "./group"; import type { CustomTypeModelSliceType } from "./sliceZone"; /** - * A Slice for a Custom Type. + * A Slice for a custom type. * * More details: {@link https://prismic.io/docs/slice} * diff --git a/src/types/model/sliceZone.ts b/src/types/model/sliceZone.ts index dae21f1f..dd3826c1 100644 --- a/src/types/model/sliceZone.ts +++ b/src/types/model/sliceZone.ts @@ -3,7 +3,7 @@ import type { CustomTypeModelFieldType } from "./types"; import type { CustomTypeModelLegacySlice, CustomTypeModelSlice } from "./slice"; /** - * A Slice Zone Custom Type field. + * A Slice Zone custom type field. * * More details: {@link https://prismic.io/docs/slice} */ @@ -51,7 +51,7 @@ export const CustomTypeModelSliceType = { } as const; /** - * A Shared Slice for a Custom Type. + * A Shared Slice for a custom type. * * More details: {@link https://prismic.io/docs/slice} */ diff --git a/src/types/model/timestamp.ts b/src/types/model/timestamp.ts index 4f9dd431..e1e7c4c0 100644 --- a/src/types/model/timestamp.ts +++ b/src/types/model/timestamp.ts @@ -1,7 +1,7 @@ import type { CustomTypeModelFieldType } from "./types"; /** - * A Timestamp Custom Type field. + * A timestamp custom type field. * * More details: {@link https://prismic.io/docs/timestamp} */ diff --git a/src/types/model/title.ts b/src/types/model/title.ts index 2ded23b9..51ba5380 100644 --- a/src/types/model/title.ts +++ b/src/types/model/title.ts @@ -1,7 +1,7 @@ import { CustomTypeModelRichTextSingleField } from "./richText"; /** - * A Title Custom Type field. + * A title custom type field. * * More details: {@link https://prismic.io/docs/rich-text-title} */ diff --git a/src/types/model/types.ts b/src/types/model/types.ts index fe58cc21..4733fea9 100644 --- a/src/types/model/types.ts +++ b/src/types/model/types.ts @@ -21,7 +21,7 @@ import type { CustomTypeModelTitleField } from "./title"; import type { CustomTypeModelUIDField } from "./uid"; /** - * Type identifier for a Custom Type field. + * Type identifier for a custom type field. */ export const CustomTypeModelFieldType = { Boolean: "Boolean", @@ -31,7 +31,7 @@ export const CustomTypeModelFieldType = { GeoPoint: "GeoPoint", Group: "Group", Image: "Image", - IntegrationFields: "IntegrationFields", + Integration: "IntegrationFields", Link: "Link", Number: "Number", Select: "Select", @@ -55,7 +55,7 @@ export const CustomTypeModelFieldType = { } as const; /** - * A Custom Type field. + * A custom type field. */ export type CustomTypeModelField = | CustomTypeModelUIDField @@ -64,7 +64,7 @@ export type CustomTypeModelField = | CustomTypeModelFieldForGroup; /** - * Any Custom Type field that is valid for a Group field. + * Any custom type field that is valid for a group field. */ export type CustomTypeModelFieldForGroup = | CustomTypeModelBooleanField diff --git a/src/types/model/uid.ts b/src/types/model/uid.ts index af37ff72..104f974e 100644 --- a/src/types/model/uid.ts +++ b/src/types/model/uid.ts @@ -1,7 +1,7 @@ import type { CustomTypeModelFieldType } from "./types"; /** - * A UID Custom Type field. + * A UID custom type field. * * More details: {@link https://prismic.io/docs/uid} */ diff --git a/src/types/value/boolean.ts b/src/types/value/boolean.ts index af718423..94056d6b 100644 --- a/src/types/value/boolean.ts +++ b/src/types/value/boolean.ts @@ -1,5 +1,5 @@ /** - * A Boolean field. + * A boolean field. * * @see More details: {@link https://prismic.io/docs/boolean} */ diff --git a/src/types/value/color.ts b/src/types/value/color.ts index b7c6932d..1d922ec7 100644 --- a/src/types/value/color.ts +++ b/src/types/value/color.ts @@ -1,7 +1,7 @@ import type { FieldState } from "./types"; /** - * A Color field. + * A color field. * * @typeParam State - State of the field which determines its shape. * @see More details: {@link https://prismic.io/docs/color} diff --git a/src/types/value/contentRelationship.ts b/src/types/value/contentRelationship.ts index 34fa14b8..dbc788d6 100644 --- a/src/types/value/contentRelationship.ts +++ b/src/types/value/contentRelationship.ts @@ -25,7 +25,7 @@ export type ContentRelationshipField< : FilledContentRelationshipField; /** - * Links that refer to Documents + * Links that refer to documents */ export interface FilledContentRelationshipField< TypeEnum = string, diff --git a/src/types/value/date.ts b/src/types/value/date.ts index 0bbcbbd1..ce3d1f73 100644 --- a/src/types/value/date.ts +++ b/src/types/value/date.ts @@ -1,7 +1,7 @@ import type { FieldState } from "./types"; /** - * A Date field. + * A date field. * * @typeParam State - State of the field which determines its shape. * @see More details: {@link https://prismic.io/docs/date} diff --git a/src/types/value/document.ts b/src/types/value/document.ts index 9e8fed6c..f740da57 100644 --- a/src/types/value/document.ts +++ b/src/types/value/document.ts @@ -14,7 +14,7 @@ export interface AlternateLanguage { } /** - * Metadata for Prismic Document + * Metadata for Prismic document */ export interface PrismicDocumentHeader { /** @@ -76,7 +76,7 @@ export interface PrismicDocumentHeader { /** * A Prismic document served through REST API v2. * - * @see More details on Custom Types: {@link https://prismic.io/docs/custom-types} + * @see More details on custom types: {@link https://prismic.io/docs/custom-types} */ export interface PrismicDocument< DataInterface extends Record< @@ -97,7 +97,7 @@ export interface PrismicDocument< * A Prismic document served through REST API v2. Does not contain a UID (a * unique identifier). * - * @see More details on Custom Types: {@link https://prismic.io/docs/custom-types} + * @see More details on custom types: {@link https://prismic.io/docs/custom-types} * @see More details on the UID field: {@link https://prismic.io/docs/uid} */ export interface PrismicDocumentWithoutUID< @@ -123,7 +123,7 @@ export interface PrismicDocumentWithoutUID< * A Prismic document served through REST API v2. Contains a UID (a unique * identifier). * - * @see More details on Custom Types: {@link https://prismic.io/docs/custom-types} + * @see More details on custom types: {@link https://prismic.io/docs/custom-types} * @see More details on the UID field: {@link https://prismic.io/docs/uid} */ export interface PrismicDocumentWithUID< diff --git a/src/types/value/embed.ts b/src/types/value/embed.ts index 1dea17c8..6b15451c 100644 --- a/src/types/value/embed.ts +++ b/src/types/value/embed.ts @@ -179,7 +179,7 @@ export type RichOEmbed = OEmbedBase & { export type AnyOEmbed = PhotoOEmbed | VideoOEmbed | LinkOEmbed | RichOEmbed; /** - * An Embed field. + * An embed field. * * @typeParam Data - Data provided by the URL's oEmbed provider. * @typeParam State - State of the field which determines its shape. diff --git a/src/types/value/geoPoint.ts b/src/types/value/geoPoint.ts index dfbce9a4..e406e8c8 100644 --- a/src/types/value/geoPoint.ts +++ b/src/types/value/geoPoint.ts @@ -1,7 +1,7 @@ import type { EmptyObjectField, FieldState } from "./types"; /** - * A Geopoint field. + * A geopoint field. * * @typeParam State - State of the field which determines its shape. * @see More details: {@link https://prismic.io/docs/geopoint} diff --git a/src/types/value/group.ts b/src/types/value/group.ts index 7d02aa46..c7298168 100644 --- a/src/types/value/group.ts +++ b/src/types/value/group.ts @@ -1,7 +1,7 @@ import type { AnyRegularField, FieldState } from "./types"; /** - * A Group field. + * A group field. * * More details: {@link https://prismic.io/docs/group} */ diff --git a/src/types/value/image.ts b/src/types/value/image.ts index 29fe8d32..bea8cd83 100644 --- a/src/types/value/image.ts +++ b/src/types/value/image.ts @@ -1,11 +1,11 @@ import type { FieldState, Simplify } from "./types"; /** - * An individual image within an Image field. The base image and each thumbnail + * An individual image within an image field. The base image and each thumbnail * uses this type. * * @typeParam State - State of the field which determines its shape. - * @see {@link ImageField} for a full Image field type. + * @see {@link ImageField} for a full image field type. */ export type ImageFieldImage = State extends "empty" ? EmptyImageFieldImage : FilledImageFieldImage; @@ -28,7 +28,7 @@ export interface EmptyImageFieldImage { } /** - * Image Field + * An image field. * * **Note**: Passing `null` to the `ThumbnailNames` parameter is deprecated and * will be removed in a future version. Use `never` instead. @@ -45,7 +45,7 @@ export type ImageField< ThumbnailNames extends string | null = never, State extends FieldState = FieldState, > = - // Simplify is necessary. Without it, Group and Slice types break for + // Simplify is necessary. Without it, group and Slice types break for // unknown reasons. If you know why, please update this comment with an // explanation. :) Simplify< diff --git a/src/types/value/integrationFields.ts b/src/types/value/integrationFields.ts index d80f306e..058f4c5a 100644 --- a/src/types/value/integrationFields.ts +++ b/src/types/value/integrationFields.ts @@ -1,7 +1,7 @@ import type { FieldState } from "./types"; /** - * Integration Fields for Custom APIs + * An integration field. * * @typeParam Data - Data from the integrated API. * @typeParam State - State of the field which determines its shape. diff --git a/src/types/value/keyText.ts b/src/types/value/keyText.ts index a72b35ae..856a1851 100644 --- a/src/types/value/keyText.ts +++ b/src/types/value/keyText.ts @@ -1,7 +1,7 @@ import type { FieldState } from "./types"; /** - * A Key text field + * A key text field * * @typeParam State - State of the field which determines its shape. * @see More details: {@link https://prismic.io/docs/key-text} diff --git a/src/types/value/link.ts b/src/types/value/link.ts index a3ef6164..c71f0fa9 100644 --- a/src/types/value/link.ts +++ b/src/types/value/link.ts @@ -6,7 +6,7 @@ import type { LinkToMediaField } from "./linkToMedia"; import type { SliceZone } from "./sliceZone"; /** - * Link Types + * Link types */ export const LinkType = { Any: "Any", @@ -36,7 +36,7 @@ export interface FilledLinkToWebField { } /** - * Link Field + * A link field. * * @typeParam TypeEnum - Type API ID of the document. * @typeParam LangEnum - Language API ID of the document. diff --git a/src/types/value/linkToMedia.ts b/src/types/value/linkToMedia.ts index 002d66b7..eebe220b 100644 --- a/src/types/value/linkToMedia.ts +++ b/src/types/value/linkToMedia.ts @@ -3,7 +3,7 @@ import type { FieldState } from "./types"; import type { EmptyLinkField, LinkType } from "./link"; /** - * Link field that points to media + * A link field that points to media. * * @typeParam State - State of the field which determines its shape. */ @@ -13,7 +13,7 @@ export type LinkToMediaField = : FilledLinkToMediaField; /** - * Link that points to media + * A link that points to media. */ export interface FilledLinkToMediaField { link_type: typeof LinkType.Media; diff --git a/src/types/value/number.ts b/src/types/value/number.ts index 3d8d3b1e..f2cff390 100644 --- a/src/types/value/number.ts +++ b/src/types/value/number.ts @@ -1,7 +1,7 @@ import type { FieldState } from "./types"; /** - * A Number field + * A number field. * * @typeParam State - State of the field which determines its shape. * @see More details: {@link https://prismic.io/docs/number} diff --git a/src/types/value/richText.ts b/src/types/value/richText.ts index fa7cf2f7..c87609b4 100644 --- a/src/types/value/richText.ts +++ b/src/types/value/richText.ts @@ -43,70 +43,70 @@ export interface RTTextNodeBase { } /** - * Rich Text `heading1` node + * Rich text `heading1` node */ export interface RTHeading1Node extends RTTextNodeBase { type: typeof RichTextNodeType.heading1; } /** - * Rich Text `heading2` node + * Rich text `heading2` node */ export interface RTHeading2Node extends RTTextNodeBase { type: typeof RichTextNodeType.heading2; } /** - * Rich Text `heading3` node + * Rich text `heading3` node */ export interface RTHeading3Node extends RTTextNodeBase { type: typeof RichTextNodeType.heading3; } /** - * Rich Text `heading4` node + * Rich text `heading4` node */ export interface RTHeading4Node extends RTTextNodeBase { type: typeof RichTextNodeType.heading4; } /** - * Rich Text `heading5` node + * Rich text `heading5` node */ export interface RTHeading5Node extends RTTextNodeBase { type: typeof RichTextNodeType.heading5; } /** - * Rich Text `heading6` node + * Rich text `heading6` node */ export interface RTHeading6Node extends RTTextNodeBase { type: typeof RichTextNodeType.heading6; } /** - * Rich Text `paragraph` node + * Rich text `paragraph` node */ export interface RTParagraphNode extends RTTextNodeBase { type: typeof RichTextNodeType.paragraph; } /** - * Rich Text `preformatted` node + * Rich text `preformatted` node */ export interface RTPreformattedNode extends RTTextNodeBase { type: typeof RichTextNodeType.preformatted; } /** - * Rich Text `list-item` node + * Rich text `list-item` node */ export interface RTListItemNode extends RTTextNodeBase { type: typeof RichTextNodeType.listItem; } /** - * Rich Text `o-list-item` node for ordered lists + * Rich text `o-list-item` node for ordered lists */ export interface RTOListItemNode extends RTTextNodeBase { type: typeof RichTextNodeType.oListItem; @@ -122,21 +122,21 @@ export interface RTSpanNodeBase { end: number; } /** - * Rich Text `strong` node + * Rich text `strong` node */ export interface RTStrongNode extends RTSpanNodeBase { type: typeof RichTextNodeType.strong; } /** - * Rich Text `embed` node + * Rich text `embed` node */ export interface RTEmNode extends RTSpanNodeBase { type: typeof RichTextNodeType.em; } /** - * Rich Text `label` node + * Rich text `label` node */ export interface RTLabelNode extends RTSpanNodeBase { type: typeof RichTextNodeType.label; @@ -148,7 +148,7 @@ export interface RTLabelNode extends RTSpanNodeBase { // Media nodes /** - * Rich Text `image` nodes. They could link to other documents, external web + * Rich text `image` nodes. They could link to other documents, external web * links and media fields */ export type RTImageNode = { @@ -167,7 +167,7 @@ export type RTImageNode = { }; /** - * Rich Text `embed` node + * Rich text `embed` node */ export type RTEmbedNode = { type: typeof RichTextNodeType.embed; @@ -177,7 +177,7 @@ export type RTEmbedNode = { // Link nodes /** - * Rich Text `a` node + * Rich text `a` node * * @see More details: {@link https://prismic.io/docs/rich-text-title#elements-and-styles} */ @@ -192,7 +192,7 @@ export interface RTLinkNode extends RTSpanNodeBase { // Serialization related nodes /** - * Rich Text `list` node + * Rich text `list` node */ export interface RTListNode { type: typeof RichTextNodeType.list; @@ -200,7 +200,7 @@ export interface RTListNode { } /** - * Rich Text o-lost node + * Rich text o-lost node */ export interface RTOListNode { type: typeof RichTextNodeType.oList; @@ -209,7 +209,7 @@ export interface RTOListNode { // This one is confusing but it's actually the inner content of a block /** - * Rich Text `span` node + * Rich text `span` node */ export interface RTSpanNode extends RTTextNodeBase { type: typeof RichTextNodeType.span; @@ -218,7 +218,7 @@ export interface RTSpanNode extends RTTextNodeBase { // Helpers /** - * Nodes from a Rich Text Field + * Nodes from a rich text field */ export type RTNode = | RTHeading1Node @@ -250,7 +250,7 @@ export type RTTextNode = | RTOListItemNode; /** - * Rich Text block nodes + * Rich text block nodes */ export type RTBlockNode = | RTHeading1Node @@ -269,17 +269,17 @@ export type RTBlockNode = | RTEmbedNode; /** - * Inline Rich Text Nodes + * Inline rich text Nodes */ export type RTInlineNode = RTStrongNode | RTEmNode | RTLabelNode | RTLinkNode; /** - * All Rich Text nodes + * All rich text nodes */ export type RTAnyNode = RTBlockNode | RTInlineNode | RTSpanNode; /** - * Rich Text Field + * A rich text field. * * @see Rich Text field documentation: {@link https://prismic.io/docs/rich-text-title} */ diff --git a/src/types/value/select.ts b/src/types/value/select.ts index f5c70c76..95669eaa 100644 --- a/src/types/value/select.ts +++ b/src/types/value/select.ts @@ -1,7 +1,7 @@ import type { FieldState } from "./types"; /** - * A Select field + * A select field. * * @typeParam Enum - Selectable options for the field. * @typeParam State - State of the field which determines its shape. diff --git a/src/types/value/sharedSlice.ts b/src/types/value/sharedSlice.ts index 1eaa39d6..68f431c4 100644 --- a/src/types/value/sharedSlice.ts +++ b/src/types/value/sharedSlice.ts @@ -1,7 +1,7 @@ import type { SharedSliceVariation } from "./sharedSliceVariation"; /** - * Shared Slice + * A Shared Slice. * * @see More details: {@link https://prismic.io/docs/slice} */ diff --git a/src/types/value/sharedSliceVariation.ts b/src/types/value/sharedSliceVariation.ts index 1e2672e9..5fe997eb 100644 --- a/src/types/value/sharedSliceVariation.ts +++ b/src/types/value/sharedSliceVariation.ts @@ -1,5 +1,8 @@ import type { AnyRegularField } from "./types"; +/** + * A Shared Slice variation. + */ export interface SharedSliceVariation< Variation = string, PrimaryFields extends Record = Record< diff --git a/src/types/value/slice.ts b/src/types/value/slice.ts index b827e226..8d569a70 100644 --- a/src/types/value/slice.ts +++ b/src/types/value/slice.ts @@ -1,7 +1,7 @@ import type { AnyRegularField } from "./types"; /** - * Slice - Sections of your website + * A Slice - sections of your website. * * @see More details: {@link https://prismic.io/docs/slice} */ diff --git a/src/types/value/timestamp.ts b/src/types/value/timestamp.ts index 2b281914..2137102f 100644 --- a/src/types/value/timestamp.ts +++ b/src/types/value/timestamp.ts @@ -3,7 +3,7 @@ import type { FieldState } from "./types"; import type { DateField } from "./date"; /** - * Simple Timestamp Field + * A timestamp field. * * @typeParam State - State of the field which determines its shape. */ diff --git a/src/types/value/title.ts b/src/types/value/title.ts index 85586c84..5401c3c6 100644 --- a/src/types/value/title.ts +++ b/src/types/value/title.ts @@ -10,7 +10,7 @@ import type { } from "./richText"; /** - * Title Field + * A title field. * * @see Title field documentation: {@link https://prismic.io/docs/rich-text-title} */ diff --git a/src/types/webhook/apiUpdate.ts b/src/types/webhook/apiUpdate.ts index b9018d9b..baad6c1f 100644 --- a/src/types/webhook/apiUpdate.ts +++ b/src/types/webhook/apiUpdate.ts @@ -25,7 +25,7 @@ interface WebhookBodyAPIUpdateOperations { } /** - * Metadata representing a mask (also called a Custom Type). + * Metadata representing a mask (also called a custom type). * * @see More details: {@link https://prismic.io/docs/custom-types} */ From f9704a724df7685d6c7f704c5e7eeeab215b6d87 Mon Sep 17 00:00:00 2001 From: Angelo Ashmore Date: Fri, 12 May 2023 11:18:38 -1000 Subject: [PATCH 2/4] docs: additional renames --- src/buildQueryURL.ts | 2 +- src/filter.ts | 2 +- src/helpers/asDate.ts | 4 +- src/helpers/asHTML.ts | 36 +++++++------- src/helpers/asImagePixelDensitySrcSet.ts | 10 ++-- src/helpers/asImageSrc.ts | 6 +-- src/helpers/asImageWidthSrcSet.ts | 12 ++--- src/helpers/asLink.ts | 12 ++--- src/helpers/asLinkAttrs.ts | 6 +-- src/helpers/asText.ts | 16 +++---- src/helpers/documentToLinkField.ts | 2 +- src/helpers/isFilled.ts | 47 ++++++++++--------- src/index.ts | 22 +++++++-- src/types/api/repository.ts | 2 +- .../{integrationFields.ts => integration.ts} | 4 +- src/types/model/types.ts | 4 +- .../{integrationFields.ts => integration.ts} | 2 +- src/types/value/richText.ts | 6 +-- src/types/value/types.ts | 4 +- test/client-graphQLFetch.test.ts | 4 +- test/helpers-isFilled.test.ts | 9 ++-- test/index.test.ts | 2 +- ...pes.ts => customType-integration.types.ts} | 14 +++--- test/types/customType.types.ts | 2 +- ...s.types.ts => fields-integration.types.ts} | 18 +++---- test/types/fields.types.ts | 2 +- test/types/helpers-isFilled.types.ts | 28 +++++------ 27 files changed, 152 insertions(+), 126 deletions(-) rename src/types/model/{integrationFields.ts => integration.ts} (69%) rename src/types/value/{integrationFields.ts => integration.ts} (93%) rename test/types/{customType-integrationFields.types.ts => customType-integration.types.ts} (65%) rename test/types/{fields-integrationFields.types.ts => fields-integration.types.ts} (54%) diff --git a/src/buildQueryURL.ts b/src/buildQueryURL.ts index e4c482c7..0b0abb8d 100644 --- a/src/buildQueryURL.ts +++ b/src/buildQueryURL.ts @@ -205,7 +205,7 @@ type BuildQueryURLParams = { ref: string; /** - * Ref used to populate Integration Fields with the latest content. + * Ref used to populate integration fields with the latest content. * * {@link https://prismic.io/docs/integration-fields} */ diff --git a/src/filter.ts b/src/filter.ts index 057a33e0..3535825a 100644 --- a/src/filter.ts +++ b/src/filter.ts @@ -177,7 +177,7 @@ export const filter = { * The `geopoint.near` filter checks that the value in the path is within * the radius of the given coordinates. * - * This filter will only work for a GeoPoint field. + * This filter will only work for a geopoint field. * * {@link https://prismic.io/docs/rest-api-technical-reference#geopointnear} */ diff --git a/src/helpers/asDate.ts b/src/helpers/asDate.ts index 5daff37d..ea43b4c3 100644 --- a/src/helpers/asDate.ts +++ b/src/helpers/asDate.ts @@ -9,9 +9,9 @@ type AsDateReturnType< > = Field extends DateField<"filled"> | TimestampField<"filled"> ? Date : null; /** - * Transforms a Date or Timestamp field into a JavaScript Date object + * Transforms a date or timestamp field into a JavaScript Date object * - * @param dateOrTimestampField - A Date or Timestamp field from Prismic + * @param dateOrTimestampField - A date or timestamp field from Prismic * * @returns A Date object, null if provided date is falsy * @see Templating date field from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#date-and-timestamp} diff --git a/src/helpers/asHTML.ts b/src/helpers/asHTML.ts index 9883fb8a..54fc8fdf 100644 --- a/src/helpers/asHTML.ts +++ b/src/helpers/asHTML.ts @@ -22,13 +22,13 @@ import type { RichTextField } from "../types/value/richText"; import { LinkResolverFunction } from "./asLink"; /** - * Serializes a node from a Rich Text or Title field with a function to HTML. + * Serializes a node from a rich text or title field with a function to HTML. * * Unlike a typical `@prismicio/richtext` function serializer, this serializer * converts the `children` argument to a single string rather than an array of * strings. * - * @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title} + * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title} */ export type HTMLRichTextFunctionSerializer = ( type: Parameters>[0], @@ -39,13 +39,13 @@ export type HTMLRichTextFunctionSerializer = ( ) => string | null | undefined; /** - * Serializes a node from a Rich Text or Title field with a map to HTML + * Serializes a node from a rich text or title field with a map to HTML * * Unlike a typical `@prismicio/richtext` map serializer, this serializer * converts the `children` property to a single string rather than an array of * strings. * - * @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title} + * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title} */ export type HTMLRichTextMapSerializer = { [P in keyof RichTextMapSerializer]: (payload: { @@ -63,7 +63,7 @@ export type HTMLRichTextMapSerializer = { * A {@link RichTextMapSerializerFunction} type specifically for * {@link HTMLRichTextMapSerializer}. * - * @typeParam BlockName - The serializer's Rich Text block type. + * @typeParam BlockName - The serializer's rich text block type. */ type HTMLRichTextMapSerializerFunction< BlockType extends keyof RichTextMapSerializer, @@ -106,17 +106,17 @@ type ExtractTextTypeGeneric = T extends RichTextMapSerializerFunction< : never; /** - * Serializes a node from a Rich Text or Title field with a map or a function to HTML + * Serializes a node from a rich text or title field with a map or a function to HTML * * @see {@link HTMLRichTextMapSerializer} and {@link HTMLRichTextFunctionSerializer} - * @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title} + * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title} */ export type HTMLRichTextSerializer = | HTMLRichTextMapSerializer | HTMLRichTextFunctionSerializer; /** - * Creates a default HTML Rich Text Serializer with a given Link Resolver providing + * Creates a default HTML rich text Serializer with a given Link Resolver providing * sensible and safe defaults for every node type * * @internal @@ -211,7 +211,7 @@ type AsHTMLConfig = { linkResolver?: LinkResolverFunction | null; /** - * An optional Rich Text Serializer, unhandled cases will fallback to the default serializer + * An optional rich text Serializer, unhandled cases will fallback to the default serializer */ htmlRichTextSerializer?: HTMLRichTextSerializer | null; }; @@ -234,13 +234,13 @@ type AsHTMLReturnType = // TODO: Remove overload when we remove support for deprecated tuple-style configuration. export const asHTML: { /** - * Serializes a Rich Text or Title field to an HTML string. + * Serializes a rich text or title field to an HTML string. * - * @param richTextField - A Rich Text or Title field from Prismic + * @param richTextField - A rich text or title field from Prismic * @param config - Configuration that determines the output of `asHTML()` * - * @returns HTML equivalent of the provided Rich Text or Title field - * @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title} + * @returns HTML equivalent of the provided rich text or title field + * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title} */ ( richTextField: Field, @@ -248,16 +248,16 @@ export const asHTML: { ): AsHTMLReturnType; /** - * Serializes a Rich Text or Title field to an HTML string. + * Serializes a rich text or title field to an HTML string. * - * @param richTextField - A Rich Text or Title field from Prismic + * @param richTextField - A rich text or title field from Prismic * @param linkResolver - An optional link resolver function to resolve links, * without it you're expected to use the `routes` options from the API - * @param htmlRichTextSerializer - An optional Rich Text Serializer, unhandled cases will fallback + * @param htmlRichTextSerializer - An optional rich text Serializer, unhandled cases will fallback * to the default serializer * - * @returns HTML equivalent of the provided Rich Text or Title field - * @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title} + * @returns HTML equivalent of the provided rich text or title field + * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title} * * @deprecated Use object-style configuration instead. * diff --git a/src/helpers/asImagePixelDensitySrcSet.ts b/src/helpers/asImagePixelDensitySrcSet.ts index eddb1438..20801908 100644 --- a/src/helpers/asImagePixelDensitySrcSet.ts +++ b/src/helpers/asImagePixelDensitySrcSet.ts @@ -30,12 +30,12 @@ type AsImagePixelDensitySrcSetReturnType< > = Field extends ImageFieldImage<"filled"> ? { /** - * The Image field's image URL with Imgix URL parameters (if given). + * The image field's image URL with Imgix URL parameters (if given). */ src: string; /** - * A pixel-densitye-based `srcset` attribute value for the Image field's + * A pixel-densitye-based `srcset` attribute value for the image field's * image with Imgix URL parameters (if given). */ srcset: string; @@ -43,7 +43,7 @@ type AsImagePixelDensitySrcSetReturnType< : null; /** - * Creates a pixel-density-based `srcset` from an Image field with optional + * Creates a pixel-density-based `srcset` from an image field with optional * image transformations (via Imgix URL parameters). * * If a `pixelDensities` parameter is not given, the following pixel densities @@ -68,8 +68,8 @@ type AsImagePixelDensitySrcSetReturnType< * @param config - An object of Imgix URL API parameters. The `pixelDensities` * parameter defines the resulting `srcset` widths. * - * @returns A `srcset` attribute value for the Image field with Imgix URL - * parameters (if given). If the Image field is empty, `null` is returned. + * @returns A `srcset` attribute value for the image field with Imgix URL + * parameters (if given). If the image field is empty, `null` is returned. * @see Imgix URL parameters reference: https://docs.imgix.com/apis/rendering */ export const asImagePixelDensitySrcSet = < diff --git a/src/helpers/asImageSrc.ts b/src/helpers/asImageSrc.ts index cf94aa6f..64e9ba08 100644 --- a/src/helpers/asImageSrc.ts +++ b/src/helpers/asImageSrc.ts @@ -11,7 +11,7 @@ type AsImageSrcReturnType = Field extends ImageFieldImage<"filled"> ? string : null; /** - * Returns the URL of an Image field with optional image transformations (via + * Returns the URL of an image field with optional image transformations (via * Imgix URL parameters). * * @example @@ -25,8 +25,8 @@ type AsImageSrcReturnType = * an image URL. * @param config - An object of Imgix URL API parameters to transform the image. * - * @returns The Image field's image URL with transformations applied (if given). - * If the Image field is empty, `null` is returned. + * @returns The image field's image URL with transformations applied (if given). + * If the image field is empty, `null` is returned. * @see Imgix URL parameters reference: https://docs.imgix.com/apis/rendering */ export const asImageSrc = ( diff --git a/src/helpers/asImageWidthSrcSet.ts b/src/helpers/asImageWidthSrcSet.ts index def1b73e..2e6896c5 100644 --- a/src/helpers/asImageWidthSrcSet.ts +++ b/src/helpers/asImageWidthSrcSet.ts @@ -21,12 +21,12 @@ type AsImageWidthSrcSetReturnType< > = Field extends ImageFieldImage<"filled"> ? { /** - * The Image field's image URL with Imgix URL parameters (if given). + * The image field's image URL with Imgix URL parameters (if given). */ src: string; /** - * A width-based `srcset` attribute value for the Image field's image with + * A width-based `srcset` attribute value for the image field's image with * Imgix URL parameters (if given). */ srcset: string; @@ -41,13 +41,13 @@ type AsImageWidthSrcSetConfig = Omit & { }; /** - * Creates a width-based `srcset` from an Image field with optional image + * Creates a width-based `srcset` from an image field with optional image * transformations (via Imgix URL parameters). * * If a `widths` parameter is not given, the following widths will be used by * default: 640, 750, 828, 1080, 1200, 1920, 2048, 3840. * - * If the Image field contains responsive views, each responsive view can be + * If the image field contains responsive views, each responsive view can be * used as a width in the resulting `srcset` by passing `"thumbnails"` as the * `widths` parameter. * @@ -72,8 +72,8 @@ type AsImageWidthSrcSetConfig = Omit & { * defines the resulting `srcset` widths. Pass `"thumbnails"` to automatically * use the field's responsive views. * - * @returns A `srcset` attribute value for the Image field with Imgix URL - * parameters (if given). If the Image field is empty, `null` is returned. + * @returns A `srcset` attribute value for the image field with Imgix URL + * parameters (if given). If the image field is empty, `null` is returned. * @see Imgix URL parameters reference: https://docs.imgix.com/apis/rendering */ export const asImageWidthSrcSet = < diff --git a/src/helpers/asLink.ts b/src/helpers/asLink.ts index 311c61c7..6bdc902c 100644 --- a/src/helpers/asLink.ts +++ b/src/helpers/asLink.ts @@ -62,15 +62,15 @@ export type AsLinkReturnType< // TODO: Remove overload when we remove support for deprecated tuple-style configuration. export const asLink: { /** - * Resolves any type of Link field or Prismic document to a URL. + * Resolves any type of link field or Prismic document to a URL. * * @typeParam LinkResolverFunctionReturnType - Link Resolver function return * type * @typeParam Field - Link field or Prismic document to resolve to a URL - * @param linkFieldOrDocument - Any kind of Link field or a document to resolve + * @param linkFieldOrDocument - Any kind of link field or a document to resolve * @param config - Configuration that determines the output of `asLink()` * - * @returns Resolved URL or, if the provided Link field or document is empty, `null` + * @returns Resolved URL or, if the provided link field or document is empty, `null` * @see Prismic Link Resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver} * @see Prismic API `routes` options documentation: {@link https://prismic.io/docs/route-resolver} */ @@ -87,16 +87,16 @@ export const asLink: { ): AsLinkReturnType; /** - * Resolves any type of Link field or Prismic document to a URL. + * Resolves any type of link field or Prismic document to a URL. * * @typeParam LinkResolverFunctionReturnType - Link Resolver function return * type * @typeParam Field - Link field or Prismic document to resolve to a URL - * @param linkFieldOrDocument - Any kind of Link field or a document to resolve + * @param linkFieldOrDocument - Any kind of link field or a document to resolve * @param linkResolver - An optional Link Resolver function. Without it, you are * expected to use the `routes` options from the API * - * @returns Resolved URL or, if the provided Link field or document is empty, `null` + * @returns Resolved URL or, if the provided link field or document is empty, `null` * @see Prismic Link Resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver} * @see Prismic API `routes` options documentation: {@link https://prismic.io/docs/route-resolver} * diff --git a/src/helpers/asLinkAttrs.ts b/src/helpers/asLinkAttrs.ts index e2da911f..7512bbe1 100644 --- a/src/helpers/asLinkAttrs.ts +++ b/src/helpers/asLinkAttrs.ts @@ -66,17 +66,17 @@ type AsLinkAttrsReturnType< }; /** - * Resolves any type of Link field or Prismic document to a set of link attributes. The attributes are designed to be passed to link HTML elements, like ``. + * Resolves any type of link field or Prismic document to a set of link attributes. The attributes are designed to be passed to link HTML elements, like ``. * * If a resolved URL is external (i.e. starts with a protocol like `https://`), `rel` is returned as `"noreferrer"`. * * @typeParam LinkResolverFunctionReturnType - Link Resolver function return * type * @typeParam Field - Link field or Prismic document to resolve to link attributes - * @param linkFieldOrDocument - Any kind of Link field or a document to resolve + * @param linkFieldOrDocument - Any kind of link field or a document to resolve * @param config - Configuration that determines the output of `asLinkAttrs()` * - * @returns Resolved set of link attributes or, if the provided Link field or document is empty, and empty object + * @returns Resolved set of link attributes or, if the provided link field or document is empty, and empty object * @see Prismic Link Resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver} * @see Prismic API `routes` options documentation: {@link https://prismic.io/docs/route-resolver} */ diff --git a/src/helpers/asText.ts b/src/helpers/asText.ts index bb7a87af..803b40e1 100644 --- a/src/helpers/asText.ts +++ b/src/helpers/asText.ts @@ -28,13 +28,13 @@ type AsTextReturnType = export const asText: { /** - * Serializes a Rich Text or Title field to a plain text string. + * Serializes a rich text or title field to a plain text string. * - * @param richTextField - A Rich Text or Title field from Prismic + * @param richTextField - A rich text or title field from Prismic * @param config - Configuration that determines the output of `asText()` * - * @returns Plain text equivalent of the provided Rich Text or Title field - * @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title} + * @returns Plain text equivalent of the provided rich text or title field + * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title} */ ( richTextField: Field, @@ -42,13 +42,13 @@ export const asText: { ): AsTextReturnType; /** - * Serializes a Rich Text or Title field to a plain text string. + * Serializes a rich text or title field to a plain text string. * - * @param richTextField - A Rich Text or Title field from Prismic + * @param richTextField - A rich text or title field from Prismic * @param separator - Separator used to join each element, defaults to a space * - * @returns Plain text equivalent of the provided Rich Text or Title field - * @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title} + * @returns Plain text equivalent of the provided rich text or title field + * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title} * * @deprecated Use object-style configuration instead. * diff --git a/src/helpers/documentToLinkField.ts b/src/helpers/documentToLinkField.ts index 31a53f4d..a589576f 100644 --- a/src/helpers/documentToLinkField.ts +++ b/src/helpers/documentToLinkField.ts @@ -32,7 +32,7 @@ export const documentToLinkField = < tags: prismicDocument.tags, lang: prismicDocument.lang, url: prismicDocument.url == null ? undefined : prismicDocument.url, - slug: prismicDocument.slugs?.[0], // Slug field is not available with GraphQl + slug: prismicDocument.slugs?.[0], // Slug field is not available with GraphQL // The REST API does not include a `data` property if the data // object is empty. // diff --git a/src/helpers/isFilled.ts b/src/helpers/isFilled.ts index ca533f6c..4844ea14 100644 --- a/src/helpers/isFilled.ts +++ b/src/helpers/isFilled.ts @@ -5,7 +5,7 @@ import type { AnyOEmbed, EmbedField } from "../types/value/embed"; import type { GeoPointField } from "../types/value/geoPoint"; import type { GroupField } from "../types/value/group"; import type { ImageField, ImageFieldImage } from "../types/value/image"; -import type { IntegrationFields } from "../types/value/integrationFields"; +import type { IntegrationField } from "../types/value/integration"; import type { KeyTextField } from "../types/value/keyText"; import type { LinkField } from "../types/value/link"; import type { LinkToMediaField } from "../types/value/linkToMedia"; @@ -44,9 +44,9 @@ const isNonEmptyArray = (input: T[]): input is [T, ...T[]] => { }; /** - * Determines if a Rich Text field is filled. + * Determines if a rich text field is filled. * - * @param field - Rich Text field to check. + * @param field - rich text field to check. * * @returns `true` if `field` is filled, `false` otherwise. */ @@ -63,7 +63,7 @@ export const richText = ( }; /** - * Determines if a Title field is filled. + * Determines if a title field is filled. * * @param field - Title field to check. * @@ -87,7 +87,7 @@ export const imageThumbnail = ( }; /** - * Determines if an Image field is filled. + * Determines if an image field is filled. * * @param field - Image field to check. * @@ -100,7 +100,7 @@ export const image = imageThumbnail as < ) => field is ImageField; /** - * Determines if a Link field is filled. + * Determines if a link field is filled. * * @param field - Link field to check. * @@ -119,7 +119,7 @@ export const link = < }; /** - * Determines if a Link to Media field is filled. + * Determines if a link to media field is filled. * * @param field - Link to Media field to check. * @@ -130,7 +130,7 @@ export const linkToMedia = link as ( ) => field is LinkToMediaField<"filled">; /** - * Determines if a Content Relationship field is filled. + * Determines if a content relationship field is filled. * * @param field - Content Relationship field to check. * @@ -155,7 +155,7 @@ export const contentRelationship = link as < >; /** - * Determines if a Date field is filled. + * Determines if a date field is filled. * * @param field - Date field to check. * @@ -166,7 +166,7 @@ export const date = isNonNullish as ( ) => field is DateField<"filled">; /** - * Determines if a Timestamp field is filled. + * Determines if a timestamp field is filled. * * @param field - Timestamp field to check. * @@ -177,7 +177,7 @@ export const timestamp = isNonNullish as ( ) => field is TimestampField<"filled">; /** - * Determines if a Color field is filled. + * Determines if a color field is filled. * * @param field - Color field to check. * @@ -188,7 +188,7 @@ export const color = isNonNullish as ( ) => field is ColorField<"filled">; /** - * Determines if a Number field is filled. + * Determines if a number field is filled. * * @param field - Number field to check. * @@ -199,7 +199,7 @@ export const number = isNonNullish as ( ) => field is NumberField<"filled">; /** - * Determines if a Key Text field is filled. + * Determines if a key text field is filled. * * @param field - Key Text field to check. * @@ -212,7 +212,7 @@ export const keyText = ( }; /** - * Determines if a Select field is filled. + * Determines if a select field is filled. * * @param field - Select field to check. * @@ -223,7 +223,7 @@ export const select = isNonNullish as ( ) => field is SelectField; /** - * Determines if an Embed field is filled. + * Determines if an embed field is filled. * * @param field - Embed field to check. * @@ -236,7 +236,7 @@ export const embed = >( }; /** - * Determines if a GeoPoint field is filled. + * Determines if a geopoint field is filled. * * @param field - GeoPoint field to check. * @@ -249,17 +249,22 @@ export const geoPoint = ( }; /** - * Determines if an Integration Fields field is filled. + * Determines if an integration field is filled. * - * @param field - Integration Fields field to check. + * @param field - Integration field to check. * * @returns `true` if `field` is filled, `false` otherwise. */ -export const integrationFields = isNonNullish as < +export const integrationField = isNonNullish as < Data extends Record, >( - field: IntegrationFields | null | undefined, -) => field is IntegrationFields; + field: IntegrationField | null | undefined, +) => field is IntegrationField; +/** + * @deprecated Renamed to `integrationField`. + */ +// TODO: Remove when we remove support for deprecated `integrationFields` export. +export const integrationFields = integrationField; /** * Determines if a Group has at least one item. diff --git a/src/index.ts b/src/index.ts index 92d91a2a..098d195d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,7 @@ -// Use for deprecations. +// Imports are used for deprecations. +import type { CustomTypeModelIntegrationField } from "./types/model/integration"; +import type { IntegrationField } from "./types/value/integration"; + import type { HTMLRichTextFunctionSerializer, HTMLRichTextMapSerializer, @@ -196,7 +199,12 @@ export type { SelectField } from "./types/value/select"; export type { TimestampField } from "./types/value/timestamp"; export type { GeoPointField } from "./types/value/geoPoint"; -export type { IntegrationFields } from "./types/value/integrationFields"; +/** + * @deprecated Renamed to `IntegrationField` + */ +// TODO: Remove when we remove support for deprecated `IntegrationFields` export. +type IntegrationFields = IntegrationField; +export { IntegrationField, IntegrationFields }; export type { GroupField } from "./types/value/group"; @@ -247,7 +255,15 @@ export type { CustomTypeModelSelectField } from "./types/model/select"; export type { CustomTypeModelTimestampField } from "./types/model/timestamp"; export type { CustomTypeModelGeoPointField } from "./types/model/geoPoint"; -export type { CustomTypeModelIntegrationFieldsField } from "./types/model/integrationFields"; +/** + * @deprecated Renamed to `CustomTypeModelIntegrationField`. + */ +// TODO: Remove when we remove support for deprecated `CustomTypeModelIntegrationField` export. +type CustomTypeModelIntegrationFieldsField = CustomTypeModelIntegrationField; +export { + CustomTypeModelIntegrationField, + CustomTypeModelIntegrationFieldsField, +}; export type { CustomTypeModelGroupField } from "./types/model/group"; export type { CustomTypeModelSliceZoneField, diff --git a/src/types/api/repository.ts b/src/types/api/repository.ts index 4db93fac..b57fb63d 100644 --- a/src/types/api/repository.ts +++ b/src/types/api/repository.ts @@ -15,7 +15,7 @@ export interface Repository { refs: Ref[]; /** - * An identifier used to query content with the latest Integration Fields + * An identifier used to query content with the latest integration fields * data. */ integrationFieldsRef: string | null; diff --git a/src/types/model/integrationFields.ts b/src/types/model/integration.ts similarity index 69% rename from src/types/model/integrationFields.ts rename to src/types/model/integration.ts index b54543ca..c97a2b58 100644 --- a/src/types/model/integrationFields.ts +++ b/src/types/model/integration.ts @@ -5,8 +5,8 @@ import type { CustomTypeModelFieldType } from "./types"; * * More details: {@link https://prismic.io/docs/integration-fields} */ -export interface CustomTypeModelIntegrationFieldsField { - type: typeof CustomTypeModelFieldType.IntegrationFields; +export interface CustomTypeModelIntegrationField { + type: typeof CustomTypeModelFieldType.Integration; config?: { label?: string | null; placeholder?: string; diff --git a/src/types/model/types.ts b/src/types/model/types.ts index 4733fea9..0e13b66d 100644 --- a/src/types/model/types.ts +++ b/src/types/model/types.ts @@ -6,7 +6,7 @@ import type { CustomTypeModelEmbedField } from "./embed"; import type { CustomTypeModelGeoPointField } from "./geoPoint"; import type { CustomTypeModelGroupField } from "./group"; import type { CustomTypeModelImageField } from "./image"; -import type { CustomTypeModelIntegrationFieldsField } from "./integrationFields"; +import type { CustomTypeModelIntegrationField } from "./integrationFields"; import type { CustomTypeModelKeyTextField } from "./keyText"; import type { CustomTypeModelLinkField } from "./link"; import type { CustomTypeModelLinkToMediaField } from "./linkToMedia"; @@ -73,7 +73,7 @@ export type CustomTypeModelFieldForGroup = | CustomTypeModelEmbedField | CustomTypeModelGeoPointField | CustomTypeModelImageField - | CustomTypeModelIntegrationFieldsField + | CustomTypeModelIntegrationField | CustomTypeModelContentRelationshipField | CustomTypeModelLinkField | CustomTypeModelLinkToMediaField diff --git a/src/types/value/integrationFields.ts b/src/types/value/integration.ts similarity index 93% rename from src/types/value/integrationFields.ts rename to src/types/value/integration.ts index 058f4c5a..9d9dbeb7 100644 --- a/src/types/value/integrationFields.ts +++ b/src/types/value/integration.ts @@ -7,7 +7,7 @@ import type { FieldState } from "./types"; * @typeParam State - State of the field which determines its shape. * @see More details: {@link https://prismic.io/docs/integration-fields} */ -export type IntegrationFields< +export type IntegrationField< Data extends Record = Record, State extends FieldState = FieldState, > = State extends "empty" ? null : Data; diff --git a/src/types/value/richText.ts b/src/types/value/richText.ts index c87609b4..6693e13e 100644 --- a/src/types/value/richText.ts +++ b/src/types/value/richText.ts @@ -35,7 +35,7 @@ export const RichTextNodeType = { // Text nodes /** - * Base to be extended by other RT Nodes. + * Base to be extended by other rich text nodes. */ export interface RTTextNodeBase { text: string; @@ -269,7 +269,7 @@ export type RTBlockNode = | RTEmbedNode; /** - * Inline rich text Nodes + * Inline rich text nodes */ export type RTInlineNode = RTStrongNode | RTEmNode | RTLabelNode | RTLinkNode; @@ -281,7 +281,7 @@ export type RTAnyNode = RTBlockNode | RTInlineNode | RTSpanNode; /** * A rich text field. * - * @see Rich Text field documentation: {@link https://prismic.io/docs/rich-text-title} + * @see Rich text field documentation: {@link https://prismic.io/docs/rich-text-title} */ export type RichTextField = State extends "empty" ? [] : [RTNode, ...RTNode[]]; diff --git a/src/types/value/types.ts b/src/types/value/types.ts index 1c3a5aca..fad5dad4 100644 --- a/src/types/value/types.ts +++ b/src/types/value/types.ts @@ -5,7 +5,7 @@ import type { DateField } from "./date"; import type { EmbedField } from "./embed"; import type { GeoPointField } from "./geoPoint"; import type { ImageField } from "./image"; -import type { IntegrationFields } from "./integrationFields"; +import type { IntegrationField } from "./integration"; import type { KeyTextField } from "./keyText"; import type { LinkField } from "./link"; import type { LinkToMediaField } from "./linkToMedia"; @@ -44,7 +44,7 @@ export type AnyRegularField = | SelectField | BooleanField | GeoPointField - | IntegrationFields; + | IntegrationField; /** * Useful to flatten the type output to improve type hints shown in editors. And diff --git a/test/client-graphQLFetch.test.ts b/test/client-graphQLFetch.test.ts index 9e5385ed..f9e282f8 100644 --- a/test/client-graphQLFetch.test.ts +++ b/test/client-graphQLFetch.test.ts @@ -68,6 +68,7 @@ it("merges provided headers with defaults", async (ctx) => { expect(json).toStrictEqual(graphqlResponse); }); +// TODO: This test doesn't seem to test what the description claims. it("includes Authorization header if access token is provided", async (ctx) => { const repositoryResponse = ctx.mock.api.repository(); repositoryResponse.integrationFieldsRef = ctx.mock.api.ref().ref; @@ -98,7 +99,8 @@ it("includes Authorization header if access token is provided", async (ctx) => { expect(json).toStrictEqual(graphqlResponse); }); -it("includes Integration Fields header if ref is available", async (ctx) => { +// TODO: This test doesn't seem to test what the description claims. +it("includes integration fields header if ref is available", async (ctx) => { const repositoryResponse = ctx.mock.api.repository(); const accessToken = "accessToken"; diff --git a/test/helpers-isFilled.test.ts b/test/helpers-isFilled.test.ts index 5fc1bef0..ddfe7028 100644 --- a/test/helpers-isFilled.test.ts +++ b/test/helpers-isFilled.test.ts @@ -76,12 +76,15 @@ it("image thumbnail", () => { }); it("integration fields", (ctx) => { - expect(isFilled.integrationFields(null)).toBe(false); - expect(isFilled.integrationFields(undefined)).toBe(false); - expect(isFilled.integrationFields(ctx.mock.value.integrationFields())).toBe( + expect(isFilled.integrationField(null)).toBe(false); + expect(isFilled.integrationField(undefined)).toBe(false); + expect(isFilled.integrationField(ctx.mock.value.integrationFields())).toBe( true, ); }); +it("aliases integrationFields to integrationField", () => { + expect(isFilled.integrationFields).toBe(isFilled.integrationField); +}); it("key text", (ctx) => { expect(isFilled.keyText(null)).toBe(false); diff --git a/test/index.test.ts b/test/index.test.ts index 3df3ec10..9b726971 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -53,7 +53,7 @@ it("custom type field type mapping", () => { GeoPoint: "GeoPoint", Group: "Group", Image: "Image", - IntegrationFields: "IntegrationFields", + IntegrationField: "IntegrationField", Link: "Link", Number: "Number", Select: "Select", diff --git a/test/types/customType-integrationFields.types.ts b/test/types/customType-integration.types.ts similarity index 65% rename from test/types/customType-integrationFields.types.ts rename to test/types/customType-integration.types.ts index 95ae66a0..242e8e95 100644 --- a/test/types/customType-integrationFields.types.ts +++ b/test/types/customType-integration.types.ts @@ -3,7 +3,7 @@ import { expectNever, expectType } from "ts-expect"; import * as prismic from "../../src"; -(value: prismic.CustomTypeModelIntegrationFieldsField): true => { +(value: prismic.CustomTypeModelIntegrationField): true => { switch (typeof value) { case "object": { if (value === null) { @@ -19,8 +19,8 @@ import * as prismic from "../../src"; } }; -expectType({ - type: prismic.CustomTypeModelFieldType.IntegrationFields, +expectType({ + type: prismic.CustomTypeModelFieldType.Integration, config: { label: "string", catalog: "string", @@ -30,8 +30,8 @@ expectType({ /** * Supports optional placeholder. */ -expectType({ - type: prismic.CustomTypeModelFieldType.IntegrationFields, +expectType({ + type: prismic.CustomTypeModelFieldType.Integration, config: { label: "string", placeholder: "string", @@ -42,7 +42,7 @@ expectType({ /** * `@prismicio/types` extends `@prismicio/types-internal` */ -expectType( +expectType( {} as prismicTI.CustomTypes.Widgets.Nestable.IntegrationField, ); @@ -50,5 +50,5 @@ expectType( * `@prismicio/types-internal` extends `@prismicio/types` */ expectType( - {} as prismic.CustomTypeModelIntegrationFieldsField, + {} as prismic.CustomTypeModelIntegrationField, ); diff --git a/test/types/customType.types.ts b/test/types/customType.types.ts index b872394a..2a513c00 100644 --- a/test/types/customType.types.ts +++ b/test/types/customType.types.ts @@ -236,7 +236,7 @@ expectType< expectType< TypeOf< prismic.CustomTypeModelFieldForGroup, - prismic.CustomTypeModelIntegrationFieldsField + prismic.CustomTypeModelIntegrationField > >(true); expectType< diff --git a/test/types/fields-integrationFields.types.ts b/test/types/fields-integration.types.ts similarity index 54% rename from test/types/fields-integrationFields.types.ts rename to test/types/fields-integration.types.ts index 3cecfaee..1a236844 100644 --- a/test/types/fields-integrationFields.types.ts +++ b/test/types/fields-integration.types.ts @@ -2,7 +2,7 @@ import { expectNever, expectType } from "ts-expect"; import * as prismic from "../../src"; -(value: prismic.IntegrationFields): true => { +(value: prismic.IntegrationField): true => { switch (typeof value) { case "object": { if (value === null) { @@ -21,13 +21,13 @@ import * as prismic from "../../src"; /** * Filled state. */ -expectType({ +expectType({ foo: "bar", }); -expectType, "filled">>({ +expectType, "filled">>({ foo: "bar", }); -expectType, "empty">>( +expectType, "empty">>( // @ts-expect-error - Empty fields cannot contain a filled value. { foo: "bar", @@ -37,9 +37,9 @@ expectType, "empty">>( /** * Empty state. */ -expectType(null); -expectType, "empty">>(null); -expectType, "filled">>( +expectType(null); +expectType, "empty">>(null); +expectType, "filled">>( // @ts-expect-error - Filled fields cannot contain an empty value. null, ); @@ -47,10 +47,10 @@ expectType, "filled">>( /** * Supports custom blob type. */ -expectType>({ +expectType>({ foo: "bar", }); -expectType>({ +expectType>({ // @ts-expect-error - Blob should match the given type. baz: "qux", }); diff --git a/test/types/fields.types.ts b/test/types/fields.types.ts index 6ee18bc8..ae889ddb 100644 --- a/test/types/fields.types.ts +++ b/test/types/fields.types.ts @@ -27,7 +27,7 @@ expectType>(true); expectType>(true); expectType>(true); expectType>(true); -expectType>(true); +expectType>(true); expectType>(true); expectType>(true); expectType>(true); diff --git a/test/types/helpers-isFilled.types.ts b/test/types/helpers-isFilled.types.ts index e647226d..e6c8fa40 100644 --- a/test/types/helpers-isFilled.types.ts +++ b/test/types/helpers-isFilled.types.ts @@ -447,66 +447,66 @@ type EmbedData = prismic.VideoOEmbed & { foo: string }; * Integration fields */ -type IntegrationFieldsDefault = Record; +type IntegrationFieldDefault = Record; // Default -(value: prismic.IntegrationFields) => { - if (prismic.isFilled.integrationFields(value)) { +(value: prismic.IntegrationField) => { + if (prismic.isFilled.integrationField(value)) { expectType< TypeEqual< - prismic.IntegrationFields, + prismic.IntegrationField, typeof value > >(true); expectType< TypeEqual< - prismic.IntegrationFields, + prismic.IntegrationField, typeof value > >(false); } else { expectType< TypeEqual< - prismic.IntegrationFields, + prismic.IntegrationField, typeof value > >(false); expectType< TypeEqual< - prismic.IntegrationFields, + prismic.IntegrationField, typeof value > >(true); } }; -type IntegrationFieldsData = { foo: string }; +type IntegrationFieldData = { foo: string }; // With data -(value: prismic.IntegrationFields) => { - if (prismic.isFilled.integrationFields(value)) { +(value: prismic.IntegrationField) => { + if (prismic.isFilled.integrationField(value)) { expectType< TypeEqual< - prismic.IntegrationFields, + prismic.IntegrationField, typeof value > >(true); expectType< TypeEqual< - prismic.IntegrationFields, + prismic.IntegrationField, typeof value > >(false); } else { expectType< TypeEqual< - prismic.IntegrationFields, + prismic.IntegrationField, typeof value > >(false); expectType< TypeEqual< - prismic.IntegrationFields, + prismic.IntegrationField, typeof value > >(true); From a4af7886c3aa18c06c36912f9f00b1f558aa275c Mon Sep 17 00:00:00 2001 From: Angelo Ashmore Date: Fri, 12 May 2023 11:29:56 -1000 Subject: [PATCH 3/4] fix: restore `CustomTypeModelFieldType["IntegrationFields"]` (deprecated) --- src/types/model/types.ts | 6 +++++- test/index.test.ts | 9 +++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/types/model/types.ts b/src/types/model/types.ts index 0e13b66d..1ac2840c 100644 --- a/src/types/model/types.ts +++ b/src/types/model/types.ts @@ -6,7 +6,7 @@ import type { CustomTypeModelEmbedField } from "./embed"; import type { CustomTypeModelGeoPointField } from "./geoPoint"; import type { CustomTypeModelGroupField } from "./group"; import type { CustomTypeModelImageField } from "./image"; -import type { CustomTypeModelIntegrationField } from "./integrationFields"; +import type { CustomTypeModelIntegrationField } from "./integration"; import type { CustomTypeModelKeyTextField } from "./keyText"; import type { CustomTypeModelLinkField } from "./link"; import type { CustomTypeModelLinkToMediaField } from "./linkToMedia"; @@ -40,6 +40,10 @@ export const CustomTypeModelFieldType = { Text: "Text", Timestamp: "Timestamp", UID: "UID", + /** + * @deprecated - Renamed to `Integration`. + */ + IntegrationFields: "IntegrationFields", /** * @deprecated - Legacy field type. Use `Number` instead. */ diff --git a/test/index.test.ts b/test/index.test.ts index 9b726971..165b7494 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -45,7 +45,7 @@ it("embed type mapping", () => { }); it("custom type field type mapping", () => { - expect(prismic.CustomTypeModelFieldType).toMatchObject({ + expect(prismic.CustomTypeModelFieldType).toStrictEqual({ Boolean: "Boolean", Color: "Color", Date: "Date", @@ -53,7 +53,7 @@ it("custom type field type mapping", () => { GeoPoint: "GeoPoint", Group: "Group", Image: "Image", - IntegrationField: "IntegrationField", + Integration: "IntegrationFields", Link: "Link", Number: "Number", Select: "Select", @@ -62,6 +62,11 @@ it("custom type field type mapping", () => { Text: "Text", Timestamp: "Timestamp", UID: "UID", + // Deprecated fields + IntegrationFields: "IntegrationFields", + Range: "Range", + Separator: "Separator", + LegacySlices: "Choice", }); }); From 85987350c0a7079091f9102d8ed7f978ab38242d Mon Sep 17 00:00:00 2001 From: Angelo Ashmore Date: Mon, 15 May 2023 08:47:15 -1000 Subject: [PATCH 4/4] docs: fix remaining renames --- src/buildQueryURL.ts | 4 ++-- src/helpers/asLink.ts | 10 +++++----- src/helpers/isFilled.ts | 2 +- src/types/model/customType.ts | 2 +- src/types/model/link.ts | 2 +- src/types/model/sharedSlice.ts | 4 ++-- src/types/model/sharedSliceVariation.ts | 2 +- src/types/model/sliceZone.ts | 2 +- src/types/value/sharedSlice.ts | 2 +- src/types/value/sharedSliceVariation.ts | 2 +- src/types/value/slice.ts | 2 +- test/types/customType-linkToMedia.types.ts | 4 ++-- test/types/fields-sharedSlice.types.ts | 2 +- test/types/fields-sliceZone.types.ts | 2 +- 14 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/buildQueryURL.ts b/src/buildQueryURL.ts index 0b0abb8d..1e43807e 100644 --- a/src/buildQueryURL.ts +++ b/src/buildQueryURL.ts @@ -184,8 +184,8 @@ export interface QueryParams { /** * The `brokenRoute` option allows you to define the route populated in the - * `url` property for broken Link or Content Relationship fields. A broken - * link is a Link or Content Relationship field whose linked document has been + * `url` property for broken link or content relationship fields. A broken + * link is a link or content relationship field whose linked document has been * unpublished or deleted. * * {@link https://prismic.io/docs/route-resolver} diff --git a/src/helpers/asLink.ts b/src/helpers/asLink.ts index 6bdc902c..6d93f20d 100644 --- a/src/helpers/asLink.ts +++ b/src/helpers/asLink.ts @@ -6,14 +6,14 @@ import type { FilledLinkToMediaField } from "../types/value/linkToMedia"; import { documentToLinkField } from "./documentToLinkField"; /** - * Resolves a Link to a Prismic document to a URL + * Resolves a link to a Prismic document to a URL * - * @typeParam ReturnType - Return type of your link resolver function, useful if + * @typeParam ReturnType - Return type of your Link Resolver function, useful if * you prefer to return a complex object - * @param linkToDocumentField - A document Link Field to resolve + * @param linkToDocumentField - A document link field to resolve * * @returns Resolved URL - * @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver} + * @see Prismic Link Resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver} */ export type LinkResolverFunction = ( linkToDocumentField: FilledContentRelationshipField, @@ -136,7 +136,7 @@ export const asLink: { return null as AsLinkReturnType; } - // Converts document to Link Field if needed + // Converts document to link field if needed const linkField = // prettier-ignore ( diff --git a/src/helpers/isFilled.ts b/src/helpers/isFilled.ts index 4844ea14..4327c217 100644 --- a/src/helpers/isFilled.ts +++ b/src/helpers/isFilled.ts @@ -121,7 +121,7 @@ export const link = < /** * Determines if a link to media field is filled. * - * @param field - Link to Media field to check. + * @param field - Link to media field to check. * * @returns `true` if `field` is filled, `false` otherwise. */ diff --git a/src/types/model/customType.ts b/src/types/model/customType.ts index 9e18074d..b3fc3a36 100644 --- a/src/types/model/customType.ts +++ b/src/types/model/customType.ts @@ -16,7 +16,7 @@ export interface CustomTypeModel< id: ID; /** - * The human readable name of the custom type Model. + * The human readable name of the custom type model. */ // TODO: Revert to `label?: string | null` if `label` can be partial in: https://github.com/prismicio/prismic-types-internal/blob/HEAD/src/customtypes/CustomType.ts#L39 label: string | null | undefined; diff --git a/src/types/model/link.ts b/src/types/model/link.ts index c1491fec..e5ac4715 100644 --- a/src/types/model/link.ts +++ b/src/types/model/link.ts @@ -19,7 +19,7 @@ export interface CustomTypeModelLinkField { } /** - * Type of a Link custom type field. + * Type of a link custom type field. * * More details: * {@link https://prismic.io/docs/link} diff --git a/src/types/model/sharedSlice.ts b/src/types/model/sharedSlice.ts index 354cae47..ef664b65 100644 --- a/src/types/model/sharedSlice.ts +++ b/src/types/model/sharedSlice.ts @@ -2,11 +2,11 @@ import type { SharedSliceModelVariation } from "./sharedSliceVariation"; import type { CustomTypeModelSliceType } from "./sliceZone"; /** - * A Prismic Shared Slice model. + * A Prismic shared Slice model. * * More details: {@link https://prismic.io/docs/slice} * - * @typeParam Variation - A variation for the Shared Slice. + * @typeParam Variation - A variation for the shared Slice. */ export interface SharedSliceModel< ID extends string = string, diff --git a/src/types/model/sharedSliceVariation.ts b/src/types/model/sharedSliceVariation.ts index 3e73d5e4..ef856a12 100644 --- a/src/types/model/sharedSliceVariation.ts +++ b/src/types/model/sharedSliceVariation.ts @@ -1,7 +1,7 @@ import type { CustomTypeModelFieldForGroup } from "./types"; /** - * A Shared Slice variation. + * A shared Slice variation. * * More details: {@link https://prismic.io/docs/slice} * diff --git a/src/types/model/sliceZone.ts b/src/types/model/sliceZone.ts index dd3826c1..ef1db3c8 100644 --- a/src/types/model/sliceZone.ts +++ b/src/types/model/sliceZone.ts @@ -51,7 +51,7 @@ export const CustomTypeModelSliceType = { } as const; /** - * A Shared Slice for a custom type. + * A shared Slice for a custom type. * * More details: {@link https://prismic.io/docs/slice} */ diff --git a/src/types/value/sharedSlice.ts b/src/types/value/sharedSlice.ts index 68f431c4..a62cd0a0 100644 --- a/src/types/value/sharedSlice.ts +++ b/src/types/value/sharedSlice.ts @@ -1,7 +1,7 @@ import type { SharedSliceVariation } from "./sharedSliceVariation"; /** - * A Shared Slice. + * A shared Slice. * * @see More details: {@link https://prismic.io/docs/slice} */ diff --git a/src/types/value/sharedSliceVariation.ts b/src/types/value/sharedSliceVariation.ts index 5fe997eb..8910897f 100644 --- a/src/types/value/sharedSliceVariation.ts +++ b/src/types/value/sharedSliceVariation.ts @@ -1,7 +1,7 @@ import type { AnyRegularField } from "./types"; /** - * A Shared Slice variation. + * A shared Slice variation. */ export interface SharedSliceVariation< Variation = string, diff --git a/src/types/value/slice.ts b/src/types/value/slice.ts index 8d569a70..1f110bcf 100644 --- a/src/types/value/slice.ts +++ b/src/types/value/slice.ts @@ -1,7 +1,7 @@ import type { AnyRegularField } from "./types"; /** - * A Slice - sections of your website. + * A Slice - sections of your webpages. * * @see More details: {@link https://prismic.io/docs/slice} */ diff --git a/test/types/customType-linkToMedia.types.ts b/test/types/customType-linkToMedia.types.ts index 2616b323..2710b363 100644 --- a/test/types/customType-linkToMedia.types.ts +++ b/test/types/customType-linkToMedia.types.ts @@ -45,8 +45,8 @@ expectType({ expectType( {} as prismicTI.CustomTypes.Widgets.Nestable.Link & { // We must manually narrow `@prismicio/types-internal`'s type - // to match a Link to Media field; `@prismicio/types-internal` - // does not contain a Link to Media-specific type. + // to match a link to media field; `@prismicio/types-internal` + // does not contain a link to media-specific type. config?: { select: "media" }; }, ); diff --git a/test/types/fields-sharedSlice.types.ts b/test/types/fields-sharedSlice.types.ts index b22b5466..5aaa5a71 100644 --- a/test/types/fields-sharedSlice.types.ts +++ b/test/types/fields-sharedSlice.types.ts @@ -28,7 +28,7 @@ expectType({ }); /** - * Supports custom Shared Slice type API ID. + * Supports custom shared Slice type API ID. */ expectType>({ slice_type: "foo", diff --git a/test/types/fields-sliceZone.types.ts b/test/types/fields-sliceZone.types.ts index 0f9cdda8..8e495541 100644 --- a/test/types/fields-sliceZone.types.ts +++ b/test/types/fields-sliceZone.types.ts @@ -78,7 +78,7 @@ expectType>>([ ]); /** - * Supports custom Shared Slice definitions. + * Supports custom shared Slice definitions. */ expectType>>([ {