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