@prismicio/client 6.7.1 → 6.7.2
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/ForbiddenError.cjs +7 -0
- package/dist/ForbiddenError.cjs.map +1 -0
- package/dist/ForbiddenError.d.ts +11 -0
- package/dist/ForbiddenError.js +7 -0
- package/dist/ForbiddenError.js.map +1 -0
- package/dist/NotFoundError.cjs +7 -0
- package/dist/NotFoundError.cjs.map +1 -0
- package/dist/NotFoundError.d.ts +3 -0
- package/dist/NotFoundError.js +7 -0
- package/dist/NotFoundError.js.map +1 -0
- package/dist/ParsingError.cjs +7 -0
- package/dist/ParsingError.cjs.map +1 -0
- package/dist/ParsingError.d.ts +12 -0
- package/dist/ParsingError.js +7 -0
- package/dist/ParsingError.js.map +1 -0
- package/dist/PrismicError.cjs +19 -0
- package/dist/PrismicError.cjs.map +1 -0
- package/dist/PrismicError.d.ts +5 -0
- package/dist/PrismicError.js +19 -0
- package/dist/PrismicError.js.map +1 -0
- package/dist/buildQueryURL.cjs +40 -0
- package/dist/buildQueryURL.cjs.map +1 -0
- package/dist/buildQueryURL.d.ts +130 -0
- package/dist/buildQueryURL.js +40 -0
- package/dist/buildQueryURL.js.map +1 -0
- package/dist/client.cjs +436 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.ts +929 -0
- package/dist/client.js +419 -0
- package/dist/client.js.map +1 -0
- package/dist/cookie.cjs +5 -0
- package/dist/cookie.cjs.map +1 -0
- package/dist/cookie.d.ts +5 -0
- package/dist/cookie.js +5 -0
- package/dist/cookie.js.map +1 -0
- package/dist/getGraphQLEndpoint.cjs +13 -0
- package/dist/getGraphQLEndpoint.cjs.map +1 -0
- package/dist/getGraphQLEndpoint.d.ts +9 -0
- package/dist/getGraphQLEndpoint.js +13 -0
- package/dist/getGraphQLEndpoint.js.map +1 -0
- package/dist/getRepositoryEndpoint.cjs +13 -0
- package/dist/getRepositoryEndpoint.cjs.map +1 -0
- package/dist/getRepositoryEndpoint.d.ts +10 -0
- package/dist/getRepositoryEndpoint.js +13 -0
- package/dist/getRepositoryEndpoint.js.map +1 -0
- package/dist/getRepositoryName.cjs +12 -0
- package/dist/getRepositoryName.cjs.map +1 -0
- package/dist/getRepositoryName.d.ts +13 -0
- package/dist/getRepositoryName.js +12 -0
- package/dist/getRepositoryName.js.map +1 -0
- package/dist/index.cjs +32 -719
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +88 -1526
- package/dist/index.js +34 -679
- package/dist/index.js.map +1 -1
- package/dist/isRepositoryEndpoint.cjs +12 -0
- package/dist/isRepositoryEndpoint.cjs.map +1 -0
- package/dist/isRepositoryEndpoint.d.ts +10 -0
- package/dist/isRepositoryEndpoint.js +12 -0
- package/dist/isRepositoryEndpoint.js.map +1 -0
- package/dist/isRepositoryName.cjs +7 -0
- package/dist/isRepositoryName.cjs.map +1 -0
- package/dist/isRepositoryName.d.ts +9 -0
- package/dist/isRepositoryName.js +7 -0
- package/dist/isRepositoryName.js.map +1 -0
- package/dist/lib/appendPredicates.cjs +14 -0
- package/dist/lib/appendPredicates.cjs.map +1 -0
- package/dist/lib/appendPredicates.d.ts +18 -0
- package/dist/lib/appendPredicates.js +14 -0
- package/dist/lib/appendPredicates.js.map +1 -0
- package/dist/lib/castArray.cjs +5 -0
- package/dist/lib/castArray.cjs.map +1 -0
- package/dist/lib/castArray.d.ts +11 -0
- package/dist/lib/castArray.js +5 -0
- package/dist/lib/castArray.js.map +1 -0
- package/dist/lib/castThunk.cjs +5 -0
- package/dist/lib/castThunk.cjs.map +1 -0
- package/dist/lib/castThunk.d.ts +10 -0
- package/dist/lib/castThunk.js +5 -0
- package/dist/lib/castThunk.js.map +1 -0
- package/dist/lib/findMasterRef.cjs +8 -0
- package/dist/lib/findMasterRef.cjs.map +1 -0
- package/dist/lib/findMasterRef.d.ts +10 -0
- package/dist/lib/findMasterRef.js +8 -0
- package/dist/lib/findMasterRef.js.map +1 -0
- package/dist/lib/findRef.cjs +12 -0
- package/dist/lib/findRef.cjs.map +1 -0
- package/dist/lib/findRef.d.ts +13 -0
- package/dist/lib/findRef.js +12 -0
- package/dist/lib/findRef.js.map +1 -0
- package/dist/lib/findRefByID.cjs +8 -0
- package/dist/lib/findRefByID.cjs.map +1 -0
- package/dist/lib/findRefByID.d.ts +11 -0
- package/dist/lib/findRefByID.js +8 -0
- package/dist/lib/findRefByID.js.map +1 -0
- package/dist/lib/findRefByLabel.cjs +8 -0
- package/dist/lib/findRefByLabel.cjs.map +1 -0
- package/dist/lib/findRefByLabel.d.ts +11 -0
- package/dist/lib/findRefByLabel.js +8 -0
- package/dist/lib/findRefByLabel.js.map +1 -0
- package/dist/lib/getPreviewCookie.cjs +21 -0
- package/dist/lib/getPreviewCookie.cjs.map +1 -0
- package/dist/lib/getPreviewCookie.d.ts +9 -0
- package/dist/lib/getPreviewCookie.js +21 -0
- package/dist/lib/getPreviewCookie.js.map +1 -0
- package/dist/lib/minifyGraphQLQuery.cjs +7 -0
- package/dist/lib/minifyGraphQLQuery.cjs.map +1 -0
- package/dist/lib/minifyGraphQLQuery.d.ts +8 -0
- package/dist/lib/minifyGraphQLQuery.js +7 -0
- package/dist/lib/minifyGraphQLQuery.js.map +1 -0
- package/dist/lib/orElseThrow.d.ts +11 -0
- package/dist/predicate.cjs +68 -0
- package/dist/predicate.cjs.map +1 -0
- package/dist/predicate.d.ts +209 -0
- package/dist/predicate.js +68 -0
- package/dist/predicate.js.map +1 -0
- package/dist/types.d.ts +156 -0
- package/package.json +21 -21
- package/src/buildQueryURL.ts +6 -3
- package/src/client.ts +71 -36
- package/src/cookie.ts +2 -1
- package/src/getRepositoryName.ts +4 -2
- package/src/isRepositoryEndpoint.ts +2 -1
- package/src/isRepositoryName.ts +2 -1
- package/src/lib/appendPredicates.ts +2 -1
- package/src/lib/getPreviewCookie.ts +2 -1
- package/src/predicate.ts +4 -2
- package/src/types.ts +3 -3
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import * as prismicT from "@prismicio/types";
|
|
2
|
+
/**
|
|
3
|
+
* Create a union of the given object's values, and optionally specify which
|
|
4
|
+
* keys to get the values from.
|
|
5
|
+
*
|
|
6
|
+
* Taken from the `type-fest` package.
|
|
7
|
+
*
|
|
8
|
+
* See:
|
|
9
|
+
* https://github.com/sindresorhus/type-fest/blob/61c35052f09caa23de5eef96d95196375d8ed498/source/value-of.d.ts
|
|
10
|
+
*/
|
|
11
|
+
export type ValueOf<ObjectType, ValueType extends keyof ObjectType = keyof ObjectType> = ObjectType[ValueType];
|
|
12
|
+
/**
|
|
13
|
+
* Functions like TypeScript's native `Extract` utility type with added support
|
|
14
|
+
* to fall back to a value if the resulting union is `never`.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* ExtractOrFallback<"a" | "b", "a">; // => "a"
|
|
20
|
+
* ExtractOrFallback<"a" | "b", "c">; // => "a" | "b"
|
|
21
|
+
* ExtractOrFallback<"a" | "b", "c", "foo">; // => "foo"
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @typeParam T - The union from which values will be extracted.
|
|
25
|
+
* @typeParam U - The extraction condition.
|
|
26
|
+
* @typeParam Fallback - The value to return if the resulting union is `never`.
|
|
27
|
+
* Defaults to `T`.
|
|
28
|
+
*/
|
|
29
|
+
type ExtractOrFallback<T, U, Fallback = T> = Extract<T, U> extends never ? Fallback : Extract<T, U>;
|
|
30
|
+
/**
|
|
31
|
+
* Extracts one or more Prismic document types that match a given Prismic
|
|
32
|
+
* document type. If no matches are found, no extraction is performed and the
|
|
33
|
+
* union of all provided Prismic document types are returned.
|
|
34
|
+
*
|
|
35
|
+
* @typeParam TDocuments - Prismic document types from which to extract.
|
|
36
|
+
* @typeParam TDocumentType - Type(s) to match `TDocuments` against.
|
|
37
|
+
*/
|
|
38
|
+
export type ExtractDocumentType<TDocuments extends prismicT.PrismicDocument, TDocumentType extends TDocuments["type"]> = ExtractOrFallback<TDocuments, {
|
|
39
|
+
type: TDocumentType;
|
|
40
|
+
}>;
|
|
41
|
+
/**
|
|
42
|
+
* A universal API to make network requests. A subset of the `fetch()` API.
|
|
43
|
+
*
|
|
44
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/API/fetch}
|
|
45
|
+
*/
|
|
46
|
+
export type FetchLike = (input: string, init?: RequestInitLike) => Promise<ResponseLike>;
|
|
47
|
+
/**
|
|
48
|
+
* An object that allows you to abort a `fetch()` request if needed via an
|
|
49
|
+
* `AbortController` object
|
|
50
|
+
*
|
|
51
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal}
|
|
52
|
+
*/
|
|
53
|
+
export type AbortSignalLike = any;
|
|
54
|
+
/**
|
|
55
|
+
* The minimum required properties from RequestInit.
|
|
56
|
+
*/
|
|
57
|
+
export interface RequestInitLike {
|
|
58
|
+
headers?: Record<string, string>;
|
|
59
|
+
/**
|
|
60
|
+
* An object that allows you to abort a `fetch()` request if needed via an
|
|
61
|
+
* `AbortController` object
|
|
62
|
+
*
|
|
63
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal}
|
|
64
|
+
*/
|
|
65
|
+
signal?: AbortSignalLike;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The minimum required properties from Response.
|
|
69
|
+
*/
|
|
70
|
+
export interface ResponseLike {
|
|
71
|
+
status: number;
|
|
72
|
+
json(): Promise<any>;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The minimum required properties to treat as an HTTP Request for automatic
|
|
76
|
+
* Prismic preview support.
|
|
77
|
+
*/
|
|
78
|
+
export type HttpRequestLike = /**
|
|
79
|
+
* Web API Request
|
|
80
|
+
*
|
|
81
|
+
* @see http://developer.mozilla.org/en-US/docs/Web/API/Request
|
|
82
|
+
*/ {
|
|
83
|
+
headers?: {
|
|
84
|
+
get(name: string): string | null;
|
|
85
|
+
};
|
|
86
|
+
url?: string;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Express-style Request
|
|
90
|
+
*/
|
|
91
|
+
| {
|
|
92
|
+
headers?: {
|
|
93
|
+
cookie?: string;
|
|
94
|
+
};
|
|
95
|
+
query?: Record<string, unknown>;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* An `orderings` parameter that orders the results by the specified field.
|
|
99
|
+
*
|
|
100
|
+
* {@link https://prismic.io/docs/technologies/search-parameters-reference-rest-api#orderings}
|
|
101
|
+
*/
|
|
102
|
+
export interface Ordering {
|
|
103
|
+
field: string;
|
|
104
|
+
direction?: "asc" | "desc";
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* A `routes` parameter that determines how a document's URL field is resolved.
|
|
108
|
+
*
|
|
109
|
+
* @example With a document's UID field.
|
|
110
|
+
*
|
|
111
|
+
* ```ts
|
|
112
|
+
* {
|
|
113
|
+
* "type": "page",
|
|
114
|
+
* "path": "/:uid"
|
|
115
|
+
* }
|
|
116
|
+
* ```
|
|
117
|
+
*
|
|
118
|
+
* @example With a Content Relationship `parent` field.
|
|
119
|
+
*
|
|
120
|
+
* ```ts
|
|
121
|
+
* {
|
|
122
|
+
* "type": "page",
|
|
123
|
+
* "path": "/:parent?/:uid",
|
|
124
|
+
* "resolvers": {
|
|
125
|
+
* "parent": "parent"
|
|
126
|
+
* }
|
|
127
|
+
* }
|
|
128
|
+
* ```
|
|
129
|
+
*
|
|
130
|
+
* {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#route-resolver}
|
|
131
|
+
*/
|
|
132
|
+
export interface Route {
|
|
133
|
+
/**
|
|
134
|
+
* The Custom Type of the document.
|
|
135
|
+
*/
|
|
136
|
+
type: string;
|
|
137
|
+
/**
|
|
138
|
+
* A specific UID to which this route definition is scoped. The route is only
|
|
139
|
+
* defined for the document whose UID matches the given UID.
|
|
140
|
+
*/
|
|
141
|
+
uid?: string;
|
|
142
|
+
/**
|
|
143
|
+
* A specific language to which this route definition is scoped. The route is
|
|
144
|
+
* only defined for documents whose language matches the given language.
|
|
145
|
+
*/
|
|
146
|
+
lang?: string;
|
|
147
|
+
/**
|
|
148
|
+
* The resolved path of the document with optional placeholders.
|
|
149
|
+
*/
|
|
150
|
+
path: string;
|
|
151
|
+
/**
|
|
152
|
+
* An object that lists the API IDs of the Content Relationships in the route.
|
|
153
|
+
*/
|
|
154
|
+
resolvers?: Record<string, string>;
|
|
155
|
+
}
|
|
156
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismicio/client",
|
|
3
|
-
"version": "6.7.
|
|
3
|
+
"version": "6.7.2",
|
|
4
4
|
"description": "The official JavaScript + TypeScript client library for Prismic",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"prismic",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"src"
|
|
35
35
|
],
|
|
36
36
|
"scripts": {
|
|
37
|
-
"build": "
|
|
38
|
-
"dev": "
|
|
39
|
-
"format": "prettier --write
|
|
37
|
+
"build": "vite build",
|
|
38
|
+
"dev": "vite build --watch",
|
|
39
|
+
"format": "prettier --write .",
|
|
40
40
|
"lint": "eslint --ext .js,.ts .",
|
|
41
41
|
"prepare": "npm run build",
|
|
42
42
|
"release": "npm run build && npm run test && standard-version && git push --follow-tags && npm run build && npm publish",
|
|
@@ -49,31 +49,31 @@
|
|
|
49
49
|
"unit:watch": "vitest watch"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@prismicio/helpers": "^2.3.
|
|
53
|
-
"@prismicio/types": "^0.2.
|
|
52
|
+
"@prismicio/helpers": "^2.3.7",
|
|
53
|
+
"@prismicio/types": "^0.2.7"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@prismicio/mock": "^0.1.1",
|
|
57
|
-
"@size-limit/preset-small-lib": "^8.0
|
|
57
|
+
"@size-limit/preset-small-lib": "^8.1.0",
|
|
58
58
|
"@types/sinon": "^10.0.13",
|
|
59
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
60
|
-
"@typescript-eslint/parser": "^5.
|
|
61
|
-
"@vitest/coverage-c8": "^0.
|
|
59
|
+
"@typescript-eslint/eslint-plugin": "^5.46.1",
|
|
60
|
+
"@typescript-eslint/parser": "^5.46.1",
|
|
61
|
+
"@vitest/coverage-c8": "^0.26.0",
|
|
62
62
|
"abort-controller": "^3.0.0",
|
|
63
|
-
"eslint": "^8.
|
|
63
|
+
"eslint": "^8.30.0",
|
|
64
64
|
"eslint-config-prettier": "^8.5.0",
|
|
65
65
|
"eslint-plugin-prettier": "^4.2.1",
|
|
66
|
-
"eslint-plugin-tsdoc": "^0.2.
|
|
67
|
-
"msw": "^0.
|
|
68
|
-
"node-fetch": "^3.
|
|
69
|
-
"
|
|
70
|
-
"prettier": "^
|
|
71
|
-
"
|
|
72
|
-
"siroc": "^0.16.0",
|
|
73
|
-
"size-limit": "^8.0.1",
|
|
66
|
+
"eslint-plugin-tsdoc": "^0.2.17",
|
|
67
|
+
"msw": "^0.49.2",
|
|
68
|
+
"node-fetch": "^3.3.0",
|
|
69
|
+
"prettier": "^2.8.1",
|
|
70
|
+
"prettier-plugin-jsdoc": "^0.4.2",
|
|
71
|
+
"size-limit": "^8.1.0",
|
|
74
72
|
"standard-version": "^9.5.0",
|
|
75
|
-
"typescript": "^4.
|
|
76
|
-
"
|
|
73
|
+
"typescript": "^4.9.4",
|
|
74
|
+
"vite": "^4.0.2",
|
|
75
|
+
"vite-plugin-sdk": "^0.1.0",
|
|
76
|
+
"vitest": "^0.26.0"
|
|
77
77
|
},
|
|
78
78
|
"engines": {
|
|
79
79
|
"node": ">=12.13.0"
|
package/src/buildQueryURL.ts
CHANGED
|
@@ -33,7 +33,8 @@ export interface QueryParams {
|
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* The `after` parameter can be used along with the orderings option. It will
|
|
36
|
-
* remove all the documents except for those after the specified document in
|
|
36
|
+
* remove all the documents except for those after the specified document in
|
|
37
|
+
* the list.
|
|
37
38
|
*
|
|
38
39
|
* {@link https://prismic.io/docs/technologies/search-parameters-reference-rest-api#after}
|
|
39
40
|
*/
|
|
@@ -57,7 +58,8 @@ export interface QueryParams {
|
|
|
57
58
|
|
|
58
59
|
/**
|
|
59
60
|
* The `graphQuery` parameter allows you to specify which fields to retrieve
|
|
60
|
-
* and what content to retrieve from Linked Documents / Content
|
|
61
|
+
* and what content to retrieve from Linked Documents / Content
|
|
62
|
+
* Relationships.
|
|
61
63
|
*
|
|
62
64
|
* {@link https://prismic.io/docs/technologies/graphquery-rest-api}
|
|
63
65
|
*/
|
|
@@ -79,7 +81,8 @@ export interface QueryParams {
|
|
|
79
81
|
orderings?: Ordering | string | (Ordering | string)[];
|
|
80
82
|
|
|
81
83
|
/**
|
|
82
|
-
* The `routes` option allows you to define how a document's `url` field is
|
|
84
|
+
* The `routes` option allows you to define how a document's `url` field is
|
|
85
|
+
* resolved.
|
|
83
86
|
*
|
|
84
87
|
* {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#route-resolver}
|
|
85
88
|
*/
|
package/src/client.ts
CHANGED
|
@@ -351,7 +351,8 @@ export class Client<
|
|
|
351
351
|
>;
|
|
352
352
|
|
|
353
353
|
/**
|
|
354
|
-
* The client's ref mode state. This determines which ref is used during
|
|
354
|
+
* The client's ref mode state. This determines which ref is used during
|
|
355
|
+
* queries.
|
|
355
356
|
*/
|
|
356
357
|
private refState: RefState = {
|
|
357
358
|
mode: RefStateMode.Master,
|
|
@@ -431,7 +432,8 @@ export class Client<
|
|
|
431
432
|
|
|
432
433
|
/**
|
|
433
434
|
* Enables the client to automatically query content from a preview session if
|
|
434
|
-
* one is active in browser environments. This is enabled by default in the
|
|
435
|
+
* one is active in browser environments. This is enabled by default in the
|
|
436
|
+
* browser.
|
|
435
437
|
*
|
|
436
438
|
* For server environments, use `enableAutoPreviewsFromReq`.
|
|
437
439
|
*
|
|
@@ -449,7 +451,8 @@ export class Client<
|
|
|
449
451
|
|
|
450
452
|
/**
|
|
451
453
|
* Enables the client to automatically query content from a preview session if
|
|
452
|
-
* one is active in server environments. This is disabled by default on the
|
|
454
|
+
* one is active in server environments. This is disabled by default on the
|
|
455
|
+
* server.
|
|
453
456
|
*
|
|
454
457
|
* For browser environments, use `enableAutoPreviews`.
|
|
455
458
|
*
|
|
@@ -462,7 +465,8 @@ export class Client<
|
|
|
462
465
|
* });
|
|
463
466
|
* ```
|
|
464
467
|
*
|
|
465
|
-
* @param req - An HTTP server request object containing the request's
|
|
468
|
+
* @param req - An HTTP server request object containing the request's
|
|
469
|
+
* cookies.
|
|
466
470
|
*/
|
|
467
471
|
enableAutoPreviewsFromReq<R extends HttpRequestLike>(req: R): void {
|
|
468
472
|
this.refState.httpRequest = req;
|
|
@@ -575,7 +579,8 @@ export class Client<
|
|
|
575
579
|
* Queries content from the Prismic repository and returns all matching
|
|
576
580
|
* content. If no predicates are provided, all documents will be fetched.
|
|
577
581
|
*
|
|
578
|
-
* This method may make multiple network requests to query all matching
|
|
582
|
+
* This method may make multiple network requests to query all matching
|
|
583
|
+
* content.
|
|
579
584
|
*
|
|
580
585
|
* @example
|
|
581
586
|
*
|
|
@@ -628,7 +633,8 @@ export class Client<
|
|
|
628
633
|
* @remarks
|
|
629
634
|
* A document's UID is different from its ID. An ID is automatically generated
|
|
630
635
|
* for all documents and is made available on its `id` property. A UID is
|
|
631
|
-
* provided in the Prismic editor and is unique among all documents of its
|
|
636
|
+
* provided in the Prismic editor and is unique among all documents of its
|
|
637
|
+
* Custom Type.
|
|
632
638
|
* @example
|
|
633
639
|
*
|
|
634
640
|
* ```ts
|
|
@@ -657,7 +663,8 @@ export class Client<
|
|
|
657
663
|
* @remarks
|
|
658
664
|
* A document's UID is different from its ID. An ID is automatically generated
|
|
659
665
|
* for all documents and is made available on its `id` property. A UID is
|
|
660
|
-
* provided in the Prismic editor and is unique among all documents of its
|
|
666
|
+
* provided in the Prismic editor and is unique among all documents of its
|
|
667
|
+
* Custom Type.
|
|
661
668
|
* @example
|
|
662
669
|
*
|
|
663
670
|
* ```ts
|
|
@@ -686,12 +693,14 @@ export class Client<
|
|
|
686
693
|
/**
|
|
687
694
|
* Queries all documents from the Prismic repository with specific IDs.
|
|
688
695
|
*
|
|
689
|
-
* This method may make multiple network requests to query all matching
|
|
696
|
+
* This method may make multiple network requests to query all matching
|
|
697
|
+
* content.
|
|
690
698
|
*
|
|
691
699
|
* @remarks
|
|
692
700
|
* A document's UID is different from its ID. An ID is automatically generated
|
|
693
701
|
* for all documents and is made available on its `id` property. A UID is
|
|
694
|
-
* provided in the Prismic editor and is unique among all documents of its
|
|
702
|
+
* provided in the Prismic editor and is unique among all documents of its
|
|
703
|
+
* Custom Type.
|
|
695
704
|
* @example
|
|
696
705
|
*
|
|
697
706
|
* ```ts
|
|
@@ -717,12 +726,14 @@ export class Client<
|
|
|
717
726
|
}
|
|
718
727
|
|
|
719
728
|
/**
|
|
720
|
-
* Queries a document from the Prismic repository with a specific UID and
|
|
729
|
+
* Queries a document from the Prismic repository with a specific UID and
|
|
730
|
+
* Custom Type.
|
|
721
731
|
*
|
|
722
732
|
* @remarks
|
|
723
733
|
* A document's UID is different from its ID. An ID is automatically generated
|
|
724
734
|
* for all documents and is made available on its `id` property. A UID is
|
|
725
|
-
* provided in the Prismic editor and is unique among all documents of its
|
|
735
|
+
* provided in the Prismic editor and is unique among all documents of its
|
|
736
|
+
* Custom Type.
|
|
726
737
|
* @example
|
|
727
738
|
*
|
|
728
739
|
* ```ts
|
|
@@ -754,12 +765,14 @@ export class Client<
|
|
|
754
765
|
}
|
|
755
766
|
|
|
756
767
|
/**
|
|
757
|
-
* Queries document from the Prismic repository with specific UIDs and Custom
|
|
768
|
+
* Queries document from the Prismic repository with specific UIDs and Custom
|
|
769
|
+
* Type.
|
|
758
770
|
*
|
|
759
771
|
* @remarks
|
|
760
772
|
* A document's UID is different from its ID. An ID is automatically generated
|
|
761
773
|
* for all documents and is made available on its `id` property. A UID is
|
|
762
|
-
* provided in the Prismic editor and is unique among all documents of its
|
|
774
|
+
* provided in the Prismic editor and is unique among all documents of its
|
|
775
|
+
* Custom Type.
|
|
763
776
|
* @example
|
|
764
777
|
*
|
|
765
778
|
* ```ts
|
|
@@ -794,14 +807,17 @@ export class Client<
|
|
|
794
807
|
}
|
|
795
808
|
|
|
796
809
|
/**
|
|
797
|
-
* Queries all documents from the Prismic repository with specific UIDs and
|
|
810
|
+
* Queries all documents from the Prismic repository with specific UIDs and
|
|
811
|
+
* Custom Type.
|
|
798
812
|
*
|
|
799
|
-
* This method may make multiple network requests to query all matching
|
|
813
|
+
* This method may make multiple network requests to query all matching
|
|
814
|
+
* content.
|
|
800
815
|
*
|
|
801
816
|
* @remarks
|
|
802
817
|
* A document's UID is different from its ID. An ID is automatically generated
|
|
803
818
|
* for all documents and is made available on its `id` property. A UID is
|
|
804
|
-
* provided in the Prismic editor and is unique among all documents of its
|
|
819
|
+
* provided in the Prismic editor and is unique among all documents of its
|
|
820
|
+
* Custom Type.
|
|
805
821
|
* @example
|
|
806
822
|
*
|
|
807
823
|
* ```ts
|
|
@@ -837,7 +853,8 @@ export class Client<
|
|
|
837
853
|
}
|
|
838
854
|
|
|
839
855
|
/**
|
|
840
|
-
* Queries a singleton document from the Prismic repository for a specific
|
|
856
|
+
* Queries a singleton document from the Prismic repository for a specific
|
|
857
|
+
* Custom Type.
|
|
841
858
|
*
|
|
842
859
|
* @remarks
|
|
843
860
|
* A singleton document is one that is configured in Prismic to only allow one
|
|
@@ -854,7 +871,8 @@ export class Client<
|
|
|
854
871
|
* @param documentType - The API ID of the singleton Custom Type.
|
|
855
872
|
* @param params - Parameters to filter, sort, and paginate the results.
|
|
856
873
|
*
|
|
857
|
-
* @returns The singleton document for the Custom Type, if a matching document
|
|
874
|
+
* @returns The singleton document for the Custom Type, if a matching document
|
|
875
|
+
* exists.
|
|
858
876
|
*/
|
|
859
877
|
async getSingle<
|
|
860
878
|
TDocument extends TDocuments,
|
|
@@ -899,9 +917,11 @@ export class Client<
|
|
|
899
917
|
}
|
|
900
918
|
|
|
901
919
|
/**
|
|
902
|
-
* Queries all documents from the Prismic repository for a specific Custom
|
|
920
|
+
* Queries all documents from the Prismic repository for a specific Custom
|
|
921
|
+
* Type.
|
|
903
922
|
*
|
|
904
|
-
* This method may make multiple network requests to query all matching
|
|
923
|
+
* This method may make multiple network requests to query all matching
|
|
924
|
+
* content.
|
|
905
925
|
*
|
|
906
926
|
* @example
|
|
907
927
|
*
|
|
@@ -932,7 +952,8 @@ export class Client<
|
|
|
932
952
|
/**
|
|
933
953
|
* Queries documents from the Prismic repository with a specific tag.
|
|
934
954
|
*
|
|
935
|
-
* Use `getAllByTag` instead if you need to query all documents with a
|
|
955
|
+
* Use `getAllByTag` instead if you need to query all documents with a
|
|
956
|
+
* specific tag.
|
|
936
957
|
*
|
|
937
958
|
* @example
|
|
938
959
|
*
|
|
@@ -958,7 +979,8 @@ export class Client<
|
|
|
958
979
|
/**
|
|
959
980
|
* Queries all documents from the Prismic repository with a specific tag.
|
|
960
981
|
*
|
|
961
|
-
* This method may make multiple network requests to query all matching
|
|
982
|
+
* This method may make multiple network requests to query all matching
|
|
983
|
+
* content.
|
|
962
984
|
*
|
|
963
985
|
* @example
|
|
964
986
|
*
|
|
@@ -1012,7 +1034,8 @@ export class Client<
|
|
|
1012
1034
|
* Queries documents from the Prismic repository with specific tags. A
|
|
1013
1035
|
* document must be tagged with all of the queried tags to be included.
|
|
1014
1036
|
*
|
|
1015
|
-
* This method may make multiple network requests to query all matching
|
|
1037
|
+
* This method may make multiple network requests to query all matching
|
|
1038
|
+
* content.
|
|
1016
1039
|
*
|
|
1017
1040
|
* @example
|
|
1018
1041
|
*
|
|
@@ -1039,7 +1062,8 @@ export class Client<
|
|
|
1039
1062
|
|
|
1040
1063
|
/**
|
|
1041
1064
|
* Queries documents from the Prismic repository with specific tags. A
|
|
1042
|
-
* document must be tagged with at least one of the queried tags to be
|
|
1065
|
+
* document must be tagged with at least one of the queried tags to be
|
|
1066
|
+
* included.
|
|
1043
1067
|
*
|
|
1044
1068
|
* @example
|
|
1045
1069
|
*
|
|
@@ -1051,7 +1075,8 @@ export class Client<
|
|
|
1051
1075
|
* @param tags - A list of tags that must be included on a document.
|
|
1052
1076
|
* @param params - Parameters to filter, sort, and paginate the results.
|
|
1053
1077
|
*
|
|
1054
|
-
* @returns A paginated response containing documents with at least one of the
|
|
1078
|
+
* @returns A paginated response containing documents with at least one of the
|
|
1079
|
+
* tags.
|
|
1055
1080
|
*/
|
|
1056
1081
|
async getBySomeTags<TDocument extends TDocuments>(
|
|
1057
1082
|
tags: string[],
|
|
@@ -1064,14 +1089,16 @@ export class Client<
|
|
|
1064
1089
|
|
|
1065
1090
|
/**
|
|
1066
1091
|
* Queries documents from the Prismic repository with specific tags. A
|
|
1067
|
-
* document must be tagged with at least one of the queried tags to be
|
|
1092
|
+
* document must be tagged with at least one of the queried tags to be
|
|
1093
|
+
* included.
|
|
1068
1094
|
*
|
|
1069
|
-
* This method may make multiple network requests to query all matching
|
|
1095
|
+
* This method may make multiple network requests to query all matching
|
|
1096
|
+
* content.
|
|
1070
1097
|
*
|
|
1071
1098
|
* @example
|
|
1072
1099
|
*
|
|
1073
1100
|
* ```ts
|
|
1074
|
-
* const response = await client.
|
|
1101
|
+
* const response = await client.getAllBySomeTags(["food", "fruit"]);
|
|
1075
1102
|
* ```
|
|
1076
1103
|
*
|
|
1077
1104
|
* @typeParam TDocument - Type of Prismic documents returned.
|
|
@@ -1327,9 +1354,11 @@ export class Client<
|
|
|
1327
1354
|
}
|
|
1328
1355
|
|
|
1329
1356
|
/**
|
|
1330
|
-
* Configures the client to query the latest published content for all future
|
|
1357
|
+
* Configures the client to query the latest published content for all future
|
|
1358
|
+
* queries.
|
|
1331
1359
|
*
|
|
1332
|
-
* If the `ref` parameter is provided during a query, it takes priority for
|
|
1360
|
+
* If the `ref` parameter is provided during a query, it takes priority for
|
|
1361
|
+
* that query.
|
|
1333
1362
|
*
|
|
1334
1363
|
* @example
|
|
1335
1364
|
*
|
|
@@ -1346,7 +1375,8 @@ export class Client<
|
|
|
1346
1375
|
* Configures the client to query content from a specific Release identified
|
|
1347
1376
|
* by its ID for all future queries.
|
|
1348
1377
|
*
|
|
1349
|
-
* If the `ref` parameter is provided during a query, it takes priority for
|
|
1378
|
+
* If the `ref` parameter is provided during a query, it takes priority for
|
|
1379
|
+
* that query.
|
|
1350
1380
|
*
|
|
1351
1381
|
* @example
|
|
1352
1382
|
*
|
|
@@ -1369,7 +1399,8 @@ export class Client<
|
|
|
1369
1399
|
* Configures the client to query content from a specific Release identified
|
|
1370
1400
|
* by its label for all future queries.
|
|
1371
1401
|
*
|
|
1372
|
-
* If the `ref` parameter is provided during a query, it takes priority for
|
|
1402
|
+
* If the `ref` parameter is provided during a query, it takes priority for
|
|
1403
|
+
* that query.
|
|
1373
1404
|
*
|
|
1374
1405
|
* @example
|
|
1375
1406
|
*
|
|
@@ -1402,7 +1433,8 @@ export class Client<
|
|
|
1402
1433
|
* const document = await client.getByID("WW4bKScAAMAqmluX");
|
|
1403
1434
|
* ```
|
|
1404
1435
|
*
|
|
1405
|
-
* @param ref - The ref or a function that returns the ref from which to query
|
|
1436
|
+
* @param ref - The ref or a function that returns the ref from which to query
|
|
1437
|
+
* content.
|
|
1406
1438
|
*/
|
|
1407
1439
|
queryContentFromRef(ref: RefStringOrThunk): void {
|
|
1408
1440
|
this.refState = {
|
|
@@ -1440,7 +1472,8 @@ export class Client<
|
|
|
1440
1472
|
* ```
|
|
1441
1473
|
*
|
|
1442
1474
|
* @param input - The `fetch()` `input` parameter. Only strings are supported.
|
|
1443
|
-
* @param init - The `fetch()` `init` parameter. Only plain objects are
|
|
1475
|
+
* @param init - The `fetch()` `init` parameter. Only plain objects are
|
|
1476
|
+
* supported.
|
|
1444
1477
|
*
|
|
1445
1478
|
* @returns The `fetch()` Response for the request.
|
|
1446
1479
|
* @experimental
|
|
@@ -1561,14 +1594,16 @@ export class Client<
|
|
|
1561
1594
|
|
|
1562
1595
|
/**
|
|
1563
1596
|
* Returns the ref needed to query based on the client's current state. This
|
|
1564
|
-
* method may make a network request to fetch a ref or resolve the user's ref
|
|
1597
|
+
* method may make a network request to fetch a ref or resolve the user's ref
|
|
1598
|
+
* thunk.
|
|
1565
1599
|
*
|
|
1566
1600
|
* If auto previews are enabled, the preview ref takes priority if available.
|
|
1567
1601
|
*
|
|
1568
1602
|
* The following strategies are used depending on the client's state:
|
|
1569
1603
|
*
|
|
1570
1604
|
* - If the user called `queryLatestContent`: Use the repository's master ref.
|
|
1571
|
-
* The ref is cached for 5 seconds. After 5 seconds, a new master ref is
|
|
1605
|
+
* The ref is cached for 5 seconds. After 5 seconds, a new master ref is
|
|
1606
|
+
* fetched.
|
|
1572
1607
|
* - If the user called `queryContentFromReleaseByID`: Use the release's ref.
|
|
1573
1608
|
* The ref is cached for 5 seconds. After 5 seconds, a new ref for the
|
|
1574
1609
|
* release is fetched.
|
package/src/cookie.ts
CHANGED
package/src/getRepositoryName.ts
CHANGED
|
@@ -4,11 +4,13 @@ import { PrismicError } from "./PrismicError";
|
|
|
4
4
|
* Get a Prismic repository's name from its standard Prismic Rest API V2 or
|
|
5
5
|
* GraphQL endpoint.
|
|
6
6
|
*
|
|
7
|
-
* @typeParam RepositoryEndpoint - Prismic Rest API V2 endpoint for the
|
|
7
|
+
* @typeParam RepositoryEndpoint - Prismic Rest API V2 endpoint for the
|
|
8
|
+
* repository.
|
|
8
9
|
* @param repositoryEndpoint - Prismic Rest API V2 endpoint for the repository.
|
|
9
10
|
*
|
|
10
11
|
* @returns The Prismic repository's name.
|
|
11
|
-
* @throws {@link Error} Thrown if an invalid Prismic Rest API V2 endpoint is
|
|
12
|
+
* @throws {@link Error} Thrown if an invalid Prismic Rest API V2 endpoint is
|
|
13
|
+
* provided.
|
|
12
14
|
*/
|
|
13
15
|
export const getRepositoryName = (repositoryEndpoint: string): string => {
|
|
14
16
|
try {
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @param input - Input to test.
|
|
6
6
|
*
|
|
7
|
-
* @returns `true` if `input` is a valid Prismic Rest API V2 endpoint, `false`
|
|
7
|
+
* @returns `true` if `input` is a valid Prismic Rest API V2 endpoint, `false`
|
|
8
|
+
* otherwise.
|
|
8
9
|
*/
|
|
9
10
|
export const isRepositoryEndpoint = (input: string): boolean => {
|
|
10
11
|
try {
|
package/src/isRepositoryName.ts
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @param input - Input to test.
|
|
5
5
|
*
|
|
6
|
-
* @returns `true` if `input` is a valid Prismic repository name, `false`
|
|
6
|
+
* @returns `true` if `input` is a valid Prismic repository name, `false`
|
|
7
|
+
* otherwise.
|
|
7
8
|
*/
|
|
8
9
|
export const isRepositoryName = (input: string): boolean => {
|
|
9
10
|
return /^[a-zA-Z0-9][-a-zA-Z0-9]{2,}[a-zA-Z0-9]$/.test(input);
|
|
@@ -9,7 +9,8 @@ interface WithPredicates {
|
|
|
9
9
|
* Appended predicates are added to the end of the existing list.
|
|
10
10
|
*
|
|
11
11
|
* @typeParam T - Object to which predicates will be append.
|
|
12
|
-
* @param objWithPredicates - Object to append predicates on the `predicates`
|
|
12
|
+
* @param objWithPredicates - Object to append predicates on the `predicates`
|
|
13
|
+
* property.
|
|
13
14
|
* @param predicates - One or more predicates to append.
|
|
14
15
|
*
|
|
15
16
|
* @returns The object with the appended predicates.
|
|
@@ -7,7 +7,8 @@ const readValue = (value: string): string => {
|
|
|
7
7
|
/**
|
|
8
8
|
* Returns the value of a cookie from a given cookie store.
|
|
9
9
|
*
|
|
10
|
-
* @param cookieJar - The stringified cookie store from which to read the
|
|
10
|
+
* @param cookieJar - The stringified cookie store from which to read the
|
|
11
|
+
* cookie.
|
|
11
12
|
*
|
|
12
13
|
* @returns The value of the cookie, if it exists.
|
|
13
14
|
*/
|
package/src/predicate.ts
CHANGED
|
@@ -30,7 +30,8 @@ const formatValue = (
|
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
|
-
* Creates a predicate builder function for predicates with a path and
|
|
33
|
+
* Creates a predicate builder function for predicates with a path and
|
|
34
|
+
* arguments.
|
|
34
35
|
*
|
|
35
36
|
* @typeParam Args - Arguments for the predicate.
|
|
36
37
|
* @param name - Name of the predicate used in the resulting string.
|
|
@@ -72,7 +73,8 @@ const pathPredicate = (name: string) => {
|
|
|
72
73
|
};
|
|
73
74
|
|
|
74
75
|
/**
|
|
75
|
-
* Creates a predicate builder function for predicates with only arguments and
|
|
76
|
+
* Creates a predicate builder function for predicates with only arguments and
|
|
77
|
+
* no path.
|
|
76
78
|
*
|
|
77
79
|
* @param name - Name of the predicate used in the resulting string.
|
|
78
80
|
*
|
package/src/types.ts
CHANGED
|
@@ -21,9 +21,9 @@ export type ValueOf<
|
|
|
21
21
|
* @example
|
|
22
22
|
*
|
|
23
23
|
* ```ts
|
|
24
|
-
* ExtractOrFallback<"a" | "b", "a"
|
|
25
|
-
* ExtractOrFallback<"a" | "b", "c"
|
|
26
|
-
* ExtractOrFallback<"a" | "b", "c", "foo"
|
|
24
|
+
* ExtractOrFallback<"a" | "b", "a">; // => "a"
|
|
25
|
+
* ExtractOrFallback<"a" | "b", "c">; // => "a" | "b"
|
|
26
|
+
* ExtractOrFallback<"a" | "b", "c", "foo">; // => "foo"
|
|
27
27
|
* ```
|
|
28
28
|
*
|
|
29
29
|
* @typeParam T - The union from which values will be extracted.
|