@prismicio/client 7.21.0 → 7.21.1-pr.425.573f39f
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 +920 -1256
- package/dist/Client.cjs.map +1 -1
- package/dist/Client.d.cts +704 -0
- package/dist/Client.d.cts.map +1 -0
- package/dist/Client.d.ts +678 -955
- package/dist/Client.d.ts.map +1 -0
- package/dist/Client.js +913 -1249
- package/dist/Client.js.map +1 -1
- package/dist/Migration.cjs +283 -296
- package/dist/Migration.cjs.map +1 -1
- package/dist/Migration.d.cts +216 -0
- package/dist/Migration.d.cts.map +1 -0
- package/dist/Migration.d.ts +197 -194
- package/dist/Migration.d.ts.map +1 -0
- package/dist/Migration.js +281 -294
- package/dist/Migration.js.map +1 -1
- package/dist/WriteClient.cjs +487 -574
- package/dist/WriteClient.cjs.map +1 -1
- package/dist/WriteClient.d.cts +262 -0
- package/dist/WriteClient.d.cts.map +1 -0
- package/dist/WriteClient.d.ts +226 -245
- package/dist/WriteClient.d.ts.map +1 -0
- package/dist/WriteClient.js +482 -569
- package/dist/WriteClient.js.map +1 -1
- package/dist/_virtual/rolldown_runtime.cjs +14 -0
- package/dist/_virtual/rolldown_runtime.js +13 -0
- package/dist/buildQueryURL.cjs +89 -59
- package/dist/buildQueryURL.cjs.map +1 -1
- package/dist/buildQueryURL.d.cts +212 -0
- package/dist/buildQueryURL.d.cts.map +1 -0
- package/dist/buildQueryURL.d.ts +146 -151
- package/dist/buildQueryURL.d.ts.map +1 -0
- package/dist/buildQueryURL.js +89 -59
- package/dist/buildQueryURL.js.map +1 -1
- package/dist/cookie.cjs +17 -3
- package/dist/cookie.cjs.map +1 -1
- package/dist/cookie.d.cts +11 -0
- package/dist/cookie.d.cts.map +1 -0
- package/dist/cookie.d.ts +7 -1
- package/dist/cookie.d.ts.map +1 -0
- package/dist/cookie.js +12 -4
- package/dist/cookie.js.map +1 -1
- package/dist/createClient.cjs +32 -5
- package/dist/createClient.cjs.map +1 -1
- package/dist/createClient.d.cts +41 -0
- package/dist/createClient.d.cts.map +1 -0
- package/dist/createClient.d.ts +11 -5
- package/dist/createClient.d.ts.map +1 -0
- package/dist/createClient.js +31 -4
- package/dist/createClient.js.map +1 -1
- package/dist/createMigration.cjs +21 -5
- package/dist/createMigration.cjs.map +1 -1
- package/dist/createMigration.d.cts +30 -0
- package/dist/createMigration.d.cts.map +1 -0
- package/dist/createMigration.d.ts +10 -4
- package/dist/createMigration.d.ts.map +1 -0
- package/dist/createMigration.js +20 -4
- package/dist/createMigration.js.map +1 -1
- package/dist/createWriteClient.cjs +29 -5
- package/dist/createWriteClient.cjs.map +1 -1
- package/dist/createWriteClient.d.cts +38 -0
- package/dist/createWriteClient.d.cts.map +1 -0
- package/dist/createWriteClient.d.ts +10 -4
- package/dist/createWriteClient.d.ts.map +1 -0
- package/dist/createWriteClient.js +28 -4
- package/dist/createWriteClient.js.map +1 -1
- package/dist/errors.cjs +31 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.d.cts +46 -0
- package/dist/errors.d.cts.map +1 -0
- package/dist/errors.d.ts +46 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +22 -0
- package/dist/errors.js.map +1 -0
- package/dist/filter.cjs +93 -236
- package/dist/filter.cjs.map +1 -1
- package/dist/filter.d.cts +213 -0
- package/dist/filter.d.cts.map +1 -0
- package/dist/filter.d.ts +212 -208
- package/dist/filter.d.ts.map +1 -0
- package/dist/filter.js +93 -237
- package/dist/filter.js.map +1 -1
- package/dist/getGraphQLEndpoint.cjs +18 -10
- package/dist/getGraphQLEndpoint.cjs.map +1 -1
- package/dist/getGraphQLEndpoint.d.cts +14 -0
- package/dist/getGraphQLEndpoint.d.cts.map +1 -0
- package/dist/getGraphQLEndpoint.d.ts +5 -1
- package/dist/getGraphQLEndpoint.d.ts.map +1 -0
- package/dist/getGraphQLEndpoint.js +18 -10
- package/dist/getGraphQLEndpoint.js.map +1 -1
- package/dist/getRepositoryEndpoint.cjs +27 -10
- package/dist/getRepositoryEndpoint.cjs.map +1 -1
- package/dist/getRepositoryEndpoint.d.cts +23 -0
- package/dist/getRepositoryEndpoint.d.cts.map +1 -0
- package/dist/getRepositoryEndpoint.d.ts +5 -1
- package/dist/getRepositoryEndpoint.d.ts.map +1 -0
- package/dist/getRepositoryEndpoint.js +27 -10
- package/dist/getRepositoryEndpoint.js.map +1 -1
- package/dist/getRepositoryName.cjs +22 -14
- package/dist/getRepositoryName.cjs.map +1 -1
- package/dist/getRepositoryName.d.cts +16 -0
- package/dist/getRepositoryName.d.cts.map +1 -0
- package/dist/getRepositoryName.d.ts +5 -1
- package/dist/getRepositoryName.d.ts.map +1 -0
- package/dist/getRepositoryName.js +23 -15
- package/dist/getRepositoryName.js.map +1 -1
- package/dist/getToolbarSrc.cjs +42 -10
- package/dist/getToolbarSrc.cjs.map +1 -1
- package/dist/getToolbarSrc.d.cts +38 -0
- package/dist/getToolbarSrc.d.cts.map +1 -0
- package/dist/getToolbarSrc.d.ts +5 -1
- package/dist/getToolbarSrc.d.ts.map +1 -0
- package/dist/getToolbarSrc.js +42 -10
- package/dist/getToolbarSrc.js.map +1 -1
- package/dist/helpers/asDate.cjs +36 -11
- package/dist/helpers/asDate.cjs.map +1 -1
- package/dist/helpers/asDate.d.cts +29 -0
- package/dist/helpers/asDate.d.cts.map +1 -0
- package/dist/helpers/asDate.d.ts +9 -4
- package/dist/helpers/asDate.d.ts.map +1 -0
- package/dist/helpers/asDate.js +36 -12
- package/dist/helpers/asDate.js.map +1 -1
- package/dist/helpers/asHTML.cjs +76 -79
- package/dist/helpers/asHTML.cjs.map +1 -1
- package/dist/helpers/asHTML.d.cts +147 -0
- package/dist/helpers/asHTML.d.cts.map +1 -0
- package/dist/helpers/asHTML.d.ts +76 -78
- package/dist/helpers/asHTML.d.ts.map +1 -0
- package/dist/helpers/asHTML.js +74 -77
- package/dist/helpers/asHTML.js.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.cjs +57 -18
- package/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.d.cts +59 -0
- package/dist/helpers/asImagePixelDensitySrcSet.d.cts.map +1 -0
- package/dist/helpers/asImagePixelDensitySrcSet.d.ts +18 -13
- package/dist/helpers/asImagePixelDensitySrcSet.d.ts.map +1 -0
- package/dist/helpers/asImagePixelDensitySrcSet.js +57 -18
- package/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -1
- package/dist/helpers/asImageSrc.cjs +30 -10
- package/dist/helpers/asImageSrc.cjs.map +1 -1
- package/dist/helpers/asImageSrc.d.cts +34 -0
- package/dist/helpers/asImageSrc.d.cts.map +1 -0
- package/dist/helpers/asImageSrc.d.ts +9 -4
- package/dist/helpers/asImageSrc.d.ts.map +1 -0
- package/dist/helpers/asImageSrc.js +30 -10
- package/dist/helpers/asImageSrc.js.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.cjs +76 -42
- package/dist/helpers/asImageWidthSrcSet.cjs.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.d.cts +67 -0
- package/dist/helpers/asImageWidthSrcSet.d.cts.map +1 -0
- package/dist/helpers/asImageWidthSrcSet.d.ts +19 -14
- package/dist/helpers/asImageWidthSrcSet.d.ts.map +1 -0
- package/dist/helpers/asImageWidthSrcSet.js +76 -42
- package/dist/helpers/asImageWidthSrcSet.js.map +1 -1
- package/dist/helpers/asLink.cjs +26 -44
- package/dist/helpers/asLink.cjs.map +1 -1
- package/dist/helpers/asLink.d.cts +83 -0
- package/dist/helpers/asLink.d.cts.map +1 -0
- package/dist/helpers/asLink.d.ts +58 -53
- package/dist/helpers/asLink.d.ts.map +1 -0
- package/dist/helpers/asLink.js +25 -43
- package/dist/helpers/asLink.js.map +1 -1
- package/dist/helpers/asLinkAttrs.cjs +44 -25
- package/dist/helpers/asLinkAttrs.cjs.map +1 -1
- package/dist/helpers/asLinkAttrs.d.cts +51 -0
- package/dist/helpers/asLinkAttrs.d.cts.map +1 -0
- package/dist/helpers/asLinkAttrs.d.ts +23 -19
- package/dist/helpers/asLinkAttrs.d.ts.map +1 -0
- package/dist/helpers/asLinkAttrs.js +43 -24
- package/dist/helpers/asLinkAttrs.js.map +1 -1
- package/dist/helpers/asText.cjs +15 -20
- package/dist/helpers/asText.cjs.map +1 -1
- package/dist/helpers/asText.d.cts +62 -0
- package/dist/helpers/asText.d.cts.map +1 -0
- package/dist/helpers/asText.d.ts +48 -43
- package/dist/helpers/asText.d.ts.map +1 -0
- package/dist/helpers/asText.js +15 -20
- package/dist/helpers/asText.js.map +1 -1
- package/dist/helpers/documentToLinkField.cjs +30 -23
- package/dist/helpers/documentToLinkField.cjs.map +1 -1
- package/dist/helpers/documentToLinkField.d.cts +21 -0
- package/dist/helpers/documentToLinkField.d.cts.map +1 -0
- package/dist/helpers/documentToLinkField.d.ts +8 -4
- package/dist/helpers/documentToLinkField.d.ts.map +1 -0
- package/dist/helpers/documentToLinkField.js +30 -23
- package/dist/helpers/documentToLinkField.js.map +1 -1
- package/dist/helpers/isFilled.cjs +215 -42
- package/dist/helpers/isFilled.cjs.map +1 -1
- package/dist/helpers/isFilled.d.cts +199 -0
- package/dist/helpers/isFilled.d.cts.map +1 -0
- package/dist/helpers/isFilled.d.ts +51 -43
- package/dist/helpers/isFilled.d.ts.map +1 -0
- package/dist/helpers/isFilled.js +210 -44
- package/dist/helpers/isFilled.js.map +1 -1
- package/dist/helpers/mapSliceZone.cjs +50 -39
- package/dist/helpers/mapSliceZone.cjs.map +1 -1
- package/dist/helpers/mapSliceZone.d.cts +139 -0
- package/dist/helpers/mapSliceZone.d.cts.map +1 -0
- package/dist/helpers/mapSliceZone.d.ts +37 -34
- package/dist/helpers/mapSliceZone.d.ts.map +1 -0
- package/dist/helpers/mapSliceZone.js +50 -40
- package/dist/helpers/mapSliceZone.js.map +1 -1
- package/dist/index.cjs +109 -96
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +173 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +142 -173
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -75
- package/dist/index.js.map +1 -1
- package/dist/isRepositoryEndpoint.cjs +20 -9
- package/dist/isRepositoryEndpoint.cjs.map +1 -1
- package/dist/isRepositoryEndpoint.d.cts +14 -0
- package/dist/isRepositoryEndpoint.d.cts.map +1 -0
- package/dist/isRepositoryEndpoint.d.ts +5 -1
- package/dist/isRepositoryEndpoint.d.ts.map +1 -0
- package/dist/isRepositoryEndpoint.js +20 -10
- package/dist/isRepositoryEndpoint.js.map +1 -1
- package/dist/isRepositoryName.cjs +14 -4
- package/dist/isRepositoryName.cjs.map +1 -1
- package/dist/isRepositoryName.d.cts +13 -0
- package/dist/isRepositoryName.d.cts.map +1 -0
- package/dist/isRepositoryName.d.ts +5 -1
- package/dist/isRepositoryName.d.ts.map +1 -0
- package/dist/isRepositoryName.js +14 -5
- package/dist/isRepositoryName.js.map +1 -1
- package/dist/lib/devMsg.cjs +22 -5
- package/dist/lib/devMsg.cjs.map +1 -1
- package/dist/lib/devMsg.js +23 -6
- package/dist/lib/devMsg.js.map +1 -1
- package/dist/lib/escapeHTML.cjs +36 -39
- package/dist/lib/escapeHTML.cjs.map +1 -1
- package/dist/lib/escapeHTML.js +36 -40
- package/dist/lib/escapeHTML.js.map +1 -1
- package/dist/lib/getOptionalLinkProperties.cjs +19 -11
- package/dist/lib/getOptionalLinkProperties.cjs.map +1 -1
- package/dist/lib/getOptionalLinkProperties.js +19 -12
- package/dist/lib/getOptionalLinkProperties.js.map +1 -1
- package/dist/lib/getPreviewCookie.cjs +25 -16
- package/dist/lib/getPreviewCookie.cjs.map +1 -1
- package/dist/lib/getPreviewCookie.js +25 -16
- package/dist/lib/getPreviewCookie.js.map +1 -1
- package/dist/lib/isInternalURL.cjs +15 -6
- package/dist/lib/isInternalURL.cjs.map +1 -1
- package/dist/lib/isInternalURL.js +15 -7
- package/dist/lib/isInternalURL.js.map +1 -1
- package/dist/lib/isMigrationValue.cjs +65 -12
- package/dist/lib/isMigrationValue.cjs.map +1 -1
- package/dist/lib/isMigrationValue.js +63 -13
- package/dist/lib/isMigrationValue.js.map +1 -1
- package/dist/lib/isValue.cjs +93 -36
- package/dist/lib/isValue.cjs.map +1 -1
- package/dist/lib/isValue.js +93 -40
- package/dist/lib/isValue.js.map +1 -1
- package/dist/lib/pLimit.cjs +51 -44
- package/dist/lib/pLimit.cjs.map +1 -1
- package/dist/lib/pLimit.js +51 -45
- package/dist/lib/pLimit.js.map +1 -1
- package/dist/lib/request.cjs +54 -35
- package/dist/lib/request.cjs.map +1 -1
- package/dist/lib/request.d.cts +61 -0
- package/dist/lib/request.d.cts.map +1 -0
- package/dist/lib/request.d.ts +38 -50
- package/dist/lib/request.d.ts.map +1 -0
- package/dist/lib/request.js +54 -35
- package/dist/lib/request.js.map +1 -1
- package/dist/lib/resolveMigrationDocumentData.cjs +147 -123
- package/dist/lib/resolveMigrationDocumentData.cjs.map +1 -1
- package/dist/lib/resolveMigrationDocumentData.js +143 -120
- package/dist/lib/resolveMigrationDocumentData.js.map +1 -1
- package/dist/lib/serializerHelpers.cjs +73 -91
- package/dist/lib/serializerHelpers.cjs.map +1 -1
- package/dist/lib/serializerHelpers.js +71 -94
- package/dist/lib/serializerHelpers.js.map +1 -1
- package/dist/lib/throttledWarn.cjs +27 -0
- package/dist/lib/throttledWarn.cjs.map +1 -0
- package/dist/lib/throttledWarn.js +26 -0
- package/dist/lib/throttledWarn.js.map +1 -0
- package/dist/lib/validateAssetMetadata.cjs +40 -20
- package/dist/lib/validateAssetMetadata.cjs.map +1 -1
- package/dist/lib/validateAssetMetadata.js +41 -21
- package/dist/lib/validateAssetMetadata.js.map +1 -1
- package/dist/package.cjs +19 -0
- package/dist/package.cjs.map +1 -0
- package/dist/package.js +7 -0
- package/dist/package.js.map +1 -0
- package/dist/richtext/asText.cjs +18 -10
- package/dist/richtext/asText.cjs.map +1 -1
- package/dist/richtext/asText.d.cts +18 -0
- package/dist/richtext/asText.d.cts.map +1 -0
- package/dist/richtext/asText.d.ts +8 -2
- package/dist/richtext/asText.d.ts.map +1 -0
- package/dist/richtext/asText.js +18 -11
- package/dist/richtext/asText.js.map +1 -1
- package/dist/richtext/asTree.cjs +106 -107
- package/dist/richtext/asTree.cjs.map +1 -1
- package/dist/richtext/asTree.d.cts +20 -0
- package/dist/richtext/asTree.d.cts.map +1 -0
- package/dist/richtext/asTree.d.ts +9 -3
- package/dist/richtext/asTree.d.ts.map +1 -0
- package/dist/richtext/asTree.js +106 -107
- package/dist/richtext/asTree.js.map +1 -1
- package/dist/richtext/composeSerializers.cjs +28 -14
- package/dist/richtext/composeSerializers.cjs.map +1 -1
- package/dist/richtext/composeSerializers.d.cts +22 -0
- package/dist/richtext/composeSerializers.d.cts.map +1 -0
- package/dist/richtext/composeSerializers.d.ts +8 -2
- package/dist/richtext/composeSerializers.d.ts.map +1 -0
- package/dist/richtext/composeSerializers.js +28 -15
- package/dist/richtext/composeSerializers.js.map +1 -1
- package/dist/richtext/serialize.cjs +30 -14
- package/dist/richtext/serialize.cjs.map +1 -1
- package/dist/richtext/serialize.d.cts +25 -0
- package/dist/richtext/serialize.d.cts.map +1 -0
- package/dist/richtext/serialize.d.ts +9 -3
- package/dist/richtext/serialize.d.ts.map +1 -0
- package/dist/richtext/serialize.js +30 -14
- package/dist/richtext/serialize.js.map +1 -1
- package/dist/richtext/types.cjs +10 -8
- package/dist/richtext/types.cjs.map +1 -1
- package/dist/richtext/types.d.cts +71 -0
- package/dist/richtext/types.d.cts.map +1 -0
- package/dist/richtext/types.d.ts +43 -43
- package/dist/richtext/types.d.ts.map +1 -0
- package/dist/richtext/types.js +10 -8
- package/dist/richtext/types.js.map +1 -1
- package/dist/richtext/wrapMapSerializer.cjs +29 -21
- package/dist/richtext/wrapMapSerializer.cjs.map +1 -1
- package/dist/richtext/wrapMapSerializer.d.cts +21 -0
- package/dist/richtext/wrapMapSerializer.d.cts.map +1 -0
- package/dist/richtext/wrapMapSerializer.d.ts +8 -2
- package/dist/richtext/wrapMapSerializer.d.ts.map +1 -0
- package/dist/richtext/wrapMapSerializer.js +29 -21
- package/dist/richtext/wrapMapSerializer.js.map +1 -1
- package/dist/richtext.cjs +13 -15
- package/dist/richtext.d.cts +8 -0
- package/dist/richtext.d.ts +8 -0
- package/dist/richtext.js +4 -11
- package/dist/types/api/asset/asset.d.cts +97 -0
- package/dist/types/api/asset/asset.d.cts.map +1 -0
- package/dist/types/api/asset/asset.d.ts +87 -167
- package/dist/types/api/asset/asset.d.ts.map +1 -0
- package/dist/types/api/asset/tag.d.cts +35 -0
- package/dist/types/api/asset/tag.d.cts.map +1 -0
- package/dist/types/api/asset/tag.d.ts +29 -47
- package/dist/types/api/asset/tag.d.ts.map +1 -0
- package/dist/types/api/integration.d.cts +34 -0
- package/dist/types/api/integration.d.cts.map +1 -0
- package/dist/types/api/integration.d.ts +17 -11
- package/dist/types/api/integration.d.ts.map +1 -0
- package/dist/types/api/query.d.cts +49 -0
- package/dist/types/api/query.d.cts.map +1 -0
- package/dist/types/api/query.d.ts +40 -34
- package/dist/types/api/query.d.ts.map +1 -0
- package/dist/types/api/ref.d.cts +36 -0
- package/dist/types/api/ref.d.cts.map +1 -0
- package/dist/types/api/ref.d.ts +30 -26
- package/dist/types/api/ref.d.ts.map +1 -0
- package/dist/types/api/release.d.cts +17 -0
- package/dist/types/api/release.d.cts.map +1 -0
- package/dist/types/api/release.d.ts +8 -2
- package/dist/types/api/release.d.ts.map +1 -0
- package/dist/types/api/repository.d.cts +115 -0
- package/dist/types/api/repository.d.cts.map +1 -0
- package/dist/types/api/repository.d.ts +90 -84
- package/dist/types/api/repository.d.ts.map +1 -0
- package/dist/types/api/tags.d.cts +13 -0
- package/dist/types/api/tags.d.cts.map +1 -0
- package/dist/types/api/tags.d.ts +5 -1
- package/dist/types/api/tags.d.ts.map +1 -0
- package/dist/types/migration/Asset.cjs +34 -29
- package/dist/types/migration/Asset.cjs.map +1 -1
- package/dist/types/migration/Asset.d.cts +109 -0
- package/dist/types/migration/Asset.d.cts.map +1 -0
- package/dist/types/migration/Asset.d.ts +89 -88
- package/dist/types/migration/Asset.d.ts.map +1 -0
- package/dist/types/migration/Asset.js +33 -29
- package/dist/types/migration/Asset.js.map +1 -1
- package/dist/types/migration/ContentRelationship.d.cts +15 -0
- package/dist/types/migration/ContentRelationship.d.cts.map +1 -0
- package/dist/types/migration/ContentRelationship.d.ts +10 -11
- package/dist/types/migration/ContentRelationship.d.ts.map +1 -0
- package/dist/types/migration/Document.cjs +50 -43
- package/dist/types/migration/Document.cjs.map +1 -1
- package/dist/types/migration/Document.d.cts +97 -0
- package/dist/types/migration/Document.d.cts.map +1 -0
- package/dist/types/migration/Document.d.ts +62 -59
- package/dist/types/migration/Document.d.ts.map +1 -0
- package/dist/types/migration/Document.js +49 -43
- package/dist/types/migration/Document.js.map +1 -1
- package/dist/types/model/boolean.d.cts +21 -0
- package/dist/types/model/boolean.d.cts.map +1 -0
- package/dist/types/model/boolean.d.ts +15 -9
- package/dist/types/model/boolean.d.ts.map +1 -0
- package/dist/types/model/color.d.cts +19 -0
- package/dist/types/model/color.d.cts.map +1 -0
- package/dist/types/model/color.d.ts +13 -7
- package/dist/types/model/color.d.ts.map +1 -0
- package/dist/types/model/contentRelationship.d.cts +59 -0
- package/dist/types/model/contentRelationship.d.cts.map +1 -0
- package/dist/types/model/contentRelationship.d.ts +33 -27
- package/dist/types/model/contentRelationship.d.ts.map +1 -0
- package/dist/types/model/customType.d.cts +54 -0
- package/dist/types/model/customType.d.cts.map +1 -0
- package/dist/types/model/customType.d.ts +36 -30
- package/dist/types/model/customType.d.ts.map +1 -0
- package/dist/types/model/date.d.cts +20 -0
- package/dist/types/model/date.d.cts.map +1 -0
- package/dist/types/model/date.d.ts +14 -8
- package/dist/types/model/date.d.ts.map +1 -0
- package/dist/types/model/embed.d.cts +19 -0
- package/dist/types/model/embed.d.cts.map +1 -0
- package/dist/types/model/embed.d.ts +13 -7
- package/dist/types/model/embed.d.ts.map +1 -0
- package/dist/types/model/geoPoint.d.cts +18 -0
- package/dist/types/model/geoPoint.d.cts.map +1 -0
- package/dist/types/model/geoPoint.d.ts +12 -6
- package/dist/types/model/geoPoint.d.ts.map +1 -0
- package/dist/types/model/group.d.cts +29 -0
- package/dist/types/model/group.d.cts.map +1 -0
- package/dist/types/model/group.d.ts +14 -8
- package/dist/types/model/group.d.ts.map +1 -0
- package/dist/types/model/image.d.cts +37 -0
- package/dist/types/model/image.d.cts.map +1 -0
- package/dist/types/model/image.d.ts +19 -13
- package/dist/types/model/image.d.ts.map +1 -0
- package/dist/types/model/integration.d.cts +20 -0
- package/dist/types/model/integration.d.cts.map +1 -0
- package/dist/types/model/integration.d.ts +14 -8
- package/dist/types/model/integration.d.ts.map +1 -0
- package/dist/types/model/keyText.d.cts +19 -0
- package/dist/types/model/keyText.d.cts.map +1 -0
- package/dist/types/model/keyText.d.ts +13 -7
- package/dist/types/model/keyText.d.ts.map +1 -0
- package/dist/types/model/link.cjs +13 -6
- package/dist/types/model/link.cjs.map +1 -1
- package/dist/types/model/link.d.cts +34 -0
- package/dist/types/model/link.d.cts.map +1 -0
- package/dist/types/model/link.d.ts +22 -16
- package/dist/types/model/link.d.ts.map +1 -0
- package/dist/types/model/link.js +13 -7
- package/dist/types/model/link.js.map +1 -1
- package/dist/types/model/linkToMedia.d.cts +23 -0
- package/dist/types/model/linkToMedia.d.cts.map +1 -0
- package/dist/types/model/linkToMedia.d.ts +17 -11
- package/dist/types/model/linkToMedia.d.ts.map +1 -0
- package/dist/types/model/number.d.cts +21 -0
- package/dist/types/model/number.d.cts.map +1 -0
- package/dist/types/model/number.d.ts +15 -9
- package/dist/types/model/number.d.ts.map +1 -0
- package/dist/types/model/range.d.cts +20 -0
- package/dist/types/model/range.d.cts.map +1 -0
- package/dist/types/model/range.d.ts +16 -10
- package/dist/types/model/range.d.ts.map +1 -0
- package/dist/types/model/richText.d.cts +43 -0
- package/dist/types/model/richText.d.cts.map +1 -0
- package/dist/types/model/richText.d.ts +26 -20
- package/dist/types/model/richText.d.ts.map +1 -0
- package/dist/types/model/select.d.cts +24 -0
- package/dist/types/model/select.d.cts.map +1 -0
- package/dist/types/model/select.d.ts +15 -9
- package/dist/types/model/select.d.ts.map +1 -0
- package/dist/types/model/separator.d.cts +16 -0
- package/dist/types/model/separator.d.cts.map +1 -0
- package/dist/types/model/separator.d.ts +12 -6
- package/dist/types/model/separator.d.ts.map +1 -0
- package/dist/types/model/sharedSlice.d.cts +22 -0
- package/dist/types/model/sharedSlice.d.cts.map +1 -0
- package/dist/types/model/sharedSlice.d.ts +14 -8
- package/dist/types/model/sharedSlice.d.ts.map +1 -0
- package/dist/types/model/sharedSliceVariation.d.cts +25 -0
- package/dist/types/model/sharedSliceVariation.d.cts.map +1 -0
- package/dist/types/model/sharedSliceVariation.d.ts +16 -10
- package/dist/types/model/sharedSliceVariation.d.ts.map +1 -0
- package/dist/types/model/slice.cjs +12 -5
- package/dist/types/model/slice.cjs.map +1 -1
- package/dist/types/model/slice.d.cts +39 -0
- package/dist/types/model/slice.d.cts.map +1 -0
- package/dist/types/model/slice.d.ts +21 -15
- package/dist/types/model/slice.d.ts.map +1 -0
- package/dist/types/model/slice.js +12 -6
- package/dist/types/model/slice.js.map +1 -1
- package/dist/types/model/sliceZone.cjs +12 -5
- package/dist/types/model/sliceZone.cjs.map +1 -1
- package/dist/types/model/sliceZone.d.cts +47 -0
- package/dist/types/model/sliceZone.d.cts.map +1 -0
- package/dist/types/model/sliceZone.d.ts +23 -17
- package/dist/types/model/sliceZone.d.ts.map +1 -0
- package/dist/types/model/sliceZone.js +12 -6
- package/dist/types/model/sliceZone.js.map +1 -1
- package/dist/types/model/table.d.cts +18 -0
- package/dist/types/model/table.d.cts.map +1 -0
- package/dist/types/model/table.d.ts +12 -6
- package/dist/types/model/table.d.ts.map +1 -0
- package/dist/types/model/timestamp.d.cts +20 -0
- package/dist/types/model/timestamp.d.cts.map +1 -0
- package/dist/types/model/timestamp.d.ts +14 -8
- package/dist/types/model/timestamp.d.ts.map +1 -0
- package/dist/types/model/title.d.cts +13 -0
- package/dist/types/model/title.d.cts.map +1 -0
- package/dist/types/model/title.d.ts +8 -2
- package/dist/types/model/title.d.ts.map +1 -0
- package/dist/types/model/types.cjs +29 -36
- package/dist/types/model/types.cjs.map +1 -1
- package/dist/types/model/types.d.cts +82 -0
- package/dist/types/model/types.d.cts.map +1 -0
- package/dist/types/model/types.d.ts +66 -60
- package/dist/types/model/types.d.ts.map +1 -0
- package/dist/types/model/types.js +29 -37
- package/dist/types/model/types.js.map +1 -1
- package/dist/types/model/uid.d.cts +19 -0
- package/dist/types/model/uid.d.cts.map +1 -0
- package/dist/types/model/uid.d.ts +13 -7
- package/dist/types/model/uid.d.ts.map +1 -0
- package/dist/types/value/boolean.d.cts +10 -0
- package/dist/types/value/boolean.d.cts.map +1 -0
- package/dist/types/value/boolean.d.ts +5 -1
- package/dist/types/value/boolean.d.ts.map +1 -0
- package/dist/types/value/color.d.cts +15 -0
- package/dist/types/value/color.d.cts.map +1 -0
- package/dist/types/value/color.d.ts +8 -2
- package/dist/types/value/color.d.ts.map +1 -0
- package/dist/types/value/contentRelationship.d.cts +37 -0
- package/dist/types/value/contentRelationship.d.cts.map +1 -0
- package/dist/types/value/contentRelationship.d.ts +23 -17
- package/dist/types/value/contentRelationship.d.ts.map +1 -0
- package/dist/types/value/date.d.cts +15 -0
- package/dist/types/value/date.d.cts.map +1 -0
- package/dist/types/value/date.d.ts +8 -2
- package/dist/types/value/date.d.ts.map +1 -0
- package/dist/types/value/document.d.cts +120 -0
- package/dist/types/value/document.d.cts.map +1 -0
- package/dist/types/value/document.d.ts +90 -84
- package/dist/types/value/document.d.ts.map +1 -0
- package/dist/types/value/embed.cjs +14 -7
- package/dist/types/value/embed.cjs.map +1 -1
- package/dist/types/value/embed.d.cts +173 -0
- package/dist/types/value/embed.d.cts.map +1 -0
- package/dist/types/value/embed.d.ts +110 -105
- package/dist/types/value/embed.d.ts.map +1 -0
- package/dist/types/value/embed.js +14 -8
- package/dist/types/value/embed.js.map +1 -1
- package/dist/types/value/geoPoint.d.cts +18 -0
- package/dist/types/value/geoPoint.d.cts.map +1 -0
- package/dist/types/value/geoPoint.d.ts +10 -4
- package/dist/types/value/geoPoint.d.ts.map +1 -0
- package/dist/types/value/group.d.cts +19 -0
- package/dist/types/value/group.d.cts.map +1 -0
- package/dist/types/value/group.d.ts +9 -3
- package/dist/types/value/group.d.ts.map +1 -0
- package/dist/types/value/image.d.cts +53 -0
- package/dist/types/value/image.d.cts.map +1 -0
- package/dist/types/value/image.d.ts +31 -25
- package/dist/types/value/image.d.ts.map +1 -0
- package/dist/types/value/integration.d.cts +22 -0
- package/dist/types/value/integration.d.cts.map +1 -0
- package/dist/types/value/integration.d.ts +9 -3
- package/dist/types/value/integration.d.ts.map +1 -0
- package/dist/types/value/keyText.d.cts +15 -0
- package/dist/types/value/keyText.d.cts.map +1 -0
- package/dist/types/value/keyText.d.ts +8 -2
- package/dist/types/value/keyText.d.ts.map +1 -0
- package/dist/types/value/link.cjs +12 -7
- package/dist/types/value/link.cjs.map +1 -1
- package/dist/types/value/link.d.cts +74 -0
- package/dist/types/value/link.d.cts.map +1 -0
- package/dist/types/value/link.d.ts +27 -21
- package/dist/types/value/link.d.ts.map +1 -0
- package/dist/types/value/link.js +12 -8
- package/dist/types/value/link.js.map +1 -1
- package/dist/types/value/linkToMedia.d.cts +33 -0
- package/dist/types/value/linkToMedia.d.cts.map +1 -0
- package/dist/types/value/linkToMedia.d.ts +19 -14
- package/dist/types/value/linkToMedia.d.ts.map +1 -0
- package/dist/types/value/number.d.cts +15 -0
- package/dist/types/value/number.d.cts.map +1 -0
- package/dist/types/value/number.d.ts +8 -2
- package/dist/types/value/number.d.ts.map +1 -0
- package/dist/types/value/richText.cjs +29 -22
- package/dist/types/value/richText.cjs.map +1 -1
- package/dist/types/value/richText.d.cts +221 -0
- package/dist/types/value/richText.d.cts.map +1 -0
- package/dist/types/value/richText.d.ts +103 -97
- package/dist/types/value/richText.d.ts.map +1 -0
- package/dist/types/value/richText.js +29 -23
- package/dist/types/value/richText.js.map +1 -1
- package/dist/types/value/select.d.cts +16 -0
- package/dist/types/value/select.d.cts.map +1 -0
- package/dist/types/value/select.d.ts +8 -2
- package/dist/types/value/select.d.ts.map +1 -0
- package/dist/types/value/sharedSlice.d.cts +17 -0
- package/dist/types/value/sharedSlice.d.cts.map +1 -0
- package/dist/types/value/sharedSlice.d.ts +11 -5
- package/dist/types/value/sharedSlice.d.ts.map +1 -0
- package/dist/types/value/sharedSliceVariation.d.cts +16 -0
- package/dist/types/value/sharedSliceVariation.d.cts.map +1 -0
- package/dist/types/value/sharedSliceVariation.d.ts +12 -6
- package/dist/types/value/sharedSliceVariation.d.ts.map +1 -0
- package/dist/types/value/slice.d.cts +19 -0
- package/dist/types/value/slice.d.cts.map +1 -0
- package/dist/types/value/slice.d.ts +13 -7
- package/dist/types/value/slice.d.ts.map +1 -0
- package/dist/types/value/sliceZone.d.cts +18 -0
- package/dist/types/value/sliceZone.d.cts.map +1 -0
- package/dist/types/value/sliceZone.d.ts +10 -4
- package/dist/types/value/sliceZone.d.ts.map +1 -0
- package/dist/types/value/table.d.cts +97 -0
- package/dist/types/value/table.d.cts.map +1 -0
- package/dist/types/value/table.d.ts +65 -59
- package/dist/types/value/table.d.ts.map +1 -0
- package/dist/types/value/timestamp.d.cts +13 -0
- package/dist/types/value/timestamp.d.cts.map +1 -0
- package/dist/types/value/timestamp.d.ts +8 -3
- package/dist/types/value/timestamp.d.ts.map +1 -0
- package/dist/types/value/title.d.cts +16 -0
- package/dist/types/value/title.d.cts.map +1 -0
- package/dist/types/value/title.d.ts +11 -7
- package/dist/types/value/title.d.ts.map +1 -0
- package/dist/types/value/types.d.cts +61 -0
- package/dist/types/value/types.d.cts.map +1 -0
- package/dist/types/value/types.d.ts +31 -28
- package/dist/types/value/types.d.ts.map +1 -0
- package/dist/types/webhook/apiUpdate.d.cts +57 -0
- package/dist/types/webhook/apiUpdate.d.cts.map +1 -0
- package/dist/types/webhook/apiUpdate.d.ts +28 -23
- package/dist/types/webhook/apiUpdate.d.ts.map +1 -0
- package/dist/types/webhook/testTrigger.d.cts +15 -0
- package/dist/types/webhook/testTrigger.d.cts.map +1 -0
- package/dist/types/webhook/testTrigger.d.ts +9 -3
- package/dist/types/webhook/testTrigger.d.ts.map +1 -0
- package/dist/types/webhook/types.cjs +12 -5
- package/dist/types/webhook/types.cjs.map +1 -1
- package/dist/types/webhook/types.d.cts +23 -0
- package/dist/types/webhook/types.d.cts.map +1 -0
- package/dist/types/webhook/types.d.ts +16 -11
- package/dist/types/webhook/types.d.ts.map +1 -0
- package/dist/types/webhook/types.js +12 -6
- package/dist/types/webhook/types.js.map +1 -1
- package/package.json +16 -45
- package/src/Client.ts +683 -1029
- package/src/WriteClient.ts +23 -14
- package/src/buildQueryURL.ts +14 -20
- package/src/createClient.ts +1 -1
- package/src/errors.ts +94 -0
- package/src/filter.ts +1 -1
- package/src/getGraphQLEndpoint.ts +1 -1
- package/src/getRepositoryEndpoint.ts +1 -1
- package/src/getRepositoryName.ts +1 -1
- package/src/getToolbarSrc.ts +1 -1
- package/src/helpers/asHTML.ts +4 -4
- package/src/helpers/asImageWidthSrcSet.ts +1 -5
- package/src/helpers/asLink.ts +0 -3
- package/src/helpers/asLinkAttrs.ts +0 -4
- package/src/helpers/mapSliceZone.ts +5 -5
- package/src/index.ts +11 -9
- package/src/lib/isValue.ts +0 -6
- package/src/lib/pLimit.ts +1 -1
- package/src/lib/request.ts +3 -3
- package/src/lib/{throttledLog.ts → throttledWarn.ts} +3 -14
- package/src/lib/validateAssetMetadata.ts +1 -1
- package/src/types/migration/Document.ts +1 -1
- package/src/types/value/date.ts +1 -1
- package/src/types/value/document.ts +3 -3
- package/src/types/value/timestamp.ts +1 -5
- package/dist/errors/ForbiddenError.cjs +0 -7
- package/dist/errors/ForbiddenError.cjs.map +0 -1
- package/dist/errors/ForbiddenError.d.ts +0 -11
- package/dist/errors/ForbiddenError.js +0 -7
- package/dist/errors/ForbiddenError.js.map +0 -1
- package/dist/errors/InvalidDataError.cjs +0 -7
- package/dist/errors/InvalidDataError.cjs.map +0 -1
- package/dist/errors/InvalidDataError.d.ts +0 -3
- package/dist/errors/InvalidDataError.js +0 -7
- package/dist/errors/InvalidDataError.js.map +0 -1
- package/dist/errors/NotFoundError.cjs +0 -7
- package/dist/errors/NotFoundError.cjs.map +0 -1
- package/dist/errors/NotFoundError.d.ts +0 -3
- package/dist/errors/NotFoundError.js +0 -7
- package/dist/errors/NotFoundError.js.map +0 -1
- package/dist/errors/ParsingError.cjs +0 -7
- package/dist/errors/ParsingError.cjs.map +0 -1
- package/dist/errors/ParsingError.d.ts +0 -14
- package/dist/errors/ParsingError.js +0 -7
- package/dist/errors/ParsingError.js.map +0 -1
- package/dist/errors/PreviewTokenExpired.cjs +0 -7
- package/dist/errors/PreviewTokenExpired.cjs.map +0 -1
- package/dist/errors/PreviewTokenExpired.d.ts +0 -8
- package/dist/errors/PreviewTokenExpired.js +0 -7
- package/dist/errors/PreviewTokenExpired.js.map +0 -1
- package/dist/errors/PrismicError.cjs +0 -13
- package/dist/errors/PrismicError.cjs.map +0 -1
- package/dist/errors/PrismicError.d.ts +0 -5
- package/dist/errors/PrismicError.js +0 -13
- package/dist/errors/PrismicError.js.map +0 -1
- package/dist/errors/RefExpiredError.cjs +0 -7
- package/dist/errors/RefExpiredError.cjs.map +0 -1
- package/dist/errors/RefExpiredError.d.ts +0 -8
- package/dist/errors/RefExpiredError.js +0 -7
- package/dist/errors/RefExpiredError.js.map +0 -1
- package/dist/errors/RefNotFoundError.cjs +0 -7
- package/dist/errors/RefNotFoundError.cjs.map +0 -1
- package/dist/errors/RefNotFoundError.d.ts +0 -8
- package/dist/errors/RefNotFoundError.js +0 -7
- package/dist/errors/RefNotFoundError.js.map +0 -1
- package/dist/errors/RepositoryNotFoundError.cjs +0 -7
- package/dist/errors/RepositoryNotFoundError.cjs.map +0 -1
- package/dist/errors/RepositoryNotFoundError.d.ts +0 -3
- package/dist/errors/RepositoryNotFoundError.js +0 -7
- package/dist/errors/RepositoryNotFoundError.js.map +0 -1
- package/dist/lib/appendFilters.cjs +0 -11
- package/dist/lib/appendFilters.cjs.map +0 -1
- package/dist/lib/appendFilters.d.ts +0 -18
- package/dist/lib/appendFilters.js +0 -11
- package/dist/lib/appendFilters.js.map +0 -1
- package/dist/lib/castArray.cjs +0 -7
- package/dist/lib/castArray.cjs.map +0 -1
- package/dist/lib/castArray.d.ts +0 -12
- package/dist/lib/castArray.js +0 -7
- package/dist/lib/castArray.js.map +0 -1
- package/dist/lib/castThunk.cjs +0 -7
- package/dist/lib/castThunk.cjs.map +0 -1
- package/dist/lib/castThunk.d.ts +0 -11
- package/dist/lib/castThunk.js +0 -7
- package/dist/lib/castThunk.js.map +0 -1
- package/dist/lib/devMsg.d.ts +0 -16
- package/dist/lib/escapeHTML.d.ts +0 -1
- package/dist/lib/everyTagFilter.cjs +0 -9
- package/dist/lib/everyTagFilter.cjs.map +0 -1
- package/dist/lib/everyTagFilter.d.ts +0 -9
- package/dist/lib/everyTagFilter.js +0 -9
- package/dist/lib/everyTagFilter.js.map +0 -1
- package/dist/lib/findMasterRef.cjs +0 -8
- package/dist/lib/findMasterRef.cjs.map +0 -1
- package/dist/lib/findMasterRef.d.ts +0 -11
- package/dist/lib/findMasterRef.js +0 -8
- package/dist/lib/findMasterRef.js.map +0 -1
- package/dist/lib/findRef.cjs +0 -12
- package/dist/lib/findRef.cjs.map +0 -1
- package/dist/lib/findRef.d.ts +0 -14
- package/dist/lib/findRef.js +0 -12
- package/dist/lib/findRef.js.map +0 -1
- package/dist/lib/findRefByID.cjs +0 -8
- package/dist/lib/findRefByID.cjs.map +0 -1
- package/dist/lib/findRefByID.d.ts +0 -12
- package/dist/lib/findRefByID.js +0 -8
- package/dist/lib/findRefByID.js.map +0 -1
- package/dist/lib/findRefByLabel.cjs +0 -8
- package/dist/lib/findRefByLabel.cjs.map +0 -1
- package/dist/lib/findRefByLabel.d.ts +0 -12
- package/dist/lib/findRefByLabel.js +0 -8
- package/dist/lib/findRefByLabel.js.map +0 -1
- package/dist/lib/getOptionalLinkProperties.d.ts +0 -12
- package/dist/lib/getPreviewCookie.d.ts +0 -9
- package/dist/lib/isInternalURL.d.ts +0 -8
- package/dist/lib/isMigrationValue.d.ts +0 -71
- package/dist/lib/isValue.d.ts +0 -78
- package/dist/lib/minifyGraphQLQuery.cjs +0 -7
- package/dist/lib/minifyGraphQLQuery.cjs.map +0 -1
- package/dist/lib/minifyGraphQLQuery.d.ts +0 -8
- package/dist/lib/minifyGraphQLQuery.js +0 -7
- package/dist/lib/minifyGraphQLQuery.js.map +0 -1
- package/dist/lib/pLimit.d.ts +0 -22
- package/dist/lib/resolveMigrationDocumentData.d.ts +0 -54
- package/dist/lib/serializerHelpers.d.ts +0 -9
- package/dist/lib/someTagsFilter.cjs +0 -9
- package/dist/lib/someTagsFilter.cjs.map +0 -1
- package/dist/lib/someTagsFilter.d.ts +0 -9
- package/dist/lib/someTagsFilter.js +0 -9
- package/dist/lib/someTagsFilter.js.map +0 -1
- package/dist/lib/throttledLog.cjs +0 -17
- package/dist/lib/throttledLog.cjs.map +0 -1
- package/dist/lib/throttledLog.d.ts +0 -15
- package/dist/lib/throttledLog.js +0 -17
- package/dist/lib/throttledLog.js.map +0 -1
- package/dist/lib/typeFilter.cjs +0 -8
- package/dist/lib/typeFilter.cjs.map +0 -1
- package/dist/lib/typeFilter.d.ts +0 -8
- package/dist/lib/typeFilter.js +0 -8
- package/dist/lib/typeFilter.js.map +0 -1
- package/dist/lib/validateAssetMetadata.d.ts +0 -10
- package/dist/package.json.cjs +0 -7
- package/dist/package.json.cjs.map +0 -1
- package/dist/package.json.js +0 -7
- package/dist/package.json.js.map +0 -1
- package/dist/richtext/index.d.ts +0 -7
- package/dist/richtext.cjs.map +0 -1
- package/dist/richtext.js.map +0 -1
- package/dist/types/api/migration/document.d.ts +0 -60
- package/dist/types/migration/Link.d.ts +0 -19
- package/src/errors/ForbiddenError.ts +0 -16
- package/src/errors/InvalidDataError.ts +0 -5
- package/src/errors/NotFoundError.ts +0 -5
- package/src/errors/ParsingError.ts +0 -16
- package/src/errors/PreviewTokenExpired.ts +0 -12
- package/src/errors/PrismicError.ts +0 -15
- package/src/errors/RefExpiredError.ts +0 -14
- package/src/errors/RefNotFoundError.ts +0 -14
- package/src/errors/RepositoryNotFoundError.ts +0 -5
- package/src/lib/appendFilters.ts +0 -26
- package/src/lib/castArray.ts +0 -14
- package/src/lib/castThunk.ts +0 -13
- package/src/lib/everyTagFilter.ts +0 -15
- package/src/lib/findMasterRef.ts +0 -16
- package/src/lib/findRef.ts +0 -25
- package/src/lib/findRefByID.ts +0 -17
- package/src/lib/findRefByLabel.ts +0 -17
- package/src/lib/minifyGraphQLQuery.ts +0 -13
- package/src/lib/someTagsFilter.ts +0 -15
- package/src/lib/typeFilter.ts +0 -12
package/dist/Client.cjs
CHANGED
|
@@ -1,1262 +1,926 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const throttledLog = require("./lib/throttledLog.cjs");
|
|
15
|
-
const typeFilter = require("./lib/typeFilter.cjs");
|
|
16
|
-
const ForbiddenError = require("./errors/ForbiddenError.cjs");
|
|
17
|
-
const NotFoundError = require("./errors/NotFoundError.cjs");
|
|
18
|
-
const ParsingError = require("./errors/ParsingError.cjs");
|
|
19
|
-
const PreviewTokenExpired = require("./errors/PreviewTokenExpired.cjs");
|
|
20
|
-
const PrismicError = require("./errors/PrismicError.cjs");
|
|
21
|
-
const RefExpiredError = require("./errors/RefExpiredError.cjs");
|
|
22
|
-
const RefNotFoundError = require("./errors/RefNotFoundError.cjs");
|
|
23
|
-
const RepositoryNotFoundError = require("./errors/RepositoryNotFoundError.cjs");
|
|
24
|
-
const asLink = require("./helpers/asLink.cjs");
|
|
25
|
-
const buildQueryURL = require("./buildQueryURL.cjs");
|
|
26
|
-
const filter = require("./filter.cjs");
|
|
27
|
-
const getRepositoryEndpoint = require("./getRepositoryEndpoint.cjs");
|
|
28
|
-
const getRepositoryName = require("./getRepositoryName.cjs");
|
|
29
|
-
const isRepositoryEndpoint = require("./isRepositoryEndpoint.cjs");
|
|
1
|
+
const require_filter = require('./filter.cjs');
|
|
2
|
+
const require_devMsg = require('./lib/devMsg.cjs');
|
|
3
|
+
const require_getPreviewCookie = require('./lib/getPreviewCookie.cjs');
|
|
4
|
+
const require_request = require('./lib/request.cjs');
|
|
5
|
+
const require_throttledWarn = require('./lib/throttledWarn.cjs');
|
|
6
|
+
const require_errors = require('./errors.cjs');
|
|
7
|
+
const require_asLink = require('./helpers/asLink.cjs');
|
|
8
|
+
const require_buildQueryURL = require('./buildQueryURL.cjs');
|
|
9
|
+
const require_getRepositoryEndpoint = require('./getRepositoryEndpoint.cjs');
|
|
10
|
+
const require_getRepositoryName = require('./getRepositoryName.cjs');
|
|
11
|
+
const require_isRepositoryEndpoint = require('./isRepositoryEndpoint.cjs');
|
|
12
|
+
|
|
13
|
+
//#region src/Client.ts
|
|
30
14
|
const MAX_PAGE_SIZE = 100;
|
|
31
15
|
const REPOSITORY_CACHE_TTL = 5e3;
|
|
32
16
|
const GET_ALL_QUERY_DELAY = 500;
|
|
33
17
|
const MAX_INVALID_REF_RETRY_ATTEMPTS = 3;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
* ```
|
|
939
|
-
*/
|
|
940
|
-
queryLatestContent() {
|
|
941
|
-
this.refState.mode = RefStateMode.Master;
|
|
942
|
-
}
|
|
943
|
-
/**
|
|
944
|
-
* Configures the client to query content from a specific Release identified
|
|
945
|
-
* by its ID for all future queries.
|
|
946
|
-
*
|
|
947
|
-
* If the `ref` parameter is provided during a query, it takes priority for
|
|
948
|
-
* that query.
|
|
949
|
-
*
|
|
950
|
-
* @example
|
|
951
|
-
*
|
|
952
|
-
* ```ts
|
|
953
|
-
* await client.queryContentFromReleaseByID("YLB7OBAAACMA7Cpa")
|
|
954
|
-
* const document = await client.getByID("WW4bKScAAMAqmluX")
|
|
955
|
-
* ```
|
|
956
|
-
*
|
|
957
|
-
* @param releaseID - The ID of the Release.
|
|
958
|
-
*/
|
|
959
|
-
queryContentFromReleaseByID(releaseID) {
|
|
960
|
-
this.refState = {
|
|
961
|
-
...this.refState,
|
|
962
|
-
mode: RefStateMode.ReleaseID,
|
|
963
|
-
releaseID
|
|
964
|
-
};
|
|
965
|
-
}
|
|
966
|
-
/**
|
|
967
|
-
* Configures the client to query content from a specific Release identified
|
|
968
|
-
* by its label for all future queries.
|
|
969
|
-
*
|
|
970
|
-
* If the `ref` parameter is provided during a query, it takes priority for
|
|
971
|
-
* that query.
|
|
972
|
-
*
|
|
973
|
-
* @example
|
|
974
|
-
*
|
|
975
|
-
* ```ts
|
|
976
|
-
* await client.queryContentFromReleaseByLabel("My Release")
|
|
977
|
-
* const document = await client.getByID("WW4bKScAAMAqmluX")
|
|
978
|
-
* ```
|
|
979
|
-
*
|
|
980
|
-
* @param releaseLabel - The label of the Release.
|
|
981
|
-
*/
|
|
982
|
-
queryContentFromReleaseByLabel(releaseLabel) {
|
|
983
|
-
this.refState = {
|
|
984
|
-
...this.refState,
|
|
985
|
-
mode: RefStateMode.ReleaseLabel,
|
|
986
|
-
releaseLabel
|
|
987
|
-
};
|
|
988
|
-
}
|
|
989
|
-
/**
|
|
990
|
-
* Configures the client to query content from a specific ref. The ref can be
|
|
991
|
-
* provided as a string or a function.
|
|
992
|
-
*
|
|
993
|
-
* If a function is provided, the ref is fetched lazily before each query. The
|
|
994
|
-
* function may also be asynchronous.
|
|
995
|
-
*
|
|
996
|
-
* @example
|
|
997
|
-
*
|
|
998
|
-
* ```ts
|
|
999
|
-
* await client.queryContentFromRef("my-ref")
|
|
1000
|
-
* const document = await client.getByID("WW4bKScAAMAqmluX")
|
|
1001
|
-
* ```
|
|
1002
|
-
*
|
|
1003
|
-
* @param ref - The ref or a function that returns the ref from which to query
|
|
1004
|
-
* content.
|
|
1005
|
-
*/
|
|
1006
|
-
queryContentFromRef(ref) {
|
|
1007
|
-
this.refState = {
|
|
1008
|
-
...this.refState,
|
|
1009
|
-
mode: RefStateMode.Manual,
|
|
1010
|
-
ref
|
|
1011
|
-
};
|
|
1012
|
-
}
|
|
1013
|
-
/**
|
|
1014
|
-
* A `fetch()` function to be used with GraphQL clients configured for
|
|
1015
|
-
* Prismic's GraphQL API. It automatically applies the necessary `prismic-ref`
|
|
1016
|
-
* and Authorization headers. Queries will automatically be minified by
|
|
1017
|
-
* removing whitespace where possible.
|
|
1018
|
-
*
|
|
1019
|
-
* @example
|
|
1020
|
-
*
|
|
1021
|
-
* ```ts
|
|
1022
|
-
* const graphQLClient = new ApolloClient({
|
|
1023
|
-
* link: new HttpLink({
|
|
1024
|
-
* uri: prismic.getGraphQLEndpoint(repositoryName),
|
|
1025
|
-
* // Provide `client.graphQLFetch` as the fetch implementation.
|
|
1026
|
-
* fetch: client.graphQLFetch,
|
|
1027
|
-
* // Using GET is required.
|
|
1028
|
-
* useGETForQueries: true,
|
|
1029
|
-
* }),
|
|
1030
|
-
* cache: new InMemoryCache(),
|
|
1031
|
-
* })
|
|
1032
|
-
* ```
|
|
1033
|
-
*
|
|
1034
|
-
* @param input - The `fetch()` `input` parameter. Only strings are supported.
|
|
1035
|
-
* @param init - The `fetch()` `init` parameter. Only plain objects are
|
|
1036
|
-
* supported.
|
|
1037
|
-
*
|
|
1038
|
-
* @returns The `fetch()` Response for the request.
|
|
1039
|
-
*
|
|
1040
|
-
* @experimental
|
|
1041
|
-
*/
|
|
1042
|
-
async graphQLFetch(input, init) {
|
|
1043
|
-
const cachedRepository = await this.getCachedRepository();
|
|
1044
|
-
const ref = await this.getResolvedRefString();
|
|
1045
|
-
const unsanitizedHeaders = {
|
|
1046
|
-
"Prismic-ref": ref,
|
|
1047
|
-
Authorization: this.accessToken ? `Token ${this.accessToken}` : "",
|
|
1048
|
-
// Asserting `init.headers` is a Record since popular GraphQL
|
|
1049
|
-
// libraries pass this as a Record. Header objects as input
|
|
1050
|
-
// are unsupported.
|
|
1051
|
-
...init ? init.headers : {}
|
|
1052
|
-
};
|
|
1053
|
-
if (cachedRepository.integrationFieldsRef) {
|
|
1054
|
-
unsanitizedHeaders["Prismic-integration-field-ref"] = cachedRepository.integrationFieldsRef;
|
|
1055
|
-
}
|
|
1056
|
-
const headers = {};
|
|
1057
|
-
for (const key in unsanitizedHeaders) {
|
|
1058
|
-
if (unsanitizedHeaders[key]) {
|
|
1059
|
-
headers[key.toLowerCase()] = unsanitizedHeaders[key];
|
|
1060
|
-
}
|
|
1061
|
-
}
|
|
1062
|
-
const url = new URL(
|
|
1063
|
-
// Asserting `input` is a string since popular GraphQL
|
|
1064
|
-
// libraries pass this as a string. Request objects as
|
|
1065
|
-
// input are unsupported.
|
|
1066
|
-
input
|
|
1067
|
-
);
|
|
1068
|
-
url.searchParams.set("ref", ref);
|
|
1069
|
-
const query = url.searchParams.get("query");
|
|
1070
|
-
if (query) {
|
|
1071
|
-
url.searchParams.set(
|
|
1072
|
-
"query",
|
|
1073
|
-
// Compress the GraphQL query (if it exists) by
|
|
1074
|
-
// removing whitespace. This is done to
|
|
1075
|
-
// optimize the query size and avoid
|
|
1076
|
-
// hitting the upper limit of GET requests
|
|
1077
|
-
// (2048 characters).
|
|
1078
|
-
minifyGraphQLQuery.minifyGraphQLQuery(query)
|
|
1079
|
-
);
|
|
1080
|
-
}
|
|
1081
|
-
return await this.fetchFn(url.toString(), {
|
|
1082
|
-
...init,
|
|
1083
|
-
headers
|
|
1084
|
-
});
|
|
1085
|
-
}
|
|
1086
|
-
/**
|
|
1087
|
-
* Returns a cached version of `getRepository` with a TTL.
|
|
1088
|
-
*
|
|
1089
|
-
* @returns Cached repository metadata.
|
|
1090
|
-
*/
|
|
1091
|
-
async getCachedRepository(params) {
|
|
1092
|
-
if (!this.cachedRepository || Date.now() >= this.cachedRepositoryExpiration) {
|
|
1093
|
-
this.cachedRepository = await this.getRepository(params);
|
|
1094
|
-
this.cachedRepositoryExpiration = Date.now() + REPOSITORY_CACHE_TTL;
|
|
1095
|
-
}
|
|
1096
|
-
return this.cachedRepository;
|
|
1097
|
-
}
|
|
1098
|
-
/**
|
|
1099
|
-
* Returns the ref needed to query based on the client's current state. This
|
|
1100
|
-
* method may make a network request to fetch a ref or resolve the user's ref
|
|
1101
|
-
* thunk.
|
|
1102
|
-
*
|
|
1103
|
-
* If auto previews are enabled, the preview ref takes priority if available.
|
|
1104
|
-
*
|
|
1105
|
-
* The following strategies are used depending on the client's state:
|
|
1106
|
-
*
|
|
1107
|
-
* - If the user called `queryLatestContent`: Use the repository's master ref.
|
|
1108
|
-
* The ref is cached for 5 seconds. After 5 seconds, a new master ref is
|
|
1109
|
-
* fetched.
|
|
1110
|
-
* - If the user called `queryContentFromReleaseByID`: Use the release's ref.
|
|
1111
|
-
* The ref is cached for 5 seconds. After 5 seconds, a new ref for the
|
|
1112
|
-
* release is fetched.
|
|
1113
|
-
* - If the user called `queryContentFromReleaseByLabel`: Use the release's ref.
|
|
1114
|
-
* The ref is cached for 5 seconds. After 5 seconds, a new ref for the
|
|
1115
|
-
* release is fetched.
|
|
1116
|
-
* - If the user called `queryContentFromRef`: Use the provided ref. Fall back
|
|
1117
|
-
* to the master ref if the ref is not a string.
|
|
1118
|
-
*
|
|
1119
|
-
* @returns The ref to use during a query.
|
|
1120
|
-
*/
|
|
1121
|
-
async getResolvedRefString(params) {
|
|
1122
|
-
if (this.refState.autoPreviewsEnabled) {
|
|
1123
|
-
let previewRef;
|
|
1124
|
-
let cookieJar;
|
|
1125
|
-
if (this.refState.httpRequest?.headers) {
|
|
1126
|
-
if ("get" in this.refState.httpRequest.headers && typeof this.refState.httpRequest.headers.get === "function") {
|
|
1127
|
-
cookieJar = this.refState.httpRequest.headers.get("cookie");
|
|
1128
|
-
} else if ("cookie" in this.refState.httpRequest.headers) {
|
|
1129
|
-
cookieJar = this.refState.httpRequest.headers.cookie;
|
|
1130
|
-
}
|
|
1131
|
-
} else if (globalThis.document?.cookie) {
|
|
1132
|
-
cookieJar = globalThis.document.cookie;
|
|
1133
|
-
}
|
|
1134
|
-
if (cookieJar) {
|
|
1135
|
-
previewRef = getPreviewCookie.getPreviewCookie(cookieJar);
|
|
1136
|
-
}
|
|
1137
|
-
if (previewRef) {
|
|
1138
|
-
return previewRef;
|
|
1139
|
-
}
|
|
1140
|
-
}
|
|
1141
|
-
const cachedRepository = await this.getCachedRepository(params);
|
|
1142
|
-
const refModeType = this.refState.mode;
|
|
1143
|
-
if (refModeType === RefStateMode.ReleaseID) {
|
|
1144
|
-
return findRefByID.findRefByID(cachedRepository.refs, this.refState.releaseID).ref;
|
|
1145
|
-
} else if (refModeType === RefStateMode.ReleaseLabel) {
|
|
1146
|
-
return findRefByLabel.findRefByLabel(cachedRepository.refs, this.refState.releaseLabel).ref;
|
|
1147
|
-
} else if (refModeType === RefStateMode.Manual) {
|
|
1148
|
-
const res = await castThunk.castThunk(this.refState.ref)();
|
|
1149
|
-
if (typeof res === "string") {
|
|
1150
|
-
return res;
|
|
1151
|
-
}
|
|
1152
|
-
}
|
|
1153
|
-
return findMasterRef.findMasterRef(cachedRepository.refs).ref;
|
|
1154
|
-
}
|
|
1155
|
-
/**
|
|
1156
|
-
* The private implementation of `this.get`. It returns the API response and
|
|
1157
|
-
* the URL used to make the request. The URL is sometimes used in the public
|
|
1158
|
-
* method to include in thrown errors.
|
|
1159
|
-
*
|
|
1160
|
-
* This method retries requests that throw `RefNotFoundError` or
|
|
1161
|
-
* `RefExpiredError`. It contains special logic to retry with the latest
|
|
1162
|
-
* master ref, provided in the API's error message.
|
|
1163
|
-
*
|
|
1164
|
-
* @typeParam TDocument - Type of Prismic documents returned.
|
|
1165
|
-
*
|
|
1166
|
-
* @param params - Parameters to filter, sort, and paginate results.
|
|
1167
|
-
*
|
|
1168
|
-
* @returns An object containing the paginated response containing the result
|
|
1169
|
-
* of the query and the URL used to make the API request.
|
|
1170
|
-
*/
|
|
1171
|
-
async _get(params, attemptCount = 0) {
|
|
1172
|
-
const url = await this.buildQueryURL(params);
|
|
1173
|
-
try {
|
|
1174
|
-
const response = await this.#request(new URL(url), params);
|
|
1175
|
-
switch (response.status) {
|
|
1176
|
-
case 200: {
|
|
1177
|
-
try {
|
|
1178
|
-
return {
|
|
1179
|
-
data: await response.clone().json(),
|
|
1180
|
-
url
|
|
1181
|
-
};
|
|
1182
|
-
} catch {
|
|
1183
|
-
throw new PrismicError.PrismicError(void 0, url, await response.text());
|
|
1184
|
-
}
|
|
1185
|
-
}
|
|
1186
|
-
case 400: {
|
|
1187
|
-
const json = await response.json();
|
|
1188
|
-
throw new ParsingError.ParsingError(json.message, url, json);
|
|
1189
|
-
}
|
|
1190
|
-
case 401: {
|
|
1191
|
-
const json = await response.json();
|
|
1192
|
-
throw new ForbiddenError.ForbiddenError(json.message, url, json);
|
|
1193
|
-
}
|
|
1194
|
-
case 404: {
|
|
1195
|
-
const json = await response.json();
|
|
1196
|
-
switch (json.type) {
|
|
1197
|
-
case "api_notfound_error": {
|
|
1198
|
-
throw new RefNotFoundError.RefNotFoundError(json.message, url, json);
|
|
1199
|
-
}
|
|
1200
|
-
case "api_security_error": {
|
|
1201
|
-
if (/preview token.*expired/i.test(json.message)) {
|
|
1202
|
-
throw new PreviewTokenExpired.PreviewTokenExpiredError(json.message, url, json);
|
|
1203
|
-
}
|
|
1204
|
-
}
|
|
1205
|
-
default: {
|
|
1206
|
-
throw new NotFoundError.NotFoundError(json.message, url, json);
|
|
1207
|
-
}
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1210
|
-
case 410: {
|
|
1211
|
-
const json = await response.json();
|
|
1212
|
-
throw new RefExpiredError.RefExpiredError(json.message, url, json);
|
|
1213
|
-
}
|
|
1214
|
-
default: {
|
|
1215
|
-
throw new PrismicError.PrismicError(void 0, url, await response.text());
|
|
1216
|
-
}
|
|
1217
|
-
}
|
|
1218
|
-
} catch (error) {
|
|
1219
|
-
if (!(error instanceof RefNotFoundError.RefNotFoundError || error instanceof RefExpiredError.RefExpiredError) || attemptCount >= MAX_INVALID_REF_RETRY_ATTEMPTS - 1) {
|
|
1220
|
-
throw error;
|
|
1221
|
-
}
|
|
1222
|
-
if (!params?.ref) {
|
|
1223
|
-
this.cachedRepository = void 0;
|
|
1224
|
-
}
|
|
1225
|
-
const masterRef = error.message.match(/Master ref is: (?<ref>.*)$/)?.groups?.ref;
|
|
1226
|
-
if (!masterRef) {
|
|
1227
|
-
throw error;
|
|
1228
|
-
}
|
|
1229
|
-
const badRef = new URL(url).searchParams.get("ref");
|
|
1230
|
-
const issue = error instanceof RefNotFoundError.RefNotFoundError ? "invalid" : "expired";
|
|
1231
|
-
throttledLog.throttledLog(`[@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.`, { level: "warn" });
|
|
1232
|
-
return await this._get({ ...params, ref: masterRef }, attemptCount + 1);
|
|
1233
|
-
}
|
|
1234
|
-
}
|
|
1235
|
-
/**
|
|
1236
|
-
* Makes an HTTP request using the client's configured fetch function and
|
|
1237
|
-
* options.
|
|
1238
|
-
*
|
|
1239
|
-
* @param url - The URL to request.
|
|
1240
|
-
* @param params - Fetch options.
|
|
1241
|
-
*
|
|
1242
|
-
* @returns The response from the fetch request.
|
|
1243
|
-
*/
|
|
1244
|
-
async #request(url, params) {
|
|
1245
|
-
return await request.request(url, this._buildRequestInit(params), this.fetchFn);
|
|
1246
|
-
}
|
|
1247
|
-
_buildRequestInit(params) {
|
|
1248
|
-
return {
|
|
1249
|
-
...this.fetchOptions,
|
|
1250
|
-
...params?.fetchOptions,
|
|
1251
|
-
headers: {
|
|
1252
|
-
...this.fetchOptions?.headers,
|
|
1253
|
-
...params?.fetchOptions?.headers
|
|
1254
|
-
},
|
|
1255
|
-
signal: params?.fetchOptions?.signal || params?.signal || this.fetchOptions?.signal
|
|
1256
|
-
};
|
|
1257
|
-
}
|
|
18
|
+
/**
|
|
19
|
+
* A client for fetching content from a Prismic repository.
|
|
20
|
+
*
|
|
21
|
+
* @see {@link https://prismic.io/docs/fetch-content}
|
|
22
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client}
|
|
23
|
+
*/
|
|
24
|
+
var Client = class {
|
|
25
|
+
/**
|
|
26
|
+
* The client's Content API endpoint.
|
|
27
|
+
*
|
|
28
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}
|
|
29
|
+
*/
|
|
30
|
+
documentAPIEndpoint;
|
|
31
|
+
/**
|
|
32
|
+
* The secure token used for the Content API.
|
|
33
|
+
*
|
|
34
|
+
* @see {@link https://prismic.io/docs/fetch-content#content-visibility}
|
|
35
|
+
*/
|
|
36
|
+
accessToken;
|
|
37
|
+
/**
|
|
38
|
+
* A list of route resolver objects that define how a document's `url`
|
|
39
|
+
* property is resolved.
|
|
40
|
+
*
|
|
41
|
+
* @see {@link https://prismic.io/docs/routes}
|
|
42
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}
|
|
43
|
+
*/
|
|
44
|
+
routes;
|
|
45
|
+
/**
|
|
46
|
+
* The URL used for link or content relationship fields that point to an
|
|
47
|
+
* archived or deleted page.
|
|
48
|
+
*
|
|
49
|
+
* @see {@link https://prismic.io/docs/routes}
|
|
50
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}
|
|
51
|
+
*/
|
|
52
|
+
brokenRoute;
|
|
53
|
+
/**
|
|
54
|
+
* Default parameters sent with each Content API request. These parameters can
|
|
55
|
+
* be overridden on each method.
|
|
56
|
+
*
|
|
57
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}
|
|
58
|
+
*/
|
|
59
|
+
defaultParams;
|
|
60
|
+
/**
|
|
61
|
+
* The `fetch` function used to make network requests.
|
|
62
|
+
*
|
|
63
|
+
* @default The global `fetch` function.
|
|
64
|
+
*
|
|
65
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}
|
|
66
|
+
*/
|
|
67
|
+
fetchFn;
|
|
68
|
+
/**
|
|
69
|
+
* The default `fetch` options sent with each Content API request. These
|
|
70
|
+
* parameters can be overriden on each method.
|
|
71
|
+
*
|
|
72
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}
|
|
73
|
+
*/
|
|
74
|
+
fetchOptions;
|
|
75
|
+
#repositoryName;
|
|
76
|
+
#getRef;
|
|
77
|
+
#autoPreviews = true;
|
|
78
|
+
#autoPreviewsRequest;
|
|
79
|
+
#cachedRepository;
|
|
80
|
+
#cachedRepositoryExpiration = 0;
|
|
81
|
+
/**
|
|
82
|
+
* @param repositoryNameOrEndpoint - The Prismic repository name or full
|
|
83
|
+
* Content API endpoint for the repository.
|
|
84
|
+
* @param config - Client configuration.
|
|
85
|
+
*/
|
|
86
|
+
constructor(repositoryNameOrEndpoint, config = {}) {
|
|
87
|
+
var _globalThis$fetch;
|
|
88
|
+
const { documentAPIEndpoint, accessToken, ref, routes, brokenRoute, defaultParams, fetchOptions = {}, fetch = (_globalThis$fetch = globalThis.fetch) === null || _globalThis$fetch === void 0 ? void 0 : _globalThis$fetch.bind(globalThis) } = config;
|
|
89
|
+
if (require_isRepositoryEndpoint.isRepositoryEndpoint(repositoryNameOrEndpoint)) {
|
|
90
|
+
try {
|
|
91
|
+
this.repositoryName = require_getRepositoryName.getRepositoryName(repositoryNameOrEndpoint);
|
|
92
|
+
} catch {
|
|
93
|
+
console.warn(`[@prismicio/client] A repository name could not be inferred from the provided endpoint (\`${repositoryNameOrEndpoint}\`). Some methods will be disabled. Create the client using a repository name to prevent this warning. For more details, see ${require_devMsg.devMsg("prefer-repository-name")}`);
|
|
94
|
+
}
|
|
95
|
+
this.documentAPIEndpoint = documentAPIEndpoint || repositoryNameOrEndpoint;
|
|
96
|
+
} else {
|
|
97
|
+
this.repositoryName = repositoryNameOrEndpoint;
|
|
98
|
+
this.documentAPIEndpoint = documentAPIEndpoint || require_getRepositoryEndpoint.getRepositoryEndpoint(repositoryNameOrEndpoint);
|
|
99
|
+
}
|
|
100
|
+
if (!fetch) throw new require_errors.PrismicError("A valid fetch implementation was not provided. In environments where fetch is not available, a fetch implementation must be provided via a polyfill or the `fetch` option.", void 0, void 0);
|
|
101
|
+
if (typeof fetch !== "function") throw new require_errors.PrismicError(`fetch must be a function, but received: ${typeof fetch}`, void 0, void 0);
|
|
102
|
+
if (!require_isRepositoryEndpoint.isRepositoryEndpoint(this.documentAPIEndpoint)) throw new require_errors.PrismicError(`documentAPIEndpoint is not a valid URL: ${documentAPIEndpoint}`, void 0, void 0);
|
|
103
|
+
if (require_isRepositoryEndpoint.isRepositoryEndpoint(repositoryNameOrEndpoint) && documentAPIEndpoint && repositoryNameOrEndpoint !== documentAPIEndpoint) console.warn(`[@prismicio/client] Multiple incompatible endpoints were provided. Create the client using a repository name to prevent this error. For more details, see ${require_devMsg.devMsg("prefer-repository-name")}`);
|
|
104
|
+
if (process.env.NODE_ENV === "development" && /\.prismic\.io\/(?!api\/v2\/?)/i.test(this.documentAPIEndpoint)) throw new require_errors.PrismicError("@prismicio/client only supports Prismic Rest API V2. Please provide only the repository name to the first createClient() parameter or use the getRepositoryEndpoint() helper to generate a valid Rest API V2 endpoint URL.", void 0, void 0);
|
|
105
|
+
if (process.env.NODE_ENV === "development" && /(?<!\.cdn)\.prismic\.io$/i.test(new URL(this.documentAPIEndpoint).hostname)) console.warn(`[@prismicio/client] The client was created with a non-CDN endpoint. Convert it to the CDN endpoint for better performance. For more details, see ${require_devMsg.devMsg("endpoint-must-use-cdn")}`);
|
|
106
|
+
this.accessToken = accessToken;
|
|
107
|
+
this.routes = routes;
|
|
108
|
+
this.brokenRoute = brokenRoute;
|
|
109
|
+
this.defaultParams = defaultParams;
|
|
110
|
+
this.fetchOptions = fetchOptions;
|
|
111
|
+
this.fetchFn = fetch;
|
|
112
|
+
this.graphQLFetch = this.graphQLFetch.bind(this);
|
|
113
|
+
if (ref) this.queryContentFromRef(ref);
|
|
114
|
+
}
|
|
115
|
+
/** The Prismic repository's name. */
|
|
116
|
+
set repositoryName(value) {
|
|
117
|
+
this.#repositoryName = value;
|
|
118
|
+
}
|
|
119
|
+
/** The Prismic repository's name. */
|
|
120
|
+
get repositoryName() {
|
|
121
|
+
if (!this.#repositoryName) throw new require_errors.PrismicError(`A repository name is required for this method but one could not be inferred from the provided API endpoint (\`${this.documentAPIEndpoint}\`). To fix this error, provide a repository name when creating the client. For more details, see ${require_devMsg.devMsg("prefer-repository-name")}`, void 0, void 0);
|
|
122
|
+
return this.#repositoryName;
|
|
123
|
+
}
|
|
124
|
+
/** @deprecated Replace with `documentAPIEndpoint`. */
|
|
125
|
+
set endpoint(value) {
|
|
126
|
+
this.documentAPIEndpoint = value;
|
|
127
|
+
}
|
|
128
|
+
/** @deprecated Replace with `documentAPIEndpoint`. */
|
|
129
|
+
get endpoint() {
|
|
130
|
+
return this.documentAPIEndpoint;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Enables the client to automatically query content from a preview session.
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
*
|
|
137
|
+
* ```ts
|
|
138
|
+
* client.enableAutoPreviews()
|
|
139
|
+
* ```
|
|
140
|
+
*
|
|
141
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#enableautopreviews}
|
|
142
|
+
*/
|
|
143
|
+
enableAutoPreviews() {
|
|
144
|
+
this.#autoPreviews = true;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Enables the client to automatically query content from a preview session
|
|
148
|
+
* using an HTTP request object.
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
*
|
|
152
|
+
* ```ts
|
|
153
|
+
* client.enableAutoPreviewsFromReq(req)
|
|
154
|
+
* ```
|
|
155
|
+
*
|
|
156
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#enableautopreviewsfromreq}
|
|
157
|
+
*/
|
|
158
|
+
enableAutoPreviewsFromReq(request$1) {
|
|
159
|
+
this.enableAutoPreviews();
|
|
160
|
+
this.#autoPreviewsRequest = request$1;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Disables the client from automatically querying content from a preview
|
|
164
|
+
* session.
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
*
|
|
168
|
+
* ```ts
|
|
169
|
+
* client.disableAutoPreviews()
|
|
170
|
+
* ```
|
|
171
|
+
*
|
|
172
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#disableautopreviews}
|
|
173
|
+
*/
|
|
174
|
+
disableAutoPreviews() {
|
|
175
|
+
this.#autoPreviews = false;
|
|
176
|
+
this.#autoPreviewsRequest = void 0;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Fetches pages based on the `params` argument. Results are paginated.
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
*
|
|
183
|
+
* ```ts
|
|
184
|
+
* const response = await client.get({ pageSize: 10 })
|
|
185
|
+
* ```
|
|
186
|
+
*
|
|
187
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#get}
|
|
188
|
+
*/
|
|
189
|
+
async get(params) {
|
|
190
|
+
return await (await this.#internalGet(params)).json();
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Fetches the first page returned based on the `params` argument.
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
*
|
|
197
|
+
* ```ts
|
|
198
|
+
* const page = await client.getFirst()
|
|
199
|
+
* ```
|
|
200
|
+
*
|
|
201
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getfirst}
|
|
202
|
+
*/
|
|
203
|
+
async getFirst(params) {
|
|
204
|
+
const actualParams = (params === null || params === void 0 ? void 0 : params.page) || (params === null || params === void 0 ? void 0 : params.pageSize) ? params : {
|
|
205
|
+
...params,
|
|
206
|
+
pageSize: 1
|
|
207
|
+
};
|
|
208
|
+
const response = await this.#internalGet(actualParams);
|
|
209
|
+
const { results } = await response.clone().json();
|
|
210
|
+
if (results[0]) return results[0];
|
|
211
|
+
throw new require_errors.NotFoundError("No documents were returned", response.url, void 0);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Fetches all pages based on the `params` argument. This method may make
|
|
215
|
+
* multiple network requests to fetch all matching pages.
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
*
|
|
219
|
+
* ```ts
|
|
220
|
+
* const pages = await client.dangerouslyGetAll()
|
|
221
|
+
* ```
|
|
222
|
+
*
|
|
223
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#dangerouslygetall}
|
|
224
|
+
*/
|
|
225
|
+
async dangerouslyGetAll(params = {}) {
|
|
226
|
+
var _this$defaultParams;
|
|
227
|
+
const { limit = Infinity,...actualParams } = params;
|
|
228
|
+
const resolvedParams = {
|
|
229
|
+
...actualParams,
|
|
230
|
+
pageSize: Math.min(limit, actualParams.pageSize || ((_this$defaultParams = this.defaultParams) === null || _this$defaultParams === void 0 ? void 0 : _this$defaultParams.pageSize) || MAX_PAGE_SIZE)
|
|
231
|
+
};
|
|
232
|
+
const documents = [];
|
|
233
|
+
let latestResult;
|
|
234
|
+
while ((!latestResult || latestResult.next_page) && documents.length < limit) {
|
|
235
|
+
const page = latestResult ? latestResult.page + 1 : void 0;
|
|
236
|
+
latestResult = await this.get({
|
|
237
|
+
...resolvedParams,
|
|
238
|
+
page
|
|
239
|
+
});
|
|
240
|
+
documents.push(...latestResult.results);
|
|
241
|
+
if (latestResult.next_page) await new Promise((res) => setTimeout(res, GET_ALL_QUERY_DELAY));
|
|
242
|
+
}
|
|
243
|
+
return documents.slice(0, limit);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Fetches a page with a specific ID.
|
|
247
|
+
*
|
|
248
|
+
* @example
|
|
249
|
+
*
|
|
250
|
+
* ```ts
|
|
251
|
+
* const page = await client.getByID("WW4bKScAAMAqmluX")
|
|
252
|
+
* ```
|
|
253
|
+
*
|
|
254
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbyid}
|
|
255
|
+
*/
|
|
256
|
+
async getByID(id, params) {
|
|
257
|
+
return await this.getFirst(appendFilters(params, require_filter.filter.at("document.id", id)));
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Fetches pages with specific IDs. Results are paginated.
|
|
261
|
+
*
|
|
262
|
+
* @example
|
|
263
|
+
*
|
|
264
|
+
* ```ts
|
|
265
|
+
* const response = await client.getByIDs([
|
|
266
|
+
* "WW4bKScAAMAqmluX",
|
|
267
|
+
* "U1kTRgEAAC8A5ldS",
|
|
268
|
+
* ])
|
|
269
|
+
* ```
|
|
270
|
+
*
|
|
271
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbyids}
|
|
272
|
+
*/
|
|
273
|
+
async getByIDs(ids, params) {
|
|
274
|
+
return await this.get(appendFilters(params, require_filter.filter.in("document.id", ids)));
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Fetches pages with specific IDs. This method may make multiple network
|
|
278
|
+
* requests to fetch all matching pages.
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
*
|
|
282
|
+
* ```ts
|
|
283
|
+
* const pages = await client.getAllByIDs([
|
|
284
|
+
* "WW4bKScAAMAqmluX",
|
|
285
|
+
* "U1kTRgEAAC8A5ldS",
|
|
286
|
+
* ])
|
|
287
|
+
* ```
|
|
288
|
+
*
|
|
289
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getallbyids}
|
|
290
|
+
*/
|
|
291
|
+
async getAllByIDs(ids, params) {
|
|
292
|
+
return await this.dangerouslyGetAll(appendFilters(params, require_filter.filter.in("document.id", ids)));
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Fetches a page with a specific UID and type.
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
*
|
|
299
|
+
* ```ts
|
|
300
|
+
* const page = await client.getByUID("blog_post", "my-first-post")
|
|
301
|
+
* ```
|
|
302
|
+
*
|
|
303
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbyuid}
|
|
304
|
+
*/
|
|
305
|
+
async getByUID(documentType, uid, params) {
|
|
306
|
+
return await this.getFirst(appendFilters(params, require_filter.filter.at("document.type", documentType), require_filter.filter.at(`my.${documentType}.uid`, uid)));
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Fetches pages with specific UIDs and a specific type. Results are
|
|
310
|
+
* paginated.
|
|
311
|
+
*
|
|
312
|
+
* @example
|
|
313
|
+
*
|
|
314
|
+
* ```ts
|
|
315
|
+
* const response = await client.getByUIDs("blog_post", [
|
|
316
|
+
* "my-first-post",
|
|
317
|
+
* "my-second-post",
|
|
318
|
+
* ])
|
|
319
|
+
* ```
|
|
320
|
+
*
|
|
321
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbyuids}
|
|
322
|
+
*/
|
|
323
|
+
async getByUIDs(documentType, uids, params) {
|
|
324
|
+
return await this.get(appendFilters(params, require_filter.filter.at("document.type", documentType), require_filter.filter.in(`my.${documentType}.uid`, uids)));
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Fetches pages with specific UIDs and a specific type. This method may make
|
|
328
|
+
* multiple network requests to fetch all matching pages.
|
|
329
|
+
*
|
|
330
|
+
* @example
|
|
331
|
+
*
|
|
332
|
+
* ```ts
|
|
333
|
+
* const pages = await client.getAllByUIDs("blog_post", [
|
|
334
|
+
* "my-first-post",
|
|
335
|
+
* "my-second-post",
|
|
336
|
+
* ])
|
|
337
|
+
* ```
|
|
338
|
+
*
|
|
339
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getallbyuids}
|
|
340
|
+
*/
|
|
341
|
+
async getAllByUIDs(documentType, uids, params) {
|
|
342
|
+
return await this.dangerouslyGetAll(appendFilters(params, require_filter.filter.at("document.type", documentType), require_filter.filter.in(`my.${documentType}.uid`, uids)));
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Fetches a specific single type page.
|
|
346
|
+
*
|
|
347
|
+
* @example
|
|
348
|
+
*
|
|
349
|
+
* ```ts
|
|
350
|
+
* const page = await client.getSingle("settings")
|
|
351
|
+
* ```
|
|
352
|
+
*
|
|
353
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getsingle}
|
|
354
|
+
*/
|
|
355
|
+
async getSingle(documentType, params) {
|
|
356
|
+
return await this.getFirst(appendFilters(params, require_filter.filter.at("document.type", documentType)));
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Fetches pages with a specific type. Results are paginated.
|
|
360
|
+
*
|
|
361
|
+
* @example
|
|
362
|
+
*
|
|
363
|
+
* ```ts
|
|
364
|
+
* const response = await client.getByType("blog_post")
|
|
365
|
+
* ```
|
|
366
|
+
*
|
|
367
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbytype}
|
|
368
|
+
*/
|
|
369
|
+
async getByType(documentType, params) {
|
|
370
|
+
return await this.get(appendFilters(params, require_filter.filter.at("document.type", documentType)));
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Fetches pages with a specific type. This method may make multiple network
|
|
374
|
+
* requests to fetch all matching documents.
|
|
375
|
+
*
|
|
376
|
+
* @example
|
|
377
|
+
*
|
|
378
|
+
* ```ts
|
|
379
|
+
* const pages = await client.getAllByType("blog_post")
|
|
380
|
+
* ```
|
|
381
|
+
*
|
|
382
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getallbytype}
|
|
383
|
+
*/
|
|
384
|
+
async getAllByType(documentType, params) {
|
|
385
|
+
return await this.dangerouslyGetAll(appendFilters(params, require_filter.filter.at("document.type", documentType)));
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Fetches pages with a specific tag. Results are paginated.
|
|
389
|
+
*
|
|
390
|
+
* @example
|
|
391
|
+
*
|
|
392
|
+
* ```ts
|
|
393
|
+
* const response = await client.getByTag("featured")
|
|
394
|
+
* ```
|
|
395
|
+
*
|
|
396
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbytag}
|
|
397
|
+
*/
|
|
398
|
+
async getByTag(tag, params) {
|
|
399
|
+
return await this.get(appendFilters(params, require_filter.filter.any("document.tags", [tag])));
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Fetches pages with a specific tag. This method may make multiple network
|
|
403
|
+
* requests to fetch all matching documents.
|
|
404
|
+
*
|
|
405
|
+
* @example
|
|
406
|
+
*
|
|
407
|
+
* ```ts
|
|
408
|
+
* const pages = await client.getAllByTag("featured")
|
|
409
|
+
* ```
|
|
410
|
+
*
|
|
411
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getallbytag}
|
|
412
|
+
*/
|
|
413
|
+
async getAllByTag(tag, params) {
|
|
414
|
+
return await this.dangerouslyGetAll(appendFilters(params, require_filter.filter.any("document.tags", [tag])));
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Fetches pages with every tag from a list of tags. Results are paginated.
|
|
418
|
+
*
|
|
419
|
+
* @example
|
|
420
|
+
*
|
|
421
|
+
* ```ts
|
|
422
|
+
* const response = await client.getByEveryTag(["featured", "homepage"])
|
|
423
|
+
* ```
|
|
424
|
+
*
|
|
425
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbyeverytag}
|
|
426
|
+
*/
|
|
427
|
+
async getByEveryTag(tags, params) {
|
|
428
|
+
return await this.get(appendFilters(params, require_filter.filter.at("document.tags", tags)));
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Fetches pages with every tag from a list of tags. This method may make
|
|
432
|
+
* multiple network requests to fetch all matching pages.
|
|
433
|
+
*
|
|
434
|
+
* @example
|
|
435
|
+
*
|
|
436
|
+
* ```ts
|
|
437
|
+
* const pages = await client.getAllByEveryTag(["featured", "homepage"])
|
|
438
|
+
* ```
|
|
439
|
+
*
|
|
440
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getallbyeverytag}
|
|
441
|
+
*/
|
|
442
|
+
async getAllByEveryTag(tags, params) {
|
|
443
|
+
return await this.dangerouslyGetAll(appendFilters(params, require_filter.filter.at("document.tags", tags)));
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Fetches pages with at least one tag from a list of tags. Results are
|
|
447
|
+
* paginated.
|
|
448
|
+
*
|
|
449
|
+
* @example
|
|
450
|
+
*
|
|
451
|
+
* ```ts
|
|
452
|
+
* const response = await client.getBySomeTags(["featured", "homepage"])
|
|
453
|
+
* ```
|
|
454
|
+
*
|
|
455
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbysometags}
|
|
456
|
+
*/
|
|
457
|
+
async getBySomeTags(tags, params) {
|
|
458
|
+
return await this.get(appendFilters(params, require_filter.filter.any("document.tags", tags)));
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Fetches pages with at least one tag from a list of tags. This method may
|
|
462
|
+
* make multiple network requests to fetch all matching documents.
|
|
463
|
+
*
|
|
464
|
+
* @example
|
|
465
|
+
*
|
|
466
|
+
* ```ts
|
|
467
|
+
* const pages = await client.getAllBySomeTags(["featured", "homepage"])
|
|
468
|
+
* ```
|
|
469
|
+
*
|
|
470
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getallbysometags}
|
|
471
|
+
*/
|
|
472
|
+
async getAllBySomeTags(tags, params) {
|
|
473
|
+
return await this.dangerouslyGetAll(appendFilters(params, require_filter.filter.any("document.tags", tags)));
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Fetches metadata about the client's Prismic repository.
|
|
477
|
+
*
|
|
478
|
+
* @example
|
|
479
|
+
*
|
|
480
|
+
* ```ts
|
|
481
|
+
* const repository = await client.getRepository()
|
|
482
|
+
* ```
|
|
483
|
+
*
|
|
484
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getrepository}
|
|
485
|
+
*/
|
|
486
|
+
async getRepository(params) {
|
|
487
|
+
if (this.#cachedRepository && this.#cachedRepositoryExpiration > Date.now()) return this.#cachedRepository;
|
|
488
|
+
const url = new URL(this.documentAPIEndpoint);
|
|
489
|
+
const accessToken = (params === null || params === void 0 ? void 0 : params.accessToken) || this.accessToken;
|
|
490
|
+
if (accessToken) url.searchParams.set("access_token", accessToken);
|
|
491
|
+
const response = await this.#request(url, params);
|
|
492
|
+
if (response.ok) {
|
|
493
|
+
this.#cachedRepository = await response.json();
|
|
494
|
+
this.#cachedRepositoryExpiration = Date.now() + REPOSITORY_CACHE_TTL;
|
|
495
|
+
return this.#cachedRepository;
|
|
496
|
+
}
|
|
497
|
+
if (response.status === 404) throw new require_errors.RepositoryNotFoundError(`Prismic repository not found. Check that "${this.documentAPIEndpoint}" is pointing to the correct repository.`, url.toString(), void 0);
|
|
498
|
+
return await this.#throwContentAPIError(response, url.toString());
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Fetches the repository's active refs.
|
|
502
|
+
*
|
|
503
|
+
* @example
|
|
504
|
+
*
|
|
505
|
+
* ```ts
|
|
506
|
+
* const refs = await client.getRefs()
|
|
507
|
+
* ```
|
|
508
|
+
*
|
|
509
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getrefs}
|
|
510
|
+
*/
|
|
511
|
+
async getRefs(params) {
|
|
512
|
+
return (await this.getRepository(params)).refs;
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Fetches a ref by its ID.
|
|
516
|
+
*
|
|
517
|
+
* @example
|
|
518
|
+
*
|
|
519
|
+
* ```ts
|
|
520
|
+
* const ref = await client.getRefByID("YhE3YhEAACIA4321")
|
|
521
|
+
* ```
|
|
522
|
+
*
|
|
523
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getrefbyid}
|
|
524
|
+
*/
|
|
525
|
+
async getRefByID(id, params) {
|
|
526
|
+
const ref = (await this.getRefs(params)).find((ref$1) => ref$1.id === id);
|
|
527
|
+
if (!ref) throw new require_errors.PrismicError(`Ref with ID "${id}" could not be found.`, void 0, void 0);
|
|
528
|
+
return ref;
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Fetches a ref by its label. A release ref's label is its name shown in the
|
|
532
|
+
* Page Builder.
|
|
533
|
+
*
|
|
534
|
+
* @example
|
|
535
|
+
*
|
|
536
|
+
* ```ts
|
|
537
|
+
* const ref = await client.getRefByLabel("My Release")
|
|
538
|
+
* ```
|
|
539
|
+
*
|
|
540
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getrefbylabel}
|
|
541
|
+
*/
|
|
542
|
+
async getRefByLabel(label, params) {
|
|
543
|
+
const ref = (await this.getRefs(params)).find((ref$1) => ref$1.label === label);
|
|
544
|
+
if (!ref) throw new require_errors.PrismicError(`Ref with label "${label}" could not be found.`, void 0, void 0);
|
|
545
|
+
return ref;
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* Fetches the repository's master ref.
|
|
549
|
+
*
|
|
550
|
+
* @example
|
|
551
|
+
*
|
|
552
|
+
* ```ts
|
|
553
|
+
* const masterRef = await client.getMasterRef()
|
|
554
|
+
* ```
|
|
555
|
+
*
|
|
556
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getmasterref}
|
|
557
|
+
*/
|
|
558
|
+
async getMasterRef(params) {
|
|
559
|
+
const ref = (await this.getRefs(params)).find((ref$1) => ref$1.isMasterRef);
|
|
560
|
+
if (!ref) throw new require_errors.PrismicError("Master ref could not be found.", void 0, void 0);
|
|
561
|
+
return ref;
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Fetches the repository's active releases.
|
|
565
|
+
*
|
|
566
|
+
* @example
|
|
567
|
+
*
|
|
568
|
+
* ```ts
|
|
569
|
+
* const releases = await client.getReleases()
|
|
570
|
+
* ```
|
|
571
|
+
*
|
|
572
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getreleases}
|
|
573
|
+
*/
|
|
574
|
+
async getReleases(params) {
|
|
575
|
+
return (await this.getRefs(params)).filter((ref) => !ref.isMasterRef);
|
|
576
|
+
}
|
|
577
|
+
/**
|
|
578
|
+
* Fetches a release with a specific ID.
|
|
579
|
+
*
|
|
580
|
+
* @example
|
|
581
|
+
*
|
|
582
|
+
* ```ts
|
|
583
|
+
* const release = await client.getReleaseByID("YhE3YhEAACIA4321")
|
|
584
|
+
* ```
|
|
585
|
+
*
|
|
586
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getreleasebyid}
|
|
587
|
+
*/
|
|
588
|
+
async getReleaseByID(id, params) {
|
|
589
|
+
const release = (await this.getReleases(params)).find((ref) => ref.id === id);
|
|
590
|
+
if (!release) throw new require_errors.PrismicError(`Release with ID "${id}" could not be found.`, void 0, void 0);
|
|
591
|
+
return release;
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* Fetches a release by its label. A release ref's label is its name shown in
|
|
595
|
+
* the Page Builder.
|
|
596
|
+
*
|
|
597
|
+
* @example
|
|
598
|
+
*
|
|
599
|
+
* ```ts
|
|
600
|
+
* const release = await client.getReleaseByLabel("My Release")
|
|
601
|
+
* ```
|
|
602
|
+
*
|
|
603
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getreleasebylabel}
|
|
604
|
+
*/
|
|
605
|
+
async getReleaseByLabel(label, params) {
|
|
606
|
+
const release = (await this.getReleases(params)).find((ref) => ref.label === label);
|
|
607
|
+
if (!release) throw new require_errors.PrismicError(`Release with label "${label}" could not be found.`, void 0, void 0);
|
|
608
|
+
return release;
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* Fetches the repository's page tags.
|
|
612
|
+
*
|
|
613
|
+
* @example
|
|
614
|
+
*
|
|
615
|
+
* ```ts
|
|
616
|
+
* const tags = await client.getTags()
|
|
617
|
+
* ```
|
|
618
|
+
*
|
|
619
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#gettags}
|
|
620
|
+
*/
|
|
621
|
+
async getTags(params) {
|
|
622
|
+
const repository = await this.getRepository(params);
|
|
623
|
+
const form = repository.forms.tags;
|
|
624
|
+
if (form) {
|
|
625
|
+
const url = new URL(form.action);
|
|
626
|
+
if (this.accessToken) url.searchParams.set("access_token", this.accessToken);
|
|
627
|
+
const response = await this.#request(url, params);
|
|
628
|
+
if (response.ok) return await response.json();
|
|
629
|
+
}
|
|
630
|
+
return repository.tags;
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
* Builds a Content API query URL with a set of parameters.
|
|
634
|
+
*
|
|
635
|
+
* @example
|
|
636
|
+
*
|
|
637
|
+
* ```ts
|
|
638
|
+
* const url = await client.buildQueryURL({
|
|
639
|
+
* filters: [filter.at("document.type", "blog_post")],
|
|
640
|
+
* })
|
|
641
|
+
* ```
|
|
642
|
+
*
|
|
643
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#buildqueryurl}
|
|
644
|
+
*/
|
|
645
|
+
async buildQueryURL({ signal, fetchOptions,...params } = {}) {
|
|
646
|
+
const ref = params.ref || await this.#getResolvedRef({
|
|
647
|
+
accessToken: params.accessToken,
|
|
648
|
+
signal,
|
|
649
|
+
fetchOptions
|
|
650
|
+
});
|
|
651
|
+
const integrationFieldsRef = params.integrationFieldsRef || (await this.getRepository({
|
|
652
|
+
accessToken: params.accessToken,
|
|
653
|
+
signal,
|
|
654
|
+
fetchOptions
|
|
655
|
+
})).integrationFieldsRef || void 0;
|
|
656
|
+
return require_buildQueryURL.buildQueryURL(this.documentAPIEndpoint, {
|
|
657
|
+
...this.defaultParams,
|
|
658
|
+
...params,
|
|
659
|
+
ref,
|
|
660
|
+
integrationFieldsRef,
|
|
661
|
+
routes: params.routes || this.routes,
|
|
662
|
+
brokenRoute: params.brokenRoute || this.brokenRoute,
|
|
663
|
+
accessToken: params.accessToken || this.accessToken
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* Fetches a previewed page's URL using a preview token and page ID.
|
|
668
|
+
*
|
|
669
|
+
* @example
|
|
670
|
+
*
|
|
671
|
+
* ```ts
|
|
672
|
+
* const url = await client.resolvePreviewURL({
|
|
673
|
+
* linkResolver,
|
|
674
|
+
* defaultURL: "/",
|
|
675
|
+
* })
|
|
676
|
+
* ```
|
|
677
|
+
*
|
|
678
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#resolvepreviewurl}
|
|
679
|
+
*/
|
|
680
|
+
async resolvePreviewURL(args) {
|
|
681
|
+
let documentID = args.documentID;
|
|
682
|
+
let previewToken = args.previewToken;
|
|
683
|
+
if (typeof globalThis.location !== "undefined") {
|
|
684
|
+
const searchParams = new URLSearchParams(globalThis.location.search);
|
|
685
|
+
documentID = documentID || searchParams.get("documentId");
|
|
686
|
+
previewToken = previewToken || searchParams.get("token");
|
|
687
|
+
} else if (this.#autoPreviewsRequest) {
|
|
688
|
+
if ("query" in this.#autoPreviewsRequest) {
|
|
689
|
+
var _this$autoPreviewsReq, _this$autoPreviewsReq2;
|
|
690
|
+
documentID = documentID || ((_this$autoPreviewsReq = this.#autoPreviewsRequest.query) === null || _this$autoPreviewsReq === void 0 ? void 0 : _this$autoPreviewsReq.documentId);
|
|
691
|
+
previewToken = previewToken || ((_this$autoPreviewsReq2 = this.#autoPreviewsRequest.query) === null || _this$autoPreviewsReq2 === void 0 ? void 0 : _this$autoPreviewsReq2.token);
|
|
692
|
+
} else if ("url" in this.#autoPreviewsRequest && this.#autoPreviewsRequest.url) {
|
|
693
|
+
const searchParams = new URL(this.#autoPreviewsRequest.url, "missing-host://").searchParams;
|
|
694
|
+
documentID = documentID || searchParams.get("documentId");
|
|
695
|
+
previewToken = previewToken || searchParams.get("token");
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
if (documentID != null && previewToken != null) {
|
|
699
|
+
const url = require_asLink.asLink(await this.getByID(documentID, {
|
|
700
|
+
ref: previewToken,
|
|
701
|
+
lang: "*",
|
|
702
|
+
signal: args.signal,
|
|
703
|
+
fetchOptions: args.fetchOptions
|
|
704
|
+
}), { linkResolver: args.linkResolver });
|
|
705
|
+
if (typeof url === "string") return url;
|
|
706
|
+
}
|
|
707
|
+
return args.defaultURL;
|
|
708
|
+
}
|
|
709
|
+
/**
|
|
710
|
+
* Configures the client to query the latest published content. This is the
|
|
711
|
+
* client's default mode.
|
|
712
|
+
*
|
|
713
|
+
* @example
|
|
714
|
+
*
|
|
715
|
+
* ```ts
|
|
716
|
+
* client.queryLatestContent()
|
|
717
|
+
* ```
|
|
718
|
+
*
|
|
719
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querylatestcontent}
|
|
720
|
+
*/
|
|
721
|
+
queryLatestContent() {
|
|
722
|
+
this.#getRef = void 0;
|
|
723
|
+
}
|
|
724
|
+
/**
|
|
725
|
+
* Configures the client to query content from a release with a specific ID.
|
|
726
|
+
*
|
|
727
|
+
* @example
|
|
728
|
+
*
|
|
729
|
+
* ```ts
|
|
730
|
+
* client.queryContentFromReleaseByID("YhE3YhEAACIA4321")
|
|
731
|
+
* ```
|
|
732
|
+
*
|
|
733
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querycontentfromreleasebyid}
|
|
734
|
+
*/
|
|
735
|
+
queryContentFromReleaseByID(id) {
|
|
736
|
+
this.#getRef = async (params) => {
|
|
737
|
+
return (await this.getReleaseByID(id, params)).ref;
|
|
738
|
+
};
|
|
739
|
+
}
|
|
740
|
+
/**
|
|
741
|
+
* Configures the client to query content from a release with a specific
|
|
742
|
+
* label.
|
|
743
|
+
*
|
|
744
|
+
* @example
|
|
745
|
+
*
|
|
746
|
+
* ```ts
|
|
747
|
+
* client.queryContentFromReleaseByLabel("My Release")
|
|
748
|
+
* ```
|
|
749
|
+
*
|
|
750
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querycontentfromreleasebylabel}
|
|
751
|
+
*/
|
|
752
|
+
queryContentFromReleaseByLabel(label) {
|
|
753
|
+
this.#getRef = async (params) => {
|
|
754
|
+
return (await this.getReleaseByLabel(label, params)).ref;
|
|
755
|
+
};
|
|
756
|
+
}
|
|
757
|
+
/**
|
|
758
|
+
* Configures the client to query content from a specific ref.
|
|
759
|
+
*
|
|
760
|
+
* @example
|
|
761
|
+
*
|
|
762
|
+
* ```ts
|
|
763
|
+
* client.queryContentFromRef("my-ref")
|
|
764
|
+
* ```
|
|
765
|
+
*
|
|
766
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querycontentfromref}
|
|
767
|
+
*/
|
|
768
|
+
queryContentFromRef(ref) {
|
|
769
|
+
this.#getRef = typeof ref === "string" ? () => ref : ref;
|
|
770
|
+
}
|
|
771
|
+
/**
|
|
772
|
+
* A preconfigured `fetch()` function for Prismic's GraphQL API that can be
|
|
773
|
+
* provided to GraphQL clients.
|
|
774
|
+
*
|
|
775
|
+
* @example
|
|
776
|
+
*
|
|
777
|
+
* ```ts
|
|
778
|
+
* import { createClient, getGraphQLEndpoint } from "@prismicio/client"
|
|
779
|
+
*
|
|
780
|
+
* const client = createClient("example-prismic-repo")
|
|
781
|
+
* const graphQLClient = new ApolloClient({
|
|
782
|
+
* link: new HttpLink({
|
|
783
|
+
* uri: getGraphQLEndpoint(client.repositoryName),
|
|
784
|
+
* // Provide `client.graphQLFetch` as the fetch implementation.
|
|
785
|
+
* fetch: client.graphQLFetch,
|
|
786
|
+
* // Using GET is required.
|
|
787
|
+
* useGETForQueries: true,
|
|
788
|
+
* }),
|
|
789
|
+
* cache: new InMemoryCache(),
|
|
790
|
+
* })
|
|
791
|
+
* ```
|
|
792
|
+
*
|
|
793
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#graphqlfetch}
|
|
794
|
+
*/
|
|
795
|
+
async graphQLFetch(input, init) {
|
|
796
|
+
const params = {
|
|
797
|
+
accessToken: this.accessToken,
|
|
798
|
+
fetchOptions: this.fetchOptions
|
|
799
|
+
};
|
|
800
|
+
const repository = await this.getRepository(params);
|
|
801
|
+
const ref = await this.#getResolvedRef(params);
|
|
802
|
+
const headers = {};
|
|
803
|
+
headers["prismic-ref"] = ref;
|
|
804
|
+
if (this.accessToken) headers["authorization"] = `Token ${this.accessToken}`;
|
|
805
|
+
if (repository.integrationFieldsRef) headers["prismic-integration-field-ref"] = repository.integrationFieldsRef;
|
|
806
|
+
for (const [key, value] of Object.entries((init === null || init === void 0 ? void 0 : init.headers) ?? {})) headers[key.toLowerCase()] = value;
|
|
807
|
+
const url = new URL(typeof input === "string" ? input : input.url);
|
|
808
|
+
const query = (url.searchParams.get("query") ?? "").replace(/(\n| )*( |{|})(\n| )*/gm, (_chars, _spaces, brackets) => brackets);
|
|
809
|
+
url.searchParams.set("query", query);
|
|
810
|
+
url.searchParams.set("ref", ref);
|
|
811
|
+
return await this.fetchFn(url.toString(), {
|
|
812
|
+
...init,
|
|
813
|
+
headers
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
/**
|
|
817
|
+
* Returns the ref needed to query based on the client's current state. This
|
|
818
|
+
* method may make a network request to fetch a ref or resolve the user's ref
|
|
819
|
+
* thunk.
|
|
820
|
+
*
|
|
821
|
+
* If auto previews are enabled, the preview ref takes priority.
|
|
822
|
+
*
|
|
823
|
+
* The following strategies are used depending on the client's state:
|
|
824
|
+
*
|
|
825
|
+
* - If the user called `queryLatestContent`: Use the repository's master ref.
|
|
826
|
+
* The ref is cached for 5 seconds. After 5 seconds, a new master ref is
|
|
827
|
+
* fetched.
|
|
828
|
+
* - If the user called `queryContentFromReleaseByID`: Use the release's ref.
|
|
829
|
+
* The ref is cached for 5 seconds. After 5 seconds, a new ref for the
|
|
830
|
+
* release is fetched.
|
|
831
|
+
* - If the user called `queryContentFromReleaseByLabel`: Use the release's ref.
|
|
832
|
+
* The ref is cached for 5 seconds. After 5 seconds, a new ref for the
|
|
833
|
+
* release is fetched.
|
|
834
|
+
* - If the user called `queryContentFromRef`: Use the provided ref. Fall back
|
|
835
|
+
* to the master ref if the ref is not a string.
|
|
836
|
+
*/
|
|
837
|
+
async #getResolvedRef(params) {
|
|
838
|
+
var _this$getRef;
|
|
839
|
+
if (this.#autoPreviews) {
|
|
840
|
+
var _this$autoPreviewsReq3, _globalThis$document;
|
|
841
|
+
const previewRef = require_getPreviewCookie.getPreviewCookie((((_this$autoPreviewsReq3 = this.#autoPreviewsRequest) === null || _this$autoPreviewsReq3 === void 0 ? void 0 : _this$autoPreviewsReq3.headers) ? "get" in this.#autoPreviewsRequest.headers ? this.#autoPreviewsRequest.headers.get("cookie") : this.#autoPreviewsRequest.headers.cookie : (_globalThis$document = globalThis.document) === null || _globalThis$document === void 0 ? void 0 : _globalThis$document.cookie) ?? "");
|
|
842
|
+
if (previewRef) return previewRef;
|
|
843
|
+
}
|
|
844
|
+
const ref = await ((_this$getRef = this.#getRef) === null || _this$getRef === void 0 ? void 0 : _this$getRef.call(this, params));
|
|
845
|
+
if (ref) return ref;
|
|
846
|
+
return (await this.getMasterRef(params)).ref;
|
|
847
|
+
}
|
|
848
|
+
/**
|
|
849
|
+
* Performs a low-level Content API request with the given parameters.
|
|
850
|
+
* Automatically retries if an invalid ref is used.
|
|
851
|
+
*/
|
|
852
|
+
async #internalGet(params, attempt = 1) {
|
|
853
|
+
const url = await this.buildQueryURL(params);
|
|
854
|
+
const response = await this.#request(new URL(url), params);
|
|
855
|
+
if (response.ok) return response;
|
|
856
|
+
try {
|
|
857
|
+
return await this.#throwContentAPIError(response, url);
|
|
858
|
+
} catch (error) {
|
|
859
|
+
if ((error instanceof require_errors.RefNotFoundError || error instanceof require_errors.RefExpiredError) && attempt < MAX_INVALID_REF_RETRY_ATTEMPTS) {
|
|
860
|
+
var _error$message$match;
|
|
861
|
+
if (!(params === null || params === void 0 ? void 0 : params.ref)) this.#cachedRepository = void 0;
|
|
862
|
+
const masterRef = (_error$message$match = error.message.match(/master ref is: (?<ref>.*)$/i)) === null || _error$message$match === void 0 || (_error$message$match = _error$message$match.groups) === null || _error$message$match === void 0 ? void 0 : _error$message$match.ref;
|
|
863
|
+
if (!masterRef) throw error;
|
|
864
|
+
require_throttledWarn.throttledWarn(`[@prismicio/client] The ref (${new URL(url).searchParams.get("ref")}) was ${error instanceof require_errors.RefNotFoundError ? "invalid" : "expired"}. Now retrying with the latest master ref (${masterRef}). If you were previewing content, the response will not include draft content.`);
|
|
865
|
+
return await this.#internalGet({
|
|
866
|
+
...params,
|
|
867
|
+
ref: masterRef
|
|
868
|
+
}, attempt + 1);
|
|
869
|
+
}
|
|
870
|
+
throw error;
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
/**
|
|
874
|
+
* Throws an error based on a Content API response. Only call in known-errored
|
|
875
|
+
* states.
|
|
876
|
+
*/
|
|
877
|
+
async #throwContentAPIError(response, url) {
|
|
878
|
+
switch (response.status) {
|
|
879
|
+
case 400: {
|
|
880
|
+
const json = await response.clone().json();
|
|
881
|
+
throw new require_errors.ParsingError(json.message, url, json);
|
|
882
|
+
}
|
|
883
|
+
case 401: {
|
|
884
|
+
const json = await response.clone().json();
|
|
885
|
+
throw new require_errors.ForbiddenError(json.message, url, json);
|
|
886
|
+
}
|
|
887
|
+
case 404: {
|
|
888
|
+
const json = await response.clone().json();
|
|
889
|
+
switch (json.type) {
|
|
890
|
+
case "api_notfound_error": throw new require_errors.RefNotFoundError(json.message, url, json);
|
|
891
|
+
case "api_security_error": if (/preview token.*expired/i.test(json.message)) throw new require_errors.PreviewTokenExpiredError(json.message, url, json);
|
|
892
|
+
default: throw new require_errors.NotFoundError(json.message, url, json);
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
case 410: {
|
|
896
|
+
const json = await response.clone().json();
|
|
897
|
+
throw new require_errors.RefExpiredError(json.message, url, json);
|
|
898
|
+
}
|
|
899
|
+
default: throw new require_errors.PrismicError(void 0, url, await response.text());
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
/** Performs a low-level network request with the client's fetch options. */
|
|
903
|
+
async #request(url, params) {
|
|
904
|
+
var _this$fetchOptions, _params$fetchOptions, _params$fetchOptions2, _this$fetchOptions2;
|
|
905
|
+
return await require_request.request(url, {
|
|
906
|
+
...this.fetchOptions,
|
|
907
|
+
...params === null || params === void 0 ? void 0 : params.fetchOptions,
|
|
908
|
+
headers: {
|
|
909
|
+
...(_this$fetchOptions = this.fetchOptions) === null || _this$fetchOptions === void 0 ? void 0 : _this$fetchOptions.headers,
|
|
910
|
+
...params === null || params === void 0 || (_params$fetchOptions = params.fetchOptions) === null || _params$fetchOptions === void 0 ? void 0 : _params$fetchOptions.headers
|
|
911
|
+
},
|
|
912
|
+
signal: (params === null || params === void 0 || (_params$fetchOptions2 = params.fetchOptions) === null || _params$fetchOptions2 === void 0 ? void 0 : _params$fetchOptions2.signal) || (params === null || params === void 0 ? void 0 : params.signal) || ((_this$fetchOptions2 = this.fetchOptions) === null || _this$fetchOptions2 === void 0 ? void 0 : _this$fetchOptions2.signal)
|
|
913
|
+
}, this.fetchFn);
|
|
914
|
+
}
|
|
915
|
+
};
|
|
916
|
+
/** Appends filters to a params object. */
|
|
917
|
+
function appendFilters(params = {}, ...filters) {
|
|
918
|
+
return {
|
|
919
|
+
...params,
|
|
920
|
+
filters: [...params.filters ?? [], ...filters]
|
|
921
|
+
};
|
|
1258
922
|
}
|
|
923
|
+
|
|
924
|
+
//#endregion
|
|
1259
925
|
exports.Client = Client;
|
|
1260
|
-
|
|
1261
|
-
exports.REPOSITORY_CACHE_TTL = REPOSITORY_CACHE_TTL;
|
|
1262
|
-
//# sourceMappingURL=Client.cjs.map
|
|
926
|
+
//# sourceMappingURL=Client.cjs.map
|