@uniformdev/mesh-edgehancer-sdk 20.35.0 → 20.35.1-alpha.210

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
@@ -33,7 +33,15 @@ __export(src_exports, {
33
33
  COLLECTION_DEFAULT_LIMIT: () => COLLECTION_DEFAULT_LIMIT,
34
34
  COLLECTION_DEFAULT_OFFSET: () => COLLECTION_DEFAULT_OFFSET,
35
35
  COLLECTION_MAX_LIMIT: () => COLLECTION_MAX_LIMIT,
36
+ afterAIDataResourceEditContextSchema: () => afterAIDataResourceEditContextSchema,
37
+ afterAIDataResourceEditResultSchema: () => afterAIDataResourceEditResultSchema,
38
+ afterAIEditContextSchema: () => afterAIEditContextSchema,
39
+ afterAIEditResultSchema: () => afterAIEditResultSchema,
36
40
  convertBatchResultsToEdgehancerResult: () => convertBatchResultsToEdgehancerResult,
41
+ createAIDataResourceEditContextSchema: () => createAIDataResourceEditContextSchema,
42
+ createAIDataResourceEditResultSchema: () => createAIDataResourceEditResultSchema,
43
+ createAIEditContextSchema: () => createAIEditContextSchema,
44
+ createAIEditResultSchema: () => createAIEditResultSchema,
37
45
  dataResourceSchema: () => dataResourceSchema,
38
46
  edgehancerMergedDataTypeSchema: () => edgehancerMergedDataTypeSchema,
39
47
  getDataResourceAsRequest: () => getDataResourceAsRequest,
@@ -50,6 +58,122 @@ __export(src_exports, {
50
58
  });
51
59
  module.exports = __toCommonJS(src_exports);
52
60
 
61
+ // ../../lib/ai-sdk/src/InvocationContexts.ts
62
+ var z = __toESM(require("zod/v3"), 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
+
78
+ // src/afterAIDataResourceEdit.ts
79
+ var z2 = __toESM(require("zod/v3"));
80
+ var afterAIDataResourceEditResultSchema = z2.strictObject({
81
+ newValue: z2.record(z2.string(), z2.string()),
82
+ success: z2.boolean(),
83
+ summary: z2.string().optional()
84
+ });
85
+ var afterAIDataResourceEditContextSchema = z2.strictObject({
86
+ /**
87
+ * The the data type of the data resource being edited (merged with its data source)
88
+ * NOTE: this can contain secrets, API keys, etc. Do not directly expose it to the AI agent!
89
+ * NOTE: this does not include the current value's variables, if any
90
+ */
91
+ mergedDataType: z2.custom(),
92
+ /** Which data source variant is currently active (undefined = published data) */
93
+ dataSourceVariant: z2.custom().optional(),
94
+ /** The edit request details */
95
+ editRequest: z2.object({
96
+ /** The edit instruction from the AI agent */
97
+ edit: z2.string(),
98
+ /** Current value of the data resource's variables (if any) */
99
+ currentValue: z2.record(z2.string(), z2.string()).optional()
100
+ }),
101
+ /** AI invocation context */
102
+ invocationContext: invocationContextsSchema,
103
+ /** User ID making the edit */
104
+ userId: z2.string(),
105
+ /** Project ID */
106
+ projectId: z2.string(),
107
+ /** The new value generated by AI */
108
+ newValue: z2.record(z2.string(), z2.string()),
109
+ /** The result from the AI editing process */
110
+ result: z2.object({
111
+ success: z2.boolean(),
112
+ summary: z2.string().optional()
113
+ })
114
+ });
115
+
116
+ // ../../lib/ai-sdk/src/toolDefinitions/editing/createPropertyEdit.ts
117
+ var z3 = __toESM(require("zod/v3"), 1);
118
+ var createPropertyEdit = {
119
+ displayName: "Create Property Edit",
120
+ 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.",
121
+ inputSchema: z3.object({
122
+ edit: z3.string().describe("Describe the edit to be made to the property"),
123
+ currentValue: z3.unknown().describe("Current value of the property (if any exists)").optional(),
124
+ projectGuidance: z3.string().describe("Guidance prompt for the project (if any exists)").optional(),
125
+ componentGuidance: z3.string().describe("Guidance prompt for the parent component").optional(),
126
+ audienceGuidance: z3.string().describe(
127
+ "Guidance prompt for the target audience of a personalized variation. Omit for non-variation edits."
128
+ ).optional(),
129
+ propertyDefinition: z3.object({
130
+ id: z3.string(),
131
+ name: z3.string(),
132
+ type: z3.string(),
133
+ guidance: z3.string().describe("Guidance prompt from the property definition (if any exists)").optional(),
134
+ typeConfig: z3.unknown().optional().describe("Type-specific configuration for the property")
135
+ }),
136
+ outputLocale: z3.string().optional().describe("The locale to use when writing the edited value"),
137
+ documentContext: z3.string().describe("Content of the surrounding document the property is part of").optional()
138
+ }),
139
+ outputSchema: z3.object({
140
+ newValue: z3.string().describe(
141
+ "The new value of the property. When the action is clear or resetOverride, this should be empty."
142
+ ),
143
+ treatNewValueAsJson: z3.boolean().describe("Whether the newValue is a JSON string"),
144
+ summary: z3.string().describe(
145
+ "A completion message to the user that summarizes the action taken. This should be 1 sentence, in English."
146
+ ).optional(),
147
+ action: z3.enum(["setValue", "clearValue", "resetOverride"]).describe(
148
+ "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. If the prompt is specifically talking about asset parameter title/description overrides, use setValue instead."
149
+ ),
150
+ success: z3.boolean().describe("Whether the edit could be completed successfully")
151
+ }),
152
+ runsAt: "server",
153
+ timeout: 100,
154
+ callable: true
155
+ };
156
+
157
+ // src/afterAIEdit.ts
158
+ var z4 = __toESM(require("zod/v3"));
159
+ var afterAIEditResultSchema = z4.strictObject({
160
+ newValue: z4.unknown(),
161
+ success: z4.boolean(),
162
+ summary: z4.string().optional()
163
+ });
164
+ var afterAIEditContextSchema = z4.strictObject({
165
+ editRequest: createPropertyEdit.inputSchema,
166
+ invocationContext: invocationContextsSchema,
167
+ userId: z4.string(),
168
+ currentLocale: z4.string().optional(),
169
+ projectId: z4.string(),
170
+ newValue: z4.unknown(),
171
+ result: z4.object({
172
+ success: z4.boolean(),
173
+ summary: z4.string().optional()
174
+ })
175
+ });
176
+
53
177
  // src/batchUtils.ts
54
178
  function convertBatchResultsToEdgehancerResult({
55
179
  batch,
@@ -109,6 +233,54 @@ var COLLECTION_DEFAULT_LIMIT = 20;
109
233
  var COLLECTION_MAX_LIMIT = 50;
110
234
  var COLLECTION_DEFAULT_OFFSET = 0;
111
235
 
236
+ // src/createAIDataResourceEdit.ts
237
+ var z5 = __toESM(require("zod/v3"));
238
+ var createAIDataResourceEditContextSchema = z5.strictObject({
239
+ /**
240
+ * The the data type of the data resource being edited (merged with its data source)
241
+ * NOTE: this can contain secrets, API keys, etc. Do not directly expose it to the AI agent!
242
+ * NOTE: this does not include the current value's variables, if any
243
+ */
244
+ mergedDataType: z5.custom(),
245
+ /** Which data source variant is currently active (undefined = published data) */
246
+ dataSourceVariant: z5.custom().optional(),
247
+ /** The edit request details */
248
+ editRequest: z5.object({
249
+ /** The edit instruction from the AI agent */
250
+ edit: z5.string(),
251
+ /** Current value of the data resource's variables (if any) */
252
+ currentValue: z5.record(z5.string(), z5.string()).optional()
253
+ }),
254
+ /** AI invocation context */
255
+ invocationContext: invocationContextsSchema,
256
+ /** User ID making the edit */
257
+ userId: z5.string(),
258
+ /** Project ID */
259
+ projectId: z5.string()
260
+ });
261
+ var createAIDataResourceEditResultSchema = z5.strictObject({
262
+ outputJsonSchema: z5.record(z5.string(), z5.any()).describe("JSON schema (draft-07) for the edited data resource result"),
263
+ instructions: z5.string().describe(
264
+ "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."
265
+ )
266
+ });
267
+
268
+ // src/createAIEdit.ts
269
+ var z6 = __toESM(require("zod/v3"));
270
+ var createAIEditContextSchema = z6.strictObject({
271
+ editRequest: createPropertyEdit.inputSchema,
272
+ invocationContext: invocationContextsSchema,
273
+ userId: z6.string(),
274
+ currentLocale: z6.string().optional(),
275
+ projectId: z6.string()
276
+ });
277
+ var createAIEditResultSchema = z6.strictObject({
278
+ outputJsonSchema: z6.record(z6.string(), z6.any()).describe("JSON schema (draft-07) for the edited content result"),
279
+ instructions: z6.string().describe(
280
+ "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."
281
+ )
282
+ });
283
+
112
284
  // src/fetchUtils.ts
113
285
  function getDataResourceAsRequest(data) {
114
286
  var _a;
@@ -148,78 +320,80 @@ function copyKeyValuePairs(source, target) {
148
320
  }
149
321
 
150
322
  // src/preRequest.ts
151
- var z2 = __toESM(require("zod"));
323
+ var z8 = __toESM(require("zod/v3"));
152
324
 
153
325
  // src/shared.ts
154
326
  var import_tsafe = require("tsafe");
155
- var z = __toESM(require("zod"));
156
- var parameterDefinitionSchema = z.object({
157
- key: z.string(),
158
- value: z.string(),
159
- omitIfEmpty: z.boolean().optional()
327
+ var z7 = __toESM(require("zod/v3"));
328
+ var parameterDefinitionSchema = z7.object({
329
+ key: z7.string(),
330
+ value: z7.string(),
331
+ omitIfEmpty: z7.boolean().optional()
160
332
  });
161
- var resolvingIssueSchema = z.union([
162
- z.string(),
163
- z.object({
164
- message: z.string(),
165
- subType: z.enum(["unpublishedData", "configuration"]).optional(),
166
- issueReference: z.string().optional(),
167
- deepLink: z.string().optional()
333
+ var resolvingIssueSchema = z7.union([
334
+ z7.string(),
335
+ z7.object({
336
+ message: z7.string(),
337
+ subType: z7.enum(["unpublishedData", "configuration"]).optional(),
338
+ issueReference: z7.string().optional(),
339
+ deepLink: z7.string().optional()
168
340
  })
169
341
  ]);
170
- var variableDefinitionSchema = z.object({
171
- displayName: z.string().optional(),
172
- type: z.string().optional(),
173
- default: z.string(),
174
- helpText: z.string().optional(),
175
- order: z.number().optional(),
176
- source: z.string().optional()
342
+ var variableDefinitionSchema = z7.object({
343
+ displayName: z7.string().optional(),
344
+ type: z7.string().optional(),
345
+ default: z7.string(),
346
+ helpText: z7.string().optional(),
347
+ order: z7.number().optional(),
348
+ source: z7.string().optional()
177
349
  });
178
- var customEdgehancerDefinitionSchema = z.object({
179
- preRequest: z.string().optional(),
180
- request: z.string().optional()
350
+ var customEdgehancerDefinitionSchema = z7.object({
351
+ preRequest: z7.string().optional(),
352
+ request: z7.string().optional(),
353
+ createAIDataResourceEdit: z7.string().optional(),
354
+ afterAIDataResourceEdit: z7.string().optional()
181
355
  });
182
- var dataSourceVariantSchema = z.intersection(
183
- z.object({
184
- headers: z.array(parameterDefinitionSchema).optional(),
185
- parameters: z.array(parameterDefinitionSchema).optional(),
186
- variables: z.record(variableDefinitionSchema).optional()
356
+ var dataSourceVariantSchema = z7.intersection(
357
+ z7.object({
358
+ headers: z7.array(parameterDefinitionSchema).optional(),
359
+ parameters: z7.array(parameterDefinitionSchema).optional(),
360
+ variables: z7.record(variableDefinitionSchema).optional()
187
361
  }),
188
- z.object({ url: z.string() })
362
+ z7.object({ url: z7.string() })
189
363
  );
190
- var mergedDataTypeSchema = z.object({
191
- id: z.string(),
192
- displayName: z.string(),
193
- archetype: z.string().optional(),
194
- allowedOnComponents: z.array(z.string()).optional(),
195
- badgeIconUrl: z.string().optional(),
196
- connectorType: z.string(),
197
- url: z.string(),
198
- headers: z.array(parameterDefinitionSchema).optional(),
199
- parameters: z.array(parameterDefinitionSchema).optional(),
200
- body: z.string().optional(),
201
- method: z.enum(["GET", "POST", "HEAD"]),
202
- variables: z.record(variableDefinitionSchema).optional(),
203
- custom: z.record(z.unknown()).optional(),
204
- customPublic: z.record(z.unknown()).optional(),
205
- ttl: z.number().optional(),
206
- purgeKey: z.string().optional(),
207
- localeMapping: z.record(z.string()).optional(),
364
+ var mergedDataTypeSchema = z7.object({
365
+ id: z7.string(),
366
+ displayName: z7.string(),
367
+ archetype: z7.string().optional(),
368
+ allowedOnComponents: z7.array(z7.string()).optional(),
369
+ badgeIconUrl: z7.string().optional(),
370
+ connectorType: z7.string(),
371
+ url: z7.string(),
372
+ headers: z7.array(parameterDefinitionSchema).optional(),
373
+ parameters: z7.array(parameterDefinitionSchema).optional(),
374
+ body: z7.string().optional(),
375
+ method: z7.enum(["GET", "POST", "HEAD"]),
376
+ variables: z7.record(variableDefinitionSchema).optional(),
377
+ custom: z7.record(z7.unknown()).optional(),
378
+ customPublic: z7.record(z7.unknown()).optional(),
379
+ ttl: z7.number().optional(),
380
+ purgeKey: z7.string().optional(),
381
+ localeMapping: z7.record(z7.string()).optional(),
208
382
  edgehancer: customEdgehancerDefinitionSchema.optional(),
209
- uiBadgeText: z.string().max(12).optional(),
210
- variants: z.object({
383
+ uiBadgeText: z7.string().max(12).optional(),
384
+ variants: z7.object({
211
385
  unpublished: dataSourceVariantSchema.optional()
212
386
  }).optional(),
213
- enableUnpublishedMode: z.boolean().optional()
387
+ enableUnpublishedMode: z7.boolean().optional()
214
388
  });
215
389
  (0, import_tsafe.assert)();
216
- var dataResourceSchema = z.union([
217
- z.string(),
218
- z.object({}).catchall(z.unknown()),
219
- z.number(),
220
- z.boolean(),
221
- z.array(z.unknown()),
222
- z.undefined()
390
+ var dataResourceSchema = z7.union([
391
+ z7.string(),
392
+ z7.object({}).catchall(z7.unknown()),
393
+ z7.number(),
394
+ z7.boolean(),
395
+ z7.array(z7.unknown()),
396
+ z7.undefined()
223
397
  ]);
224
398
 
225
399
  // src/preRequest.ts
@@ -232,40 +406,48 @@ var edgehancerMergedDataTypeSchema = mergedDataTypeSchema.omit({
232
406
  purgeKey: true,
233
407
  variables: true
234
408
  });
235
- var preRequestEdgehancerDataResourceResultSchema = z2.strictObject({
236
- errors: z2.array(resolvingIssueSchema).optional(),
237
- warnings: z2.array(resolvingIssueSchema).optional(),
238
- infos: z2.array(resolvingIssueSchema).optional(),
409
+ var preRequestEdgehancerDataResourceResultSchema = z8.strictObject({
410
+ errors: z8.array(resolvingIssueSchema).optional(),
411
+ warnings: z8.array(resolvingIssueSchema).optional(),
412
+ infos: z8.array(resolvingIssueSchema).optional(),
239
413
  dataResource: edgehancerMergedDataTypeSchema
240
414
  });
241
- var preRequestEdgehancerResultSchema = z2.strictObject({
242
- dataResources: z2.array(preRequestEdgehancerDataResourceResultSchema)
415
+ var preRequestEdgehancerResultSchema = z8.strictObject({
416
+ dataResources: z8.array(preRequestEdgehancerDataResourceResultSchema)
243
417
  });
244
418
 
245
419
  // src/request.ts
246
- var z3 = __toESM(require("zod"));
247
- var requestEdgehancerDataResourceResolutionResultSchema = z3.strictObject({
248
- errors: z3.array(resolvingIssueSchema).optional().describe(
420
+ var z9 = __toESM(require("zod/v3"));
421
+ var requestEdgehancerDataResourceResolutionResultSchema = z9.strictObject({
422
+ errors: z9.array(resolvingIssueSchema).optional().describe(
249
423
  "Errors that occurred while running your code to return with the API response, if any. Unhandled exceptions will be captured automatically."
250
424
  ),
251
- warnings: z3.array(resolvingIssueSchema).optional().describe("Warnings that occurred while running your code to return with the API response, if any."),
252
- infos: z3.array(resolvingIssueSchema).optional().describe(
425
+ warnings: z9.array(resolvingIssueSchema).optional().describe("Warnings that occurred while running your code to return with the API response, if any."),
426
+ infos: z9.array(resolvingIssueSchema).optional().describe(
253
427
  "Informational messages that occurred while running your code to return with the API response, if any."
254
428
  ),
255
- surrogateKeys: z3.array(z3.string()).optional().describe(
429
+ surrogateKeys: z9.array(z9.string()).optional().describe(
256
430
  "Extra surrogate keys for the data that was fetched. These act as auxiliary cache keys that can allow granular purging of cached data."
257
431
  ),
258
432
  result: dataResourceSchema.describe("The result of fetching the data resource")
259
433
  });
260
- var requestEdgehancerResultSchema = z3.strictObject({
261
- results: z3.array(requestEdgehancerDataResourceResolutionResultSchema)
434
+ var requestEdgehancerResultSchema = z9.strictObject({
435
+ results: z9.array(requestEdgehancerDataResourceResolutionResultSchema)
262
436
  });
263
437
  // Annotate the CommonJS export names for ESM import in node:
264
438
  0 && (module.exports = {
265
439
  COLLECTION_DEFAULT_LIMIT,
266
440
  COLLECTION_DEFAULT_OFFSET,
267
441
  COLLECTION_MAX_LIMIT,
442
+ afterAIDataResourceEditContextSchema,
443
+ afterAIDataResourceEditResultSchema,
444
+ afterAIEditContextSchema,
445
+ afterAIEditResultSchema,
268
446
  convertBatchResultsToEdgehancerResult,
447
+ createAIDataResourceEditContextSchema,
448
+ createAIDataResourceEditResultSchema,
449
+ createAIEditContextSchema,
450
+ createAIEditResultSchema,
269
451
  dataResourceSchema,
270
452
  edgehancerMergedDataTypeSchema,
271
453
  getDataResourceAsRequest,