@prismicio/client 7.21.6-canary.529a352 → 7.21.6
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 +20 -19
- package/dist/Client.cjs.map +1 -1
- package/dist/Client.d.cts +12 -5
- package/dist/Client.d.cts.map +1 -1
- package/dist/Client.d.ts +12 -5
- package/dist/Client.d.ts.map +1 -1
- package/dist/Client.js +9 -8
- package/dist/Client.js.map +1 -1
- package/dist/Migration.cjs +19 -18
- package/dist/Migration.cjs.map +1 -1
- package/dist/Migration.d.cts +1 -0
- package/dist/Migration.d.cts.map +1 -1
- package/dist/Migration.d.ts +1 -0
- package/dist/Migration.d.ts.map +1 -1
- package/dist/Migration.js +12 -11
- package/dist/Migration.js.map +1 -1
- package/dist/WriteClient.cjs +21 -17
- package/dist/WriteClient.cjs.map +1 -1
- package/dist/WriteClient.d.cts +1 -0
- package/dist/WriteClient.d.cts.map +1 -1
- package/dist/WriteClient.d.ts +1 -0
- package/dist/WriteClient.d.ts.map +1 -1
- package/dist/WriteClient.js +14 -10
- package/dist/WriteClient.js.map +1 -1
- package/dist/_virtual/{_rolldown/runtime.js → rolldown_runtime.cjs} +5 -4
- package/dist/_virtual/rolldown_runtime.js +13 -0
- package/dist/buildQueryURL.cjs +5 -4
- 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 +3 -2
- package/dist/buildQueryURL.js.map +1 -1
- package/dist/cookie.cjs +9 -7
- 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 +4 -3
- package/dist/cookie.js.map +1 -1
- package/dist/createClient.cjs +3 -2
- package/dist/createClient.cjs.map +1 -1
- package/dist/createClient.d.cts +1 -0
- package/dist/createClient.d.cts.map +1 -1
- package/dist/createClient.d.ts +1 -0
- package/dist/createClient.d.ts.map +1 -1
- package/dist/createClient.js +2 -1
- package/dist/createClient.js.map +1 -1
- package/dist/createMigration.cjs +3 -2
- package/dist/createMigration.cjs.map +1 -1
- package/dist/createMigration.d.cts +1 -0
- package/dist/createMigration.d.cts.map +1 -1
- package/dist/createMigration.d.ts +1 -0
- package/dist/createMigration.d.ts.map +1 -1
- package/dist/createMigration.js +2 -1
- package/dist/createMigration.js.map +1 -1
- package/dist/createWriteClient.cjs +3 -2
- package/dist/createWriteClient.cjs.map +1 -1
- package/dist/createWriteClient.d.cts +1 -0
- package/dist/createWriteClient.d.cts.map +1 -1
- package/dist/createWriteClient.d.ts +1 -0
- package/dist/createWriteClient.d.ts.map +1 -1
- package/dist/createWriteClient.js +2 -1
- package/dist/createWriteClient.js.map +1 -1
- package/dist/errors.cjs +2 -1
- 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 +2 -1
- 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 +4 -3
- 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 +2 -1
- package/dist/getGraphQLEndpoint.js.map +1 -1
- package/dist/getRepositoryEndpoint.cjs +4 -3
- 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 +2 -1
- package/dist/getRepositoryEndpoint.js.map +1 -1
- package/dist/getRepositoryName.cjs +3 -2
- 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 +2 -1
- package/dist/getRepositoryName.js.map +1 -1
- package/dist/getToolbarSrc.cjs +4 -3
- 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 +2 -1
- package/dist/getToolbarSrc.js.map +1 -1
- package/dist/helpers/asDate.cjs +2 -1
- package/dist/helpers/asDate.cjs.map +1 -1
- package/dist/helpers/asDate.d.cts +1 -0
- package/dist/helpers/asDate.d.cts.map +1 -1
- package/dist/helpers/asDate.d.ts +1 -0
- package/dist/helpers/asDate.d.ts.map +1 -1
- package/dist/helpers/asDate.js +1 -1
- package/dist/helpers/asHTML.cjs +6 -5
- package/dist/helpers/asHTML.cjs.map +1 -1
- package/dist/helpers/asHTML.d.cts +1 -0
- package/dist/helpers/asHTML.d.cts.map +1 -1
- package/dist/helpers/asHTML.d.ts +1 -0
- package/dist/helpers/asHTML.d.ts.map +1 -1
- package/dist/helpers/asHTML.js +2 -1
- package/dist/helpers/asHTML.js.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.cjs +4 -3
- package/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.d.cts +1 -0
- package/dist/helpers/asImagePixelDensitySrcSet.d.cts.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.d.ts +1 -0
- package/dist/helpers/asImagePixelDensitySrcSet.d.ts.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.js +3 -2
- package/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -1
- package/dist/helpers/asImageSrc.cjs +3 -2
- package/dist/helpers/asImageSrc.cjs.map +1 -1
- package/dist/helpers/asImageSrc.d.cts +1 -0
- package/dist/helpers/asImageSrc.d.cts.map +1 -1
- package/dist/helpers/asImageSrc.d.ts +1 -0
- package/dist/helpers/asImageSrc.d.ts.map +1 -1
- package/dist/helpers/asImageSrc.js +2 -1
- package/dist/helpers/asImageSrc.js.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.cjs +5 -4
- package/dist/helpers/asImageWidthSrcSet.cjs.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.d.cts +1 -0
- package/dist/helpers/asImageWidthSrcSet.d.cts.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.d.ts +1 -0
- package/dist/helpers/asImageWidthSrcSet.d.ts.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.js +4 -3
- package/dist/helpers/asImageWidthSrcSet.js.map +1 -1
- package/dist/helpers/asLink.cjs +4 -3
- package/dist/helpers/asLink.cjs.map +1 -1
- package/dist/helpers/asLink.d.cts +1 -0
- package/dist/helpers/asLink.d.cts.map +1 -1
- package/dist/helpers/asLink.d.ts +1 -0
- package/dist/helpers/asLink.d.ts.map +1 -1
- package/dist/helpers/asLink.js +2 -1
- package/dist/helpers/asLink.js.map +1 -1
- package/dist/helpers/asLinkAttrs.cjs +5 -4
- 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 +2 -1
- package/dist/helpers/asLinkAttrs.js.map +1 -1
- package/dist/helpers/asText.cjs +5 -4
- package/dist/helpers/asText.cjs.map +1 -1
- package/dist/helpers/asText.d.cts +1 -0
- package/dist/helpers/asText.d.cts.map +1 -1
- package/dist/helpers/asText.d.ts +1 -0
- package/dist/helpers/asText.d.ts.map +1 -1
- package/dist/helpers/asText.js +6 -5
- package/dist/helpers/asText.js.map +1 -1
- package/dist/helpers/documentToLinkField.cjs +3 -2
- 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 +2 -1
- package/dist/helpers/documentToLinkField.js.map +1 -1
- package/dist/helpers/isFilled.cjs +13 -11
- 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 +8 -7
- package/dist/helpers/isFilled.js.map +1 -1
- package/dist/helpers/mapSliceZone.cjs +2 -1
- package/dist/helpers/mapSliceZone.cjs.map +1 -1
- package/dist/helpers/mapSliceZone.d.cts +1 -0
- package/dist/helpers/mapSliceZone.d.cts.map +1 -1
- package/dist/helpers/mapSliceZone.d.ts +1 -0
- 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 +2 -1
- package/dist/index.js.map +1 -1
- package/dist/isRepositoryEndpoint.cjs +2 -1
- 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 +2 -1
- 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 +3 -2
- package/dist/lib/devMsg.cjs.map +1 -1
- package/dist/lib/devMsg.js +2 -1
- package/dist/lib/devMsg.js.map +1 -1
- package/dist/lib/escapeHTML.cjs +2 -1
- package/dist/lib/escapeHTML.cjs.map +1 -1
- package/dist/lib/escapeHTML.js +1 -1
- package/dist/lib/getOptionalLinkProperties.cjs +2 -1
- 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 +4 -3
- package/dist/lib/getPreviewCookie.cjs.map +1 -1
- package/dist/lib/getPreviewCookie.js +4 -3
- package/dist/lib/getPreviewCookie.js.map +1 -1
- package/dist/lib/isInternalURL.cjs +2 -1
- package/dist/lib/isInternalURL.cjs.map +1 -1
- package/dist/lib/isInternalURL.js +1 -1
- package/dist/lib/isMigrationValue.cjs +7 -6
- package/dist/lib/isMigrationValue.cjs.map +1 -1
- package/dist/lib/isMigrationValue.js +2 -1
- package/dist/lib/isMigrationValue.js.map +1 -1
- package/dist/lib/isValue.cjs +4 -3
- package/dist/lib/isValue.cjs.map +1 -1
- package/dist/lib/isValue.js +2 -1
- package/dist/lib/isValue.js.map +1 -1
- package/dist/lib/pLimit.cjs +2 -1
- 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 +4 -3
- package/dist/lib/request.cjs.map +1 -1
- package/dist/lib/request.d.cts +1 -0
- package/dist/lib/request.d.cts.map +1 -1
- package/dist/lib/request.d.ts +1 -0
- package/dist/lib/request.d.ts.map +1 -1
- package/dist/lib/request.js +3 -2
- package/dist/lib/request.js.map +1 -1
- package/dist/lib/resolveMigrationDocumentData.cjs +19 -18
- package/dist/lib/resolveMigrationDocumentData.cjs.map +1 -1
- package/dist/lib/resolveMigrationDocumentData.js +12 -11
- package/dist/lib/resolveMigrationDocumentData.js.map +1 -1
- package/dist/lib/serializerHelpers.cjs +5 -4
- package/dist/lib/serializerHelpers.cjs.map +1 -1
- package/dist/lib/serializerHelpers.js +2 -1
- package/dist/lib/serializerHelpers.js.map +1 -1
- package/dist/lib/throttledWarn.cjs +2 -1
- 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 +3 -2
- package/dist/lib/validateAssetMetadata.cjs.map +1 -1
- package/dist/lib/validateAssetMetadata.js +2 -1
- package/dist/lib/validateAssetMetadata.js.map +1 -1
- package/dist/package.cjs +13 -12
- 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 +2 -1
- package/dist/richtext/asText.cjs.map +1 -1
- package/dist/richtext/asText.d.cts +1 -0
- package/dist/richtext/asText.d.cts.map +1 -1
- package/dist/richtext/asText.d.ts +1 -0
- package/dist/richtext/asText.d.ts.map +1 -1
- package/dist/richtext/asText.js +1 -1
- package/dist/richtext/asTree.cjs +3 -2
- package/dist/richtext/asTree.cjs.map +1 -1
- package/dist/richtext/asTree.d.cts +1 -0
- package/dist/richtext/asTree.d.cts.map +1 -1
- package/dist/richtext/asTree.d.ts +1 -0
- package/dist/richtext/asTree.d.ts.map +1 -1
- package/dist/richtext/asTree.js +2 -1
- package/dist/richtext/asTree.js.map +1 -1
- package/dist/richtext/composeSerializers.cjs +2 -1
- package/dist/richtext/composeSerializers.cjs.map +1 -1
- package/dist/richtext/composeSerializers.d.cts +1 -0
- package/dist/richtext/composeSerializers.d.cts.map +1 -1
- package/dist/richtext/composeSerializers.d.ts +1 -0
- package/dist/richtext/composeSerializers.d.ts.map +1 -1
- package/dist/richtext/composeSerializers.js +1 -1
- package/dist/richtext/serialize.cjs +3 -2
- package/dist/richtext/serialize.cjs.map +1 -1
- package/dist/richtext/serialize.d.cts +1 -0
- package/dist/richtext/serialize.d.cts.map +1 -1
- package/dist/richtext/serialize.d.ts +1 -0
- package/dist/richtext/serialize.d.ts.map +1 -1
- package/dist/richtext/serialize.js +2 -1
- package/dist/richtext/serialize.js.map +1 -1
- package/dist/richtext/types.cjs +3 -2
- package/dist/richtext/types.cjs.map +1 -1
- package/dist/richtext/types.d.cts +1 -0
- package/dist/richtext/types.d.cts.map +1 -1
- package/dist/richtext/types.d.ts +1 -0
- package/dist/richtext/types.d.ts.map +1 -1
- package/dist/richtext/types.js +2 -1
- package/dist/richtext/types.js.map +1 -1
- package/dist/richtext/wrapMapSerializer.cjs +3 -2
- package/dist/richtext/wrapMapSerializer.cjs.map +1 -1
- package/dist/richtext/wrapMapSerializer.d.cts +1 -0
- package/dist/richtext/wrapMapSerializer.d.cts.map +1 -1
- package/dist/richtext/wrapMapSerializer.d.ts +1 -0
- package/dist/richtext/wrapMapSerializer.d.ts.map +1 -1
- package/dist/richtext/wrapMapSerializer.js +2 -1
- package/dist/richtext/wrapMapSerializer.js.map +1 -1
- package/dist/richtext.cjs +8 -8
- package/dist/richtext.js +2 -1
- package/dist/types/api/asset/asset.d.cts +1 -0
- package/dist/types/api/asset/asset.d.cts.map +1 -1
- package/dist/types/api/asset/asset.d.ts +1 -0
- 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 +1 -0
- package/dist/types/api/integration.d.cts.map +1 -1
- package/dist/types/api/integration.d.ts +1 -0
- package/dist/types/api/integration.d.ts.map +1 -1
- package/dist/types/api/query.d.cts +1 -0
- package/dist/types/api/query.d.cts.map +1 -1
- package/dist/types/api/query.d.ts +1 -0
- 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 +1 -0
- package/dist/types/api/release.d.cts.map +1 -1
- package/dist/types/api/release.d.ts +1 -0
- package/dist/types/api/release.d.ts.map +1 -1
- package/dist/types/api/repository.d.cts +1 -0
- package/dist/types/api/repository.d.cts.map +1 -1
- package/dist/types/api/repository.d.ts +1 -0
- 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 +2 -1
- package/dist/types/migration/Asset.cjs.map +1 -1
- package/dist/types/migration/Asset.d.cts +1 -0
- package/dist/types/migration/Asset.d.cts.map +1 -1
- package/dist/types/migration/Asset.d.ts +1 -0
- 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 +2 -1
- package/dist/types/migration/Document.cjs.map +1 -1
- package/dist/types/migration/Document.d.cts +1 -0
- package/dist/types/migration/Document.d.cts.map +1 -1
- package/dist/types/migration/Document.d.ts +1 -0
- 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 +1 -0
- package/dist/types/model/boolean.d.cts.map +1 -1
- package/dist/types/model/boolean.d.ts +1 -0
- package/dist/types/model/boolean.d.ts.map +1 -1
- package/dist/types/model/color.d.cts +1 -0
- package/dist/types/model/color.d.cts.map +1 -1
- package/dist/types/model/color.d.ts +1 -0
- package/dist/types/model/color.d.ts.map +1 -1
- package/dist/types/model/contentRelationship.d.cts +1 -0
- package/dist/types/model/contentRelationship.d.cts.map +1 -1
- package/dist/types/model/contentRelationship.d.ts +1 -0
- package/dist/types/model/contentRelationship.d.ts.map +1 -1
- package/dist/types/model/customType.d.cts +1 -0
- package/dist/types/model/customType.d.cts.map +1 -1
- package/dist/types/model/customType.d.ts +1 -0
- package/dist/types/model/customType.d.ts.map +1 -1
- package/dist/types/model/date.d.cts +1 -0
- package/dist/types/model/date.d.cts.map +1 -1
- package/dist/types/model/date.d.ts +1 -0
- package/dist/types/model/date.d.ts.map +1 -1
- package/dist/types/model/embed.d.cts +1 -0
- package/dist/types/model/embed.d.cts.map +1 -1
- package/dist/types/model/embed.d.ts +1 -0
- package/dist/types/model/embed.d.ts.map +1 -1
- package/dist/types/model/geoPoint.d.cts +1 -0
- package/dist/types/model/geoPoint.d.cts.map +1 -1
- package/dist/types/model/geoPoint.d.ts +1 -0
- package/dist/types/model/geoPoint.d.ts.map +1 -1
- package/dist/types/model/group.d.cts +1 -0
- package/dist/types/model/group.d.cts.map +1 -1
- package/dist/types/model/group.d.ts +1 -0
- package/dist/types/model/group.d.ts.map +1 -1
- package/dist/types/model/image.d.cts +1 -0
- package/dist/types/model/image.d.cts.map +1 -1
- package/dist/types/model/image.d.ts +1 -0
- package/dist/types/model/image.d.ts.map +1 -1
- package/dist/types/model/integration.d.cts +1 -0
- package/dist/types/model/integration.d.cts.map +1 -1
- package/dist/types/model/integration.d.ts +1 -0
- package/dist/types/model/integration.d.ts.map +1 -1
- package/dist/types/model/keyText.d.cts +1 -0
- package/dist/types/model/keyText.d.cts.map +1 -1
- package/dist/types/model/keyText.d.ts +1 -0
- package/dist/types/model/keyText.d.ts.map +1 -1
- package/dist/types/model/link.cjs +2 -1
- package/dist/types/model/link.cjs.map +1 -1
- package/dist/types/model/link.d.cts +1 -0
- package/dist/types/model/link.d.cts.map +1 -1
- package/dist/types/model/link.d.ts +1 -0
- 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 +1 -0
- package/dist/types/model/linkToMedia.d.cts.map +1 -1
- package/dist/types/model/linkToMedia.d.ts +1 -0
- package/dist/types/model/linkToMedia.d.ts.map +1 -1
- package/dist/types/model/number.d.cts +1 -0
- package/dist/types/model/number.d.cts.map +1 -1
- package/dist/types/model/number.d.ts +1 -0
- package/dist/types/model/number.d.ts.map +1 -1
- package/dist/types/model/range.d.cts +1 -0
- package/dist/types/model/range.d.cts.map +1 -1
- package/dist/types/model/range.d.ts +1 -0
- package/dist/types/model/range.d.ts.map +1 -1
- package/dist/types/model/richText.d.cts +1 -0
- package/dist/types/model/richText.d.cts.map +1 -1
- package/dist/types/model/richText.d.ts +1 -0
- package/dist/types/model/richText.d.ts.map +1 -1
- package/dist/types/model/select.d.cts +1 -0
- package/dist/types/model/select.d.cts.map +1 -1
- package/dist/types/model/select.d.ts +1 -0
- package/dist/types/model/select.d.ts.map +1 -1
- package/dist/types/model/separator.d.cts +1 -0
- package/dist/types/model/separator.d.cts.map +1 -1
- package/dist/types/model/separator.d.ts +1 -0
- package/dist/types/model/separator.d.ts.map +1 -1
- package/dist/types/model/sharedSlice.d.cts +1 -0
- package/dist/types/model/sharedSlice.d.cts.map +1 -1
- package/dist/types/model/sharedSlice.d.ts +1 -0
- package/dist/types/model/sharedSlice.d.ts.map +1 -1
- package/dist/types/model/sharedSliceVariation.d.cts +1 -0
- package/dist/types/model/sharedSliceVariation.d.cts.map +1 -1
- package/dist/types/model/sharedSliceVariation.d.ts +1 -0
- package/dist/types/model/sharedSliceVariation.d.ts.map +1 -1
- package/dist/types/model/slice.cjs +2 -1
- package/dist/types/model/slice.cjs.map +1 -1
- package/dist/types/model/slice.d.cts +1 -0
- package/dist/types/model/slice.d.cts.map +1 -1
- package/dist/types/model/slice.d.ts +1 -0
- package/dist/types/model/slice.d.ts.map +1 -1
- package/dist/types/model/slice.js +1 -1
- package/dist/types/model/sliceZone.cjs +2 -1
- package/dist/types/model/sliceZone.cjs.map +1 -1
- package/dist/types/model/sliceZone.d.cts +1 -0
- package/dist/types/model/sliceZone.d.cts.map +1 -1
- package/dist/types/model/sliceZone.d.ts +1 -0
- 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 +1 -0
- package/dist/types/model/table.d.cts.map +1 -1
- package/dist/types/model/table.d.ts +1 -0
- package/dist/types/model/table.d.ts.map +1 -1
- package/dist/types/model/timestamp.d.cts +1 -0
- package/dist/types/model/timestamp.d.cts.map +1 -1
- package/dist/types/model/timestamp.d.ts +1 -0
- package/dist/types/model/timestamp.d.ts.map +1 -1
- package/dist/types/model/title.d.cts +1 -0
- package/dist/types/model/title.d.cts.map +1 -1
- package/dist/types/model/title.d.ts +1 -0
- package/dist/types/model/title.d.ts.map +1 -1
- package/dist/types/model/types.cjs +2 -1
- package/dist/types/model/types.cjs.map +1 -1
- package/dist/types/model/types.d.cts +1 -0
- package/dist/types/model/types.d.cts.map +1 -1
- package/dist/types/model/types.d.ts +1 -0
- 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 +1 -0
- package/dist/types/model/uid.d.cts.map +1 -1
- package/dist/types/model/uid.d.ts +1 -0
- 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 +1 -0
- package/dist/types/value/color.d.cts.map +1 -1
- package/dist/types/value/color.d.ts +1 -0
- package/dist/types/value/color.d.ts.map +1 -1
- package/dist/types/value/contentRelationship.d.cts +1 -0
- package/dist/types/value/contentRelationship.d.cts.map +1 -1
- package/dist/types/value/contentRelationship.d.ts +1 -0
- package/dist/types/value/contentRelationship.d.ts.map +1 -1
- package/dist/types/value/date.d.cts +1 -0
- package/dist/types/value/date.d.cts.map +1 -1
- package/dist/types/value/date.d.ts +1 -0
- package/dist/types/value/date.d.ts.map +1 -1
- package/dist/types/value/document.d.cts +1 -0
- package/dist/types/value/document.d.cts.map +1 -1
- package/dist/types/value/document.d.ts +1 -0
- package/dist/types/value/document.d.ts.map +1 -1
- package/dist/types/value/embed.cjs +2 -1
- package/dist/types/value/embed.cjs.map +1 -1
- package/dist/types/value/embed.d.cts +1 -0
- package/dist/types/value/embed.d.cts.map +1 -1
- package/dist/types/value/embed.d.ts +1 -0
- 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 +1 -0
- package/dist/types/value/geoPoint.d.cts.map +1 -1
- package/dist/types/value/geoPoint.d.ts +1 -0
- package/dist/types/value/geoPoint.d.ts.map +1 -1
- package/dist/types/value/group.d.cts +1 -0
- package/dist/types/value/group.d.cts.map +1 -1
- package/dist/types/value/group.d.ts +1 -0
- package/dist/types/value/group.d.ts.map +1 -1
- package/dist/types/value/image.d.cts +1 -0
- package/dist/types/value/image.d.cts.map +1 -1
- package/dist/types/value/image.d.ts +1 -0
- package/dist/types/value/image.d.ts.map +1 -1
- package/dist/types/value/integration.d.cts +1 -0
- package/dist/types/value/integration.d.cts.map +1 -1
- package/dist/types/value/integration.d.ts +1 -0
- package/dist/types/value/integration.d.ts.map +1 -1
- package/dist/types/value/keyText.d.cts +1 -0
- package/dist/types/value/keyText.d.cts.map +1 -1
- package/dist/types/value/keyText.d.ts +1 -0
- package/dist/types/value/keyText.d.ts.map +1 -1
- package/dist/types/value/link.cjs +2 -1
- package/dist/types/value/link.cjs.map +1 -1
- package/dist/types/value/link.d.cts +1 -0
- package/dist/types/value/link.d.cts.map +1 -1
- package/dist/types/value/link.d.ts +1 -0
- 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 +1 -0
- package/dist/types/value/linkToMedia.d.cts.map +1 -1
- package/dist/types/value/linkToMedia.d.ts +1 -0
- package/dist/types/value/linkToMedia.d.ts.map +1 -1
- package/dist/types/value/number.d.cts +1 -0
- package/dist/types/value/number.d.cts.map +1 -1
- package/dist/types/value/number.d.ts +1 -0
- package/dist/types/value/number.d.ts.map +1 -1
- package/dist/types/value/richText.cjs +2 -1
- package/dist/types/value/richText.cjs.map +1 -1
- package/dist/types/value/richText.d.cts +1 -0
- package/dist/types/value/richText.d.cts.map +1 -1
- package/dist/types/value/richText.d.ts +1 -0
- 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 +1 -0
- package/dist/types/value/select.d.cts.map +1 -1
- package/dist/types/value/select.d.ts +1 -0
- package/dist/types/value/select.d.ts.map +1 -1
- package/dist/types/value/sharedSlice.d.cts +1 -0
- package/dist/types/value/sharedSlice.d.cts.map +1 -1
- package/dist/types/value/sharedSlice.d.ts +1 -0
- package/dist/types/value/sharedSlice.d.ts.map +1 -1
- package/dist/types/value/sharedSliceVariation.d.cts +1 -0
- package/dist/types/value/sharedSliceVariation.d.cts.map +1 -1
- package/dist/types/value/sharedSliceVariation.d.ts +1 -0
- package/dist/types/value/sharedSliceVariation.d.ts.map +1 -1
- package/dist/types/value/slice.d.cts +1 -0
- package/dist/types/value/slice.d.cts.map +1 -1
- package/dist/types/value/slice.d.ts +1 -0
- package/dist/types/value/slice.d.ts.map +1 -1
- package/dist/types/value/sliceZone.d.cts +1 -0
- package/dist/types/value/sliceZone.d.cts.map +1 -1
- package/dist/types/value/sliceZone.d.ts +1 -0
- package/dist/types/value/sliceZone.d.ts.map +1 -1
- package/dist/types/value/table.d.cts +1 -0
- package/dist/types/value/table.d.cts.map +1 -1
- package/dist/types/value/table.d.ts +1 -0
- package/dist/types/value/table.d.ts.map +1 -1
- package/dist/types/value/timestamp.d.cts +1 -0
- package/dist/types/value/timestamp.d.cts.map +1 -1
- package/dist/types/value/timestamp.d.ts +1 -0
- package/dist/types/value/timestamp.d.ts.map +1 -1
- package/dist/types/value/title.d.cts +1 -0
- package/dist/types/value/title.d.cts.map +1 -1
- package/dist/types/value/title.d.ts +1 -0
- package/dist/types/value/title.d.ts.map +1 -1
- package/dist/types/value/types.d.cts +1 -0
- package/dist/types/value/types.d.cts.map +1 -1
- package/dist/types/value/types.d.ts +1 -0
- package/dist/types/value/types.d.ts.map +1 -1
- package/dist/types/webhook/apiUpdate.d.cts +1 -0
- package/dist/types/webhook/apiUpdate.d.cts.map +1 -1
- package/dist/types/webhook/apiUpdate.d.ts +1 -0
- package/dist/types/webhook/apiUpdate.d.ts.map +1 -1
- package/dist/types/webhook/testTrigger.d.cts +1 -0
- package/dist/types/webhook/testTrigger.d.cts.map +1 -1
- package/dist/types/webhook/testTrigger.d.ts +1 -0
- package/dist/types/webhook/testTrigger.d.ts.map +1 -1
- package/dist/types/webhook/types.cjs +2 -1
- 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/helpers/asImageWidthSrcSet.ts +0 -1
- package/dist/_virtual/_rolldown/runtime.cjs +0 -13
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
//#region src/lib/isInternalURL.ts
|
|
2
3
|
/**
|
|
3
4
|
* Determines if a URL is internal or external.
|
|
@@ -11,7 +12,7 @@ const isInternalURL = (url) => {
|
|
|
11
12
|
const isSpecialLink = !isInternal && !/^https?:\/\//.test(url);
|
|
12
13
|
return isInternal && !isSpecialLink;
|
|
13
14
|
};
|
|
15
|
+
|
|
14
16
|
//#endregion
|
|
15
17
|
exports.isInternalURL = isInternalURL;
|
|
16
|
-
|
|
17
18
|
//# 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,8 +1,9 @@
|
|
|
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(
|
|
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');
|
|
6
|
+
|
|
6
7
|
//#region src/lib/isMigrationValue.ts
|
|
7
8
|
/**
|
|
8
9
|
* Checks if a value is a migration content relationship field.
|
|
@@ -67,10 +68,10 @@ const linkToMedia = (value) => {
|
|
|
67
68
|
const rtImageNode = (value) => {
|
|
68
69
|
return typeof value === "object" && value !== null && "id" in value && value.id instanceof require_Asset.PrismicMigrationAsset && "type" in value && value.type === require_richText.RichTextNodeType.image;
|
|
69
70
|
};
|
|
71
|
+
|
|
70
72
|
//#endregion
|
|
71
73
|
exports.contentRelationship = contentRelationship;
|
|
72
74
|
exports.image = image;
|
|
73
75
|
exports.linkToMedia = linkToMedia;
|
|
74
76
|
exports.rtImageNode = rtImageNode;
|
|
75
|
-
|
|
76
77
|
//# 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,6EACE,MAAM,IACxB,OAAO,UAAU,YACjB,UAAU,QACV,eAAe,SACf,MAAM,cAAcC,sBAAS,YAC7B,QAAQ,UACP,oBAAoB,MAAM,GAAG,IAAI,OAAO,MAAM,OAAO;;;;;;;;;;;;AAczD,MAAa,SAAS,UAAiD;AACtE,QACC,iBAAiBC,uCAChB,OAAO,UAAU,YACjB,UAAU,QACV,QAAQ,SACR,OAAO,OAAO,MAAM,CAAC,OACnB,mBAAmB,0BAA0BA,oCAC9C;;;;;;;;;;;;;;;;;AAmBJ,MAAa,eACZ,UAC4D;AAC5D,QACC,OAAO,UAAU,YACjB,UAAU,QACV,QAAQ,SACR,MAAM,cAAcA,uCACpB,eAAe,SACf,MAAM,cAAcD,sBAAS;;;;;;;;;;;;;AAe/B,MAAa,eACZ,UACmC;AACnC,QACC,OAAO,UAAU,YACjB,UAAU,QACV,QAAQ,SACR,MAAM,cAAcC,uCACpB,UAAU,SACV,MAAM,SAASC,kCAAiB"}
|
|
@@ -3,6 +3,7 @@ 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
|
+
|
|
6
7
|
//#region src/lib/isMigrationValue.ts
|
|
7
8
|
/**
|
|
8
9
|
* Checks if a value is a migration content relationship field.
|
|
@@ -67,7 +68,7 @@ const linkToMedia = (value) => {
|
|
|
67
68
|
const rtImageNode = (value) => {
|
|
68
69
|
return typeof value === "object" && value !== null && "id" in value && value.id instanceof PrismicMigrationAsset && "type" in value && value.type === RichTextNodeType.image;
|
|
69
70
|
};
|
|
71
|
+
|
|
70
72
|
//#endregion
|
|
71
73
|
export { contentRelationship, image, linkToMedia, rtImageNode };
|
|
72
|
-
|
|
73
74
|
//# 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,5 +1,6 @@
|
|
|
1
|
-
const require_richText = require(
|
|
2
|
-
const require_link = require(
|
|
1
|
+
const require_richText = require('../types/value/richText.cjs');
|
|
2
|
+
const require_link = require('../types/value/link.cjs');
|
|
3
|
+
|
|
3
4
|
//#region src/lib/isValue.ts
|
|
4
5
|
/**
|
|
5
6
|
* Checks if a value is a link to media field.
|
|
@@ -99,11 +100,11 @@ const prismicDocument = (value) => {
|
|
|
99
100
|
return false;
|
|
100
101
|
}
|
|
101
102
|
};
|
|
103
|
+
|
|
102
104
|
//#endregion
|
|
103
105
|
exports.filledContentRelationship = filledContentRelationship;
|
|
104
106
|
exports.filledImage = filledImage;
|
|
105
107
|
exports.filledLinkToMedia = filledLinkToMedia;
|
|
106
108
|
exports.prismicDocument = prismicDocument;
|
|
107
109
|
exports.rtImageNode = rtImageNode;
|
|
108
|
-
|
|
109
110
|
//# 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,QACxD;MACC,eAAe,SACf,MAAM,cAAcA,sBAAS,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,WAEnD;MACC,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,kCAAiB,OAEvD,QAAO;AAGR,QAAO;;;;;;;;;;;;AAaR,MAAa,eAAe,UAA8C;AACzE,KACC,UAAU,MAAM,IAChB,UAAU,SACV,MAAM,SAASA,kCAAiB,MAEhC,QAAO;AAGR,QAAO;;;;;;;;;;;;;;;;;AAkBR,MAAa,6BACZ,UACsE;AACtE,KAAI,SAAS,OAAO,UAAU,YAAY,EAAE,aAAa,QACxD;MACC,eAAe,SACf,MAAM,cAAcD,sBAAS,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,5 +1,6 @@
|
|
|
1
1
|
import { RichTextNodeType } from "../types/value/richText.js";
|
|
2
2
|
import { LinkType } from "../types/value/link.js";
|
|
3
|
+
|
|
3
4
|
//#region src/lib/isValue.ts
|
|
4
5
|
/**
|
|
5
6
|
* Checks if a value is a link to media field.
|
|
@@ -99,7 +100,7 @@ const prismicDocument = (value) => {
|
|
|
99
100
|
return false;
|
|
100
101
|
}
|
|
101
102
|
};
|
|
103
|
+
|
|
102
104
|
//#endregion
|
|
103
105
|
export { filledContentRelationship, filledImage, filledLinkToMedia, prismicDocument, rtImageNode };
|
|
104
|
-
|
|
105
106
|
//# 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,QACxD;MACC,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,WAEnD;MACC,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,QACxD;MACC,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,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
//#region src/lib/pLimit.ts
|
|
2
3
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
3
4
|
/**
|
|
@@ -48,7 +49,7 @@ const pLimit = ({ interval } = {}) => {
|
|
|
48
49
|
enqueue(function_, resolve, arguments_);
|
|
49
50
|
}));
|
|
50
51
|
};
|
|
52
|
+
|
|
51
53
|
//#endregion
|
|
52
54
|
exports.pLimit = pLimit;
|
|
53
|
-
|
|
54
55
|
//# sourceMappingURL=pLimit.cjs.map
|
package/dist/lib/pLimit.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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":"
|
|
1
|
+
{"version":3,"file":"pLimit.cjs","names":["queue: AnyFunction[]"],"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,MAAMA,QAAuB,EAAE;CAC/B,IAAI,OAAO;CACX,IAAI,iBAAiB;CAErB,MAAM,mBAAmB;AACxB,MAAI,CAAC,QAAQ,MAAM,SAAS,GAAG;;AAC9B,yBAAM,OAAO,uDAAI;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,QAAW,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":[],"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,
|
|
1
|
+
{"version":3,"file":"pLimit.js","names":["queue: AnyFunction[]"],"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,MAAMA,QAAuB,EAAE;CAC/B,IAAI,OAAO;CACX,IAAI,iBAAiB;CAErB,MAAM,mBAAmB;AACxB,MAAI,CAAC,QAAQ,MAAM,SAAS,GAAG;;AAC9B,yBAAM,OAAO,uDAAI;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,QAAW,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,4 +1,5 @@
|
|
|
1
|
-
const require_pLimit = require(
|
|
1
|
+
const require_pLimit = require('./pLimit.cjs');
|
|
2
|
+
|
|
2
3
|
//#region src/lib/request.ts
|
|
3
4
|
/**
|
|
4
5
|
* The default number of milliseconds to wait before retrying a rate-limited
|
|
@@ -44,7 +45,7 @@ async function request(url, init, fetchFn) {
|
|
|
44
45
|
let job;
|
|
45
46
|
if (init === null || init === void 0 ? void 0 : init.body) {
|
|
46
47
|
var _url$hostname;
|
|
47
|
-
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: DEFAULT_RETRY_AFTER })))(() => fetchFn(stringURL, init));
|
|
48
49
|
} else {
|
|
49
50
|
var _DEDUPLICATED_JOBS$st;
|
|
50
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);
|
|
@@ -67,7 +68,7 @@ async function request(url, init, fetchFn) {
|
|
|
67
68
|
}
|
|
68
69
|
return response;
|
|
69
70
|
}
|
|
71
|
+
|
|
70
72
|
//#endregion
|
|
71
73
|
exports.request = request;
|
|
72
|
-
|
|
73
74
|
//# sourceMappingURL=request.cjs.map
|
package/dist/lib/request.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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\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 a blob upfront instead.\n\tconst blob = await response.blob()\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 () => blob.text(),\n\t\tjson: async () => JSON.parse(await blob.text()),\n\t\tblob: async () => blob,\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":"
|
|
1
|
+
{"version":3,"file":"request.cjs","names":["THROTTLED_RUNNERS: Partial<Record<string, LimitFunction>>","DEDUPLICATED_JOBS: Partial<\n\tRecord<string, Map<AbortSignalLike | undefined, Promise<ResponseLike>>>\n>","memoized: ResponseLike","job: Promise<ResponseLike>","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\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 a blob upfront instead.\n\tconst blob = await response.blob()\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 () => blob.text(),\n\t\tjson: async () => JSON.parse(await blob.text()),\n\t\tblob: async () => blob,\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,MAAMA,oBAA4D,EAAE;;;;;AAMpE,MAAMC,oBAEF,EAAE;AAsFN,eAAe,gBAAgB,UAA+C;CAI7E,MAAM,OAAO,MAAM,SAAS,MAAM;CAElC,MAAMC,WAAyB;EAC9B,IAAI,SAAS;EACb,QAAQ,SAAS;EACjB,SAAS,SAAS;EAClB,KAAK,SAAS;EACd,MAAM,YAAY,KAAK,MAAM;EAC7B,MAAM,YAAY,KAAK,MAAM,MAAM,KAAK,MAAM,CAAC;EAC/C,MAAM,YAAY;EAClB,aAAa;EACb;AAED,QAAO;;;;;;;;;;;;AAaR,eAAsB,QACrB,KACA,MACA,SACwB;CACxB,MAAM,YAAY,IAAI,UAAU;CAEhC,IAAIC;AAGJ,iDAAI,KAAM,MAAM;;AAMf,SAJgB,kCAAkB,IAAI,cAAtB,mCAAoCC,sBAAO,EAC1D,UAAU,qBACV,CAAC,SAEiB,QAAQ,WAAW,KAAK,CAAC;QACtC;;EAEN,MAAM,uCAAc,kBAAkB,0FAAY,gDAAI,KAAM,OAAO;AACnE,MAAI,YACH,OAAM;OACA;AACN,SAAM,QAAQ,WAAW,KAAK,CAC5B,KAAK,gBAAgB,CACrB,cAAc;;AACd,gDAAkB,oFAAY,mDAAO,KAAM,OAAO;AAClD,mCAAI,kBAAkB,4FAAY,UAAS,EAC1C,QAAO,kBAAkB;KAEzB;AAEH,IADa,kBAAkB,eAAlB,kBAAkB,6BAAe,IAAI,KAAK,GACnD,gDAAI,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.cts","names":[],"sources":["../../src/lib/request.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"request.d.cts","names":[],"sources":["../../src/lib/request.ts"],"sourcesContent":[],"mappings":";;AA2CA;AAUA;;;;AA4BU,KAtDE,SAAA,GAsDF,CAAA,KAAA,EAAA,MAAA,EAAA,IAAA,CAAA,EApDF,eAoDE,EAAA,GAnDL,OAmDK,CAnDG,YAmDH,CAAA;;;AAMV;;;;AAQiB,KApDL,eAAA,GAoDK,GAAA;;;;AAOA,UAjDA,eAAA,SAAwB,IAiDb,CAjDkB,WAiDlB,EAAA,OAAA,CAAA,CAAA;;;;;;;;eArCd;;;;YAKH;;;;;;;WAWD;;;;;UAMO,YAAA;;;WAGP;;UAGD;UACA;UACA,QAAQ;WACP;;;;;UAMO,WAAA"}
|
package/dist/lib/request.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.ts","names":[],"sources":["../../src/lib/request.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"request.d.ts","names":[],"sources":["../../src/lib/request.ts"],"sourcesContent":[],"mappings":";;AA2CA;AAUA;;;;AA4BU,KAtDE,SAAA,GAsDF,CAAA,KAAA,EAAA,MAAA,EAAA,IAAA,CAAA,EApDF,eAoDE,EAAA,GAnDL,OAmDK,CAnDG,YAmDH,CAAA;;;AAMV;;;;AAQiB,KApDL,eAAA,GAoDK,GAAA;;;;AAOA,UAjDA,eAAA,SAAwB,IAiDb,CAjDkB,WAiDlB,EAAA,OAAA,CAAA,CAAA;;;;;;;;eArCd;;;;YAKH;;;;;;;WAWD;;;;;UAMO,YAAA;;;WAGP;;UAGD;UACA;UACA,QAAQ;WACP;;;;;UAMO,WAAA"}
|
package/dist/lib/request.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { pLimit } from "./pLimit.js";
|
|
2
|
+
|
|
2
3
|
//#region src/lib/request.ts
|
|
3
4
|
/**
|
|
4
5
|
* The default number of milliseconds to wait before retrying a rate-limited
|
|
@@ -44,7 +45,7 @@ async function request(url, init, fetchFn) {
|
|
|
44
45
|
let job;
|
|
45
46
|
if (init === null || init === void 0 ? void 0 : init.body) {
|
|
46
47
|
var _url$hostname;
|
|
47
|
-
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: DEFAULT_RETRY_AFTER })))(() => fetchFn(stringURL, init));
|
|
48
49
|
} else {
|
|
49
50
|
var _DEDUPLICATED_JOBS$st;
|
|
50
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);
|
|
@@ -67,7 +68,7 @@ async function request(url, init, fetchFn) {
|
|
|
67
68
|
}
|
|
68
69
|
return response;
|
|
69
70
|
}
|
|
71
|
+
|
|
70
72
|
//#endregion
|
|
71
73
|
export { request };
|
|
72
|
-
|
|
73
74
|
//# sourceMappingURL=request.js.map
|
package/dist/lib/request.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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\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 a blob upfront instead.\n\tconst blob = await response.blob()\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 () => blob.text(),\n\t\tjson: async () => JSON.parse(await blob.text()),\n\t\tblob: async () => blob,\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":"
|
|
1
|
+
{"version":3,"file":"request.js","names":["THROTTLED_RUNNERS: Partial<Record<string, LimitFunction>>","DEDUPLICATED_JOBS: Partial<\n\tRecord<string, Map<AbortSignalLike | undefined, Promise<ResponseLike>>>\n>","memoized: ResponseLike","job: Promise<ResponseLike>"],"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\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 a blob upfront instead.\n\tconst blob = await response.blob()\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 () => blob.text(),\n\t\tjson: async () => JSON.parse(await blob.text()),\n\t\tblob: async () => blob,\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,MAAMA,oBAA4D,EAAE;;;;;AAMpE,MAAMC,oBAEF,EAAE;AAsFN,eAAe,gBAAgB,UAA+C;CAI7E,MAAM,OAAO,MAAM,SAAS,MAAM;CAElC,MAAMC,WAAyB;EAC9B,IAAI,SAAS;EACb,QAAQ,SAAS;EACjB,SAAS,SAAS;EAClB,KAAK,SAAS;EACd,MAAM,YAAY,KAAK,MAAM;EAC7B,MAAM,YAAY,KAAK,MAAM,MAAM,KAAK,MAAM,CAAC;EAC/C,MAAM,YAAY;EAClB,aAAa;EACb;AAED,QAAO;;;;;;;;;;;;AAaR,eAAsB,QACrB,KACA,MACA,SACwB;CACxB,MAAM,YAAY,IAAI,UAAU;CAEhC,IAAIC;AAGJ,iDAAI,KAAM,MAAM;;AAMf,SAJgB,kCAAkB,IAAI,cAAtB,mCAAoC,OAAO,EAC1D,UAAU,qBACV,CAAC,SAEiB,QAAQ,WAAW,KAAK,CAAC;QACtC;;EAEN,MAAM,uCAAc,kBAAkB,0FAAY,gDAAI,KAAM,OAAO;AACnE,MAAI,YACH,OAAM;OACA;AACN,SAAM,QAAQ,WAAW,KAAK,CAC5B,KAAK,gBAAgB,CACrB,cAAc;;AACd,gDAAkB,oFAAY,mDAAO,KAAM,OAAO;AAClD,mCAAI,kBAAkB,4FAAY,UAAS,EAC1C,QAAO,kBAAkB;KAEzB;AAEH,IADa,kBAAkB,eAAlB,kBAAkB,6BAAe,IAAI,KAAK,GACnD,gDAAI,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"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
const require_richText = require(
|
|
2
|
-
const require_link = require(
|
|
3
|
-
const require_Asset = require(
|
|
4
|
-
const require_Document = require(
|
|
5
|
-
const require_isFilled = require(
|
|
6
|
-
const require_isMigrationValue = require(
|
|
7
|
-
const require_getOptionalLinkProperties = require(
|
|
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_isFilled = require('../helpers/isFilled.cjs');
|
|
6
|
+
const require_isMigrationValue = require('./isMigrationValue.cjs');
|
|
7
|
+
const require_getOptionalLinkProperties = require('./getOptionalLinkProperties.cjs');
|
|
8
|
+
|
|
8
9
|
//#region src/lib/resolveMigrationDocumentData.ts
|
|
9
10
|
/**
|
|
10
11
|
* Resolves a migration content relationship to a content relationship field.
|
|
@@ -45,9 +46,9 @@ async function resolveMigrationContentRelationship(relation) {
|
|
|
45
46
|
*
|
|
46
47
|
* @returns Resolved image field.
|
|
47
48
|
*/
|
|
48
|
-
const resolveMigrationImage = (image, migration, withThumbnails) => {
|
|
49
|
+
const resolveMigrationImage = (image$1, migration, withThumbnails) => {
|
|
49
50
|
var _migration$_assets$ge;
|
|
50
|
-
const { id: master
|
|
51
|
+
const { id: master,...thumbnails } = image$1 instanceof require_Asset.PrismicMigrationAsset ? { id: image$1 } : image$1;
|
|
51
52
|
const asset = (_migration$_assets$ge = migration._assets.get(master.config.id)) === null || _migration$_assets$ge === void 0 ? void 0 : _migration$_assets$ge.asset;
|
|
52
53
|
const maybeInitialField = master.originalField;
|
|
53
54
|
if (asset) {
|
|
@@ -88,12 +89,12 @@ const resolveMigrationImage = (image, migration, withThumbnails) => {
|
|
|
88
89
|
*
|
|
89
90
|
* @returns Resolved rich text image node.
|
|
90
91
|
*/
|
|
91
|
-
const resolveMigrationRTImageNode = async (rtImageNode, migration) => {
|
|
92
|
-
const image = resolveMigrationImage(rtImageNode.id, migration);
|
|
93
|
-
if (image) {
|
|
94
|
-
const linkTo = await resolveMigrationDocumentData(rtImageNode.linkTo, migration);
|
|
92
|
+
const resolveMigrationRTImageNode = async (rtImageNode$1, migration) => {
|
|
93
|
+
const image$1 = resolveMigrationImage(rtImageNode$1.id, migration);
|
|
94
|
+
if (image$1) {
|
|
95
|
+
const linkTo = await resolveMigrationDocumentData(rtImageNode$1.linkTo, migration);
|
|
95
96
|
return {
|
|
96
|
-
...image,
|
|
97
|
+
...image$1,
|
|
97
98
|
type: require_richText.RichTextNodeType.image,
|
|
98
99
|
linkTo: require_isFilled.link(linkTo) ? linkTo : void 0
|
|
99
100
|
};
|
|
@@ -107,10 +108,10 @@ const resolveMigrationRTImageNode = async (rtImageNode, migration) => {
|
|
|
107
108
|
*
|
|
108
109
|
* @returns Resolved link to media field.
|
|
109
110
|
*/
|
|
110
|
-
const resolveMigrationLinkToMedia = (linkToMedia, migration) => {
|
|
111
|
+
const resolveMigrationLinkToMedia = (linkToMedia$1, migration) => {
|
|
111
112
|
var _migration$_assets$ge2;
|
|
112
|
-
const asset = (_migration$_assets$ge2 = migration._assets.get(linkToMedia.id.config.id)) === null || _migration$_assets$ge2 === void 0 ? void 0 : _migration$_assets$ge2.asset;
|
|
113
|
-
const optionalLinkProperties = require_getOptionalLinkProperties.getOptionalLinkProperties(linkToMedia);
|
|
113
|
+
const asset = (_migration$_assets$ge2 = migration._assets.get(linkToMedia$1.id.config.id)) === null || _migration$_assets$ge2 === void 0 ? void 0 : _migration$_assets$ge2.asset;
|
|
114
|
+
const optionalLinkProperties = require_getOptionalLinkProperties.getOptionalLinkProperties(linkToMedia$1);
|
|
114
115
|
if (asset) return {
|
|
115
116
|
...optionalLinkProperties,
|
|
116
117
|
id: asset.id,
|
|
@@ -148,8 +149,8 @@ async function resolveMigrationDocumentData(input, migration) {
|
|
|
148
149
|
}
|
|
149
150
|
return input;
|
|
150
151
|
}
|
|
152
|
+
|
|
151
153
|
//#endregion
|
|
152
154
|
exports.resolveMigrationContentRelationship = resolveMigrationContentRelationship;
|
|
153
155
|
exports.resolveMigrationDocumentData = resolveMigrationDocumentData;
|
|
154
|
-
|
|
155
156
|
//# sourceMappingURL=resolveMigrationDocumentData.cjs.map
|