@uniformdev/mesh-edgehancer-sdk 20.31.1-alpha.1 → 20.31.1-alpha.184

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/index.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/index.ts
@@ -23,7 +33,15 @@ __export(src_exports, {
23
33
  COLLECTION_DEFAULT_LIMIT: () => COLLECTION_DEFAULT_LIMIT,
24
34
  COLLECTION_DEFAULT_OFFSET: () => COLLECTION_DEFAULT_OFFSET,
25
35
  COLLECTION_MAX_LIMIT: () => COLLECTION_MAX_LIMIT,
36
+ afterAIDataResourceEditContextSchema: () => afterAIDataResourceEditContextSchema,
37
+ afterAIDataResourceEditResultSchema: () => afterAIDataResourceEditResultSchema,
38
+ afterAIEditContextSchema: () => afterAIEditContextSchema,
39
+ afterAIEditResultSchema: () => afterAIEditResultSchema,
26
40
  convertBatchResultsToEdgehancerResult: () => convertBatchResultsToEdgehancerResult,
41
+ createAIDataResourceEditContextSchema: () => createAIDataResourceEditContextSchema,
42
+ createAIDataResourceEditResultSchema: () => createAIDataResourceEditResultSchema,
43
+ createAIEditContextSchema: () => createAIEditContextSchema,
44
+ createAIEditResultSchema: () => createAIEditResultSchema,
27
45
  dataResourceSchema: () => dataResourceSchema,
28
46
  edgehancerMergedDataTypeSchema: () => edgehancerMergedDataTypeSchema,
29
47
  getDataResourceAsRequest: () => getDataResourceAsRequest,
@@ -40,6 +58,126 @@ __export(src_exports, {
40
58
  });
41
59
  module.exports = __toCommonJS(src_exports);
42
60
 
61
+ // ../../lib/ai-sdk/src/InvocationContexts.ts
62
+ var z = __toESM(require("zod"), 1);
63
+ var invocationContextsSchema = z.enum([
64
+ "composition",
65
+ "compositionPattern",
66
+ "componentPattern",
67
+ "entry",
68
+ "entryPattern",
69
+ "general"
70
+ ]);
71
+ var invocationContextInfoSchema = z.object({
72
+ context: invocationContextsSchema,
73
+ id: z.string(),
74
+ displayName: z.string().optional(),
75
+ icon: z.string().optional()
76
+ });
77
+ var invocationContextAnnotationSchema = z.object({
78
+ type: z.literal("invocationContext"),
79
+ value: invocationContextInfoSchema
80
+ });
81
+
82
+ // src/afterAIDataResourceEdit.ts
83
+ var z2 = __toESM(require("zod"));
84
+ var afterAIDataResourceEditResultSchema = z2.strictObject({
85
+ newValue: z2.record(z2.string(), z2.string()),
86
+ success: z2.boolean(),
87
+ summary: z2.string().optional()
88
+ });
89
+ var afterAIDataResourceEditContextSchema = z2.strictObject({
90
+ /**
91
+ * The the data type of the data resource being edited (merged with its data source)
92
+ * NOTE: this can contain secrets, API keys, etc. Do not directly expose it to the AI agent!
93
+ * NOTE: this does not include the current value's variables, if any
94
+ */
95
+ mergedDataType: z2.custom(),
96
+ /** Which data source variant is currently active (undefined = published data) */
97
+ dataSourceVariant: z2.custom().optional(),
98
+ /** The edit request details */
99
+ editRequest: z2.object({
100
+ /** The edit instruction from the AI agent */
101
+ edit: z2.string(),
102
+ /** Current value of the data resource's variables (if any) */
103
+ currentValue: z2.record(z2.string(), z2.string()).optional()
104
+ }),
105
+ /** AI invocation context */
106
+ invocationContext: invocationContextsSchema,
107
+ /** User ID making the edit */
108
+ userId: z2.string(),
109
+ /** Project ID */
110
+ projectId: z2.string(),
111
+ /** The new value generated by AI */
112
+ newValue: z2.record(z2.string(), z2.string()),
113
+ /** The result from the AI editing process */
114
+ result: z2.object({
115
+ success: z2.boolean(),
116
+ summary: z2.string().optional()
117
+ })
118
+ });
119
+
120
+ // ../../lib/ai-sdk/src/toolDefinitions/editing/createPropertyEdit.ts
121
+ var z3 = __toESM(require("zod"), 1);
122
+ var createPropertyEdit = {
123
+ displayName: "Create Property Edit",
124
+ description: "Edits a property on a composition, entry, or pattern with AI. This is a callable tool NOT FOR AGENT USE - agents use applyPropertyEdit to broker client-side application of the edit.",
125
+ inputSchema: z3.object({
126
+ edit: z3.string().describe("Describe the edit to be made to the property"),
127
+ currentValue: z3.unknown().describe("Current value of the property (if any exists)").optional(),
128
+ projectGuidance: z3.string().describe("Guidance prompt for the project (if any exists)").optional(),
129
+ componentGuidance: z3.string().describe("Guidance prompt for the parent component").optional(),
130
+ audienceGuidance: z3.string().describe(
131
+ "Guidance prompt for the target audience of a personalized variation. Omit for non-variation edits."
132
+ ).optional(),
133
+ propertyDefinition: z3.object({
134
+ id: z3.string(),
135
+ name: z3.string(),
136
+ type: z3.string(),
137
+ guidance: z3.string().describe("Guidance prompt from the property definition (if any exists)").optional(),
138
+ typeConfig: z3.unknown().optional().describe("Type-specific configuration for the property")
139
+ }),
140
+ outputLocale: z3.string().optional().describe("The locale to use when writing the edited value"),
141
+ documentContext: z3.string().describe("Content of the surrounding document the property is part of").optional()
142
+ }),
143
+ outputSchema: z3.object({
144
+ newValue: z3.string().describe(
145
+ "The new value of the property. When the action is clear or resetOverride, this should be empty."
146
+ ),
147
+ treatNewValueAsJson: z3.boolean().describe("Whether the newValue is a JSON string"),
148
+ summary: z3.string().describe(
149
+ "A completion message to the user that summarizes the action taken. This should be 1 sentence, in English."
150
+ ).optional(),
151
+ action: z3.enum(["setValue", "clearValue", "resetOverride"]).describe(
152
+ "setValue = update the value, clearValue = remove the value/set to empty, resetOverride = remove a pattern override and inherit the pattern value. Only use resetOverride if the prompt asks for it."
153
+ ),
154
+ success: z3.boolean().describe("Whether the edit could be completed successfully")
155
+ }),
156
+ runsAt: "server",
157
+ timeout: 100,
158
+ callable: true
159
+ };
160
+
161
+ // src/afterAIEdit.ts
162
+ var z4 = __toESM(require("zod"));
163
+ var afterAIEditResultSchema = z4.strictObject({
164
+ newValue: z4.unknown(),
165
+ success: z4.boolean(),
166
+ summary: z4.string().optional()
167
+ });
168
+ var afterAIEditContextSchema = z4.strictObject({
169
+ editRequest: createPropertyEdit.inputSchema,
170
+ invocationContext: invocationContextsSchema,
171
+ userId: z4.string(),
172
+ currentLocale: z4.string().optional(),
173
+ projectId: z4.string(),
174
+ newValue: z4.unknown(),
175
+ result: z4.object({
176
+ success: z4.boolean(),
177
+ summary: z4.string().optional()
178
+ })
179
+ });
180
+
43
181
  // src/batchUtils.ts
44
182
  function convertBatchResultsToEdgehancerResult({
45
183
  batch,
@@ -99,6 +237,54 @@ var COLLECTION_DEFAULT_LIMIT = 20;
99
237
  var COLLECTION_MAX_LIMIT = 50;
100
238
  var COLLECTION_DEFAULT_OFFSET = 0;
101
239
 
240
+ // src/createAIDataResourceEdit.ts
241
+ var z5 = __toESM(require("zod"));
242
+ var createAIDataResourceEditContextSchema = z5.strictObject({
243
+ /**
244
+ * The the data type of the data resource being edited (merged with its data source)
245
+ * NOTE: this can contain secrets, API keys, etc. Do not directly expose it to the AI agent!
246
+ * NOTE: this does not include the current value's variables, if any
247
+ */
248
+ mergedDataType: z5.custom(),
249
+ /** Which data source variant is currently active (undefined = published data) */
250
+ dataSourceVariant: z5.custom().optional(),
251
+ /** The edit request details */
252
+ editRequest: z5.object({
253
+ /** The edit instruction from the AI agent */
254
+ edit: z5.string(),
255
+ /** Current value of the data resource's variables (if any) */
256
+ currentValue: z5.record(z5.string(), z5.string()).optional()
257
+ }),
258
+ /** AI invocation context */
259
+ invocationContext: invocationContextsSchema,
260
+ /** User ID making the edit */
261
+ userId: z5.string(),
262
+ /** Project ID */
263
+ projectId: z5.string()
264
+ });
265
+ var createAIDataResourceEditResultSchema = z5.strictObject({
266
+ outputJsonSchema: z5.record(z5.string(), z5.any()).describe("JSON schema (draft-07) for the edited data resource result"),
267
+ instructions: z5.string().describe(
268
+ "Instructions for the AI editor LLM to follow when editing this data resource (e.g. conventions/rules, allowed values, data format expectations, etc). Describe how to transform or edit the data resource content."
269
+ )
270
+ });
271
+
272
+ // src/createAIEdit.ts
273
+ var z6 = __toESM(require("zod"));
274
+ var createAIEditContextSchema = z6.strictObject({
275
+ editRequest: createPropertyEdit.inputSchema,
276
+ invocationContext: invocationContextsSchema,
277
+ userId: z6.string(),
278
+ currentLocale: z6.string().optional(),
279
+ projectId: z6.string()
280
+ });
281
+ var createAIEditResultSchema = z6.strictObject({
282
+ outputJsonSchema: z6.record(z6.string(), z6.any()).describe("JSON schema (draft-07) for the edited content result"),
283
+ instructions: z6.string().describe(
284
+ "Instructions for the AI editor LLM to follow (e.g. conventions/rules, allowed values, etc). Just describe your value type, do not give guiding instructions. There is no need to worry about clearing or resetting values, that is automatically handled."
285
+ )
286
+ });
287
+
102
288
  // src/fetchUtils.ts
103
289
  function getDataResourceAsRequest(data) {
104
290
  var _a;
@@ -138,78 +324,80 @@ function copyKeyValuePairs(source, target) {
138
324
  }
139
325
 
140
326
  // src/preRequest.ts
141
- var import_zod2 = require("zod");
327
+ var z8 = __toESM(require("zod"));
142
328
 
143
329
  // src/shared.ts
144
330
  var import_tsafe = require("tsafe");
145
- var import_zod = require("zod");
146
- var parameterDefinitionSchema = import_zod.z.object({
147
- key: import_zod.z.string(),
148
- value: import_zod.z.string(),
149
- omitIfEmpty: import_zod.z.boolean().optional()
331
+ var z7 = __toESM(require("zod"));
332
+ var parameterDefinitionSchema = z7.object({
333
+ key: z7.string(),
334
+ value: z7.string(),
335
+ omitIfEmpty: z7.boolean().optional()
150
336
  });
151
- var resolvingIssueSchema = import_zod.z.union([
152
- import_zod.z.string(),
153
- import_zod.z.object({
154
- message: import_zod.z.string(),
155
- subType: import_zod.z.enum(["unpublishedData", "configuration"]).optional(),
156
- issueReference: import_zod.z.string().optional(),
157
- deepLink: import_zod.z.string().optional()
337
+ var resolvingIssueSchema = z7.union([
338
+ z7.string(),
339
+ z7.object({
340
+ message: z7.string(),
341
+ subType: z7.enum(["unpublishedData", "configuration"]).optional(),
342
+ issueReference: z7.string().optional(),
343
+ deepLink: z7.string().optional()
158
344
  })
159
345
  ]);
160
- var variableDefinitionSchema = import_zod.z.object({
161
- displayName: import_zod.z.string().optional(),
162
- type: import_zod.z.string().optional(),
163
- default: import_zod.z.string(),
164
- helpText: import_zod.z.string().optional(),
165
- order: import_zod.z.number().optional(),
166
- source: import_zod.z.string().optional()
346
+ var variableDefinitionSchema = z7.object({
347
+ displayName: z7.string().optional(),
348
+ type: z7.string().optional(),
349
+ default: z7.string(),
350
+ helpText: z7.string().optional(),
351
+ order: z7.number().optional(),
352
+ source: z7.string().optional()
167
353
  });
168
- var customEdgehancerDefinitionSchema = import_zod.z.object({
169
- preRequest: import_zod.z.string().optional(),
170
- request: import_zod.z.string().optional()
354
+ var customEdgehancerDefinitionSchema = z7.object({
355
+ preRequest: z7.string().optional(),
356
+ request: z7.string().optional(),
357
+ createAIDataResourceEdit: z7.string().optional(),
358
+ afterAIDataResourceEdit: z7.string().optional()
171
359
  });
172
- var dataSourceVariantSchema = import_zod.z.intersection(
173
- import_zod.z.object({
174
- headers: import_zod.z.array(parameterDefinitionSchema).optional(),
175
- parameters: import_zod.z.array(parameterDefinitionSchema).optional(),
176
- variables: import_zod.z.record(variableDefinitionSchema).optional()
360
+ var dataSourceVariantSchema = z7.intersection(
361
+ z7.object({
362
+ headers: z7.array(parameterDefinitionSchema).optional(),
363
+ parameters: z7.array(parameterDefinitionSchema).optional(),
364
+ variables: z7.record(variableDefinitionSchema).optional()
177
365
  }),
178
- import_zod.z.object({ url: import_zod.z.string() })
366
+ z7.object({ url: z7.string() })
179
367
  );
180
- var mergedDataTypeSchema = import_zod.z.object({
181
- id: import_zod.z.string(),
182
- displayName: import_zod.z.string(),
183
- archetype: import_zod.z.string().optional(),
184
- allowedOnComponents: import_zod.z.array(import_zod.z.string()).optional(),
185
- badgeIconUrl: import_zod.z.string().optional(),
186
- connectorType: import_zod.z.string(),
187
- url: import_zod.z.string(),
188
- headers: import_zod.z.array(parameterDefinitionSchema).optional(),
189
- parameters: import_zod.z.array(parameterDefinitionSchema).optional(),
190
- body: import_zod.z.string().optional(),
191
- method: import_zod.z.enum(["GET", "POST", "HEAD"]),
192
- variables: import_zod.z.record(variableDefinitionSchema).optional(),
193
- custom: import_zod.z.record(import_zod.z.unknown()).optional(),
194
- customPublic: import_zod.z.record(import_zod.z.unknown()).optional(),
195
- ttl: import_zod.z.number().optional(),
196
- purgeKey: import_zod.z.string().optional(),
197
- localeMapping: import_zod.z.record(import_zod.z.string()).optional(),
368
+ var mergedDataTypeSchema = z7.object({
369
+ id: z7.string(),
370
+ displayName: z7.string(),
371
+ archetype: z7.string().optional(),
372
+ allowedOnComponents: z7.array(z7.string()).optional(),
373
+ badgeIconUrl: z7.string().optional(),
374
+ connectorType: z7.string(),
375
+ url: z7.string(),
376
+ headers: z7.array(parameterDefinitionSchema).optional(),
377
+ parameters: z7.array(parameterDefinitionSchema).optional(),
378
+ body: z7.string().optional(),
379
+ method: z7.enum(["GET", "POST", "HEAD"]),
380
+ variables: z7.record(variableDefinitionSchema).optional(),
381
+ custom: z7.record(z7.unknown()).optional(),
382
+ customPublic: z7.record(z7.unknown()).optional(),
383
+ ttl: z7.number().optional(),
384
+ purgeKey: z7.string().optional(),
385
+ localeMapping: z7.record(z7.string()).optional(),
198
386
  edgehancer: customEdgehancerDefinitionSchema.optional(),
199
- uiBadgeText: import_zod.z.string().max(12).optional(),
200
- variants: import_zod.z.object({
387
+ uiBadgeText: z7.string().max(12).optional(),
388
+ variants: z7.object({
201
389
  unpublished: dataSourceVariantSchema.optional()
202
390
  }).optional(),
203
- enableUnpublishedMode: import_zod.z.boolean().optional()
391
+ enableUnpublishedMode: z7.boolean().optional()
204
392
  });
205
393
  (0, import_tsafe.assert)();
206
- var dataResourceSchema = import_zod.z.union([
207
- import_zod.z.string(),
208
- import_zod.z.object({}).catchall(import_zod.z.unknown()),
209
- import_zod.z.number(),
210
- import_zod.z.boolean(),
211
- import_zod.z.array(import_zod.z.unknown()),
212
- import_zod.z.undefined()
394
+ var dataResourceSchema = z7.union([
395
+ z7.string(),
396
+ z7.object({}).catchall(z7.unknown()),
397
+ z7.number(),
398
+ z7.boolean(),
399
+ z7.array(z7.unknown()),
400
+ z7.undefined()
213
401
  ]);
214
402
 
215
403
  // src/preRequest.ts
@@ -222,40 +410,48 @@ var edgehancerMergedDataTypeSchema = mergedDataTypeSchema.omit({
222
410
  purgeKey: true,
223
411
  variables: true
224
412
  });
225
- var preRequestEdgehancerDataResourceResultSchema = import_zod2.z.strictObject({
226
- errors: import_zod2.z.array(resolvingIssueSchema).optional(),
227
- warnings: import_zod2.z.array(resolvingIssueSchema).optional(),
228
- infos: import_zod2.z.array(resolvingIssueSchema).optional(),
413
+ var preRequestEdgehancerDataResourceResultSchema = z8.strictObject({
414
+ errors: z8.array(resolvingIssueSchema).optional(),
415
+ warnings: z8.array(resolvingIssueSchema).optional(),
416
+ infos: z8.array(resolvingIssueSchema).optional(),
229
417
  dataResource: edgehancerMergedDataTypeSchema
230
418
  });
231
- var preRequestEdgehancerResultSchema = import_zod2.z.strictObject({
232
- dataResources: import_zod2.z.array(preRequestEdgehancerDataResourceResultSchema)
419
+ var preRequestEdgehancerResultSchema = z8.strictObject({
420
+ dataResources: z8.array(preRequestEdgehancerDataResourceResultSchema)
233
421
  });
234
422
 
235
423
  // src/request.ts
236
- var import_zod3 = require("zod");
237
- var requestEdgehancerDataResourceResolutionResultSchema = import_zod3.z.strictObject({
238
- errors: import_zod3.z.array(resolvingIssueSchema).optional().describe(
424
+ var z9 = __toESM(require("zod"));
425
+ var requestEdgehancerDataResourceResolutionResultSchema = z9.strictObject({
426
+ errors: z9.array(resolvingIssueSchema).optional().describe(
239
427
  "Errors that occurred while running your code to return with the API response, if any. Unhandled exceptions will be captured automatically."
240
428
  ),
241
- warnings: import_zod3.z.array(resolvingIssueSchema).optional().describe("Warnings that occurred while running your code to return with the API response, if any."),
242
- infos: import_zod3.z.array(resolvingIssueSchema).optional().describe(
429
+ warnings: z9.array(resolvingIssueSchema).optional().describe("Warnings that occurred while running your code to return with the API response, if any."),
430
+ infos: z9.array(resolvingIssueSchema).optional().describe(
243
431
  "Informational messages that occurred while running your code to return with the API response, if any."
244
432
  ),
245
- surrogateKeys: import_zod3.z.array(import_zod3.z.string()).optional().describe(
433
+ surrogateKeys: z9.array(z9.string()).optional().describe(
246
434
  "Extra surrogate keys for the data that was fetched. These act as auxiliary cache keys that can allow granular purging of cached data."
247
435
  ),
248
436
  result: dataResourceSchema.describe("The result of fetching the data resource")
249
437
  });
250
- var requestEdgehancerResultSchema = import_zod3.z.strictObject({
251
- results: import_zod3.z.array(requestEdgehancerDataResourceResolutionResultSchema)
438
+ var requestEdgehancerResultSchema = z9.strictObject({
439
+ results: z9.array(requestEdgehancerDataResourceResolutionResultSchema)
252
440
  });
253
441
  // Annotate the CommonJS export names for ESM import in node:
254
442
  0 && (module.exports = {
255
443
  COLLECTION_DEFAULT_LIMIT,
256
444
  COLLECTION_DEFAULT_OFFSET,
257
445
  COLLECTION_MAX_LIMIT,
446
+ afterAIDataResourceEditContextSchema,
447
+ afterAIDataResourceEditResultSchema,
448
+ afterAIEditContextSchema,
449
+ afterAIEditResultSchema,
258
450
  convertBatchResultsToEdgehancerResult,
451
+ createAIDataResourceEditContextSchema,
452
+ createAIDataResourceEditResultSchema,
453
+ createAIEditContextSchema,
454
+ createAIEditResultSchema,
259
455
  dataResourceSchema,
260
456
  edgehancerMergedDataTypeSchema,
261
457
  getDataResourceAsRequest,