@prismicio/client 7.21.0-alpha.1 → 7.21.0-canary.147e3f2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Client.cjs +920 -1268
- package/dist/Client.cjs.map +1 -1
- package/dist/Client.d.cts +704 -0
- package/dist/Client.d.cts.map +1 -0
- package/dist/Client.d.ts +678 -955
- package/dist/Client.d.ts.map +1 -0
- package/dist/Client.js +913 -1261
- package/dist/Client.js.map +1 -1
- package/dist/Migration.cjs +281 -312
- package/dist/Migration.cjs.map +1 -1
- package/dist/Migration.d.cts +216 -0
- package/dist/Migration.d.cts.map +1 -0
- package/dist/Migration.d.ts +197 -194
- package/dist/Migration.d.ts.map +1 -0
- package/dist/Migration.js +280 -311
- package/dist/Migration.js.map +1 -1
- package/dist/WriteClient.cjs +486 -558
- package/dist/WriteClient.cjs.map +1 -1
- package/dist/WriteClient.d.cts +262 -0
- package/dist/WriteClient.d.cts.map +1 -0
- package/dist/WriteClient.d.ts +226 -245
- package/dist/WriteClient.d.ts.map +1 -0
- package/dist/WriteClient.js +482 -554
- package/dist/WriteClient.js.map +1 -1
- package/dist/_virtual/rolldown_runtime.cjs +14 -0
- package/dist/_virtual/rolldown_runtime.js +13 -0
- package/dist/buildQueryURL.cjs +89 -59
- package/dist/buildQueryURL.cjs.map +1 -1
- package/dist/buildQueryURL.d.cts +212 -0
- package/dist/buildQueryURL.d.cts.map +1 -0
- package/dist/buildQueryURL.d.ts +164 -161
- package/dist/buildQueryURL.d.ts.map +1 -0
- package/dist/buildQueryURL.js +89 -59
- package/dist/buildQueryURL.js.map +1 -1
- package/dist/cookie.cjs +17 -3
- package/dist/cookie.cjs.map +1 -1
- package/dist/cookie.d.cts +11 -0
- package/dist/cookie.d.cts.map +1 -0
- package/dist/cookie.d.ts +7 -1
- package/dist/cookie.d.ts.map +1 -0
- package/dist/cookie.js +12 -4
- package/dist/cookie.js.map +1 -1
- package/dist/createClient.cjs +32 -5
- package/dist/createClient.cjs.map +1 -1
- package/dist/createClient.d.cts +41 -0
- package/dist/createClient.d.cts.map +1 -0
- package/dist/createClient.d.ts +22 -13
- package/dist/createClient.d.ts.map +1 -0
- package/dist/createClient.js +31 -4
- package/dist/createClient.js.map +1 -1
- package/dist/createMigration.cjs +21 -5
- package/dist/createMigration.cjs.map +1 -1
- package/dist/createMigration.d.cts +30 -0
- package/dist/createMigration.d.cts.map +1 -0
- package/dist/createMigration.d.ts +11 -5
- package/dist/createMigration.d.ts.map +1 -0
- package/dist/createMigration.js +20 -4
- package/dist/createMigration.js.map +1 -1
- package/dist/createWriteClient.cjs +29 -5
- package/dist/createWriteClient.cjs.map +1 -1
- package/dist/createWriteClient.d.cts +38 -0
- package/dist/createWriteClient.d.cts.map +1 -0
- package/dist/createWriteClient.d.ts +11 -5
- package/dist/createWriteClient.d.ts.map +1 -0
- package/dist/createWriteClient.js +28 -4
- package/dist/createWriteClient.js.map +1 -1
- package/dist/errors.cjs +31 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.d.cts +46 -0
- package/dist/errors.d.cts.map +1 -0
- package/dist/errors.d.ts +46 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +22 -0
- package/dist/errors.js.map +1 -0
- package/dist/filter.cjs +93 -236
- package/dist/filter.cjs.map +1 -1
- package/dist/filter.d.cts +213 -0
- package/dist/filter.d.cts.map +1 -0
- package/dist/filter.d.ts +212 -208
- package/dist/filter.d.ts.map +1 -0
- package/dist/filter.js +93 -237
- package/dist/filter.js.map +1 -1
- package/dist/getGraphQLEndpoint.cjs +18 -10
- package/dist/getGraphQLEndpoint.cjs.map +1 -1
- package/dist/getGraphQLEndpoint.d.cts +14 -0
- package/dist/getGraphQLEndpoint.d.cts.map +1 -0
- package/dist/getGraphQLEndpoint.d.ts +5 -1
- package/dist/getGraphQLEndpoint.d.ts.map +1 -0
- package/dist/getGraphQLEndpoint.js +18 -10
- package/dist/getGraphQLEndpoint.js.map +1 -1
- package/dist/getRepositoryEndpoint.cjs +27 -10
- package/dist/getRepositoryEndpoint.cjs.map +1 -1
- package/dist/getRepositoryEndpoint.d.cts +23 -0
- package/dist/getRepositoryEndpoint.d.cts.map +1 -0
- package/dist/getRepositoryEndpoint.d.ts +14 -3
- package/dist/getRepositoryEndpoint.d.ts.map +1 -0
- package/dist/getRepositoryEndpoint.js +27 -10
- package/dist/getRepositoryEndpoint.js.map +1 -1
- package/dist/getRepositoryName.cjs +22 -14
- package/dist/getRepositoryName.cjs.map +1 -1
- package/dist/getRepositoryName.d.cts +16 -0
- package/dist/getRepositoryName.d.cts.map +1 -0
- package/dist/getRepositoryName.d.ts +5 -1
- package/dist/getRepositoryName.d.ts.map +1 -0
- package/dist/getRepositoryName.js +23 -15
- package/dist/getRepositoryName.js.map +1 -1
- package/dist/getToolbarSrc.cjs +42 -10
- package/dist/getToolbarSrc.cjs.map +1 -1
- package/dist/getToolbarSrc.d.cts +38 -0
- package/dist/getToolbarSrc.d.cts.map +1 -0
- package/dist/getToolbarSrc.d.ts +5 -1
- package/dist/getToolbarSrc.d.ts.map +1 -0
- package/dist/getToolbarSrc.js +42 -10
- package/dist/getToolbarSrc.js.map +1 -1
- package/dist/helpers/asDate.cjs +36 -11
- package/dist/helpers/asDate.cjs.map +1 -1
- package/dist/helpers/asDate.d.cts +29 -0
- package/dist/helpers/asDate.d.cts.map +1 -0
- package/dist/helpers/asDate.d.ts +20 -8
- package/dist/helpers/asDate.d.ts.map +1 -0
- package/dist/helpers/asDate.js +36 -12
- package/dist/helpers/asDate.js.map +1 -1
- package/dist/helpers/asHTML.cjs +76 -79
- package/dist/helpers/asHTML.cjs.map +1 -1
- package/dist/helpers/asHTML.d.cts +147 -0
- package/dist/helpers/asHTML.d.cts.map +1 -0
- package/dist/helpers/asHTML.d.ts +84 -78
- package/dist/helpers/asHTML.d.ts.map +1 -0
- package/dist/helpers/asHTML.js +74 -77
- package/dist/helpers/asHTML.js.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.cjs +57 -18
- package/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.d.cts +59 -0
- package/dist/helpers/asImagePixelDensitySrcSet.d.cts.map +1 -0
- package/dist/helpers/asImagePixelDensitySrcSet.d.ts +31 -25
- package/dist/helpers/asImagePixelDensitySrcSet.d.ts.map +1 -0
- package/dist/helpers/asImagePixelDensitySrcSet.js +57 -18
- package/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -1
- package/dist/helpers/asImageSrc.cjs +30 -10
- package/dist/helpers/asImageSrc.cjs.map +1 -1
- package/dist/helpers/asImageSrc.d.cts +34 -0
- package/dist/helpers/asImageSrc.d.cts.map +1 -0
- package/dist/helpers/asImageSrc.d.ts +20 -14
- package/dist/helpers/asImageSrc.d.ts.map +1 -0
- package/dist/helpers/asImageSrc.js +30 -10
- package/dist/helpers/asImageSrc.js.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.cjs +76 -42
- package/dist/helpers/asImageWidthSrcSet.cjs.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.d.cts +67 -0
- package/dist/helpers/asImageWidthSrcSet.d.cts.map +1 -0
- package/dist/helpers/asImageWidthSrcSet.d.ts +34 -28
- package/dist/helpers/asImageWidthSrcSet.d.ts.map +1 -0
- package/dist/helpers/asImageWidthSrcSet.js +76 -42
- package/dist/helpers/asImageWidthSrcSet.js.map +1 -1
- package/dist/helpers/asLink.cjs +26 -44
- package/dist/helpers/asLink.cjs.map +1 -1
- package/dist/helpers/asLink.d.cts +83 -0
- package/dist/helpers/asLink.d.cts.map +1 -0
- package/dist/helpers/asLink.d.ts +64 -58
- package/dist/helpers/asLink.d.ts.map +1 -0
- package/dist/helpers/asLink.js +25 -43
- package/dist/helpers/asLink.js.map +1 -1
- package/dist/helpers/asLinkAttrs.cjs +44 -25
- package/dist/helpers/asLinkAttrs.cjs.map +1 -1
- package/dist/helpers/asLinkAttrs.d.cts +51 -0
- package/dist/helpers/asLinkAttrs.d.cts.map +1 -0
- package/dist/helpers/asLinkAttrs.d.ts +29 -28
- package/dist/helpers/asLinkAttrs.d.ts.map +1 -0
- package/dist/helpers/asLinkAttrs.js +43 -24
- package/dist/helpers/asLinkAttrs.js.map +1 -1
- package/dist/helpers/asText.cjs +15 -20
- package/dist/helpers/asText.cjs.map +1 -1
- package/dist/helpers/asText.d.cts +62 -0
- package/dist/helpers/asText.d.cts.map +1 -0
- package/dist/helpers/asText.d.ts +48 -33
- package/dist/helpers/asText.d.ts.map +1 -0
- package/dist/helpers/asText.js +15 -20
- package/dist/helpers/asText.js.map +1 -1
- package/dist/helpers/documentToLinkField.cjs +30 -24
- package/dist/helpers/documentToLinkField.cjs.map +1 -1
- package/dist/helpers/documentToLinkField.d.cts +21 -0
- package/dist/helpers/documentToLinkField.d.cts.map +1 -0
- package/dist/helpers/documentToLinkField.d.ts +8 -4
- package/dist/helpers/documentToLinkField.d.ts.map +1 -0
- package/dist/helpers/documentToLinkField.js +30 -24
- package/dist/helpers/documentToLinkField.js.map +1 -1
- package/dist/helpers/isFilled.cjs +215 -42
- package/dist/helpers/isFilled.cjs.map +1 -1
- package/dist/helpers/isFilled.d.cts +199 -0
- package/dist/helpers/isFilled.d.cts.map +1 -0
- package/dist/helpers/isFilled.d.ts +65 -56
- package/dist/helpers/isFilled.d.ts.map +1 -0
- package/dist/helpers/isFilled.js +210 -44
- package/dist/helpers/isFilled.js.map +1 -1
- package/dist/helpers/mapSliceZone.cjs +50 -39
- package/dist/helpers/mapSliceZone.cjs.map +1 -1
- package/dist/helpers/mapSliceZone.d.cts +139 -0
- package/dist/helpers/mapSliceZone.d.cts.map +1 -0
- package/dist/helpers/mapSliceZone.d.ts +47 -44
- package/dist/helpers/mapSliceZone.d.ts.map +1 -0
- package/dist/helpers/mapSliceZone.js +50 -40
- package/dist/helpers/mapSliceZone.js.map +1 -1
- package/dist/index.cjs +109 -94
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +173 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +143 -173
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -73
- package/dist/index.js.map +1 -1
- package/dist/isRepositoryEndpoint.cjs +20 -9
- package/dist/isRepositoryEndpoint.cjs.map +1 -1
- package/dist/isRepositoryEndpoint.d.cts +14 -0
- package/dist/isRepositoryEndpoint.d.cts.map +1 -0
- package/dist/isRepositoryEndpoint.d.ts +7 -3
- package/dist/isRepositoryEndpoint.d.ts.map +1 -0
- package/dist/isRepositoryEndpoint.js +20 -10
- package/dist/isRepositoryEndpoint.js.map +1 -1
- package/dist/isRepositoryName.cjs +14 -4
- package/dist/isRepositoryName.cjs.map +1 -1
- package/dist/isRepositoryName.d.cts +13 -0
- package/dist/isRepositoryName.d.cts.map +1 -0
- package/dist/isRepositoryName.d.ts +5 -1
- package/dist/isRepositoryName.d.ts.map +1 -0
- package/dist/isRepositoryName.js +14 -5
- package/dist/isRepositoryName.js.map +1 -1
- package/dist/lib/devMsg.cjs +22 -5
- package/dist/lib/devMsg.cjs.map +1 -1
- package/dist/lib/devMsg.js +23 -6
- package/dist/lib/devMsg.js.map +1 -1
- package/dist/lib/escapeHTML.cjs +36 -39
- package/dist/lib/escapeHTML.cjs.map +1 -1
- package/dist/lib/escapeHTML.js +36 -40
- package/dist/lib/escapeHTML.js.map +1 -1
- package/dist/lib/getOptionalLinkProperties.cjs +19 -11
- package/dist/lib/getOptionalLinkProperties.cjs.map +1 -1
- package/dist/lib/getOptionalLinkProperties.js +19 -12
- package/dist/lib/getOptionalLinkProperties.js.map +1 -1
- package/dist/lib/getPreviewCookie.cjs +25 -16
- package/dist/lib/getPreviewCookie.cjs.map +1 -1
- package/dist/lib/getPreviewCookie.js +25 -16
- package/dist/lib/getPreviewCookie.js.map +1 -1
- package/dist/lib/isInternalURL.cjs +15 -6
- package/dist/lib/isInternalURL.cjs.map +1 -1
- package/dist/lib/isInternalURL.js +15 -7
- package/dist/lib/isInternalURL.js.map +1 -1
- package/dist/lib/isMigrationValue.cjs +65 -12
- package/dist/lib/isMigrationValue.cjs.map +1 -1
- package/dist/lib/isMigrationValue.js +63 -13
- package/dist/lib/isMigrationValue.js.map +1 -1
- package/dist/lib/isValue.cjs +93 -36
- package/dist/lib/isValue.cjs.map +1 -1
- package/dist/lib/isValue.js +93 -40
- package/dist/lib/isValue.js.map +1 -1
- package/dist/lib/pLimit.cjs +51 -45
- package/dist/lib/pLimit.cjs.map +1 -1
- package/dist/lib/pLimit.js +51 -46
- package/dist/lib/pLimit.js.map +1 -1
- package/dist/lib/request.cjs +54 -37
- package/dist/lib/request.cjs.map +1 -1
- package/dist/lib/request.d.cts +61 -0
- package/dist/lib/request.d.cts.map +1 -0
- package/dist/lib/request.d.ts +38 -50
- package/dist/lib/request.d.ts.map +1 -0
- package/dist/lib/request.js +54 -37
- package/dist/lib/request.js.map +1 -1
- package/dist/lib/resolveMigrationDocumentData.cjs +147 -125
- package/dist/lib/resolveMigrationDocumentData.cjs.map +1 -1
- package/dist/lib/resolveMigrationDocumentData.js +143 -122
- package/dist/lib/resolveMigrationDocumentData.js.map +1 -1
- package/dist/lib/serializerHelpers.cjs +73 -91
- package/dist/lib/serializerHelpers.cjs.map +1 -1
- package/dist/lib/serializerHelpers.js +71 -94
- package/dist/lib/serializerHelpers.js.map +1 -1
- package/dist/lib/throttledWarn.cjs +27 -0
- package/dist/lib/throttledWarn.cjs.map +1 -0
- package/dist/lib/throttledWarn.js +26 -0
- package/dist/lib/throttledWarn.js.map +1 -0
- package/dist/lib/validateAssetMetadata.cjs +40 -20
- package/dist/lib/validateAssetMetadata.cjs.map +1 -1
- package/dist/lib/validateAssetMetadata.js +41 -21
- package/dist/lib/validateAssetMetadata.js.map +1 -1
- package/dist/package.cjs +19 -0
- package/dist/package.cjs.map +1 -0
- package/dist/package.js +7 -0
- package/dist/package.js.map +1 -0
- package/dist/richtext/asText.cjs +18 -10
- package/dist/richtext/asText.cjs.map +1 -1
- package/dist/richtext/asText.d.cts +18 -0
- package/dist/richtext/asText.d.cts.map +1 -0
- package/dist/richtext/asText.d.ts +13 -7
- package/dist/richtext/asText.d.ts.map +1 -0
- package/dist/richtext/asText.js +18 -11
- package/dist/richtext/asText.js.map +1 -1
- package/dist/richtext/asTree.cjs +106 -107
- package/dist/richtext/asTree.cjs.map +1 -1
- package/dist/richtext/asTree.d.cts +20 -0
- package/dist/richtext/asTree.d.cts.map +1 -0
- package/dist/richtext/asTree.d.ts +9 -3
- package/dist/richtext/asTree.d.ts.map +1 -0
- package/dist/richtext/asTree.js +106 -107
- package/dist/richtext/asTree.js.map +1 -1
- package/dist/richtext/composeSerializers.cjs +28 -14
- package/dist/richtext/composeSerializers.cjs.map +1 -1
- package/dist/richtext/composeSerializers.d.cts +22 -0
- package/dist/richtext/composeSerializers.d.cts.map +1 -0
- package/dist/richtext/composeSerializers.d.ts +8 -2
- package/dist/richtext/composeSerializers.d.ts.map +1 -0
- package/dist/richtext/composeSerializers.js +28 -15
- package/dist/richtext/composeSerializers.js.map +1 -1
- package/dist/richtext/serialize.cjs +30 -14
- package/dist/richtext/serialize.cjs.map +1 -1
- package/dist/richtext/serialize.d.cts +25 -0
- package/dist/richtext/serialize.d.cts.map +1 -0
- package/dist/richtext/serialize.d.ts +17 -11
- package/dist/richtext/serialize.d.ts.map +1 -0
- package/dist/richtext/serialize.js +30 -14
- package/dist/richtext/serialize.js.map +1 -1
- package/dist/richtext/types.cjs +10 -8
- package/dist/richtext/types.cjs.map +1 -1
- package/dist/richtext/types.d.cts +71 -0
- package/dist/richtext/types.d.cts.map +1 -0
- package/dist/richtext/types.d.ts +49 -49
- package/dist/richtext/types.d.ts.map +1 -0
- package/dist/richtext/types.js +10 -8
- package/dist/richtext/types.js.map +1 -1
- package/dist/richtext/wrapMapSerializer.cjs +29 -21
- package/dist/richtext/wrapMapSerializer.cjs.map +1 -1
- package/dist/richtext/wrapMapSerializer.d.cts +21 -0
- package/dist/richtext/wrapMapSerializer.d.cts.map +1 -0
- package/dist/richtext/wrapMapSerializer.d.ts +8 -2
- package/dist/richtext/wrapMapSerializer.d.ts.map +1 -0
- package/dist/richtext/wrapMapSerializer.js +29 -21
- package/dist/richtext/wrapMapSerializer.js.map +1 -1
- package/dist/richtext.cjs +13 -15
- package/dist/richtext.d.cts +8 -0
- package/dist/richtext.d.ts +8 -0
- package/dist/richtext.js +4 -11
- package/dist/types/api/asset/asset.d.cts +97 -0
- package/dist/types/api/asset/asset.d.cts.map +1 -0
- package/dist/types/api/asset/asset.d.ts +87 -167
- package/dist/types/api/asset/asset.d.ts.map +1 -0
- package/dist/types/api/asset/tag.d.cts +35 -0
- package/dist/types/api/asset/tag.d.cts.map +1 -0
- package/dist/types/api/asset/tag.d.ts +29 -47
- package/dist/types/api/asset/tag.d.ts.map +1 -0
- package/dist/types/api/integration.d.cts +34 -0
- package/dist/types/api/integration.d.cts.map +1 -0
- package/dist/types/api/integration.d.ts +17 -11
- package/dist/types/api/integration.d.ts.map +1 -0
- package/dist/types/api/query.d.cts +49 -0
- package/dist/types/api/query.d.cts.map +1 -0
- package/dist/types/api/query.d.ts +40 -34
- package/dist/types/api/query.d.ts.map +1 -0
- package/dist/types/api/ref.d.cts +36 -0
- package/dist/types/api/ref.d.cts.map +1 -0
- package/dist/types/api/ref.d.ts +30 -26
- package/dist/types/api/ref.d.ts.map +1 -0
- package/dist/types/api/release.d.cts +17 -0
- package/dist/types/api/release.d.cts.map +1 -0
- package/dist/types/api/release.d.ts +8 -2
- package/dist/types/api/release.d.ts.map +1 -0
- package/dist/types/api/repository.d.cts +115 -0
- package/dist/types/api/repository.d.cts.map +1 -0
- package/dist/types/api/repository.d.ts +90 -84
- package/dist/types/api/repository.d.ts.map +1 -0
- package/dist/types/api/tags.d.cts +13 -0
- package/dist/types/api/tags.d.cts.map +1 -0
- package/dist/types/api/tags.d.ts +5 -1
- package/dist/types/api/tags.d.ts.map +1 -0
- package/dist/types/migration/Asset.cjs +34 -32
- package/dist/types/migration/Asset.cjs.map +1 -1
- package/dist/types/migration/Asset.d.cts +109 -0
- package/dist/types/migration/Asset.d.cts.map +1 -0
- package/dist/types/migration/Asset.d.ts +89 -88
- package/dist/types/migration/Asset.d.ts.map +1 -0
- package/dist/types/migration/Asset.js +33 -32
- package/dist/types/migration/Asset.js.map +1 -1
- package/dist/types/migration/ContentRelationship.d.cts +15 -0
- package/dist/types/migration/ContentRelationship.d.cts.map +1 -0
- package/dist/types/migration/ContentRelationship.d.ts +10 -11
- package/dist/types/migration/ContentRelationship.d.ts.map +1 -0
- package/dist/types/migration/Document.cjs +50 -46
- package/dist/types/migration/Document.cjs.map +1 -1
- package/dist/types/migration/Document.d.cts +97 -0
- package/dist/types/migration/Document.d.cts.map +1 -0
- package/dist/types/migration/Document.d.ts +62 -59
- package/dist/types/migration/Document.d.ts.map +1 -0
- package/dist/types/migration/Document.js +49 -46
- package/dist/types/migration/Document.js.map +1 -1
- package/dist/types/model/boolean.d.cts +21 -0
- package/dist/types/model/boolean.d.cts.map +1 -0
- package/dist/types/model/boolean.d.ts +15 -9
- package/dist/types/model/boolean.d.ts.map +1 -0
- package/dist/types/model/color.d.cts +19 -0
- package/dist/types/model/color.d.cts.map +1 -0
- package/dist/types/model/color.d.ts +13 -7
- package/dist/types/model/color.d.ts.map +1 -0
- package/dist/types/model/contentRelationship.d.cts +59 -0
- package/dist/types/model/contentRelationship.d.cts.map +1 -0
- package/dist/types/model/contentRelationship.d.ts +33 -26
- package/dist/types/model/contentRelationship.d.ts.map +1 -0
- package/dist/types/model/customType.d.cts +54 -0
- package/dist/types/model/customType.d.cts.map +1 -0
- package/dist/types/model/customType.d.ts +36 -30
- package/dist/types/model/customType.d.ts.map +1 -0
- package/dist/types/model/date.d.cts +20 -0
- package/dist/types/model/date.d.cts.map +1 -0
- package/dist/types/model/date.d.ts +14 -8
- package/dist/types/model/date.d.ts.map +1 -0
- package/dist/types/model/embed.d.cts +19 -0
- package/dist/types/model/embed.d.cts.map +1 -0
- package/dist/types/model/embed.d.ts +13 -7
- package/dist/types/model/embed.d.ts.map +1 -0
- package/dist/types/model/geoPoint.d.cts +18 -0
- package/dist/types/model/geoPoint.d.cts.map +1 -0
- package/dist/types/model/geoPoint.d.ts +12 -6
- package/dist/types/model/geoPoint.d.ts.map +1 -0
- package/dist/types/model/group.d.cts +29 -0
- package/dist/types/model/group.d.cts.map +1 -0
- package/dist/types/model/group.d.ts +14 -8
- package/dist/types/model/group.d.ts.map +1 -0
- package/dist/types/model/image.d.cts +37 -0
- package/dist/types/model/image.d.cts.map +1 -0
- package/dist/types/model/image.d.ts +19 -13
- package/dist/types/model/image.d.ts.map +1 -0
- package/dist/types/model/integration.d.cts +20 -0
- package/dist/types/model/integration.d.cts.map +1 -0
- package/dist/types/model/integration.d.ts +14 -8
- package/dist/types/model/integration.d.ts.map +1 -0
- package/dist/types/model/keyText.d.cts +19 -0
- package/dist/types/model/keyText.d.cts.map +1 -0
- package/dist/types/model/keyText.d.ts +13 -7
- package/dist/types/model/keyText.d.ts.map +1 -0
- package/dist/types/model/link.cjs +13 -6
- package/dist/types/model/link.cjs.map +1 -1
- package/dist/types/model/link.d.cts +34 -0
- package/dist/types/model/link.d.cts.map +1 -0
- package/dist/types/model/link.d.ts +22 -16
- package/dist/types/model/link.d.ts.map +1 -0
- package/dist/types/model/link.js +13 -7
- package/dist/types/model/link.js.map +1 -1
- package/dist/types/model/linkToMedia.d.cts +23 -0
- package/dist/types/model/linkToMedia.d.cts.map +1 -0
- package/dist/types/model/linkToMedia.d.ts +17 -11
- package/dist/types/model/linkToMedia.d.ts.map +1 -0
- package/dist/types/model/number.d.cts +21 -0
- package/dist/types/model/number.d.cts.map +1 -0
- package/dist/types/model/number.d.ts +15 -9
- package/dist/types/model/number.d.ts.map +1 -0
- package/dist/types/model/range.d.cts +20 -0
- package/dist/types/model/range.d.cts.map +1 -0
- package/dist/types/model/range.d.ts +16 -10
- package/dist/types/model/range.d.ts.map +1 -0
- package/dist/types/model/richText.d.cts +43 -0
- package/dist/types/model/richText.d.cts.map +1 -0
- package/dist/types/model/richText.d.ts +26 -20
- package/dist/types/model/richText.d.ts.map +1 -0
- package/dist/types/model/select.d.cts +24 -0
- package/dist/types/model/select.d.cts.map +1 -0
- package/dist/types/model/select.d.ts +15 -9
- package/dist/types/model/select.d.ts.map +1 -0
- package/dist/types/model/separator.d.cts +16 -0
- package/dist/types/model/separator.d.cts.map +1 -0
- package/dist/types/model/separator.d.ts +12 -6
- package/dist/types/model/separator.d.ts.map +1 -0
- package/dist/types/model/sharedSlice.d.cts +22 -0
- package/dist/types/model/sharedSlice.d.cts.map +1 -0
- package/dist/types/model/sharedSlice.d.ts +14 -8
- package/dist/types/model/sharedSlice.d.ts.map +1 -0
- package/dist/types/model/sharedSliceVariation.d.cts +25 -0
- package/dist/types/model/sharedSliceVariation.d.cts.map +1 -0
- package/dist/types/model/sharedSliceVariation.d.ts +16 -10
- package/dist/types/model/sharedSliceVariation.d.ts.map +1 -0
- package/dist/types/model/slice.cjs +12 -5
- package/dist/types/model/slice.cjs.map +1 -1
- package/dist/types/model/slice.d.cts +39 -0
- package/dist/types/model/slice.d.cts.map +1 -0
- package/dist/types/model/slice.d.ts +21 -15
- package/dist/types/model/slice.d.ts.map +1 -0
- package/dist/types/model/slice.js +12 -6
- package/dist/types/model/slice.js.map +1 -1
- package/dist/types/model/sliceZone.cjs +12 -5
- package/dist/types/model/sliceZone.cjs.map +1 -1
- package/dist/types/model/sliceZone.d.cts +47 -0
- package/dist/types/model/sliceZone.d.cts.map +1 -0
- package/dist/types/model/sliceZone.d.ts +23 -17
- package/dist/types/model/sliceZone.d.ts.map +1 -0
- package/dist/types/model/sliceZone.js +12 -6
- package/dist/types/model/sliceZone.js.map +1 -1
- package/dist/types/model/table.d.cts +18 -0
- package/dist/types/model/table.d.cts.map +1 -0
- package/dist/types/model/table.d.ts +12 -6
- package/dist/types/model/table.d.ts.map +1 -0
- package/dist/types/model/timestamp.d.cts +20 -0
- package/dist/types/model/timestamp.d.cts.map +1 -0
- package/dist/types/model/timestamp.d.ts +14 -8
- package/dist/types/model/timestamp.d.ts.map +1 -0
- package/dist/types/model/title.d.cts +13 -0
- package/dist/types/model/title.d.cts.map +1 -0
- package/dist/types/model/title.d.ts +8 -2
- package/dist/types/model/title.d.ts.map +1 -0
- package/dist/types/model/types.cjs +29 -36
- package/dist/types/model/types.cjs.map +1 -1
- package/dist/types/model/types.d.cts +82 -0
- package/dist/types/model/types.d.cts.map +1 -0
- package/dist/types/model/types.d.ts +66 -61
- package/dist/types/model/types.d.ts.map +1 -0
- package/dist/types/model/types.js +29 -37
- package/dist/types/model/types.js.map +1 -1
- package/dist/types/model/uid.d.cts +19 -0
- package/dist/types/model/uid.d.cts.map +1 -0
- package/dist/types/model/uid.d.ts +13 -7
- package/dist/types/model/uid.d.ts.map +1 -0
- package/dist/types/value/boolean.d.cts +10 -0
- package/dist/types/value/boolean.d.cts.map +1 -0
- package/dist/types/value/boolean.d.ts +5 -1
- package/dist/types/value/boolean.d.ts.map +1 -0
- package/dist/types/value/color.d.cts +15 -0
- package/dist/types/value/color.d.cts.map +1 -0
- package/dist/types/value/color.d.ts +8 -2
- package/dist/types/value/color.d.ts.map +1 -0
- package/dist/types/value/contentRelationship.d.cts +37 -0
- package/dist/types/value/contentRelationship.d.cts.map +1 -0
- package/dist/types/value/contentRelationship.d.ts +23 -17
- package/dist/types/value/contentRelationship.d.ts.map +1 -0
- package/dist/types/value/date.d.cts +15 -0
- package/dist/types/value/date.d.cts.map +1 -0
- package/dist/types/value/date.d.ts +8 -2
- package/dist/types/value/date.d.ts.map +1 -0
- package/dist/types/value/document.d.cts +120 -0
- package/dist/types/value/document.d.cts.map +1 -0
- package/dist/types/value/document.d.ts +90 -84
- package/dist/types/value/document.d.ts.map +1 -0
- package/dist/types/value/embed.cjs +14 -7
- package/dist/types/value/embed.cjs.map +1 -1
- package/dist/types/value/embed.d.cts +173 -0
- package/dist/types/value/embed.d.cts.map +1 -0
- package/dist/types/value/embed.d.ts +110 -105
- package/dist/types/value/embed.d.ts.map +1 -0
- package/dist/types/value/embed.js +14 -8
- package/dist/types/value/embed.js.map +1 -1
- package/dist/types/value/geoPoint.d.cts +18 -0
- package/dist/types/value/geoPoint.d.cts.map +1 -0
- package/dist/types/value/geoPoint.d.ts +10 -4
- package/dist/types/value/geoPoint.d.ts.map +1 -0
- package/dist/types/value/group.d.cts +19 -0
- package/dist/types/value/group.d.cts.map +1 -0
- package/dist/types/value/group.d.ts +9 -3
- package/dist/types/value/group.d.ts.map +1 -0
- package/dist/types/value/image.d.cts +53 -0
- package/dist/types/value/image.d.cts.map +1 -0
- package/dist/types/value/image.d.ts +31 -25
- package/dist/types/value/image.d.ts.map +1 -0
- package/dist/types/value/integration.d.cts +22 -0
- package/dist/types/value/integration.d.cts.map +1 -0
- package/dist/types/value/integration.d.ts +9 -3
- package/dist/types/value/integration.d.ts.map +1 -0
- package/dist/types/value/keyText.d.cts +15 -0
- package/dist/types/value/keyText.d.cts.map +1 -0
- package/dist/types/value/keyText.d.ts +8 -2
- package/dist/types/value/keyText.d.ts.map +1 -0
- package/dist/types/value/link.cjs +12 -7
- package/dist/types/value/link.cjs.map +1 -1
- package/dist/types/value/link.d.cts +74 -0
- package/dist/types/value/link.d.cts.map +1 -0
- package/dist/types/value/link.d.ts +27 -21
- package/dist/types/value/link.d.ts.map +1 -0
- package/dist/types/value/link.js +12 -8
- package/dist/types/value/link.js.map +1 -1
- package/dist/types/value/linkToMedia.d.cts +33 -0
- package/dist/types/value/linkToMedia.d.cts.map +1 -0
- package/dist/types/value/linkToMedia.d.ts +19 -14
- package/dist/types/value/linkToMedia.d.ts.map +1 -0
- package/dist/types/value/number.d.cts +15 -0
- package/dist/types/value/number.d.cts.map +1 -0
- package/dist/types/value/number.d.ts +8 -2
- package/dist/types/value/number.d.ts.map +1 -0
- package/dist/types/value/richText.cjs +29 -22
- package/dist/types/value/richText.cjs.map +1 -1
- package/dist/types/value/richText.d.cts +221 -0
- package/dist/types/value/richText.d.cts.map +1 -0
- package/dist/types/value/richText.d.ts +103 -97
- package/dist/types/value/richText.d.ts.map +1 -0
- package/dist/types/value/richText.js +29 -23
- package/dist/types/value/richText.js.map +1 -1
- package/dist/types/value/select.d.cts +16 -0
- package/dist/types/value/select.d.cts.map +1 -0
- package/dist/types/value/select.d.ts +8 -2
- package/dist/types/value/select.d.ts.map +1 -0
- package/dist/types/value/sharedSlice.d.cts +17 -0
- package/dist/types/value/sharedSlice.d.cts.map +1 -0
- package/dist/types/value/sharedSlice.d.ts +11 -5
- package/dist/types/value/sharedSlice.d.ts.map +1 -0
- package/dist/types/value/sharedSliceVariation.d.cts +16 -0
- package/dist/types/value/sharedSliceVariation.d.cts.map +1 -0
- package/dist/types/value/sharedSliceVariation.d.ts +12 -6
- package/dist/types/value/sharedSliceVariation.d.ts.map +1 -0
- package/dist/types/value/slice.d.cts +19 -0
- package/dist/types/value/slice.d.cts.map +1 -0
- package/dist/types/value/slice.d.ts +13 -7
- package/dist/types/value/slice.d.ts.map +1 -0
- package/dist/types/value/sliceZone.d.cts +18 -0
- package/dist/types/value/sliceZone.d.cts.map +1 -0
- package/dist/types/value/sliceZone.d.ts +10 -4
- package/dist/types/value/sliceZone.d.ts.map +1 -0
- package/dist/types/value/table.d.cts +97 -0
- package/dist/types/value/table.d.cts.map +1 -0
- package/dist/types/value/table.d.ts +65 -59
- package/dist/types/value/table.d.ts.map +1 -0
- package/dist/types/value/timestamp.d.cts +13 -0
- package/dist/types/value/timestamp.d.cts.map +1 -0
- package/dist/types/value/timestamp.d.ts +8 -3
- package/dist/types/value/timestamp.d.ts.map +1 -0
- package/dist/types/value/title.d.cts +16 -0
- package/dist/types/value/title.d.cts.map +1 -0
- package/dist/types/value/title.d.ts +11 -7
- package/dist/types/value/title.d.ts.map +1 -0
- package/dist/types/value/types.d.cts +61 -0
- package/dist/types/value/types.d.cts.map +1 -0
- package/dist/types/value/types.d.ts +31 -28
- package/dist/types/value/types.d.ts.map +1 -0
- package/dist/types/webhook/apiUpdate.d.cts +57 -0
- package/dist/types/webhook/apiUpdate.d.cts.map +1 -0
- package/dist/types/webhook/apiUpdate.d.ts +28 -23
- package/dist/types/webhook/apiUpdate.d.ts.map +1 -0
- package/dist/types/webhook/testTrigger.d.cts +15 -0
- package/dist/types/webhook/testTrigger.d.cts.map +1 -0
- package/dist/types/webhook/testTrigger.d.ts +9 -3
- package/dist/types/webhook/testTrigger.d.ts.map +1 -0
- package/dist/types/webhook/types.cjs +12 -5
- package/dist/types/webhook/types.cjs.map +1 -1
- package/dist/types/webhook/types.d.cts +23 -0
- package/dist/types/webhook/types.d.cts.map +1 -0
- package/dist/types/webhook/types.d.ts +16 -11
- package/dist/types/webhook/types.d.ts.map +1 -0
- package/dist/types/webhook/types.js +12 -6
- package/dist/types/webhook/types.js.map +1 -1
- package/package.json +20 -49
- package/src/Client.ts +682 -1028
- package/src/WriteClient.ts +44 -46
- package/src/buildQueryURL.ts +41 -39
- package/src/createClient.ts +11 -8
- package/src/errors.ts +94 -0
- package/src/getGraphQLEndpoint.ts +1 -1
- package/src/getRepositoryEndpoint.ts +10 -3
- package/src/getRepositoryName.ts +1 -1
- package/src/getToolbarSrc.ts +1 -1
- package/src/helpers/asDate.ts +11 -4
- package/src/helpers/asHTML.ts +38 -30
- package/src/helpers/asImagePixelDensitySrcSet.ts +16 -15
- package/src/helpers/asImageSrc.ts +11 -10
- package/src/helpers/asImageWidthSrcSet.ts +19 -22
- package/src/helpers/asLink.ts +33 -35
- package/src/helpers/asLinkAttrs.ts +6 -13
- package/src/helpers/asText.ts +20 -10
- package/src/helpers/isFilled.ts +15 -14
- package/src/helpers/mapSliceZone.ts +15 -15
- package/src/index.ts +13 -10
- package/src/isRepositoryEndpoint.ts +2 -2
- package/src/lib/isValue.ts +0 -6
- package/src/lib/pLimit.ts +1 -1
- package/src/lib/request.ts +3 -3
- package/src/lib/{throttledLog.ts → throttledWarn.ts} +3 -14
- package/src/lib/validateAssetMetadata.ts +1 -1
- package/src/richtext/asText.ts +5 -5
- package/src/richtext/serialize.ts +8 -8
- package/src/richtext/types.ts +6 -6
- package/src/types/migration/Asset.ts +10 -2
- package/src/types/migration/Document.ts +1 -1
- package/src/types/model/contentRelationship.ts +1 -0
- package/src/types/model/types.ts +0 -2
- package/src/types/value/date.ts +1 -1
- package/src/types/value/document.ts +3 -3
- package/src/types/value/timestamp.ts +1 -5
- package/dist/errors/ForbiddenError.cjs +0 -7
- package/dist/errors/ForbiddenError.cjs.map +0 -1
- package/dist/errors/ForbiddenError.d.ts +0 -11
- package/dist/errors/ForbiddenError.js +0 -7
- package/dist/errors/ForbiddenError.js.map +0 -1
- package/dist/errors/InvalidDataError.cjs +0 -7
- package/dist/errors/InvalidDataError.cjs.map +0 -1
- package/dist/errors/InvalidDataError.d.ts +0 -3
- package/dist/errors/InvalidDataError.js +0 -7
- package/dist/errors/InvalidDataError.js.map +0 -1
- package/dist/errors/NotFoundError.cjs +0 -7
- package/dist/errors/NotFoundError.cjs.map +0 -1
- package/dist/errors/NotFoundError.d.ts +0 -3
- package/dist/errors/NotFoundError.js +0 -7
- package/dist/errors/NotFoundError.js.map +0 -1
- package/dist/errors/ParsingError.cjs +0 -7
- package/dist/errors/ParsingError.cjs.map +0 -1
- package/dist/errors/ParsingError.d.ts +0 -14
- package/dist/errors/ParsingError.js +0 -7
- package/dist/errors/ParsingError.js.map +0 -1
- package/dist/errors/PreviewTokenExpired.cjs +0 -7
- package/dist/errors/PreviewTokenExpired.cjs.map +0 -1
- package/dist/errors/PreviewTokenExpired.d.ts +0 -8
- package/dist/errors/PreviewTokenExpired.js +0 -7
- package/dist/errors/PreviewTokenExpired.js.map +0 -1
- package/dist/errors/PrismicError.cjs +0 -16
- package/dist/errors/PrismicError.cjs.map +0 -1
- package/dist/errors/PrismicError.d.ts +0 -5
- package/dist/errors/PrismicError.js +0 -16
- package/dist/errors/PrismicError.js.map +0 -1
- package/dist/errors/RefExpiredError.cjs +0 -7
- package/dist/errors/RefExpiredError.cjs.map +0 -1
- package/dist/errors/RefExpiredError.d.ts +0 -8
- package/dist/errors/RefExpiredError.js +0 -7
- package/dist/errors/RefExpiredError.js.map +0 -1
- package/dist/errors/RefNotFoundError.cjs +0 -7
- package/dist/errors/RefNotFoundError.cjs.map +0 -1
- package/dist/errors/RefNotFoundError.d.ts +0 -8
- package/dist/errors/RefNotFoundError.js +0 -7
- package/dist/errors/RefNotFoundError.js.map +0 -1
- package/dist/errors/RepositoryNotFoundError.cjs +0 -7
- package/dist/errors/RepositoryNotFoundError.cjs.map +0 -1
- package/dist/errors/RepositoryNotFoundError.d.ts +0 -3
- package/dist/errors/RepositoryNotFoundError.js +0 -7
- package/dist/errors/RepositoryNotFoundError.js.map +0 -1
- package/dist/lib/appendFilters.cjs +0 -11
- package/dist/lib/appendFilters.cjs.map +0 -1
- package/dist/lib/appendFilters.d.ts +0 -18
- package/dist/lib/appendFilters.js +0 -11
- package/dist/lib/appendFilters.js.map +0 -1
- package/dist/lib/castArray.cjs +0 -7
- package/dist/lib/castArray.cjs.map +0 -1
- package/dist/lib/castArray.d.ts +0 -12
- package/dist/lib/castArray.js +0 -7
- package/dist/lib/castArray.js.map +0 -1
- package/dist/lib/castThunk.cjs +0 -7
- package/dist/lib/castThunk.cjs.map +0 -1
- package/dist/lib/castThunk.d.ts +0 -11
- package/dist/lib/castThunk.js +0 -7
- package/dist/lib/castThunk.js.map +0 -1
- package/dist/lib/devMsg.d.ts +0 -16
- package/dist/lib/escapeHTML.d.ts +0 -1
- package/dist/lib/everyTagFilter.cjs +0 -9
- package/dist/lib/everyTagFilter.cjs.map +0 -1
- package/dist/lib/everyTagFilter.d.ts +0 -9
- package/dist/lib/everyTagFilter.js +0 -9
- package/dist/lib/everyTagFilter.js.map +0 -1
- package/dist/lib/findMasterRef.cjs +0 -8
- package/dist/lib/findMasterRef.cjs.map +0 -1
- package/dist/lib/findMasterRef.d.ts +0 -11
- package/dist/lib/findMasterRef.js +0 -8
- package/dist/lib/findMasterRef.js.map +0 -1
- package/dist/lib/findRef.cjs +0 -12
- package/dist/lib/findRef.cjs.map +0 -1
- package/dist/lib/findRef.d.ts +0 -14
- package/dist/lib/findRef.js +0 -12
- package/dist/lib/findRef.js.map +0 -1
- package/dist/lib/findRefByID.cjs +0 -8
- package/dist/lib/findRefByID.cjs.map +0 -1
- package/dist/lib/findRefByID.d.ts +0 -12
- package/dist/lib/findRefByID.js +0 -8
- package/dist/lib/findRefByID.js.map +0 -1
- package/dist/lib/findRefByLabel.cjs +0 -8
- package/dist/lib/findRefByLabel.cjs.map +0 -1
- package/dist/lib/findRefByLabel.d.ts +0 -12
- package/dist/lib/findRefByLabel.js +0 -8
- package/dist/lib/findRefByLabel.js.map +0 -1
- package/dist/lib/getOptionalLinkProperties.d.ts +0 -12
- package/dist/lib/getPreviewCookie.d.ts +0 -9
- package/dist/lib/isInternalURL.d.ts +0 -8
- package/dist/lib/isMigrationValue.d.ts +0 -71
- package/dist/lib/isValue.d.ts +0 -78
- package/dist/lib/minifyGraphQLQuery.cjs +0 -7
- package/dist/lib/minifyGraphQLQuery.cjs.map +0 -1
- package/dist/lib/minifyGraphQLQuery.d.ts +0 -8
- package/dist/lib/minifyGraphQLQuery.js +0 -7
- package/dist/lib/minifyGraphQLQuery.js.map +0 -1
- package/dist/lib/pLimit.d.ts +0 -22
- package/dist/lib/resolveMigrationDocumentData.d.ts +0 -54
- package/dist/lib/serializerHelpers.d.ts +0 -9
- package/dist/lib/someTagsFilter.cjs +0 -9
- package/dist/lib/someTagsFilter.cjs.map +0 -1
- package/dist/lib/someTagsFilter.d.ts +0 -9
- package/dist/lib/someTagsFilter.js +0 -9
- package/dist/lib/someTagsFilter.js.map +0 -1
- package/dist/lib/throttledLog.cjs +0 -17
- package/dist/lib/throttledLog.cjs.map +0 -1
- package/dist/lib/throttledLog.d.ts +0 -15
- package/dist/lib/throttledLog.js +0 -17
- package/dist/lib/throttledLog.js.map +0 -1
- package/dist/lib/typeFilter.cjs +0 -8
- package/dist/lib/typeFilter.cjs.map +0 -1
- package/dist/lib/typeFilter.d.ts +0 -8
- package/dist/lib/typeFilter.js +0 -8
- package/dist/lib/typeFilter.js.map +0 -1
- package/dist/lib/validateAssetMetadata.d.ts +0 -10
- package/dist/package.json.cjs +0 -7
- package/dist/package.json.cjs.map +0 -1
- package/dist/package.json.js +0 -7
- package/dist/package.json.js.map +0 -1
- package/dist/richtext/index.d.ts +0 -7
- package/dist/richtext.cjs.map +0 -1
- package/dist/richtext.js.map +0 -1
- package/dist/types/api/migration/document.d.ts +0 -60
- package/dist/types/migration/Link.d.ts +0 -19
- package/src/errors/ForbiddenError.ts +0 -16
- package/src/errors/InvalidDataError.ts +0 -5
- package/src/errors/NotFoundError.ts +0 -5
- package/src/errors/ParsingError.ts +0 -16
- package/src/errors/PreviewTokenExpired.ts +0 -12
- package/src/errors/PrismicError.ts +0 -15
- package/src/errors/RefExpiredError.ts +0 -14
- package/src/errors/RefNotFoundError.ts +0 -14
- package/src/errors/RepositoryNotFoundError.ts +0 -5
- package/src/lib/appendFilters.ts +0 -26
- package/src/lib/castArray.ts +0 -14
- package/src/lib/castThunk.ts +0 -13
- package/src/lib/everyTagFilter.ts +0 -15
- package/src/lib/findMasterRef.ts +0 -16
- package/src/lib/findRef.ts +0 -25
- package/src/lib/findRefByID.ts +0 -17
- package/src/lib/findRefByLabel.ts +0 -17
- package/src/lib/minifyGraphQLQuery.ts +0 -13
- package/src/lib/someTagsFilter.ts +0 -15
- package/src/lib/typeFilter.ts +0 -12
package/src/WriteClient.ts
CHANGED
|
@@ -27,17 +27,19 @@ import type {
|
|
|
27
27
|
} from "./types/migration/Document"
|
|
28
28
|
import type { PrismicDocument } from "./types/value/document"
|
|
29
29
|
|
|
30
|
-
import {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
import {
|
|
31
|
+
ForbiddenError,
|
|
32
|
+
InvalidDataError,
|
|
33
|
+
NotFoundError,
|
|
34
|
+
PrismicError,
|
|
35
|
+
} from "./errors"
|
|
34
36
|
|
|
35
37
|
import { name, version } from "../package.json"
|
|
36
38
|
|
|
37
39
|
import { Client } from "./Client"
|
|
38
40
|
import type { ClientConfig, FetchParams } from "./Client"
|
|
39
41
|
import type { Migration } from "./Migration"
|
|
40
|
-
//
|
|
42
|
+
// oxlint-disable-next-line no-unused-vars
|
|
41
43
|
import type { createMigration } from "./createMigration"
|
|
42
44
|
|
|
43
45
|
const CLIENT_IDENTIFIER = `${name.replace("@", "").replace("/", "-")}/${version}`
|
|
@@ -315,7 +317,7 @@ export class WriteClient<
|
|
|
315
317
|
let url: URL | undefined
|
|
316
318
|
try {
|
|
317
319
|
url = new URL(file)
|
|
318
|
-
} catch
|
|
320
|
+
} catch {
|
|
319
321
|
// noop only on invalid URL, fetch errors will throw in the next if statement
|
|
320
322
|
}
|
|
321
323
|
|
|
@@ -340,7 +342,10 @@ export class WriteClient<
|
|
|
340
342
|
}
|
|
341
343
|
|
|
342
344
|
const asset = await this.createAsset(resolvedFile, filename, {
|
|
343
|
-
|
|
345
|
+
notes,
|
|
346
|
+
credits,
|
|
347
|
+
alt,
|
|
348
|
+
tags,
|
|
344
349
|
...fetchParams,
|
|
345
350
|
})
|
|
346
351
|
|
|
@@ -372,7 +377,7 @@ export class WriteClient<
|
|
|
372
377
|
): Promise<void> {
|
|
373
378
|
// Resolve master locale
|
|
374
379
|
const repository = await this.getRepository(fetchParams)
|
|
375
|
-
const masterLocale = repository.languages.
|
|
380
|
+
const masterLocale = repository.languages[0].id
|
|
376
381
|
reporter?.({
|
|
377
382
|
type: "documents:masterLocale",
|
|
378
383
|
data: {
|
|
@@ -622,7 +627,7 @@ export class WriteClient<
|
|
|
622
627
|
url: string,
|
|
623
628
|
params: FetchParams = {},
|
|
624
629
|
): Promise<Blob> {
|
|
625
|
-
const res = await this
|
|
630
|
+
const res = await this.#request(new URL(url), params)
|
|
626
631
|
|
|
627
632
|
if (!res.ok) {
|
|
628
633
|
throw new PrismicError("Could not fetch foreign asset", url, undefined)
|
|
@@ -844,22 +849,26 @@ export class WriteClient<
|
|
|
844
849
|
*/
|
|
845
850
|
async #request(
|
|
846
851
|
url: URL,
|
|
847
|
-
params?:
|
|
852
|
+
params?: FetchParams,
|
|
848
853
|
init?: RequestInitLike,
|
|
849
854
|
): Promise<ResponseLike> {
|
|
850
|
-
const baseInit = this._buildRequestInit(params)
|
|
851
|
-
|
|
852
855
|
return await request(
|
|
853
856
|
url,
|
|
854
857
|
{
|
|
855
|
-
...
|
|
858
|
+
...this.fetchOptions,
|
|
859
|
+
...params?.fetchOptions,
|
|
856
860
|
...init,
|
|
857
861
|
headers: {
|
|
858
|
-
...
|
|
862
|
+
...this.fetchOptions?.headers,
|
|
863
|
+
...params?.fetchOptions?.headers,
|
|
859
864
|
...init?.headers,
|
|
860
865
|
repository: this.repositoryName,
|
|
861
866
|
authorization: `Bearer ${this.writeToken}`,
|
|
862
867
|
},
|
|
868
|
+
signal:
|
|
869
|
+
params?.fetchOptions?.signal ||
|
|
870
|
+
params?.signal ||
|
|
871
|
+
this.fetchOptions?.signal,
|
|
863
872
|
},
|
|
864
873
|
this.fetchFn,
|
|
865
874
|
)
|
|
@@ -908,45 +917,34 @@ export class WriteClient<
|
|
|
908
917
|
* @throws {@link PrismicError} For 500, and other unexpected errors.
|
|
909
918
|
*/
|
|
910
919
|
async #handleMigrationAPIError(response: ResponseLike): Promise<never> {
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
json = JSON.parse(text)
|
|
916
|
-
} catch {
|
|
917
|
-
// no-op
|
|
918
|
-
}
|
|
920
|
+
const payload = (await response.json()) as unknown
|
|
921
|
+
|
|
922
|
+
// Common message across all branches
|
|
923
|
+
const message = (payload as { message?: string }).message
|
|
919
924
|
|
|
920
925
|
switch (response.status) {
|
|
921
|
-
case 400:
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
"Validation failed, check the response property of the error for details",
|
|
925
|
-
response.url,
|
|
926
|
-
json, // `json` has the shape Array<{ property: string, value: unknown, error: string }>
|
|
927
|
-
)
|
|
928
|
-
}
|
|
929
|
-
throw new InvalidDataError(text, response.url, text)
|
|
926
|
+
case 400: {
|
|
927
|
+
throw new InvalidDataError(message, response.url, payload)
|
|
928
|
+
}
|
|
930
929
|
|
|
931
|
-
case 401:
|
|
932
|
-
throw new ForbiddenError(
|
|
930
|
+
case 401: {
|
|
931
|
+
throw new ForbiddenError(message, response.url, payload)
|
|
932
|
+
}
|
|
933
933
|
|
|
934
|
-
case 403:
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
json,
|
|
940
|
-
)
|
|
941
|
-
}
|
|
942
|
-
throw new ForbiddenError(text, response.url, text)
|
|
934
|
+
case 403: {
|
|
935
|
+
// The lambda authorizer uses an uppercase key, remove this once it is fixed
|
|
936
|
+
const msg = message ?? (payload as { Message?: string }).Message
|
|
937
|
+
throw new ForbiddenError(msg, response.url, payload)
|
|
938
|
+
}
|
|
943
939
|
|
|
944
|
-
case 404:
|
|
945
|
-
throw new NotFoundError(
|
|
940
|
+
case 404: {
|
|
941
|
+
throw new NotFoundError(message, response.url, payload)
|
|
942
|
+
}
|
|
946
943
|
|
|
947
944
|
case 500:
|
|
948
|
-
default:
|
|
949
|
-
throw new PrismicError(
|
|
945
|
+
default: {
|
|
946
|
+
throw new PrismicError(message, response.url, payload)
|
|
947
|
+
}
|
|
950
948
|
}
|
|
951
949
|
}
|
|
952
950
|
}
|
package/src/buildQueryURL.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { castArray } from "./lib/castArray"
|
|
2
1
|
import { devMsg } from "./lib/devMsg"
|
|
3
2
|
|
|
4
3
|
import { version } from "../package.json"
|
|
@@ -9,9 +8,7 @@ import { version } from "../package.json"
|
|
|
9
8
|
*/
|
|
10
9
|
const PRISMIC_DEV_PARAM = "x-d"
|
|
11
10
|
|
|
12
|
-
/**
|
|
13
|
-
* The query parameter used to indicate the version of the client to the API.
|
|
14
|
-
*/
|
|
11
|
+
/** The query parameter used to indicate the version of the client to the API. */
|
|
15
12
|
const PRISMIC_CLIENT_VERSION_PARAM = "x-c"
|
|
16
13
|
|
|
17
14
|
/**
|
|
@@ -39,11 +36,11 @@ export interface Ordering {
|
|
|
39
36
|
}
|
|
40
37
|
|
|
41
38
|
/**
|
|
42
|
-
* A `routes` parameter that determines how a
|
|
39
|
+
* A `routes` parameter that determines how a page's URL field is resolved.
|
|
43
40
|
*
|
|
44
41
|
* {@link https://prismic.io/docs/route-resolver}
|
|
45
42
|
*
|
|
46
|
-
* @example With a
|
|
43
|
+
* @example With a page's UID field.
|
|
47
44
|
*
|
|
48
45
|
* ```ts
|
|
49
46
|
* {
|
|
@@ -65,38 +62,32 @@ export interface Ordering {
|
|
|
65
62
|
* ```
|
|
66
63
|
*/
|
|
67
64
|
export interface Route {
|
|
68
|
-
/**
|
|
69
|
-
* The custom type of the document.
|
|
70
|
-
*/
|
|
65
|
+
/** The custom type of the page. */
|
|
71
66
|
type: string
|
|
72
67
|
|
|
73
68
|
/**
|
|
74
69
|
* A specific UID to which this route definition is scoped. The route is only
|
|
75
|
-
* defined for the
|
|
70
|
+
* defined for the page whose UID matches the given UID.
|
|
76
71
|
*/
|
|
77
72
|
uid?: string
|
|
78
73
|
|
|
79
74
|
/**
|
|
80
75
|
* A specific language to which this route definition is scoped. The route is
|
|
81
|
-
* only defined for
|
|
76
|
+
* only defined for pages whose language matches the given language.
|
|
82
77
|
*/
|
|
83
78
|
lang?: string
|
|
84
79
|
|
|
85
|
-
/**
|
|
86
|
-
* The resolved path of the document with optional placeholders.
|
|
87
|
-
*/
|
|
80
|
+
/** The resolved path of the page with optional placeholders. */
|
|
88
81
|
path: string
|
|
89
82
|
|
|
90
|
-
/**
|
|
91
|
-
* An object that lists the API IDs of the Content Relationships in the route.
|
|
92
|
-
*/
|
|
83
|
+
/** An object that lists the API IDs of the Content Relationships in the route. */
|
|
93
84
|
resolvers?: Record<string, string>
|
|
94
85
|
}
|
|
95
86
|
|
|
96
87
|
/**
|
|
97
|
-
* Parameters for the Prismic
|
|
88
|
+
* Parameters for the Prismic Content API.
|
|
98
89
|
*
|
|
99
|
-
* {@link https://prismic.io/docs/
|
|
90
|
+
* @see Learn how to fetch content from Prismic: {@link https://prismic.io/docs/fetch-content}
|
|
100
91
|
*/
|
|
101
92
|
export interface QueryParams {
|
|
102
93
|
/**
|
|
@@ -108,8 +99,8 @@ export interface QueryParams {
|
|
|
108
99
|
accessToken?: string
|
|
109
100
|
|
|
110
101
|
/**
|
|
111
|
-
* The `pageSize` parameter defines the maximum number of
|
|
112
|
-
*
|
|
102
|
+
* The `pageSize` parameter defines the maximum number of pages that the API
|
|
103
|
+
* will return for your query.
|
|
113
104
|
*
|
|
114
105
|
* {@link https://prismic.io/docs/rest-api-technical-reference#pagesize}
|
|
115
106
|
*/
|
|
@@ -124,8 +115,8 @@ export interface QueryParams {
|
|
|
124
115
|
|
|
125
116
|
/**
|
|
126
117
|
* The `after` parameter can be used along with the orderings option. It will
|
|
127
|
-
* remove all the
|
|
128
|
-
*
|
|
118
|
+
* remove all the pages except for those after the specified page in the
|
|
119
|
+
* list.
|
|
129
120
|
*
|
|
130
121
|
* {@link https://prismic.io/docs/rest-api-technical-reference#after}
|
|
131
122
|
*/
|
|
@@ -141,7 +132,7 @@ export interface QueryParams {
|
|
|
141
132
|
|
|
142
133
|
/**
|
|
143
134
|
* The `fetchLinks` parameter allows you to retrieve a specific content field
|
|
144
|
-
* from a linked
|
|
135
|
+
* from a linked page and add it to the page response object.
|
|
145
136
|
*
|
|
146
137
|
* {@link https://prismic.io/docs/rest-api-technical-reference#fetchlinks}
|
|
147
138
|
*/
|
|
@@ -189,7 +180,7 @@ export interface QueryParams {
|
|
|
189
180
|
orderings?: string | Ordering | (string | Ordering)[]
|
|
190
181
|
|
|
191
182
|
/**
|
|
192
|
-
* The `routes` option allows you to define how a
|
|
183
|
+
* The `routes` option allows you to define how a page's `url` field is
|
|
193
184
|
* resolved.
|
|
194
185
|
*
|
|
195
186
|
* {@link https://prismic.io/docs/route-resolver}
|
|
@@ -199,7 +190,7 @@ export interface QueryParams {
|
|
|
199
190
|
/**
|
|
200
191
|
* The `brokenRoute` option allows you to define the route populated in the
|
|
201
192
|
* `url` property for broken link or content relationship fields. A broken
|
|
202
|
-
* link is a link or content relationship field whose linked
|
|
193
|
+
* link is a link or content relationship field whose linked page has been
|
|
203
194
|
* unpublished or deleted.
|
|
204
195
|
*
|
|
205
196
|
* {@link https://prismic.io/docs/route-resolver}
|
|
@@ -207,9 +198,7 @@ export interface QueryParams {
|
|
|
207
198
|
brokenRoute?: string
|
|
208
199
|
}
|
|
209
200
|
|
|
210
|
-
/**
|
|
211
|
-
* Arguments for `buildQueryURL` to construct a Query URL.
|
|
212
|
-
*/
|
|
201
|
+
/** Arguments for `buildQueryURL` to construct a Query URL. */
|
|
213
202
|
type BuildQueryURLParams = {
|
|
214
203
|
/**
|
|
215
204
|
* Ref used to query documents.
|
|
@@ -249,9 +238,7 @@ const RENAMED_PARAMS = {
|
|
|
249
238
|
accessToken: "access_token",
|
|
250
239
|
} as const
|
|
251
240
|
|
|
252
|
-
/**
|
|
253
|
-
* A valid parameter name for the Prismic REST API V2.
|
|
254
|
-
*/
|
|
241
|
+
/** A valid parameter name for the Prismic REST API V2. */
|
|
255
242
|
type ValidParamName =
|
|
256
243
|
| Exclude<
|
|
257
244
|
keyof QueryParams,
|
|
@@ -296,21 +283,29 @@ const castOrderingToString = (ordering: Ordering | string): string => {
|
|
|
296
283
|
export type BuildQueryURLArgs = QueryParams & BuildQueryURLParams
|
|
297
284
|
|
|
298
285
|
/**
|
|
299
|
-
*
|
|
300
|
-
* paginated response for this URL includes
|
|
286
|
+
* Builds a Prismic Content API URL to request pages from a repository. The
|
|
287
|
+
* paginated response for this URL includes pages matching the parameters.
|
|
301
288
|
*
|
|
302
289
|
* A ref is required to make a request. Request the `endpoint` URL to retrieve a
|
|
303
290
|
* list of available refs.
|
|
304
291
|
*
|
|
305
292
|
* Type the JSON response with `Query`.
|
|
306
293
|
*
|
|
307
|
-
*
|
|
308
|
-
*
|
|
294
|
+
* @example
|
|
295
|
+
*
|
|
296
|
+
* ```ts
|
|
297
|
+
* const url = buildQueryURL("https://my-repo.cdn.prismic.io/api/v2", {
|
|
298
|
+
* ref: "my-ref",
|
|
299
|
+
* filters: [filter.at("document.type", "blog_post")],
|
|
300
|
+
* })
|
|
301
|
+
* ```
|
|
309
302
|
*
|
|
310
|
-
* @param endpoint - URL to the repository's
|
|
303
|
+
* @param endpoint - URL to the repository's Content API.
|
|
311
304
|
* @param args - Arguments to filter and scope the query.
|
|
312
305
|
*
|
|
313
|
-
* @returns URL that can be used to request
|
|
306
|
+
* @returns URL that can be used to request pages from the repository.
|
|
307
|
+
*
|
|
308
|
+
* @see Prismic Content API technical reference: {@link https://prismic.io/docs/content-api}
|
|
314
309
|
*/
|
|
315
310
|
export const buildQueryURL = (
|
|
316
311
|
endpoint: string,
|
|
@@ -318,7 +313,10 @@ export const buildQueryURL = (
|
|
|
318
313
|
): string => {
|
|
319
314
|
const { filters, predicates, ...params } = args
|
|
320
315
|
|
|
321
|
-
|
|
316
|
+
if (!endpoint.endsWith("/")) {
|
|
317
|
+
endpoint += "/"
|
|
318
|
+
}
|
|
319
|
+
const url = new URL(`documents/search`, endpoint)
|
|
322
320
|
|
|
323
321
|
if (filters) {
|
|
324
322
|
// TODO: Remove warning when we remove support for string `filters` values.
|
|
@@ -395,3 +393,7 @@ export const buildQueryURL = (
|
|
|
395
393
|
|
|
396
394
|
return url.toString()
|
|
397
395
|
}
|
|
396
|
+
|
|
397
|
+
function castArray<A>(a: A | A[]): A[] {
|
|
398
|
+
return Array.isArray(a) ? a : [a]
|
|
399
|
+
}
|
package/src/createClient.ts
CHANGED
|
@@ -14,26 +14,29 @@ export interface CreateClient {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
* Creates a Prismic client that can be used to query a repository.
|
|
17
|
+
* Creates a Prismic client that can be used to query content from a repository.
|
|
18
18
|
*
|
|
19
19
|
* @example
|
|
20
20
|
*
|
|
21
21
|
* ```ts
|
|
22
|
-
* // With a repository name
|
|
23
|
-
* createClient("
|
|
22
|
+
* // With a repository name
|
|
23
|
+
* createClient("my-repo")
|
|
24
24
|
*
|
|
25
|
-
* //
|
|
26
|
-
* createClient("https://
|
|
25
|
+
* // With a full Prismic Content API endpoint
|
|
26
|
+
* createClient("https://my-repo.cdn.prismic.io/api/v2")
|
|
27
27
|
* ```
|
|
28
28
|
*
|
|
29
|
-
* @typeParam TDocuments - A union of Prismic
|
|
29
|
+
* @typeParam TDocuments - A union of Prismic page and custom types for the
|
|
30
|
+
* repository.
|
|
30
31
|
*
|
|
31
|
-
* @param repositoryNameOrEndpoint - The Prismic repository name or full
|
|
32
|
-
* API
|
|
32
|
+
* @param repositoryNameOrEndpoint - The Prismic repository name or full Content
|
|
33
|
+
* API endpoint for the repository.
|
|
33
34
|
* @param options - Configuration that determines how content will be queried
|
|
34
35
|
* from the Prismic repository.
|
|
35
36
|
*
|
|
36
37
|
* @returns A client that can query content from the repository.
|
|
38
|
+
*
|
|
39
|
+
* @see https://prismic.io/docs/technical-reference/prismicio-client/v7
|
|
37
40
|
*/
|
|
38
41
|
export const createClient: CreateClient = <TDocuments extends PrismicDocument>(
|
|
39
42
|
repositoryNameOrEndpoint: string,
|
package/src/errors.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
export class PrismicError<Response> extends Error {
|
|
2
|
+
url?: string
|
|
3
|
+
response: Response
|
|
4
|
+
|
|
5
|
+
constructor(
|
|
6
|
+
message = "An invalid API response was returned",
|
|
7
|
+
url: string | undefined,
|
|
8
|
+
response: Response,
|
|
9
|
+
) {
|
|
10
|
+
super(message)
|
|
11
|
+
|
|
12
|
+
this.url = url
|
|
13
|
+
this.response = response
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type ForbiddenErrorRepositoryAPIResponse = {
|
|
18
|
+
type: string
|
|
19
|
+
message: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type ForbiddenErrorQueryAPIResponse = {
|
|
23
|
+
error: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export class ForbiddenError<
|
|
27
|
+
TResponse =
|
|
28
|
+
| ForbiddenErrorRepositoryAPIResponse
|
|
29
|
+
| ForbiddenErrorQueryAPIResponse,
|
|
30
|
+
> extends PrismicError<TResponse> {}
|
|
31
|
+
|
|
32
|
+
export class NotFoundError<
|
|
33
|
+
TResponse = undefined,
|
|
34
|
+
> extends PrismicError<TResponse> {}
|
|
35
|
+
|
|
36
|
+
export class RepositoryNotFoundError<
|
|
37
|
+
TResponse = undefined,
|
|
38
|
+
> extends NotFoundError<TResponse> {}
|
|
39
|
+
|
|
40
|
+
type ParsingErrorAPIResponse = {
|
|
41
|
+
type: "parsing-error"
|
|
42
|
+
message: string
|
|
43
|
+
pos: {
|
|
44
|
+
line: number
|
|
45
|
+
column: number
|
|
46
|
+
id: number
|
|
47
|
+
location: string
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export class ParsingError<
|
|
52
|
+
TResponse = ParsingErrorAPIResponse,
|
|
53
|
+
> extends PrismicError<TResponse> {}
|
|
54
|
+
|
|
55
|
+
export class InvalidDataError<
|
|
56
|
+
TResponse = undefined,
|
|
57
|
+
> extends PrismicError<TResponse> {}
|
|
58
|
+
|
|
59
|
+
type RefExpiredErrorAPIResponse = {
|
|
60
|
+
type: "api_validation_error"
|
|
61
|
+
message: string
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// This error extends `ForbiddenError` for backwards compatibility. Before the
|
|
65
|
+
// API started returning 410 for expired refs, it returned 403, which threw a
|
|
66
|
+
// `ForbiddenError`.
|
|
67
|
+
// TODO: Extend this error from `PrismicError` in v8.
|
|
68
|
+
export class RefExpiredError<
|
|
69
|
+
TResponse = RefExpiredErrorAPIResponse,
|
|
70
|
+
> extends ForbiddenError<TResponse> {}
|
|
71
|
+
|
|
72
|
+
type RefNotFoundErrorAPIResponse = {
|
|
73
|
+
type: "api_notfound_error"
|
|
74
|
+
message: string
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// This error extends `ForbiddenError` for backwards compatibility. Before the
|
|
78
|
+
// API started returning 404 for not found refs, it returned 403, which threw a
|
|
79
|
+
// `ForbiddenError`.
|
|
80
|
+
// TODO: Extend this error from `PrismicError` in v8.
|
|
81
|
+
export class RefNotFoundError<
|
|
82
|
+
TResponse = RefNotFoundErrorAPIResponse,
|
|
83
|
+
> extends ForbiddenError<TResponse> {}
|
|
84
|
+
|
|
85
|
+
type PreviewTokenExpiredErrorAPIResponse = {
|
|
86
|
+
type: "api_security_error"
|
|
87
|
+
message: string
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// This error extends `ForbiddenError` for backwards compatibility.
|
|
91
|
+
// TODO: Extend this error from `PrismicError` in v8.
|
|
92
|
+
export class PreviewTokenExpiredError<
|
|
93
|
+
TResponse = PreviewTokenExpiredErrorAPIResponse,
|
|
94
|
+
> extends ForbiddenError<TResponse> {}
|
|
@@ -1,15 +1,22 @@
|
|
|
1
|
-
import { PrismicError } from "./errors
|
|
1
|
+
import { PrismicError } from "./errors"
|
|
2
2
|
|
|
3
3
|
import { isRepositoryName } from "./isRepositoryName"
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Get a repository's Prismic
|
|
6
|
+
* Get a repository's Prismic Content API endpoint.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* getRepositoryEndpoint("my-repo")
|
|
12
|
+
* // => "https://my-repo.cdn.prismic.io/api/v2"
|
|
13
|
+
* ```
|
|
7
14
|
*
|
|
8
15
|
* @typeParam RepositoryName - Name of the Prismic repository.
|
|
9
16
|
*
|
|
10
17
|
* @param repositoryName - Name of the repository.
|
|
11
18
|
*
|
|
12
|
-
* @returns The repository's Prismic
|
|
19
|
+
* @returns The repository's Prismic Content API endpoint.
|
|
13
20
|
*
|
|
14
21
|
* @throws {@link Error} Thrown if an invalid repository name is provided.
|
|
15
22
|
*/
|
package/src/getRepositoryName.ts
CHANGED
package/src/getToolbarSrc.ts
CHANGED
package/src/helpers/asDate.ts
CHANGED
|
@@ -9,13 +9,20 @@ type AsDateReturnType<
|
|
|
9
9
|
> = Field extends DateField<"filled"> | TimestampField<"filled"> ? Date : null
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Converts a date or timestamp field to a JavaScript Date object.
|
|
13
13
|
*
|
|
14
|
-
* @
|
|
14
|
+
* @example
|
|
15
15
|
*
|
|
16
|
-
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* const date = asDate(document.data.release_date)
|
|
18
|
+
* // => Date object or null
|
|
19
|
+
* ```
|
|
17
20
|
*
|
|
18
|
-
* @
|
|
21
|
+
* @param dateOrTimestampField - A date or timestamp field from Prismic.
|
|
22
|
+
*
|
|
23
|
+
* @returns A Date object, or `null` if the field is empty.
|
|
24
|
+
*
|
|
25
|
+
* @see Learn about date and timestamp fields: {@link https://prismic.io/docs/fields/date}
|
|
19
26
|
*/
|
|
20
27
|
export const asDate = <
|
|
21
28
|
Field extends DateField | TimestampField | null | undefined,
|