@uipath/uipath-typescript 1.1.2 → 1.2.0

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.cjs CHANGED
@@ -276,6 +276,11 @@ function optionalKeys(shape) {
276
276
  }
277
277
  function pick(schema, mask) {
278
278
  const currDef = schema._zod.def;
279
+ const checks = currDef.checks;
280
+ const hasChecks = checks && checks.length > 0;
281
+ if (hasChecks) {
282
+ throw new Error(".pick() cannot be used on object schemas containing refinements");
283
+ }
279
284
  const def = mergeDefs(schema._zod.def, {
280
285
  get shape() {
281
286
  const newShape = {};
@@ -296,6 +301,11 @@ function pick(schema, mask) {
296
301
  }
297
302
  function omit(schema, mask) {
298
303
  const currDef = schema._zod.def;
304
+ const checks = currDef.checks;
305
+ const hasChecks = checks && checks.length > 0;
306
+ if (hasChecks) {
307
+ throw new Error(".omit() cannot be used on object schemas containing refinements");
308
+ }
299
309
  const def = mergeDefs(schema._zod.def, {
300
310
  get shape() {
301
311
  const newShape = { ...schema._zod.def.shape };
@@ -321,7 +331,14 @@ function extend(schema, shape) {
321
331
  const checks = schema._zod.def.checks;
322
332
  const hasChecks = checks && checks.length > 0;
323
333
  if (hasChecks) {
324
- throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");
334
+ // Only throw if new shape overlaps with existing shape
335
+ // Use getOwnPropertyDescriptor to check key existence without accessing values
336
+ const existingShape = schema._zod.def.shape;
337
+ for (const key in shape) {
338
+ if (Object.getOwnPropertyDescriptor(existingShape, key) !== undefined) {
339
+ throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
340
+ }
341
+ }
325
342
  }
326
343
  const def = mergeDefs(schema._zod.def, {
327
344
  get shape() {
@@ -329,7 +346,6 @@ function extend(schema, shape) {
329
346
  assignProp(this, "shape", _shape); // self-caching
330
347
  return _shape;
331
348
  },
332
- checks: [],
333
349
  });
334
350
  return clone(schema, def);
335
351
  }
@@ -337,15 +353,13 @@ function safeExtend(schema, shape) {
337
353
  if (!isPlainObject(shape)) {
338
354
  throw new Error("Invalid input to safeExtend: expected a plain object");
339
355
  }
340
- const def = {
341
- ...schema._zod.def,
356
+ const def = mergeDefs(schema._zod.def, {
342
357
  get shape() {
343
358
  const _shape = { ...schema._zod.def.shape, ...shape };
344
359
  assignProp(this, "shape", _shape); // self-caching
345
360
  return _shape;
346
361
  },
347
- checks: schema._zod.def.checks,
348
- };
362
+ });
349
363
  return clone(schema, def);
350
364
  }
351
365
  function merge(a, b) {
@@ -363,6 +377,12 @@ function merge(a, b) {
363
377
  return clone(a, def);
364
378
  }
365
379
  function partial(Class, schema, mask) {
380
+ const currDef = schema._zod.def;
381
+ const checks = currDef.checks;
382
+ const hasChecks = checks && checks.length > 0;
383
+ if (hasChecks) {
384
+ throw new Error(".partial() cannot be used on object schemas containing refinements");
385
+ }
366
386
  const def = mergeDefs(schema._zod.def, {
367
387
  get shape() {
368
388
  const oldShape = schema._zod.def.shape;
@@ -432,7 +452,6 @@ function required(Class, schema, mask) {
432
452
  assignProp(this, "shape", shape); // self-caching
433
453
  return shape;
434
454
  },
435
- checks: [],
436
455
  });
437
456
  return clone(schema, def);
438
457
  }
@@ -682,7 +701,8 @@ const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?:
682
701
  const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
683
702
  const base64url = /^[A-Za-z0-9_-]*$/;
684
703
  // https://blog.stevenlevithan.com/archives/validate-phone-number#r4-3 (regex sans spaces)
685
- const e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
704
+ // E.164: leading digit must be 1-9; total digits (excluding '+') between 7-15
705
+ const e164 = /^\+[1-9]\d{6,14}$/;
686
706
  // const dateSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
687
707
  const dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
688
708
  const date$1 = /*@__PURE__*/ new RegExp(`^${dateSource}$`);
@@ -986,8 +1006,8 @@ class Doc {
986
1006
 
987
1007
  const version = {
988
1008
  major: 4,
989
- minor: 2,
990
- patch: 1,
1009
+ minor: 3,
1010
+ patch: 6,
991
1011
  };
992
1012
 
993
1013
  const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
@@ -1097,7 +1117,8 @@ const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
1097
1117
  return runChecks(result, checks, ctx);
1098
1118
  };
1099
1119
  }
1100
- inst["~standard"] = {
1120
+ // Lazy initialize ~standard to avoid creating objects for every schema
1121
+ defineLazy(inst, "~standard", () => ({
1101
1122
  validate: (value) => {
1102
1123
  try {
1103
1124
  const r = safeParse$1(inst, value);
@@ -1109,7 +1130,7 @@ const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
1109
1130
  },
1110
1131
  vendor: "zod",
1111
1132
  version: 1,
1112
- };
1133
+ }));
1113
1134
  });
1114
1135
  const $ZodString = /*@__PURE__*/ $constructor("$ZodString", (inst, def) => {
1115
1136
  $ZodType.init(inst, def);
@@ -1479,8 +1500,12 @@ const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
1479
1500
  return payload; //handleArrayResultsAsync(parseResults, final);
1480
1501
  };
1481
1502
  });
1482
- function handlePropertyResult(result, final, key, input) {
1503
+ function handlePropertyResult(result, final, key, input, isOptionalOut) {
1483
1504
  if (result.issues.length) {
1505
+ // For optional-out schemas, ignore errors on absent keys
1506
+ if (isOptionalOut && !(key in input)) {
1507
+ return;
1508
+ }
1484
1509
  final.issues.push(...prefixIssues(key, result.issues));
1485
1510
  }
1486
1511
  if (result.value === undefined) {
@@ -1514,6 +1539,7 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
1514
1539
  const keySet = def.keySet;
1515
1540
  const _catchall = def.catchall._zod;
1516
1541
  const t = _catchall.def.type;
1542
+ const isOptionalOut = _catchall.optout === "optional";
1517
1543
  for (const key in input) {
1518
1544
  if (keySet.has(key))
1519
1545
  continue;
@@ -1523,10 +1549,10 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
1523
1549
  }
1524
1550
  const r = _catchall.run({ value: input[key], issues: [] }, ctx);
1525
1551
  if (r instanceof Promise) {
1526
- proms.push(r.then((r) => handlePropertyResult(r, payload, key, input)));
1552
+ proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
1527
1553
  }
1528
1554
  else {
1529
- handlePropertyResult(r, payload, key, input);
1555
+ handlePropertyResult(r, payload, key, input, isOptionalOut);
1530
1556
  }
1531
1557
  }
1532
1558
  if (unrecognized.length) {
@@ -1594,12 +1620,13 @@ const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
1594
1620
  const shape = value.shape;
1595
1621
  for (const key of value.keys) {
1596
1622
  const el = shape[key];
1623
+ const isOptionalOut = el._zod.optout === "optional";
1597
1624
  const r = el._zod.run({ value: input[key], issues: [] }, ctx);
1598
1625
  if (r instanceof Promise) {
1599
- proms.push(r.then((r) => handlePropertyResult(r, payload, key, input)));
1626
+ proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
1600
1627
  }
1601
1628
  else {
1602
- handlePropertyResult(r, payload, key, input);
1629
+ handlePropertyResult(r, payload, key, input, isOptionalOut);
1603
1630
  }
1604
1631
  }
1605
1632
  if (!catchall) {
@@ -1631,8 +1658,33 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) =>
1631
1658
  for (const key of normalized.keys) {
1632
1659
  const id = ids[key];
1633
1660
  const k = esc(key);
1661
+ const schema = shape[key];
1662
+ const isOptionalOut = schema?._zod?.optout === "optional";
1634
1663
  doc.write(`const ${id} = ${parseStr(key)};`);
1635
- doc.write(`
1664
+ if (isOptionalOut) {
1665
+ // For optional-out schemas, ignore errors on absent keys
1666
+ doc.write(`
1667
+ if (${id}.issues.length) {
1668
+ if (${k} in input) {
1669
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1670
+ ...iss,
1671
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
1672
+ })));
1673
+ }
1674
+ }
1675
+
1676
+ if (${id}.value === undefined) {
1677
+ if (${k} in input) {
1678
+ newResult[${k}] = undefined;
1679
+ }
1680
+ } else {
1681
+ newResult[${k}] = ${id}.value;
1682
+ }
1683
+
1684
+ `);
1685
+ }
1686
+ else {
1687
+ doc.write(`
1636
1688
  if (${id}.issues.length) {
1637
1689
  payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1638
1690
  ...iss,
@@ -1640,7 +1692,6 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) =>
1640
1692
  })));
1641
1693
  }
1642
1694
 
1643
-
1644
1695
  if (${id}.value === undefined) {
1645
1696
  if (${k} in input) {
1646
1697
  newResult[${k}] = undefined;
@@ -1650,6 +1701,7 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) =>
1650
1701
  }
1651
1702
 
1652
1703
  `);
1704
+ }
1653
1705
  }
1654
1706
  doc.write(`payload.value = newResult;`);
1655
1707
  doc.write(`return payload;`);
@@ -1816,11 +1868,38 @@ function mergeValues(a, b) {
1816
1868
  return { valid: false, mergeErrorPath: [] };
1817
1869
  }
1818
1870
  function handleIntersectionResults(result, left, right) {
1819
- if (left.issues.length) {
1820
- result.issues.push(...left.issues);
1871
+ // Track which side(s) report each key as unrecognized
1872
+ const unrecKeys = new Map();
1873
+ let unrecIssue;
1874
+ for (const iss of left.issues) {
1875
+ if (iss.code === "unrecognized_keys") {
1876
+ unrecIssue ?? (unrecIssue = iss);
1877
+ for (const k of iss.keys) {
1878
+ if (!unrecKeys.has(k))
1879
+ unrecKeys.set(k, {});
1880
+ unrecKeys.get(k).l = true;
1881
+ }
1882
+ }
1883
+ else {
1884
+ result.issues.push(iss);
1885
+ }
1821
1886
  }
1822
- if (right.issues.length) {
1823
- result.issues.push(...right.issues);
1887
+ for (const iss of right.issues) {
1888
+ if (iss.code === "unrecognized_keys") {
1889
+ for (const k of iss.keys) {
1890
+ if (!unrecKeys.has(k))
1891
+ unrecKeys.set(k, {});
1892
+ unrecKeys.get(k).r = true;
1893
+ }
1894
+ }
1895
+ else {
1896
+ result.issues.push(iss);
1897
+ }
1898
+ }
1899
+ // Report only keys unrecognized by BOTH sides
1900
+ const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
1901
+ if (bothKeys.length && unrecIssue) {
1902
+ result.issues.push({ ...unrecIssue, keys: bothKeys });
1824
1903
  }
1825
1904
  if (aborted(result))
1826
1905
  return result;
@@ -1905,6 +1984,17 @@ const $ZodOptional = /*@__PURE__*/ $constructor("$ZodOptional", (inst, def) => {
1905
1984
  return def.innerType._zod.run(payload, ctx);
1906
1985
  };
1907
1986
  });
1987
+ const $ZodExactOptional = /*@__PURE__*/ $constructor("$ZodExactOptional", (inst, def) => {
1988
+ // Call parent init - inherits optin/optout = "optional"
1989
+ $ZodOptional.init(inst, def);
1990
+ // Override values/pattern to NOT add undefined
1991
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1992
+ defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
1993
+ // Override parse to just delegate (no undefined handling)
1994
+ inst._zod.parse = (payload, ctx) => {
1995
+ return def.innerType._zod.run(payload, ctx);
1996
+ };
1997
+ });
1908
1998
  const $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (inst, def) => {
1909
1999
  $ZodType.init(inst, def);
1910
2000
  defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
@@ -2127,9 +2217,6 @@ class $ZodRegistry {
2127
2217
  const meta = _meta[0];
2128
2218
  this._map.set(schema, meta);
2129
2219
  if (meta && typeof meta === "object" && "id" in meta) {
2130
- if (this._idmap.has(meta.id)) {
2131
- throw new Error(`ID ${meta.id} already exists in the registry`);
2132
- }
2133
2220
  this._idmap.set(meta.id, schema);
2134
2221
  }
2135
2222
  return this;
@@ -2170,12 +2257,14 @@ function registry() {
2170
2257
  (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
2171
2258
  const globalRegistry = globalThis.__zod_globalRegistry;
2172
2259
 
2260
+ // @__NO_SIDE_EFFECTS__
2173
2261
  function _string(Class, params) {
2174
2262
  return new Class({
2175
2263
  type: "string",
2176
2264
  ...normalizeParams(params),
2177
2265
  });
2178
2266
  }
2267
+ // @__NO_SIDE_EFFECTS__
2179
2268
  function _email(Class, params) {
2180
2269
  return new Class({
2181
2270
  type: "string",
@@ -2185,6 +2274,7 @@ function _email(Class, params) {
2185
2274
  ...normalizeParams(params),
2186
2275
  });
2187
2276
  }
2277
+ // @__NO_SIDE_EFFECTS__
2188
2278
  function _guid(Class, params) {
2189
2279
  return new Class({
2190
2280
  type: "string",
@@ -2194,6 +2284,7 @@ function _guid(Class, params) {
2194
2284
  ...normalizeParams(params),
2195
2285
  });
2196
2286
  }
2287
+ // @__NO_SIDE_EFFECTS__
2197
2288
  function _uuid(Class, params) {
2198
2289
  return new Class({
2199
2290
  type: "string",
@@ -2203,6 +2294,7 @@ function _uuid(Class, params) {
2203
2294
  ...normalizeParams(params),
2204
2295
  });
2205
2296
  }
2297
+ // @__NO_SIDE_EFFECTS__
2206
2298
  function _uuidv4(Class, params) {
2207
2299
  return new Class({
2208
2300
  type: "string",
@@ -2213,6 +2305,7 @@ function _uuidv4(Class, params) {
2213
2305
  ...normalizeParams(params),
2214
2306
  });
2215
2307
  }
2308
+ // @__NO_SIDE_EFFECTS__
2216
2309
  function _uuidv6(Class, params) {
2217
2310
  return new Class({
2218
2311
  type: "string",
@@ -2223,6 +2316,7 @@ function _uuidv6(Class, params) {
2223
2316
  ...normalizeParams(params),
2224
2317
  });
2225
2318
  }
2319
+ // @__NO_SIDE_EFFECTS__
2226
2320
  function _uuidv7(Class, params) {
2227
2321
  return new Class({
2228
2322
  type: "string",
@@ -2233,6 +2327,7 @@ function _uuidv7(Class, params) {
2233
2327
  ...normalizeParams(params),
2234
2328
  });
2235
2329
  }
2330
+ // @__NO_SIDE_EFFECTS__
2236
2331
  function _url(Class, params) {
2237
2332
  return new Class({
2238
2333
  type: "string",
@@ -2242,6 +2337,7 @@ function _url(Class, params) {
2242
2337
  ...normalizeParams(params),
2243
2338
  });
2244
2339
  }
2340
+ // @__NO_SIDE_EFFECTS__
2245
2341
  function _emoji(Class, params) {
2246
2342
  return new Class({
2247
2343
  type: "string",
@@ -2251,6 +2347,7 @@ function _emoji(Class, params) {
2251
2347
  ...normalizeParams(params),
2252
2348
  });
2253
2349
  }
2350
+ // @__NO_SIDE_EFFECTS__
2254
2351
  function _nanoid(Class, params) {
2255
2352
  return new Class({
2256
2353
  type: "string",
@@ -2260,6 +2357,7 @@ function _nanoid(Class, params) {
2260
2357
  ...normalizeParams(params),
2261
2358
  });
2262
2359
  }
2360
+ // @__NO_SIDE_EFFECTS__
2263
2361
  function _cuid(Class, params) {
2264
2362
  return new Class({
2265
2363
  type: "string",
@@ -2269,6 +2367,7 @@ function _cuid(Class, params) {
2269
2367
  ...normalizeParams(params),
2270
2368
  });
2271
2369
  }
2370
+ // @__NO_SIDE_EFFECTS__
2272
2371
  function _cuid2(Class, params) {
2273
2372
  return new Class({
2274
2373
  type: "string",
@@ -2278,6 +2377,7 @@ function _cuid2(Class, params) {
2278
2377
  ...normalizeParams(params),
2279
2378
  });
2280
2379
  }
2380
+ // @__NO_SIDE_EFFECTS__
2281
2381
  function _ulid(Class, params) {
2282
2382
  return new Class({
2283
2383
  type: "string",
@@ -2287,6 +2387,7 @@ function _ulid(Class, params) {
2287
2387
  ...normalizeParams(params),
2288
2388
  });
2289
2389
  }
2390
+ // @__NO_SIDE_EFFECTS__
2290
2391
  function _xid(Class, params) {
2291
2392
  return new Class({
2292
2393
  type: "string",
@@ -2296,6 +2397,7 @@ function _xid(Class, params) {
2296
2397
  ...normalizeParams(params),
2297
2398
  });
2298
2399
  }
2400
+ // @__NO_SIDE_EFFECTS__
2299
2401
  function _ksuid(Class, params) {
2300
2402
  return new Class({
2301
2403
  type: "string",
@@ -2305,6 +2407,7 @@ function _ksuid(Class, params) {
2305
2407
  ...normalizeParams(params),
2306
2408
  });
2307
2409
  }
2410
+ // @__NO_SIDE_EFFECTS__
2308
2411
  function _ipv4(Class, params) {
2309
2412
  return new Class({
2310
2413
  type: "string",
@@ -2314,6 +2417,7 @@ function _ipv4(Class, params) {
2314
2417
  ...normalizeParams(params),
2315
2418
  });
2316
2419
  }
2420
+ // @__NO_SIDE_EFFECTS__
2317
2421
  function _ipv6(Class, params) {
2318
2422
  return new Class({
2319
2423
  type: "string",
@@ -2323,6 +2427,7 @@ function _ipv6(Class, params) {
2323
2427
  ...normalizeParams(params),
2324
2428
  });
2325
2429
  }
2430
+ // @__NO_SIDE_EFFECTS__
2326
2431
  function _cidrv4(Class, params) {
2327
2432
  return new Class({
2328
2433
  type: "string",
@@ -2332,6 +2437,7 @@ function _cidrv4(Class, params) {
2332
2437
  ...normalizeParams(params),
2333
2438
  });
2334
2439
  }
2440
+ // @__NO_SIDE_EFFECTS__
2335
2441
  function _cidrv6(Class, params) {
2336
2442
  return new Class({
2337
2443
  type: "string",
@@ -2341,6 +2447,7 @@ function _cidrv6(Class, params) {
2341
2447
  ...normalizeParams(params),
2342
2448
  });
2343
2449
  }
2450
+ // @__NO_SIDE_EFFECTS__
2344
2451
  function _base64(Class, params) {
2345
2452
  return new Class({
2346
2453
  type: "string",
@@ -2350,6 +2457,7 @@ function _base64(Class, params) {
2350
2457
  ...normalizeParams(params),
2351
2458
  });
2352
2459
  }
2460
+ // @__NO_SIDE_EFFECTS__
2353
2461
  function _base64url(Class, params) {
2354
2462
  return new Class({
2355
2463
  type: "string",
@@ -2359,6 +2467,7 @@ function _base64url(Class, params) {
2359
2467
  ...normalizeParams(params),
2360
2468
  });
2361
2469
  }
2470
+ // @__NO_SIDE_EFFECTS__
2362
2471
  function _e164(Class, params) {
2363
2472
  return new Class({
2364
2473
  type: "string",
@@ -2368,6 +2477,7 @@ function _e164(Class, params) {
2368
2477
  ...normalizeParams(params),
2369
2478
  });
2370
2479
  }
2480
+ // @__NO_SIDE_EFFECTS__
2371
2481
  function _jwt(Class, params) {
2372
2482
  return new Class({
2373
2483
  type: "string",
@@ -2377,6 +2487,7 @@ function _jwt(Class, params) {
2377
2487
  ...normalizeParams(params),
2378
2488
  });
2379
2489
  }
2490
+ // @__NO_SIDE_EFFECTS__
2380
2491
  function _isoDateTime(Class, params) {
2381
2492
  return new Class({
2382
2493
  type: "string",
@@ -2388,6 +2499,7 @@ function _isoDateTime(Class, params) {
2388
2499
  ...normalizeParams(params),
2389
2500
  });
2390
2501
  }
2502
+ // @__NO_SIDE_EFFECTS__
2391
2503
  function _isoDate(Class, params) {
2392
2504
  return new Class({
2393
2505
  type: "string",
@@ -2396,6 +2508,7 @@ function _isoDate(Class, params) {
2396
2508
  ...normalizeParams(params),
2397
2509
  });
2398
2510
  }
2511
+ // @__NO_SIDE_EFFECTS__
2399
2512
  function _isoTime(Class, params) {
2400
2513
  return new Class({
2401
2514
  type: "string",
@@ -2405,6 +2518,7 @@ function _isoTime(Class, params) {
2405
2518
  ...normalizeParams(params),
2406
2519
  });
2407
2520
  }
2521
+ // @__NO_SIDE_EFFECTS__
2408
2522
  function _isoDuration(Class, params) {
2409
2523
  return new Class({
2410
2524
  type: "string",
@@ -2413,17 +2527,20 @@ function _isoDuration(Class, params) {
2413
2527
  ...normalizeParams(params),
2414
2528
  });
2415
2529
  }
2530
+ // @__NO_SIDE_EFFECTS__
2416
2531
  function _unknown(Class) {
2417
2532
  return new Class({
2418
2533
  type: "unknown",
2419
2534
  });
2420
2535
  }
2536
+ // @__NO_SIDE_EFFECTS__
2421
2537
  function _never(Class, params) {
2422
2538
  return new Class({
2423
2539
  type: "never",
2424
2540
  ...normalizeParams(params),
2425
2541
  });
2426
2542
  }
2543
+ // @__NO_SIDE_EFFECTS__
2427
2544
  function _maxLength(maximum, params) {
2428
2545
  const ch = new $ZodCheckMaxLength({
2429
2546
  check: "max_length",
@@ -2432,6 +2549,7 @@ function _maxLength(maximum, params) {
2432
2549
  });
2433
2550
  return ch;
2434
2551
  }
2552
+ // @__NO_SIDE_EFFECTS__
2435
2553
  function _minLength(minimum, params) {
2436
2554
  return new $ZodCheckMinLength({
2437
2555
  check: "min_length",
@@ -2439,6 +2557,7 @@ function _minLength(minimum, params) {
2439
2557
  minimum,
2440
2558
  });
2441
2559
  }
2560
+ // @__NO_SIDE_EFFECTS__
2442
2561
  function _length(length, params) {
2443
2562
  return new $ZodCheckLengthEquals({
2444
2563
  check: "length_equals",
@@ -2446,6 +2565,7 @@ function _length(length, params) {
2446
2565
  length,
2447
2566
  });
2448
2567
  }
2568
+ // @__NO_SIDE_EFFECTS__
2449
2569
  function _regex(pattern, params) {
2450
2570
  return new $ZodCheckRegex({
2451
2571
  check: "string_format",
@@ -2454,6 +2574,7 @@ function _regex(pattern, params) {
2454
2574
  pattern,
2455
2575
  });
2456
2576
  }
2577
+ // @__NO_SIDE_EFFECTS__
2457
2578
  function _lowercase(params) {
2458
2579
  return new $ZodCheckLowerCase({
2459
2580
  check: "string_format",
@@ -2461,6 +2582,7 @@ function _lowercase(params) {
2461
2582
  ...normalizeParams(params),
2462
2583
  });
2463
2584
  }
2585
+ // @__NO_SIDE_EFFECTS__
2464
2586
  function _uppercase(params) {
2465
2587
  return new $ZodCheckUpperCase({
2466
2588
  check: "string_format",
@@ -2468,6 +2590,7 @@ function _uppercase(params) {
2468
2590
  ...normalizeParams(params),
2469
2591
  });
2470
2592
  }
2593
+ // @__NO_SIDE_EFFECTS__
2471
2594
  function _includes(includes, params) {
2472
2595
  return new $ZodCheckIncludes({
2473
2596
  check: "string_format",
@@ -2476,6 +2599,7 @@ function _includes(includes, params) {
2476
2599
  includes,
2477
2600
  });
2478
2601
  }
2602
+ // @__NO_SIDE_EFFECTS__
2479
2603
  function _startsWith(prefix, params) {
2480
2604
  return new $ZodCheckStartsWith({
2481
2605
  check: "string_format",
@@ -2484,6 +2608,7 @@ function _startsWith(prefix, params) {
2484
2608
  prefix,
2485
2609
  });
2486
2610
  }
2611
+ // @__NO_SIDE_EFFECTS__
2487
2612
  function _endsWith(suffix, params) {
2488
2613
  return new $ZodCheckEndsWith({
2489
2614
  check: "string_format",
@@ -2492,6 +2617,7 @@ function _endsWith(suffix, params) {
2492
2617
  suffix,
2493
2618
  });
2494
2619
  }
2620
+ // @__NO_SIDE_EFFECTS__
2495
2621
  function _overwrite(tx) {
2496
2622
  return new $ZodCheckOverwrite({
2497
2623
  check: "overwrite",
@@ -2499,25 +2625,31 @@ function _overwrite(tx) {
2499
2625
  });
2500
2626
  }
2501
2627
  // normalize
2628
+ // @__NO_SIDE_EFFECTS__
2502
2629
  function _normalize(form) {
2503
2630
  return _overwrite((input) => input.normalize(form));
2504
2631
  }
2505
2632
  // trim
2633
+ // @__NO_SIDE_EFFECTS__
2506
2634
  function _trim() {
2507
2635
  return _overwrite((input) => input.trim());
2508
2636
  }
2509
2637
  // toLowerCase
2638
+ // @__NO_SIDE_EFFECTS__
2510
2639
  function _toLowerCase() {
2511
2640
  return _overwrite((input) => input.toLowerCase());
2512
2641
  }
2513
2642
  // toUpperCase
2643
+ // @__NO_SIDE_EFFECTS__
2514
2644
  function _toUpperCase() {
2515
2645
  return _overwrite((input) => input.toUpperCase());
2516
2646
  }
2517
2647
  // slugify
2648
+ // @__NO_SIDE_EFFECTS__
2518
2649
  function _slugify() {
2519
2650
  return _overwrite((input) => slugify(input));
2520
2651
  }
2652
+ // @__NO_SIDE_EFFECTS__
2521
2653
  function _array(Class, element, params) {
2522
2654
  return new Class({
2523
2655
  type: "array",
@@ -2529,6 +2661,7 @@ function _array(Class, element, params) {
2529
2661
  });
2530
2662
  }
2531
2663
  // same as _custom but defaults to abort:false
2664
+ // @__NO_SIDE_EFFECTS__
2532
2665
  function _refine(Class, fn, _params) {
2533
2666
  const schema = new Class({
2534
2667
  type: "custom",
@@ -2538,6 +2671,7 @@ function _refine(Class, fn, _params) {
2538
2671
  });
2539
2672
  return schema;
2540
2673
  }
2674
+ // @__NO_SIDE_EFFECTS__
2541
2675
  function _superRefine(fn) {
2542
2676
  const ch = _check((payload) => {
2543
2677
  payload.addIssue = (issue$1) => {
@@ -2560,6 +2694,7 @@ function _superRefine(fn) {
2560
2694
  });
2561
2695
  return ch;
2562
2696
  }
2697
+ // @__NO_SIDE_EFFECTS__
2563
2698
  function _check(fn, params) {
2564
2699
  const ch = new $ZodCheck({
2565
2700
  check: "custom",
@@ -2626,14 +2761,7 @@ function process(schema, ctx, _params = { path: [], schemaPath: [] }) {
2626
2761
  schemaPath: [..._params.schemaPath, schema],
2627
2762
  path: _params.path,
2628
2763
  };
2629
- const parent = schema._zod.parent;
2630
- if (parent) {
2631
- // schema was cloned from another schema
2632
- result.ref = parent;
2633
- process(parent, ctx, params);
2634
- ctx.seen.get(parent).isParent = true;
2635
- }
2636
- else if (schema._zod.processJSONSchema) {
2764
+ if (schema._zod.processJSONSchema) {
2637
2765
  schema._zod.processJSONSchema(ctx, result.schema, params);
2638
2766
  }
2639
2767
  else {
@@ -2644,6 +2772,14 @@ function process(schema, ctx, _params = { path: [], schemaPath: [] }) {
2644
2772
  }
2645
2773
  processor(schema, ctx, _json, params);
2646
2774
  }
2775
+ const parent = schema._zod.parent;
2776
+ if (parent) {
2777
+ // Also set ref if processor didn't (for inheritance)
2778
+ if (!result.ref)
2779
+ result.ref = parent;
2780
+ process(parent, ctx, params);
2781
+ ctx.seen.get(parent).isParent = true;
2782
+ }
2647
2783
  }
2648
2784
  // metadata
2649
2785
  const meta = ctx.metadataRegistry.get(schema);
@@ -2669,6 +2805,18 @@ function extractDefs(ctx, schema
2669
2805
  const root = ctx.seen.get(schema);
2670
2806
  if (!root)
2671
2807
  throw new Error("Unprocessed schema. This is a bug in Zod.");
2808
+ // Track ids to detect duplicates across different schemas
2809
+ const idToSchema = new Map();
2810
+ for (const entry of ctx.seen.entries()) {
2811
+ const id = ctx.metadataRegistry.get(entry[0])?.id;
2812
+ if (id) {
2813
+ const existing = idToSchema.get(id);
2814
+ if (existing && existing !== entry[0]) {
2815
+ throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
2816
+ }
2817
+ idToSchema.set(id, entry[0]);
2818
+ }
2819
+ }
2672
2820
  // returns a ref to the schema
2673
2821
  // defId will be empty if the ref points to an external schema (or #)
2674
2822
  const makeURI = (entry) => {
@@ -2770,43 +2918,84 @@ function extractDefs(ctx, schema
2770
2918
  }
2771
2919
  }
2772
2920
  function finalize(ctx, schema) {
2773
- //
2774
- // iterate over seen map;
2775
2921
  const root = ctx.seen.get(schema);
2776
2922
  if (!root)
2777
2923
  throw new Error("Unprocessed schema. This is a bug in Zod.");
2778
- // flatten _refs
2924
+ // flatten refs - inherit properties from parent schemas
2779
2925
  const flattenRef = (zodSchema) => {
2780
2926
  const seen = ctx.seen.get(zodSchema);
2927
+ // already processed
2928
+ if (seen.ref === null)
2929
+ return;
2781
2930
  const schema = seen.def ?? seen.schema;
2782
2931
  const _cached = { ...schema };
2783
- // already seen
2784
- if (seen.ref === null) {
2785
- return;
2786
- }
2787
- // flatten ref if defined
2788
2932
  const ref = seen.ref;
2789
- seen.ref = null; // prevent recursion
2933
+ seen.ref = null; // prevent infinite recursion
2790
2934
  if (ref) {
2791
2935
  flattenRef(ref);
2936
+ const refSeen = ctx.seen.get(ref);
2937
+ const refSchema = refSeen.schema;
2792
2938
  // merge referenced schema into current
2793
- const refSchema = ctx.seen.get(ref).schema;
2794
2939
  if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
2940
+ // older drafts can't combine $ref with other properties
2795
2941
  schema.allOf = schema.allOf ?? [];
2796
2942
  schema.allOf.push(refSchema);
2797
2943
  }
2798
2944
  else {
2799
2945
  Object.assign(schema, refSchema);
2800
- Object.assign(schema, _cached); // prevent overwriting any fields in the original schema
2946
+ }
2947
+ // restore child's own properties (child wins)
2948
+ Object.assign(schema, _cached);
2949
+ const isParentRef = zodSchema._zod.parent === ref;
2950
+ // For parent chain, child is a refinement - remove parent-only properties
2951
+ if (isParentRef) {
2952
+ for (const key in schema) {
2953
+ if (key === "$ref" || key === "allOf")
2954
+ continue;
2955
+ if (!(key in _cached)) {
2956
+ delete schema[key];
2957
+ }
2958
+ }
2959
+ }
2960
+ // When ref was extracted to $defs, remove properties that match the definition
2961
+ if (refSchema.$ref && refSeen.def) {
2962
+ for (const key in schema) {
2963
+ if (key === "$ref" || key === "allOf")
2964
+ continue;
2965
+ if (key in refSeen.def && JSON.stringify(schema[key]) === JSON.stringify(refSeen.def[key])) {
2966
+ delete schema[key];
2967
+ }
2968
+ }
2969
+ }
2970
+ }
2971
+ // If parent was extracted (has $ref), propagate $ref to this schema
2972
+ // This handles cases like: readonly().meta({id}).describe()
2973
+ // where processor sets ref to innerType but parent should be referenced
2974
+ const parent = zodSchema._zod.parent;
2975
+ if (parent && parent !== ref) {
2976
+ // Ensure parent is processed first so its def has inherited properties
2977
+ flattenRef(parent);
2978
+ const parentSeen = ctx.seen.get(parent);
2979
+ if (parentSeen?.schema.$ref) {
2980
+ schema.$ref = parentSeen.schema.$ref;
2981
+ // De-duplicate with parent's definition
2982
+ if (parentSeen.def) {
2983
+ for (const key in schema) {
2984
+ if (key === "$ref" || key === "allOf")
2985
+ continue;
2986
+ if (key in parentSeen.def && JSON.stringify(schema[key]) === JSON.stringify(parentSeen.def[key])) {
2987
+ delete schema[key];
2988
+ }
2989
+ }
2990
+ }
2801
2991
  }
2802
2992
  }
2803
2993
  // execute overrides
2804
- if (!seen.isParent)
2805
- ctx.override({
2806
- zodSchema: zodSchema,
2807
- jsonSchema: schema,
2808
- path: seen.path ?? [],
2809
- });
2994
+ ctx.override({
2995
+ zodSchema: zodSchema,
2996
+ jsonSchema: schema,
2997
+ path: seen.path ?? [],
2998
+ });
2810
2999
  };
2811
3000
  for (const entry of [...ctx.seen.entries()].reverse()) {
2812
3001
  flattenRef(entry[0]);
@@ -2859,8 +3048,8 @@ function finalize(ctx, schema) {
2859
3048
  value: {
2860
3049
  ...schema["~standard"],
2861
3050
  jsonSchema: {
2862
- input: createStandardJSONSchemaMethod(schema, "input"),
2863
- output: createStandardJSONSchemaMethod(schema, "output"),
3051
+ input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
3052
+ output: createStandardJSONSchemaMethod(schema, "output", ctx.processors),
2864
3053
  },
2865
3054
  },
2866
3055
  enumerable: false,
@@ -2939,9 +3128,9 @@ const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
2939
3128
  extractDefs(ctx, schema);
2940
3129
  return finalize(ctx, schema);
2941
3130
  };
2942
- const createStandardJSONSchemaMethod = (schema, io) => (params) => {
3131
+ const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
2943
3132
  const { libraryOptions, target } = params ?? {};
2944
- const ctx = initializeContext({ ...(libraryOptions ?? {}), target, io, processors: {} });
3133
+ const ctx = initializeContext({ ...(libraryOptions ?? {}), target, io, processors });
2945
3134
  process(schema, ctx);
2946
3135
  extractDefs(ctx, schema);
2947
3136
  return finalize(ctx, schema);
@@ -2969,6 +3158,11 @@ const stringProcessor = (schema, ctx, _json, _params) => {
2969
3158
  json.format = formatMap[format] ?? format;
2970
3159
  if (json.format === "")
2971
3160
  delete json.format; // empty format is not valid
3161
+ // JSON Schema format: "time" requires a full time with offset or Z
3162
+ // z.iso.time() does not include timezone information, so format: "time" should never be used
3163
+ if (format === "time") {
3164
+ delete json.format;
3165
+ }
2972
3166
  }
2973
3167
  if (contentEncoding)
2974
3168
  json.contentEncoding = contentEncoding;
@@ -3277,8 +3471,11 @@ const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
3277
3471
  ...(def.checks ?? []),
3278
3472
  ...checks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch),
3279
3473
  ],
3280
- }));
3474
+ }), {
3475
+ parent: true,
3476
+ });
3281
3477
  };
3478
+ inst.with = inst.check;
3282
3479
  inst.clone = (def, params) => clone(inst, def, params);
3283
3480
  inst.brand = () => inst;
3284
3481
  inst.register = ((reg, meta) => {
@@ -3306,6 +3503,7 @@ const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
3306
3503
  inst.overwrite = (fn) => inst.check(_overwrite(fn));
3307
3504
  // wrappers
3308
3505
  inst.optional = () => optional(inst);
3506
+ inst.exactOptional = () => exactOptional(inst);
3309
3507
  inst.nullable = () => nullable(inst);
3310
3508
  inst.nullish = () => optional(nullable(inst));
3311
3509
  inst.nonoptional = (params) => nonoptional(inst, params);
@@ -3342,6 +3540,7 @@ const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
3342
3540
  // helpers
3343
3541
  inst.isOptional = () => inst.safeParse(undefined).success;
3344
3542
  inst.isNullable = () => inst.safeParse(null).success;
3543
+ inst.apply = (fn) => fn(inst);
3345
3544
  return inst;
3346
3545
  });
3347
3546
  /** @internal */
@@ -3692,6 +3891,18 @@ function optional(innerType) {
3692
3891
  innerType: innerType,
3693
3892
  });
3694
3893
  }
3894
+ const ZodExactOptional = /*@__PURE__*/ $constructor("ZodExactOptional", (inst, def) => {
3895
+ $ZodExactOptional.init(inst, def);
3896
+ ZodType.init(inst, def);
3897
+ inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
3898
+ inst.unwrap = () => inst._zod.def.innerType;
3899
+ });
3900
+ function exactOptional(innerType) {
3901
+ return new ZodExactOptional({
3902
+ type: "optional",
3903
+ innerType: innerType,
3904
+ });
3905
+ }
3695
3906
  const ZodNullable = /*@__PURE__*/ $constructor("ZodNullable", (inst, def) => {
3696
3907
  $ZodNullable.init(inst, def);
3697
3908
  ZodType.init(inst, def);
@@ -3831,7 +4042,6 @@ class UiPathConfig {
3831
4042
  class ExecutionContext {
3832
4043
  constructor() {
3833
4044
  this.context = new Map();
3834
- this.headers = {};
3835
4045
  }
3836
4046
  /**
3837
4047
  * Set a context value that will be available throughout the execution
@@ -3846,35 +4056,10 @@ class ExecutionContext {
3846
4056
  return this.context.get(key);
3847
4057
  }
3848
4058
  /**
3849
- * Set custom headers that will be included in all API requests
3850
- */
3851
- setHeaders(headers) {
3852
- this.headers = { ...this.headers, ...headers };
3853
- }
3854
- /**
3855
- * Get all custom headers
3856
- */
3857
- getHeaders() {
3858
- return { ...this.headers };
3859
- }
3860
- /**
3861
- * Clear all context and headers
4059
+ * Clear all context
3862
4060
  */
3863
4061
  clear() {
3864
4062
  this.context.clear();
3865
- this.headers = {};
3866
- }
3867
- /**
3868
- * Create a request spec for an API call
3869
- */
3870
- createRequestSpec(spec = {}) {
3871
- return {
3872
- ...spec,
3873
- headers: {
3874
- ...this.getHeaders(),
3875
- ...spec.headers
3876
- }
3877
- };
3878
4063
  }
3879
4064
  }
3880
4065
 
@@ -4692,7 +4877,9 @@ const DATA_FABRIC_ENDPOINTS = {
4692
4877
  BATCH_INSERT_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/insert-batch`,
4693
4878
  UPDATE_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/update-batch`,
4694
4879
  DELETE_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/delete-batch`,
4695
- DOWNLOAD_ATTACHMENT: (entityName, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/${entityName}/${recordId}/${fieldName}`,
4880
+ DOWNLOAD_ATTACHMENT: (entityId, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/entity/${entityId}/${recordId}/${fieldName}`,
4881
+ UPLOAD_ATTACHMENT: (entityId, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/entity/${entityId}/${recordId}/${fieldName}`,
4882
+ DELETE_ATTACHMENT: (entityId, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/entity/${entityId}/${recordId}/${fieldName}`,
4696
4883
  },
4697
4884
  CHOICESETS: {
4698
4885
  GET_ALL: `${DATAFABRIC_BASE}/api/Entity/choiceset`,
@@ -5138,7 +5325,7 @@ function normalizeBaseUrl(url) {
5138
5325
  // Connection string placeholder that will be replaced during build
5139
5326
  const CONNECTION_STRING = "InstrumentationKey=a6efa11d-1feb-4508-9738-e13e12dcae5e;IngestionEndpoint=https://westeurope-5.in.applicationinsights.azure.com/;LiveEndpoint=https://westeurope.livediagnostics.monitor.azure.com/;ApplicationId=7c58eb1c-9581-4ba6-839e-11725848a037";
5140
5327
  // SDK Version placeholder
5141
- const SDK_VERSION = "1.1.2";
5328
+ const SDK_VERSION = "1.2.0";
5142
5329
  const VERSION = "Version";
5143
5330
  const SERVICE = "Service";
5144
5331
  const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
@@ -6004,11 +6191,8 @@ class ApiClient {
6004
6191
  return this.tokenManager.getValidToken();
6005
6192
  }
6006
6193
  async getDefaultHeaders() {
6007
- // Get headers from execution context first
6008
- const contextHeaders = this.executionContext.getHeaders();
6009
6194
  const token = await this.getValidToken();
6010
6195
  return {
6011
- ...contextHeaders,
6012
6196
  'Authorization': `Bearer ${token}`,
6013
6197
  'Content-Type': CONTENT_TYPES.JSON,
6014
6198
  ...this.defaultHeaders,
@@ -6020,8 +6204,13 @@ class ApiClient {
6020
6204
  const normalizedPath = path.startsWith('/') ? path.substring(1) : path;
6021
6205
  // Construct URL with org and tenant names
6022
6206
  const url = new URL(`${this.config.orgName}/${this.config.tenantName}/${normalizedPath}`, this.config.baseUrl).toString();
6207
+ const isFormData = options.body instanceof FormData;
6208
+ const defaultHeaders = await this.getDefaultHeaders();
6209
+ if (isFormData) {
6210
+ delete defaultHeaders['Content-Type'];
6211
+ }
6023
6212
  const headers = {
6024
- ...await this.getDefaultHeaders(),
6213
+ ...defaultHeaders,
6025
6214
  ...options.headers
6026
6215
  };
6027
6216
  // Convert params to URLSearchParams
@@ -6032,11 +6221,15 @@ class ApiClient {
6032
6221
  });
6033
6222
  }
6034
6223
  const fullUrl = searchParams.toString() ? `${url}?${searchParams.toString()}` : url;
6224
+ let body = undefined;
6225
+ if (options.body) {
6226
+ body = isFormData ? options.body : JSON.stringify(options.body);
6227
+ }
6035
6228
  try {
6036
6229
  const response = await fetch(fullUrl, {
6037
6230
  method,
6038
6231
  headers,
6039
- body: options.body ? JSON.stringify(options.body) : undefined,
6232
+ body,
6040
6233
  signal: options.signal
6041
6234
  });
6042
6235
  if (!response.ok) {
@@ -7319,13 +7512,19 @@ function createEntityMethods(entityData, service) {
7319
7512
  return service.getRecordById(entityData.id, recordId, options);
7320
7513
  },
7321
7514
  async downloadAttachment(recordId, fieldName) {
7322
- if (!entityData.name)
7323
- throw new Error('Entity name is undefined');
7324
- return service.downloadAttachment({
7325
- entityName: entityData.name,
7326
- recordId,
7327
- fieldName
7328
- });
7515
+ if (!entityData.id)
7516
+ throw new Error('Entity ID is undefined');
7517
+ return service.downloadAttachment(entityData.id, recordId, fieldName);
7518
+ },
7519
+ async uploadAttachment(recordId, fieldName, file, options) {
7520
+ if (!entityData.id)
7521
+ throw new Error('Entity ID is undefined');
7522
+ return service.uploadAttachment(entityData.id, recordId, fieldName, file, options);
7523
+ },
7524
+ async deleteAttachment(recordId, fieldName) {
7525
+ if (!entityData.id)
7526
+ throw new Error('Entity ID is undefined');
7527
+ return service.deleteAttachment(entityData.id, recordId, fieldName);
7329
7528
  },
7330
7529
  async insert(data, options) {
7331
7530
  return this.insertRecord(data, options);
@@ -7807,7 +8006,9 @@ class EntityService extends BaseService {
7807
8006
  /**
7808
8007
  * Downloads an attachment from an entity record field
7809
8008
  *
7810
- * @param options - Options containing entityName, recordId, and fieldName
8009
+ * @param entityId - UUID of the entity
8010
+ * @param recordId - UUID of the record containing the attachment
8011
+ * @param fieldName - Name of the File-type field containing the attachment
7811
8012
  * @returns Promise resolving to Blob containing the file content
7812
8013
  *
7813
8014
  * @example
@@ -7816,20 +8017,96 @@ class EntityService extends BaseService {
7816
8017
  *
7817
8018
  * const entities = new Entities(sdk);
7818
8019
  *
8020
+ * // Get the entityId from getAll()
8021
+ * const allEntities = await entities.getAll();
8022
+ * const entityId = allEntities[0].id;
8023
+ *
8024
+ * // Get the recordId from getAllRecords()
8025
+ * const records = await entities.getAllRecords(entityId);
8026
+ * const recordId = records[0].id;
8027
+ *
7819
8028
  * // Download attachment for a specific record and field
7820
- * const blob = await entities.downloadAttachment({
7821
- * entityName: 'Invoice',
7822
- * recordId: '<record-uuid>',
7823
- * fieldName: 'Documents'
7824
- * });
8029
+ * const blob = await entities.downloadAttachment(entityId, recordId, 'Documents');
8030
+ * ```
7825
8031
  */
7826
- async downloadAttachment(options) {
7827
- const { entityName, recordId, fieldName } = options;
7828
- const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.DOWNLOAD_ATTACHMENT(entityName, recordId, fieldName), {
8032
+ async downloadAttachment(entityId, recordId, fieldName) {
8033
+ const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.DOWNLOAD_ATTACHMENT(entityId, recordId, fieldName), {
7829
8034
  responseType: RESPONSE_TYPES.BLOB
7830
8035
  });
7831
8036
  return response.data;
7832
8037
  }
8038
+ /**
8039
+ * Uploads an attachment to a File-type field of an entity record
8040
+ *
8041
+ * @param entityId - UUID of the entity
8042
+ * @param recordId - UUID of the record to upload the attachment to
8043
+ * @param fieldName - Name of the File-type field
8044
+ * @param file - File to upload (Blob, File, or Uint8Array)
8045
+ * @param options - Optional {@link EntityUploadAttachmentOptions} (e.g. expansionLevel)
8046
+ * @returns Promise resolving to {@link EntityUploadAttachmentResponse}
8047
+ *
8048
+ * @example
8049
+ * ```typescript
8050
+ * import { Entities } from '@uipath/uipath-typescript/entities';
8051
+ *
8052
+ * const entities = new Entities(sdk);
8053
+ *
8054
+ * // Get the entityId from getAll()
8055
+ * const allEntities = await entities.getAll();
8056
+ * const entityId = allEntities[0].id;
8057
+ *
8058
+ * // Get the recordId from getAllRecords()
8059
+ * const records = await entities.getAllRecords(entityId);
8060
+ * const recordId = records[0].id;
8061
+ *
8062
+ * // Upload a file attachment
8063
+ * const response = await entities.uploadAttachment(entityId, recordId, 'Documents', file);
8064
+ * ```
8065
+ */
8066
+ async uploadAttachment(entityId, recordId, fieldName, file, options) {
8067
+ const formData = new FormData();
8068
+ if (file instanceof Uint8Array) {
8069
+ formData.append('file', new Blob([file.buffer]));
8070
+ }
8071
+ else {
8072
+ formData.append('file', file);
8073
+ }
8074
+ const params = createParams({ expansionLevel: options?.expansionLevel });
8075
+ const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPLOAD_ATTACHMENT(entityId, recordId, fieldName), formData, { params });
8076
+ // Convert PascalCase response to camelCase
8077
+ const camelResponse = pascalToCamelCaseKeys(response.data);
8078
+ return camelResponse;
8079
+ }
8080
+ /**
8081
+ * Removes an attachment from a File-type field of an entity record
8082
+ *
8083
+ * @param entityId - UUID of the entity
8084
+ * @param recordId - UUID of the record containing the attachment
8085
+ * @param fieldName - Name of the File-type field containing the attachment
8086
+ * @returns Promise resolving to {@link EntityDeleteAttachmentResponse}
8087
+ *
8088
+ * @example
8089
+ * ```typescript
8090
+ * import { Entities } from '@uipath/uipath-typescript/entities';
8091
+ *
8092
+ * const entities = new Entities(sdk);
8093
+ *
8094
+ * // Get the entityId from getAll()
8095
+ * const allEntities = await entities.getAll();
8096
+ * const entityId = allEntities[0].id;
8097
+ *
8098
+ * // Get the recordId from getAllRecords()
8099
+ * const records = await entities.getAllRecords(entityId);
8100
+ * const recordId = records[0].id;
8101
+ *
8102
+ * // Delete attachment for a specific record and field
8103
+ * await entities.deleteAttachment(entityId, recordId, 'Documents');
8104
+ * ```
8105
+ */
8106
+ async deleteAttachment(entityId, recordId, fieldName) {
8107
+ const response = await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_ATTACHMENT(entityId, recordId, fieldName));
8108
+ return response.data;
8109
+ }
7833
8110
  /**
7834
8111
  * @hidden
7835
8112
  * @deprecated Use {@link getAllRecords} instead.
@@ -7963,6 +8240,12 @@ __decorate([
7963
8240
  __decorate([
7964
8241
  track('Entities.DownloadAttachment')
7965
8242
  ], EntityService.prototype, "downloadAttachment", null);
8243
+ __decorate([
8244
+ track('Entities.UploadAttachment')
8245
+ ], EntityService.prototype, "uploadAttachment", null);
8246
+ __decorate([
8247
+ track('Entities.DeleteAttachment')
8248
+ ], EntityService.prototype, "deleteAttachment", null);
7966
8249
 
7967
8250
  class ChoiceSetService extends BaseService {
7968
8251
  /**