@prismicio/client 7.22.2 → 7.22.3-canary.15d0e36
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 +3 -1
- package/dist/Client.cjs.map +1 -1
- package/dist/Client.d.cts +1 -0
- package/dist/Client.d.cts.map +1 -1
- package/dist/Client.d.ts +1 -0
- package/dist/Client.d.ts.map +1 -1
- package/dist/Client.js +3 -1
- package/dist/Client.js.map +1 -1
- package/dist/Migration.d.cts +1 -0
- package/dist/Migration.d.ts +1 -0
- package/dist/WriteClient.d.cts +1 -0
- package/dist/WriteClient.d.ts +1 -0
- package/dist/buildQueryURL.d.cts +1 -0
- package/dist/buildQueryURL.d.ts +1 -0
- package/dist/cookie.cjs +7 -1
- package/dist/cookie.cjs.map +1 -1
- package/dist/cookie.d.cts +3 -1
- package/dist/cookie.d.cts.map +1 -1
- package/dist/cookie.d.ts +3 -1
- package/dist/cookie.d.ts.map +1 -1
- package/dist/cookie.js +7 -2
- package/dist/cookie.js.map +1 -1
- package/dist/errors.d.cts +1 -0
- package/dist/errors.d.ts +1 -0
- package/dist/getToolbarSrc.cjs +8 -3
- package/dist/getToolbarSrc.cjs.map +1 -1
- package/dist/getToolbarSrc.d.cts +10 -1
- package/dist/getToolbarSrc.d.cts.map +1 -1
- package/dist/getToolbarSrc.d.ts +10 -1
- package/dist/getToolbarSrc.d.ts.map +1 -1
- package/dist/getToolbarSrc.js +8 -3
- package/dist/getToolbarSrc.js.map +1 -1
- package/dist/helpers/asDate.d.cts +1 -0
- package/dist/helpers/asDate.d.ts +1 -0
- package/dist/helpers/asHTML.d.cts +1 -0
- package/dist/helpers/asHTML.d.ts +1 -0
- package/dist/helpers/asImagePixelDensitySrcSet.d.cts +1 -0
- package/dist/helpers/asImagePixelDensitySrcSet.d.ts +1 -0
- package/dist/helpers/asImageSrc.d.cts +1 -0
- package/dist/helpers/asImageSrc.d.ts +1 -0
- package/dist/helpers/asImageWidthSrcSet.d.cts +1 -0
- package/dist/helpers/asImageWidthSrcSet.d.ts +1 -0
- package/dist/helpers/asLink.d.cts +1 -0
- package/dist/helpers/asLink.d.ts +1 -0
- package/dist/helpers/asLinkAttrs.d.cts +1 -0
- package/dist/helpers/asLinkAttrs.d.ts +1 -0
- package/dist/helpers/asText.d.cts +1 -0
- package/dist/helpers/asText.d.ts +1 -0
- package/dist/helpers/documentToLinkField.d.cts +1 -0
- package/dist/helpers/documentToLinkField.d.ts +1 -0
- package/dist/helpers/mapSliceZone.d.cts +1 -0
- package/dist/helpers/mapSliceZone.d.ts +1 -0
- package/dist/package.cjs +1 -1
- package/dist/package.js +1 -1
- package/dist/types/migration/ContentRelationship.d.cts +1 -0
- package/dist/types/migration/ContentRelationship.d.ts +1 -0
- package/dist/types/migration/Document.d.cts +1 -0
- package/dist/types/migration/Document.d.ts +1 -0
- package/dist/types/value/embed.d.cts +1 -0
- package/dist/types/value/embed.d.ts +1 -0
- package/dist/types/value/linkToMedia.d.cts +1 -0
- package/dist/types/value/linkToMedia.d.ts +1 -0
- package/dist/types/value/types.d.cts +1 -0
- package/dist/types/value/types.d.ts +1 -0
- package/dist/types/webhook/apiUpdate.d.cts +1 -0
- package/dist/types/webhook/apiUpdate.d.ts +1 -0
- package/package.json +7 -7
- package/src/Client.ts +7 -1
- package/src/cookie.ts +3 -0
- package/src/getToolbarSrc.ts +18 -4
|
@@ -43,4 +43,5 @@ type AsImagePixelDensitySrcSetReturnType<Field extends ImageFieldImage | null |
|
|
|
43
43
|
*/
|
|
44
44
|
export declare const asImagePixelDensitySrcSet: <Field extends ImageFieldImage | null | undefined>(field: Field, config?: AsImagePixelDensitySrcSetConfig) => AsImagePixelDensitySrcSetReturnType<Field>;
|
|
45
45
|
//#endregion
|
|
46
|
+
export {};
|
|
46
47
|
//# sourceMappingURL=asImagePixelDensitySrcSet.d.ts.map
|
|
@@ -21,4 +21,5 @@ type AsImageSrcReturnType<Field extends ImageFieldImage | null | undefined> = Fi
|
|
|
21
21
|
*/
|
|
22
22
|
export declare const asImageSrc: <Field extends ImageFieldImage | null | undefined>(field: Field, config?: ImgixURLParams) => AsImageSrcReturnType<Field>;
|
|
23
23
|
//#endregion
|
|
24
|
+
export {};
|
|
24
25
|
//# sourceMappingURL=asImageSrc.d.cts.map
|
|
@@ -21,4 +21,5 @@ type AsImageSrcReturnType<Field extends ImageFieldImage | null | undefined> = Fi
|
|
|
21
21
|
*/
|
|
22
22
|
export declare const asImageSrc: <Field extends ImageFieldImage | null | undefined>(field: Field, config?: ImgixURLParams) => AsImageSrcReturnType<Field>;
|
|
23
23
|
//#endregion
|
|
24
|
+
export {};
|
|
24
25
|
//# sourceMappingURL=asImageSrc.d.ts.map
|
|
@@ -50,4 +50,5 @@ type AsImageWidthSrcSetConfig = Omit<BuildWidthSrcSetParams, "widths"> & {
|
|
|
50
50
|
*/
|
|
51
51
|
export declare const asImageWidthSrcSet: <Field extends ImageFieldImage | null | undefined>(field: Field, config?: AsImageWidthSrcSetConfig) => AsImageWidthSrcSetReturnType<Field>;
|
|
52
52
|
//#endregion
|
|
53
|
+
export {};
|
|
53
54
|
//# sourceMappingURL=asImageWidthSrcSet.d.cts.map
|
|
@@ -50,4 +50,5 @@ type AsImageWidthSrcSetConfig = Omit<BuildWidthSrcSetParams, "widths"> & {
|
|
|
50
50
|
*/
|
|
51
51
|
export declare const asImageWidthSrcSet: <Field extends ImageFieldImage | null | undefined>(field: Field, config?: AsImageWidthSrcSetConfig) => AsImageWidthSrcSetReturnType<Field>;
|
|
52
52
|
//#endregion
|
|
53
|
+
export {};
|
|
53
54
|
//# sourceMappingURL=asImageWidthSrcSet.d.ts.map
|
|
@@ -60,4 +60,5 @@ export declare const asLink: {
|
|
|
60
60
|
<LinkResolverFunctionReturnType = string | null | undefined, Field extends LinkField | PrismicDocument | null | undefined = LinkField | PrismicDocument | null | undefined>(linkFieldOrDocument: Field, ...config: AsLinkDeprecatedTupleConfig<LinkResolverFunctionReturnType>): AsLinkReturnType<LinkResolverFunctionReturnType, Field>;
|
|
61
61
|
};
|
|
62
62
|
//#endregion
|
|
63
|
+
export {};
|
|
63
64
|
//# sourceMappingURL=asLink.d.cts.map
|
package/dist/helpers/asLink.d.ts
CHANGED
|
@@ -60,4 +60,5 @@ export declare const asLink: {
|
|
|
60
60
|
<LinkResolverFunctionReturnType = string | null | undefined, Field extends LinkField | PrismicDocument | null | undefined = LinkField | PrismicDocument | null | undefined>(linkFieldOrDocument: Field, ...config: AsLinkDeprecatedTupleConfig<LinkResolverFunctionReturnType>): AsLinkReturnType<LinkResolverFunctionReturnType, Field>;
|
|
61
61
|
};
|
|
62
62
|
//#endregion
|
|
63
|
+
export {};
|
|
63
64
|
//# sourceMappingURL=asLink.d.ts.map
|
|
@@ -41,4 +41,5 @@ type AsLinkAttrsReturnType<LinkResolverFunctionReturnType = ReturnType<LinkResol
|
|
|
41
41
|
*/
|
|
42
42
|
export declare const asLinkAttrs: <LinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>, Field extends LinkField | PrismicDocument | null | undefined = LinkField | PrismicDocument | null | undefined>(linkFieldOrDocument: Field, config?: AsLinkAttrsConfig<LinkResolverFunctionReturnType>) => AsLinkAttrsReturnType<LinkResolverFunctionReturnType>;
|
|
43
43
|
//#endregion
|
|
44
|
+
export {};
|
|
44
45
|
//# sourceMappingURL=asLinkAttrs.d.cts.map
|
|
@@ -41,4 +41,5 @@ type AsLinkAttrsReturnType<LinkResolverFunctionReturnType = ReturnType<LinkResol
|
|
|
41
41
|
*/
|
|
42
42
|
export declare const asLinkAttrs: <LinkResolverFunctionReturnType = ReturnType<LinkResolverFunction>, Field extends LinkField | PrismicDocument | null | undefined = LinkField | PrismicDocument | null | undefined>(linkFieldOrDocument: Field, config?: AsLinkAttrsConfig<LinkResolverFunctionReturnType>) => AsLinkAttrsReturnType<LinkResolverFunctionReturnType>;
|
|
43
43
|
//#endregion
|
|
44
|
+
export {};
|
|
44
45
|
//# sourceMappingURL=asLinkAttrs.d.ts.map
|
package/dist/helpers/asText.d.ts
CHANGED
|
@@ -12,4 +12,5 @@ type SetOptional<T, Keys extends keyof T> = Omit<T, Keys> & Partial<Pick<T, Keys
|
|
|
12
12
|
*/
|
|
13
13
|
export declare const documentToLinkField: <TDocument extends SetOptional<PrismicDocument, "slugs">>(prismicDocument: TDocument) => FilledContentRelationshipField<TDocument["type"], TDocument["lang"], TDocument["data"]>;
|
|
14
14
|
//#endregion
|
|
15
|
+
export {};
|
|
15
16
|
//# sourceMappingURL=documentToLinkField.d.cts.map
|
|
@@ -12,4 +12,5 @@ type SetOptional<T, Keys extends keyof T> = Omit<T, Keys> & Partial<Pick<T, Keys
|
|
|
12
12
|
*/
|
|
13
13
|
export declare const documentToLinkField: <TDocument extends SetOptional<PrismicDocument, "slugs">>(prismicDocument: TDocument) => FilledContentRelationshipField<TDocument["type"], TDocument["lang"], TDocument["data"]>;
|
|
14
14
|
//#endregion
|
|
15
|
+
export {};
|
|
15
16
|
//# sourceMappingURL=documentToLinkField.d.ts.map
|
|
@@ -109,4 +109,5 @@ type MapSliceLike<TSliceLike extends SliceLike<any>, TSliceMappers extends Slice
|
|
|
109
109
|
*/
|
|
110
110
|
export declare function mapSliceZone<TSliceLike extends SliceLike, TSliceMappers extends SliceMappers<TSliceLike, TContext>, TContext = unknown>(sliceZone: SliceZoneLike<TSliceLike>, mappers: TSliceMappers, context?: TContext): Promise<MapSliceLike<TSliceLike, TSliceMappers>[]>;
|
|
111
111
|
//#endregion
|
|
112
|
+
export {};
|
|
112
113
|
//# sourceMappingURL=mapSliceZone.d.cts.map
|
|
@@ -109,4 +109,5 @@ type MapSliceLike<TSliceLike extends SliceLike<any>, TSliceMappers extends Slice
|
|
|
109
109
|
*/
|
|
110
110
|
export declare function mapSliceZone<TSliceLike extends SliceLike, TSliceMappers extends SliceMappers<TSliceLike, TContext>, TContext = unknown>(sliceZone: SliceZoneLike<TSliceLike>, mappers: TSliceMappers, context?: TContext): Promise<MapSliceLike<TSliceLike, TSliceMappers>[]>;
|
|
111
111
|
//#endregion
|
|
112
|
+
export {};
|
|
112
113
|
//# sourceMappingURL=mapSliceZone.d.ts.map
|
package/dist/package.cjs
CHANGED
package/dist/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismicio/client",
|
|
3
|
-
"version": "7.22.
|
|
3
|
+
"version": "7.22.3-canary.15d0e36",
|
|
4
4
|
"description": "The official JavaScript + TypeScript client library for Prismic",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"client",
|
|
@@ -70,13 +70,13 @@
|
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@prismicio/e2e-tests-utils": "^1.20.0",
|
|
72
72
|
"@prismicio/types-internal": "^3.17.2",
|
|
73
|
-
"@types/node": "^26.6.
|
|
74
|
-
"@vitest/coverage-v8": "^5.0.
|
|
75
|
-
"oxfmt": "^0.
|
|
76
|
-
"oxlint": "^1.
|
|
77
|
-
"tsdown": "^0.23.
|
|
73
|
+
"@types/node": "^26.6.5",
|
|
74
|
+
"@vitest/coverage-v8": "^5.0.5",
|
|
75
|
+
"oxfmt": "^0.73.0",
|
|
76
|
+
"oxlint": "^1.88.0",
|
|
77
|
+
"tsdown": "^0.23.1",
|
|
78
78
|
"typescript": "^7.0.2",
|
|
79
|
-
"vitest": "^5.0.
|
|
79
|
+
"vitest": "^5.0.5"
|
|
80
80
|
},
|
|
81
81
|
"engines": {
|
|
82
82
|
"node": ">=22"
|
package/src/Client.ts
CHANGED
|
@@ -457,11 +457,17 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
457
457
|
while ((!latestResult || latestResult.next_page) && documents.length < limit) {
|
|
458
458
|
const page = latestResult ? latestResult.page + 1 : undefined
|
|
459
459
|
|
|
460
|
+
const requestedAt = Date.now()
|
|
460
461
|
const response = await this.#internalGet({ ...resolvedParams, page })
|
|
461
462
|
latestResult = (await response.json()) as Query<TDocument>
|
|
462
463
|
documents.push(...latestResult.results)
|
|
463
464
|
|
|
464
|
-
|
|
465
|
+
// Caches (CDN, Next.js Data Cache) replay the origin's `Date` header, even
|
|
466
|
+
// when they also replay an `x-cache: Miss`. The margin covers clock skew.
|
|
467
|
+
const isCached =
|
|
468
|
+
response.headers.get("x-cache")?.startsWith("Hit") ||
|
|
469
|
+
Date.parse(response.headers.get("date") ?? "") < requestedAt - 5000
|
|
470
|
+
if (latestResult.next_page && !isCached) {
|
|
465
471
|
await new Promise((res) => setTimeout(res, GET_ALL_QUERY_DELAY))
|
|
466
472
|
}
|
|
467
473
|
}
|
package/src/cookie.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
/** The well-known name of the cookie used to store a Prismic preview session's ref. */
|
|
2
2
|
export const preview = "io.prismic.preview"
|
|
3
|
+
|
|
4
|
+
/** The well-known name of the cookie used to store a Prismic preview session's ID. */
|
|
5
|
+
export const previewSession = "io.prismic.previewSession"
|
package/src/getToolbarSrc.ts
CHANGED
|
@@ -30,13 +30,27 @@ import { isRepositoryName } from "./isRepositoryName"
|
|
|
30
30
|
*
|
|
31
31
|
* @param repositoryName - The name of the Prismic repository. For example, `"my-repo"` if the
|
|
32
32
|
* repository URL is `my-repo.prismic.io`.
|
|
33
|
+
* @param config - Options that configure the toolbar URL.
|
|
33
34
|
* @returns The URL for the given Prismic repository's Prismic Toolbar script.
|
|
34
35
|
*/
|
|
35
|
-
export const getToolbarSrc =
|
|
36
|
-
repositoryName:
|
|
37
|
-
|
|
36
|
+
export const getToolbarSrc = (
|
|
37
|
+
repositoryName: string,
|
|
38
|
+
config?: {
|
|
39
|
+
/** The version of the Prismic Toolbar to load. Defaults to 4. */
|
|
40
|
+
version?: 4 | 5
|
|
41
|
+
/**
|
|
42
|
+
* The URL the toolbar script is loaded from, without a trailing slash. For example, a toolbar
|
|
43
|
+
* preview build. Defaults to `https://static.cdn.prismic.io`.
|
|
44
|
+
*/
|
|
45
|
+
host?: string
|
|
46
|
+
},
|
|
47
|
+
): string => {
|
|
38
48
|
if (isRepositoryName(repositoryName)) {
|
|
39
|
-
|
|
49
|
+
const url = new URL(`${config?.host ?? "https://static.cdn.prismic.io"}/prismic.js`)
|
|
50
|
+
url.searchParams.set("repo", repositoryName)
|
|
51
|
+
if (config?.version) url.searchParams.set("v", config.version.toString())
|
|
52
|
+
|
|
53
|
+
return url.toString()
|
|
40
54
|
} else {
|
|
41
55
|
throw new PrismicError(
|
|
42
56
|
`An invalid Prismic repository name was given: ${repositoryName}`,
|