@prismicio/client 7.22.3 → 7.23.0-canary.4aca7e3

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.
Files changed (63) hide show
  1. package/dist/Client.d.cts +1 -0
  2. package/dist/Client.d.ts +1 -0
  3. package/dist/Migration.d.cts +1 -0
  4. package/dist/Migration.d.ts +1 -0
  5. package/dist/WriteClient.d.cts +1 -0
  6. package/dist/WriteClient.d.ts +1 -0
  7. package/dist/buildQueryURL.d.cts +1 -0
  8. package/dist/buildQueryURL.d.ts +1 -0
  9. package/dist/cookie.cjs +7 -1
  10. package/dist/cookie.cjs.map +1 -1
  11. package/dist/cookie.d.cts +3 -1
  12. package/dist/cookie.d.cts.map +1 -1
  13. package/dist/cookie.d.ts +3 -1
  14. package/dist/cookie.d.ts.map +1 -1
  15. package/dist/cookie.js +7 -2
  16. package/dist/cookie.js.map +1 -1
  17. package/dist/errors.d.cts +1 -0
  18. package/dist/errors.d.ts +1 -0
  19. package/dist/getToolbarSrc.cjs +8 -3
  20. package/dist/getToolbarSrc.cjs.map +1 -1
  21. package/dist/getToolbarSrc.d.cts +10 -1
  22. package/dist/getToolbarSrc.d.cts.map +1 -1
  23. package/dist/getToolbarSrc.d.ts +10 -1
  24. package/dist/getToolbarSrc.d.ts.map +1 -1
  25. package/dist/getToolbarSrc.js +8 -3
  26. package/dist/getToolbarSrc.js.map +1 -1
  27. package/dist/helpers/asDate.d.cts +1 -0
  28. package/dist/helpers/asDate.d.ts +1 -0
  29. package/dist/helpers/asHTML.d.cts +1 -0
  30. package/dist/helpers/asHTML.d.ts +1 -0
  31. package/dist/helpers/asImagePixelDensitySrcSet.d.cts +1 -0
  32. package/dist/helpers/asImagePixelDensitySrcSet.d.ts +1 -0
  33. package/dist/helpers/asImageSrc.d.cts +1 -0
  34. package/dist/helpers/asImageSrc.d.ts +1 -0
  35. package/dist/helpers/asImageWidthSrcSet.d.cts +1 -0
  36. package/dist/helpers/asImageWidthSrcSet.d.ts +1 -0
  37. package/dist/helpers/asLink.d.cts +1 -0
  38. package/dist/helpers/asLink.d.ts +1 -0
  39. package/dist/helpers/asLinkAttrs.d.cts +1 -0
  40. package/dist/helpers/asLinkAttrs.d.ts +1 -0
  41. package/dist/helpers/asText.d.cts +1 -0
  42. package/dist/helpers/asText.d.ts +1 -0
  43. package/dist/helpers/documentToLinkField.d.cts +1 -0
  44. package/dist/helpers/documentToLinkField.d.ts +1 -0
  45. package/dist/helpers/mapSliceZone.d.cts +1 -0
  46. package/dist/helpers/mapSliceZone.d.ts +1 -0
  47. package/dist/package.cjs +1 -1
  48. package/dist/package.js +1 -1
  49. package/dist/types/migration/ContentRelationship.d.cts +1 -0
  50. package/dist/types/migration/ContentRelationship.d.ts +1 -0
  51. package/dist/types/migration/Document.d.cts +1 -0
  52. package/dist/types/migration/Document.d.ts +1 -0
  53. package/dist/types/value/embed.d.cts +1 -0
  54. package/dist/types/value/embed.d.ts +1 -0
  55. package/dist/types/value/linkToMedia.d.cts +1 -0
  56. package/dist/types/value/linkToMedia.d.ts +1 -0
  57. package/dist/types/value/types.d.cts +1 -0
  58. package/dist/types/value/types.d.ts +1 -0
  59. package/dist/types/webhook/apiUpdate.d.cts +1 -0
  60. package/dist/types/webhook/apiUpdate.d.ts +1 -0
  61. package/package.json +7 -7
  62. package/src/cookie.ts +3 -0
  63. package/src/getToolbarSrc.ts +18 -4
package/dist/Client.d.cts CHANGED
@@ -626,4 +626,5 @@ export declare class Client<TDocuments extends PrismicDocument = PrismicDocument
626
626
  }): Promise<Response>;
627
627
  }
628
628
  //#endregion
629
+ export {};
629
630
  //# sourceMappingURL=Client.d.cts.map
