@prismicio/client 7.21.0-alpha.1 → 7.21.0-pr.414.2f27ec1
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 +1212 -1268
- package/dist/Client.cjs.map +1 -1
- package/dist/Client.d.cts +976 -0
- package/dist/Client.d.cts.map +1 -0
- package/dist/Client.d.ts +921 -926
- package/dist/Client.d.ts.map +1 -0
- package/dist/Client.js +1188 -1244
- package/dist/Client.js.map +1 -1
- package/dist/Migration.cjs +281 -312
- 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 +280 -311
- package/dist/Migration.js.map +1 -1
- package/dist/WriteClient.cjs +486 -558
- 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 +480 -552
- 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 +220 -0
- package/dist/buildQueryURL.d.cts.map +1 -0
- package/dist/buildQueryURL.d.ts +169 -158
- package/dist/buildQueryURL.d.ts.map +1 -0
- package/dist/buildQueryURL.js +88 -58
- 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 +22 -13
- 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 +11 -5
- 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 +11 -5
- package/dist/createWriteClient.d.ts.map +1 -0
- package/dist/createWriteClient.js +28 -4
- package/dist/createWriteClient.js.map +1 -1
- package/dist/errors/ForbiddenError.cjs +7 -6
- package/dist/errors/ForbiddenError.cjs.map +1 -1
- package/dist/errors/ForbiddenError.d.cts +14 -0
- package/dist/errors/ForbiddenError.d.cts.map +1 -0
- package/dist/errors/ForbiddenError.d.ts +10 -7
- package/dist/errors/ForbiddenError.d.ts.map +1 -0
- package/dist/errors/ForbiddenError.js +7 -6
- package/dist/errors/ForbiddenError.js.map +1 -1
- package/dist/errors/InvalidDataError.cjs +7 -6
- package/dist/errors/InvalidDataError.cjs.map +1 -1
- package/dist/errors/InvalidDataError.d.cts +7 -0
- package/dist/errors/InvalidDataError.d.cts.map +1 -0
- package/dist/errors/InvalidDataError.d.ts +7 -3
- package/dist/errors/InvalidDataError.d.ts.map +1 -0
- package/dist/errors/InvalidDataError.js +7 -6
- package/dist/errors/InvalidDataError.js.map +1 -1
- package/dist/errors/NotFoundError.cjs +7 -6
- package/dist/errors/NotFoundError.cjs.map +1 -1
- package/dist/errors/NotFoundError.d.cts +7 -0
- package/dist/errors/NotFoundError.d.cts.map +1 -0
- package/dist/errors/NotFoundError.d.ts +7 -3
- package/dist/errors/NotFoundError.d.ts.map +1 -0
- package/dist/errors/NotFoundError.js +7 -6
- package/dist/errors/NotFoundError.js.map +1 -1
- package/dist/errors/ParsingError.cjs +7 -6
- package/dist/errors/ParsingError.cjs.map +1 -1
- package/dist/errors/ParsingError.d.cts +17 -0
- package/dist/errors/ParsingError.d.cts.map +1 -0
- package/dist/errors/ParsingError.d.ts +15 -12
- package/dist/errors/ParsingError.d.ts.map +1 -0
- package/dist/errors/ParsingError.js +7 -6
- package/dist/errors/ParsingError.js.map +1 -1
- package/dist/errors/PreviewTokenExpired.cjs +7 -6
- package/dist/errors/PreviewTokenExpired.cjs.map +1 -1
- package/dist/errors/PreviewTokenExpired.d.cts +11 -0
- package/dist/errors/PreviewTokenExpired.d.cts.map +1 -0
- package/dist/errors/PreviewTokenExpired.d.ts +9 -6
- package/dist/errors/PreviewTokenExpired.d.ts.map +1 -0
- package/dist/errors/PreviewTokenExpired.js +7 -6
- package/dist/errors/PreviewTokenExpired.js.map +1 -1
- package/dist/errors/PrismicError.cjs +14 -15
- package/dist/errors/PrismicError.cjs.map +1 -1
- package/dist/errors/PrismicError.d.cts +9 -0
- package/dist/errors/PrismicError.d.cts.map +1 -0
- package/dist/errors/PrismicError.d.ts +8 -4
- package/dist/errors/PrismicError.d.ts.map +1 -0
- package/dist/errors/PrismicError.js +13 -15
- package/dist/errors/PrismicError.js.map +1 -1
- package/dist/errors/RefExpiredError.cjs +7 -6
- package/dist/errors/RefExpiredError.cjs.map +1 -1
- package/dist/errors/RefExpiredError.d.cts +11 -0
- package/dist/errors/RefExpiredError.d.cts.map +1 -0
- package/dist/errors/RefExpiredError.d.ts +9 -6
- package/dist/errors/RefExpiredError.d.ts.map +1 -0
- package/dist/errors/RefExpiredError.js +7 -6
- package/dist/errors/RefExpiredError.js.map +1 -1
- package/dist/errors/RefNotFoundError.cjs +7 -6
- package/dist/errors/RefNotFoundError.cjs.map +1 -1
- package/dist/errors/RefNotFoundError.d.cts +11 -0
- package/dist/errors/RefNotFoundError.d.cts.map +1 -0
- package/dist/errors/RefNotFoundError.d.ts +9 -6
- package/dist/errors/RefNotFoundError.d.ts.map +1 -0
- package/dist/errors/RefNotFoundError.js +7 -6
- package/dist/errors/RefNotFoundError.js.map +1 -1
- package/dist/errors/RepositoryNotFoundError.cjs +7 -6
- package/dist/errors/RepositoryNotFoundError.cjs.map +1 -1
- package/dist/errors/RepositoryNotFoundError.d.cts +7 -0
- package/dist/errors/RepositoryNotFoundError.d.cts.map +1 -0
- package/dist/errors/RepositoryNotFoundError.d.ts +7 -3
- package/dist/errors/RepositoryNotFoundError.d.ts.map +1 -0
- package/dist/errors/RepositoryNotFoundError.js +7 -6
- package/dist/errors/RepositoryNotFoundError.js.map +1 -1
- 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 +17 -9
- 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 +14 -3
- package/dist/getRepositoryEndpoint.d.ts.map +1 -0
- package/dist/getRepositoryEndpoint.js +26 -9
- 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 +22 -14
- 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 +41 -9
- 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 +20 -8
- 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 +84 -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 +31 -25
- 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 +20 -14
- 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 +34 -28
- 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 +64 -58
- 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 +29 -28
- 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 -33
- 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 -24
- 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 -24
- 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 +65 -56
- 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 +47 -44
- 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 +117 -94
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +181 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +151 -173
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +39 -73
- 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 +7 -3
- 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/appendFilters.cjs +21 -8
- package/dist/lib/appendFilters.cjs.map +1 -1
- package/dist/lib/appendFilters.js +21 -8
- package/dist/lib/appendFilters.js.map +1 -1
- package/dist/lib/castArray.cjs +17 -4
- package/dist/lib/castArray.cjs.map +1 -1
- package/dist/lib/castArray.js +17 -5
- package/dist/lib/castArray.js.map +1 -1
- package/dist/lib/castThunk.cjs +16 -4
- package/dist/lib/castThunk.cjs.map +1 -1
- package/dist/lib/castThunk.js +16 -5
- package/dist/lib/castThunk.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/everyTagFilter.cjs +16 -6
- package/dist/lib/everyTagFilter.cjs.map +1 -1
- package/dist/lib/everyTagFilter.js +15 -5
- package/dist/lib/everyTagFilter.js.map +1 -1
- package/dist/lib/findMasterRef.cjs +16 -5
- package/dist/lib/findMasterRef.cjs.map +1 -1
- package/dist/lib/findMasterRef.js +16 -5
- package/dist/lib/findMasterRef.js.map +1 -1
- package/dist/lib/findRef.cjs +21 -9
- package/dist/lib/findRef.cjs.map +1 -1
- package/dist/lib/findRef.js +21 -9
- package/dist/lib/findRef.js.map +1 -1
- package/dist/lib/findRefByID.cjs +17 -5
- package/dist/lib/findRefByID.cjs.map +1 -1
- package/dist/lib/findRefByID.js +17 -5
- package/dist/lib/findRefByID.js.map +1 -1
- package/dist/lib/findRefByLabel.cjs +17 -5
- package/dist/lib/findRefByLabel.cjs.map +1 -1
- package/dist/lib/findRefByLabel.js +17 -5
- package/dist/lib/findRefByLabel.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/minifyGraphQLQuery.cjs +13 -4
- package/dist/lib/minifyGraphQLQuery.cjs.map +1 -1
- package/dist/lib/minifyGraphQLQuery.js +13 -5
- package/dist/lib/minifyGraphQLQuery.js.map +1 -1
- package/dist/lib/pLimit.cjs +51 -45
- package/dist/lib/pLimit.cjs.map +1 -1
- package/dist/lib/pLimit.js +51 -46
- package/dist/lib/pLimit.js.map +1 -1
- package/dist/lib/request.cjs +54 -37
- 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 -37
- package/dist/lib/request.js.map +1 -1
- package/dist/lib/resolveMigrationDocumentData.cjs +147 -125
- package/dist/lib/resolveMigrationDocumentData.cjs.map +1 -1
- package/dist/lib/resolveMigrationDocumentData.js +143 -122
- 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/someTagsFilter.cjs +16 -6
- package/dist/lib/someTagsFilter.cjs.map +1 -1
- package/dist/lib/someTagsFilter.js +15 -5
- package/dist/lib/someTagsFilter.js.map +1 -1
- package/dist/lib/throttledLog.cjs +22 -11
- package/dist/lib/throttledLog.cjs.map +1 -1
- package/dist/lib/throttledLog.js +22 -12
- package/dist/lib/throttledLog.js.map +1 -1
- package/dist/lib/typeFilter.cjs +14 -5
- package/dist/lib/typeFilter.cjs.map +1 -1
- package/dist/lib/typeFilter.js +14 -5
- package/dist/lib/typeFilter.js.map +1 -1
- package/dist/lib/validateAssetMetadata.cjs +40 -20
- package/dist/lib/validateAssetMetadata.cjs.map +1 -1
- package/dist/lib/validateAssetMetadata.js +40 -20
- 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 +13 -7
- 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 +17 -11
- 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 +49 -49
- 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 -32
- 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 -32
- 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 -46
- 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 -46
- 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 -26
- 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 -61
- 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 +20 -49
- package/src/Client.ts +26 -9
- package/src/WriteClient.ts +28 -36
- package/src/buildQueryURL.ts +33 -22
- package/src/createClient.ts +11 -8
- package/src/getRepositoryEndpoint.ts +9 -2
- package/src/helpers/asDate.ts +11 -4
- package/src/helpers/asHTML.ts +38 -30
- package/src/helpers/asImagePixelDensitySrcSet.ts +16 -15
- package/src/helpers/asImageSrc.ts +11 -10
- package/src/helpers/asImageWidthSrcSet.ts +19 -22
- package/src/helpers/asLink.ts +33 -35
- package/src/helpers/asLinkAttrs.ts +6 -13
- package/src/helpers/asText.ts +20 -10
- package/src/helpers/isFilled.ts +15 -14
- package/src/helpers/mapSliceZone.ts +15 -15
- package/src/index.ts +3 -2
- package/src/isRepositoryEndpoint.ts +2 -2
- 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/richtext/asText.ts +5 -5
- package/src/richtext/serialize.ts +8 -8
- package/src/richtext/types.ts +6 -6
- package/src/types/migration/Asset.ts +10 -2
- package/src/types/migration/Document.ts +1 -1
- package/src/types/model/contentRelationship.ts +1 -0
- package/src/types/model/types.ts +0 -2
- 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/lib/appendFilters.d.ts +0 -18
- package/dist/lib/castArray.d.ts +0 -12
- package/dist/lib/castThunk.d.ts +0 -11
- package/dist/lib/devMsg.d.ts +0 -16
- package/dist/lib/escapeHTML.d.ts +0 -1
- package/dist/lib/everyTagFilter.d.ts +0 -9
- package/dist/lib/findMasterRef.d.ts +0 -11
- package/dist/lib/findRef.d.ts +0 -14
- package/dist/lib/findRefByID.d.ts +0 -12
- package/dist/lib/findRefByLabel.d.ts +0 -12
- 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.d.ts +0 -8
- 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.d.ts +0 -9
- package/dist/lib/throttledLog.d.ts +0 -15
- package/dist/lib/typeFilter.d.ts +0 -8
- 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/dist/WriteClient.js
CHANGED
|
@@ -1,560 +1,488 @@
|
|
|
1
|
-
|
|
2
|
-
var __typeError = (msg) => {
|
|
3
|
-
throw TypeError(msg);
|
|
4
|
-
};
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
8
|
-
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
9
|
-
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
10
|
-
var _WriteClient_instances, request_fn, handleAssetAPIError_fn, handleMigrationAPIError_fn;
|
|
1
|
+
import { name, version } from "./package.js";
|
|
11
2
|
import { devMsg } from "./lib/devMsg.js";
|
|
3
|
+
import { PrismicError } from "./errors/PrismicError.js";
|
|
12
4
|
import { pLimit } from "./lib/pLimit.js";
|
|
13
5
|
import { request } from "./lib/request.js";
|
|
14
|
-
import { resolveMigrationContentRelationship, resolveMigrationDocumentData } from "./lib/resolveMigrationDocumentData.js";
|
|
15
6
|
import { ForbiddenError } from "./errors/ForbiddenError.js";
|
|
16
|
-
import { InvalidDataError } from "./errors/InvalidDataError.js";
|
|
17
7
|
import { NotFoundError } from "./errors/NotFoundError.js";
|
|
18
|
-
import { PrismicError } from "./errors/PrismicError.js";
|
|
19
|
-
import { name, version } from "./package.json.js";
|
|
20
8
|
import { Client } from "./Client.js";
|
|
9
|
+
import { resolveMigrationContentRelationship, resolveMigrationDocumentData } from "./lib/resolveMigrationDocumentData.js";
|
|
10
|
+
import { InvalidDataError } from "./errors/InvalidDataError.js";
|
|
11
|
+
|
|
12
|
+
//#region src/WriteClient.ts
|
|
21
13
|
const CLIENT_IDENTIFIER = `${name.replace("@", "").replace("/", "-")}/${version}`;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
return;
|
|
493
|
-
}
|
|
494
|
-
default: {
|
|
495
|
-
await __privateMethod(this, _WriteClient_instances, handleMigrationAPIError_fn).call(this, response);
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
_WriteClient_instances = new WeakSet();
|
|
501
|
-
request_fn = async function(url, params, init) {
|
|
502
|
-
const baseInit = this._buildRequestInit(params);
|
|
503
|
-
return await request(url, {
|
|
504
|
-
...baseInit,
|
|
505
|
-
...init,
|
|
506
|
-
headers: {
|
|
507
|
-
...baseInit.headers,
|
|
508
|
-
...init == null ? void 0 : init.headers,
|
|
509
|
-
repository: this.repositoryName,
|
|
510
|
-
authorization: `Bearer ${this.writeToken}`
|
|
511
|
-
}
|
|
512
|
-
}, this.fetchFn);
|
|
513
|
-
};
|
|
514
|
-
handleAssetAPIError_fn = async function(response) {
|
|
515
|
-
const json = await response.json();
|
|
516
|
-
switch (response.status) {
|
|
517
|
-
case 401:
|
|
518
|
-
case 403:
|
|
519
|
-
throw new ForbiddenError(json.error, response.url, json);
|
|
520
|
-
case 404:
|
|
521
|
-
throw new NotFoundError(json.error, response.url, json);
|
|
522
|
-
case 400:
|
|
523
|
-
throw new InvalidDataError(json.error, response.url, json);
|
|
524
|
-
case 500:
|
|
525
|
-
case 503:
|
|
526
|
-
default:
|
|
527
|
-
throw new PrismicError(json.error, response.url, json);
|
|
528
|
-
}
|
|
529
|
-
};
|
|
530
|
-
handleMigrationAPIError_fn = async function(response) {
|
|
531
|
-
const text = await response.text();
|
|
532
|
-
let json;
|
|
533
|
-
try {
|
|
534
|
-
json = JSON.parse(text);
|
|
535
|
-
} catch {
|
|
536
|
-
}
|
|
537
|
-
switch (response.status) {
|
|
538
|
-
case 400:
|
|
539
|
-
if (json) {
|
|
540
|
-
throw new InvalidDataError("Validation failed, check the response property of the error for details", response.url, json);
|
|
541
|
-
}
|
|
542
|
-
throw new InvalidDataError(text, response.url, text);
|
|
543
|
-
case 401:
|
|
544
|
-
throw new ForbiddenError(text, response.url, text);
|
|
545
|
-
case 403:
|
|
546
|
-
if (json) {
|
|
547
|
-
throw new ForbiddenError(json.Message, response.url, json);
|
|
548
|
-
}
|
|
549
|
-
throw new ForbiddenError(text, response.url, text);
|
|
550
|
-
case 404:
|
|
551
|
-
throw new NotFoundError(text, response.url, text);
|
|
552
|
-
case 500:
|
|
553
|
-
default:
|
|
554
|
-
throw new PrismicError(text, response.url, text);
|
|
555
|
-
}
|
|
556
|
-
};
|
|
557
|
-
export {
|
|
558
|
-
WriteClient
|
|
14
|
+
/**
|
|
15
|
+
* A client that allows querying and writing content to a Prismic repository.
|
|
16
|
+
*
|
|
17
|
+
* If used in an environment where a global `fetch` function is unavailable,
|
|
18
|
+
* such as Node.js, the `fetch` option must be provided as part of the `options`
|
|
19
|
+
* parameter.
|
|
20
|
+
*
|
|
21
|
+
* @typeParam TDocuments - Document types that are registered for the Prismic
|
|
22
|
+
* repository. Query methods will automatically be typed based on this type.
|
|
23
|
+
*/
|
|
24
|
+
var WriteClient = class extends Client {
|
|
25
|
+
writeToken;
|
|
26
|
+
assetAPIEndpoint = "https://asset-api.prismic.io/";
|
|
27
|
+
migrationAPIEndpoint = "https://migration.prismic.io/";
|
|
28
|
+
/**
|
|
29
|
+
* Creates a Prismic client that can be used to query and write content to a
|
|
30
|
+
* repository.
|
|
31
|
+
*
|
|
32
|
+
* If used in an environment where a global `fetch` function is unavailable,
|
|
33
|
+
* such as in some Node.js versions, the `fetch` option must be provided as
|
|
34
|
+
* part of the `options` parameter.
|
|
35
|
+
*
|
|
36
|
+
* @param repositoryName - The Prismic repository name for the repository.
|
|
37
|
+
* @param options - Configuration that determines how content will be queried
|
|
38
|
+
* from and written to the Prismic repository.
|
|
39
|
+
*
|
|
40
|
+
* @returns A client that can query and write content to the repository.
|
|
41
|
+
*/
|
|
42
|
+
constructor(repositoryName, options) {
|
|
43
|
+
super(repositoryName, options);
|
|
44
|
+
if (typeof globalThis.window !== "undefined") console.warn(`[@prismicio/client] Prismic write client appears to be running in a browser environment. This is not recommended as it exposes your write token. Consider using Prismic write client in a server environment only, preferring the regular client for browser environment. For more details, see ${devMsg("avoid-write-client-in-browser")}`);
|
|
45
|
+
this.writeToken = options.writeToken;
|
|
46
|
+
if (options.assetAPIEndpoint) this.assetAPIEndpoint = `${options.assetAPIEndpoint}/`;
|
|
47
|
+
if (options.migrationAPIEndpoint) this.migrationAPIEndpoint = `${options.migrationAPIEndpoint}/`;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Creates a migration release on the Prismic repository based on the provided
|
|
51
|
+
* prepared migration.
|
|
52
|
+
*
|
|
53
|
+
* @param migration - A migration prepared with {@link createMigration}.
|
|
54
|
+
* @param params - An event listener and additional fetch parameters.
|
|
55
|
+
*
|
|
56
|
+
* @see Prismic Migration API technical reference: {@link https://prismic.io/docs/migration-api-technical-reference}
|
|
57
|
+
*/
|
|
58
|
+
async migrate(migration, params = {}) {
|
|
59
|
+
var _params$reporter, _params$reporter2;
|
|
60
|
+
(_params$reporter = params.reporter) === null || _params$reporter === void 0 || _params$reporter.call(params, {
|
|
61
|
+
type: "start",
|
|
62
|
+
data: { pending: {
|
|
63
|
+
documents: migration._documents.length,
|
|
64
|
+
assets: migration._assets.size
|
|
65
|
+
} }
|
|
66
|
+
});
|
|
67
|
+
await this.migrateCreateAssets(migration, params);
|
|
68
|
+
await this.migrateCreateDocuments(migration, params);
|
|
69
|
+
await this.migrateUpdateDocuments(migration, params);
|
|
70
|
+
(_params$reporter2 = params.reporter) === null || _params$reporter2 === void 0 || _params$reporter2.call(params, {
|
|
71
|
+
type: "end",
|
|
72
|
+
data: { migrated: {
|
|
73
|
+
documents: migration._documents.length,
|
|
74
|
+
assets: migration._assets.size
|
|
75
|
+
} }
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Creates assets in the Prismic repository's media library.
|
|
80
|
+
*
|
|
81
|
+
* @param migration - A migration prepared with {@link createMigration}.
|
|
82
|
+
* @param params - An event listener and additional fetch parameters.
|
|
83
|
+
*
|
|
84
|
+
* @internal This method is one of the step performed by the {@link migrate} method.
|
|
85
|
+
*/
|
|
86
|
+
async migrateCreateAssets(migration, { reporter,...fetchParams } = {}) {
|
|
87
|
+
let created = 0;
|
|
88
|
+
for (const [_, migrationAsset] of migration._assets) {
|
|
89
|
+
reporter === null || reporter === void 0 || reporter({
|
|
90
|
+
type: "assets:creating",
|
|
91
|
+
data: {
|
|
92
|
+
current: ++created,
|
|
93
|
+
remaining: migration._assets.size - created,
|
|
94
|
+
total: migration._assets.size,
|
|
95
|
+
asset: migrationAsset
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
const { file, filename, notes, credits, alt, tags } = migrationAsset.config;
|
|
99
|
+
let resolvedFile;
|
|
100
|
+
if (typeof file === "string") {
|
|
101
|
+
let url;
|
|
102
|
+
try {
|
|
103
|
+
url = new URL(file);
|
|
104
|
+
} catch {}
|
|
105
|
+
if (url) resolvedFile = await this.fetchForeignAsset(url.toString(), fetchParams);
|
|
106
|
+
else resolvedFile = file;
|
|
107
|
+
} else if (file instanceof URL) resolvedFile = await this.fetchForeignAsset(file.toString(), fetchParams);
|
|
108
|
+
else resolvedFile = file;
|
|
109
|
+
migrationAsset.asset = await this.createAsset(resolvedFile, filename, {
|
|
110
|
+
notes,
|
|
111
|
+
credits,
|
|
112
|
+
alt,
|
|
113
|
+
tags,
|
|
114
|
+
...fetchParams
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
reporter === null || reporter === void 0 || reporter({
|
|
118
|
+
type: "assets:created",
|
|
119
|
+
data: { created }
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Creates documents in the Prismic repository's migration release.
|
|
124
|
+
*
|
|
125
|
+
* @param migration - A migration prepared with {@link createMigration}.
|
|
126
|
+
* @param params - An event listener and additional fetch parameters.
|
|
127
|
+
*
|
|
128
|
+
* @internal This method is one of the step performed by the {@link migrate} method.
|
|
129
|
+
*/
|
|
130
|
+
async migrateCreateDocuments(migration, { reporter,...fetchParams } = {}) {
|
|
131
|
+
const masterLocale = (await this.getRepository(fetchParams)).languages[0].id;
|
|
132
|
+
reporter === null || reporter === void 0 || reporter({
|
|
133
|
+
type: "documents:masterLocale",
|
|
134
|
+
data: { masterLocale }
|
|
135
|
+
});
|
|
136
|
+
const documentsToCreate = [];
|
|
137
|
+
for (const doc of migration._documents) if (!doc.document.id) if (doc.document.lang === masterLocale) documentsToCreate.unshift(doc);
|
|
138
|
+
else documentsToCreate.push(doc);
|
|
139
|
+
let created = 0;
|
|
140
|
+
for (const doc of documentsToCreate) {
|
|
141
|
+
reporter === null || reporter === void 0 || reporter({
|
|
142
|
+
type: "documents:creating",
|
|
143
|
+
data: {
|
|
144
|
+
current: ++created,
|
|
145
|
+
remaining: documentsToCreate.length - created,
|
|
146
|
+
total: documentsToCreate.length,
|
|
147
|
+
document: doc
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
let masterLanguageDocumentID;
|
|
151
|
+
if (doc.masterLanguageDocument) {
|
|
152
|
+
const masterLanguageDocument = await resolveMigrationContentRelationship(doc.masterLanguageDocument);
|
|
153
|
+
masterLanguageDocumentID = "id" in masterLanguageDocument ? masterLanguageDocument.id : void 0;
|
|
154
|
+
} else if (doc.originalPrismicDocument) {
|
|
155
|
+
var _doc$originalPrismicD;
|
|
156
|
+
const maybeOriginalID = (_doc$originalPrismicD = doc.originalPrismicDocument.alternate_languages.find(({ lang }) => lang === masterLocale)) === null || _doc$originalPrismicD === void 0 ? void 0 : _doc$originalPrismicD.id;
|
|
157
|
+
if (maybeOriginalID) {
|
|
158
|
+
var _migration$_getByOrig;
|
|
159
|
+
masterLanguageDocumentID = (_migration$_getByOrig = migration._getByOriginalID(maybeOriginalID)) === null || _migration$_getByOrig === void 0 ? void 0 : _migration$_getByOrig.document.id;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
const { id } = await this.createDocument({
|
|
163
|
+
...doc.document,
|
|
164
|
+
data: {}
|
|
165
|
+
}, doc.title, {
|
|
166
|
+
masterLanguageDocumentID,
|
|
167
|
+
...fetchParams
|
|
168
|
+
});
|
|
169
|
+
doc.document.id = id;
|
|
170
|
+
}
|
|
171
|
+
reporter === null || reporter === void 0 || reporter({
|
|
172
|
+
type: "documents:created",
|
|
173
|
+
data: { created }
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Updates documents in the Prismic repository's migration release with their
|
|
178
|
+
* patched data.
|
|
179
|
+
*
|
|
180
|
+
* @param migration - A migration prepared with {@link createMigration}.
|
|
181
|
+
* @param params - An event listener and additional fetch parameters.
|
|
182
|
+
*
|
|
183
|
+
* @internal This method is one of the step performed by the {@link migrate} method.
|
|
184
|
+
*/
|
|
185
|
+
async migrateUpdateDocuments(migration, { reporter,...fetchParams } = {}) {
|
|
186
|
+
let i = 0;
|
|
187
|
+
for (const doc of migration._documents) {
|
|
188
|
+
reporter === null || reporter === void 0 || reporter({
|
|
189
|
+
type: "documents:updating",
|
|
190
|
+
data: {
|
|
191
|
+
current: ++i,
|
|
192
|
+
remaining: migration._documents.length - i,
|
|
193
|
+
total: migration._documents.length,
|
|
194
|
+
document: doc
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
await this.updateDocument(doc.document.id, {
|
|
198
|
+
...doc.document,
|
|
199
|
+
documentTitle: doc.title,
|
|
200
|
+
data: await resolveMigrationDocumentData(doc.document.data, migration)
|
|
201
|
+
}, fetchParams);
|
|
202
|
+
}
|
|
203
|
+
reporter === null || reporter === void 0 || reporter({
|
|
204
|
+
type: "documents:updated",
|
|
205
|
+
data: { updated: migration._documents.length }
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Creates an asset in the Prismic media library.
|
|
210
|
+
*
|
|
211
|
+
* @param file - The file to upload as an asset.
|
|
212
|
+
* @param filename - The filename of the asset.
|
|
213
|
+
* @param params - Additional asset data and fetch parameters.
|
|
214
|
+
*
|
|
215
|
+
* @returns The created asset.
|
|
216
|
+
*/
|
|
217
|
+
async createAsset(file, filename, { notes, credits, alt, tags,...params } = {}) {
|
|
218
|
+
const url = new URL("assets", this.assetAPIEndpoint);
|
|
219
|
+
const formData = new FormData();
|
|
220
|
+
formData.append("file", new File([file], filename, { type: file instanceof File ? file.type : void 0 }));
|
|
221
|
+
if (notes) formData.append("notes", notes);
|
|
222
|
+
if (credits) formData.append("credits", credits);
|
|
223
|
+
if (alt) formData.append("alt", alt);
|
|
224
|
+
const response = await this.#request(url, params, {
|
|
225
|
+
method: "POST",
|
|
226
|
+
body: formData
|
|
227
|
+
});
|
|
228
|
+
switch (response.status) {
|
|
229
|
+
case 200: {
|
|
230
|
+
const asset = await response.json();
|
|
231
|
+
if (tags && tags.length) return this.updateAsset(asset.id, { tags });
|
|
232
|
+
return asset;
|
|
233
|
+
}
|
|
234
|
+
default: return await this.#handleAssetAPIError(response);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Updates an asset in the Prismic media library.
|
|
239
|
+
*
|
|
240
|
+
* @param id - The ID of the asset to update.
|
|
241
|
+
* @param params - The asset data to update and additional fetch parameters.
|
|
242
|
+
*
|
|
243
|
+
* @returns The updated asset.
|
|
244
|
+
*/
|
|
245
|
+
async updateAsset(id, { notes, credits, alt, filename, tags,...params } = {}) {
|
|
246
|
+
const url = new URL(`assets/${id}`, this.assetAPIEndpoint);
|
|
247
|
+
if (tags && tags.length) tags = await this.resolveAssetTagIDs(tags, {
|
|
248
|
+
createTags: true,
|
|
249
|
+
...params
|
|
250
|
+
});
|
|
251
|
+
const response = await this.#request(url, params, {
|
|
252
|
+
method: "PATCH",
|
|
253
|
+
body: JSON.stringify({
|
|
254
|
+
notes,
|
|
255
|
+
credits,
|
|
256
|
+
alt,
|
|
257
|
+
filename,
|
|
258
|
+
tags
|
|
259
|
+
}),
|
|
260
|
+
headers: { "content-type": "application/json" }
|
|
261
|
+
});
|
|
262
|
+
switch (response.status) {
|
|
263
|
+
case 200: return await response.json();
|
|
264
|
+
default: return await this.#handleAssetAPIError(response);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Fetches a foreign asset from a URL.
|
|
269
|
+
*
|
|
270
|
+
* @param url - The URL of the asset to fetch.
|
|
271
|
+
* @param params - Additional fetch parameters.
|
|
272
|
+
*
|
|
273
|
+
* @returns A file representing the fetched asset.
|
|
274
|
+
*/
|
|
275
|
+
async fetchForeignAsset(url, params = {}) {
|
|
276
|
+
const res = await this.fetchFn(url, this._buildRequestInit(params));
|
|
277
|
+
if (!res.ok) throw new PrismicError("Could not fetch foreign asset", url, void 0);
|
|
278
|
+
const blob = await res.blob();
|
|
279
|
+
return new File([blob], "", { type: res.headers.get("content-type") || void 0 });
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* {@link resolveAssetTagIDs} rate limiter.
|
|
283
|
+
*/
|
|
284
|
+
_resolveAssetTagIDsLimit = pLimit();
|
|
285
|
+
/**
|
|
286
|
+
* Resolves asset tag IDs from tag names.
|
|
287
|
+
*
|
|
288
|
+
* @param tagNames - An array of tag names to resolve.
|
|
289
|
+
* @param params - Whether or not missing tags should be created and
|
|
290
|
+
* additional fetch parameters.
|
|
291
|
+
*
|
|
292
|
+
* @returns An array of resolved tag IDs.
|
|
293
|
+
*/
|
|
294
|
+
async resolveAssetTagIDs(tagNames = [], { createTags,...params } = {}) {
|
|
295
|
+
return this._resolveAssetTagIDsLimit(async () => {
|
|
296
|
+
const existingTags = await this.getAssetTags(params);
|
|
297
|
+
const existingTagMap = {};
|
|
298
|
+
for (const tag of existingTags) existingTagMap[tag.name] = tag;
|
|
299
|
+
const resolvedTagIDs = [];
|
|
300
|
+
for (const tagName of tagNames) {
|
|
301
|
+
if (!existingTagMap[tagName] && createTags) existingTagMap[tagName] = await this.createAssetTag(tagName, params);
|
|
302
|
+
if (existingTagMap[tagName]) resolvedTagIDs.push(existingTagMap[tagName].id);
|
|
303
|
+
}
|
|
304
|
+
return resolvedTagIDs;
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Creates a tag in the Asset API.
|
|
309
|
+
*
|
|
310
|
+
* @remarks
|
|
311
|
+
* Tags should be at least 3 characters long and 20 characters at most.
|
|
312
|
+
*
|
|
313
|
+
* @param name - The name of the tag to create.
|
|
314
|
+
* @param params - Additional fetch parameters.
|
|
315
|
+
*
|
|
316
|
+
* @returns The created tag.
|
|
317
|
+
*/
|
|
318
|
+
async createAssetTag(name$1, params) {
|
|
319
|
+
const url = new URL("tags", this.assetAPIEndpoint);
|
|
320
|
+
const response = await this.#request(url, params, {
|
|
321
|
+
method: "POST",
|
|
322
|
+
body: JSON.stringify({ name: name$1 }),
|
|
323
|
+
headers: { "content-type": "application/json" }
|
|
324
|
+
});
|
|
325
|
+
switch (response.status) {
|
|
326
|
+
case 201: return await response.json();
|
|
327
|
+
default: return await this.#handleAssetAPIError(response);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Queries existing tags from the Asset API.
|
|
332
|
+
*
|
|
333
|
+
* @param params - Additional fetch parameters.
|
|
334
|
+
*
|
|
335
|
+
* @returns An array of existing tags.
|
|
336
|
+
*/
|
|
337
|
+
async getAssetTags(params) {
|
|
338
|
+
const url = new URL("tags", this.assetAPIEndpoint);
|
|
339
|
+
const response = await this.#request(url, params);
|
|
340
|
+
switch (response.status) {
|
|
341
|
+
case 200: return (await response.json()).items;
|
|
342
|
+
default: return await this.#handleAssetAPIError(response);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Creates a document in the repository's migration release.
|
|
347
|
+
*
|
|
348
|
+
* @typeParam TType - Type of Prismic documents to create.
|
|
349
|
+
*
|
|
350
|
+
* @param document - The document to create.
|
|
351
|
+
* @param documentTitle - The title of the document to create which will be
|
|
352
|
+
* displayed in the editor.
|
|
353
|
+
* @param params - Document master language document ID and additional fetch
|
|
354
|
+
* parameters.
|
|
355
|
+
*
|
|
356
|
+
* @returns The ID of the created document.
|
|
357
|
+
*
|
|
358
|
+
* @see Prismic Migration API technical reference: {@link https://prismic.io/docs/migration-api-technical-reference}
|
|
359
|
+
*/
|
|
360
|
+
async createDocument(document, documentTitle, { masterLanguageDocumentID,...params } = {}) {
|
|
361
|
+
const url = new URL("documents", this.migrationAPIEndpoint);
|
|
362
|
+
const response = await this.#request(url, params, {
|
|
363
|
+
method: "POST",
|
|
364
|
+
body: JSON.stringify({
|
|
365
|
+
title: documentTitle,
|
|
366
|
+
type: document.type,
|
|
367
|
+
uid: document.uid || void 0,
|
|
368
|
+
lang: document.lang,
|
|
369
|
+
alternate_language_id: masterLanguageDocumentID,
|
|
370
|
+
tags: document.tags,
|
|
371
|
+
data: document.data
|
|
372
|
+
}),
|
|
373
|
+
headers: {
|
|
374
|
+
"content-type": "application/json",
|
|
375
|
+
"x-client": CLIENT_IDENTIFIER
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
switch (response.status) {
|
|
379
|
+
case 201: return { id: (await response.json()).id };
|
|
380
|
+
default: return await this.#handleMigrationAPIError(response);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Updates an existing document in the repository's migration release.
|
|
385
|
+
*
|
|
386
|
+
* @typeParam TType - Type of Prismic documents to update.
|
|
387
|
+
*
|
|
388
|
+
* @param id - The ID of the document to update.
|
|
389
|
+
* @param document - The document content to update.
|
|
390
|
+
* @param params - Additional fetch parameters.
|
|
391
|
+
*
|
|
392
|
+
* @see Prismic Migration API technical reference: {@link https://prismic.io/docs/migration-api-technical-reference}
|
|
393
|
+
*/
|
|
394
|
+
async updateDocument(id, document, params) {
|
|
395
|
+
const url = new URL(`documents/${id}`, this.migrationAPIEndpoint);
|
|
396
|
+
const response = await this.#request(url, params, {
|
|
397
|
+
method: "PUT",
|
|
398
|
+
body: JSON.stringify({
|
|
399
|
+
title: document.documentTitle,
|
|
400
|
+
uid: document.uid || void 0,
|
|
401
|
+
tags: document.tags,
|
|
402
|
+
data: document.data
|
|
403
|
+
}),
|
|
404
|
+
headers: {
|
|
405
|
+
"content-type": "application/json",
|
|
406
|
+
"x-client": CLIENT_IDENTIFIER
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
switch (response.status) {
|
|
410
|
+
case 200: return;
|
|
411
|
+
default: await this.#handleMigrationAPIError(response);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Makes an authenticated HTTP request for write operations using the client's
|
|
416
|
+
* configured fetch function and options.
|
|
417
|
+
*
|
|
418
|
+
* @param url - The URL to request.
|
|
419
|
+
* @param params - Fetch options from the user.
|
|
420
|
+
* @param init - Additional fetch options to merge with the user-provided
|
|
421
|
+
* options.
|
|
422
|
+
*
|
|
423
|
+
* @returns The response from the fetch request.
|
|
424
|
+
*/
|
|
425
|
+
async #request(url, params, init) {
|
|
426
|
+
const baseInit = this._buildRequestInit(params);
|
|
427
|
+
return await request(url, {
|
|
428
|
+
...baseInit,
|
|
429
|
+
...init,
|
|
430
|
+
headers: {
|
|
431
|
+
...baseInit.headers,
|
|
432
|
+
...init === null || init === void 0 ? void 0 : init.headers,
|
|
433
|
+
repository: this.repositoryName,
|
|
434
|
+
authorization: `Bearer ${this.writeToken}`
|
|
435
|
+
}
|
|
436
|
+
}, this.fetchFn);
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Handles error responses from the Asset API with comprehensive error
|
|
440
|
+
* parsing.
|
|
441
|
+
*
|
|
442
|
+
* @param response - The HTTP response from the Asset API.
|
|
443
|
+
*
|
|
444
|
+
* @throws {@link InvalidDataError} For 400 errors.
|
|
445
|
+
* @throws {@link ForbiddenError} For 401 and 403 errors.
|
|
446
|
+
* @throws {@link NotFoundError} For 404 errors.
|
|
447
|
+
* @throws {@link PrismicError} For 500, 503, and other unexpected errors.
|
|
448
|
+
*/
|
|
449
|
+
async #handleAssetAPIError(response) {
|
|
450
|
+
const json = await response.json();
|
|
451
|
+
switch (response.status) {
|
|
452
|
+
case 401:
|
|
453
|
+
case 403: throw new ForbiddenError(json.error, response.url, json);
|
|
454
|
+
case 404: throw new NotFoundError(json.error, response.url, json);
|
|
455
|
+
case 400: throw new InvalidDataError(json.error, response.url, json);
|
|
456
|
+
case 500:
|
|
457
|
+
case 503:
|
|
458
|
+
default: throw new PrismicError(json.error, response.url, json);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Handles error responses from the Migration API with comprehensive error
|
|
463
|
+
* parsing.
|
|
464
|
+
*
|
|
465
|
+
* @param response - The HTTP response from the Migration API.
|
|
466
|
+
*
|
|
467
|
+
* @throws {@link InvalidDataError} For 400 errors.
|
|
468
|
+
* @throws {@link ForbiddenError} For 401 and 403 errors.
|
|
469
|
+
* @throws {@link NotFoundError} For 404 errors.
|
|
470
|
+
* @throws {@link PrismicError} For 500, and other unexpected errors.
|
|
471
|
+
*/
|
|
472
|
+
async #handleMigrationAPIError(response) {
|
|
473
|
+
const payload = await response.json();
|
|
474
|
+
const message = payload.message;
|
|
475
|
+
switch (response.status) {
|
|
476
|
+
case 400: throw new InvalidDataError(message, response.url, payload);
|
|
477
|
+
case 401: throw new ForbiddenError(message, response.url, payload);
|
|
478
|
+
case 403: throw new ForbiddenError(message ?? payload.Message, response.url, payload);
|
|
479
|
+
case 404: throw new NotFoundError(message, response.url, payload);
|
|
480
|
+
case 500:
|
|
481
|
+
default: throw new PrismicError(message, response.url, payload);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
559
484
|
};
|
|
560
|
-
|
|
485
|
+
|
|
486
|
+
//#endregion
|
|
487
|
+
export { WriteClient };
|
|
488
|
+
//# sourceMappingURL=WriteClient.js.map
|