@prismicio/client 7.21.7-pr.444.5136044 → 7.21.7
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/Client.cjs +263 -190
- package/dist/Client.cjs.map +1 -1
- package/dist/Client.d.cts +241 -175
- package/dist/Client.d.cts.map +1 -1
- package/dist/Client.d.ts +241 -175
- package/dist/Client.d.ts.map +1 -1
- package/dist/Client.js +263 -190
- package/dist/Client.js.map +1 -1
- package/dist/Migration.cjs +86 -54
- package/dist/Migration.cjs.map +1 -1
- package/dist/Migration.d.cts +84 -50
- package/dist/Migration.d.cts.map +1 -1
- package/dist/Migration.d.ts +84 -50
- package/dist/Migration.d.ts.map +1 -1
- package/dist/Migration.js +86 -54
- package/dist/Migration.js.map +1 -1
- package/dist/WriteClient.cjs +77 -39
- package/dist/WriteClient.cjs.map +1 -1
- package/dist/WriteClient.d.cts +63 -24
- package/dist/WriteClient.d.cts.map +1 -1
- package/dist/WriteClient.d.ts +63 -24
- package/dist/WriteClient.d.ts.map +1 -1
- package/dist/WriteClient.js +77 -39
- package/dist/WriteClient.js.map +1 -1
- package/dist/buildQueryURL.cjs +22 -15
- package/dist/buildQueryURL.cjs.map +1 -1
- package/dist/buildQueryURL.d.cts +63 -53
- package/dist/buildQueryURL.d.cts.map +1 -1
- package/dist/buildQueryURL.d.ts +63 -53
- package/dist/buildQueryURL.d.ts.map +1 -1
- package/dist/buildQueryURL.js +22 -15
- package/dist/buildQueryURL.js.map +1 -1
- package/dist/cookie.cjs +4 -1
- package/dist/cookie.cjs.map +1 -1
- package/dist/cookie.d.cts +4 -1
- package/dist/cookie.d.cts.map +1 -1
- package/dist/cookie.d.ts +4 -1
- package/dist/cookie.d.ts.map +1 -1
- package/dist/cookie.js +4 -1
- package/dist/cookie.js.map +1 -1
- package/dist/createClient.cjs +14 -10
- package/dist/createClient.cjs.map +1 -1
- package/dist/createClient.d.cts +18 -11
- package/dist/createClient.d.cts.map +1 -1
- package/dist/createClient.d.ts +18 -11
- package/dist/createClient.d.ts.map +1 -1
- package/dist/createClient.js +14 -10
- package/dist/createClient.js.map +1 -1
- package/dist/createMigration.cjs +7 -4
- package/dist/createMigration.cjs.map +1 -1
- package/dist/createMigration.d.cts +11 -5
- package/dist/createMigration.d.cts.map +1 -1
- package/dist/createMigration.d.ts +11 -5
- package/dist/createMigration.d.ts.map +1 -1
- package/dist/createMigration.js +7 -4
- package/dist/createMigration.js.map +1 -1
- package/dist/createWriteClient.cjs +13 -8
- package/dist/createWriteClient.cjs.map +1 -1
- package/dist/createWriteClient.d.cts +15 -10
- package/dist/createWriteClient.d.cts.map +1 -1
- package/dist/createWriteClient.d.ts +15 -10
- package/dist/createWriteClient.d.ts.map +1 -1
- package/dist/createWriteClient.js +13 -8
- package/dist/createWriteClient.js.map +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts.map +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/filter.cjs +18 -5
- package/dist/filter.cjs.map +1 -1
- package/dist/filter.d.cts +63 -59
- package/dist/filter.d.cts.map +1 -1
- package/dist/filter.d.ts +63 -59
- package/dist/filter.d.ts.map +1 -1
- package/dist/filter.js +18 -5
- package/dist/filter.js.map +1 -1
- package/dist/getGraphQLEndpoint.cjs +2 -0
- package/dist/getGraphQLEndpoint.cjs.map +1 -1
- package/dist/getGraphQLEndpoint.d.cts +2 -0
- package/dist/getGraphQLEndpoint.d.cts.map +1 -1
- package/dist/getGraphQLEndpoint.d.ts +2 -0
- package/dist/getGraphQLEndpoint.d.ts.map +1 -1
- package/dist/getGraphQLEndpoint.js +2 -0
- package/dist/getGraphQLEndpoint.js.map +1 -1
- package/dist/getRepositoryEndpoint.cjs +8 -4
- package/dist/getRepositoryEndpoint.cjs.map +1 -1
- package/dist/getRepositoryEndpoint.d.cts +8 -4
- package/dist/getRepositoryEndpoint.d.cts.map +1 -1
- package/dist/getRepositoryEndpoint.d.ts +8 -4
- package/dist/getRepositoryEndpoint.d.ts.map +1 -1
- package/dist/getRepositoryEndpoint.js +8 -4
- package/dist/getRepositoryEndpoint.js.map +1 -1
- package/dist/getRepositoryName.cjs +5 -2
- package/dist/getRepositoryName.cjs.map +1 -1
- package/dist/getRepositoryName.d.cts +5 -2
- package/dist/getRepositoryName.d.cts.map +1 -1
- package/dist/getRepositoryName.d.ts +5 -2
- package/dist/getRepositoryName.d.ts.map +1 -1
- package/dist/getRepositoryName.js +5 -2
- package/dist/getRepositoryName.js.map +1 -1
- package/dist/getToolbarSrc.cjs +19 -17
- package/dist/getToolbarSrc.cjs.map +1 -1
- package/dist/getToolbarSrc.d.cts +19 -17
- package/dist/getToolbarSrc.d.cts.map +1 -1
- package/dist/getToolbarSrc.d.ts +19 -17
- package/dist/getToolbarSrc.d.ts.map +1 -1
- package/dist/getToolbarSrc.js +19 -17
- package/dist/getToolbarSrc.js.map +1 -1
- package/dist/helpers/asDate.cjs +9 -6
- package/dist/helpers/asDate.cjs.map +1 -1
- package/dist/helpers/asDate.d.cts +10 -5
- package/dist/helpers/asDate.d.cts.map +1 -1
- package/dist/helpers/asDate.d.ts +10 -5
- package/dist/helpers/asDate.d.ts.map +1 -1
- package/dist/helpers/asDate.js +9 -6
- package/dist/helpers/asDate.js.map +1 -1
- package/dist/helpers/asHTML.cjs +26 -25
- package/dist/helpers/asHTML.cjs.map +1 -1
- package/dist/helpers/asHTML.d.cts +55 -29
- package/dist/helpers/asHTML.d.cts.map +1 -1
- package/dist/helpers/asHTML.d.ts +55 -29
- package/dist/helpers/asHTML.d.ts.map +1 -1
- package/dist/helpers/asHTML.js +26 -25
- package/dist/helpers/asHTML.js.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.cjs +27 -21
- package/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.d.cts +36 -25
- package/dist/helpers/asImagePixelDensitySrcSet.d.cts.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.d.ts +36 -25
- package/dist/helpers/asImagePixelDensitySrcSet.d.ts.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.js +27 -21
- package/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -1
- package/dist/helpers/asImageSrc.cjs +12 -7
- package/dist/helpers/asImageSrc.cjs.map +1 -1
- package/dist/helpers/asImageSrc.d.cts +15 -8
- package/dist/helpers/asImageSrc.d.cts.map +1 -1
- package/dist/helpers/asImageSrc.d.ts +15 -8
- package/dist/helpers/asImageSrc.d.ts.map +1 -1
- package/dist/helpers/asImageSrc.js +12 -7
- package/dist/helpers/asImageSrc.js.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.cjs +32 -25
- package/dist/helpers/asImageWidthSrcSet.cjs.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.d.cts +41 -29
- package/dist/helpers/asImageWidthSrcSet.d.cts.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.d.ts +41 -29
- package/dist/helpers/asImageWidthSrcSet.d.ts.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.js +32 -25
- package/dist/helpers/asImageWidthSrcSet.js.map +1 -1
- package/dist/helpers/asLink.cjs.map +1 -1
- package/dist/helpers/asLink.d.cts +32 -15
- package/dist/helpers/asLink.d.cts.map +1 -1
- package/dist/helpers/asLink.d.ts +32 -15
- package/dist/helpers/asLink.d.ts.map +1 -1
- package/dist/helpers/asLink.js.map +1 -1
- package/dist/helpers/asLinkAttrs.cjs +11 -8
- package/dist/helpers/asLinkAttrs.cjs.map +1 -1
- package/dist/helpers/asLinkAttrs.d.cts +14 -9
- package/dist/helpers/asLinkAttrs.d.cts.map +1 -1
- package/dist/helpers/asLinkAttrs.d.ts +14 -9
- package/dist/helpers/asLinkAttrs.d.ts.map +1 -1
- package/dist/helpers/asLinkAttrs.js +11 -8
- package/dist/helpers/asLinkAttrs.js.map +1 -1
- package/dist/helpers/asText.cjs.map +1 -1
- package/dist/helpers/asText.d.cts +23 -10
- package/dist/helpers/asText.d.cts.map +1 -1
- package/dist/helpers/asText.d.ts +23 -10
- package/dist/helpers/asText.d.ts.map +1 -1
- package/dist/helpers/asText.js.map +1 -1
- package/dist/helpers/documentToLinkField.cjs +7 -2
- package/dist/helpers/documentToLinkField.cjs.map +1 -1
- package/dist/helpers/documentToLinkField.d.cts +5 -1
- package/dist/helpers/documentToLinkField.d.cts.map +1 -1
- package/dist/helpers/documentToLinkField.d.ts +5 -1
- package/dist/helpers/documentToLinkField.d.ts.map +1 -1
- package/dist/helpers/documentToLinkField.js +7 -2
- package/dist/helpers/documentToLinkField.js.map +1 -1
- package/dist/helpers/isFilled.cjs +35 -8
- package/dist/helpers/isFilled.cjs.map +1 -1
- package/dist/helpers/isFilled.d.cts +32 -8
- package/dist/helpers/isFilled.d.cts.map +1 -1
- package/dist/helpers/isFilled.d.ts +32 -8
- package/dist/helpers/isFilled.d.ts.map +1 -1
- package/dist/helpers/isFilled.js +35 -8
- package/dist/helpers/isFilled.js.map +1 -1
- package/dist/helpers/mapSliceZone.cjs +10 -8
- package/dist/helpers/mapSliceZone.cjs.map +1 -1
- package/dist/helpers/mapSliceZone.d.cts +63 -35
- package/dist/helpers/mapSliceZone.d.cts.map +1 -1
- package/dist/helpers/mapSliceZone.d.ts +63 -35
- package/dist/helpers/mapSliceZone.d.ts.map +1 -1
- package/dist/helpers/mapSliceZone.js +10 -8
- package/dist/helpers/mapSliceZone.js.map +1 -1
- package/dist/index.cjs +17 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +50 -36
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +50 -36
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -11
- package/dist/index.js.map +1 -1
- package/dist/isRepositoryEndpoint.cjs +4 -3
- package/dist/isRepositoryEndpoint.cjs.map +1 -1
- package/dist/isRepositoryEndpoint.d.cts +4 -3
- package/dist/isRepositoryEndpoint.d.cts.map +1 -1
- package/dist/isRepositoryEndpoint.d.ts +4 -3
- package/dist/isRepositoryEndpoint.d.ts.map +1 -1
- package/dist/isRepositoryEndpoint.js +4 -3
- package/dist/isRepositoryEndpoint.js.map +1 -1
- package/dist/isRepositoryName.cjs +2 -1
- package/dist/isRepositoryName.cjs.map +1 -1
- package/dist/isRepositoryName.d.cts +2 -1
- package/dist/isRepositoryName.d.cts.map +1 -1
- package/dist/isRepositoryName.d.ts +2 -1
- package/dist/isRepositoryName.d.ts.map +1 -1
- package/dist/isRepositoryName.js +2 -1
- package/dist/isRepositoryName.js.map +1 -1
- package/dist/lib/devMsg.cjs +8 -6
- package/dist/lib/devMsg.cjs.map +1 -1
- package/dist/lib/devMsg.js +8 -6
- package/dist/lib/devMsg.js.map +1 -1
- package/dist/lib/getOptionalLinkProperties.cjs +6 -5
- package/dist/lib/getOptionalLinkProperties.cjs.map +1 -1
- package/dist/lib/getOptionalLinkProperties.js +6 -5
- package/dist/lib/getOptionalLinkProperties.js.map +1 -1
- package/dist/lib/getPreviewCookie.cjs +3 -1
- package/dist/lib/getPreviewCookie.cjs.map +1 -1
- package/dist/lib/getPreviewCookie.js +3 -1
- package/dist/lib/getPreviewCookie.js.map +1 -1
- package/dist/lib/isInternalURL.cjs +1 -0
- package/dist/lib/isInternalURL.cjs.map +1 -1
- package/dist/lib/isInternalURL.js +1 -0
- package/dist/lib/isInternalURL.js.map +1 -1
- package/dist/lib/isMigrationValue.cjs +17 -7
- package/dist/lib/isMigrationValue.cjs.map +1 -1
- package/dist/lib/isMigrationValue.js +17 -7
- package/dist/lib/isMigrationValue.js.map +1 -1
- package/dist/lib/isValue.cjs +16 -2
- package/dist/lib/isValue.cjs.map +1 -1
- package/dist/lib/isValue.js +16 -2
- package/dist/lib/isValue.js.map +1 -1
- package/dist/lib/pLimit.cjs +7 -5
- package/dist/lib/pLimit.cjs.map +1 -1
- package/dist/lib/pLimit.js +7 -5
- package/dist/lib/pLimit.js.map +1 -1
- package/dist/lib/request.cjs +23 -12
- package/dist/lib/request.cjs.map +1 -1
- package/dist/lib/request.d.cts +20 -7
- package/dist/lib/request.d.cts.map +1 -1
- package/dist/lib/request.d.ts +20 -7
- package/dist/lib/request.d.ts.map +1 -1
- package/dist/lib/request.js +23 -12
- package/dist/lib/request.js.map +1 -1
- package/dist/lib/resolveMigrationDocumentData.cjs +15 -7
- package/dist/lib/resolveMigrationDocumentData.cjs.map +1 -1
- package/dist/lib/resolveMigrationDocumentData.js +15 -7
- 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/throttledWarn.cjs +4 -3
- package/dist/lib/throttledWarn.cjs.map +1 -1
- package/dist/lib/throttledWarn.js +4 -3
- package/dist/lib/throttledWarn.js.map +1 -1
- package/dist/lib/validateAssetMetadata.cjs +18 -6
- package/dist/lib/validateAssetMetadata.cjs.map +1 -1
- package/dist/lib/validateAssetMetadata.js +18 -6
- package/dist/lib/validateAssetMetadata.js.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.js +1 -1
- package/dist/richtext/asText.cjs +2 -0
- package/dist/richtext/asText.cjs.map +1 -1
- package/dist/richtext/asText.d.cts +2 -0
- package/dist/richtext/asText.d.cts.map +1 -1
- package/dist/richtext/asText.d.ts +2 -0
- package/dist/richtext/asText.d.ts.map +1 -1
- package/dist/richtext/asText.js +2 -0
- package/dist/richtext/asText.js.map +1 -1
- package/dist/richtext/asTree.cjs +4 -2
- package/dist/richtext/asTree.cjs.map +1 -1
- package/dist/richtext/asTree.d.cts +4 -2
- package/dist/richtext/asTree.d.cts.map +1 -1
- package/dist/richtext/asTree.d.ts +4 -2
- package/dist/richtext/asTree.d.ts.map +1 -1
- package/dist/richtext/asTree.js +4 -2
- package/dist/richtext/asTree.js.map +1 -1
- package/dist/richtext/composeSerializers.cjs +7 -4
- package/dist/richtext/composeSerializers.cjs.map +1 -1
- package/dist/richtext/composeSerializers.d.cts +7 -4
- package/dist/richtext/composeSerializers.d.cts.map +1 -1
- package/dist/richtext/composeSerializers.d.ts +7 -4
- package/dist/richtext/composeSerializers.d.ts.map +1 -1
- package/dist/richtext/composeSerializers.js +7 -4
- package/dist/richtext/composeSerializers.js.map +1 -1
- package/dist/richtext/serialize.cjs +6 -2
- package/dist/richtext/serialize.cjs.map +1 -1
- package/dist/richtext/serialize.d.cts +6 -2
- package/dist/richtext/serialize.d.cts.map +1 -1
- package/dist/richtext/serialize.d.ts +6 -2
- package/dist/richtext/serialize.d.ts.map +1 -1
- package/dist/richtext/serialize.js +6 -2
- package/dist/richtext/serialize.js.map +1 -1
- package/dist/richtext/types.cjs.map +1 -1
- package/dist/richtext/types.d.cts +7 -3
- package/dist/richtext/types.d.cts.map +1 -1
- package/dist/richtext/types.d.ts +7 -3
- package/dist/richtext/types.d.ts.map +1 -1
- package/dist/richtext/types.js.map +1 -1
- package/dist/richtext/wrapMapSerializer.cjs +5 -2
- package/dist/richtext/wrapMapSerializer.cjs.map +1 -1
- package/dist/richtext/wrapMapSerializer.d.cts +5 -2
- package/dist/richtext/wrapMapSerializer.d.cts.map +1 -1
- package/dist/richtext/wrapMapSerializer.d.ts +5 -2
- package/dist/richtext/wrapMapSerializer.d.ts.map +1 -1
- package/dist/richtext/wrapMapSerializer.js +5 -2
- package/dist/richtext/wrapMapSerializer.js.map +1 -1
- package/dist/types/api/asset/asset.d.cts +70 -17
- package/dist/types/api/asset/asset.d.cts.map +1 -1
- package/dist/types/api/asset/asset.d.ts +70 -17
- package/dist/types/api/asset/asset.d.ts.map +1 -1
- package/dist/types/api/asset/tag.d.cts +23 -5
- package/dist/types/api/asset/tag.d.cts.map +1 -1
- package/dist/types/api/asset/tag.d.ts +23 -5
- package/dist/types/api/asset/tag.d.ts.map +1 -1
- package/dist/types/api/integration.d.cts +4 -2
- package/dist/types/api/integration.d.cts.map +1 -1
- package/dist/types/api/integration.d.ts +4 -2
- package/dist/types/api/integration.d.ts.map +1 -1
- package/dist/types/api/query.d.cts +27 -10
- package/dist/types/api/query.d.cts.map +1 -1
- package/dist/types/api/query.d.ts +27 -10
- package/dist/types/api/query.d.ts.map +1 -1
- package/dist/types/api/ref.d.cts +16 -6
- package/dist/types/api/ref.d.cts.map +1 -1
- package/dist/types/api/ref.d.ts +16 -6
- package/dist/types/api/ref.d.ts.map +1 -1
- package/dist/types/api/release.d.cts +2 -1
- package/dist/types/api/release.d.cts.map +1 -1
- package/dist/types/api/release.d.ts +2 -1
- package/dist/types/api/release.d.ts.map +1 -1
- package/dist/types/api/repository.d.cts +45 -18
- package/dist/types/api/repository.d.cts.map +1 -1
- package/dist/types/api/repository.d.ts +45 -18
- package/dist/types/api/repository.d.ts.map +1 -1
- package/dist/types/api/tags.d.cts +3 -2
- package/dist/types/api/tags.d.cts.map +1 -1
- package/dist/types/api/tags.d.ts +3 -2
- package/dist/types/api/tags.d.ts.map +1 -1
- package/dist/types/migration/Asset.cjs +13 -4
- package/dist/types/migration/Asset.cjs.map +1 -1
- package/dist/types/migration/Asset.d.cts +66 -20
- package/dist/types/migration/Asset.d.cts.map +1 -1
- package/dist/types/migration/Asset.d.ts +66 -20
- package/dist/types/migration/Asset.d.ts.map +1 -1
- package/dist/types/migration/Asset.js +13 -4
- package/dist/types/migration/Asset.js.map +1 -1
- package/dist/types/migration/ContentRelationship.d.cts +3 -1
- package/dist/types/migration/ContentRelationship.d.cts.map +1 -1
- package/dist/types/migration/ContentRelationship.d.ts +3 -1
- package/dist/types/migration/ContentRelationship.d.ts.map +1 -1
- package/dist/types/migration/Document.cjs +19 -10
- package/dist/types/migration/Document.cjs.map +1 -1
- package/dist/types/migration/Document.d.cts +31 -12
- package/dist/types/migration/Document.d.cts.map +1 -1
- package/dist/types/migration/Document.d.ts +31 -12
- package/dist/types/migration/Document.d.ts.map +1 -1
- package/dist/types/migration/Document.js +19 -10
- package/dist/types/migration/Document.js.map +1 -1
- package/dist/types/model/contentRelationship.d.cts +15 -5
- package/dist/types/model/contentRelationship.d.cts.map +1 -1
- package/dist/types/model/contentRelationship.d.ts +15 -5
- package/dist/types/model/contentRelationship.d.ts.map +1 -1
- package/dist/types/model/customType.d.cts +17 -6
- package/dist/types/model/customType.d.cts.map +1 -1
- package/dist/types/model/customType.d.ts +17 -6
- package/dist/types/model/customType.d.ts.map +1 -1
- package/dist/types/model/image.d.cts.map +1 -1
- package/dist/types/model/image.d.ts.map +1 -1
- package/dist/types/model/linkToMedia.d.cts.map +1 -1
- package/dist/types/model/linkToMedia.d.ts.map +1 -1
- package/dist/types/model/range.d.cts +3 -1
- package/dist/types/model/range.d.cts.map +1 -1
- package/dist/types/model/range.d.ts +3 -1
- package/dist/types/model/range.d.ts.map +1 -1
- package/dist/types/model/separator.d.cts +3 -1
- package/dist/types/model/separator.d.cts.map +1 -1
- package/dist/types/model/separator.d.ts +3 -1
- package/dist/types/model/separator.d.ts.map +1 -1
- package/dist/types/model/sharedSliceVariation.d.cts.map +1 -1
- package/dist/types/model/sharedSliceVariation.d.ts.map +1 -1
- package/dist/types/model/slice.cjs.map +1 -1
- package/dist/types/model/slice.d.cts +3 -1
- package/dist/types/model/slice.d.cts.map +1 -1
- package/dist/types/model/slice.d.ts +3 -1
- package/dist/types/model/slice.d.ts.map +1 -1
- package/dist/types/model/slice.js.map +1 -1
- package/dist/types/model/sliceZone.cjs.map +1 -1
- package/dist/types/model/sliceZone.d.cts.map +1 -1
- package/dist/types/model/sliceZone.d.ts.map +1 -1
- package/dist/types/model/sliceZone.js.map +1 -1
- package/dist/types/model/types.cjs +3 -1
- package/dist/types/model/types.cjs.map +1 -1
- package/dist/types/model/types.d.cts +31 -9
- package/dist/types/model/types.d.cts.map +1 -1
- package/dist/types/model/types.d.ts +31 -9
- package/dist/types/model/types.d.ts.map +1 -1
- package/dist/types/model/types.js +3 -1
- package/dist/types/model/types.js.map +1 -1
- package/dist/types/value/color.d.cts +1 -0
- package/dist/types/value/color.d.cts.map +1 -1
- package/dist/types/value/color.d.ts +1 -0
- package/dist/types/value/color.d.ts.map +1 -1
- package/dist/types/value/contentRelationship.d.cts +5 -3
- package/dist/types/value/contentRelationship.d.cts.map +1 -1
- package/dist/types/value/contentRelationship.d.ts +5 -3
- package/dist/types/value/contentRelationship.d.ts.map +1 -1
- package/dist/types/value/date.d.cts +1 -0
- package/dist/types/value/date.d.cts.map +1 -1
- package/dist/types/value/date.d.ts +1 -0
- package/dist/types/value/date.d.ts.map +1 -1
- package/dist/types/value/document.d.cts +50 -23
- package/dist/types/value/document.d.cts.map +1 -1
- package/dist/types/value/document.d.ts +50 -23
- package/dist/types/value/document.d.ts.map +1 -1
- package/dist/types/value/embed.cjs +1 -1
- package/dist/types/value/embed.cjs.map +1 -1
- package/dist/types/value/embed.d.cts +95 -28
- package/dist/types/value/embed.d.cts.map +1 -1
- package/dist/types/value/embed.d.ts +95 -28
- package/dist/types/value/embed.d.ts.map +1 -1
- package/dist/types/value/embed.js +1 -1
- package/dist/types/value/embed.js.map +1 -1
- package/dist/types/value/geoPoint.d.cts +1 -0
- package/dist/types/value/geoPoint.d.cts.map +1 -1
- package/dist/types/value/geoPoint.d.ts +1 -0
- package/dist/types/value/geoPoint.d.ts.map +1 -1
- package/dist/types/value/group.d.cts.map +1 -1
- package/dist/types/value/group.d.ts.map +1 -1
- package/dist/types/value/image.d.cts +8 -5
- package/dist/types/value/image.d.cts.map +1 -1
- package/dist/types/value/image.d.ts +8 -5
- package/dist/types/value/image.d.ts.map +1 -1
- package/dist/types/value/integration.d.cts +1 -0
- package/dist/types/value/integration.d.cts.map +1 -1
- package/dist/types/value/integration.d.ts +1 -0
- package/dist/types/value/integration.d.ts.map +1 -1
- package/dist/types/value/keyText.d.cts +1 -0
- package/dist/types/value/keyText.d.cts.map +1 -1
- package/dist/types/value/keyText.d.ts +1 -0
- package/dist/types/value/keyText.d.ts.map +1 -1
- package/dist/types/value/link.cjs +3 -1
- package/dist/types/value/link.cjs.map +1 -1
- package/dist/types/value/link.d.cts +12 -8
- package/dist/types/value/link.d.cts.map +1 -1
- package/dist/types/value/link.d.ts +12 -8
- package/dist/types/value/link.d.ts.map +1 -1
- package/dist/types/value/link.js +3 -1
- package/dist/types/value/link.js.map +1 -1
- package/dist/types/value/linkToMedia.d.cts.map +1 -1
- package/dist/types/value/linkToMedia.d.ts.map +1 -1
- package/dist/types/value/number.d.cts +1 -0
- package/dist/types/value/number.d.cts.map +1 -1
- package/dist/types/value/number.d.ts +1 -0
- package/dist/types/value/number.d.ts.map +1 -1
- package/dist/types/value/richText.cjs.map +1 -1
- package/dist/types/value/richText.d.cts +77 -26
- package/dist/types/value/richText.d.cts.map +1 -1
- package/dist/types/value/richText.d.ts +77 -26
- package/dist/types/value/richText.d.ts.map +1 -1
- package/dist/types/value/richText.js.map +1 -1
- package/dist/types/value/select.d.cts +1 -0
- package/dist/types/value/select.d.cts.map +1 -1
- package/dist/types/value/select.d.ts +1 -0
- package/dist/types/value/select.d.ts.map +1 -1
- package/dist/types/value/sharedSliceVariation.d.cts +3 -1
- package/dist/types/value/sharedSliceVariation.d.cts.map +1 -1
- package/dist/types/value/sharedSliceVariation.d.ts +3 -1
- package/dist/types/value/sharedSliceVariation.d.ts.map +1 -1
- package/dist/types/value/slice.d.cts.map +1 -1
- package/dist/types/value/slice.d.ts.map +1 -1
- package/dist/types/value/sliceZone.d.cts +4 -3
- package/dist/types/value/sliceZone.d.cts.map +1 -1
- package/dist/types/value/sliceZone.d.ts +4 -3
- package/dist/types/value/sliceZone.d.ts.map +1 -1
- package/dist/types/value/table.d.cts +63 -14
- package/dist/types/value/table.d.cts.map +1 -1
- package/dist/types/value/table.d.ts +63 -14
- package/dist/types/value/table.d.ts.map +1 -1
- package/dist/types/value/timestamp.d.cts.map +1 -1
- package/dist/types/value/timestamp.d.ts.map +1 -1
- package/dist/types/value/title.d.cts +1 -1
- package/dist/types/value/title.d.cts.map +1 -1
- package/dist/types/value/title.d.ts +1 -1
- package/dist/types/value/title.d.ts.map +1 -1
- package/dist/types/value/types.d.cts +24 -11
- package/dist/types/value/types.d.cts.map +1 -1
- package/dist/types/value/types.d.ts +24 -11
- package/dist/types/value/types.d.ts.map +1 -1
- package/dist/types/webhook/apiUpdate.d.cts +3 -1
- package/dist/types/webhook/apiUpdate.d.cts.map +1 -1
- package/dist/types/webhook/apiUpdate.d.ts +3 -1
- package/dist/types/webhook/apiUpdate.d.ts.map +1 -1
- package/package.json +35 -33
- package/src/Client.ts +399 -236
- package/src/Migration.ts +139 -80
- package/src/WriteClient.ts +174 -64
- package/src/buildQueryURL.ts +100 -68
- package/src/cookie.ts +4 -1
- package/src/createClient.ts +20 -12
- package/src/createMigration.ts +16 -8
- package/src/createWriteClient.ts +19 -11
- package/src/errors.ts +15 -5
- package/src/filter.ts +122 -79
- package/src/getGraphQLEndpoint.ts +3 -0
- package/src/getRepositoryEndpoint.ts +9 -4
- package/src/getRepositoryName.ts +5 -2
- package/src/getToolbarSrc.ts +20 -17
- package/src/helpers/asDate.ts +18 -13
- package/src/helpers/asHTML.ts +102 -55
- package/src/helpers/asImagePixelDensitySrcSet.ts +49 -29
- package/src/helpers/asImageSrc.ts +16 -8
- package/src/helpers/asImageWidthSrcSet.ts +52 -33
- package/src/helpers/asLink.ts +54 -26
- package/src/helpers/asLinkAttrs.ts +29 -14
- package/src/helpers/asText.ts +31 -15
- package/src/helpers/documentToLinkField.ts +15 -4
- package/src/helpers/isFilled.ts +51 -14
- package/src/helpers/mapSliceZone.ts +84 -42
- package/src/index.ts +68 -18
- package/src/isRepositoryEndpoint.ts +4 -3
- package/src/isRepositoryName.ts +2 -1
- package/src/lib/devMsg.ts +8 -6
- package/src/lib/getOptionalLinkProperties.ts +6 -5
- package/src/lib/getPreviewCookie.ts +3 -1
- package/src/lib/isInternalURL.ts +1 -0
- package/src/lib/isMigrationValue.ts +22 -9
- package/src/lib/isValue.ts +38 -9
- package/src/lib/pLimit.ts +16 -9
- package/src/lib/request.ts +40 -15
- package/src/lib/resolveMigrationDocumentData.ts +27 -8
- package/src/lib/serializerHelpers.ts +29 -9
- package/src/lib/throttledWarn.ts +8 -4
- package/src/lib/validateAssetMetadata.ts +43 -17
- package/src/richtext/asText.ts +8 -2
- package/src/richtext/asTree.ts +26 -8
- package/src/richtext/composeSerializers.ts +11 -5
- package/src/richtext/serialize.ts +12 -4
- package/src/richtext/types.ts +57 -13
- package/src/richtext/wrapMapSerializer.ts +8 -4
- package/src/types/api/asset/asset.ts +77 -26
- package/src/types/api/asset/tag.ts +18 -6
- package/src/types/api/integration.ts +10 -4
- package/src/types/api/migration/document.ts +27 -11
- package/src/types/api/query.ts +27 -10
- package/src/types/api/ref.ts +16 -6
- package/src/types/api/release.ts +2 -1
- package/src/types/api/repository.ts +45 -18
- package/src/types/api/tags.ts +3 -2
- package/src/types/migration/Asset.ts +82 -26
- package/src/types/migration/ContentRelationship.ts +12 -5
- package/src/types/migration/Document.ts +52 -26
- package/src/types/migration/Link.ts +9 -7
- package/src/types/model/contentRelationship.ts +20 -7
- package/src/types/model/customType.ts +21 -7
- package/src/types/model/image.ts +5 -4
- package/src/types/model/linkToMedia.ts +2 -1
- package/src/types/model/range.ts +3 -1
- package/src/types/model/separator.ts +3 -1
- package/src/types/model/sharedSliceVariation.ts +4 -4
- package/src/types/model/slice.ts +12 -7
- package/src/types/model/sliceZone.ts +11 -4
- package/src/types/model/types.ts +31 -10
- package/src/types/value/color.ts +3 -3
- package/src/types/value/contentRelationship.ts +13 -8
- package/src/types/value/date.ts +3 -1
- package/src/types/value/document.ts +52 -24
- package/src/types/value/embed.ts +80 -33
- package/src/types/value/geoPoint.ts +8 -6
- package/src/types/value/group.ts +4 -1
- package/src/types/value/image.ts +14 -10
- package/src/types/value/integration.ts +1 -0
- package/src/types/value/keyText.ts +3 -3
- package/src/types/value/link.ts +22 -14
- package/src/types/value/linkToMedia.ts +5 -2
- package/src/types/value/number.ts +3 -3
- package/src/types/value/richText.ts +82 -30
- package/src/types/value/select.ts +1 -0
- package/src/types/value/sharedSliceVariation.ts +11 -3
- package/src/types/value/slice.ts +8 -2
- package/src/types/value/sliceZone.ts +6 -4
- package/src/types/value/table.ts +64 -25
- package/src/types/value/timestamp.ts +2 -3
- package/src/types/value/title.ts +18 -16
- package/src/types/value/types.ts +21 -8
- package/src/types/webhook/apiUpdate.ts +3 -1
package/src/helpers/asLink.ts
CHANGED
|
@@ -3,37 +3,48 @@ import type { PrismicDocument } from "../types/value/document"
|
|
|
3
3
|
import type { FilledLinkToWebField, LinkField } from "../types/value/link"
|
|
4
4
|
import { LinkType } from "../types/value/link"
|
|
5
5
|
import type { FilledLinkToMediaField } from "../types/value/linkToMedia"
|
|
6
|
+
|
|
6
7
|
import { documentToLinkField } from "./documentToLinkField"
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Resolves a link to a Prismic page to a URL.
|
|
10
11
|
*
|
|
11
|
-
* @typeParam ReturnType - Return type of your link resolver function. Useful if
|
|
12
|
-
* return a complex object.
|
|
12
|
+
* @typeParam ReturnType - Return type of your link resolver function. Useful if
|
|
13
|
+
* you prefer to return a complex object.
|
|
14
|
+
*
|
|
13
15
|
* @param linkToDocumentField - A page link field to resolve.
|
|
16
|
+
*
|
|
14
17
|
* @returns Resolved URL.
|
|
18
|
+
*
|
|
15
19
|
* @see Learn about route resolvers and link resolvers: {@link https://prismic.io/docs/routes}
|
|
16
20
|
*/
|
|
17
21
|
export type LinkResolverFunction<ReturnType = string | null | undefined> = (
|
|
18
22
|
linkToDocumentField: FilledContentRelationshipField,
|
|
19
23
|
) => ReturnType
|
|
20
24
|
|
|
21
|
-
/**
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Configuration that determines the output of `asLink()`.
|
|
27
|
+
*/
|
|
28
|
+
type AsLinkConfig<LinkResolverFunctionReturnType = string | null | undefined> =
|
|
29
|
+
{
|
|
30
|
+
/**
|
|
31
|
+
* An optional link resolver function. Without it, you're expected to use
|
|
32
|
+
* the `routes` option from the API.
|
|
33
|
+
*/
|
|
34
|
+
linkResolver?: LinkResolverFunction<LinkResolverFunctionReturnType> | null
|
|
35
|
+
}
|
|
29
36
|
|
|
30
37
|
// TODO: Remove when we remove support for deprecated tuple-style configuration.
|
|
31
|
-
/**
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
38
|
+
/**
|
|
39
|
+
* @deprecated Use object-style configuration instead.
|
|
40
|
+
*/
|
|
41
|
+
type AsLinkDeprecatedTupleConfig<
|
|
42
|
+
LinkResolverFunctionReturnType = string | null | undefined,
|
|
43
|
+
> = [linkResolver?: LinkResolverFunction<LinkResolverFunctionReturnType> | null]
|
|
35
44
|
|
|
36
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* The return type of `asLink()`.
|
|
47
|
+
*/
|
|
37
48
|
export type AsLinkReturnType<
|
|
38
49
|
LinkResolverFunctionReturnType = string | null | undefined,
|
|
39
50
|
Field extends LinkField | PrismicDocument | null | undefined =
|
|
@@ -55,17 +66,21 @@ export const asLink: {
|
|
|
55
66
|
* Converts any type of link field or Prismic page to a URL.
|
|
56
67
|
*
|
|
57
68
|
* @example
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
69
|
+
*
|
|
70
|
+
* ```ts
|
|
71
|
+
* const url = asLink(document.data.link)
|
|
72
|
+
* // => "/blog/my-post"
|
|
73
|
+
* ```
|
|
62
74
|
*
|
|
63
75
|
* @typeParam LinkResolverFunctionReturnType - Link resolver function return
|
|
64
|
-
*
|
|
76
|
+
* type.
|
|
65
77
|
* @typeParam Field - Link field or Prismic page to resolve to a URL.
|
|
78
|
+
*
|
|
66
79
|
* @param linkFieldOrDocument - Any kind of link field or a page to resolve.
|
|
67
80
|
* @param config - Configuration that determines the output of `asLink()`.
|
|
81
|
+
*
|
|
68
82
|
* @returns Resolved URL, or `null` if the link field or page is empty.
|
|
83
|
+
*
|
|
69
84
|
* @see Learn about route resolvers and link resolvers: {@link https://prismic.io/docs/routes}
|
|
70
85
|
*/
|
|
71
86
|
<
|
|
@@ -84,13 +99,17 @@ export const asLink: {
|
|
|
84
99
|
* Converts any type of link field or Prismic page to a URL.
|
|
85
100
|
*
|
|
86
101
|
* @deprecated Use object-style configuration instead.
|
|
102
|
+
*
|
|
87
103
|
* @typeParam LinkResolverFunctionReturnType - Link resolver function return
|
|
88
|
-
*
|
|
104
|
+
* type.
|
|
89
105
|
* @typeParam Field - Link field or Prismic page to resolve to a URL.
|
|
106
|
+
*
|
|
90
107
|
* @param linkFieldOrDocument - Any kind of link field or a page to resolve.
|
|
91
|
-
* @param linkResolver - An optional link resolver function. Without it,
|
|
92
|
-
* the `routes` option from the API.
|
|
108
|
+
* @param linkResolver - An optional link resolver function. Without it,
|
|
109
|
+
* you're expected to use the `routes` option from the API.
|
|
110
|
+
*
|
|
93
111
|
* @returns Resolved URL, or `null` if the link field or page is empty.
|
|
112
|
+
*
|
|
94
113
|
* @see Learn about route resolvers and link resolvers: {@link https://prismic.io/docs/routes}
|
|
95
114
|
*/
|
|
96
115
|
<
|
|
@@ -134,7 +153,10 @@ export const asLink: {
|
|
|
134
153
|
// TODO: Remove when we remove support for deprecated tuple-style configuration.
|
|
135
154
|
const [configObjectOrLinkResolver] = configObjectOrTuple
|
|
136
155
|
let config: AsLinkConfig<LinkResolverFunctionReturnType>
|
|
137
|
-
if (
|
|
156
|
+
if (
|
|
157
|
+
typeof configObjectOrLinkResolver === "function" ||
|
|
158
|
+
configObjectOrLinkResolver == null
|
|
159
|
+
) {
|
|
138
160
|
config = {
|
|
139
161
|
linkResolver: configObjectOrLinkResolver,
|
|
140
162
|
}
|
|
@@ -156,13 +178,19 @@ export const asLink: {
|
|
|
156
178
|
const resolvedURL = config.linkResolver(linkField)
|
|
157
179
|
|
|
158
180
|
if (resolvedURL != null) {
|
|
159
|
-
return resolvedURL as AsLinkReturnType<
|
|
181
|
+
return resolvedURL as AsLinkReturnType<
|
|
182
|
+
LinkResolverFunctionReturnType,
|
|
183
|
+
Field
|
|
184
|
+
>
|
|
160
185
|
}
|
|
161
186
|
}
|
|
162
187
|
|
|
163
188
|
if ("url" in linkField && linkField.url) {
|
|
164
189
|
// When using route resolver...
|
|
165
|
-
return linkField.url as AsLinkReturnType<
|
|
190
|
+
return linkField.url as AsLinkReturnType<
|
|
191
|
+
LinkResolverFunctionReturnType,
|
|
192
|
+
Field
|
|
193
|
+
>
|
|
166
194
|
}
|
|
167
195
|
|
|
168
196
|
// When empty or route resolver and link resolver are not used...
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { isInternalURL } from "../lib/isInternalURL"
|
|
2
|
+
|
|
2
3
|
import type { FilledContentRelationshipField } from "../types/value/contentRelationship"
|
|
3
4
|
import type { PrismicDocument } from "../types/value/document"
|
|
4
5
|
import type { FilledLinkToWebField, LinkField } from "../types/value/link"
|
|
5
6
|
import type { FilledLinkToMediaField } from "../types/value/linkToMedia"
|
|
7
|
+
|
|
6
8
|
import type { AsLinkReturnType, LinkResolverFunction } from "./asLink"
|
|
7
9
|
import { asLink } from "./asLink"
|
|
8
10
|
import { link as isFilledLink } from "./isFilled"
|
|
@@ -15,7 +17,9 @@ type AsLinkAttrsConfigRelArgs<
|
|
|
15
17
|
| null
|
|
16
18
|
| undefined,
|
|
17
19
|
> = {
|
|
18
|
-
href:
|
|
20
|
+
href:
|
|
21
|
+
| NonNullable<AsLinkReturnType<LinkResolverFunctionReturnType, Field>>
|
|
22
|
+
| undefined
|
|
19
23
|
isExternal: boolean
|
|
20
24
|
target?: string
|
|
21
25
|
}
|
|
@@ -34,7 +38,9 @@ export type AsLinkAttrsConfig<
|
|
|
34
38
|
) => string | undefined | void
|
|
35
39
|
}
|
|
36
40
|
|
|
37
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* The return type of `asLinkAttrs()`.
|
|
43
|
+
*/
|
|
38
44
|
type AsLinkAttrsReturnType<
|
|
39
45
|
LinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>,
|
|
40
46
|
Field extends LinkField | PrismicDocument | null | undefined =
|
|
@@ -48,7 +54,9 @@ type AsLinkAttrsReturnType<
|
|
|
48
54
|
| FilledContentRelationshipField
|
|
49
55
|
| PrismicDocument
|
|
50
56
|
? {
|
|
51
|
-
href:
|
|
57
|
+
href:
|
|
58
|
+
| NonNullable<AsLinkReturnType<LinkResolverFunctionReturnType, Field>>
|
|
59
|
+
| undefined
|
|
52
60
|
target?: string
|
|
53
61
|
rel?: string
|
|
54
62
|
}
|
|
@@ -59,19 +67,22 @@ type AsLinkAttrsReturnType<
|
|
|
59
67
|
}
|
|
60
68
|
|
|
61
69
|
/**
|
|
62
|
-
* Resolves any type of link field or Prismic page to a set of link attributes.
|
|
63
|
-
* designed to be passed to link HTML elements, like `<a>`.
|
|
70
|
+
* Resolves any type of link field or Prismic page to a set of link attributes.
|
|
71
|
+
* The attributes are designed to be passed to link HTML elements, like `<a>`.
|
|
64
72
|
*
|
|
65
|
-
* If a resolved URL is external (i.e. starts with a protocol like `https://`),
|
|
66
|
-
* `"noreferrer"`.
|
|
73
|
+
* If a resolved URL is external (i.e. starts with a protocol like `https://`),
|
|
74
|
+
* `rel` is returned as `"noreferrer"`.
|
|
67
75
|
*
|
|
68
|
-
* @typeParam LinkResolverFunctionReturnType -
|
|
69
|
-
*
|
|
76
|
+
* @typeParam LinkResolverFunctionReturnType - link resolver function return
|
|
77
|
+
* type
|
|
70
78
|
* @typeParam Field - Link field or Prismic page to resolve to link attributes
|
|
79
|
+
*
|
|
71
80
|
* @param linkFieldOrDocument - Any kind of link field or a page to resolve
|
|
72
81
|
* @param config - Configuration that determines the output of `asLinkAttrs()`
|
|
73
|
-
*
|
|
74
|
-
*
|
|
82
|
+
*
|
|
83
|
+
* @returns Resolved set of link attributes or, if the provided link field or
|
|
84
|
+
* page is empty, and empty object
|
|
85
|
+
*
|
|
75
86
|
* @see Learn about route resolvers and link resolvers: {@link https://prismic.io/docs/routes}
|
|
76
87
|
*/
|
|
77
88
|
export const asLinkAttrs = <
|
|
@@ -87,12 +98,16 @@ export const asLinkAttrs = <
|
|
|
87
98
|
): AsLinkAttrsReturnType<LinkResolverFunctionReturnType> => {
|
|
88
99
|
if (
|
|
89
100
|
linkFieldOrDocument &&
|
|
90
|
-
("link_type" in linkFieldOrDocument
|
|
101
|
+
("link_type" in linkFieldOrDocument
|
|
102
|
+
? isFilledLink(linkFieldOrDocument)
|
|
103
|
+
: linkFieldOrDocument)
|
|
91
104
|
) {
|
|
92
|
-
const target =
|
|
105
|
+
const target =
|
|
106
|
+
"target" in linkFieldOrDocument ? linkFieldOrDocument.target : undefined
|
|
93
107
|
|
|
94
108
|
const rawHref = asLink(linkFieldOrDocument, config.linkResolver)
|
|
95
|
-
const href =
|
|
109
|
+
const href =
|
|
110
|
+
rawHref == null ? undefined : (rawHref as NonNullable<typeof rawHref>)
|
|
96
111
|
|
|
97
112
|
const isExternal = typeof href === "string" ? !isInternalURL(href) : false
|
|
98
113
|
|
package/src/helpers/asText.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { asText as baseAsText } from "../richtext/asText"
|
|
2
1
|
import type { RichTextField } from "../types/value/richText"
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
import { asText as baseAsText } from "../richtext/asText"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Configuration that determines the output of `asText()`.
|
|
7
|
+
*/
|
|
5
8
|
type AsTextConfig = {
|
|
6
9
|
/**
|
|
7
10
|
* Separator used to join each element.
|
|
@@ -12,28 +15,34 @@ type AsTextConfig = {
|
|
|
12
15
|
}
|
|
13
16
|
|
|
14
17
|
// TODO: Remove when we remove support for deprecated tuple-style configuration.
|
|
15
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated Use object-style configuration instead.
|
|
20
|
+
*/
|
|
16
21
|
type AsTextDeprecatedTupleConfig = [separator?: string]
|
|
17
22
|
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
/**
|
|
24
|
+
* The return type of `asText()`.
|
|
25
|
+
*/
|
|
26
|
+
type AsTextReturnType<Field extends RichTextField | null | undefined> =
|
|
27
|
+
Field extends RichTextField ? string : null
|
|
22
28
|
|
|
23
29
|
export const asText: {
|
|
24
30
|
/**
|
|
25
31
|
* Converts a rich text field to a plain text string.
|
|
26
32
|
*
|
|
27
33
|
* @example
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
34
|
+
*
|
|
35
|
+
* ```ts
|
|
36
|
+
* const text = asText(document.data.content)
|
|
37
|
+
* // => "Hello world"
|
|
38
|
+
* ```
|
|
32
39
|
*
|
|
33
40
|
* @param richTextField - A rich text field from Prismic.
|
|
34
41
|
* @param config - Configuration that determines the output of `asText()`.
|
|
42
|
+
*
|
|
35
43
|
* @returns Plain text equivalent of the rich text field, or `null` if the
|
|
36
|
-
*
|
|
44
|
+
* field is empty.
|
|
45
|
+
*
|
|
37
46
|
* @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}
|
|
38
47
|
*/
|
|
39
48
|
<Field extends RichTextField | null | undefined>(
|
|
@@ -45,10 +54,14 @@ export const asText: {
|
|
|
45
54
|
* Converts a rich text field to a plain text string.
|
|
46
55
|
*
|
|
47
56
|
* @deprecated Use object-style configuration instead.
|
|
57
|
+
*
|
|
48
58
|
* @param richTextField - A rich text field from Prismic.
|
|
49
|
-
* @param separator - Separator used to join each element. Defaults to a
|
|
59
|
+
* @param separator - Separator used to join each element. Defaults to a
|
|
60
|
+
* space.
|
|
61
|
+
*
|
|
50
62
|
* @returns Plain text equivalent of the rich text field, or `null` if the
|
|
51
|
-
*
|
|
63
|
+
* field is empty.
|
|
64
|
+
*
|
|
52
65
|
* @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}
|
|
53
66
|
*/
|
|
54
67
|
<Field extends RichTextField | null | undefined>(
|
|
@@ -72,7 +85,10 @@ export const asText: {
|
|
|
72
85
|
config = { ...configObjectOrSeparator }
|
|
73
86
|
}
|
|
74
87
|
|
|
75
|
-
return baseAsText(
|
|
88
|
+
return baseAsText(
|
|
89
|
+
richTextField,
|
|
90
|
+
config.separator,
|
|
91
|
+
) as AsTextReturnType<Field>
|
|
76
92
|
} else {
|
|
77
93
|
return null as AsTextReturnType<Field>
|
|
78
94
|
}
|
|
@@ -2,19 +2,30 @@ import type { FilledContentRelationshipField } from "../types/value/contentRelat
|
|
|
2
2
|
import type { PrismicDocument } from "../types/value/document"
|
|
3
3
|
import { LinkType } from "../types/value/link"
|
|
4
4
|
|
|
5
|
-
type SetOptional<T, Keys extends keyof T> = Omit<T, Keys> &
|
|
5
|
+
type SetOptional<T, Keys extends keyof T> = Omit<T, Keys> &
|
|
6
|
+
Partial<Pick<T, Keys>>
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
|
-
* Converts a document into a link field, this is useful when crawling the API
|
|
9
|
+
* Converts a document into a link field, this is useful when crawling the API
|
|
10
|
+
* for document links
|
|
9
11
|
*
|
|
10
12
|
* @typeParam TDocument - Specific interface of the provided document
|
|
13
|
+
*
|
|
11
14
|
* @param prismicDocument - A document coming from Prismic
|
|
15
|
+
*
|
|
12
16
|
* @returns The equivalent link field to use with `asLink()`
|
|
17
|
+
*
|
|
13
18
|
* @internal
|
|
14
19
|
*/
|
|
15
|
-
export const documentToLinkField = <
|
|
20
|
+
export const documentToLinkField = <
|
|
21
|
+
TDocument extends SetOptional<PrismicDocument, "slugs">,
|
|
22
|
+
>(
|
|
16
23
|
prismicDocument: TDocument,
|
|
17
|
-
): FilledContentRelationshipField<
|
|
24
|
+
): FilledContentRelationshipField<
|
|
25
|
+
TDocument["type"],
|
|
26
|
+
TDocument["lang"],
|
|
27
|
+
TDocument["data"]
|
|
28
|
+
> => {
|
|
18
29
|
return {
|
|
19
30
|
link_type: LinkType.Document,
|
|
20
31
|
id: prismicDocument.id,
|
package/src/helpers/isFilled.ts
CHANGED
|
@@ -8,7 +8,10 @@ import type { AnyOEmbed, EmbedField } from "../types/value/embed"
|
|
|
8
8
|
import type { GeoPointField } from "../types/value/geoPoint"
|
|
9
9
|
import type { GroupField, NestedGroupField } from "../types/value/group"
|
|
10
10
|
import type { ImageField, ImageFieldImage } from "../types/value/image"
|
|
11
|
-
import type {
|
|
11
|
+
import type {
|
|
12
|
+
IntegrationField,
|
|
13
|
+
IntegrationFieldData,
|
|
14
|
+
} from "../types/value/integration"
|
|
12
15
|
import type { KeyTextField } from "../types/value/keyText"
|
|
13
16
|
import type { LinkField } from "../types/value/link"
|
|
14
17
|
import type { LinkToMediaField } from "../types/value/linkToMedia"
|
|
@@ -24,10 +27,11 @@ import type { TitleField } from "../types/value/title"
|
|
|
24
27
|
import type { AnyRegularField, Repeatable } from "../types/value/types"
|
|
25
28
|
|
|
26
29
|
/**
|
|
27
|
-
* Determines if a value is not nullish (i.e. not `null` or `undefined`). This
|
|
28
|
-
* nullable field values are filled.
|
|
30
|
+
* Determines if a value is not nullish (i.e. not `null` or `undefined`). This
|
|
31
|
+
* is used to check if nullable field values are filled.
|
|
29
32
|
*
|
|
30
33
|
* @param input - The value to check.
|
|
34
|
+
*
|
|
31
35
|
* @returns `true` if `input` is not nullish, `false` otherwise.
|
|
32
36
|
*/
|
|
33
37
|
const isNonNullish = <T>(input: T): input is NonNullable<T> => {
|
|
@@ -35,9 +39,11 @@ const isNonNullish = <T>(input: T): input is NonNullable<T> => {
|
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
/**
|
|
38
|
-
* Determines if an array is not empty. This is used to check if array-based
|
|
42
|
+
* Determines if an array is not empty. This is used to check if array-based
|
|
43
|
+
* fields are filled.
|
|
39
44
|
*
|
|
40
45
|
* @param input - The array to check.
|
|
46
|
+
*
|
|
41
47
|
* @returns `true` if `input` has at least one element, `false` otherwise.
|
|
42
48
|
*/
|
|
43
49
|
const isNonEmptyArray = <T>(input: T[]): input is [T, ...T[]] => {
|
|
@@ -47,7 +53,8 @@ const isNonEmptyArray = <T>(input: T[]): input is [T, ...T[]] => {
|
|
|
47
53
|
/**
|
|
48
54
|
* Determines if a rich text field is filled.
|
|
49
55
|
*
|
|
50
|
-
* @param field -
|
|
56
|
+
* @param field - rich text field to check.
|
|
57
|
+
*
|
|
51
58
|
* @returns `true` if `field` is filled, `false` otherwise.
|
|
52
59
|
*/
|
|
53
60
|
export const richText = (
|
|
@@ -66,6 +73,7 @@ export const richText = (
|
|
|
66
73
|
* Determines if a title field is filled.
|
|
67
74
|
*
|
|
68
75
|
* @param field - Title field to check.
|
|
76
|
+
*
|
|
69
77
|
* @returns `true` if `field` is filled, `false` otherwise.
|
|
70
78
|
*/
|
|
71
79
|
export const title = richText as (
|
|
@@ -76,6 +84,7 @@ export const title = richText as (
|
|
|
76
84
|
* Determines if an image thumbnail is filled.
|
|
77
85
|
*
|
|
78
86
|
* @param thumbnail - Image thumbnail to check.
|
|
87
|
+
*
|
|
79
88
|
* @returns `true` if the thumbnail is filled, `false` otherwise.
|
|
80
89
|
*/
|
|
81
90
|
export const imageThumbnail = (
|
|
@@ -88,9 +97,12 @@ export const imageThumbnail = (
|
|
|
88
97
|
* Determines if an image field is filled.
|
|
89
98
|
*
|
|
90
99
|
* @param field - Image field to check.
|
|
100
|
+
*
|
|
91
101
|
* @returns `true` if `field` is filled, `false` otherwise.
|
|
92
102
|
*/
|
|
93
|
-
export const image = imageThumbnail as <
|
|
103
|
+
export const image = imageThumbnail as <
|
|
104
|
+
ThumbnailNames extends string | null = never,
|
|
105
|
+
>(
|
|
94
106
|
field: ImageField<ThumbnailNames> | null | undefined,
|
|
95
107
|
) => field is ImageField<ThumbnailNames, "filled">
|
|
96
108
|
|
|
@@ -98,13 +110,15 @@ export const image = imageThumbnail as <ThumbnailNames extends string | null = n
|
|
|
98
110
|
* Determines if a link field is filled.
|
|
99
111
|
*
|
|
100
112
|
* @param field - Link field to check.
|
|
113
|
+
*
|
|
101
114
|
* @returns `true` if `field` is filled, `false` otherwise.
|
|
102
115
|
*/
|
|
103
116
|
export const link = <
|
|
104
117
|
TypeEnum = string,
|
|
105
118
|
LangEnum = string,
|
|
106
|
-
DataInterface extends
|
|
107
|
-
|
|
119
|
+
DataInterface extends
|
|
120
|
+
| Record<string, AnyRegularField | GroupField | SliceZone>
|
|
121
|
+
| unknown = unknown,
|
|
108
122
|
>(
|
|
109
123
|
field: LinkField<TypeEnum, LangEnum, DataInterface> | null | undefined,
|
|
110
124
|
): field is LinkField<TypeEnum, LangEnum, DataInterface, "filled"> => {
|
|
@@ -115,6 +129,7 @@ export const link = <
|
|
|
115
129
|
* Determines if a link to media field is filled.
|
|
116
130
|
*
|
|
117
131
|
* @param field - Link to media field to check.
|
|
132
|
+
*
|
|
118
133
|
* @returns `true` if `field` is filled, `false` otherwise.
|
|
119
134
|
*/
|
|
120
135
|
export const linkToMedia = link as (
|
|
@@ -125,9 +140,12 @@ export const linkToMedia = link as (
|
|
|
125
140
|
* Determines if a content relationship field is filled.
|
|
126
141
|
*
|
|
127
142
|
* @param field - Content relationship field to check.
|
|
143
|
+
*
|
|
128
144
|
* @returns `true` if the field is filled, `false` otherwise.
|
|
129
145
|
*/
|
|
130
|
-
export const contentRelationship = link as <
|
|
146
|
+
export const contentRelationship = link as <
|
|
147
|
+
Field extends ContentRelationshipField,
|
|
148
|
+
>(
|
|
131
149
|
field: Field | null | undefined,
|
|
132
150
|
) => field is Exclude<Field, EmptyContentRelationshipField>
|
|
133
151
|
|
|
@@ -135,6 +153,7 @@ export const contentRelationship = link as <Field extends ContentRelationshipFie
|
|
|
135
153
|
* Determines if a date field is filled.
|
|
136
154
|
*
|
|
137
155
|
* @param field - Date field to check.
|
|
156
|
+
*
|
|
138
157
|
* @returns `true` if `field` is filled, `false` otherwise.
|
|
139
158
|
*/
|
|
140
159
|
export const date = isNonNullish as (
|
|
@@ -145,6 +164,7 @@ export const date = isNonNullish as (
|
|
|
145
164
|
* Determines if a timestamp field is filled.
|
|
146
165
|
*
|
|
147
166
|
* @param field - Timestamp field to check.
|
|
167
|
+
*
|
|
148
168
|
* @returns `true` if `field` is filled, `false` otherwise.
|
|
149
169
|
*/
|
|
150
170
|
export const timestamp = isNonNullish as (
|
|
@@ -155,6 +175,7 @@ export const timestamp = isNonNullish as (
|
|
|
155
175
|
* Determines if a color field is filled.
|
|
156
176
|
*
|
|
157
177
|
* @param field - Color field to check.
|
|
178
|
+
*
|
|
158
179
|
* @returns `true` if `field` is filled, `false` otherwise.
|
|
159
180
|
*/
|
|
160
181
|
export const color = isNonNullish as (
|
|
@@ -165,6 +186,7 @@ export const color = isNonNullish as (
|
|
|
165
186
|
* Determines if a number field is filled.
|
|
166
187
|
*
|
|
167
188
|
* @param field - Number field to check.
|
|
189
|
+
*
|
|
168
190
|
* @returns `true` if `field` is filled, `false` otherwise.
|
|
169
191
|
*/
|
|
170
192
|
export const number = isNonNullish as (
|
|
@@ -175,6 +197,7 @@ export const number = isNonNullish as (
|
|
|
175
197
|
* Determines if a key text field is filled.
|
|
176
198
|
*
|
|
177
199
|
* @param field - Key text field to check.
|
|
200
|
+
*
|
|
178
201
|
* @returns `true` if the field is filled, `false` otherwise.
|
|
179
202
|
*/
|
|
180
203
|
export const keyText = (
|
|
@@ -187,6 +210,7 @@ export const keyText = (
|
|
|
187
210
|
* Determines if a select field is filled.
|
|
188
211
|
*
|
|
189
212
|
* @param field - Select field to check.
|
|
213
|
+
*
|
|
190
214
|
* @returns `true` if `field` is filled, `false` otherwise.
|
|
191
215
|
*/
|
|
192
216
|
export const select = isNonNullish as <Enum extends string>(
|
|
@@ -197,6 +221,7 @@ export const select = isNonNullish as <Enum extends string>(
|
|
|
197
221
|
* Determines if an embed field is filled.
|
|
198
222
|
*
|
|
199
223
|
* @param field - Embed field to check.
|
|
224
|
+
*
|
|
200
225
|
* @returns `true` if `field` is filled, `false` otherwise.
|
|
201
226
|
*/
|
|
202
227
|
export const embed = <Field extends EmbedField<AnyOEmbed>>(
|
|
@@ -209,6 +234,7 @@ export const embed = <Field extends EmbedField<AnyOEmbed>>(
|
|
|
209
234
|
* Determines if a geopoint field is filled.
|
|
210
235
|
*
|
|
211
236
|
* @param field - Geopoint field to check.
|
|
237
|
+
*
|
|
212
238
|
* @returns `true` if the field is filled, `false` otherwise.
|
|
213
239
|
*/
|
|
214
240
|
export const geoPoint = (
|
|
@@ -221,6 +247,7 @@ export const geoPoint = (
|
|
|
221
247
|
* Determines if a table field is filled.
|
|
222
248
|
*
|
|
223
249
|
* @param field - Table field to check.
|
|
250
|
+
*
|
|
224
251
|
* @returns `true` if `field` is filled, `false` otherwise.
|
|
225
252
|
*/
|
|
226
253
|
export const table = isNonNullish as (
|
|
@@ -231,15 +258,20 @@ export const table = isNonNullish as (
|
|
|
231
258
|
* Determines if an integration field is filled.
|
|
232
259
|
*
|
|
233
260
|
* @param field - Integration field to check.
|
|
261
|
+
*
|
|
234
262
|
* @returns `true` if `field` is filled, `false` otherwise.
|
|
235
263
|
*/
|
|
236
264
|
export const integration = isNonNullish as <Data extends IntegrationFieldData>(
|
|
237
265
|
field: IntegrationField<Data> | null | undefined,
|
|
238
266
|
) => field is IntegrationField<Data, "filled">
|
|
239
|
-
/**
|
|
267
|
+
/**
|
|
268
|
+
* @deprecated Renamed to `integration`.
|
|
269
|
+
*/
|
|
240
270
|
// TODO: Remove when we remove support for deprecated `integrationField` export.
|
|
241
271
|
export const integrationField = integration
|
|
242
|
-
/**
|
|
272
|
+
/**
|
|
273
|
+
* @deprecated Renamed to `integrationField`.
|
|
274
|
+
*/
|
|
243
275
|
// TODO: Remove when we remove support for deprecated `integrationFields` export.
|
|
244
276
|
export const integrationFields = integration
|
|
245
277
|
|
|
@@ -247,8 +279,9 @@ export const integrationFields = integration
|
|
|
247
279
|
* Determines if a repeatable field has at least one item.
|
|
248
280
|
*
|
|
249
281
|
* @param repeatable - Repeatable to check.
|
|
282
|
+
*
|
|
250
283
|
* @returns `true` if `repeatable` contains at least one item, `false`
|
|
251
|
-
*
|
|
284
|
+
* otherwise.
|
|
252
285
|
*/
|
|
253
286
|
export const repeatable = <T extends LinkField>(
|
|
254
287
|
repeatable: Repeatable<T> | null | undefined,
|
|
@@ -260,9 +293,12 @@ export const repeatable = <T extends LinkField>(
|
|
|
260
293
|
* Determines if a group has at least one item.
|
|
261
294
|
*
|
|
262
295
|
* @param group - Group to check.
|
|
296
|
+
*
|
|
263
297
|
* @returns `true` if the group contains at least one item, `false` otherwise.
|
|
264
298
|
*/
|
|
265
|
-
export const group = <
|
|
299
|
+
export const group = <
|
|
300
|
+
Fields extends Record<string, AnyRegularField | NestedGroupField>,
|
|
301
|
+
>(
|
|
266
302
|
group: GroupField<Fields> | null | undefined,
|
|
267
303
|
): group is GroupField<Fields, "filled"> => {
|
|
268
304
|
return isNonNullish(group) && isNonEmptyArray(group)
|
|
@@ -272,8 +308,9 @@ export const group = <Fields extends Record<string, AnyRegularField | NestedGrou
|
|
|
272
308
|
* Determines if a slice zone has at least one slice.
|
|
273
309
|
*
|
|
274
310
|
* @param slices - Slice zone to check.
|
|
311
|
+
*
|
|
275
312
|
* @returns `true` if the slice zone contains at least one slice, `false`
|
|
276
|
-
*
|
|
313
|
+
* otherwise.
|
|
277
314
|
*/
|
|
278
315
|
export const sliceZone = <Slices extends Slice | SharedSlice>(
|
|
279
316
|
slices: SliceZone<Slices> | null | undefined,
|