@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/helpers/asHTML.ts
CHANGED
|
@@ -19,13 +19,13 @@ import { composeSerializers, serialize, wrapMapSerializer } from "../richtext"
|
|
|
19
19
|
import type { LinkResolverFunction } from "./asLink"
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
* Serializes a node from a rich text
|
|
22
|
+
* Serializes a node from a rich text field with a function to HTML.
|
|
23
23
|
*
|
|
24
24
|
* Unlike a typical `@prismicio/client/richtext` function serializer, this
|
|
25
25
|
* serializer converts the `children` argument to a single string rather than an
|
|
26
26
|
* array of strings.
|
|
27
27
|
*
|
|
28
|
-
* @see
|
|
28
|
+
* @see Learn how to style rich text and customize rendering: {@link https://prismic.io/docs/fields/rich-text}
|
|
29
29
|
*/
|
|
30
30
|
export type HTMLRichTextFunctionSerializer = (
|
|
31
31
|
type: Parameters<RichTextFunctionSerializer<string>>[0],
|
|
@@ -36,13 +36,13 @@ export type HTMLRichTextFunctionSerializer = (
|
|
|
36
36
|
) => string | null | undefined
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
|
-
* Serializes a node from a rich text
|
|
39
|
+
* Serializes a node from a rich text field with a map to HTML.
|
|
40
40
|
*
|
|
41
41
|
* Unlike a typical `@prismicio/client/richtext` map serializer, this serializer
|
|
42
42
|
* converts the `children` property to a single string rather than an array of
|
|
43
43
|
* strings and accepts shorthand declarations.
|
|
44
44
|
*
|
|
45
|
-
* @see
|
|
45
|
+
* @see Learn how to style rich text and customize rendering: {@link https://prismic.io/docs/fields/rich-text}
|
|
46
46
|
*/
|
|
47
47
|
export type HTMLRichTextMapSerializer = {
|
|
48
48
|
[P in keyof RichTextMapSerializer<string>]: P extends RichTextMapSerializer<string>["span"]
|
|
@@ -51,13 +51,13 @@ export type HTMLRichTextMapSerializer = {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
|
-
* Serializes a node from a rich text
|
|
54
|
+
* Serializes a node from a rich text field with a map to HTML.
|
|
55
55
|
*
|
|
56
56
|
* Unlike a typical `@prismicio/client/richtext` map serializer, this serializer
|
|
57
57
|
* converts the `children` property to a single string rather than an array of
|
|
58
58
|
* strings but doesn't accept shorthand declarations.
|
|
59
59
|
*
|
|
60
|
-
* @see
|
|
60
|
+
* @see Learn how to style rich text and customize rendering: {@link https://prismic.io/docs/fields/rich-text}
|
|
61
61
|
*/
|
|
62
62
|
export type HTMLStrictRichTextMapSerializer = {
|
|
63
63
|
[P in keyof RichTextMapSerializer<string>]: (payload: {
|
|
@@ -93,10 +93,10 @@ type HTMLRichTextMapSerializerFunction<
|
|
|
93
93
|
*/
|
|
94
94
|
type ExtractNodeGeneric<T> =
|
|
95
95
|
T extends RichTextMapSerializerFunction<
|
|
96
|
-
//
|
|
96
|
+
// oxlint-disable-next-line no-explicit-any
|
|
97
97
|
any,
|
|
98
98
|
infer U,
|
|
99
|
-
//
|
|
99
|
+
// oxlint-disable-next-line no-explicit-any
|
|
100
100
|
any
|
|
101
101
|
>
|
|
102
102
|
? U
|
|
@@ -110,9 +110,9 @@ type ExtractNodeGeneric<T> =
|
|
|
110
110
|
*/
|
|
111
111
|
type ExtractTextTypeGeneric<T> =
|
|
112
112
|
T extends RichTextMapSerializerFunction<
|
|
113
|
-
//
|
|
113
|
+
// oxlint-disable-next-line no-explicit-any
|
|
114
114
|
any,
|
|
115
|
-
//
|
|
115
|
+
// oxlint-disable-next-line no-explicit-any
|
|
116
116
|
any,
|
|
117
117
|
infer U
|
|
118
118
|
>
|
|
@@ -135,11 +135,10 @@ export type HTMLRichTextMapSerializerShorthand = {
|
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
/**
|
|
138
|
-
* Serializes a node from a rich text
|
|
139
|
-
* HTML
|
|
138
|
+
* Serializes a node from a rich text field with a map or a function to HTML.
|
|
140
139
|
*
|
|
141
140
|
* @see {@link HTMLRichTextMapSerializer} and {@link HTMLRichTextFunctionSerializer}
|
|
142
|
-
* @see
|
|
141
|
+
* @see Learn how to style rich text and customize rendering: {@link https://prismic.io/docs/fields/rich-text}
|
|
143
142
|
*/
|
|
144
143
|
export type HTMLRichTextSerializer =
|
|
145
144
|
| HTMLRichTextMapSerializer
|
|
@@ -291,14 +290,14 @@ const wrapMapSerializerWithStringChildren = (
|
|
|
291
290
|
*/
|
|
292
291
|
type AsHTMLConfig = {
|
|
293
292
|
/**
|
|
294
|
-
* An optional link resolver function to resolve links. Without it you're
|
|
295
|
-
* expected to use the `routes`
|
|
293
|
+
* An optional link resolver function to resolve links. Without it, you're
|
|
294
|
+
* expected to use the `routes` option from the API.
|
|
296
295
|
*/
|
|
297
296
|
linkResolver?: LinkResolverFunction | null
|
|
298
297
|
|
|
299
298
|
/**
|
|
300
|
-
* An optional rich text serializer
|
|
301
|
-
* default serializer
|
|
299
|
+
* An optional rich text serializer. Unhandled cases will fall back to the
|
|
300
|
+
* default serializer.
|
|
302
301
|
*/
|
|
303
302
|
serializer?: HTMLRichTextSerializer | null
|
|
304
303
|
}
|
|
@@ -321,14 +320,22 @@ type AsHTMLReturnType<Field extends RichTextField | null | undefined> =
|
|
|
321
320
|
// TODO: Remove overload when we remove support for deprecated tuple-style configuration.
|
|
322
321
|
export const asHTML: {
|
|
323
322
|
/**
|
|
324
|
-
*
|
|
323
|
+
* Converts a rich text field to an HTML string.
|
|
325
324
|
*
|
|
326
|
-
* @
|
|
327
|
-
* @param config - Configuration that determines the output of `asHTML()`
|
|
325
|
+
* @example
|
|
328
326
|
*
|
|
329
|
-
*
|
|
327
|
+
* ```ts
|
|
328
|
+
* const html = asHTML(document.data.content)
|
|
329
|
+
* // => "<p>Hello world</p>"
|
|
330
|
+
* ```
|
|
330
331
|
*
|
|
331
|
-
* @
|
|
332
|
+
* @param richTextField - A rich text field from Prismic.
|
|
333
|
+
* @param config - Configuration that determines the output of `asHTML()`.
|
|
334
|
+
*
|
|
335
|
+
* @returns HTML equivalent of the rich text field, or `null` if the field is
|
|
336
|
+
* empty.
|
|
337
|
+
*
|
|
338
|
+
* @see Learn how to style rich text and customize rendering: {@link https://prismic.io/docs/fields/rich-text}
|
|
332
339
|
*/
|
|
333
340
|
<Field extends RichTextField | null | undefined>(
|
|
334
341
|
richTextField: Field,
|
|
@@ -336,19 +343,20 @@ export const asHTML: {
|
|
|
336
343
|
): AsHTMLReturnType<Field>
|
|
337
344
|
|
|
338
345
|
/**
|
|
339
|
-
*
|
|
346
|
+
* Converts a rich text field to an HTML string.
|
|
340
347
|
*
|
|
341
348
|
* @deprecated Use object-style configuration instead.
|
|
342
349
|
*
|
|
343
|
-
* @param richTextField - A rich text
|
|
344
|
-
* @param linkResolver - An optional link resolver function to resolve links
|
|
345
|
-
*
|
|
346
|
-
* @param serializer - An optional rich text serializer
|
|
347
|
-
*
|
|
350
|
+
* @param richTextField - A rich text field from Prismic.
|
|
351
|
+
* @param linkResolver - An optional link resolver function to resolve links.
|
|
352
|
+
* Without it, you're expected to use the `routes` option from the API.
|
|
353
|
+
* @param serializer - An optional rich text serializer. Unhandled cases will
|
|
354
|
+
* fall back to the default serializer.
|
|
348
355
|
*
|
|
349
|
-
* @returns HTML equivalent of the
|
|
356
|
+
* @returns HTML equivalent of the rich text field, or `null` if the field is
|
|
357
|
+
* empty.
|
|
350
358
|
*
|
|
351
|
-
* @see
|
|
359
|
+
* @see Learn how to style rich text and customize rendering: {@link https://prismic.io/docs/fields/rich-text}
|
|
352
360
|
*/
|
|
353
361
|
<Field extends RichTextField | null | undefined>(
|
|
354
362
|
richTextField: Field,
|
|
@@ -28,13 +28,13 @@ type AsImagePixelDensitySrcSetReturnType<
|
|
|
28
28
|
Field extends ImageFieldImage<"filled">
|
|
29
29
|
? {
|
|
30
30
|
/**
|
|
31
|
-
* The image field's
|
|
31
|
+
* The image field's URL with imgix URL parameters (if given).
|
|
32
32
|
*/
|
|
33
33
|
src: string
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
* A pixel-
|
|
37
|
-
*
|
|
36
|
+
* A pixel-density-based `srcset` attribute value for the image field
|
|
37
|
+
* with imgix URL parameters (if given).
|
|
38
38
|
*/
|
|
39
39
|
srcset: string
|
|
40
40
|
}
|
|
@@ -42,7 +42,7 @@ type AsImagePixelDensitySrcSetReturnType<
|
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* Creates a pixel-density-based `srcset` from an image field with optional
|
|
45
|
-
* image transformations
|
|
45
|
+
* image transformations via imgix URL parameters.
|
|
46
46
|
*
|
|
47
47
|
* If a `pixelDensities` parameter is not given, the following pixel densities
|
|
48
48
|
* will be used by default: 1, 2, 3.
|
|
@@ -50,26 +50,27 @@ type AsImagePixelDensitySrcSetReturnType<
|
|
|
50
50
|
* @example
|
|
51
51
|
*
|
|
52
52
|
* ```ts
|
|
53
|
-
* const srcset = asImagePixelDensitySrcSet(document.data.
|
|
53
|
+
* const srcset = asImagePixelDensitySrcSet(document.data.photo, {
|
|
54
54
|
* pixelDensities: [1, 2],
|
|
55
55
|
* sat: -100,
|
|
56
56
|
* })
|
|
57
57
|
* // => {
|
|
58
|
-
* // src:
|
|
59
|
-
* // srcset:
|
|
60
|
-
* //
|
|
58
|
+
* // src: "https://images.prismic.io/repo/image.png?sat=-100",
|
|
59
|
+
* // srcset: "https://images.prismic.io/repo/image.png?sat=-100&dpr=1 1x, " +
|
|
60
|
+
* // "https://images.prismic.io/repo/image.png?sat=-100&dpr=2 2x"
|
|
61
61
|
* // }
|
|
62
62
|
* ```
|
|
63
63
|
*
|
|
64
|
-
* @param field -
|
|
65
|
-
* an image URL.
|
|
66
|
-
* @param config - An object of
|
|
67
|
-
* parameter defines the resulting `srcset`
|
|
64
|
+
* @param field - An image field (or one of its responsive views) from which to
|
|
65
|
+
* get an image URL.
|
|
66
|
+
* @param config - An object of imgix URL API parameters. The `pixelDensities`
|
|
67
|
+
* parameter defines the resulting `srcset` pixel densities.
|
|
68
68
|
*
|
|
69
|
-
* @returns A `srcset` attribute value for the image field with
|
|
70
|
-
* parameters
|
|
69
|
+
* @returns A `srcset` attribute value for the image field with imgix URL
|
|
70
|
+
* parameters, or `null` if the field is empty.
|
|
71
71
|
*
|
|
72
|
-
* @see
|
|
72
|
+
* @see Learn how to optimize images with imgix: {@link https://prismic.io/docs/fields/image}
|
|
73
|
+
* @see imgix URL parameters reference: {@link https://docs.imgix.com/apis/rendering}
|
|
73
74
|
*/
|
|
74
75
|
export const asImagePixelDensitySrcSet = <
|
|
75
76
|
Field extends ImageFieldImage | null | undefined,
|
|
@@ -12,24 +12,25 @@ type AsImageSrcReturnType<Field extends ImageFieldImage | null | undefined> =
|
|
|
12
12
|
Field extends ImageFieldImage<"filled"> ? string : null
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* Returns the URL of an image field with optional image transformations
|
|
16
|
-
*
|
|
15
|
+
* Returns the URL of an image field with optional image transformations via
|
|
16
|
+
* imgix URL parameters.
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
19
19
|
*
|
|
20
20
|
* ```ts
|
|
21
|
-
* const src = asImageSrc(document.data.
|
|
22
|
-
* // => https://images.prismic.io/repo/image.png?sat=-100
|
|
21
|
+
* const src = asImageSrc(document.data.photo, { sat: -100 })
|
|
22
|
+
* // => "https://images.prismic.io/repo/image.png?sat=-100"
|
|
23
23
|
* ```
|
|
24
24
|
*
|
|
25
|
-
* @param field -
|
|
26
|
-
* an image URL.
|
|
27
|
-
* @param config - An object of
|
|
25
|
+
* @param field - An image field (or one of its responsive views) from which to
|
|
26
|
+
* get an image URL.
|
|
27
|
+
* @param config - An object of imgix URL API parameters to transform the image.
|
|
28
28
|
*
|
|
29
|
-
* @returns The image field's
|
|
30
|
-
*
|
|
29
|
+
* @returns The image field's URL with transformations applied, or `null` if the
|
|
30
|
+
* field is empty.
|
|
31
31
|
*
|
|
32
|
-
* @see
|
|
32
|
+
* @see Learn how to optimize images with imgix: {@link https://prismic.io/docs/fields/image}
|
|
33
|
+
* @see imgix URL parameters reference: {@link https://docs.imgix.com/apis/rendering}
|
|
33
34
|
*/
|
|
34
35
|
export const asImageSrc = <Field extends ImageFieldImage | null | undefined>(
|
|
35
36
|
field: Field,
|
|
@@ -19,13 +19,13 @@ type AsImageWidthSrcSetReturnType<
|
|
|
19
19
|
Field extends ImageFieldImage<"filled">
|
|
20
20
|
? {
|
|
21
21
|
/**
|
|
22
|
-
* The image field's
|
|
22
|
+
* The image field's URL with imgix URL parameters (if given).
|
|
23
23
|
*/
|
|
24
24
|
src: string
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
* A width-based `srcset` attribute value for the image field
|
|
28
|
-
*
|
|
27
|
+
* A width-based `srcset` attribute value for the image field with imgix
|
|
28
|
+
* URL parameters (if given).
|
|
29
29
|
*/
|
|
30
30
|
srcset: string
|
|
31
31
|
}
|
|
@@ -40,10 +40,10 @@ type AsImageWidthSrcSetConfig = Omit<BuildWidthSrcSetParams, "widths"> & {
|
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* Creates a width-based `srcset` from an image field with optional image
|
|
43
|
-
* transformations
|
|
43
|
+
* transformations via imgix URL parameters.
|
|
44
44
|
*
|
|
45
|
-
* If a `widths` parameter is not given, the following widths
|
|
46
|
-
* default: 640, 750, 828, 1080, 1200, 1920, 2048, 3840.
|
|
45
|
+
* If a `widths` parameter is not given, the following widths (in pixels) will
|
|
46
|
+
* be used by default: 640, 750, 828, 1080, 1200, 1920, 2048, 3840.
|
|
47
47
|
*
|
|
48
48
|
* If the image field contains responsive views, each responsive view can be
|
|
49
49
|
* used as a width in the resulting `srcset` by passing `"thumbnails"` as the
|
|
@@ -52,28 +52,29 @@ type AsImageWidthSrcSetConfig = Omit<BuildWidthSrcSetParams, "widths"> & {
|
|
|
52
52
|
* @example
|
|
53
53
|
*
|
|
54
54
|
* ```ts
|
|
55
|
-
* const srcset = asImageWidthSrcSet(document.data.
|
|
55
|
+
* const srcset = asImageWidthSrcSet(document.data.photo, {
|
|
56
56
|
* widths: [400, 800, 1600],
|
|
57
57
|
* sat: -100,
|
|
58
58
|
* })
|
|
59
59
|
* // => {
|
|
60
|
-
* // src:
|
|
61
|
-
* // srcset:
|
|
62
|
-
* //
|
|
63
|
-
* //
|
|
60
|
+
* // src: "https://images.prismic.io/repo/image.png?sat=-100",
|
|
61
|
+
* // srcset: "https://images.prismic.io/repo/image.png?sat=-100&width=400 400w, " +
|
|
62
|
+
* // "https://images.prismic.io/repo/image.png?sat=-100&width=800 800w, " +
|
|
63
|
+
* // "https://images.prismic.io/repo/image.png?sat=-100&width=1600 1600w"
|
|
64
64
|
* // }
|
|
65
65
|
* ```
|
|
66
66
|
*
|
|
67
|
-
* @param field -
|
|
68
|
-
* an image URL.
|
|
69
|
-
* @param config - An object of
|
|
67
|
+
* @param field - An image field (or one of its responsive views) from which to
|
|
68
|
+
* get an image URL.
|
|
69
|
+
* @param config - An object of imgix URL API parameters. The `widths` parameter
|
|
70
70
|
* defines the resulting `srcset` widths. Pass `"thumbnails"` to automatically
|
|
71
71
|
* use the field's responsive views.
|
|
72
72
|
*
|
|
73
|
-
* @returns A `srcset` attribute value for the image field with
|
|
74
|
-
* parameters
|
|
73
|
+
* @returns A `srcset` attribute value for the image field with imgix URL
|
|
74
|
+
* parameters, or `null` if the field is empty.
|
|
75
75
|
*
|
|
76
|
-
* @see
|
|
76
|
+
* @see Learn how to optimize images with imgix: {@link https://prismic.io/docs/fields/image}
|
|
77
|
+
* @see imgix URL parameters reference: {@link https://docs.imgix.com/apis/rendering}
|
|
77
78
|
*/
|
|
78
79
|
export const asImageWidthSrcSet = <
|
|
79
80
|
Field extends ImageFieldImage | null | undefined,
|
|
@@ -84,11 +85,7 @@ export const asImageWidthSrcSet = <
|
|
|
84
85
|
if (field && isFilled.imageThumbnail(field)) {
|
|
85
86
|
// We are using destructuring to omit `widths` from the object
|
|
86
87
|
// we will pass to `buildURL()`.
|
|
87
|
-
let {
|
|
88
|
-
widths = DEFAULT_WIDTHS,
|
|
89
|
-
// eslint-disable-next-line prefer-const
|
|
90
|
-
...imgixParams
|
|
91
|
-
} = config
|
|
88
|
+
let { widths = DEFAULT_WIDTHS, ...imgixParams } = config
|
|
92
89
|
const {
|
|
93
90
|
url,
|
|
94
91
|
dimensions,
|
package/src/helpers/asLink.ts
CHANGED
|
@@ -7,16 +7,16 @@ import type { FilledLinkToMediaField } from "../types/value/linkToMedia"
|
|
|
7
7
|
import { documentToLinkField } from "./documentToLinkField"
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* Resolves a link to a Prismic
|
|
10
|
+
* Resolves a link to a Prismic page to a URL.
|
|
11
11
|
*
|
|
12
|
-
* @typeParam ReturnType - Return type of your link resolver function
|
|
13
|
-
* you prefer to return a complex object
|
|
12
|
+
* @typeParam ReturnType - Return type of your link resolver function. Useful if
|
|
13
|
+
* you prefer to return a complex object.
|
|
14
14
|
*
|
|
15
|
-
* @param linkToDocumentField - A
|
|
15
|
+
* @param linkToDocumentField - A page link field to resolve.
|
|
16
16
|
*
|
|
17
|
-
* @returns Resolved URL
|
|
17
|
+
* @returns Resolved URL.
|
|
18
18
|
*
|
|
19
|
-
* @see
|
|
19
|
+
* @see Learn about route resolvers and link resolvers: {@link https://prismic.io/docs/routes}
|
|
20
20
|
*/
|
|
21
21
|
export type LinkResolverFunction<ReturnType = string | null | undefined> = (
|
|
22
22
|
linkToDocumentField: FilledContentRelationshipField,
|
|
@@ -28,8 +28,8 @@ export type LinkResolverFunction<ReturnType = string | null | undefined> = (
|
|
|
28
28
|
type AsLinkConfig<LinkResolverFunctionReturnType = string | null | undefined> =
|
|
29
29
|
{
|
|
30
30
|
/**
|
|
31
|
-
* An optional link resolver function. Without it, you
|
|
32
|
-
* the `routes`
|
|
31
|
+
* An optional link resolver function. Without it, you're expected to use
|
|
32
|
+
* the `routes` option from the API.
|
|
33
33
|
*/
|
|
34
34
|
linkResolver?: LinkResolverFunction<LinkResolverFunctionReturnType> | null
|
|
35
35
|
}
|
|
@@ -63,21 +63,25 @@ export type AsLinkReturnType<
|
|
|
63
63
|
// TODO: Remove overload when we remove support for deprecated tuple-style configuration.
|
|
64
64
|
export const asLink: {
|
|
65
65
|
/**
|
|
66
|
-
*
|
|
66
|
+
* Converts any type of link field or Prismic page to a URL.
|
|
67
67
|
*
|
|
68
|
-
* @
|
|
69
|
-
* type
|
|
70
|
-
* @typeParam Field - Link field or Prismic document to resolve to a URL
|
|
68
|
+
* @example
|
|
71
69
|
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
70
|
+
* ```ts
|
|
71
|
+
* const url = asLink(document.data.link)
|
|
72
|
+
* // => "/blog/my-post"
|
|
73
|
+
* ```
|
|
75
74
|
*
|
|
76
|
-
* @
|
|
77
|
-
*
|
|
75
|
+
* @typeParam LinkResolverFunctionReturnType - Link resolver function return
|
|
76
|
+
* type.
|
|
77
|
+
* @typeParam Field - Link field or Prismic page to resolve to a URL.
|
|
78
78
|
*
|
|
79
|
-
* @
|
|
80
|
-
* @
|
|
79
|
+
* @param linkFieldOrDocument - Any kind of link field or a page to resolve.
|
|
80
|
+
* @param config - Configuration that determines the output of `asLink()`.
|
|
81
|
+
*
|
|
82
|
+
* @returns Resolved URL, or `null` if the link field or page is empty.
|
|
83
|
+
*
|
|
84
|
+
* @see Learn about route resolvers and link resolvers: {@link https://prismic.io/docs/routes}
|
|
81
85
|
*/
|
|
82
86
|
<
|
|
83
87
|
LinkResolverFunctionReturnType = string | null | undefined,
|
|
@@ -92,24 +96,21 @@ export const asLink: {
|
|
|
92
96
|
): AsLinkReturnType<LinkResolverFunctionReturnType, Field>
|
|
93
97
|
|
|
94
98
|
/**
|
|
95
|
-
*
|
|
99
|
+
* Converts any type of link field or Prismic page to a URL.
|
|
96
100
|
*
|
|
97
101
|
* @deprecated Use object-style configuration instead.
|
|
98
102
|
*
|
|
99
|
-
* @typeParam LinkResolverFunctionReturnType -
|
|
100
|
-
* type
|
|
101
|
-
* @typeParam Field - Link field or Prismic
|
|
103
|
+
* @typeParam LinkResolverFunctionReturnType - Link resolver function return
|
|
104
|
+
* type.
|
|
105
|
+
* @typeParam Field - Link field or Prismic page to resolve to a URL.
|
|
102
106
|
*
|
|
103
|
-
* @param linkFieldOrDocument - Any kind of link field or a
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
* are expected to use the `routes` options from the API
|
|
107
|
+
* @param linkFieldOrDocument - Any kind of link field or a page to resolve.
|
|
108
|
+
* @param linkResolver - An optional link resolver function. Without it,
|
|
109
|
+
* you're expected to use the `routes` option from the API.
|
|
107
110
|
*
|
|
108
|
-
* @returns Resolved URL or
|
|
109
|
-
* `null`
|
|
111
|
+
* @returns Resolved URL, or `null` if the link field or page is empty.
|
|
110
112
|
*
|
|
111
|
-
* @see
|
|
112
|
-
* @see Prismic API `routes` options documentation: {@link https://prismic.io/docs/route-resolver}
|
|
113
|
+
* @see Learn about route resolvers and link resolvers: {@link https://prismic.io/docs/routes}
|
|
113
114
|
*/
|
|
114
115
|
<
|
|
115
116
|
LinkResolverFunctionReturnType = string | null | undefined,
|
|
@@ -144,9 +145,6 @@ export const asLink: {
|
|
|
144
145
|
const linkField =
|
|
145
146
|
// prettier-ignore
|
|
146
147
|
(
|
|
147
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
148
|
-
// @ts-ignore - Bug in TypeScript 4.9: https://github.com/microsoft/TypeScript/issues/51501
|
|
149
|
-
// TODO: Remove the `prettier-ignore` comment when this bug is fixed.
|
|
150
148
|
"link_type" in linkFieldOrDocument
|
|
151
149
|
? linkFieldOrDocument
|
|
152
150
|
: documentToLinkField(linkFieldOrDocument)
|
|
@@ -195,7 +193,7 @@ export const asLink: {
|
|
|
195
193
|
>
|
|
196
194
|
}
|
|
197
195
|
|
|
198
|
-
// When empty or
|
|
196
|
+
// When empty or route resolver and link resolver are not used...
|
|
199
197
|
return null as AsLinkReturnType<LinkResolverFunctionReturnType, Field>
|
|
200
198
|
}
|
|
201
199
|
|
|
@@ -67,26 +67,23 @@ type AsLinkAttrsReturnType<
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
|
-
* Resolves any type of link field or Prismic
|
|
71
|
-
*
|
|
72
|
-
* like `<a>`.
|
|
70
|
+
* Resolves any type of link field or Prismic page to a set of link attributes.
|
|
71
|
+
* The attributes are designed to be passed to link HTML elements, like `<a>`.
|
|
73
72
|
*
|
|
74
73
|
* If a resolved URL is external (i.e. starts with a protocol like `https://`),
|
|
75
74
|
* `rel` is returned as `"noreferrer"`.
|
|
76
75
|
*
|
|
77
76
|
* @typeParam LinkResolverFunctionReturnType - link resolver function return
|
|
78
77
|
* type
|
|
79
|
-
* @typeParam Field - Link field or Prismic
|
|
80
|
-
* attributes
|
|
78
|
+
* @typeParam Field - Link field or Prismic page to resolve to link attributes
|
|
81
79
|
*
|
|
82
|
-
* @param linkFieldOrDocument - Any kind of link field or a
|
|
80
|
+
* @param linkFieldOrDocument - Any kind of link field or a page to resolve
|
|
83
81
|
* @param config - Configuration that determines the output of `asLinkAttrs()`
|
|
84
82
|
*
|
|
85
83
|
* @returns Resolved set of link attributes or, if the provided link field or
|
|
86
|
-
*
|
|
84
|
+
* page is empty, and empty object
|
|
87
85
|
*
|
|
88
|
-
* @see
|
|
89
|
-
* @see Prismic API `routes` options documentation: {@link https://prismic.io/docs/route-resolver}
|
|
86
|
+
* @see Learn about route resolvers and link resolvers: {@link https://prismic.io/docs/routes}
|
|
90
87
|
*/
|
|
91
88
|
export const asLinkAttrs = <
|
|
92
89
|
LinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>,
|
|
@@ -101,15 +98,11 @@ export const asLinkAttrs = <
|
|
|
101
98
|
): AsLinkAttrsReturnType<LinkResolverFunctionReturnType> => {
|
|
102
99
|
if (
|
|
103
100
|
linkFieldOrDocument &&
|
|
104
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
105
|
-
// @ts-ignore - Bug in TypeScript 4.9: https://github.com/microsoft/TypeScript/issues/51501
|
|
106
101
|
("link_type" in linkFieldOrDocument
|
|
107
102
|
? isFilledLink(linkFieldOrDocument)
|
|
108
103
|
: linkFieldOrDocument)
|
|
109
104
|
) {
|
|
110
105
|
const target =
|
|
111
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
112
|
-
// @ts-ignore - Bug in TypeScript 4.9: https://github.com/microsoft/TypeScript/issues/51501
|
|
113
106
|
"target" in linkFieldOrDocument ? linkFieldOrDocument.target : undefined
|
|
114
107
|
|
|
115
108
|
const rawHref = asLink(linkFieldOrDocument, config.linkResolver)
|
package/src/helpers/asText.ts
CHANGED
|
@@ -28,14 +28,22 @@ type AsTextReturnType<Field extends RichTextField | null | undefined> =
|
|
|
28
28
|
|
|
29
29
|
export const asText: {
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* Converts a rich text field to a plain text string.
|
|
32
32
|
*
|
|
33
|
-
* @
|
|
34
|
-
* @param config - Configuration that determines the output of `asText()`
|
|
33
|
+
* @example
|
|
35
34
|
*
|
|
36
|
-
*
|
|
35
|
+
* ```ts
|
|
36
|
+
* const text = asText(document.data.content)
|
|
37
|
+
* // => "Hello world"
|
|
38
|
+
* ```
|
|
37
39
|
*
|
|
38
|
-
* @
|
|
40
|
+
* @param richTextField - A rich text field from Prismic.
|
|
41
|
+
* @param config - Configuration that determines the output of `asText()`.
|
|
42
|
+
*
|
|
43
|
+
* @returns Plain text equivalent of the rich text field, or `null` if the
|
|
44
|
+
* field is empty.
|
|
45
|
+
*
|
|
46
|
+
* @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}
|
|
39
47
|
*/
|
|
40
48
|
<Field extends RichTextField | null | undefined>(
|
|
41
49
|
richTextField: Field,
|
|
@@ -43,16 +51,18 @@ export const asText: {
|
|
|
43
51
|
): AsTextReturnType<Field>
|
|
44
52
|
|
|
45
53
|
/**
|
|
46
|
-
*
|
|
54
|
+
* Converts a rich text field to a plain text string.
|
|
47
55
|
*
|
|
48
56
|
* @deprecated Use object-style configuration instead.
|
|
49
57
|
*
|
|
50
|
-
* @param richTextField - A rich text
|
|
51
|
-
* @param separator - Separator used to join each element
|
|
58
|
+
* @param richTextField - A rich text field from Prismic.
|
|
59
|
+
* @param separator - Separator used to join each element. Defaults to a
|
|
60
|
+
* space.
|
|
52
61
|
*
|
|
53
|
-
* @returns Plain text equivalent of the
|
|
62
|
+
* @returns Plain text equivalent of the rich text field, or `null` if the
|
|
63
|
+
* field is empty.
|
|
54
64
|
*
|
|
55
|
-
* @see
|
|
65
|
+
* @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}
|
|
56
66
|
*/
|
|
57
67
|
<Field extends RichTextField | null | undefined>(
|
|
58
68
|
richTextField: Field,
|