@puckeditor/cloud-client 0.8.0-canary.63de6e49 → 0.8.0-canary.76327c84

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.
@@ -22183,7 +22183,8 @@ async function* iterateSSE(body) {
22183
22183
 
22184
22184
  // src/lib/cloud-api.ts
22185
22185
  var DEFAULT_API_VERSION = "v2";
22186
- var cloudApi = async (path, body, options = {}, onChunk) => {
22186
+ var CLOUD_CLIENT_VERSION = true ? "0.8.0-canary.76327c84" : "unknown";
22187
+ var cloudApi = async (path, body, options = {}, onChunk, forwardHeaders) => {
22187
22188
  const {
22188
22189
  ai = {},
22189
22190
  apiKey = getApiKey(),
@@ -22197,7 +22198,12 @@ var cloudApi = async (path, body, options = {}, onChunk) => {
22197
22198
  }
22198
22199
  const { context, tools = {} } = ai;
22199
22200
  const res = await fetch(`${host}/${path}`, {
22200
- headers: { "x-api-key": apiKey, "puck-api-version": apiVersion },
22201
+ headers: {
22202
+ "x-api-key": apiKey,
22203
+ "puck-api-version": apiVersion,
22204
+ "x-puck-cloud-client-version": CLOUD_CLIENT_VERSION,
22205
+ ...forwardHeaders?.pluginAiVersion ? { "x-puck-plugin-ai-version": forwardHeaders.pluginAiVersion } : {}
22206
+ },
22201
22207
  method: "post",
22202
22208
  body: JSON.stringify({
22203
22209
  ...body,
@@ -22224,7 +22230,7 @@ var cloudApi = async (path, body, options = {}, onChunk) => {
22224
22230
  };
22225
22231
 
22226
22232
  // src/api/chat.ts
22227
- function chat({ chatId, messages, config: config2, pageData }, options = {}) {
22233
+ function chat({ chatId, messages, config: config2, pageData }, options = {}, forwardHeaders) {
22228
22234
  const stream = createUIMessageStream({
22229
22235
  execute: async ({ writer }) => {
22230
22236
  await cloudApi(
@@ -22237,7 +22243,8 @@ function chat({ chatId, messages, config: config2, pageData }, options = {}) {
22237
22243
  } else {
22238
22244
  writer.write(chunk);
22239
22245
  }
22240
- }
22246
+ },
22247
+ forwardHeaders
22241
22248
  );
22242
22249
  }
22243
22250
  });
@@ -22435,7 +22442,9 @@ var routeRegistry = [
22435
22442
  {
22436
22443
  pattern: "/api/puck/chat",
22437
22444
  methods: {
22438
- POST: ({ body }, options) => chat(body, options)
22445
+ POST: ({ body, headers }, options) => chat(body, options, {
22446
+ pluginAiVersion: headers.get("x-puck-plugin-ai-version")
22447
+ })
22439
22448
  }
22440
22449
  }
22441
22450
  ];
@@ -22226,7 +22226,8 @@ async function* iterateSSE(body) {
22226
22226
 
22227
22227
  // src/lib/cloud-api.ts
22228
22228
  var DEFAULT_API_VERSION = "v2";
22229
- var cloudApi = async (path, body, options = {}, onChunk) => {
22229
+ var CLOUD_CLIENT_VERSION = true ? "0.8.0-canary.76327c84" : "unknown";
22230
+ var cloudApi = async (path, body, options = {}, onChunk, forwardHeaders) => {
22230
22231
  const {
22231
22232
  ai = {},
22232
22233
  apiKey = getApiKey(),
@@ -22240,7 +22241,12 @@ var cloudApi = async (path, body, options = {}, onChunk) => {
22240
22241
  }
22241
22242
  const { context, tools = {} } = ai;
22242
22243
  const res = await fetch(`${host}/${path}`, {
22243
- headers: { "x-api-key": apiKey, "puck-api-version": apiVersion },
22244
+ headers: {
22245
+ "x-api-key": apiKey,
22246
+ "puck-api-version": apiVersion,
22247
+ "x-puck-cloud-client-version": CLOUD_CLIENT_VERSION,
22248
+ ...forwardHeaders?.pluginAiVersion ? { "x-puck-plugin-ai-version": forwardHeaders.pluginAiVersion } : {}
22249
+ },
22244
22250
  method: "post",
22245
22251
  body: JSON.stringify({
22246
22252
  ...body,
@@ -22267,7 +22273,7 @@ var cloudApi = async (path, body, options = {}, onChunk) => {
22267
22273
  };
22268
22274
 
22269
22275
  // src/api/chat.ts
22270
- function chat({ chatId, messages, config: config2, pageData }, options = {}) {
22276
+ function chat({ chatId, messages, config: config2, pageData }, options = {}, forwardHeaders) {
22271
22277
  const stream = createUIMessageStream({
22272
22278
  execute: async ({ writer }) => {
22273
22279
  await cloudApi(
@@ -22280,7 +22286,8 @@ function chat({ chatId, messages, config: config2, pageData }, options = {}) {
22280
22286
  } else {
22281
22287
  writer.write(chunk);
22282
22288
  }
22283
- }
22289
+ },
22290
+ forwardHeaders
22284
22291
  );
22285
22292
  }
22286
22293
  });
@@ -10,7 +10,7 @@ import {
10
10
  getAttachment,
11
11
  handlePuckRequest,
12
12
  tool
13
- } from "./chunk-XI3V7SYA.mjs";
13
+ } from "./chunk-56QXLCJ6.mjs";
14
14
  import {
15
15
  init_react_import
16
16
  } from "./chunk-O6DC5HI2.mjs";
package/dist/index.d.mts CHANGED
@@ -49,7 +49,9 @@ type ChatParams = {
49
49
  config: Config;
50
50
  pageData: Data;
51
51
  };
52
- declare function chat({ chatId, messages, config, pageData }: ChatParams, options?: PuckCloudOptions | undefined): Response;
52
+ declare function chat({ chatId, messages, config, pageData }: ChatParams, options?: PuckCloudOptions | undefined, forwardHeaders?: {
53
+ pluginAiVersion?: string | null;
54
+ }): Response;
53
55
 
54
56
  type GenerateParams = {
55
57
  prompt: string;
package/dist/index.d.ts CHANGED
@@ -49,7 +49,9 @@ type ChatParams = {
49
49
  config: Config;
50
50
  pageData: Data;
51
51
  };
52
- declare function chat({ chatId, messages, config, pageData }: ChatParams, options?: PuckCloudOptions | undefined): Response;
52
+ declare function chat({ chatId, messages, config, pageData }: ChatParams, options?: PuckCloudOptions | undefined, forwardHeaders?: {
53
+ pluginAiVersion?: string | null;
54
+ }): Response;
53
55
 
54
56
  type GenerateParams = {
55
57
  prompt: string;
package/dist/index.js CHANGED
@@ -22228,7 +22228,8 @@ async function* iterateSSE(body) {
22228
22228
 
22229
22229
  // src/lib/cloud-api.ts
22230
22230
  var DEFAULT_API_VERSION = "v2";
22231
- var cloudApi = async (path, body, options = {}, onChunk) => {
22231
+ var CLOUD_CLIENT_VERSION = true ? "0.8.0-canary.76327c84" : "unknown";
22232
+ var cloudApi = async (path, body, options = {}, onChunk, forwardHeaders) => {
22232
22233
  const {
22233
22234
  ai = {},
22234
22235
  apiKey = getApiKey(),
@@ -22242,7 +22243,12 @@ var cloudApi = async (path, body, options = {}, onChunk) => {
22242
22243
  }
22243
22244
  const { context, tools = {} } = ai;
22244
22245
  const res = await fetch(`${host}/${path}`, {
22245
- headers: { "x-api-key": apiKey, "puck-api-version": apiVersion },
22246
+ headers: {
22247
+ "x-api-key": apiKey,
22248
+ "puck-api-version": apiVersion,
22249
+ "x-puck-cloud-client-version": CLOUD_CLIENT_VERSION,
22250
+ ...forwardHeaders?.pluginAiVersion ? { "x-puck-plugin-ai-version": forwardHeaders.pluginAiVersion } : {}
22251
+ },
22246
22252
  method: "post",
22247
22253
  body: JSON.stringify({
22248
22254
  ...body,
@@ -22269,7 +22275,7 @@ var cloudApi = async (path, body, options = {}, onChunk) => {
22269
22275
  };
22270
22276
 
22271
22277
  // src/api/chat.ts
22272
- function chat({ chatId, messages, config: config2, pageData }, options = {}) {
22278
+ function chat({ chatId, messages, config: config2, pageData }, options = {}, forwardHeaders) {
22273
22279
  const stream = createUIMessageStream({
22274
22280
  execute: async ({ writer }) => {
22275
22281
  await cloudApi(
@@ -22282,7 +22288,8 @@ function chat({ chatId, messages, config: config2, pageData }, options = {}) {
22282
22288
  } else {
22283
22289
  writer.write(chunk);
22284
22290
  }
22285
- }
22291
+ },
22292
+ forwardHeaders
22286
22293
  );
22287
22294
  }
22288
22295
  });
@@ -22480,7 +22487,9 @@ var routeRegistry = [
22480
22487
  {
22481
22488
  pattern: "/api/puck/chat",
22482
22489
  methods: {
22483
- POST: ({ body }, options) => chat(body, options)
22490
+ POST: ({ body, headers }, options) => chat(body, options, {
22491
+ pluginAiVersion: headers.get("x-puck-plugin-ai-version")
22492
+ })
22484
22493
  }
22485
22494
  }
22486
22495
  ];
package/dist/index.mjs CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  generate,
5
5
  puckHandler,
6
6
  tool
7
- } from "./chunk-XI3V7SYA.mjs";
7
+ } from "./chunk-56QXLCJ6.mjs";
8
8
  import "./chunk-O6DC5HI2.mjs";
9
9
  export {
10
10
  chat,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@puckeditor/cloud-client",
3
- "version": "0.8.0-canary.63de6e49",
3
+ "version": "0.8.0-canary.76327c84",
4
4
  "author": "Chris Villa <chris@puckeditor.com>",
5
5
  "repository": "puckeditor/puck",
6
6
  "bugs": "https://github.com/puckeditor/puck/issues",