@prismicio/client 7.21.0-alpha.2 → 7.21.0-canary.31d5815
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 +966 -0
- package/dist/Client.cjs.map +1 -0
- package/dist/Client.d.cts +749 -0
- package/dist/Client.d.cts.map +1 -0
- package/dist/Client.d.ts +749 -0
- package/dist/Client.d.ts.map +1 -0
- package/dist/Client.js +966 -0
- package/dist/Client.js.map +1 -0
- package/dist/Migration.cjs +284 -0
- package/dist/Migration.cjs.map +1 -0
- package/dist/Migration.d.cts +216 -0
- package/dist/Migration.d.cts.map +1 -0
- package/dist/Migration.d.ts +216 -0
- package/dist/Migration.d.ts.map +1 -0
- package/dist/Migration.js +284 -0
- package/dist/Migration.js.map +1 -0
- package/dist/WriteClient.cjs +491 -0
- package/dist/WriteClient.cjs.map +1 -0
- package/dist/WriteClient.d.cts +262 -0
- package/dist/WriteClient.d.cts.map +1 -0
- package/dist/WriteClient.d.ts +262 -0
- package/dist/WriteClient.d.ts.map +1 -0
- package/dist/WriteClient.js +491 -0
- package/dist/WriteClient.js.map +1 -0
- package/dist/_virtual/rolldown_runtime.cjs +14 -0
- package/dist/_virtual/rolldown_runtime.js +13 -0
- package/dist/buildQueryURL.cjs +96 -0
- package/dist/buildQueryURL.cjs.map +1 -0
- package/dist/buildQueryURL.d.cts +220 -0
- package/dist/buildQueryURL.d.cts.map +1 -0
- package/dist/buildQueryURL.d.ts +220 -0
- package/dist/buildQueryURL.d.ts.map +1 -0
- package/dist/buildQueryURL.js +96 -0
- package/dist/buildQueryURL.js.map +1 -0
- package/dist/cookie.cjs +19 -0
- package/dist/cookie.cjs.map +1 -0
- package/dist/cookie.d.cts +11 -0
- package/dist/cookie.d.cts.map +1 -0
- package/dist/cookie.d.ts +11 -0
- package/dist/cookie.d.ts.map +1 -0
- package/dist/cookie.js +13 -0
- package/dist/cookie.js.map +1 -0
- package/dist/createClient.cjs +33 -0
- package/dist/createClient.cjs.map +1 -0
- package/dist/createClient.d.cts +41 -0
- package/dist/createClient.d.cts.map +1 -0
- package/dist/createClient.d.ts +41 -0
- package/dist/createClient.d.ts.map +1 -0
- package/dist/createClient.js +33 -0
- package/dist/createClient.js.map +1 -0
- package/dist/createMigration.cjs +22 -0
- package/dist/createMigration.cjs.map +1 -0
- package/dist/createMigration.d.cts +30 -0
- package/dist/createMigration.d.cts.map +1 -0
- package/dist/createMigration.d.ts +30 -0
- package/dist/createMigration.d.ts.map +1 -0
- package/dist/createMigration.js +22 -0
- package/dist/createMigration.js.map +1 -0
- package/dist/createWriteClient.cjs +30 -0
- package/dist/createWriteClient.cjs.map +1 -0
- package/dist/createWriteClient.d.cts +38 -0
- package/dist/createWriteClient.d.cts.map +1 -0
- package/dist/createWriteClient.d.ts +38 -0
- package/dist/createWriteClient.d.ts.map +1 -0
- package/dist/createWriteClient.js +30 -0
- package/dist/createWriteClient.js.map +1 -0
- package/dist/errors/ForbiddenError.cjs +8 -0
- package/dist/errors/ForbiddenError.cjs.map +1 -0
- package/dist/errors/ForbiddenError.d.cts +14 -0
- package/dist/errors/ForbiddenError.d.cts.map +1 -0
- package/dist/errors/ForbiddenError.d.ts +14 -0
- package/dist/errors/ForbiddenError.d.ts.map +1 -0
- package/dist/errors/ForbiddenError.js +8 -0
- package/dist/errors/ForbiddenError.js.map +1 -0
- package/dist/errors/InvalidDataError.cjs +8 -0
- package/dist/errors/InvalidDataError.cjs.map +1 -0
- package/dist/errors/InvalidDataError.d.cts +7 -0
- package/dist/errors/InvalidDataError.d.cts.map +1 -0
- package/dist/errors/InvalidDataError.d.ts +7 -0
- package/dist/errors/InvalidDataError.d.ts.map +1 -0
- package/dist/errors/InvalidDataError.js +8 -0
- package/dist/errors/InvalidDataError.js.map +1 -0
- package/dist/errors/NotFoundError.cjs +8 -0
- package/dist/errors/NotFoundError.cjs.map +1 -0
- package/dist/errors/NotFoundError.d.cts +7 -0
- package/dist/errors/NotFoundError.d.cts.map +1 -0
- package/dist/errors/NotFoundError.d.ts +7 -0
- package/dist/errors/NotFoundError.d.ts.map +1 -0
- package/dist/errors/NotFoundError.js +8 -0
- package/dist/errors/NotFoundError.js.map +1 -0
- package/dist/errors/ParsingError.cjs +8 -0
- package/dist/errors/ParsingError.cjs.map +1 -0
- package/dist/errors/ParsingError.d.cts +17 -0
- package/dist/errors/ParsingError.d.cts.map +1 -0
- package/dist/errors/ParsingError.d.ts +17 -0
- package/dist/errors/ParsingError.d.ts.map +1 -0
- package/dist/errors/ParsingError.js +8 -0
- package/dist/errors/ParsingError.js.map +1 -0
- package/dist/errors/PreviewTokenExpired.cjs +8 -0
- package/dist/errors/PreviewTokenExpired.cjs.map +1 -0
- package/dist/errors/PreviewTokenExpired.d.cts +11 -0
- package/dist/errors/PreviewTokenExpired.d.cts.map +1 -0
- package/dist/errors/PreviewTokenExpired.d.ts +11 -0
- package/dist/errors/PreviewTokenExpired.d.ts.map +1 -0
- package/dist/errors/PreviewTokenExpired.js +8 -0
- package/dist/errors/PreviewTokenExpired.js.map +1 -0
- package/dist/errors/PrismicError.cjs +15 -0
- package/dist/errors/PrismicError.cjs.map +1 -0
- package/dist/errors/PrismicError.d.cts +9 -0
- package/dist/errors/PrismicError.d.cts.map +1 -0
- package/dist/errors/PrismicError.d.ts +9 -0
- package/dist/errors/PrismicError.d.ts.map +1 -0
- package/dist/errors/PrismicError.js +14 -0
- package/dist/errors/PrismicError.js.map +1 -0
- package/dist/errors/RefExpiredError.cjs +8 -0
- package/dist/errors/RefExpiredError.cjs.map +1 -0
- package/dist/errors/RefExpiredError.d.cts +11 -0
- package/dist/errors/RefExpiredError.d.cts.map +1 -0
- package/dist/errors/RefExpiredError.d.ts +11 -0
- package/dist/errors/RefExpiredError.d.ts.map +1 -0
- package/dist/errors/RefExpiredError.js +8 -0
- package/dist/errors/RefExpiredError.js.map +1 -0
- package/dist/errors/RefNotFoundError.cjs +8 -0
- package/dist/errors/RefNotFoundError.cjs.map +1 -0
- package/dist/errors/RefNotFoundError.d.cts +11 -0
- package/dist/errors/RefNotFoundError.d.cts.map +1 -0
- package/dist/errors/RefNotFoundError.d.ts +11 -0
- package/dist/errors/RefNotFoundError.d.ts.map +1 -0
- package/dist/errors/RefNotFoundError.js +8 -0
- package/dist/errors/RefNotFoundError.js.map +1 -0
- package/dist/errors/RepositoryNotFoundError.cjs +8 -0
- package/dist/errors/RepositoryNotFoundError.cjs.map +1 -0
- package/dist/errors/RepositoryNotFoundError.d.cts +7 -0
- package/dist/errors/RepositoryNotFoundError.d.cts.map +1 -0
- package/dist/errors/RepositoryNotFoundError.d.ts +7 -0
- package/dist/errors/RepositoryNotFoundError.d.ts.map +1 -0
- package/dist/errors/RepositoryNotFoundError.js +8 -0
- package/dist/errors/RepositoryNotFoundError.js.map +1 -0
- package/dist/filter.cjs +104 -0
- package/dist/filter.cjs.map +1 -0
- package/dist/filter.d.cts +213 -0
- package/dist/filter.d.cts.map +1 -0
- package/dist/filter.d.ts +213 -0
- package/dist/filter.d.ts.map +1 -0
- package/dist/filter.js +103 -0
- package/dist/filter.js.map +1 -0
- package/dist/getGraphQLEndpoint.cjs +21 -0
- package/dist/getGraphQLEndpoint.cjs.map +1 -0
- package/dist/getGraphQLEndpoint.d.cts +14 -0
- package/dist/getGraphQLEndpoint.d.cts.map +1 -0
- package/dist/getGraphQLEndpoint.d.ts +14 -0
- package/dist/getGraphQLEndpoint.d.ts.map +1 -0
- package/dist/getGraphQLEndpoint.js +21 -0
- package/dist/getGraphQLEndpoint.js.map +1 -0
- package/dist/getRepositoryEndpoint.cjs +30 -0
- package/dist/getRepositoryEndpoint.cjs.map +1 -0
- package/dist/getRepositoryEndpoint.d.cts +23 -0
- package/dist/getRepositoryEndpoint.d.cts.map +1 -0
- package/dist/getRepositoryEndpoint.d.ts +23 -0
- package/dist/getRepositoryEndpoint.d.ts.map +1 -0
- package/dist/getRepositoryEndpoint.js +30 -0
- package/dist/getRepositoryEndpoint.js.map +1 -0
- package/dist/getRepositoryName.cjs +25 -0
- package/dist/getRepositoryName.cjs.map +1 -0
- package/dist/getRepositoryName.d.cts +16 -0
- package/dist/getRepositoryName.d.cts.map +1 -0
- package/dist/getRepositoryName.d.ts +16 -0
- package/dist/getRepositoryName.d.ts.map +1 -0
- package/dist/getRepositoryName.js +25 -0
- package/dist/getRepositoryName.js.map +1 -0
- package/dist/getToolbarSrc.cjs +45 -0
- package/dist/getToolbarSrc.cjs.map +1 -0
- package/dist/getToolbarSrc.d.cts +38 -0
- package/dist/getToolbarSrc.d.cts.map +1 -0
- package/dist/getToolbarSrc.d.ts +38 -0
- package/dist/getToolbarSrc.d.ts.map +1 -0
- package/dist/getToolbarSrc.js +45 -0
- package/dist/getToolbarSrc.js.map +1 -0
- package/dist/helpers/asDate.cjs +39 -0
- package/dist/helpers/asDate.cjs.map +1 -0
- package/dist/helpers/asDate.d.cts +29 -0
- package/dist/helpers/asDate.d.cts.map +1 -0
- package/dist/helpers/asDate.d.ts +29 -0
- package/dist/helpers/asDate.d.ts.map +1 -0
- package/dist/helpers/asDate.js +38 -0
- package/dist/helpers/asDate.js.map +1 -0
- package/dist/helpers/asHTML.cjs +83 -0
- package/dist/helpers/asHTML.cjs.map +1 -0
- package/dist/helpers/asHTML.d.cts +147 -0
- package/dist/helpers/asHTML.d.cts.map +1 -0
- package/dist/helpers/asHTML.d.ts +147 -0
- package/dist/helpers/asHTML.d.ts.map +1 -0
- package/dist/helpers/asHTML.js +83 -0
- package/dist/helpers/asHTML.js.map +1 -0
- package/dist/helpers/asImagePixelDensitySrcSet.cjs +60 -0
- package/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -0
- package/dist/helpers/asImagePixelDensitySrcSet.d.cts +59 -0
- package/dist/helpers/asImagePixelDensitySrcSet.d.cts.map +1 -0
- package/dist/helpers/asImagePixelDensitySrcSet.d.ts +59 -0
- package/dist/helpers/asImagePixelDensitySrcSet.d.ts.map +1 -0
- package/dist/helpers/asImagePixelDensitySrcSet.js +60 -0
- package/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -0
- package/dist/helpers/asImageSrc.cjs +33 -0
- package/dist/helpers/asImageSrc.cjs.map +1 -0
- package/dist/helpers/asImageSrc.d.cts +34 -0
- package/dist/helpers/asImageSrc.d.cts.map +1 -0
- package/dist/helpers/asImageSrc.d.ts +34 -0
- package/dist/helpers/asImageSrc.d.ts.map +1 -0
- package/dist/helpers/asImageSrc.js +33 -0
- package/dist/helpers/asImageSrc.js.map +1 -0
- package/dist/helpers/asImageWidthSrcSet.cjs +79 -0
- package/dist/helpers/asImageWidthSrcSet.cjs.map +1 -0
- package/dist/helpers/asImageWidthSrcSet.d.cts +67 -0
- package/dist/helpers/asImageWidthSrcSet.d.cts.map +1 -0
- package/dist/helpers/asImageWidthSrcSet.d.ts +67 -0
- package/dist/helpers/asImageWidthSrcSet.d.ts.map +1 -0
- package/dist/helpers/asImageWidthSrcSet.js +79 -0
- package/dist/helpers/asImageWidthSrcSet.js.map +1 -0
- package/dist/helpers/asLink.cjs +29 -0
- package/dist/helpers/asLink.cjs.map +1 -0
- package/dist/helpers/asLink.d.cts +83 -0
- package/dist/helpers/asLink.d.cts.map +1 -0
- package/dist/helpers/asLink.d.ts +83 -0
- package/dist/helpers/asLink.d.ts.map +1 -0
- package/dist/helpers/asLink.js +29 -0
- package/dist/helpers/asLink.js.map +1 -0
- package/dist/helpers/asLinkAttrs.cjs +47 -0
- package/dist/helpers/asLinkAttrs.cjs.map +1 -0
- package/dist/helpers/asLinkAttrs.d.cts +51 -0
- package/dist/helpers/asLinkAttrs.d.cts.map +1 -0
- package/dist/helpers/asLinkAttrs.d.ts +51 -0
- package/dist/helpers/asLinkAttrs.d.ts.map +1 -0
- package/dist/helpers/asLinkAttrs.js +47 -0
- package/dist/helpers/asLinkAttrs.js.map +1 -0
- package/dist/helpers/asText.cjs +16 -0
- package/dist/helpers/asText.cjs.map +1 -0
- package/dist/helpers/asText.d.cts +62 -0
- package/dist/helpers/asText.d.cts.map +1 -0
- package/dist/helpers/asText.d.ts +62 -0
- package/dist/helpers/asText.d.ts.map +1 -0
- package/dist/helpers/asText.js +16 -0
- package/dist/helpers/asText.js.map +1 -0
- package/dist/helpers/documentToLinkField.cjs +33 -0
- package/dist/helpers/documentToLinkField.cjs.map +1 -0
- package/dist/helpers/documentToLinkField.d.cts +21 -0
- package/dist/helpers/documentToLinkField.d.cts.map +1 -0
- package/dist/helpers/documentToLinkField.d.ts +21 -0
- package/dist/helpers/documentToLinkField.d.ts.map +1 -0
- package/dist/helpers/documentToLinkField.js +33 -0
- package/dist/helpers/documentToLinkField.js.map +1 -0
- package/dist/helpers/isFilled.cjs +250 -0
- package/dist/helpers/isFilled.cjs.map +1 -0
- package/dist/helpers/isFilled.d.cts +199 -0
- package/dist/helpers/isFilled.d.cts.map +1 -0
- package/dist/helpers/isFilled.d.ts +199 -0
- package/dist/helpers/isFilled.d.ts.map +1 -0
- package/dist/helpers/isFilled.js +243 -0
- package/dist/helpers/isFilled.js.map +1 -0
- package/dist/helpers/mapSliceZone.cjs +53 -0
- package/dist/helpers/mapSliceZone.cjs.map +1 -0
- package/dist/helpers/mapSliceZone.d.cts +139 -0
- package/dist/helpers/mapSliceZone.d.cts.map +1 -0
- package/dist/helpers/mapSliceZone.d.ts +139 -0
- package/dist/helpers/mapSliceZone.d.ts.map +1 -0
- package/dist/helpers/mapSliceZone.js +52 -0
- package/dist/helpers/mapSliceZone.js.map +1 -0
- package/dist/index.cjs +117 -3882
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +151 -4394
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +151 -4394
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +63 -0
- package/dist/index.js.map +1 -0
- package/dist/isRepositoryEndpoint.cjs +23 -0
- package/dist/isRepositoryEndpoint.cjs.map +1 -0
- package/dist/isRepositoryEndpoint.d.cts +14 -0
- package/dist/isRepositoryEndpoint.d.cts.map +1 -0
- package/dist/isRepositoryEndpoint.d.ts +14 -0
- package/dist/isRepositoryEndpoint.d.ts.map +1 -0
- package/dist/isRepositoryEndpoint.js +22 -0
- package/dist/isRepositoryEndpoint.js.map +1 -0
- package/dist/isRepositoryName.cjs +17 -0
- package/dist/isRepositoryName.cjs.map +1 -0
- package/dist/isRepositoryName.d.cts +13 -0
- package/dist/isRepositoryName.d.cts.map +1 -0
- package/dist/isRepositoryName.d.ts +13 -0
- package/dist/isRepositoryName.d.ts.map +1 -0
- package/dist/isRepositoryName.js +16 -0
- package/dist/isRepositoryName.js.map +1 -0
- package/dist/lib/appendFilters.cjs +24 -0
- package/dist/lib/appendFilters.cjs.map +1 -0
- package/dist/lib/appendFilters.js +24 -0
- package/dist/lib/appendFilters.js.map +1 -0
- package/dist/lib/castArray.cjs +20 -0
- package/dist/lib/castArray.cjs.map +1 -0
- package/dist/lib/castArray.js +19 -0
- package/dist/lib/castArray.js.map +1 -0
- package/dist/lib/devMsg.cjs +25 -0
- package/dist/lib/devMsg.cjs.map +1 -0
- package/dist/lib/devMsg.js +25 -0
- package/dist/lib/devMsg.js.map +1 -0
- package/dist/lib/escapeHTML.cjs +40 -0
- package/dist/lib/escapeHTML.cjs.map +1 -0
- package/dist/lib/escapeHTML.js +39 -0
- package/dist/lib/escapeHTML.js.map +1 -0
- package/dist/lib/everyTagFilter.cjs +19 -0
- package/dist/lib/everyTagFilter.cjs.map +1 -0
- package/dist/lib/everyTagFilter.js +19 -0
- package/dist/lib/everyTagFilter.js.map +1 -0
- package/dist/lib/findMasterRef.cjs +19 -0
- package/dist/lib/findMasterRef.cjs.map +1 -0
- package/dist/lib/findMasterRef.js +19 -0
- package/dist/lib/findMasterRef.js.map +1 -0
- package/dist/lib/findRef.cjs +24 -0
- package/dist/lib/findRef.cjs.map +1 -0
- package/dist/lib/findRef.js +24 -0
- package/dist/lib/findRef.js.map +1 -0
- package/dist/lib/findRefByID.cjs +20 -0
- package/dist/lib/findRefByID.cjs.map +1 -0
- package/dist/lib/findRefByID.js +20 -0
- package/dist/lib/findRefByID.js.map +1 -0
- package/dist/lib/findRefByLabel.cjs +20 -0
- package/dist/lib/findRefByLabel.cjs.map +1 -0
- package/dist/lib/findRefByLabel.js +20 -0
- package/dist/lib/findRefByLabel.js.map +1 -0
- package/dist/lib/getOptionalLinkProperties.cjs +22 -0
- package/dist/lib/getOptionalLinkProperties.cjs.map +1 -0
- package/dist/lib/getOptionalLinkProperties.js +21 -0
- package/dist/lib/getOptionalLinkProperties.js.map +1 -0
- package/dist/lib/getPreviewCookie.cjs +30 -0
- package/dist/lib/getPreviewCookie.cjs.map +1 -0
- package/dist/lib/getPreviewCookie.js +30 -0
- package/dist/lib/getPreviewCookie.js.map +1 -0
- package/dist/lib/isInternalURL.cjs +18 -0
- package/dist/lib/isInternalURL.cjs.map +1 -0
- package/dist/lib/isInternalURL.js +17 -0
- package/dist/lib/isInternalURL.js.map +1 -0
- package/dist/lib/isMigrationValue.cjs +77 -0
- package/dist/lib/isMigrationValue.cjs.map +1 -0
- package/dist/lib/isMigrationValue.js +74 -0
- package/dist/lib/isMigrationValue.js.map +1 -0
- package/dist/lib/isValue.cjs +110 -0
- package/dist/lib/isValue.cjs.map +1 -0
- package/dist/lib/isValue.js +106 -0
- package/dist/lib/isValue.js.map +1 -0
- package/dist/lib/minifyGraphQLQuery.cjs +16 -0
- package/dist/lib/minifyGraphQLQuery.cjs.map +1 -0
- package/dist/lib/minifyGraphQLQuery.js +15 -0
- package/dist/lib/minifyGraphQLQuery.js.map +1 -0
- package/dist/lib/pLimit.cjs +55 -0
- package/dist/lib/pLimit.cjs.map +1 -0
- package/dist/lib/pLimit.js +54 -0
- package/dist/lib/pLimit.js.map +1 -0
- package/dist/lib/request.cjs +60 -0
- package/dist/lib/request.cjs.map +1 -0
- package/dist/lib/request.d.cts +61 -0
- package/dist/lib/request.d.cts.map +1 -0
- package/dist/lib/request.d.ts +61 -0
- package/dist/lib/request.d.ts.map +1 -0
- package/dist/lib/request.js +60 -0
- package/dist/lib/request.js.map +1 -0
- package/dist/lib/resolveMigrationDocumentData.cjs +156 -0
- package/dist/lib/resolveMigrationDocumentData.cjs.map +1 -0
- package/dist/lib/resolveMigrationDocumentData.js +155 -0
- package/dist/lib/resolveMigrationDocumentData.js.map +1 -0
- package/dist/lib/serializerHelpers.cjs +95 -0
- package/dist/lib/serializerHelpers.cjs.map +1 -0
- package/dist/lib/serializerHelpers.js +90 -0
- package/dist/lib/serializerHelpers.js.map +1 -0
- package/dist/lib/someTagsFilter.cjs +19 -0
- package/dist/lib/someTagsFilter.cjs.map +1 -0
- package/dist/lib/someTagsFilter.js +19 -0
- package/dist/lib/someTagsFilter.js.map +1 -0
- package/dist/lib/throttledLog.cjs +28 -0
- package/dist/lib/throttledLog.cjs.map +1 -0
- package/dist/lib/throttledLog.js +27 -0
- package/dist/lib/throttledLog.js.map +1 -0
- package/dist/lib/typeFilter.cjs +17 -0
- package/dist/lib/typeFilter.cjs.map +1 -0
- package/dist/lib/typeFilter.js +17 -0
- package/dist/lib/typeFilter.js.map +1 -0
- package/dist/lib/validateAssetMetadata.cjs +48 -0
- package/dist/lib/validateAssetMetadata.cjs.map +1 -0
- package/dist/lib/validateAssetMetadata.js +48 -0
- package/dist/lib/validateAssetMetadata.js.map +1 -0
- 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 +21 -0
- package/dist/richtext/asText.cjs.map +1 -0
- package/dist/richtext/asText.d.cts +18 -0
- package/dist/richtext/asText.d.cts.map +1 -0
- package/dist/richtext/asText.d.ts +18 -0
- package/dist/richtext/asText.d.ts.map +1 -0
- package/dist/richtext/asText.js +20 -0
- package/dist/richtext/asText.js.map +1 -0
- package/dist/richtext/asTree.cjs +122 -0
- package/dist/richtext/asTree.cjs.map +1 -0
- package/dist/richtext/asTree.d.cts +20 -0
- package/dist/richtext/asTree.d.cts.map +1 -0
- package/dist/richtext/asTree.d.ts +20 -0
- package/dist/richtext/asTree.d.ts.map +1 -0
- package/dist/richtext/asTree.js +122 -0
- package/dist/richtext/asTree.js.map +1 -0
- package/dist/richtext/composeSerializers.cjs +31 -0
- package/dist/richtext/composeSerializers.cjs.map +1 -0
- package/dist/richtext/composeSerializers.d.cts +22 -0
- package/dist/richtext/composeSerializers.d.cts.map +1 -0
- package/dist/richtext/composeSerializers.d.ts +22 -0
- package/dist/richtext/composeSerializers.d.ts.map +1 -0
- package/dist/richtext/composeSerializers.js +30 -0
- package/dist/richtext/composeSerializers.js.map +1 -0
- package/dist/richtext/serialize.cjs +35 -0
- package/dist/richtext/serialize.cjs.map +1 -0
- package/dist/richtext/serialize.d.cts +25 -0
- package/dist/richtext/serialize.d.cts.map +1 -0
- package/dist/richtext/serialize.d.ts +25 -0
- package/dist/richtext/serialize.d.ts.map +1 -0
- package/dist/richtext/serialize.js +35 -0
- package/dist/richtext/serialize.js.map +1 -0
- package/dist/richtext/types.cjs +13 -0
- package/dist/richtext/types.cjs.map +1 -0
- package/dist/richtext/types.d.cts +71 -0
- package/dist/richtext/types.d.cts.map +1 -0
- package/dist/richtext/types.d.ts +71 -0
- package/dist/richtext/types.d.ts.map +1 -0
- package/dist/richtext/types.js +13 -0
- package/dist/richtext/types.js.map +1 -0
- package/dist/richtext/wrapMapSerializer.cjs +32 -0
- package/dist/richtext/wrapMapSerializer.cjs.map +1 -0
- package/dist/richtext/wrapMapSerializer.d.cts +21 -0
- package/dist/richtext/wrapMapSerializer.d.cts.map +1 -0
- package/dist/richtext/wrapMapSerializer.d.ts +21 -0
- package/dist/richtext/wrapMapSerializer.d.ts.map +1 -0
- package/dist/richtext/wrapMapSerializer.js +32 -0
- package/dist/richtext/wrapMapSerializer.js.map +1 -0
- package/dist/richtext.cjs +13 -0
- package/dist/richtext.d.cts +8 -0
- package/dist/richtext.d.ts +8 -0
- package/dist/richtext.js +8 -0
- 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 +97 -0
- 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 +35 -0
- 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 +34 -0
- 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 +49 -0
- 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 +36 -0
- 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 +17 -0
- 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 +115 -0
- 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 +13 -0
- package/dist/types/api/tags.d.ts.map +1 -0
- package/dist/types/migration/Asset.cjs +35 -0
- package/dist/types/migration/Asset.cjs.map +1 -0
- 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 +109 -0
- package/dist/types/migration/Asset.d.ts.map +1 -0
- package/dist/types/migration/Asset.js +34 -0
- package/dist/types/migration/Asset.js.map +1 -0
- 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 +15 -0
- package/dist/types/migration/ContentRelationship.d.ts.map +1 -0
- package/dist/types/migration/Document.cjs +51 -0
- package/dist/types/migration/Document.cjs.map +1 -0
- 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 +97 -0
- package/dist/types/migration/Document.d.ts.map +1 -0
- package/dist/types/migration/Document.js +50 -0
- package/dist/types/migration/Document.js.map +1 -0
- 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 +21 -0
- 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 +19 -0
- 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 +59 -0
- 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 +54 -0
- 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 +20 -0
- 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 +19 -0
- 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 +18 -0
- 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 +29 -0
- 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 +37 -0
- 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 +20 -0
- 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 +19 -0
- package/dist/types/model/keyText.d.ts.map +1 -0
- package/dist/types/model/link.cjs +16 -0
- package/dist/types/model/link.cjs.map +1 -0
- 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 +34 -0
- package/dist/types/model/link.d.ts.map +1 -0
- package/dist/types/model/link.js +15 -0
- package/dist/types/model/link.js.map +1 -0
- 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 +23 -0
- 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 +21 -0
- 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 +20 -0
- 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 +43 -0
- 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 +24 -0
- 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 +16 -0
- 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 +22 -0
- 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 +25 -0
- package/dist/types/model/sharedSliceVariation.d.ts.map +1 -0
- package/dist/types/model/slice.cjs +15 -0
- package/dist/types/model/slice.cjs.map +1 -0
- 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 +39 -0
- package/dist/types/model/slice.d.ts.map +1 -0
- package/dist/types/model/slice.js +14 -0
- package/dist/types/model/slice.js.map +1 -0
- package/dist/types/model/sliceZone.cjs +15 -0
- package/dist/types/model/sliceZone.cjs.map +1 -0
- 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 +47 -0
- package/dist/types/model/sliceZone.d.ts.map +1 -0
- package/dist/types/model/sliceZone.js +14 -0
- package/dist/types/model/sliceZone.js.map +1 -0
- 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 +18 -0
- 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 +20 -0
- 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 +13 -0
- package/dist/types/model/title.d.ts.map +1 -0
- package/dist/types/model/types.cjs +32 -0
- package/dist/types/model/types.cjs.map +1 -0
- 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 +82 -0
- package/dist/types/model/types.d.ts.map +1 -0
- package/dist/types/model/types.js +31 -0
- package/dist/types/model/types.js.map +1 -0
- 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 +19 -0
- 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 +10 -0
- 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 +15 -0
- 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 +37 -0
- 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 +15 -0
- 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 +120 -0
- package/dist/types/value/document.d.ts.map +1 -0
- package/dist/types/value/embed.cjs +17 -0
- package/dist/types/value/embed.cjs.map +1 -0
- 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 +173 -0
- package/dist/types/value/embed.d.ts.map +1 -0
- package/dist/types/value/embed.js +16 -0
- package/dist/types/value/embed.js.map +1 -0
- 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 +18 -0
- 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 +19 -0
- 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 +53 -0
- 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 +22 -0
- 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 +15 -0
- package/dist/types/value/keyText.d.ts.map +1 -0
- package/dist/types/value/link.cjs +15 -0
- package/dist/types/value/link.cjs.map +1 -0
- 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 +74 -0
- package/dist/types/value/link.d.ts.map +1 -0
- package/dist/types/value/link.js +14 -0
- package/dist/types/value/link.js.map +1 -0
- 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 +33 -0
- 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 +15 -0
- package/dist/types/value/number.d.ts.map +1 -0
- package/dist/types/value/richText.cjs +32 -0
- package/dist/types/value/richText.cjs.map +1 -0
- 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 +221 -0
- package/dist/types/value/richText.d.ts.map +1 -0
- package/dist/types/value/richText.js +31 -0
- package/dist/types/value/richText.js.map +1 -0
- 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 +16 -0
- 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 +17 -0
- 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 +16 -0
- 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 +19 -0
- 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 +18 -0
- 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 +97 -0
- 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 +13 -0
- 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 +16 -0
- 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 +61 -0
- 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 +57 -0
- 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 +15 -0
- package/dist/types/webhook/testTrigger.d.ts.map +1 -0
- package/dist/types/webhook/types.cjs +15 -0
- package/dist/types/webhook/types.cjs.map +1 -0
- 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 +23 -0
- package/dist/types/webhook/types.d.ts.map +1 -0
- package/dist/types/webhook/types.js +14 -0
- package/dist/types/webhook/types.js.map +1 -0
- package/package.json +29 -35
- package/src/Client.ts +378 -657
- package/src/WriteClient.ts +38 -42
- package/src/buildQueryURL.ts +4 -1
- package/src/createClient.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 +1 -0
- 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 +0 -1
- package/src/types/migration/Document.ts +1 -1
- package/src/types/model/contentRelationship.ts +1 -0
- 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/index.d.mts +0 -4424
- package/dist/index.mjs +0 -3837
- package/dist/index.mjs.map +0 -1
- package/dist/richtext/index.cjs +0 -244
- package/dist/richtext/index.cjs.map +0 -1
- package/dist/richtext/index.d.cts +0 -78
- package/dist/richtext/index.d.mts +0 -78
- package/dist/richtext/index.d.ts +0 -78
- package/dist/richtext/index.mjs +0 -237
- package/dist/richtext/index.mjs.map +0 -1
- package/dist/shared/client.TSGr56lO.d.cts +0 -899
- package/dist/shared/client.TSGr56lO.d.mts +0 -899
- package/dist/shared/client.TSGr56lO.d.ts +0 -899
package/dist/Client.cjs
ADDED
|
@@ -0,0 +1,966 @@
|
|
|
1
|
+
const require_filter = require('./filter.cjs');
|
|
2
|
+
const require_appendFilters = require('./lib/appendFilters.cjs');
|
|
3
|
+
const require_devMsg = require('./lib/devMsg.cjs');
|
|
4
|
+
const require_everyTagFilter = require('./lib/everyTagFilter.cjs');
|
|
5
|
+
const require_PrismicError = require('./errors/PrismicError.cjs');
|
|
6
|
+
const require_findMasterRef = require('./lib/findMasterRef.cjs');
|
|
7
|
+
const require_findRefByID = require('./lib/findRefByID.cjs');
|
|
8
|
+
const require_findRefByLabel = require('./lib/findRefByLabel.cjs');
|
|
9
|
+
const require_getPreviewCookie = require('./lib/getPreviewCookie.cjs');
|
|
10
|
+
const require_minifyGraphQLQuery = require('./lib/minifyGraphQLQuery.cjs');
|
|
11
|
+
const require_request = require('./lib/request.cjs');
|
|
12
|
+
const require_someTagsFilter = require('./lib/someTagsFilter.cjs');
|
|
13
|
+
const require_throttledLog = require('./lib/throttledLog.cjs');
|
|
14
|
+
const require_typeFilter = require('./lib/typeFilter.cjs');
|
|
15
|
+
const require_ForbiddenError = require('./errors/ForbiddenError.cjs');
|
|
16
|
+
const require_NotFoundError = require('./errors/NotFoundError.cjs');
|
|
17
|
+
const require_ParsingError = require('./errors/ParsingError.cjs');
|
|
18
|
+
const require_PreviewTokenExpired = require('./errors/PreviewTokenExpired.cjs');
|
|
19
|
+
const require_RefExpiredError = require('./errors/RefExpiredError.cjs');
|
|
20
|
+
const require_RefNotFoundError = require('./errors/RefNotFoundError.cjs');
|
|
21
|
+
const require_RepositoryNotFoundError = require('./errors/RepositoryNotFoundError.cjs');
|
|
22
|
+
const require_asLink = require('./helpers/asLink.cjs');
|
|
23
|
+
const require_buildQueryURL = require('./buildQueryURL.cjs');
|
|
24
|
+
const require_getRepositoryEndpoint = require('./getRepositoryEndpoint.cjs');
|
|
25
|
+
const require_getRepositoryName = require('./getRepositoryName.cjs');
|
|
26
|
+
const require_isRepositoryEndpoint = require('./isRepositoryEndpoint.cjs');
|
|
27
|
+
|
|
28
|
+
//#region src/Client.ts
|
|
29
|
+
/**
|
|
30
|
+
* The largest page size allowed by the Prismic REST API V2. This value is used
|
|
31
|
+
* to minimize the number of requests required to query content.
|
|
32
|
+
*/
|
|
33
|
+
const MAX_PAGE_SIZE = 100;
|
|
34
|
+
/**
|
|
35
|
+
* The number of milliseconds in which repository metadata is considered valid.
|
|
36
|
+
* A ref can be invalidated quickly depending on how frequently content is
|
|
37
|
+
* updated in the Prismic repository. As such, repository's metadata can only be
|
|
38
|
+
* considered valid for a short amount of time.
|
|
39
|
+
*/
|
|
40
|
+
const REPOSITORY_CACHE_TTL = 5e3;
|
|
41
|
+
/**
|
|
42
|
+
* The number of milliseconds in which a multi-page `getAll` (e.g. `getAll`,
|
|
43
|
+
* `getAllByType`, `getAllByTag`) will wait between individual page requests.
|
|
44
|
+
*
|
|
45
|
+
* This is done to ensure API performance is sustainable and reduces the chance
|
|
46
|
+
* of a failed API request due to overloading.
|
|
47
|
+
*/
|
|
48
|
+
const GET_ALL_QUERY_DELAY = 500;
|
|
49
|
+
/**
|
|
50
|
+
* The maximum number of attempts to retry a query with an invalid ref. We allow
|
|
51
|
+
* multiple attempts since each attempt may use a different (and possibly
|
|
52
|
+
* invalid) ref. Capping the number of attempts prevents infinite loops.
|
|
53
|
+
*/
|
|
54
|
+
const MAX_INVALID_REF_RETRY_ATTEMPTS = 3;
|
|
55
|
+
/**
|
|
56
|
+
* A client that allows querying content from a Prismic repository.
|
|
57
|
+
*
|
|
58
|
+
* If used in an environment where a global `fetch` function is unavailable,
|
|
59
|
+
* such as Node.js, the `fetch` option must be provided as part of the `options`
|
|
60
|
+
* parameter.
|
|
61
|
+
*
|
|
62
|
+
* @typeParam TDocuments - Document types that are registered for the Prismic
|
|
63
|
+
* repository. Query methods will automatically be typed based on this type.
|
|
64
|
+
*/
|
|
65
|
+
var Client = class {
|
|
66
|
+
/**
|
|
67
|
+
* The function used to make network requests to the Prismic REST API. In
|
|
68
|
+
* environments where a global `fetch` function does not exist, such as
|
|
69
|
+
* Node.js, this function must be provided.
|
|
70
|
+
*/
|
|
71
|
+
fetchFn;
|
|
72
|
+
fetchOptions;
|
|
73
|
+
#repositoryName;
|
|
74
|
+
/**
|
|
75
|
+
* The Prismic repository's name.
|
|
76
|
+
*/
|
|
77
|
+
set repositoryName(value) {
|
|
78
|
+
this.#repositoryName = value;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The Prismic repository's name.
|
|
82
|
+
*/
|
|
83
|
+
get repositoryName() {
|
|
84
|
+
if (!this.#repositoryName) throw new require_PrismicError.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);
|
|
85
|
+
return this.#repositoryName;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The Prismic REST API V2 endpoint for the repository (use
|
|
89
|
+
* `prismic.getRepositoryEndpoint` for the default endpoint).
|
|
90
|
+
*/
|
|
91
|
+
documentAPIEndpoint;
|
|
92
|
+
/**
|
|
93
|
+
* The Prismic REST API V2 endpoint for the repository (use
|
|
94
|
+
* `prismic.getRepositoryEndpoint` for the default endpoint).
|
|
95
|
+
*
|
|
96
|
+
* @deprecated Use `documentAPIEndpoint` instead.
|
|
97
|
+
*/
|
|
98
|
+
set endpoint(value) {
|
|
99
|
+
this.documentAPIEndpoint = value;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* The Prismic REST API V2 endpoint for the repository (use
|
|
103
|
+
* `prismic.getRepositoryEndpoint` for the default endpoint).
|
|
104
|
+
*
|
|
105
|
+
* @deprecated Use `documentAPIEndpoint` instead.
|
|
106
|
+
*/
|
|
107
|
+
get endpoint() {
|
|
108
|
+
return this.documentAPIEndpoint;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* The secure token for accessing the API (only needed if your repository is
|
|
112
|
+
* set to private).
|
|
113
|
+
*
|
|
114
|
+
* {@link https://user-guides.prismic.io/en/articles/1036153-generating-an-access-token}
|
|
115
|
+
*/
|
|
116
|
+
accessToken;
|
|
117
|
+
/**
|
|
118
|
+
* A list of route resolver objects that define how a document's `url` field
|
|
119
|
+
* is resolved.
|
|
120
|
+
*
|
|
121
|
+
* {@link https://prismic.io/docs/route-resolver}
|
|
122
|
+
*/
|
|
123
|
+
routes;
|
|
124
|
+
/**
|
|
125
|
+
* The `brokenRoute` option allows you to define the route populated in the
|
|
126
|
+
* `url` property for broken link or content relationship fields. A broken
|
|
127
|
+
* link is a link or content relationship field whose linked document has been
|
|
128
|
+
* unpublished or deleted.
|
|
129
|
+
*
|
|
130
|
+
* {@link https://prismic.io/docs/route-resolver}
|
|
131
|
+
*/
|
|
132
|
+
brokenRoute;
|
|
133
|
+
/**
|
|
134
|
+
* Default parameters that will be sent with each query. These parameters can
|
|
135
|
+
* be overridden on each query if needed.
|
|
136
|
+
*/
|
|
137
|
+
defaultParams;
|
|
138
|
+
#getRef;
|
|
139
|
+
#autoPreviews = true;
|
|
140
|
+
#autoPreviewsRequest;
|
|
141
|
+
#cachedRepository;
|
|
142
|
+
#cachedRepositoryExpiration = 0;
|
|
143
|
+
/**
|
|
144
|
+
* Creates a Prismic client that can be used to query a repository.
|
|
145
|
+
*
|
|
146
|
+
* If used in an environment where a global `fetch` function is unavailable,
|
|
147
|
+
* such as in some Node.js versions, the `fetch` option must be provided as
|
|
148
|
+
* part of the `options` parameter.
|
|
149
|
+
*
|
|
150
|
+
* @param repositoryNameOrEndpoint - The Prismic repository name or full Rest
|
|
151
|
+
* API V2 endpoint for the repository.
|
|
152
|
+
* @param options - Configuration that determines how content will be queried
|
|
153
|
+
* from the Prismic repository.
|
|
154
|
+
*
|
|
155
|
+
* @returns A client that can query content from the repository.
|
|
156
|
+
*/
|
|
157
|
+
constructor(repositoryNameOrEndpoint, options = {}) {
|
|
158
|
+
this.fetchOptions = options.fetchOptions;
|
|
159
|
+
if (typeof options.fetch === "function") this.fetchFn = options.fetch;
|
|
160
|
+
else if (typeof globalThis.fetch === "function") this.fetchFn = globalThis.fetch;
|
|
161
|
+
else throw new require_PrismicError.PrismicError("A valid fetch implementation was not provided. In environments where fetch is not available (including Node.js), a fetch implementation must be provided via a polyfill or the `fetch` option.", void 0, void 0);
|
|
162
|
+
if (this.fetchFn === globalThis.fetch) this.fetchFn = this.fetchFn.bind(globalThis);
|
|
163
|
+
if ((options.documentAPIEndpoint || require_isRepositoryEndpoint.isRepositoryEndpoint(repositoryNameOrEndpoint)) && process.env.NODE_ENV === "development") {
|
|
164
|
+
const documentAPIEndpoint = options.documentAPIEndpoint || repositoryNameOrEndpoint;
|
|
165
|
+
if (/\.prismic\.io\/(?!api\/v2\/?)/i.test(documentAPIEndpoint)) throw new require_PrismicError.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);
|
|
166
|
+
const hostname = new URL(documentAPIEndpoint).hostname.toLowerCase();
|
|
167
|
+
if (hostname.endsWith(".prismic.io") && !hostname.endsWith(".cdn.prismic.io")) 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")}`);
|
|
168
|
+
if (options.documentAPIEndpoint && require_isRepositoryEndpoint.isRepositoryEndpoint(repositoryNameOrEndpoint) && repositoryNameOrEndpoint !== options.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")}`);
|
|
169
|
+
}
|
|
170
|
+
if (require_isRepositoryEndpoint.isRepositoryEndpoint(repositoryNameOrEndpoint)) {
|
|
171
|
+
this.documentAPIEndpoint = repositoryNameOrEndpoint;
|
|
172
|
+
try {
|
|
173
|
+
this.repositoryName = require_getRepositoryName.getRepositoryName(repositoryNameOrEndpoint);
|
|
174
|
+
} catch {
|
|
175
|
+
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")}`);
|
|
176
|
+
}
|
|
177
|
+
} else {
|
|
178
|
+
this.documentAPIEndpoint = options.documentAPIEndpoint || require_getRepositoryEndpoint.getRepositoryEndpoint(repositoryNameOrEndpoint);
|
|
179
|
+
this.repositoryName = repositoryNameOrEndpoint;
|
|
180
|
+
}
|
|
181
|
+
this.accessToken = options.accessToken;
|
|
182
|
+
this.routes = options.routes;
|
|
183
|
+
this.brokenRoute = options.brokenRoute;
|
|
184
|
+
this.defaultParams = options.defaultParams;
|
|
185
|
+
if (options.ref) this.queryContentFromRef(options.ref);
|
|
186
|
+
this.graphQLFetch = this.graphQLFetch.bind(this);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Enables the client to automatically query content from a preview session.
|
|
190
|
+
*
|
|
191
|
+
* @example
|
|
192
|
+
*
|
|
193
|
+
* ```ts
|
|
194
|
+
* client.enableAutoPreviews()
|
|
195
|
+
* ```
|
|
196
|
+
*
|
|
197
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#enableautopreviews}
|
|
198
|
+
*/
|
|
199
|
+
enableAutoPreviews() {
|
|
200
|
+
this.#autoPreviews = true;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Enables the client to automatically query content from a preview session
|
|
204
|
+
* using an HTTP request object.
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
*
|
|
208
|
+
* ```ts
|
|
209
|
+
* client.enableAutoPreviewsFromReq(req)
|
|
210
|
+
* ```
|
|
211
|
+
*
|
|
212
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#enableautopreviewsfromreq}
|
|
213
|
+
*/
|
|
214
|
+
enableAutoPreviewsFromReq(request$1) {
|
|
215
|
+
this.enableAutoPreviews();
|
|
216
|
+
this.#autoPreviewsRequest = request$1;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Disables the client from automatically querying content from a preview
|
|
220
|
+
* session.
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
*
|
|
224
|
+
* ```ts
|
|
225
|
+
* client.disableAutoPreviews()
|
|
226
|
+
* ```
|
|
227
|
+
*
|
|
228
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#disableautopreviews}
|
|
229
|
+
*/
|
|
230
|
+
disableAutoPreviews() {
|
|
231
|
+
this.#autoPreviews = false;
|
|
232
|
+
this.#autoPreviewsRequest = void 0;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Fetches pages based on the `params` argument. Results are paginated.
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
*
|
|
239
|
+
* ```ts
|
|
240
|
+
* const response = await client.get({ pageSize: 10 })
|
|
241
|
+
* ```
|
|
242
|
+
*
|
|
243
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#get}
|
|
244
|
+
*/
|
|
245
|
+
async get(params) {
|
|
246
|
+
return await (await this.#internalGet(params)).json();
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Fetches the first page returned based on the `params` argument.
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
*
|
|
253
|
+
* ```ts
|
|
254
|
+
* const page = await client.getFirst()
|
|
255
|
+
* ```
|
|
256
|
+
*
|
|
257
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getfirst}
|
|
258
|
+
*/
|
|
259
|
+
async getFirst(params) {
|
|
260
|
+
const actualParams = (params === null || params === void 0 ? void 0 : params.page) || (params === null || params === void 0 ? void 0 : params.pageSize) ? params : {
|
|
261
|
+
...params,
|
|
262
|
+
pageSize: 1
|
|
263
|
+
};
|
|
264
|
+
const response = await this.#internalGet(actualParams);
|
|
265
|
+
const { results } = await response.clone().json();
|
|
266
|
+
if (results[0]) return results[0];
|
|
267
|
+
throw new require_NotFoundError.NotFoundError("No documents were returned", response.url, void 0);
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Fetches all pages based on the `params` argument. This method may make
|
|
271
|
+
* multiple network requests to fetch all matching pages.
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
*
|
|
275
|
+
* ```ts
|
|
276
|
+
* const pages = await client.dangerouslyGetAll()
|
|
277
|
+
* ```
|
|
278
|
+
*
|
|
279
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#dangerouslygetall}
|
|
280
|
+
*/
|
|
281
|
+
async dangerouslyGetAll(params = {}) {
|
|
282
|
+
var _this$defaultParams;
|
|
283
|
+
const { limit = Infinity,...actualParams } = params;
|
|
284
|
+
const resolvedParams = {
|
|
285
|
+
...actualParams,
|
|
286
|
+
pageSize: Math.min(limit, actualParams.pageSize || ((_this$defaultParams = this.defaultParams) === null || _this$defaultParams === void 0 ? void 0 : _this$defaultParams.pageSize) || MAX_PAGE_SIZE)
|
|
287
|
+
};
|
|
288
|
+
const documents = [];
|
|
289
|
+
let latestResult;
|
|
290
|
+
while ((!latestResult || latestResult.next_page) && documents.length < limit) {
|
|
291
|
+
const page = latestResult ? latestResult.page + 1 : void 0;
|
|
292
|
+
latestResult = await this.get({
|
|
293
|
+
...resolvedParams,
|
|
294
|
+
page
|
|
295
|
+
});
|
|
296
|
+
documents.push(...latestResult.results);
|
|
297
|
+
if (latestResult.next_page) await new Promise((res) => setTimeout(res, GET_ALL_QUERY_DELAY));
|
|
298
|
+
}
|
|
299
|
+
return documents.slice(0, limit);
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Fetches a page with a specific ID.
|
|
303
|
+
*
|
|
304
|
+
* @example
|
|
305
|
+
*
|
|
306
|
+
* ```ts
|
|
307
|
+
* const page = await client.getByID("WW4bKScAAMAqmluX")
|
|
308
|
+
* ```
|
|
309
|
+
*
|
|
310
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbyid}
|
|
311
|
+
*/
|
|
312
|
+
async getByID(id, params) {
|
|
313
|
+
return await this.getFirst(require_appendFilters.appendFilters(params, require_filter.filter.at("document.id", id)));
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Fetches pages with specific IDs. Results are paginated.
|
|
317
|
+
*
|
|
318
|
+
* @example
|
|
319
|
+
*
|
|
320
|
+
* ```ts
|
|
321
|
+
* const response = await client.getByIDs([
|
|
322
|
+
* "WW4bKScAAMAqmluX",
|
|
323
|
+
* "U1kTRgEAAC8A5ldS",
|
|
324
|
+
* ])
|
|
325
|
+
* ```
|
|
326
|
+
*
|
|
327
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbyids}
|
|
328
|
+
*/
|
|
329
|
+
async getByIDs(ids, params) {
|
|
330
|
+
return await this.get(require_appendFilters.appendFilters(params, require_filter.filter.in("document.id", ids)));
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Fetches pages with specific IDs. This method may make multiple network
|
|
334
|
+
* requests to fetch all matching pages.
|
|
335
|
+
*
|
|
336
|
+
* @example
|
|
337
|
+
*
|
|
338
|
+
* ```ts
|
|
339
|
+
* const pages = await client.getAllByIDs([
|
|
340
|
+
* "WW4bKScAAMAqmluX",
|
|
341
|
+
* "U1kTRgEAAC8A5ldS",
|
|
342
|
+
* ])
|
|
343
|
+
* ```
|
|
344
|
+
*
|
|
345
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getallbyids}
|
|
346
|
+
*/
|
|
347
|
+
async getAllByIDs(ids, params) {
|
|
348
|
+
return await this.dangerouslyGetAll(require_appendFilters.appendFilters(params, require_filter.filter.in("document.id", ids)));
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Fetches a page with a specific UID and type.
|
|
352
|
+
*
|
|
353
|
+
* @example
|
|
354
|
+
*
|
|
355
|
+
* ```ts
|
|
356
|
+
* const page = await client.getByUID("blog_post", "my-first-post")
|
|
357
|
+
* ```
|
|
358
|
+
*
|
|
359
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbyuid}
|
|
360
|
+
*/
|
|
361
|
+
async getByUID(documentType, uid, params) {
|
|
362
|
+
return await this.getFirst(require_appendFilters.appendFilters(params, [require_typeFilter.typeFilter(documentType), require_filter.filter.at(`my.${documentType}.uid`, uid)]));
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Fetches pages with specific UIDs and a specific type. Results are
|
|
366
|
+
* paginated.
|
|
367
|
+
*
|
|
368
|
+
* @example
|
|
369
|
+
*
|
|
370
|
+
* ```ts
|
|
371
|
+
* const response = await client.getByUIDs("blog_post", [
|
|
372
|
+
* "my-first-post",
|
|
373
|
+
* "my-second-post",
|
|
374
|
+
* ])
|
|
375
|
+
* ```
|
|
376
|
+
*
|
|
377
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbyuids}
|
|
378
|
+
*/
|
|
379
|
+
async getByUIDs(documentType, uids, params) {
|
|
380
|
+
return await this.get(require_appendFilters.appendFilters(params, [require_typeFilter.typeFilter(documentType), require_filter.filter.in(`my.${documentType}.uid`, uids)]));
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Fetches pages with specific UIDs and a specific type. This method may make
|
|
384
|
+
* multiple network requests to fetch all matching pages.
|
|
385
|
+
*
|
|
386
|
+
* @example
|
|
387
|
+
*
|
|
388
|
+
* ```ts
|
|
389
|
+
* const pages = await client.getAllByUIDs("blog_post", [
|
|
390
|
+
* "my-first-post",
|
|
391
|
+
* "my-second-post",
|
|
392
|
+
* ])
|
|
393
|
+
* ```
|
|
394
|
+
*
|
|
395
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getallbyuids}
|
|
396
|
+
*/
|
|
397
|
+
async getAllByUIDs(documentType, uids, params) {
|
|
398
|
+
return await this.dangerouslyGetAll(require_appendFilters.appendFilters(params, [require_typeFilter.typeFilter(documentType), require_filter.filter.in(`my.${documentType}.uid`, uids)]));
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Fetches a specific single type page.
|
|
402
|
+
*
|
|
403
|
+
* @example
|
|
404
|
+
*
|
|
405
|
+
* ```ts
|
|
406
|
+
* const page = await client.getSingle("settings")
|
|
407
|
+
* ```
|
|
408
|
+
*
|
|
409
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getsingle}
|
|
410
|
+
*/
|
|
411
|
+
async getSingle(documentType, params) {
|
|
412
|
+
return await this.getFirst(require_appendFilters.appendFilters(params, require_typeFilter.typeFilter(documentType)));
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Fetches pages with a specific type. Results are paginated.
|
|
416
|
+
*
|
|
417
|
+
* @example
|
|
418
|
+
*
|
|
419
|
+
* ```ts
|
|
420
|
+
* const response = await client.getByType("blog_post")
|
|
421
|
+
* ```
|
|
422
|
+
*
|
|
423
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbytype}
|
|
424
|
+
*/
|
|
425
|
+
async getByType(documentType, params) {
|
|
426
|
+
return await this.get(require_appendFilters.appendFilters(params, require_typeFilter.typeFilter(documentType)));
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Fetches pages with a specific type. This method may make multiple network
|
|
430
|
+
* requests to fetch all matching documents.
|
|
431
|
+
*
|
|
432
|
+
* @example
|
|
433
|
+
*
|
|
434
|
+
* ```ts
|
|
435
|
+
* const pages = await client.getAllByType("blog_post")
|
|
436
|
+
* ```
|
|
437
|
+
*
|
|
438
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getallbytype}
|
|
439
|
+
*/
|
|
440
|
+
async getAllByType(documentType, params) {
|
|
441
|
+
return await this.dangerouslyGetAll(require_appendFilters.appendFilters(params, require_typeFilter.typeFilter(documentType)));
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Fetches pages with a specific tag. Results are paginated.
|
|
445
|
+
*
|
|
446
|
+
* @example
|
|
447
|
+
*
|
|
448
|
+
* ```ts
|
|
449
|
+
* const response = await client.getByTag("featured")
|
|
450
|
+
* ```
|
|
451
|
+
*
|
|
452
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbytag}
|
|
453
|
+
*/
|
|
454
|
+
async getByTag(tag, params) {
|
|
455
|
+
return await this.get(require_appendFilters.appendFilters(params, require_someTagsFilter.someTagsFilter(tag)));
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* Fetches pages with a specific tag. This method may make multiple network
|
|
459
|
+
* requests to fetch all matching documents.
|
|
460
|
+
*
|
|
461
|
+
* @example
|
|
462
|
+
*
|
|
463
|
+
* ```ts
|
|
464
|
+
* const pages = await client.getAllByTag("featured")
|
|
465
|
+
* ```
|
|
466
|
+
*
|
|
467
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getallbytag}
|
|
468
|
+
*/
|
|
469
|
+
async getAllByTag(tag, params) {
|
|
470
|
+
return await this.dangerouslyGetAll(require_appendFilters.appendFilters(params, require_someTagsFilter.someTagsFilter(tag)));
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* Fetches pages with every tag from a list of tags. Results are paginated.
|
|
474
|
+
*
|
|
475
|
+
* @example
|
|
476
|
+
*
|
|
477
|
+
* ```ts
|
|
478
|
+
* const response = await client.getByEveryTag(["featured", "homepage"])
|
|
479
|
+
* ```
|
|
480
|
+
*
|
|
481
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbyeverytag}
|
|
482
|
+
*/
|
|
483
|
+
async getByEveryTag(tags, params) {
|
|
484
|
+
return await this.get(require_appendFilters.appendFilters(params, require_everyTagFilter.everyTagFilter(tags)));
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Fetches pages with every tag from a list of tags. This method may make
|
|
488
|
+
* multiple network requests to fetch all matching pages.
|
|
489
|
+
*
|
|
490
|
+
* @example
|
|
491
|
+
*
|
|
492
|
+
* ```ts
|
|
493
|
+
* const pages = await client.getAllByEveryTag(["featured", "homepage"])
|
|
494
|
+
* ```
|
|
495
|
+
*
|
|
496
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getallbyeverytag}
|
|
497
|
+
*/
|
|
498
|
+
async getAllByEveryTag(tags, params) {
|
|
499
|
+
return await this.dangerouslyGetAll(require_appendFilters.appendFilters(params, require_everyTagFilter.everyTagFilter(tags)));
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Fetches pages with at least one tag from a list of tags. Results are
|
|
503
|
+
* paginated.
|
|
504
|
+
*
|
|
505
|
+
* @example
|
|
506
|
+
*
|
|
507
|
+
* ```ts
|
|
508
|
+
* const response = await client.getBySomeTags(["featured", "homepage"])
|
|
509
|
+
* ```
|
|
510
|
+
*
|
|
511
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbysometags}
|
|
512
|
+
*/
|
|
513
|
+
async getBySomeTags(tags, params) {
|
|
514
|
+
return await this.get(require_appendFilters.appendFilters(params, require_someTagsFilter.someTagsFilter(tags)));
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* Fetches pages with at least one tag from a list of tags. This method may
|
|
518
|
+
* make multiple network requests to fetch all matching documents.
|
|
519
|
+
*
|
|
520
|
+
* @example
|
|
521
|
+
*
|
|
522
|
+
* ```ts
|
|
523
|
+
* const pages = await client.getAllBySomeTags(["featured", "homepage"])
|
|
524
|
+
* ```
|
|
525
|
+
*
|
|
526
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getallbysometags}
|
|
527
|
+
*/
|
|
528
|
+
async getAllBySomeTags(tags, params) {
|
|
529
|
+
return await this.dangerouslyGetAll(require_appendFilters.appendFilters(params, require_someTagsFilter.someTagsFilter(tags)));
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Fetches metadata about the client's Prismic repository.
|
|
533
|
+
*
|
|
534
|
+
* @example
|
|
535
|
+
*
|
|
536
|
+
* ```ts
|
|
537
|
+
* const repository = await client.getRepository()
|
|
538
|
+
* ```
|
|
539
|
+
*
|
|
540
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getrepository}
|
|
541
|
+
*/
|
|
542
|
+
async getRepository(params) {
|
|
543
|
+
if (this.#cachedRepository && this.#cachedRepositoryExpiration > Date.now()) return this.#cachedRepository;
|
|
544
|
+
const url = new URL(this.documentAPIEndpoint);
|
|
545
|
+
const accessToken = (params === null || params === void 0 ? void 0 : params.accessToken) || this.accessToken;
|
|
546
|
+
if (accessToken) url.searchParams.set("access_token", accessToken);
|
|
547
|
+
const response = await this.#request(url, params);
|
|
548
|
+
if (response.ok) {
|
|
549
|
+
this.#cachedRepository = await response.json();
|
|
550
|
+
this.#cachedRepositoryExpiration = Date.now() + REPOSITORY_CACHE_TTL;
|
|
551
|
+
return this.#cachedRepository;
|
|
552
|
+
}
|
|
553
|
+
if (response.status === 404) throw new require_RepositoryNotFoundError.RepositoryNotFoundError(`Prismic repository not found. Check that "${this.documentAPIEndpoint}" is pointing to the correct repository.`, url.toString(), void 0);
|
|
554
|
+
return await this.#throwContentAPIError(response, url.toString());
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* Fetches the repository's active refs.
|
|
558
|
+
*
|
|
559
|
+
* @example
|
|
560
|
+
*
|
|
561
|
+
* ```ts
|
|
562
|
+
* const refs = await client.getRefs()
|
|
563
|
+
* ```
|
|
564
|
+
*
|
|
565
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getrefs}
|
|
566
|
+
*/
|
|
567
|
+
async getRefs(params) {
|
|
568
|
+
return (await this.getRepository(params)).refs;
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Fetches a ref by its ID.
|
|
572
|
+
*
|
|
573
|
+
* @example
|
|
574
|
+
*
|
|
575
|
+
* ```ts
|
|
576
|
+
* const ref = await client.getRefByID("YhE3YhEAACIA4321")
|
|
577
|
+
* ```
|
|
578
|
+
*
|
|
579
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getrefbyid}
|
|
580
|
+
*/
|
|
581
|
+
async getRefByID(id, params) {
|
|
582
|
+
return require_findRefByID.findRefByID(await this.getRefs(params), id);
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* Fetches a ref by its label. A release ref's label is its name shown in the
|
|
586
|
+
* Page Builder.
|
|
587
|
+
*
|
|
588
|
+
* @example
|
|
589
|
+
*
|
|
590
|
+
* ```ts
|
|
591
|
+
* const ref = await client.getRefByLabel("My Release")
|
|
592
|
+
* ```
|
|
593
|
+
*
|
|
594
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getrefbylabel}
|
|
595
|
+
*/
|
|
596
|
+
async getRefByLabel(label, params) {
|
|
597
|
+
return require_findRefByLabel.findRefByLabel(await this.getRefs(params), label);
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Fetches the repository's master ref.
|
|
601
|
+
*
|
|
602
|
+
* @example
|
|
603
|
+
*
|
|
604
|
+
* ```ts
|
|
605
|
+
* const masterRef = await client.getMasterRef()
|
|
606
|
+
* ```
|
|
607
|
+
*
|
|
608
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getmasterref}
|
|
609
|
+
*/
|
|
610
|
+
async getMasterRef(params) {
|
|
611
|
+
return require_findMasterRef.findMasterRef(await this.getRefs(params));
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* Fetches the repository's active releases.
|
|
615
|
+
*
|
|
616
|
+
* @example
|
|
617
|
+
*
|
|
618
|
+
* ```ts
|
|
619
|
+
* const releases = await client.getReleases()
|
|
620
|
+
* ```
|
|
621
|
+
*
|
|
622
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getreleases}
|
|
623
|
+
*/
|
|
624
|
+
async getReleases(params) {
|
|
625
|
+
return (await this.getRefs(params)).filter((ref) => !ref.isMasterRef);
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* Fetches a release with a specific ID.
|
|
629
|
+
*
|
|
630
|
+
* @example
|
|
631
|
+
*
|
|
632
|
+
* ```ts
|
|
633
|
+
* const release = await client.getReleaseByID("YhE3YhEAACIA4321")
|
|
634
|
+
* ```
|
|
635
|
+
*
|
|
636
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getreleasebyid}
|
|
637
|
+
*/
|
|
638
|
+
async getReleaseByID(id, params) {
|
|
639
|
+
return require_findRefByID.findRefByID(await this.getReleases(params), id);
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Fetches a release by its label. A release ref's label is its name shown in
|
|
643
|
+
* the Page Builder.
|
|
644
|
+
*
|
|
645
|
+
* @example
|
|
646
|
+
*
|
|
647
|
+
* ```ts
|
|
648
|
+
* const release = await client.getReleaseByLabel("My Release")
|
|
649
|
+
* ```
|
|
650
|
+
*
|
|
651
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getreleasebylabel}
|
|
652
|
+
*/
|
|
653
|
+
async getReleaseByLabel(label, params) {
|
|
654
|
+
return require_findRefByLabel.findRefByLabel(await this.getReleases(params), label);
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* Fetches the repository's page tags.
|
|
658
|
+
*
|
|
659
|
+
* @example
|
|
660
|
+
*
|
|
661
|
+
* ```ts
|
|
662
|
+
* const tags = await client.getTags()
|
|
663
|
+
* ```
|
|
664
|
+
*
|
|
665
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#gettags}
|
|
666
|
+
*/
|
|
667
|
+
async getTags(params) {
|
|
668
|
+
const repository = await this.getRepository(params);
|
|
669
|
+
const form = repository.forms.tags;
|
|
670
|
+
if (form) {
|
|
671
|
+
const url = new URL(form.action);
|
|
672
|
+
if (this.accessToken) url.searchParams.set("access_token", this.accessToken);
|
|
673
|
+
const response = await this.#request(url, params);
|
|
674
|
+
if (response.ok) return await response.json();
|
|
675
|
+
}
|
|
676
|
+
return repository.tags;
|
|
677
|
+
}
|
|
678
|
+
/**
|
|
679
|
+
* Builds a Content API query URL with a set of parameters.
|
|
680
|
+
*
|
|
681
|
+
* @example
|
|
682
|
+
*
|
|
683
|
+
* ```ts
|
|
684
|
+
* const url = await client.buildQueryURL({
|
|
685
|
+
* filters: [filter.at("document.type", "blog_post")],
|
|
686
|
+
* })
|
|
687
|
+
* ```
|
|
688
|
+
*
|
|
689
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#buildqueryurl}
|
|
690
|
+
*/
|
|
691
|
+
async buildQueryURL({ signal, fetchOptions,...params } = {}) {
|
|
692
|
+
const ref = params.ref || await this.#getResolvedRef({
|
|
693
|
+
accessToken: params.accessToken,
|
|
694
|
+
signal,
|
|
695
|
+
fetchOptions
|
|
696
|
+
});
|
|
697
|
+
const integrationFieldsRef = params.integrationFieldsRef || (await this.getRepository({
|
|
698
|
+
accessToken: params.accessToken,
|
|
699
|
+
signal,
|
|
700
|
+
fetchOptions
|
|
701
|
+
})).integrationFieldsRef || void 0;
|
|
702
|
+
return require_buildQueryURL.buildQueryURL(this.documentAPIEndpoint, {
|
|
703
|
+
...this.defaultParams,
|
|
704
|
+
...params,
|
|
705
|
+
ref,
|
|
706
|
+
integrationFieldsRef,
|
|
707
|
+
routes: params.routes || this.routes,
|
|
708
|
+
brokenRoute: params.brokenRoute || this.brokenRoute,
|
|
709
|
+
accessToken: params.accessToken || this.accessToken
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
/**
|
|
713
|
+
* Fetches a previewed page's URL using a preview token and page ID.
|
|
714
|
+
*
|
|
715
|
+
* @example
|
|
716
|
+
*
|
|
717
|
+
* ```ts
|
|
718
|
+
* const url = await client.resolvePreviewURL({
|
|
719
|
+
* linkResolver,
|
|
720
|
+
* defaultURL: "/",
|
|
721
|
+
* })
|
|
722
|
+
* ```
|
|
723
|
+
*
|
|
724
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#resolvepreviewurl}
|
|
725
|
+
*/
|
|
726
|
+
async resolvePreviewURL(args) {
|
|
727
|
+
let documentID = args.documentID;
|
|
728
|
+
let previewToken = args.previewToken;
|
|
729
|
+
if (typeof globalThis.location !== "undefined") {
|
|
730
|
+
const searchParams = new URLSearchParams(globalThis.location.search);
|
|
731
|
+
documentID = documentID || searchParams.get("documentId");
|
|
732
|
+
previewToken = previewToken || searchParams.get("token");
|
|
733
|
+
} else if (this.#autoPreviewsRequest) {
|
|
734
|
+
if ("query" in this.#autoPreviewsRequest) {
|
|
735
|
+
var _this$autoPreviewsReq, _this$autoPreviewsReq2;
|
|
736
|
+
documentID = documentID || ((_this$autoPreviewsReq = this.#autoPreviewsRequest.query) === null || _this$autoPreviewsReq === void 0 ? void 0 : _this$autoPreviewsReq.documentId);
|
|
737
|
+
previewToken = previewToken || ((_this$autoPreviewsReq2 = this.#autoPreviewsRequest.query) === null || _this$autoPreviewsReq2 === void 0 ? void 0 : _this$autoPreviewsReq2.token);
|
|
738
|
+
} else if ("url" in this.#autoPreviewsRequest && this.#autoPreviewsRequest.url) {
|
|
739
|
+
const searchParams = new URL(this.#autoPreviewsRequest.url, "missing-host://").searchParams;
|
|
740
|
+
documentID = documentID || searchParams.get("documentId");
|
|
741
|
+
previewToken = previewToken || searchParams.get("token");
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
if (documentID != null && previewToken != null) {
|
|
745
|
+
const url = require_asLink.asLink(await this.getByID(documentID, {
|
|
746
|
+
ref: previewToken,
|
|
747
|
+
lang: "*",
|
|
748
|
+
signal: args.signal,
|
|
749
|
+
fetchOptions: args.fetchOptions
|
|
750
|
+
}), { linkResolver: args.linkResolver });
|
|
751
|
+
if (typeof url === "string") return url;
|
|
752
|
+
}
|
|
753
|
+
return args.defaultURL;
|
|
754
|
+
}
|
|
755
|
+
/**
|
|
756
|
+
* Configures the client to query the latest published content. This is the
|
|
757
|
+
* client's default mode.
|
|
758
|
+
*
|
|
759
|
+
* @example
|
|
760
|
+
*
|
|
761
|
+
* ```ts
|
|
762
|
+
* client.queryLatestContent()
|
|
763
|
+
* ```
|
|
764
|
+
*
|
|
765
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querylatestcontent}
|
|
766
|
+
*/
|
|
767
|
+
queryLatestContent() {
|
|
768
|
+
this.#getRef = void 0;
|
|
769
|
+
}
|
|
770
|
+
/**
|
|
771
|
+
* Configures the client to query content from a release with a specific ID.
|
|
772
|
+
*
|
|
773
|
+
* @example
|
|
774
|
+
*
|
|
775
|
+
* ```ts
|
|
776
|
+
* client.queryContentFromReleaseByID("YhE3YhEAACIA4321")
|
|
777
|
+
* ```
|
|
778
|
+
*
|
|
779
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querycontentfromreleasebyid}
|
|
780
|
+
*/
|
|
781
|
+
queryContentFromReleaseByID(id) {
|
|
782
|
+
this.#getRef = async (params) => {
|
|
783
|
+
return (await this.getReleaseByID(id, params)).ref;
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
/**
|
|
787
|
+
* Configures the client to query content from a release with a specific
|
|
788
|
+
* label.
|
|
789
|
+
*
|
|
790
|
+
* @example
|
|
791
|
+
*
|
|
792
|
+
* ```ts
|
|
793
|
+
* client.queryContentFromReleaseByLabel("My Release")
|
|
794
|
+
* ```
|
|
795
|
+
*
|
|
796
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querycontentfromreleasebylabel}
|
|
797
|
+
*/
|
|
798
|
+
queryContentFromReleaseByLabel(label) {
|
|
799
|
+
this.#getRef = async (params) => {
|
|
800
|
+
return (await this.getReleaseByLabel(label, params)).ref;
|
|
801
|
+
};
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* Configures the client to query content from a specific ref.
|
|
805
|
+
*
|
|
806
|
+
* @example
|
|
807
|
+
*
|
|
808
|
+
* ```ts
|
|
809
|
+
* client.queryContentFromRef("my-ref")
|
|
810
|
+
* ```
|
|
811
|
+
*
|
|
812
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querycontentfromref}
|
|
813
|
+
*/
|
|
814
|
+
queryContentFromRef(ref) {
|
|
815
|
+
this.#getRef = typeof ref === "string" ? () => ref : ref;
|
|
816
|
+
}
|
|
817
|
+
/**
|
|
818
|
+
* A preconfigured `fetch()` function for Prismic's GraphQL API that can be
|
|
819
|
+
* provided to GraphQL clients.
|
|
820
|
+
*
|
|
821
|
+
* @example
|
|
822
|
+
*
|
|
823
|
+
* ```ts
|
|
824
|
+
* import { createClient, getGraphQLEndpoint } from "@prismicio/client"
|
|
825
|
+
*
|
|
826
|
+
* const client = createClient("example-prismic-repo")
|
|
827
|
+
* const graphQLClient = new ApolloClient({
|
|
828
|
+
* link: new HttpLink({
|
|
829
|
+
* uri: getGraphQLEndpoint(client.repositoryName),
|
|
830
|
+
* // Provide `client.graphQLFetch` as the fetch implementation.
|
|
831
|
+
* fetch: client.graphQLFetch,
|
|
832
|
+
* // Using GET is required.
|
|
833
|
+
* useGETForQueries: true,
|
|
834
|
+
* }),
|
|
835
|
+
* cache: new InMemoryCache(),
|
|
836
|
+
* })
|
|
837
|
+
* ```
|
|
838
|
+
*
|
|
839
|
+
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#graphqlfetch}
|
|
840
|
+
*/
|
|
841
|
+
async graphQLFetch(input, init) {
|
|
842
|
+
const repository = await this.getRepository();
|
|
843
|
+
const ref = await this.#getResolvedRef();
|
|
844
|
+
const unsanitizedHeaders = {
|
|
845
|
+
"Prismic-ref": ref,
|
|
846
|
+
Authorization: this.accessToken ? `Token ${this.accessToken}` : "",
|
|
847
|
+
...init ? init.headers : {}
|
|
848
|
+
};
|
|
849
|
+
if (repository.integrationFieldsRef) unsanitizedHeaders["Prismic-integration-field-ref"] = repository.integrationFieldsRef;
|
|
850
|
+
const headers = {};
|
|
851
|
+
for (const key in unsanitizedHeaders) if (unsanitizedHeaders[key]) headers[key.toLowerCase()] = unsanitizedHeaders[key];
|
|
852
|
+
const url = new URL(input);
|
|
853
|
+
url.searchParams.set("ref", ref);
|
|
854
|
+
const query = url.searchParams.get("query");
|
|
855
|
+
if (query) url.searchParams.set("query", require_minifyGraphQLQuery.minifyGraphQLQuery(query));
|
|
856
|
+
return await this.fetchFn(url.toString(), {
|
|
857
|
+
...init,
|
|
858
|
+
headers
|
|
859
|
+
});
|
|
860
|
+
}
|
|
861
|
+
/**
|
|
862
|
+
* Returns the ref needed to query based on the client's current state. This
|
|
863
|
+
* method may make a network request to fetch a ref or resolve the user's ref
|
|
864
|
+
* thunk.
|
|
865
|
+
*
|
|
866
|
+
* If auto previews are enabled, the preview ref takes priority if available.
|
|
867
|
+
*
|
|
868
|
+
* The following strategies are used depending on the client's state:
|
|
869
|
+
*
|
|
870
|
+
* - If the user called `queryLatestContent`: Use the repository's master ref.
|
|
871
|
+
* The ref is cached for 5 seconds. After 5 seconds, a new master ref is
|
|
872
|
+
* fetched.
|
|
873
|
+
* - If the user called `queryContentFromReleaseByID`: Use the release's ref.
|
|
874
|
+
* The ref is cached for 5 seconds. After 5 seconds, a new ref for the
|
|
875
|
+
* release is fetched.
|
|
876
|
+
* - If the user called `queryContentFromReleaseByLabel`: Use the release's ref.
|
|
877
|
+
* The ref is cached for 5 seconds. After 5 seconds, a new ref for the
|
|
878
|
+
* release is fetched.
|
|
879
|
+
* - If the user called `queryContentFromRef`: Use the provided ref. Fall back
|
|
880
|
+
* to the master ref if the ref is not a string.
|
|
881
|
+
*
|
|
882
|
+
* @returns The ref to use during a query.
|
|
883
|
+
*/
|
|
884
|
+
async #getResolvedRef(params) {
|
|
885
|
+
var _this$getRef;
|
|
886
|
+
if (this.#autoPreviews) {
|
|
887
|
+
var _this$autoPreviewsReq3, _globalThis$document;
|
|
888
|
+
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) ?? "");
|
|
889
|
+
if (previewRef) return previewRef;
|
|
890
|
+
}
|
|
891
|
+
const ref = await ((_this$getRef = this.#getRef) === null || _this$getRef === void 0 ? void 0 : _this$getRef.call(this, params));
|
|
892
|
+
if (ref) return ref;
|
|
893
|
+
return (await this.getMasterRef(params)).ref;
|
|
894
|
+
}
|
|
895
|
+
async #internalGet(params, attempt = 1) {
|
|
896
|
+
const url = await this.buildQueryURL(params);
|
|
897
|
+
const response = await this.#request(new URL(url), params);
|
|
898
|
+
if (response.ok) return response;
|
|
899
|
+
try {
|
|
900
|
+
return await this.#throwContentAPIError(response, url);
|
|
901
|
+
} catch (error) {
|
|
902
|
+
if ((error instanceof require_RefNotFoundError.RefNotFoundError || error instanceof require_RefExpiredError.RefExpiredError) && attempt < MAX_INVALID_REF_RETRY_ATTEMPTS) {
|
|
903
|
+
var _error$message$match;
|
|
904
|
+
if (!(params === null || params === void 0 ? void 0 : params.ref)) this.#cachedRepository = void 0;
|
|
905
|
+
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;
|
|
906
|
+
if (!masterRef) throw error;
|
|
907
|
+
require_throttledLog.throttledLog(`[@prismicio/client] The ref (${new URL(url).searchParams.get("ref")}) was ${error instanceof require_RefNotFoundError.RefNotFoundError ? "invalid" : "expired"}. Now retrying with the latest master ref (${masterRef}). If you were previewing content, the response will not include draft content.`, { level: "warn" });
|
|
908
|
+
return await this.#internalGet({
|
|
909
|
+
...params,
|
|
910
|
+
ref: masterRef
|
|
911
|
+
}, attempt + 1);
|
|
912
|
+
}
|
|
913
|
+
throw error;
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
async #throwContentAPIError(response, url) {
|
|
917
|
+
switch (response.status) {
|
|
918
|
+
case 400: {
|
|
919
|
+
const json = await response.clone().json();
|
|
920
|
+
throw new require_ParsingError.ParsingError(json.message, url, json);
|
|
921
|
+
}
|
|
922
|
+
case 401: {
|
|
923
|
+
const json = await response.clone().json();
|
|
924
|
+
throw new require_ForbiddenError.ForbiddenError(json.message, url, json);
|
|
925
|
+
}
|
|
926
|
+
case 404: {
|
|
927
|
+
const json = await response.clone().json();
|
|
928
|
+
switch (json.type) {
|
|
929
|
+
case "api_notfound_error": throw new require_RefNotFoundError.RefNotFoundError(json.message, url, json);
|
|
930
|
+
case "api_security_error": if (/preview token.*expired/i.test(json.message)) throw new require_PreviewTokenExpired.PreviewTokenExpiredError(json.message, url, json);
|
|
931
|
+
default: throw new require_NotFoundError.NotFoundError(json.message, url, json);
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
case 410: {
|
|
935
|
+
const json = await response.clone().json();
|
|
936
|
+
throw new require_RefExpiredError.RefExpiredError(json.message, url, json);
|
|
937
|
+
}
|
|
938
|
+
default: throw new require_PrismicError.PrismicError(void 0, url, await response.text());
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
/**
|
|
942
|
+
* Makes an HTTP request using the client's configured fetch function and
|
|
943
|
+
* options.
|
|
944
|
+
*
|
|
945
|
+
* @param url - The URL to request.
|
|
946
|
+
* @param params - Fetch options.
|
|
947
|
+
*
|
|
948
|
+
* @returns The response from the fetch request.
|
|
949
|
+
*/
|
|
950
|
+
async #request(url, params) {
|
|
951
|
+
var _this$fetchOptions, _params$fetchOptions, _params$fetchOptions2, _this$fetchOptions2;
|
|
952
|
+
return await require_request.request(url, {
|
|
953
|
+
...this.fetchOptions,
|
|
954
|
+
...params === null || params === void 0 ? void 0 : params.fetchOptions,
|
|
955
|
+
headers: {
|
|
956
|
+
...(_this$fetchOptions = this.fetchOptions) === null || _this$fetchOptions === void 0 ? void 0 : _this$fetchOptions.headers,
|
|
957
|
+
...params === null || params === void 0 || (_params$fetchOptions = params.fetchOptions) === null || _params$fetchOptions === void 0 ? void 0 : _params$fetchOptions.headers
|
|
958
|
+
},
|
|
959
|
+
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)
|
|
960
|
+
}, this.fetchFn);
|
|
961
|
+
}
|
|
962
|
+
};
|
|
963
|
+
|
|
964
|
+
//#endregion
|
|
965
|
+
exports.Client = Client;
|
|
966
|
+
//# sourceMappingURL=Client.cjs.map
|