package/dist/Client.d.ts CHANGED
@@ -626,4 +626,5 @@ export declare class Client<TDocuments extends PrismicDocument = PrismicDocument
626
626
  }): Promise<Response>;
627
627
  }
628
628
  //#endregion
629
+ export {};
629
630
  //# sourceMappingURL=Client.d.ts.map
@@ -176,4 +176,5 @@ export declare class Migration<TDocuments extends PrismicDocument = PrismicDocum
176
176
  _getByOriginalID<TType extends TDocuments["type"]>(id: string): PrismicMigrationDocument<ExtractDocumentType<TDocuments, TType>> | undefined;
177
177
  }
178
178
  //#endregion
179
+ export {};
179
180
  //# sourceMappingURL=Migration.d.cts.map
@@ -176,4 +176,5 @@ export declare class Migration<TDocuments extends PrismicDocument = PrismicDocum
176
176
  _getByOriginalID<TType extends TDocuments["type"]>(id: string): PrismicMigrationDocument<ExtractDocumentType<TDocuments, TType>> | undefined;
177
177
  }
178
178
  //#endregion
179
+ export {};
179
180
  //# sourceMappingURL=Migration.d.ts.map
@@ -241,4 +241,5 @@ export declare class WriteClient<TDocuments extends PrismicDocument = PrismicDoc
241
241
  private updateDocument;
242
242
  }
243
243
  //#endregion
244
+ export {};
244
245
  //# sourceMappingURL=WriteClient.d.cts.map
@@ -241,4 +241,5 @@ export declare class WriteClient<TDocuments extends PrismicDocument = PrismicDoc
241
241
  private updateDocument;
242
242
  }
243
243
  //#endregion
244
+ export {};
244
245
  //# sourceMappingURL=WriteClient.d.ts.map
@@ -198,4 +198,5 @@ export type BuildQueryURLArgs = QueryParams & BuildQueryURLParams;
198
198
  */
199
199
  export declare const buildQueryURL: (endpoint: string, args: BuildQueryURLArgs) => string;
200
200
  //#endregion
201
+ export {};
201
202
  //# sourceMappingURL=buildQueryURL.d.cts.map
@@ -198,4 +198,5 @@ export type BuildQueryURLArgs = QueryParams & BuildQueryURLParams;
198
198
  */
199
199
  export declare const buildQueryURL: (endpoint: string, args: BuildQueryURLArgs) => string;
200
200
  //#endregion
201
+ export {};
201
202
  //# sourceMappingURL=buildQueryURL.d.ts.map
package/dist/cookie.cjs CHANGED
@@ -1,7 +1,12 @@
1
1
  //#region src/cookie.ts
2
- var cookie_exports = /* @__PURE__ */ require("./_virtual/_rolldown/runtime.cjs").__exportAll({ preview: () => preview });
2
+ var cookie_exports = /* @__PURE__ */ require("./_virtual/_rolldown/runtime.cjs").__exportAll({
3
+ preview: () => preview,
4
+ previewSession: () => previewSession
5
+ });
3
6
  /** The well-known name of the cookie used to store a Prismic preview session's ref. */
4
7
  const preview = "io.prismic.preview";
8
+ /** The well-known name of the cookie used to store a Prismic preview session's ID. */
9
+ const previewSession = "io.prismic.previewSession";
5
10
  //#endregion
