@prismicio/client 7.21.0-alpha.2 → 7.21.0-pr.414.8f3ed35
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 +1271 -0
- package/dist/Client.cjs.map +1 -0
- package/dist/Client.d.ts +981 -0
- package/dist/Client.js +1271 -0
- package/dist/Client.js.map +1 -0
- package/dist/Migration.cjs +297 -0
- package/dist/Migration.cjs.map +1 -0
- package/dist/Migration.d.ts +213 -0
- package/dist/Migration.js +297 -0
- package/dist/Migration.js.map +1 -0
- package/dist/WriteClient.cjs +575 -0
- package/dist/WriteClient.cjs.map +1 -0
- package/dist/WriteClient.d.ts +281 -0
- package/dist/WriteClient.js +575 -0
- package/dist/WriteClient.js.map +1 -0
- package/dist/buildQueryURL.cjs +69 -0
- package/dist/buildQueryURL.cjs.map +1 -0
- package/dist/buildQueryURL.d.ts +217 -0
- package/dist/buildQueryURL.js +69 -0
- package/dist/buildQueryURL.js.map +1 -0
- package/dist/cookie.cjs +5 -0
- package/dist/cookie.cjs.map +1 -0
- package/dist/cookie.d.ts +5 -0
- package/dist/cookie.js +5 -0
- package/dist/cookie.js.map +1 -0
- package/dist/createClient.cjs +6 -0
- package/dist/createClient.cjs.map +1 -0
- package/dist/createClient.d.ts +35 -0
- package/dist/createClient.js +6 -0
- package/dist/createClient.js.map +1 -0
- package/dist/createMigration.cjs +6 -0
- package/dist/createMigration.cjs.map +1 -0
- package/dist/createMigration.d.ts +24 -0
- package/dist/createMigration.js +6 -0
- package/dist/createMigration.js.map +1 -0
- package/dist/createWriteClient.cjs +6 -0
- package/dist/createWriteClient.cjs.map +1 -0
- package/dist/createWriteClient.d.ts +32 -0
- package/dist/createWriteClient.js +6 -0
- package/dist/createWriteClient.js.map +1 -0
- package/dist/errors/ForbiddenError.cjs +7 -0
- package/dist/errors/ForbiddenError.cjs.map +1 -0
- package/dist/errors/ForbiddenError.d.ts +11 -0
- package/dist/errors/ForbiddenError.js +7 -0
- package/dist/errors/ForbiddenError.js.map +1 -0
- package/dist/errors/InvalidDataError.cjs +7 -0
- package/dist/errors/InvalidDataError.cjs.map +1 -0
- package/dist/errors/InvalidDataError.d.ts +3 -0
- package/dist/errors/InvalidDataError.js +7 -0
- package/dist/errors/InvalidDataError.js.map +1 -0
- package/dist/errors/NotFoundError.cjs +7 -0
- package/dist/errors/NotFoundError.cjs.map +1 -0
- package/dist/errors/NotFoundError.d.ts +3 -0
- package/dist/errors/NotFoundError.js +7 -0
- package/dist/errors/NotFoundError.js.map +1 -0
- package/dist/errors/ParsingError.cjs +7 -0
- package/dist/errors/ParsingError.cjs.map +1 -0
- package/dist/errors/ParsingError.d.ts +14 -0
- package/dist/errors/ParsingError.js +7 -0
- package/dist/errors/ParsingError.js.map +1 -0
- package/dist/errors/PreviewTokenExpired.cjs +7 -0
- package/dist/errors/PreviewTokenExpired.cjs.map +1 -0
- package/dist/errors/PreviewTokenExpired.d.ts +8 -0
- package/dist/errors/PreviewTokenExpired.js +7 -0
- package/dist/errors/PreviewTokenExpired.js.map +1 -0
- package/dist/errors/PrismicError.cjs +13 -0
- package/dist/errors/PrismicError.cjs.map +1 -0
- package/dist/errors/PrismicError.d.ts +5 -0
- package/dist/errors/PrismicError.js +13 -0
- package/dist/errors/PrismicError.js.map +1 -0
- package/dist/errors/RefExpiredError.cjs +7 -0
- package/dist/errors/RefExpiredError.cjs.map +1 -0
- package/dist/errors/RefExpiredError.d.ts +8 -0
- package/dist/errors/RefExpiredError.js +7 -0
- package/dist/errors/RefExpiredError.js.map +1 -0
- package/dist/errors/RefNotFoundError.cjs +7 -0
- package/dist/errors/RefNotFoundError.cjs.map +1 -0
- package/dist/errors/RefNotFoundError.d.ts +8 -0
- package/dist/errors/RefNotFoundError.js +7 -0
- package/dist/errors/RefNotFoundError.js.map +1 -0
- package/dist/errors/RepositoryNotFoundError.cjs +7 -0
- package/dist/errors/RepositoryNotFoundError.cjs.map +1 -0
- package/dist/errors/RepositoryNotFoundError.d.ts +3 -0
- package/dist/errors/RepositoryNotFoundError.js +7 -0
- package/dist/errors/RepositoryNotFoundError.js.map +1 -0
- package/dist/filter.cjs +247 -0
- package/dist/filter.cjs.map +1 -0
- package/dist/filter.d.ts +209 -0
- package/dist/filter.js +247 -0
- package/dist/filter.js.map +1 -0
- package/dist/getGraphQLEndpoint.cjs +13 -0
- package/dist/getGraphQLEndpoint.cjs.map +1 -0
- package/dist/getGraphQLEndpoint.d.ts +10 -0
- package/dist/getGraphQLEndpoint.js +13 -0
- package/dist/getGraphQLEndpoint.js.map +1 -0
- package/dist/getRepositoryEndpoint.cjs +13 -0
- package/dist/getRepositoryEndpoint.cjs.map +1 -0
- package/dist/getRepositoryEndpoint.d.ts +19 -0
- package/dist/getRepositoryEndpoint.js +13 -0
- package/dist/getRepositoryEndpoint.js.map +1 -0
- package/dist/getRepositoryName.cjs +17 -0
- package/dist/getRepositoryName.cjs.map +1 -0
- package/dist/getRepositoryName.d.ts +12 -0
- package/dist/getRepositoryName.js +17 -0
- package/dist/getRepositoryName.js.map +1 -0
- package/dist/getToolbarSrc.cjs +13 -0
- package/dist/getToolbarSrc.cjs.map +1 -0
- package/dist/getToolbarSrc.d.ts +34 -0
- package/dist/getToolbarSrc.js +13 -0
- package/dist/getToolbarSrc.js.map +1 -0
- package/dist/helpers/asDate.cjs +14 -0
- package/dist/helpers/asDate.cjs.map +1 -0
- package/dist/helpers/asDate.d.ts +24 -0
- package/dist/helpers/asDate.js +14 -0
- package/dist/helpers/asDate.js.map +1 -0
- package/dist/helpers/asHTML.cjs +86 -0
- package/dist/helpers/asHTML.cjs.map +1 -0
- package/dist/helpers/asHTML.d.ts +149 -0
- package/dist/helpers/asHTML.js +86 -0
- package/dist/helpers/asHTML.js.map +1 -0
- package/dist/helpers/asImagePixelDensitySrcSet.cjs +21 -0
- package/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -0
- package/dist/helpers/asImagePixelDensitySrcSet.d.ts +54 -0
- package/dist/helpers/asImagePixelDensitySrcSet.js +21 -0
- package/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -0
- package/dist/helpers/asImageSrc.cjs +13 -0
- package/dist/helpers/asImageSrc.cjs.map +1 -0
- package/dist/helpers/asImageSrc.d.ts +29 -0
- package/dist/helpers/asImageSrc.js +13 -0
- package/dist/helpers/asImageSrc.js.map +1 -0
- package/dist/helpers/asImageWidthSrcSet.cjs +45 -0
- package/dist/helpers/asImageWidthSrcSet.cjs.map +1 -0
- package/dist/helpers/asImageWidthSrcSet.d.ts +62 -0
- package/dist/helpers/asImageWidthSrcSet.js +45 -0
- package/dist/helpers/asImageWidthSrcSet.js.map +1 -0
- package/dist/helpers/asLink.cjs +47 -0
- package/dist/helpers/asLink.cjs.map +1 -0
- package/dist/helpers/asLink.d.ts +78 -0
- package/dist/helpers/asLink.js +47 -0
- package/dist/helpers/asLink.js.map +1 -0
- package/dist/helpers/asLinkAttrs.cjs +28 -0
- package/dist/helpers/asLinkAttrs.cjs.map +1 -0
- package/dist/helpers/asLinkAttrs.d.ts +47 -0
- package/dist/helpers/asLinkAttrs.js +28 -0
- package/dist/helpers/asLinkAttrs.js.map +1 -0
- package/dist/helpers/asText.cjs +21 -0
- package/dist/helpers/asText.cjs.map +1 -0
- package/dist/helpers/asText.d.ts +57 -0
- package/dist/helpers/asText.js +21 -0
- package/dist/helpers/asText.js.map +1 -0
- package/dist/helpers/documentToLinkField.cjs +26 -0
- package/dist/helpers/documentToLinkField.cjs.map +1 -0
- package/dist/helpers/documentToLinkField.d.ts +17 -0
- package/dist/helpers/documentToLinkField.js +26 -0
- package/dist/helpers/documentToLinkField.js.map +1 -0
- package/dist/helpers/isFilled.cjs +77 -0
- package/dist/helpers/isFilled.cjs.map +1 -0
- package/dist/helpers/isFilled.d.ts +191 -0
- package/dist/helpers/isFilled.js +77 -0
- package/dist/helpers/isFilled.js.map +1 -0
- package/dist/helpers/mapSliceZone.cjs +42 -0
- package/dist/helpers/mapSliceZone.cjs.map +1 -0
- package/dist/helpers/mapSliceZone.d.ts +136 -0
- package/dist/helpers/mapSliceZone.js +42 -0
- package/dist/helpers/mapSliceZone.js.map +1 -0
- package/dist/index.cjs +94 -3880
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +129 -4349
- package/dist/index.js +99 -0
- package/dist/index.js.map +1 -0
- package/dist/isRepositoryEndpoint.cjs +12 -0
- package/dist/isRepositoryEndpoint.cjs.map +1 -0
- package/dist/isRepositoryEndpoint.d.ts +10 -0
- package/dist/isRepositoryEndpoint.js +12 -0
- package/dist/isRepositoryEndpoint.js.map +1 -0
- package/dist/isRepositoryName.cjs +7 -0
- package/dist/isRepositoryName.cjs.map +1 -0
- package/dist/isRepositoryName.d.ts +9 -0
- package/dist/isRepositoryName.js +7 -0
- package/dist/isRepositoryName.js.map +1 -0
- package/dist/lib/appendFilters.cjs +11 -0
- package/dist/lib/appendFilters.cjs.map +1 -0
- package/dist/lib/appendFilters.d.ts +18 -0
- package/dist/lib/appendFilters.js +11 -0
- package/dist/lib/appendFilters.js.map +1 -0
- package/dist/lib/castArray.cjs +7 -0
- package/dist/lib/castArray.cjs.map +1 -0
- package/dist/lib/castArray.d.ts +12 -0
- package/dist/lib/castArray.js +7 -0
- package/dist/lib/castArray.js.map +1 -0
- package/dist/lib/castThunk.cjs +7 -0
- package/dist/lib/castThunk.cjs.map +1 -0
- package/dist/lib/castThunk.d.ts +11 -0
- package/dist/lib/castThunk.js +7 -0
- package/dist/lib/castThunk.js.map +1 -0
- package/dist/lib/devMsg.cjs +8 -0
- package/dist/lib/devMsg.cjs.map +1 -0
- package/dist/lib/devMsg.d.ts +16 -0
- package/dist/lib/devMsg.js +8 -0
- package/dist/lib/devMsg.js.map +1 -0
- package/dist/lib/escapeHTML.cjs +43 -0
- package/dist/lib/escapeHTML.cjs.map +1 -0
- package/dist/lib/escapeHTML.d.ts +1 -0
- package/dist/lib/escapeHTML.js +43 -0
- package/dist/lib/escapeHTML.js.map +1 -0
- package/dist/lib/everyTagFilter.cjs +9 -0
- package/dist/lib/everyTagFilter.cjs.map +1 -0
- package/dist/lib/everyTagFilter.d.ts +9 -0
- package/dist/lib/everyTagFilter.js +9 -0
- package/dist/lib/everyTagFilter.js.map +1 -0
- package/dist/lib/findMasterRef.cjs +8 -0
- package/dist/lib/findMasterRef.cjs.map +1 -0
- package/dist/lib/findMasterRef.d.ts +11 -0
- package/dist/lib/findMasterRef.js +8 -0
- package/dist/lib/findMasterRef.js.map +1 -0
- package/dist/lib/findRef.cjs +12 -0
- package/dist/lib/findRef.cjs.map +1 -0
- package/dist/lib/findRef.d.ts +14 -0
- package/dist/lib/findRef.js +12 -0
- package/dist/lib/findRef.js.map +1 -0
- package/dist/lib/findRefByID.cjs +8 -0
- package/dist/lib/findRefByID.cjs.map +1 -0
- package/dist/lib/findRefByID.d.ts +12 -0
- package/dist/lib/findRefByID.js +8 -0
- package/dist/lib/findRefByID.js.map +1 -0
- package/dist/lib/findRefByLabel.cjs +8 -0
- package/dist/lib/findRefByLabel.cjs.map +1 -0
- package/dist/lib/findRefByLabel.d.ts +12 -0
- package/dist/lib/findRefByLabel.js +8 -0
- package/dist/lib/findRefByLabel.js.map +1 -0
- package/dist/lib/getOptionalLinkProperties.cjs +14 -0
- package/dist/lib/getOptionalLinkProperties.cjs.map +1 -0
- package/dist/lib/getOptionalLinkProperties.d.ts +12 -0
- package/dist/lib/getOptionalLinkProperties.js +14 -0
- package/dist/lib/getOptionalLinkProperties.js.map +1 -0
- package/dist/lib/getPreviewCookie.cjs +21 -0
- package/dist/lib/getPreviewCookie.cjs.map +1 -0
- package/dist/lib/getPreviewCookie.d.ts +9 -0
- package/dist/lib/getPreviewCookie.js +21 -0
- package/dist/lib/getPreviewCookie.js.map +1 -0
- package/dist/lib/isInternalURL.cjs +9 -0
- package/dist/lib/isInternalURL.cjs.map +1 -0
- package/dist/lib/isInternalURL.d.ts +8 -0
- package/dist/lib/isInternalURL.js +9 -0
- package/dist/lib/isInternalURL.js.map +1 -0
- package/dist/lib/isMigrationValue.cjs +24 -0
- package/dist/lib/isMigrationValue.cjs.map +1 -0
- package/dist/lib/isMigrationValue.d.ts +71 -0
- package/dist/lib/isMigrationValue.js +24 -0
- package/dist/lib/isMigrationValue.js.map +1 -0
- package/dist/lib/isValue.cjs +53 -0
- package/dist/lib/isValue.cjs.map +1 -0
- package/dist/lib/isValue.d.ts +78 -0
- package/dist/lib/isValue.js +53 -0
- package/dist/lib/isValue.js.map +1 -0
- package/dist/lib/minifyGraphQLQuery.cjs +7 -0
- package/dist/lib/minifyGraphQLQuery.cjs.map +1 -0
- package/dist/lib/minifyGraphQLQuery.d.ts +8 -0
- package/dist/lib/minifyGraphQLQuery.js +7 -0
- package/dist/lib/minifyGraphQLQuery.js.map +1 -0
- package/dist/lib/pLimit.cjs +48 -0
- package/dist/lib/pLimit.cjs.map +1 -0
- package/dist/lib/pLimit.d.ts +22 -0
- package/dist/lib/pLimit.js +48 -0
- package/dist/lib/pLimit.js.map +1 -0
- package/dist/lib/request.cjs +41 -0
- package/dist/lib/request.cjs.map +1 -0
- package/dist/lib/request.d.ts +73 -0
- package/dist/lib/request.js +41 -0
- package/dist/lib/request.js.map +1 -0
- package/dist/lib/resolveMigrationDocumentData.cjs +132 -0
- package/dist/lib/resolveMigrationDocumentData.cjs.map +1 -0
- package/dist/lib/resolveMigrationDocumentData.d.ts +54 -0
- package/dist/lib/resolveMigrationDocumentData.js +132 -0
- package/dist/lib/resolveMigrationDocumentData.js.map +1 -0
- package/dist/lib/serializerHelpers.cjs +113 -0
- package/dist/lib/serializerHelpers.cjs.map +1 -0
- package/dist/lib/serializerHelpers.d.ts +9 -0
- package/dist/lib/serializerHelpers.js +113 -0
- package/dist/lib/serializerHelpers.js.map +1 -0
- package/dist/lib/someTagsFilter.cjs +9 -0
- package/dist/lib/someTagsFilter.cjs.map +1 -0
- package/dist/lib/someTagsFilter.d.ts +9 -0
- package/dist/lib/someTagsFilter.js +9 -0
- package/dist/lib/someTagsFilter.js.map +1 -0
- package/dist/lib/throttledLog.cjs +17 -0
- package/dist/lib/throttledLog.cjs.map +1 -0
- package/dist/lib/throttledLog.d.ts +15 -0
- package/dist/lib/throttledLog.js +17 -0
- package/dist/lib/throttledLog.js.map +1 -0
- package/dist/lib/typeFilter.cjs +8 -0
- package/dist/lib/typeFilter.cjs.map +1 -0
- package/dist/lib/typeFilter.d.ts +8 -0
- package/dist/lib/typeFilter.js +8 -0
- package/dist/lib/typeFilter.js.map +1 -0
- package/dist/lib/validateAssetMetadata.cjs +28 -0
- package/dist/lib/validateAssetMetadata.cjs.map +1 -0
- package/dist/lib/validateAssetMetadata.d.ts +10 -0
- package/dist/lib/validateAssetMetadata.js +28 -0
- package/dist/lib/validateAssetMetadata.js.map +1 -0
- package/dist/package.json.cjs +7 -0
- package/dist/package.json.cjs.map +1 -0
- package/dist/package.json.js +7 -0
- package/dist/package.json.js.map +1 -0
- package/dist/richtext/asText.cjs +13 -0
- package/dist/richtext/asText.cjs.map +1 -0
- package/dist/richtext/asText.d.ts +12 -0
- package/dist/richtext/asText.js +13 -0
- package/dist/richtext/asText.js.map +1 -0
- package/dist/richtext/asTree.cjs +123 -0
- package/dist/richtext/asTree.cjs.map +1 -0
- package/dist/richtext/asTree.d.ts +14 -0
- package/dist/richtext/asTree.js +123 -0
- package/dist/richtext/asTree.js.map +1 -0
- package/dist/richtext/composeSerializers.cjs +17 -0
- package/dist/richtext/composeSerializers.cjs.map +1 -0
- package/dist/richtext/composeSerializers.d.ts +16 -0
- package/dist/richtext/composeSerializers.js +17 -0
- package/dist/richtext/composeSerializers.js.map +1 -0
- package/dist/richtext/index.d.ts +7 -78
- package/dist/richtext/serialize.cjs +19 -0
- package/dist/richtext/serialize.cjs.map +1 -0
- package/dist/richtext/serialize.d.ts +19 -0
- package/dist/richtext/serialize.js +19 -0
- package/dist/richtext/serialize.js.map +1 -0
- package/dist/richtext/types.cjs +11 -0
- package/dist/richtext/types.cjs.map +1 -0
- package/dist/richtext/types.d.ts +71 -0
- package/dist/richtext/types.js +11 -0
- package/dist/richtext/types.js.map +1 -0
- package/dist/richtext/wrapMapSerializer.cjs +24 -0
- package/dist/richtext/wrapMapSerializer.cjs.map +1 -0
- package/dist/richtext/wrapMapSerializer.d.ts +15 -0
- package/dist/richtext/wrapMapSerializer.js +24 -0
- package/dist/richtext/wrapMapSerializer.js.map +1 -0
- package/dist/richtext.cjs +15 -0
- package/dist/richtext.cjs.map +1 -0
- package/dist/richtext.js +15 -0
- package/dist/richtext.js.map +1 -0
- package/dist/types/api/asset/asset.d.ts +177 -0
- package/dist/types/api/asset/tag.d.ts +53 -0
- package/dist/types/api/integration.d.ts +28 -0
- package/dist/types/api/migration/document.d.ts +60 -0
- package/dist/types/api/query.d.ts +43 -0
- package/dist/types/api/ref.d.ts +32 -0
- package/dist/types/api/release.d.ts +11 -0
- package/dist/types/api/repository.d.ts +109 -0
- package/dist/types/api/tags.d.ts +9 -0
- package/dist/types/migration/Asset.cjs +30 -0
- package/dist/types/migration/Asset.cjs.map +1 -0
- package/dist/types/migration/Asset.d.ts +108 -0
- package/dist/types/migration/Asset.js +30 -0
- package/dist/types/migration/Asset.js.map +1 -0
- package/dist/types/migration/ContentRelationship.d.ts +16 -0
- package/dist/types/migration/Document.cjs +44 -0
- package/dist/types/migration/Document.cjs.map +1 -0
- package/dist/types/migration/Document.d.ts +94 -0
- package/dist/types/migration/Document.js +44 -0
- package/dist/types/migration/Document.js.map +1 -0
- package/dist/types/migration/Link.d.ts +19 -0
- package/dist/types/model/boolean.d.ts +15 -0
- package/dist/types/model/color.d.ts +13 -0
- package/dist/types/model/contentRelationship.d.ts +53 -0
- package/dist/types/model/customType.d.ts +48 -0
- package/dist/types/model/date.d.ts +14 -0
- package/dist/types/model/embed.d.ts +13 -0
- package/dist/types/model/geoPoint.d.ts +12 -0
- package/dist/types/model/group.d.ts +23 -0
- package/dist/types/model/image.d.ts +31 -0
- package/dist/types/model/integration.d.ts +14 -0
- package/dist/types/model/keyText.d.ts +13 -0
- package/dist/types/model/link.cjs +9 -0
- package/dist/types/model/link.cjs.map +1 -0
- package/dist/types/model/link.d.ts +28 -0
- package/dist/types/model/link.js +9 -0
- package/dist/types/model/link.js.map +1 -0
- package/dist/types/model/linkToMedia.d.ts +17 -0
- package/dist/types/model/number.d.ts +15 -0
- package/dist/types/model/range.d.ts +14 -0
- package/dist/types/model/richText.d.ts +37 -0
- package/dist/types/model/select.d.ts +18 -0
- package/dist/types/model/separator.d.ts +10 -0
- package/dist/types/model/sharedSlice.d.ts +16 -0
- package/dist/types/model/sharedSliceVariation.d.ts +19 -0
- package/dist/types/model/slice.cjs +8 -0
- package/dist/types/model/slice.cjs.map +1 -0
- package/dist/types/model/slice.d.ts +33 -0
- package/dist/types/model/slice.js +8 -0
- package/dist/types/model/slice.js.map +1 -0
- package/dist/types/model/sliceZone.cjs +8 -0
- package/dist/types/model/sliceZone.cjs.map +1 -0
- package/dist/types/model/sliceZone.d.ts +41 -0
- package/dist/types/model/sliceZone.js +8 -0
- package/dist/types/model/sliceZone.js.map +1 -0
- package/dist/types/model/table.d.ts +12 -0
- package/dist/types/model/timestamp.d.ts +14 -0
- package/dist/types/model/title.d.ts +7 -0
- package/dist/types/model/types.cjs +39 -0
- package/dist/types/model/types.cjs.map +1 -0
- package/dist/types/model/types.d.ts +76 -0
- package/dist/types/model/types.js +39 -0
- package/dist/types/model/types.js.map +1 -0
- package/dist/types/model/uid.d.ts +13 -0
- package/dist/types/value/boolean.d.ts +6 -0
- package/dist/types/value/color.d.ts +9 -0
- package/dist/types/value/contentRelationship.d.ts +31 -0
- package/dist/types/value/date.d.ts +9 -0
- package/dist/types/value/document.d.ts +114 -0
- package/dist/types/value/embed.cjs +10 -0
- package/dist/types/value/embed.cjs.map +1 -0
- package/dist/types/value/embed.d.ts +168 -0
- package/dist/types/value/embed.js +10 -0
- package/dist/types/value/embed.js.map +1 -0
- package/dist/types/value/geoPoint.d.ts +12 -0
- package/dist/types/value/group.d.ts +13 -0
- package/dist/types/value/image.d.ts +47 -0
- package/dist/types/value/integration.d.ts +16 -0
- package/dist/types/value/keyText.d.ts +9 -0
- package/dist/types/value/link.cjs +10 -0
- package/dist/types/value/link.cjs.map +1 -0
- package/dist/types/value/link.d.ts +68 -0
- package/dist/types/value/link.js +10 -0
- package/dist/types/value/link.js.map +1 -0
- package/dist/types/value/linkToMedia.d.ts +28 -0
- package/dist/types/value/number.d.ts +9 -0
- package/dist/types/value/richText.cjs +25 -0
- package/dist/types/value/richText.cjs.map +1 -0
- package/dist/types/value/richText.d.ts +215 -0
- package/dist/types/value/richText.js +25 -0
- package/dist/types/value/richText.js.map +1 -0
- package/dist/types/value/select.d.ts +10 -0
- package/dist/types/value/sharedSlice.d.ts +11 -0
- package/dist/types/value/sharedSliceVariation.d.ts +10 -0
- package/dist/types/value/slice.d.ts +13 -0
- package/dist/types/value/sliceZone.d.ts +12 -0
- package/dist/types/value/table.d.ts +91 -0
- package/dist/types/value/timestamp.d.ts +7 -0
- package/dist/types/value/title.d.ts +12 -0
- package/dist/types/value/types.d.ts +58 -0
- package/dist/types/webhook/apiUpdate.d.ts +52 -0
- package/dist/types/webhook/testTrigger.d.ts +9 -0
- package/dist/types/webhook/types.cjs +8 -0
- package/dist/types/webhook/types.cjs.map +1 -0
- package/dist/types/webhook/types.d.ts +18 -0
- package/dist/types/webhook/types.js +8 -0
- package/dist/types/webhook/types.js.map +1 -0
- package/package.json +39 -23
- package/src/Client.ts +25 -8
- package/src/WriteClient.ts +22 -33
- package/src/buildQueryURL.ts +4 -1
- package/src/createClient.ts +1 -1
- package/src/index.ts +1 -0
- package/src/types/model/contentRelationship.ts +1 -0
- package/src/types/value/date.ts +1 -1
- package/src/types/value/timestamp.ts +1 -5
- package/dist/index.d.cts +0 -4424
- 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.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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isValue.js","sources":["../../../src/lib/isValue.ts"],"sourcesContent":["import type { InjectMigrationSpecificTypes } from \"../types/migration/Document\"\nimport type { FilledContentRelationshipField } from \"../types/value/contentRelationship\"\nimport type { PrismicDocument } from \"../types/value/document\"\nimport type { GroupField } from \"../types/value/group\"\nimport type { ImageField } from \"../types/value/image\"\nimport { LinkType } from \"../types/value/link\"\nimport type { OptionalLinkProperties } from \"../types/value/link\"\nimport type { FilledLinkToMediaField } from \"../types/value/linkToMedia\"\nimport { type RTImageNode, RichTextNodeType } from \"../types/value/richText\"\nimport type { SliceZone } from \"../types/value/sliceZone\"\nimport type { AnyRegularField } from \"../types/value/types\"\n\n/**\n * Unknown value to check if it's a specific field type.\n *\n * @remarks\n * Explicit types are added to help ensure narrowing is done effectively.\n */\ntype UnknownValue =\n\t| PrismicDocument\n\t| InjectMigrationSpecificTypes<AnyRegularField | GroupField | SliceZone>\n\t| unknown\n\n/**\n * Checks if a value is a link to media field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a link to media field, `false` otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const filledLinkToMedia = (\n\tvalue: UnknownValue,\n): value is FilledLinkToMediaField => {\n\tif (value && typeof value === \"object\" && !(\"version\" in value)) {\n\t\tif (\n\t\t\t\"link_type\" in value &&\n\t\t\tvalue.link_type === LinkType.Media &&\n\t\t\t\"id\" in value &&\n\t\t\t\"name\" in value &&\n\t\t\t\"kind\" in value &&\n\t\t\t\"url\" in value &&\n\t\t\t\"size\" in value\n\t\t) {\n\t\t\tvalue\n\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\n/**\n * Checks if a value is like an image field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is like an image field, `false` otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nconst imageLike = (\n\tvalue: UnknownValue,\n): value is ImageField<string, \"filled\"> | RTImageNode => {\n\tif (\n\t\tvalue &&\n\t\ttypeof value === \"object\" &&\n\t\t(!(\"version\" in value) || typeof value.version === \"object\")\n\t) {\n\t\tif (\n\t\t\t\"id\" in value &&\n\t\t\t\"url\" in value &&\n\t\t\ttypeof value.url === \"string\" &&\n\t\t\t\"dimensions\" in value &&\n\t\t\t\"edit\" in value &&\n\t\t\t\"alt\" in value &&\n\t\t\t\"copyright\" in value\n\t\t) {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\n/**\n * Checks if a value is an image field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is an image field, `false` otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const filledImage = (\n\tvalue: UnknownValue,\n): value is ImageField<string, \"filled\"> => {\n\tif (\n\t\timageLike(value) &&\n\t\t(!(\"type\" in value) || value.type !== RichTextNodeType.image)\n\t) {\n\t\tvalue\n\n\t\treturn true\n\t}\n\n\treturn false\n}\n\n/**\n * Checks if a value is a rich text image node.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a rich text image node, `false` otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const rtImageNode = (value: UnknownValue): value is RTImageNode => {\n\tif (\n\t\timageLike(value) &&\n\t\t\"type\" in value &&\n\t\tvalue.type === RichTextNodeType.image\n\t) {\n\t\tvalue\n\n\t\treturn true\n\t}\n\n\treturn false\n}\n\n/**\n * Checks if a value is a content relationship field.\n *\n * @remarks\n * The return value includes `OptionalLinkProperties` because\n * `FilledContentRelationshipField` may be a link field, not strictly a content\n * relationship field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a content relationship, `false` otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const filledContentRelationship = (\n\tvalue: UnknownValue,\n): value is FilledContentRelationshipField & OptionalLinkProperties => {\n\tif (value && typeof value === \"object\" && !(\"version\" in value)) {\n\t\tif (\n\t\t\t\"link_type\" in value &&\n\t\t\tvalue.link_type === LinkType.Document &&\n\t\t\t\"id\" in value &&\n\t\t\t\"type\" in value &&\n\t\t\t\"tags\" in value &&\n\t\t\t\"lang\" in value\n\t\t) {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\n/**\n * Checks if a value is a Prismic document.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a Prismic document, `false` otherwise.\n *\n * @internal\n * This is not an official helper function and it's only designed to work with internal processes.\n */\nexport const prismicDocument = (\n\tvalue: UnknownValue,\n): value is PrismicDocument => {\n\ttry {\n\t\treturn (\n\t\t\ttypeof value === \"object\" &&\n\t\t\tvalue !== null &&\n\t\t\t\"id\" in value &&\n\t\t\t\"href\" in value &&\n\t\t\ttypeof value.href === \"string\" &&\n\t\t\tnew URL(value.href) &&\n\t\t\t\"type\" in value &&\n\t\t\t\"lang\" in value &&\n\t\t\t\"tags\" in value &&\n\t\t\tArray.isArray(value.tags)\n\t\t)\n\t} catch {\n\t\treturn false\n\t}\n}\n"],"names":[],"mappings":";;AAiCO,MAAM,oBAAoB,CAChC,UACoC;AACpC,MAAI,SAAS,OAAO,UAAU,YAAY,EAAE,aAAa,QAAQ;AAChE,QACC,eAAe,SACf,MAAM,cAAc,SAAS,SAC7B,QAAQ,SACR,UAAU,SACV,UAAU,SACV,SAAS,SACT,UAAU,OACT;AAGD,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAYA,MAAM,YAAY,CACjB,UACwD;AACxD,MACC,SACA,OAAO,UAAU,aAChB,EAAE,aAAa,UAAU,OAAO,MAAM,YAAY,WAClD;AACD,QACC,QAAQ,SACR,SAAS,SACT,OAAO,MAAM,QAAQ,YACrB,gBAAgB,SAChB,UAAU,SACV,SAAS,SACT,eAAe,OACd;AACD,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAYO,MAAM,cAAc,CAC1B,UAC0C;AAC1C,MACC,UAAU,KAAK,MACd,EAAE,UAAU,UAAU,MAAM,SAAS,iBAAiB,QACtD;AAGD,WAAO;AAAA,EACR;AAEA,SAAO;AACR;AAYO,MAAM,cAAc,CAAC,UAA6C;AACxE,MACC,UAAU,KAAK,KACf,UAAU,SACV,MAAM,SAAS,iBAAiB,OAC/B;AAGD,WAAO;AAAA,EACR;AAEA,SAAO;AACR;AAiBO,MAAM,4BAA4B,CACxC,UACqE;AACrE,MAAI,SAAS,OAAO,UAAU,YAAY,EAAE,aAAa,QAAQ;AAChE,QACC,eAAe,SACf,MAAM,cAAc,SAAS,YAC7B,QAAQ,SACR,UAAU,SACV,UAAU,SACV,UAAU,OACT;AACD,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAYO,MAAM,kBAAkB,CAC9B,UAC6B;AAC7B,MAAI;AACH,WACC,OAAO,UAAU,YACjB,UAAU,QACV,QAAQ,SACR,UAAU,SACV,OAAO,MAAM,SAAS,YACtB,IAAI,IAAI,MAAM,IAAI,KAClB,UAAU,SACV,UAAU,SACV,UAAU,SACV,MAAM,QAAQ,MAAM,IAAI;AAAA,EAE1B,QAAQ;AACP,WAAO;AAAA,EACR;AACD;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const minifyGraphQLQuery = (query) => {
|
|
4
|
+
return query.replace(/(\n| )*( |{|})(\n| )*/gm, (_chars, _spaces, brackets) => brackets);
|
|
5
|
+
};
|
|
6
|
+
exports.minifyGraphQLQuery = minifyGraphQLQuery;
|
|
7
|
+
//# sourceMappingURL=minifyGraphQLQuery.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"minifyGraphQLQuery.cjs","sources":["../../../src/lib/minifyGraphQLQuery.ts"],"sourcesContent":["/**\n * Minifies a GraphQL query by removing whitespace where possible.\n *\n * @param query - GraphQL query to minify.\n *\n * @returns A minified version of `query`.\n */\nexport const minifyGraphQLQuery = (query: string): string => {\n\treturn query.replace(\n\t\t/(\\n| )*( |{|})(\\n| )*/gm,\n\t\t(_chars, _spaces, brackets) => brackets,\n\t)\n}\n"],"names":[],"mappings":";;AAOO,MAAM,qBAAqB,CAAC,UAAyB;AAC3D,SAAO,MAAM,QACZ,2BACA,CAAC,QAAQ,SAAS,aAAa,QAAQ;AAEzC;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"minifyGraphQLQuery.js","sources":["../../../src/lib/minifyGraphQLQuery.ts"],"sourcesContent":["/**\n * Minifies a GraphQL query by removing whitespace where possible.\n *\n * @param query - GraphQL query to minify.\n *\n * @returns A minified version of `query`.\n */\nexport const minifyGraphQLQuery = (query: string): string => {\n\treturn query.replace(\n\t\t/(\\n| )*( |{|})(\\n| )*/gm,\n\t\t(_chars, _spaces, brackets) => brackets,\n\t)\n}\n"],"names":[],"mappings":"AAOO,MAAM,qBAAqB,CAAC,UAAyB;AAC3D,SAAO,MAAM,QACZ,2BACA,CAAC,QAAQ,SAAS,aAAa,QAAQ;AAEzC;"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
4
|
+
const pLimit = ({ interval } = {}) => {
|
|
5
|
+
const queue = [];
|
|
6
|
+
let busy = false;
|
|
7
|
+
let lastCompletion = 0;
|
|
8
|
+
const resumeNext = () => {
|
|
9
|
+
if (!busy && queue.length > 0) {
|
|
10
|
+
queue.shift()?.();
|
|
11
|
+
busy = true;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
const next = () => {
|
|
15
|
+
busy = false;
|
|
16
|
+
resumeNext();
|
|
17
|
+
};
|
|
18
|
+
const run = async (function_, resolve, arguments_) => {
|
|
19
|
+
const timeSinceLastCompletion = Date.now() - lastCompletion;
|
|
20
|
+
if (interval && timeSinceLastCompletion < interval) {
|
|
21
|
+
await sleep(interval - timeSinceLastCompletion);
|
|
22
|
+
}
|
|
23
|
+
const result = (async () => function_(...arguments_))();
|
|
24
|
+
resolve(result);
|
|
25
|
+
try {
|
|
26
|
+
await result;
|
|
27
|
+
} catch {
|
|
28
|
+
}
|
|
29
|
+
lastCompletion = Date.now();
|
|
30
|
+
next();
|
|
31
|
+
};
|
|
32
|
+
const enqueue = (function_, resolve, arguments_) => {
|
|
33
|
+
new Promise((internalResolve) => {
|
|
34
|
+
queue.push(internalResolve);
|
|
35
|
+
}).then(run.bind(void 0, function_, resolve, arguments_));
|
|
36
|
+
(async () => {
|
|
37
|
+
await Promise.resolve();
|
|
38
|
+
if (!busy) {
|
|
39
|
+
resumeNext();
|
|
40
|
+
}
|
|
41
|
+
})();
|
|
42
|
+
};
|
|
43
|
+
return ((function_, ...arguments_) => new Promise((resolve) => {
|
|
44
|
+
enqueue(function_, resolve, arguments_);
|
|
45
|
+
}));
|
|
46
|
+
};
|
|
47
|
+
exports.pLimit = pLimit;
|
|
48
|
+
//# sourceMappingURL=pLimit.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pLimit.cjs","sources":["../../../src/lib/pLimit.ts"],"sourcesContent":["/*\n ** Core logic from https://github.com/sindresorhus/p-limit\n ** Many thanks to @sindresorhus\n */\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyFunction = (...arguments_: readonly any[]) => unknown\n\nconst sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))\n\n/**\n * @param fn - Promise-returning/async function.\n * @param arguments - Any arguments to pass through to `fn`. Support for passing\n * arguments on to the `fn` is provided in order to be able to avoid creating\n * unnecessary closures. You probably don't need this optimization unless\n * you're pushing a lot of functions.\n *\n * @returns The promise returned by calling `fn(...arguments)`.\n */\nexport type LimitFunction = <TArguments extends unknown[], TReturnType>(\n\tfunction_: (\n\t\t...arguments_: TArguments\n\t) => PromiseLike<TReturnType> | TReturnType,\n\t...arguments_: TArguments\n) => Promise<TReturnType>\n\n/**\n * Creates a limiting function that will only execute one promise at a time and\n * respect a given interval between each call.\n *\n * @param args - Options for the function, `interval` is the minimum time to\n * wait between each promise execution.\n *\n * @returns A limiting function as per configuration, see {@link LimitFunction}.\n */\nexport const pLimit = ({\n\tinterval,\n}: { interval?: number } = {}): LimitFunction => {\n\tconst queue: AnyFunction[] = []\n\tlet busy = false\n\tlet lastCompletion = 0\n\n\tconst resumeNext = () => {\n\t\tif (!busy && queue.length > 0) {\n\t\t\tqueue.shift()?.()\n\t\t\tbusy = true\n\t\t}\n\t}\n\n\tconst next = () => {\n\t\tbusy = false\n\n\t\tresumeNext()\n\t}\n\n\tconst run = async (\n\t\tfunction_: AnyFunction,\n\t\tresolve: (value: unknown) => void,\n\t\targuments_: unknown[],\n\t) => {\n\t\tconst timeSinceLastCompletion = Date.now() - lastCompletion\n\n\t\tif (interval && timeSinceLastCompletion < interval) {\n\t\t\tawait sleep(interval - timeSinceLastCompletion)\n\t\t}\n\t\tconst result = (async () => function_(...arguments_))()\n\n\t\tresolve(result)\n\n\t\ttry {\n\t\t\tawait result\n\t\t} catch {}\n\n\t\tlastCompletion = Date.now()\n\n\t\tnext()\n\t}\n\n\tconst enqueue = (\n\t\tfunction_: AnyFunction,\n\t\tresolve: (value: unknown) => void,\n\t\targuments_: unknown[],\n\t) => {\n\t\t// Queue `internalResolve` instead of the `run` function\n\t\t// to preserve asynchronous context.\n\t\tnew Promise((internalResolve) => {\n\t\t\tqueue.push(internalResolve)\n\t\t}).then(run.bind(undefined, function_, resolve, arguments_))\n\t\t;(async () => {\n\t\t\t// This function needs to wait until the next microtask before comparing\n\t\t\t// `activeCount` to `concurrency`, because `activeCount` is updated asynchronously\n\t\t\t// after the `internalResolve` function is dequeued and called. The comparison in the if-statement\n\t\t\t// needs to happen asynchronously as well to get an up-to-date value for `activeCount`.\n\t\t\tawait Promise.resolve()\n\n\t\t\tif (!busy) {\n\t\t\t\tresumeNext()\n\t\t\t}\n\t\t})()\n\t}\n\n\treturn ((function_: AnyFunction, ...arguments_: unknown[]) =>\n\t\tnew Promise<unknown>((resolve) => {\n\t\t\tenqueue(function_, resolve, arguments_)\n\t\t})) as LimitFunction\n}\n"],"names":[],"mappings":";;AAQA,MAAM,QAAQ,CAAC,OAAe,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,EAAE,CAAC;AA2BvE,MAAM,SAAS,CAAC,EACtB,SAAA,IAC0B,OAAqB;AAC/C,QAAM,QAAuB,CAAA;AAC7B,MAAI,OAAO;AACX,MAAI,iBAAiB;AAErB,QAAM,aAAa,MAAK;AACvB,QAAI,CAAC,QAAQ,MAAM,SAAS,GAAG;AAC9B,YAAM,UAAK;AACX,aAAO;AAAA,IACR;AAAA,EACD;AAEA,QAAM,OAAO,MAAK;AACjB,WAAO;AAEP,eAAA;AAAA,EACD;AAEA,QAAM,MAAM,OACX,WACA,SACA,eACG;AACH,UAAM,0BAA0B,KAAK,IAAA,IAAQ;AAE7C,QAAI,YAAY,0BAA0B,UAAU;AACnD,YAAM,MAAM,WAAW,uBAAuB;AAAA,IAC/C;AACA,UAAM,UAAU,YAAY,UAAU,GAAG,UAAU,GAAA;AAEnD,YAAQ,MAAM;AAEd,QAAI;AACH,YAAM;AAAA,IACP,QAAQ;AAAA,IAAC;AAET,qBAAiB,KAAK,IAAA;AAEtB,SAAA;AAAA,EACD;AAEA,QAAM,UAAU,CACf,WACA,SACA,eACG;AAGH,QAAI,QAAQ,CAAC,oBAAmB;AAC/B,YAAM,KAAK,eAAe;AAAA,IAC3B,CAAC,EAAE,KAAK,IAAI,KAAK,QAAW,WAAW,SAAS,UAAU,CAAC;AAC1D,KAAC,YAAW;AAKZ,YAAM,QAAQ,QAAA;AAEd,UAAI,CAAC,MAAM;AACV,mBAAA;AAAA,MACD;AAAA,IACD,GAAA;AAAA,EACD;AAEA,UAAQ,CAAC,cAA2B,eACnC,IAAI,QAAiB,CAAC,YAAW;AAChC,YAAQ,WAAW,SAAS,UAAU;AAAA,EACvC,CAAC;AACH;;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param fn - Promise-returning/async function.
|
|
3
|
+
* @param arguments - Any arguments to pass through to `fn`. Support for passing
|
|
4
|
+
* arguments on to the `fn` is provided in order to be able to avoid creating
|
|
5
|
+
* unnecessary closures. You probably don't need this optimization unless
|
|
6
|
+
* you're pushing a lot of functions.
|
|
7
|
+
*
|
|
8
|
+
* @returns The promise returned by calling `fn(...arguments)`.
|
|
9
|
+
*/
|
|
10
|
+
export type LimitFunction = <TArguments extends unknown[], TReturnType>(function_: (...arguments_: TArguments) => PromiseLike<TReturnType> | TReturnType, ...arguments_: TArguments) => Promise<TReturnType>;
|
|
11
|
+
/**
|
|
12
|
+
* Creates a limiting function that will only execute one promise at a time and
|
|
13
|
+
* respect a given interval between each call.
|
|
14
|
+
*
|
|
15
|
+
* @param args - Options for the function, `interval` is the minimum time to
|
|
16
|
+
* wait between each promise execution.
|
|
17
|
+
*
|
|
18
|
+
* @returns A limiting function as per configuration, see {@link LimitFunction}.
|
|
19
|
+
*/
|
|
20
|
+
export declare const pLimit: ({ interval, }?: {
|
|
21
|
+
interval?: number;
|
|
22
|
+
}) => LimitFunction;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
2
|
+
const pLimit = ({ interval } = {}) => {
|
|
3
|
+
const queue = [];
|
|
4
|
+
let busy = false;
|
|
5
|
+
let lastCompletion = 0;
|
|
6
|
+
const resumeNext = () => {
|
|
7
|
+
if (!busy && queue.length > 0) {
|
|
8
|
+
queue.shift()?.();
|
|
9
|
+
busy = true;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
const next = () => {
|
|
13
|
+
busy = false;
|
|
14
|
+
resumeNext();
|
|
15
|
+
};
|
|
16
|
+
const run = async (function_, resolve, arguments_) => {
|
|
17
|
+
const timeSinceLastCompletion = Date.now() - lastCompletion;
|
|
18
|
+
if (interval && timeSinceLastCompletion < interval) {
|
|
19
|
+
await sleep(interval - timeSinceLastCompletion);
|
|
20
|
+
}
|
|
21
|
+
const result = (async () => function_(...arguments_))();
|
|
22
|
+
resolve(result);
|
|
23
|
+
try {
|
|
24
|
+
await result;
|
|
25
|
+
} catch {
|
|
26
|
+
}
|
|
27
|
+
lastCompletion = Date.now();
|
|
28
|
+
next();
|
|
29
|
+
};
|
|
30
|
+
const enqueue = (function_, resolve, arguments_) => {
|
|
31
|
+
new Promise((internalResolve) => {
|
|
32
|
+
queue.push(internalResolve);
|
|
33
|
+
}).then(run.bind(void 0, function_, resolve, arguments_));
|
|
34
|
+
(async () => {
|
|
35
|
+
await Promise.resolve();
|
|
36
|
+
if (!busy) {
|
|
37
|
+
resumeNext();
|
|
38
|
+
}
|
|
39
|
+
})();
|
|
40
|
+
};
|
|
41
|
+
return ((function_, ...arguments_) => new Promise((resolve) => {
|
|
42
|
+
enqueue(function_, resolve, arguments_);
|
|
43
|
+
}));
|
|
44
|
+
};
|
|
45
|
+
export {
|
|
46
|
+
pLimit
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=pLimit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pLimit.js","sources":["../../../src/lib/pLimit.ts"],"sourcesContent":["/*\n ** Core logic from https://github.com/sindresorhus/p-limit\n ** Many thanks to @sindresorhus\n */\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyFunction = (...arguments_: readonly any[]) => unknown\n\nconst sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))\n\n/**\n * @param fn - Promise-returning/async function.\n * @param arguments - Any arguments to pass through to `fn`. Support for passing\n * arguments on to the `fn` is provided in order to be able to avoid creating\n * unnecessary closures. You probably don't need this optimization unless\n * you're pushing a lot of functions.\n *\n * @returns The promise returned by calling `fn(...arguments)`.\n */\nexport type LimitFunction = <TArguments extends unknown[], TReturnType>(\n\tfunction_: (\n\t\t...arguments_: TArguments\n\t) => PromiseLike<TReturnType> | TReturnType,\n\t...arguments_: TArguments\n) => Promise<TReturnType>\n\n/**\n * Creates a limiting function that will only execute one promise at a time and\n * respect a given interval between each call.\n *\n * @param args - Options for the function, `interval` is the minimum time to\n * wait between each promise execution.\n *\n * @returns A limiting function as per configuration, see {@link LimitFunction}.\n */\nexport const pLimit = ({\n\tinterval,\n}: { interval?: number } = {}): LimitFunction => {\n\tconst queue: AnyFunction[] = []\n\tlet busy = false\n\tlet lastCompletion = 0\n\n\tconst resumeNext = () => {\n\t\tif (!busy && queue.length > 0) {\n\t\t\tqueue.shift()?.()\n\t\t\tbusy = true\n\t\t}\n\t}\n\n\tconst next = () => {\n\t\tbusy = false\n\n\t\tresumeNext()\n\t}\n\n\tconst run = async (\n\t\tfunction_: AnyFunction,\n\t\tresolve: (value: unknown) => void,\n\t\targuments_: unknown[],\n\t) => {\n\t\tconst timeSinceLastCompletion = Date.now() - lastCompletion\n\n\t\tif (interval && timeSinceLastCompletion < interval) {\n\t\t\tawait sleep(interval - timeSinceLastCompletion)\n\t\t}\n\t\tconst result = (async () => function_(...arguments_))()\n\n\t\tresolve(result)\n\n\t\ttry {\n\t\t\tawait result\n\t\t} catch {}\n\n\t\tlastCompletion = Date.now()\n\n\t\tnext()\n\t}\n\n\tconst enqueue = (\n\t\tfunction_: AnyFunction,\n\t\tresolve: (value: unknown) => void,\n\t\targuments_: unknown[],\n\t) => {\n\t\t// Queue `internalResolve` instead of the `run` function\n\t\t// to preserve asynchronous context.\n\t\tnew Promise((internalResolve) => {\n\t\t\tqueue.push(internalResolve)\n\t\t}).then(run.bind(undefined, function_, resolve, arguments_))\n\t\t;(async () => {\n\t\t\t// This function needs to wait until the next microtask before comparing\n\t\t\t// `activeCount` to `concurrency`, because `activeCount` is updated asynchronously\n\t\t\t// after the `internalResolve` function is dequeued and called. The comparison in the if-statement\n\t\t\t// needs to happen asynchronously as well to get an up-to-date value for `activeCount`.\n\t\t\tawait Promise.resolve()\n\n\t\t\tif (!busy) {\n\t\t\t\tresumeNext()\n\t\t\t}\n\t\t})()\n\t}\n\n\treturn ((function_: AnyFunction, ...arguments_: unknown[]) =>\n\t\tnew Promise<unknown>((resolve) => {\n\t\t\tenqueue(function_, resolve, arguments_)\n\t\t})) as LimitFunction\n}\n"],"names":[],"mappings":"AAQA,MAAM,QAAQ,CAAC,OAAe,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,EAAE,CAAC;AA2BvE,MAAM,SAAS,CAAC,EACtB,SAAA,IAC0B,OAAqB;AAC/C,QAAM,QAAuB,CAAA;AAC7B,MAAI,OAAO;AACX,MAAI,iBAAiB;AAErB,QAAM,aAAa,MAAK;AACvB,QAAI,CAAC,QAAQ,MAAM,SAAS,GAAG;AAC9B,YAAM,UAAK;AACX,aAAO;AAAA,IACR;AAAA,EACD;AAEA,QAAM,OAAO,MAAK;AACjB,WAAO;AAEP,eAAA;AAAA,EACD;AAEA,QAAM,MAAM,OACX,WACA,SACA,eACG;AACH,UAAM,0BAA0B,KAAK,IAAA,IAAQ;AAE7C,QAAI,YAAY,0BAA0B,UAAU;AACnD,YAAM,MAAM,WAAW,uBAAuB;AAAA,IAC/C;AACA,UAAM,UAAU,YAAY,UAAU,GAAG,UAAU,GAAA;AAEnD,YAAQ,MAAM;AAEd,QAAI;AACH,YAAM;AAAA,IACP,QAAQ;AAAA,IAAC;AAET,qBAAiB,KAAK,IAAA;AAEtB,SAAA;AAAA,EACD;AAEA,QAAM,UAAU,CACf,WACA,SACA,eACG;AAGH,QAAI,QAAQ,CAAC,oBAAmB;AAC/B,YAAM,KAAK,eAAe;AAAA,IAC3B,CAAC,EAAE,KAAK,IAAI,KAAK,QAAW,WAAW,SAAS,UAAU,CAAC;AAC1D,KAAC,YAAW;AAKZ,YAAM,QAAQ,QAAA;AAEd,UAAI,CAAC,MAAM;AACV,mBAAA;AAAA,MACD;AAAA,IACD,GAAA;AAAA,EACD;AAEA,UAAQ,CAAC,cAA2B,eACnC,IAAI,QAAiB,CAAC,YAAW;AAChC,YAAQ,WAAW,SAAS,UAAU;AAAA,EACvC,CAAC;AACH;"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const pLimit = require("./pLimit.cjs");
|
|
4
|
+
const DEFAULT_RETRY_AFTER = 1500;
|
|
5
|
+
const THROTTLED_RUNNERS = {};
|
|
6
|
+
const DEDUPLICATED_JOBS = {};
|
|
7
|
+
async function request(url, init, fetchFn) {
|
|
8
|
+
const stringURL = url.toString();
|
|
9
|
+
let job;
|
|
10
|
+
if (init?.body) {
|
|
11
|
+
const runner = THROTTLED_RUNNERS[url.hostname] ||= pLimit.pLimit({
|
|
12
|
+
interval: DEFAULT_RETRY_AFTER
|
|
13
|
+
});
|
|
14
|
+
job = runner(() => fetchFn(stringURL, init));
|
|
15
|
+
} else {
|
|
16
|
+
const existingJob = DEDUPLICATED_JOBS[stringURL]?.get(init?.signal);
|
|
17
|
+
if (existingJob) {
|
|
18
|
+
job = existingJob;
|
|
19
|
+
} else {
|
|
20
|
+
job = fetchFn(stringURL, init).finally(() => {
|
|
21
|
+
DEDUPLICATED_JOBS[stringURL]?.delete(init?.signal);
|
|
22
|
+
if (DEDUPLICATED_JOBS[stringURL]?.size === 0) {
|
|
23
|
+
delete DEDUPLICATED_JOBS[stringURL];
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
const map = DEDUPLICATED_JOBS[stringURL] ||= /* @__PURE__ */ new Map();
|
|
27
|
+
map.set(init?.signal, job);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const response = await job;
|
|
31
|
+
if (response.status === 429) {
|
|
32
|
+
const retryAfter = Number(response.headers.get("retry-after"));
|
|
33
|
+
const resolvedRetryAfter = Number.isNaN(retryAfter) ? DEFAULT_RETRY_AFTER : retryAfter * 1e3;
|
|
34
|
+
await new Promise((resolve) => setTimeout(resolve, resolvedRetryAfter));
|
|
35
|
+
return request(url, init, fetchFn);
|
|
36
|
+
}
|
|
37
|
+
return response.clone();
|
|
38
|
+
}
|
|
39
|
+
exports.DEFAULT_RETRY_AFTER = DEFAULT_RETRY_AFTER;
|
|
40
|
+
exports.request = request;
|
|
41
|
+
//# sourceMappingURL=request.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.cjs","sources":["../../../src/lib/request.ts"],"sourcesContent":["import { type LimitFunction, pLimit } from \"./pLimit\"\n\n/**\n * The default number of milliseconds to wait before retrying a rate-limited\n * `fetch()` request (429 response code). The default value is only used if the\n * response does not include a `retry-after` header.\n */\nexport const DEFAULT_RETRY_AFTER = 1500 // ms\n\n/**\n * A record of URLs mapped to throttled task runners.\n */\nconst THROTTLED_RUNNERS: Partial<Record<string, LimitFunction>> = {}\n\n/**\n * A record of URLs mapped to active deduplicated jobs. Jobs are keyed by their\n * optional signal.\n */\nconst DEDUPLICATED_JOBS: Partial<\n\tRecord<string, Map<AbortSignalLike | undefined, Promise<ResponseLike>>>\n> = {}\n\n/**\n * A universal API to make network requests. A subset of the `fetch()` API.\n *\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/fetch}\n */\nexport type FetchLike = (\n\tinput: string,\n\tinit?: RequestInitLike,\n) => Promise<ResponseLike>\n\n/**\n * An object that allows you to abort a `fetch()` request if needed via an\n * `AbortController` object\n *\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal}\n */\n// `any` is used often here to ensure this type is universally valid among\n// different AbortSignal implementations. The types of each property are not\n// important to validate since it is blindly passed to a given `fetch()`\n// function.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AbortSignalLike = any\n\n/**\n * A subset of RequestInit properties to configure a `fetch()` request.\n */\n// Only options relevant to the client are included. Extending from the full\n// RequestInit would cause issues, such as accepting Header objects.\n//\n// An interface is used to allow other libraries to augment the type with\n// environment-specific types.\nexport interface RequestInitLike extends Pick<RequestInit, \"cache\"> {\n\t/**\n\t * The HTTP method to use for the request.\n\t */\n\tmethod?: string\n\n\t/**\n\t * The request body to send with the request.\n\t */\n\t// We want to keep the body type as compatible as possible, so\n\t// we only declare the type we need and accept anything else.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tbody?: any | FormData | string\n\n\t/**\n\t * An object literal to set the `fetch()` request's headers.\n\t */\n\theaders?: Record<string, string>\n\n\t/**\n\t * An AbortSignal to set the `fetch()` request's signal.\n\t *\n\t * See:\n\t * [https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)\n\t */\n\t// NOTE: `AbortSignalLike` is `any`! It is left as `AbortSignalLike`\n\t// for backwards compatibility (the type is exported) and to signal to\n\t// other readers that this should be an AbortSignal-like object.\n\tsignal?: AbortSignalLike\n}\n\n/**\n * The minimum required properties from Response.\n */\nexport interface ResponseLike {\n\tok: boolean\n\tstatus: number\n\theaders: HeadersLike\n\turl: string\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tjson(): Promise<any>\n\ttext(): Promise<string>\n\tblob(): Promise<Blob>\n\tclone(): ResponseLike\n}\n\n/**\n * The minimum required properties from Headers.\n */\nexport interface HeadersLike {\n\tget(name: string): string | null\n}\n\n/**\n * Makes an HTTP request with automatic retry for rate limits and request\n * deduplication.\n *\n * @param url - The URL to request.\n * @param init - Fetch options.\n * @param fetchFn - The fetch function to use.\n *\n * @returns The response from the fetch request.\n */\nexport async function request(\n\turl: URL,\n\tinit: RequestInitLike | undefined,\n\tfetchFn: FetchLike,\n): Promise<ResponseLike> {\n\tconst stringURL = url.toString()\n\n\tlet job: Promise<ResponseLike>\n\n\t// Throttle requests with a body.\n\tif (init?.body) {\n\t\t// Rate limiting is done per hostname.\n\t\tconst runner = (THROTTLED_RUNNERS[url.hostname] ||= pLimit({\n\t\t\tinterval: DEFAULT_RETRY_AFTER,\n\t\t}))\n\n\t\tjob = runner(() => fetchFn(stringURL, init))\n\t} else {\n\t\t// Deduplicate all other requests.\n\t\tconst existingJob = DEDUPLICATED_JOBS[stringURL]?.get(init?.signal)\n\t\tif (existingJob) {\n\t\t\tjob = existingJob\n\t\t} else {\n\t\t\tjob = fetchFn(stringURL, init).finally(() => {\n\t\t\t\tDEDUPLICATED_JOBS[stringURL]?.delete(init?.signal)\n\t\t\t\tif (DEDUPLICATED_JOBS[stringURL]?.size === 0) {\n\t\t\t\t\tdelete DEDUPLICATED_JOBS[stringURL]\n\t\t\t\t}\n\t\t\t})\n\t\t\tconst map = (DEDUPLICATED_JOBS[stringURL] ||= new Map())\n\t\t\tmap.set(init?.signal, job)\n\t\t}\n\t}\n\n\tconst response = await job\n\n\t// Retry rate limited requests.\n\tif (response.status === 429) {\n\t\tconst retryAfter = Number(response.headers.get(\"retry-after\"))\n\t\tconst resolvedRetryAfter = Number.isNaN(retryAfter)\n\t\t\t? DEFAULT_RETRY_AFTER\n\t\t\t: retryAfter * 1000\n\n\t\tawait new Promise((resolve) => setTimeout(resolve, resolvedRetryAfter))\n\n\t\treturn request(url, init, fetchFn)\n\t}\n\n\treturn response.clone()\n}\n"],"names":["pLimit"],"mappings":";;;AAOO,MAAM,sBAAsB;AAKnC,MAAM,oBAA4D,CAAA;AAMlE,MAAM,oBAEF,CAAA;AAgGJ,eAAsB,QACrB,KACA,MACA,SAAkB;AAElB,QAAM,YAAY,IAAI,SAAA;AAEtB,MAAI;AAGJ,MAAI,MAAM,MAAM;AAEf,UAAM,SAAU,kBAAkB,IAAI,QAAQ,MAAMA,OAAAA,OAAO;AAAA,MAC1D,UAAU;AAAA,IAAA,CACV;AAED,UAAM,OAAO,MAAM,QAAQ,WAAW,IAAI,CAAC;AAAA,EAC5C,OAAO;AAEN,UAAM,cAAc,kBAAkB,SAAS,GAAG,IAAI,MAAM,MAAM;AAClE,QAAI,aAAa;AAChB,YAAM;AAAA,IACP,OAAO;AACN,YAAM,QAAQ,WAAW,IAAI,EAAE,QAAQ,MAAK;AAC3C,0BAAkB,SAAS,GAAG,OAAO,MAAM,MAAM;AACjD,YAAI,kBAAkB,SAAS,GAAG,SAAS,GAAG;AAC7C,iBAAO,kBAAkB,SAAS;AAAA,QACnC;AAAA,MACD,CAAC;AACD,YAAM,MAAO,kBAAkB,SAAS,0BAAU,IAAA;AAClD,UAAI,IAAI,MAAM,QAAQ,GAAG;AAAA,IAC1B;AAAA,EACD;AAEA,QAAM,WAAW,MAAM;AAGvB,MAAI,SAAS,WAAW,KAAK;AAC5B,UAAM,aAAa,OAAO,SAAS,QAAQ,IAAI,aAAa,CAAC;AAC7D,UAAM,qBAAqB,OAAO,MAAM,UAAU,IAC/C,sBACA,aAAa;AAEhB,UAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,kBAAkB,CAAC;AAEtE,WAAO,QAAQ,KAAK,MAAM,OAAO;AAAA,EAClC;AAEA,SAAO,SAAS,MAAA;AACjB;;;"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The default number of milliseconds to wait before retrying a rate-limited
|
|
3
|
+
* `fetch()` request (429 response code). The default value is only used if the
|
|
4
|
+
* response does not include a `retry-after` header.
|
|
5
|
+
*/
|
|
6
|
+
export declare const DEFAULT_RETRY_AFTER = 1500;
|
|
7
|
+
/**
|
|
8
|
+
* A universal API to make network requests. A subset of the `fetch()` API.
|
|
9
|
+
*
|
|
10
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/API/fetch}
|
|
11
|
+
*/
|
|
12
|
+
export type FetchLike = (input: string, init?: RequestInitLike) => Promise<ResponseLike>;
|
|
13
|
+
/**
|
|
14
|
+
* An object that allows you to abort a `fetch()` request if needed via an
|
|
15
|
+
* `AbortController` object
|
|
16
|
+
*
|
|
17
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal}
|
|
18
|
+
*/
|
|
19
|
+
export type AbortSignalLike = any;
|
|
20
|
+
/**
|
|
21
|
+
* A subset of RequestInit properties to configure a `fetch()` request.
|
|
22
|
+
*/
|
|
23
|
+
export interface RequestInitLike extends Pick<RequestInit, "cache"> {
|
|
24
|
+
/**
|
|
25
|
+
* The HTTP method to use for the request.
|
|
26
|
+
*/
|
|
27
|
+
method?: string;
|
|
28
|
+
/**
|
|
29
|
+
* The request body to send with the request.
|
|
30
|
+
*/
|
|
31
|
+
body?: any | FormData | string;
|
|
32
|
+
/**
|
|
33
|
+
* An object literal to set the `fetch()` request's headers.
|
|
34
|
+
*/
|
|
35
|
+
headers?: Record<string, string>;
|
|
36
|
+
/**
|
|
37
|
+
* An AbortSignal to set the `fetch()` request's signal.
|
|
38
|
+
*
|
|
39
|
+
* See:
|
|
40
|
+
* [https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)
|
|
41
|
+
*/
|
|
42
|
+
signal?: AbortSignalLike;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The minimum required properties from Response.
|
|
46
|
+
*/
|
|
47
|
+
export interface ResponseLike {
|
|
48
|
+
ok: boolean;
|
|
49
|
+
status: number;
|
|
50
|
+
headers: HeadersLike;
|
|
51
|
+
url: string;
|
|
52
|
+
json(): Promise<any>;
|
|
53
|
+
text(): Promise<string>;
|
|
54
|
+
blob(): Promise<Blob>;
|
|
55
|
+
clone(): ResponseLike;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The minimum required properties from Headers.
|
|
59
|
+
*/
|
|
60
|
+
export interface HeadersLike {
|
|
61
|
+
get(name: string): string | null;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Makes an HTTP request with automatic retry for rate limits and request
|
|
65
|
+
* deduplication.
|
|
66
|
+
*
|
|
67
|
+
* @param url - The URL to request.
|
|
68
|
+
* @param init - Fetch options.
|
|
69
|
+
* @param fetchFn - The fetch function to use.
|
|
70
|
+
*
|
|
71
|
+
* @returns The response from the fetch request.
|
|
72
|
+
*/
|
|
73
|
+
export declare function request(url: URL, init: RequestInitLike | undefined, fetchFn: FetchLike): Promise<ResponseLike>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { pLimit } from "./pLimit.js";
|
|
2
|
+
const DEFAULT_RETRY_AFTER = 1500;
|
|
3
|
+
const THROTTLED_RUNNERS = {};
|
|
4
|
+
const DEDUPLICATED_JOBS = {};
|
|
5
|
+
async function request(url, init, fetchFn) {
|
|
6
|
+
const stringURL = url.toString();
|
|
7
|
+
let job;
|
|
8
|
+
if (init?.body) {
|
|
9
|
+
const runner = THROTTLED_RUNNERS[url.hostname] ||= pLimit({
|
|
10
|
+
interval: DEFAULT_RETRY_AFTER
|
|
11
|
+
});
|
|
12
|
+
job = runner(() => fetchFn(stringURL, init));
|
|
13
|
+
} else {
|
|
14
|
+
const existingJob = DEDUPLICATED_JOBS[stringURL]?.get(init?.signal);
|
|
15
|
+
if (existingJob) {
|
|
16
|
+
job = existingJob;
|
|
17
|
+
} else {
|
|
18
|
+
job = fetchFn(stringURL, init).finally(() => {
|
|
19
|
+
DEDUPLICATED_JOBS[stringURL]?.delete(init?.signal);
|
|
20
|
+
if (DEDUPLICATED_JOBS[stringURL]?.size === 0) {
|
|
21
|
+
delete DEDUPLICATED_JOBS[stringURL];
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
const map = DEDUPLICATED_JOBS[stringURL] ||= /* @__PURE__ */ new Map();
|
|
25
|
+
map.set(init?.signal, job);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const response = await job;
|
|
29
|
+
if (response.status === 429) {
|
|
30
|
+
const retryAfter = Number(response.headers.get("retry-after"));
|
|
31
|
+
const resolvedRetryAfter = Number.isNaN(retryAfter) ? DEFAULT_RETRY_AFTER : retryAfter * 1e3;
|
|
32
|
+
await new Promise((resolve) => setTimeout(resolve, resolvedRetryAfter));
|
|
33
|
+
return request(url, init, fetchFn);
|
|
34
|
+
}
|
|
35
|
+
return response.clone();
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
DEFAULT_RETRY_AFTER,
|
|
39
|
+
request
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.js","sources":["../../../src/lib/request.ts"],"sourcesContent":["import { type LimitFunction, pLimit } from \"./pLimit\"\n\n/**\n * The default number of milliseconds to wait before retrying a rate-limited\n * `fetch()` request (429 response code). The default value is only used if the\n * response does not include a `retry-after` header.\n */\nexport const DEFAULT_RETRY_AFTER = 1500 // ms\n\n/**\n * A record of URLs mapped to throttled task runners.\n */\nconst THROTTLED_RUNNERS: Partial<Record<string, LimitFunction>> = {}\n\n/**\n * A record of URLs mapped to active deduplicated jobs. Jobs are keyed by their\n * optional signal.\n */\nconst DEDUPLICATED_JOBS: Partial<\n\tRecord<string, Map<AbortSignalLike | undefined, Promise<ResponseLike>>>\n> = {}\n\n/**\n * A universal API to make network requests. A subset of the `fetch()` API.\n *\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/fetch}\n */\nexport type FetchLike = (\n\tinput: string,\n\tinit?: RequestInitLike,\n) => Promise<ResponseLike>\n\n/**\n * An object that allows you to abort a `fetch()` request if needed via an\n * `AbortController` object\n *\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal}\n */\n// `any` is used often here to ensure this type is universally valid among\n// different AbortSignal implementations. The types of each property are not\n// important to validate since it is blindly passed to a given `fetch()`\n// function.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AbortSignalLike = any\n\n/**\n * A subset of RequestInit properties to configure a `fetch()` request.\n */\n// Only options relevant to the client are included. Extending from the full\n// RequestInit would cause issues, such as accepting Header objects.\n//\n// An interface is used to allow other libraries to augment the type with\n// environment-specific types.\nexport interface RequestInitLike extends Pick<RequestInit, \"cache\"> {\n\t/**\n\t * The HTTP method to use for the request.\n\t */\n\tmethod?: string\n\n\t/**\n\t * The request body to send with the request.\n\t */\n\t// We want to keep the body type as compatible as possible, so\n\t// we only declare the type we need and accept anything else.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tbody?: any | FormData | string\n\n\t/**\n\t * An object literal to set the `fetch()` request's headers.\n\t */\n\theaders?: Record<string, string>\n\n\t/**\n\t * An AbortSignal to set the `fetch()` request's signal.\n\t *\n\t * See:\n\t * [https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)\n\t */\n\t// NOTE: `AbortSignalLike` is `any`! It is left as `AbortSignalLike`\n\t// for backwards compatibility (the type is exported) and to signal to\n\t// other readers that this should be an AbortSignal-like object.\n\tsignal?: AbortSignalLike\n}\n\n/**\n * The minimum required properties from Response.\n */\nexport interface ResponseLike {\n\tok: boolean\n\tstatus: number\n\theaders: HeadersLike\n\turl: string\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tjson(): Promise<any>\n\ttext(): Promise<string>\n\tblob(): Promise<Blob>\n\tclone(): ResponseLike\n}\n\n/**\n * The minimum required properties from Headers.\n */\nexport interface HeadersLike {\n\tget(name: string): string | null\n}\n\n/**\n * Makes an HTTP request with automatic retry for rate limits and request\n * deduplication.\n *\n * @param url - The URL to request.\n * @param init - Fetch options.\n * @param fetchFn - The fetch function to use.\n *\n * @returns The response from the fetch request.\n */\nexport async function request(\n\turl: URL,\n\tinit: RequestInitLike | undefined,\n\tfetchFn: FetchLike,\n): Promise<ResponseLike> {\n\tconst stringURL = url.toString()\n\n\tlet job: Promise<ResponseLike>\n\n\t// Throttle requests with a body.\n\tif (init?.body) {\n\t\t// Rate limiting is done per hostname.\n\t\tconst runner = (THROTTLED_RUNNERS[url.hostname] ||= pLimit({\n\t\t\tinterval: DEFAULT_RETRY_AFTER,\n\t\t}))\n\n\t\tjob = runner(() => fetchFn(stringURL, init))\n\t} else {\n\t\t// Deduplicate all other requests.\n\t\tconst existingJob = DEDUPLICATED_JOBS[stringURL]?.get(init?.signal)\n\t\tif (existingJob) {\n\t\t\tjob = existingJob\n\t\t} else {\n\t\t\tjob = fetchFn(stringURL, init).finally(() => {\n\t\t\t\tDEDUPLICATED_JOBS[stringURL]?.delete(init?.signal)\n\t\t\t\tif (DEDUPLICATED_JOBS[stringURL]?.size === 0) {\n\t\t\t\t\tdelete DEDUPLICATED_JOBS[stringURL]\n\t\t\t\t}\n\t\t\t})\n\t\t\tconst map = (DEDUPLICATED_JOBS[stringURL] ||= new Map())\n\t\t\tmap.set(init?.signal, job)\n\t\t}\n\t}\n\n\tconst response = await job\n\n\t// Retry rate limited requests.\n\tif (response.status === 429) {\n\t\tconst retryAfter = Number(response.headers.get(\"retry-after\"))\n\t\tconst resolvedRetryAfter = Number.isNaN(retryAfter)\n\t\t\t? DEFAULT_RETRY_AFTER\n\t\t\t: retryAfter * 1000\n\n\t\tawait new Promise((resolve) => setTimeout(resolve, resolvedRetryAfter))\n\n\t\treturn request(url, init, fetchFn)\n\t}\n\n\treturn response.clone()\n}\n"],"names":[],"mappings":";AAOO,MAAM,sBAAsB;AAKnC,MAAM,oBAA4D,CAAA;AAMlE,MAAM,oBAEF,CAAA;AAgGJ,eAAsB,QACrB,KACA,MACA,SAAkB;AAElB,QAAM,YAAY,IAAI,SAAA;AAEtB,MAAI;AAGJ,MAAI,MAAM,MAAM;AAEf,UAAM,SAAU,kBAAkB,IAAI,QAAQ,MAAM,OAAO;AAAA,MAC1D,UAAU;AAAA,IAAA,CACV;AAED,UAAM,OAAO,MAAM,QAAQ,WAAW,IAAI,CAAC;AAAA,EAC5C,OAAO;AAEN,UAAM,cAAc,kBAAkB,SAAS,GAAG,IAAI,MAAM,MAAM;AAClE,QAAI,aAAa;AAChB,YAAM;AAAA,IACP,OAAO;AACN,YAAM,QAAQ,WAAW,IAAI,EAAE,QAAQ,MAAK;AAC3C,0BAAkB,SAAS,GAAG,OAAO,MAAM,MAAM;AACjD,YAAI,kBAAkB,SAAS,GAAG,SAAS,GAAG;AAC7C,iBAAO,kBAAkB,SAAS;AAAA,QACnC;AAAA,MACD,CAAC;AACD,YAAM,MAAO,kBAAkB,SAAS,0BAAU,IAAA;AAClD,UAAI,IAAI,MAAM,QAAQ,GAAG;AAAA,IAC1B;AAAA,EACD;AAEA,QAAM,WAAW,MAAM;AAGvB,MAAI,SAAS,WAAW,KAAK;AAC5B,UAAM,aAAa,OAAO,SAAS,QAAQ,IAAI,aAAa,CAAC;AAC7D,UAAM,qBAAqB,OAAO,MAAM,UAAU,IAC/C,sBACA,aAAa;AAEhB,UAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,kBAAkB,CAAC;AAEtE,WAAO,QAAQ,KAAK,MAAM,OAAO;AAAA,EAClC;AAEA,SAAO,SAAS,MAAA;AACjB;"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const Asset = require("../types/migration/Asset.cjs");
|
|
4
|
+
const Document = require("../types/migration/Document.cjs");
|
|
5
|
+
const link = require("../types/value/link.cjs");
|
|
6
|
+
const richText = require("../types/value/richText.cjs");
|
|
7
|
+
const isFilled = require("../helpers/isFilled.cjs");
|
|
8
|
+
const isMigrationValue = require("./isMigrationValue.cjs");
|
|
9
|
+
const getOptionalLinkProperties = require("./getOptionalLinkProperties.cjs");
|
|
10
|
+
async function resolveMigrationContentRelationship(relation) {
|
|
11
|
+
if (typeof relation === "function") {
|
|
12
|
+
return resolveMigrationContentRelationship(await relation());
|
|
13
|
+
}
|
|
14
|
+
if (relation instanceof Document.PrismicMigrationDocument) {
|
|
15
|
+
return relation.document.id ? { link_type: link.LinkType.Document, id: relation.document.id } : { link_type: link.LinkType.Any };
|
|
16
|
+
}
|
|
17
|
+
const optionalLinkProperties = relation && "link_type" in relation ? getOptionalLinkProperties.getOptionalLinkProperties(relation) : void 0;
|
|
18
|
+
if (relation) {
|
|
19
|
+
if (isMigrationValue.contentRelationship(relation.id) || typeof relation.id !== "string") {
|
|
20
|
+
return {
|
|
21
|
+
...optionalLinkProperties,
|
|
22
|
+
...await resolveMigrationContentRelationship(relation.id)
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
...optionalLinkProperties,
|
|
27
|
+
link_type: link.LinkType.Document,
|
|
28
|
+
id: relation.id
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
...optionalLinkProperties,
|
|
33
|
+
link_type: link.LinkType.Any
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const resolveMigrationImage = (image, migration, withThumbnails) => {
|
|
37
|
+
const { id: master, ...thumbnails } = image instanceof Asset.PrismicMigrationAsset ? { id: image } : image;
|
|
38
|
+
const asset = migration._assets.get(master.config.id)?.asset;
|
|
39
|
+
const maybeInitialField = master.originalField;
|
|
40
|
+
if (asset) {
|
|
41
|
+
const parameters = (maybeInitialField?.url || asset.url).split("?")[1];
|
|
42
|
+
const url = `${asset.url.split("?")[0]}${parameters ? `?${parameters}` : ""}`;
|
|
43
|
+
const dimensions = {
|
|
44
|
+
width: asset.width,
|
|
45
|
+
height: asset.height
|
|
46
|
+
};
|
|
47
|
+
const edit = maybeInitialField && "edit" in maybeInitialField ? maybeInitialField?.edit : { x: 0, y: 0, zoom: 1, background: "transparent" };
|
|
48
|
+
const alt = master.config.alt || asset.alt || null;
|
|
49
|
+
const resolvedThumbnails = {};
|
|
50
|
+
if (withThumbnails) {
|
|
51
|
+
for (const [name, thumbnail] of Object.entries(thumbnails)) {
|
|
52
|
+
const resolvedThumbnail = resolveMigrationImage(thumbnail, migration);
|
|
53
|
+
if (resolvedThumbnail) {
|
|
54
|
+
resolvedThumbnails[name] = resolvedThumbnail;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
id: asset.id,
|
|
60
|
+
url,
|
|
61
|
+
dimensions,
|
|
62
|
+
edit,
|
|
63
|
+
alt,
|
|
64
|
+
copyright: asset.credits || null,
|
|
65
|
+
...resolvedThumbnails
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const resolveMigrationRTImageNode = async (rtImageNode, migration) => {
|
|
70
|
+
const image = resolveMigrationImage(rtImageNode.id, migration);
|
|
71
|
+
if (image) {
|
|
72
|
+
const linkTo = await resolveMigrationDocumentData(rtImageNode.linkTo, migration);
|
|
73
|
+
return {
|
|
74
|
+
...image,
|
|
75
|
+
type: richText.RichTextNodeType.image,
|
|
76
|
+
linkTo: isFilled.link(linkTo) ? linkTo : void 0
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const resolveMigrationLinkToMedia = (linkToMedia, migration) => {
|
|
81
|
+
const asset = migration._assets.get(linkToMedia.id.config.id)?.asset;
|
|
82
|
+
const optionalLinkProperties = getOptionalLinkProperties.getOptionalLinkProperties(linkToMedia);
|
|
83
|
+
if (asset) {
|
|
84
|
+
return {
|
|
85
|
+
...optionalLinkProperties,
|
|
86
|
+
id: asset.id,
|
|
87
|
+
link_type: link.LinkType.Media
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
...optionalLinkProperties,
|
|
92
|
+
link_type: link.LinkType.Any
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
async function resolveMigrationDocumentData(input, migration) {
|
|
96
|
+
if (isMigrationValue.contentRelationship(input)) {
|
|
97
|
+
return resolveMigrationContentRelationship(input);
|
|
98
|
+
}
|
|
99
|
+
if (isMigrationValue.image(input)) {
|
|
100
|
+
return resolveMigrationImage(input, migration, true);
|
|
101
|
+
}
|
|
102
|
+
if (isMigrationValue.linkToMedia(input)) {
|
|
103
|
+
return resolveMigrationLinkToMedia(input, migration);
|
|
104
|
+
}
|
|
105
|
+
if (isMigrationValue.rtImageNode(input)) {
|
|
106
|
+
return resolveMigrationRTImageNode(input, migration);
|
|
107
|
+
}
|
|
108
|
+
if (typeof input === "function") {
|
|
109
|
+
return await resolveMigrationDocumentData(await input(), migration);
|
|
110
|
+
}
|
|
111
|
+
if (Array.isArray(input)) {
|
|
112
|
+
const res = [];
|
|
113
|
+
for (const element of input) {
|
|
114
|
+
res.push(await resolveMigrationDocumentData(element, migration));
|
|
115
|
+
}
|
|
116
|
+
return res.filter(Boolean);
|
|
117
|
+
}
|
|
118
|
+
if (input && typeof input === "object") {
|
|
119
|
+
const res = {};
|
|
120
|
+
for (const key in input) {
|
|
121
|
+
res[key] = await resolveMigrationDocumentData(input[key], migration);
|
|
122
|
+
}
|
|
123
|
+
return res;
|
|
124
|
+
}
|
|
125
|
+
return input;
|
|
126
|
+
}
|
|
127
|
+
exports.resolveMigrationContentRelationship = resolveMigrationContentRelationship;
|
|
128
|
+
exports.resolveMigrationDocumentData = resolveMigrationDocumentData;
|
|
129
|
+
exports.resolveMigrationImage = resolveMigrationImage;
|
|
130
|
+
exports.resolveMigrationLinkToMedia = resolveMigrationLinkToMedia;
|
|
131
|
+
exports.resolveMigrationRTImageNode = resolveMigrationRTImageNode;
|
|
132
|
+
//# sourceMappingURL=resolveMigrationDocumentData.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveMigrationDocumentData.cjs","sources":["../../../src/lib/resolveMigrationDocumentData.ts"],"sourcesContent":["import type { MigrationLinkToMediaField } from \"../types/migration/Asset\"\nimport {\n\ttype MigrationImage,\n\ttype MigrationLinkToMedia,\n\ttype MigrationRTImageNode,\n\tPrismicMigrationAsset,\n} from \"../types/migration/Asset\"\nimport type {\n\tMigrationContentRelationship,\n\tMigrationContentRelationshipField,\n} from \"../types/migration/ContentRelationship\"\nimport { PrismicMigrationDocument } from \"../types/migration/Document\"\nimport type { MaybeLink } from \"../types/migration/Link\"\nimport type { FilledImageFieldImage } from \"../types/value/image\"\nimport type { LinkField, OptionalLinkProperties } from \"../types/value/link\"\nimport { LinkType } from \"../types/value/link\"\nimport type { RTImageNode } from \"../types/value/richText\"\nimport { RichTextNodeType } from \"../types/value/richText\"\n\nimport * as isFilled from \"../helpers/isFilled\"\nimport type { Migration } from \"../Migration\"\n\nimport * as isMigration from \"./isMigrationValue\"\nimport { getOptionalLinkProperties } from \"./getOptionalLinkProperties\"\n\n/**\n * Resolves a migration content relationship to a content relationship field.\n *\n * @param relation - Content relationship to resolve.\n *\n * @returns Resolved content relationship field.\n */\nexport async function resolveMigrationContentRelationship(\n\trelation: MaybeLink<MigrationContentRelationship>,\n): Promise<MigrationContentRelationshipField & OptionalLinkProperties> {\n\tif (typeof relation === \"function\") {\n\t\treturn resolveMigrationContentRelationship(await relation())\n\t}\n\n\tif (relation instanceof PrismicMigrationDocument) {\n\t\treturn relation.document.id\n\t\t\t? { link_type: LinkType.Document, id: relation.document.id }\n\t\t\t: { link_type: LinkType.Any }\n\t}\n\n\tconst optionalLinkProperties =\n\t\trelation && \"link_type\" in relation\n\t\t\t? getOptionalLinkProperties(relation)\n\t\t\t: undefined\n\n\tif (relation) {\n\t\tif (\n\t\t\tisMigration.contentRelationship(relation.id) ||\n\t\t\ttypeof relation.id !== \"string\"\n\t\t) {\n\t\t\treturn {\n\t\t\t\t...optionalLinkProperties,\n\t\t\t\t...(await resolveMigrationContentRelationship(relation.id)),\n\t\t\t}\n\t\t}\n\n\t\t// This is only called when resolveMigrationContentRelationship recursively\n\t\t// calls itself from the statement above and the resolved content relation\n\t\t// is a Prismic document value.\n\t\treturn {\n\t\t\t...optionalLinkProperties,\n\t\t\tlink_type: LinkType.Document,\n\t\t\tid: relation.id,\n\t\t}\n\t}\n\n\treturn {\n\t\t...optionalLinkProperties,\n\t\tlink_type: LinkType.Any,\n\t}\n}\n\n/**\n * Resolves a migration image to an image field.\n *\n * @param migrationAsset - Asset to resolve.\n * @param migration - Migration instance.\n * @param withThumbnails - Whether to include thumbnails.\n *\n * @returns Resolved image field.\n */\nexport const resolveMigrationImage = (\n\timage: MigrationImage,\n\tmigration: Migration,\n\twithThumbnails?: boolean,\n): FilledImageFieldImage | undefined => {\n\tconst { id: master, ...thumbnails } =\n\t\timage instanceof PrismicMigrationAsset ? { id: image } : image\n\n\tconst asset = migration._assets.get(master.config.id)?.asset\n\tconst maybeInitialField = master.originalField\n\n\tif (asset) {\n\t\tconst parameters = (maybeInitialField?.url || asset.url).split(\"?\")[1]\n\t\tconst url = `${asset.url.split(\"?\")[0]}${parameters ? `?${parameters}` : \"\"}`\n\t\tconst dimensions: FilledImageFieldImage[\"dimensions\"] = {\n\t\t\twidth: asset.width!,\n\t\t\theight: asset.height!,\n\t\t}\n\t\tconst edit: FilledImageFieldImage[\"edit\"] =\n\t\t\tmaybeInitialField && \"edit\" in maybeInitialField\n\t\t\t\t? maybeInitialField?.edit\n\t\t\t\t: { x: 0, y: 0, zoom: 1, background: \"transparent\" }\n\n\t\t// We give priority to the asset's specific alt text, then the image's general alt text\n\t\tconst alt = master.config.alt || asset.alt || null\n\n\t\tconst resolvedThumbnails: Record<string, FilledImageFieldImage> = {}\n\t\tif (withThumbnails) {\n\t\t\tfor (const [name, thumbnail] of Object.entries(thumbnails)) {\n\t\t\t\tconst resolvedThumbnail = resolveMigrationImage(thumbnail, migration)\n\t\t\t\tif (resolvedThumbnail) {\n\t\t\t\t\tresolvedThumbnails[name] = resolvedThumbnail\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tid: asset.id,\n\t\t\turl,\n\t\t\tdimensions,\n\t\t\tedit,\n\t\t\talt: alt,\n\t\t\tcopyright: asset.credits || null,\n\t\t\t...resolvedThumbnails,\n\t\t}\n\t}\n}\n\n/**\n * Resolves a migration rich text image node to a regular rich text image node.\n *\n * @param rtImageNode - Migration rich text image node to resolve.\n * @param migration - Migration instance.\n *\n * @returns Resolved rich text image node.\n */\nexport const resolveMigrationRTImageNode = async (\n\trtImageNode: MigrationRTImageNode,\n\tmigration: Migration,\n): Promise<RTImageNode | undefined> => {\n\tconst image = resolveMigrationImage(rtImageNode.id, migration)\n\n\tif (image) {\n\t\tconst linkTo = (await resolveMigrationDocumentData(\n\t\t\trtImageNode.linkTo,\n\t\t\tmigration,\n\t\t)) as LinkField\n\n\t\treturn {\n\t\t\t...image,\n\t\t\ttype: RichTextNodeType.image,\n\t\t\tlinkTo: isFilled.link(linkTo) ? linkTo : undefined,\n\t\t}\n\t}\n}\n\n/**\n * Resolves a migration link to media to a regular link to media field.\n *\n * @param linkToMedia - Migration link to media to resolve.\n * @param migration - Migration instance.\n *\n * @returns Resolved link to media field.\n */\nexport const resolveMigrationLinkToMedia = (\n\tlinkToMedia: MaybeLink<MigrationLinkToMedia>,\n\tmigration: Migration,\n): MigrationLinkToMediaField => {\n\tconst asset = migration._assets.get(linkToMedia.id.config.id)?.asset\n\tconst optionalLinkProperties = getOptionalLinkProperties(linkToMedia)\n\n\tif (asset) {\n\t\treturn {\n\t\t\t...optionalLinkProperties,\n\t\t\tid: asset.id,\n\t\t\tlink_type: LinkType.Media,\n\t\t}\n\t}\n\n\treturn {\n\t\t...optionalLinkProperties,\n\t\tlink_type: LinkType.Any,\n\t}\n}\n\n/**\n * Resolves a migration document data to actual data ready to be sent to the\n * Migration API.\n *\n * @param input - Migration link to media to resolve.\n * @param migration - Migration instance.\n *\n * @returns Resolved data.\n */\nexport async function resolveMigrationDocumentData(\n\tinput: unknown,\n\tmigration: Migration,\n): Promise<unknown> {\n\t// Migration fields\n\tif (isMigration.contentRelationship(input)) {\n\t\treturn resolveMigrationContentRelationship(input)\n\t}\n\n\tif (isMigration.image(input)) {\n\t\treturn resolveMigrationImage(input, migration, true)\n\t}\n\n\tif (isMigration.linkToMedia(input)) {\n\t\treturn resolveMigrationLinkToMedia(input, migration)\n\t}\n\n\tif (isMigration.rtImageNode(input)) {\n\t\treturn resolveMigrationRTImageNode(input, migration)\n\t}\n\n\tif (typeof input === \"function\") {\n\t\treturn await resolveMigrationDocumentData(await input(), migration)\n\t}\n\n\t// Object traversing\n\tif (Array.isArray(input)) {\n\t\tconst res = []\n\n\t\tfor (const element of input) {\n\t\t\tres.push(await resolveMigrationDocumentData(element, migration))\n\t\t}\n\n\t\treturn res.filter(Boolean)\n\t}\n\n\tif (input && typeof input === \"object\") {\n\t\tconst res: Record<PropertyKey, unknown> = {}\n\n\t\tfor (const key in input) {\n\t\t\tres[key] = await resolveMigrationDocumentData(\n\t\t\t\tinput[key as keyof typeof input],\n\t\t\t\tmigration,\n\t\t\t)\n\t\t}\n\n\t\treturn res\n\t}\n\n\t// Primitives\n\treturn input\n}\n"],"names":["PrismicMigrationDocument","LinkType","getOptionalLinkProperties","isMigration.contentRelationship","PrismicMigrationAsset","RichTextNodeType","isFilled.link","isMigration.image","isMigration.linkToMedia","isMigration.rtImageNode"],"mappings":";;;;;;;;;AAgCA,eAAsB,oCACrB,UAAiD;AAEjD,MAAI,OAAO,aAAa,YAAY;AACnC,WAAO,oCAAoC,MAAM,UAAU;AAAA,EAC5D;AAEA,MAAI,oBAAoBA,SAAAA,0BAA0B;AACjD,WAAO,SAAS,SAAS,KACtB,EAAE,WAAWC,KAAAA,SAAS,UAAU,IAAI,SAAS,SAAS,GAAA,IACtD,EAAE,WAAWA,KAAAA,SAAS,IAAA;AAAA,EAC1B;AAEA,QAAM,yBACL,YAAY,eAAe,WACxBC,0BAAAA,0BAA0B,QAAQ,IAClC;AAEJ,MAAI,UAAU;AACb,QACCC,iBAAAA,oBAAgC,SAAS,EAAE,KAC3C,OAAO,SAAS,OAAO,UACtB;AACD,aAAO;AAAA,QACN,GAAG;AAAA,QACH,GAAI,MAAM,oCAAoC,SAAS,EAAE;AAAA,MAAA;AAAA,IAE3D;AAKA,WAAO;AAAA,MACN,GAAG;AAAA,MACH,WAAWF,KAAAA,SAAS;AAAA,MACpB,IAAI,SAAS;AAAA,IAAA;AAAA,EAEf;AAEA,SAAO;AAAA,IACN,GAAG;AAAA,IACH,WAAWA,KAAAA,SAAS;AAAA,EAAA;AAEtB;AAWO,MAAM,wBAAwB,CACpC,OACA,WACA,mBACsC;AACtC,QAAM,EAAE,IAAI,QAAQ,GAAG,WAAA,IACtB,iBAAiBG,MAAAA,wBAAwB,EAAE,IAAI,MAAA,IAAU;AAE1D,QAAM,QAAQ,UAAU,QAAQ,IAAI,OAAO,OAAO,EAAE,GAAG;AACvD,QAAM,oBAAoB,OAAO;AAEjC,MAAI,OAAO;AACV,UAAM,cAAc,mBAAmB,OAAO,MAAM,KAAK,MAAM,GAAG,EAAE,CAAC;AACrE,UAAM,MAAM,GAAG,MAAM,IAAI,MAAM,GAAG,EAAE,CAAC,CAAC,GAAG,aAAa,IAAI,UAAU,KAAK,EAAE;AAC3E,UAAM,aAAkD;AAAA,MACvD,OAAO,MAAM;AAAA,MACb,QAAQ,MAAM;AAAA,IAAA;AAEf,UAAM,OACL,qBAAqB,UAAU,oBAC5B,mBAAmB,OACnB,EAAE,GAAG,GAAG,GAAG,GAAG,MAAM,GAAG,YAAY,cAAA;AAGvC,UAAM,MAAM,OAAO,OAAO,OAAO,MAAM,OAAO;AAE9C,UAAM,qBAA4D,CAAA;AAClE,QAAI,gBAAgB;AACnB,iBAAW,CAAC,MAAM,SAAS,KAAK,OAAO,QAAQ,UAAU,GAAG;AAC3D,cAAM,oBAAoB,sBAAsB,WAAW,SAAS;AACpE,YAAI,mBAAmB;AACtB,6BAAmB,IAAI,IAAI;AAAA,QAC5B;AAAA,MACD;AAAA,IACD;AAEA,WAAO;AAAA,MACN,IAAI,MAAM;AAAA,MACV;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,WAAW,MAAM,WAAW;AAAA,MAC5B,GAAG;AAAA,IAAA;AAAA,EAEL;AACD;AAUO,MAAM,8BAA8B,OAC1C,aACA,cACqC;AACrC,QAAM,QAAQ,sBAAsB,YAAY,IAAI,SAAS;AAE7D,MAAI,OAAO;AACV,UAAM,SAAU,MAAM,6BACrB,YAAY,QACZ,SAAS;AAGV,WAAO;AAAA,MACN,GAAG;AAAA,MACH,MAAMC,SAAAA,iBAAiB;AAAA,MACvB,QAAQC,SAAAA,KAAc,MAAM,IAAI,SAAS;AAAA,IAAA;AAAA,EAE3C;AACD;AAUO,MAAM,8BAA8B,CAC1C,aACA,cAC8B;AAC9B,QAAM,QAAQ,UAAU,QAAQ,IAAI,YAAY,GAAG,OAAO,EAAE,GAAG;AAC/D,QAAM,yBAAyBJ,0BAAAA,0BAA0B,WAAW;AAEpE,MAAI,OAAO;AACV,WAAO;AAAA,MACN,GAAG;AAAA,MACH,IAAI,MAAM;AAAA,MACV,WAAWD,KAAAA,SAAS;AAAA,IAAA;AAAA,EAEtB;AAEA,SAAO;AAAA,IACN,GAAG;AAAA,IACH,WAAWA,KAAAA,SAAS;AAAA,EAAA;AAEtB;AAWA,eAAsB,6BACrB,OACA,WAAoB;AAGpB,MAAIE,iBAAAA,oBAAgC,KAAK,GAAG;AAC3C,WAAO,oCAAoC,KAAK;AAAA,EACjD;AAEA,MAAII,iBAAAA,MAAkB,KAAK,GAAG;AAC7B,WAAO,sBAAsB,OAAO,WAAW,IAAI;AAAA,EACpD;AAEA,MAAIC,iBAAAA,YAAwB,KAAK,GAAG;AACnC,WAAO,4BAA4B,OAAO,SAAS;AAAA,EACpD;AAEA,MAAIC,iBAAAA,YAAwB,KAAK,GAAG;AACnC,WAAO,4BAA4B,OAAO,SAAS;AAAA,EACpD;AAEA,MAAI,OAAO,UAAU,YAAY;AAChC,WAAO,MAAM,6BAA6B,MAAM,MAAA,GAAS,SAAS;AAAA,EACnE;AAGA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACzB,UAAM,MAAM,CAAA;AAEZ,eAAW,WAAW,OAAO;AAC5B,UAAI,KAAK,MAAM,6BAA6B,SAAS,SAAS,CAAC;AAAA,IAChE;AAEA,WAAO,IAAI,OAAO,OAAO;AAAA,EAC1B;AAEA,MAAI,SAAS,OAAO,UAAU,UAAU;AACvC,UAAM,MAAoC,CAAA;AAE1C,eAAW,OAAO,OAAO;AACxB,UAAI,GAAG,IAAI,MAAM,6BAChB,MAAM,GAAyB,GAC/B,SAAS;AAAA,IAEX;AAEA,WAAO;AAAA,EACR;AAGA,SAAO;AACR;;;;;;"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { MigrationLinkToMediaField } from "../types/migration/Asset.js";
|
|
2
|
+
import { type MigrationImage, type MigrationLinkToMedia, type MigrationRTImageNode } from "../types/migration/Asset.js";
|
|
3
|
+
import type { MigrationContentRelationship, MigrationContentRelationshipField } from "../types/migration/ContentRelationship.js";
|
|
4
|
+
import type { MaybeLink } from "../types/migration/Link.js";
|
|
5
|
+
import type { FilledImageFieldImage } from "../types/value/image.js";
|
|
6
|
+
import type { OptionalLinkProperties } from "../types/value/link.js";
|
|
7
|
+
import type { RTImageNode } from "../types/value/richText.js";
|
|
8
|
+
import type { Migration } from "../Migration.js";
|
|
9
|
+
/**
|
|
10
|
+
* Resolves a migration content relationship to a content relationship field.
|
|
11
|
+
*
|
|
12
|
+
* @param relation - Content relationship to resolve.
|
|
13
|
+
*
|
|
14
|
+
* @returns Resolved content relationship field.
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveMigrationContentRelationship(relation: MaybeLink<MigrationContentRelationship>): Promise<MigrationContentRelationshipField & OptionalLinkProperties>;
|
|
17
|
+
/**
|
|
18
|
+
* Resolves a migration image to an image field.
|
|
19
|
+
*
|
|
20
|
+
* @param migrationAsset - Asset to resolve.
|
|
21
|
+
* @param migration - Migration instance.
|
|
22
|
+
* @param withThumbnails - Whether to include thumbnails.
|
|
23
|
+
*
|
|
24
|
+
* @returns Resolved image field.
|
|
25
|
+
*/
|
|
26
|
+
export declare const resolveMigrationImage: (image: MigrationImage, migration: Migration, withThumbnails?: boolean) => FilledImageFieldImage | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Resolves a migration rich text image node to a regular rich text image node.
|
|
29
|
+
*
|
|
30
|
+
* @param rtImageNode - Migration rich text image node to resolve.
|
|
31
|
+
* @param migration - Migration instance.
|
|
32
|
+
*
|
|
33
|
+
* @returns Resolved rich text image node.
|
|
34
|
+
*/
|
|
35
|
+
export declare const resolveMigrationRTImageNode: (rtImageNode: MigrationRTImageNode, migration: Migration) => Promise<RTImageNode | undefined>;
|
|
36
|
+
/**
|
|
37
|
+
* Resolves a migration link to media to a regular link to media field.
|
|
38
|
+
*
|
|
39
|
+
* @param linkToMedia - Migration link to media to resolve.
|
|
40
|
+
* @param migration - Migration instance.
|
|
41
|
+
*
|
|
42
|
+
* @returns Resolved link to media field.
|
|
43
|
+
*/
|
|
44
|
+
export declare const resolveMigrationLinkToMedia: (linkToMedia: MaybeLink<MigrationLinkToMedia>, migration: Migration) => MigrationLinkToMediaField;
|
|
45
|
+
/**
|
|
46
|
+
* Resolves a migration document data to actual data ready to be sent to the
|
|
47
|
+
* Migration API.
|
|
48
|
+
*
|
|
49
|
+
* @param input - Migration link to media to resolve.
|
|
50
|
+
* @param migration - Migration instance.
|
|
51
|
+
*
|
|
52
|
+
* @returns Resolved data.
|
|
53
|
+
*/
|
|
54
|
+
export declare function resolveMigrationDocumentData(input: unknown, migration: Migration): Promise<unknown>;
|