@prismicio/client 7.17.0-alpha.0 → 7.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BaseClient.cjs.map +1 -1
- package/dist/BaseClient.js.map +1 -1
- package/dist/Client.cjs.map +1 -1
- package/dist/Client.js.map +1 -1
- package/dist/Migration.cjs.map +1 -1
- package/dist/Migration.js.map +1 -1
- package/dist/WriteClient.cjs.map +1 -1
- package/dist/WriteClient.js.map +1 -1
- package/dist/buildQueryURL.cjs.map +1 -1
- package/dist/buildQueryURL.js.map +1 -1
- package/dist/errors/PrismicError.cjs.map +1 -1
- package/dist/errors/PrismicError.js.map +1 -1
- package/dist/filter.cjs.map +1 -1
- package/dist/filter.js.map +1 -1
- package/dist/getGraphQLEndpoint.cjs.map +1 -1
- package/dist/getGraphQLEndpoint.js.map +1 -1
- package/dist/getRepositoryEndpoint.cjs.map +1 -1
- package/dist/getRepositoryEndpoint.js.map +1 -1
- package/dist/getRepositoryName.cjs.map +1 -1
- package/dist/getRepositoryName.js.map +1 -1
- package/dist/getToolbarSrc.cjs.map +1 -1
- package/dist/getToolbarSrc.js.map +1 -1
- package/dist/helpers/asDate.cjs.map +1 -1
- package/dist/helpers/asDate.js.map +1 -1
- package/dist/helpers/asHTML.cjs.map +1 -1
- package/dist/helpers/asHTML.js +1 -1
- package/dist/helpers/asHTML.js.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.js +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -1
- package/dist/helpers/asImageSrc.cjs.map +1 -1
- package/dist/helpers/asImageSrc.js.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.cjs.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.js +1 -1
- package/dist/helpers/asImageWidthSrcSet.js.map +1 -1
- package/dist/helpers/asLink.cjs.map +1 -1
- package/dist/helpers/asLink.js.map +1 -1
- package/dist/helpers/asLinkAttrs.cjs.map +1 -1
- package/dist/helpers/asLinkAttrs.d.ts +1 -1
- package/dist/helpers/asLinkAttrs.js.map +1 -1
- package/dist/helpers/asText.cjs.map +1 -1
- package/dist/helpers/asText.js.map +1 -1
- package/dist/helpers/documentToLinkField.cjs.map +1 -1
- package/dist/helpers/documentToLinkField.js.map +1 -1
- package/dist/helpers/isFilled.cjs.map +1 -1
- package/dist/helpers/isFilled.js.map +1 -1
- package/dist/helpers/mapSliceZone.cjs.map +1 -1
- package/dist/helpers/mapSliceZone.js.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/isRepositoryEndpoint.cjs.map +1 -1
- package/dist/isRepositoryEndpoint.js.map +1 -1
- package/dist/lib/appendFilters.cjs.map +1 -1
- package/dist/lib/appendFilters.js.map +1 -1
- package/dist/lib/escapeHTML.cjs.map +1 -1
- package/dist/lib/escapeHTML.js.map +1 -1
- package/dist/lib/everyTagFilter.cjs.map +1 -1
- package/dist/lib/findMasterRef.cjs.map +1 -1
- package/dist/lib/findRef.cjs.map +1 -1
- package/dist/lib/findRef.js.map +1 -1
- package/dist/lib/getOptionalLinkProperties.cjs.map +1 -1
- package/dist/lib/getOptionalLinkProperties.js.map +1 -1
- package/dist/lib/getPreviewCookie.cjs.map +1 -1
- package/dist/lib/getPreviewCookie.js.map +1 -1
- package/dist/lib/isMigrationValue.cjs.map +1 -1
- package/dist/lib/isValue.cjs.map +1 -1
- package/dist/lib/isValue.js.map +1 -1
- package/dist/lib/pLimit.cjs.map +1 -1
- package/dist/lib/pLimit.js.map +1 -1
- package/dist/lib/resolveMigrationDocumentData.cjs.map +1 -1
- package/dist/lib/resolveMigrationDocumentData.js.map +1 -1
- package/dist/lib/serializerHelpers.cjs.map +1 -1
- package/dist/lib/serializerHelpers.js.map +1 -1
- package/dist/lib/someTagsFilter.cjs.map +1 -1
- package/dist/lib/validateAssetMetadata.cjs.map +1 -1
- package/dist/lib/validateAssetMetadata.js.map +1 -1
- package/dist/package.json.cjs +1 -1
- package/dist/package.json.js +1 -1
- package/dist/richtext/asText.cjs.map +1 -1
- package/dist/richtext/asText.js.map +1 -1
- package/dist/richtext/asTree.cjs.map +1 -1
- package/dist/richtext/asTree.js.map +1 -1
- package/dist/richtext/composeSerializers.cjs.map +1 -1
- package/dist/richtext/composeSerializers.js.map +1 -1
- package/dist/richtext/serialize.cjs.map +1 -1
- package/dist/richtext/serialize.js.map +1 -1
- package/dist/richtext/wrapMapSerializer.cjs.map +1 -1
- package/dist/richtext/wrapMapSerializer.js.map +1 -1
- package/dist/types/migration/Asset.cjs.map +1 -1
- package/dist/types/migration/Asset.js.map +1 -1
- package/dist/types/migration/Document.cjs.map +1 -1
- package/dist/types/migration/Document.js.map +1 -1
- package/dist/types/value/table.d.ts +4 -4
- package/package.json +13 -13
- package/src/types/value/table.ts +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asLink.cjs","sources":["../../../src/helpers/asLink.ts"],"sourcesContent":["import type { FilledContentRelationshipField } from \"../types/value/contentRelationship\"\nimport type { PrismicDocument } from \"../types/value/document\"\nimport type { FilledLinkToWebField, LinkField } from \"../types/value/link\"\nimport { LinkType } from \"../types/value/link\"\nimport type { FilledLinkToMediaField } from \"../types/value/linkToMedia\"\n\nimport { documentToLinkField } from \"./documentToLinkField\"\n\n/**\n * Resolves a link to a Prismic document to a URL\n *\n * @typeParam ReturnType - Return type of your link resolver function, useful if\n * you prefer to return a complex object\n *\n * @param linkToDocumentField - A document link field to resolve\n *\n * @returns Resolved URL\n *\n * @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}\n */\nexport type LinkResolverFunction<ReturnType = string | null | undefined> = (\n\tlinkToDocumentField: FilledContentRelationshipField,\n) => ReturnType\n\n/**\n * Configuration that determines the output of `asLink()`.\n */\ntype AsLinkConfig<LinkResolverFunctionReturnType = string | null | undefined> =\n\t{\n\t\t/**\n\t\t * An optional link resolver function. Without it, you are expected to use\n\t\t * the `routes` options from the API.\n\t\t */\n\t\tlinkResolver?: LinkResolverFunction<LinkResolverFunctionReturnType> | null\n\t}\n\n// TODO: Remove when we remove support for deprecated tuple-style configuration.\n/**\n * @deprecated Use object-style configuration instead.\n */\ntype AsLinkDeprecatedTupleConfig<\n\tLinkResolverFunctionReturnType = string | null | undefined,\n> = [linkResolver?: LinkResolverFunction<LinkResolverFunctionReturnType> | null]\n\n/**\n * The return type of `asLink()`.\n */\nexport type AsLinkReturnType<\n\tLinkResolverFunctionReturnType = string | null | undefined,\n\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t| LinkField\n\t\t| PrismicDocument\n\t\t| null\n\t\t| undefined,\n> = Field extends\n\t| FilledLinkToWebField\n\t| FilledLinkToMediaField\n\t| FilledContentRelationshipField\n\t| PrismicDocument\n\t? LinkResolverFunctionReturnType | string | null\n\t: null\n\n// TODO: Remove overload when we remove support for deprecated tuple-style configuration.\nexport const asLink: {\n\t/**\n\t * Resolves any type of link field or Prismic document to a URL.\n\t *\n\t * @typeParam LinkResolverFunctionReturnType - link resolver function return\n\t * type\n\t * @typeParam Field - Link field or Prismic document to resolve to a URL\n\t *\n\t * @param linkFieldOrDocument - Any kind of link field or a document to\n\t * resolve\n\t * @param config - Configuration that determines the output of `asLink()`\n\t *\n\t * @returns Resolved URL or, if the provided link field or document is empty,\n\t * `null`\n\t *\n\t * @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}\n\t * @see Prismic API `routes` options documentation: {@link https://prismic.io/docs/route-resolver}\n\t */\n\t<\n\t\tLinkResolverFunctionReturnType = string | null | undefined,\n\t\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t\t| LinkField\n\t\t\t| PrismicDocument\n\t\t\t| null\n\t\t\t| undefined,\n\t>(\n\t\tlinkFieldOrDocument: Field,\n\t\tconfig?: AsLinkConfig<LinkResolverFunctionReturnType>,\n\t): AsLinkReturnType<LinkResolverFunctionReturnType, Field>\n\n\t/**\n\t * Resolves any type of link field or Prismic document to a URL.\n\t *\n\t * @deprecated Use object-style configuration instead.\n\t *\n\t * @typeParam LinkResolverFunctionReturnType - link resolver function return\n\t * type\n\t * @typeParam Field - Link field or Prismic document to resolve to a URL\n\t *\n\t * @param linkFieldOrDocument - Any kind of link field or a document to\n\t * resolve\n\t * @param linkResolver - An optional link resolver function. Without it, you\n\t * are expected to use the `routes` options from the API\n\t *\n\t * @returns Resolved URL or, if the provided link field or document is empty,\n\t * `null`\n\t *\n\t * @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}\n\t * @see Prismic API `routes` options documentation: {@link https://prismic.io/docs/route-resolver}\n\t */\n\t<\n\t\tLinkResolverFunctionReturnType = string | null | undefined,\n\t\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t\t| LinkField\n\t\t\t| PrismicDocument\n\t\t\t| null\n\t\t\t| undefined,\n\t>(\n\t\tlinkFieldOrDocument: Field,\n\t\t...config: AsLinkDeprecatedTupleConfig<LinkResolverFunctionReturnType>\n\t): AsLinkReturnType<LinkResolverFunctionReturnType, Field>\n} = <\n\tLinkResolverFunctionReturnType = string | null | undefined,\n\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t| LinkField\n\t\t| PrismicDocument\n\t\t| null\n\t\t| undefined,\n>(\n\tlinkFieldOrDocument: Field,\n\t// TODO: Rename to `config` when we remove support for deprecated tuple-style configuration.\n\t...configObjectOrTuple:\n\t\t| [config?: AsLinkConfig<LinkResolverFunctionReturnType>]\n\t\t| AsLinkDeprecatedTupleConfig<LinkResolverFunctionReturnType>\n): AsLinkReturnType<LinkResolverFunctionReturnType, Field> => {\n\tif (!linkFieldOrDocument) {\n\t\treturn null as AsLinkReturnType<LinkResolverFunctionReturnType, Field>\n\t}\n\n\t// Converts document to link field if needed\n\tconst linkField =\n\t\t// prettier-ignore\n\t\t(\n\t\t\t// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n\t\t\t// @ts-ignore - Bug in TypeScript 4.9: https://github.com/microsoft/TypeScript/issues/51501\n\t\t\t// TODO: Remove the `prettier-ignore` comment when this bug is fixed.\n\t\t\t\"link_type\" in linkFieldOrDocument\n\t\t\t\t? linkFieldOrDocument\n\t\t\t\t: documentToLinkField(linkFieldOrDocument)\n\t\t) as LinkField\n\n\t// TODO: Remove when we remove support for deprecated tuple-style configuration.\n\tconst [configObjectOrLinkResolver] = configObjectOrTuple\n\tlet config: AsLinkConfig<LinkResolverFunctionReturnType>\n\tif (\n\t\ttypeof configObjectOrLinkResolver === \"function\" ||\n\t\tconfigObjectOrLinkResolver == null\n\t) {\n\t\tconfig = {\n\t\t\tlinkResolver: configObjectOrLinkResolver,\n\t\t}\n\t} else {\n\t\tconfig = { ...configObjectOrLinkResolver }\n\t}\n\n\tswitch (linkField.link_type) {\n\t\tcase LinkType.Media:\n\t\tcase LinkType.Web:\n\t\t\treturn (\"url\" in linkField ? linkField.url : null) as AsLinkReturnType<\n\t\t\t\tLinkResolverFunctionReturnType,\n\t\t\t\tField\n\t\t\t>\n\n\t\tcase LinkType.Document: {\n\t\t\tif (\"id\" in linkField && config.linkResolver) {\n\t\t\t\t// When using link resolver...\n\t\t\t\tconst resolvedURL = config.linkResolver(linkField)\n\n\t\t\t\tif (resolvedURL != null) {\n\t\t\t\t\treturn resolvedURL as AsLinkReturnType<\n\t\t\t\t\t\tLinkResolverFunctionReturnType,\n\t\t\t\t\t\tField\n\t\t\t\t\t>\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (\"url\" in linkField && linkField.url) {\n\t\t\t\t// When using route resolver...\n\t\t\t\treturn linkField.url as AsLinkReturnType<\n\t\t\t\t\tLinkResolverFunctionReturnType,\n\t\t\t\t\tField\n\t\t\t\t>\n\t\t\t}\n\n\t\t\t// When empty or link resolver and route resolver are not used...\n\t\t\treturn null as AsLinkReturnType<LinkResolverFunctionReturnType, Field>\n\t\t}\n\n\t\tcase LinkType.Any:\n\t\tdefault:\n\t\t\treturn null as AsLinkReturnType<LinkResolverFunctionReturnType, Field>\n\t}\n}\n"],"names":["documentToLinkField","LinkType"],"mappings":";;;;AA+Da,MAAA,SA6DT,CAQH,wBAEG,wBAGyD;AAC5D,MAAI,CAAC,qBAAqB;AAClB,WAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"asLink.cjs","sources":["../../../src/helpers/asLink.ts"],"sourcesContent":["import type { FilledContentRelationshipField } from \"../types/value/contentRelationship\"\nimport type { PrismicDocument } from \"../types/value/document\"\nimport type { FilledLinkToWebField, LinkField } from \"../types/value/link\"\nimport { LinkType } from \"../types/value/link\"\nimport type { FilledLinkToMediaField } from \"../types/value/linkToMedia\"\n\nimport { documentToLinkField } from \"./documentToLinkField\"\n\n/**\n * Resolves a link to a Prismic document to a URL\n *\n * @typeParam ReturnType - Return type of your link resolver function, useful if\n * you prefer to return a complex object\n *\n * @param linkToDocumentField - A document link field to resolve\n *\n * @returns Resolved URL\n *\n * @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}\n */\nexport type LinkResolverFunction<ReturnType = string | null | undefined> = (\n\tlinkToDocumentField: FilledContentRelationshipField,\n) => ReturnType\n\n/**\n * Configuration that determines the output of `asLink()`.\n */\ntype AsLinkConfig<LinkResolverFunctionReturnType = string | null | undefined> =\n\t{\n\t\t/**\n\t\t * An optional link resolver function. Without it, you are expected to use\n\t\t * the `routes` options from the API.\n\t\t */\n\t\tlinkResolver?: LinkResolverFunction<LinkResolverFunctionReturnType> | null\n\t}\n\n// TODO: Remove when we remove support for deprecated tuple-style configuration.\n/**\n * @deprecated Use object-style configuration instead.\n */\ntype AsLinkDeprecatedTupleConfig<\n\tLinkResolverFunctionReturnType = string | null | undefined,\n> = [linkResolver?: LinkResolverFunction<LinkResolverFunctionReturnType> | null]\n\n/**\n * The return type of `asLink()`.\n */\nexport type AsLinkReturnType<\n\tLinkResolverFunctionReturnType = string | null | undefined,\n\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t| LinkField\n\t\t| PrismicDocument\n\t\t| null\n\t\t| undefined,\n> = Field extends\n\t| FilledLinkToWebField\n\t| FilledLinkToMediaField\n\t| FilledContentRelationshipField\n\t| PrismicDocument\n\t? LinkResolverFunctionReturnType | string | null\n\t: null\n\n// TODO: Remove overload when we remove support for deprecated tuple-style configuration.\nexport const asLink: {\n\t/**\n\t * Resolves any type of link field or Prismic document to a URL.\n\t *\n\t * @typeParam LinkResolverFunctionReturnType - link resolver function return\n\t * type\n\t * @typeParam Field - Link field or Prismic document to resolve to a URL\n\t *\n\t * @param linkFieldOrDocument - Any kind of link field or a document to\n\t * resolve\n\t * @param config - Configuration that determines the output of `asLink()`\n\t *\n\t * @returns Resolved URL or, if the provided link field or document is empty,\n\t * `null`\n\t *\n\t * @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}\n\t * @see Prismic API `routes` options documentation: {@link https://prismic.io/docs/route-resolver}\n\t */\n\t<\n\t\tLinkResolverFunctionReturnType = string | null | undefined,\n\t\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t\t| LinkField\n\t\t\t| PrismicDocument\n\t\t\t| null\n\t\t\t| undefined,\n\t>(\n\t\tlinkFieldOrDocument: Field,\n\t\tconfig?: AsLinkConfig<LinkResolverFunctionReturnType>,\n\t): AsLinkReturnType<LinkResolverFunctionReturnType, Field>\n\n\t/**\n\t * Resolves any type of link field or Prismic document to a URL.\n\t *\n\t * @deprecated Use object-style configuration instead.\n\t *\n\t * @typeParam LinkResolverFunctionReturnType - link resolver function return\n\t * type\n\t * @typeParam Field - Link field or Prismic document to resolve to a URL\n\t *\n\t * @param linkFieldOrDocument - Any kind of link field or a document to\n\t * resolve\n\t * @param linkResolver - An optional link resolver function. Without it, you\n\t * are expected to use the `routes` options from the API\n\t *\n\t * @returns Resolved URL or, if the provided link field or document is empty,\n\t * `null`\n\t *\n\t * @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}\n\t * @see Prismic API `routes` options documentation: {@link https://prismic.io/docs/route-resolver}\n\t */\n\t<\n\t\tLinkResolverFunctionReturnType = string | null | undefined,\n\t\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t\t| LinkField\n\t\t\t| PrismicDocument\n\t\t\t| null\n\t\t\t| undefined,\n\t>(\n\t\tlinkFieldOrDocument: Field,\n\t\t...config: AsLinkDeprecatedTupleConfig<LinkResolverFunctionReturnType>\n\t): AsLinkReturnType<LinkResolverFunctionReturnType, Field>\n} = <\n\tLinkResolverFunctionReturnType = string | null | undefined,\n\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t| LinkField\n\t\t| PrismicDocument\n\t\t| null\n\t\t| undefined,\n>(\n\tlinkFieldOrDocument: Field,\n\t// TODO: Rename to `config` when we remove support for deprecated tuple-style configuration.\n\t...configObjectOrTuple:\n\t\t| [config?: AsLinkConfig<LinkResolverFunctionReturnType>]\n\t\t| AsLinkDeprecatedTupleConfig<LinkResolverFunctionReturnType>\n): AsLinkReturnType<LinkResolverFunctionReturnType, Field> => {\n\tif (!linkFieldOrDocument) {\n\t\treturn null as AsLinkReturnType<LinkResolverFunctionReturnType, Field>\n\t}\n\n\t// Converts document to link field if needed\n\tconst linkField =\n\t\t// prettier-ignore\n\t\t(\n\t\t\t// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n\t\t\t// @ts-ignore - Bug in TypeScript 4.9: https://github.com/microsoft/TypeScript/issues/51501\n\t\t\t// TODO: Remove the `prettier-ignore` comment when this bug is fixed.\n\t\t\t\"link_type\" in linkFieldOrDocument\n\t\t\t\t? linkFieldOrDocument\n\t\t\t\t: documentToLinkField(linkFieldOrDocument)\n\t\t) as LinkField\n\n\t// TODO: Remove when we remove support for deprecated tuple-style configuration.\n\tconst [configObjectOrLinkResolver] = configObjectOrTuple\n\tlet config: AsLinkConfig<LinkResolverFunctionReturnType>\n\tif (\n\t\ttypeof configObjectOrLinkResolver === \"function\" ||\n\t\tconfigObjectOrLinkResolver == null\n\t) {\n\t\tconfig = {\n\t\t\tlinkResolver: configObjectOrLinkResolver,\n\t\t}\n\t} else {\n\t\tconfig = { ...configObjectOrLinkResolver }\n\t}\n\n\tswitch (linkField.link_type) {\n\t\tcase LinkType.Media:\n\t\tcase LinkType.Web:\n\t\t\treturn (\"url\" in linkField ? linkField.url : null) as AsLinkReturnType<\n\t\t\t\tLinkResolverFunctionReturnType,\n\t\t\t\tField\n\t\t\t>\n\n\t\tcase LinkType.Document: {\n\t\t\tif (\"id\" in linkField && config.linkResolver) {\n\t\t\t\t// When using link resolver...\n\t\t\t\tconst resolvedURL = config.linkResolver(linkField)\n\n\t\t\t\tif (resolvedURL != null) {\n\t\t\t\t\treturn resolvedURL as AsLinkReturnType<\n\t\t\t\t\t\tLinkResolverFunctionReturnType,\n\t\t\t\t\t\tField\n\t\t\t\t\t>\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (\"url\" in linkField && linkField.url) {\n\t\t\t\t// When using route resolver...\n\t\t\t\treturn linkField.url as AsLinkReturnType<\n\t\t\t\t\tLinkResolverFunctionReturnType,\n\t\t\t\t\tField\n\t\t\t\t>\n\t\t\t}\n\n\t\t\t// When empty or link resolver and route resolver are not used...\n\t\t\treturn null as AsLinkReturnType<LinkResolverFunctionReturnType, Field>\n\t\t}\n\n\t\tcase LinkType.Any:\n\t\tdefault:\n\t\t\treturn null as AsLinkReturnType<LinkResolverFunctionReturnType, Field>\n\t}\n}\n"],"names":["documentToLinkField","LinkType"],"mappings":";;;;AA+Da,MAAA,SA6DT,CAQH,wBAEG,wBAGyD;AAC5D,MAAI,CAAC,qBAAqB;AAClB,WAAA;AAAA,EAAA;AAIF,QAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMJ,eAAe,sBACZ,sBACAA,oBAAAA,oBAAoB,mBAAmB;AAAA;AAItC,QAAA,CAAC,0BAA0B,IAAI;AACjC,MAAA;AACJ,MACC,OAAO,+BAA+B,cACtC,8BAA8B,MAC7B;AACQ,aAAA;AAAA,MACR,cAAc;AAAA;SAET;AACG,aAAA,EAAE,GAAG;;AAGf,UAAQ,UAAU,WAAW;AAAA,IAC5B,KAAKC,KAAS,SAAA;AAAA,IACd,KAAKA,KAAS,SAAA;AACL,aAAA,SAAS,YAAY,UAAU,MAAM;AAAA,IAK9C,KAAKA,KAAAA,SAAS,UAAU;AACnB,UAAA,QAAQ,aAAa,OAAO,cAAc;AAEvC,cAAA,cAAc,OAAO,aAAa,SAAS;AAEjD,YAAI,eAAe,MAAM;AACjB,iBAAA;AAAA,QAAA;AAAA,MAIR;AAGG,UAAA,SAAS,aAAa,UAAU,KAAK;AAExC,eAAO,UAAU;AAAA,MAAA;AAOX,aAAA;AAAA,IAAA;AAAA,IAGR,KAAKA,KAAS,SAAA;AAAA,IACd;AACQ,aAAA;AAAA,EAAA;AAEV;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asLink.js","sources":["../../../src/helpers/asLink.ts"],"sourcesContent":["import type { FilledContentRelationshipField } from \"../types/value/contentRelationship\"\nimport type { PrismicDocument } from \"../types/value/document\"\nimport type { FilledLinkToWebField, LinkField } from \"../types/value/link\"\nimport { LinkType } from \"../types/value/link\"\nimport type { FilledLinkToMediaField } from \"../types/value/linkToMedia\"\n\nimport { documentToLinkField } from \"./documentToLinkField\"\n\n/**\n * Resolves a link to a Prismic document to a URL\n *\n * @typeParam ReturnType - Return type of your link resolver function, useful if\n * you prefer to return a complex object\n *\n * @param linkToDocumentField - A document link field to resolve\n *\n * @returns Resolved URL\n *\n * @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}\n */\nexport type LinkResolverFunction<ReturnType = string | null | undefined> = (\n\tlinkToDocumentField: FilledContentRelationshipField,\n) => ReturnType\n\n/**\n * Configuration that determines the output of `asLink()`.\n */\ntype AsLinkConfig<LinkResolverFunctionReturnType = string | null | undefined> =\n\t{\n\t\t/**\n\t\t * An optional link resolver function. Without it, you are expected to use\n\t\t * the `routes` options from the API.\n\t\t */\n\t\tlinkResolver?: LinkResolverFunction<LinkResolverFunctionReturnType> | null\n\t}\n\n// TODO: Remove when we remove support for deprecated tuple-style configuration.\n/**\n * @deprecated Use object-style configuration instead.\n */\ntype AsLinkDeprecatedTupleConfig<\n\tLinkResolverFunctionReturnType = string | null | undefined,\n> = [linkResolver?: LinkResolverFunction<LinkResolverFunctionReturnType> | null]\n\n/**\n * The return type of `asLink()`.\n */\nexport type AsLinkReturnType<\n\tLinkResolverFunctionReturnType = string | null | undefined,\n\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t| LinkField\n\t\t| PrismicDocument\n\t\t| null\n\t\t| undefined,\n> = Field extends\n\t| FilledLinkToWebField\n\t| FilledLinkToMediaField\n\t| FilledContentRelationshipField\n\t| PrismicDocument\n\t? LinkResolverFunctionReturnType | string | null\n\t: null\n\n// TODO: Remove overload when we remove support for deprecated tuple-style configuration.\nexport const asLink: {\n\t/**\n\t * Resolves any type of link field or Prismic document to a URL.\n\t *\n\t * @typeParam LinkResolverFunctionReturnType - link resolver function return\n\t * type\n\t * @typeParam Field - Link field or Prismic document to resolve to a URL\n\t *\n\t * @param linkFieldOrDocument - Any kind of link field or a document to\n\t * resolve\n\t * @param config - Configuration that determines the output of `asLink()`\n\t *\n\t * @returns Resolved URL or, if the provided link field or document is empty,\n\t * `null`\n\t *\n\t * @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}\n\t * @see Prismic API `routes` options documentation: {@link https://prismic.io/docs/route-resolver}\n\t */\n\t<\n\t\tLinkResolverFunctionReturnType = string | null | undefined,\n\t\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t\t| LinkField\n\t\t\t| PrismicDocument\n\t\t\t| null\n\t\t\t| undefined,\n\t>(\n\t\tlinkFieldOrDocument: Field,\n\t\tconfig?: AsLinkConfig<LinkResolverFunctionReturnType>,\n\t): AsLinkReturnType<LinkResolverFunctionReturnType, Field>\n\n\t/**\n\t * Resolves any type of link field or Prismic document to a URL.\n\t *\n\t * @deprecated Use object-style configuration instead.\n\t *\n\t * @typeParam LinkResolverFunctionReturnType - link resolver function return\n\t * type\n\t * @typeParam Field - Link field or Prismic document to resolve to a URL\n\t *\n\t * @param linkFieldOrDocument - Any kind of link field or a document to\n\t * resolve\n\t * @param linkResolver - An optional link resolver function. Without it, you\n\t * are expected to use the `routes` options from the API\n\t *\n\t * @returns Resolved URL or, if the provided link field or document is empty,\n\t * `null`\n\t *\n\t * @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}\n\t * @see Prismic API `routes` options documentation: {@link https://prismic.io/docs/route-resolver}\n\t */\n\t<\n\t\tLinkResolverFunctionReturnType = string | null | undefined,\n\t\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t\t| LinkField\n\t\t\t| PrismicDocument\n\t\t\t| null\n\t\t\t| undefined,\n\t>(\n\t\tlinkFieldOrDocument: Field,\n\t\t...config: AsLinkDeprecatedTupleConfig<LinkResolverFunctionReturnType>\n\t): AsLinkReturnType<LinkResolverFunctionReturnType, Field>\n} = <\n\tLinkResolverFunctionReturnType = string | null | undefined,\n\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t| LinkField\n\t\t| PrismicDocument\n\t\t| null\n\t\t| undefined,\n>(\n\tlinkFieldOrDocument: Field,\n\t// TODO: Rename to `config` when we remove support for deprecated tuple-style configuration.\n\t...configObjectOrTuple:\n\t\t| [config?: AsLinkConfig<LinkResolverFunctionReturnType>]\n\t\t| AsLinkDeprecatedTupleConfig<LinkResolverFunctionReturnType>\n): AsLinkReturnType<LinkResolverFunctionReturnType, Field> => {\n\tif (!linkFieldOrDocument) {\n\t\treturn null as AsLinkReturnType<LinkResolverFunctionReturnType, Field>\n\t}\n\n\t// Converts document to link field if needed\n\tconst linkField =\n\t\t// prettier-ignore\n\t\t(\n\t\t\t// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n\t\t\t// @ts-ignore - Bug in TypeScript 4.9: https://github.com/microsoft/TypeScript/issues/51501\n\t\t\t// TODO: Remove the `prettier-ignore` comment when this bug is fixed.\n\t\t\t\"link_type\" in linkFieldOrDocument\n\t\t\t\t? linkFieldOrDocument\n\t\t\t\t: documentToLinkField(linkFieldOrDocument)\n\t\t) as LinkField\n\n\t// TODO: Remove when we remove support for deprecated tuple-style configuration.\n\tconst [configObjectOrLinkResolver] = configObjectOrTuple\n\tlet config: AsLinkConfig<LinkResolverFunctionReturnType>\n\tif (\n\t\ttypeof configObjectOrLinkResolver === \"function\" ||\n\t\tconfigObjectOrLinkResolver == null\n\t) {\n\t\tconfig = {\n\t\t\tlinkResolver: configObjectOrLinkResolver,\n\t\t}\n\t} else {\n\t\tconfig = { ...configObjectOrLinkResolver }\n\t}\n\n\tswitch (linkField.link_type) {\n\t\tcase LinkType.Media:\n\t\tcase LinkType.Web:\n\t\t\treturn (\"url\" in linkField ? linkField.url : null) as AsLinkReturnType<\n\t\t\t\tLinkResolverFunctionReturnType,\n\t\t\t\tField\n\t\t\t>\n\n\t\tcase LinkType.Document: {\n\t\t\tif (\"id\" in linkField && config.linkResolver) {\n\t\t\t\t// When using link resolver...\n\t\t\t\tconst resolvedURL = config.linkResolver(linkField)\n\n\t\t\t\tif (resolvedURL != null) {\n\t\t\t\t\treturn resolvedURL as AsLinkReturnType<\n\t\t\t\t\t\tLinkResolverFunctionReturnType,\n\t\t\t\t\t\tField\n\t\t\t\t\t>\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (\"url\" in linkField && linkField.url) {\n\t\t\t\t// When using route resolver...\n\t\t\t\treturn linkField.url as AsLinkReturnType<\n\t\t\t\t\tLinkResolverFunctionReturnType,\n\t\t\t\t\tField\n\t\t\t\t>\n\t\t\t}\n\n\t\t\t// When empty or link resolver and route resolver are not used...\n\t\t\treturn null as AsLinkReturnType<LinkResolverFunctionReturnType, Field>\n\t\t}\n\n\t\tcase LinkType.Any:\n\t\tdefault:\n\t\t\treturn null as AsLinkReturnType<LinkResolverFunctionReturnType, Field>\n\t}\n}\n"],"names":[],"mappings":";;AA+Da,MAAA,SA6DT,CAQH,wBAEG,wBAGyD;AAC5D,MAAI,CAAC,qBAAqB;AAClB,WAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"asLink.js","sources":["../../../src/helpers/asLink.ts"],"sourcesContent":["import type { FilledContentRelationshipField } from \"../types/value/contentRelationship\"\nimport type { PrismicDocument } from \"../types/value/document\"\nimport type { FilledLinkToWebField, LinkField } from \"../types/value/link\"\nimport { LinkType } from \"../types/value/link\"\nimport type { FilledLinkToMediaField } from \"../types/value/linkToMedia\"\n\nimport { documentToLinkField } from \"./documentToLinkField\"\n\n/**\n * Resolves a link to a Prismic document to a URL\n *\n * @typeParam ReturnType - Return type of your link resolver function, useful if\n * you prefer to return a complex object\n *\n * @param linkToDocumentField - A document link field to resolve\n *\n * @returns Resolved URL\n *\n * @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}\n */\nexport type LinkResolverFunction<ReturnType = string | null | undefined> = (\n\tlinkToDocumentField: FilledContentRelationshipField,\n) => ReturnType\n\n/**\n * Configuration that determines the output of `asLink()`.\n */\ntype AsLinkConfig<LinkResolverFunctionReturnType = string | null | undefined> =\n\t{\n\t\t/**\n\t\t * An optional link resolver function. Without it, you are expected to use\n\t\t * the `routes` options from the API.\n\t\t */\n\t\tlinkResolver?: LinkResolverFunction<LinkResolverFunctionReturnType> | null\n\t}\n\n// TODO: Remove when we remove support for deprecated tuple-style configuration.\n/**\n * @deprecated Use object-style configuration instead.\n */\ntype AsLinkDeprecatedTupleConfig<\n\tLinkResolverFunctionReturnType = string | null | undefined,\n> = [linkResolver?: LinkResolverFunction<LinkResolverFunctionReturnType> | null]\n\n/**\n * The return type of `asLink()`.\n */\nexport type AsLinkReturnType<\n\tLinkResolverFunctionReturnType = string | null | undefined,\n\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t| LinkField\n\t\t| PrismicDocument\n\t\t| null\n\t\t| undefined,\n> = Field extends\n\t| FilledLinkToWebField\n\t| FilledLinkToMediaField\n\t| FilledContentRelationshipField\n\t| PrismicDocument\n\t? LinkResolverFunctionReturnType | string | null\n\t: null\n\n// TODO: Remove overload when we remove support for deprecated tuple-style configuration.\nexport const asLink: {\n\t/**\n\t * Resolves any type of link field or Prismic document to a URL.\n\t *\n\t * @typeParam LinkResolverFunctionReturnType - link resolver function return\n\t * type\n\t * @typeParam Field - Link field or Prismic document to resolve to a URL\n\t *\n\t * @param linkFieldOrDocument - Any kind of link field or a document to\n\t * resolve\n\t * @param config - Configuration that determines the output of `asLink()`\n\t *\n\t * @returns Resolved URL or, if the provided link field or document is empty,\n\t * `null`\n\t *\n\t * @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}\n\t * @see Prismic API `routes` options documentation: {@link https://prismic.io/docs/route-resolver}\n\t */\n\t<\n\t\tLinkResolverFunctionReturnType = string | null | undefined,\n\t\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t\t| LinkField\n\t\t\t| PrismicDocument\n\t\t\t| null\n\t\t\t| undefined,\n\t>(\n\t\tlinkFieldOrDocument: Field,\n\t\tconfig?: AsLinkConfig<LinkResolverFunctionReturnType>,\n\t): AsLinkReturnType<LinkResolverFunctionReturnType, Field>\n\n\t/**\n\t * Resolves any type of link field or Prismic document to a URL.\n\t *\n\t * @deprecated Use object-style configuration instead.\n\t *\n\t * @typeParam LinkResolverFunctionReturnType - link resolver function return\n\t * type\n\t * @typeParam Field - Link field or Prismic document to resolve to a URL\n\t *\n\t * @param linkFieldOrDocument - Any kind of link field or a document to\n\t * resolve\n\t * @param linkResolver - An optional link resolver function. Without it, you\n\t * are expected to use the `routes` options from the API\n\t *\n\t * @returns Resolved URL or, if the provided link field or document is empty,\n\t * `null`\n\t *\n\t * @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}\n\t * @see Prismic API `routes` options documentation: {@link https://prismic.io/docs/route-resolver}\n\t */\n\t<\n\t\tLinkResolverFunctionReturnType = string | null | undefined,\n\t\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t\t| LinkField\n\t\t\t| PrismicDocument\n\t\t\t| null\n\t\t\t| undefined,\n\t>(\n\t\tlinkFieldOrDocument: Field,\n\t\t...config: AsLinkDeprecatedTupleConfig<LinkResolverFunctionReturnType>\n\t): AsLinkReturnType<LinkResolverFunctionReturnType, Field>\n} = <\n\tLinkResolverFunctionReturnType = string | null | undefined,\n\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t| LinkField\n\t\t| PrismicDocument\n\t\t| null\n\t\t| undefined,\n>(\n\tlinkFieldOrDocument: Field,\n\t// TODO: Rename to `config` when we remove support for deprecated tuple-style configuration.\n\t...configObjectOrTuple:\n\t\t| [config?: AsLinkConfig<LinkResolverFunctionReturnType>]\n\t\t| AsLinkDeprecatedTupleConfig<LinkResolverFunctionReturnType>\n): AsLinkReturnType<LinkResolverFunctionReturnType, Field> => {\n\tif (!linkFieldOrDocument) {\n\t\treturn null as AsLinkReturnType<LinkResolverFunctionReturnType, Field>\n\t}\n\n\t// Converts document to link field if needed\n\tconst linkField =\n\t\t// prettier-ignore\n\t\t(\n\t\t\t// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n\t\t\t// @ts-ignore - Bug in TypeScript 4.9: https://github.com/microsoft/TypeScript/issues/51501\n\t\t\t// TODO: Remove the `prettier-ignore` comment when this bug is fixed.\n\t\t\t\"link_type\" in linkFieldOrDocument\n\t\t\t\t? linkFieldOrDocument\n\t\t\t\t: documentToLinkField(linkFieldOrDocument)\n\t\t) as LinkField\n\n\t// TODO: Remove when we remove support for deprecated tuple-style configuration.\n\tconst [configObjectOrLinkResolver] = configObjectOrTuple\n\tlet config: AsLinkConfig<LinkResolverFunctionReturnType>\n\tif (\n\t\ttypeof configObjectOrLinkResolver === \"function\" ||\n\t\tconfigObjectOrLinkResolver == null\n\t) {\n\t\tconfig = {\n\t\t\tlinkResolver: configObjectOrLinkResolver,\n\t\t}\n\t} else {\n\t\tconfig = { ...configObjectOrLinkResolver }\n\t}\n\n\tswitch (linkField.link_type) {\n\t\tcase LinkType.Media:\n\t\tcase LinkType.Web:\n\t\t\treturn (\"url\" in linkField ? linkField.url : null) as AsLinkReturnType<\n\t\t\t\tLinkResolverFunctionReturnType,\n\t\t\t\tField\n\t\t\t>\n\n\t\tcase LinkType.Document: {\n\t\t\tif (\"id\" in linkField && config.linkResolver) {\n\t\t\t\t// When using link resolver...\n\t\t\t\tconst resolvedURL = config.linkResolver(linkField)\n\n\t\t\t\tif (resolvedURL != null) {\n\t\t\t\t\treturn resolvedURL as AsLinkReturnType<\n\t\t\t\t\t\tLinkResolverFunctionReturnType,\n\t\t\t\t\t\tField\n\t\t\t\t\t>\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (\"url\" in linkField && linkField.url) {\n\t\t\t\t// When using route resolver...\n\t\t\t\treturn linkField.url as AsLinkReturnType<\n\t\t\t\t\tLinkResolverFunctionReturnType,\n\t\t\t\t\tField\n\t\t\t\t>\n\t\t\t}\n\n\t\t\t// When empty or link resolver and route resolver are not used...\n\t\t\treturn null as AsLinkReturnType<LinkResolverFunctionReturnType, Field>\n\t\t}\n\n\t\tcase LinkType.Any:\n\t\tdefault:\n\t\t\treturn null as AsLinkReturnType<LinkResolverFunctionReturnType, Field>\n\t}\n}\n"],"names":[],"mappings":";;AA+Da,MAAA,SA6DT,CAQH,wBAEG,wBAGyD;AAC5D,MAAI,CAAC,qBAAqB;AAClB,WAAA;AAAA,EAAA;AAIF,QAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMJ,eAAe,sBACZ,sBACA,oBAAoB,mBAAmB;AAAA;AAItC,QAAA,CAAC,0BAA0B,IAAI;AACjC,MAAA;AACJ,MACC,OAAO,+BAA+B,cACtC,8BAA8B,MAC7B;AACQ,aAAA;AAAA,MACR,cAAc;AAAA;SAET;AACG,aAAA,EAAE,GAAG;;AAGf,UAAQ,UAAU,WAAW;AAAA,IAC5B,KAAK,SAAS;AAAA,IACd,KAAK,SAAS;AACL,aAAA,SAAS,YAAY,UAAU,MAAM;AAAA,IAK9C,KAAK,SAAS,UAAU;AACnB,UAAA,QAAQ,aAAa,OAAO,cAAc;AAEvC,cAAA,cAAc,OAAO,aAAa,SAAS;AAEjD,YAAI,eAAe,MAAM;AACjB,iBAAA;AAAA,QAAA;AAAA,MAIR;AAGG,UAAA,SAAS,aAAa,UAAU,KAAK;AAExC,eAAO,UAAU;AAAA,MAAA;AAOX,aAAA;AAAA,IAAA;AAAA,IAGR,KAAK,SAAS;AAAA,IACd;AACQ,aAAA;AAAA,EAAA;AAEV;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asLinkAttrs.cjs","sources":["../../../src/helpers/asLinkAttrs.ts"],"sourcesContent":["import { isInternalURL } from \"../lib/isInternalURL\"\n\nimport type { FilledContentRelationshipField } from \"../types/value/contentRelationship\"\nimport type { PrismicDocument } from \"../types/value/document\"\nimport type { FilledLinkToWebField, LinkField } from \"../types/value/link\"\nimport type { FilledLinkToMediaField } from \"../types/value/linkToMedia\"\n\nimport type { AsLinkReturnType, LinkResolverFunction } from \"./asLink\"\nimport { asLink } from \"./asLink\"\nimport { link as isFilledLink } from \"./isFilled\"\n\ntype AsLinkAttrsConfigRelArgs<\n\tLinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>,\n\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t| LinkField\n\t\t| PrismicDocument\n\t\t| null\n\t\t| undefined,\n> = {\n\thref:\n\t\t| NonNullable<AsLinkReturnType<LinkResolverFunctionReturnType, Field>>\n\t\t| undefined\n\tisExternal: boolean\n\ttarget?: string\n}\n\nexport type AsLinkAttrsConfig<\n\tLinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>,\n\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t| LinkField\n\t\t| PrismicDocument\n\t\t| null\n\t\t| undefined,\n> = {\n\tlinkResolver?: LinkResolverFunction<LinkResolverFunctionReturnType>\n\trel?: (\n\t\targs: AsLinkAttrsConfigRelArgs<LinkResolverFunctionReturnType, Field>,\n\t) => string | undefined | void\n}\n\n/**\n * The return type of `asLinkAttrs()`.\n */\ntype AsLinkAttrsReturnType<\n\tLinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>,\n\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t| LinkField\n\t\t| PrismicDocument\n\t\t| null\n\t\t| undefined,\n> = Field extends\n\t| FilledLinkToWebField\n\t| FilledLinkToMediaField\n\t| FilledContentRelationshipField\n\t| PrismicDocument\n\t? {\n\t\t\thref:\n\t\t\t\t| NonNullable<AsLinkReturnType<LinkResolverFunctionReturnType, Field>>\n\t\t\t\t| undefined\n\t\t\ttarget?: string\n\t\t\trel?: string\n\t\t}\n\t: {\n\t\t\thref?: undefined\n\t\t\ttarget?: undefined\n\t\t\trel?: undefined\n\t\t}\n\n/**\n * Resolves any type of link field or Prismic document to a set of link\n * attributes. The attributes are designed to be passed to link HTML elements,\n * like `<a>`.\n *\n * If a resolved URL is external (i.e. starts with a protocol like `https://`),\n * `rel` is returned as `\"noreferrer\"`.\n *\n * @typeParam LinkResolverFunctionReturnType - link resolver function return\n * type\n * @typeParam Field - Link field or Prismic document to resolve to link\n * attributes\n *\n * @param linkFieldOrDocument - Any kind of link field or a document to resolve\n * @param config - Configuration that determines the output of `asLinkAttrs()`\n *\n * @returns Resolved set of link attributes or, if the provided link field or\n * document is empty, and empty object\n *\n * @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}\n * @see Prismic API `routes` options documentation: {@link https://prismic.io/docs/route-resolver}\n */\nexport const asLinkAttrs = <\n\tLinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>,\n\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t| LinkField\n\t\t| PrismicDocument\n\t\t| null\n\t\t| undefined,\n>(\n\tlinkFieldOrDocument: Field,\n\tconfig: AsLinkAttrsConfig<LinkResolverFunctionReturnType> = {},\n): AsLinkAttrsReturnType<LinkResolverFunctionReturnType> => {\n\tif (\n\t\tlinkFieldOrDocument &&\n\t\t// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n\t\t// @ts-ignore - Bug in TypeScript 4.9: https://github.com/microsoft/TypeScript/issues/51501\n\t\t(\"link_type\" in linkFieldOrDocument\n\t\t\t? isFilledLink(linkFieldOrDocument)\n\t\t\t: linkFieldOrDocument)\n\t) {\n\t\tconst target =\n\t\t\t// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n\t\t\t// @ts-ignore - Bug in TypeScript 4.9: https://github.com/microsoft/TypeScript/issues/51501\n\t\t\t\"target\" in linkFieldOrDocument ? linkFieldOrDocument.target : undefined\n\n\t\tconst rawHref = asLink(linkFieldOrDocument, config.linkResolver)\n\t\tconst href =\n\t\t\trawHref == null ? undefined : (rawHref as NonNullable<typeof rawHref>)\n\n\t\tconst isExternal = typeof href === \"string\" ? !isInternalURL(href) : false\n\n\t\tconst rel = config.rel\n\t\t\t? config.rel({ href, isExternal, target })\n\t\t\t: isExternal\n\t\t\t\t? \"noreferrer\"\n\t\t\t\t: undefined\n\n\t\treturn {\n\t\t\thref,\n\t\t\ttarget,\n\t\t\trel: rel == null ? undefined : rel,\n\t\t}\n\t}\n\n\treturn {}\n}\n"],"names":["isFilledLink","asLink","isInternalURL"],"mappings":";;;;;AA0FO,MAAM,cAAc,CAQ1B,qBACA,SAA4D,OACF;AAEzD,MAAA;AAAA;AAAA,GAGC,eAAe,sBACbA,SAAAA,KAAa,mBAAmB,IAChC,sBACF;AACK,UAAA;AAAA;AAAA;AAAA,MAGL,YAAY,sBAAsB,oBAAoB,SAAS;AAAA;AAEhE,UAAM,UAAUC,OAAA,OAAO,qBAAqB,OAAO,YAAY;AACzD,UAAA,OACL,WAAW,OAAO,SAAa;AAEhC,UAAM,aAAa,OAAO,SAAS,WAAW,CAACC,
|
|
1
|
+
{"version":3,"file":"asLinkAttrs.cjs","sources":["../../../src/helpers/asLinkAttrs.ts"],"sourcesContent":["import { isInternalURL } from \"../lib/isInternalURL\"\n\nimport type { FilledContentRelationshipField } from \"../types/value/contentRelationship\"\nimport type { PrismicDocument } from \"../types/value/document\"\nimport type { FilledLinkToWebField, LinkField } from \"../types/value/link\"\nimport type { FilledLinkToMediaField } from \"../types/value/linkToMedia\"\n\nimport type { AsLinkReturnType, LinkResolverFunction } from \"./asLink\"\nimport { asLink } from \"./asLink\"\nimport { link as isFilledLink } from \"./isFilled\"\n\ntype AsLinkAttrsConfigRelArgs<\n\tLinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>,\n\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t| LinkField\n\t\t| PrismicDocument\n\t\t| null\n\t\t| undefined,\n> = {\n\thref:\n\t\t| NonNullable<AsLinkReturnType<LinkResolverFunctionReturnType, Field>>\n\t\t| undefined\n\tisExternal: boolean\n\ttarget?: string\n}\n\nexport type AsLinkAttrsConfig<\n\tLinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>,\n\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t| LinkField\n\t\t| PrismicDocument\n\t\t| null\n\t\t| undefined,\n> = {\n\tlinkResolver?: LinkResolverFunction<LinkResolverFunctionReturnType>\n\trel?: (\n\t\targs: AsLinkAttrsConfigRelArgs<LinkResolverFunctionReturnType, Field>,\n\t) => string | undefined | void\n}\n\n/**\n * The return type of `asLinkAttrs()`.\n */\ntype AsLinkAttrsReturnType<\n\tLinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>,\n\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t| LinkField\n\t\t| PrismicDocument\n\t\t| null\n\t\t| undefined,\n> = Field extends\n\t| FilledLinkToWebField\n\t| FilledLinkToMediaField\n\t| FilledContentRelationshipField\n\t| PrismicDocument\n\t? {\n\t\t\thref:\n\t\t\t\t| NonNullable<AsLinkReturnType<LinkResolverFunctionReturnType, Field>>\n\t\t\t\t| undefined\n\t\t\ttarget?: string\n\t\t\trel?: string\n\t\t}\n\t: {\n\t\t\thref?: undefined\n\t\t\ttarget?: undefined\n\t\t\trel?: undefined\n\t\t}\n\n/**\n * Resolves any type of link field or Prismic document to a set of link\n * attributes. The attributes are designed to be passed to link HTML elements,\n * like `<a>`.\n *\n * If a resolved URL is external (i.e. starts with a protocol like `https://`),\n * `rel` is returned as `\"noreferrer\"`.\n *\n * @typeParam LinkResolverFunctionReturnType - link resolver function return\n * type\n * @typeParam Field - Link field or Prismic document to resolve to link\n * attributes\n *\n * @param linkFieldOrDocument - Any kind of link field or a document to resolve\n * @param config - Configuration that determines the output of `asLinkAttrs()`\n *\n * @returns Resolved set of link attributes or, if the provided link field or\n * document is empty, and empty object\n *\n * @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}\n * @see Prismic API `routes` options documentation: {@link https://prismic.io/docs/route-resolver}\n */\nexport const asLinkAttrs = <\n\tLinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>,\n\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t| LinkField\n\t\t| PrismicDocument\n\t\t| null\n\t\t| undefined,\n>(\n\tlinkFieldOrDocument: Field,\n\tconfig: AsLinkAttrsConfig<LinkResolverFunctionReturnType> = {},\n): AsLinkAttrsReturnType<LinkResolverFunctionReturnType> => {\n\tif (\n\t\tlinkFieldOrDocument &&\n\t\t// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n\t\t// @ts-ignore - Bug in TypeScript 4.9: https://github.com/microsoft/TypeScript/issues/51501\n\t\t(\"link_type\" in linkFieldOrDocument\n\t\t\t? isFilledLink(linkFieldOrDocument)\n\t\t\t: linkFieldOrDocument)\n\t) {\n\t\tconst target =\n\t\t\t// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n\t\t\t// @ts-ignore - Bug in TypeScript 4.9: https://github.com/microsoft/TypeScript/issues/51501\n\t\t\t\"target\" in linkFieldOrDocument ? linkFieldOrDocument.target : undefined\n\n\t\tconst rawHref = asLink(linkFieldOrDocument, config.linkResolver)\n\t\tconst href =\n\t\t\trawHref == null ? undefined : (rawHref as NonNullable<typeof rawHref>)\n\n\t\tconst isExternal = typeof href === \"string\" ? !isInternalURL(href) : false\n\n\t\tconst rel = config.rel\n\t\t\t? config.rel({ href, isExternal, target })\n\t\t\t: isExternal\n\t\t\t\t? \"noreferrer\"\n\t\t\t\t: undefined\n\n\t\treturn {\n\t\t\thref,\n\t\t\ttarget,\n\t\t\trel: rel == null ? undefined : rel,\n\t\t}\n\t}\n\n\treturn {}\n}\n"],"names":["isFilledLink","asLink","isInternalURL"],"mappings":";;;;;AA0FO,MAAM,cAAc,CAQ1B,qBACA,SAA4D,OACF;AAEzD,MAAA;AAAA;AAAA,GAGC,eAAe,sBACbA,SAAAA,KAAa,mBAAmB,IAChC,sBACF;AACK,UAAA;AAAA;AAAA;AAAA,MAGL,YAAY,sBAAsB,oBAAoB,SAAS;AAAA;AAEhE,UAAM,UAAUC,OAAA,OAAO,qBAAqB,OAAO,YAAY;AACzD,UAAA,OACL,WAAW,OAAO,SAAa;AAEhC,UAAM,aAAa,OAAO,SAAS,WAAW,CAACC,cAAA,cAAc,IAAI,IAAI;AAErE,UAAM,MAAM,OAAO,MAChB,OAAO,IAAI,EAAE,MAAM,YAAY,OAAQ,CAAA,IACvC,aACC,eACA;AAEG,WAAA;AAAA,MACN;AAAA,MACA;AAAA,MACA,KAAK,OAAO,OAAO,SAAY;AAAA;;AAIjC,SAAO;AACR;;"}
|
|
@@ -46,5 +46,5 @@ type AsLinkAttrsReturnType<LinkResolverFunctionReturnType = ReturnType<LinkResol
|
|
|
46
46
|
* @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}
|
|
47
47
|
* @see Prismic API `routes` options documentation: {@link https://prismic.io/docs/route-resolver}
|
|
48
48
|
*/
|
|
49
|
-
export declare const asLinkAttrs: <LinkResolverFunctionReturnType =
|
|
49
|
+
export declare const asLinkAttrs: <LinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>, Field extends LinkField | PrismicDocument | null | undefined = LinkField | PrismicDocument | null | undefined>(linkFieldOrDocument: Field, config?: AsLinkAttrsConfig<LinkResolverFunctionReturnType>) => AsLinkAttrsReturnType<LinkResolverFunctionReturnType>;
|
|
50
50
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asLinkAttrs.js","sources":["../../../src/helpers/asLinkAttrs.ts"],"sourcesContent":["import { isInternalURL } from \"../lib/isInternalURL\"\n\nimport type { FilledContentRelationshipField } from \"../types/value/contentRelationship\"\nimport type { PrismicDocument } from \"../types/value/document\"\nimport type { FilledLinkToWebField, LinkField } from \"../types/value/link\"\nimport type { FilledLinkToMediaField } from \"../types/value/linkToMedia\"\n\nimport type { AsLinkReturnType, LinkResolverFunction } from \"./asLink\"\nimport { asLink } from \"./asLink\"\nimport { link as isFilledLink } from \"./isFilled\"\n\ntype AsLinkAttrsConfigRelArgs<\n\tLinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>,\n\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t| LinkField\n\t\t| PrismicDocument\n\t\t| null\n\t\t| undefined,\n> = {\n\thref:\n\t\t| NonNullable<AsLinkReturnType<LinkResolverFunctionReturnType, Field>>\n\t\t| undefined\n\tisExternal: boolean\n\ttarget?: string\n}\n\nexport type AsLinkAttrsConfig<\n\tLinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>,\n\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t| LinkField\n\t\t| PrismicDocument\n\t\t| null\n\t\t| undefined,\n> = {\n\tlinkResolver?: LinkResolverFunction<LinkResolverFunctionReturnType>\n\trel?: (\n\t\targs: AsLinkAttrsConfigRelArgs<LinkResolverFunctionReturnType, Field>,\n\t) => string | undefined | void\n}\n\n/**\n * The return type of `asLinkAttrs()`.\n */\ntype AsLinkAttrsReturnType<\n\tLinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>,\n\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t| LinkField\n\t\t| PrismicDocument\n\t\t| null\n\t\t| undefined,\n> = Field extends\n\t| FilledLinkToWebField\n\t| FilledLinkToMediaField\n\t| FilledContentRelationshipField\n\t| PrismicDocument\n\t? {\n\t\t\thref:\n\t\t\t\t| NonNullable<AsLinkReturnType<LinkResolverFunctionReturnType, Field>>\n\t\t\t\t| undefined\n\t\t\ttarget?: string\n\t\t\trel?: string\n\t\t}\n\t: {\n\t\t\thref?: undefined\n\t\t\ttarget?: undefined\n\t\t\trel?: undefined\n\t\t}\n\n/**\n * Resolves any type of link field or Prismic document to a set of link\n * attributes. The attributes are designed to be passed to link HTML elements,\n * like `<a>`.\n *\n * If a resolved URL is external (i.e. starts with a protocol like `https://`),\n * `rel` is returned as `\"noreferrer\"`.\n *\n * @typeParam LinkResolverFunctionReturnType - link resolver function return\n * type\n * @typeParam Field - Link field or Prismic document to resolve to link\n * attributes\n *\n * @param linkFieldOrDocument - Any kind of link field or a document to resolve\n * @param config - Configuration that determines the output of `asLinkAttrs()`\n *\n * @returns Resolved set of link attributes or, if the provided link field or\n * document is empty, and empty object\n *\n * @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}\n * @see Prismic API `routes` options documentation: {@link https://prismic.io/docs/route-resolver}\n */\nexport const asLinkAttrs = <\n\tLinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>,\n\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t| LinkField\n\t\t| PrismicDocument\n\t\t| null\n\t\t| undefined,\n>(\n\tlinkFieldOrDocument: Field,\n\tconfig: AsLinkAttrsConfig<LinkResolverFunctionReturnType> = {},\n): AsLinkAttrsReturnType<LinkResolverFunctionReturnType> => {\n\tif (\n\t\tlinkFieldOrDocument &&\n\t\t// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n\t\t// @ts-ignore - Bug in TypeScript 4.9: https://github.com/microsoft/TypeScript/issues/51501\n\t\t(\"link_type\" in linkFieldOrDocument\n\t\t\t? isFilledLink(linkFieldOrDocument)\n\t\t\t: linkFieldOrDocument)\n\t) {\n\t\tconst target =\n\t\t\t// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n\t\t\t// @ts-ignore - Bug in TypeScript 4.9: https://github.com/microsoft/TypeScript/issues/51501\n\t\t\t\"target\" in linkFieldOrDocument ? linkFieldOrDocument.target : undefined\n\n\t\tconst rawHref = asLink(linkFieldOrDocument, config.linkResolver)\n\t\tconst href =\n\t\t\trawHref == null ? undefined : (rawHref as NonNullable<typeof rawHref>)\n\n\t\tconst isExternal = typeof href === \"string\" ? !isInternalURL(href) : false\n\n\t\tconst rel = config.rel\n\t\t\t? config.rel({ href, isExternal, target })\n\t\t\t: isExternal\n\t\t\t\t? \"noreferrer\"\n\t\t\t\t: undefined\n\n\t\treturn {\n\t\t\thref,\n\t\t\ttarget,\n\t\t\trel: rel == null ? undefined : rel,\n\t\t}\n\t}\n\n\treturn {}\n}\n"],"names":["isFilledLink"],"mappings":";;;AA0FO,MAAM,cAAc,CAQ1B,qBACA,SAA4D,OACF;AAEzD,MAAA;AAAA;AAAA,GAGC,eAAe,sBACbA,KAAa,mBAAmB,IAChC,sBACF;AACK,UAAA;AAAA;AAAA;AAAA,MAGL,YAAY,sBAAsB,oBAAoB,SAAS;AAAA;AAEhE,UAAM,UAAU,OAAO,qBAAqB,OAAO,YAAY;AACzD,UAAA,OACL,WAAW,OAAO,SAAa;AAEhC,UAAM,aAAa,OAAO,SAAS,WAAW,CAAC,cAAc,IAAI,IAAI;AAErE,UAAM,MAAM,OAAO,MAChB,OAAO,IAAI,EAAE,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"asLinkAttrs.js","sources":["../../../src/helpers/asLinkAttrs.ts"],"sourcesContent":["import { isInternalURL } from \"../lib/isInternalURL\"\n\nimport type { FilledContentRelationshipField } from \"../types/value/contentRelationship\"\nimport type { PrismicDocument } from \"../types/value/document\"\nimport type { FilledLinkToWebField, LinkField } from \"../types/value/link\"\nimport type { FilledLinkToMediaField } from \"../types/value/linkToMedia\"\n\nimport type { AsLinkReturnType, LinkResolverFunction } from \"./asLink\"\nimport { asLink } from \"./asLink\"\nimport { link as isFilledLink } from \"./isFilled\"\n\ntype AsLinkAttrsConfigRelArgs<\n\tLinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>,\n\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t| LinkField\n\t\t| PrismicDocument\n\t\t| null\n\t\t| undefined,\n> = {\n\thref:\n\t\t| NonNullable<AsLinkReturnType<LinkResolverFunctionReturnType, Field>>\n\t\t| undefined\n\tisExternal: boolean\n\ttarget?: string\n}\n\nexport type AsLinkAttrsConfig<\n\tLinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>,\n\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t| LinkField\n\t\t| PrismicDocument\n\t\t| null\n\t\t| undefined,\n> = {\n\tlinkResolver?: LinkResolverFunction<LinkResolverFunctionReturnType>\n\trel?: (\n\t\targs: AsLinkAttrsConfigRelArgs<LinkResolverFunctionReturnType, Field>,\n\t) => string | undefined | void\n}\n\n/**\n * The return type of `asLinkAttrs()`.\n */\ntype AsLinkAttrsReturnType<\n\tLinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>,\n\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t| LinkField\n\t\t| PrismicDocument\n\t\t| null\n\t\t| undefined,\n> = Field extends\n\t| FilledLinkToWebField\n\t| FilledLinkToMediaField\n\t| FilledContentRelationshipField\n\t| PrismicDocument\n\t? {\n\t\t\thref:\n\t\t\t\t| NonNullable<AsLinkReturnType<LinkResolverFunctionReturnType, Field>>\n\t\t\t\t| undefined\n\t\t\ttarget?: string\n\t\t\trel?: string\n\t\t}\n\t: {\n\t\t\thref?: undefined\n\t\t\ttarget?: undefined\n\t\t\trel?: undefined\n\t\t}\n\n/**\n * Resolves any type of link field or Prismic document to a set of link\n * attributes. The attributes are designed to be passed to link HTML elements,\n * like `<a>`.\n *\n * If a resolved URL is external (i.e. starts with a protocol like `https://`),\n * `rel` is returned as `\"noreferrer\"`.\n *\n * @typeParam LinkResolverFunctionReturnType - link resolver function return\n * type\n * @typeParam Field - Link field or Prismic document to resolve to link\n * attributes\n *\n * @param linkFieldOrDocument - Any kind of link field or a document to resolve\n * @param config - Configuration that determines the output of `asLinkAttrs()`\n *\n * @returns Resolved set of link attributes or, if the provided link field or\n * document is empty, and empty object\n *\n * @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}\n * @see Prismic API `routes` options documentation: {@link https://prismic.io/docs/route-resolver}\n */\nexport const asLinkAttrs = <\n\tLinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>,\n\tField extends LinkField | PrismicDocument | null | undefined =\n\t\t| LinkField\n\t\t| PrismicDocument\n\t\t| null\n\t\t| undefined,\n>(\n\tlinkFieldOrDocument: Field,\n\tconfig: AsLinkAttrsConfig<LinkResolverFunctionReturnType> = {},\n): AsLinkAttrsReturnType<LinkResolverFunctionReturnType> => {\n\tif (\n\t\tlinkFieldOrDocument &&\n\t\t// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n\t\t// @ts-ignore - Bug in TypeScript 4.9: https://github.com/microsoft/TypeScript/issues/51501\n\t\t(\"link_type\" in linkFieldOrDocument\n\t\t\t? isFilledLink(linkFieldOrDocument)\n\t\t\t: linkFieldOrDocument)\n\t) {\n\t\tconst target =\n\t\t\t// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n\t\t\t// @ts-ignore - Bug in TypeScript 4.9: https://github.com/microsoft/TypeScript/issues/51501\n\t\t\t\"target\" in linkFieldOrDocument ? linkFieldOrDocument.target : undefined\n\n\t\tconst rawHref = asLink(linkFieldOrDocument, config.linkResolver)\n\t\tconst href =\n\t\t\trawHref == null ? undefined : (rawHref as NonNullable<typeof rawHref>)\n\n\t\tconst isExternal = typeof href === \"string\" ? !isInternalURL(href) : false\n\n\t\tconst rel = config.rel\n\t\t\t? config.rel({ href, isExternal, target })\n\t\t\t: isExternal\n\t\t\t\t? \"noreferrer\"\n\t\t\t\t: undefined\n\n\t\treturn {\n\t\t\thref,\n\t\t\ttarget,\n\t\t\trel: rel == null ? undefined : rel,\n\t\t}\n\t}\n\n\treturn {}\n}\n"],"names":["isFilledLink"],"mappings":";;;AA0FO,MAAM,cAAc,CAQ1B,qBACA,SAA4D,OACF;AAEzD,MAAA;AAAA;AAAA,GAGC,eAAe,sBACbA,KAAa,mBAAmB,IAChC,sBACF;AACK,UAAA;AAAA;AAAA;AAAA,MAGL,YAAY,sBAAsB,oBAAoB,SAAS;AAAA;AAEhE,UAAM,UAAU,OAAO,qBAAqB,OAAO,YAAY;AACzD,UAAA,OACL,WAAW,OAAO,SAAa;AAEhC,UAAM,aAAa,OAAO,SAAS,WAAW,CAAC,cAAc,IAAI,IAAI;AAErE,UAAM,MAAM,OAAO,MAChB,OAAO,IAAI,EAAE,MAAM,YAAY,OAAQ,CAAA,IACvC,aACC,eACA;AAEG,WAAA;AAAA,MACN;AAAA,MACA;AAAA,MACA,KAAK,OAAO,OAAO,SAAY;AAAA;;AAIjC,SAAO;AACR;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asText.cjs","sources":["../../../src/helpers/asText.ts"],"sourcesContent":["import type { RichTextField } from \"../types/value/richText\"\n\nimport { asText as baseAsText } from \"../richtext/asText\"\n\n/**\n * Configuration that determines the output of `asText()`.\n */\ntype AsTextConfig = {\n\t/**\n\t * Separator used to join each element.\n\t *\n\t * @defaultValue ` ` (a space)\n\t */\n\tseparator?: string\n}\n\n// TODO: Remove when we remove support for deprecated tuple-style configuration.\n/**\n * @deprecated Use object-style configuration instead.\n */\ntype AsTextDeprecatedTupleConfig = [separator?: string]\n\n/**\n * The return type of `asText()`.\n */\ntype AsTextReturnType<Field extends RichTextField | null | undefined> =\n\tField extends RichTextField ? string : null\n\nexport const asText: {\n\t/**\n\t * Serializes a rich text or title field to a plain text string.\n\t *\n\t * @param richTextField - A rich text or title field from Prismic\n\t * @param config - Configuration that determines the output of `asText()`\n\t *\n\t * @returns Plain text equivalent of the provided rich text or title field\n\t *\n\t * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}\n\t */\n\t<Field extends RichTextField | null | undefined>(\n\t\trichTextField: Field,\n\t\tconfig?: AsTextConfig,\n\t): AsTextReturnType<Field>\n\n\t/**\n\t * Serializes a rich text or title field to a plain text string.\n\t *\n\t * @deprecated Use object-style configuration instead.\n\t *\n\t * @param richTextField - A rich text or title field from Prismic\n\t * @param separator - Separator used to join each element, defaults to a space\n\t *\n\t * @returns Plain text equivalent of the provided rich text or title field\n\t *\n\t * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}\n\t */\n\t<Field extends RichTextField | null | undefined>(\n\t\trichTextField: Field,\n\t\t...config: AsTextDeprecatedTupleConfig\n\t): AsTextReturnType<Field>\n} = <Field extends RichTextField | null | undefined>(\n\trichTextField: Field,\n\t// TODO: Rename to `config` when we remove support for deprecated tuple-style configuration.\n\t...configObjectOrTuple: [config?: AsTextConfig] | AsTextDeprecatedTupleConfig\n): AsTextReturnType<Field> => {\n\tif (richTextField) {\n\t\t// TODO: Remove when we remove support for deprecated tuple-style configuration.\n\t\tconst [configObjectOrSeparator] = configObjectOrTuple\n\t\tlet config: AsTextConfig\n\t\tif (typeof configObjectOrSeparator === \"string\") {\n\t\t\tconfig = {\n\t\t\t\tseparator: configObjectOrSeparator,\n\t\t\t}\n\t\t} else {\n\t\t\tconfig = { ...configObjectOrSeparator }\n\t\t}\n\n\t\treturn baseAsText(\n\t\t\trichTextField,\n\t\t\tconfig.separator,\n\t\t) as AsTextReturnType<Field>\n\t} else {\n\t\treturn null as AsTextReturnType<Field>\n\t}\n}\n"],"names":["baseAsText"],"mappings":";;;AA4Ba,MAAA,SAgCT,CACH,kBAEG,wBACyB;AAC5B,MAAI,eAAe;AAEZ,UAAA,CAAC,uBAAuB,IAAI;AAC9B,QAAA;AACA,QAAA,OAAO,4BAA4B,UAAU;AACvC,eAAA;AAAA,QACR,WAAW;AAAA
|
|
1
|
+
{"version":3,"file":"asText.cjs","sources":["../../../src/helpers/asText.ts"],"sourcesContent":["import type { RichTextField } from \"../types/value/richText\"\n\nimport { asText as baseAsText } from \"../richtext/asText\"\n\n/**\n * Configuration that determines the output of `asText()`.\n */\ntype AsTextConfig = {\n\t/**\n\t * Separator used to join each element.\n\t *\n\t * @defaultValue ` ` (a space)\n\t */\n\tseparator?: string\n}\n\n// TODO: Remove when we remove support for deprecated tuple-style configuration.\n/**\n * @deprecated Use object-style configuration instead.\n */\ntype AsTextDeprecatedTupleConfig = [separator?: string]\n\n/**\n * The return type of `asText()`.\n */\ntype AsTextReturnType<Field extends RichTextField | null | undefined> =\n\tField extends RichTextField ? string : null\n\nexport const asText: {\n\t/**\n\t * Serializes a rich text or title field to a plain text string.\n\t *\n\t * @param richTextField - A rich text or title field from Prismic\n\t * @param config - Configuration that determines the output of `asText()`\n\t *\n\t * @returns Plain text equivalent of the provided rich text or title field\n\t *\n\t * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}\n\t */\n\t<Field extends RichTextField | null | undefined>(\n\t\trichTextField: Field,\n\t\tconfig?: AsTextConfig,\n\t): AsTextReturnType<Field>\n\n\t/**\n\t * Serializes a rich text or title field to a plain text string.\n\t *\n\t * @deprecated Use object-style configuration instead.\n\t *\n\t * @param richTextField - A rich text or title field from Prismic\n\t * @param separator - Separator used to join each element, defaults to a space\n\t *\n\t * @returns Plain text equivalent of the provided rich text or title field\n\t *\n\t * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}\n\t */\n\t<Field extends RichTextField | null | undefined>(\n\t\trichTextField: Field,\n\t\t...config: AsTextDeprecatedTupleConfig\n\t): AsTextReturnType<Field>\n} = <Field extends RichTextField | null | undefined>(\n\trichTextField: Field,\n\t// TODO: Rename to `config` when we remove support for deprecated tuple-style configuration.\n\t...configObjectOrTuple: [config?: AsTextConfig] | AsTextDeprecatedTupleConfig\n): AsTextReturnType<Field> => {\n\tif (richTextField) {\n\t\t// TODO: Remove when we remove support for deprecated tuple-style configuration.\n\t\tconst [configObjectOrSeparator] = configObjectOrTuple\n\t\tlet config: AsTextConfig\n\t\tif (typeof configObjectOrSeparator === \"string\") {\n\t\t\tconfig = {\n\t\t\t\tseparator: configObjectOrSeparator,\n\t\t\t}\n\t\t} else {\n\t\t\tconfig = { ...configObjectOrSeparator }\n\t\t}\n\n\t\treturn baseAsText(\n\t\t\trichTextField,\n\t\t\tconfig.separator,\n\t\t) as AsTextReturnType<Field>\n\t} else {\n\t\treturn null as AsTextReturnType<Field>\n\t}\n}\n"],"names":["baseAsText"],"mappings":";;;AA4Ba,MAAA,SAgCT,CACH,kBAEG,wBACyB;AAC5B,MAAI,eAAe;AAEZ,UAAA,CAAC,uBAAuB,IAAI;AAC9B,QAAA;AACA,QAAA,OAAO,4BAA4B,UAAU;AACvC,eAAA;AAAA,QACR,WAAW;AAAA;WAEN;AACG,eAAA,EAAE,GAAG;;AAGR,WAAAA,gBACN,eACA,OAAO,SAAS;AAAA,EAAA,OAEX;AACC,WAAA;AAAA,EAAA;AAET;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asText.js","sources":["../../../src/helpers/asText.ts"],"sourcesContent":["import type { RichTextField } from \"../types/value/richText\"\n\nimport { asText as baseAsText } from \"../richtext/asText\"\n\n/**\n * Configuration that determines the output of `asText()`.\n */\ntype AsTextConfig = {\n\t/**\n\t * Separator used to join each element.\n\t *\n\t * @defaultValue ` ` (a space)\n\t */\n\tseparator?: string\n}\n\n// TODO: Remove when we remove support for deprecated tuple-style configuration.\n/**\n * @deprecated Use object-style configuration instead.\n */\ntype AsTextDeprecatedTupleConfig = [separator?: string]\n\n/**\n * The return type of `asText()`.\n */\ntype AsTextReturnType<Field extends RichTextField | null | undefined> =\n\tField extends RichTextField ? string : null\n\nexport const asText: {\n\t/**\n\t * Serializes a rich text or title field to a plain text string.\n\t *\n\t * @param richTextField - A rich text or title field from Prismic\n\t * @param config - Configuration that determines the output of `asText()`\n\t *\n\t * @returns Plain text equivalent of the provided rich text or title field\n\t *\n\t * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}\n\t */\n\t<Field extends RichTextField | null | undefined>(\n\t\trichTextField: Field,\n\t\tconfig?: AsTextConfig,\n\t): AsTextReturnType<Field>\n\n\t/**\n\t * Serializes a rich text or title field to a plain text string.\n\t *\n\t * @deprecated Use object-style configuration instead.\n\t *\n\t * @param richTextField - A rich text or title field from Prismic\n\t * @param separator - Separator used to join each element, defaults to a space\n\t *\n\t * @returns Plain text equivalent of the provided rich text or title field\n\t *\n\t * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}\n\t */\n\t<Field extends RichTextField | null | undefined>(\n\t\trichTextField: Field,\n\t\t...config: AsTextDeprecatedTupleConfig\n\t): AsTextReturnType<Field>\n} = <Field extends RichTextField | null | undefined>(\n\trichTextField: Field,\n\t// TODO: Rename to `config` when we remove support for deprecated tuple-style configuration.\n\t...configObjectOrTuple: [config?: AsTextConfig] | AsTextDeprecatedTupleConfig\n): AsTextReturnType<Field> => {\n\tif (richTextField) {\n\t\t// TODO: Remove when we remove support for deprecated tuple-style configuration.\n\t\tconst [configObjectOrSeparator] = configObjectOrTuple\n\t\tlet config: AsTextConfig\n\t\tif (typeof configObjectOrSeparator === \"string\") {\n\t\t\tconfig = {\n\t\t\t\tseparator: configObjectOrSeparator,\n\t\t\t}\n\t\t} else {\n\t\t\tconfig = { ...configObjectOrSeparator }\n\t\t}\n\n\t\treturn baseAsText(\n\t\t\trichTextField,\n\t\t\tconfig.separator,\n\t\t) as AsTextReturnType<Field>\n\t} else {\n\t\treturn null as AsTextReturnType<Field>\n\t}\n}\n"],"names":["baseAsText"],"mappings":";AA4Ba,MAAA,SAgCT,CACH,kBAEG,wBACyB;AAC5B,MAAI,eAAe;AAEZ,UAAA,CAAC,uBAAuB,IAAI;AAC9B,QAAA;AACA,QAAA,OAAO,4BAA4B,UAAU;AACvC,eAAA;AAAA,QACR,WAAW;AAAA
|
|
1
|
+
{"version":3,"file":"asText.js","sources":["../../../src/helpers/asText.ts"],"sourcesContent":["import type { RichTextField } from \"../types/value/richText\"\n\nimport { asText as baseAsText } from \"../richtext/asText\"\n\n/**\n * Configuration that determines the output of `asText()`.\n */\ntype AsTextConfig = {\n\t/**\n\t * Separator used to join each element.\n\t *\n\t * @defaultValue ` ` (a space)\n\t */\n\tseparator?: string\n}\n\n// TODO: Remove when we remove support for deprecated tuple-style configuration.\n/**\n * @deprecated Use object-style configuration instead.\n */\ntype AsTextDeprecatedTupleConfig = [separator?: string]\n\n/**\n * The return type of `asText()`.\n */\ntype AsTextReturnType<Field extends RichTextField | null | undefined> =\n\tField extends RichTextField ? string : null\n\nexport const asText: {\n\t/**\n\t * Serializes a rich text or title field to a plain text string.\n\t *\n\t * @param richTextField - A rich text or title field from Prismic\n\t * @param config - Configuration that determines the output of `asText()`\n\t *\n\t * @returns Plain text equivalent of the provided rich text or title field\n\t *\n\t * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}\n\t */\n\t<Field extends RichTextField | null | undefined>(\n\t\trichTextField: Field,\n\t\tconfig?: AsTextConfig,\n\t): AsTextReturnType<Field>\n\n\t/**\n\t * Serializes a rich text or title field to a plain text string.\n\t *\n\t * @deprecated Use object-style configuration instead.\n\t *\n\t * @param richTextField - A rich text or title field from Prismic\n\t * @param separator - Separator used to join each element, defaults to a space\n\t *\n\t * @returns Plain text equivalent of the provided rich text or title field\n\t *\n\t * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}\n\t */\n\t<Field extends RichTextField | null | undefined>(\n\t\trichTextField: Field,\n\t\t...config: AsTextDeprecatedTupleConfig\n\t): AsTextReturnType<Field>\n} = <Field extends RichTextField | null | undefined>(\n\trichTextField: Field,\n\t// TODO: Rename to `config` when we remove support for deprecated tuple-style configuration.\n\t...configObjectOrTuple: [config?: AsTextConfig] | AsTextDeprecatedTupleConfig\n): AsTextReturnType<Field> => {\n\tif (richTextField) {\n\t\t// TODO: Remove when we remove support for deprecated tuple-style configuration.\n\t\tconst [configObjectOrSeparator] = configObjectOrTuple\n\t\tlet config: AsTextConfig\n\t\tif (typeof configObjectOrSeparator === \"string\") {\n\t\t\tconfig = {\n\t\t\t\tseparator: configObjectOrSeparator,\n\t\t\t}\n\t\t} else {\n\t\t\tconfig = { ...configObjectOrSeparator }\n\t\t}\n\n\t\treturn baseAsText(\n\t\t\trichTextField,\n\t\t\tconfig.separator,\n\t\t) as AsTextReturnType<Field>\n\t} else {\n\t\treturn null as AsTextReturnType<Field>\n\t}\n}\n"],"names":["baseAsText"],"mappings":";AA4Ba,MAAA,SAgCT,CACH,kBAEG,wBACyB;AAC5B,MAAI,eAAe;AAEZ,UAAA,CAAC,uBAAuB,IAAI;AAC9B,QAAA;AACA,QAAA,OAAO,4BAA4B,UAAU;AACvC,eAAA;AAAA,QACR,WAAW;AAAA;WAEN;AACG,eAAA,EAAE,GAAG;;AAGR,WAAAA,SACN,eACA,OAAO,SAAS;AAAA,EAAA,OAEX;AACC,WAAA;AAAA,EAAA;AAET;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentToLinkField.cjs","sources":["../../../src/helpers/documentToLinkField.ts"],"sourcesContent":["import type { FilledContentRelationshipField } from \"../types/value/contentRelationship\"\nimport type { PrismicDocument } from \"../types/value/document\"\nimport { LinkType } from \"../types/value/link\"\n\ntype SetOptional<T, Keys extends keyof T> = Omit<T, Keys> &\n\tPartial<Pick<T, Keys>>\n\n/**\n * Converts a document into a link field, this is useful when crawling the API\n * for document links\n *\n * @typeParam TDocument - Specific interface of the provided document\n *\n * @param prismicDocument - A document coming from Prismic\n *\n * @returns The equivalent link field to use with `asLink()`\n *\n * @internal\n */\nexport const documentToLinkField = <\n\tTDocument extends SetOptional<PrismicDocument, \"slugs\">,\n>(\n\tprismicDocument: TDocument,\n): FilledContentRelationshipField<\n\tTDocument[\"type\"],\n\tTDocument[\"lang\"],\n\tTDocument[\"data\"]\n> => {\n\treturn {\n\t\tlink_type: LinkType.Document,\n\t\tid: prismicDocument.id,\n\t\tuid: prismicDocument.uid || undefined,\n\t\ttype: prismicDocument.type,\n\t\ttags: prismicDocument.tags,\n\t\tlang: prismicDocument.lang,\n\t\turl: prismicDocument.url == null ? undefined : prismicDocument.url,\n\t\tslug: prismicDocument.slugs?.[0], // Slug field is not available with GraphQL\n\t\t// The REST API does not include a `data` property if the data\n\t\t// object is empty.\n\t\t//\n\t\t// A presence check for `prismicDocument.data` is done to\n\t\t// support partial documents. While `documentToLinkField` is\n\t\t// not typed to accept partial documents, passing a partial\n\t\t// document can happen in untyped projects.\n\t\t...(prismicDocument.data && Object.keys(prismicDocument.data).length > 0\n\t\t\t? { data: prismicDocument.data }\n\t\t\t: {}),\n\t}\n}\n"],"names":["LinkType"],"mappings":";;;AAmBa,MAAA,sBAAsB,CAGlC,oBAKG;;AACI,SAAA;AAAA,IACN,WAAWA,KAAS,SAAA;AAAA,IACpB,IAAI,gBAAgB;AAAA,IACpB,KAAK,gBAAgB,OAAO;AAAA,IAC5B,MAAM,gBAAgB;AAAA,IACtB,MAAM,gBAAgB;AAAA,IACtB,MAAM,gBAAgB;AAAA,IACtB,KAAK,gBAAgB,OAAO,OAAO,SAAY,gBAAgB;AAAA,IAC/D,OAAM,qBAAgB,UAAhB,mBAAwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQ9B,GAAI,gBAAgB,QAAQ,OAAO,KAAK,gBAAgB,IAAI,EAAE,SAAS,IACpE,EAAE,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"documentToLinkField.cjs","sources":["../../../src/helpers/documentToLinkField.ts"],"sourcesContent":["import type { FilledContentRelationshipField } from \"../types/value/contentRelationship\"\nimport type { PrismicDocument } from \"../types/value/document\"\nimport { LinkType } from \"../types/value/link\"\n\ntype SetOptional<T, Keys extends keyof T> = Omit<T, Keys> &\n\tPartial<Pick<T, Keys>>\n\n/**\n * Converts a document into a link field, this is useful when crawling the API\n * for document links\n *\n * @typeParam TDocument - Specific interface of the provided document\n *\n * @param prismicDocument - A document coming from Prismic\n *\n * @returns The equivalent link field to use with `asLink()`\n *\n * @internal\n */\nexport const documentToLinkField = <\n\tTDocument extends SetOptional<PrismicDocument, \"slugs\">,\n>(\n\tprismicDocument: TDocument,\n): FilledContentRelationshipField<\n\tTDocument[\"type\"],\n\tTDocument[\"lang\"],\n\tTDocument[\"data\"]\n> => {\n\treturn {\n\t\tlink_type: LinkType.Document,\n\t\tid: prismicDocument.id,\n\t\tuid: prismicDocument.uid || undefined,\n\t\ttype: prismicDocument.type,\n\t\ttags: prismicDocument.tags,\n\t\tlang: prismicDocument.lang,\n\t\turl: prismicDocument.url == null ? undefined : prismicDocument.url,\n\t\tslug: prismicDocument.slugs?.[0], // Slug field is not available with GraphQL\n\t\t// The REST API does not include a `data` property if the data\n\t\t// object is empty.\n\t\t//\n\t\t// A presence check for `prismicDocument.data` is done to\n\t\t// support partial documents. While `documentToLinkField` is\n\t\t// not typed to accept partial documents, passing a partial\n\t\t// document can happen in untyped projects.\n\t\t...(prismicDocument.data && Object.keys(prismicDocument.data).length > 0\n\t\t\t? { data: prismicDocument.data }\n\t\t\t: {}),\n\t}\n}\n"],"names":["LinkType"],"mappings":";;;AAmBa,MAAA,sBAAsB,CAGlC,oBAKG;;AACI,SAAA;AAAA,IACN,WAAWA,KAAS,SAAA;AAAA,IACpB,IAAI,gBAAgB;AAAA,IACpB,KAAK,gBAAgB,OAAO;AAAA,IAC5B,MAAM,gBAAgB;AAAA,IACtB,MAAM,gBAAgB;AAAA,IACtB,MAAM,gBAAgB;AAAA,IACtB,KAAK,gBAAgB,OAAO,OAAO,SAAY,gBAAgB;AAAA,IAC/D,OAAM,qBAAgB,UAAhB,mBAAwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQ9B,GAAI,gBAAgB,QAAQ,OAAO,KAAK,gBAAgB,IAAI,EAAE,SAAS,IACpE,EAAE,MAAM,gBAAgB,KAAA,IACxB,CAAA;AAAA;AAEL;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentToLinkField.js","sources":["../../../src/helpers/documentToLinkField.ts"],"sourcesContent":["import type { FilledContentRelationshipField } from \"../types/value/contentRelationship\"\nimport type { PrismicDocument } from \"../types/value/document\"\nimport { LinkType } from \"../types/value/link\"\n\ntype SetOptional<T, Keys extends keyof T> = Omit<T, Keys> &\n\tPartial<Pick<T, Keys>>\n\n/**\n * Converts a document into a link field, this is useful when crawling the API\n * for document links\n *\n * @typeParam TDocument - Specific interface of the provided document\n *\n * @param prismicDocument - A document coming from Prismic\n *\n * @returns The equivalent link field to use with `asLink()`\n *\n * @internal\n */\nexport const documentToLinkField = <\n\tTDocument extends SetOptional<PrismicDocument, \"slugs\">,\n>(\n\tprismicDocument: TDocument,\n): FilledContentRelationshipField<\n\tTDocument[\"type\"],\n\tTDocument[\"lang\"],\n\tTDocument[\"data\"]\n> => {\n\treturn {\n\t\tlink_type: LinkType.Document,\n\t\tid: prismicDocument.id,\n\t\tuid: prismicDocument.uid || undefined,\n\t\ttype: prismicDocument.type,\n\t\ttags: prismicDocument.tags,\n\t\tlang: prismicDocument.lang,\n\t\turl: prismicDocument.url == null ? undefined : prismicDocument.url,\n\t\tslug: prismicDocument.slugs?.[0], // Slug field is not available with GraphQL\n\t\t// The REST API does not include a `data` property if the data\n\t\t// object is empty.\n\t\t//\n\t\t// A presence check for `prismicDocument.data` is done to\n\t\t// support partial documents. While `documentToLinkField` is\n\t\t// not typed to accept partial documents, passing a partial\n\t\t// document can happen in untyped projects.\n\t\t...(prismicDocument.data && Object.keys(prismicDocument.data).length > 0\n\t\t\t? { data: prismicDocument.data }\n\t\t\t: {}),\n\t}\n}\n"],"names":[],"mappings":";AAmBa,MAAA,sBAAsB,CAGlC,oBAKG;;AACI,SAAA;AAAA,IACN,WAAW,SAAS;AAAA,IACpB,IAAI,gBAAgB;AAAA,IACpB,KAAK,gBAAgB,OAAO;AAAA,IAC5B,MAAM,gBAAgB;AAAA,IACtB,MAAM,gBAAgB;AAAA,IACtB,MAAM,gBAAgB;AAAA,IACtB,KAAK,gBAAgB,OAAO,OAAO,SAAY,gBAAgB;AAAA,IAC/D,OAAM,qBAAgB,UAAhB,mBAAwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQ9B,GAAI,gBAAgB,QAAQ,OAAO,KAAK,gBAAgB,IAAI,EAAE,SAAS,IACpE,EAAE,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"documentToLinkField.js","sources":["../../../src/helpers/documentToLinkField.ts"],"sourcesContent":["import type { FilledContentRelationshipField } from \"../types/value/contentRelationship\"\nimport type { PrismicDocument } from \"../types/value/document\"\nimport { LinkType } from \"../types/value/link\"\n\ntype SetOptional<T, Keys extends keyof T> = Omit<T, Keys> &\n\tPartial<Pick<T, Keys>>\n\n/**\n * Converts a document into a link field, this is useful when crawling the API\n * for document links\n *\n * @typeParam TDocument - Specific interface of the provided document\n *\n * @param prismicDocument - A document coming from Prismic\n *\n * @returns The equivalent link field to use with `asLink()`\n *\n * @internal\n */\nexport const documentToLinkField = <\n\tTDocument extends SetOptional<PrismicDocument, \"slugs\">,\n>(\n\tprismicDocument: TDocument,\n): FilledContentRelationshipField<\n\tTDocument[\"type\"],\n\tTDocument[\"lang\"],\n\tTDocument[\"data\"]\n> => {\n\treturn {\n\t\tlink_type: LinkType.Document,\n\t\tid: prismicDocument.id,\n\t\tuid: prismicDocument.uid || undefined,\n\t\ttype: prismicDocument.type,\n\t\ttags: prismicDocument.tags,\n\t\tlang: prismicDocument.lang,\n\t\turl: prismicDocument.url == null ? undefined : prismicDocument.url,\n\t\tslug: prismicDocument.slugs?.[0], // Slug field is not available with GraphQL\n\t\t// The REST API does not include a `data` property if the data\n\t\t// object is empty.\n\t\t//\n\t\t// A presence check for `prismicDocument.data` is done to\n\t\t// support partial documents. While `documentToLinkField` is\n\t\t// not typed to accept partial documents, passing a partial\n\t\t// document can happen in untyped projects.\n\t\t...(prismicDocument.data && Object.keys(prismicDocument.data).length > 0\n\t\t\t? { data: prismicDocument.data }\n\t\t\t: {}),\n\t}\n}\n"],"names":[],"mappings":";AAmBa,MAAA,sBAAsB,CAGlC,oBAKG;;AACI,SAAA;AAAA,IACN,WAAW,SAAS;AAAA,IACpB,IAAI,gBAAgB;AAAA,IACpB,KAAK,gBAAgB,OAAO;AAAA,IAC5B,MAAM,gBAAgB;AAAA,IACtB,MAAM,gBAAgB;AAAA,IACtB,MAAM,gBAAgB;AAAA,IACtB,KAAK,gBAAgB,OAAO,OAAO,SAAY,gBAAgB;AAAA,IAC/D,OAAM,qBAAgB,UAAhB,mBAAwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQ9B,GAAI,gBAAgB,QAAQ,OAAO,KAAK,gBAAgB,IAAI,EAAE,SAAS,IACpE,EAAE,MAAM,gBAAgB,KAAA,IACxB,CAAA;AAAA;AAEL;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isFilled.cjs","sources":["../../../src/helpers/isFilled.ts"],"sourcesContent":["import type { ColorField } from \"../types/value/color\"\nimport type { ContentRelationshipField } from \"../types/value/contentRelationship\"\nimport type { DateField } from \"../types/value/date\"\nimport type { AnyOEmbed, EmbedField } from \"../types/value/embed\"\nimport type { GeoPointField } from \"../types/value/geoPoint\"\nimport type { GroupField, NestedGroupField } from \"../types/value/group\"\nimport type { ImageField, ImageFieldImage } from \"../types/value/image\"\nimport type { IntegrationField } from \"../types/value/integration\"\nimport type { KeyTextField } from \"../types/value/keyText\"\nimport type { LinkField } from \"../types/value/link\"\nimport type { LinkToMediaField } from \"../types/value/linkToMedia\"\nimport type { NumberField } from \"../types/value/number\"\nimport type { RichTextField } from \"../types/value/richText\"\nimport type { SelectField } from \"../types/value/select\"\nimport type { SharedSlice } from \"../types/value/sharedSlice\"\nimport type { Slice } from \"../types/value/slice\"\nimport type { SliceZone } from \"../types/value/sliceZone\"\nimport type { TableField } from \"../types/value/table\"\nimport type { TimestampField } from \"../types/value/timestamp\"\nimport type { TitleField } from \"../types/value/title\"\nimport type { AnyRegularField, Repeatable } from \"../types/value/types\"\n\n/**\n * Determines if a value is not nullish (i.e. not `null` or `undefined`). This\n * is used to check if nullable field values are filled.\n *\n * @param input - The value to check.\n *\n * @returns `true` if `input` is not nullish, `false` otherwise.\n */\nconst isNonNullish = <T>(input: T): input is NonNullable<T> => {\n\treturn input != null\n}\n\n/**\n * Determines if an array is not empty. This is used to check if array-based\n * fields are filled.\n *\n * @param input - The array to check.\n *\n * @returns `true` if `input` has at least one element, `false` otherwise.\n */\nconst isNonEmptyArray = <T>(input: T[]): input is [T, ...T[]] => {\n\treturn !!input.length\n}\n\n/**\n * Determines if a rich text field is filled.\n *\n * @param field - rich text field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const richText = (\n\tfield: RichTextField | null | undefined,\n): field is RichTextField<\"filled\"> => {\n\tif (!isNonNullish(field)) {\n\t\treturn false\n\t} else if (field.length === 1 && \"text\" in field[0]) {\n\t\treturn !!field[0].text\n\t} else {\n\t\treturn !!field.length\n\t}\n}\n\n/**\n * Determines if a title field is filled.\n *\n * @param field - Title field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const title = richText as (\n\tfield: TitleField | null | undefined,\n) => field is TitleField<\"filled\">\n\n/**\n * Determines if an Image thumbnail is filled.\n *\n * @param thumbnail - Image thumbnail to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const imageThumbnail = (\n\tthumbnail: ImageFieldImage | null | undefined,\n): thumbnail is ImageFieldImage<\"filled\"> => {\n\treturn isNonNullish(thumbnail) && !!thumbnail.url\n}\n\n/**\n * Determines if an image field is filled.\n *\n * @param field - Image field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const image = imageThumbnail as <\n\tThumbnailNames extends string | null = never,\n>(\n\tfield: ImageField<ThumbnailNames> | null | undefined,\n) => field is ImageField<ThumbnailNames, \"filled\">\n\n/**\n * Determines if a link field is filled.\n *\n * @param field - Link field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const link = <\n\tTypeEnum = string,\n\tLangEnum = string,\n\tDataInterface extends\n\t\t| Record<string, AnyRegularField | GroupField | SliceZone>\n\t\t| unknown = unknown,\n>(\n\tfield: LinkField<TypeEnum, LangEnum, DataInterface> | null | undefined,\n): field is LinkField<TypeEnum, LangEnum, DataInterface, \"filled\"> => {\n\treturn isNonNullish(field) && (\"id\" in field || \"url\" in field)\n}\n\n/**\n * Determines if a link to media field is filled.\n *\n * @param field - Link to media field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const linkToMedia = link as (\n\tfield: LinkToMediaField | null | undefined,\n) => field is LinkToMediaField<\"filled\">\n\n/**\n * Determines if a content relationship field is filled.\n *\n * @param field - Content Relationship field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const contentRelationship = link as <\n\tTypeEnum = string,\n\tLangEnum = string,\n\tDataInterface extends\n\t\t| Record<string, AnyRegularField | GroupField | SliceZone>\n\t\t| unknown = unknown,\n>(\n\tfield:\n\t\t| ContentRelationshipField<TypeEnum, LangEnum, DataInterface>\n\t\t| null\n\t\t| undefined,\n) => field is ContentRelationshipField<\n\tTypeEnum,\n\tLangEnum,\n\tDataInterface,\n\t\"filled\"\n>\n\n/**\n * Determines if a date field is filled.\n *\n * @param field - Date field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const date = isNonNullish as (\n\tfield: DateField | null | undefined,\n) => field is DateField<\"filled\">\n\n/**\n * Determines if a timestamp field is filled.\n *\n * @param field - Timestamp field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const timestamp = isNonNullish as (\n\tfield: TimestampField | null | undefined,\n) => field is TimestampField<\"filled\">\n\n/**\n * Determines if a color field is filled.\n *\n * @param field - Color field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const color = isNonNullish as (\n\tfield: ColorField | null | undefined,\n) => field is ColorField<\"filled\">\n\n/**\n * Determines if a number field is filled.\n *\n * @param field - Number field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const number = isNonNullish as (\n\tfield: NumberField | null | undefined,\n) => field is NumberField<\"filled\">\n\n/**\n * Determines if a key text field is filled.\n *\n * @param field - Key Text field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const keyText = (\n\tfield: KeyTextField | null | undefined,\n): field is KeyTextField<\"filled\"> => {\n\treturn isNonNullish(keyText) && !!field\n}\n\n/**\n * Determines if a select field is filled.\n *\n * @param field - Select field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const select = isNonNullish as <Enum extends string>(\n\tfield: SelectField<Enum> | null | undefined,\n) => field is SelectField<Enum, \"filled\">\n\n/**\n * Determines if an embed field is filled.\n *\n * @param field - Embed field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const embed = <Field extends EmbedField<AnyOEmbed>>(\n\tfield: Field | null | undefined,\n): field is Extract<Field, EmbedField<AnyOEmbed, \"filled\">> => {\n\treturn isNonNullish(field) && !!field.embed_url\n}\n\n/**\n * Determines if a geopoint field is filled.\n *\n * @param field - GeoPoint field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const geoPoint = (\n\tfield: GeoPointField | null | undefined,\n): field is GeoPointField<\"filled\"> => {\n\treturn isNonNullish(field) && \"longitude\" in field\n}\n\n/**\n * Determines if a table field is filled.\n *\n * @param field - Table field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const table = isNonNullish as (\n\tfield: TableField | null | undefined,\n) => field is TableField<\"filled\">\n\n/**\n * Determines if an integration field is filled.\n *\n * @param field - Integration field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const integrationField = isNonNullish as <\n\tData extends Record<string, unknown>,\n>(\n\tfield: IntegrationField<Data> | null | undefined,\n) => field is IntegrationField<Data, \"filled\">\n/**\n * @deprecated Renamed to `integrationField`.\n */\n// TODO: Remove when we remove support for deprecated `integrationFields` export.\nexport const integrationFields = integrationField\n\n/**\n * Determines if a repeatable field has at least one item.\n *\n * @param repeatable - Repeatable to check.\n *\n * @returns `true` if `repeatable` contains at least one item, `false`\n * otherwise.\n */\nexport const repeatable = <T extends LinkField>(\n\trepeatable: Repeatable<T> | null | undefined,\n): repeatable is Repeatable<T, \"filled\"> => {\n\treturn isNonNullish(repeatable) && isNonEmptyArray(repeatable)\n}\n\n/**\n * Determines if a Group has at least one item.\n *\n * @param group - Group to check.\n *\n * @returns `true` if `group` contains at least one item, `false` otherwise.\n */\nexport const group = <\n\tFields extends Record<string, AnyRegularField | NestedGroupField>,\n>(\n\tgroup: GroupField<Fields> | null | undefined,\n): group is GroupField<Fields, \"filled\"> => {\n\treturn isNonNullish(group) && isNonEmptyArray(group)\n}\n\n/**\n * Determines if a Slice Zone has at least one Slice.\n *\n * @param slices - Slice Zone to check.\n *\n * @returns `true` if `slices` contains at least one Slice, `false` otherwise.\n */\nexport const sliceZone = <Slices extends Slice | SharedSlice>(\n\tslices: SliceZone<Slices> | null | undefined,\n): slices is SliceZone<Slices, \"filled\"> => {\n\treturn isNonNullish(slices) && isNonEmptyArray(slices)\n}\n"],"names":["repeatable","group"],"mappings":";;AA8BA,MAAM,eAAe,CAAI,UAAqC;AAC7D,SAAO,SAAS;AACjB;AAUA,MAAM,kBAAkB,CAAI,UAAoC;AACxD,SAAA,CAAC,CAAC,MAAM;AAChB;AASa,MAAA,WAAW,CACvB,UACqC;AACjC,MAAA,CAAC,aAAa,KAAK,GAAG;AAClB,WAAA;AAAA,EAAA,WACG,MAAM,WAAW,KAAK,UAAU,MAAM,CAAC,GAAG;AACpD,WAAO,CAAC,CAAC,MAAM,CAAC,EAAE;AAAA,EAAA,OACZ;AACC,WAAA,CAAC,CAAC,MAAM;AAAA,EAChB;AACD;AASO,MAAM,QAAQ;AAWR,MAAA,iBAAiB,CAC7B,cAC2C;AAC3C,SAAO,aAAa,SAAS,KAAK,CAAC,CAAC,UAAU;AAC/C;AASO,MAAM,QAAQ;AAaR,MAAA,OAAO,CAOnB,UACoE;AACpE,SAAO,aAAa,KAAK,MAAM,QAAQ,SAAS,SAAS;AAC1D;AASO,MAAM,cAAc;AAWpB,MAAM,sBAAsB;AAyB5B,MAAM,OAAO;AAWb,MAAM,YAAY;AAWlB,MAAM,QAAQ;AAWd,MAAM,SAAS;AAWT,MAAA,UAAU,CACtB,UACoC;AACpC,SAAO,aAAa,OAAO,KAAK,CAAC,CAAC;AACnC;AASO,MAAM,SAAS;AAWT,MAAA,QAAQ,CACpB,UAC6D;AAC7D,SAAO,aAAa,KAAK,KAAK,CAAC,CAAC,MAAM;AACvC;AASa,MAAA,WAAW,CACvB,UACqC;AAC9B,SAAA,aAAa,KAAK,KAAK,eAAe;AAC9C;AASO,MAAM,QAAQ;AAWd,MAAM,mBAAmB;AASzB,MAAM,oBAAoB;AAUpB,MAAA,aAAa,CACzBA,gBAC0C;AAC1C,SAAO,aAAaA,WAAU,KAAK,gBAAgBA,WAAU;AAC9D;AASa,MAAA,QAAQ,CAGpBC,WAC0C;AAC1C,SAAO,aAAaA,MAAK,KAAK,gBAAgBA,MAAK;AACpD;AASa,MAAA,YAAY,CACxB,WAC0C;AAC1C,SAAO,aAAa,MAAM,KAAK,gBAAgB,MAAM;AACtD;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"isFilled.cjs","sources":["../../../src/helpers/isFilled.ts"],"sourcesContent":["import type { ColorField } from \"../types/value/color\"\nimport type { ContentRelationshipField } from \"../types/value/contentRelationship\"\nimport type { DateField } from \"../types/value/date\"\nimport type { AnyOEmbed, EmbedField } from \"../types/value/embed\"\nimport type { GeoPointField } from \"../types/value/geoPoint\"\nimport type { GroupField, NestedGroupField } from \"../types/value/group\"\nimport type { ImageField, ImageFieldImage } from \"../types/value/image\"\nimport type { IntegrationField } from \"../types/value/integration\"\nimport type { KeyTextField } from \"../types/value/keyText\"\nimport type { LinkField } from \"../types/value/link\"\nimport type { LinkToMediaField } from \"../types/value/linkToMedia\"\nimport type { NumberField } from \"../types/value/number\"\nimport type { RichTextField } from \"../types/value/richText\"\nimport type { SelectField } from \"../types/value/select\"\nimport type { SharedSlice } from \"../types/value/sharedSlice\"\nimport type { Slice } from \"../types/value/slice\"\nimport type { SliceZone } from \"../types/value/sliceZone\"\nimport type { TableField } from \"../types/value/table\"\nimport type { TimestampField } from \"../types/value/timestamp\"\nimport type { TitleField } from \"../types/value/title\"\nimport type { AnyRegularField, Repeatable } from \"../types/value/types\"\n\n/**\n * Determines if a value is not nullish (i.e. not `null` or `undefined`). This\n * is used to check if nullable field values are filled.\n *\n * @param input - The value to check.\n *\n * @returns `true` if `input` is not nullish, `false` otherwise.\n */\nconst isNonNullish = <T>(input: T): input is NonNullable<T> => {\n\treturn input != null\n}\n\n/**\n * Determines if an array is not empty. This is used to check if array-based\n * fields are filled.\n *\n * @param input - The array to check.\n *\n * @returns `true` if `input` has at least one element, `false` otherwise.\n */\nconst isNonEmptyArray = <T>(input: T[]): input is [T, ...T[]] => {\n\treturn !!input.length\n}\n\n/**\n * Determines if a rich text field is filled.\n *\n * @param field - rich text field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const richText = (\n\tfield: RichTextField | null | undefined,\n): field is RichTextField<\"filled\"> => {\n\tif (!isNonNullish(field)) {\n\t\treturn false\n\t} else if (field.length === 1 && \"text\" in field[0]) {\n\t\treturn !!field[0].text\n\t} else {\n\t\treturn !!field.length\n\t}\n}\n\n/**\n * Determines if a title field is filled.\n *\n * @param field - Title field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const title = richText as (\n\tfield: TitleField | null | undefined,\n) => field is TitleField<\"filled\">\n\n/**\n * Determines if an Image thumbnail is filled.\n *\n * @param thumbnail - Image thumbnail to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const imageThumbnail = (\n\tthumbnail: ImageFieldImage | null | undefined,\n): thumbnail is ImageFieldImage<\"filled\"> => {\n\treturn isNonNullish(thumbnail) && !!thumbnail.url\n}\n\n/**\n * Determines if an image field is filled.\n *\n * @param field - Image field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const image = imageThumbnail as <\n\tThumbnailNames extends string | null = never,\n>(\n\tfield: ImageField<ThumbnailNames> | null | undefined,\n) => field is ImageField<ThumbnailNames, \"filled\">\n\n/**\n * Determines if a link field is filled.\n *\n * @param field - Link field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const link = <\n\tTypeEnum = string,\n\tLangEnum = string,\n\tDataInterface extends\n\t\t| Record<string, AnyRegularField | GroupField | SliceZone>\n\t\t| unknown = unknown,\n>(\n\tfield: LinkField<TypeEnum, LangEnum, DataInterface> | null | undefined,\n): field is LinkField<TypeEnum, LangEnum, DataInterface, \"filled\"> => {\n\treturn isNonNullish(field) && (\"id\" in field || \"url\" in field)\n}\n\n/**\n * Determines if a link to media field is filled.\n *\n * @param field - Link to media field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const linkToMedia = link as (\n\tfield: LinkToMediaField | null | undefined,\n) => field is LinkToMediaField<\"filled\">\n\n/**\n * Determines if a content relationship field is filled.\n *\n * @param field - Content Relationship field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const contentRelationship = link as <\n\tTypeEnum = string,\n\tLangEnum = string,\n\tDataInterface extends\n\t\t| Record<string, AnyRegularField | GroupField | SliceZone>\n\t\t| unknown = unknown,\n>(\n\tfield:\n\t\t| ContentRelationshipField<TypeEnum, LangEnum, DataInterface>\n\t\t| null\n\t\t| undefined,\n) => field is ContentRelationshipField<\n\tTypeEnum,\n\tLangEnum,\n\tDataInterface,\n\t\"filled\"\n>\n\n/**\n * Determines if a date field is filled.\n *\n * @param field - Date field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const date = isNonNullish as (\n\tfield: DateField | null | undefined,\n) => field is DateField<\"filled\">\n\n/**\n * Determines if a timestamp field is filled.\n *\n * @param field - Timestamp field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const timestamp = isNonNullish as (\n\tfield: TimestampField | null | undefined,\n) => field is TimestampField<\"filled\">\n\n/**\n * Determines if a color field is filled.\n *\n * @param field - Color field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const color = isNonNullish as (\n\tfield: ColorField | null | undefined,\n) => field is ColorField<\"filled\">\n\n/**\n * Determines if a number field is filled.\n *\n * @param field - Number field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const number = isNonNullish as (\n\tfield: NumberField | null | undefined,\n) => field is NumberField<\"filled\">\n\n/**\n * Determines if a key text field is filled.\n *\n * @param field - Key Text field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const keyText = (\n\tfield: KeyTextField | null | undefined,\n): field is KeyTextField<\"filled\"> => {\n\treturn isNonNullish(keyText) && !!field\n}\n\n/**\n * Determines if a select field is filled.\n *\n * @param field - Select field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const select = isNonNullish as <Enum extends string>(\n\tfield: SelectField<Enum> | null | undefined,\n) => field is SelectField<Enum, \"filled\">\n\n/**\n * Determines if an embed field is filled.\n *\n * @param field - Embed field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const embed = <Field extends EmbedField<AnyOEmbed>>(\n\tfield: Field | null | undefined,\n): field is Extract<Field, EmbedField<AnyOEmbed, \"filled\">> => {\n\treturn isNonNullish(field) && !!field.embed_url\n}\n\n/**\n * Determines if a geopoint field is filled.\n *\n * @param field - GeoPoint field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const geoPoint = (\n\tfield: GeoPointField | null | undefined,\n): field is GeoPointField<\"filled\"> => {\n\treturn isNonNullish(field) && \"longitude\" in field\n}\n\n/**\n * Determines if a table field is filled.\n *\n * @param field - Table field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const table = isNonNullish as (\n\tfield: TableField | null | undefined,\n) => field is TableField<\"filled\">\n\n/**\n * Determines if an integration field is filled.\n *\n * @param field - Integration field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const integrationField = isNonNullish as <\n\tData extends Record<string, unknown>,\n>(\n\tfield: IntegrationField<Data> | null | undefined,\n) => field is IntegrationField<Data, \"filled\">\n/**\n * @deprecated Renamed to `integrationField`.\n */\n// TODO: Remove when we remove support for deprecated `integrationFields` export.\nexport const integrationFields = integrationField\n\n/**\n * Determines if a repeatable field has at least one item.\n *\n * @param repeatable - Repeatable to check.\n *\n * @returns `true` if `repeatable` contains at least one item, `false`\n * otherwise.\n */\nexport const repeatable = <T extends LinkField>(\n\trepeatable: Repeatable<T> | null | undefined,\n): repeatable is Repeatable<T, \"filled\"> => {\n\treturn isNonNullish(repeatable) && isNonEmptyArray(repeatable)\n}\n\n/**\n * Determines if a Group has at least one item.\n *\n * @param group - Group to check.\n *\n * @returns `true` if `group` contains at least one item, `false` otherwise.\n */\nexport const group = <\n\tFields extends Record<string, AnyRegularField | NestedGroupField>,\n>(\n\tgroup: GroupField<Fields> | null | undefined,\n): group is GroupField<Fields, \"filled\"> => {\n\treturn isNonNullish(group) && isNonEmptyArray(group)\n}\n\n/**\n * Determines if a Slice Zone has at least one Slice.\n *\n * @param slices - Slice Zone to check.\n *\n * @returns `true` if `slices` contains at least one Slice, `false` otherwise.\n */\nexport const sliceZone = <Slices extends Slice | SharedSlice>(\n\tslices: SliceZone<Slices> | null | undefined,\n): slices is SliceZone<Slices, \"filled\"> => {\n\treturn isNonNullish(slices) && isNonEmptyArray(slices)\n}\n"],"names":["repeatable","group"],"mappings":";;AA8BA,MAAM,eAAe,CAAI,UAAqC;AAC7D,SAAO,SAAS;AACjB;AAUA,MAAM,kBAAkB,CAAI,UAAoC;AACxD,SAAA,CAAC,CAAC,MAAM;AAChB;AASa,MAAA,WAAW,CACvB,UACqC;AACjC,MAAA,CAAC,aAAa,KAAK,GAAG;AAClB,WAAA;AAAA,EAAA,WACG,MAAM,WAAW,KAAK,UAAU,MAAM,CAAC,GAAG;AACpD,WAAO,CAAC,CAAC,MAAM,CAAC,EAAE;AAAA,EAAA,OACZ;AACC,WAAA,CAAC,CAAC,MAAM;AAAA,EAAA;AAEjB;AASO,MAAM,QAAQ;AAWR,MAAA,iBAAiB,CAC7B,cAC2C;AAC3C,SAAO,aAAa,SAAS,KAAK,CAAC,CAAC,UAAU;AAC/C;AASO,MAAM,QAAQ;AAaR,MAAA,OAAO,CAOnB,UACoE;AACpE,SAAO,aAAa,KAAK,MAAM,QAAQ,SAAS,SAAS;AAC1D;AASO,MAAM,cAAc;AAWpB,MAAM,sBAAsB;AAyB5B,MAAM,OAAO;AAWb,MAAM,YAAY;AAWlB,MAAM,QAAQ;AAWd,MAAM,SAAS;AAWT,MAAA,UAAU,CACtB,UACoC;AACpC,SAAO,aAAa,OAAO,KAAK,CAAC,CAAC;AACnC;AASO,MAAM,SAAS;AAWT,MAAA,QAAQ,CACpB,UAC6D;AAC7D,SAAO,aAAa,KAAK,KAAK,CAAC,CAAC,MAAM;AACvC;AASa,MAAA,WAAW,CACvB,UACqC;AAC9B,SAAA,aAAa,KAAK,KAAK,eAAe;AAC9C;AASO,MAAM,QAAQ;AAWd,MAAM,mBAAmB;AASzB,MAAM,oBAAoB;AAUpB,MAAA,aAAa,CACzBA,gBAC0C;AAC1C,SAAO,aAAaA,WAAU,KAAK,gBAAgBA,WAAU;AAC9D;AASa,MAAA,QAAQ,CAGpBC,WAC0C;AAC1C,SAAO,aAAaA,MAAK,KAAK,gBAAgBA,MAAK;AACpD;AASa,MAAA,YAAY,CACxB,WAC0C;AAC1C,SAAO,aAAa,MAAM,KAAK,gBAAgB,MAAM;AACtD;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isFilled.js","sources":["../../../src/helpers/isFilled.ts"],"sourcesContent":["import type { ColorField } from \"../types/value/color\"\nimport type { ContentRelationshipField } from \"../types/value/contentRelationship\"\nimport type { DateField } from \"../types/value/date\"\nimport type { AnyOEmbed, EmbedField } from \"../types/value/embed\"\nimport type { GeoPointField } from \"../types/value/geoPoint\"\nimport type { GroupField, NestedGroupField } from \"../types/value/group\"\nimport type { ImageField, ImageFieldImage } from \"../types/value/image\"\nimport type { IntegrationField } from \"../types/value/integration\"\nimport type { KeyTextField } from \"../types/value/keyText\"\nimport type { LinkField } from \"../types/value/link\"\nimport type { LinkToMediaField } from \"../types/value/linkToMedia\"\nimport type { NumberField } from \"../types/value/number\"\nimport type { RichTextField } from \"../types/value/richText\"\nimport type { SelectField } from \"../types/value/select\"\nimport type { SharedSlice } from \"../types/value/sharedSlice\"\nimport type { Slice } from \"../types/value/slice\"\nimport type { SliceZone } from \"../types/value/sliceZone\"\nimport type { TableField } from \"../types/value/table\"\nimport type { TimestampField } from \"../types/value/timestamp\"\nimport type { TitleField } from \"../types/value/title\"\nimport type { AnyRegularField, Repeatable } from \"../types/value/types\"\n\n/**\n * Determines if a value is not nullish (i.e. not `null` or `undefined`). This\n * is used to check if nullable field values are filled.\n *\n * @param input - The value to check.\n *\n * @returns `true` if `input` is not nullish, `false` otherwise.\n */\nconst isNonNullish = <T>(input: T): input is NonNullable<T> => {\n\treturn input != null\n}\n\n/**\n * Determines if an array is not empty. This is used to check if array-based\n * fields are filled.\n *\n * @param input - The array to check.\n *\n * @returns `true` if `input` has at least one element, `false` otherwise.\n */\nconst isNonEmptyArray = <T>(input: T[]): input is [T, ...T[]] => {\n\treturn !!input.length\n}\n\n/**\n * Determines if a rich text field is filled.\n *\n * @param field - rich text field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const richText = (\n\tfield: RichTextField | null | undefined,\n): field is RichTextField<\"filled\"> => {\n\tif (!isNonNullish(field)) {\n\t\treturn false\n\t} else if (field.length === 1 && \"text\" in field[0]) {\n\t\treturn !!field[0].text\n\t} else {\n\t\treturn !!field.length\n\t}\n}\n\n/**\n * Determines if a title field is filled.\n *\n * @param field - Title field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const title = richText as (\n\tfield: TitleField | null | undefined,\n) => field is TitleField<\"filled\">\n\n/**\n * Determines if an Image thumbnail is filled.\n *\n * @param thumbnail - Image thumbnail to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const imageThumbnail = (\n\tthumbnail: ImageFieldImage | null | undefined,\n): thumbnail is ImageFieldImage<\"filled\"> => {\n\treturn isNonNullish(thumbnail) && !!thumbnail.url\n}\n\n/**\n * Determines if an image field is filled.\n *\n * @param field - Image field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const image = imageThumbnail as <\n\tThumbnailNames extends string | null = never,\n>(\n\tfield: ImageField<ThumbnailNames> | null | undefined,\n) => field is ImageField<ThumbnailNames, \"filled\">\n\n/**\n * Determines if a link field is filled.\n *\n * @param field - Link field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const link = <\n\tTypeEnum = string,\n\tLangEnum = string,\n\tDataInterface extends\n\t\t| Record<string, AnyRegularField | GroupField | SliceZone>\n\t\t| unknown = unknown,\n>(\n\tfield: LinkField<TypeEnum, LangEnum, DataInterface> | null | undefined,\n): field is LinkField<TypeEnum, LangEnum, DataInterface, \"filled\"> => {\n\treturn isNonNullish(field) && (\"id\" in field || \"url\" in field)\n}\n\n/**\n * Determines if a link to media field is filled.\n *\n * @param field - Link to media field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const linkToMedia = link as (\n\tfield: LinkToMediaField | null | undefined,\n) => field is LinkToMediaField<\"filled\">\n\n/**\n * Determines if a content relationship field is filled.\n *\n * @param field - Content Relationship field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const contentRelationship = link as <\n\tTypeEnum = string,\n\tLangEnum = string,\n\tDataInterface extends\n\t\t| Record<string, AnyRegularField | GroupField | SliceZone>\n\t\t| unknown = unknown,\n>(\n\tfield:\n\t\t| ContentRelationshipField<TypeEnum, LangEnum, DataInterface>\n\t\t| null\n\t\t| undefined,\n) => field is ContentRelationshipField<\n\tTypeEnum,\n\tLangEnum,\n\tDataInterface,\n\t\"filled\"\n>\n\n/**\n * Determines if a date field is filled.\n *\n * @param field - Date field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const date = isNonNullish as (\n\tfield: DateField | null | undefined,\n) => field is DateField<\"filled\">\n\n/**\n * Determines if a timestamp field is filled.\n *\n * @param field - Timestamp field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const timestamp = isNonNullish as (\n\tfield: TimestampField | null | undefined,\n) => field is TimestampField<\"filled\">\n\n/**\n * Determines if a color field is filled.\n *\n * @param field - Color field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const color = isNonNullish as (\n\tfield: ColorField | null | undefined,\n) => field is ColorField<\"filled\">\n\n/**\n * Determines if a number field is filled.\n *\n * @param field - Number field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const number = isNonNullish as (\n\tfield: NumberField | null | undefined,\n) => field is NumberField<\"filled\">\n\n/**\n * Determines if a key text field is filled.\n *\n * @param field - Key Text field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const keyText = (\n\tfield: KeyTextField | null | undefined,\n): field is KeyTextField<\"filled\"> => {\n\treturn isNonNullish(keyText) && !!field\n}\n\n/**\n * Determines if a select field is filled.\n *\n * @param field - Select field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const select = isNonNullish as <Enum extends string>(\n\tfield: SelectField<Enum> | null | undefined,\n) => field is SelectField<Enum, \"filled\">\n\n/**\n * Determines if an embed field is filled.\n *\n * @param field - Embed field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const embed = <Field extends EmbedField<AnyOEmbed>>(\n\tfield: Field | null | undefined,\n): field is Extract<Field, EmbedField<AnyOEmbed, \"filled\">> => {\n\treturn isNonNullish(field) && !!field.embed_url\n}\n\n/**\n * Determines if a geopoint field is filled.\n *\n * @param field - GeoPoint field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const geoPoint = (\n\tfield: GeoPointField | null | undefined,\n): field is GeoPointField<\"filled\"> => {\n\treturn isNonNullish(field) && \"longitude\" in field\n}\n\n/**\n * Determines if a table field is filled.\n *\n * @param field - Table field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const table = isNonNullish as (\n\tfield: TableField | null | undefined,\n) => field is TableField<\"filled\">\n\n/**\n * Determines if an integration field is filled.\n *\n * @param field - Integration field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const integrationField = isNonNullish as <\n\tData extends Record<string, unknown>,\n>(\n\tfield: IntegrationField<Data> | null | undefined,\n) => field is IntegrationField<Data, \"filled\">\n/**\n * @deprecated Renamed to `integrationField`.\n */\n// TODO: Remove when we remove support for deprecated `integrationFields` export.\nexport const integrationFields = integrationField\n\n/**\n * Determines if a repeatable field has at least one item.\n *\n * @param repeatable - Repeatable to check.\n *\n * @returns `true` if `repeatable` contains at least one item, `false`\n * otherwise.\n */\nexport const repeatable = <T extends LinkField>(\n\trepeatable: Repeatable<T> | null | undefined,\n): repeatable is Repeatable<T, \"filled\"> => {\n\treturn isNonNullish(repeatable) && isNonEmptyArray(repeatable)\n}\n\n/**\n * Determines if a Group has at least one item.\n *\n * @param group - Group to check.\n *\n * @returns `true` if `group` contains at least one item, `false` otherwise.\n */\nexport const group = <\n\tFields extends Record<string, AnyRegularField | NestedGroupField>,\n>(\n\tgroup: GroupField<Fields> | null | undefined,\n): group is GroupField<Fields, \"filled\"> => {\n\treturn isNonNullish(group) && isNonEmptyArray(group)\n}\n\n/**\n * Determines if a Slice Zone has at least one Slice.\n *\n * @param slices - Slice Zone to check.\n *\n * @returns `true` if `slices` contains at least one Slice, `false` otherwise.\n */\nexport const sliceZone = <Slices extends Slice | SharedSlice>(\n\tslices: SliceZone<Slices> | null | undefined,\n): slices is SliceZone<Slices, \"filled\"> => {\n\treturn isNonNullish(slices) && isNonEmptyArray(slices)\n}\n"],"names":["repeatable","group"],"mappings":"AA8BA,MAAM,eAAe,CAAI,UAAqC;AAC7D,SAAO,SAAS;AACjB;AAUA,MAAM,kBAAkB,CAAI,UAAoC;AACxD,SAAA,CAAC,CAAC,MAAM;AAChB;AASa,MAAA,WAAW,CACvB,UACqC;AACjC,MAAA,CAAC,aAAa,KAAK,GAAG;AAClB,WAAA;AAAA,EAAA,WACG,MAAM,WAAW,KAAK,UAAU,MAAM,CAAC,GAAG;AACpD,WAAO,CAAC,CAAC,MAAM,CAAC,EAAE;AAAA,EAAA,OACZ;AACC,WAAA,CAAC,CAAC,MAAM;AAAA,EAChB;AACD;AASO,MAAM,QAAQ;AAWR,MAAA,iBAAiB,CAC7B,cAC2C;AAC3C,SAAO,aAAa,SAAS,KAAK,CAAC,CAAC,UAAU;AAC/C;AASO,MAAM,QAAQ;AAaR,MAAA,OAAO,CAOnB,UACoE;AACpE,SAAO,aAAa,KAAK,MAAM,QAAQ,SAAS,SAAS;AAC1D;AASO,MAAM,cAAc;AAWpB,MAAM,sBAAsB;AAyB5B,MAAM,OAAO;AAWb,MAAM,YAAY;AAWlB,MAAM,QAAQ;AAWd,MAAM,SAAS;AAWT,MAAA,UAAU,CACtB,UACoC;AACpC,SAAO,aAAa,OAAO,KAAK,CAAC,CAAC;AACnC;AASO,MAAM,SAAS;AAWT,MAAA,QAAQ,CACpB,UAC6D;AAC7D,SAAO,aAAa,KAAK,KAAK,CAAC,CAAC,MAAM;AACvC;AASa,MAAA,WAAW,CACvB,UACqC;AAC9B,SAAA,aAAa,KAAK,KAAK,eAAe;AAC9C;AASO,MAAM,QAAQ;AAWd,MAAM,mBAAmB;AASzB,MAAM,oBAAoB;AAUpB,MAAA,aAAa,CACzBA,gBAC0C;AAC1C,SAAO,aAAaA,WAAU,KAAK,gBAAgBA,WAAU;AAC9D;AASa,MAAA,QAAQ,CAGpBC,WAC0C;AAC1C,SAAO,aAAaA,MAAK,KAAK,gBAAgBA,MAAK;AACpD;AASa,MAAA,YAAY,CACxB,WAC0C;AAC1C,SAAO,aAAa,MAAM,KAAK,gBAAgB,MAAM;AACtD;"}
|
|
1
|
+
{"version":3,"file":"isFilled.js","sources":["../../../src/helpers/isFilled.ts"],"sourcesContent":["import type { ColorField } from \"../types/value/color\"\nimport type { ContentRelationshipField } from \"../types/value/contentRelationship\"\nimport type { DateField } from \"../types/value/date\"\nimport type { AnyOEmbed, EmbedField } from \"../types/value/embed\"\nimport type { GeoPointField } from \"../types/value/geoPoint\"\nimport type { GroupField, NestedGroupField } from \"../types/value/group\"\nimport type { ImageField, ImageFieldImage } from \"../types/value/image\"\nimport type { IntegrationField } from \"../types/value/integration\"\nimport type { KeyTextField } from \"../types/value/keyText\"\nimport type { LinkField } from \"../types/value/link\"\nimport type { LinkToMediaField } from \"../types/value/linkToMedia\"\nimport type { NumberField } from \"../types/value/number\"\nimport type { RichTextField } from \"../types/value/richText\"\nimport type { SelectField } from \"../types/value/select\"\nimport type { SharedSlice } from \"../types/value/sharedSlice\"\nimport type { Slice } from \"../types/value/slice\"\nimport type { SliceZone } from \"../types/value/sliceZone\"\nimport type { TableField } from \"../types/value/table\"\nimport type { TimestampField } from \"../types/value/timestamp\"\nimport type { TitleField } from \"../types/value/title\"\nimport type { AnyRegularField, Repeatable } from \"../types/value/types\"\n\n/**\n * Determines if a value is not nullish (i.e. not `null` or `undefined`). This\n * is used to check if nullable field values are filled.\n *\n * @param input - The value to check.\n *\n * @returns `true` if `input` is not nullish, `false` otherwise.\n */\nconst isNonNullish = <T>(input: T): input is NonNullable<T> => {\n\treturn input != null\n}\n\n/**\n * Determines if an array is not empty. This is used to check if array-based\n * fields are filled.\n *\n * @param input - The array to check.\n *\n * @returns `true` if `input` has at least one element, `false` otherwise.\n */\nconst isNonEmptyArray = <T>(input: T[]): input is [T, ...T[]] => {\n\treturn !!input.length\n}\n\n/**\n * Determines if a rich text field is filled.\n *\n * @param field - rich text field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const richText = (\n\tfield: RichTextField | null | undefined,\n): field is RichTextField<\"filled\"> => {\n\tif (!isNonNullish(field)) {\n\t\treturn false\n\t} else if (field.length === 1 && \"text\" in field[0]) {\n\t\treturn !!field[0].text\n\t} else {\n\t\treturn !!field.length\n\t}\n}\n\n/**\n * Determines if a title field is filled.\n *\n * @param field - Title field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const title = richText as (\n\tfield: TitleField | null | undefined,\n) => field is TitleField<\"filled\">\n\n/**\n * Determines if an Image thumbnail is filled.\n *\n * @param thumbnail - Image thumbnail to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const imageThumbnail = (\n\tthumbnail: ImageFieldImage | null | undefined,\n): thumbnail is ImageFieldImage<\"filled\"> => {\n\treturn isNonNullish(thumbnail) && !!thumbnail.url\n}\n\n/**\n * Determines if an image field is filled.\n *\n * @param field - Image field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const image = imageThumbnail as <\n\tThumbnailNames extends string | null = never,\n>(\n\tfield: ImageField<ThumbnailNames> | null | undefined,\n) => field is ImageField<ThumbnailNames, \"filled\">\n\n/**\n * Determines if a link field is filled.\n *\n * @param field - Link field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const link = <\n\tTypeEnum = string,\n\tLangEnum = string,\n\tDataInterface extends\n\t\t| Record<string, AnyRegularField | GroupField | SliceZone>\n\t\t| unknown = unknown,\n>(\n\tfield: LinkField<TypeEnum, LangEnum, DataInterface> | null | undefined,\n): field is LinkField<TypeEnum, LangEnum, DataInterface, \"filled\"> => {\n\treturn isNonNullish(field) && (\"id\" in field || \"url\" in field)\n}\n\n/**\n * Determines if a link to media field is filled.\n *\n * @param field - Link to media field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const linkToMedia = link as (\n\tfield: LinkToMediaField | null | undefined,\n) => field is LinkToMediaField<\"filled\">\n\n/**\n * Determines if a content relationship field is filled.\n *\n * @param field - Content Relationship field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const contentRelationship = link as <\n\tTypeEnum = string,\n\tLangEnum = string,\n\tDataInterface extends\n\t\t| Record<string, AnyRegularField | GroupField | SliceZone>\n\t\t| unknown = unknown,\n>(\n\tfield:\n\t\t| ContentRelationshipField<TypeEnum, LangEnum, DataInterface>\n\t\t| null\n\t\t| undefined,\n) => field is ContentRelationshipField<\n\tTypeEnum,\n\tLangEnum,\n\tDataInterface,\n\t\"filled\"\n>\n\n/**\n * Determines if a date field is filled.\n *\n * @param field - Date field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const date = isNonNullish as (\n\tfield: DateField | null | undefined,\n) => field is DateField<\"filled\">\n\n/**\n * Determines if a timestamp field is filled.\n *\n * @param field - Timestamp field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const timestamp = isNonNullish as (\n\tfield: TimestampField | null | undefined,\n) => field is TimestampField<\"filled\">\n\n/**\n * Determines if a color field is filled.\n *\n * @param field - Color field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const color = isNonNullish as (\n\tfield: ColorField | null | undefined,\n) => field is ColorField<\"filled\">\n\n/**\n * Determines if a number field is filled.\n *\n * @param field - Number field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const number = isNonNullish as (\n\tfield: NumberField | null | undefined,\n) => field is NumberField<\"filled\">\n\n/**\n * Determines if a key text field is filled.\n *\n * @param field - Key Text field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const keyText = (\n\tfield: KeyTextField | null | undefined,\n): field is KeyTextField<\"filled\"> => {\n\treturn isNonNullish(keyText) && !!field\n}\n\n/**\n * Determines if a select field is filled.\n *\n * @param field - Select field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const select = isNonNullish as <Enum extends string>(\n\tfield: SelectField<Enum> | null | undefined,\n) => field is SelectField<Enum, \"filled\">\n\n/**\n * Determines if an embed field is filled.\n *\n * @param field - Embed field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const embed = <Field extends EmbedField<AnyOEmbed>>(\n\tfield: Field | null | undefined,\n): field is Extract<Field, EmbedField<AnyOEmbed, \"filled\">> => {\n\treturn isNonNullish(field) && !!field.embed_url\n}\n\n/**\n * Determines if a geopoint field is filled.\n *\n * @param field - GeoPoint field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const geoPoint = (\n\tfield: GeoPointField | null | undefined,\n): field is GeoPointField<\"filled\"> => {\n\treturn isNonNullish(field) && \"longitude\" in field\n}\n\n/**\n * Determines if a table field is filled.\n *\n * @param field - Table field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const table = isNonNullish as (\n\tfield: TableField | null | undefined,\n) => field is TableField<\"filled\">\n\n/**\n * Determines if an integration field is filled.\n *\n * @param field - Integration field to check.\n *\n * @returns `true` if `field` is filled, `false` otherwise.\n */\nexport const integrationField = isNonNullish as <\n\tData extends Record<string, unknown>,\n>(\n\tfield: IntegrationField<Data> | null | undefined,\n) => field is IntegrationField<Data, \"filled\">\n/**\n * @deprecated Renamed to `integrationField`.\n */\n// TODO: Remove when we remove support for deprecated `integrationFields` export.\nexport const integrationFields = integrationField\n\n/**\n * Determines if a repeatable field has at least one item.\n *\n * @param repeatable - Repeatable to check.\n *\n * @returns `true` if `repeatable` contains at least one item, `false`\n * otherwise.\n */\nexport const repeatable = <T extends LinkField>(\n\trepeatable: Repeatable<T> | null | undefined,\n): repeatable is Repeatable<T, \"filled\"> => {\n\treturn isNonNullish(repeatable) && isNonEmptyArray(repeatable)\n}\n\n/**\n * Determines if a Group has at least one item.\n *\n * @param group - Group to check.\n *\n * @returns `true` if `group` contains at least one item, `false` otherwise.\n */\nexport const group = <\n\tFields extends Record<string, AnyRegularField | NestedGroupField>,\n>(\n\tgroup: GroupField<Fields> | null | undefined,\n): group is GroupField<Fields, \"filled\"> => {\n\treturn isNonNullish(group) && isNonEmptyArray(group)\n}\n\n/**\n * Determines if a Slice Zone has at least one Slice.\n *\n * @param slices - Slice Zone to check.\n *\n * @returns `true` if `slices` contains at least one Slice, `false` otherwise.\n */\nexport const sliceZone = <Slices extends Slice | SharedSlice>(\n\tslices: SliceZone<Slices> | null | undefined,\n): slices is SliceZone<Slices, \"filled\"> => {\n\treturn isNonNullish(slices) && isNonEmptyArray(slices)\n}\n"],"names":["repeatable","group"],"mappings":"AA8BA,MAAM,eAAe,CAAI,UAAqC;AAC7D,SAAO,SAAS;AACjB;AAUA,MAAM,kBAAkB,CAAI,UAAoC;AACxD,SAAA,CAAC,CAAC,MAAM;AAChB;AASa,MAAA,WAAW,CACvB,UACqC;AACjC,MAAA,CAAC,aAAa,KAAK,GAAG;AAClB,WAAA;AAAA,EAAA,WACG,MAAM,WAAW,KAAK,UAAU,MAAM,CAAC,GAAG;AACpD,WAAO,CAAC,CAAC,MAAM,CAAC,EAAE;AAAA,EAAA,OACZ;AACC,WAAA,CAAC,CAAC,MAAM;AAAA,EAAA;AAEjB;AASO,MAAM,QAAQ;AAWR,MAAA,iBAAiB,CAC7B,cAC2C;AAC3C,SAAO,aAAa,SAAS,KAAK,CAAC,CAAC,UAAU;AAC/C;AASO,MAAM,QAAQ;AAaR,MAAA,OAAO,CAOnB,UACoE;AACpE,SAAO,aAAa,KAAK,MAAM,QAAQ,SAAS,SAAS;AAC1D;AASO,MAAM,cAAc;AAWpB,MAAM,sBAAsB;AAyB5B,MAAM,OAAO;AAWb,MAAM,YAAY;AAWlB,MAAM,QAAQ;AAWd,MAAM,SAAS;AAWT,MAAA,UAAU,CACtB,UACoC;AACpC,SAAO,aAAa,OAAO,KAAK,CAAC,CAAC;AACnC;AASO,MAAM,SAAS;AAWT,MAAA,QAAQ,CACpB,UAC6D;AAC7D,SAAO,aAAa,KAAK,KAAK,CAAC,CAAC,MAAM;AACvC;AASa,MAAA,WAAW,CACvB,UACqC;AAC9B,SAAA,aAAa,KAAK,KAAK,eAAe;AAC9C;AASO,MAAM,QAAQ;AAWd,MAAM,mBAAmB;AASzB,MAAM,oBAAoB;AAUpB,MAAA,aAAa,CACzBA,gBAC0C;AAC1C,SAAO,aAAaA,WAAU,KAAK,gBAAgBA,WAAU;AAC9D;AASa,MAAA,QAAQ,CAGpBC,WAC0C;AAC1C,SAAO,aAAaA,MAAK,KAAK,gBAAgBA,MAAK;AACpD;AASa,MAAA,YAAY,CACxB,WAC0C;AAC1C,SAAO,aAAa,MAAM,KAAK,gBAAgB,MAAM;AACtD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapSliceZone.cjs","sources":["../../../src/helpers/mapSliceZone.ts"],"sourcesContent":["import type { Slice } from \"../types/value/slice\"\n\n/**\n * Convert a value to a lazyily loaded module. This is useful when using\n * functions like `() => import(\"...\")`.\n */\ntype LazyModule<T> = () => Promise<T | { default: T }>\n\n/**\n * Mark a type as potentially lazy-loaded via a module.\n */\ntype MaybeLazyModule<T> = T | LazyModule<T>\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyFunction = (...args: any[]) => any\n\n/**\n * Returns the type of a `SliceLike` type.\n *\n * @typeParam Slice - The Slice from which the type will be extracted.\n */\ntype ExtractSliceType<TSlice extends SliceLike> = TSlice extends SliceLikeRestV2\n\t? TSlice[\"slice_type\"]\n\t: TSlice extends SliceLikeGraphQL\n\t\t? TSlice[\"type\"]\n\t\t: never\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * Rest API V2 for the `mapSliceZone()` helper.\n *\n * @typeParam SliceType - Type name of the Slice.\n */\ntype SliceLikeRestV2<TSliceType extends string = string> = Pick<\n\tSlice<TSliceType>,\n\t\"id\" | \"slice_type\"\n>\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * GraphQL API for the `mapSliceZone()` helper.\n *\n * @typeParam SliceType - Type name of the Slice.\n */\ntype SliceLikeGraphQL<TSliceType extends string = string> = {\n\ttype: Slice<TSliceType>[\"slice_type\"]\n}\n\n/**\n * The minimum required properties to represent a Prismic Slice for the\n * `mapSliceZone()` helper.\n *\n * If using Prismic's Rest API V2, use the `Slice` export from\n * `@prismicio/client` for a full interface.\n *\n * @typeParam SliceType - Type name of the Slice.\n */\ntype SliceLike<TSliceType extends string = string> =\n\t| SliceLikeRestV2<TSliceType>\n\t| SliceLikeGraphQL<TSliceType>\n\n/**\n * A looser version of the `SliceZone` type from `@prismicio/client` using\n * `SliceLike`.\n *\n * If using Prismic's Rest API V2, use the `SliceZone` export from\n * `@prismicio/client` for the full type.\n *\n * @typeParam TSlice - The type(s) of a Slice in the Slice Zone.\n */\ntype SliceZoneLike<TSlice extends SliceLike = SliceLike> = readonly TSlice[]\n\n/**\n * A set of properties that identify a Slice as having been mapped. Consumers of\n * the mapped Slice Zone can use these properties to detect and specially handle\n * mapped Slices.\n */\ntype MappedSliceLike = {\n\t/**\n\t * If `true`, this Slice has been modified from its original value using a\n\t * mapper.\n\t *\n\t * @internal\n\t */\n\t__mapped: true\n}\n\n/**\n * Arguments for a function mapping content from a Prismic Slice using the\n * `mapSliceZone()` helper.\n *\n * @typeParam TSlice - The Slice passed as a prop.\n * @typeParam TContext - Arbitrary data passed to `mapSliceZone()` and made\n * available to all Slice mappers.\n */\ntype SliceMapperArgs<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> = {\n\t/**\n\t * Slice data.\n\t */\n\tslice: TSlice\n\n\t/**\n\t * The index of the Slice in the Slice Zone.\n\t */\n\tindex: number\n\n\t/**\n\t * All Slices from the Slice Zone to which the Slice belongs.\n\t */\n\t// TODO: We have to keep this list of Slices general due to circular\n\t// reference limtiations. If we had another generic to determine the full\n\t// union of Slice types, it would include TSlice. This causes TypeScript to\n\t// throw a compilation error.\n\tslices: SliceZoneLike<\n\t\tTSlice extends SliceLikeGraphQL ? SliceLikeGraphQL : SliceLikeRestV2\n\t>\n\n\t/**\n\t * Arbitrary data passed to `mapSliceZone()` and made available to all Slice\n\t * mappers.\n\t */\n\tcontext: TContext\n}\n\n/**\n * A record of mappers.\n */\ntype SliceMappers<TSlice extends SliceLike = SliceLike, TContext = unknown> = {\n\t[P in ExtractSliceType<TSlice>]?: MaybeLazyModule<\n\t\tSliceMapper<\n\t\t\tExtract<TSlice, SliceLike<P>>,\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\tany,\n\t\t\tTContext\n\t\t>\n\t>\n}\n\n/**\n * A function that maps a Slice and its metadata to a modified version. The\n * return value will replace the Slice in the Slice Zone.\n */\nexport type SliceMapper<\n\tTSlice extends SliceLike = SliceLike,\n\tTMappedSlice extends Record<string, unknown> | undefined | void =\n\t\t| Record<string, unknown>\n\t\t| undefined\n\t\t| void,\n\tTContext = unknown,\n> = (\n\targs: SliceMapperArgs<TSlice, TContext>,\n) => TMappedSlice | Promise<TMappedSlice>\n\n/**\n * Unwraps a lazily loaded mapper module.\n */\ntype ResolveLazySliceMapperModule<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSliceMapper extends SliceMapper<any, any> | LazyModule<SliceMapper>,\n> =\n\tTSliceMapper extends LazyModule<SliceMapper>\n\t\t? Awaited<ReturnType<TSliceMapper>> extends {\n\t\t\t\tdefault: unknown\n\t\t\t}\n\t\t\t? Awaited<ReturnType<TSliceMapper>>[\"default\"]\n\t\t\t: Awaited<ReturnType<TSliceMapper>>\n\t\t: TSliceMapper\n\n/**\n * Transforms a Slice into its mapped version.\n */\ntype MapSliceLike<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSliceLike extends SliceLike<any>,\n\tTSliceMappers extends SliceMappers<\n\t\tTSliceLike,\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tany\n\t>,\n> = TSliceLike extends Slice\n\t? TSliceLike[\"slice_type\"] extends keyof TSliceMappers\n\t\t? TSliceMappers[TSliceLike[\"slice_type\"]] extends AnyFunction\n\t\t\t? SliceLikeRestV2<TSliceLike[\"slice_type\"]> &\n\t\t\t\t\tMappedSliceLike &\n\t\t\t\t\tAwaited<\n\t\t\t\t\t\tReturnType<\n\t\t\t\t\t\t\tResolveLazySliceMapperModule<\n\t\t\t\t\t\t\t\tTSliceMappers[TSliceLike[\"slice_type\"]]\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t>\n\t\t\t\t\t>\n\t\t\t: TSliceLike\n\t\t: TSliceLike\n\t: TSliceLike extends SliceLikeGraphQL\n\t\t? TSliceLike[\"type\"] extends keyof TSliceMappers\n\t\t\t? TSliceMappers[TSliceLike[\"type\"]] extends AnyFunction\n\t\t\t\t? SliceLikeGraphQL<TSliceLike[\"type\"]> &\n\t\t\t\t\t\tMappedSliceLike &\n\t\t\t\t\t\tAwaited<\n\t\t\t\t\t\t\tReturnType<\n\t\t\t\t\t\t\t\tResolveLazySliceMapperModule<TSliceMappers[TSliceLike[\"type\"]]>\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t>\n\t\t\t\t: TSliceLike\n\t\t\t: TSliceLike\n\t\t: never\n\n/**\n * Transforms a Slice Zone using a set of mapping functions, one for each type\n * of Slice. Mapping functions can be async.\n *\n * Whenever possible, use this function on the server to minimize client-side\n * processing.\n *\n * @example\n *\n * ```typescript\n * const mappedSliceZone = await mapSliceZone(page.data.slices, {\n * \tcode_block: ({ slice }) => ({\n * \t\tcodeHTML: await highlight(slice.primary.code),\n * \t}),\n * });\n * ```\n */\nexport function mapSliceZone<\n\tTSliceLike extends SliceLike,\n\tTSliceMappers extends SliceMappers<TSliceLike, TContext>,\n\tTContext = unknown,\n>(\n\tsliceZone: SliceZoneLike<TSliceLike>,\n\tmappers: TSliceMappers,\n\tcontext?: TContext,\n): Promise<MapSliceLike<TSliceLike, TSliceMappers>[]> {\n\treturn Promise.all(\n\t\tsliceZone.map(async (slice, index, slices) => {\n\t\t\tconst isRestSliceType = \"slice_type\" in slice\n\t\t\tconst sliceType = isRestSliceType ? slice.slice_type : slice.type\n\n\t\t\tconst mapper = mappers[sliceType as keyof typeof mappers]\n\n\t\t\tif (!mapper) {\n\t\t\t\treturn slice\n\t\t\t}\n\n\t\t\tconst mapperArgs = { slice, slices, index, context }\n\n\t\t\t// `result` may be a mapper function OR a module\n\t\t\t// containing a mapper function.\n\t\t\tlet result = await mapper(\n\t\t\t\t// @ts-expect-error - I don't know how to fix this type\n\t\t\t\tmapperArgs,\n\t\t\t)\n\n\t\t\t// `result` is a module containing a mapper function,\n\t\t\t// we need to dig out the mapper function. `result`\n\t\t\t// will be reassigned with the mapper function's value.\n\t\t\tif (\n\t\t\t\t// `mapper.length < 1` ensures the given\n\t\t\t\t// function is something of the form:\n\t\t\t\t// `() => import(...)`\n\t\t\t\tmapper.length < 1 &&\n\t\t\t\t(typeof result === \"function\" ||\n\t\t\t\t\t(typeof result === \"object\" && \"default\" in result))\n\t\t\t) {\n\t\t\t\tresult = \"default\" in result ? result.default : result\n\t\t\t\tresult = await result(mapperArgs)\n\t\t\t}\n\n\t\t\tif (isRestSliceType) {\n\t\t\t\treturn {\n\t\t\t\t\t__mapped: true,\n\t\t\t\t\tid: slice.id,\n\t\t\t\t\tslice_type: sliceType,\n\t\t\t\t\t...result,\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn {\n\t\t\t\t\t__mapped: true,\n\t\t\t\t\ttype: sliceType,\n\t\t\t\t\t...result,\n\t\t\t\t}\n\t\t\t}\n\t\t}),\n\t)\n}\n"],"names":[],"mappings":";;AAmOgB,SAAA,aAKf,WACA,SACA,SAAkB;AAElB,SAAO,QAAQ,IACd,UAAU,IAAI,OAAO,OAAO,OAAO,WAAU;AAC5C,UAAM,kBAAkB,gBAAgB;AACxC,UAAM,YAAY,kBAAkB,MAAM,aAAa,MAAM;AAEvD,UAAA,SAAS,QAAQ,SAAiC;AAExD,QAAI,CAAC,QAAQ;AACL,aAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"mapSliceZone.cjs","sources":["../../../src/helpers/mapSliceZone.ts"],"sourcesContent":["import type { Slice } from \"../types/value/slice\"\n\n/**\n * Convert a value to a lazyily loaded module. This is useful when using\n * functions like `() => import(\"...\")`.\n */\ntype LazyModule<T> = () => Promise<T | { default: T }>\n\n/**\n * Mark a type as potentially lazy-loaded via a module.\n */\ntype MaybeLazyModule<T> = T | LazyModule<T>\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyFunction = (...args: any[]) => any\n\n/**\n * Returns the type of a `SliceLike` type.\n *\n * @typeParam Slice - The Slice from which the type will be extracted.\n */\ntype ExtractSliceType<TSlice extends SliceLike> = TSlice extends SliceLikeRestV2\n\t? TSlice[\"slice_type\"]\n\t: TSlice extends SliceLikeGraphQL\n\t\t? TSlice[\"type\"]\n\t\t: never\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * Rest API V2 for the `mapSliceZone()` helper.\n *\n * @typeParam SliceType - Type name of the Slice.\n */\ntype SliceLikeRestV2<TSliceType extends string = string> = Pick<\n\tSlice<TSliceType>,\n\t\"id\" | \"slice_type\"\n>\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * GraphQL API for the `mapSliceZone()` helper.\n *\n * @typeParam SliceType - Type name of the Slice.\n */\ntype SliceLikeGraphQL<TSliceType extends string = string> = {\n\ttype: Slice<TSliceType>[\"slice_type\"]\n}\n\n/**\n * The minimum required properties to represent a Prismic Slice for the\n * `mapSliceZone()` helper.\n *\n * If using Prismic's Rest API V2, use the `Slice` export from\n * `@prismicio/client` for a full interface.\n *\n * @typeParam SliceType - Type name of the Slice.\n */\ntype SliceLike<TSliceType extends string = string> =\n\t| SliceLikeRestV2<TSliceType>\n\t| SliceLikeGraphQL<TSliceType>\n\n/**\n * A looser version of the `SliceZone` type from `@prismicio/client` using\n * `SliceLike`.\n *\n * If using Prismic's Rest API V2, use the `SliceZone` export from\n * `@prismicio/client` for the full type.\n *\n * @typeParam TSlice - The type(s) of a Slice in the Slice Zone.\n */\ntype SliceZoneLike<TSlice extends SliceLike = SliceLike> = readonly TSlice[]\n\n/**\n * A set of properties that identify a Slice as having been mapped. Consumers of\n * the mapped Slice Zone can use these properties to detect and specially handle\n * mapped Slices.\n */\ntype MappedSliceLike = {\n\t/**\n\t * If `true`, this Slice has been modified from its original value using a\n\t * mapper.\n\t *\n\t * @internal\n\t */\n\t__mapped: true\n}\n\n/**\n * Arguments for a function mapping content from a Prismic Slice using the\n * `mapSliceZone()` helper.\n *\n * @typeParam TSlice - The Slice passed as a prop.\n * @typeParam TContext - Arbitrary data passed to `mapSliceZone()` and made\n * available to all Slice mappers.\n */\ntype SliceMapperArgs<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> = {\n\t/**\n\t * Slice data.\n\t */\n\tslice: TSlice\n\n\t/**\n\t * The index of the Slice in the Slice Zone.\n\t */\n\tindex: number\n\n\t/**\n\t * All Slices from the Slice Zone to which the Slice belongs.\n\t */\n\t// TODO: We have to keep this list of Slices general due to circular\n\t// reference limtiations. If we had another generic to determine the full\n\t// union of Slice types, it would include TSlice. This causes TypeScript to\n\t// throw a compilation error.\n\tslices: SliceZoneLike<\n\t\tTSlice extends SliceLikeGraphQL ? SliceLikeGraphQL : SliceLikeRestV2\n\t>\n\n\t/**\n\t * Arbitrary data passed to `mapSliceZone()` and made available to all Slice\n\t * mappers.\n\t */\n\tcontext: TContext\n}\n\n/**\n * A record of mappers.\n */\ntype SliceMappers<TSlice extends SliceLike = SliceLike, TContext = unknown> = {\n\t[P in ExtractSliceType<TSlice>]?: MaybeLazyModule<\n\t\tSliceMapper<\n\t\t\tExtract<TSlice, SliceLike<P>>,\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\tany,\n\t\t\tTContext\n\t\t>\n\t>\n}\n\n/**\n * A function that maps a Slice and its metadata to a modified version. The\n * return value will replace the Slice in the Slice Zone.\n */\nexport type SliceMapper<\n\tTSlice extends SliceLike = SliceLike,\n\tTMappedSlice extends Record<string, unknown> | undefined | void =\n\t\t| Record<string, unknown>\n\t\t| undefined\n\t\t| void,\n\tTContext = unknown,\n> = (\n\targs: SliceMapperArgs<TSlice, TContext>,\n) => TMappedSlice | Promise<TMappedSlice>\n\n/**\n * Unwraps a lazily loaded mapper module.\n */\ntype ResolveLazySliceMapperModule<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSliceMapper extends SliceMapper<any, any> | LazyModule<SliceMapper>,\n> =\n\tTSliceMapper extends LazyModule<SliceMapper>\n\t\t? Awaited<ReturnType<TSliceMapper>> extends {\n\t\t\t\tdefault: unknown\n\t\t\t}\n\t\t\t? Awaited<ReturnType<TSliceMapper>>[\"default\"]\n\t\t\t: Awaited<ReturnType<TSliceMapper>>\n\t\t: TSliceMapper\n\n/**\n * Transforms a Slice into its mapped version.\n */\ntype MapSliceLike<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSliceLike extends SliceLike<any>,\n\tTSliceMappers extends SliceMappers<\n\t\tTSliceLike,\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tany\n\t>,\n> = TSliceLike extends Slice\n\t? TSliceLike[\"slice_type\"] extends keyof TSliceMappers\n\t\t? TSliceMappers[TSliceLike[\"slice_type\"]] extends AnyFunction\n\t\t\t? SliceLikeRestV2<TSliceLike[\"slice_type\"]> &\n\t\t\t\t\tMappedSliceLike &\n\t\t\t\t\tAwaited<\n\t\t\t\t\t\tReturnType<\n\t\t\t\t\t\t\tResolveLazySliceMapperModule<\n\t\t\t\t\t\t\t\tTSliceMappers[TSliceLike[\"slice_type\"]]\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t>\n\t\t\t\t\t>\n\t\t\t: TSliceLike\n\t\t: TSliceLike\n\t: TSliceLike extends SliceLikeGraphQL\n\t\t? TSliceLike[\"type\"] extends keyof TSliceMappers\n\t\t\t? TSliceMappers[TSliceLike[\"type\"]] extends AnyFunction\n\t\t\t\t? SliceLikeGraphQL<TSliceLike[\"type\"]> &\n\t\t\t\t\t\tMappedSliceLike &\n\t\t\t\t\t\tAwaited<\n\t\t\t\t\t\t\tReturnType<\n\t\t\t\t\t\t\t\tResolveLazySliceMapperModule<TSliceMappers[TSliceLike[\"type\"]]>\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t>\n\t\t\t\t: TSliceLike\n\t\t\t: TSliceLike\n\t\t: never\n\n/**\n * Transforms a Slice Zone using a set of mapping functions, one for each type\n * of Slice. Mapping functions can be async.\n *\n * Whenever possible, use this function on the server to minimize client-side\n * processing.\n *\n * @example\n *\n * ```typescript\n * const mappedSliceZone = await mapSliceZone(page.data.slices, {\n * \tcode_block: ({ slice }) => ({\n * \t\tcodeHTML: await highlight(slice.primary.code),\n * \t}),\n * });\n * ```\n */\nexport function mapSliceZone<\n\tTSliceLike extends SliceLike,\n\tTSliceMappers extends SliceMappers<TSliceLike, TContext>,\n\tTContext = unknown,\n>(\n\tsliceZone: SliceZoneLike<TSliceLike>,\n\tmappers: TSliceMappers,\n\tcontext?: TContext,\n): Promise<MapSliceLike<TSliceLike, TSliceMappers>[]> {\n\treturn Promise.all(\n\t\tsliceZone.map(async (slice, index, slices) => {\n\t\t\tconst isRestSliceType = \"slice_type\" in slice\n\t\t\tconst sliceType = isRestSliceType ? slice.slice_type : slice.type\n\n\t\t\tconst mapper = mappers[sliceType as keyof typeof mappers]\n\n\t\t\tif (!mapper) {\n\t\t\t\treturn slice\n\t\t\t}\n\n\t\t\tconst mapperArgs = { slice, slices, index, context }\n\n\t\t\t// `result` may be a mapper function OR a module\n\t\t\t// containing a mapper function.\n\t\t\tlet result = await mapper(\n\t\t\t\t// @ts-expect-error - I don't know how to fix this type\n\t\t\t\tmapperArgs,\n\t\t\t)\n\n\t\t\t// `result` is a module containing a mapper function,\n\t\t\t// we need to dig out the mapper function. `result`\n\t\t\t// will be reassigned with the mapper function's value.\n\t\t\tif (\n\t\t\t\t// `mapper.length < 1` ensures the given\n\t\t\t\t// function is something of the form:\n\t\t\t\t// `() => import(...)`\n\t\t\t\tmapper.length < 1 &&\n\t\t\t\t(typeof result === \"function\" ||\n\t\t\t\t\t(typeof result === \"object\" && \"default\" in result))\n\t\t\t) {\n\t\t\t\tresult = \"default\" in result ? result.default : result\n\t\t\t\tresult = await result(mapperArgs)\n\t\t\t}\n\n\t\t\tif (isRestSliceType) {\n\t\t\t\treturn {\n\t\t\t\t\t__mapped: true,\n\t\t\t\t\tid: slice.id,\n\t\t\t\t\tslice_type: sliceType,\n\t\t\t\t\t...result,\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn {\n\t\t\t\t\t__mapped: true,\n\t\t\t\t\ttype: sliceType,\n\t\t\t\t\t...result,\n\t\t\t\t}\n\t\t\t}\n\t\t}),\n\t)\n}\n"],"names":[],"mappings":";;AAmOgB,SAAA,aAKf,WACA,SACA,SAAkB;AAElB,SAAO,QAAQ,IACd,UAAU,IAAI,OAAO,OAAO,OAAO,WAAU;AAC5C,UAAM,kBAAkB,gBAAgB;AACxC,UAAM,YAAY,kBAAkB,MAAM,aAAa,MAAM;AAEvD,UAAA,SAAS,QAAQ,SAAiC;AAExD,QAAI,CAAC,QAAQ;AACL,aAAA;AAAA,IAAA;AAGR,UAAM,aAAa,EAAE,OAAO,QAAQ,OAAO,QAAO;AAIlD,QAAI,SAAS,MAAM;AAAA;AAAA,MAElB;AAAA,IAAU;AAMX;AAAA;AAAA;AAAA;AAAA,MAIC,OAAO,SAAS,MACf,OAAO,WAAW,cACjB,OAAO,WAAW,YAAY,aAAa;AAAA,MAC5C;AACQ,eAAA,aAAa,SAAS,OAAO,UAAU;AACvC,eAAA,MAAM,OAAO,UAAU;AAAA,IAAA;AAGjC,QAAI,iBAAiB;AACb,aAAA;AAAA,QACN,UAAU;AAAA,QACV,IAAI,MAAM;AAAA,QACV,YAAY;AAAA,QACZ,GAAG;AAAA;WAEE;AACC,aAAA;AAAA,QACN,UAAU;AAAA,QACV,MAAM;AAAA,QACN,GAAG;AAAA;;EAEL,CACA,CAAC;AAEJ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapSliceZone.js","sources":["../../../src/helpers/mapSliceZone.ts"],"sourcesContent":["import type { Slice } from \"../types/value/slice\"\n\n/**\n * Convert a value to a lazyily loaded module. This is useful when using\n * functions like `() => import(\"...\")`.\n */\ntype LazyModule<T> = () => Promise<T | { default: T }>\n\n/**\n * Mark a type as potentially lazy-loaded via a module.\n */\ntype MaybeLazyModule<T> = T | LazyModule<T>\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyFunction = (...args: any[]) => any\n\n/**\n * Returns the type of a `SliceLike` type.\n *\n * @typeParam Slice - The Slice from which the type will be extracted.\n */\ntype ExtractSliceType<TSlice extends SliceLike> = TSlice extends SliceLikeRestV2\n\t? TSlice[\"slice_type\"]\n\t: TSlice extends SliceLikeGraphQL\n\t\t? TSlice[\"type\"]\n\t\t: never\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * Rest API V2 for the `mapSliceZone()` helper.\n *\n * @typeParam SliceType - Type name of the Slice.\n */\ntype SliceLikeRestV2<TSliceType extends string = string> = Pick<\n\tSlice<TSliceType>,\n\t\"id\" | \"slice_type\"\n>\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * GraphQL API for the `mapSliceZone()` helper.\n *\n * @typeParam SliceType - Type name of the Slice.\n */\ntype SliceLikeGraphQL<TSliceType extends string = string> = {\n\ttype: Slice<TSliceType>[\"slice_type\"]\n}\n\n/**\n * The minimum required properties to represent a Prismic Slice for the\n * `mapSliceZone()` helper.\n *\n * If using Prismic's Rest API V2, use the `Slice` export from\n * `@prismicio/client` for a full interface.\n *\n * @typeParam SliceType - Type name of the Slice.\n */\ntype SliceLike<TSliceType extends string = string> =\n\t| SliceLikeRestV2<TSliceType>\n\t| SliceLikeGraphQL<TSliceType>\n\n/**\n * A looser version of the `SliceZone` type from `@prismicio/client` using\n * `SliceLike`.\n *\n * If using Prismic's Rest API V2, use the `SliceZone` export from\n * `@prismicio/client` for the full type.\n *\n * @typeParam TSlice - The type(s) of a Slice in the Slice Zone.\n */\ntype SliceZoneLike<TSlice extends SliceLike = SliceLike> = readonly TSlice[]\n\n/**\n * A set of properties that identify a Slice as having been mapped. Consumers of\n * the mapped Slice Zone can use these properties to detect and specially handle\n * mapped Slices.\n */\ntype MappedSliceLike = {\n\t/**\n\t * If `true`, this Slice has been modified from its original value using a\n\t * mapper.\n\t *\n\t * @internal\n\t */\n\t__mapped: true\n}\n\n/**\n * Arguments for a function mapping content from a Prismic Slice using the\n * `mapSliceZone()` helper.\n *\n * @typeParam TSlice - The Slice passed as a prop.\n * @typeParam TContext - Arbitrary data passed to `mapSliceZone()` and made\n * available to all Slice mappers.\n */\ntype SliceMapperArgs<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> = {\n\t/**\n\t * Slice data.\n\t */\n\tslice: TSlice\n\n\t/**\n\t * The index of the Slice in the Slice Zone.\n\t */\n\tindex: number\n\n\t/**\n\t * All Slices from the Slice Zone to which the Slice belongs.\n\t */\n\t// TODO: We have to keep this list of Slices general due to circular\n\t// reference limtiations. If we had another generic to determine the full\n\t// union of Slice types, it would include TSlice. This causes TypeScript to\n\t// throw a compilation error.\n\tslices: SliceZoneLike<\n\t\tTSlice extends SliceLikeGraphQL ? SliceLikeGraphQL : SliceLikeRestV2\n\t>\n\n\t/**\n\t * Arbitrary data passed to `mapSliceZone()` and made available to all Slice\n\t * mappers.\n\t */\n\tcontext: TContext\n}\n\n/**\n * A record of mappers.\n */\ntype SliceMappers<TSlice extends SliceLike = SliceLike, TContext = unknown> = {\n\t[P in ExtractSliceType<TSlice>]?: MaybeLazyModule<\n\t\tSliceMapper<\n\t\t\tExtract<TSlice, SliceLike<P>>,\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\tany,\n\t\t\tTContext\n\t\t>\n\t>\n}\n\n/**\n * A function that maps a Slice and its metadata to a modified version. The\n * return value will replace the Slice in the Slice Zone.\n */\nexport type SliceMapper<\n\tTSlice extends SliceLike = SliceLike,\n\tTMappedSlice extends Record<string, unknown> | undefined | void =\n\t\t| Record<string, unknown>\n\t\t| undefined\n\t\t| void,\n\tTContext = unknown,\n> = (\n\targs: SliceMapperArgs<TSlice, TContext>,\n) => TMappedSlice | Promise<TMappedSlice>\n\n/**\n * Unwraps a lazily loaded mapper module.\n */\ntype ResolveLazySliceMapperModule<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSliceMapper extends SliceMapper<any, any> | LazyModule<SliceMapper>,\n> =\n\tTSliceMapper extends LazyModule<SliceMapper>\n\t\t? Awaited<ReturnType<TSliceMapper>> extends {\n\t\t\t\tdefault: unknown\n\t\t\t}\n\t\t\t? Awaited<ReturnType<TSliceMapper>>[\"default\"]\n\t\t\t: Awaited<ReturnType<TSliceMapper>>\n\t\t: TSliceMapper\n\n/**\n * Transforms a Slice into its mapped version.\n */\ntype MapSliceLike<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSliceLike extends SliceLike<any>,\n\tTSliceMappers extends SliceMappers<\n\t\tTSliceLike,\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tany\n\t>,\n> = TSliceLike extends Slice\n\t? TSliceLike[\"slice_type\"] extends keyof TSliceMappers\n\t\t? TSliceMappers[TSliceLike[\"slice_type\"]] extends AnyFunction\n\t\t\t? SliceLikeRestV2<TSliceLike[\"slice_type\"]> &\n\t\t\t\t\tMappedSliceLike &\n\t\t\t\t\tAwaited<\n\t\t\t\t\t\tReturnType<\n\t\t\t\t\t\t\tResolveLazySliceMapperModule<\n\t\t\t\t\t\t\t\tTSliceMappers[TSliceLike[\"slice_type\"]]\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t>\n\t\t\t\t\t>\n\t\t\t: TSliceLike\n\t\t: TSliceLike\n\t: TSliceLike extends SliceLikeGraphQL\n\t\t? TSliceLike[\"type\"] extends keyof TSliceMappers\n\t\t\t? TSliceMappers[TSliceLike[\"type\"]] extends AnyFunction\n\t\t\t\t? SliceLikeGraphQL<TSliceLike[\"type\"]> &\n\t\t\t\t\t\tMappedSliceLike &\n\t\t\t\t\t\tAwaited<\n\t\t\t\t\t\t\tReturnType<\n\t\t\t\t\t\t\t\tResolveLazySliceMapperModule<TSliceMappers[TSliceLike[\"type\"]]>\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t>\n\t\t\t\t: TSliceLike\n\t\t\t: TSliceLike\n\t\t: never\n\n/**\n * Transforms a Slice Zone using a set of mapping functions, one for each type\n * of Slice. Mapping functions can be async.\n *\n * Whenever possible, use this function on the server to minimize client-side\n * processing.\n *\n * @example\n *\n * ```typescript\n * const mappedSliceZone = await mapSliceZone(page.data.slices, {\n * \tcode_block: ({ slice }) => ({\n * \t\tcodeHTML: await highlight(slice.primary.code),\n * \t}),\n * });\n * ```\n */\nexport function mapSliceZone<\n\tTSliceLike extends SliceLike,\n\tTSliceMappers extends SliceMappers<TSliceLike, TContext>,\n\tTContext = unknown,\n>(\n\tsliceZone: SliceZoneLike<TSliceLike>,\n\tmappers: TSliceMappers,\n\tcontext?: TContext,\n): Promise<MapSliceLike<TSliceLike, TSliceMappers>[]> {\n\treturn Promise.all(\n\t\tsliceZone.map(async (slice, index, slices) => {\n\t\t\tconst isRestSliceType = \"slice_type\" in slice\n\t\t\tconst sliceType = isRestSliceType ? slice.slice_type : slice.type\n\n\t\t\tconst mapper = mappers[sliceType as keyof typeof mappers]\n\n\t\t\tif (!mapper) {\n\t\t\t\treturn slice\n\t\t\t}\n\n\t\t\tconst mapperArgs = { slice, slices, index, context }\n\n\t\t\t// `result` may be a mapper function OR a module\n\t\t\t// containing a mapper function.\n\t\t\tlet result = await mapper(\n\t\t\t\t// @ts-expect-error - I don't know how to fix this type\n\t\t\t\tmapperArgs,\n\t\t\t)\n\n\t\t\t// `result` is a module containing a mapper function,\n\t\t\t// we need to dig out the mapper function. `result`\n\t\t\t// will be reassigned with the mapper function's value.\n\t\t\tif (\n\t\t\t\t// `mapper.length < 1` ensures the given\n\t\t\t\t// function is something of the form:\n\t\t\t\t// `() => import(...)`\n\t\t\t\tmapper.length < 1 &&\n\t\t\t\t(typeof result === \"function\" ||\n\t\t\t\t\t(typeof result === \"object\" && \"default\" in result))\n\t\t\t) {\n\t\t\t\tresult = \"default\" in result ? result.default : result\n\t\t\t\tresult = await result(mapperArgs)\n\t\t\t}\n\n\t\t\tif (isRestSliceType) {\n\t\t\t\treturn {\n\t\t\t\t\t__mapped: true,\n\t\t\t\t\tid: slice.id,\n\t\t\t\t\tslice_type: sliceType,\n\t\t\t\t\t...result,\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn {\n\t\t\t\t\t__mapped: true,\n\t\t\t\t\ttype: sliceType,\n\t\t\t\t\t...result,\n\t\t\t\t}\n\t\t\t}\n\t\t}),\n\t)\n}\n"],"names":[],"mappings":"AAmOgB,SAAA,aAKf,WACA,SACA,SAAkB;AAElB,SAAO,QAAQ,IACd,UAAU,IAAI,OAAO,OAAO,OAAO,WAAU;AAC5C,UAAM,kBAAkB,gBAAgB;AACxC,UAAM,YAAY,kBAAkB,MAAM,aAAa,MAAM;AAEvD,UAAA,SAAS,QAAQ,SAAiC;AAExD,QAAI,CAAC,QAAQ;AACL,aAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"mapSliceZone.js","sources":["../../../src/helpers/mapSliceZone.ts"],"sourcesContent":["import type { Slice } from \"../types/value/slice\"\n\n/**\n * Convert a value to a lazyily loaded module. This is useful when using\n * functions like `() => import(\"...\")`.\n */\ntype LazyModule<T> = () => Promise<T | { default: T }>\n\n/**\n * Mark a type as potentially lazy-loaded via a module.\n */\ntype MaybeLazyModule<T> = T | LazyModule<T>\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyFunction = (...args: any[]) => any\n\n/**\n * Returns the type of a `SliceLike` type.\n *\n * @typeParam Slice - The Slice from which the type will be extracted.\n */\ntype ExtractSliceType<TSlice extends SliceLike> = TSlice extends SliceLikeRestV2\n\t? TSlice[\"slice_type\"]\n\t: TSlice extends SliceLikeGraphQL\n\t\t? TSlice[\"type\"]\n\t\t: never\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * Rest API V2 for the `mapSliceZone()` helper.\n *\n * @typeParam SliceType - Type name of the Slice.\n */\ntype SliceLikeRestV2<TSliceType extends string = string> = Pick<\n\tSlice<TSliceType>,\n\t\"id\" | \"slice_type\"\n>\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * GraphQL API for the `mapSliceZone()` helper.\n *\n * @typeParam SliceType - Type name of the Slice.\n */\ntype SliceLikeGraphQL<TSliceType extends string = string> = {\n\ttype: Slice<TSliceType>[\"slice_type\"]\n}\n\n/**\n * The minimum required properties to represent a Prismic Slice for the\n * `mapSliceZone()` helper.\n *\n * If using Prismic's Rest API V2, use the `Slice` export from\n * `@prismicio/client` for a full interface.\n *\n * @typeParam SliceType - Type name of the Slice.\n */\ntype SliceLike<TSliceType extends string = string> =\n\t| SliceLikeRestV2<TSliceType>\n\t| SliceLikeGraphQL<TSliceType>\n\n/**\n * A looser version of the `SliceZone` type from `@prismicio/client` using\n * `SliceLike`.\n *\n * If using Prismic's Rest API V2, use the `SliceZone` export from\n * `@prismicio/client` for the full type.\n *\n * @typeParam TSlice - The type(s) of a Slice in the Slice Zone.\n */\ntype SliceZoneLike<TSlice extends SliceLike = SliceLike> = readonly TSlice[]\n\n/**\n * A set of properties that identify a Slice as having been mapped. Consumers of\n * the mapped Slice Zone can use these properties to detect and specially handle\n * mapped Slices.\n */\ntype MappedSliceLike = {\n\t/**\n\t * If `true`, this Slice has been modified from its original value using a\n\t * mapper.\n\t *\n\t * @internal\n\t */\n\t__mapped: true\n}\n\n/**\n * Arguments for a function mapping content from a Prismic Slice using the\n * `mapSliceZone()` helper.\n *\n * @typeParam TSlice - The Slice passed as a prop.\n * @typeParam TContext - Arbitrary data passed to `mapSliceZone()` and made\n * available to all Slice mappers.\n */\ntype SliceMapperArgs<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> = {\n\t/**\n\t * Slice data.\n\t */\n\tslice: TSlice\n\n\t/**\n\t * The index of the Slice in the Slice Zone.\n\t */\n\tindex: number\n\n\t/**\n\t * All Slices from the Slice Zone to which the Slice belongs.\n\t */\n\t// TODO: We have to keep this list of Slices general due to circular\n\t// reference limtiations. If we had another generic to determine the full\n\t// union of Slice types, it would include TSlice. This causes TypeScript to\n\t// throw a compilation error.\n\tslices: SliceZoneLike<\n\t\tTSlice extends SliceLikeGraphQL ? SliceLikeGraphQL : SliceLikeRestV2\n\t>\n\n\t/**\n\t * Arbitrary data passed to `mapSliceZone()` and made available to all Slice\n\t * mappers.\n\t */\n\tcontext: TContext\n}\n\n/**\n * A record of mappers.\n */\ntype SliceMappers<TSlice extends SliceLike = SliceLike, TContext = unknown> = {\n\t[P in ExtractSliceType<TSlice>]?: MaybeLazyModule<\n\t\tSliceMapper<\n\t\t\tExtract<TSlice, SliceLike<P>>,\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\tany,\n\t\t\tTContext\n\t\t>\n\t>\n}\n\n/**\n * A function that maps a Slice and its metadata to a modified version. The\n * return value will replace the Slice in the Slice Zone.\n */\nexport type SliceMapper<\n\tTSlice extends SliceLike = SliceLike,\n\tTMappedSlice extends Record<string, unknown> | undefined | void =\n\t\t| Record<string, unknown>\n\t\t| undefined\n\t\t| void,\n\tTContext = unknown,\n> = (\n\targs: SliceMapperArgs<TSlice, TContext>,\n) => TMappedSlice | Promise<TMappedSlice>\n\n/**\n * Unwraps a lazily loaded mapper module.\n */\ntype ResolveLazySliceMapperModule<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSliceMapper extends SliceMapper<any, any> | LazyModule<SliceMapper>,\n> =\n\tTSliceMapper extends LazyModule<SliceMapper>\n\t\t? Awaited<ReturnType<TSliceMapper>> extends {\n\t\t\t\tdefault: unknown\n\t\t\t}\n\t\t\t? Awaited<ReturnType<TSliceMapper>>[\"default\"]\n\t\t\t: Awaited<ReturnType<TSliceMapper>>\n\t\t: TSliceMapper\n\n/**\n * Transforms a Slice into its mapped version.\n */\ntype MapSliceLike<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSliceLike extends SliceLike<any>,\n\tTSliceMappers extends SliceMappers<\n\t\tTSliceLike,\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tany\n\t>,\n> = TSliceLike extends Slice\n\t? TSliceLike[\"slice_type\"] extends keyof TSliceMappers\n\t\t? TSliceMappers[TSliceLike[\"slice_type\"]] extends AnyFunction\n\t\t\t? SliceLikeRestV2<TSliceLike[\"slice_type\"]> &\n\t\t\t\t\tMappedSliceLike &\n\t\t\t\t\tAwaited<\n\t\t\t\t\t\tReturnType<\n\t\t\t\t\t\t\tResolveLazySliceMapperModule<\n\t\t\t\t\t\t\t\tTSliceMappers[TSliceLike[\"slice_type\"]]\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t>\n\t\t\t\t\t>\n\t\t\t: TSliceLike\n\t\t: TSliceLike\n\t: TSliceLike extends SliceLikeGraphQL\n\t\t? TSliceLike[\"type\"] extends keyof TSliceMappers\n\t\t\t? TSliceMappers[TSliceLike[\"type\"]] extends AnyFunction\n\t\t\t\t? SliceLikeGraphQL<TSliceLike[\"type\"]> &\n\t\t\t\t\t\tMappedSliceLike &\n\t\t\t\t\t\tAwaited<\n\t\t\t\t\t\t\tReturnType<\n\t\t\t\t\t\t\t\tResolveLazySliceMapperModule<TSliceMappers[TSliceLike[\"type\"]]>\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t>\n\t\t\t\t: TSliceLike\n\t\t\t: TSliceLike\n\t\t: never\n\n/**\n * Transforms a Slice Zone using a set of mapping functions, one for each type\n * of Slice. Mapping functions can be async.\n *\n * Whenever possible, use this function on the server to minimize client-side\n * processing.\n *\n * @example\n *\n * ```typescript\n * const mappedSliceZone = await mapSliceZone(page.data.slices, {\n * \tcode_block: ({ slice }) => ({\n * \t\tcodeHTML: await highlight(slice.primary.code),\n * \t}),\n * });\n * ```\n */\nexport function mapSliceZone<\n\tTSliceLike extends SliceLike,\n\tTSliceMappers extends SliceMappers<TSliceLike, TContext>,\n\tTContext = unknown,\n>(\n\tsliceZone: SliceZoneLike<TSliceLike>,\n\tmappers: TSliceMappers,\n\tcontext?: TContext,\n): Promise<MapSliceLike<TSliceLike, TSliceMappers>[]> {\n\treturn Promise.all(\n\t\tsliceZone.map(async (slice, index, slices) => {\n\t\t\tconst isRestSliceType = \"slice_type\" in slice\n\t\t\tconst sliceType = isRestSliceType ? slice.slice_type : slice.type\n\n\t\t\tconst mapper = mappers[sliceType as keyof typeof mappers]\n\n\t\t\tif (!mapper) {\n\t\t\t\treturn slice\n\t\t\t}\n\n\t\t\tconst mapperArgs = { slice, slices, index, context }\n\n\t\t\t// `result` may be a mapper function OR a module\n\t\t\t// containing a mapper function.\n\t\t\tlet result = await mapper(\n\t\t\t\t// @ts-expect-error - I don't know how to fix this type\n\t\t\t\tmapperArgs,\n\t\t\t)\n\n\t\t\t// `result` is a module containing a mapper function,\n\t\t\t// we need to dig out the mapper function. `result`\n\t\t\t// will be reassigned with the mapper function's value.\n\t\t\tif (\n\t\t\t\t// `mapper.length < 1` ensures the given\n\t\t\t\t// function is something of the form:\n\t\t\t\t// `() => import(...)`\n\t\t\t\tmapper.length < 1 &&\n\t\t\t\t(typeof result === \"function\" ||\n\t\t\t\t\t(typeof result === \"object\" && \"default\" in result))\n\t\t\t) {\n\t\t\t\tresult = \"default\" in result ? result.default : result\n\t\t\t\tresult = await result(mapperArgs)\n\t\t\t}\n\n\t\t\tif (isRestSliceType) {\n\t\t\t\treturn {\n\t\t\t\t\t__mapped: true,\n\t\t\t\t\tid: slice.id,\n\t\t\t\t\tslice_type: sliceType,\n\t\t\t\t\t...result,\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn {\n\t\t\t\t\t__mapped: true,\n\t\t\t\t\ttype: sliceType,\n\t\t\t\t\t...result,\n\t\t\t\t}\n\t\t\t}\n\t\t}),\n\t)\n}\n"],"names":[],"mappings":"AAmOgB,SAAA,aAKf,WACA,SACA,SAAkB;AAElB,SAAO,QAAQ,IACd,UAAU,IAAI,OAAO,OAAO,OAAO,WAAU;AAC5C,UAAM,kBAAkB,gBAAgB;AACxC,UAAM,YAAY,kBAAkB,MAAM,aAAa,MAAM;AAEvD,UAAA,SAAS,QAAQ,SAAiC;AAExD,QAAI,CAAC,QAAQ;AACL,aAAA;AAAA,IAAA;AAGR,UAAM,aAAa,EAAE,OAAO,QAAQ,OAAO,QAAO;AAIlD,QAAI,SAAS,MAAM;AAAA;AAAA,MAElB;AAAA,IAAU;AAMX;AAAA;AAAA;AAAA;AAAA,MAIC,OAAO,SAAS,MACf,OAAO,WAAW,cACjB,OAAO,WAAW,YAAY,aAAa;AAAA,MAC5C;AACQ,eAAA,aAAa,SAAS,OAAO,UAAU;AACvC,eAAA,MAAM,OAAO,UAAU;AAAA,IAAA;AAGjC,QAAI,iBAAiB;AACb,aAAA;AAAA,QACN,UAAU;AAAA,QACV,IAAI,MAAM;AAAA,QACV,YAAY;AAAA,QACZ,GAAG;AAAA;WAEE;AACC,aAAA;AAAA,QACN,UAAU;AAAA,QACV,MAAM;AAAA,QACN,GAAG;AAAA;;EAEL,CACA,CAAC;AAEJ;"}
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/index.ts"],"sourcesContent":["// Imports are used for deprecations.\nimport type { CustomTypeModelIntegrationField } from \"./types/model/integration\"\nimport type { IntegrationField } from \"./types/value/integration\"\nimport { RichTextNodeType } from \"./types/value/richText\"\n\nimport type {\n\tHTMLRichTextFunctionSerializer,\n\tHTMLRichTextMapSerializer,\n} from \"./helpers/asHTML\"\nimport { mapSliceZone } from \"./helpers/mapSliceZone\"\n\nimport { filter } from \"./filter\"\n\n//=============================================================================\n// Client - Query content from Prismic.\n//=============================================================================\n\n// Primary Client API.\nexport { createClient } from \"./createClient\"\nexport { Client } from \"./Client\"\n\n// Write Client API.\nexport { createWriteClient } from \"./createWriteClient\"\nexport { WriteClient } from \"./WriteClient\"\n\n// Migration helper.\nexport { createMigration } from \"./createMigration\"\nexport { Migration } from \"./Migration\"\n\n// API endpoint helpers.\nexport { getRepositoryEndpoint } from \"./getRepositoryEndpoint\"\nexport { getRepositoryName } from \"./getRepositoryName\"\nexport { getGraphQLEndpoint } from \"./getGraphQLEndpoint\"\nexport { isRepositoryName } from \"./isRepositoryName\"\nexport { isRepositoryEndpoint } from \"./isRepositoryEndpoint\"\nexport { buildQueryURL } from \"./buildQueryURL\"\n\n// Toolbar helpers.\nexport { getToolbarSrc } from \"./getToolbarSrc\"\n\n// Query filters API.\n/**\n * @deprecated Renamed to `filter`\n */\n// TODO: Remove when we remove support for deprecated `predicate` export.\nconst predicate = filter\nexport { filter, predicate }\n\n// A collection of well-known cookie names shared between Prismic libraries and systems.\nexport * as cookie from \"./cookie\"\n\n// General types used to query content from Prismic. These are made public to allow users to better type their projects.\nexport type { CreateClient } from \"./createClient\"\nexport type { ClientConfig } from \"./Client\"\nexport type { CreateWriteClient } from \"./createWriteClient\"\nexport type { WriteClientConfig, MigrateReporterEvents } from \"./WriteClient\"\nexport type {\n\tAbortSignalLike,\n\tFetchLike,\n\tHttpRequestLike,\n\tRequestInitLike,\n\tResponseLike,\n} from \"./BaseClient\"\nexport type {\n\tBuildQueryURLArgs,\n\tOrdering,\n\tQueryParams,\n\tRoute,\n} from \"./buildQueryURL\"\nexport type { CreateMigration } from \"./createMigration\"\n\n//=============================================================================\n// Helpers - Manipulate content from Prismic.\n//=============================================================================\n\n// Primary Helpers API.\nexport { asDate } from \"./helpers/asDate\"\nexport { asLink } from \"./helpers/asLink\"\nexport { asLinkAttrs } from \"./helpers/asLinkAttrs\"\nexport { asText } from \"./helpers/asText\"\nexport { asHTML } from \"./helpers/asHTML\"\nexport { asImageSrc } from \"./helpers/asImageSrc\"\nexport { asImageWidthSrcSet } from \"./helpers/asImageWidthSrcSet\"\nexport { asImagePixelDensitySrcSet } from \"./helpers/asImagePixelDensitySrcSet\"\nexport * as isFilled from \"./helpers/isFilled\"\n\n/**\n * @deprecated Renamed to `mapSliceZone`\n */\nconst unstable_mapSliceZone = mapSliceZone\nexport { mapSliceZone, unstable_mapSliceZone }\n\n// Conversion helper.\nexport { documentToLinkField } from \"./helpers/documentToLinkField\"\n\nexport type { LinkResolverFunction } from \"./helpers/asLink\"\nexport type { AsLinkAttrsConfig } from \"./helpers/asLinkAttrs\"\nexport type { SliceMapper } from \"./helpers/mapSliceZone\"\n\n/**\n * @deprecated Renamed to `HTMLRichTextMapSerializer`\n */\ntype HTMLMapSerializer = HTMLRichTextMapSerializer\n/**\n * @deprecated Renamed to `HTMLRichTextFunctionSerializer`\n */\ntype HTMLFunctionSerializer = HTMLRichTextFunctionSerializer\nexport type {\n\tHTMLRichTextMapSerializer,\n\tHTMLRichTextFunctionSerializer,\n\tHTMLMapSerializer,\n\tHTMLFunctionSerializer,\n}\nexport type { HTMLRichTextSerializer } from \"./helpers/asHTML\"\n\n//=============================================================================\n// Errors - Custom errors for Prismic APIs.\n//=============================================================================\n\n// Client Errors\nexport { PrismicError } from \"./errors/PrismicError\"\nexport { ForbiddenError } from \"./errors/ForbiddenError\"\nexport { NotFoundError } from \"./errors/NotFoundError\"\nexport { RefNotFoundError } from \"./errors/RefNotFoundError\"\nexport { RefExpiredError } from \"./errors/RefExpiredError\"\nexport { PreviewTokenExpiredError } from \"./errors/PreviewTokenExpired\"\nexport { ParsingError } from \"./errors/ParsingError\"\nexport { RepositoryNotFoundError } from \"./errors/RepositoryNotFoundError\"\n\n//=============================================================================\n// Types - Types representing Prismic content, models, and API payloads.\n//=============================================================================\n\n// Values - Types representing Prismic content.\n/**\n * @deprecated Use {@link RichTextNodeType} instead.\n */\n// TODO: Remove in v8.\nconst Element = RichTextNodeType\nexport { RichTextNodeType, Element }\nexport { LinkType } from \"./types/value/link\"\nexport { OEmbedType } from \"./types/value/embed\"\n\nexport type {\n\tPrismicDocument,\n\tPrismicDocumentWithUID,\n\tPrismicDocumentWithoutUID,\n\tPrismicDocumentHeader,\n\tAlternateLanguage,\n} from \"./types/value/document\"\n\nexport type {\n\t// RichText & Title\n\tRichTextField,\n\t// RichText & Title (block nodes)\n\tRTTextNodeBase,\n\tRTHeading1Node,\n\tRTHeading2Node,\n\tRTHeading3Node,\n\tRTHeading4Node,\n\tRTHeading5Node,\n\tRTHeading6Node,\n\tRTParagraphNode,\n\tRTPreformattedNode,\n\tRTListItemNode,\n\tRTOListItemNode,\n\t// RichText & Title (span nodes)\n\tRTSpanNodeBase,\n\tRTStrongNode,\n\tRTEmNode,\n\tRTLabelNode,\n\t// RichText & Title (media nodes)\n\tRTImageNode,\n\tRTEmbedNode,\n\t// RichText & Title (link nodes)\n\tRTLinkNode,\n\t// RichText & Title (serialization related nodes)\n\tRTListNode,\n\tRTOListNode,\n\tRTSpanNode,\n\t// RichText & Title (helpers)\n\tRTNode,\n\tRTTextNode,\n\tRTBlockNode,\n\tRTInlineNode,\n\tRTAnyNode,\n\tRichTextNodeTypes,\n} from \"./types/value/richText\"\nexport type { TitleField } from \"./types/value/title\"\n\nexport type {\n\tImageField,\n\tImageFieldImage,\n\tFilledImageFieldImage,\n\tEmptyImageFieldImage,\n} from \"./types/value/image\"\n\nexport type {\n\tEmptyLinkField,\n\tLinkField,\n\tFilledLinkToWebField,\n} from \"./types/value/link\"\nexport type {\n\tContentRelationshipField,\n\tFilledContentRelationshipField,\n} from \"./types/value/contentRelationship\"\nexport type {\n\tLinkToMediaField,\n\tFilledLinkToMediaField,\n} from \"./types/value/linkToMedia\"\n\nexport type {\n\tOEmbedExtra,\n\tPhotoOEmbed,\n\tVideoOEmbed,\n\tLinkOEmbed,\n\tRichOEmbed,\n\tAnyOEmbed,\n\tEmbedField,\n} from \"./types/value/embed\"\n\nexport type {\n\tTableField,\n\tTableFieldHead,\n\tTableFieldHeadRow,\n\tTableFieldBody,\n\tTableFieldBodyRow,\n\tTableFieldHeaderCell,\n\tTableFieldDataCell,\n} from \"./types/value/table\"\n\nexport type { BooleanField } from \"./types/value/boolean\"\nexport type { ColorField } from \"./types/value/color\"\nexport type { DateField } from \"./types/value/date\"\nexport type { KeyTextField } from \"./types/value/keyText\"\nexport type { NumberField } from \"./types/value/number\"\nexport type { SelectField } from \"./types/value/select\"\nexport type { TimestampField } from \"./types/value/timestamp\"\nexport type { GeoPointField } from \"./types/value/geoPoint\"\n\n/**\n * @deprecated Renamed to `IntegrationField`\n */\n// TODO: Remove when we remove support for deprecated `IntegrationFields` export.\ntype IntegrationFields = IntegrationField\nexport { IntegrationField, IntegrationFields }\n\nexport type { GroupField, NestedGroupField } from \"./types/value/group\"\n\nexport type { SliceZone } from \"./types/value/sliceZone\"\nexport type { Slice } from \"./types/value/slice\"\nexport type { SharedSlice } from \"./types/value/sharedSlice\"\nexport type { SharedSliceVariation } from \"./types/value/sharedSliceVariation\"\n\nexport type {\n\tFieldState,\n\tAnyRegularField,\n\tAnySlicePrimaryField,\n\tRepeatable,\n} from \"./types/value/types\"\n\n// Models - Types representing Prismic content models.\nexport { CustomTypeModelFieldType } from \"./types/model/types\"\nexport { CustomTypeModelLinkSelectType } from \"./types/model/link\"\nexport { CustomTypeModelSliceType } from \"./types/model/sliceZone\"\nexport { CustomTypeModelSliceDisplay } from \"./types/model/slice\"\n\nexport type {\n\tCustomTypeModel,\n\tCustomTypeModelDefinition,\n\tCustomTypeModelTab,\n} from \"./types/model/customType\"\n\nexport type {\n\tCustomTypeModelRichTextField,\n\tCustomTypeModelRichTextMultiField,\n\tCustomTypeModelRichTextSingleField,\n} from \"./types/model/richText\"\nexport type { CustomTypeModelTitleField } from \"./types/model/title\"\n\nexport type {\n\tCustomTypeModelImageField,\n\tCustomTypeModelImageConstraint,\n\tCustomTypeModelImageThumbnail,\n} from \"./types/model/image\"\n\nexport type { CustomTypeModelContentRelationshipField } from \"./types/model/contentRelationship\"\nexport type { CustomTypeModelLinkField } from \"./types/model/link\"\nexport type { CustomTypeModelLinkToMediaField } from \"./types/model/linkToMedia\"\n\nexport type { CustomTypeModelEmbedField } from \"./types/model/embed\"\n\nexport type { CustomTypeModelBooleanField } from \"./types/model/boolean\"\nexport type { CustomTypeModelColorField } from \"./types/model/color\"\nexport type { CustomTypeModelDateField } from \"./types/model/date\"\nexport type { CustomTypeModelKeyTextField } from \"./types/model/keyText\"\nexport type { CustomTypeModelNumberField } from \"./types/model/number\"\nexport type { CustomTypeModelSelectField } from \"./types/model/select\"\nexport type { CustomTypeModelTimestampField } from \"./types/model/timestamp\"\nexport type { CustomTypeModelGeoPointField } from \"./types/model/geoPoint\"\nexport type { CustomTypeModelTableField } from \"./types/model/table\"\n\n/**\n * @deprecated Renamed to `CustomTypeModelIntegrationField`.\n */\n// TODO: Remove when we remove support for deprecated `CustomTypeModelIntegrationField` export.\ntype CustomTypeModelIntegrationFieldsField = CustomTypeModelIntegrationField\nexport {\n\tCustomTypeModelIntegrationField,\n\tCustomTypeModelIntegrationFieldsField,\n}\nexport type {\n\tCustomTypeModelGroupField,\n\tCustomTypeModelNestedGroupField,\n} from \"./types/model/group\"\nexport type {\n\tCustomTypeModelSliceZoneField,\n\tCustomTypeModelSliceLabel,\n\tCustomTypeModelSharedSlice,\n} from \"./types/model/sliceZone\"\nexport type {\n\tCustomTypeModelSlice,\n\tCustomTypeModelLegacySlice,\n} from \"./types/model/slice\"\nexport type { SharedSliceModel } from \"./types/model/sharedSlice\"\nexport type { SharedSliceModelVariation } from \"./types/model/sharedSliceVariation\"\n\nexport type { CustomTypeModelUIDField } from \"./types/model/uid\"\n\nexport type { CustomTypeModelRangeField } from \"./types/model/range\"\nexport type { CustomTypeModelSeparatorField } from \"./types/model/separator\"\n\nexport type {\n\tCustomTypeModelField,\n\tCustomTypeModelFieldForGroup,\n\tCustomTypeModelFieldForNestedGroup,\n\tCustomTypeModelFieldForSlicePrimary,\n} from \"./types/model/types\"\n\n// Migrations - Types representing Prismic Migration API content values.\nexport { PrismicMigrationDocument } from \"./types/migration/Document\"\nexport type {\n\tPendingPrismicDocument,\n\tExistingPrismicDocument,\n\tInjectMigrationSpecificTypes,\n} from \"./types/migration/Document\"\n\nexport { PrismicMigrationAsset } from \"./types/migration/Asset\"\nexport type {\n\tMigrationImage,\n\tMigrationLinkToMedia,\n\tMigrationRTImageNode,\n} from \"./types/migration/Asset\"\nexport type { MigrationContentRelationship } from \"./types/migration/ContentRelationship\"\n\n// API - Types representing Prismic Rest API V2 responses.\nexport type { Query } from \"./types/api/query\"\n\nexport type { Ref } from \"./types/api/ref\"\n\nexport type { Release } from \"./types/api/release\"\n\nexport type {\n\tRepository,\n\tLanguage,\n\tForm,\n\tFormField,\n} from \"./types/api/repository\"\n\nexport type { Tags } from \"./types/api/tags\"\n\n// Webhook - Types representing Prismic webhooks.\nexport { WebhookType } from \"./types/webhook/types\"\n\nexport type { WebhookBody } from \"./types/webhook/types\"\n\nexport type { WebhookBodyAPIUpdate } from \"./types/webhook/apiUpdate\"\n\nexport type { WebhookBodyTestTrigger } from \"./types/webhook/testTrigger\"\n"],"names":["filter","mapSliceZone","RichTextNodeType"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,MAAM,YAAYA,OAAA;AA4ClB,MAAM,wBAAwBC,aAAA;AAiD9B,MAAM,UAAUC,SAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/index.ts"],"sourcesContent":["// Imports are used for deprecations.\nimport type { CustomTypeModelIntegrationField } from \"./types/model/integration\"\nimport type { IntegrationField } from \"./types/value/integration\"\nimport { RichTextNodeType } from \"./types/value/richText\"\n\nimport type {\n\tHTMLRichTextFunctionSerializer,\n\tHTMLRichTextMapSerializer,\n} from \"./helpers/asHTML\"\nimport { mapSliceZone } from \"./helpers/mapSliceZone\"\n\nimport { filter } from \"./filter\"\n\n//=============================================================================\n// Client - Query content from Prismic.\n//=============================================================================\n\n// Primary Client API.\nexport { createClient } from \"./createClient\"\nexport { Client } from \"./Client\"\n\n// Write Client API.\nexport { createWriteClient } from \"./createWriteClient\"\nexport { WriteClient } from \"./WriteClient\"\n\n// Migration helper.\nexport { createMigration } from \"./createMigration\"\nexport { Migration } from \"./Migration\"\n\n// API endpoint helpers.\nexport { getRepositoryEndpoint } from \"./getRepositoryEndpoint\"\nexport { getRepositoryName } from \"./getRepositoryName\"\nexport { getGraphQLEndpoint } from \"./getGraphQLEndpoint\"\nexport { isRepositoryName } from \"./isRepositoryName\"\nexport { isRepositoryEndpoint } from \"./isRepositoryEndpoint\"\nexport { buildQueryURL } from \"./buildQueryURL\"\n\n// Toolbar helpers.\nexport { getToolbarSrc } from \"./getToolbarSrc\"\n\n// Query filters API.\n/**\n * @deprecated Renamed to `filter`\n */\n// TODO: Remove when we remove support for deprecated `predicate` export.\nconst predicate = filter\nexport { filter, predicate }\n\n// A collection of well-known cookie names shared between Prismic libraries and systems.\nexport * as cookie from \"./cookie\"\n\n// General types used to query content from Prismic. These are made public to allow users to better type their projects.\nexport type { CreateClient } from \"./createClient\"\nexport type { ClientConfig } from \"./Client\"\nexport type { CreateWriteClient } from \"./createWriteClient\"\nexport type { WriteClientConfig, MigrateReporterEvents } from \"./WriteClient\"\nexport type {\n\tAbortSignalLike,\n\tFetchLike,\n\tHttpRequestLike,\n\tRequestInitLike,\n\tResponseLike,\n} from \"./BaseClient\"\nexport type {\n\tBuildQueryURLArgs,\n\tOrdering,\n\tQueryParams,\n\tRoute,\n} from \"./buildQueryURL\"\nexport type { CreateMigration } from \"./createMigration\"\n\n//=============================================================================\n// Helpers - Manipulate content from Prismic.\n//=============================================================================\n\n// Primary Helpers API.\nexport { asDate } from \"./helpers/asDate\"\nexport { asLink } from \"./helpers/asLink\"\nexport { asLinkAttrs } from \"./helpers/asLinkAttrs\"\nexport { asText } from \"./helpers/asText\"\nexport { asHTML } from \"./helpers/asHTML\"\nexport { asImageSrc } from \"./helpers/asImageSrc\"\nexport { asImageWidthSrcSet } from \"./helpers/asImageWidthSrcSet\"\nexport { asImagePixelDensitySrcSet } from \"./helpers/asImagePixelDensitySrcSet\"\nexport * as isFilled from \"./helpers/isFilled\"\n\n/**\n * @deprecated Renamed to `mapSliceZone`\n */\nconst unstable_mapSliceZone = mapSliceZone\nexport { mapSliceZone, unstable_mapSliceZone }\n\n// Conversion helper.\nexport { documentToLinkField } from \"./helpers/documentToLinkField\"\n\nexport type { LinkResolverFunction } from \"./helpers/asLink\"\nexport type { AsLinkAttrsConfig } from \"./helpers/asLinkAttrs\"\nexport type { SliceMapper } from \"./helpers/mapSliceZone\"\n\n/**\n * @deprecated Renamed to `HTMLRichTextMapSerializer`\n */\ntype HTMLMapSerializer = HTMLRichTextMapSerializer\n/**\n * @deprecated Renamed to `HTMLRichTextFunctionSerializer`\n */\ntype HTMLFunctionSerializer = HTMLRichTextFunctionSerializer\nexport type {\n\tHTMLRichTextMapSerializer,\n\tHTMLRichTextFunctionSerializer,\n\tHTMLMapSerializer,\n\tHTMLFunctionSerializer,\n}\nexport type { HTMLRichTextSerializer } from \"./helpers/asHTML\"\n\n//=============================================================================\n// Errors - Custom errors for Prismic APIs.\n//=============================================================================\n\n// Client Errors\nexport { PrismicError } from \"./errors/PrismicError\"\nexport { ForbiddenError } from \"./errors/ForbiddenError\"\nexport { NotFoundError } from \"./errors/NotFoundError\"\nexport { RefNotFoundError } from \"./errors/RefNotFoundError\"\nexport { RefExpiredError } from \"./errors/RefExpiredError\"\nexport { PreviewTokenExpiredError } from \"./errors/PreviewTokenExpired\"\nexport { ParsingError } from \"./errors/ParsingError\"\nexport { RepositoryNotFoundError } from \"./errors/RepositoryNotFoundError\"\n\n//=============================================================================\n// Types - Types representing Prismic content, models, and API payloads.\n//=============================================================================\n\n// Values - Types representing Prismic content.\n/**\n * @deprecated Use {@link RichTextNodeType} instead.\n */\n// TODO: Remove in v8.\nconst Element = RichTextNodeType\nexport { RichTextNodeType, Element }\nexport { LinkType } from \"./types/value/link\"\nexport { OEmbedType } from \"./types/value/embed\"\n\nexport type {\n\tPrismicDocument,\n\tPrismicDocumentWithUID,\n\tPrismicDocumentWithoutUID,\n\tPrismicDocumentHeader,\n\tAlternateLanguage,\n} from \"./types/value/document\"\n\nexport type {\n\t// RichText & Title\n\tRichTextField,\n\t// RichText & Title (block nodes)\n\tRTTextNodeBase,\n\tRTHeading1Node,\n\tRTHeading2Node,\n\tRTHeading3Node,\n\tRTHeading4Node,\n\tRTHeading5Node,\n\tRTHeading6Node,\n\tRTParagraphNode,\n\tRTPreformattedNode,\n\tRTListItemNode,\n\tRTOListItemNode,\n\t// RichText & Title (span nodes)\n\tRTSpanNodeBase,\n\tRTStrongNode,\n\tRTEmNode,\n\tRTLabelNode,\n\t// RichText & Title (media nodes)\n\tRTImageNode,\n\tRTEmbedNode,\n\t// RichText & Title (link nodes)\n\tRTLinkNode,\n\t// RichText & Title (serialization related nodes)\n\tRTListNode,\n\tRTOListNode,\n\tRTSpanNode,\n\t// RichText & Title (helpers)\n\tRTNode,\n\tRTTextNode,\n\tRTBlockNode,\n\tRTInlineNode,\n\tRTAnyNode,\n\tRichTextNodeTypes,\n} from \"./types/value/richText\"\nexport type { TitleField } from \"./types/value/title\"\n\nexport type {\n\tImageField,\n\tImageFieldImage,\n\tFilledImageFieldImage,\n\tEmptyImageFieldImage,\n} from \"./types/value/image\"\n\nexport type {\n\tEmptyLinkField,\n\tLinkField,\n\tFilledLinkToWebField,\n} from \"./types/value/link\"\nexport type {\n\tContentRelationshipField,\n\tFilledContentRelationshipField,\n} from \"./types/value/contentRelationship\"\nexport type {\n\tLinkToMediaField,\n\tFilledLinkToMediaField,\n} from \"./types/value/linkToMedia\"\n\nexport type {\n\tOEmbedExtra,\n\tPhotoOEmbed,\n\tVideoOEmbed,\n\tLinkOEmbed,\n\tRichOEmbed,\n\tAnyOEmbed,\n\tEmbedField,\n} from \"./types/value/embed\"\n\nexport type {\n\tTableField,\n\tTableFieldHead,\n\tTableFieldHeadRow,\n\tTableFieldBody,\n\tTableFieldBodyRow,\n\tTableFieldHeaderCell,\n\tTableFieldDataCell,\n} from \"./types/value/table\"\n\nexport type { BooleanField } from \"./types/value/boolean\"\nexport type { ColorField } from \"./types/value/color\"\nexport type { DateField } from \"./types/value/date\"\nexport type { KeyTextField } from \"./types/value/keyText\"\nexport type { NumberField } from \"./types/value/number\"\nexport type { SelectField } from \"./types/value/select\"\nexport type { TimestampField } from \"./types/value/timestamp\"\nexport type { GeoPointField } from \"./types/value/geoPoint\"\n\n/**\n * @deprecated Renamed to `IntegrationField`\n */\n// TODO: Remove when we remove support for deprecated `IntegrationFields` export.\ntype IntegrationFields = IntegrationField\nexport { IntegrationField, IntegrationFields }\n\nexport type { GroupField, NestedGroupField } from \"./types/value/group\"\n\nexport type { SliceZone } from \"./types/value/sliceZone\"\nexport type { Slice } from \"./types/value/slice\"\nexport type { SharedSlice } from \"./types/value/sharedSlice\"\nexport type { SharedSliceVariation } from \"./types/value/sharedSliceVariation\"\n\nexport type {\n\tFieldState,\n\tAnyRegularField,\n\tAnySlicePrimaryField,\n\tRepeatable,\n} from \"./types/value/types\"\n\n// Models - Types representing Prismic content models.\nexport { CustomTypeModelFieldType } from \"./types/model/types\"\nexport { CustomTypeModelLinkSelectType } from \"./types/model/link\"\nexport { CustomTypeModelSliceType } from \"./types/model/sliceZone\"\nexport { CustomTypeModelSliceDisplay } from \"./types/model/slice\"\n\nexport type {\n\tCustomTypeModel,\n\tCustomTypeModelDefinition,\n\tCustomTypeModelTab,\n} from \"./types/model/customType\"\n\nexport type {\n\tCustomTypeModelRichTextField,\n\tCustomTypeModelRichTextMultiField,\n\tCustomTypeModelRichTextSingleField,\n} from \"./types/model/richText\"\nexport type { CustomTypeModelTitleField } from \"./types/model/title\"\n\nexport type {\n\tCustomTypeModelImageField,\n\tCustomTypeModelImageConstraint,\n\tCustomTypeModelImageThumbnail,\n} from \"./types/model/image\"\n\nexport type { CustomTypeModelContentRelationshipField } from \"./types/model/contentRelationship\"\nexport type { CustomTypeModelLinkField } from \"./types/model/link\"\nexport type { CustomTypeModelLinkToMediaField } from \"./types/model/linkToMedia\"\n\nexport type { CustomTypeModelEmbedField } from \"./types/model/embed\"\n\nexport type { CustomTypeModelBooleanField } from \"./types/model/boolean\"\nexport type { CustomTypeModelColorField } from \"./types/model/color\"\nexport type { CustomTypeModelDateField } from \"./types/model/date\"\nexport type { CustomTypeModelKeyTextField } from \"./types/model/keyText\"\nexport type { CustomTypeModelNumberField } from \"./types/model/number\"\nexport type { CustomTypeModelSelectField } from \"./types/model/select\"\nexport type { CustomTypeModelTimestampField } from \"./types/model/timestamp\"\nexport type { CustomTypeModelGeoPointField } from \"./types/model/geoPoint\"\nexport type { CustomTypeModelTableField } from \"./types/model/table\"\n\n/**\n * @deprecated Renamed to `CustomTypeModelIntegrationField`.\n */\n// TODO: Remove when we remove support for deprecated `CustomTypeModelIntegrationField` export.\ntype CustomTypeModelIntegrationFieldsField = CustomTypeModelIntegrationField\nexport {\n\tCustomTypeModelIntegrationField,\n\tCustomTypeModelIntegrationFieldsField,\n}\nexport type {\n\tCustomTypeModelGroupField,\n\tCustomTypeModelNestedGroupField,\n} from \"./types/model/group\"\nexport type {\n\tCustomTypeModelSliceZoneField,\n\tCustomTypeModelSliceLabel,\n\tCustomTypeModelSharedSlice,\n} from \"./types/model/sliceZone\"\nexport type {\n\tCustomTypeModelSlice,\n\tCustomTypeModelLegacySlice,\n} from \"./types/model/slice\"\nexport type { SharedSliceModel } from \"./types/model/sharedSlice\"\nexport type { SharedSliceModelVariation } from \"./types/model/sharedSliceVariation\"\n\nexport type { CustomTypeModelUIDField } from \"./types/model/uid\"\n\nexport type { CustomTypeModelRangeField } from \"./types/model/range\"\nexport type { CustomTypeModelSeparatorField } from \"./types/model/separator\"\n\nexport type {\n\tCustomTypeModelField,\n\tCustomTypeModelFieldForGroup,\n\tCustomTypeModelFieldForNestedGroup,\n\tCustomTypeModelFieldForSlicePrimary,\n} from \"./types/model/types\"\n\n// Migrations - Types representing Prismic Migration API content values.\nexport { PrismicMigrationDocument } from \"./types/migration/Document\"\nexport type {\n\tPendingPrismicDocument,\n\tExistingPrismicDocument,\n\tInjectMigrationSpecificTypes,\n} from \"./types/migration/Document\"\n\nexport { PrismicMigrationAsset } from \"./types/migration/Asset\"\nexport type {\n\tMigrationImage,\n\tMigrationLinkToMedia,\n\tMigrationRTImageNode,\n} from \"./types/migration/Asset\"\nexport type { MigrationContentRelationship } from \"./types/migration/ContentRelationship\"\n\n// API - Types representing Prismic Rest API V2 responses.\nexport type { Query } from \"./types/api/query\"\n\nexport type { Ref } from \"./types/api/ref\"\n\nexport type { Release } from \"./types/api/release\"\n\nexport type {\n\tRepository,\n\tLanguage,\n\tForm,\n\tFormField,\n} from \"./types/api/repository\"\n\nexport type { Tags } from \"./types/api/tags\"\n\n// Webhook - Types representing Prismic webhooks.\nexport { WebhookType } from \"./types/webhook/types\"\n\nexport type { WebhookBody } from \"./types/webhook/types\"\n\nexport type { WebhookBodyAPIUpdate } from \"./types/webhook/apiUpdate\"\n\nexport type { WebhookBodyTestTrigger } from \"./types/webhook/testTrigger\"\n"],"names":["filter","mapSliceZone","RichTextNodeType"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,MAAM,YAAYA,OAAAA;AA4ClB,MAAM,wBAAwBC,aAAAA;AAiD9B,MAAM,UAAUC,SAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isRepositoryEndpoint.cjs","sources":["../../src/isRepositoryEndpoint.ts"],"sourcesContent":["/**\n * Determines if a string if a Prismic Rest API V2 endpoint. Note that any valid\n * URL is a valid endpoint to support network proxies.\n *\n * @param input - Input to test.\n *\n * @returns `true` if `input` is a valid Prismic Rest API V2 endpoint, `false`\n * otherwise.\n */\nexport const isRepositoryEndpoint = (input: string): boolean => {\n\ttry {\n\t\tnew URL(input)\n\n\t\treturn true\n\t} catch {\n\t\treturn false\n\t}\n}\n"],"names":[],"mappings":";;AASa,MAAA,uBAAuB,CAAC,UAA0B;AAC1D,MAAA;AACH,QAAI,IAAI,KAAK;AAEN,WAAA;AAAA,EAAA,QACA;AACA,WAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"isRepositoryEndpoint.cjs","sources":["../../src/isRepositoryEndpoint.ts"],"sourcesContent":["/**\n * Determines if a string if a Prismic Rest API V2 endpoint. Note that any valid\n * URL is a valid endpoint to support network proxies.\n *\n * @param input - Input to test.\n *\n * @returns `true` if `input` is a valid Prismic Rest API V2 endpoint, `false`\n * otherwise.\n */\nexport const isRepositoryEndpoint = (input: string): boolean => {\n\ttry {\n\t\tnew URL(input)\n\n\t\treturn true\n\t} catch {\n\t\treturn false\n\t}\n}\n"],"names":[],"mappings":";;AASa,MAAA,uBAAuB,CAAC,UAA0B;AAC1D,MAAA;AACH,QAAI,IAAI,KAAK;AAEN,WAAA;AAAA,EAAA,QACA;AACA,WAAA;AAAA,EAAA;AAET;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isRepositoryEndpoint.js","sources":["../../src/isRepositoryEndpoint.ts"],"sourcesContent":["/**\n * Determines if a string if a Prismic Rest API V2 endpoint. Note that any valid\n * URL is a valid endpoint to support network proxies.\n *\n * @param input - Input to test.\n *\n * @returns `true` if `input` is a valid Prismic Rest API V2 endpoint, `false`\n * otherwise.\n */\nexport const isRepositoryEndpoint = (input: string): boolean => {\n\ttry {\n\t\tnew URL(input)\n\n\t\treturn true\n\t} catch {\n\t\treturn false\n\t}\n}\n"],"names":[],"mappings":"AASa,MAAA,uBAAuB,CAAC,UAA0B;AAC1D,MAAA;AACH,QAAI,IAAI,KAAK;AAEN,WAAA;AAAA,EAAA,QACA;AACA,WAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"isRepositoryEndpoint.js","sources":["../../src/isRepositoryEndpoint.ts"],"sourcesContent":["/**\n * Determines if a string if a Prismic Rest API V2 endpoint. Note that any valid\n * URL is a valid endpoint to support network proxies.\n *\n * @param input - Input to test.\n *\n * @returns `true` if `input` is a valid Prismic Rest API V2 endpoint, `false`\n * otherwise.\n */\nexport const isRepositoryEndpoint = (input: string): boolean => {\n\ttry {\n\t\tnew URL(input)\n\n\t\treturn true\n\t} catch {\n\t\treturn false\n\t}\n}\n"],"names":[],"mappings":"AASa,MAAA,uBAAuB,CAAC,UAA0B;AAC1D,MAAA;AACH,QAAI,IAAI,KAAK;AAEN,WAAA;AAAA,EAAA,QACA;AACA,WAAA;AAAA,EAAA;AAET;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appendFilters.cjs","sources":["../../../src/lib/appendFilters.ts"],"sourcesContent":["import { castArray } from \"./castArray\"\n\ninterface WithFilters {\n\tfilters?: string | string[]\n}\n\n/**\n * Adds one or more filters to an object with a `filters` property. Appended\n * filters are added to the end of the existing list.\n *\n * @typeParam T - Object to which filters will be append.\n *\n * @param objWithFilters - Object to append filters on the `filters` property.\n * @param filters - One or more filters to append.\n *\n * @returns The object with the appended filters.\n */\nexport const appendFilters = <T extends WithFilters>(\n\tobjWithFilters: T = {} as T,\n\tfilters: string | string[],\n): T & { filters: string[] } => {\n\treturn {\n\t\t...objWithFilters,\n\t\tfilters: [...(objWithFilters.filters || []), ...castArray(filters)],\n\t}\n}\n"],"names":["castArray"],"mappings":";;;AAiBO,MAAM,gBAAgB,CAC5B,iBAAoB,IACpB,YAC8B;AACvB,SAAA;AAAA,IACN,GAAG;AAAA,IACH,SAAS,CAAC,GAAI,eAAe,WAAW,CAAA,GAAK,GAAGA,
|
|
1
|
+
{"version":3,"file":"appendFilters.cjs","sources":["../../../src/lib/appendFilters.ts"],"sourcesContent":["import { castArray } from \"./castArray\"\n\ninterface WithFilters {\n\tfilters?: string | string[]\n}\n\n/**\n * Adds one or more filters to an object with a `filters` property. Appended\n * filters are added to the end of the existing list.\n *\n * @typeParam T - Object to which filters will be append.\n *\n * @param objWithFilters - Object to append filters on the `filters` property.\n * @param filters - One or more filters to append.\n *\n * @returns The object with the appended filters.\n */\nexport const appendFilters = <T extends WithFilters>(\n\tobjWithFilters: T = {} as T,\n\tfilters: string | string[],\n): T & { filters: string[] } => {\n\treturn {\n\t\t...objWithFilters,\n\t\tfilters: [...(objWithFilters.filters || []), ...castArray(filters)],\n\t}\n}\n"],"names":["castArray"],"mappings":";;;AAiBO,MAAM,gBAAgB,CAC5B,iBAAoB,IACpB,YAC8B;AACvB,SAAA;AAAA,IACN,GAAG;AAAA,IACH,SAAS,CAAC,GAAI,eAAe,WAAW,CAAA,GAAK,GAAGA,UAAU,UAAA,OAAO,CAAC;AAAA;AAEpE;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appendFilters.js","sources":["../../../src/lib/appendFilters.ts"],"sourcesContent":["import { castArray } from \"./castArray\"\n\ninterface WithFilters {\n\tfilters?: string | string[]\n}\n\n/**\n * Adds one or more filters to an object with a `filters` property. Appended\n * filters are added to the end of the existing list.\n *\n * @typeParam T - Object to which filters will be append.\n *\n * @param objWithFilters - Object to append filters on the `filters` property.\n * @param filters - One or more filters to append.\n *\n * @returns The object with the appended filters.\n */\nexport const appendFilters = <T extends WithFilters>(\n\tobjWithFilters: T = {} as T,\n\tfilters: string | string[],\n): T & { filters: string[] } => {\n\treturn {\n\t\t...objWithFilters,\n\t\tfilters: [...(objWithFilters.filters || []), ...castArray(filters)],\n\t}\n}\n"],"names":[],"mappings":";AAiBO,MAAM,gBAAgB,CAC5B,iBAAoB,IACpB,YAC8B;AACvB,SAAA;AAAA,IACN,GAAG;AAAA,IACH,SAAS,CAAC,GAAI,eAAe,WAAW,CAAA,GAAK,GAAG,UAAU,OAAO,CAAC;AAAA
|
|
1
|
+
{"version":3,"file":"appendFilters.js","sources":["../../../src/lib/appendFilters.ts"],"sourcesContent":["import { castArray } from \"./castArray\"\n\ninterface WithFilters {\n\tfilters?: string | string[]\n}\n\n/**\n * Adds one or more filters to an object with a `filters` property. Appended\n * filters are added to the end of the existing list.\n *\n * @typeParam T - Object to which filters will be append.\n *\n * @param objWithFilters - Object to append filters on the `filters` property.\n * @param filters - One or more filters to append.\n *\n * @returns The object with the appended filters.\n */\nexport const appendFilters = <T extends WithFilters>(\n\tobjWithFilters: T = {} as T,\n\tfilters: string | string[],\n): T & { filters: string[] } => {\n\treturn {\n\t\t...objWithFilters,\n\t\tfilters: [...(objWithFilters.filters || []), ...castArray(filters)],\n\t}\n}\n"],"names":[],"mappings":";AAiBO,MAAM,gBAAgB,CAC5B,iBAAoB,IACpB,YAC8B;AACvB,SAAA;AAAA,IACN,GAAG;AAAA,IACH,SAAS,CAAC,GAAI,eAAe,WAAW,CAAA,GAAK,GAAG,UAAU,OAAO,CAAC;AAAA;AAEpE;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"escapeHTML.cjs","sources":["../../../src/lib/escapeHTML.ts"],"sourcesContent":["/*\n ** Core logic from https://github.com/component/escape-html\n ** Many thanks to @component\n */\n\nconst matchHtmlRegExp = /[\"'&<>]/\n\nexport const escapeHTML = (string?: string | null): string => {\n\tconst str = \"\" + string\n\tconst match = matchHtmlRegExp.exec(str)\n\n\tif (!match) {\n\t\treturn str\n\t}\n\n\tlet escape\n\tlet html = \"\"\n\tlet index = 0\n\tlet lastIndex = 0\n\n\tfor (index = match.index; index < str.length; index++) {\n\t\tswitch (str.charCodeAt(index)) {\n\t\t\tcase 34: // \"\n\t\t\t\tescape = \""\"\n\t\t\t\tbreak\n\t\t\tcase 38: // &\n\t\t\t\tescape = \"&\"\n\t\t\t\tbreak\n\t\t\tcase 39: // '\n\t\t\t\tescape = \"'\"\n\t\t\t\tbreak\n\t\t\tcase 60: // <\n\t\t\t\tescape = \"<\"\n\t\t\t\tbreak\n\t\t\tcase 62: // >\n\t\t\t\tescape = \">\"\n\t\t\t\tbreak\n\t\t\tdefault:\n\t\t\t\tcontinue\n\t\t}\n\n\t\tif (lastIndex !== index) {\n\t\t\thtml += str.substring(lastIndex, index)\n\t\t}\n\n\t\tlastIndex = index + 1\n\t\thtml += escape\n\t}\n\n\treturn lastIndex !== index ? html + str.substring(lastIndex, index) : html\n}\n"],"names":[],"mappings":";;AAKA,MAAM,kBAAkB;AAEX,MAAA,aAAa,CAAC,WAAkC;AAC5D,QAAM,MAAM,KAAK;AACX,QAAA,QAAQ,gBAAgB,KAAK,GAAG;AAEtC,MAAI,CAAC,OAAO;AACJ,WAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"escapeHTML.cjs","sources":["../../../src/lib/escapeHTML.ts"],"sourcesContent":["/*\n ** Core logic from https://github.com/component/escape-html\n ** Many thanks to @component\n */\n\nconst matchHtmlRegExp = /[\"'&<>]/\n\nexport const escapeHTML = (string?: string | null): string => {\n\tconst str = \"\" + string\n\tconst match = matchHtmlRegExp.exec(str)\n\n\tif (!match) {\n\t\treturn str\n\t}\n\n\tlet escape\n\tlet html = \"\"\n\tlet index = 0\n\tlet lastIndex = 0\n\n\tfor (index = match.index; index < str.length; index++) {\n\t\tswitch (str.charCodeAt(index)) {\n\t\t\tcase 34: // \"\n\t\t\t\tescape = \""\"\n\t\t\t\tbreak\n\t\t\tcase 38: // &\n\t\t\t\tescape = \"&\"\n\t\t\t\tbreak\n\t\t\tcase 39: // '\n\t\t\t\tescape = \"'\"\n\t\t\t\tbreak\n\t\t\tcase 60: // <\n\t\t\t\tescape = \"<\"\n\t\t\t\tbreak\n\t\t\tcase 62: // >\n\t\t\t\tescape = \">\"\n\t\t\t\tbreak\n\t\t\tdefault:\n\t\t\t\tcontinue\n\t\t}\n\n\t\tif (lastIndex !== index) {\n\t\t\thtml += str.substring(lastIndex, index)\n\t\t}\n\n\t\tlastIndex = index + 1\n\t\thtml += escape\n\t}\n\n\treturn lastIndex !== index ? html + str.substring(lastIndex, index) : html\n}\n"],"names":[],"mappings":";;AAKA,MAAM,kBAAkB;AAEX,MAAA,aAAa,CAAC,WAAkC;AAC5D,QAAM,MAAM,KAAK;AACX,QAAA,QAAQ,gBAAgB,KAAK,GAAG;AAEtC,MAAI,CAAC,OAAO;AACJ,WAAA;AAAA,EAAA;AAGJ,MAAA;AACJ,MAAI,OAAO;AACX,MAAI,QAAQ;AACZ,MAAI,YAAY;AAEhB,OAAK,QAAQ,MAAM,OAAO,QAAQ,IAAI,QAAQ,SAAS;AAC9C,YAAA,IAAI,WAAW,KAAK,GAAG;AAAA,MAC9B,KAAK;AACK,iBAAA;AACT;AAAA,MACD,KAAK;AACK,iBAAA;AACT;AAAA,MACD,KAAK;AACK,iBAAA;AACT;AAAA,MACD,KAAK;AACK,iBAAA;AACT;AAAA,MACD,KAAK;AACK,iBAAA;AACT;AAAA,MACD;AACC;AAAA,IAAA;AAGF,QAAI,cAAc,OAAO;AAChB,cAAA,IAAI,UAAU,WAAW,KAAK;AAAA,IAAA;AAGvC,gBAAY,QAAQ;AACZ,YAAA;AAAA,EAAA;AAGT,SAAO,cAAc,QAAQ,OAAO,IAAI,UAAU,WAAW,KAAK,IAAI;AACvE;;"}
|