6
11
  Object.defineProperty(exports, "cookie_exports", {
7
12
  enumerable: true,
@@ -10,5 +15,6 @@ Object.defineProperty(exports, "cookie_exports", {
10
15
  }
11
16
  });
12
17
  exports.preview = preview;
18
+ exports.previewSession = previewSession;
13
19
 
14
20
  //# sourceMappingURL=cookie.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"cookie.cjs","names":[],"sources":["../src/cookie.ts"],"sourcesContent":["/** The well-known name of the cookie used to store a Prismic preview session's ref. */\nexport const preview = \"io.prismic.preview\"\n"],"mappings":";;;AACA,MAAa,UAAU"}
1
+ {"version":3,"file":"cookie.cjs","names":[],"sources":["../src/cookie.ts"],"sourcesContent":["/** The well-known name of the cookie used to store a Prismic preview session's ref. */\nexport const preview = \"io.prismic.preview\"\n\n/** The well-known name of the cookie used to store a Prismic preview session's ID. */\nexport const previewSession = \"io.prismic.previewSession\"\n"],"mappings":";;;;;;AACA,MAAa,UAAU;;AAGvB,MAAa,iBAAiB"}
package/dist/cookie.d.cts CHANGED
@@ -1,8 +1,10 @@
1
1
  declare namespace cookie_d_exports {
2
- export { preview };
2
+ export { preview, previewSession };
3
3
  }
4
4
  /** The well-known name of the cookie used to store a Prismic preview session's ref. */
5
5
  export declare const preview = "io.prismic.preview";
6
+ /** The well-known name of the cookie used to store a Prismic preview session's ID. */
7
+ export declare const previewSession = "io.prismic.previewSession";
6
8
  //#endregion
7
9
  export { cookie_d_exports };
8
10
  //# sourceMappingURL=cookie.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cookie.d.cts","names":[],"sources":["../src/cookie.ts"],"mappings":";;;;qBACa"}
1
+ {"version":3,"file":"cookie.d.cts","names":[],"sources":["../src/cookie.ts"],"mappings":";;;;qBACa;;qBAGA"}
package/dist/cookie.d.ts CHANGED
@@ -1,8 +1,10 @@
1
1
  declare namespace cookie_d_exports {
2
- export { preview };
2
+ export { preview, previewSession };
3
3
  }
4
4
  /** The well-known name of the cookie used to store a Prismic preview session's ref. */
5
5
  export declare const preview = "io.prismic.preview";
6
+ /** The well-known name of the cookie used to store a Prismic preview session's ID. */
7
+ export declare const previewSession = "io.prismic.previewSession";
6
8
  //#endregion
7
9
  export { cookie_d_exports };
8
10
  //# sourceMappingURL=cookie.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cookie.d.ts","names":[],"sources":["../src/cookie.ts"],"mappings":";;;;qBACa"}
1
+ {"version":3,"file":"cookie.d.ts","names":[],"sources":["../src/cookie.ts"],"mappings":";;;;qBACa;;qBAGA"}
package/dist/cookie.js CHANGED
@@ -1,9 +1,14 @@
1
1
  import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
2
  //#region src/cookie.ts
3
- var cookie_exports = /* @__PURE__ */ __exportAll({ preview: () => preview });
3
+ var cookie_exports = /* @__PURE__ */ __exportAll({
4
+ preview: () => preview,
5
+ previewSession: () => previewSession
6
+ });
4
7
  /** The well-known name of the cookie used to store a Prismic preview session's ref. */
5
8
  const preview = "io.prismic.preview";
9
+ /** The well-known name of the cookie used to store a Prismic preview session's ID. */
10
+ const previewSession = "io.prismic.previewSession";
6
11
  //#endregion
7
- export { cookie_exports, preview };
12
+ export { cookie_exports, preview, previewSession };
8
13
 
9
14
  //# sourceMappingURL=cookie.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cookie.js","names":[],"sources":["../src/cookie.ts"],"sourcesContent":["/** The well-known name of the cookie used to store a Prismic preview session's ref. */\nexport const preview = \"io.prismic.preview\"\n"],"mappings":";;;;AACA,MAAa,UAAU"}
1
+ {"version":3,"file":"cookie.js","names":[],"sources":["../src/cookie.ts"],"sourcesContent":["/** The well-known name of the cookie used to store a Prismic preview session's ref. */\nexport const preview = \"io.prismic.preview\"\n\n/** The well-known name of the cookie used to store a Prismic preview session's ID. */\nexport const previewSession = \"io.prismic.previewSession\"\n"],"mappings":";;;;;;;AACA,MAAa,UAAU;;AAGvB,MAAa,iBAAiB"}
package/dist/errors.d.cts CHANGED
@@ -42,4 +42,5 @@ type PreviewTokenExpiredErrorAPIResponse = {
42
42
  };
43
43
  export declare class PreviewTokenExpiredError<TResponse = PreviewTokenExpiredErrorAPIResponse> extends ForbiddenError<TResponse> {}
44
44
  //#endregion
45
+ export {};
45
46
  //# sourceMappingURL=errors.d.cts.map
package/dist/errors.d.ts CHANGED
@@ -42,4 +42,5 @@ type PreviewTokenExpiredErrorAPIResponse = {
42
42
  };
43
43
  export declare class PreviewTokenExpiredError<TResponse = PreviewTokenExpiredErrorAPIResponse> extends ForbiddenError<TResponse> {}
44
44
  //#endregion
45
+ export {};
45
46
  //# sourceMappingURL=errors.d.ts.map
@@ -30,11 +30,16 @@ const require_isRepositoryName = require("./isRepositoryName.cjs");
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
- const getToolbarSrc = (repositoryName) => {
36
- if (require_isRepositoryName.isRepositoryName(repositoryName)) return `https://static.cdn.prismic.io/prismic.js?new=true&repo=${repositoryName}`;
37
- else throw new require_errors.PrismicError(`An invalid Prismic repository name was given: ${repositoryName}`, void 0, void 0);
36
+ const getToolbarSrc = (repositoryName, config) => {
37
+ if (require_isRepositoryName.isRepositoryName(repositoryName)) {
38
+ const url = new URL(`${config?.host ?? "https://static.cdn.prismic.io"}/prismic.js`);
39
+ url.searchParams.set("repo", repositoryName);
40
+ if (config?.version) url.searchParams.set("v", config.version.toString());
41
+ return url.toString();
42
+ } else throw new require_errors.PrismicError(`An invalid Prismic repository name was given: ${repositoryName}`, void 0, void 0);
38
43
  };
39
44
  //#endregion
40
45
  exports.getToolbarSrc = getToolbarSrc;
@@ -1 +1 @@
1
- {"version":3,"file":"getToolbarSrc.cjs","names":["isRepositoryName","PrismicError"],"sources":["../src/getToolbarSrc.ts"],"sourcesContent":["import { PrismicError } from \"./errors\"\nimport { isRepositoryName } from \"./isRepositoryName\"\n\n/**\n * Returns the URL for a Prismic repository's Prismic Toolbar script. Use the URL to inject the\n * script into your app.\n *\n * @example\n * \t```typescriptreact\n * \t// In Next.js apps, use `next/script` in your `app/layout.tsx` file.\n *\n * \timport Script from \"next/script\";\n * \timport * as prismic from \"@prismicio/client\";\n *\n * \texport default function RootLayout({\n * \tchildren,\n * \t}: {\n * \tchildren: React.ReactNode,\n * \t}) {\n * \tconst toolbarSrc = prismic.getToolbarSrc(\"my-repo\");\n *\n * \treturn (\n * \t<html lang=\"en\">\n * \t<body>{children}</body>\n * \t<Script src={toolbarSrc} />\n * \t</html>\n * \t);\n * \t}\n * \t```\n *\n * @param repositoryName - The name of the Prismic repository. For example, `\"my-repo\"` if the\n * repository URL is `my-repo.prismic.io`.\n * @returns The URL for the given Prismic repository's Prismic Toolbar script.\n */\nexport const getToolbarSrc = <TRepositoryName extends string>(\n\trepositoryName: TRepositoryName,\n): `https://static.cdn.prismic.io/prismic.js?new=true&repo=${TRepositoryName}` => {\n\tif (isRepositoryName(repositoryName)) {\n\t\treturn `https://static.cdn.prismic.io/prismic.js?new=true&repo=${repositoryName}` as const\n\t} else {\n\t\tthrow new PrismicError(\n\t\t\t`An invalid Prismic repository name was given: ${repositoryName}`,\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t)\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAa,iBACZ,mBACiF;CACjF,IAAIA,yBAAAA,iBAAiB,cAAc,GAClC,OAAO,0DAA0D;MAEjE,MAAM,IAAIC,eAAAA,aACT,iDAAiD,kBACjD,KAAA,GACA,KAAA,CACD;AAEF"}
1
+ {"version":3,"file":"getToolbarSrc.cjs","names":["isRepositoryName","PrismicError"],"sources":["../src/getToolbarSrc.ts"],"sourcesContent":["import { PrismicError } from \"./errors\"\nimport { isRepositoryName } from \"./isRepositoryName\"\n\n/**\n * Returns the URL for a Prismic repository's Prismic Toolbar script. Use the URL to inject the\n * script into your app.\n *\n * @example\n * \t```typescriptreact\n * \t// In Next.js apps, use `next/script` in your `app/layout.tsx` file.\n *\n * \timport Script from \"next/script\";\n * \timport * as prismic from \"@prismicio/client\";\n *\n * \texport default function RootLayout({\n * \tchildren,\n * \t}: {\n * \tchildren: React.ReactNode,\n * \t}) {\n * \tconst toolbarSrc = prismic.getToolbarSrc(\"my-repo\");\n *\n * \treturn (\n * \t<html lang=\"en\">\n * \t<body>{children}</body>\n * \t<Script src={toolbarSrc} />\n * \t</html>\n * \t);\n * \t}\n * \t```\n *\n * @param repositoryName - The name of the Prismic repository. For example, `\"my-repo\"` if the\n * repository URL is `my-repo.prismic.io`.\n * @param config - Options that configure the toolbar URL.\n * @returns The URL for the given Prismic repository's Prismic Toolbar script.\n */\nexport const getToolbarSrc = (\n\trepositoryName: string,\n\tconfig?: {\n\t\t/** The version of the Prismic Toolbar to load. Defaults to 4. */\n\t\tversion?: 4 | 5\n\t\t/**\n\t\t * The URL the toolbar script is loaded from, without a trailing slash. For example, a toolbar\n\t\t * preview build. Defaults to `https://static.cdn.prismic.io`.\n\t\t */\n\t\thost?: string\n\t},\n): string => {\n\tif (isRepositoryName(repositoryName)) {\n\t\tconst url = new URL(`${config?.host ?? \"https://static.cdn.prismic.io\"}/prismic.js`)\n\t\turl.searchParams.set(\"repo\", repositoryName)\n\t\tif (config?.version) url.searchParams.set(\"v\", config.version.toString())\n\n\t\treturn url.toString()\n\t} else {\n\t\tthrow new PrismicError(\n\t\t\t`An invalid Prismic repository name was given: ${repositoryName}`,\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t)\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,iBACZ,gBACA,WASY;CACZ,IAAIA,yBAAAA,iBAAiB,cAAc,GAAG;EACrC,MAAM,MAAM,IAAI,IAAI,GAAG,QAAQ,QAAQ,gCAAgC,YAAY;EACnF,IAAI,aAAa,IAAI,QAAQ,cAAc;EAC3C,IAAI,QAAQ,SAAS,IAAI,aAAa,IAAI,KAAK,OAAO,QAAQ,SAAS,CAAC;EAExE,OAAO,IAAI,SAAS;CACrB,OACC,MAAM,IAAIC,eAAAA,aACT,iDAAiD,kBACjD,KAAA,GACA,KAAA,CACD;AAEF"}
@@ -28,8 +28,17 @@
28
28
  *
29
29
  * @param repositoryName - The name of the Prismic repository. For example, `"my-repo"` if the
30
30
  * repository URL is `my-repo.prismic.io`.
31
+ * @param config - Options that configure the toolbar URL.
31
32
  * @returns The URL for the given Prismic repository's Prismic Toolbar script.
32
33
  */
33
- export declare const getToolbarSrc: <TRepositoryName extends string>(repositoryName: TRepositoryName) => `https://static.cdn.prismic.io/prismic.js?new=true&repo=${TRepositoryName}`;
34
+ export declare const getToolbarSrc: (repositoryName: string, config?: {
35
+ /** The version of the Prismic Toolbar to load. Defaults to 4. */
36
+ version?: 4 | 5;
37
+ /**
38
+ * The URL the toolbar script is loaded from, without a trailing slash. For example, a toolbar
39
+ * preview build. Defaults to `https://static.cdn.prismic.io`.
40
+ */
41
+ host?: string;
42
+ }) => string;
34
43
  //#endregion
35
44
  //# sourceMappingURL=getToolbarSrc.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getToolbarSrc.d.cts","names":[],"sources":["../src/getToolbarSrc.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAkCa,gBAAiB,gCAA8B,gBAC3C,8EAC4C"}
1
+ {"version":3,"file":"getToolbarSrc.d.cts","names":[],"sources":["../src/getToolbarSrc.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAmCa,gBAAa,wBACH;;EAGrB;;;;;EAKA"}
@@ -28,8 +28,17 @@
28
28
  *
29
29
  * @param repositoryName - The name of the Prismic repository. For example, `"my-repo"` if the
30
30
  * repository URL is `my-repo.prismic.io`.
31
+ * @param config - Options that configure the toolbar URL.
31
32
  * @returns The URL for the given Prismic repository's Prismic Toolbar script.
32
33
  */
33
- export declare const getToolbarSrc: <TRepositoryName extends string>(repositoryName: TRepositoryName) => `https://static.cdn.prismic.io/prismic.js?new=true&repo=${TRepositoryName}`;
34
+ export declare const getToolbarSrc: (repositoryName: string, config?: {
35
+ /** The version of the Prismic Toolbar to load. Defaults to 4. */
36
+ version?: 4 | 5;
37
+ /**
38
+ * The URL the toolbar script is loaded from, without a trailing slash. For example, a toolbar
39
+ * preview build. Defaults to `https://static.cdn.prismic.io`.
40
+ */
41
+ host?: string;
42
+ }) => string;
34
43
  //#endregion
35
44
  //# sourceMappingURL=getToolbarSrc.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getToolbarSrc.d.ts","names":[],"sources":["../src/getToolbarSrc.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAkCa,gBAAiB,gCAA8B,gBAC3C,8EAC4C"}
1
+ {"version":3,"file":"getToolbarSrc.d.ts","names":[],"sources":["../src/getToolbarSrc.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAmCa,gBAAa,wBACH;;EAGrB;;;;;EAKA"}
@@ -30,11 +30,16 @@ import { isRepositoryName } from "./isRepositoryName.js";
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
- const getToolbarSrc = (repositoryName) => {
36
- if (isRepositoryName(repositoryName)) return `https://static.cdn.prismic.io/prismic.js?new=true&repo=${repositoryName}`;
37
- else throw new PrismicError(`An invalid Prismic repository name was given: ${repositoryName}`, void 0, void 0);
36
+ const getToolbarSrc = (repositoryName, config) => {
37
+ if (isRepositoryName(repositoryName)) {
38
+ const url = new URL(`${config?.host ?? "https://static.cdn.prismic.io"}/prismic.js`);
39
+ url.searchParams.set("repo", repositoryName);
40
+ if (config?.version) url.searchParams.set("v", config.version.toString());
41
+ return url.toString();
42
+ } else throw new PrismicError(`An invalid Prismic repository name was given: ${repositoryName}`, void 0, void 0);
38
43
  };
39
44
  //#endregion
40
45
  export { getToolbarSrc };
@@ -1 +1 @@
1
- {"version":3,"file":"getToolbarSrc.js","names":[],"sources":["../src/getToolbarSrc.ts"],"sourcesContent":["import { PrismicError } from \"./errors\"\nimport { isRepositoryName } from \"./isRepositoryName\"\n\n/**\n * Returns the URL for a Prismic repository's Prismic Toolbar script. Use the URL to inject the\n * script into your app.\n *\n * @example\n * \t```typescriptreact\n * \t// In Next.js apps, use `next/script` in your `app/layout.tsx` file.\n *\n * \timport Script from \"next/script\";\n * \timport * as prismic from \"@prismicio/client\";\n *\n * \texport default function RootLayout({\n * \tchildren,\n * \t}: {\n * \tchildren: React.ReactNode,\n * \t}) {\n * \tconst toolbarSrc = prismic.getToolbarSrc(\"my-repo\");\n *\n * \treturn (\n * \t<html lang=\"en\">\n * \t<body>{children}</body>\n * \t<Script src={toolbarSrc} />\n * \t</html>\n * \t);\n * \t}\n * \t```\n *\n * @param repositoryName - The name of the Prismic repository. For example, `\"my-repo\"` if the\n * repository URL is `my-repo.prismic.io`.\n * @returns The URL for the given Prismic repository's Prismic Toolbar script.\n */\nexport const getToolbarSrc = <TRepositoryName extends string>(\n\trepositoryName: TRepositoryName,\n): `https://static.cdn.prismic.io/prismic.js?new=true&repo=${TRepositoryName}` => {\n\tif (isRepositoryName(repositoryName)) {\n\t\treturn `https://static.cdn.prismic.io/prismic.js?new=true&repo=${repositoryName}` as const\n\t} else {\n\t\tthrow new PrismicError(\n\t\t\t`An invalid Prismic repository name was given: ${repositoryName}`,\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t)\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAa,iBACZ,mBACiF;CACjF,IAAI,iBAAiB,cAAc,GAClC,OAAO,0DAA0D;MAEjE,MAAM,IAAI,aACT,iDAAiD,kBACjD,KAAA,GACA,KAAA,CACD;AAEF"}
1
+ {"version":3,"file":"getToolbarSrc.js","names":[],"sources":["../src/getToolbarSrc.ts"],"sourcesContent":["import { PrismicError } from \"./errors\"\nimport { isRepositoryName } from \"./isRepositoryName\"\n\n/**\n * Returns the URL for a Prismic repository's Prismic Toolbar script. Use the URL to inject the\n * script into your app.\n *\n * @example\n * \t```typescriptreact\n * \t// In Next.js apps, use `next/script` in your `app/layout.tsx` file.\n *\n * \timport Script from \"next/script\";\n * \timport * as prismic from \"@prismicio/client\";\n *\n * \texport default function RootLayout({\n * \tchildren,\n * \t}: {\n * \tchildren: React.ReactNode,\n * \t}) {\n * \tconst toolbarSrc = prismic.getToolbarSrc(\"my-repo\");\n *\n * \treturn (\n * \t<html lang=\"en\">\n * \t<body>{children}</body>\n * \t<Script src={toolbarSrc} />\n * \t</html>\n * \t);\n * \t}\n * \t```\n *\n * @param repositoryName - The name of the Prismic repository. For example, `\"my-repo\"` if the\n * repository URL is `my-repo.prismic.io`.\n * @param config - Options that configure the toolbar URL.\n * @returns The URL for the given Prismic repository's Prismic Toolbar script.\n */\nexport const getToolbarSrc = (\n\trepositoryName: string,\n\tconfig?: {\n\t\t/** The version of the Prismic Toolbar to load. Defaults to 4. */\n\t\tversion?: 4 | 5\n\t\t/**\n\t\t * The URL the toolbar script is loaded from, without a trailing slash. For example, a toolbar\n\t\t * preview build. Defaults to `https://static.cdn.prismic.io`.\n\t\t */\n\t\thost?: string\n\t},\n): string => {\n\tif (isRepositoryName(repositoryName)) {\n\t\tconst url = new URL(`${config?.host ?? \"https://static.cdn.prismic.io\"}/prismic.js`)\n\t\turl.searchParams.set(\"repo\", repositoryName)\n\t\tif (config?.version) url.searchParams.set(\"v\", config.version.toString())\n\n\t\treturn url.toString()\n\t} else {\n\t\tthrow new PrismicError(\n\t\t\t`An invalid Prismic repository name was given: ${repositoryName}`,\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t)\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,iBACZ,gBACA,WASY;CACZ,IAAI,iBAAiB,cAAc,GAAG;EACrC,MAAM,MAAM,IAAI,IAAI,GAAG,QAAQ,QAAQ,gCAAgC,YAAY;EACnF,IAAI,aAAa,IAAI,QAAQ,cAAc;EAC3C,IAAI,QAAQ,SAAS,IAAI,aAAa,IAAI,KAAK,OAAO,QAAQ,SAAS,CAAC;EAExE,OAAO,IAAI,SAAS;CACrB,OACC,MAAM,IAAI,aACT,iDAAiD,kBACjD,KAAA,GACA,KAAA,CACD;AAEF"}
@@ -18,4 +18,5 @@ type AsDateReturnType<Field extends DateField | TimestampField | null | undefine
18
18
  */
19
19
  export declare const asDate: <Field extends DateField | TimestampField | null | undefined>(dateOrTimestampField: Field) => AsDateReturnType<Field>;
20
20
  //#endregion
21
+ export {};
21
22
  //# sourceMappingURL=asDate.d.cts.map
@@ -18,4 +18,5 @@ type AsDateReturnType<Field extends DateField | TimestampField | null | undefine
18
18
  */
19
19
  export declare const asDate: <Field extends DateField | TimestampField | null | undefined>(dateOrTimestampField: Field) => AsDateReturnType<Field>;
20
20
  //#endregion
21
+ export {};
21
22
  //# sourceMappingURL=asDate.d.ts.map
@@ -118,4 +118,5 @@ export declare const asHTML: {
118
118
  <Field extends RichTextField | null | undefined>(richTextField: Field, ...config: AsHTMLDeprecatedTupleConfig): AsHTMLReturnType<Field>;
119
119
  };
120
120
  //#endregion
121
+ export {};
121
122
  //# sourceMappingURL=asHTML.d.cts.map
@@ -118,4 +118,5 @@ export declare const asHTML: {
118
118
  <Field extends RichTextField | null | undefined>(richTextField: Field, ...config: AsHTMLDeprecatedTupleConfig): AsHTMLReturnType<Field>;
119
119
  };
120
120
  //#endregion
121
+ export {};
121
122
  //# sourceMappingURL=asHTML.d.ts.map
@@ -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.cts.map
@@ -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
@@ -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
@@ -43,4 +43,5 @@ export declare const asText: {
43
43
  <Field extends RichTextField | null | undefined>(richTextField: Field, ...config: AsTextDeprecatedTupleConfig): AsTextReturnType<Field>;
44
44
  };
45
45
  //#endregion
46
+ export {};
46
47
  //# sourceMappingURL=asText.d.cts.map
@@ -43,4 +43,5 @@ export declare const asText: {
43
43
  <Field extends RichTextField | null | undefined>(richTextField: Field, ...config: AsTextDeprecatedTupleConfig): AsTextReturnType<Field>;
44
44
  };
45
45
  //#endregion
46
+ export {};
46
47
  //# sourceMappingURL=asText.d.ts.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.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
@@ -1,6 +1,6 @@
1
1
  //#region package.json
2
2
  var name = "@prismicio/client";
3
- var version = "7.22.3";
3
+ var version = "7.23.0-canary.4aca7e3";
4
4
  //#endregion
5
5
  Object.defineProperty(exports, "name", {
6
6
  enumerable: true,
package/dist/package.js CHANGED
@@ -1,6 +1,6 @@
1
1
  //#region package.json
2
2
  var name = "@prismicio/client";
3
- var version = "7.22.3";
3
+ var version = "7.23.0-canary.4aca7e3";
4
4
  //#endregion
5
5
  export { name, version };
6
6
 
@@ -8,4 +8,5 @@ export type MigrationContentRelationship<TDocuments extends PrismicDocument = Pr
8
8
  id: ValueOrThunk<TDocuments | PrismicMigrationDocument<TDocuments> | undefined>;
9
9
  });
10
10
  //#endregion
11
+ export {};
11
12
  //# sourceMappingURL=ContentRelationship.d.cts.map
@@ -8,4 +8,5 @@ export type MigrationContentRelationship<TDocuments extends PrismicDocument = Pr
8
8
  id: ValueOrThunk<TDocuments | PrismicMigrationDocument<TDocuments> | undefined>;
9
9
  });
10
10
  //#endregion
11
+ export {};
11
12
  //# sourceMappingURL=ContentRelationship.d.ts.map
@@ -74,4 +74,5 @@ export declare class PrismicMigrationDocument<TDocument extends PrismicDocument
74
74
  });
75
75
  }
76
76
  //#endregion
77
+ export {};
77
78
  //# sourceMappingURL=Document.d.cts.map
@@ -74,4 +74,5 @@ export declare class PrismicMigrationDocument<TDocument extends PrismicDocument
74
74
  });
75
75
  }
76
76
  //#endregion
77
+ export {};
77
78
  //# sourceMappingURL=Document.d.ts.map
@@ -120,4 +120,5 @@ export type EmbedField<Data extends AnyOEmbed = AnyOEmbed & OEmbedExtra, State e
120
120
  html: string | null;
121
121
  };
