@prismicio/client 7.21.6 → 7.21.7-canary.673a207
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 +19 -20
- package/dist/Client.cjs.map +1 -1
- package/dist/Client.d.cts +5 -12
- package/dist/Client.d.cts.map +1 -1
- package/dist/Client.d.ts +5 -12
- package/dist/Client.d.ts.map +1 -1
- package/dist/Client.js +8 -9
- package/dist/Client.js.map +1 -1
- package/dist/Migration.cjs +18 -19
- package/dist/Migration.cjs.map +1 -1
- package/dist/Migration.d.cts +0 -1
- package/dist/Migration.d.cts.map +1 -1
- package/dist/Migration.d.ts +0 -1
- package/dist/Migration.d.ts.map +1 -1
- package/dist/Migration.js +11 -12
- package/dist/Migration.js.map +1 -1
- package/dist/WriteClient.cjs +19 -23
- package/dist/WriteClient.cjs.map +1 -1
- package/dist/WriteClient.d.cts +0 -1
- package/dist/WriteClient.d.cts.map +1 -1
- package/dist/WriteClient.d.ts +0 -1
- package/dist/WriteClient.d.ts.map +1 -1
- package/dist/WriteClient.js +12 -16
- package/dist/WriteClient.js.map +1 -1
- package/dist/_virtual/_rolldown/runtime.cjs +13 -0
- package/dist/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.js} +4 -5
- package/dist/buildQueryURL.cjs +4 -5
- package/dist/buildQueryURL.cjs.map +1 -1
- package/dist/buildQueryURL.d.cts.map +1 -1
- package/dist/buildQueryURL.d.ts.map +1 -1
- package/dist/buildQueryURL.js +2 -3
- package/dist/buildQueryURL.js.map +1 -1
- package/dist/cookie.cjs +7 -9
- package/dist/cookie.cjs.map +1 -1
- package/dist/cookie.d.cts.map +1 -1
- package/dist/cookie.d.ts.map +1 -1
- package/dist/cookie.js +3 -4
- package/dist/cookie.js.map +1 -1
- package/dist/createClient.cjs +2 -3
- package/dist/createClient.cjs.map +1 -1
- package/dist/createClient.d.cts +0 -1
- package/dist/createClient.d.cts.map +1 -1
- package/dist/createClient.d.ts +0 -1
- package/dist/createClient.d.ts.map +1 -1
- package/dist/createClient.js +1 -2
- package/dist/createClient.js.map +1 -1
- package/dist/createMigration.cjs +2 -3
- package/dist/createMigration.cjs.map +1 -1
- package/dist/createMigration.d.cts +0 -1
- package/dist/createMigration.d.cts.map +1 -1
- package/dist/createMigration.d.ts +0 -1
- package/dist/createMigration.d.ts.map +1 -1
- package/dist/createMigration.js +1 -2
- package/dist/createMigration.js.map +1 -1
- package/dist/createWriteClient.cjs +2 -3
- package/dist/createWriteClient.cjs.map +1 -1
- package/dist/createWriteClient.d.cts +0 -1
- package/dist/createWriteClient.d.cts.map +1 -1
- package/dist/createWriteClient.d.ts +0 -1
- package/dist/createWriteClient.d.ts.map +1 -1
- package/dist/createWriteClient.js +1 -2
- package/dist/createWriteClient.js.map +1 -1
- package/dist/errors.cjs +1 -2
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts.map +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +1 -1
- package/dist/filter.cjs +1 -2
- package/dist/filter.cjs.map +1 -1
- package/dist/filter.d.cts.map +1 -1
- package/dist/filter.d.ts.map +1 -1
- package/dist/filter.js +1 -1
- package/dist/getGraphQLEndpoint.cjs +3 -4
- package/dist/getGraphQLEndpoint.cjs.map +1 -1
- package/dist/getGraphQLEndpoint.d.cts.map +1 -1
- package/dist/getGraphQLEndpoint.d.ts.map +1 -1
- package/dist/getGraphQLEndpoint.js +1 -2
- package/dist/getGraphQLEndpoint.js.map +1 -1
- package/dist/getRepositoryEndpoint.cjs +3 -4
- package/dist/getRepositoryEndpoint.cjs.map +1 -1
- package/dist/getRepositoryEndpoint.d.cts.map +1 -1
- package/dist/getRepositoryEndpoint.d.ts.map +1 -1
- package/dist/getRepositoryEndpoint.js +1 -2
- package/dist/getRepositoryEndpoint.js.map +1 -1
- package/dist/getRepositoryName.cjs +2 -3
- package/dist/getRepositoryName.cjs.map +1 -1
- package/dist/getRepositoryName.d.cts.map +1 -1
- package/dist/getRepositoryName.d.ts.map +1 -1
- package/dist/getRepositoryName.js +1 -2
- package/dist/getRepositoryName.js.map +1 -1
- package/dist/getToolbarSrc.cjs +3 -4
- package/dist/getToolbarSrc.cjs.map +1 -1
- package/dist/getToolbarSrc.d.cts.map +1 -1
- package/dist/getToolbarSrc.d.ts.map +1 -1
- package/dist/getToolbarSrc.js +1 -2
- package/dist/getToolbarSrc.js.map +1 -1
- package/dist/helpers/asDate.cjs +1 -2
- package/dist/helpers/asDate.cjs.map +1 -1
- package/dist/helpers/asDate.d.cts +0 -1
- package/dist/helpers/asDate.d.cts.map +1 -1
- package/dist/helpers/asDate.d.ts +0 -1
- package/dist/helpers/asDate.d.ts.map +1 -1
- package/dist/helpers/asDate.js +1 -1
- package/dist/helpers/asHTML.cjs +5 -6
- package/dist/helpers/asHTML.cjs.map +1 -1
- package/dist/helpers/asHTML.d.cts +0 -1
- package/dist/helpers/asHTML.d.cts.map +1 -1
- package/dist/helpers/asHTML.d.ts +0 -1
- package/dist/helpers/asHTML.d.ts.map +1 -1
- package/dist/helpers/asHTML.js +1 -2
- package/dist/helpers/asHTML.js.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.cjs +3 -4
- package/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.d.cts +0 -1
- package/dist/helpers/asImagePixelDensitySrcSet.d.cts.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.d.ts +0 -1
- package/dist/helpers/asImagePixelDensitySrcSet.d.ts.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.js +2 -3
- package/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -1
- package/dist/helpers/asImageSrc.cjs +2 -3
- package/dist/helpers/asImageSrc.cjs.map +1 -1
- package/dist/helpers/asImageSrc.d.cts +0 -1
- package/dist/helpers/asImageSrc.d.cts.map +1 -1
- package/dist/helpers/asImageSrc.d.ts +0 -1
- package/dist/helpers/asImageSrc.d.ts.map +1 -1
- package/dist/helpers/asImageSrc.js +1 -2
- package/dist/helpers/asImageSrc.js.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.cjs +4 -5
- package/dist/helpers/asImageWidthSrcSet.cjs.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.d.cts +0 -1
- package/dist/helpers/asImageWidthSrcSet.d.cts.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.d.ts +0 -1
- package/dist/helpers/asImageWidthSrcSet.d.ts.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.js +3 -4
- package/dist/helpers/asImageWidthSrcSet.js.map +1 -1
- package/dist/helpers/asLink.cjs +3 -4
- package/dist/helpers/asLink.cjs.map +1 -1
- package/dist/helpers/asLink.d.cts +0 -1
- package/dist/helpers/asLink.d.cts.map +1 -1
- package/dist/helpers/asLink.d.ts +0 -1
- package/dist/helpers/asLink.d.ts.map +1 -1
- package/dist/helpers/asLink.js +1 -2
- package/dist/helpers/asLink.js.map +1 -1
- package/dist/helpers/asLinkAttrs.cjs +4 -5
- package/dist/helpers/asLinkAttrs.cjs.map +1 -1
- package/dist/helpers/asLinkAttrs.d.cts.map +1 -1
- package/dist/helpers/asLinkAttrs.d.ts.map +1 -1
- package/dist/helpers/asLinkAttrs.js +1 -2
- package/dist/helpers/asLinkAttrs.js.map +1 -1
- package/dist/helpers/asText.cjs +4 -5
- package/dist/helpers/asText.cjs.map +1 -1
- package/dist/helpers/asText.d.cts +0 -1
- package/dist/helpers/asText.d.cts.map +1 -1
- package/dist/helpers/asText.d.ts +0 -1
- package/dist/helpers/asText.d.ts.map +1 -1
- package/dist/helpers/asText.js +5 -6
- package/dist/helpers/asText.js.map +1 -1
- package/dist/helpers/documentToLinkField.cjs +2 -3
- package/dist/helpers/documentToLinkField.cjs.map +1 -1
- package/dist/helpers/documentToLinkField.d.cts.map +1 -1
- package/dist/helpers/documentToLinkField.d.ts.map +1 -1
- package/dist/helpers/documentToLinkField.js +1 -2
- package/dist/helpers/documentToLinkField.js.map +1 -1
- package/dist/helpers/isFilled.cjs +11 -13
- package/dist/helpers/isFilled.cjs.map +1 -1
- package/dist/helpers/isFilled.d.cts.map +1 -1
- package/dist/helpers/isFilled.d.ts.map +1 -1
- package/dist/helpers/isFilled.js +7 -8
- package/dist/helpers/isFilled.js.map +1 -1
- package/dist/helpers/mapSliceZone.cjs +1 -2
- package/dist/helpers/mapSliceZone.cjs.map +1 -1
- package/dist/helpers/mapSliceZone.d.cts +0 -1
- package/dist/helpers/mapSliceZone.d.cts.map +1 -1
- package/dist/helpers/mapSliceZone.d.ts +0 -1
- package/dist/helpers/mapSliceZone.d.ts.map +1 -1
- package/dist/helpers/mapSliceZone.js +1 -1
- package/dist/index.cjs +49 -49
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/isRepositoryEndpoint.cjs +1 -2
- package/dist/isRepositoryEndpoint.cjs.map +1 -1
- package/dist/isRepositoryEndpoint.d.cts.map +1 -1
- package/dist/isRepositoryEndpoint.d.ts.map +1 -1
- package/dist/isRepositoryEndpoint.js +1 -1
- package/dist/isRepositoryName.cjs +1 -2
- package/dist/isRepositoryName.cjs.map +1 -1
- package/dist/isRepositoryName.d.cts.map +1 -1
- package/dist/isRepositoryName.d.ts.map +1 -1
- package/dist/isRepositoryName.js +1 -1
- package/dist/lib/devMsg.cjs +2 -3
- package/dist/lib/devMsg.cjs.map +1 -1
- package/dist/lib/devMsg.js +1 -2
- package/dist/lib/devMsg.js.map +1 -1
- package/dist/lib/escapeHTML.cjs +1 -2
- package/dist/lib/escapeHTML.cjs.map +1 -1
- package/dist/lib/escapeHTML.js +1 -1
- package/dist/lib/getOptionalLinkProperties.cjs +1 -2
- package/dist/lib/getOptionalLinkProperties.cjs.map +1 -1
- package/dist/lib/getOptionalLinkProperties.js +1 -1
- package/dist/lib/getOptionalLinkProperties.js.map +1 -1
- package/dist/lib/getPreviewCookie.cjs +3 -4
- package/dist/lib/getPreviewCookie.cjs.map +1 -1
- package/dist/lib/getPreviewCookie.js +3 -4
- package/dist/lib/getPreviewCookie.js.map +1 -1
- package/dist/lib/isInternalURL.cjs +1 -2
- package/dist/lib/isInternalURL.cjs.map +1 -1
- package/dist/lib/isInternalURL.js +1 -1
- package/dist/lib/isMigrationValue.cjs +6 -7
- package/dist/lib/isMigrationValue.cjs.map +1 -1
- package/dist/lib/isMigrationValue.js +1 -2
- package/dist/lib/isMigrationValue.js.map +1 -1
- package/dist/lib/isValue.cjs +3 -4
- package/dist/lib/isValue.cjs.map +1 -1
- package/dist/lib/isValue.js +1 -2
- package/dist/lib/isValue.js.map +1 -1
- package/dist/lib/pLimit.cjs +1 -2
- package/dist/lib/pLimit.cjs.map +1 -1
- package/dist/lib/pLimit.js +1 -1
- package/dist/lib/pLimit.js.map +1 -1
- package/dist/lib/request.cjs +8 -8
- package/dist/lib/request.cjs.map +1 -1
- package/dist/lib/request.d.cts +1 -1
- package/dist/lib/request.d.cts.map +1 -1
- package/dist/lib/request.d.ts +1 -1
- package/dist/lib/request.d.ts.map +1 -1
- package/dist/lib/request.js +7 -7
- package/dist/lib/request.js.map +1 -1
- package/dist/lib/resolveMigrationDocumentData.cjs +18 -19
- package/dist/lib/resolveMigrationDocumentData.cjs.map +1 -1
- package/dist/lib/resolveMigrationDocumentData.js +11 -12
- package/dist/lib/resolveMigrationDocumentData.js.map +1 -1
- package/dist/lib/serializerHelpers.cjs +4 -5
- package/dist/lib/serializerHelpers.cjs.map +1 -1
- package/dist/lib/serializerHelpers.js +1 -2
- package/dist/lib/serializerHelpers.js.map +1 -1
- package/dist/lib/throttledWarn.cjs +1 -2
- package/dist/lib/throttledWarn.cjs.map +1 -1
- package/dist/lib/throttledWarn.js +1 -1
- package/dist/lib/throttledWarn.js.map +1 -1
- package/dist/lib/validateAssetMetadata.cjs +2 -3
- package/dist/lib/validateAssetMetadata.cjs.map +1 -1
- package/dist/lib/validateAssetMetadata.js +1 -2
- package/dist/lib/validateAssetMetadata.js.map +1 -1
- package/dist/package.cjs +12 -13
- package/dist/package.cjs.map +1 -1
- package/dist/package.js +2 -2
- package/dist/package.js.map +1 -1
- package/dist/richtext/asText.cjs +1 -2
- package/dist/richtext/asText.cjs.map +1 -1
- package/dist/richtext/asText.d.cts +0 -1
- package/dist/richtext/asText.d.cts.map +1 -1
- package/dist/richtext/asText.d.ts +0 -1
- package/dist/richtext/asText.d.ts.map +1 -1
- package/dist/richtext/asText.js +1 -1
- package/dist/richtext/asTree.cjs +2 -3
- package/dist/richtext/asTree.cjs.map +1 -1
- package/dist/richtext/asTree.d.cts +0 -1
- package/dist/richtext/asTree.d.cts.map +1 -1
- package/dist/richtext/asTree.d.ts +0 -1
- package/dist/richtext/asTree.d.ts.map +1 -1
- package/dist/richtext/asTree.js +1 -2
- package/dist/richtext/asTree.js.map +1 -1
- package/dist/richtext/composeSerializers.cjs +1 -2
- package/dist/richtext/composeSerializers.cjs.map +1 -1
- package/dist/richtext/composeSerializers.d.cts +0 -1
- package/dist/richtext/composeSerializers.d.cts.map +1 -1
- package/dist/richtext/composeSerializers.d.ts +0 -1
- package/dist/richtext/composeSerializers.d.ts.map +1 -1
- package/dist/richtext/composeSerializers.js +1 -1
- package/dist/richtext/serialize.cjs +2 -3
- package/dist/richtext/serialize.cjs.map +1 -1
- package/dist/richtext/serialize.d.cts +0 -1
- package/dist/richtext/serialize.d.cts.map +1 -1
- package/dist/richtext/serialize.d.ts +0 -1
- package/dist/richtext/serialize.d.ts.map +1 -1
- package/dist/richtext/serialize.js +1 -2
- package/dist/richtext/serialize.js.map +1 -1
- package/dist/richtext/types.cjs +2 -3
- package/dist/richtext/types.cjs.map +1 -1
- package/dist/richtext/types.d.cts +0 -1
- package/dist/richtext/types.d.cts.map +1 -1
- package/dist/richtext/types.d.ts +0 -1
- package/dist/richtext/types.d.ts.map +1 -1
- package/dist/richtext/types.js +1 -2
- package/dist/richtext/types.js.map +1 -1
- package/dist/richtext/wrapMapSerializer.cjs +2 -3
- package/dist/richtext/wrapMapSerializer.cjs.map +1 -1
- package/dist/richtext/wrapMapSerializer.d.cts +0 -1
- package/dist/richtext/wrapMapSerializer.d.cts.map +1 -1
- package/dist/richtext/wrapMapSerializer.d.ts +0 -1
- package/dist/richtext/wrapMapSerializer.d.ts.map +1 -1
- package/dist/richtext/wrapMapSerializer.js +1 -2
- package/dist/richtext/wrapMapSerializer.js.map +1 -1
- package/dist/richtext.cjs +8 -8
- package/dist/richtext.js +1 -2
- package/dist/types/api/asset/asset.d.cts +0 -1
- package/dist/types/api/asset/asset.d.cts.map +1 -1
- package/dist/types/api/asset/asset.d.ts +0 -1
- package/dist/types/api/asset/asset.d.ts.map +1 -1
- package/dist/types/api/asset/tag.d.cts.map +1 -1
- package/dist/types/api/asset/tag.d.ts.map +1 -1
- package/dist/types/api/integration.d.cts +0 -1
- package/dist/types/api/integration.d.cts.map +1 -1
- package/dist/types/api/integration.d.ts +0 -1
- package/dist/types/api/integration.d.ts.map +1 -1
- package/dist/types/api/query.d.cts +0 -1
- package/dist/types/api/query.d.cts.map +1 -1
- package/dist/types/api/query.d.ts +0 -1
- package/dist/types/api/query.d.ts.map +1 -1
- package/dist/types/api/ref.d.cts.map +1 -1
- package/dist/types/api/ref.d.ts.map +1 -1
- package/dist/types/api/release.d.cts +0 -1
- package/dist/types/api/release.d.cts.map +1 -1
- package/dist/types/api/release.d.ts +0 -1
- package/dist/types/api/release.d.ts.map +1 -1
- package/dist/types/api/repository.d.cts +0 -1
- package/dist/types/api/repository.d.cts.map +1 -1
- package/dist/types/api/repository.d.ts +0 -1
- package/dist/types/api/repository.d.ts.map +1 -1
- package/dist/types/api/tags.d.cts.map +1 -1
- package/dist/types/api/tags.d.ts.map +1 -1
- package/dist/types/migration/Asset.cjs +1 -2
- package/dist/types/migration/Asset.cjs.map +1 -1
- package/dist/types/migration/Asset.d.cts +0 -1
- package/dist/types/migration/Asset.d.cts.map +1 -1
- package/dist/types/migration/Asset.d.ts +0 -1
- package/dist/types/migration/Asset.d.ts.map +1 -1
- package/dist/types/migration/Asset.js +1 -1
- package/dist/types/migration/ContentRelationship.d.cts.map +1 -1
- package/dist/types/migration/ContentRelationship.d.ts.map +1 -1
- package/dist/types/migration/Document.cjs +1 -2
- package/dist/types/migration/Document.cjs.map +1 -1
- package/dist/types/migration/Document.d.cts +0 -1
- package/dist/types/migration/Document.d.cts.map +1 -1
- package/dist/types/migration/Document.d.ts +0 -1
- package/dist/types/migration/Document.d.ts.map +1 -1
- package/dist/types/migration/Document.js +1 -1
- package/dist/types/migration/Document.js.map +1 -1
- package/dist/types/model/boolean.d.cts +0 -1
- package/dist/types/model/boolean.d.cts.map +1 -1
- package/dist/types/model/boolean.d.ts +0 -1
- package/dist/types/model/boolean.d.ts.map +1 -1
- package/dist/types/model/color.d.cts +0 -1
- package/dist/types/model/color.d.cts.map +1 -1
- package/dist/types/model/color.d.ts +0 -1
- package/dist/types/model/color.d.ts.map +1 -1
- package/dist/types/model/contentRelationship.d.cts +0 -1
- package/dist/types/model/contentRelationship.d.cts.map +1 -1
- package/dist/types/model/contentRelationship.d.ts +0 -1
- package/dist/types/model/contentRelationship.d.ts.map +1 -1
- package/dist/types/model/customType.d.cts +0 -1
- package/dist/types/model/customType.d.cts.map +1 -1
- package/dist/types/model/customType.d.ts +0 -1
- package/dist/types/model/customType.d.ts.map +1 -1
- package/dist/types/model/date.d.cts +0 -1
- package/dist/types/model/date.d.cts.map +1 -1
- package/dist/types/model/date.d.ts +0 -1
- package/dist/types/model/date.d.ts.map +1 -1
- package/dist/types/model/embed.d.cts +0 -1
- package/dist/types/model/embed.d.cts.map +1 -1
- package/dist/types/model/embed.d.ts +0 -1
- package/dist/types/model/embed.d.ts.map +1 -1
- package/dist/types/model/geoPoint.d.cts +0 -1
- package/dist/types/model/geoPoint.d.cts.map +1 -1
- package/dist/types/model/geoPoint.d.ts +0 -1
- package/dist/types/model/geoPoint.d.ts.map +1 -1
- package/dist/types/model/group.d.cts +0 -1
- package/dist/types/model/group.d.cts.map +1 -1
- package/dist/types/model/group.d.ts +0 -1
- package/dist/types/model/group.d.ts.map +1 -1
- package/dist/types/model/image.d.cts +0 -1
- package/dist/types/model/image.d.cts.map +1 -1
- package/dist/types/model/image.d.ts +0 -1
- package/dist/types/model/image.d.ts.map +1 -1
- package/dist/types/model/integration.d.cts +0 -1
- package/dist/types/model/integration.d.cts.map +1 -1
- package/dist/types/model/integration.d.ts +0 -1
- package/dist/types/model/integration.d.ts.map +1 -1
- package/dist/types/model/keyText.d.cts +0 -1
- package/dist/types/model/keyText.d.cts.map +1 -1
- package/dist/types/model/keyText.d.ts +0 -1
- package/dist/types/model/keyText.d.ts.map +1 -1
- package/dist/types/model/link.cjs +1 -2
- package/dist/types/model/link.cjs.map +1 -1
- package/dist/types/model/link.d.cts +0 -1
- package/dist/types/model/link.d.cts.map +1 -1
- package/dist/types/model/link.d.ts +0 -1
- package/dist/types/model/link.d.ts.map +1 -1
- package/dist/types/model/link.js +1 -1
- package/dist/types/model/linkToMedia.d.cts +0 -1
- package/dist/types/model/linkToMedia.d.cts.map +1 -1
- package/dist/types/model/linkToMedia.d.ts +0 -1
- package/dist/types/model/linkToMedia.d.ts.map +1 -1
- package/dist/types/model/number.d.cts +0 -1
- package/dist/types/model/number.d.cts.map +1 -1
- package/dist/types/model/number.d.ts +0 -1
- package/dist/types/model/number.d.ts.map +1 -1
- package/dist/types/model/range.d.cts +0 -1
- package/dist/types/model/range.d.cts.map +1 -1
- package/dist/types/model/range.d.ts +0 -1
- package/dist/types/model/range.d.ts.map +1 -1
- package/dist/types/model/richText.d.cts +0 -1
- package/dist/types/model/richText.d.cts.map +1 -1
- package/dist/types/model/richText.d.ts +0 -1
- package/dist/types/model/richText.d.ts.map +1 -1
- package/dist/types/model/select.d.cts +0 -1
- package/dist/types/model/select.d.cts.map +1 -1
- package/dist/types/model/select.d.ts +0 -1
- package/dist/types/model/select.d.ts.map +1 -1
- package/dist/types/model/separator.d.cts +0 -1
- package/dist/types/model/separator.d.cts.map +1 -1
- package/dist/types/model/separator.d.ts +0 -1
- package/dist/types/model/separator.d.ts.map +1 -1
- package/dist/types/model/sharedSlice.d.cts +0 -1
- package/dist/types/model/sharedSlice.d.cts.map +1 -1
- package/dist/types/model/sharedSlice.d.ts +0 -1
- package/dist/types/model/sharedSlice.d.ts.map +1 -1
- package/dist/types/model/sharedSliceVariation.d.cts +0 -1
- package/dist/types/model/sharedSliceVariation.d.cts.map +1 -1
- package/dist/types/model/sharedSliceVariation.d.ts +0 -1
- package/dist/types/model/sharedSliceVariation.d.ts.map +1 -1
- package/dist/types/model/slice.cjs +1 -2
- package/dist/types/model/slice.cjs.map +1 -1
- package/dist/types/model/slice.d.cts +0 -1
- package/dist/types/model/slice.d.cts.map +1 -1
- package/dist/types/model/slice.d.ts +0 -1
- package/dist/types/model/slice.d.ts.map +1 -1
- package/dist/types/model/slice.js +1 -1
- package/dist/types/model/sliceZone.cjs +1 -2
- package/dist/types/model/sliceZone.cjs.map +1 -1
- package/dist/types/model/sliceZone.d.cts +0 -1
- package/dist/types/model/sliceZone.d.cts.map +1 -1
- package/dist/types/model/sliceZone.d.ts +0 -1
- package/dist/types/model/sliceZone.d.ts.map +1 -1
- package/dist/types/model/sliceZone.js +1 -1
- package/dist/types/model/table.d.cts +0 -1
- package/dist/types/model/table.d.cts.map +1 -1
- package/dist/types/model/table.d.ts +0 -1
- package/dist/types/model/table.d.ts.map +1 -1
- package/dist/types/model/timestamp.d.cts +0 -1
- package/dist/types/model/timestamp.d.cts.map +1 -1
- package/dist/types/model/timestamp.d.ts +0 -1
- package/dist/types/model/timestamp.d.ts.map +1 -1
- package/dist/types/model/title.d.cts +0 -1
- package/dist/types/model/title.d.cts.map +1 -1
- package/dist/types/model/title.d.ts +0 -1
- package/dist/types/model/title.d.ts.map +1 -1
- package/dist/types/model/types.cjs +1 -2
- package/dist/types/model/types.cjs.map +1 -1
- package/dist/types/model/types.d.cts +0 -1
- package/dist/types/model/types.d.cts.map +1 -1
- package/dist/types/model/types.d.ts +0 -1
- package/dist/types/model/types.d.ts.map +1 -1
- package/dist/types/model/types.js +1 -1
- package/dist/types/model/uid.d.cts +0 -1
- package/dist/types/model/uid.d.cts.map +1 -1
- package/dist/types/model/uid.d.ts +0 -1
- package/dist/types/model/uid.d.ts.map +1 -1
- package/dist/types/value/boolean.d.cts.map +1 -1
- package/dist/types/value/boolean.d.ts.map +1 -1
- package/dist/types/value/color.d.cts +0 -1
- package/dist/types/value/color.d.cts.map +1 -1
- package/dist/types/value/color.d.ts +0 -1
- package/dist/types/value/color.d.ts.map +1 -1
- package/dist/types/value/contentRelationship.d.cts +0 -1
- package/dist/types/value/contentRelationship.d.cts.map +1 -1
- package/dist/types/value/contentRelationship.d.ts +0 -1
- package/dist/types/value/contentRelationship.d.ts.map +1 -1
- package/dist/types/value/date.d.cts +0 -1
- package/dist/types/value/date.d.cts.map +1 -1
- package/dist/types/value/date.d.ts +0 -1
- package/dist/types/value/date.d.ts.map +1 -1
- package/dist/types/value/document.d.cts +0 -1
- package/dist/types/value/document.d.cts.map +1 -1
- package/dist/types/value/document.d.ts +0 -1
- package/dist/types/value/document.d.ts.map +1 -1
- package/dist/types/value/embed.cjs +1 -2
- package/dist/types/value/embed.cjs.map +1 -1
- package/dist/types/value/embed.d.cts +0 -1
- package/dist/types/value/embed.d.cts.map +1 -1
- package/dist/types/value/embed.d.ts +0 -1
- package/dist/types/value/embed.d.ts.map +1 -1
- package/dist/types/value/embed.js +1 -1
- package/dist/types/value/geoPoint.d.cts +0 -1
- package/dist/types/value/geoPoint.d.cts.map +1 -1
- package/dist/types/value/geoPoint.d.ts +0 -1
- package/dist/types/value/geoPoint.d.ts.map +1 -1
- package/dist/types/value/group.d.cts +0 -1
- package/dist/types/value/group.d.cts.map +1 -1
- package/dist/types/value/group.d.ts +0 -1
- package/dist/types/value/group.d.ts.map +1 -1
- package/dist/types/value/image.d.cts +0 -1
- package/dist/types/value/image.d.cts.map +1 -1
- package/dist/types/value/image.d.ts +0 -1
- package/dist/types/value/image.d.ts.map +1 -1
- package/dist/types/value/integration.d.cts +0 -1
- package/dist/types/value/integration.d.cts.map +1 -1
- package/dist/types/value/integration.d.ts +0 -1
- package/dist/types/value/integration.d.ts.map +1 -1
- package/dist/types/value/keyText.d.cts +0 -1
- package/dist/types/value/keyText.d.cts.map +1 -1
- package/dist/types/value/keyText.d.ts +0 -1
- package/dist/types/value/keyText.d.ts.map +1 -1
- package/dist/types/value/link.cjs +1 -2
- package/dist/types/value/link.cjs.map +1 -1
- package/dist/types/value/link.d.cts +0 -1
- package/dist/types/value/link.d.cts.map +1 -1
- package/dist/types/value/link.d.ts +0 -1
- package/dist/types/value/link.d.ts.map +1 -1
- package/dist/types/value/link.js +1 -1
- package/dist/types/value/linkToMedia.d.cts +0 -1
- package/dist/types/value/linkToMedia.d.cts.map +1 -1
- package/dist/types/value/linkToMedia.d.ts +0 -1
- package/dist/types/value/linkToMedia.d.ts.map +1 -1
- package/dist/types/value/number.d.cts +0 -1
- package/dist/types/value/number.d.cts.map +1 -1
- package/dist/types/value/number.d.ts +0 -1
- package/dist/types/value/number.d.ts.map +1 -1
- package/dist/types/value/richText.cjs +1 -2
- package/dist/types/value/richText.cjs.map +1 -1
- package/dist/types/value/richText.d.cts +0 -1
- package/dist/types/value/richText.d.cts.map +1 -1
- package/dist/types/value/richText.d.ts +0 -1
- package/dist/types/value/richText.d.ts.map +1 -1
- package/dist/types/value/richText.js +1 -1
- package/dist/types/value/select.d.cts +0 -1
- package/dist/types/value/select.d.cts.map +1 -1
- package/dist/types/value/select.d.ts +0 -1
- package/dist/types/value/select.d.ts.map +1 -1
- package/dist/types/value/sharedSlice.d.cts +0 -1
- package/dist/types/value/sharedSlice.d.cts.map +1 -1
- package/dist/types/value/sharedSlice.d.ts +0 -1
- package/dist/types/value/sharedSlice.d.ts.map +1 -1
- package/dist/types/value/sharedSliceVariation.d.cts +0 -1
- package/dist/types/value/sharedSliceVariation.d.cts.map +1 -1
- package/dist/types/value/sharedSliceVariation.d.ts +0 -1
- package/dist/types/value/sharedSliceVariation.d.ts.map +1 -1
- package/dist/types/value/slice.d.cts +0 -1
- package/dist/types/value/slice.d.cts.map +1 -1
- package/dist/types/value/slice.d.ts +0 -1
- package/dist/types/value/slice.d.ts.map +1 -1
- package/dist/types/value/sliceZone.d.cts +0 -1
- package/dist/types/value/sliceZone.d.cts.map +1 -1
- package/dist/types/value/sliceZone.d.ts +0 -1
- package/dist/types/value/sliceZone.d.ts.map +1 -1
- package/dist/types/value/table.d.cts +0 -1
- package/dist/types/value/table.d.cts.map +1 -1
- package/dist/types/value/table.d.ts +0 -1
- package/dist/types/value/table.d.ts.map +1 -1
- package/dist/types/value/timestamp.d.cts +0 -1
- package/dist/types/value/timestamp.d.cts.map +1 -1
- package/dist/types/value/timestamp.d.ts +0 -1
- package/dist/types/value/timestamp.d.ts.map +1 -1
- package/dist/types/value/title.d.cts +0 -1
- package/dist/types/value/title.d.cts.map +1 -1
- package/dist/types/value/title.d.ts +0 -1
- package/dist/types/value/title.d.ts.map +1 -1
- package/dist/types/value/types.d.cts +0 -1
- package/dist/types/value/types.d.cts.map +1 -1
- package/dist/types/value/types.d.ts +0 -1
- package/dist/types/value/types.d.ts.map +1 -1
- package/dist/types/webhook/apiUpdate.d.cts +0 -1
- package/dist/types/webhook/apiUpdate.d.cts.map +1 -1
- package/dist/types/webhook/apiUpdate.d.ts +0 -1
- package/dist/types/webhook/apiUpdate.d.ts.map +1 -1
- package/dist/types/webhook/testTrigger.d.cts +0 -1
- package/dist/types/webhook/testTrigger.d.cts.map +1 -1
- package/dist/types/webhook/testTrigger.d.ts +0 -1
- package/dist/types/webhook/testTrigger.d.ts.map +1 -1
- package/dist/types/webhook/types.cjs +1 -2
- package/dist/types/webhook/types.cjs.map +1 -1
- package/dist/types/webhook/types.d.cts.map +1 -1
- package/dist/types/webhook/types.d.ts.map +1 -1
- package/dist/types/webhook/types.js +1 -1
- package/package.json +12 -12
- package/src/WriteClient.ts +2 -2
- package/src/helpers/asImageWidthSrcSet.ts +1 -0
- package/src/lib/request.ts +7 -5
- package/dist/_virtual/rolldown_runtime.js +0 -13
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
//#region src/lib/isInternalURL.ts
|
|
3
2
|
/**
|
|
4
3
|
* Determines if a URL is internal or external.
|
|
@@ -12,7 +11,7 @@ const isInternalURL = (url) => {
|
|
|
12
11
|
const isSpecialLink = !isInternal && !/^https?:\/\//.test(url);
|
|
13
12
|
return isInternal && !isSpecialLink;
|
|
14
13
|
};
|
|
15
|
-
|
|
16
14
|
//#endregion
|
|
17
15
|
exports.isInternalURL = isInternalURL;
|
|
16
|
+
|
|
18
17
|
//# sourceMappingURL=isInternalURL.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isInternalURL.cjs","names":[],"sources":["../../src/lib/isInternalURL.ts"],"sourcesContent":["/**\n * Determines if a URL is internal or external.\n *\n * @param url - The URL to check if internal or external.\n *\n * @returns `true` if `url` is internal, `false` otherwise.\n */\n// TODO: This does not detect all relative URLs as internal such as `about` or `./about`. This function assumes relative URLs start with a \"/\" or \"#\"`.\nexport const isInternalURL = (url: string): boolean => {\n\tconst isInternal = /^(\\/(?!\\/)|#)/.test(url)\n\tconst isSpecialLink = !isInternal && !/^https?:\\/\\//.test(url)\n\n\treturn isInternal && !isSpecialLink\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"isInternalURL.cjs","names":[],"sources":["../../src/lib/isInternalURL.ts"],"sourcesContent":["/**\n * Determines if a URL is internal or external.\n *\n * @param url - The URL to check if internal or external.\n *\n * @returns `true` if `url` is internal, `false` otherwise.\n */\n// TODO: This does not detect all relative URLs as internal such as `about` or `./about`. This function assumes relative URLs start with a \"/\" or \"#\"`.\nexport const isInternalURL = (url: string): boolean => {\n\tconst isInternal = /^(\\/(?!\\/)|#)/.test(url)\n\tconst isSpecialLink = !isInternal && !/^https?:\\/\\//.test(url)\n\n\treturn isInternal && !isSpecialLink\n}\n"],"mappings":";;;;;;;;AAQA,MAAa,iBAAiB,QAAyB;CACtD,MAAM,aAAa,gBAAgB,KAAK,IAAI;CAC5C,MAAM,gBAAgB,CAAC,cAAc,CAAC,eAAe,KAAK,IAAI;AAE9D,QAAO,cAAc,CAAC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
const require_richText = require(
|
|
2
|
-
const require_link = require(
|
|
3
|
-
const require_Asset = require(
|
|
4
|
-
const require_Document = require(
|
|
5
|
-
const require_isValue = require(
|
|
6
|
-
|
|
1
|
+
const require_richText = require("../types/value/richText.cjs");
|
|
2
|
+
const require_link = require("../types/value/link.cjs");
|
|
3
|
+
const require_Asset = require("../types/migration/Asset.cjs");
|
|
4
|
+
const require_Document = require("../types/migration/Document.cjs");
|
|
5
|
+
const require_isValue = require("./isValue.cjs");
|
|
7
6
|
//#region src/lib/isMigrationValue.ts
|
|
8
7
|
/**
|
|
9
8
|
* Checks if a value is a migration content relationship field.
|
|
@@ -68,10 +67,10 @@ const linkToMedia = (value) => {
|
|
|
68
67
|
const rtImageNode = (value) => {
|
|
69
68
|
return typeof value === "object" && value !== null && "id" in value && value.id instanceof require_Asset.PrismicMigrationAsset && "type" in value && value.type === require_richText.RichTextNodeType.image;
|
|
70
69
|
};
|
|
71
|
-
|
|
72
70
|
//#endregion
|
|
73
71
|
exports.contentRelationship = contentRelationship;
|
|
74
72
|
exports.image = image;
|
|
75
73
|
exports.linkToMedia = linkToMedia;
|
|
76
74
|
exports.rtImageNode = rtImageNode;
|
|
75
|
+
|
|
77
76
|
//# sourceMappingURL=isMigrationValue.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isMigrationValue.cjs","names":["PrismicMigrationDocument","LinkType","PrismicMigrationAsset","RichTextNodeType"],"sources":["../../src/lib/isMigrationValue.ts"],"sourcesContent":["import type {\n\tMigrationImage,\n\tMigrationLinkToMedia,\n\tMigrationRTImageNode,\n} from \"../types/migration/Asset\"\nimport { PrismicMigrationAsset } from \"../types/migration/Asset\"\nimport type { MigrationContentRelationship } from \"../types/migration/ContentRelationship\"\nimport {\n\ttype InjectMigrationSpecificTypes,\n\tPrismicMigrationDocument,\n} from \"../types/migration/Document\"\nimport type { PrismicDocument } from \"../types/value/document\"\nimport type { GroupField } from \"../types/value/group\"\nimport { LinkType } from \"../types/value/link\"\nimport type { OptionalLinkProperties } from \"../types/value/link\"\nimport { RichTextNodeType } from \"../types/value/richText\"\nimport type { SliceZone } from \"../types/value/sliceZone\"\nimport type { AnyRegularField } from \"../types/value/types\"\n\nimport * as is from \"./isValue\"\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 migration content relationship field.\n *\n * @remarks\n * `OptionalLinkProperties` is included because `MigrationContentRelationship`\n * may be a link field, not strictly a content relationship field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a migration content relationship field, `false`\n * 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 contentRelationship = (\n\tvalue: UnknownValue,\n): value is MigrationContentRelationship & OptionalLinkProperties => {\n\treturn (\n\t\tvalue instanceof PrismicMigrationDocument ||\n\t\tis.prismicDocument(value) ||\n\t\t(typeof value === \"object\" &&\n\t\t\tvalue !== null &&\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(contentRelationship(value.id) || typeof value.id === \"function\"))\n\t)\n}\n\n/**\n * Checks if a value is a migration image field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a migration 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 image = (value: UnknownValue): value is MigrationImage => {\n\treturn (\n\t\tvalue instanceof PrismicMigrationAsset ||\n\t\t(typeof value === \"object\" &&\n\t\t\tvalue !== null &&\n\t\t\t\"id\" in value &&\n\t\t\tObject.values(value).every(\n\t\t\t\t(maybeThumbnail) => maybeThumbnail instanceof PrismicMigrationAsset,\n\t\t\t))\n\t)\n}\n\n/**\n * Checks if a value is a migration link to media field.\n *\n * - @remarks `OptionalLinkProperties` is included because\n * `MigrationContentRelationship` 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 migration link to media field, `false`\n * 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 linkToMedia = (\n\tvalue: UnknownValue,\n): value is MigrationLinkToMedia & OptionalLinkProperties => {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\t\"id\" in value &&\n\t\tvalue.id instanceof PrismicMigrationAsset &&\n\t\t\"link_type\" in value &&\n\t\tvalue.link_type === LinkType.Media\n\t)\n}\n\n/**\n * Checks if a value is a migration rich text image node.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a migration rich text image node, `false`\n * 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 = (\n\tvalue: UnknownValue,\n): value is MigrationRTImageNode => {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\t\"id\" in value &&\n\t\tvalue.id instanceof PrismicMigrationAsset &&\n\t\t\"type\" in value &&\n\t\tvalue.type === RichTextNodeType.image\n\t)\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"isMigrationValue.cjs","names":["PrismicMigrationDocument","LinkType","PrismicMigrationAsset","RichTextNodeType"],"sources":["../../src/lib/isMigrationValue.ts"],"sourcesContent":["import type {\n\tMigrationImage,\n\tMigrationLinkToMedia,\n\tMigrationRTImageNode,\n} from \"../types/migration/Asset\"\nimport { PrismicMigrationAsset } from \"../types/migration/Asset\"\nimport type { MigrationContentRelationship } from \"../types/migration/ContentRelationship\"\nimport {\n\ttype InjectMigrationSpecificTypes,\n\tPrismicMigrationDocument,\n} from \"../types/migration/Document\"\nimport type { PrismicDocument } from \"../types/value/document\"\nimport type { GroupField } from \"../types/value/group\"\nimport { LinkType } from \"../types/value/link\"\nimport type { OptionalLinkProperties } from \"../types/value/link\"\nimport { RichTextNodeType } from \"../types/value/richText\"\nimport type { SliceZone } from \"../types/value/sliceZone\"\nimport type { AnyRegularField } from \"../types/value/types\"\n\nimport * as is from \"./isValue\"\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 migration content relationship field.\n *\n * @remarks\n * `OptionalLinkProperties` is included because `MigrationContentRelationship`\n * may be a link field, not strictly a content relationship field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a migration content relationship field, `false`\n * 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 contentRelationship = (\n\tvalue: UnknownValue,\n): value is MigrationContentRelationship & OptionalLinkProperties => {\n\treturn (\n\t\tvalue instanceof PrismicMigrationDocument ||\n\t\tis.prismicDocument(value) ||\n\t\t(typeof value === \"object\" &&\n\t\t\tvalue !== null &&\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(contentRelationship(value.id) || typeof value.id === \"function\"))\n\t)\n}\n\n/**\n * Checks if a value is a migration image field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a migration 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 image = (value: UnknownValue): value is MigrationImage => {\n\treturn (\n\t\tvalue instanceof PrismicMigrationAsset ||\n\t\t(typeof value === \"object\" &&\n\t\t\tvalue !== null &&\n\t\t\t\"id\" in value &&\n\t\t\tObject.values(value).every(\n\t\t\t\t(maybeThumbnail) => maybeThumbnail instanceof PrismicMigrationAsset,\n\t\t\t))\n\t)\n}\n\n/**\n * Checks if a value is a migration link to media field.\n *\n * - @remarks `OptionalLinkProperties` is included because\n * `MigrationContentRelationship` 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 migration link to media field, `false`\n * 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 linkToMedia = (\n\tvalue: UnknownValue,\n): value is MigrationLinkToMedia & OptionalLinkProperties => {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\t\"id\" in value &&\n\t\tvalue.id instanceof PrismicMigrationAsset &&\n\t\t\"link_type\" in value &&\n\t\tvalue.link_type === LinkType.Media\n\t)\n}\n\n/**\n * Checks if a value is a migration rich text image node.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a migration rich text image node, `false`\n * 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 = (\n\tvalue: UnknownValue,\n): value is MigrationRTImageNode => {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\t\"id\" in value &&\n\t\tvalue.id instanceof PrismicMigrationAsset &&\n\t\t\"type\" in value &&\n\t\tvalue.type === RichTextNodeType.image\n\t)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA+CA,MAAa,uBACZ,UACoE;AACpE,QACC,iBAAiBA,iBAAAA,4BAAAA,gBAAAA,gBACE,MAAM,IACxB,OAAO,UAAU,YACjB,UAAU,QACV,eAAe,SACf,MAAM,cAAcC,aAAAA,SAAS,YAC7B,QAAQ,UACP,oBAAoB,MAAM,GAAG,IAAI,OAAO,MAAM,OAAO;;;;;;;;;;;;AAczD,MAAa,SAAS,UAAiD;AACtE,QACC,iBAAiBC,cAAAA,yBAChB,OAAO,UAAU,YACjB,UAAU,QACV,QAAQ,SACR,OAAO,OAAO,MAAM,CAAC,OACnB,mBAAmB,0BAA0BA,cAAAA,sBAC9C;;;;;;;;;;;;;;;;;AAmBJ,MAAa,eACZ,UAC4D;AAC5D,QACC,OAAO,UAAU,YACjB,UAAU,QACV,QAAQ,SACR,MAAM,cAAcA,cAAAA,yBACpB,eAAe,SACf,MAAM,cAAcD,aAAAA,SAAS;;;;;;;;;;;;;AAe/B,MAAa,eACZ,UACmC;AACnC,QACC,OAAO,UAAU,YACjB,UAAU,QACV,QAAQ,SACR,MAAM,cAAcC,cAAAA,yBACpB,UAAU,SACV,MAAM,SAASC,iBAAAA,iBAAiB"}
|
|
@@ -3,7 +3,6 @@ import { LinkType } from "../types/value/link.js";
|
|
|
3
3
|
import { PrismicMigrationAsset } from "../types/migration/Asset.js";
|
|
4
4
|
import { PrismicMigrationDocument } from "../types/migration/Document.js";
|
|
5
5
|
import { prismicDocument } from "./isValue.js";
|
|
6
|
-
|
|
7
6
|
//#region src/lib/isMigrationValue.ts
|
|
8
7
|
/**
|
|
9
8
|
* Checks if a value is a migration content relationship field.
|
|
@@ -68,7 +67,7 @@ const linkToMedia = (value) => {
|
|
|
68
67
|
const rtImageNode = (value) => {
|
|
69
68
|
return typeof value === "object" && value !== null && "id" in value && value.id instanceof PrismicMigrationAsset && "type" in value && value.type === RichTextNodeType.image;
|
|
70
69
|
};
|
|
71
|
-
|
|
72
70
|
//#endregion
|
|
73
71
|
export { contentRelationship, image, linkToMedia, rtImageNode };
|
|
72
|
+
|
|
74
73
|
//# sourceMappingURL=isMigrationValue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isMigrationValue.js","names":["is.prismicDocument"],"sources":["../../src/lib/isMigrationValue.ts"],"sourcesContent":["import type {\n\tMigrationImage,\n\tMigrationLinkToMedia,\n\tMigrationRTImageNode,\n} from \"../types/migration/Asset\"\nimport { PrismicMigrationAsset } from \"../types/migration/Asset\"\nimport type { MigrationContentRelationship } from \"../types/migration/ContentRelationship\"\nimport {\n\ttype InjectMigrationSpecificTypes,\n\tPrismicMigrationDocument,\n} from \"../types/migration/Document\"\nimport type { PrismicDocument } from \"../types/value/document\"\nimport type { GroupField } from \"../types/value/group\"\nimport { LinkType } from \"../types/value/link\"\nimport type { OptionalLinkProperties } from \"../types/value/link\"\nimport { RichTextNodeType } from \"../types/value/richText\"\nimport type { SliceZone } from \"../types/value/sliceZone\"\nimport type { AnyRegularField } from \"../types/value/types\"\n\nimport * as is from \"./isValue\"\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 migration content relationship field.\n *\n * @remarks\n * `OptionalLinkProperties` is included because `MigrationContentRelationship`\n * may be a link field, not strictly a content relationship field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a migration content relationship field, `false`\n * 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 contentRelationship = (\n\tvalue: UnknownValue,\n): value is MigrationContentRelationship & OptionalLinkProperties => {\n\treturn (\n\t\tvalue instanceof PrismicMigrationDocument ||\n\t\tis.prismicDocument(value) ||\n\t\t(typeof value === \"object\" &&\n\t\t\tvalue !== null &&\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(contentRelationship(value.id) || typeof value.id === \"function\"))\n\t)\n}\n\n/**\n * Checks if a value is a migration image field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a migration 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 image = (value: UnknownValue): value is MigrationImage => {\n\treturn (\n\t\tvalue instanceof PrismicMigrationAsset ||\n\t\t(typeof value === \"object\" &&\n\t\t\tvalue !== null &&\n\t\t\t\"id\" in value &&\n\t\t\tObject.values(value).every(\n\t\t\t\t(maybeThumbnail) => maybeThumbnail instanceof PrismicMigrationAsset,\n\t\t\t))\n\t)\n}\n\n/**\n * Checks if a value is a migration link to media field.\n *\n * - @remarks `OptionalLinkProperties` is included because\n * `MigrationContentRelationship` 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 migration link to media field, `false`\n * 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 linkToMedia = (\n\tvalue: UnknownValue,\n): value is MigrationLinkToMedia & OptionalLinkProperties => {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\t\"id\" in value &&\n\t\tvalue.id instanceof PrismicMigrationAsset &&\n\t\t\"link_type\" in value &&\n\t\tvalue.link_type === LinkType.Media\n\t)\n}\n\n/**\n * Checks if a value is a migration rich text image node.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a migration rich text image node, `false`\n * 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 = (\n\tvalue: UnknownValue,\n): value is MigrationRTImageNode => {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\t\"id\" in value &&\n\t\tvalue.id instanceof PrismicMigrationAsset &&\n\t\t\"type\" in value &&\n\t\tvalue.type === RichTextNodeType.image\n\t)\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"isMigrationValue.js","names":["is.prismicDocument"],"sources":["../../src/lib/isMigrationValue.ts"],"sourcesContent":["import type {\n\tMigrationImage,\n\tMigrationLinkToMedia,\n\tMigrationRTImageNode,\n} from \"../types/migration/Asset\"\nimport { PrismicMigrationAsset } from \"../types/migration/Asset\"\nimport type { MigrationContentRelationship } from \"../types/migration/ContentRelationship\"\nimport {\n\ttype InjectMigrationSpecificTypes,\n\tPrismicMigrationDocument,\n} from \"../types/migration/Document\"\nimport type { PrismicDocument } from \"../types/value/document\"\nimport type { GroupField } from \"../types/value/group\"\nimport { LinkType } from \"../types/value/link\"\nimport type { OptionalLinkProperties } from \"../types/value/link\"\nimport { RichTextNodeType } from \"../types/value/richText\"\nimport type { SliceZone } from \"../types/value/sliceZone\"\nimport type { AnyRegularField } from \"../types/value/types\"\n\nimport * as is from \"./isValue\"\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 migration content relationship field.\n *\n * @remarks\n * `OptionalLinkProperties` is included because `MigrationContentRelationship`\n * may be a link field, not strictly a content relationship field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a migration content relationship field, `false`\n * 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 contentRelationship = (\n\tvalue: UnknownValue,\n): value is MigrationContentRelationship & OptionalLinkProperties => {\n\treturn (\n\t\tvalue instanceof PrismicMigrationDocument ||\n\t\tis.prismicDocument(value) ||\n\t\t(typeof value === \"object\" &&\n\t\t\tvalue !== null &&\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(contentRelationship(value.id) || typeof value.id === \"function\"))\n\t)\n}\n\n/**\n * Checks if a value is a migration image field.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a migration 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 image = (value: UnknownValue): value is MigrationImage => {\n\treturn (\n\t\tvalue instanceof PrismicMigrationAsset ||\n\t\t(typeof value === \"object\" &&\n\t\t\tvalue !== null &&\n\t\t\t\"id\" in value &&\n\t\t\tObject.values(value).every(\n\t\t\t\t(maybeThumbnail) => maybeThumbnail instanceof PrismicMigrationAsset,\n\t\t\t))\n\t)\n}\n\n/**\n * Checks if a value is a migration link to media field.\n *\n * - @remarks `OptionalLinkProperties` is included because\n * `MigrationContentRelationship` 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 migration link to media field, `false`\n * 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 linkToMedia = (\n\tvalue: UnknownValue,\n): value is MigrationLinkToMedia & OptionalLinkProperties => {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\t\"id\" in value &&\n\t\tvalue.id instanceof PrismicMigrationAsset &&\n\t\t\"link_type\" in value &&\n\t\tvalue.link_type === LinkType.Media\n\t)\n}\n\n/**\n * Checks if a value is a migration rich text image node.\n *\n * @param value - Value to check.\n *\n * @returns `true` if `value` is a migration rich text image node, `false`\n * 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 = (\n\tvalue: UnknownValue,\n): value is MigrationRTImageNode => {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\t\"id\" in value &&\n\t\tvalue.id instanceof PrismicMigrationAsset &&\n\t\t\"type\" in value &&\n\t\tvalue.type === RichTextNodeType.image\n\t)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA+CA,MAAa,uBACZ,UACoE;AACpE,QACC,iBAAiB,4BACjBA,gBAAmB,MAAM,IACxB,OAAO,UAAU,YACjB,UAAU,QACV,eAAe,SACf,MAAM,cAAc,SAAS,YAC7B,QAAQ,UACP,oBAAoB,MAAM,GAAG,IAAI,OAAO,MAAM,OAAO;;;;;;;;;;;;AAczD,MAAa,SAAS,UAAiD;AACtE,QACC,iBAAiB,yBAChB,OAAO,UAAU,YACjB,UAAU,QACV,QAAQ,SACR,OAAO,OAAO,MAAM,CAAC,OACnB,mBAAmB,0BAA0B,sBAC9C;;;;;;;;;;;;;;;;;AAmBJ,MAAa,eACZ,UAC4D;AAC5D,QACC,OAAO,UAAU,YACjB,UAAU,QACV,QAAQ,SACR,MAAM,cAAc,yBACpB,eAAe,SACf,MAAM,cAAc,SAAS;;;;;;;;;;;;;AAe/B,MAAa,eACZ,UACmC;AACnC,QACC,OAAO,UAAU,YACjB,UAAU,QACV,QAAQ,SACR,MAAM,cAAc,yBACpB,UAAU,SACV,MAAM,SAAS,iBAAiB"}
|
package/dist/lib/isValue.cjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
const require_richText = require(
|
|
2
|
-
const require_link = require(
|
|
3
|
-
|
|
1
|
+
const require_richText = require("../types/value/richText.cjs");
|
|
2
|
+
const require_link = require("../types/value/link.cjs");
|
|
4
3
|
//#region src/lib/isValue.ts
|
|
5
4
|
/**
|
|
6
5
|
* Checks if a value is a link to media field.
|
|
@@ -100,11 +99,11 @@ const prismicDocument = (value) => {
|
|
|
100
99
|
return false;
|
|
101
100
|
}
|
|
102
101
|
};
|
|
103
|
-
|
|
104
102
|
//#endregion
|
|
105
103
|
exports.filledContentRelationship = filledContentRelationship;
|
|
106
104
|
exports.filledImage = filledImage;
|
|
107
105
|
exports.filledLinkToMedia = filledLinkToMedia;
|
|
108
106
|
exports.prismicDocument = prismicDocument;
|
|
109
107
|
exports.rtImageNode = rtImageNode;
|
|
108
|
+
|
|
110
109
|
//# sourceMappingURL=isValue.cjs.map
|
package/dist/lib/isValue.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isValue.cjs","names":["LinkType","RichTextNodeType"],"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\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\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\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"],"mappings":"
|
|
1
|
+
{"version":3,"file":"isValue.cjs","names":["LinkType","RichTextNodeType"],"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\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\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\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"],"mappings":";;;;;;;;;;;;;AAiCA,MAAa,qBACZ,UACqC;AACrC,KAAI,SAAS,OAAO,UAAU,YAAY,EAAE,aAAa;MAEvD,eAAe,SACf,MAAM,cAAcA,aAAAA,SAAS,SAC7B,QAAQ,SACR,UAAU,SACV,UAAU,SACV,SAAS,SACT,UAAU,MAEV,QAAO;;AAIT,QAAO;;;;;;;;;;;;AAaR,MAAM,aACL,UACyD;AACzD,KACC,SACA,OAAO,UAAU,aAChB,EAAE,aAAa,UAAU,OAAO,MAAM,YAAY;MAGlD,QAAQ,SACR,SAAS,SACT,OAAO,MAAM,QAAQ,YACrB,gBAAgB,SAChB,UAAU,SACV,SAAS,SACT,eAAe,MAEf,QAAO;;AAIT,QAAO;;;;;;;;;;;;AAaR,MAAa,eACZ,UAC2C;AAC3C,KACC,UAAU,MAAM,KACf,EAAE,UAAU,UAAU,MAAM,SAASC,iBAAAA,iBAAiB,OAEvD,QAAO;AAGR,QAAO;;;;;;;;;;;;AAaR,MAAa,eAAe,UAA8C;AACzE,KACC,UAAU,MAAM,IAChB,UAAU,SACV,MAAM,SAASA,iBAAAA,iBAAiB,MAEhC,QAAO;AAGR,QAAO;;;;;;;;;;;;;;;;;AAkBR,MAAa,6BACZ,UACsE;AACtE,KAAI,SAAS,OAAO,UAAU,YAAY,EAAE,aAAa;MAEvD,eAAe,SACf,MAAM,cAAcD,aAAAA,SAAS,YAC7B,QAAQ,SACR,UAAU,SACV,UAAU,SACV,UAAU,MAEV,QAAO;;AAIT,QAAO;;;;;;;;;;;;AAaR,MAAa,mBACZ,UAC8B;AAC9B,KAAI;AACH,SACC,OAAO,UAAU,YACjB,UAAU,QACV,QAAQ,SACR,UAAU,SACV,OAAO,MAAM,SAAS,YACtB,IAAI,IAAI,MAAM,KAAK,IACnB,UAAU,SACV,UAAU,SACV,UAAU,SACV,MAAM,QAAQ,MAAM,KAAK;SAEnB;AACP,SAAO"}
|
package/dist/lib/isValue.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { RichTextNodeType } from "../types/value/richText.js";
|
|
2
2
|
import { LinkType } from "../types/value/link.js";
|
|
3
|
-
|
|
4
3
|
//#region src/lib/isValue.ts
|
|
5
4
|
/**
|
|
6
5
|
* Checks if a value is a link to media field.
|
|
@@ -100,7 +99,7 @@ const prismicDocument = (value) => {
|
|
|
100
99
|
return false;
|
|
101
100
|
}
|
|
102
101
|
};
|
|
103
|
-
|
|
104
102
|
//#endregion
|
|
105
103
|
export { filledContentRelationship, filledImage, filledLinkToMedia, prismicDocument, rtImageNode };
|
|
104
|
+
|
|
106
105
|
//# sourceMappingURL=isValue.js.map
|
package/dist/lib/isValue.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isValue.js","names":[],"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\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\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\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"],"mappings":"
|
|
1
|
+
{"version":3,"file":"isValue.js","names":[],"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\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\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\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"],"mappings":";;;;;;;;;;;;;AAiCA,MAAa,qBACZ,UACqC;AACrC,KAAI,SAAS,OAAO,UAAU,YAAY,EAAE,aAAa;MAEvD,eAAe,SACf,MAAM,cAAc,SAAS,SAC7B,QAAQ,SACR,UAAU,SACV,UAAU,SACV,SAAS,SACT,UAAU,MAEV,QAAO;;AAIT,QAAO;;;;;;;;;;;;AAaR,MAAM,aACL,UACyD;AACzD,KACC,SACA,OAAO,UAAU,aAChB,EAAE,aAAa,UAAU,OAAO,MAAM,YAAY;MAGlD,QAAQ,SACR,SAAS,SACT,OAAO,MAAM,QAAQ,YACrB,gBAAgB,SAChB,UAAU,SACV,SAAS,SACT,eAAe,MAEf,QAAO;;AAIT,QAAO;;;;;;;;;;;;AAaR,MAAa,eACZ,UAC2C;AAC3C,KACC,UAAU,MAAM,KACf,EAAE,UAAU,UAAU,MAAM,SAAS,iBAAiB,OAEvD,QAAO;AAGR,QAAO;;;;;;;;;;;;AAaR,MAAa,eAAe,UAA8C;AACzE,KACC,UAAU,MAAM,IAChB,UAAU,SACV,MAAM,SAAS,iBAAiB,MAEhC,QAAO;AAGR,QAAO;;;;;;;;;;;;;;;;;AAkBR,MAAa,6BACZ,UACsE;AACtE,KAAI,SAAS,OAAO,UAAU,YAAY,EAAE,aAAa;MAEvD,eAAe,SACf,MAAM,cAAc,SAAS,YAC7B,QAAQ,SACR,UAAU,SACV,UAAU,SACV,UAAU,MAEV,QAAO;;AAIT,QAAO;;;;;;;;;;;;AAaR,MAAa,mBACZ,UAC8B;AAC9B,KAAI;AACH,SACC,OAAO,UAAU,YACjB,UAAU,QACV,QAAQ,SACR,UAAU,SACV,OAAO,MAAM,SAAS,YACtB,IAAI,IAAI,MAAM,KAAK,IACnB,UAAU,SACV,UAAU,SACV,UAAU,SACV,MAAM,QAAQ,MAAM,KAAK;SAEnB;AACP,SAAO"}
|
package/dist/lib/pLimit.cjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
//#region src/lib/pLimit.ts
|
|
3
2
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
4
3
|
/**
|
|
@@ -49,7 +48,7 @@ const pLimit = ({ interval } = {}) => {
|
|
|
49
48
|
enqueue(function_, resolve, arguments_);
|
|
50
49
|
}));
|
|
51
50
|
};
|
|
52
|
-
|
|
53
51
|
//#endregion
|
|
54
52
|
exports.pLimit = pLimit;
|
|
53
|
+
|
|
55
54
|
//# sourceMappingURL=pLimit.cjs.map
|
package/dist/lib/pLimit.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pLimit.cjs","names":[
|
|
1
|
+
{"version":3,"file":"pLimit.cjs","names":[],"sources":["../../src/lib/pLimit.ts"],"sourcesContent":["/*\n ** Core logic from https://github.com/sindresorhus/p-limit\n ** Many thanks to @sindresorhus\n */\n\n// oxlint-disable-next-line 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"],"mappings":";AAQA,MAAM,SAAS,OAAe,IAAI,SAAS,YAAY,WAAW,SAAS,GAAG,CAAC;;;;;;;;;;AA2B/E,MAAa,UAAU,EACtB,aAC0B,EAAE,KAAoB;CAChD,MAAM,QAAuB,EAAE;CAC/B,IAAI,OAAO;CACX,IAAI,iBAAiB;CAErB,MAAM,mBAAmB;AACxB,MAAI,CAAC,QAAQ,MAAM,SAAS,GAAG;;AAC9B,IAAA,eAAA,MAAM,OAAO,MAAA,QAAA,iBAAA,KAAA,KAAA,cAAI;AACjB,UAAO;;;CAIT,MAAM,aAAa;AAClB,SAAO;AAEP,cAAY;;CAGb,MAAM,MAAM,OACX,WACA,SACA,eACI;EACJ,MAAM,0BAA0B,KAAK,KAAK,GAAG;AAE7C,MAAI,YAAY,0BAA0B,SACzC,OAAM,MAAM,WAAW,wBAAwB;EAEhD,MAAM,UAAU,YAAY,UAAU,GAAG,WAAW,GAAG;AAEvD,UAAQ,OAAO;AAEf,MAAI;AACH,SAAM;UACC;AAER,mBAAiB,KAAK,KAAK;AAE3B,QAAM;;CAGP,MAAM,WACL,WACA,SACA,eACI;AAGJ,MAAI,SAAS,oBAAoB;AAChC,SAAM,KAAK,gBAAgB;IAC1B,CAAC,KAAK,IAAI,KAAK,KAAA,GAAW,WAAW,SAAS,WAAW,CAAC;AAC3D,GAAC,YAAY;AAKb,SAAM,QAAQ,SAAS;AAEvB,OAAI,CAAC,KACJ,aAAY;MAEV;;AAGL,UAAS,WAAwB,GAAG,eACnC,IAAI,SAAkB,YAAY;AACjC,UAAQ,WAAW,SAAS,WAAW;GACtC"}
|
package/dist/lib/pLimit.js
CHANGED
package/dist/lib/pLimit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pLimit.js","names":[
|
|
1
|
+
{"version":3,"file":"pLimit.js","names":[],"sources":["../../src/lib/pLimit.ts"],"sourcesContent":["/*\n ** Core logic from https://github.com/sindresorhus/p-limit\n ** Many thanks to @sindresorhus\n */\n\n// oxlint-disable-next-line 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"],"mappings":";AAQA,MAAM,SAAS,OAAe,IAAI,SAAS,YAAY,WAAW,SAAS,GAAG,CAAC;;;;;;;;;;AA2B/E,MAAa,UAAU,EACtB,aAC0B,EAAE,KAAoB;CAChD,MAAM,QAAuB,EAAE;CAC/B,IAAI,OAAO;CACX,IAAI,iBAAiB;CAErB,MAAM,mBAAmB;AACxB,MAAI,CAAC,QAAQ,MAAM,SAAS,GAAG;;AAC9B,IAAA,eAAA,MAAM,OAAO,MAAA,QAAA,iBAAA,KAAA,KAAA,cAAI;AACjB,UAAO;;;CAIT,MAAM,aAAa;AAClB,SAAO;AAEP,cAAY;;CAGb,MAAM,MAAM,OACX,WACA,SACA,eACI;EACJ,MAAM,0BAA0B,KAAK,KAAK,GAAG;AAE7C,MAAI,YAAY,0BAA0B,SACzC,OAAM,MAAM,WAAW,wBAAwB;EAEhD,MAAM,UAAU,YAAY,UAAU,GAAG,WAAW,GAAG;AAEvD,UAAQ,OAAO;AAEf,MAAI;AACH,SAAM;UACC;AAER,mBAAiB,KAAK,KAAK;AAE3B,QAAM;;CAGP,MAAM,WACL,WACA,SACA,eACI;AAGJ,MAAI,SAAS,oBAAoB;AAChC,SAAM,KAAK,gBAAgB;IAC1B,CAAC,KAAK,IAAI,KAAK,KAAA,GAAW,WAAW,SAAS,WAAW,CAAC;AAC3D,GAAC,YAAY;AAKb,SAAM,QAAQ,SAAS;AAEvB,OAAI,CAAC,KACJ,aAAY;MAEV;;AAGL,UAAS,WAAwB,GAAG,eACnC,IAAI,SAAkB,YAAY;AACjC,UAAQ,WAAW,SAAS,WAAW;GACtC"}
|
package/dist/lib/request.cjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
const require_pLimit = require(
|
|
2
|
-
|
|
1
|
+
const require_pLimit = require("./pLimit.cjs");
|
|
3
2
|
//#region src/lib/request.ts
|
|
4
3
|
/**
|
|
5
4
|
* The default number of milliseconds to wait before retrying a rate-limited
|
|
@@ -17,15 +16,16 @@ const THROTTLED_RUNNERS = {};
|
|
|
17
16
|
*/
|
|
18
17
|
const DEDUPLICATED_JOBS = {};
|
|
19
18
|
async function memoizeResponse(response) {
|
|
20
|
-
const
|
|
19
|
+
const buffer = await response.arrayBuffer();
|
|
21
20
|
const memoized = {
|
|
22
21
|
ok: response.ok,
|
|
23
22
|
status: response.status,
|
|
24
23
|
headers: response.headers,
|
|
25
24
|
url: response.url,
|
|
26
|
-
text: async () =>
|
|
27
|
-
json: async () => JSON.parse(
|
|
28
|
-
|
|
25
|
+
text: async () => new TextDecoder().decode(buffer),
|
|
26
|
+
json: async () => JSON.parse(new TextDecoder().decode(buffer)),
|
|
27
|
+
arrayBuffer: async () => buffer,
|
|
28
|
+
blob: async () => new Blob([buffer]),
|
|
29
29
|
clone: () => memoized
|
|
30
30
|
};
|
|
31
31
|
return memoized;
|
|
@@ -45,7 +45,7 @@ async function request(url, init, fetchFn) {
|
|
|
45
45
|
let job;
|
|
46
46
|
if (init === null || init === void 0 ? void 0 : init.body) {
|
|
47
47
|
var _url$hostname;
|
|
48
|
-
job = (THROTTLED_RUNNERS[_url$hostname = url.hostname] || (THROTTLED_RUNNERS[_url$hostname] = require_pLimit.pLimit({ interval:
|
|
48
|
+
job = (THROTTLED_RUNNERS[_url$hostname = url.hostname] || (THROTTLED_RUNNERS[_url$hostname] = require_pLimit.pLimit({ interval: 1500 })))(() => fetchFn(stringURL, init));
|
|
49
49
|
} else {
|
|
50
50
|
var _DEDUPLICATED_JOBS$st;
|
|
51
51
|
const existingJob = (_DEDUPLICATED_JOBS$st = DEDUPLICATED_JOBS[stringURL]) === null || _DEDUPLICATED_JOBS$st === void 0 ? void 0 : _DEDUPLICATED_JOBS$st.get(init === null || init === void 0 ? void 0 : init.signal);
|
|
@@ -68,7 +68,7 @@ async function request(url, init, fetchFn) {
|
|
|
68
68
|
}
|
|
69
69
|
return response;
|
|
70
70
|
}
|
|
71
|
-
|
|
72
71
|
//#endregion
|
|
73
72
|
exports.request = request;
|
|
73
|
+
|
|
74
74
|
//# sourceMappingURL=request.cjs.map
|
package/dist/lib/request.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.cjs","names":["
|
|
1
|
+
{"version":3,"file":"request.cjs","names":["pLimit"],"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// oxlint-disable-next-line 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// oxlint-disable-next-line 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// oxlint-disable-next-line no-explicit-any\n\tjson(): Promise<any>\n\ttext(): Promise<string>\n\tarrayBuffer(): Promise<ArrayBuffer>\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\nasync function memoizeResponse(response: ResponseLike): Promise<ResponseLike> {\n\t// Deduplicated responses are shared across multiple callers. Calling\n\t// response.clone() on a shared response can cause backpressure hangs\n\t// in Node.js, so we buffer the body as an ArrayBuffer upfront instead.\n\tconst buffer = await response.arrayBuffer()\n\n\tconst memoized: ResponseLike = {\n\t\tok: response.ok,\n\t\tstatus: response.status,\n\t\theaders: response.headers,\n\t\turl: response.url,\n\t\ttext: async () => new TextDecoder().decode(buffer),\n\t\tjson: async () => JSON.parse(new TextDecoder().decode(buffer)),\n\t\tarrayBuffer: async () => buffer,\n\t\tblob: async () => new Blob([buffer]),\n\t\tclone: () => memoized,\n\t}\n\n\treturn memoized\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)\n\t\t\t\t.then(memoizeResponse)\n\t\t\t\t.finally(() => {\n\t\t\t\t\tDEDUPLICATED_JOBS[stringURL]?.delete(init?.signal)\n\t\t\t\t\tif (DEDUPLICATED_JOBS[stringURL]?.size === 0) {\n\t\t\t\t\t\tdelete DEDUPLICATED_JOBS[stringURL]\n\t\t\t\t\t}\n\t\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\n}\n"],"mappings":";;;;;;;AAOA,MAAa,sBAAsB;;;;AAKnC,MAAM,oBAA4D,EAAE;;;;;AAMpE,MAAM,oBAEF,EAAE;AAuFN,eAAe,gBAAgB,UAA+C;CAI7E,MAAM,SAAS,MAAM,SAAS,aAAa;CAE3C,MAAM,WAAyB;EAC9B,IAAI,SAAS;EACb,QAAQ,SAAS;EACjB,SAAS,SAAS;EAClB,KAAK,SAAS;EACd,MAAM,YAAY,IAAI,aAAa,CAAC,OAAO,OAAO;EAClD,MAAM,YAAY,KAAK,MAAM,IAAI,aAAa,CAAC,OAAO,OAAO,CAAC;EAC9D,aAAa,YAAY;EACzB,MAAM,YAAY,IAAI,KAAK,CAAC,OAAO,CAAC;EACpC,aAAa;EACb;AAED,QAAO;;;;;;;;;;;;AAaR,eAAsB,QACrB,KACA,MACA,SACwB;CACxB,MAAM,YAAY,IAAI,UAAU;CAEhC,IAAI;AAGJ,KAAA,SAAA,QAAA,SAAA,KAAA,IAAA,KAAA,IAAI,KAAM,MAAM;;AAMf,SAJgB,kBAAA,gBAAkB,IAAI,cAAtB,kBAAA,iBAAoCA,eAAAA,OAAO,EAC1D,UAAA,MACA,CAAC,SAEiB,QAAQ,WAAW,KAAK,CAAC;QACtC;;EAEN,MAAM,eAAA,wBAAc,kBAAkB,gBAAA,QAAA,0BAAA,KAAA,IAAA,KAAA,IAAA,sBAAY,IAAA,SAAA,QAAA,SAAA,KAAA,IAAA,KAAA,IAAI,KAAM,OAAO;AACnE,MAAI,YACH,OAAM;OACA;AACN,SAAM,QAAQ,WAAW,KAAK,CAC5B,KAAK,gBAAgB,CACrB,cAAc;;AACd,KAAA,yBAAA,kBAAkB,gBAAA,QAAA,2BAAA,KAAA,KAAA,uBAAY,OAAA,SAAA,QAAA,SAAA,KAAA,IAAA,KAAA,IAAO,KAAM,OAAO;AAClD,UAAA,yBAAI,kBAAkB,gBAAA,QAAA,2BAAA,KAAA,IAAA,KAAA,IAAA,uBAAY,UAAS,EAC1C,QAAO,kBAAkB;KAEzB;AAEH,IADa,kBAAkB,eAAlB,kBAAkB,6BAAe,IAAI,KAAK,GACnD,IAAA,SAAA,QAAA,SAAA,KAAA,IAAA,KAAA,IAAI,KAAM,QAAQ,IAAI;;;CAI5B,MAAM,WAAW,MAAM;AAGvB,KAAI,SAAS,WAAW,KAAK;EAC5B,MAAM,aAAa,OAAO,SAAS,QAAQ,IAAI,cAAc,CAAC;EAC9D,MAAM,qBAAqB,OAAO,MAAM,WAAW,GAChD,sBACA,aAAa;AAEhB,QAAM,IAAI,SAAS,YAAY,WAAW,SAAS,mBAAmB,CAAC;AAEvE,SAAO,QAAQ,KAAK,MAAM,QAAQ;;AAGnC,QAAO"}
|
package/dist/lib/request.d.cts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
//#region src/lib/request.d.ts
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* A universal API to make network requests. A subset of the `fetch()` API.
|
|
5
4
|
*
|
|
@@ -47,6 +46,7 @@ interface ResponseLike {
|
|
|
47
46
|
url: string;
|
|
48
47
|
json(): Promise<any>;
|
|
49
48
|
text(): Promise<string>;
|
|
49
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
50
50
|
blob(): Promise<Blob>;
|
|
51
51
|
clone(): ResponseLike;
|
|
52
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.cts","names":[],"sources":["../../src/lib/request.ts"],"
|
|
1
|
+
{"version":3,"file":"request.d.cts","names":[],"sources":["../../src/lib/request.ts"],"mappings":";;;;;;KA2BY,SAAA,IACX,KAAA,UACA,IAAA,GAAO,eAAA,KACH,OAAA,CAAQ,YAAA;;;;;AAab;;KAAY,eAAA;;;AAUZ;UAAiB,eAAA,SAAwB,IAAA,CAAK,WAAA;;;;EAI7C,MAAA;EAwBS;;;EAhBT,IAAA,SAAa,QAAA;EAZ2B;;;EAiBxC,OAAA,GAAU,MAAA;EALG;;;;;;EAgBb,MAAA,GAAS,eAAA;AAAA;;;;UAMO,YAAA;EAChB,EAAA;EACA,MAAA;EACA,OAAA,EAAS,WAAA;EACT,GAAA;EAEA,IAAA,IAAQ,OAAA;EACR,IAAA,IAAQ,OAAA;EACR,WAAA,IAAe,OAAA,CAAQ,WAAA;EACvB,IAAA,IAAQ,OAAA,CAAQ,IAAA;EAChB,KAAA,IAAS,YAAA;AAAA;;;;UAMO,WAAA;EAChB,GAAA,CAAI,IAAA;AAAA"}
|
package/dist/lib/request.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
//#region src/lib/request.d.ts
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* A universal API to make network requests. A subset of the `fetch()` API.
|
|
5
4
|
*
|
|
@@ -47,6 +46,7 @@ interface ResponseLike {
|
|
|
47
46
|
url: string;
|
|
48
47
|
json(): Promise<any>;
|
|
49
48
|
text(): Promise<string>;
|
|
49
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
50
50
|
blob(): Promise<Blob>;
|
|
51
51
|
clone(): ResponseLike;
|
|
52
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.ts","names":[],"sources":["../../src/lib/request.ts"],"
|
|
1
|
+
{"version":3,"file":"request.d.ts","names":[],"sources":["../../src/lib/request.ts"],"mappings":";;;;;;KA2BY,SAAA,IACX,KAAA,UACA,IAAA,GAAO,eAAA,KACH,OAAA,CAAQ,YAAA;;;;;AAab;;KAAY,eAAA;;;AAUZ;UAAiB,eAAA,SAAwB,IAAA,CAAK,WAAA;;;;EAI7C,MAAA;EAwBS;;;EAhBT,IAAA,SAAa,QAAA;EAZ2B;;;EAiBxC,OAAA,GAAU,MAAA;EALG;;;;;;EAgBb,MAAA,GAAS,eAAA;AAAA;;;;UAMO,YAAA;EAChB,EAAA;EACA,MAAA;EACA,OAAA,EAAS,WAAA;EACT,GAAA;EAEA,IAAA,IAAQ,OAAA;EACR,IAAA,IAAQ,OAAA;EACR,WAAA,IAAe,OAAA,CAAQ,WAAA;EACvB,IAAA,IAAQ,OAAA,CAAQ,IAAA;EAChB,KAAA,IAAS,YAAA;AAAA;;;;UAMO,WAAA;EAChB,GAAA,CAAI,IAAA;AAAA"}
|
package/dist/lib/request.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { pLimit } from "./pLimit.js";
|
|
2
|
-
|
|
3
2
|
//#region src/lib/request.ts
|
|
4
3
|
/**
|
|
5
4
|
* The default number of milliseconds to wait before retrying a rate-limited
|
|
@@ -17,15 +16,16 @@ const THROTTLED_RUNNERS = {};
|
|
|
17
16
|
*/
|
|
18
17
|
const DEDUPLICATED_JOBS = {};
|
|
19
18
|
async function memoizeResponse(response) {
|
|
20
|
-
const
|
|
19
|
+
const buffer = await response.arrayBuffer();
|
|
21
20
|
const memoized = {
|
|
22
21
|
ok: response.ok,
|
|
23
22
|
status: response.status,
|
|
24
23
|
headers: response.headers,
|
|
25
24
|
url: response.url,
|
|
26
|
-
text: async () =>
|
|
27
|
-
json: async () => JSON.parse(
|
|
28
|
-
|
|
25
|
+
text: async () => new TextDecoder().decode(buffer),
|
|
26
|
+
json: async () => JSON.parse(new TextDecoder().decode(buffer)),
|
|
27
|
+
arrayBuffer: async () => buffer,
|
|
28
|
+
blob: async () => new Blob([buffer]),
|
|
29
29
|
clone: () => memoized
|
|
30
30
|
};
|
|
31
31
|
return memoized;
|
|
@@ -45,7 +45,7 @@ async function request(url, init, fetchFn) {
|
|
|
45
45
|
let job;
|
|
46
46
|
if (init === null || init === void 0 ? void 0 : init.body) {
|
|
47
47
|
var _url$hostname;
|
|
48
|
-
job = (THROTTLED_RUNNERS[_url$hostname = url.hostname] || (THROTTLED_RUNNERS[_url$hostname] = pLimit({ interval:
|
|
48
|
+
job = (THROTTLED_RUNNERS[_url$hostname = url.hostname] || (THROTTLED_RUNNERS[_url$hostname] = pLimit({ interval: 1500 })))(() => fetchFn(stringURL, init));
|
|
49
49
|
} else {
|
|
50
50
|
var _DEDUPLICATED_JOBS$st;
|
|
51
51
|
const existingJob = (_DEDUPLICATED_JOBS$st = DEDUPLICATED_JOBS[stringURL]) === null || _DEDUPLICATED_JOBS$st === void 0 ? void 0 : _DEDUPLICATED_JOBS$st.get(init === null || init === void 0 ? void 0 : init.signal);
|
|
@@ -68,7 +68,7 @@ async function request(url, init, fetchFn) {
|
|
|
68
68
|
}
|
|
69
69
|
return response;
|
|
70
70
|
}
|
|
71
|
-
|
|
72
71
|
//#endregion
|
|
73
72
|
export { request };
|
|
73
|
+
|
|
74
74
|
//# sourceMappingURL=request.js.map
|
package/dist/lib/request.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.js","names":[
|
|
1
|
+
{"version":3,"file":"request.js","names":[],"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// oxlint-disable-next-line 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// oxlint-disable-next-line 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// oxlint-disable-next-line no-explicit-any\n\tjson(): Promise<any>\n\ttext(): Promise<string>\n\tarrayBuffer(): Promise<ArrayBuffer>\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\nasync function memoizeResponse(response: ResponseLike): Promise<ResponseLike> {\n\t// Deduplicated responses are shared across multiple callers. Calling\n\t// response.clone() on a shared response can cause backpressure hangs\n\t// in Node.js, so we buffer the body as an ArrayBuffer upfront instead.\n\tconst buffer = await response.arrayBuffer()\n\n\tconst memoized: ResponseLike = {\n\t\tok: response.ok,\n\t\tstatus: response.status,\n\t\theaders: response.headers,\n\t\turl: response.url,\n\t\ttext: async () => new TextDecoder().decode(buffer),\n\t\tjson: async () => JSON.parse(new TextDecoder().decode(buffer)),\n\t\tarrayBuffer: async () => buffer,\n\t\tblob: async () => new Blob([buffer]),\n\t\tclone: () => memoized,\n\t}\n\n\treturn memoized\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)\n\t\t\t\t.then(memoizeResponse)\n\t\t\t\t.finally(() => {\n\t\t\t\t\tDEDUPLICATED_JOBS[stringURL]?.delete(init?.signal)\n\t\t\t\t\tif (DEDUPLICATED_JOBS[stringURL]?.size === 0) {\n\t\t\t\t\t\tdelete DEDUPLICATED_JOBS[stringURL]\n\t\t\t\t\t}\n\t\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\n}\n"],"mappings":";;;;;;;AAOA,MAAa,sBAAsB;;;;AAKnC,MAAM,oBAA4D,EAAE;;;;;AAMpE,MAAM,oBAEF,EAAE;AAuFN,eAAe,gBAAgB,UAA+C;CAI7E,MAAM,SAAS,MAAM,SAAS,aAAa;CAE3C,MAAM,WAAyB;EAC9B,IAAI,SAAS;EACb,QAAQ,SAAS;EACjB,SAAS,SAAS;EAClB,KAAK,SAAS;EACd,MAAM,YAAY,IAAI,aAAa,CAAC,OAAO,OAAO;EAClD,MAAM,YAAY,KAAK,MAAM,IAAI,aAAa,CAAC,OAAO,OAAO,CAAC;EAC9D,aAAa,YAAY;EACzB,MAAM,YAAY,IAAI,KAAK,CAAC,OAAO,CAAC;EACpC,aAAa;EACb;AAED,QAAO;;;;;;;;;;;;AAaR,eAAsB,QACrB,KACA,MACA,SACwB;CACxB,MAAM,YAAY,IAAI,UAAU;CAEhC,IAAI;AAGJ,KAAA,SAAA,QAAA,SAAA,KAAA,IAAA,KAAA,IAAI,KAAM,MAAM;;AAMf,SAJgB,kBAAA,gBAAkB,IAAI,cAAtB,kBAAA,iBAAoC,OAAO,EAC1D,UAAA,MACA,CAAC,SAEiB,QAAQ,WAAW,KAAK,CAAC;QACtC;;EAEN,MAAM,eAAA,wBAAc,kBAAkB,gBAAA,QAAA,0BAAA,KAAA,IAAA,KAAA,IAAA,sBAAY,IAAA,SAAA,QAAA,SAAA,KAAA,IAAA,KAAA,IAAI,KAAM,OAAO;AACnE,MAAI,YACH,OAAM;OACA;AACN,SAAM,QAAQ,WAAW,KAAK,CAC5B,KAAK,gBAAgB,CACrB,cAAc;;AACd,KAAA,yBAAA,kBAAkB,gBAAA,QAAA,2BAAA,KAAA,KAAA,uBAAY,OAAA,SAAA,QAAA,SAAA,KAAA,IAAA,KAAA,IAAO,KAAM,OAAO;AAClD,UAAA,yBAAI,kBAAkB,gBAAA,QAAA,2BAAA,KAAA,IAAA,KAAA,IAAA,uBAAY,UAAS,EAC1C,QAAO,kBAAkB;KAEzB;AAEH,IADa,kBAAkB,eAAlB,kBAAkB,6BAAe,IAAI,KAAK,GACnD,IAAA,SAAA,QAAA,SAAA,KAAA,IAAA,KAAA,IAAI,KAAM,QAAQ,IAAI;;;CAI5B,MAAM,WAAW,MAAM;AAGvB,KAAI,SAAS,WAAW,KAAK;EAC5B,MAAM,aAAa,OAAO,SAAS,QAAQ,IAAI,cAAc,CAAC;EAC9D,MAAM,qBAAqB,OAAO,MAAM,WAAW,GAChD,sBACA,aAAa;AAEhB,QAAM,IAAI,SAAS,YAAY,WAAW,SAAS,mBAAmB,CAAC;AAEvE,SAAO,QAAQ,KAAK,MAAM,QAAQ;;AAGnC,QAAO"}
|