@uniformdev/mesh-edgehancer-sdk 20.36.0 → 20.36.1-alpha.1

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,126 @@ __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"), 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
+
53
181
  // src/batchUtils.ts
54
182
  function convertBatchResultsToEdgehancerResult({
55
183
  batch,
@@ -109,6 +237,54 @@ var COLLECTION_DEFAULT_LIMIT = 20;
109
237
  var COLLECTION_MAX_LIMIT = 50;
110
238
  var COLLECTION_DEFAULT_OFFSET = 0;
111
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
+
112
288
  // src/fetchUtils.ts
113
289
  function getDataResourceAsRequest(data) {
114
290
  var _a;
@@ -148,78 +324,80 @@ function copyKeyValuePairs(source, target) {
148
324
  }
149
325
 
150
326
  // src/preRequest.ts
151
- var z2 = __toESM(require("zod"));
327
+ var z8 = __toESM(require("zod"));
152
328
 
153
329
  // src/shared.ts
154
330
  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()
331
+ var z7 = __toESM(require("zod"));
332
+ var parameterDefinitionSchema = z7.object({
333
+ key: z7.string(),
334
+ value: z7.string(),
335
+ omitIfEmpty: z7.boolean().optional()
160
336
  });
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()
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()
168
344
  })
169
345
  ]);
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()
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()
177
353
  });
178
- var customEdgehancerDefinitionSchema = z.object({
179
- preRequest: z.string().optional(),
180
- request: 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()
181
359
  });
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()
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()
187
365
  }),
188
- z.object({ url: z.string() })
366
+ z7.object({ url: z7.string() })
189
367
  );
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(),
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(),
208
386
  edgehancer: customEdgehancerDefinitionSchema.optional(),
209
- uiBadgeText: z.string().max(12).optional(),
210
- variants: z.object({
387
+ uiBadgeText: z7.string().max(12).optional(),
388
+ variants: z7.object({
211
389
  unpublished: dataSourceVariantSchema.optional()
212
390
  }).optional(),
213
- enableUnpublishedMode: z.boolean().optional()
391
+ enableUnpublishedMode: z7.boolean().optional()
214
392
  });
215
393
  (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()
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()
223
401
  ]);
224
402
 
225
403
  // src/preRequest.ts
@@ -232,40 +410,48 @@ var edgehancerMergedDataTypeSchema = mergedDataTypeSchema.omit({
232
410
  purgeKey: true,
233
411
  variables: true
234
412
  });
235
- var preRequestEdgehancerDataResourceResultSchema = z2.strictObject({
236
- errors: z2.array(resolvingIssueSchema).optional(),
237
- warnings: z2.array(resolvingIssueSchema).optional(),
238
- infos: z2.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(),
239
417
  dataResource: edgehancerMergedDataTypeSchema
240
418
  });
241
- var preRequestEdgehancerResultSchema = z2.strictObject({
242
- dataResources: z2.array(preRequestEdgehancerDataResourceResultSchema)
419
+ var preRequestEdgehancerResultSchema = z8.strictObject({
420
+ dataResources: z8.array(preRequestEdgehancerDataResourceResultSchema)
243
421
  });
244
422
 
245
423
  // src/request.ts
246
- var z3 = __toESM(require("zod"));
247
- var requestEdgehancerDataResourceResolutionResultSchema = z3.strictObject({
248
- errors: z3.array(resolvingIssueSchema).optional().describe(
424
+ var z9 = __toESM(require("zod"));
425
+ var requestEdgehancerDataResourceResolutionResultSchema = z9.strictObject({
426
+ errors: z9.array(resolvingIssueSchema).optional().describe(
249
427
  "Errors that occurred while running your code to return with the API response, if any. Unhandled exceptions will be captured automatically."
250
428
  ),
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(
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(
253
431
  "Informational messages that occurred while running your code to return with the API response, if any."
254
432
  ),
255
- surrogateKeys: z3.array(z3.string()).optional().describe(
433
+ surrogateKeys: z9.array(z9.string()).optional().describe(
256
434
  "Extra surrogate keys for the data that was fetched. These act as auxiliary cache keys that can allow granular purging of cached data."
257
435
  ),
258
436
  result: dataResourceSchema.describe("The result of fetching the data resource")
259
437
  });
260
- var requestEdgehancerResultSchema = z3.strictObject({
261
- results: z3.array(requestEdgehancerDataResourceResolutionResultSchema)
438
+ var requestEdgehancerResultSchema = z9.strictObject({
439
+ results: z9.array(requestEdgehancerDataResourceResolutionResultSchema)
262
440
  });
263
441
  // Annotate the CommonJS export names for ESM import in node:
264
442
  0 && (module.exports = {
265
443
  COLLECTION_DEFAULT_LIMIT,
266
444
  COLLECTION_DEFAULT_OFFSET,
267
445
  COLLECTION_MAX_LIMIT,
446
+ afterAIDataResourceEditContextSchema,
447
+ afterAIDataResourceEditResultSchema,
448
+ afterAIEditContextSchema,
449
+ afterAIEditResultSchema,
268
450
  convertBatchResultsToEdgehancerResult,
451
+ createAIDataResourceEditContextSchema,
452
+ createAIDataResourceEditResultSchema,
453
+ createAIEditContextSchema,
454
+ createAIEditResultSchema,
269
455
  dataResourceSchema,
270
456
  edgehancerMergedDataTypeSchema,
271
457
  getDataResourceAsRequest,