122
122
  //#endregion
123
+ export {};
123
124
  //# sourceMappingURL=embed.d.cts.map
@@ -120,4 +120,5 @@ export type EmbedField<Data extends AnyOEmbed = AnyOEmbed & OEmbedExtra, State e
120
120
  html: string | null;
121
121
  };
122
122
  //#endregion
123
+ export {};
123
124
  //# sourceMappingURL=embed.d.ts.map
@@ -27,4 +27,5 @@ export type FilledLinkToMediaField<Variant = string> = {
27
27
  width?: string | null;
28
28
  } & OptionalLinkProperties<Variant>;
29
29
  //#endregion
30
+ export {};
30
31
  //# sourceMappingURL=linkToMedia.d.cts.map
@@ -27,4 +27,5 @@ export type FilledLinkToMediaField<Variant = string> = {
27
27
  width?: string | null;
28
28
  } & OptionalLinkProperties<Variant>;
29
29
  //#endregion
30
+ export {};
30
31
  //# sourceMappingURL=linkToMedia.d.ts.map
@@ -42,4 +42,5 @@ type WithKey<Field extends LinkField> = Field & {
42
42
  */
43
43
  export type Simplify<T> = { [P in keyof T]: T[P]; };
44
44
  //#endregion
45
+ export {};
45
46
  //# sourceMappingURL=types.d.cts.map
@@ -42,4 +42,5 @@ type WithKey<Field extends LinkField> = Field & {
42
42
  */
43
43
  export type Simplify<T> = { [P in keyof T]: T[P]; };
44
44
  //#endregion
45
+ export {};
45
46
  //# sourceMappingURL=types.d.ts.map
@@ -49,4 +49,5 @@ interface WebhookBodyAPIUpdateRelease {
49
49
  documents: string[];
50
50
  }
51
51
  //#endregion
52
+ export {};
52
53
  //# sourceMappingURL=apiUpdate.d.cts.map
@@ -49,4 +49,5 @@ interface WebhookBodyAPIUpdateRelease {
49
49
  documents: string[];
50
50
  }
51
51
  //#endregion
52
+ export {};
52
53
  //# sourceMappingURL=apiUpdate.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/client",
3
- "version": "7.22.3",
3
+ "version": "7.23.0-canary.4aca7e3",
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.4",
74
- "@vitest/coverage-v8": "^5.0.3",
75
- "oxfmt": "^0.71.0",
76
- "oxlint": "^1.86.0",
77
- "tsdown": "^0.23.0",
73
+ "@types/node": "^26.6.5",
74
+ "@vitest/coverage-v8": "^5.0.5",
75
+ "oxfmt": "^0.74.0",
76
+ "oxlint": "^1.89.0",
77
+ "tsdown": "^0.23.1",
78
78
  "typescript": "^7.0.2",
79
- "vitest": "^5.0.3"
79
+ "vitest": "^5.0.5"
80
80
  },
81
81
  "engines": {
82
82
  "node": ">=22"
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"
@@ -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 = <TRepositoryName extends string>(
36
- repositoryName: TRepositoryName,
37
- ): `https://static.cdn.prismic.io/prismic.js?new=true&repo=${TRepositoryName}` => {
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
- return `https://static.cdn.prismic.io/prismic.js?new=true&repo=${repositoryName}` as const
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}`,