@prismicio/client 7.20.2-alpha.0 → 7.20.3
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 +120 -132
- package/dist/Client.cjs.map +1 -1
- package/dist/Client.d.ts +7 -7
- package/dist/Client.js +120 -132
- package/dist/Client.js.map +1 -1
- package/dist/Migration.cjs +83 -101
- package/dist/Migration.cjs.map +1 -1
- package/dist/Migration.d.ts +9 -9
- package/dist/Migration.js +83 -101
- package/dist/Migration.js.map +1 -1
- package/dist/WriteClient.cjs +115 -92
- package/dist/WriteClient.cjs.map +1 -1
- package/dist/WriteClient.d.ts +6 -6
- package/dist/WriteClient.js +115 -92
- package/dist/WriteClient.js.map +1 -1
- package/dist/buildQueryURL.cjs.map +1 -1
- package/dist/buildQueryURL.d.ts +29 -21
- package/dist/buildQueryURL.js.map +1 -1
- package/dist/createClient.cjs.map +1 -1
- package/dist/createClient.d.ts +13 -10
- package/dist/createClient.js.map +1 -1
- package/dist/createMigration.cjs.map +1 -1
- package/dist/createMigration.d.ts +2 -2
- package/dist/createMigration.js.map +1 -1
- package/dist/createWriteClient.cjs.map +1 -1
- package/dist/createWriteClient.d.ts +2 -2
- package/dist/errors/ForbiddenError.d.ts +1 -1
- package/dist/errors/InvalidDataError.d.ts +1 -1
- package/dist/errors/NotFoundError.d.ts +1 -1
- package/dist/errors/ParsingError.d.ts +1 -1
- package/dist/errors/PreviewTokenExpired.d.ts +1 -1
- package/dist/errors/PrismicError.cjs +2 -5
- package/dist/errors/PrismicError.cjs.map +1 -1
- package/dist/errors/PrismicError.js +2 -5
- package/dist/errors/PrismicError.js.map +1 -1
- package/dist/errors/RefExpiredError.d.ts +1 -1
- package/dist/errors/RefNotFoundError.d.ts +1 -1
- package/dist/errors/RepositoryNotFoundError.d.ts +1 -1
- package/dist/filter.cjs.map +1 -1
- package/dist/filter.js.map +1 -1
- package/dist/getGraphQLEndpoint.cjs.map +1 -1
- package/dist/getGraphQLEndpoint.js.map +1 -1
- package/dist/getRepositoryEndpoint.cjs.map +1 -1
- package/dist/getRepositoryEndpoint.d.ts +9 -2
- package/dist/getRepositoryEndpoint.js.map +1 -1
- package/dist/getRepositoryName.cjs.map +1 -1
- package/dist/getRepositoryName.js.map +1 -1
- package/dist/getToolbarSrc.cjs.map +1 -1
- package/dist/getToolbarSrc.js.map +1 -1
- package/dist/helpers/asDate.cjs.map +1 -1
- package/dist/helpers/asDate.d.ts +13 -6
- package/dist/helpers/asDate.js.map +1 -1
- package/dist/helpers/asHTML.cjs +22 -22
- package/dist/helpers/asHTML.cjs.map +1 -1
- package/dist/helpers/asHTML.d.ts +37 -29
- package/dist/helpers/asHTML.js +22 -22
- package/dist/helpers/asHTML.js.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.d.ts +17 -16
- package/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -1
- package/dist/helpers/asImageSrc.cjs.map +1 -1
- package/dist/helpers/asImageSrc.d.ts +12 -11
- package/dist/helpers/asImageSrc.js.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.cjs.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.d.ts +19 -18
- package/dist/helpers/asImageWidthSrcSet.js.map +1 -1
- package/dist/helpers/asLink.cjs.map +1 -1
- package/dist/helpers/asLink.d.ts +36 -35
- package/dist/helpers/asLink.js.map +1 -1
- package/dist/helpers/asLinkAttrs.cjs.map +1 -1
- package/dist/helpers/asLinkAttrs.d.ts +11 -14
- package/dist/helpers/asLinkAttrs.js.map +1 -1
- package/dist/helpers/asText.cjs.map +1 -1
- package/dist/helpers/asText.d.ts +21 -11
- package/dist/helpers/asText.js.map +1 -1
- package/dist/helpers/documentToLinkField.cjs +1 -2
- package/dist/helpers/documentToLinkField.cjs.map +1 -1
- package/dist/helpers/documentToLinkField.d.ts +2 -2
- package/dist/helpers/documentToLinkField.js +1 -2
- package/dist/helpers/documentToLinkField.js.map +1 -1
- package/dist/helpers/isFilled.cjs +1 -1
- package/dist/helpers/isFilled.cjs.map +1 -1
- package/dist/helpers/isFilled.d.ts +35 -34
- package/dist/helpers/isFilled.js +1 -1
- package/dist/helpers/isFilled.js.map +1 -1
- package/dist/helpers/mapSliceZone.cjs.map +1 -1
- package/dist/helpers/mapSliceZone.d.ts +11 -11
- package/dist/helpers/mapSliceZone.js.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +120 -120
- package/dist/index.js.map +1 -1
- package/dist/isRepositoryEndpoint.cjs.map +1 -1
- package/dist/isRepositoryEndpoint.d.ts +2 -2
- package/dist/isRepositoryEndpoint.js.map +1 -1
- package/dist/isRepositoryName.cjs.map +1 -1
- package/dist/isRepositoryName.js.map +1 -1
- package/dist/lib/appendFilters.cjs.map +1 -1
- package/dist/lib/appendFilters.js.map +1 -1
- package/dist/lib/castArray.cjs.map +1 -1
- package/dist/lib/castArray.js.map +1 -1
- package/dist/lib/castThunk.cjs.map +1 -1
- package/dist/lib/castThunk.js.map +1 -1
- package/dist/lib/devMsg.cjs.map +1 -1
- package/dist/lib/devMsg.js.map +1 -1
- package/dist/lib/escapeHTML.cjs.map +1 -1
- package/dist/lib/escapeHTML.js.map +1 -1
- package/dist/lib/everyTagFilter.cjs.map +1 -1
- package/dist/lib/everyTagFilter.js.map +1 -1
- package/dist/lib/findMasterRef.cjs.map +1 -1
- package/dist/lib/findMasterRef.d.ts +1 -1
- package/dist/lib/findMasterRef.js.map +1 -1
- package/dist/lib/findRef.cjs.map +1 -1
- package/dist/lib/findRef.d.ts +1 -1
- package/dist/lib/findRef.js.map +1 -1
- package/dist/lib/findRefByID.cjs.map +1 -1
- package/dist/lib/findRefByID.d.ts +1 -1
- package/dist/lib/findRefByID.js.map +1 -1
- package/dist/lib/findRefByLabel.cjs.map +1 -1
- package/dist/lib/findRefByLabel.d.ts +1 -1
- package/dist/lib/findRefByLabel.js.map +1 -1
- package/dist/lib/getOptionalLinkProperties.cjs.map +1 -1
- package/dist/lib/getOptionalLinkProperties.d.ts +1 -1
- package/dist/lib/getOptionalLinkProperties.js.map +1 -1
- package/dist/lib/getPreviewCookie.cjs.map +1 -1
- package/dist/lib/getPreviewCookie.js.map +1 -1
- package/dist/lib/isInternalURL.cjs.map +1 -1
- package/dist/lib/isInternalURL.js.map +1 -1
- package/dist/lib/isMigrationValue.cjs.map +1 -1
- package/dist/lib/isMigrationValue.d.ts +8 -8
- package/dist/lib/isMigrationValue.js.map +1 -1
- package/dist/lib/isValue.cjs.map +1 -1
- package/dist/lib/isValue.d.ts +10 -10
- package/dist/lib/isValue.js.map +1 -1
- package/dist/lib/minifyGraphQLQuery.cjs.map +1 -1
- package/dist/lib/minifyGraphQLQuery.js.map +1 -1
- package/dist/lib/pLimit.cjs +3 -4
- package/dist/lib/pLimit.cjs.map +1 -1
- package/dist/lib/pLimit.js +3 -4
- package/dist/lib/pLimit.js.map +1 -1
- package/dist/lib/request.cjs +8 -10
- package/dist/lib/request.cjs.map +1 -1
- package/dist/lib/request.js +8 -10
- package/dist/lib/request.js.map +1 -1
- package/dist/lib/resolveMigrationDocumentData.cjs +4 -6
- package/dist/lib/resolveMigrationDocumentData.cjs.map +1 -1
- package/dist/lib/resolveMigrationDocumentData.d.ts +8 -8
- package/dist/lib/resolveMigrationDocumentData.js +4 -6
- package/dist/lib/resolveMigrationDocumentData.js.map +1 -1
- package/dist/lib/serializerHelpers.cjs +2 -2
- package/dist/lib/serializerHelpers.cjs.map +1 -1
- package/dist/lib/serializerHelpers.d.ts +3 -3
- package/dist/lib/serializerHelpers.js +2 -2
- package/dist/lib/serializerHelpers.js.map +1 -1
- package/dist/lib/someTagsFilter.cjs.map +1 -1
- package/dist/lib/someTagsFilter.js.map +1 -1
- package/dist/lib/throttledLog.cjs.map +1 -1
- package/dist/lib/throttledLog.js.map +1 -1
- package/dist/lib/typeFilter.cjs.map +1 -1
- package/dist/lib/typeFilter.js.map +1 -1
- package/dist/lib/validateAssetMetadata.cjs.map +1 -1
- package/dist/lib/validateAssetMetadata.d.ts +1 -1
- package/dist/lib/validateAssetMetadata.js.map +1 -1
- package/dist/package.json.cjs +1 -1
- package/dist/package.json.js +1 -1
- package/dist/richtext/asText.cjs.map +1 -1
- package/dist/richtext/asText.d.ts +6 -6
- package/dist/richtext/asText.js.map +1 -1
- package/dist/richtext/asTree.cjs.map +1 -1
- package/dist/richtext/asTree.d.ts +2 -2
- package/dist/richtext/asTree.js.map +1 -1
- package/dist/richtext/composeSerializers.cjs.map +1 -1
- package/dist/richtext/composeSerializers.d.ts +1 -1
- package/dist/richtext/composeSerializers.js.map +1 -1
- package/dist/richtext/index.d.ts +7 -7
- package/dist/richtext/serialize.cjs.map +1 -1
- package/dist/richtext/serialize.d.ts +10 -10
- package/dist/richtext/serialize.js.map +1 -1
- package/dist/richtext/types.cjs.map +1 -1
- package/dist/richtext/types.d.ts +7 -7
- package/dist/richtext/types.js.map +1 -1
- package/dist/richtext/wrapMapSerializer.cjs.map +1 -1
- package/dist/richtext/wrapMapSerializer.d.ts +1 -1
- package/dist/richtext/wrapMapSerializer.js.map +1 -1
- package/dist/types/api/asset/asset.d.ts +1 -1
- package/dist/types/api/integration.d.ts +1 -1
- package/dist/types/api/migration/document.d.ts +1 -1
- package/dist/types/api/query.d.ts +1 -1
- package/dist/types/api/release.d.ts +1 -1
- package/dist/types/api/repository.d.ts +1 -1
- package/dist/types/migration/Asset.cjs +12 -15
- package/dist/types/migration/Asset.cjs.map +1 -1
- package/dist/types/migration/Asset.d.ts +7 -7
- package/dist/types/migration/Asset.js +12 -15
- package/dist/types/migration/Asset.js.map +1 -1
- package/dist/types/migration/ContentRelationship.d.ts +3 -3
- package/dist/types/migration/Document.cjs +24 -27
- package/dist/types/migration/Document.cjs.map +1 -1
- package/dist/types/migration/Document.d.ts +9 -9
- package/dist/types/migration/Document.js +24 -27
- package/dist/types/migration/Document.js.map +1 -1
- package/dist/types/migration/Link.d.ts +1 -1
- package/dist/types/model/boolean.d.ts +1 -1
- package/dist/types/model/color.d.ts +1 -1
- package/dist/types/model/contentRelationship.d.ts +3 -2
- package/dist/types/model/customType.d.ts +1 -1
- package/dist/types/model/date.d.ts +1 -1
- package/dist/types/model/embed.d.ts +1 -1
- package/dist/types/model/geoPoint.d.ts +1 -1
- package/dist/types/model/group.d.ts +1 -1
- package/dist/types/model/image.d.ts +1 -1
- package/dist/types/model/integration.d.ts +1 -1
- package/dist/types/model/keyText.d.ts +1 -1
- package/dist/types/model/link.d.ts +1 -1
- package/dist/types/model/linkToMedia.d.ts +2 -2
- package/dist/types/model/number.d.ts +1 -1
- package/dist/types/model/range.d.ts +1 -1
- package/dist/types/model/richText.d.ts +1 -1
- package/dist/types/model/select.d.ts +1 -1
- package/dist/types/model/separator.d.ts +1 -1
- package/dist/types/model/sharedSlice.d.ts +2 -2
- package/dist/types/model/sharedSliceVariation.d.ts +1 -1
- package/dist/types/model/slice.d.ts +3 -3
- package/dist/types/model/sliceZone.d.ts +2 -2
- package/dist/types/model/table.d.ts +1 -1
- package/dist/types/model/timestamp.d.ts +1 -1
- package/dist/types/model/title.d.ts +1 -1
- package/dist/types/model/types.d.ts +22 -22
- package/dist/types/model/uid.d.ts +1 -1
- package/dist/types/value/color.d.ts +1 -1
- package/dist/types/value/contentRelationship.d.ts +3 -3
- package/dist/types/value/date.d.ts +1 -1
- package/dist/types/value/document.d.ts +4 -4
- package/dist/types/value/embed.d.ts +1 -1
- package/dist/types/value/geoPoint.d.ts +1 -1
- package/dist/types/value/group.d.ts +1 -1
- package/dist/types/value/image.d.ts +1 -1
- package/dist/types/value/integration.d.ts +1 -1
- package/dist/types/value/keyText.d.ts +1 -1
- package/dist/types/value/link.d.ts +5 -5
- package/dist/types/value/linkToMedia.d.ts +2 -2
- package/dist/types/value/number.d.ts +1 -1
- package/dist/types/value/richText.d.ts +3 -3
- package/dist/types/value/select.d.ts +1 -1
- package/dist/types/value/sharedSlice.d.ts +1 -1
- package/dist/types/value/sharedSliceVariation.d.ts +1 -1
- package/dist/types/value/slice.d.ts +1 -1
- package/dist/types/value/sliceZone.d.ts +3 -3
- package/dist/types/value/table.d.ts +2 -2
- package/dist/types/value/timestamp.d.ts +2 -2
- package/dist/types/value/title.d.ts +2 -2
- package/dist/types/value/types.d.ts +18 -18
- package/dist/types/webhook/apiUpdate.d.ts +1 -1
- package/dist/types/webhook/testTrigger.d.ts +1 -1
- package/dist/types/webhook/types.d.ts +2 -2
- package/package.json +11 -11
- package/src/WriteClient.ts +32 -21
- package/src/buildQueryURL.ts +29 -21
- package/src/createClient.ts +11 -8
- package/src/getRepositoryEndpoint.ts +9 -2
- package/src/helpers/asDate.ts +11 -4
- package/src/helpers/asHTML.ts +34 -26
- package/src/helpers/asImagePixelDensitySrcSet.ts +16 -15
- package/src/helpers/asImageSrc.ts +11 -10
- package/src/helpers/asImageWidthSrcSet.ts +18 -17
- package/src/helpers/asLink.ts +33 -32
- package/src/helpers/asLinkAttrs.ts +6 -9
- package/src/helpers/asText.ts +20 -10
- package/src/helpers/isFilled.ts +15 -14
- package/src/helpers/mapSliceZone.ts +10 -10
- package/src/index.ts +2 -2
- package/src/isRepositoryEndpoint.ts +2 -2
- 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/model/contentRelationship.ts +1 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { FieldState } from "./types";
|
|
2
|
-
import type { SharedSlice } from "./sharedSlice";
|
|
3
|
-
import type { Slice } from "./slice";
|
|
1
|
+
import type { FieldState } from "./types.js";
|
|
2
|
+
import type { SharedSlice } from "./sharedSlice.js";
|
|
3
|
+
import type { Slice } from "./slice.js";
|
|
4
4
|
/**
|
|
5
5
|
* Prismic Slices are sections of your website. Prismic documents contain a
|
|
6
6
|
* dynamic "Slice Zone" that allows content creators to add, edit, and rearrange
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { FieldState } from "./types";
|
|
2
|
-
import type { RTHeading1Node, RTHeading2Node, RTHeading3Node, RTHeading4Node, RTHeading5Node, RTHeading6Node } from "./richText";
|
|
1
|
+
import type { FieldState } from "./types.js";
|
|
2
|
+
import type { RTHeading1Node, RTHeading2Node, RTHeading3Node, RTHeading4Node, RTHeading5Node, RTHeading6Node } from "./richText.js";
|
|
3
3
|
/**
|
|
4
4
|
* A title field.
|
|
5
5
|
*
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import type { BooleanField } from "./boolean";
|
|
2
|
-
import type { ColorField } from "./color";
|
|
3
|
-
import type { ContentRelationshipField } from "./contentRelationship";
|
|
4
|
-
import type { DateField } from "./date";
|
|
5
|
-
import type { EmbedField } from "./embed";
|
|
6
|
-
import type { GeoPointField } from "./geoPoint";
|
|
7
|
-
import type { GroupField } from "./group";
|
|
8
|
-
import type { ImageField } from "./image";
|
|
9
|
-
import type { IntegrationField } from "./integration";
|
|
10
|
-
import type { KeyTextField } from "./keyText";
|
|
11
|
-
import type { LinkField } from "./link";
|
|
12
|
-
import type { LinkToMediaField } from "./linkToMedia";
|
|
13
|
-
import type { NumberField } from "./number";
|
|
14
|
-
import type { RichTextField } from "./richText";
|
|
15
|
-
import type { SelectField } from "./select";
|
|
16
|
-
import type { TableField } from "./table";
|
|
17
|
-
import type { TimestampField } from "./timestamp";
|
|
18
|
-
import type { TitleField } from "./title";
|
|
1
|
+
import type { BooleanField } from "./boolean.js";
|
|
2
|
+
import type { ColorField } from "./color.js";
|
|
3
|
+
import type { ContentRelationshipField } from "./contentRelationship.js";
|
|
4
|
+
import type { DateField } from "./date.js";
|
|
5
|
+
import type { EmbedField } from "./embed.js";
|
|
6
|
+
import type { GeoPointField } from "./geoPoint.js";
|
|
7
|
+
import type { GroupField } from "./group.js";
|
|
8
|
+
import type { ImageField } from "./image.js";
|
|
9
|
+
import type { IntegrationField } from "./integration.js";
|
|
10
|
+
import type { KeyTextField } from "./keyText.js";
|
|
11
|
+
import type { LinkField } from "./link.js";
|
|
12
|
+
import type { LinkToMediaField } from "./linkToMedia.js";
|
|
13
|
+
import type { NumberField } from "./number.js";
|
|
14
|
+
import type { RichTextField } from "./richText.js";
|
|
15
|
+
import type { SelectField } from "./select.js";
|
|
16
|
+
import type { TableField } from "./table.js";
|
|
17
|
+
import type { TimestampField } from "./timestamp.js";
|
|
18
|
+
import type { TitleField } from "./title.js";
|
|
19
19
|
/**
|
|
20
20
|
* Empty state for object-shaped fields.
|
|
21
21
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { WebhookBodyAPIUpdate } from "./apiUpdate";
|
|
2
|
-
import type { WebhookBodyTestTrigger } from "./testTrigger";
|
|
1
|
+
import type { WebhookBodyAPIUpdate } from "./apiUpdate.js";
|
|
2
|
+
import type { WebhookBodyTestTrigger } from "./testTrigger.js";
|
|
3
3
|
export type WebhookBody = WebhookBodyAPIUpdate | WebhookBodyTestTrigger;
|
|
4
4
|
/**
|
|
5
5
|
* Types of Prismic Webhooks.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismicio/client",
|
|
3
|
-
"version": "7.20.
|
|
3
|
+
"version": "7.20.3",
|
|
4
4
|
"description": "The official JavaScript + TypeScript client library for Prismic",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -83,28 +83,28 @@
|
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@prismicio/mock": "0.7.1",
|
|
86
|
-
"@prismicio/types-internal": "^3.
|
|
86
|
+
"@prismicio/types-internal": "^3.16.1",
|
|
87
87
|
"@size-limit/preset-small-lib": "^11.2.0",
|
|
88
88
|
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
|
|
89
89
|
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
90
90
|
"@typescript-eslint/parser": "^6.21.0",
|
|
91
|
-
"@vitest/coverage-v8": "^2.
|
|
91
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
92
92
|
"abort-controller": "^3.0.0",
|
|
93
93
|
"eslint": "^8.57.1",
|
|
94
|
-
"eslint-config-prettier": "^9.1.
|
|
95
|
-
"eslint-plugin-prettier": "^5.
|
|
94
|
+
"eslint-config-prettier": "^9.1.2",
|
|
95
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
96
96
|
"eslint-plugin-tsdoc": "^0.3.0",
|
|
97
97
|
"msw": "^1.3.5",
|
|
98
98
|
"node-fetch": "^3.3.2",
|
|
99
|
-
"prettier": "^3.
|
|
100
|
-
"prettier-plugin-jsdoc": "1.3.
|
|
99
|
+
"prettier": "^3.6.2",
|
|
100
|
+
"prettier-plugin-jsdoc": "1.3.3",
|
|
101
101
|
"size-limit": "^11.2.0",
|
|
102
102
|
"standard-version": "^9.5.0",
|
|
103
103
|
"ts-expect": "^1.3.0",
|
|
104
|
-
"typescript": "^5.
|
|
105
|
-
"vite": "^
|
|
106
|
-
"vite-plugin-sdk": "^0.1.
|
|
107
|
-
"vitest": "^2.
|
|
104
|
+
"typescript": "^5.9.3",
|
|
105
|
+
"vite": "^7.1.10",
|
|
106
|
+
"vite-plugin-sdk": "^0.1.5",
|
|
107
|
+
"vitest": "^3.2.4"
|
|
108
108
|
},
|
|
109
109
|
"engines": {
|
|
110
110
|
"node": ">=14.15.0"
|
package/src/WriteClient.ts
CHANGED
|
@@ -908,34 +908,45 @@ export class WriteClient<
|
|
|
908
908
|
* @throws {@link PrismicError} For 500, and other unexpected errors.
|
|
909
909
|
*/
|
|
910
910
|
async #handleMigrationAPIError(response: ResponseLike): Promise<never> {
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
911
|
+
// Some responses come with a JSON body, some with a text body.
|
|
912
|
+
const text = await response.text()
|
|
913
|
+
let json: unknown
|
|
914
|
+
try {
|
|
915
|
+
json = JSON.parse(text)
|
|
916
|
+
} catch {
|
|
917
|
+
// no-op
|
|
918
|
+
}
|
|
915
919
|
|
|
916
920
|
switch (response.status) {
|
|
917
|
-
case 400:
|
|
918
|
-
|
|
919
|
-
|
|
921
|
+
case 400:
|
|
922
|
+
if (json) {
|
|
923
|
+
throw new InvalidDataError(
|
|
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)
|
|
920
930
|
|
|
921
|
-
case 401:
|
|
922
|
-
throw new ForbiddenError(
|
|
923
|
-
}
|
|
931
|
+
case 401:
|
|
932
|
+
throw new ForbiddenError(text, response.url, text)
|
|
924
933
|
|
|
925
|
-
case 403:
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
934
|
+
case 403:
|
|
935
|
+
if (json) {
|
|
936
|
+
throw new ForbiddenError(
|
|
937
|
+
(json as { Message: string }).Message,
|
|
938
|
+
response.url,
|
|
939
|
+
json,
|
|
940
|
+
)
|
|
941
|
+
}
|
|
942
|
+
throw new ForbiddenError(text, response.url, text)
|
|
930
943
|
|
|
931
|
-
case 404:
|
|
932
|
-
throw new NotFoundError(
|
|
933
|
-
}
|
|
944
|
+
case 404:
|
|
945
|
+
throw new NotFoundError(text, response.url, text)
|
|
934
946
|
|
|
935
947
|
case 500:
|
|
936
|
-
default:
|
|
937
|
-
throw new PrismicError(
|
|
938
|
-
}
|
|
948
|
+
default:
|
|
949
|
+
throw new PrismicError(text, response.url, text)
|
|
939
950
|
}
|
|
940
951
|
}
|
|
941
952
|
}
|
package/src/buildQueryURL.ts
CHANGED
|
@@ -39,11 +39,11 @@ export interface Ordering {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
|
-
* A `routes` parameter that determines how a
|
|
42
|
+
* A `routes` parameter that determines how a page's URL field is resolved.
|
|
43
43
|
*
|
|
44
44
|
* {@link https://prismic.io/docs/route-resolver}
|
|
45
45
|
*
|
|
46
|
-
* @example With a
|
|
46
|
+
* @example With a page's UID field.
|
|
47
47
|
*
|
|
48
48
|
* ```ts
|
|
49
49
|
* {
|
|
@@ -66,24 +66,24 @@ export interface Ordering {
|
|
|
66
66
|
*/
|
|
67
67
|
export interface Route {
|
|
68
68
|
/**
|
|
69
|
-
* The custom type of the
|
|
69
|
+
* The custom type of the page.
|
|
70
70
|
*/
|
|
71
71
|
type: string
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
74
|
* A specific UID to which this route definition is scoped. The route is only
|
|
75
|
-
* defined for the
|
|
75
|
+
* defined for the page whose UID matches the given UID.
|
|
76
76
|
*/
|
|
77
77
|
uid?: string
|
|
78
78
|
|
|
79
79
|
/**
|
|
80
80
|
* A specific language to which this route definition is scoped. The route is
|
|
81
|
-
* only defined for
|
|
81
|
+
* only defined for pages whose language matches the given language.
|
|
82
82
|
*/
|
|
83
83
|
lang?: string
|
|
84
84
|
|
|
85
85
|
/**
|
|
86
|
-
* The resolved path of the
|
|
86
|
+
* The resolved path of the page with optional placeholders.
|
|
87
87
|
*/
|
|
88
88
|
path: string
|
|
89
89
|
|
|
@@ -94,9 +94,9 @@ export interface Route {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
/**
|
|
97
|
-
* Parameters for the Prismic
|
|
97
|
+
* Parameters for the Prismic Content API.
|
|
98
98
|
*
|
|
99
|
-
* {@link https://prismic.io/docs/
|
|
99
|
+
* @see Learn how to fetch content from Prismic: {@link https://prismic.io/docs/fetch-content}
|
|
100
100
|
*/
|
|
101
101
|
export interface QueryParams {
|
|
102
102
|
/**
|
|
@@ -108,8 +108,8 @@ export interface QueryParams {
|
|
|
108
108
|
accessToken?: string
|
|
109
109
|
|
|
110
110
|
/**
|
|
111
|
-
* The `pageSize` parameter defines the maximum number of
|
|
112
|
-
*
|
|
111
|
+
* The `pageSize` parameter defines the maximum number of pages that the API
|
|
112
|
+
* will return for your query.
|
|
113
113
|
*
|
|
114
114
|
* {@link https://prismic.io/docs/rest-api-technical-reference#pagesize}
|
|
115
115
|
*/
|
|
@@ -124,8 +124,8 @@ export interface QueryParams {
|
|
|
124
124
|
|
|
125
125
|
/**
|
|
126
126
|
* The `after` parameter can be used along with the orderings option. It will
|
|
127
|
-
* remove all the
|
|
128
|
-
*
|
|
127
|
+
* remove all the pages except for those after the specified page in the
|
|
128
|
+
* list.
|
|
129
129
|
*
|
|
130
130
|
* {@link https://prismic.io/docs/rest-api-technical-reference#after}
|
|
131
131
|
*/
|
|
@@ -141,7 +141,7 @@ export interface QueryParams {
|
|
|
141
141
|
|
|
142
142
|
/**
|
|
143
143
|
* The `fetchLinks` parameter allows you to retrieve a specific content field
|
|
144
|
-
* from a linked
|
|
144
|
+
* from a linked page and add it to the page response object.
|
|
145
145
|
*
|
|
146
146
|
* {@link https://prismic.io/docs/rest-api-technical-reference#fetchlinks}
|
|
147
147
|
*/
|
|
@@ -189,7 +189,7 @@ export interface QueryParams {
|
|
|
189
189
|
orderings?: string | Ordering | (string | Ordering)[]
|
|
190
190
|
|
|
191
191
|
/**
|
|
192
|
-
* The `routes` option allows you to define how a
|
|
192
|
+
* The `routes` option allows you to define how a page's `url` field is
|
|
193
193
|
* resolved.
|
|
194
194
|
*
|
|
195
195
|
* {@link https://prismic.io/docs/route-resolver}
|
|
@@ -199,7 +199,7 @@ export interface QueryParams {
|
|
|
199
199
|
/**
|
|
200
200
|
* The `brokenRoute` option allows you to define the route populated in the
|
|
201
201
|
* `url` property for broken link or content relationship fields. A broken
|
|
202
|
-
* link is a link or content relationship field whose linked
|
|
202
|
+
* link is a link or content relationship field whose linked page has been
|
|
203
203
|
* unpublished or deleted.
|
|
204
204
|
*
|
|
205
205
|
* {@link https://prismic.io/docs/route-resolver}
|
|
@@ -296,21 +296,29 @@ const castOrderingToString = (ordering: Ordering | string): string => {
|
|
|
296
296
|
export type BuildQueryURLArgs = QueryParams & BuildQueryURLParams
|
|
297
297
|
|
|
298
298
|
/**
|
|
299
|
-
*
|
|
300
|
-
* paginated response for this URL includes
|
|
299
|
+
* Builds a Prismic Content API URL to request pages from a repository. The
|
|
300
|
+
* paginated response for this URL includes pages matching the parameters.
|
|
301
301
|
*
|
|
302
302
|
* A ref is required to make a request. Request the `endpoint` URL to retrieve a
|
|
303
303
|
* list of available refs.
|
|
304
304
|
*
|
|
305
305
|
* Type the JSON response with `Query`.
|
|
306
306
|
*
|
|
307
|
-
*
|
|
308
|
-
* {@link https://prismic.io/docs/rest-api-technical-reference}
|
|
307
|
+
* @example
|
|
309
308
|
*
|
|
310
|
-
*
|
|
309
|
+
* ```ts
|
|
310
|
+
* const url = buildQueryURL("https://my-repo.cdn.prismic.io/api/v2", {
|
|
311
|
+
* ref: "my-ref",
|
|
312
|
+
* filters: [filter.at("document.type", "blog_post")],
|
|
313
|
+
* })
|
|
314
|
+
* ```
|
|
315
|
+
*
|
|
316
|
+
* @param endpoint - URL to the repository's Content API.
|
|
311
317
|
* @param args - Arguments to filter and scope the query.
|
|
312
318
|
*
|
|
313
|
-
* @returns URL that can be used to request
|
|
319
|
+
* @returns URL that can be used to request pages from the repository.
|
|
320
|
+
*
|
|
321
|
+
* @see Prismic Content API technical reference: {@link https://prismic.io/docs/content-api}
|
|
314
322
|
*/
|
|
315
323
|
export const buildQueryURL = (
|
|
316
324
|
endpoint: string,
|
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 @prismicio/client technical reference: {@link https://prismic.io/docs/technical-reference/prismicio-client/v7}
|
|
37
40
|
*/
|
|
38
41
|
export const createClient: CreateClient = <TDocuments extends PrismicDocument>(
|
|
39
42
|
repositoryNameOrEndpoint: string,
|
|
@@ -3,13 +3,20 @@ import { PrismicError } from "./errors/PrismicError"
|
|
|
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/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,
|
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: {
|
|
@@ -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,
|