@prismicio/client 7.22.0 → 7.22.1-canary.1615579
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/README.md +6 -0
- package/dist/Client.cjs +8 -4
- package/dist/Client.cjs.map +1 -1
- package/dist/Client.d.cts +14 -16
- package/dist/Client.d.cts.map +1 -1
- package/dist/Client.d.ts +14 -16
- package/dist/Client.d.ts.map +1 -1
- package/dist/Client.js +8 -4
- package/dist/Client.js.map +1 -1
- package/dist/Migration.cjs +24 -23
- package/dist/Migration.cjs.map +1 -1
- package/dist/Migration.d.cts +1 -3
- package/dist/Migration.d.cts.map +1 -1
- package/dist/Migration.d.ts +1 -3
- package/dist/Migration.d.ts.map +1 -1
- package/dist/Migration.js +24 -23
- package/dist/Migration.js.map +1 -1
- package/dist/WriteClient.cjs +21 -19
- package/dist/WriteClient.cjs.map +1 -1
- package/dist/WriteClient.d.cts +18 -22
- package/dist/WriteClient.d.cts.map +1 -1
- package/dist/WriteClient.d.ts +18 -22
- package/dist/WriteClient.d.ts.map +1 -1
- package/dist/WriteClient.js +21 -19
- package/dist/WriteClient.js.map +1 -1
- package/dist/buildQueryURL.cjs.map +1 -1
- package/dist/buildQueryURL.d.cts +5 -6
- package/dist/buildQueryURL.d.cts.map +1 -1
- package/dist/buildQueryURL.d.ts +5 -6
- package/dist/buildQueryURL.d.ts.map +1 -1
- package/dist/buildQueryURL.js.map +1 -1
- package/dist/cookie.d.cts +1 -1
- package/dist/cookie.d.cts.map +1 -1
- package/dist/cookie.d.ts +1 -1
- package/dist/cookie.d.ts.map +1 -1
- package/dist/createClient.cjs.map +1 -1
- package/dist/createClient.d.cts +2 -4
- package/dist/createClient.d.cts.map +1 -1
- package/dist/createClient.d.ts +2 -4
- package/dist/createClient.d.ts.map +1 -1
- package/dist/createClient.js.map +1 -1
- package/dist/createMigration.cjs.map +1 -1
- package/dist/createMigration.d.cts +2 -4
- package/dist/createMigration.d.cts.map +1 -1
- package/dist/createMigration.d.ts +2 -4
- package/dist/createMigration.d.ts.map +1 -1
- package/dist/createMigration.js.map +1 -1
- package/dist/createWriteClient.cjs.map +1 -1
- package/dist/createWriteClient.d.cts +2 -4
- package/dist/createWriteClient.d.cts.map +1 -1
- package/dist/createWriteClient.d.ts +2 -4
- package/dist/createWriteClient.d.ts.map +1 -1
- package/dist/createWriteClient.js.map +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts +9 -10
- package/dist/errors.d.cts.map +1 -1
- package/dist/errors.d.ts +9 -10
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/filter.cjs +175 -0
- package/dist/filter.cjs.map +1 -1
- package/dist/filter.d.cts +3 -4
- package/dist/filter.d.cts.map +1 -1
- package/dist/filter.d.ts +3 -4
- package/dist/filter.d.ts.map +1 -1
- package/dist/filter.js +175 -0
- package/dist/filter.js.map +1 -1
- package/dist/getGraphQLEndpoint.cjs.map +1 -1
- package/dist/getGraphQLEndpoint.d.cts +1 -2
- package/dist/getGraphQLEndpoint.d.cts.map +1 -1
- package/dist/getGraphQLEndpoint.d.ts +1 -2
- package/dist/getGraphQLEndpoint.d.ts.map +1 -1
- package/dist/getGraphQLEndpoint.js.map +1 -1
- package/dist/getRepositoryEndpoint.cjs.map +1 -1
- package/dist/getRepositoryEndpoint.d.cts +1 -2
- package/dist/getRepositoryEndpoint.d.cts.map +1 -1
- package/dist/getRepositoryEndpoint.d.ts +1 -2
- package/dist/getRepositoryEndpoint.d.ts.map +1 -1
- package/dist/getRepositoryEndpoint.js.map +1 -1
- package/dist/getRepositoryName.cjs.map +1 -1
- package/dist/getRepositoryName.d.cts +1 -2
- package/dist/getRepositoryName.d.cts.map +1 -1
- package/dist/getRepositoryName.d.ts +1 -2
- package/dist/getRepositoryName.d.ts.map +1 -1
- package/dist/getRepositoryName.js.map +1 -1
- package/dist/getToolbarSrc.cjs.map +1 -1
- package/dist/getToolbarSrc.d.cts +1 -2
- package/dist/getToolbarSrc.d.cts.map +1 -1
- package/dist/getToolbarSrc.d.ts +1 -2
- package/dist/getToolbarSrc.d.ts.map +1 -1
- package/dist/getToolbarSrc.js.map +1 -1
- package/dist/helpers/asDate.cjs.map +1 -1
- package/dist/helpers/asDate.d.cts +1 -3
- package/dist/helpers/asDate.d.cts.map +1 -1
- package/dist/helpers/asDate.d.ts +1 -3
- package/dist/helpers/asDate.d.ts.map +1 -1
- package/dist/helpers/asDate.js.map +1 -1
- package/dist/helpers/asHTML.cjs +7 -5
- package/dist/helpers/asHTML.cjs.map +1 -1
- package/dist/helpers/asHTML.d.cts +12 -11
- package/dist/helpers/asHTML.d.cts.map +1 -1
- package/dist/helpers/asHTML.d.ts +12 -11
- package/dist/helpers/asHTML.d.ts.map +1 -1
- package/dist/helpers/asHTML.js +7 -5
- package/dist/helpers/asHTML.js.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.d.cts +3 -4
- package/dist/helpers/asImagePixelDensitySrcSet.d.cts.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.d.ts +3 -4
- package/dist/helpers/asImagePixelDensitySrcSet.d.ts.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -1
- package/dist/helpers/asImageSrc.cjs.map +1 -1
- package/dist/helpers/asImageSrc.d.cts +1 -3
- package/dist/helpers/asImageSrc.d.cts.map +1 -1
- package/dist/helpers/asImageSrc.d.ts +1 -3
- package/dist/helpers/asImageSrc.d.ts.map +1 -1
- package/dist/helpers/asImageSrc.js.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.cjs.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.d.cts +3 -4
- package/dist/helpers/asImageWidthSrcSet.d.cts.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.d.ts +3 -4
- package/dist/helpers/asImageWidthSrcSet.d.ts.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.js.map +1 -1
- package/dist/helpers/asLink.cjs.map +1 -1
- package/dist/helpers/asLink.d.cts +3 -5
- package/dist/helpers/asLink.d.cts.map +1 -1
- package/dist/helpers/asLink.d.ts +3 -5
- package/dist/helpers/asLink.d.ts.map +1 -1
- package/dist/helpers/asLink.js.map +1 -1
- package/dist/helpers/asLinkAttrs.cjs.map +1 -1
- package/dist/helpers/asLinkAttrs.d.cts +2 -4
- package/dist/helpers/asLinkAttrs.d.cts.map +1 -1
- package/dist/helpers/asLinkAttrs.d.ts +2 -4
- package/dist/helpers/asLinkAttrs.d.ts.map +1 -1
- package/dist/helpers/asLinkAttrs.js.map +1 -1
- package/dist/helpers/asText.cjs.map +1 -1
- package/dist/helpers/asText.d.cts +1 -3
- package/dist/helpers/asText.d.cts.map +1 -1
- package/dist/helpers/asText.d.ts +1 -3
- package/dist/helpers/asText.d.ts.map +1 -1
- package/dist/helpers/asText.js.map +1 -1
- package/dist/helpers/documentToLinkField.cjs.map +1 -1
- package/dist/helpers/documentToLinkField.d.cts +1 -3
- package/dist/helpers/documentToLinkField.d.cts.map +1 -1
- package/dist/helpers/documentToLinkField.d.ts +1 -3
- package/dist/helpers/documentToLinkField.d.ts.map +1 -1
- package/dist/helpers/documentToLinkField.js.map +1 -1
- package/dist/helpers/isFilled.cjs +20 -0
- package/dist/helpers/isFilled.cjs.map +1 -1
- package/dist/helpers/isFilled.d.cts +22 -24
- package/dist/helpers/isFilled.d.cts.map +1 -1
- package/dist/helpers/isFilled.d.ts +22 -24
- package/dist/helpers/isFilled.d.ts.map +1 -1
- package/dist/helpers/isFilled.js +1 -1
- package/dist/helpers/isFilled.js.map +1 -1
- package/dist/helpers/mapSliceZone.cjs.map +1 -1
- package/dist/helpers/mapSliceZone.d.cts +10 -8
- package/dist/helpers/mapSliceZone.d.cts.map +1 -1
- package/dist/helpers/mapSliceZone.d.ts +10 -8
- package/dist/helpers/mapSliceZone.d.ts.map +1 -1
- package/dist/helpers/mapSliceZone.js.map +1 -1
- package/dist/index.d.cts +3 -4
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/isRepositoryEndpoint.cjs.map +1 -1
- package/dist/isRepositoryEndpoint.d.cts +1 -2
- package/dist/isRepositoryEndpoint.d.cts.map +1 -1
- package/dist/isRepositoryEndpoint.d.ts +1 -2
- package/dist/isRepositoryEndpoint.d.ts.map +1 -1
- package/dist/isRepositoryEndpoint.js.map +1 -1
- package/dist/isRepositoryName.cjs.map +1 -1
- package/dist/isRepositoryName.d.cts +1 -2
- package/dist/isRepositoryName.d.cts.map +1 -1
- package/dist/isRepositoryName.d.ts +1 -2
- package/dist/isRepositoryName.d.ts.map +1 -1
- package/dist/isRepositoryName.js.map +1 -1
- package/dist/lib/devMsg.cjs.map +1 -1
- package/dist/lib/devMsg.js.map +1 -1
- package/dist/lib/escapeHTML.cjs.map +1 -1
- package/dist/lib/escapeHTML.js.map +1 -1
- package/dist/lib/getOptionalLinkProperties.cjs.map +1 -1
- package/dist/lib/getOptionalLinkProperties.js.map +1 -1
- package/dist/lib/getPreviewCookie.cjs.map +1 -1
- package/dist/lib/getPreviewCookie.js.map +1 -1
- package/dist/lib/isInternalURL.cjs.map +1 -1
- package/dist/lib/isInternalURL.js.map +1 -1
- package/dist/lib/isMigrationValue.cjs.map +1 -1
- package/dist/lib/isMigrationValue.js.map +1 -1
- package/dist/lib/isValue.cjs.map +1 -1
- package/dist/lib/isValue.js.map +1 -1
- package/dist/lib/pLimit.cjs.map +1 -1
- package/dist/lib/pLimit.js.map +1 -1
- package/dist/lib/request.cjs +1 -0
- package/dist/lib/request.cjs.map +1 -1
- package/dist/lib/request.d.cts +5 -6
- package/dist/lib/request.d.cts.map +1 -1
- package/dist/lib/request.d.ts +5 -6
- package/dist/lib/request.d.ts.map +1 -1
- package/dist/lib/request.js +1 -1
- package/dist/lib/request.js.map +1 -1
- package/dist/lib/resolveMigrationDocumentData.cjs +3 -0
- package/dist/lib/resolveMigrationDocumentData.cjs.map +1 -1
- package/dist/lib/resolveMigrationDocumentData.js +1 -1
- package/dist/lib/resolveMigrationDocumentData.js.map +1 -1
- package/dist/lib/serializerHelpers.cjs +10 -6
- package/dist/lib/serializerHelpers.cjs.map +1 -1
- package/dist/lib/serializerHelpers.js +10 -6
- package/dist/lib/serializerHelpers.js.map +1 -1
- package/dist/lib/throttledWarn.cjs.map +1 -1
- package/dist/lib/throttledWarn.js.map +1 -1
- package/dist/lib/validateAssetMetadata.cjs.map +1 -1
- package/dist/lib/validateAssetMetadata.js.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.js +1 -1
- package/dist/richtext/asText.cjs.map +1 -1
- package/dist/richtext/asText.d.cts +1 -3
- package/dist/richtext/asText.d.cts.map +1 -1
- package/dist/richtext/asText.d.ts +1 -3
- package/dist/richtext/asText.d.ts.map +1 -1
- package/dist/richtext/asText.js.map +1 -1
- package/dist/richtext/asTree.cjs.map +1 -1
- package/dist/richtext/asTree.d.cts +1 -3
- package/dist/richtext/asTree.d.cts.map +1 -1
- package/dist/richtext/asTree.d.ts +1 -3
- package/dist/richtext/asTree.d.ts.map +1 -1
- package/dist/richtext/asTree.js.map +1 -1
- package/dist/richtext/composeSerializers.cjs.map +1 -1
- package/dist/richtext/composeSerializers.d.cts +1 -3
- package/dist/richtext/composeSerializers.d.cts.map +1 -1
- package/dist/richtext/composeSerializers.d.ts +1 -3
- package/dist/richtext/composeSerializers.d.ts.map +1 -1
- package/dist/richtext/composeSerializers.js.map +1 -1
- package/dist/richtext/serialize.cjs.map +1 -1
- package/dist/richtext/serialize.d.cts +1 -3
- package/dist/richtext/serialize.d.cts.map +1 -1
- package/dist/richtext/serialize.d.ts +1 -3
- package/dist/richtext/serialize.d.ts.map +1 -1
- package/dist/richtext/serialize.js.map +1 -1
- package/dist/richtext/types.cjs.map +1 -1
- package/dist/richtext/types.d.cts +5 -7
- package/dist/richtext/types.d.cts.map +1 -1
- package/dist/richtext/types.d.ts +5 -7
- package/dist/richtext/types.d.ts.map +1 -1
- package/dist/richtext/types.js.map +1 -1
- package/dist/richtext/wrapMapSerializer.cjs.map +1 -1
- package/dist/richtext/wrapMapSerializer.d.cts +1 -3
- package/dist/richtext/wrapMapSerializer.d.cts.map +1 -1
- package/dist/richtext/wrapMapSerializer.d.ts +1 -3
- package/dist/richtext/wrapMapSerializer.d.ts.map +1 -1
- package/dist/richtext/wrapMapSerializer.js.map +1 -1
- package/dist/types/api/asset/asset.d.cts +35 -20
- package/dist/types/api/asset/asset.d.cts.map +1 -1
- package/dist/types/api/asset/asset.d.ts +35 -20
- package/dist/types/api/asset/asset.d.ts.map +1 -1
- package/dist/types/api/asset/tag.d.cts +12 -7
- package/dist/types/api/asset/tag.d.cts.map +1 -1
- package/dist/types/api/asset/tag.d.ts +12 -7
- package/dist/types/api/asset/tag.d.ts.map +1 -1
- package/dist/types/api/integration.d.cts +2 -4
- package/dist/types/api/integration.d.cts.map +1 -1
- package/dist/types/api/integration.d.ts +2 -4
- package/dist/types/api/integration.d.ts.map +1 -1
- package/dist/types/api/migration/release.d.cts +3 -7
- package/dist/types/api/migration/release.d.cts.map +1 -1
- package/dist/types/api/migration/release.d.ts +3 -7
- package/dist/types/api/migration/release.d.ts.map +1 -1
- package/dist/types/api/query.d.cts +1 -3
- package/dist/types/api/query.d.cts.map +1 -1
- package/dist/types/api/query.d.ts +1 -3
- package/dist/types/api/query.d.ts.map +1 -1
- package/dist/types/api/ref.d.cts +1 -2
- package/dist/types/api/ref.d.cts.map +1 -1
- package/dist/types/api/ref.d.ts +1 -2
- package/dist/types/api/ref.d.ts.map +1 -1
- package/dist/types/api/release.d.cts +1 -3
- package/dist/types/api/release.d.cts.map +1 -1
- package/dist/types/api/release.d.ts +1 -3
- package/dist/types/api/release.d.ts.map +1 -1
- package/dist/types/api/repository.d.cts +4 -6
- package/dist/types/api/repository.d.cts.map +1 -1
- package/dist/types/api/repository.d.ts +4 -6
- package/dist/types/api/repository.d.ts.map +1 -1
- package/dist/types/api/tags.d.cts +1 -2
- package/dist/types/api/tags.d.cts.map +1 -1
- package/dist/types/api/tags.d.ts +1 -2
- package/dist/types/api/tags.d.ts.map +1 -1
- package/dist/types/migration/Asset.cjs.map +1 -1
- package/dist/types/migration/Asset.d.cts +21 -15
- package/dist/types/migration/Asset.d.cts.map +1 -1
- package/dist/types/migration/Asset.d.ts +21 -15
- package/dist/types/migration/Asset.d.ts.map +1 -1
- package/dist/types/migration/Asset.js.map +1 -1
- package/dist/types/migration/ContentRelationship.d.cts +1 -3
- package/dist/types/migration/ContentRelationship.d.cts.map +1 -1
- package/dist/types/migration/ContentRelationship.d.ts +1 -3
- package/dist/types/migration/ContentRelationship.d.ts.map +1 -1
- package/dist/types/migration/Document.cjs.map +1 -1
- package/dist/types/migration/Document.d.cts +8 -8
- package/dist/types/migration/Document.d.cts.map +1 -1
- package/dist/types/migration/Document.d.ts +8 -8
- package/dist/types/migration/Document.d.ts.map +1 -1
- package/dist/types/migration/Document.js.map +1 -1
- package/dist/types/model/boolean.d.cts +1 -3
- package/dist/types/model/boolean.d.cts.map +1 -1
- package/dist/types/model/boolean.d.ts +1 -3
- package/dist/types/model/boolean.d.ts.map +1 -1
- package/dist/types/model/color.d.cts +1 -3
- package/dist/types/model/color.d.cts.map +1 -1
- package/dist/types/model/color.d.ts +1 -3
- package/dist/types/model/color.d.ts.map +1 -1
- package/dist/types/model/contentRelationship.d.cts +6 -8
- package/dist/types/model/contentRelationship.d.cts.map +1 -1
- package/dist/types/model/contentRelationship.d.ts +6 -8
- package/dist/types/model/contentRelationship.d.ts.map +1 -1
- package/dist/types/model/customType.d.cts +3 -5
- package/dist/types/model/customType.d.cts.map +1 -1
- package/dist/types/model/customType.d.ts +3 -5
- package/dist/types/model/customType.d.ts.map +1 -1
- package/dist/types/model/date.d.cts +1 -3
- package/dist/types/model/date.d.cts.map +1 -1
- package/dist/types/model/date.d.ts +1 -3
- package/dist/types/model/date.d.ts.map +1 -1
- package/dist/types/model/embed.d.cts +1 -3
- package/dist/types/model/embed.d.cts.map +1 -1
- package/dist/types/model/embed.d.ts +1 -3
- package/dist/types/model/embed.d.ts.map +1 -1
- package/dist/types/model/geoPoint.d.cts +1 -3
- package/dist/types/model/geoPoint.d.cts.map +1 -1
- package/dist/types/model/geoPoint.d.ts +1 -3
- package/dist/types/model/geoPoint.d.ts.map +1 -1
- package/dist/types/model/group.d.cts +2 -4
- package/dist/types/model/group.d.cts.map +1 -1
- package/dist/types/model/group.d.ts +2 -4
- package/dist/types/model/group.d.ts.map +1 -1
- package/dist/types/model/image.d.cts +3 -5
- package/dist/types/model/image.d.cts.map +1 -1
- package/dist/types/model/image.d.ts +3 -5
- package/dist/types/model/image.d.ts.map +1 -1
- package/dist/types/model/integration.d.cts +1 -3
- package/dist/types/model/integration.d.cts.map +1 -1
- package/dist/types/model/integration.d.ts +1 -3
- package/dist/types/model/integration.d.ts.map +1 -1
- package/dist/types/model/keyText.d.cts +1 -3
- package/dist/types/model/keyText.d.cts.map +1 -1
- package/dist/types/model/keyText.d.ts +1 -3
- package/dist/types/model/keyText.d.ts.map +1 -1
- package/dist/types/model/link.cjs.map +1 -1
- package/dist/types/model/link.d.cts +2 -4
- package/dist/types/model/link.d.cts.map +1 -1
- package/dist/types/model/link.d.ts +2 -4
- package/dist/types/model/link.d.ts.map +1 -1
- package/dist/types/model/link.js.map +1 -1
- package/dist/types/model/linkToMedia.d.cts +1 -3
- package/dist/types/model/linkToMedia.d.cts.map +1 -1
- package/dist/types/model/linkToMedia.d.ts +1 -3
- package/dist/types/model/linkToMedia.d.ts.map +1 -1
- package/dist/types/model/number.d.cts +1 -3
- package/dist/types/model/number.d.cts.map +1 -1
- package/dist/types/model/number.d.ts +1 -3
- package/dist/types/model/number.d.ts.map +1 -1
- package/dist/types/model/range.d.cts +1 -3
- package/dist/types/model/range.d.cts.map +1 -1
- package/dist/types/model/range.d.ts +1 -3
- package/dist/types/model/range.d.ts.map +1 -1
- package/dist/types/model/richText.d.cts +3 -5
- package/dist/types/model/richText.d.cts.map +1 -1
- package/dist/types/model/richText.d.ts +3 -5
- package/dist/types/model/richText.d.ts.map +1 -1
- package/dist/types/model/select.d.cts +1 -3
- package/dist/types/model/select.d.cts.map +1 -1
- package/dist/types/model/select.d.ts +1 -3
- package/dist/types/model/select.d.ts.map +1 -1
- package/dist/types/model/separator.d.cts +1 -3
- package/dist/types/model/separator.d.cts.map +1 -1
- package/dist/types/model/separator.d.ts +1 -3
- package/dist/types/model/separator.d.ts.map +1 -1
- package/dist/types/model/sharedSlice.d.cts +1 -3
- package/dist/types/model/sharedSlice.d.cts.map +1 -1
- package/dist/types/model/sharedSlice.d.ts +1 -3
- package/dist/types/model/sharedSlice.d.ts.map +1 -1
- package/dist/types/model/sharedSliceVariation.d.cts +1 -3
- package/dist/types/model/sharedSliceVariation.d.cts.map +1 -1
- package/dist/types/model/sharedSliceVariation.d.ts +1 -3
- package/dist/types/model/sharedSliceVariation.d.ts.map +1 -1
- package/dist/types/model/slice.cjs.map +1 -1
- package/dist/types/model/slice.d.cts +3 -5
- package/dist/types/model/slice.d.cts.map +1 -1
- package/dist/types/model/slice.d.ts +3 -5
- package/dist/types/model/slice.d.ts.map +1 -1
- package/dist/types/model/slice.js.map +1 -1
- package/dist/types/model/sliceZone.cjs.map +1 -1
- package/dist/types/model/sliceZone.d.cts +4 -6
- package/dist/types/model/sliceZone.d.cts.map +1 -1
- package/dist/types/model/sliceZone.d.ts +4 -6
- package/dist/types/model/sliceZone.d.ts.map +1 -1
- package/dist/types/model/sliceZone.js.map +1 -1
- package/dist/types/model/table.d.cts +1 -3
- package/dist/types/model/table.d.cts.map +1 -1
- package/dist/types/model/table.d.ts +1 -3
- package/dist/types/model/table.d.ts.map +1 -1
- package/dist/types/model/timestamp.d.cts +1 -3
- package/dist/types/model/timestamp.d.cts.map +1 -1
- package/dist/types/model/timestamp.d.ts +1 -3
- package/dist/types/model/timestamp.d.ts.map +1 -1
- package/dist/types/model/title.d.cts +1 -3
- package/dist/types/model/title.d.cts.map +1 -1
- package/dist/types/model/title.d.ts +1 -3
- package/dist/types/model/title.d.ts.map +1 -1
- package/dist/types/model/types.cjs +4 -0
- package/dist/types/model/types.cjs.map +1 -1
- package/dist/types/model/types.d.cts +13 -11
- package/dist/types/model/types.d.cts.map +1 -1
- package/dist/types/model/types.d.ts +13 -11
- package/dist/types/model/types.d.ts.map +1 -1
- package/dist/types/model/types.js +4 -0
- package/dist/types/model/types.js.map +1 -1
- package/dist/types/model/uid.d.cts +1 -3
- package/dist/types/model/uid.d.cts.map +1 -1
- package/dist/types/model/uid.d.ts +1 -3
- package/dist/types/model/uid.d.ts.map +1 -1
- package/dist/types/value/boolean.d.cts +1 -2
- package/dist/types/value/boolean.d.cts.map +1 -1
- package/dist/types/value/boolean.d.ts +1 -2
- package/dist/types/value/boolean.d.ts.map +1 -1
- package/dist/types/value/color.d.cts +1 -3
- package/dist/types/value/color.d.cts.map +1 -1
- package/dist/types/value/color.d.ts +1 -3
- package/dist/types/value/color.d.ts.map +1 -1
- package/dist/types/value/contentRelationship.d.cts +3 -5
- package/dist/types/value/contentRelationship.d.cts.map +1 -1
- package/dist/types/value/contentRelationship.d.ts +3 -5
- package/dist/types/value/contentRelationship.d.ts.map +1 -1
- package/dist/types/value/date.d.cts +1 -3
- package/dist/types/value/date.d.cts.map +1 -1
- package/dist/types/value/date.d.ts +1 -3
- package/dist/types/value/date.d.ts.map +1 -1
- package/dist/types/value/document.d.cts +5 -7
- package/dist/types/value/document.d.cts.map +1 -1
- package/dist/types/value/document.d.ts +5 -7
- package/dist/types/value/document.d.ts.map +1 -1
- package/dist/types/value/embed.cjs.map +1 -1
- package/dist/types/value/embed.d.cts +43 -25
- package/dist/types/value/embed.d.cts.map +1 -1
- package/dist/types/value/embed.d.ts +43 -25
- package/dist/types/value/embed.d.ts.map +1 -1
- package/dist/types/value/embed.js.map +1 -1
- package/dist/types/value/geoPoint.d.cts +1 -3
- package/dist/types/value/geoPoint.d.cts.map +1 -1
- package/dist/types/value/geoPoint.d.ts +1 -3
- package/dist/types/value/geoPoint.d.ts.map +1 -1
- package/dist/types/value/group.d.cts +2 -4
- package/dist/types/value/group.d.cts.map +1 -1
- package/dist/types/value/group.d.ts +2 -4
- package/dist/types/value/group.d.ts.map +1 -1
- package/dist/types/value/image.d.cts +4 -6
- package/dist/types/value/image.d.cts.map +1 -1
- package/dist/types/value/image.d.ts +4 -6
- package/dist/types/value/image.d.ts.map +1 -1
- package/dist/types/value/integration.d.cts +2 -4
- package/dist/types/value/integration.d.cts.map +1 -1
- package/dist/types/value/integration.d.ts +2 -4
- package/dist/types/value/integration.d.ts.map +1 -1
- package/dist/types/value/keyText.d.cts +1 -3
- package/dist/types/value/keyText.d.cts.map +1 -1
- package/dist/types/value/keyText.d.ts +1 -3
- package/dist/types/value/keyText.d.ts.map +1 -1
- package/dist/types/value/link.cjs.map +1 -1
- package/dist/types/value/link.d.cts +6 -8
- package/dist/types/value/link.d.cts.map +1 -1
- package/dist/types/value/link.d.ts +6 -8
- package/dist/types/value/link.d.ts.map +1 -1
- package/dist/types/value/link.js.map +1 -1
- package/dist/types/value/linkToMedia.d.cts +2 -4
- package/dist/types/value/linkToMedia.d.cts.map +1 -1
- package/dist/types/value/linkToMedia.d.ts +2 -4
- package/dist/types/value/linkToMedia.d.ts.map +1 -1
- package/dist/types/value/number.d.cts +1 -3
- package/dist/types/value/number.d.cts.map +1 -1
- package/dist/types/value/number.d.ts +1 -3
- package/dist/types/value/number.d.ts.map +1 -1
- package/dist/types/value/richText.cjs.map +1 -1
- package/dist/types/value/richText.d.cts +29 -31
- package/dist/types/value/richText.d.cts.map +1 -1
- package/dist/types/value/richText.d.ts +29 -31
- package/dist/types/value/richText.d.ts.map +1 -1
- package/dist/types/value/richText.js.map +1 -1
- package/dist/types/value/select.d.cts +1 -3
- package/dist/types/value/select.d.cts.map +1 -1
- package/dist/types/value/select.d.ts +1 -3
- package/dist/types/value/select.d.ts.map +1 -1
- package/dist/types/value/sharedSlice.d.cts +1 -3
- package/dist/types/value/sharedSlice.d.cts.map +1 -1
- package/dist/types/value/sharedSlice.d.ts +1 -3
- package/dist/types/value/sharedSlice.d.ts.map +1 -1
- package/dist/types/value/sharedSliceVariation.d.cts +1 -3
- package/dist/types/value/sharedSliceVariation.d.cts.map +1 -1
- package/dist/types/value/sharedSliceVariation.d.ts +1 -3
- package/dist/types/value/sharedSliceVariation.d.ts.map +1 -1
- package/dist/types/value/slice.d.cts +1 -3
- package/dist/types/value/slice.d.cts.map +1 -1
- package/dist/types/value/slice.d.ts +1 -3
- package/dist/types/value/slice.d.ts.map +1 -1
- package/dist/types/value/sliceZone.d.cts +1 -3
- package/dist/types/value/sliceZone.d.cts.map +1 -1
- package/dist/types/value/sliceZone.d.ts +1 -3
- package/dist/types/value/sliceZone.d.ts.map +1 -1
- package/dist/types/value/table.d.cts +26 -16
- package/dist/types/value/table.d.cts.map +1 -1
- package/dist/types/value/table.d.ts +26 -16
- package/dist/types/value/table.d.ts.map +1 -1
- package/dist/types/value/timestamp.d.cts +1 -3
- package/dist/types/value/timestamp.d.cts.map +1 -1
- package/dist/types/value/timestamp.d.ts +1 -3
- package/dist/types/value/timestamp.d.ts.map +1 -1
- package/dist/types/value/title.d.cts +1 -3
- package/dist/types/value/title.d.cts.map +1 -1
- package/dist/types/value/title.d.ts +1 -3
- package/dist/types/value/title.d.ts.map +1 -1
- package/dist/types/value/types.d.cts +6 -8
- package/dist/types/value/types.d.cts.map +1 -1
- package/dist/types/value/types.d.ts +6 -8
- package/dist/types/value/types.d.ts.map +1 -1
- package/dist/types/webhook/apiUpdate.d.cts +1 -3
- package/dist/types/webhook/apiUpdate.d.cts.map +1 -1
- package/dist/types/webhook/apiUpdate.d.ts +1 -3
- package/dist/types/webhook/apiUpdate.d.ts.map +1 -1
- package/dist/types/webhook/testTrigger.d.cts +1 -3
- package/dist/types/webhook/testTrigger.d.cts.map +1 -1
- package/dist/types/webhook/testTrigger.d.ts +1 -3
- package/dist/types/webhook/testTrigger.d.ts.map +1 -1
- package/dist/types/webhook/types.cjs.map +1 -1
- package/dist/types/webhook/types.d.cts +3 -5
- package/dist/types/webhook/types.d.cts.map +1 -1
- package/dist/types/webhook/types.d.ts +3 -5
- package/dist/types/webhook/types.d.ts.map +1 -1
- package/dist/types/webhook/types.js.map +1 -1
- package/package.json +11 -11
- package/src/WriteClient.ts +14 -19
- package/src/lib/resolveMigrationDocumentData.ts +1 -1
- package/src/types/api/migration/release.ts +2 -5
package/dist/WriteClient.js
CHANGED
|
@@ -65,27 +65,24 @@ var WriteClient = class extends Client {
|
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
|
-
* Publishes the repository's migration release, moving its documents into the
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* @param params - Additional fetch parameters.
|
|
72
|
-
*
|
|
73
|
-
* @returns The result of the publish operation, including the total number of
|
|
74
|
-
* documents that were published.
|
|
68
|
+
* Publishes the repository's migration release, moving its documents into the repository as
|
|
69
|
+
* published content.
|
|
75
70
|
*
|
|
76
71
|
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* const migration = createMigration()
|
|
77
74
|
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
* // Prepare and run a migration.
|
|
82
|
-
* migration.createDocument(doc, "My document")
|
|
83
|
-
* await writeClient.migrate(migration)
|
|
75
|
+
* // Prepare and run a migration.
|
|
76
|
+
* migration.createDocument(doc, "My document")
|
|
77
|
+
* await writeClient.migrate(migration)
|
|
84
78
|
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
79
|
+
* // Publish the migration release.
|
|
80
|
+
* const { totalItems } = await writeClient.publishMigrationRelease()
|
|
81
|
+
* ```
|
|
88
82
|
*
|
|
83
|
+
* @param params - Additional fetch parameters.
|
|
84
|
+
* @returns The result of the publish operation, including the total number of documents that were
|
|
85
|
+
* published.
|
|
89
86
|
* @see Prismic Migration API technical reference: {@link https://prismic.io/docs/migration-api-technical-reference}
|
|
90
87
|
*/
|
|
91
88
|
async publishMigrationRelease(params) {
|
|
@@ -160,8 +157,10 @@ var WriteClient = class extends Client {
|
|
|
160
157
|
data: { masterLocale }
|
|
161
158
|
});
|
|
162
159
|
const documentsToCreate = [];
|
|
163
|
-
for (const doc of migration._documents) if (!doc.document.id)
|
|
164
|
-
|
|
160
|
+
for (const doc of migration._documents) if (!doc.document.id) {
|
|
161
|
+
if (doc.document.lang === masterLocale) documentsToCreate.unshift(doc);
|
|
162
|
+
else documentsToCreate.push(doc);
|
|
163
|
+
}
|
|
165
164
|
let created = 0;
|
|
166
165
|
for (const doc of documentsToCreate) {
|
|
167
166
|
reporter?.({
|
|
@@ -473,7 +472,10 @@ var WriteClient = class extends Client {
|
|
|
473
472
|
switch (response.status) {
|
|
474
473
|
case 400: throw new InvalidDataError(message, response.url, payload);
|
|
475
474
|
case 401: throw new ForbiddenError(message, response.url, payload);
|
|
476
|
-
case 403:
|
|
475
|
+
case 403: {
|
|
476
|
+
const msg = message ?? payload.Message;
|
|
477
|
+
throw new ForbiddenError(msg, response.url, payload);
|
|
478
|
+
}
|
|
477
479
|
case 404: throw new NotFoundError(message, response.url, payload);
|
|
478
480
|
default: throw new PrismicError(message, response.url, payload);
|
|
479
481
|
}
|
package/dist/WriteClient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WriteClient.js","names":["#request","#handleMigrationAPIError","#handleAssetAPIError"],"sources":["../src/WriteClient.ts"],"sourcesContent":["import { name, version } from \"../package.json\"\nimport { Client } from \"./Client\"\nimport type { ClientConfig, FetchParams } from \"./Client\"\n// oxlint-disable-next-line no-unused-vars\nimport type { createMigration } from \"./createMigration\"\nimport { ForbiddenError, InvalidDataError, NotFoundError, PrismicError } from \"./errors\"\nimport { devMsg } from \"./lib/devMsg\"\nimport { pLimit } from \"./lib/pLimit\"\nimport type { ResponseLike } from \"./lib/request\"\nimport { type RequestInitLike, request } from \"./lib/request\"\nimport {\n\tresolveMigrationContentRelationship,\n\tresolveMigrationDocumentData,\n} from \"./lib/resolveMigrationDocumentData\"\nimport type { Migration } from \"./Migration\"\nimport type {\n\tAsset,\n\tPatchAssetParams,\n\tPostAssetParams,\n\tPostAssetResult,\n} from \"./types/api/asset/asset\"\nimport type { AssetTag, GetAssetTagsResult, PostAssetTagResult } from \"./types/api/asset/tag\"\nimport { type PostDocumentResult } from \"./types/api/migration/document\"\nimport type { PublishMigrationReleaseResult } from \"./types/api/migration/release\"\nimport type { PrismicMigrationAsset } from \"./types/migration/Asset\"\nimport type {\n\tMigrationDocument,\n\tPendingPrismicDocument,\n\tPrismicMigrationDocument,\n} from \"./types/migration/Document\"\nimport type { PrismicDocument } from \"./types/value/document\"\n\nconst CLIENT_IDENTIFIER = `${name.replace(\"@\", \"\").replace(\"/\", \"-\")}/${version}`\n\n/**\n * Extracts one or more Prismic document types that match a given Prismic document type. If no\n * matches are found, no extraction is performed and the union of all provided Prismic document\n * types are returned.\n *\n * @typeParam TDocuments - Prismic document types from which to extract.\n * @typeParam TDocumentType - Type(s) to match `TDocuments` against.\n */\ntype ExtractDocumentType<\n\tTDocuments extends { type: string },\n\tTDocumentType extends TDocuments[\"type\"],\n> =\n\tExtract<TDocuments, { type: TDocumentType }> extends never\n\t\t? TDocuments\n\t\t: Extract<TDocuments, { type: TDocumentType }>\n\n/** Utility type to construct events reported by the migration process. */\ntype MigrateReporterEvent<TType extends string, TData = never> = TData extends never\n\t? { type: TType }\n\t: {\n\t\t\ttype: TType\n\t\t\tdata: TData\n\t\t}\n\n/** A map of event types and their data reported by the migration process. */\ntype MigrateReporterEventMap = {\n\tstart: {\n\t\tpending: {\n\t\t\tdocuments: number\n\t\t\tassets: number\n\t\t}\n\t}\n\tend: {\n\t\tmigrated: {\n\t\t\tdocuments: number\n\t\t\tassets: number\n\t\t}\n\t}\n\t\"assets:creating\": {\n\t\tcurrent: number\n\t\tremaining: number\n\t\ttotal: number\n\t\tasset: PrismicMigrationAsset\n\t}\n\t\"assets:created\": {\n\t\tcreated: number\n\t}\n\t\"documents:masterLocale\": {\n\t\tmasterLocale: string\n\t}\n\t\"documents:creating\": {\n\t\tcurrent: number\n\t\tremaining: number\n\t\ttotal: number\n\t\tdocument: PrismicMigrationDocument\n\t}\n\t\"documents:created\": {\n\t\tcreated: number\n\t}\n\t\"documents:updating\": {\n\t\tcurrent: number\n\t\tremaining: number\n\t\ttotal: number\n\t\tdocument: PrismicMigrationDocument\n\t}\n\t\"documents:updated\": {\n\t\tupdated: number\n\t}\n}\n\n/** Available event types reported by the migration process. */\ntype MigrateReporterEventTypes = keyof MigrateReporterEventMap\n\n/**\n * All events reported by the migration process. Events can be listened to by providing a `reporter`\n * function to the `migrate` method.\n */\nexport type MigrateReporterEvents = {\n\t[K in MigrateReporterEventTypes]: MigrateReporterEvent<K, MigrateReporterEventMap[K]>\n}[MigrateReporterEventTypes]\n\n/** Additional parameters for creating an asset in the Prismic media library. */\nexport type CreateAssetParams = {\n\t/** Asset notes. */\n\tnotes?: string\n\n\t/** Asset credits. */\n\tcredits?: string\n\n\t/** Asset alt text. */\n\talt?: string\n\n\t/** Asset tags. */\n\ttags?: string[]\n}\n\n/** Configuration for clients that determine how content is queried. */\nexport type WriteClientConfig = {\n\t/** A Prismic write token that allows writing content to the repository. */\n\twriteToken: string\n\n\t/**\n\t * The Prismic Asset API endpoint.\n\t *\n\t * @defaultValue `\"https://asset-api.prismic.io/\"`\n\t * @see Prismic Asset API technical reference: {@link https://prismic.io/docs/asset-api-technical-reference}\n\t */\n\tassetAPIEndpoint?: string\n\n\t/**\n\t * The Prismic Migration API endpoint.\n\t *\n\t * @defaultValue `\"https://migration.prismic.io/\"`\n\t * @see Prismic Migration API technical reference: {@link https://prismic.io/docs/migration-api-technical-reference}\n\t */\n\tmigrationAPIEndpoint?: string\n} & ClientConfig\n\n/**\n * A client that allows querying and writing content to a Prismic repository.\n *\n * If used in an environment where a global `fetch` function is unavailable, such as Node.js, the\n * `fetch` option must be provided as part of the `options` parameter.\n *\n * @typeParam TDocuments - Document types that are registered for the Prismic repository. Query\n * methods will automatically be typed based on this type.\n */\nexport class WriteClient<\n\tTDocuments extends PrismicDocument = PrismicDocument,\n> extends Client<TDocuments> {\n\twriteToken: string\n\n\tassetAPIEndpoint = \"https://asset-api.prismic.io/\"\n\tmigrationAPIEndpoint = \"https://migration.prismic.io/\"\n\n\t/**\n\t * Creates a Prismic client that can be used to query and write content to a repository.\n\t *\n\t * If used in an environment where a global `fetch` function is unavailable, such as in some\n\t * Node.js versions, the `fetch` option must be provided as part of the `options` parameter.\n\t *\n\t * @param repositoryName - The Prismic repository name for the repository.\n\t * @param options - Configuration that determines how content will be queried from and written to\n\t * the Prismic repository.\n\t * @returns A client that can query and write content to the repository.\n\t */\n\tconstructor(repositoryName: string, options: WriteClientConfig) {\n\t\tsuper(repositoryName, options)\n\n\t\tif (typeof globalThis.window !== \"undefined\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[@prismicio/client] Prismic write client appears to be running in a browser environment. This is not recommended as it exposes your write token. Consider using Prismic write client in a server environment only, preferring the regular client for browser environment. For more details, see ${devMsg(\"avoid-write-client-in-browser\")}`,\n\t\t\t)\n\t\t}\n\n\t\tthis.writeToken = options.writeToken\n\n\t\tif (options.assetAPIEndpoint) {\n\t\t\tthis.assetAPIEndpoint = `${options.assetAPIEndpoint}/`\n\t\t}\n\n\t\tif (options.migrationAPIEndpoint) {\n\t\t\tthis.migrationAPIEndpoint = `${options.migrationAPIEndpoint}/`\n\t\t}\n\t}\n\n\t/**\n\t * Creates a migration release on the Prismic repository based on the provided prepared migration.\n\t *\n\t * @param migration - A migration prepared with {@link createMigration}.\n\t * @param params - An event listener and additional fetch parameters.\n\t * @see Prismic Migration API technical reference: {@link https://prismic.io/docs/migration-api-technical-reference}\n\t */\n\tasync migrate(\n\t\tmigration: Migration<TDocuments>,\n\t\tparams: {\n\t\t\treporter?: (event: MigrateReporterEvents) => void\n\t\t} & FetchParams = {},\n\t): Promise<void> {\n\t\tparams.reporter?.({\n\t\t\ttype: \"start\",\n\t\t\tdata: {\n\t\t\t\tpending: {\n\t\t\t\t\tdocuments: migration._documents.length,\n\t\t\t\t\tassets: migration._assets.size,\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\n\t\tawait this.migrateCreateAssets(migration, params)\n\t\tawait this.migrateCreateDocuments(migration, params)\n\t\tawait this.migrateUpdateDocuments(migration, params)\n\n\t\tparams.reporter?.({\n\t\t\ttype: \"end\",\n\t\t\tdata: {\n\t\t\t\tmigrated: {\n\t\t\t\t\tdocuments: migration._documents.length,\n\t\t\t\t\tassets: migration._assets.size,\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\t}\n\n\t/**\n\t * Publishes the repository's migration release, moving its documents into the\n\t * repository as published content.\n\t *\n\t * @param params - Additional fetch parameters.\n\t *\n\t * @returns The result of the publish operation, including the total number of\n\t * documents that were published.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const migration = createMigration()\n\t *\n\t * // Prepare and run a migration.\n\t * migration.createDocument(doc, \"My document\")\n\t * await writeClient.migrate(migration)\n\t *\n\t * // Publish the migration release.\n\t * const { totalItems } = await writeClient.publishMigrationRelease()\n\t * ```\n\t *\n\t * @see Prismic Migration API technical reference: {@link https://prismic.io/docs/migration-api-technical-reference}\n\t */\n\tasync publishMigrationRelease(\n\t\tparams?: FetchParams,\n\t): Promise<PublishMigrationReleaseResult> {\n\t\tconst url = new URL(\"migration-release/publish\", this.migrationAPIEndpoint)\n\n\t\tconst response = await this.#request(url, params, {\n\t\t\tmethod: \"POST\",\n\t\t\t// A body is included so `request()` treats this as a write: it is\n\t\t\t// routed through the per-host write throttle and, crucially, is not\n\t\t\t// deduplicated with concurrent publishes from other repositories\n\t\t\t// (which share this URL but differ only by auth headers).\n\t\t\tbody: JSON.stringify({}),\n\t\t\theaders: {\n\t\t\t\t\"content-type\": \"application/json\",\n\t\t\t\t\"x-client\": CLIENT_IDENTIFIER,\n\t\t\t},\n\t\t})\n\t\tswitch (response.status) {\n\t\t\tcase 202: {\n\t\t\t\tconst json = (await response.json()) as PublishMigrationReleaseResult\n\n\t\t\t\treturn { totalItems: json.totalItems }\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\treturn await this.#handleMigrationAPIError(response)\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Creates assets in the Prismic repository's media library.\n\t *\n\t * @param migration - A migration prepared with {@link createMigration}.\n\t * @param params - An event listener and additional fetch parameters.\n\t * @internal This method is one of the step performed by the {@link migrate} method.\n\t */\n\tprivate async migrateCreateAssets(\n\t\tmigration: Migration<TDocuments>,\n\t\t{\n\t\t\treporter,\n\t\t\t...fetchParams\n\t\t}: { reporter?: (event: MigrateReporterEvents) => void } & FetchParams = {},\n\t): Promise<void> {\n\t\tlet created = 0\n\t\tfor (const [_, migrationAsset] of migration._assets) {\n\t\t\treporter?.({\n\t\t\t\ttype: \"assets:creating\",\n\t\t\t\tdata: {\n\t\t\t\t\tcurrent: ++created,\n\t\t\t\t\tremaining: migration._assets.size - created,\n\t\t\t\t\ttotal: migration._assets.size,\n\t\t\t\t\tasset: migrationAsset,\n\t\t\t\t},\n\t\t\t})\n\n\t\t\tconst { file, filename, notes, credits, alt, tags } = migrationAsset.config\n\n\t\t\tlet resolvedFile: PostAssetParams[\"file\"] | File\n\t\t\tif (typeof file === \"string\") {\n\t\t\t\tlet url: URL | undefined\n\t\t\t\ttry {\n\t\t\t\t\turl = new URL(file)\n\t\t\t\t} catch {\n\t\t\t\t\t// noop only on invalid URL, fetch errors will throw in the next if statement\n\t\t\t\t}\n\n\t\t\t\tif (url) {\n\t\t\t\t\t// File is a URL, fetch it\n\t\t\t\t\tresolvedFile = await this.fetchForeignAsset(url.toString(), fetchParams)\n\t\t\t\t} else {\n\t\t\t\t\t// File is actual file content, use it as-is\n\t\t\t\t\tresolvedFile = file\n\t\t\t\t}\n\t\t\t} else if (file instanceof URL) {\n\t\t\t\t// File is a URL instance, fetch it\n\t\t\t\tresolvedFile = await this.fetchForeignAsset(file.toString(), fetchParams)\n\t\t\t} else {\n\t\t\t\tresolvedFile = file\n\t\t\t}\n\n\t\t\tconst asset = await this.createAsset(resolvedFile, filename, {\n\t\t\t\tnotes,\n\t\t\t\tcredits,\n\t\t\t\talt,\n\t\t\t\ttags,\n\t\t\t\t...fetchParams,\n\t\t\t})\n\n\t\t\tmigrationAsset.asset = asset\n\t\t}\n\n\t\treporter?.({\n\t\t\ttype: \"assets:created\",\n\t\t\tdata: {\n\t\t\t\tcreated,\n\t\t\t},\n\t\t})\n\t}\n\n\t/**\n\t * Creates documents in the Prismic repository's migration release.\n\t *\n\t * @param migration - A migration prepared with {@link createMigration}.\n\t * @param params - An event listener and additional fetch parameters.\n\t * @internal This method is one of the step performed by the {@link migrate} method.\n\t */\n\tprivate async migrateCreateDocuments(\n\t\tmigration: Migration<TDocuments>,\n\t\t{\n\t\t\treporter,\n\t\t\t...fetchParams\n\t\t}: { reporter?: (event: MigrateReporterEvents) => void } & FetchParams = {},\n\t): Promise<void> {\n\t\t// Resolve master locale\n\t\tconst repository = await this.getRepository(fetchParams)\n\t\tconst masterLocale = repository.languages[0].id\n\t\treporter?.({\n\t\t\ttype: \"documents:masterLocale\",\n\t\t\tdata: {\n\t\t\t\tmasterLocale,\n\t\t\t},\n\t\t})\n\n\t\tconst documentsToCreate: PrismicMigrationDocument<TDocuments>[] = []\n\t\t// We create an array with non-master locale documents last because\n\t\t// we need their master locale document to be created first.\n\t\tfor (const doc of migration._documents) {\n\t\t\tif (!doc.document.id) {\n\t\t\t\tif (doc.document.lang === masterLocale) {\n\t\t\t\t\tdocumentsToCreate.unshift(doc)\n\t\t\t\t} else {\n\t\t\t\t\tdocumentsToCreate.push(doc)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tlet created = 0\n\t\tfor (const doc of documentsToCreate) {\n\t\t\treporter?.({\n\t\t\t\ttype: \"documents:creating\",\n\t\t\t\tdata: {\n\t\t\t\t\tcurrent: ++created,\n\t\t\t\t\tremaining: documentsToCreate.length - created,\n\t\t\t\t\ttotal: documentsToCreate.length,\n\t\t\t\t\tdocument: doc,\n\t\t\t\t},\n\t\t\t})\n\n\t\t\t// Resolve master language document ID for non-master locale documents\n\t\t\tlet masterLanguageDocumentID: string | undefined\n\t\t\tif (doc.masterLanguageDocument) {\n\t\t\t\tconst masterLanguageDocument = await resolveMigrationContentRelationship(\n\t\t\t\t\tdoc.masterLanguageDocument,\n\t\t\t\t)\n\n\t\t\t\tmasterLanguageDocumentID =\n\t\t\t\t\t\"id\" in masterLanguageDocument ? masterLanguageDocument.id : undefined\n\t\t\t} else if (doc.originalPrismicDocument) {\n\t\t\t\tconst maybeOriginalID = doc.originalPrismicDocument.alternate_languages.find(\n\t\t\t\t\t({ lang }) => lang === masterLocale,\n\t\t\t\t)?.id\n\n\t\t\t\tif (maybeOriginalID) {\n\t\t\t\t\tmasterLanguageDocumentID = migration._getByOriginalID(maybeOriginalID)?.document.id\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst { id } = await this.createDocument(\n\t\t\t\t// We'll upload documents data later on.\n\t\t\t\t{ ...doc.document, data: {} },\n\t\t\t\tdoc.title!,\n\t\t\t\t{\n\t\t\t\t\tmasterLanguageDocumentID,\n\t\t\t\t\t...fetchParams,\n\t\t\t\t},\n\t\t\t)\n\n\t\t\tdoc.document.id = id\n\t\t}\n\n\t\treporter?.({\n\t\t\ttype: \"documents:created\",\n\t\t\tdata: { created },\n\t\t})\n\t}\n\n\t/**\n\t * Updates documents in the Prismic repository's migration release with their patched data.\n\t *\n\t * @param migration - A migration prepared with {@link createMigration}.\n\t * @param params - An event listener and additional fetch parameters.\n\t * @internal This method is one of the step performed by the {@link migrate} method.\n\t */\n\tprivate async migrateUpdateDocuments(\n\t\tmigration: Migration<TDocuments>,\n\t\t{\n\t\t\treporter,\n\t\t\t...fetchParams\n\t\t}: { reporter?: (event: MigrateReporterEvents) => void } & FetchParams = {},\n\t): Promise<void> {\n\t\tlet i = 0\n\t\tfor (const doc of migration._documents) {\n\t\t\treporter?.({\n\t\t\t\ttype: \"documents:updating\",\n\t\t\t\tdata: {\n\t\t\t\t\tcurrent: ++i,\n\t\t\t\t\tremaining: migration._documents.length - i,\n\t\t\t\t\ttotal: migration._documents.length,\n\t\t\t\t\tdocument: doc,\n\t\t\t\t},\n\t\t\t})\n\n\t\t\tawait this.updateDocument(\n\t\t\t\tdoc.document.id!,\n\t\t\t\t// We need to forward again document name and tags to update them\n\t\t\t\t// in case the document already existed during the previous step.\n\t\t\t\t{\n\t\t\t\t\t...doc.document,\n\t\t\t\t\tdocumentTitle: doc.title,\n\t\t\t\t\tdata: await resolveMigrationDocumentData(doc.document.data, migration),\n\t\t\t\t},\n\t\t\t\tfetchParams,\n\t\t\t)\n\t\t}\n\n\t\treporter?.({\n\t\t\ttype: \"documents:updated\",\n\t\t\tdata: {\n\t\t\t\tupdated: migration._documents.length,\n\t\t\t},\n\t\t})\n\t}\n\n\t/**\n\t * Creates an asset in the Prismic media library.\n\t *\n\t * @param file - The file to upload as an asset.\n\t * @param filename - The filename of the asset.\n\t * @param params - Additional asset data and fetch parameters.\n\t * @returns The created asset.\n\t */\n\tprivate async createAsset(\n\t\tfile: PostAssetParams[\"file\"] | File,\n\t\tfilename: string,\n\t\t{ notes, credits, alt, tags, ...params }: CreateAssetParams & FetchParams = {},\n\t): Promise<Asset> {\n\t\tconst url = new URL(\"assets\", this.assetAPIEndpoint)\n\n\t\tconst formData = new FormData()\n\t\tformData.append(\n\t\t\t\"file\",\n\t\t\tnew File([file], filename, {\n\t\t\t\ttype: file instanceof File ? file.type : undefined,\n\t\t\t}),\n\t\t)\n\n\t\tif (notes) {\n\t\t\tformData.append(\"notes\", notes)\n\t\t}\n\n\t\tif (credits) {\n\t\t\tformData.append(\"credits\", credits)\n\t\t}\n\n\t\tif (alt) {\n\t\t\tformData.append(\"alt\", alt)\n\t\t}\n\n\t\tconst response = await this.#request(url, params, {\n\t\t\tmethod: \"POST\",\n\t\t\tbody: formData,\n\t\t})\n\t\tswitch (response.status) {\n\t\t\tcase 200: {\n\t\t\t\tconst asset = (await response.json()) as PostAssetResult\n\n\t\t\t\tif (tags && tags.length) {\n\t\t\t\t\treturn this.updateAsset(asset.id, { tags })\n\t\t\t\t}\n\n\t\t\t\treturn asset\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\treturn await this.#handleAssetAPIError(response)\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Updates an asset in the Prismic media library.\n\t *\n\t * @param id - The ID of the asset to update.\n\t * @param params - The asset data to update and additional fetch parameters.\n\t * @returns The updated asset.\n\t */\n\tprivate async updateAsset(\n\t\tid: string,\n\t\t{ notes, credits, alt, filename, tags, ...params }: PatchAssetParams & FetchParams = {},\n\t): Promise<Asset> {\n\t\tconst url = new URL(`assets/${id}`, this.assetAPIEndpoint)\n\n\t\t// Resolve tags if any and create missing ones\n\t\tif (tags && tags.length) {\n\t\t\ttags = await this.resolveAssetTagIDs(tags, {\n\t\t\t\tcreateTags: true,\n\t\t\t\t...params,\n\t\t\t})\n\t\t}\n\n\t\tconst response = await this.#request(url, params, {\n\t\t\tmethod: \"PATCH\",\n\t\t\tbody: JSON.stringify({\n\t\t\t\tnotes,\n\t\t\t\tcredits,\n\t\t\t\talt,\n\t\t\t\tfilename,\n\t\t\t\ttags,\n\t\t\t}),\n\t\t\theaders: {\n\t\t\t\t\"content-type\": \"application/json\",\n\t\t\t},\n\t\t})\n\t\tswitch (response.status) {\n\t\t\tcase 200: {\n\t\t\t\treturn (await response.json()) as Asset\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\treturn await this.#handleAssetAPIError(response)\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Fetches a foreign asset from a URL.\n\t *\n\t * @param url - The URL of the asset to fetch.\n\t * @param params - Additional fetch parameters.\n\t * @returns A file representing the fetched asset.\n\t */\n\tprivate async fetchForeignAsset(url: string, params: FetchParams = {}): Promise<Blob> {\n\t\tconst res = await this.#request(new URL(url), params)\n\n\t\tif (!res.ok) {\n\t\t\tthrow new PrismicError(\"Could not fetch foreign asset\", url, undefined)\n\t\t}\n\n\t\tconst buffer = await res.arrayBuffer()\n\n\t\t// Ensure a correct content type is attached to the blob.\n\t\treturn new File([buffer], \"\", {\n\t\t\ttype: res.headers.get(\"content-type\") || undefined,\n\t\t})\n\t}\n\n\t/** {@link resolveAssetTagIDs} rate limiter. */\n\tprivate _resolveAssetTagIDsLimit = pLimit()\n\n\t/**\n\t * Resolves asset tag IDs from tag names.\n\t *\n\t * @param tagNames - An array of tag names to resolve.\n\t * @param params - Whether or not missing tags should be created and additional fetch parameters.\n\t * @returns An array of resolved tag IDs.\n\t */\n\tprivate async resolveAssetTagIDs(\n\t\ttagNames: string[] = [],\n\t\t{ createTags, ...params }: { createTags?: boolean } & FetchParams = {},\n\t): Promise<string[]> {\n\t\treturn this._resolveAssetTagIDsLimit(async () => {\n\t\t\tconst existingTags = await this.getAssetTags(params)\n\t\t\tconst existingTagMap: Record<string, AssetTag> = {}\n\t\t\tfor (const tag of existingTags) {\n\t\t\t\texistingTagMap[tag.name] = tag\n\t\t\t}\n\n\t\t\tconst resolvedTagIDs = []\n\t\t\tfor (const tagName of tagNames) {\n\t\t\t\t// Tag does not exists yet, we create it if `createTags` is set\n\t\t\t\tif (!existingTagMap[tagName] && createTags) {\n\t\t\t\t\texistingTagMap[tagName] = await this.createAssetTag(tagName, params)\n\t\t\t\t}\n\n\t\t\t\t// Add tag if found\n\t\t\t\tif (existingTagMap[tagName]) {\n\t\t\t\t\tresolvedTagIDs.push(existingTagMap[tagName].id)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn resolvedTagIDs\n\t\t})\n\t}\n\n\t/**\n\t * Creates a tag in the Asset API.\n\t *\n\t * @remarks\n\t * Tags should be at least 3 characters long and 20 characters at most.\n\t * @param name - The name of the tag to create.\n\t * @param params - Additional fetch parameters.\n\t * @returns The created tag.\n\t */\n\tprivate async createAssetTag(name: string, params?: FetchParams): Promise<AssetTag> {\n\t\tconst url = new URL(\"tags\", this.assetAPIEndpoint)\n\n\t\tconst response = await this.#request(url, params, {\n\t\t\tmethod: \"POST\",\n\t\t\tbody: JSON.stringify({ name }),\n\t\t\theaders: {\n\t\t\t\t\"content-type\": \"application/json\",\n\t\t\t},\n\t\t})\n\t\tswitch (response.status) {\n\t\t\tcase 201: {\n\t\t\t\treturn (await response.json()) as PostAssetTagResult\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\treturn await this.#handleAssetAPIError(response)\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Queries existing tags from the Asset API.\n\t *\n\t * @param params - Additional fetch parameters.\n\t * @returns An array of existing tags.\n\t */\n\tprivate async getAssetTags(params?: FetchParams): Promise<AssetTag[]> {\n\t\tconst url = new URL(\"tags\", this.assetAPIEndpoint)\n\n\t\tconst response = await this.#request(url, params)\n\t\tswitch (response.status) {\n\t\t\tcase 200: {\n\t\t\t\tconst json = (await response.json()) as GetAssetTagsResult\n\n\t\t\t\treturn json.items\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\treturn await this.#handleAssetAPIError(response)\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Creates a document in the repository's migration release.\n\t *\n\t * @typeParam TType - Type of Prismic documents to create.\n\t * @param document - The document to create.\n\t * @param documentTitle - The title of the document to create which will be displayed in the\n\t * editor.\n\t * @param params - Document master language document ID and additional fetch parameters.\n\t * @returns The ID of the created document.\n\t * @see Prismic Migration API technical reference: {@link https://prismic.io/docs/migration-api-technical-reference}\n\t */\n\tprivate async createDocument<TType extends TDocuments[\"type\"]>(\n\t\tdocument: PendingPrismicDocument<ExtractDocumentType<TDocuments, TType>>,\n\t\tdocumentTitle: string,\n\t\t{\n\t\t\tmasterLanguageDocumentID,\n\t\t\t...params\n\t\t}: { masterLanguageDocumentID?: string } & FetchParams = {},\n\t): Promise<{ id: string }> {\n\t\tconst url = new URL(\"documents\", this.migrationAPIEndpoint)\n\n\t\tconst response = await this.#request(url, params, {\n\t\t\tmethod: \"POST\",\n\t\t\tbody: JSON.stringify({\n\t\t\t\ttitle: documentTitle,\n\t\t\t\ttype: document.type,\n\t\t\t\tuid: document.uid || undefined,\n\t\t\t\tlang: document.lang,\n\t\t\t\talternate_language_id: masterLanguageDocumentID,\n\t\t\t\ttags: document.tags,\n\t\t\t\tdata: document.data,\n\t\t\t}),\n\t\t\theaders: {\n\t\t\t\t\"content-type\": \"application/json\",\n\t\t\t\t\"x-client\": CLIENT_IDENTIFIER,\n\t\t\t},\n\t\t})\n\t\tswitch (response.status) {\n\t\t\tcase 201: {\n\t\t\t\tconst json = (await response.json()) as PostDocumentResult\n\n\t\t\t\treturn { id: json.id }\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\treturn await this.#handleMigrationAPIError(response)\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Updates an existing document in the repository's migration release.\n\t *\n\t * @typeParam TType - Type of Prismic documents to update.\n\t * @param id - The ID of the document to update.\n\t * @param document - The document content to update.\n\t * @param params - Additional fetch parameters.\n\t * @see Prismic Migration API technical reference: {@link https://prismic.io/docs/migration-api-technical-reference}\n\t */\n\tprivate async updateDocument<TType extends TDocuments[\"type\"]>(\n\t\tid: string,\n\t\tdocument: MigrationDocument<ExtractDocumentType<TDocuments, TType>> & {\n\t\t\tdocumentTitle?: string\n\t\t},\n\t\tparams?: FetchParams,\n\t): Promise<void> {\n\t\tconst url = new URL(`documents/${id}`, this.migrationAPIEndpoint)\n\n\t\tconst response = await this.#request(url, params, {\n\t\t\tmethod: \"PUT\",\n\t\t\tbody: JSON.stringify({\n\t\t\t\ttitle: document.documentTitle,\n\t\t\t\tuid: document.uid || undefined,\n\t\t\t\ttags: document.tags,\n\t\t\t\tdata: document.data,\n\t\t\t}),\n\t\t\theaders: {\n\t\t\t\t\"content-type\": \"application/json\",\n\t\t\t\t\"x-client\": CLIENT_IDENTIFIER,\n\t\t\t},\n\t\t})\n\t\tswitch (response.status) {\n\t\t\tcase 200: {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tawait this.#handleMigrationAPIError(response)\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Makes an authenticated HTTP request for write operations using the client's configured fetch\n\t * function and options.\n\t *\n\t * @param url - The URL to request.\n\t * @param params - Fetch options from the user.\n\t * @param init - Additional fetch options to merge with the user-provided options.\n\t * @returns The response from the fetch request.\n\t */\n\tasync #request(url: URL, params?: FetchParams, init?: RequestInitLike): Promise<ResponseLike> {\n\t\treturn await request(\n\t\t\turl,\n\t\t\t{\n\t\t\t\t...this.fetchOptions,\n\t\t\t\t...params?.fetchOptions,\n\t\t\t\t...init,\n\t\t\t\theaders: {\n\t\t\t\t\t...this.fetchOptions?.headers,\n\t\t\t\t\t...params?.fetchOptions?.headers,\n\t\t\t\t\t...init?.headers,\n\t\t\t\t\trepository: this.repositoryName,\n\t\t\t\t\tauthorization: `Bearer ${this.writeToken}`,\n\t\t\t\t},\n\t\t\t\tsignal: params?.fetchOptions?.signal || params?.signal || this.fetchOptions?.signal,\n\t\t\t},\n\t\t\tthis.fetchFn,\n\t\t)\n\t}\n\n\t/**\n\t * Handles error responses from the Asset API with comprehensive error parsing.\n\t *\n\t * @param response - The HTTP response from the Asset API.\n\t * @throws {@link InvalidDataError} For 400 errors.\n\t * @throws {@link ForbiddenError} For 401 and 403 errors.\n\t * @throws {@link NotFoundError} For 404 errors.\n\t * @throws {@link PrismicError} For 500, 503, and other unexpected errors.\n\t */\n\tasync #handleAssetAPIError(response: ResponseLike): Promise<never> {\n\t\tconst json = await response.json()\n\t\tswitch (response.status) {\n\t\t\tcase 401:\n\t\t\tcase 403:\n\t\t\t\tthrow new ForbiddenError(json.error, response.url, json)\n\n\t\t\tcase 404:\n\t\t\t\tthrow new NotFoundError(json.error, response.url, json)\n\n\t\t\tcase 400:\n\t\t\t\tthrow new InvalidDataError(json.error, response.url, json)\n\n\t\t\tcase 500:\n\t\t\tcase 503:\n\t\t\tdefault:\n\t\t\t\tthrow new PrismicError(json.error, response.url, json)\n\t\t}\n\t}\n\n\t/**\n\t * Handles error responses from the Migration API with comprehensive error parsing.\n\t *\n\t * @param response - The HTTP response from the Migration API.\n\t * @throws {@link InvalidDataError} For 400 errors.\n\t * @throws {@link ForbiddenError} For 401 and 403 errors.\n\t * @throws {@link NotFoundError} For 404 errors.\n\t * @throws {@link PrismicError} For 500, and other unexpected errors.\n\t */\n\tasync #handleMigrationAPIError(response: ResponseLike): Promise<never> {\n\t\tconst payload = (await response.json()) as unknown\n\n\t\t// Common message across all branches\n\t\tconst message = (payload as { message?: string }).message\n\n\t\tswitch (response.status) {\n\t\t\tcase 400: {\n\t\t\t\tthrow new InvalidDataError(message, response.url, payload)\n\t\t\t}\n\n\t\t\tcase 401: {\n\t\t\t\tthrow new ForbiddenError(message, response.url, payload)\n\t\t\t}\n\n\t\t\tcase 403: {\n\t\t\t\t// The lambda authorizer uses an uppercase key, remove this once it is fixed\n\t\t\t\tconst msg = message ?? (payload as { Message?: string }).Message\n\t\t\t\tthrow new ForbiddenError(msg, response.url, payload)\n\t\t\t}\n\n\t\t\tcase 404: {\n\t\t\t\tthrow new NotFoundError(message, response.url, payload)\n\t\t\t}\n\n\t\t\tcase 500:\n\t\t\tdefault: {\n\t\t\t\tthrow new PrismicError(message, response.url, payload)\n\t\t\t}\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;AAgCA,MAAM,oBAAoB,GAAG,KAAK,QAAQ,KAAK,GAAG,CAAC,QAAQ,KAAK,IAAI,CAAC,GAAG;;;;;;;;;;AAiIxE,IAAa,cAAb,cAEU,OAAmB;CAC5B;CAEA,mBAAmB;CACnB,uBAAuB;;;;;;;;;;;;CAavB,YAAY,gBAAwB,SAA4B;AAC/D,QAAM,gBAAgB,QAAQ;AAE9B,MAAI,OAAO,WAAW,WAAW,YAChC,SAAQ,KACP,mSAAmS,OAAO,gCAAgC,GAC1U;AAGF,OAAK,aAAa,QAAQ;AAE1B,MAAI,QAAQ,iBACX,MAAK,mBAA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D,KAAK,IACJ,OAAM,IAAI,iBAAiB,KAAK,OAAO,SAAS,KAAK,KAAK;GAI3D,QACC,OAAM,IAAI,aAAa,KAAK,OAAO,SAAS,KAAK,KAAK;;;;;;;;;;;;CAazD,OAAA,wBAA+B,UAAwC;EACtE,MAAM,UAAW,MAAM,SAAS,MAAM;EAGtC,MAAM,UAAW,QAAiC;AAElD,UAAQ,SAAS,QAAjB;GACC,KAAK,IACJ,OAAM,IAAI,iBAAiB,SAAS,SAAS,KAAK,QAAQ;GAG3D,KAAK,IACJ,OAAM,IAAI,eAAe,SAAS,SAAS,KAAK,QAAQ;GAGzD,KAAK,IAGJ,OAAM,IAAI,eADE,WAAY,QAAiC,SAC3B,SAAS,KAAK,QAAQ;GAGrD,KAAK,IACJ,OAAM,IAAI,cAAc,SAAS,SAAS,KAAK,QAAQ;GAIxD,QACC,OAAM,IAAI,aAAa,SAAS,SAAS,KAAK,QAAQ"}
|
|
1
|
+
{"version":3,"file":"WriteClient.js","names":[],"sources":["../src/WriteClient.ts"],"sourcesContent":["import { name, version } from \"../package.json\"\nimport { Client } from \"./Client\"\nimport type { ClientConfig, FetchParams } from \"./Client\"\n// oxlint-disable-next-line no-unused-vars\nimport type { createMigration } from \"./createMigration\"\nimport { ForbiddenError, InvalidDataError, NotFoundError, PrismicError } from \"./errors\"\nimport { devMsg } from \"./lib/devMsg\"\nimport { pLimit } from \"./lib/pLimit\"\nimport type { ResponseLike } from \"./lib/request\"\nimport { type RequestInitLike, request } from \"./lib/request\"\nimport {\n\tresolveMigrationContentRelationship,\n\tresolveMigrationDocumentData,\n} from \"./lib/resolveMigrationDocumentData\"\nimport type { Migration } from \"./Migration\"\nimport type {\n\tAsset,\n\tPatchAssetParams,\n\tPostAssetParams,\n\tPostAssetResult,\n} from \"./types/api/asset/asset\"\nimport type { AssetTag, GetAssetTagsResult, PostAssetTagResult } from \"./types/api/asset/tag\"\nimport { type PostDocumentResult } from \"./types/api/migration/document\"\nimport type { PublishMigrationReleaseResult } from \"./types/api/migration/release\"\nimport type { PrismicMigrationAsset } from \"./types/migration/Asset\"\nimport type {\n\tMigrationDocument,\n\tPendingPrismicDocument,\n\tPrismicMigrationDocument,\n} from \"./types/migration/Document\"\nimport type { PrismicDocument } from \"./types/value/document\"\n\nconst CLIENT_IDENTIFIER = `${name.replace(\"@\", \"\").replace(\"/\", \"-\")}/${version}`\n\n/**\n * Extracts one or more Prismic document types that match a given Prismic document type. If no\n * matches are found, no extraction is performed and the union of all provided Prismic document\n * types are returned.\n *\n * @typeParam TDocuments - Prismic document types from which to extract.\n * @typeParam TDocumentType - Type(s) to match `TDocuments` against.\n */\ntype ExtractDocumentType<\n\tTDocuments extends { type: string },\n\tTDocumentType extends TDocuments[\"type\"],\n> =\n\tExtract<TDocuments, { type: TDocumentType }> extends never\n\t\t? TDocuments\n\t\t: Extract<TDocuments, { type: TDocumentType }>\n\n/** Utility type to construct events reported by the migration process. */\ntype MigrateReporterEvent<TType extends string, TData = never> = TData extends never\n\t? { type: TType }\n\t: {\n\t\t\ttype: TType\n\t\t\tdata: TData\n\t\t}\n\n/** A map of event types and their data reported by the migration process. */\ntype MigrateReporterEventMap = {\n\tstart: {\n\t\tpending: {\n\t\t\tdocuments: number\n\t\t\tassets: number\n\t\t}\n\t}\n\tend: {\n\t\tmigrated: {\n\t\t\tdocuments: number\n\t\t\tassets: number\n\t\t}\n\t}\n\t\"assets:creating\": {\n\t\tcurrent: number\n\t\tremaining: number\n\t\ttotal: number\n\t\tasset: PrismicMigrationAsset\n\t}\n\t\"assets:created\": {\n\t\tcreated: number\n\t}\n\t\"documents:masterLocale\": {\n\t\tmasterLocale: string\n\t}\n\t\"documents:creating\": {\n\t\tcurrent: number\n\t\tremaining: number\n\t\ttotal: number\n\t\tdocument: PrismicMigrationDocument\n\t}\n\t\"documents:created\": {\n\t\tcreated: number\n\t}\n\t\"documents:updating\": {\n\t\tcurrent: number\n\t\tremaining: number\n\t\ttotal: number\n\t\tdocument: PrismicMigrationDocument\n\t}\n\t\"documents:updated\": {\n\t\tupdated: number\n\t}\n}\n\n/** Available event types reported by the migration process. */\ntype MigrateReporterEventTypes = keyof MigrateReporterEventMap\n\n/**\n * All events reported by the migration process. Events can be listened to by providing a `reporter`\n * function to the `migrate` method.\n */\nexport type MigrateReporterEvents = {\n\t[K in MigrateReporterEventTypes]: MigrateReporterEvent<K, MigrateReporterEventMap[K]>\n}[MigrateReporterEventTypes]\n\n/** Additional parameters for creating an asset in the Prismic media library. */\nexport type CreateAssetParams = {\n\t/** Asset notes. */\n\tnotes?: string\n\n\t/** Asset credits. */\n\tcredits?: string\n\n\t/** Asset alt text. */\n\talt?: string\n\n\t/** Asset tags. */\n\ttags?: string[]\n}\n\n/** Configuration for clients that determine how content is queried. */\nexport type WriteClientConfig = {\n\t/** A Prismic write token that allows writing content to the repository. */\n\twriteToken: string\n\n\t/**\n\t * The Prismic Asset API endpoint.\n\t *\n\t * @defaultValue `\"https://asset-api.prismic.io/\"`\n\t * @see Prismic Asset API technical reference: {@link https://prismic.io/docs/asset-api-technical-reference}\n\t */\n\tassetAPIEndpoint?: string\n\n\t/**\n\t * The Prismic Migration API endpoint.\n\t *\n\t * @defaultValue `\"https://migration.prismic.io/\"`\n\t * @see Prismic Migration API technical reference: {@link https://prismic.io/docs/migration-api-technical-reference}\n\t */\n\tmigrationAPIEndpoint?: string\n} & ClientConfig\n\n/**\n * A client that allows querying and writing content to a Prismic repository.\n *\n * If used in an environment where a global `fetch` function is unavailable, such as Node.js, the\n * `fetch` option must be provided as part of the `options` parameter.\n *\n * @typeParam TDocuments - Document types that are registered for the Prismic repository. Query\n * methods will automatically be typed based on this type.\n */\nexport class WriteClient<\n\tTDocuments extends PrismicDocument = PrismicDocument,\n> extends Client<TDocuments> {\n\twriteToken: string\n\n\tassetAPIEndpoint = \"https://asset-api.prismic.io/\"\n\tmigrationAPIEndpoint = \"https://migration.prismic.io/\"\n\n\t/**\n\t * Creates a Prismic client that can be used to query and write content to a repository.\n\t *\n\t * If used in an environment where a global `fetch` function is unavailable, such as in some\n\t * Node.js versions, the `fetch` option must be provided as part of the `options` parameter.\n\t *\n\t * @param repositoryName - The Prismic repository name for the repository.\n\t * @param options - Configuration that determines how content will be queried from and written to\n\t * the Prismic repository.\n\t * @returns A client that can query and write content to the repository.\n\t */\n\tconstructor(repositoryName: string, options: WriteClientConfig) {\n\t\tsuper(repositoryName, options)\n\n\t\tif (typeof globalThis.window !== \"undefined\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[@prismicio/client] Prismic write client appears to be running in a browser environment. This is not recommended as it exposes your write token. Consider using Prismic write client in a server environment only, preferring the regular client for browser environment. For more details, see ${devMsg(\"avoid-write-client-in-browser\")}`,\n\t\t\t)\n\t\t}\n\n\t\tthis.writeToken = options.writeToken\n\n\t\tif (options.assetAPIEndpoint) {\n\t\t\tthis.assetAPIEndpoint = `${options.assetAPIEndpoint}/`\n\t\t}\n\n\t\tif (options.migrationAPIEndpoint) {\n\t\t\tthis.migrationAPIEndpoint = `${options.migrationAPIEndpoint}/`\n\t\t}\n\t}\n\n\t/**\n\t * Creates a migration release on the Prismic repository based on the provided prepared migration.\n\t *\n\t * @param migration - A migration prepared with {@link createMigration}.\n\t * @param params - An event listener and additional fetch parameters.\n\t * @see Prismic Migration API technical reference: {@link https://prismic.io/docs/migration-api-technical-reference}\n\t */\n\tasync migrate(\n\t\tmigration: Migration<TDocuments>,\n\t\tparams: {\n\t\t\treporter?: (event: MigrateReporterEvents) => void\n\t\t} & FetchParams = {},\n\t): Promise<void> {\n\t\tparams.reporter?.({\n\t\t\ttype: \"start\",\n\t\t\tdata: {\n\t\t\t\tpending: {\n\t\t\t\t\tdocuments: migration._documents.length,\n\t\t\t\t\tassets: migration._assets.size,\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\n\t\tawait this.migrateCreateAssets(migration, params)\n\t\tawait this.migrateCreateDocuments(migration, params)\n\t\tawait this.migrateUpdateDocuments(migration, params)\n\n\t\tparams.reporter?.({\n\t\t\ttype: \"end\",\n\t\t\tdata: {\n\t\t\t\tmigrated: {\n\t\t\t\t\tdocuments: migration._documents.length,\n\t\t\t\t\tassets: migration._assets.size,\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\t}\n\n\t/**\n\t * Publishes the repository's migration release, moving its documents into the repository as\n\t * published content.\n\t *\n\t * @example\n\t * \t```ts\n\t * \tconst migration = createMigration()\n\t *\n\t * \t// Prepare and run a migration.\n\t * \tmigration.createDocument(doc, \"My document\")\n\t * \tawait writeClient.migrate(migration)\n\t *\n\t * \t// Publish the migration release.\n\t * \tconst { totalItems } = await writeClient.publishMigrationRelease()\n\t * \t```\n\t *\n\t * @param params - Additional fetch parameters.\n\t * @returns The result of the publish operation, including the total number of documents that were\n\t * published.\n\t * @see Prismic Migration API technical reference: {@link https://prismic.io/docs/migration-api-technical-reference}\n\t */\n\tasync publishMigrationRelease(params?: FetchParams): Promise<PublishMigrationReleaseResult> {\n\t\tconst url = new URL(\"migration-release/publish\", this.migrationAPIEndpoint)\n\n\t\tconst response = await this.#request(url, params, {\n\t\t\tmethod: \"POST\",\n\t\t\t// A body is included so `request()` treats this as a write: it is\n\t\t\t// routed through the per-host write throttle and, crucially, is not\n\t\t\t// deduplicated with concurrent publishes from other repositories\n\t\t\t// (which share this URL but differ only by auth headers).\n\t\t\tbody: JSON.stringify({}),\n\t\t\theaders: {\n\t\t\t\t\"content-type\": \"application/json\",\n\t\t\t\t\"x-client\": CLIENT_IDENTIFIER,\n\t\t\t},\n\t\t})\n\t\tswitch (response.status) {\n\t\t\tcase 202: {\n\t\t\t\tconst json = (await response.json()) as PublishMigrationReleaseResult\n\n\t\t\t\treturn { totalItems: json.totalItems }\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\treturn await this.#handleMigrationAPIError(response)\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Creates assets in the Prismic repository's media library.\n\t *\n\t * @param migration - A migration prepared with {@link createMigration}.\n\t * @param params - An event listener and additional fetch parameters.\n\t * @internal This method is one of the step performed by the {@link migrate} method.\n\t */\n\tprivate async migrateCreateAssets(\n\t\tmigration: Migration<TDocuments>,\n\t\t{\n\t\t\treporter,\n\t\t\t...fetchParams\n\t\t}: { reporter?: (event: MigrateReporterEvents) => void } & FetchParams = {},\n\t): Promise<void> {\n\t\tlet created = 0\n\t\tfor (const [_, migrationAsset] of migration._assets) {\n\t\t\treporter?.({\n\t\t\t\ttype: \"assets:creating\",\n\t\t\t\tdata: {\n\t\t\t\t\tcurrent: ++created,\n\t\t\t\t\tremaining: migration._assets.size - created,\n\t\t\t\t\ttotal: migration._assets.size,\n\t\t\t\t\tasset: migrationAsset,\n\t\t\t\t},\n\t\t\t})\n\n\t\t\tconst { file, filename, notes, credits, alt, tags } = migrationAsset.config\n\n\t\t\tlet resolvedFile: PostAssetParams[\"file\"] | File\n\t\t\tif (typeof file === \"string\") {\n\t\t\t\tlet url: URL | undefined\n\t\t\t\ttry {\n\t\t\t\t\turl = new URL(file)\n\t\t\t\t} catch {\n\t\t\t\t\t// noop only on invalid URL, fetch errors will throw in the next if statement\n\t\t\t\t}\n\n\t\t\t\tif (url) {\n\t\t\t\t\t// File is a URL, fetch it\n\t\t\t\t\tresolvedFile = await this.fetchForeignAsset(url.toString(), fetchParams)\n\t\t\t\t} else {\n\t\t\t\t\t// File is actual file content, use it as-is\n\t\t\t\t\tresolvedFile = file\n\t\t\t\t}\n\t\t\t} else if (file instanceof URL) {\n\t\t\t\t// File is a URL instance, fetch it\n\t\t\t\tresolvedFile = await this.fetchForeignAsset(file.toString(), fetchParams)\n\t\t\t} else {\n\t\t\t\tresolvedFile = file\n\t\t\t}\n\n\t\t\tconst asset = await this.createAsset(resolvedFile, filename, {\n\t\t\t\tnotes,\n\t\t\t\tcredits,\n\t\t\t\talt,\n\t\t\t\ttags,\n\t\t\t\t...fetchParams,\n\t\t\t})\n\n\t\t\tmigrationAsset.asset = asset\n\t\t}\n\n\t\treporter?.({\n\t\t\ttype: \"assets:created\",\n\t\t\tdata: {\n\t\t\t\tcreated,\n\t\t\t},\n\t\t})\n\t}\n\n\t/**\n\t * Creates documents in the Prismic repository's migration release.\n\t *\n\t * @param migration - A migration prepared with {@link createMigration}.\n\t * @param params - An event listener and additional fetch parameters.\n\t * @internal This method is one of the step performed by the {@link migrate} method.\n\t */\n\tprivate async migrateCreateDocuments(\n\t\tmigration: Migration<TDocuments>,\n\t\t{\n\t\t\treporter,\n\t\t\t...fetchParams\n\t\t}: { reporter?: (event: MigrateReporterEvents) => void } & FetchParams = {},\n\t): Promise<void> {\n\t\t// Resolve master locale\n\t\tconst repository = await this.getRepository(fetchParams)\n\t\tconst masterLocale = repository.languages[0].id\n\t\treporter?.({\n\t\t\ttype: \"documents:masterLocale\",\n\t\t\tdata: {\n\t\t\t\tmasterLocale,\n\t\t\t},\n\t\t})\n\n\t\tconst documentsToCreate: PrismicMigrationDocument<TDocuments>[] = []\n\t\t// We create an array with non-master locale documents last because\n\t\t// we need their master locale document to be created first.\n\t\tfor (const doc of migration._documents) {\n\t\t\tif (!doc.document.id) {\n\t\t\t\tif (doc.document.lang === masterLocale) {\n\t\t\t\t\tdocumentsToCreate.unshift(doc)\n\t\t\t\t} else {\n\t\t\t\t\tdocumentsToCreate.push(doc)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tlet created = 0\n\t\tfor (const doc of documentsToCreate) {\n\t\t\treporter?.({\n\t\t\t\ttype: \"documents:creating\",\n\t\t\t\tdata: {\n\t\t\t\t\tcurrent: ++created,\n\t\t\t\t\tremaining: documentsToCreate.length - created,\n\t\t\t\t\ttotal: documentsToCreate.length,\n\t\t\t\t\tdocument: doc,\n\t\t\t\t},\n\t\t\t})\n\n\t\t\t// Resolve master language document ID for non-master locale documents\n\t\t\tlet masterLanguageDocumentID: string | undefined\n\t\t\tif (doc.masterLanguageDocument) {\n\t\t\t\tconst masterLanguageDocument = await resolveMigrationContentRelationship(\n\t\t\t\t\tdoc.masterLanguageDocument,\n\t\t\t\t)\n\n\t\t\t\tmasterLanguageDocumentID =\n\t\t\t\t\t\"id\" in masterLanguageDocument ? masterLanguageDocument.id : undefined\n\t\t\t} else if (doc.originalPrismicDocument) {\n\t\t\t\tconst maybeOriginalID = doc.originalPrismicDocument.alternate_languages.find(\n\t\t\t\t\t({ lang }) => lang === masterLocale,\n\t\t\t\t)?.id\n\n\t\t\t\tif (maybeOriginalID) {\n\t\t\t\t\tmasterLanguageDocumentID = migration._getByOriginalID(maybeOriginalID)?.document.id\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst { id } = await this.createDocument(\n\t\t\t\t// We'll upload documents data later on.\n\t\t\t\t{ ...doc.document, data: {} },\n\t\t\t\tdoc.title!,\n\t\t\t\t{\n\t\t\t\t\tmasterLanguageDocumentID,\n\t\t\t\t\t...fetchParams,\n\t\t\t\t},\n\t\t\t)\n\n\t\t\tdoc.document.id = id\n\t\t}\n\n\t\treporter?.({\n\t\t\ttype: \"documents:created\",\n\t\t\tdata: { created },\n\t\t})\n\t}\n\n\t/**\n\t * Updates documents in the Prismic repository's migration release with their patched data.\n\t *\n\t * @param migration - A migration prepared with {@link createMigration}.\n\t * @param params - An event listener and additional fetch parameters.\n\t * @internal This method is one of the step performed by the {@link migrate} method.\n\t */\n\tprivate async migrateUpdateDocuments(\n\t\tmigration: Migration<TDocuments>,\n\t\t{\n\t\t\treporter,\n\t\t\t...fetchParams\n\t\t}: { reporter?: (event: MigrateReporterEvents) => void } & FetchParams = {},\n\t): Promise<void> {\n\t\tlet i = 0\n\t\tfor (const doc of migration._documents) {\n\t\t\treporter?.({\n\t\t\t\ttype: \"documents:updating\",\n\t\t\t\tdata: {\n\t\t\t\t\tcurrent: ++i,\n\t\t\t\t\tremaining: migration._documents.length - i,\n\t\t\t\t\ttotal: migration._documents.length,\n\t\t\t\t\tdocument: doc,\n\t\t\t\t},\n\t\t\t})\n\n\t\t\tawait this.updateDocument(\n\t\t\t\tdoc.document.id!,\n\t\t\t\t// We need to forward again document name and tags to update them\n\t\t\t\t// in case the document already existed during the previous step.\n\t\t\t\t{\n\t\t\t\t\t...doc.document,\n\t\t\t\t\tdocumentTitle: doc.title,\n\t\t\t\t\tdata: await resolveMigrationDocumentData(doc.document.data, migration),\n\t\t\t\t},\n\t\t\t\tfetchParams,\n\t\t\t)\n\t\t}\n\n\t\treporter?.({\n\t\t\ttype: \"documents:updated\",\n\t\t\tdata: {\n\t\t\t\tupdated: migration._documents.length,\n\t\t\t},\n\t\t})\n\t}\n\n\t/**\n\t * Creates an asset in the Prismic media library.\n\t *\n\t * @param file - The file to upload as an asset.\n\t * @param filename - The filename of the asset.\n\t * @param params - Additional asset data and fetch parameters.\n\t * @returns The created asset.\n\t */\n\tprivate async createAsset(\n\t\tfile: PostAssetParams[\"file\"] | File,\n\t\tfilename: string,\n\t\t{ notes, credits, alt, tags, ...params }: CreateAssetParams & FetchParams = {},\n\t): Promise<Asset> {\n\t\tconst url = new URL(\"assets\", this.assetAPIEndpoint)\n\n\t\tconst formData = new FormData()\n\t\tformData.append(\n\t\t\t\"file\",\n\t\t\tnew File([file], filename, {\n\t\t\t\ttype: file instanceof File ? file.type : undefined,\n\t\t\t}),\n\t\t)\n\n\t\tif (notes) {\n\t\t\tformData.append(\"notes\", notes)\n\t\t}\n\n\t\tif (credits) {\n\t\t\tformData.append(\"credits\", credits)\n\t\t}\n\n\t\tif (alt) {\n\t\t\tformData.append(\"alt\", alt)\n\t\t}\n\n\t\tconst response = await this.#request(url, params, {\n\t\t\tmethod: \"POST\",\n\t\t\tbody: formData,\n\t\t})\n\t\tswitch (response.status) {\n\t\t\tcase 200: {\n\t\t\t\tconst asset = (await response.json()) as PostAssetResult\n\n\t\t\t\tif (tags && tags.length) {\n\t\t\t\t\treturn this.updateAsset(asset.id, { tags })\n\t\t\t\t}\n\n\t\t\t\treturn asset\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\treturn await this.#handleAssetAPIError(response)\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Updates an asset in the Prismic media library.\n\t *\n\t * @param id - The ID of the asset to update.\n\t * @param params - The asset data to update and additional fetch parameters.\n\t * @returns The updated asset.\n\t */\n\tprivate async updateAsset(\n\t\tid: string,\n\t\t{ notes, credits, alt, filename, tags, ...params }: PatchAssetParams & FetchParams = {},\n\t): Promise<Asset> {\n\t\tconst url = new URL(`assets/${id}`, this.assetAPIEndpoint)\n\n\t\t// Resolve tags if any and create missing ones\n\t\tif (tags && tags.length) {\n\t\t\ttags = await this.resolveAssetTagIDs(tags, {\n\t\t\t\tcreateTags: true,\n\t\t\t\t...params,\n\t\t\t})\n\t\t}\n\n\t\tconst response = await this.#request(url, params, {\n\t\t\tmethod: \"PATCH\",\n\t\t\tbody: JSON.stringify({\n\t\t\t\tnotes,\n\t\t\t\tcredits,\n\t\t\t\talt,\n\t\t\t\tfilename,\n\t\t\t\ttags,\n\t\t\t}),\n\t\t\theaders: {\n\t\t\t\t\"content-type\": \"application/json\",\n\t\t\t},\n\t\t})\n\t\tswitch (response.status) {\n\t\t\tcase 200: {\n\t\t\t\treturn (await response.json()) as Asset\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\treturn await this.#handleAssetAPIError(response)\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Fetches a foreign asset from a URL.\n\t *\n\t * @param url - The URL of the asset to fetch.\n\t * @param params - Additional fetch parameters.\n\t * @returns A file representing the fetched asset.\n\t */\n\tprivate async fetchForeignAsset(url: string, params: FetchParams = {}): Promise<Blob> {\n\t\tconst res = await this.#request(new URL(url), params)\n\n\t\tif (!res.ok) {\n\t\t\tthrow new PrismicError(\"Could not fetch foreign asset\", url, undefined)\n\t\t}\n\n\t\tconst buffer = await res.arrayBuffer()\n\n\t\t// Ensure a correct content type is attached to the blob.\n\t\treturn new File([buffer], \"\", {\n\t\t\ttype: res.headers.get(\"content-type\") || undefined,\n\t\t})\n\t}\n\n\t/** {@link resolveAssetTagIDs} rate limiter. */\n\tprivate _resolveAssetTagIDsLimit = pLimit()\n\n\t/**\n\t * Resolves asset tag IDs from tag names.\n\t *\n\t * @param tagNames - An array of tag names to resolve.\n\t * @param params - Whether or not missing tags should be created and additional fetch parameters.\n\t * @returns An array of resolved tag IDs.\n\t */\n\tprivate async resolveAssetTagIDs(\n\t\ttagNames: string[] = [],\n\t\t{ createTags, ...params }: { createTags?: boolean } & FetchParams = {},\n\t): Promise<string[]> {\n\t\treturn this._resolveAssetTagIDsLimit(async () => {\n\t\t\tconst existingTags = await this.getAssetTags(params)\n\t\t\tconst existingTagMap: Record<string, AssetTag> = {}\n\t\t\tfor (const tag of existingTags) {\n\t\t\t\texistingTagMap[tag.name] = tag\n\t\t\t}\n\n\t\t\tconst resolvedTagIDs = []\n\t\t\tfor (const tagName of tagNames) {\n\t\t\t\t// Tag does not exists yet, we create it if `createTags` is set\n\t\t\t\tif (!existingTagMap[tagName] && createTags) {\n\t\t\t\t\texistingTagMap[tagName] = await this.createAssetTag(tagName, params)\n\t\t\t\t}\n\n\t\t\t\t// Add tag if found\n\t\t\t\tif (existingTagMap[tagName]) {\n\t\t\t\t\tresolvedTagIDs.push(existingTagMap[tagName].id)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn resolvedTagIDs\n\t\t})\n\t}\n\n\t/**\n\t * Creates a tag in the Asset API.\n\t *\n\t * @remarks\n\t * Tags should be at least 3 characters long and 20 characters at most.\n\t * @param name - The name of the tag to create.\n\t * @param params - Additional fetch parameters.\n\t * @returns The created tag.\n\t */\n\tprivate async createAssetTag(name: string, params?: FetchParams): Promise<AssetTag> {\n\t\tconst url = new URL(\"tags\", this.assetAPIEndpoint)\n\n\t\tconst response = await this.#request(url, params, {\n\t\t\tmethod: \"POST\",\n\t\t\tbody: JSON.stringify({ name }),\n\t\t\theaders: {\n\t\t\t\t\"content-type\": \"application/json\",\n\t\t\t},\n\t\t})\n\t\tswitch (response.status) {\n\t\t\tcase 201: {\n\t\t\t\treturn (await response.json()) as PostAssetTagResult\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\treturn await this.#handleAssetAPIError(response)\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Queries existing tags from the Asset API.\n\t *\n\t * @param params - Additional fetch parameters.\n\t * @returns An array of existing tags.\n\t */\n\tprivate async getAssetTags(params?: FetchParams): Promise<AssetTag[]> {\n\t\tconst url = new URL(\"tags\", this.assetAPIEndpoint)\n\n\t\tconst response = await this.#request(url, params)\n\t\tswitch (response.status) {\n\t\t\tcase 200: {\n\t\t\t\tconst json = (await response.json()) as GetAssetTagsResult\n\n\t\t\t\treturn json.items\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\treturn await this.#handleAssetAPIError(response)\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Creates a document in the repository's migration release.\n\t *\n\t * @typeParam TType - Type of Prismic documents to create.\n\t * @param document - The document to create.\n\t * @param documentTitle - The title of the document to create which will be displayed in the\n\t * editor.\n\t * @param params - Document master language document ID and additional fetch parameters.\n\t * @returns The ID of the created document.\n\t * @see Prismic Migration API technical reference: {@link https://prismic.io/docs/migration-api-technical-reference}\n\t */\n\tprivate async createDocument<TType extends TDocuments[\"type\"]>(\n\t\tdocument: PendingPrismicDocument<ExtractDocumentType<TDocuments, TType>>,\n\t\tdocumentTitle: string,\n\t\t{\n\t\t\tmasterLanguageDocumentID,\n\t\t\t...params\n\t\t}: { masterLanguageDocumentID?: string } & FetchParams = {},\n\t): Promise<{ id: string }> {\n\t\tconst url = new URL(\"documents\", this.migrationAPIEndpoint)\n\n\t\tconst response = await this.#request(url, params, {\n\t\t\tmethod: \"POST\",\n\t\t\tbody: JSON.stringify({\n\t\t\t\ttitle: documentTitle,\n\t\t\t\ttype: document.type,\n\t\t\t\tuid: document.uid || undefined,\n\t\t\t\tlang: document.lang,\n\t\t\t\talternate_language_id: masterLanguageDocumentID,\n\t\t\t\ttags: document.tags,\n\t\t\t\tdata: document.data,\n\t\t\t}),\n\t\t\theaders: {\n\t\t\t\t\"content-type\": \"application/json\",\n\t\t\t\t\"x-client\": CLIENT_IDENTIFIER,\n\t\t\t},\n\t\t})\n\t\tswitch (response.status) {\n\t\t\tcase 201: {\n\t\t\t\tconst json = (await response.json()) as PostDocumentResult\n\n\t\t\t\treturn { id: json.id }\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\treturn await this.#handleMigrationAPIError(response)\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Updates an existing document in the repository's migration release.\n\t *\n\t * @typeParam TType - Type of Prismic documents to update.\n\t * @param id - The ID of the document to update.\n\t * @param document - The document content to update.\n\t * @param params - Additional fetch parameters.\n\t * @see Prismic Migration API technical reference: {@link https://prismic.io/docs/migration-api-technical-reference}\n\t */\n\tprivate async updateDocument<TType extends TDocuments[\"type\"]>(\n\t\tid: string,\n\t\tdocument: MigrationDocument<ExtractDocumentType<TDocuments, TType>> & {\n\t\t\tdocumentTitle?: string\n\t\t},\n\t\tparams?: FetchParams,\n\t): Promise<void> {\n\t\tconst url = new URL(`documents/${id}`, this.migrationAPIEndpoint)\n\n\t\tconst response = await this.#request(url, params, {\n\t\t\tmethod: \"PUT\",\n\t\t\tbody: JSON.stringify({\n\t\t\t\ttitle: document.documentTitle,\n\t\t\t\tuid: document.uid || undefined,\n\t\t\t\ttags: document.tags,\n\t\t\t\tdata: document.data,\n\t\t\t}),\n\t\t\theaders: {\n\t\t\t\t\"content-type\": \"application/json\",\n\t\t\t\t\"x-client\": CLIENT_IDENTIFIER,\n\t\t\t},\n\t\t})\n\t\tswitch (response.status) {\n\t\t\tcase 200: {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tawait this.#handleMigrationAPIError(response)\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Makes an authenticated HTTP request for write operations using the client's configured fetch\n\t * function and options.\n\t *\n\t * @param url - The URL to request.\n\t * @param params - Fetch options from the user.\n\t * @param init - Additional fetch options to merge with the user-provided options.\n\t * @returns The response from the fetch request.\n\t */\n\tasync #request(url: URL, params?: FetchParams, init?: RequestInitLike): Promise<ResponseLike> {\n\t\treturn await request(\n\t\t\turl,\n\t\t\t{\n\t\t\t\t...this.fetchOptions,\n\t\t\t\t...params?.fetchOptions,\n\t\t\t\t...init,\n\t\t\t\theaders: {\n\t\t\t\t\t...this.fetchOptions?.headers,\n\t\t\t\t\t...params?.fetchOptions?.headers,\n\t\t\t\t\t...init?.headers,\n\t\t\t\t\trepository: this.repositoryName,\n\t\t\t\t\tauthorization: `Bearer ${this.writeToken}`,\n\t\t\t\t},\n\t\t\t\tsignal: params?.fetchOptions?.signal || params?.signal || this.fetchOptions?.signal,\n\t\t\t},\n\t\t\tthis.fetchFn,\n\t\t)\n\t}\n\n\t/**\n\t * Handles error responses from the Asset API with comprehensive error parsing.\n\t *\n\t * @param response - The HTTP response from the Asset API.\n\t * @throws {@link InvalidDataError} For 400 errors.\n\t * @throws {@link ForbiddenError} For 401 and 403 errors.\n\t * @throws {@link NotFoundError} For 404 errors.\n\t * @throws {@link PrismicError} For 500, 503, and other unexpected errors.\n\t */\n\tasync #handleAssetAPIError(response: ResponseLike): Promise<never> {\n\t\tconst json = await response.json()\n\t\tswitch (response.status) {\n\t\t\tcase 401:\n\t\t\tcase 403:\n\t\t\t\tthrow new ForbiddenError(json.error, response.url, json)\n\n\t\t\tcase 404:\n\t\t\t\tthrow new NotFoundError(json.error, response.url, json)\n\n\t\t\tcase 400:\n\t\t\t\tthrow new InvalidDataError(json.error, response.url, json)\n\n\t\t\tcase 500:\n\t\t\tcase 503:\n\t\t\tdefault:\n\t\t\t\tthrow new PrismicError(json.error, response.url, json)\n\t\t}\n\t}\n\n\t/**\n\t * Handles error responses from the Migration API with comprehensive error parsing.\n\t *\n\t * @param response - The HTTP response from the Migration API.\n\t * @throws {@link InvalidDataError} For 400 errors.\n\t * @throws {@link ForbiddenError} For 401 and 403 errors.\n\t * @throws {@link NotFoundError} For 404 errors.\n\t * @throws {@link PrismicError} For 500, and other unexpected errors.\n\t */\n\tasync #handleMigrationAPIError(response: ResponseLike): Promise<never> {\n\t\tconst payload = (await response.json()) as unknown\n\n\t\t// Common message across all branches\n\t\tconst message = (payload as { message?: string }).message\n\n\t\tswitch (response.status) {\n\t\t\tcase 400: {\n\t\t\t\tthrow new InvalidDataError(message, response.url, payload)\n\t\t\t}\n\n\t\t\tcase 401: {\n\t\t\t\tthrow new ForbiddenError(message, response.url, payload)\n\t\t\t}\n\n\t\t\tcase 403: {\n\t\t\t\t// The lambda authorizer uses an uppercase key, remove this once it is fixed\n\t\t\t\tconst msg = message ?? (payload as { Message?: string }).Message\n\t\t\t\tthrow new ForbiddenError(msg, response.url, payload)\n\t\t\t}\n\n\t\t\tcase 404: {\n\t\t\t\tthrow new NotFoundError(message, response.url, payload)\n\t\t\t}\n\n\t\t\tcase 500:\n\t\t\tdefault: {\n\t\t\t\tthrow new PrismicError(message, response.url, payload)\n\t\t\t}\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;AAgCA,MAAM,oBAAoB,GAAG,KAAK,QAAQ,KAAK,EAAE,CAAC,CAAC,QAAQ,KAAK,GAAG,EAAE,GAAG;;;;;;;;;;AAiIxE,IAAa,cAAb,cAEU,OAAmB;CAC5B;CAEA,mBAAmB;CACnB,uBAAuB;;;;;;;;;;;;CAavB,YAAY,gBAAwB,SAA4B;EAC/D,MAAM,gBAAgB,OAAO;EAE7B,IAAI,OAAO,WAAW,WAAW,aAChC,QAAQ,KACP,mSAAmS,OAAO,+BAA+B,GAC1U;EAGD,KAAK,aAAa,QAAQ;EAE1B,IAAI,QAAQ,kBACX,KAAK,mBAAmB,GAAG,QAAQ,iBAAiB;EAGrD,IAAI,QAAQ,sBACX,KAAK,uBAAuB,GAAG,QAAQ,qBAAqB;CAE9D;;;;;;;;CASA,MAAM,QACL,WACA,SAEkB,CAAC,GACH;EAChB,OAAO,WAAW;GACjB,MAAM;GACN,MAAM,EACL,SAAS;IACR,WAAW,UAAU,WAAW;IAChC,QAAQ,UAAU,QAAQ;GAC3B,EACD;EACD,CAAC;EAED,MAA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AI;GAI1D,SACC,MAAM,IAAI,aAAa,KAAK,OAAO,SAAS,KAAK,IAAI;EACvD;CACD;;;;;;;;;;CAWA,MAAM,yBAAyB,UAAwC;EACtE,MAAM,UAAW,MAAM,SAAS,KAAK;EAGrC,MAAM,UAAW,QAAiC;EAElD,QAAQ,SAAS,QAAjB;GACC,KAAK,KACJ,MAAM,IAAI,iBAAiB,SAAS,SAAS,KAAK,OAAO;GAG1D,KAAK,KACJ,MAAM,IAAI,eAAe,SAAS,SAAS,KAAK,OAAO;GAGxD,KAAK,KAAK;IAET,MAAM,MAAM,WAAY,QAAiC;IACzD,MAAM,IAAI,eAAe,KAAK,SAAS,KAAK,OAAO;GACpD;GAEA,KAAK,KACJ,MAAM,IAAI,cAAc,SAAS,SAAS,KAAK,OAAO;GAIvD,SACC,MAAM,IAAI,aAAa,SAAS,SAAS,KAAK,OAAO;EAEvD;CACD;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildQueryURL.cjs","names":["devMsg","version"],"sources":["../src/buildQueryURL.ts"],"sourcesContent":["import { version } from \"../package.json\"\nimport { devMsg } from \"./lib/devMsg\"\n\n/** The query parameter used to indicate if the client is in development mode to the API. */\nconst PRISMIC_DEV_PARAM = \"x-d\"\n\n/** The query parameter used to indicate the version of the client to the API. */\nconst PRISMIC_CLIENT_VERSION_PARAM = \"x-c\"\n\n/**\n * Create a union of the given object's values, and optionally specify which keys to get the values\n * from.\n *\n * Taken from the `type-fest` package.\n *\n * See:\n * https://github.com/sindresorhus/type-fest/blob/61c35052f09caa23de5eef96d95196375d8ed498/source/value-of.d.ts\n */\ntype ValueOf<\n\tObjectType,\n\tValueType extends keyof ObjectType = keyof ObjectType,\n> = ObjectType[ValueType]\n\n/**\n * An `orderings` parameter that orders the results by the specified field.\n *\n * {@link https://prismic.io/docs/rest-api-technical-reference#orderings}\n */\nexport interface Ordering {\n\tfield: string\n\tdirection?: \"asc\" | \"desc\"\n}\n\n/**\n * A `routes` parameter that determines how a page's URL field is resolved.\n *\n * {@link https://prismic.io/docs/route-resolver}\n *\n * @example\n * \tWith a page's UID field.\n *\n * \t```ts\n * \t{\n * \t\"type\": \"page\",\n * \t\"path\": \"/:uid\"\n * \t}\n * \t```\n *\n * @example\n * \tWith a Content Relationship `parent` field.\n *\n * \t```ts\n * \t{\n * \t\"type\": \"page\",\n * \t\"path\": \"/:parent?/:uid\",\n * \t\"resolvers\": {\n * \t\"parent\": \"parent\"\n * \t}\n * \t}\n * \t```\n */\nexport interface Route {\n\t/** The custom type of the page. */\n\ttype: string\n\n\t/**\n\t * A specific UID to which this route definition is scoped. The route is only defined for the page\n\t * whose UID matches the given UID.\n\t */\n\tuid?: string\n\n\t/**\n\t * A specific language to which this route definition is scoped. The route is only defined for\n\t * pages whose language matches the given language.\n\t */\n\tlang?: string\n\n\t/** The resolved path of the page with optional placeholders. */\n\tpath: string\n\n\t/** An object that lists the API IDs of the Content Relationships in the route. */\n\tresolvers?: Record<string, string>\n}\n\n/**\n * Parameters for the Prismic Content API.\n *\n * @see Learn how to fetch content from Prismic: {@link https://prismic.io/docs/fetch-content}\n */\nexport interface QueryParams {\n\t/**\n\t * The secure token for accessing the API (only needed if your repository is set to private).\n\t *\n\t * {@link https://prismic.io/docs/access-token}\n\t */\n\taccessToken?: string\n\n\t/**\n\t * The `pageSize` parameter defines the maximum number of pages that the API will return for your\n\t * query.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#pagesize}\n\t */\n\tpageSize?: number\n\n\t/**\n\t * The `page` parameter defines the pagination for the result of your query.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#page}\n\t */\n\tpage?: number\n\n\t/**\n\t * The `after` parameter can be used along with the orderings option. It will remove all the pages\n\t * except for those after the specified page in the list.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#after}\n\t */\n\tafter?: string\n\n\t/**\n\t * The `fetch` parameter is used to make queries faster by only retrieving the specified field(s).\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#fetch}\n\t */\n\tfetch?: string | string[]\n\n\t/**\n\t * The `fetchLinks` parameter allows you to retrieve a specific content field from a linked page\n\t * and add it to the page response object.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#fetchlinks}\n\t */\n\tfetchLinks?: string | string[]\n\n\t/**\n\t * The `graphQuery` parameter allows you to specify which fields to retrieve and what content to\n\t * retrieve from Linked Documents / Content Relationships.\n\t *\n\t * {@link https://prismic.io/docs/graphquery-rest-api}\n\t */\n\tgraphQuery?: string\n\n\t/**\n\t * The `lang` option defines the language code for the results of your query.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#lang}\n\t */\n\tlang?: string\n\n\t/**\n\t * The `orderings` parameter orders the results by the specified field(s). You can specify as many\n\t * fields as you want.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#orderings}\n\t *\n\t * @remarks\n\t * Strings and arrays of strings are deprecated as of `@prismicio/client@7.0.0`. Please migrate\n\t * to the more explicit array of objects.\n\t * @example\n\t * \t;```typescript\n\t * \tbuildQueryURL(endpoint, {\n\t * \t\torderings: [\n\t * \t\t\t{ field: \"my.product.price\", direction: \"desc\" },\n\t * \t\t\t{ field: \"my.product.title\" },\n\t * \t\t],\n\t * \t})\n\t * \t```\n\t */\n\t// TODO: Update TSDoc with deprecated API removal in v8\n\torderings?: string | Ordering | (string | Ordering)[]\n\n\t/**\n\t * The `routes` option allows you to define how a page's `url` field is resolved.\n\t *\n\t * {@link https://prismic.io/docs/route-resolver}\n\t */\n\troutes?: Route | string | (Route | string)[]\n\n\t/**\n\t * The `brokenRoute` option allows you to define the route populated in the `url` property for\n\t * broken link or content relationship fields. A broken link is a link or content relationship\n\t * field whose linked page has been unpublished or deleted.\n\t *\n\t * {@link https://prismic.io/docs/route-resolver}\n\t */\n\tbrokenRoute?: string\n}\n\n/** Arguments for `buildQueryURL` to construct a Query URL. */\ntype BuildQueryURLParams = {\n\t/**\n\t * Ref used to query documents.\n\t *\n\t * {@link https://prismic.io/docs/api#refs-and-the-entry-api}\n\t */\n\tref: string\n\n\t/**\n\t * Ref used to populate integration fields with the latest content.\n\t *\n\t * {@link https://prismic.io/docs/integration-fields}\n\t */\n\tintegrationFieldsRef?: string\n\n\t/**\n\t * One or more filters to filter documents for the query.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#q}\n\t */\n\tfilters?: string | string[]\n\n\t/**\n\t * @deprecated Renamed to `filters`. Ensure the value is an array of filters,\n\t * not a single, non-array filter.\n\t */\n\tpredicates?: string | string[]\n}\n\n/**\n * Parameters in this map have been renamed from the official Prismic REST API V2 specification for\n * better developer ergonomics.\n *\n * These parameters are renamed to their mapped value.\n */\nconst RENAMED_PARAMS = {\n\taccessToken: \"access_token\",\n} as const\n\n/** A valid parameter name for the Prismic REST API V2. */\ntype ValidParamName =\n\t| Exclude<keyof QueryParams, keyof typeof RENAMED_PARAMS | keyof BuildQueryURLParams>\n\t| ValueOf<typeof RENAMED_PARAMS>\n\n/**\n * Converts an Ordering to a string that is compatible with Prismic's REST API. If the value\n * provided is already a string, no conversion is performed.\n *\n * @param ordering - Ordering to convert.\n * @returns String representation of the Ordering.\n */\nconst castOrderingToString = (ordering: Ordering | string): string => {\n\t// TODO: Remove the following when `orderings` strings are no longer supported.\n\tif (typeof ordering === \"string\") {\n\t\tif (process.env.NODE_ENV === \"development\") {\n\t\t\tconst [field, direction] = ordering.split(\" \")\n\n\t\t\tconst objectForm =\n\t\t\t\tdirection === \"desc\" ? `{ field: \"${field}\", direction: \"desc\" }` : `{ field: \"${field}\" }`\n\n\t\t\tconsole.warn(\n\t\t\t\t`[@prismicio/client] A string value was provided to the \\`orderings\\` query parameter. Strings are deprecated. Please convert it to the object form: ${objectForm}. For more details, see ${devMsg(\n\t\t\t\t\t\"orderings-must-be-an-array-of-objects\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\n\t\treturn ordering\n\t}\n\n\treturn ordering.direction === \"desc\" ? `${ordering.field} desc` : ordering.field\n}\n\nexport type BuildQueryURLArgs = QueryParams & BuildQueryURLParams\n\n/**\n * Builds a Prismic Content API URL to request pages from a repository. The paginated response for\n * this URL includes pages matching the parameters.\n *\n * A ref is required to make a request. Request the `endpoint` URL to retrieve a list of available\n * refs.\n *\n * Type the JSON response with `Query`.\n *\n * @example\n * \t;```ts\n * \tconst url = buildQueryURL(\"https://my-repo.cdn.prismic.io/api/v2\", {\n * \t\tref: \"my-ref\",\n * \t\tfilters: [filter.at(\"document.type\", \"blog_post\")],\n * \t})\n * \t```\n *\n * @param endpoint - URL to the repository's Content API.\n * @param args - Arguments to filter and scope the query.\n * @returns URL that can be used to request pages from the repository.\n * @see Prismic Content API technical reference: {@link https://prismic.io/docs/content-api}\n */\nexport const buildQueryURL = (endpoint: string, args: BuildQueryURLArgs): string => {\n\tconst { filters, predicates, ...params } = args\n\n\tif (!endpoint.endsWith(\"/\")) {\n\t\tendpoint += \"/\"\n\t}\n\tconst url = new URL(`documents/search`, endpoint)\n\n\tif (filters) {\n\t\t// TODO: Remove warning when we remove support for string `filters` values.\n\t\tif (process.env.NODE_ENV === \"development\" && !Array.isArray(filters)) {\n\t\t\tconsole.warn(\n\t\t\t\t`[@prismicio/client] A non-array value was provided to the \\`filters\\` query parameter (\\`${filters}\\`). Non-array values are deprecated. Please convert it to an array. For more details, see ${devMsg(\n\t\t\t\t\t\"filters-must-be-an-array\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\n\t\t// TODO: Remove `castArray` when we remove support for string `filters` values.\n\t\tfor (const filter of castArray(filters)) {\n\t\t\turl.searchParams.append(\"q\", `[${filter}]`)\n\t\t}\n\t}\n\n\t// TODO: Remove when we remove support for deprecated `predicates` argument.\n\tif (predicates) {\n\t\tfor (const predicate of castArray(predicates)) {\n\t\t\turl.searchParams.append(\"q\", `[${predicate}]`)\n\t\t}\n\t}\n\n\t// Iterate over each parameter and add it to the URL. In some cases, the\n\t// parameter value needs to be transformed to fit the REST API.\n\tfor (const k in params) {\n\t\tconst name = (RENAMED_PARAMS[k as keyof typeof RENAMED_PARAMS] || k) as ValidParamName\n\n\t\tlet value = params[k as keyof typeof params]\n\n\t\tif (name === \"orderings\") {\n\t\t\tconst scopedValue = params[name]\n\n\t\t\tif (scopedValue != null) {\n\t\t\t\t// TODO: Remove the following warning when `orderings` strings are no longer supported.\n\t\t\t\tif (process.env.NODE_ENV === \"development\" && typeof scopedValue === \"string\") {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`[@prismicio/client] A string value was provided to the \\`orderings\\` query parameter. Strings are deprecated. Please convert it to an array of objects. For more details, see ${devMsg(\n\t\t\t\t\t\t\t\"orderings-must-be-an-array-of-objects\",\n\t\t\t\t\t\t)}`,\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tconst v = castArray(scopedValue)\n\t\t\t\t\t.map((ordering) => castOrderingToString(ordering))\n\t\t\t\t\t.join(\",\")\n\n\t\t\t\tvalue = `[${v}]`\n\t\t\t}\n\t\t} else if (name === \"routes\") {\n\t\t\tif (typeof params[name] === \"object\") {\n\t\t\t\tvalue = JSON.stringify(castArray(params[name]))\n\t\t\t}\n\t\t}\n\n\t\tif (value != null) {\n\t\t\turl.searchParams.set(name, castArray<string | number | Route | Ordering>(value).join(\",\"))\n\t\t}\n\t}\n\n\turl.searchParams.set(PRISMIC_CLIENT_VERSION_PARAM, `js-${version}`)\n\n\tif (process.env.NODE_ENV === \"development\") {\n\t\turl.searchParams.set(PRISMIC_DEV_PARAM, \"1\")\n\t}\n\n\treturn url.toString()\n}\n\nfunction castArray<A>(a: A | A[]): A[] {\n\treturn Array.isArray(a) ? a : [a]\n}\n"],"mappings":";;;;AAIA,MAAM,oBAAoB;;AAG1B,MAAM,+BAA+B;;;;;;;AA0NrC,MAAM,iBAAiB,EACtB,aAAa,gBACb;;;;;;;;AAcD,MAAM,wBAAwB,aAAwC;AAErE,KAAI,OAAO,aAAa,UAAU;AACjC,MAAI,QAAQ,IAAI,aAAa,e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U,OAAO,MAAM,CAAC;;AAIjD,MAAI,SAAS,KACZ,KAAI,aAAa,IAAI,MAAM,UAA8C,MAAM,CAAC,KAAK,IAAI,CAAC;;AAI5F,KAAI,aAAa,IAAI,8BAA8B,MAAMC,gBAAAA,UAAU;AAEnE,KAAI,QAAQ,IAAI,aAAa,cAC5B,KAAI,aAAa,IAAI,mBAAmB,IAAI;AAG7C,QAAO,IAAI,UAAU;;AAGtB,SAAS,UAAa,GAAiB;AACtC,QAAO,MAAM,QAAQ,EAAE,GAAG,IAAI,CAAC,EAAE"}
|
|
1
|
+
{"version":3,"file":"buildQueryURL.cjs","names":["devMsg","version"],"sources":["../src/buildQueryURL.ts"],"sourcesContent":["import { version } from \"../package.json\"\nimport { devMsg } from \"./lib/devMsg\"\n\n/** The query parameter used to indicate if the client is in development mode to the API. */\nconst PRISMIC_DEV_PARAM = \"x-d\"\n\n/** The query parameter used to indicate the version of the client to the API. */\nconst PRISMIC_CLIENT_VERSION_PARAM = \"x-c\"\n\n/**\n * Create a union of the given object's values, and optionally specify which keys to get the values\n * from.\n *\n * Taken from the `type-fest` package.\n *\n * See:\n * https://github.com/sindresorhus/type-fest/blob/61c35052f09caa23de5eef96d95196375d8ed498/source/value-of.d.ts\n */\ntype ValueOf<\n\tObjectType,\n\tValueType extends keyof ObjectType = keyof ObjectType,\n> = ObjectType[ValueType]\n\n/**\n * An `orderings` parameter that orders the results by the specified field.\n *\n * {@link https://prismic.io/docs/rest-api-technical-reference#orderings}\n */\nexport interface Ordering {\n\tfield: string\n\tdirection?: \"asc\" | \"desc\"\n}\n\n/**\n * A `routes` parameter that determines how a page's URL field is resolved.\n *\n * {@link https://prismic.io/docs/route-resolver}\n *\n * @example\n * \tWith a page's UID field.\n *\n * \t```ts\n * \t{\n * \t\"type\": \"page\",\n * \t\"path\": \"/:uid\"\n * \t}\n * \t```\n *\n * @example\n * \tWith a Content Relationship `parent` field.\n *\n * \t```ts\n * \t{\n * \t\"type\": \"page\",\n * \t\"path\": \"/:parent?/:uid\",\n * \t\"resolvers\": {\n * \t\"parent\": \"parent\"\n * \t}\n * \t}\n * \t```\n */\nexport interface Route {\n\t/** The custom type of the page. */\n\ttype: string\n\n\t/**\n\t * A specific UID to which this route definition is scoped. The route is only defined for the page\n\t * whose UID matches the given UID.\n\t */\n\tuid?: string\n\n\t/**\n\t * A specific language to which this route definition is scoped. The route is only defined for\n\t * pages whose language matches the given language.\n\t */\n\tlang?: string\n\n\t/** The resolved path of the page with optional placeholders. */\n\tpath: string\n\n\t/** An object that lists the API IDs of the Content Relationships in the route. */\n\tresolvers?: Record<string, string>\n}\n\n/**\n * Parameters for the Prismic Content API.\n *\n * @see Learn how to fetch content from Prismic: {@link https://prismic.io/docs/fetch-content}\n */\nexport interface QueryParams {\n\t/**\n\t * The secure token for accessing the API (only needed if your repository is set to private).\n\t *\n\t * {@link https://prismic.io/docs/access-token}\n\t */\n\taccessToken?: string\n\n\t/**\n\t * The `pageSize` parameter defines the maximum number of pages that the API will return for your\n\t * query.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#pagesize}\n\t */\n\tpageSize?: number\n\n\t/**\n\t * The `page` parameter defines the pagination for the result of your query.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#page}\n\t */\n\tpage?: number\n\n\t/**\n\t * The `after` parameter can be used along with the orderings option. It will remove all the pages\n\t * except for those after the specified page in the list.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#after}\n\t */\n\tafter?: string\n\n\t/**\n\t * The `fetch` parameter is used to make queries faster by only retrieving the specified field(s).\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#fetch}\n\t */\n\tfetch?: string | string[]\n\n\t/**\n\t * The `fetchLinks` parameter allows you to retrieve a specific content field from a linked page\n\t * and add it to the page response object.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#fetchlinks}\n\t */\n\tfetchLinks?: string | string[]\n\n\t/**\n\t * The `graphQuery` parameter allows you to specify which fields to retrieve and what content to\n\t * retrieve from Linked Documents / Content Relationships.\n\t *\n\t * {@link https://prismic.io/docs/graphquery-rest-api}\n\t */\n\tgraphQuery?: string\n\n\t/**\n\t * The `lang` option defines the language code for the results of your query.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#lang}\n\t */\n\tlang?: string\n\n\t/**\n\t * The `orderings` parameter orders the results by the specified field(s). You can specify as many\n\t * fields as you want.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#orderings}\n\t *\n\t * @remarks\n\t * Strings and arrays of strings are deprecated as of `@prismicio/client@7.0.0`. Please migrate\n\t * to the more explicit array of objects.\n\t * @example\n\t * \t;```typescript\n\t * \tbuildQueryURL(endpoint, {\n\t * \t\torderings: [\n\t * \t\t\t{ field: \"my.product.price\", direction: \"desc\" },\n\t * \t\t\t{ field: \"my.product.title\" },\n\t * \t\t],\n\t * \t})\n\t * \t```\n\t */\n\t// TODO: Update TSDoc with deprecated API removal in v8\n\torderings?: string | Ordering | (string | Ordering)[]\n\n\t/**\n\t * The `routes` option allows you to define how a page's `url` field is resolved.\n\t *\n\t * {@link https://prismic.io/docs/route-resolver}\n\t */\n\troutes?: Route | string | (Route | string)[]\n\n\t/**\n\t * The `brokenRoute` option allows you to define the route populated in the `url` property for\n\t * broken link or content relationship fields. A broken link is a link or content relationship\n\t * field whose linked page has been unpublished or deleted.\n\t *\n\t * {@link https://prismic.io/docs/route-resolver}\n\t */\n\tbrokenRoute?: string\n}\n\n/** Arguments for `buildQueryURL` to construct a Query URL. */\ntype BuildQueryURLParams = {\n\t/**\n\t * Ref used to query documents.\n\t *\n\t * {@link https://prismic.io/docs/api#refs-and-the-entry-api}\n\t */\n\tref: string\n\n\t/**\n\t * Ref used to populate integration fields with the latest content.\n\t *\n\t * {@link https://prismic.io/docs/integration-fields}\n\t */\n\tintegrationFieldsRef?: string\n\n\t/**\n\t * One or more filters to filter documents for the query.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#q}\n\t */\n\tfilters?: string | string[]\n\n\t/**\n\t * @deprecated Renamed to `filters`. Ensure the value is an array of filters,\n\t * not a single, non-array filter.\n\t */\n\tpredicates?: string | string[]\n}\n\n/**\n * Parameters in this map have been renamed from the official Prismic REST API V2 specification for\n * better developer ergonomics.\n *\n * These parameters are renamed to their mapped value.\n */\nconst RENAMED_PARAMS = {\n\taccessToken: \"access_token\",\n} as const\n\n/** A valid parameter name for the Prismic REST API V2. */\ntype ValidParamName =\n\t| Exclude<keyof QueryParams, keyof typeof RENAMED_PARAMS | keyof BuildQueryURLParams>\n\t| ValueOf<typeof RENAMED_PARAMS>\n\n/**\n * Converts an Ordering to a string that is compatible with Prismic's REST API. If the value\n * provided is already a string, no conversion is performed.\n *\n * @param ordering - Ordering to convert.\n * @returns String representation of the Ordering.\n */\nconst castOrderingToString = (ordering: Ordering | string): string => {\n\t// TODO: Remove the following when `orderings` strings are no longer supported.\n\tif (typeof ordering === \"string\") {\n\t\tif (process.env.NODE_ENV === \"development\") {\n\t\t\tconst [field, direction] = ordering.split(\" \")\n\n\t\t\tconst objectForm =\n\t\t\t\tdirection === \"desc\" ? `{ field: \"${field}\", direction: \"desc\" }` : `{ field: \"${field}\" }`\n\n\t\t\tconsole.warn(\n\t\t\t\t`[@prismicio/client] A string value was provided to the \\`orderings\\` query parameter. Strings are deprecated. Please convert it to the object form: ${objectForm}. For more details, see ${devMsg(\n\t\t\t\t\t\"orderings-must-be-an-array-of-objects\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\n\t\treturn ordering\n\t}\n\n\treturn ordering.direction === \"desc\" ? `${ordering.field} desc` : ordering.field\n}\n\nexport type BuildQueryURLArgs = QueryParams & BuildQueryURLParams\n\n/**\n * Builds a Prismic Content API URL to request pages from a repository. The paginated response for\n * this URL includes pages matching the parameters.\n *\n * A ref is required to make a request. Request the `endpoint` URL to retrieve a list of available\n * refs.\n *\n * Type the JSON response with `Query`.\n *\n * @example\n * \t;```ts\n * \tconst url = buildQueryURL(\"https://my-repo.cdn.prismic.io/api/v2\", {\n * \t\tref: \"my-ref\",\n * \t\tfilters: [filter.at(\"document.type\", \"blog_post\")],\n * \t})\n * \t```\n *\n * @param endpoint - URL to the repository's Content API.\n * @param args - Arguments to filter and scope the query.\n * @returns URL that can be used to request pages from the repository.\n * @see Prismic Content API technical reference: {@link https://prismic.io/docs/content-api}\n */\nexport const buildQueryURL = (endpoint: string, args: BuildQueryURLArgs): string => {\n\tconst { filters, predicates, ...params } = args\n\n\tif (!endpoint.endsWith(\"/\")) {\n\t\tendpoint += \"/\"\n\t}\n\tconst url = new URL(`documents/search`, endpoint)\n\n\tif (filters) {\n\t\t// TODO: Remove warning when we remove support for string `filters` values.\n\t\tif (process.env.NODE_ENV === \"development\" && !Array.isArray(filters)) {\n\t\t\tconsole.warn(\n\t\t\t\t`[@prismicio/client] A non-array value was provided to the \\`filters\\` query parameter (\\`${filters}\\`). Non-array values are deprecated. Please convert it to an array. For more details, see ${devMsg(\n\t\t\t\t\t\"filters-must-be-an-array\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\n\t\t// TODO: Remove `castArray` when we remove support for string `filters` values.\n\t\tfor (const filter of castArray(filters)) {\n\t\t\turl.searchParams.append(\"q\", `[${filter}]`)\n\t\t}\n\t}\n\n\t// TODO: Remove when we remove support for deprecated `predicates` argument.\n\tif (predicates) {\n\t\tfor (const predicate of castArray(predicates)) {\n\t\t\turl.searchParams.append(\"q\", `[${predicate}]`)\n\t\t}\n\t}\n\n\t// Iterate over each parameter and add it to the URL. In some cases, the\n\t// parameter value needs to be transformed to fit the REST API.\n\tfor (const k in params) {\n\t\tconst name = (RENAMED_PARAMS[k as keyof typeof RENAMED_PARAMS] || k) as ValidParamName\n\n\t\tlet value = params[k as keyof typeof params]\n\n\t\tif (name === \"orderings\") {\n\t\t\tconst scopedValue = params[name]\n\n\t\t\tif (scopedValue != null) {\n\t\t\t\t// TODO: Remove the following warning when `orderings` strings are no longer supported.\n\t\t\t\tif (process.env.NODE_ENV === \"development\" && typeof scopedValue === \"string\") {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`[@prismicio/client] A string value was provided to the \\`orderings\\` query parameter. Strings are deprecated. Please convert it to an array of objects. For more details, see ${devMsg(\n\t\t\t\t\t\t\t\"orderings-must-be-an-array-of-objects\",\n\t\t\t\t\t\t)}`,\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tconst v = castArray(scopedValue)\n\t\t\t\t\t.map((ordering) => castOrderingToString(ordering))\n\t\t\t\t\t.join(\",\")\n\n\t\t\t\tvalue = `[${v}]`\n\t\t\t}\n\t\t} else if (name === \"routes\") {\n\t\t\tif (typeof params[name] === \"object\") {\n\t\t\t\tvalue = JSON.stringify(castArray(params[name]))\n\t\t\t}\n\t\t}\n\n\t\tif (value != null) {\n\t\t\turl.searchParams.set(name, castArray<string | number | Route | Ordering>(value).join(\",\"))\n\t\t}\n\t}\n\n\turl.searchParams.set(PRISMIC_CLIENT_VERSION_PARAM, `js-${version}`)\n\n\tif (process.env.NODE_ENV === \"development\") {\n\t\turl.searchParams.set(PRISMIC_DEV_PARAM, \"1\")\n\t}\n\n\treturn url.toString()\n}\n\nfunction castArray<A>(a: A | A[]): A[] {\n\treturn Array.isArray(a) ? a : [a]\n}\n"],"mappings":";;;;AAIA,MAAM,oBAAoB;;AAG1B,MAAM,+BAA+B;;;;;;;AA0NrC,MAAM,iBAAiB,EACtB,aAAa,eACd;;;;;;;;AAcA,MAAM,wBAAwB,aAAwC;CAErE,IAAI,OAAO,aAAa,UAAU;EACjC,IAAI,QAAQ,IAAI,aAAa,eAAe;GAC3C,MAAM,CAAC,OAAO,aAAa,SAAS,MAAM,GAAG;GAE7C,MAAM,aACL,cAAc,SAAS,aAAa,MAAM,0BAA0B,aAAa,MAAM;GAExF,QAAQ,KACP,uJAAuJ,WAAW,0BAA0BA,eAAAA,OAC3L,uCACD,GACD;EACD;EAEA,OAAO;CACR;CAEA,OAAO,SAAS,cAAc,SAAS,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I,QAAQ,IAAI,aAAa,eAC5B,IAAI,aAAa,IAAI,mBAAmB,GAAG;CAG5C,OAAO,IAAI,SAAS;AACrB;AAEA,SAAS,UAAa,GAAiB;CACtC,OAAO,MAAM,QAAQ,CAAC,IAAI,IAAI,CAAC,CAAC;AACjC"}
|
package/dist/buildQueryURL.d.cts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* {@link https://prismic.io/docs/rest-api-technical-reference#orderings}
|
|
6
6
|
*/
|
|
7
|
-
interface Ordering {
|
|
7
|
+
export interface Ordering {
|
|
8
8
|
field: string;
|
|
9
9
|
direction?: "asc" | "desc";
|
|
10
10
|
}
|
|
@@ -36,7 +36,7 @@ interface Ordering {
|
|
|
36
36
|
* }
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
|
-
interface Route {
|
|
39
|
+
export interface Route {
|
|
40
40
|
/** The custom type of the page. */
|
|
41
41
|
type: string;
|
|
42
42
|
/**
|
|
@@ -59,7 +59,7 @@ interface Route {
|
|
|
59
59
|
*
|
|
60
60
|
* @see Learn how to fetch content from Prismic: {@link https://prismic.io/docs/fetch-content}
|
|
61
61
|
*/
|
|
62
|
-
interface QueryParams {
|
|
62
|
+
export interface QueryParams {
|
|
63
63
|
/**
|
|
64
64
|
* The secure token for accessing the API (only needed if your repository is set to private).
|
|
65
65
|
*
|
|
@@ -173,7 +173,7 @@ type BuildQueryURLParams = {
|
|
|
173
173
|
*/
|
|
174
174
|
predicates?: string | string[];
|
|
175
175
|
};
|
|
176
|
-
type BuildQueryURLArgs = QueryParams & BuildQueryURLParams;
|
|
176
|
+
export type BuildQueryURLArgs = QueryParams & BuildQueryURLParams;
|
|
177
177
|
/**
|
|
178
178
|
* Builds a Prismic Content API URL to request pages from a repository. The paginated response for
|
|
179
179
|
* this URL includes pages matching the parameters.
|
|
@@ -196,7 +196,6 @@ type BuildQueryURLArgs = QueryParams & BuildQueryURLParams;
|
|
|
196
196
|
* @returns URL that can be used to request pages from the repository.
|
|
197
197
|
* @see Prismic Content API technical reference: {@link https://prismic.io/docs/content-api}
|
|
198
198
|
*/
|
|
199
|
-
declare const buildQueryURL: (endpoint: string, args: BuildQueryURLArgs) => string;
|
|
199
|
+
export declare const buildQueryURL: (endpoint: string, args: BuildQueryURLArgs) => string;
|
|
200
200
|
//#endregion
|
|
201
|
-
export { BuildQueryURLArgs, Ordering, QueryParams, Route, buildQueryURL };
|
|
202
201
|
//# sourceMappingURL=buildQueryURL.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildQueryURL.d.cts","names":[],"sources":["../src/buildQueryURL.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"buildQueryURL.d.cts","names":[],"sources":["../src/buildQueryURL.ts"],"mappings":";;;;;;iBA4BiB;EAChB;EACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA+BgB;;EAEhB;;;;;EAMA;;;;;EAMA;;EAGA;;EAGA,YAAY;;;;;;;iBAQI;;;;;;EAMhB;;;;;;;EAQA;;;;;;EAOA;;;;;;;EAQA;;;;;;EAOA;;;;;;;EAQA;;;;;;;EAQA;;;;;;EAOA;;;;;;;;;;;;;;;;;;;;EAsBA,qBAAqB,qBAAqB;;;;;;EAO1C,SAAS,kBAAkB;;;;;;;;EAS3B;;;KAII;;;;;;EAMJ;;;;;;EAOA;;;;;;EAOA;;;;;EAMA;;YA+CW,oBAAoB,cAAc;;;;;;;;;;;;;;;;;;;;;;;qBAwBjC,gBAAa,kBAAoB,MAAQ"}
|
package/dist/buildQueryURL.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* {@link https://prismic.io/docs/rest-api-technical-reference#orderings}
|
|
6
6
|
*/
|
|
7
|
-
interface Ordering {
|
|
7
|
+
export interface Ordering {
|
|
8
8
|
field: string;
|
|
9
9
|
direction?: "asc" | "desc";
|
|
10
10
|
}
|
|
@@ -36,7 +36,7 @@ interface Ordering {
|
|
|
36
36
|
* }
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
|
-
interface Route {
|
|
39
|
+
export interface Route {
|
|
40
40
|
/** The custom type of the page. */
|
|
41
41
|
type: string;
|
|
42
42
|
/**
|
|
@@ -59,7 +59,7 @@ interface Route {
|
|
|
59
59
|
*
|
|
60
60
|
* @see Learn how to fetch content from Prismic: {@link https://prismic.io/docs/fetch-content}
|
|
61
61
|
*/
|
|
62
|
-
interface QueryParams {
|
|
62
|
+
export interface QueryParams {
|
|
63
63
|
/**
|
|
64
64
|
* The secure token for accessing the API (only needed if your repository is set to private).
|
|
65
65
|
*
|
|
@@ -173,7 +173,7 @@ type BuildQueryURLParams = {
|
|
|
173
173
|
*/
|
|
174
174
|
predicates?: string | string[];
|
|
175
175
|
};
|
|
176
|
-
type BuildQueryURLArgs = QueryParams & BuildQueryURLParams;
|
|
176
|
+
export type BuildQueryURLArgs = QueryParams & BuildQueryURLParams;
|
|
177
177
|
/**
|
|
178
178
|
* Builds a Prismic Content API URL to request pages from a repository. The paginated response for
|
|
179
179
|
* this URL includes pages matching the parameters.
|
|
@@ -196,7 +196,6 @@ type BuildQueryURLArgs = QueryParams & BuildQueryURLParams;
|
|
|
196
196
|
* @returns URL that can be used to request pages from the repository.
|
|
197
197
|
* @see Prismic Content API technical reference: {@link https://prismic.io/docs/content-api}
|
|
198
198
|
*/
|
|
199
|
-
declare const buildQueryURL: (endpoint: string, args: BuildQueryURLArgs) => string;
|
|
199
|
+
export declare const buildQueryURL: (endpoint: string, args: BuildQueryURLArgs) => string;
|
|
200
200
|
//#endregion
|
|
201
|
-
export { BuildQueryURLArgs, Ordering, QueryParams, Route, buildQueryURL };
|
|
202
201
|
//# sourceMappingURL=buildQueryURL.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildQueryURL.d.ts","names":[],"sources":["../src/buildQueryURL.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"buildQueryURL.d.ts","names":[],"sources":["../src/buildQueryURL.ts"],"mappings":";;;;;;iBA4BiB;EAChB;EACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA+BgB;;EAEhB;;;;;EAMA;;;;;EAMA;;EAGA;;EAGA,YAAY;;;;;;;iBAQI;;;;;;EAMhB;;;;;;;EAQA;;;;;;EAOA;;;;;;;EAQA;;;;;;EAOA;;;;;;;EAQA;;;;;;;EAQA;;;;;;EAOA;;;;;;;;;;;;;;;;;;;;EAsBA,qBAAqB,qBAAqB;;;;;;EAO1C,SAAS,kBAAkB;;;;;;;;EAS3B;;;KAII;;;;;;EAMJ;;;;;;EAOA;;;;;;EAOA;;;;;EAMA;;YA+CW,oBAAoB,cAAc;;;;;;;;;;;;;;;;;;;;;;;qBAwBjC,gBAAa,kBAAoB,MAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildQueryURL.js","names":[],"sources":["../src/buildQueryURL.ts"],"sourcesContent":["import { version } from \"../package.json\"\nimport { devMsg } from \"./lib/devMsg\"\n\n/** The query parameter used to indicate if the client is in development mode to the API. */\nconst PRISMIC_DEV_PARAM = \"x-d\"\n\n/** The query parameter used to indicate the version of the client to the API. */\nconst PRISMIC_CLIENT_VERSION_PARAM = \"x-c\"\n\n/**\n * Create a union of the given object's values, and optionally specify which keys to get the values\n * from.\n *\n * Taken from the `type-fest` package.\n *\n * See:\n * https://github.com/sindresorhus/type-fest/blob/61c35052f09caa23de5eef96d95196375d8ed498/source/value-of.d.ts\n */\ntype ValueOf<\n\tObjectType,\n\tValueType extends keyof ObjectType = keyof ObjectType,\n> = ObjectType[ValueType]\n\n/**\n * An `orderings` parameter that orders the results by the specified field.\n *\n * {@link https://prismic.io/docs/rest-api-technical-reference#orderings}\n */\nexport interface Ordering {\n\tfield: string\n\tdirection?: \"asc\" | \"desc\"\n}\n\n/**\n * A `routes` parameter that determines how a page's URL field is resolved.\n *\n * {@link https://prismic.io/docs/route-resolver}\n *\n * @example\n * \tWith a page's UID field.\n *\n * \t```ts\n * \t{\n * \t\"type\": \"page\",\n * \t\"path\": \"/:uid\"\n * \t}\n * \t```\n *\n * @example\n * \tWith a Content Relationship `parent` field.\n *\n * \t```ts\n * \t{\n * \t\"type\": \"page\",\n * \t\"path\": \"/:parent?/:uid\",\n * \t\"resolvers\": {\n * \t\"parent\": \"parent\"\n * \t}\n * \t}\n * \t```\n */\nexport interface Route {\n\t/** The custom type of the page. */\n\ttype: string\n\n\t/**\n\t * A specific UID to which this route definition is scoped. The route is only defined for the page\n\t * whose UID matches the given UID.\n\t */\n\tuid?: string\n\n\t/**\n\t * A specific language to which this route definition is scoped. The route is only defined for\n\t * pages whose language matches the given language.\n\t */\n\tlang?: string\n\n\t/** The resolved path of the page with optional placeholders. */\n\tpath: string\n\n\t/** An object that lists the API IDs of the Content Relationships in the route. */\n\tresolvers?: Record<string, string>\n}\n\n/**\n * Parameters for the Prismic Content API.\n *\n * @see Learn how to fetch content from Prismic: {@link https://prismic.io/docs/fetch-content}\n */\nexport interface QueryParams {\n\t/**\n\t * The secure token for accessing the API (only needed if your repository is set to private).\n\t *\n\t * {@link https://prismic.io/docs/access-token}\n\t */\n\taccessToken?: string\n\n\t/**\n\t * The `pageSize` parameter defines the maximum number of pages that the API will return for your\n\t * query.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#pagesize}\n\t */\n\tpageSize?: number\n\n\t/**\n\t * The `page` parameter defines the pagination for the result of your query.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#page}\n\t */\n\tpage?: number\n\n\t/**\n\t * The `after` parameter can be used along with the orderings option. It will remove all the pages\n\t * except for those after the specified page in the list.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#after}\n\t */\n\tafter?: string\n\n\t/**\n\t * The `fetch` parameter is used to make queries faster by only retrieving the specified field(s).\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#fetch}\n\t */\n\tfetch?: string | string[]\n\n\t/**\n\t * The `fetchLinks` parameter allows you to retrieve a specific content field from a linked page\n\t * and add it to the page response object.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#fetchlinks}\n\t */\n\tfetchLinks?: string | string[]\n\n\t/**\n\t * The `graphQuery` parameter allows you to specify which fields to retrieve and what content to\n\t * retrieve from Linked Documents / Content Relationships.\n\t *\n\t * {@link https://prismic.io/docs/graphquery-rest-api}\n\t */\n\tgraphQuery?: string\n\n\t/**\n\t * The `lang` option defines the language code for the results of your query.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#lang}\n\t */\n\tlang?: string\n\n\t/**\n\t * The `orderings` parameter orders the results by the specified field(s). You can specify as many\n\t * fields as you want.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#orderings}\n\t *\n\t * @remarks\n\t * Strings and arrays of strings are deprecated as of `@prismicio/client@7.0.0`. Please migrate\n\t * to the more explicit array of objects.\n\t * @example\n\t * \t;```typescript\n\t * \tbuildQueryURL(endpoint, {\n\t * \t\torderings: [\n\t * \t\t\t{ field: \"my.product.price\", direction: \"desc\" },\n\t * \t\t\t{ field: \"my.product.title\" },\n\t * \t\t],\n\t * \t})\n\t * \t```\n\t */\n\t// TODO: Update TSDoc with deprecated API removal in v8\n\torderings?: string | Ordering | (string | Ordering)[]\n\n\t/**\n\t * The `routes` option allows you to define how a page's `url` field is resolved.\n\t *\n\t * {@link https://prismic.io/docs/route-resolver}\n\t */\n\troutes?: Route | string | (Route | string)[]\n\n\t/**\n\t * The `brokenRoute` option allows you to define the route populated in the `url` property for\n\t * broken link or content relationship fields. A broken link is a link or content relationship\n\t * field whose linked page has been unpublished or deleted.\n\t *\n\t * {@link https://prismic.io/docs/route-resolver}\n\t */\n\tbrokenRoute?: string\n}\n\n/** Arguments for `buildQueryURL` to construct a Query URL. */\ntype BuildQueryURLParams = {\n\t/**\n\t * Ref used to query documents.\n\t *\n\t * {@link https://prismic.io/docs/api#refs-and-the-entry-api}\n\t */\n\tref: string\n\n\t/**\n\t * Ref used to populate integration fields with the latest content.\n\t *\n\t * {@link https://prismic.io/docs/integration-fields}\n\t */\n\tintegrationFieldsRef?: string\n\n\t/**\n\t * One or more filters to filter documents for the query.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#q}\n\t */\n\tfilters?: string | string[]\n\n\t/**\n\t * @deprecated Renamed to `filters`. Ensure the value is an array of filters,\n\t * not a single, non-array filter.\n\t */\n\tpredicates?: string | string[]\n}\n\n/**\n * Parameters in this map have been renamed from the official Prismic REST API V2 specification for\n * better developer ergonomics.\n *\n * These parameters are renamed to their mapped value.\n */\nconst RENAMED_PARAMS = {\n\taccessToken: \"access_token\",\n} as const\n\n/** A valid parameter name for the Prismic REST API V2. */\ntype ValidParamName =\n\t| Exclude<keyof QueryParams, keyof typeof RENAMED_PARAMS | keyof BuildQueryURLParams>\n\t| ValueOf<typeof RENAMED_PARAMS>\n\n/**\n * Converts an Ordering to a string that is compatible with Prismic's REST API. If the value\n * provided is already a string, no conversion is performed.\n *\n * @param ordering - Ordering to convert.\n * @returns String representation of the Ordering.\n */\nconst castOrderingToString = (ordering: Ordering | string): string => {\n\t// TODO: Remove the following when `orderings` strings are no longer supported.\n\tif (typeof ordering === \"string\") {\n\t\tif (process.env.NODE_ENV === \"development\") {\n\t\t\tconst [field, direction] = ordering.split(\" \")\n\n\t\t\tconst objectForm =\n\t\t\t\tdirection === \"desc\" ? `{ field: \"${field}\", direction: \"desc\" }` : `{ field: \"${field}\" }`\n\n\t\t\tconsole.warn(\n\t\t\t\t`[@prismicio/client] A string value was provided to the \\`orderings\\` query parameter. Strings are deprecated. Please convert it to the object form: ${objectForm}. For more details, see ${devMsg(\n\t\t\t\t\t\"orderings-must-be-an-array-of-objects\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\n\t\treturn ordering\n\t}\n\n\treturn ordering.direction === \"desc\" ? `${ordering.field} desc` : ordering.field\n}\n\nexport type BuildQueryURLArgs = QueryParams & BuildQueryURLParams\n\n/**\n * Builds a Prismic Content API URL to request pages from a repository. The paginated response for\n * this URL includes pages matching the parameters.\n *\n * A ref is required to make a request. Request the `endpoint` URL to retrieve a list of available\n * refs.\n *\n * Type the JSON response with `Query`.\n *\n * @example\n * \t;```ts\n * \tconst url = buildQueryURL(\"https://my-repo.cdn.prismic.io/api/v2\", {\n * \t\tref: \"my-ref\",\n * \t\tfilters: [filter.at(\"document.type\", \"blog_post\")],\n * \t})\n * \t```\n *\n * @param endpoint - URL to the repository's Content API.\n * @param args - Arguments to filter and scope the query.\n * @returns URL that can be used to request pages from the repository.\n * @see Prismic Content API technical reference: {@link https://prismic.io/docs/content-api}\n */\nexport const buildQueryURL = (endpoint: string, args: BuildQueryURLArgs): string => {\n\tconst { filters, predicates, ...params } = args\n\n\tif (!endpoint.endsWith(\"/\")) {\n\t\tendpoint += \"/\"\n\t}\n\tconst url = new URL(`documents/search`, endpoint)\n\n\tif (filters) {\n\t\t// TODO: Remove warning when we remove support for string `filters` values.\n\t\tif (process.env.NODE_ENV === \"development\" && !Array.isArray(filters)) {\n\t\t\tconsole.warn(\n\t\t\t\t`[@prismicio/client] A non-array value was provided to the \\`filters\\` query parameter (\\`${filters}\\`). Non-array values are deprecated. Please convert it to an array. For more details, see ${devMsg(\n\t\t\t\t\t\"filters-must-be-an-array\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\n\t\t// TODO: Remove `castArray` when we remove support for string `filters` values.\n\t\tfor (const filter of castArray(filters)) {\n\t\t\turl.searchParams.append(\"q\", `[${filter}]`)\n\t\t}\n\t}\n\n\t// TODO: Remove when we remove support for deprecated `predicates` argument.\n\tif (predicates) {\n\t\tfor (const predicate of castArray(predicates)) {\n\t\t\turl.searchParams.append(\"q\", `[${predicate}]`)\n\t\t}\n\t}\n\n\t// Iterate over each parameter and add it to the URL. In some cases, the\n\t// parameter value needs to be transformed to fit the REST API.\n\tfor (const k in params) {\n\t\tconst name = (RENAMED_PARAMS[k as keyof typeof RENAMED_PARAMS] || k) as ValidParamName\n\n\t\tlet value = params[k as keyof typeof params]\n\n\t\tif (name === \"orderings\") {\n\t\t\tconst scopedValue = params[name]\n\n\t\t\tif (scopedValue != null) {\n\t\t\t\t// TODO: Remove the following warning when `orderings` strings are no longer supported.\n\t\t\t\tif (process.env.NODE_ENV === \"development\" && typeof scopedValue === \"string\") {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`[@prismicio/client] A string value was provided to the \\`orderings\\` query parameter. Strings are deprecated. Please convert it to an array of objects. For more details, see ${devMsg(\n\t\t\t\t\t\t\t\"orderings-must-be-an-array-of-objects\",\n\t\t\t\t\t\t)}`,\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tconst v = castArray(scopedValue)\n\t\t\t\t\t.map((ordering) => castOrderingToString(ordering))\n\t\t\t\t\t.join(\",\")\n\n\t\t\t\tvalue = `[${v}]`\n\t\t\t}\n\t\t} else if (name === \"routes\") {\n\t\t\tif (typeof params[name] === \"object\") {\n\t\t\t\tvalue = JSON.stringify(castArray(params[name]))\n\t\t\t}\n\t\t}\n\n\t\tif (value != null) {\n\t\t\turl.searchParams.set(name, castArray<string | number | Route | Ordering>(value).join(\",\"))\n\t\t}\n\t}\n\n\turl.searchParams.set(PRISMIC_CLIENT_VERSION_PARAM, `js-${version}`)\n\n\tif (process.env.NODE_ENV === \"development\") {\n\t\turl.searchParams.set(PRISMIC_DEV_PARAM, \"1\")\n\t}\n\n\treturn url.toString()\n}\n\nfunction castArray<A>(a: A | A[]): A[] {\n\treturn Array.isArray(a) ? a : [a]\n}\n"],"mappings":";;;;AAIA,MAAM,oBAAoB;;AAG1B,MAAM,+BAA+B;;;;;;;AA0NrC,MAAM,iBAAiB,EACtB,aAAa,gBACb;;;;;;;;AAcD,MAAM,wBAAwB,aAAwC;AAErE,KAAI,OAAO,aAAa,UAAU;AACjC,MAAI,QAAQ,IAAI,aAAa,eAAe;GAC3C,MAAM,CAAC,OAAO,aAAa,SAAS,MAAM,IAAI;GAE9C,MAAM,aACL,cAAc,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AAC;;AAI5F,KAAI,aAAa,IAAI,8BAA8B,MAAM,UAAU;AAEnE,KAAI,QAAQ,IAAI,aAAa,cAC5B,KAAI,aAAa,IAAI,mBAAmB,IAAI;AAG7C,QAAO,IAAI,UAAU;;AAGtB,SAAS,UAAa,GAAiB;AACtC,QAAO,MAAM,QAAQ,EAAE,GAAG,IAAI,CAAC,EAAE"}
|
|
1
|
+
{"version":3,"file":"buildQueryURL.js","names":[],"sources":["../src/buildQueryURL.ts"],"sourcesContent":["import { version } from \"../package.json\"\nimport { devMsg } from \"./lib/devMsg\"\n\n/** The query parameter used to indicate if the client is in development mode to the API. */\nconst PRISMIC_DEV_PARAM = \"x-d\"\n\n/** The query parameter used to indicate the version of the client to the API. */\nconst PRISMIC_CLIENT_VERSION_PARAM = \"x-c\"\n\n/**\n * Create a union of the given object's values, and optionally specify which keys to get the values\n * from.\n *\n * Taken from the `type-fest` package.\n *\n * See:\n * https://github.com/sindresorhus/type-fest/blob/61c35052f09caa23de5eef96d95196375d8ed498/source/value-of.d.ts\n */\ntype ValueOf<\n\tObjectType,\n\tValueType extends keyof ObjectType = keyof ObjectType,\n> = ObjectType[ValueType]\n\n/**\n * An `orderings` parameter that orders the results by the specified field.\n *\n * {@link https://prismic.io/docs/rest-api-technical-reference#orderings}\n */\nexport interface Ordering {\n\tfield: string\n\tdirection?: \"asc\" | \"desc\"\n}\n\n/**\n * A `routes` parameter that determines how a page's URL field is resolved.\n *\n * {@link https://prismic.io/docs/route-resolver}\n *\n * @example\n * \tWith a page's UID field.\n *\n * \t```ts\n * \t{\n * \t\"type\": \"page\",\n * \t\"path\": \"/:uid\"\n * \t}\n * \t```\n *\n * @example\n * \tWith a Content Relationship `parent` field.\n *\n * \t```ts\n * \t{\n * \t\"type\": \"page\",\n * \t\"path\": \"/:parent?/:uid\",\n * \t\"resolvers\": {\n * \t\"parent\": \"parent\"\n * \t}\n * \t}\n * \t```\n */\nexport interface Route {\n\t/** The custom type of the page. */\n\ttype: string\n\n\t/**\n\t * A specific UID to which this route definition is scoped. The route is only defined for the page\n\t * whose UID matches the given UID.\n\t */\n\tuid?: string\n\n\t/**\n\t * A specific language to which this route definition is scoped. The route is only defined for\n\t * pages whose language matches the given language.\n\t */\n\tlang?: string\n\n\t/** The resolved path of the page with optional placeholders. */\n\tpath: string\n\n\t/** An object that lists the API IDs of the Content Relationships in the route. */\n\tresolvers?: Record<string, string>\n}\n\n/**\n * Parameters for the Prismic Content API.\n *\n * @see Learn how to fetch content from Prismic: {@link https://prismic.io/docs/fetch-content}\n */\nexport interface QueryParams {\n\t/**\n\t * The secure token for accessing the API (only needed if your repository is set to private).\n\t *\n\t * {@link https://prismic.io/docs/access-token}\n\t */\n\taccessToken?: string\n\n\t/**\n\t * The `pageSize` parameter defines the maximum number of pages that the API will return for your\n\t * query.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#pagesize}\n\t */\n\tpageSize?: number\n\n\t/**\n\t * The `page` parameter defines the pagination for the result of your query.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#page}\n\t */\n\tpage?: number\n\n\t/**\n\t * The `after` parameter can be used along with the orderings option. It will remove all the pages\n\t * except for those after the specified page in the list.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#after}\n\t */\n\tafter?: string\n\n\t/**\n\t * The `fetch` parameter is used to make queries faster by only retrieving the specified field(s).\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#fetch}\n\t */\n\tfetch?: string | string[]\n\n\t/**\n\t * The `fetchLinks` parameter allows you to retrieve a specific content field from a linked page\n\t * and add it to the page response object.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#fetchlinks}\n\t */\n\tfetchLinks?: string | string[]\n\n\t/**\n\t * The `graphQuery` parameter allows you to specify which fields to retrieve and what content to\n\t * retrieve from Linked Documents / Content Relationships.\n\t *\n\t * {@link https://prismic.io/docs/graphquery-rest-api}\n\t */\n\tgraphQuery?: string\n\n\t/**\n\t * The `lang` option defines the language code for the results of your query.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#lang}\n\t */\n\tlang?: string\n\n\t/**\n\t * The `orderings` parameter orders the results by the specified field(s). You can specify as many\n\t * fields as you want.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#orderings}\n\t *\n\t * @remarks\n\t * Strings and arrays of strings are deprecated as of `@prismicio/client@7.0.0`. Please migrate\n\t * to the more explicit array of objects.\n\t * @example\n\t * \t;```typescript\n\t * \tbuildQueryURL(endpoint, {\n\t * \t\torderings: [\n\t * \t\t\t{ field: \"my.product.price\", direction: \"desc\" },\n\t * \t\t\t{ field: \"my.product.title\" },\n\t * \t\t],\n\t * \t})\n\t * \t```\n\t */\n\t// TODO: Update TSDoc with deprecated API removal in v8\n\torderings?: string | Ordering | (string | Ordering)[]\n\n\t/**\n\t * The `routes` option allows you to define how a page's `url` field is resolved.\n\t *\n\t * {@link https://prismic.io/docs/route-resolver}\n\t */\n\troutes?: Route | string | (Route | string)[]\n\n\t/**\n\t * The `brokenRoute` option allows you to define the route populated in the `url` property for\n\t * broken link or content relationship fields. A broken link is a link or content relationship\n\t * field whose linked page has been unpublished or deleted.\n\t *\n\t * {@link https://prismic.io/docs/route-resolver}\n\t */\n\tbrokenRoute?: string\n}\n\n/** Arguments for `buildQueryURL` to construct a Query URL. */\ntype BuildQueryURLParams = {\n\t/**\n\t * Ref used to query documents.\n\t *\n\t * {@link https://prismic.io/docs/api#refs-and-the-entry-api}\n\t */\n\tref: string\n\n\t/**\n\t * Ref used to populate integration fields with the latest content.\n\t *\n\t * {@link https://prismic.io/docs/integration-fields}\n\t */\n\tintegrationFieldsRef?: string\n\n\t/**\n\t * One or more filters to filter documents for the query.\n\t *\n\t * {@link https://prismic.io/docs/rest-api-technical-reference#q}\n\t */\n\tfilters?: string | string[]\n\n\t/**\n\t * @deprecated Renamed to `filters`. Ensure the value is an array of filters,\n\t * not a single, non-array filter.\n\t */\n\tpredicates?: string | string[]\n}\n\n/**\n * Parameters in this map have been renamed from the official Prismic REST API V2 specification for\n * better developer ergonomics.\n *\n * These parameters are renamed to their mapped value.\n */\nconst RENAMED_PARAMS = {\n\taccessToken: \"access_token\",\n} as const\n\n/** A valid parameter name for the Prismic REST API V2. */\ntype ValidParamName =\n\t| Exclude<keyof QueryParams, keyof typeof RENAMED_PARAMS | keyof BuildQueryURLParams>\n\t| ValueOf<typeof RENAMED_PARAMS>\n\n/**\n * Converts an Ordering to a string that is compatible with Prismic's REST API. If the value\n * provided is already a string, no conversion is performed.\n *\n * @param ordering - Ordering to convert.\n * @returns String representation of the Ordering.\n */\nconst castOrderingToString = (ordering: Ordering | string): string => {\n\t// TODO: Remove the following when `orderings` strings are no longer supported.\n\tif (typeof ordering === \"string\") {\n\t\tif (process.env.NODE_ENV === \"development\") {\n\t\t\tconst [field, direction] = ordering.split(\" \")\n\n\t\t\tconst objectForm =\n\t\t\t\tdirection === \"desc\" ? `{ field: \"${field}\", direction: \"desc\" }` : `{ field: \"${field}\" }`\n\n\t\t\tconsole.warn(\n\t\t\t\t`[@prismicio/client] A string value was provided to the \\`orderings\\` query parameter. Strings are deprecated. Please convert it to the object form: ${objectForm}. For more details, see ${devMsg(\n\t\t\t\t\t\"orderings-must-be-an-array-of-objects\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\n\t\treturn ordering\n\t}\n\n\treturn ordering.direction === \"desc\" ? `${ordering.field} desc` : ordering.field\n}\n\nexport type BuildQueryURLArgs = QueryParams & BuildQueryURLParams\n\n/**\n * Builds a Prismic Content API URL to request pages from a repository. The paginated response for\n * this URL includes pages matching the parameters.\n *\n * A ref is required to make a request. Request the `endpoint` URL to retrieve a list of available\n * refs.\n *\n * Type the JSON response with `Query`.\n *\n * @example\n * \t;```ts\n * \tconst url = buildQueryURL(\"https://my-repo.cdn.prismic.io/api/v2\", {\n * \t\tref: \"my-ref\",\n * \t\tfilters: [filter.at(\"document.type\", \"blog_post\")],\n * \t})\n * \t```\n *\n * @param endpoint - URL to the repository's Content API.\n * @param args - Arguments to filter and scope the query.\n * @returns URL that can be used to request pages from the repository.\n * @see Prismic Content API technical reference: {@link https://prismic.io/docs/content-api}\n */\nexport const buildQueryURL = (endpoint: string, args: BuildQueryURLArgs): string => {\n\tconst { filters, predicates, ...params } = args\n\n\tif (!endpoint.endsWith(\"/\")) {\n\t\tendpoint += \"/\"\n\t}\n\tconst url = new URL(`documents/search`, endpoint)\n\n\tif (filters) {\n\t\t// TODO: Remove warning when we remove support for string `filters` values.\n\t\tif (process.env.NODE_ENV === \"development\" && !Array.isArray(filters)) {\n\t\t\tconsole.warn(\n\t\t\t\t`[@prismicio/client] A non-array value was provided to the \\`filters\\` query parameter (\\`${filters}\\`). Non-array values are deprecated. Please convert it to an array. For more details, see ${devMsg(\n\t\t\t\t\t\"filters-must-be-an-array\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\n\t\t// TODO: Remove `castArray` when we remove support for string `filters` values.\n\t\tfor (const filter of castArray(filters)) {\n\t\t\turl.searchParams.append(\"q\", `[${filter}]`)\n\t\t}\n\t}\n\n\t// TODO: Remove when we remove support for deprecated `predicates` argument.\n\tif (predicates) {\n\t\tfor (const predicate of castArray(predicates)) {\n\t\t\turl.searchParams.append(\"q\", `[${predicate}]`)\n\t\t}\n\t}\n\n\t// Iterate over each parameter and add it to the URL. In some cases, the\n\t// parameter value needs to be transformed to fit the REST API.\n\tfor (const k in params) {\n\t\tconst name = (RENAMED_PARAMS[k as keyof typeof RENAMED_PARAMS] || k) as ValidParamName\n\n\t\tlet value = params[k as keyof typeof params]\n\n\t\tif (name === \"orderings\") {\n\t\t\tconst scopedValue = params[name]\n\n\t\t\tif (scopedValue != null) {\n\t\t\t\t// TODO: Remove the following warning when `orderings` strings are no longer supported.\n\t\t\t\tif (process.env.NODE_ENV === \"development\" && typeof scopedValue === \"string\") {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`[@prismicio/client] A string value was provided to the \\`orderings\\` query parameter. Strings are deprecated. Please convert it to an array of objects. For more details, see ${devMsg(\n\t\t\t\t\t\t\t\"orderings-must-be-an-array-of-objects\",\n\t\t\t\t\t\t)}`,\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tconst v = castArray(scopedValue)\n\t\t\t\t\t.map((ordering) => castOrderingToString(ordering))\n\t\t\t\t\t.join(\",\")\n\n\t\t\t\tvalue = `[${v}]`\n\t\t\t}\n\t\t} else if (name === \"routes\") {\n\t\t\tif (typeof params[name] === \"object\") {\n\t\t\t\tvalue = JSON.stringify(castArray(params[name]))\n\t\t\t}\n\t\t}\n\n\t\tif (value != null) {\n\t\t\turl.searchParams.set(name, castArray<string | number | Route | Ordering>(value).join(\",\"))\n\t\t}\n\t}\n\n\turl.searchParams.set(PRISMIC_CLIENT_VERSION_PARAM, `js-${version}`)\n\n\tif (process.env.NODE_ENV === \"development\") {\n\t\turl.searchParams.set(PRISMIC_DEV_PARAM, \"1\")\n\t}\n\n\treturn url.toString()\n}\n\nfunction castArray<A>(a: A | A[]): A[] {\n\treturn Array.isArray(a) ? a : [a]\n}\n"],"mappings":";;;;AAIA,MAAM,oBAAoB;;AAG1B,MAAM,+BAA+B;;;;;;;AA0NrC,MAAM,iBAAiB,EACtB,aAAa,eACd;;;;;;;;AAcA,MAAM,wBAAwB,aAAwC;CAErE,IAAI,OAAO,aAAa,UAAU;EACjC,IAAI,QAAQ,IAAI,aAAa,eAAe;GAC3C,MAAM,CAAC,OAAO,aAAa,SAAS,MAAM,GAAG;GAE7C,MAAM,aACL,cAAc,SAAS,aAAa,MAAM,0BAA0B,aAAa,MAAM;GAExF,QAAQ,KACP,uJAAuJ,WAAW,0BAA0B,OAC3L,uCACD,GACD;EACD;EAEA,OAAO;CACR;CAEA,OAAO,SAAS,cAAc,SAAS,GAAG,SAAS,MAAM,SAAS,SAAS;AAC5E;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,iBAAiB,UAAkB,SAAoC;CACnF,MAAM,EAAE,SAAS,YAAY,GA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I,CAAC,CAAC;AACjC"}
|
package/dist/cookie.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ declare namespace cookie_d_exports {
|
|
|
2
2
|
export { preview };
|
|
3
3
|
}
|
|
4
4
|
/** The well-known name of the cookie used to store a Prismic preview session's ref. */
|
|
5
|
-
declare const preview = "io.prismic.preview";
|
|
5
|
+
export declare const preview = "io.prismic.preview";
|
|
6
6
|
//#endregion
|
|
7
7
|
export { cookie_d_exports };
|
|
8
8
|
//# sourceMappingURL=cookie.d.cts.map
|
package/dist/cookie.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cookie.d.cts","names":[],"sources":["../src/cookie.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"cookie.d.cts","names":[],"sources":["../src/cookie.ts"],"mappings":";;;;qBACa"}
|
package/dist/cookie.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ declare namespace cookie_d_exports {
|
|
|
2
2
|
export { preview };
|
|
3
3
|
}
|
|
4
4
|
/** The well-known name of the cookie used to store a Prismic preview session's ref. */
|
|
5
|
-
declare const preview = "io.prismic.preview";
|
|
5
|
+
export declare const preview = "io.prismic.preview";
|
|
6
6
|
//#endregion
|
|
7
7
|
export { cookie_d_exports };
|
|
8
8
|
//# sourceMappingURL=cookie.d.ts.map
|
package/dist/cookie.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cookie.d.ts","names":[],"sources":["../src/cookie.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"cookie.d.ts","names":[],"sources":["../src/cookie.ts"],"mappings":";;;;qBACa"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createClient.cjs","names":["Client"],"sources":["../src/createClient.ts"],"sourcesContent":["import type { ClientConfig } from \"./Client\"\nimport { Client } from \"./Client\"\nimport type { PrismicDocument } from \"./types/value/document\"\n\n/** Type definitions for the `createClient()` function. May be augmented by third-party libraries. */\nexport interface CreateClient {\n\t<TDocuments extends PrismicDocument>(\n\t\t...args: ConstructorParameters<typeof Client>\n\t): Client<TDocuments>\n}\n\n/**\n * Creates a Prismic client that can be used to query content from a repository.\n *\n * @example\n * \t;```ts\n * \t// With a repository name\n * \tcreateClient(\"my-repo\")\n *\n * \t// With a full Prismic Content API endpoint\n * \tcreateClient(\"https://my-repo.cdn.prismic.io/api/v2\")\n * \t```\n *\n * @typeParam TDocuments - A union of Prismic page and custom types for the\n * repository.\n * @param repositoryNameOrEndpoint - The Prismic repository name or full Content API endpoint for\n * the repository.\n * @param options - Configuration that determines how content will be queried from the Prismic\n * repository.\n * @returns A client that can query content from the repository.\n * @see https://prismic.io/docs/technical-reference/prismicio-client/v7\n */\nexport const createClient: CreateClient = <TDocuments extends PrismicDocument>(\n\trepositoryNameOrEndpoint: string,\n\toptions?: ClientConfig,\n) => new Client<TDocuments>(repositoryNameOrEndpoint, options)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,gBACZ,0BACA,YACI,IAAIA,eAAAA,OAAmB,0BAA0B,
|
|
1
|
+
{"version":3,"file":"createClient.cjs","names":["Client"],"sources":["../src/createClient.ts"],"sourcesContent":["import type { ClientConfig } from \"./Client\"\nimport { Client } from \"./Client\"\nimport type { PrismicDocument } from \"./types/value/document\"\n\n/** Type definitions for the `createClient()` function. May be augmented by third-party libraries. */\nexport interface CreateClient {\n\t<TDocuments extends PrismicDocument>(\n\t\t...args: ConstructorParameters<typeof Client>\n\t): Client<TDocuments>\n}\n\n/**\n * Creates a Prismic client that can be used to query content from a repository.\n *\n * @example\n * \t;```ts\n * \t// With a repository name\n * \tcreateClient(\"my-repo\")\n *\n * \t// With a full Prismic Content API endpoint\n * \tcreateClient(\"https://my-repo.cdn.prismic.io/api/v2\")\n * \t```\n *\n * @typeParam TDocuments - A union of Prismic page and custom types for the\n * repository.\n * @param repositoryNameOrEndpoint - The Prismic repository name or full Content API endpoint for\n * the repository.\n * @param options - Configuration that determines how content will be queried from the Prismic\n * repository.\n * @returns A client that can query content from the repository.\n * @see https://prismic.io/docs/technical-reference/prismicio-client/v7\n */\nexport const createClient: CreateClient = <TDocuments extends PrismicDocument>(\n\trepositoryNameOrEndpoint: string,\n\toptions?: ClientConfig,\n) => new Client<TDocuments>(repositoryNameOrEndpoint, options)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,gBACZ,0BACA,YACI,IAAIA,eAAAA,OAAmB,0BAA0B,OAAO"}
|
package/dist/createClient.d.cts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { PrismicDocument } from "./types/value/document.cjs";
|
|
2
2
|
import { Client } from "./Client.cjs";
|
|
3
|
-
|
|
4
3
|
//#region src/createClient.d.ts
|
|
5
4
|
/** Type definitions for the `createClient()` function. May be augmented by third-party libraries. */
|
|
6
|
-
interface CreateClient {
|
|
5
|
+
export interface CreateClient {
|
|
7
6
|
<TDocuments extends PrismicDocument>(...args: ConstructorParameters<typeof Client>): Client<TDocuments>;
|
|
8
7
|
}
|
|
9
8
|
/**
|
|
@@ -27,7 +26,6 @@ interface CreateClient {
|
|
|
27
26
|
* @returns A client that can query content from the repository.
|
|
28
27
|
* @see https://prismic.io/docs/technical-reference/prismicio-client/v7
|
|
29
28
|
*/
|
|
30
|
-
declare const createClient: CreateClient;
|
|
29
|
+
export declare const createClient: CreateClient;
|
|
31
30
|
//#endregion
|
|
32
|
-
export { CreateClient, createClient };
|
|
33
31
|
//# sourceMappingURL=createClient.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createClient.d.cts","names":[],"sources":["../src/createClient.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"createClient.d.cts","names":[],"sources":["../src/createClient.ts"],"mappings":";;;;iBAKiB;GACf,mBAAmB,oBAChB,MAAM,6BAA6B,UACpC,OAAO;;;;;;;;;;;;;;;;;;;;;;;qBAwBE,cAAc"}
|
package/dist/createClient.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { PrismicDocument } from "./types/value/document.js";
|
|
2
2
|
import { Client } from "./Client.js";
|
|
3
|
-
|
|
4
3
|
//#region src/createClient.d.ts
|
|
5
4
|
/** Type definitions for the `createClient()` function. May be augmented by third-party libraries. */
|
|
6
|
-
interface CreateClient {
|
|
5
|
+
export interface CreateClient {
|
|
7
6
|
<TDocuments extends PrismicDocument>(...args: ConstructorParameters<typeof Client>): Client<TDocuments>;
|
|
8
7
|
}
|
|
9
8
|
/**
|
|
@@ -27,7 +26,6 @@ interface CreateClient {
|
|
|
27
26
|
* @returns A client that can query content from the repository.
|
|
28
27
|
* @see https://prismic.io/docs/technical-reference/prismicio-client/v7
|
|
29
28
|
*/
|
|
30
|
-
declare const createClient: CreateClient;
|
|
29
|
+
export declare const createClient: CreateClient;
|
|
31
30
|
//#endregion
|
|
32
|
-
export { CreateClient, createClient };
|
|
33
31
|
//# sourceMappingURL=createClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createClient.d.ts","names":[],"sources":["../src/createClient.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"createClient.d.ts","names":[],"sources":["../src/createClient.ts"],"mappings":";;;;iBAKiB;GACf,mBAAmB,oBAChB,MAAM,6BAA6B,UACpC,OAAO;;;;;;;;;;;;;;;;;;;;;;;qBAwBE,cAAc"}
|
package/dist/createClient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createClient.js","names":[],"sources":["../src/createClient.ts"],"sourcesContent":["import type { ClientConfig } from \"./Client\"\nimport { Client } from \"./Client\"\nimport type { PrismicDocument } from \"./types/value/document\"\n\n/** Type definitions for the `createClient()` function. May be augmented by third-party libraries. */\nexport interface CreateClient {\n\t<TDocuments extends PrismicDocument>(\n\t\t...args: ConstructorParameters<typeof Client>\n\t): Client<TDocuments>\n}\n\n/**\n * Creates a Prismic client that can be used to query content from a repository.\n *\n * @example\n * \t;```ts\n * \t// With a repository name\n * \tcreateClient(\"my-repo\")\n *\n * \t// With a full Prismic Content API endpoint\n * \tcreateClient(\"https://my-repo.cdn.prismic.io/api/v2\")\n * \t```\n *\n * @typeParam TDocuments - A union of Prismic page and custom types for the\n * repository.\n * @param repositoryNameOrEndpoint - The Prismic repository name or full Content API endpoint for\n * the repository.\n * @param options - Configuration that determines how content will be queried from the Prismic\n * repository.\n * @returns A client that can query content from the repository.\n * @see https://prismic.io/docs/technical-reference/prismicio-client/v7\n */\nexport const createClient: CreateClient = <TDocuments extends PrismicDocument>(\n\trepositoryNameOrEndpoint: string,\n\toptions?: ClientConfig,\n) => new Client<TDocuments>(repositoryNameOrEndpoint, options)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,gBACZ,0BACA,YACI,IAAI,OAAmB,0BAA0B,
|
|
1
|
+
{"version":3,"file":"createClient.js","names":[],"sources":["../src/createClient.ts"],"sourcesContent":["import type { ClientConfig } from \"./Client\"\nimport { Client } from \"./Client\"\nimport type { PrismicDocument } from \"./types/value/document\"\n\n/** Type definitions for the `createClient()` function. May be augmented by third-party libraries. */\nexport interface CreateClient {\n\t<TDocuments extends PrismicDocument>(\n\t\t...args: ConstructorParameters<typeof Client>\n\t): Client<TDocuments>\n}\n\n/**\n * Creates a Prismic client that can be used to query content from a repository.\n *\n * @example\n * \t;```ts\n * \t// With a repository name\n * \tcreateClient(\"my-repo\")\n *\n * \t// With a full Prismic Content API endpoint\n * \tcreateClient(\"https://my-repo.cdn.prismic.io/api/v2\")\n * \t```\n *\n * @typeParam TDocuments - A union of Prismic page and custom types for the\n * repository.\n * @param repositoryNameOrEndpoint - The Prismic repository name or full Content API endpoint for\n * the repository.\n * @param options - Configuration that determines how content will be queried from the Prismic\n * repository.\n * @returns A client that can query content from the repository.\n * @see https://prismic.io/docs/technical-reference/prismicio-client/v7\n */\nexport const createClient: CreateClient = <TDocuments extends PrismicDocument>(\n\trepositoryNameOrEndpoint: string,\n\toptions?: ClientConfig,\n) => new Client<TDocuments>(repositoryNameOrEndpoint, options)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,gBACZ,0BACA,YACI,IAAI,OAAmB,0BAA0B,OAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createMigration.cjs","names":["Migration"],"sources":["../src/createMigration.ts"],"sourcesContent":["import { Migration } from \"./Migration\"\nimport type { PrismicDocument } from \"./types/value/document\"\n\n/** Type definitions for the `createMigration()` function. May be augmented by third-party libraries. */\nexport interface CreateMigration {\n\t<TDocuments extends PrismicDocument>(\n\t\t...args: ConstructorParameters<typeof Migration>\n\t): Migration<TDocuments>\n}\n\n/**\n * Creates a Prismic migration instance that can be used to prepare your migration to Prismic.\n *\n * @example\n * \t;```ts\n * \tcreateMigration()\n * \t```\n *\n * @typeParam TDocuments - A union of Prismic document types for the repository.\n * @returns A migration instance to prepare your migration.\n */\nexport const createMigration: CreateMigration = <TDocuments extends PrismicDocument>() =>\n\tnew Migration<TDocuments>()\n"],"mappings":";;;;;;;;;;;;;AAqBA,MAAa,wBACZ,IAAIA,kBAAAA,
|
|
1
|
+
{"version":3,"file":"createMigration.cjs","names":["Migration"],"sources":["../src/createMigration.ts"],"sourcesContent":["import { Migration } from \"./Migration\"\nimport type { PrismicDocument } from \"./types/value/document\"\n\n/** Type definitions for the `createMigration()` function. May be augmented by third-party libraries. */\nexport interface CreateMigration {\n\t<TDocuments extends PrismicDocument>(\n\t\t...args: ConstructorParameters<typeof Migration>\n\t): Migration<TDocuments>\n}\n\n/**\n * Creates a Prismic migration instance that can be used to prepare your migration to Prismic.\n *\n * @example\n * \t;```ts\n * \tcreateMigration()\n * \t```\n *\n * @typeParam TDocuments - A union of Prismic document types for the repository.\n * @returns A migration instance to prepare your migration.\n */\nexport const createMigration: CreateMigration = <TDocuments extends PrismicDocument>() =>\n\tnew Migration<TDocuments>()\n"],"mappings":";;;;;;;;;;;;;AAqBA,MAAa,wBACZ,IAAIA,kBAAAA,UAAsB"}
|