@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/Client.ts
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { devMsg } from "./lib/devMsg"
|
|
2
|
+
import { getPreviewCookie } from "./lib/getPreviewCookie"
|
|
3
|
+
import type { ResponseLike } from "./lib/request"
|
|
4
|
+
import {
|
|
5
|
+
type AbortSignalLike,
|
|
6
|
+
type FetchLike,
|
|
7
|
+
type RequestInitLike,
|
|
8
|
+
request,
|
|
9
|
+
} from "./lib/request"
|
|
10
|
+
import { throttledWarn } from "./lib/throttledWarn"
|
|
11
|
+
|
|
12
|
+
import type { Query } from "./types/api/query"
|
|
13
|
+
import type { Ref } from "./types/api/ref"
|
|
14
|
+
import type { Repository } from "./types/api/repository"
|
|
15
|
+
import type { PrismicDocument } from "./types/value/document"
|
|
16
|
+
|
|
2
17
|
import {
|
|
3
18
|
ForbiddenError,
|
|
4
19
|
NotFoundError,
|
|
@@ -9,27 +24,24 @@ import {
|
|
|
9
24
|
RefNotFoundError,
|
|
10
25
|
RepositoryNotFoundError,
|
|
11
26
|
} from "./errors"
|
|
27
|
+
|
|
28
|
+
import { type LinkResolverFunction, asLink } from "./helpers/asLink"
|
|
29
|
+
|
|
30
|
+
import { type BuildQueryURLArgs, buildQueryURL } from "./buildQueryURL"
|
|
12
31
|
import { filter } from "./filter"
|
|
13
32
|
import { getRepositoryEndpoint } from "./getRepositoryEndpoint"
|
|
14
33
|
import { getRepositoryName } from "./getRepositoryName"
|
|
15
|
-
import { type LinkResolverFunction, asLink } from "./helpers/asLink"
|
|
16
34
|
import { isRepositoryEndpoint } from "./isRepositoryEndpoint"
|
|
17
|
-
import { devMsg } from "./lib/devMsg"
|
|
18
|
-
import { getPreviewCookie } from "./lib/getPreviewCookie"
|
|
19
|
-
import type { ResponseLike } from "./lib/request"
|
|
20
|
-
import { type AbortSignalLike, type FetchLike, type RequestInitLike, request } from "./lib/request"
|
|
21
|
-
import { throttledWarn } from "./lib/throttledWarn"
|
|
22
|
-
import type { Query } from "./types/api/query"
|
|
23
|
-
import type { Ref } from "./types/api/ref"
|
|
24
|
-
import type { Repository } from "./types/api/repository"
|
|
25
|
-
import type { PrismicDocument } from "./types/value/document"
|
|
26
35
|
|
|
27
36
|
const MAX_PAGE_SIZE = 100
|
|
28
37
|
const REPOSITORY_CACHE_TTL = 5000
|
|
29
38
|
const GET_ALL_QUERY_DELAY = 500
|
|
30
39
|
const MAX_INVALID_REF_RETRY_ATTEMPTS = 3
|
|
31
40
|
|
|
32
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* Extracts a document type with a matching `type` property from a union of
|
|
43
|
+
* document types.
|
|
44
|
+
*/
|
|
33
45
|
type ExtractDocumentType<
|
|
34
46
|
TDocuments extends PrismicDocument,
|
|
35
47
|
TDocumentType extends TDocuments["type"],
|
|
@@ -39,12 +51,12 @@ type ExtractDocumentType<
|
|
|
39
51
|
: Extract<TDocuments, { type: TDocumentType }>
|
|
40
52
|
|
|
41
53
|
/**
|
|
42
|
-
* The minimum required properties to treat as an HTTP Request for automatic
|
|
43
|
-
* support.
|
|
54
|
+
* The minimum required properties to treat as an HTTP Request for automatic
|
|
55
|
+
* Prismic preview support.
|
|
44
56
|
*/
|
|
45
57
|
export type HttpRequestLike =
|
|
46
58
|
| // Web API Request
|
|
47
|
-
|
|
59
|
+
{
|
|
48
60
|
headers?: {
|
|
49
61
|
get(name: string): string | null
|
|
50
62
|
}
|
|
@@ -59,8 +71,8 @@ export type HttpRequestLike =
|
|
|
59
71
|
}
|
|
60
72
|
|
|
61
73
|
/**
|
|
62
|
-
* A function that returns a ref string. Used to configure which ref the client
|
|
63
|
-
* from.
|
|
74
|
+
* A function that returns a ref string. Used to configure which ref the client
|
|
75
|
+
* queries content from.
|
|
64
76
|
*/
|
|
65
77
|
type GetRef = (
|
|
66
78
|
params?: Pick<BuildQueryURLArgs, "accessToken"> & FetchParams,
|
|
@@ -69,9 +81,9 @@ type GetRef = (
|
|
|
69
81
|
/** Parameters for client methods that use `fetch()`. */
|
|
70
82
|
export type FetchParams = {
|
|
71
83
|
/**
|
|
72
|
-
* Options provided to the client's `fetch()` on all network requests. These
|
|
73
|
-
* merged with internally required options. They can also be
|
|
74
|
-
* the query's `fetchOptions` parameter.
|
|
84
|
+
* Options provided to the client's `fetch()` on all network requests. These
|
|
85
|
+
* options will be merged with internally required options. They can also be
|
|
86
|
+
* overriden on a per-query basis using the query's `fetchOptions` parameter.
|
|
75
87
|
*/
|
|
76
88
|
fetchOptions?: RequestInitLike
|
|
77
89
|
/** @deprecated Move to `fetchOptions.signal`: */
|
|
@@ -94,28 +106,31 @@ export type ClientConfig = {
|
|
|
94
106
|
*/
|
|
95
107
|
accessToken?: string
|
|
96
108
|
/**
|
|
97
|
-
* The version of the repository's content. It can optionally be a function
|
|
109
|
+
* The version of the repository's content. It can optionally be a function
|
|
110
|
+
* that returns a ref.
|
|
98
111
|
*
|
|
99
112
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}
|
|
100
113
|
*/
|
|
101
114
|
ref?: string | GetRef
|
|
102
115
|
/**
|
|
103
|
-
* A list of route resolver objects that define how a document's `url`
|
|
116
|
+
* A list of route resolver objects that define how a document's `url`
|
|
117
|
+
* property is resolved.
|
|
104
118
|
*
|
|
105
119
|
* @see {@link https://prismic.io/docs/routes}
|
|
106
120
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}
|
|
107
121
|
*/
|
|
108
122
|
routes?: NonNullable<BuildQueryURLArgs["routes"]>
|
|
109
123
|
/**
|
|
110
|
-
* The URL used for link or content relationship fields that point to an
|
|
124
|
+
* The URL used for link or content relationship fields that point to an
|
|
125
|
+
* archived or deleted page.
|
|
111
126
|
*
|
|
112
127
|
* @see {@link https://prismic.io/docs/routes}
|
|
113
128
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}
|
|
114
129
|
*/
|
|
115
130
|
brokenRoute?: NonNullable<BuildQueryURLArgs["brokenRoute"]>
|
|
116
131
|
/**
|
|
117
|
-
* Default parameters sent with each Content API request. These parameters can
|
|
118
|
-
* each method.
|
|
132
|
+
* Default parameters sent with each Content API request. These parameters can
|
|
133
|
+
* be overridden on each method.
|
|
119
134
|
*
|
|
120
135
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}
|
|
121
136
|
*/
|
|
@@ -127,12 +142,13 @@ export type ClientConfig = {
|
|
|
127
142
|
* The `fetch` function used to make network requests.
|
|
128
143
|
*
|
|
129
144
|
* @default The global `fetch` function.
|
|
145
|
+
*
|
|
130
146
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}
|
|
131
147
|
*/
|
|
132
148
|
fetch?: FetchLike
|
|
133
149
|
/**
|
|
134
|
-
* The default `fetch` options sent with each Content API request. These
|
|
135
|
-
* overriden on each method.
|
|
150
|
+
* The default `fetch` options sent with each Content API request. These
|
|
151
|
+
* parameters can be overriden on each method.
|
|
136
152
|
*
|
|
137
153
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}
|
|
138
154
|
*/
|
|
@@ -140,8 +156,8 @@ export type ClientConfig = {
|
|
|
140
156
|
}
|
|
141
157
|
|
|
142
158
|
/**
|
|
143
|
-
* Parameters specific to client methods that fetch all documents. These methods
|
|
144
|
-
* (e.g. `getAllByType`).
|
|
159
|
+
* Parameters specific to client methods that fetch all documents. These methods
|
|
160
|
+
* start with `getAll` (e.g. `getAllByType`).
|
|
145
161
|
*/
|
|
146
162
|
type GetAllParams = {
|
|
147
163
|
/**
|
|
@@ -172,36 +188,42 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
172
188
|
*/
|
|
173
189
|
accessToken?: string
|
|
174
190
|
/**
|
|
175
|
-
* A list of route resolver objects that define how a document's `url`
|
|
191
|
+
* A list of route resolver objects that define how a document's `url`
|
|
192
|
+
* property is resolved.
|
|
176
193
|
*
|
|
177
194
|
* @see {@link https://prismic.io/docs/routes}
|
|
178
195
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}
|
|
179
196
|
*/
|
|
180
197
|
routes?: NonNullable<BuildQueryURLArgs["routes"]>
|
|
181
198
|
/**
|
|
182
|
-
* The URL used for link or content relationship fields that point to an
|
|
199
|
+
* The URL used for link or content relationship fields that point to an
|
|
200
|
+
* archived or deleted page.
|
|
183
201
|
*
|
|
184
202
|
* @see {@link https://prismic.io/docs/routes}
|
|
185
203
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}
|
|
186
204
|
*/
|
|
187
205
|
brokenRoute?: NonNullable<BuildQueryURLArgs["brokenRoute"]>
|
|
188
206
|
/**
|
|
189
|
-
* Default parameters sent with each Content API request. These parameters can
|
|
190
|
-
* each method.
|
|
207
|
+
* Default parameters sent with each Content API request. These parameters can
|
|
208
|
+
* be overridden on each method.
|
|
191
209
|
*
|
|
192
210
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}
|
|
193
211
|
*/
|
|
194
|
-
defaultParams?: Omit<
|
|
212
|
+
defaultParams?: Omit<
|
|
213
|
+
BuildQueryURLArgs,
|
|
214
|
+
"ref" | "integrationFieldsRef" | "accessToken" | "routes"
|
|
215
|
+
>
|
|
195
216
|
/**
|
|
196
217
|
* The `fetch` function used to make network requests.
|
|
197
218
|
*
|
|
198
219
|
* @default The global `fetch` function.
|
|
220
|
+
*
|
|
199
221
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}
|
|
200
222
|
*/
|
|
201
223
|
fetchFn: FetchLike
|
|
202
224
|
/**
|
|
203
|
-
* The default `fetch` options sent with each Content API request. These
|
|
204
|
-
* overriden on each method.
|
|
225
|
+
* The default `fetch` options sent with each Content API request. These
|
|
226
|
+
* parameters can be overriden on each method.
|
|
205
227
|
*
|
|
206
228
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}
|
|
207
229
|
*/
|
|
@@ -217,8 +239,8 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
217
239
|
#cachedRepositoryExpiration = 0 // Timestamp
|
|
218
240
|
|
|
219
241
|
/**
|
|
220
|
-
* @param repositoryNameOrEndpoint - The Prismic repository name or full
|
|
221
|
-
* the repository.
|
|
242
|
+
* @param repositoryNameOrEndpoint - The Prismic repository name or full
|
|
243
|
+
* Content API endpoint for the repository.
|
|
222
244
|
* @param config - Client configuration.
|
|
223
245
|
*/
|
|
224
246
|
constructor(repositoryNameOrEndpoint: string, config: ClientConfig = {}) {
|
|
@@ -291,8 +313,12 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
291
313
|
}
|
|
292
314
|
if (
|
|
293
315
|
process.env.NODE_ENV === "development" &&
|
|
294
|
-
/\.prismic\.io$/i.test(
|
|
295
|
-
|
|
316
|
+
/\.prismic\.io$/i.test(
|
|
317
|
+
new URL(this.documentAPIEndpoint).hostname,
|
|
318
|
+
) &&
|
|
319
|
+
!/\.cdn\.prismic\.io$/i.test(
|
|
320
|
+
new URL(this.documentAPIEndpoint).hostname,
|
|
321
|
+
)
|
|
296
322
|
) {
|
|
297
323
|
console.warn(
|
|
298
324
|
`[@prismicio/client] The client was created with a non-CDN endpoint. Convert it to the CDN endpoint for better performance. For more details, see ${devMsg("endpoint-must-use-cdn")}`,
|
|
@@ -345,9 +371,10 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
345
371
|
* Enables the client to automatically query content from a preview session.
|
|
346
372
|
*
|
|
347
373
|
* @example
|
|
348
|
-
*
|
|
349
|
-
*
|
|
350
|
-
*
|
|
374
|
+
*
|
|
375
|
+
* ```ts
|
|
376
|
+
* client.enableAutoPreviews()
|
|
377
|
+
* ```
|
|
351
378
|
*
|
|
352
379
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#enableautopreviews}
|
|
353
380
|
*/
|
|
@@ -356,13 +383,14 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
356
383
|
}
|
|
357
384
|
|
|
358
385
|
/**
|
|
359
|
-
* Enables the client to automatically query content from a preview session
|
|
360
|
-
* object.
|
|
386
|
+
* Enables the client to automatically query content from a preview session
|
|
387
|
+
* using an HTTP request object.
|
|
361
388
|
*
|
|
362
389
|
* @example
|
|
363
|
-
*
|
|
364
|
-
*
|
|
365
|
-
*
|
|
390
|
+
*
|
|
391
|
+
* ```ts
|
|
392
|
+
* client.enableAutoPreviewsFromReq(req)
|
|
393
|
+
* ```
|
|
366
394
|
*
|
|
367
395
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#enableautopreviewsfromreq}
|
|
368
396
|
*/
|
|
@@ -372,12 +400,14 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
372
400
|
}
|
|
373
401
|
|
|
374
402
|
/**
|
|
375
|
-
* Disables the client from automatically querying content from a preview
|
|
403
|
+
* Disables the client from automatically querying content from a preview
|
|
404
|
+
* session.
|
|
376
405
|
*
|
|
377
406
|
* @example
|
|
378
|
-
*
|
|
379
|
-
*
|
|
380
|
-
*
|
|
407
|
+
*
|
|
408
|
+
* ```ts
|
|
409
|
+
* client.disableAutoPreviews()
|
|
410
|
+
* ```
|
|
381
411
|
*
|
|
382
412
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#disableautopreviews}
|
|
383
413
|
*/
|
|
@@ -390,9 +420,10 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
390
420
|
* Fetches pages based on the `params` argument. Results are paginated.
|
|
391
421
|
*
|
|
392
422
|
* @example
|
|
393
|
-
*
|
|
394
|
-
*
|
|
395
|
-
*
|
|
423
|
+
*
|
|
424
|
+
* ```ts
|
|
425
|
+
* const response = await client.get({ pageSize: 10 })
|
|
426
|
+
* ```
|
|
396
427
|
*
|
|
397
428
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#get}
|
|
398
429
|
*/
|
|
@@ -408,16 +439,18 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
408
439
|
* Fetches the first page returned based on the `params` argument.
|
|
409
440
|
*
|
|
410
441
|
* @example
|
|
411
|
-
*
|
|
412
|
-
*
|
|
413
|
-
*
|
|
442
|
+
*
|
|
443
|
+
* ```ts
|
|
444
|
+
* const page = await client.getFirst()
|
|
445
|
+
* ```
|
|
414
446
|
*
|
|
415
447
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getfirst}
|
|
416
448
|
*/
|
|
417
449
|
async getFirst<TDocument extends TDocuments>(
|
|
418
450
|
params?: Partial<BuildQueryURLArgs> & FetchParams,
|
|
419
451
|
): Promise<TDocument> {
|
|
420
|
-
const actualParams =
|
|
452
|
+
const actualParams =
|
|
453
|
+
params?.page || params?.pageSize ? params : { ...params, pageSize: 1 }
|
|
421
454
|
const response = await this.#internalGet(actualParams)
|
|
422
455
|
const { results }: Query<TDocument> = await response.clone().json()
|
|
423
456
|
|
|
@@ -425,22 +458,29 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
425
458
|
return results[0]
|
|
426
459
|
}
|
|
427
460
|
|
|
428
|
-
throw new NotFoundError(
|
|
461
|
+
throw new NotFoundError(
|
|
462
|
+
"No documents were returned",
|
|
463
|
+
response.url,
|
|
464
|
+
undefined,
|
|
465
|
+
)
|
|
429
466
|
}
|
|
430
467
|
|
|
431
468
|
/**
|
|
432
|
-
* Fetches all pages based on the `params` argument. This method may make
|
|
433
|
-
* requests to fetch all matching pages.
|
|
469
|
+
* Fetches all pages based on the `params` argument. This method may make
|
|
470
|
+
* multiple network requests to fetch all matching pages.
|
|
434
471
|
*
|
|
435
472
|
* @example
|
|
436
|
-
*
|
|
437
|
-
*
|
|
438
|
-
*
|
|
473
|
+
*
|
|
474
|
+
* ```ts
|
|
475
|
+
* const pages = await client.dangerouslyGetAll()
|
|
476
|
+
* ```
|
|
439
477
|
*
|
|
440
478
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#dangerouslygetall}
|
|
441
479
|
*/
|
|
442
480
|
async dangerouslyGetAll<TDocument extends TDocuments>(
|
|
443
|
-
params: Partial<Omit<BuildQueryURLArgs, "page">> &
|
|
481
|
+
params: Partial<Omit<BuildQueryURLArgs, "page">> &
|
|
482
|
+
GetAllParams &
|
|
483
|
+
FetchParams = {},
|
|
444
484
|
): Promise<TDocument[]> {
|
|
445
485
|
const { limit = Infinity, ...actualParams } = params
|
|
446
486
|
const resolvedParams = {
|
|
@@ -454,7 +494,10 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
454
494
|
const documents: TDocument[] = []
|
|
455
495
|
let latestResult: Query<TDocument> | undefined
|
|
456
496
|
|
|
457
|
-
while (
|
|
497
|
+
while (
|
|
498
|
+
(!latestResult || latestResult.next_page) &&
|
|
499
|
+
documents.length < limit
|
|
500
|
+
) {
|
|
458
501
|
const page = latestResult ? latestResult.page + 1 : undefined
|
|
459
502
|
|
|
460
503
|
latestResult = await this.get<TDocument>({ ...resolvedParams, page })
|
|
@@ -472,9 +515,10 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
472
515
|
* Fetches a page with a specific ID.
|
|
473
516
|
*
|
|
474
517
|
* @example
|
|
475
|
-
*
|
|
476
|
-
*
|
|
477
|
-
*
|
|
518
|
+
*
|
|
519
|
+
* ```ts
|
|
520
|
+
* const page = await client.getByID("WW4bKScAAMAqmluX")
|
|
521
|
+
* ```
|
|
478
522
|
*
|
|
479
523
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbyid}
|
|
480
524
|
*/
|
|
@@ -482,16 +526,22 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
482
526
|
id: string,
|
|
483
527
|
params?: Partial<BuildQueryURLArgs> & FetchParams,
|
|
484
528
|
): Promise<TDocument> {
|
|
485
|
-
return await this.getFirst<TDocument>(
|
|
529
|
+
return await this.getFirst<TDocument>(
|
|
530
|
+
appendFilters(params, filter.at("document.id", id)),
|
|
531
|
+
)
|
|
486
532
|
}
|
|
487
533
|
|
|
488
534
|
/**
|
|
489
535
|
* Fetches pages with specific IDs. Results are paginated.
|
|
490
536
|
*
|
|
491
537
|
* @example
|
|
492
|
-
*
|
|
493
|
-
*
|
|
494
|
-
*
|
|
538
|
+
*
|
|
539
|
+
* ```ts
|
|
540
|
+
* const response = await client.getByIDs([
|
|
541
|
+
* "WW4bKScAAMAqmluX",
|
|
542
|
+
* "U1kTRgEAAC8A5ldS",
|
|
543
|
+
* ])
|
|
544
|
+
* ```
|
|
495
545
|
*
|
|
496
546
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbyids}
|
|
497
547
|
*/
|
|
@@ -499,23 +549,31 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
499
549
|
ids: string[],
|
|
500
550
|
params?: Partial<BuildQueryURLArgs> & FetchParams,
|
|
501
551
|
): Promise<Query<TDocument>> {
|
|
502
|
-
return await this.get<TDocument>(
|
|
552
|
+
return await this.get<TDocument>(
|
|
553
|
+
appendFilters(params, filter.in("document.id", ids)),
|
|
554
|
+
)
|
|
503
555
|
}
|
|
504
556
|
|
|
505
557
|
/**
|
|
506
|
-
* Fetches pages with specific IDs. This method may make multiple network
|
|
507
|
-
* matching pages.
|
|
558
|
+
* Fetches pages with specific IDs. This method may make multiple network
|
|
559
|
+
* requests to fetch all matching pages.
|
|
508
560
|
*
|
|
509
561
|
* @example
|
|
510
|
-
*
|
|
511
|
-
*
|
|
512
|
-
*
|
|
562
|
+
*
|
|
563
|
+
* ```ts
|
|
564
|
+
* const pages = await client.getAllByIDs([
|
|
565
|
+
* "WW4bKScAAMAqmluX",
|
|
566
|
+
* "U1kTRgEAAC8A5ldS",
|
|
567
|
+
* ])
|
|
568
|
+
* ```
|
|
513
569
|
*
|
|
514
570
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getallbyids}
|
|
515
571
|
*/
|
|
516
572
|
async getAllByIDs<TDocument extends TDocuments>(
|
|
517
573
|
ids: string[],
|
|
518
|
-
params?: Partial<Omit<BuildQueryURLArgs, "page">> &
|
|
574
|
+
params?: Partial<Omit<BuildQueryURLArgs, "page">> &
|
|
575
|
+
GetAllParams &
|
|
576
|
+
FetchParams,
|
|
519
577
|
): Promise<TDocument[]> {
|
|
520
578
|
return await this.dangerouslyGetAll<TDocument>(
|
|
521
579
|
appendFilters(params, filter.in("document.id", ids)),
|
|
@@ -526,9 +584,10 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
526
584
|
* Fetches a page with a specific UID and type.
|
|
527
585
|
*
|
|
528
586
|
* @example
|
|
529
|
-
*
|
|
530
|
-
*
|
|
531
|
-
*
|
|
587
|
+
*
|
|
588
|
+
* ```ts
|
|
589
|
+
* const page = await client.getByUID("blog_post", "my-first-post")
|
|
590
|
+
* ```
|
|
532
591
|
*
|
|
533
592
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbyuid}
|
|
534
593
|
*/
|
|
@@ -550,12 +609,17 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
550
609
|
}
|
|
551
610
|
|
|
552
611
|
/**
|
|
553
|
-
* Fetches pages with specific UIDs and a specific type. Results are
|
|
612
|
+
* Fetches pages with specific UIDs and a specific type. Results are
|
|
613
|
+
* paginated.
|
|
554
614
|
*
|
|
555
615
|
* @example
|
|
556
|
-
*
|
|
557
|
-
*
|
|
558
|
-
*
|
|
616
|
+
*
|
|
617
|
+
* ```ts
|
|
618
|
+
* const response = await client.getByUIDs("blog_post", [
|
|
619
|
+
* "my-first-post",
|
|
620
|
+
* "my-second-post",
|
|
621
|
+
* ])
|
|
622
|
+
* ```
|
|
559
623
|
*
|
|
560
624
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbyuids}
|
|
561
625
|
*/
|
|
@@ -577,13 +641,17 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
577
641
|
}
|
|
578
642
|
|
|
579
643
|
/**
|
|
580
|
-
* Fetches pages with specific UIDs and a specific type. This method may make
|
|
581
|
-
* requests to fetch all matching pages.
|
|
644
|
+
* Fetches pages with specific UIDs and a specific type. This method may make
|
|
645
|
+
* multiple network requests to fetch all matching pages.
|
|
582
646
|
*
|
|
583
647
|
* @example
|
|
584
|
-
*
|
|
585
|
-
*
|
|
586
|
-
*
|
|
648
|
+
*
|
|
649
|
+
* ```ts
|
|
650
|
+
* const pages = await client.getAllByUIDs("blog_post", [
|
|
651
|
+
* "my-first-post",
|
|
652
|
+
* "my-second-post",
|
|
653
|
+
* ])
|
|
654
|
+
* ```
|
|
587
655
|
*
|
|
588
656
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getallbyuids}
|
|
589
657
|
*/
|
|
@@ -593,9 +661,13 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
593
661
|
>(
|
|
594
662
|
documentType: TDocumentType,
|
|
595
663
|
uids: string[],
|
|
596
|
-
params?: Partial<Omit<BuildQueryURLArgs, "page">> &
|
|
664
|
+
params?: Partial<Omit<BuildQueryURLArgs, "page">> &
|
|
665
|
+
GetAllParams &
|
|
666
|
+
FetchParams,
|
|
597
667
|
): Promise<ExtractDocumentType<TDocument, TDocumentType>[]> {
|
|
598
|
-
return await this.dangerouslyGetAll<
|
|
668
|
+
return await this.dangerouslyGetAll<
|
|
669
|
+
ExtractDocumentType<TDocument, TDocumentType>
|
|
670
|
+
>(
|
|
599
671
|
appendFilters(
|
|
600
672
|
params,
|
|
601
673
|
filter.at("document.type", documentType),
|
|
@@ -608,9 +680,10 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
608
680
|
* Fetches a specific single type page.
|
|
609
681
|
*
|
|
610
682
|
* @example
|
|
611
|
-
*
|
|
612
|
-
*
|
|
613
|
-
*
|
|
683
|
+
*
|
|
684
|
+
* ```ts
|
|
685
|
+
* const page = await client.getSingle("settings")
|
|
686
|
+
* ```
|
|
614
687
|
*
|
|
615
688
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getsingle}
|
|
616
689
|
*/
|
|
@@ -630,9 +703,10 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
630
703
|
* Fetches pages with a specific type. Results are paginated.
|
|
631
704
|
*
|
|
632
705
|
* @example
|
|
633
|
-
*
|
|
634
|
-
*
|
|
635
|
-
*
|
|
706
|
+
*
|
|
707
|
+
* ```ts
|
|
708
|
+
* const response = await client.getByType("blog_post")
|
|
709
|
+
* ```
|
|
636
710
|
*
|
|
637
711
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbytype}
|
|
638
712
|
*/
|
|
@@ -649,13 +723,14 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
649
723
|
}
|
|
650
724
|
|
|
651
725
|
/**
|
|
652
|
-
* Fetches pages with a specific type. This method may make multiple network
|
|
653
|
-
* matching documents.
|
|
726
|
+
* Fetches pages with a specific type. This method may make multiple network
|
|
727
|
+
* requests to fetch all matching documents.
|
|
654
728
|
*
|
|
655
729
|
* @example
|
|
656
|
-
*
|
|
657
|
-
*
|
|
658
|
-
*
|
|
730
|
+
*
|
|
731
|
+
* ```ts
|
|
732
|
+
* const pages = await client.getAllByType("blog_post")
|
|
733
|
+
* ```
|
|
659
734
|
*
|
|
660
735
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getallbytype}
|
|
661
736
|
*/
|
|
@@ -664,20 +739,23 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
664
739
|
TDocumentType extends TDocument["type"] = TDocument["type"],
|
|
665
740
|
>(
|
|
666
741
|
documentType: TDocumentType,
|
|
667
|
-
params?: Partial<Omit<BuildQueryURLArgs, "page">> &
|
|
742
|
+
params?: Partial<Omit<BuildQueryURLArgs, "page">> &
|
|
743
|
+
GetAllParams &
|
|
744
|
+
FetchParams,
|
|
668
745
|
): Promise<ExtractDocumentType<TDocument, TDocumentType>[]> {
|
|
669
|
-
return await this.dangerouslyGetAll<
|
|
670
|
-
|
|
671
|
-
)
|
|
746
|
+
return await this.dangerouslyGetAll<
|
|
747
|
+
ExtractDocumentType<TDocument, TDocumentType>
|
|
748
|
+
>(appendFilters(params, filter.at("document.type", documentType)))
|
|
672
749
|
}
|
|
673
750
|
|
|
674
751
|
/**
|
|
675
752
|
* Fetches pages with a specific tag. Results are paginated.
|
|
676
753
|
*
|
|
677
754
|
* @example
|
|
678
|
-
*
|
|
679
|
-
*
|
|
680
|
-
*
|
|
755
|
+
*
|
|
756
|
+
* ```ts
|
|
757
|
+
* const response = await client.getByTag("featured")
|
|
758
|
+
* ```
|
|
681
759
|
*
|
|
682
760
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbytag}
|
|
683
761
|
*/
|
|
@@ -685,23 +763,28 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
685
763
|
tag: string,
|
|
686
764
|
params?: Partial<BuildQueryURLArgs> & FetchParams,
|
|
687
765
|
): Promise<Query<TDocument>> {
|
|
688
|
-
return await this.get<TDocument>(
|
|
766
|
+
return await this.get<TDocument>(
|
|
767
|
+
appendFilters(params, filter.any("document.tags", [tag])),
|
|
768
|
+
)
|
|
689
769
|
}
|
|
690
770
|
|
|
691
771
|
/**
|
|
692
|
-
* Fetches pages with a specific tag. This method may make multiple network
|
|
693
|
-
* matching documents.
|
|
772
|
+
* Fetches pages with a specific tag. This method may make multiple network
|
|
773
|
+
* requests to fetch all matching documents.
|
|
694
774
|
*
|
|
695
775
|
* @example
|
|
696
|
-
*
|
|
697
|
-
*
|
|
698
|
-
*
|
|
776
|
+
*
|
|
777
|
+
* ```ts
|
|
778
|
+
* const pages = await client.getAllByTag("featured")
|
|
779
|
+
* ```
|
|
699
780
|
*
|
|
700
781
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getallbytag}
|
|
701
782
|
*/
|
|
702
783
|
async getAllByTag<TDocument extends TDocuments>(
|
|
703
784
|
tag: string,
|
|
704
|
-
params?: Partial<Omit<BuildQueryURLArgs, "page">> &
|
|
785
|
+
params?: Partial<Omit<BuildQueryURLArgs, "page">> &
|
|
786
|
+
GetAllParams &
|
|
787
|
+
FetchParams,
|
|
705
788
|
): Promise<TDocument[]> {
|
|
706
789
|
return await this.dangerouslyGetAll<TDocument>(
|
|
707
790
|
appendFilters(params, filter.any("document.tags", [tag])),
|
|
@@ -712,9 +795,10 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
712
795
|
* Fetches pages with every tag from a list of tags. Results are paginated.
|
|
713
796
|
*
|
|
714
797
|
* @example
|
|
715
|
-
*
|
|
716
|
-
*
|
|
717
|
-
*
|
|
798
|
+
*
|
|
799
|
+
* ```ts
|
|
800
|
+
* const response = await client.getByEveryTag(["featured", "homepage"])
|
|
801
|
+
* ```
|
|
718
802
|
*
|
|
719
803
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbyeverytag}
|
|
720
804
|
*/
|
|
@@ -722,23 +806,28 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
722
806
|
tags: string[],
|
|
723
807
|
params?: Partial<BuildQueryURLArgs> & FetchParams,
|
|
724
808
|
): Promise<Query<TDocument>> {
|
|
725
|
-
return await this.get<TDocument>(
|
|
809
|
+
return await this.get<TDocument>(
|
|
810
|
+
appendFilters(params, filter.at("document.tags", tags)),
|
|
811
|
+
)
|
|
726
812
|
}
|
|
727
813
|
|
|
728
814
|
/**
|
|
729
|
-
* Fetches pages with every tag from a list of tags. This method may make
|
|
730
|
-
* requests to fetch all matching pages.
|
|
815
|
+
* Fetches pages with every tag from a list of tags. This method may make
|
|
816
|
+
* multiple network requests to fetch all matching pages.
|
|
731
817
|
*
|
|
732
818
|
* @example
|
|
733
|
-
*
|
|
734
|
-
*
|
|
735
|
-
*
|
|
819
|
+
*
|
|
820
|
+
* ```ts
|
|
821
|
+
* const pages = await client.getAllByEveryTag(["featured", "homepage"])
|
|
822
|
+
* ```
|
|
736
823
|
*
|
|
737
824
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getallbyeverytag}
|
|
738
825
|
*/
|
|
739
826
|
async getAllByEveryTag<TDocument extends TDocuments>(
|
|
740
827
|
tags: string[],
|
|
741
|
-
params?: Partial<Omit<BuildQueryURLArgs, "page">> &
|
|
828
|
+
params?: Partial<Omit<BuildQueryURLArgs, "page">> &
|
|
829
|
+
GetAllParams &
|
|
830
|
+
FetchParams,
|
|
742
831
|
): Promise<TDocument[]> {
|
|
743
832
|
return await this.dangerouslyGetAll<TDocument>(
|
|
744
833
|
appendFilters(params, filter.at("document.tags", tags)),
|
|
@@ -746,12 +835,14 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
746
835
|
}
|
|
747
836
|
|
|
748
837
|
/**
|
|
749
|
-
* Fetches pages with at least one tag from a list of tags. Results are
|
|
838
|
+
* Fetches pages with at least one tag from a list of tags. Results are
|
|
839
|
+
* paginated.
|
|
750
840
|
*
|
|
751
841
|
* @example
|
|
752
|
-
*
|
|
753
|
-
*
|
|
754
|
-
*
|
|
842
|
+
*
|
|
843
|
+
* ```ts
|
|
844
|
+
* const response = await client.getBySomeTags(["featured", "homepage"])
|
|
845
|
+
* ```
|
|
755
846
|
*
|
|
756
847
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbysometags}
|
|
757
848
|
*/
|
|
@@ -759,23 +850,28 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
759
850
|
tags: string[],
|
|
760
851
|
params?: Partial<BuildQueryURLArgs> & FetchParams,
|
|
761
852
|
): Promise<Query<TDocument>> {
|
|
762
|
-
return await this.get<TDocument>(
|
|
853
|
+
return await this.get<TDocument>(
|
|
854
|
+
appendFilters(params, filter.any("document.tags", tags)),
|
|
855
|
+
)
|
|
763
856
|
}
|
|
764
857
|
|
|
765
858
|
/**
|
|
766
|
-
* Fetches pages with at least one tag from a list of tags. This method may
|
|
767
|
-
* requests to fetch all matching documents.
|
|
859
|
+
* Fetches pages with at least one tag from a list of tags. This method may
|
|
860
|
+
* make multiple network requests to fetch all matching documents.
|
|
768
861
|
*
|
|
769
862
|
* @example
|
|
770
|
-
*
|
|
771
|
-
*
|
|
772
|
-
*
|
|
863
|
+
*
|
|
864
|
+
* ```ts
|
|
865
|
+
* const pages = await client.getAllBySomeTags(["featured", "homepage"])
|
|
866
|
+
* ```
|
|
773
867
|
*
|
|
774
868
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getallbysometags}
|
|
775
869
|
*/
|
|
776
870
|
async getAllBySomeTags<TDocument extends TDocuments>(
|
|
777
871
|
tags: string[],
|
|
778
|
-
params?: Partial<Omit<BuildQueryURLArgs, "page">> &
|
|
872
|
+
params?: Partial<Omit<BuildQueryURLArgs, "page">> &
|
|
873
|
+
GetAllParams &
|
|
874
|
+
FetchParams,
|
|
779
875
|
): Promise<TDocument[]> {
|
|
780
876
|
return await this.dangerouslyGetAll<TDocument>(
|
|
781
877
|
appendFilters(params, filter.any("document.tags", tags)),
|
|
@@ -786,16 +882,20 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
786
882
|
* Fetches metadata about the client's Prismic repository.
|
|
787
883
|
*
|
|
788
884
|
* @example
|
|
789
|
-
*
|
|
790
|
-
*
|
|
791
|
-
*
|
|
885
|
+
*
|
|
886
|
+
* ```ts
|
|
887
|
+
* const repository = await client.getRepository()
|
|
888
|
+
* ```
|
|
792
889
|
*
|
|
793
890
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getrepository}
|
|
794
891
|
*/
|
|
795
892
|
async getRepository(
|
|
796
893
|
params?: Pick<BuildQueryURLArgs, "accessToken"> & FetchParams,
|
|
797
894
|
): Promise<Repository> {
|
|
798
|
-
if (
|
|
895
|
+
if (
|
|
896
|
+
this.#cachedRepository &&
|
|
897
|
+
this.#cachedRepositoryExpiration > Date.now()
|
|
898
|
+
) {
|
|
799
899
|
return this.#cachedRepository
|
|
800
900
|
}
|
|
801
901
|
|
|
@@ -830,9 +930,10 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
830
930
|
* Fetches the repository's active refs.
|
|
831
931
|
*
|
|
832
932
|
* @example
|
|
833
|
-
*
|
|
834
|
-
*
|
|
835
|
-
*
|
|
933
|
+
*
|
|
934
|
+
* ```ts
|
|
935
|
+
* const refs = await client.getRefs()
|
|
936
|
+
* ```
|
|
836
937
|
*
|
|
837
938
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getrefs}
|
|
838
939
|
*/
|
|
@@ -846,9 +947,10 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
846
947
|
* Fetches a ref by its ID.
|
|
847
948
|
*
|
|
848
949
|
* @example
|
|
849
|
-
*
|
|
850
|
-
*
|
|
851
|
-
*
|
|
950
|
+
*
|
|
951
|
+
* ```ts
|
|
952
|
+
* const ref = await client.getRefByID("YhE3YhEAACIA4321")
|
|
953
|
+
* ```
|
|
852
954
|
*
|
|
853
955
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getrefbyid}
|
|
854
956
|
*/
|
|
@@ -857,19 +959,25 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
857
959
|
const ref = refs.find((ref) => ref.id === id)
|
|
858
960
|
|
|
859
961
|
if (!ref) {
|
|
860
|
-
throw new PrismicError(
|
|
962
|
+
throw new PrismicError(
|
|
963
|
+
`Ref with ID "${id}" could not be found.`,
|
|
964
|
+
undefined,
|
|
965
|
+
undefined,
|
|
966
|
+
)
|
|
861
967
|
}
|
|
862
968
|
|
|
863
969
|
return ref
|
|
864
970
|
}
|
|
865
971
|
|
|
866
972
|
/**
|
|
867
|
-
* Fetches a ref by its label. A release ref's label is its name shown in the
|
|
973
|
+
* Fetches a ref by its label. A release ref's label is its name shown in the
|
|
974
|
+
* Page Builder.
|
|
868
975
|
*
|
|
869
976
|
* @example
|
|
870
|
-
*
|
|
871
|
-
*
|
|
872
|
-
*
|
|
977
|
+
*
|
|
978
|
+
* ```ts
|
|
979
|
+
* const ref = await client.getRefByLabel("My Release")
|
|
980
|
+
* ```
|
|
873
981
|
*
|
|
874
982
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getrefbylabel}
|
|
875
983
|
*/
|
|
@@ -878,7 +986,11 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
878
986
|
const ref = refs.find((ref) => ref.label === label)
|
|
879
987
|
|
|
880
988
|
if (!ref) {
|
|
881
|
-
throw new PrismicError(
|
|
989
|
+
throw new PrismicError(
|
|
990
|
+
`Ref with label "${label}" could not be found.`,
|
|
991
|
+
undefined,
|
|
992
|
+
undefined,
|
|
993
|
+
)
|
|
882
994
|
}
|
|
883
995
|
|
|
884
996
|
return ref
|
|
@@ -888,9 +1000,10 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
888
1000
|
* Fetches the repository's master ref.
|
|
889
1001
|
*
|
|
890
1002
|
* @example
|
|
891
|
-
*
|
|
892
|
-
*
|
|
893
|
-
*
|
|
1003
|
+
*
|
|
1004
|
+
* ```ts
|
|
1005
|
+
* const masterRef = await client.getMasterRef()
|
|
1006
|
+
* ```
|
|
894
1007
|
*
|
|
895
1008
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getmasterref}
|
|
896
1009
|
*/
|
|
@@ -899,7 +1012,11 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
899
1012
|
const ref = refs.find((ref) => ref.isMasterRef)
|
|
900
1013
|
|
|
901
1014
|
if (!ref) {
|
|
902
|
-
throw new PrismicError(
|
|
1015
|
+
throw new PrismicError(
|
|
1016
|
+
"Master ref could not be found.",
|
|
1017
|
+
undefined,
|
|
1018
|
+
undefined,
|
|
1019
|
+
)
|
|
903
1020
|
}
|
|
904
1021
|
|
|
905
1022
|
return ref
|
|
@@ -909,9 +1026,10 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
909
1026
|
* Fetches the repository's active releases.
|
|
910
1027
|
*
|
|
911
1028
|
* @example
|
|
912
|
-
*
|
|
913
|
-
*
|
|
914
|
-
*
|
|
1029
|
+
*
|
|
1030
|
+
* ```ts
|
|
1031
|
+
* const releases = await client.getReleases()
|
|
1032
|
+
* ```
|
|
915
1033
|
*
|
|
916
1034
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getreleases}
|
|
917
1035
|
*/
|
|
@@ -925,9 +1043,10 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
925
1043
|
* Fetches a release with a specific ID.
|
|
926
1044
|
*
|
|
927
1045
|
* @example
|
|
928
|
-
*
|
|
929
|
-
*
|
|
930
|
-
*
|
|
1046
|
+
*
|
|
1047
|
+
* ```ts
|
|
1048
|
+
* const release = await client.getReleaseByID("YhE3YhEAACIA4321")
|
|
1049
|
+
* ```
|
|
931
1050
|
*
|
|
932
1051
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getreleasebyid}
|
|
933
1052
|
*/
|
|
@@ -936,19 +1055,25 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
936
1055
|
const release = releases.find((ref) => ref.id === id)
|
|
937
1056
|
|
|
938
1057
|
if (!release) {
|
|
939
|
-
throw new PrismicError(
|
|
1058
|
+
throw new PrismicError(
|
|
1059
|
+
`Release with ID "${id}" could not be found.`,
|
|
1060
|
+
undefined,
|
|
1061
|
+
undefined,
|
|
1062
|
+
)
|
|
940
1063
|
}
|
|
941
1064
|
|
|
942
1065
|
return release
|
|
943
1066
|
}
|
|
944
1067
|
|
|
945
1068
|
/**
|
|
946
|
-
* Fetches a release by its label. A release ref's label is its name shown in
|
|
1069
|
+
* Fetches a release by its label. A release ref's label is its name shown in
|
|
1070
|
+
* the Page Builder.
|
|
947
1071
|
*
|
|
948
1072
|
* @example
|
|
949
|
-
*
|
|
950
|
-
*
|
|
951
|
-
*
|
|
1073
|
+
*
|
|
1074
|
+
* ```ts
|
|
1075
|
+
* const release = await client.getReleaseByLabel("My Release")
|
|
1076
|
+
* ```
|
|
952
1077
|
*
|
|
953
1078
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getreleasebylabel}
|
|
954
1079
|
*/
|
|
@@ -971,9 +1096,10 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
971
1096
|
* Fetches the repository's page tags.
|
|
972
1097
|
*
|
|
973
1098
|
* @example
|
|
974
|
-
*
|
|
975
|
-
*
|
|
976
|
-
*
|
|
1099
|
+
*
|
|
1100
|
+
* ```ts
|
|
1101
|
+
* const tags = await client.getTags()
|
|
1102
|
+
* ```
|
|
977
1103
|
*
|
|
978
1104
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#gettags}
|
|
979
1105
|
*/
|
|
@@ -999,11 +1125,12 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
999
1125
|
* Builds a Content API query URL with a set of parameters.
|
|
1000
1126
|
*
|
|
1001
1127
|
* @example
|
|
1002
|
-
*
|
|
1003
|
-
*
|
|
1004
|
-
*
|
|
1005
|
-
*
|
|
1006
|
-
*
|
|
1128
|
+
*
|
|
1129
|
+
* ```ts
|
|
1130
|
+
* const url = await client.buildQueryURL({
|
|
1131
|
+
* filters: [filter.at("document.type", "blog_post")],
|
|
1132
|
+
* })
|
|
1133
|
+
* ```
|
|
1007
1134
|
*
|
|
1008
1135
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#buildqueryurl}
|
|
1009
1136
|
*/
|
|
@@ -1045,12 +1172,13 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
1045
1172
|
* Fetches a previewed page's URL using a preview token and page ID.
|
|
1046
1173
|
*
|
|
1047
1174
|
* @example
|
|
1048
|
-
*
|
|
1049
|
-
*
|
|
1050
|
-
*
|
|
1051
|
-
*
|
|
1052
|
-
*
|
|
1053
|
-
*
|
|
1175
|
+
*
|
|
1176
|
+
* ```ts
|
|
1177
|
+
* const url = await client.resolvePreviewURL({
|
|
1178
|
+
* linkResolver,
|
|
1179
|
+
* defaultURL: "/",
|
|
1180
|
+
* })
|
|
1181
|
+
* ```
|
|
1054
1182
|
*
|
|
1055
1183
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#resolvepreviewurl}
|
|
1056
1184
|
*/
|
|
@@ -1076,15 +1204,23 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
1076
1204
|
previewToken = previewToken || searchParams.get("token")
|
|
1077
1205
|
} else if (this.#autoPreviewsRequest) {
|
|
1078
1206
|
if ("query" in this.#autoPreviewsRequest) {
|
|
1079
|
-
documentID =
|
|
1080
|
-
|
|
1081
|
-
|
|
1207
|
+
documentID =
|
|
1208
|
+
documentID || (this.#autoPreviewsRequest.query?.documentId as string)
|
|
1209
|
+
previewToken =
|
|
1210
|
+
previewToken || (this.#autoPreviewsRequest.query?.token as string)
|
|
1211
|
+
} else if (
|
|
1212
|
+
"url" in this.#autoPreviewsRequest &&
|
|
1213
|
+
this.#autoPreviewsRequest.url
|
|
1214
|
+
) {
|
|
1082
1215
|
// Including "missing-host://" by default
|
|
1083
1216
|
// handles a case where Next.js Route Handlers
|
|
1084
1217
|
// only provide the pathname and search
|
|
1085
1218
|
// parameters in the `url` property
|
|
1086
1219
|
// (e.g. `/api/preview?foo=bar`).
|
|
1087
|
-
const searchParams = new URL(
|
|
1220
|
+
const searchParams = new URL(
|
|
1221
|
+
this.#autoPreviewsRequest.url,
|
|
1222
|
+
"missing-host://",
|
|
1223
|
+
).searchParams
|
|
1088
1224
|
|
|
1089
1225
|
documentID = documentID || searchParams.get("documentId")
|
|
1090
1226
|
previewToken = previewToken || searchParams.get("token")
|
|
@@ -1110,12 +1246,14 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
1110
1246
|
}
|
|
1111
1247
|
|
|
1112
1248
|
/**
|
|
1113
|
-
* Configures the client to query the latest published content. This is the
|
|
1249
|
+
* Configures the client to query the latest published content. This is the
|
|
1250
|
+
* client's default mode.
|
|
1114
1251
|
*
|
|
1115
1252
|
* @example
|
|
1116
|
-
*
|
|
1117
|
-
*
|
|
1118
|
-
*
|
|
1253
|
+
*
|
|
1254
|
+
* ```ts
|
|
1255
|
+
* client.queryLatestContent()
|
|
1256
|
+
* ```
|
|
1119
1257
|
*
|
|
1120
1258
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querylatestcontent}
|
|
1121
1259
|
*/
|
|
@@ -1127,9 +1265,10 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
1127
1265
|
* Configures the client to query content from a release with a specific ID.
|
|
1128
1266
|
*
|
|
1129
1267
|
* @example
|
|
1130
|
-
*
|
|
1131
|
-
*
|
|
1132
|
-
*
|
|
1268
|
+
*
|
|
1269
|
+
* ```ts
|
|
1270
|
+
* client.queryContentFromReleaseByID("YhE3YhEAACIA4321")
|
|
1271
|
+
* ```
|
|
1133
1272
|
*
|
|
1134
1273
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querycontentfromreleasebyid}
|
|
1135
1274
|
*/
|
|
@@ -1141,12 +1280,14 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
1141
1280
|
}
|
|
1142
1281
|
|
|
1143
1282
|
/**
|
|
1144
|
-
* Configures the client to query content from a release with a specific
|
|
1283
|
+
* Configures the client to query content from a release with a specific
|
|
1284
|
+
* label.
|
|
1145
1285
|
*
|
|
1146
1286
|
* @example
|
|
1147
|
-
*
|
|
1148
|
-
*
|
|
1149
|
-
*
|
|
1287
|
+
*
|
|
1288
|
+
* ```ts
|
|
1289
|
+
* client.queryContentFromReleaseByLabel("My Release")
|
|
1290
|
+
* ```
|
|
1150
1291
|
*
|
|
1151
1292
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querycontentfromreleasebylabel}
|
|
1152
1293
|
*/
|
|
@@ -1161,9 +1302,10 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
1161
1302
|
* Configures the client to query content from a specific ref.
|
|
1162
1303
|
*
|
|
1163
1304
|
* @example
|
|
1164
|
-
*
|
|
1165
|
-
*
|
|
1166
|
-
*
|
|
1305
|
+
*
|
|
1306
|
+
* ```ts
|
|
1307
|
+
* client.queryContentFromRef("my-ref")
|
|
1308
|
+
* ```
|
|
1167
1309
|
*
|
|
1168
1310
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querycontentfromref}
|
|
1169
1311
|
*/
|
|
@@ -1172,25 +1314,26 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
1172
1314
|
}
|
|
1173
1315
|
|
|
1174
1316
|
/**
|
|
1175
|
-
* A preconfigured `fetch()` function for Prismic's GraphQL API that can be
|
|
1176
|
-
* clients.
|
|
1317
|
+
* A preconfigured `fetch()` function for Prismic's GraphQL API that can be
|
|
1318
|
+
* provided to GraphQL clients.
|
|
1177
1319
|
*
|
|
1178
1320
|
* @example
|
|
1179
|
-
* ```ts
|
|
1180
|
-
* import { createClient, getGraphQLEndpoint } from "@prismicio/client"
|
|
1181
1321
|
*
|
|
1182
|
-
*
|
|
1183
|
-
*
|
|
1322
|
+
* ```ts
|
|
1323
|
+
* import { createClient, getGraphQLEndpoint } from "@prismicio/client"
|
|
1324
|
+
*
|
|
1325
|
+
* const client = createClient("example-prismic-repo")
|
|
1326
|
+
* const graphQLClient = new ApolloClient({
|
|
1184
1327
|
* link: new HttpLink({
|
|
1185
|
-
*
|
|
1186
|
-
*
|
|
1187
|
-
*
|
|
1188
|
-
*
|
|
1189
|
-
*
|
|
1328
|
+
* uri: getGraphQLEndpoint(client.repositoryName),
|
|
1329
|
+
* // Provide `client.graphQLFetch` as the fetch implementation.
|
|
1330
|
+
* fetch: client.graphQLFetch,
|
|
1331
|
+
* // Using GET is required.
|
|
1332
|
+
* useGETForQueries: true,
|
|
1190
1333
|
* }),
|
|
1191
1334
|
* cache: new InMemoryCache(),
|
|
1192
|
-
*
|
|
1193
|
-
*
|
|
1335
|
+
* })
|
|
1336
|
+
* ```
|
|
1194
1337
|
*
|
|
1195
1338
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#graphqlfetch}
|
|
1196
1339
|
*/
|
|
@@ -1234,23 +1377,29 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
1234
1377
|
}
|
|
1235
1378
|
|
|
1236
1379
|
/**
|
|
1237
|
-
* Returns the ref needed to query based on the client's current state. This
|
|
1238
|
-
* network request to fetch a ref or resolve the user's ref
|
|
1380
|
+
* Returns the ref needed to query based on the client's current state. This
|
|
1381
|
+
* method may make a network request to fetch a ref or resolve the user's ref
|
|
1382
|
+
* thunk.
|
|
1239
1383
|
*
|
|
1240
1384
|
* If auto previews are enabled, the preview ref takes priority.
|
|
1241
1385
|
*
|
|
1242
1386
|
* The following strategies are used depending on the client's state:
|
|
1243
1387
|
*
|
|
1244
|
-
* - If the user called `queryLatestContent`: Use the repository's master ref.
|
|
1245
|
-
* 5 seconds. After 5 seconds, a new master ref is
|
|
1246
|
-
*
|
|
1247
|
-
*
|
|
1248
|
-
*
|
|
1249
|
-
*
|
|
1250
|
-
* - If the user called `
|
|
1251
|
-
*
|
|
1388
|
+
* - If the user called `queryLatestContent`: Use the repository's master ref.
|
|
1389
|
+
* The ref is cached for 5 seconds. After 5 seconds, a new master ref is
|
|
1390
|
+
* fetched.
|
|
1391
|
+
* - If the user called `queryContentFromReleaseByID`: Use the release's ref.
|
|
1392
|
+
* The ref is cached for 5 seconds. After 5 seconds, a new ref for the
|
|
1393
|
+
* release is fetched.
|
|
1394
|
+
* - If the user called `queryContentFromReleaseByLabel`: Use the release's ref.
|
|
1395
|
+
* The ref is cached for 5 seconds. After 5 seconds, a new ref for the
|
|
1396
|
+
* release is fetched.
|
|
1397
|
+
* - If the user called `queryContentFromRef`: Use the provided ref. Fall back
|
|
1398
|
+
* to the master ref if the ref is not a string.
|
|
1252
1399
|
*/
|
|
1253
|
-
async #getResolvedRef(
|
|
1400
|
+
async #getResolvedRef(
|
|
1401
|
+
params?: Pick<BuildQueryURLArgs, "accessToken"> & FetchParams,
|
|
1402
|
+
) {
|
|
1254
1403
|
if (this.#autoPreviews) {
|
|
1255
1404
|
const cookies = this.#autoPreviewsRequest?.headers
|
|
1256
1405
|
? "get" in this.#autoPreviewsRequest.headers
|
|
@@ -1273,8 +1422,8 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
1273
1422
|
}
|
|
1274
1423
|
|
|
1275
1424
|
/**
|
|
1276
|
-
* Performs a low-level Content API request with the given parameters.
|
|
1277
|
-
* invalid ref is used.
|
|
1425
|
+
* Performs a low-level Content API request with the given parameters.
|
|
1426
|
+
* Automatically retries if an invalid ref is used.
|
|
1278
1427
|
*/
|
|
1279
1428
|
async #internalGet(
|
|
1280
1429
|
params?: Partial<BuildQueryURLArgs> & FetchParams,
|
|
@@ -1291,7 +1440,8 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
1291
1440
|
return await this.#throwContentAPIError(response, url)
|
|
1292
1441
|
} catch (error) {
|
|
1293
1442
|
if (
|
|
1294
|
-
(error instanceof RefNotFoundError ||
|
|
1443
|
+
(error instanceof RefNotFoundError ||
|
|
1444
|
+
error instanceof RefExpiredError) &&
|
|
1295
1445
|
attempt < MAX_INVALID_REF_RETRY_ATTEMPTS
|
|
1296
1446
|
) {
|
|
1297
1447
|
// If no explicit ref is given (i.e. the master ref from
|
|
@@ -1302,7 +1452,8 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
1302
1452
|
this.#cachedRepository = undefined
|
|
1303
1453
|
}
|
|
1304
1454
|
|
|
1305
|
-
const masterRef = error.message.match(/master ref is: (?<ref>.*)$/i)
|
|
1455
|
+
const masterRef = error.message.match(/master ref is: (?<ref>.*)$/i)
|
|
1456
|
+
?.groups?.ref
|
|
1306
1457
|
if (!masterRef) {
|
|
1307
1458
|
throw error
|
|
1308
1459
|
}
|
|
@@ -1313,15 +1464,24 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
1313
1464
|
`[@prismicio/client] The ref (${badRef}) was ${issue}. Now retrying with the latest master ref (${masterRef}). If you were previewing content, the response will not include draft content.`,
|
|
1314
1465
|
)
|
|
1315
1466
|
|
|
1316
|
-
return await this.#internalGet(
|
|
1467
|
+
return await this.#internalGet(
|
|
1468
|
+
{ ...params, ref: masterRef },
|
|
1469
|
+
attempt + 1,
|
|
1470
|
+
)
|
|
1317
1471
|
}
|
|
1318
1472
|
|
|
1319
1473
|
throw error
|
|
1320
1474
|
}
|
|
1321
1475
|
}
|
|
1322
1476
|
|
|
1323
|
-
/**
|
|
1324
|
-
|
|
1477
|
+
/**
|
|
1478
|
+
* Throws an error based on a Content API response. Only call in known-errored
|
|
1479
|
+
* states.
|
|
1480
|
+
*/
|
|
1481
|
+
async #throwContentAPIError(
|
|
1482
|
+
response: ResponseLike,
|
|
1483
|
+
url: string,
|
|
1484
|
+
): Promise<never> {
|
|
1325
1485
|
switch (response.status) {
|
|
1326
1486
|
case 400: {
|
|
1327
1487
|
const json = await response.clone().json()
|
|
@@ -1368,7 +1528,10 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
1368
1528
|
...this.fetchOptions?.headers,
|
|
1369
1529
|
...params?.fetchOptions?.headers,
|
|
1370
1530
|
},
|
|
1371
|
-
signal:
|
|
1531
|
+
signal:
|
|
1532
|
+
params?.fetchOptions?.signal ||
|
|
1533
|
+
params?.signal ||
|
|
1534
|
+
this.fetchOptions?.signal,
|
|
1372
1535
|
},
|
|
1373
1536
|
this.fetchFn,
|
|
1374
1537
|
)
|