@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.umd.js CHANGED
@@ -278,6 +278,11 @@
278
278
  }
279
279
  function pick(schema, mask) {
280
280
  const currDef = schema._zod.def;
281
+ const checks = currDef.checks;
282
+ const hasChecks = checks && checks.length > 0;
283
+ if (hasChecks) {
284
+ throw new Error(".pick() cannot be used on object schemas containing refinements");
285
+ }
281
286
  const def = mergeDefs(schema._zod.def, {
282
287
  get shape() {
283
288
  const newShape = {};
@@ -298,6 +303,11 @@
298
303
  }
299
304
  function omit(schema, mask) {
300
305
  const currDef = schema._zod.def;
306
+ const checks = currDef.checks;
307
+ const hasChecks = checks && checks.length > 0;
308
+ if (hasChecks) {
309
+ throw new Error(".omit() cannot be used on object schemas containing refinements");
310
+ }
301
311
  const def = mergeDefs(schema._zod.def, {
302
312
  get shape() {
303
313
  const newShape = { ...schema._zod.def.shape };
@@ -323,7 +333,14 @@
323
333
  const checks = schema._zod.def.checks;
324
334
  const hasChecks = checks && checks.length > 0;
325
335
  if (hasChecks) {
326
- throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");
336
+ // Only throw if new shape overlaps with existing shape
337
+ // Use getOwnPropertyDescriptor to check key existence without accessing values
338
+ const existingShape = schema._zod.def.shape;
339
+ for (const key in shape) {
340
+ if (Object.getOwnPropertyDescriptor(existingShape, key) !== undefined) {
341
+ throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
342
+ }
343
+ }
327
344
  }
328
345
  const def = mergeDefs(schema._zod.def, {
329
346
  get shape() {
@@ -331,7 +348,6 @@
331
348
  assignProp(this, "shape", _shape); // self-caching
332
349
  return _shape;
333
350
  },
334
- checks: [],
335
351
  });
336
352
  return clone(schema, def);
337
353
  }
@@ -339,15 +355,13 @@
339
355
  if (!isPlainObject$1(shape)) {
340
356
  throw new Error("Invalid input to safeExtend: expected a plain object");
341
357
  }
342
- const def = {
343
- ...schema._zod.def,
358
+ const def = mergeDefs(schema._zod.def, {
344
359
  get shape() {
345
360
  const _shape = { ...schema._zod.def.shape, ...shape };
346
361
  assignProp(this, "shape", _shape); // self-caching
347
362
  return _shape;
348
363
  },
349
- checks: schema._zod.def.checks,
350
- };
364
+ });
351
365
  return clone(schema, def);
352
366
  }
353
367
  function merge$1(a, b) {
@@ -365,6 +379,12 @@
365
379
  return clone(a, def);
366
380
  }
367
381
  function partial(Class, schema, mask) {
382
+ const currDef = schema._zod.def;
383
+ const checks = currDef.checks;
384
+ const hasChecks = checks && checks.length > 0;
385
+ if (hasChecks) {
386
+ throw new Error(".partial() cannot be used on object schemas containing refinements");
387
+ }
368
388
  const def = mergeDefs(schema._zod.def, {
369
389
  get shape() {
370
390
  const oldShape = schema._zod.def.shape;
@@ -434,7 +454,6 @@
434
454
  assignProp(this, "shape", shape); // self-caching
435
455
  return shape;
436
456
  },
437
- checks: [],
438
457
  });
439
458
  return clone(schema, def);
440
459
  }
@@ -684,7 +703,8 @@
684
703
  const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
685
704
  const base64url = /^[A-Za-z0-9_-]*$/;
686
705
  // https://blog.stevenlevithan.com/archives/validate-phone-number#r4-3 (regex sans spaces)
687
- const e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
706
+ // E.164: leading digit must be 1-9; total digits (excluding '+') between 7-15
707
+ const e164 = /^\+[1-9]\d{6,14}$/;
688
708
  // 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])))`;
689
709
  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])))`;
690
710
  const date$1 = /*@__PURE__*/ new RegExp(`^${dateSource}$`);
@@ -988,8 +1008,8 @@
988
1008
 
989
1009
  const version = {
990
1010
  major: 4,
991
- minor: 2,
992
- patch: 1,
1011
+ minor: 3,
1012
+ patch: 6,
993
1013
  };
994
1014
 
995
1015
  const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
@@ -1099,7 +1119,8 @@
1099
1119
  return runChecks(result, checks, ctx);
1100
1120
  };
1101
1121
  }
1102
- inst["~standard"] = {
1122
+ // Lazy initialize ~standard to avoid creating objects for every schema
1123
+ defineLazy(inst, "~standard", () => ({
1103
1124
  validate: (value) => {
1104
1125
  try {
1105
1126
  const r = safeParse$1(inst, value);
@@ -1111,7 +1132,7 @@
1111
1132
  },
1112
1133
  vendor: "zod",
1113
1134
  version: 1,
1114
- };
1135
+ }));
1115
1136
  });
1116
1137
  const $ZodString = /*@__PURE__*/ $constructor("$ZodString", (inst, def) => {
1117
1138
  $ZodType.init(inst, def);
@@ -1481,8 +1502,12 @@
1481
1502
  return payload; //handleArrayResultsAsync(parseResults, final);
1482
1503
  };
1483
1504
  });
1484
- function handlePropertyResult(result, final, key, input) {
1505
+ function handlePropertyResult(result, final, key, input, isOptionalOut) {
1485
1506
  if (result.issues.length) {
1507
+ // For optional-out schemas, ignore errors on absent keys
1508
+ if (isOptionalOut && !(key in input)) {
1509
+ return;
1510
+ }
1486
1511
  final.issues.push(...prefixIssues(key, result.issues));
1487
1512
  }
1488
1513
  if (result.value === undefined) {
@@ -1516,6 +1541,7 @@
1516
1541
  const keySet = def.keySet;
1517
1542
  const _catchall = def.catchall._zod;
1518
1543
  const t = _catchall.def.type;
1544
+ const isOptionalOut = _catchall.optout === "optional";
1519
1545
  for (const key in input) {
1520
1546
  if (keySet.has(key))
1521
1547
  continue;
@@ -1525,10 +1551,10 @@
1525
1551
  }
1526
1552
  const r = _catchall.run({ value: input[key], issues: [] }, ctx);
1527
1553
  if (r instanceof Promise) {
1528
- proms.push(r.then((r) => handlePropertyResult(r, payload, key, input)));
1554
+ proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
1529
1555
  }
1530
1556
  else {
1531
- handlePropertyResult(r, payload, key, input);
1557
+ handlePropertyResult(r, payload, key, input, isOptionalOut);
1532
1558
  }
1533
1559
  }
1534
1560
  if (unrecognized.length) {
@@ -1596,12 +1622,13 @@
1596
1622
  const shape = value.shape;
1597
1623
  for (const key of value.keys) {
1598
1624
  const el = shape[key];
1625
+ const isOptionalOut = el._zod.optout === "optional";
1599
1626
  const r = el._zod.run({ value: input[key], issues: [] }, ctx);
1600
1627
  if (r instanceof Promise) {
1601
- proms.push(r.then((r) => handlePropertyResult(r, payload, key, input)));
1628
+ proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
1602
1629
  }
1603
1630
  else {
1604
- handlePropertyResult(r, payload, key, input);
1631
+ handlePropertyResult(r, payload, key, input, isOptionalOut);
1605
1632
  }
1606
1633
  }
1607
1634
  if (!catchall) {
@@ -1633,8 +1660,33 @@
1633
1660
  for (const key of normalized.keys) {
1634
1661
  const id = ids[key];
1635
1662
  const k = esc(key);
1663
+ const schema = shape[key];
1664
+ const isOptionalOut = schema?._zod?.optout === "optional";
1636
1665
  doc.write(`const ${id} = ${parseStr(key)};`);
1637
- doc.write(`
1666
+ if (isOptionalOut) {
1667
+ // For optional-out schemas, ignore errors on absent keys
1668
+ doc.write(`
1669
+ if (${id}.issues.length) {
1670
+ if (${k} in input) {
1671
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1672
+ ...iss,
1673
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
1674
+ })));
1675
+ }
1676
+ }
1677
+
1678
+ if (${id}.value === undefined) {
1679
+ if (${k} in input) {
1680
+ newResult[${k}] = undefined;
1681
+ }
1682
+ } else {
1683
+ newResult[${k}] = ${id}.value;
1684
+ }
1685
+
1686
+ `);
1687
+ }
1688
+ else {
1689
+ doc.write(`
1638
1690
  if (${id}.issues.length) {
1639
1691
  payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1640
1692
  ...iss,
@@ -1642,7 +1694,6 @@
1642
1694
  })));
1643
1695
  }
1644
1696
 
1645
-
1646
1697
  if (${id}.value === undefined) {
1647
1698
  if (${k} in input) {
1648
1699
  newResult[${k}] = undefined;
@@ -1652,6 +1703,7 @@
1652
1703
  }
1653
1704
 
1654
1705
  `);
1706
+ }
1655
1707
  }
1656
1708
  doc.write(`payload.value = newResult;`);
1657
1709
  doc.write(`return payload;`);
@@ -1818,11 +1870,38 @@
1818
1870
  return { valid: false, mergeErrorPath: [] };
1819
1871
  }
1820
1872
  function handleIntersectionResults(result, left, right) {
1821
- if (left.issues.length) {
1822
- result.issues.push(...left.issues);
1873
+ // Track which side(s) report each key as unrecognized
1874
+ const unrecKeys = new Map();
1875
+ let unrecIssue;
1876
+ for (const iss of left.issues) {
1877
+ if (iss.code === "unrecognized_keys") {
1878
+ unrecIssue ?? (unrecIssue = iss);
1879
+ for (const k of iss.keys) {
1880
+ if (!unrecKeys.has(k))
1881
+ unrecKeys.set(k, {});
1882
+ unrecKeys.get(k).l = true;
1883
+ }
1884
+ }
1885
+ else {
1886
+ result.issues.push(iss);
1887
+ }
1823
1888
  }
1824
- if (right.issues.length) {
1825
- result.issues.push(...right.issues);
1889
+ for (const iss of right.issues) {
1890
+ if (iss.code === "unrecognized_keys") {
1891
+ for (const k of iss.keys) {
1892
+ if (!unrecKeys.has(k))
1893
+ unrecKeys.set(k, {});
1894
+ unrecKeys.get(k).r = true;
1895
+ }
1896
+ }
1897
+ else {
1898
+ result.issues.push(iss);
1899
+ }
1900
+ }
1901
+ // Report only keys unrecognized by BOTH sides
1902
+ const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
1903
+ if (bothKeys.length && unrecIssue) {
1904
+ result.issues.push({ ...unrecIssue, keys: bothKeys });
1826
1905
  }
1827
1906
  if (aborted(result))
1828
1907
  return result;
@@ -1907,6 +1986,17 @@
1907
1986
  return def.innerType._zod.run(payload, ctx);
1908
1987
  };
1909
1988
  });
1989
+ const $ZodExactOptional = /*@__PURE__*/ $constructor("$ZodExactOptional", (inst, def) => {
1990
+ // Call parent init - inherits optin/optout = "optional"
1991
+ $ZodOptional.init(inst, def);
1992
+ // Override values/pattern to NOT add undefined
1993
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1994
+ defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
1995
+ // Override parse to just delegate (no undefined handling)
1996
+ inst._zod.parse = (payload, ctx) => {
1997
+ return def.innerType._zod.run(payload, ctx);
1998
+ };
1999
+ });
1910
2000
  const $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (inst, def) => {
1911
2001
  $ZodType.init(inst, def);
1912
2002
  defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
@@ -2129,9 +2219,6 @@
2129
2219
  const meta = _meta[0];
2130
2220
  this._map.set(schema, meta);
2131
2221
  if (meta && typeof meta === "object" && "id" in meta) {
2132
- if (this._idmap.has(meta.id)) {
2133
- throw new Error(`ID ${meta.id} already exists in the registry`);
2134
- }
2135
2222
  this._idmap.set(meta.id, schema);
2136
2223
  }
2137
2224
  return this;
@@ -2172,12 +2259,14 @@
2172
2259
  (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
2173
2260
  const globalRegistry = globalThis.__zod_globalRegistry;
2174
2261
 
2262
+ // @__NO_SIDE_EFFECTS__
2175
2263
  function _string(Class, params) {
2176
2264
  return new Class({
2177
2265
  type: "string",
2178
2266
  ...normalizeParams(params),
2179
2267
  });
2180
2268
  }
2269
+ // @__NO_SIDE_EFFECTS__
2181
2270
  function _email(Class, params) {
2182
2271
  return new Class({
2183
2272
  type: "string",
@@ -2187,6 +2276,7 @@
2187
2276
  ...normalizeParams(params),
2188
2277
  });
2189
2278
  }
2279
+ // @__NO_SIDE_EFFECTS__
2190
2280
  function _guid(Class, params) {
2191
2281
  return new Class({
2192
2282
  type: "string",
@@ -2196,6 +2286,7 @@
2196
2286
  ...normalizeParams(params),
2197
2287
  });
2198
2288
  }
2289
+ // @__NO_SIDE_EFFECTS__
2199
2290
  function _uuid(Class, params) {
2200
2291
  return new Class({
2201
2292
  type: "string",
@@ -2205,6 +2296,7 @@
2205
2296
  ...normalizeParams(params),
2206
2297
  });
2207
2298
  }
2299
+ // @__NO_SIDE_EFFECTS__
2208
2300
  function _uuidv4(Class, params) {
2209
2301
  return new Class({
2210
2302
  type: "string",
@@ -2215,6 +2307,7 @@
2215
2307
  ...normalizeParams(params),
2216
2308
  });
2217
2309
  }
2310
+ // @__NO_SIDE_EFFECTS__
2218
2311
  function _uuidv6(Class, params) {
2219
2312
  return new Class({
2220
2313
  type: "string",
@@ -2225,6 +2318,7 @@
2225
2318
  ...normalizeParams(params),
2226
2319
  });
2227
2320
  }
2321
+ // @__NO_SIDE_EFFECTS__
2228
2322
  function _uuidv7(Class, params) {
2229
2323
  return new Class({
2230
2324
  type: "string",
@@ -2235,6 +2329,7 @@
2235
2329
  ...normalizeParams(params),
2236
2330
  });
2237
2331
  }
2332
+ // @__NO_SIDE_EFFECTS__
2238
2333
  function _url(Class, params) {
2239
2334
  return new Class({
2240
2335
  type: "string",
@@ -2244,6 +2339,7 @@
2244
2339
  ...normalizeParams(params),
2245
2340
  });
2246
2341
  }
2342
+ // @__NO_SIDE_EFFECTS__
2247
2343
  function _emoji(Class, params) {
2248
2344
  return new Class({
2249
2345
  type: "string",
@@ -2253,6 +2349,7 @@
2253
2349
  ...normalizeParams(params),
2254
2350
  });
2255
2351
  }
2352
+ // @__NO_SIDE_EFFECTS__
2256
2353
  function _nanoid(Class, params) {
2257
2354
  return new Class({
2258
2355
  type: "string",
@@ -2262,6 +2359,7 @@
2262
2359
  ...normalizeParams(params),
2263
2360
  });
2264
2361
  }
2362
+ // @__NO_SIDE_EFFECTS__
2265
2363
  function _cuid(Class, params) {
2266
2364
  return new Class({
2267
2365
  type: "string",
@@ -2271,6 +2369,7 @@
2271
2369
  ...normalizeParams(params),
2272
2370
  });
2273
2371
  }
2372
+ // @__NO_SIDE_EFFECTS__
2274
2373
  function _cuid2(Class, params) {
2275
2374
  return new Class({
2276
2375
  type: "string",
@@ -2280,6 +2379,7 @@
2280
2379
  ...normalizeParams(params),
2281
2380
  });
2282
2381
  }
2382
+ // @__NO_SIDE_EFFECTS__
2283
2383
  function _ulid(Class, params) {
2284
2384
  return new Class({
2285
2385
  type: "string",
@@ -2289,6 +2389,7 @@
2289
2389
  ...normalizeParams(params),
2290
2390
  });
2291
2391
  }
2392
+ // @__NO_SIDE_EFFECTS__
2292
2393
  function _xid(Class, params) {
2293
2394
  return new Class({
2294
2395
  type: "string",
@@ -2298,6 +2399,7 @@
2298
2399
  ...normalizeParams(params),
2299
2400
  });
2300
2401
  }
2402
+ // @__NO_SIDE_EFFECTS__
2301
2403
  function _ksuid(Class, params) {
2302
2404
  return new Class({
2303
2405
  type: "string",
@@ -2307,6 +2409,7 @@
2307
2409
  ...normalizeParams(params),
2308
2410
  });
2309
2411
  }
2412
+ // @__NO_SIDE_EFFECTS__
2310
2413
  function _ipv4(Class, params) {
2311
2414
  return new Class({
2312
2415
  type: "string",
@@ -2316,6 +2419,7 @@
2316
2419
  ...normalizeParams(params),
2317
2420
  });
2318
2421
  }
2422
+ // @__NO_SIDE_EFFECTS__
2319
2423
  function _ipv6(Class, params) {
2320
2424
  return new Class({
2321
2425
  type: "string",
@@ -2325,6 +2429,7 @@
2325
2429
  ...normalizeParams(params),
2326
2430
  });
2327
2431
  }
2432
+ // @__NO_SIDE_EFFECTS__
2328
2433
  function _cidrv4(Class, params) {
2329
2434
  return new Class({
2330
2435
  type: "string",
@@ -2334,6 +2439,7 @@
2334
2439
  ...normalizeParams(params),
2335
2440
  });
2336
2441
  }
2442
+ // @__NO_SIDE_EFFECTS__
2337
2443
  function _cidrv6(Class, params) {
2338
2444
  return new Class({
2339
2445
  type: "string",
@@ -2343,6 +2449,7 @@
2343
2449
  ...normalizeParams(params),
2344
2450
  });
2345
2451
  }
2452
+ // @__NO_SIDE_EFFECTS__
2346
2453
  function _base64(Class, params) {
2347
2454
  return new Class({
2348
2455
  type: "string",
@@ -2352,6 +2459,7 @@
2352
2459
  ...normalizeParams(params),
2353
2460
  });
2354
2461
  }
2462
+ // @__NO_SIDE_EFFECTS__
2355
2463
  function _base64url(Class, params) {
2356
2464
  return new Class({
2357
2465
  type: "string",
@@ -2361,6 +2469,7 @@
2361
2469
  ...normalizeParams(params),
2362
2470
  });
2363
2471
  }
2472
+ // @__NO_SIDE_EFFECTS__
2364
2473
  function _e164(Class, params) {
2365
2474
  return new Class({
2366
2475
  type: "string",
@@ -2370,6 +2479,7 @@
2370
2479
  ...normalizeParams(params),
2371
2480
  });
2372
2481
  }
2482
+ // @__NO_SIDE_EFFECTS__
2373
2483
  function _jwt(Class, params) {
2374
2484
  return new Class({
2375
2485
  type: "string",
@@ -2379,6 +2489,7 @@
2379
2489
  ...normalizeParams(params),
2380
2490
  });
2381
2491
  }
2492
+ // @__NO_SIDE_EFFECTS__
2382
2493
  function _isoDateTime(Class, params) {
2383
2494
  return new Class({
2384
2495
  type: "string",
@@ -2390,6 +2501,7 @@
2390
2501
  ...normalizeParams(params),
2391
2502
  });
2392
2503
  }
2504
+ // @__NO_SIDE_EFFECTS__
2393
2505
  function _isoDate(Class, params) {
2394
2506
  return new Class({
2395
2507
  type: "string",
@@ -2398,6 +2510,7 @@
2398
2510
  ...normalizeParams(params),
2399
2511
  });
2400
2512
  }
2513
+ // @__NO_SIDE_EFFECTS__
2401
2514
  function _isoTime(Class, params) {
2402
2515
  return new Class({
2403
2516
  type: "string",
@@ -2407,6 +2520,7 @@
2407
2520
  ...normalizeParams(params),
2408
2521
  });
2409
2522
  }
2523
+ // @__NO_SIDE_EFFECTS__
2410
2524
  function _isoDuration(Class, params) {
2411
2525
  return new Class({
2412
2526
  type: "string",
@@ -2415,17 +2529,20 @@
2415
2529
  ...normalizeParams(params),
2416
2530
  });
2417
2531
  }
2532
+ // @__NO_SIDE_EFFECTS__
2418
2533
  function _unknown(Class) {
2419
2534
  return new Class({
2420
2535
  type: "unknown",
2421
2536
  });
2422
2537
  }
2538
+ // @__NO_SIDE_EFFECTS__
2423
2539
  function _never(Class, params) {
2424
2540
  return new Class({
2425
2541
  type: "never",
2426
2542
  ...normalizeParams(params),
2427
2543
  });
2428
2544
  }
2545
+ // @__NO_SIDE_EFFECTS__
2429
2546
  function _maxLength(maximum, params) {
2430
2547
  const ch = new $ZodCheckMaxLength({
2431
2548
  check: "max_length",
@@ -2434,6 +2551,7 @@
2434
2551
  });
2435
2552
  return ch;
2436
2553
  }
2554
+ // @__NO_SIDE_EFFECTS__
2437
2555
  function _minLength(minimum, params) {
2438
2556
  return new $ZodCheckMinLength({
2439
2557
  check: "min_length",
@@ -2441,6 +2559,7 @@
2441
2559
  minimum,
2442
2560
  });
2443
2561
  }
2562
+ // @__NO_SIDE_EFFECTS__
2444
2563
  function _length(length, params) {
2445
2564
  return new $ZodCheckLengthEquals({
2446
2565
  check: "length_equals",
@@ -2448,6 +2567,7 @@
2448
2567
  length,
2449
2568
  });
2450
2569
  }
2570
+ // @__NO_SIDE_EFFECTS__
2451
2571
  function _regex(pattern, params) {
2452
2572
  return new $ZodCheckRegex({
2453
2573
  check: "string_format",
@@ -2456,6 +2576,7 @@
2456
2576
  pattern,
2457
2577
  });
2458
2578
  }
2579
+ // @__NO_SIDE_EFFECTS__
2459
2580
  function _lowercase(params) {
2460
2581
  return new $ZodCheckLowerCase({
2461
2582
  check: "string_format",
@@ -2463,6 +2584,7 @@
2463
2584
  ...normalizeParams(params),
2464
2585
  });
2465
2586
  }
2587
+ // @__NO_SIDE_EFFECTS__
2466
2588
  function _uppercase(params) {
2467
2589
  return new $ZodCheckUpperCase({
2468
2590
  check: "string_format",
@@ -2470,6 +2592,7 @@
2470
2592
  ...normalizeParams(params),
2471
2593
  });
2472
2594
  }
2595
+ // @__NO_SIDE_EFFECTS__
2473
2596
  function _includes(includes, params) {
2474
2597
  return new $ZodCheckIncludes({
2475
2598
  check: "string_format",
@@ -2478,6 +2601,7 @@
2478
2601
  includes,
2479
2602
  });
2480
2603
  }
2604
+ // @__NO_SIDE_EFFECTS__
2481
2605
  function _startsWith(prefix, params) {
2482
2606
  return new $ZodCheckStartsWith({
2483
2607
  check: "string_format",
@@ -2486,6 +2610,7 @@
2486
2610
  prefix,
2487
2611
  });
2488
2612
  }
2613
+ // @__NO_SIDE_EFFECTS__
2489
2614
  function _endsWith(suffix, params) {
2490
2615
  return new $ZodCheckEndsWith({
2491
2616
  check: "string_format",
@@ -2494,6 +2619,7 @@
2494
2619
  suffix,
2495
2620
  });
2496
2621
  }
2622
+ // @__NO_SIDE_EFFECTS__
2497
2623
  function _overwrite(tx) {
2498
2624
  return new $ZodCheckOverwrite({
2499
2625
  check: "overwrite",
@@ -2501,25 +2627,31 @@
2501
2627
  });
2502
2628
  }
2503
2629
  // normalize
2630
+ // @__NO_SIDE_EFFECTS__
2504
2631
  function _normalize(form) {
2505
2632
  return _overwrite((input) => input.normalize(form));
2506
2633
  }
2507
2634
  // trim
2635
+ // @__NO_SIDE_EFFECTS__
2508
2636
  function _trim() {
2509
2637
  return _overwrite((input) => input.trim());
2510
2638
  }
2511
2639
  // toLowerCase
2640
+ // @__NO_SIDE_EFFECTS__
2512
2641
  function _toLowerCase() {
2513
2642
  return _overwrite((input) => input.toLowerCase());
2514
2643
  }
2515
2644
  // toUpperCase
2645
+ // @__NO_SIDE_EFFECTS__
2516
2646
  function _toUpperCase() {
2517
2647
  return _overwrite((input) => input.toUpperCase());
2518
2648
  }
2519
2649
  // slugify
2650
+ // @__NO_SIDE_EFFECTS__
2520
2651
  function _slugify() {
2521
2652
  return _overwrite((input) => slugify(input));
2522
2653
  }
2654
+ // @__NO_SIDE_EFFECTS__
2523
2655
  function _array(Class, element, params) {
2524
2656
  return new Class({
2525
2657
  type: "array",
@@ -2531,6 +2663,7 @@
2531
2663
  });
2532
2664
  }
2533
2665
  // same as _custom but defaults to abort:false
2666
+ // @__NO_SIDE_EFFECTS__
2534
2667
  function _refine(Class, fn, _params) {
2535
2668
  const schema = new Class({
2536
2669
  type: "custom",
@@ -2540,6 +2673,7 @@
2540
2673
  });
2541
2674
  return schema;
2542
2675
  }
2676
+ // @__NO_SIDE_EFFECTS__
2543
2677
  function _superRefine(fn) {
2544
2678
  const ch = _check((payload) => {
2545
2679
  payload.addIssue = (issue$1) => {
@@ -2562,6 +2696,7 @@
2562
2696
  });
2563
2697
  return ch;
2564
2698
  }
2699
+ // @__NO_SIDE_EFFECTS__
2565
2700
  function _check(fn, params) {
2566
2701
  const ch = new $ZodCheck({
2567
2702
  check: "custom",
@@ -2628,14 +2763,7 @@
2628
2763
  schemaPath: [..._params.schemaPath, schema],
2629
2764
  path: _params.path,
2630
2765
  };
2631
- const parent = schema._zod.parent;
2632
- if (parent) {
2633
- // schema was cloned from another schema
2634
- result.ref = parent;
2635
- process(parent, ctx, params);
2636
- ctx.seen.get(parent).isParent = true;
2637
- }
2638
- else if (schema._zod.processJSONSchema) {
2766
+ if (schema._zod.processJSONSchema) {
2639
2767
  schema._zod.processJSONSchema(ctx, result.schema, params);
2640
2768
  }
2641
2769
  else {
@@ -2646,6 +2774,14 @@
2646
2774
  }
2647
2775
  processor(schema, ctx, _json, params);
2648
2776
  }
2777
+ const parent = schema._zod.parent;
2778
+ if (parent) {
2779
+ // Also set ref if processor didn't (for inheritance)
2780
+ if (!result.ref)
2781
+ result.ref = parent;
2782
+ process(parent, ctx, params);
2783
+ ctx.seen.get(parent).isParent = true;
2784
+ }
2649
2785
  }
2650
2786
  // metadata
2651
2787
  const meta = ctx.metadataRegistry.get(schema);
@@ -2671,6 +2807,18 @@
2671
2807
  const root = ctx.seen.get(schema);
2672
2808
  if (!root)
2673
2809
  throw new Error("Unprocessed schema. This is a bug in Zod.");
2810
+ // Track ids to detect duplicates across different schemas
2811
+ const idToSchema = new Map();
2812
+ for (const entry of ctx.seen.entries()) {
2813
+ const id = ctx.metadataRegistry.get(entry[0])?.id;
2814
+ if (id) {
2815
+ const existing = idToSchema.get(id);
2816
+ if (existing && existing !== entry[0]) {
2817
+ throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
2818
+ }
2819
+ idToSchema.set(id, entry[0]);
2820
+ }
2821
+ }
2674
2822
  // returns a ref to the schema
2675
2823
  // defId will be empty if the ref points to an external schema (or #)
2676
2824
  const makeURI = (entry) => {
@@ -2772,43 +2920,84 @@
2772
2920
  }
2773
2921
  }
2774
2922
  function finalize(ctx, schema) {
2775
- //
2776
- // iterate over seen map;
2777
2923
  const root = ctx.seen.get(schema);
2778
2924
  if (!root)
2779
2925
  throw new Error("Unprocessed schema. This is a bug in Zod.");
2780
- // flatten _refs
2926
+ // flatten refs - inherit properties from parent schemas
2781
2927
  const flattenRef = (zodSchema) => {
2782
2928
  const seen = ctx.seen.get(zodSchema);
2929
+ // already processed
2930
+ if (seen.ref === null)
2931
+ return;
2783
2932
  const schema = seen.def ?? seen.schema;
2784
2933
  const _cached = { ...schema };
2785
- // already seen
2786
- if (seen.ref === null) {
2787
- return;
2788
- }
2789
- // flatten ref if defined
2790
2934
  const ref = seen.ref;
2791
- seen.ref = null; // prevent recursion
2935
+ seen.ref = null; // prevent infinite recursion
2792
2936
  if (ref) {
2793
2937
  flattenRef(ref);
2938
+ const refSeen = ctx.seen.get(ref);
2939
+ const refSchema = refSeen.schema;
2794
2940
  // merge referenced schema into current
2795
- const refSchema = ctx.seen.get(ref).schema;
2796
2941
  if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
2942
+ // older drafts can't combine $ref with other properties
2797
2943
  schema.allOf = schema.allOf ?? [];
2798
2944
  schema.allOf.push(refSchema);
2799
2945
  }
2800
2946
  else {
2801
2947
  Object.assign(schema, refSchema);
2802
- Object.assign(schema, _cached); // prevent overwriting any fields in the original schema
2948
+ }
2949
+ // restore child's own properties (child wins)
2950
+ Object.assign(schema, _cached);
2951
+ const isParentRef = zodSchema._zod.parent === ref;
2952
+ // For parent chain, child is a refinement - remove parent-only properties
2953
+ if (isParentRef) {
2954
+ for (const key in schema) {
2955
+ if (key === "$ref" || key === "allOf")
2956
+ continue;
2957
+ if (!(key in _cached)) {
2958
+ delete schema[key];
2959
+ }
2960
+ }
2961
+ }
2962
+ // When ref was extracted to $defs, remove properties that match the definition
2963
+ if (refSchema.$ref && refSeen.def) {
2964
+ for (const key in schema) {
2965
+ if (key === "$ref" || key === "allOf")
2966
+ continue;
2967
+ if (key in refSeen.def && JSON.stringify(schema[key]) === JSON.stringify(refSeen.def[key])) {
2968
+ delete schema[key];
2969
+ }
2970
+ }
2971
+ }
2972
+ }
2973
+ // If parent was extracted (has $ref), propagate $ref to this schema
2974
+ // This handles cases like: readonly().meta({id}).describe()
2975
+ // where processor sets ref to innerType but parent should be referenced
2976
+ const parent = zodSchema._zod.parent;
2977
+ if (parent && parent !== ref) {
2978
+ // Ensure parent is processed first so its def has inherited properties
2979
+ flattenRef(parent);
2980
+ const parentSeen = ctx.seen.get(parent);
2981
+ if (parentSeen?.schema.$ref) {
2982
+ schema.$ref = parentSeen.schema.$ref;
2983
+ // De-duplicate with parent's definition
2984
+ if (parentSeen.def) {
2985
+ for (const key in schema) {
2986
+ if (key === "$ref" || key === "allOf")
2987
+ continue;
2988
+ if (key in parentSeen.def && JSON.stringify(schema[key]) === JSON.stringify(parentSeen.def[key])) {
2989
+ delete schema[key];
2990
+ }
2991
+ }
2992
+ }
2803
2993
  }
2804
2994
  }
2805
2995
  // execute overrides
2806
- if (!seen.isParent)
2807
- ctx.override({
2808
- zodSchema: zodSchema,
2809
- jsonSchema: schema,
2810
- path: seen.path ?? [],
2811
- });
2996
+ ctx.override({
2997
+ zodSchema: zodSchema,
2998
+ jsonSchema: schema,
2999
+ path: seen.path ?? [],
3000
+ });
2812
3001
  };
2813
3002
  for (const entry of [...ctx.seen.entries()].reverse()) {
2814
3003
  flattenRef(entry[0]);
@@ -2861,8 +3050,8 @@
2861
3050
  value: {
2862
3051
  ...schema["~standard"],
2863
3052
  jsonSchema: {
2864
- input: createStandardJSONSchemaMethod(schema, "input"),
2865
- output: createStandardJSONSchemaMethod(schema, "output"),
3053
+ input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
3054
+ output: createStandardJSONSchemaMethod(schema, "output", ctx.processors),
2866
3055
  },
2867
3056
  },
2868
3057
  enumerable: false,
@@ -2941,9 +3130,9 @@
2941
3130
  extractDefs(ctx, schema);
2942
3131
  return finalize(ctx, schema);
2943
3132
  };
2944
- const createStandardJSONSchemaMethod = (schema, io) => (params) => {
3133
+ const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
2945
3134
  const { libraryOptions, target } = params ?? {};
2946
- const ctx = initializeContext({ ...(libraryOptions ?? {}), target, io, processors: {} });
3135
+ const ctx = initializeContext({ ...(libraryOptions ?? {}), target, io, processors });
2947
3136
  process(schema, ctx);
2948
3137
  extractDefs(ctx, schema);
2949
3138
  return finalize(ctx, schema);
@@ -2971,6 +3160,11 @@
2971
3160
  json.format = formatMap[format] ?? format;
2972
3161
  if (json.format === "")
2973
3162
  delete json.format; // empty format is not valid
3163
+ // JSON Schema format: "time" requires a full time with offset or Z
3164
+ // z.iso.time() does not include timezone information, so format: "time" should never be used
3165
+ if (format === "time") {
3166
+ delete json.format;
3167
+ }
2974
3168
  }
2975
3169
  if (contentEncoding)
2976
3170
  json.contentEncoding = contentEncoding;
@@ -3279,8 +3473,11 @@
3279
3473
  ...(def.checks ?? []),
3280
3474
  ...checks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch),
3281
3475
  ],
3282
- }));
3476
+ }), {
3477
+ parent: true,
3478
+ });
3283
3479
  };
3480
+ inst.with = inst.check;
3284
3481
  inst.clone = (def, params) => clone(inst, def, params);
3285
3482
  inst.brand = () => inst;
3286
3483
  inst.register = ((reg, meta) => {
@@ -3308,6 +3505,7 @@
3308
3505
  inst.overwrite = (fn) => inst.check(_overwrite(fn));
3309
3506
  // wrappers
3310
3507
  inst.optional = () => optional(inst);
3508
+ inst.exactOptional = () => exactOptional(inst);
3311
3509
  inst.nullable = () => nullable(inst);
3312
3510
  inst.nullish = () => optional(nullable(inst));
3313
3511
  inst.nonoptional = (params) => nonoptional(inst, params);
@@ -3344,6 +3542,7 @@
3344
3542
  // helpers
3345
3543
  inst.isOptional = () => inst.safeParse(undefined).success;
3346
3544
  inst.isNullable = () => inst.safeParse(null).success;
3545
+ inst.apply = (fn) => fn(inst);
3347
3546
  return inst;
3348
3547
  });
3349
3548
  /** @internal */
@@ -3694,6 +3893,18 @@
3694
3893
  innerType: innerType,
3695
3894
  });
3696
3895
  }
3896
+ const ZodExactOptional = /*@__PURE__*/ $constructor("ZodExactOptional", (inst, def) => {
3897
+ $ZodExactOptional.init(inst, def);
3898
+ ZodType.init(inst, def);
3899
+ inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
3900
+ inst.unwrap = () => inst._zod.def.innerType;
3901
+ });
3902
+ function exactOptional(innerType) {
3903
+ return new ZodExactOptional({
3904
+ type: "optional",
3905
+ innerType: innerType,
3906
+ });
3907
+ }
3697
3908
  const ZodNullable = /*@__PURE__*/ $constructor("ZodNullable", (inst, def) => {
3698
3909
  $ZodNullable.init(inst, def);
3699
3910
  ZodType.init(inst, def);
@@ -3833,7 +4044,6 @@
3833
4044
  class ExecutionContext {
3834
4045
  constructor() {
3835
4046
  this.context = new Map();
3836
- this.headers = {};
3837
4047
  }
3838
4048
  /**
3839
4049
  * Set a context value that will be available throughout the execution
@@ -3848,35 +4058,10 @@
3848
4058
  return this.context.get(key);
3849
4059
  }
3850
4060
  /**
3851
- * Set custom headers that will be included in all API requests
3852
- */
3853
- setHeaders(headers) {
3854
- this.headers = { ...this.headers, ...headers };
3855
- }
3856
- /**
3857
- * Get all custom headers
3858
- */
3859
- getHeaders() {
3860
- return { ...this.headers };
3861
- }
3862
- /**
3863
- * Clear all context and headers
4061
+ * Clear all context
3864
4062
  */
3865
4063
  clear() {
3866
4064
  this.context.clear();
3867
- this.headers = {};
3868
- }
3869
- /**
3870
- * Create a request spec for an API call
3871
- */
3872
- createRequestSpec(spec = {}) {
3873
- return {
3874
- ...spec,
3875
- headers: {
3876
- ...this.getHeaders(),
3877
- ...spec.headers
3878
- }
3879
- };
3880
4065
  }
3881
4066
  }
3882
4067
 
@@ -4694,7 +4879,9 @@
4694
4879
  BATCH_INSERT_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/insert-batch`,
4695
4880
  UPDATE_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/update-batch`,
4696
4881
  DELETE_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/delete-batch`,
4697
- DOWNLOAD_ATTACHMENT: (entityName, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/${entityName}/${recordId}/${fieldName}`,
4882
+ DOWNLOAD_ATTACHMENT: (entityId, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/entity/${entityId}/${recordId}/${fieldName}`,
4883
+ UPLOAD_ATTACHMENT: (entityId, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/entity/${entityId}/${recordId}/${fieldName}`,
4884
+ DELETE_ATTACHMENT: (entityId, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/entity/${entityId}/${recordId}/${fieldName}`,
4698
4885
  },
4699
4886
  CHOICESETS: {
4700
4887
  GET_ALL: `${DATAFABRIC_BASE}/api/Entity/choiceset`,
@@ -8895,7 +9082,7 @@
8895
9082
  // Connection string placeholder that will be replaced during build
8896
9083
  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";
8897
9084
  // SDK Version placeholder
8898
- const SDK_VERSION = "1.1.2";
9085
+ const SDK_VERSION = "1.2.0";
8899
9086
  const VERSION = "Version";
8900
9087
  const SERVICE = "Service";
8901
9088
  const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
@@ -9761,11 +9948,8 @@
9761
9948
  return this.tokenManager.getValidToken();
9762
9949
  }
9763
9950
  async getDefaultHeaders() {
9764
- // Get headers from execution context first
9765
- const contextHeaders = this.executionContext.getHeaders();
9766
9951
  const token = await this.getValidToken();
9767
9952
  return {
9768
- ...contextHeaders,
9769
9953
  'Authorization': `Bearer ${token}`,
9770
9954
  'Content-Type': CONTENT_TYPES.JSON,
9771
9955
  ...this.defaultHeaders,
@@ -9777,8 +9961,13 @@
9777
9961
  const normalizedPath = path.startsWith('/') ? path.substring(1) : path;
9778
9962
  // Construct URL with org and tenant names
9779
9963
  const url = new URL(`${this.config.orgName}/${this.config.tenantName}/${normalizedPath}`, this.config.baseUrl).toString();
9964
+ const isFormData = options.body instanceof FormData;
9965
+ const defaultHeaders = await this.getDefaultHeaders();
9966
+ if (isFormData) {
9967
+ delete defaultHeaders['Content-Type'];
9968
+ }
9780
9969
  const headers = {
9781
- ...await this.getDefaultHeaders(),
9970
+ ...defaultHeaders,
9782
9971
  ...options.headers
9783
9972
  };
9784
9973
  // Convert params to URLSearchParams
@@ -9789,11 +9978,15 @@
9789
9978
  });
9790
9979
  }
9791
9980
  const fullUrl = searchParams.toString() ? `${url}?${searchParams.toString()}` : url;
9981
+ let body = undefined;
9982
+ if (options.body) {
9983
+ body = isFormData ? options.body : JSON.stringify(options.body);
9984
+ }
9792
9985
  try {
9793
9986
  const response = await fetch(fullUrl, {
9794
9987
  method,
9795
9988
  headers,
9796
- body: options.body ? JSON.stringify(options.body) : undefined,
9989
+ body,
9797
9990
  signal: options.signal
9798
9991
  });
9799
9992
  if (!response.ok) {
@@ -11076,13 +11269,19 @@
11076
11269
  return service.getRecordById(entityData.id, recordId, options);
11077
11270
  },
11078
11271
  async downloadAttachment(recordId, fieldName) {
11079
- if (!entityData.name)
11080
- throw new Error('Entity name is undefined');
11081
- return service.downloadAttachment({
11082
- entityName: entityData.name,
11083
- recordId,
11084
- fieldName
11085
- });
11272
+ if (!entityData.id)
11273
+ throw new Error('Entity ID is undefined');
11274
+ return service.downloadAttachment(entityData.id, recordId, fieldName);
11275
+ },
11276
+ async uploadAttachment(recordId, fieldName, file, options) {
11277
+ if (!entityData.id)
11278
+ throw new Error('Entity ID is undefined');
11279
+ return service.uploadAttachment(entityData.id, recordId, fieldName, file, options);
11280
+ },
11281
+ async deleteAttachment(recordId, fieldName) {
11282
+ if (!entityData.id)
11283
+ throw new Error('Entity ID is undefined');
11284
+ return service.deleteAttachment(entityData.id, recordId, fieldName);
11086
11285
  },
11087
11286
  async insert(data, options) {
11088
11287
  return this.insertRecord(data, options);
@@ -11564,7 +11763,9 @@
11564
11763
  /**
11565
11764
  * Downloads an attachment from an entity record field
11566
11765
  *
11567
- * @param options - Options containing entityName, recordId, and fieldName
11766
+ * @param entityId - UUID of the entity
11767
+ * @param recordId - UUID of the record containing the attachment
11768
+ * @param fieldName - Name of the File-type field containing the attachment
11568
11769
  * @returns Promise resolving to Blob containing the file content
11569
11770
  *
11570
11771
  * @example
@@ -11573,20 +11774,96 @@
11573
11774
  *
11574
11775
  * const entities = new Entities(sdk);
11575
11776
  *
11777
+ * // Get the entityId from getAll()
11778
+ * const allEntities = await entities.getAll();
11779
+ * const entityId = allEntities[0].id;
11780
+ *
11781
+ * // Get the recordId from getAllRecords()
11782
+ * const records = await entities.getAllRecords(entityId);
11783
+ * const recordId = records[0].id;
11784
+ *
11576
11785
  * // Download attachment for a specific record and field
11577
- * const blob = await entities.downloadAttachment({
11578
- * entityName: 'Invoice',
11579
- * recordId: '<record-uuid>',
11580
- * fieldName: 'Documents'
11581
- * });
11786
+ * const blob = await entities.downloadAttachment(entityId, recordId, 'Documents');
11787
+ * ```
11582
11788
  */
11583
- async downloadAttachment(options) {
11584
- const { entityName, recordId, fieldName } = options;
11585
- const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.DOWNLOAD_ATTACHMENT(entityName, recordId, fieldName), {
11789
+ async downloadAttachment(entityId, recordId, fieldName) {
11790
+ const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.DOWNLOAD_ATTACHMENT(entityId, recordId, fieldName), {
11586
11791
  responseType: RESPONSE_TYPES.BLOB
11587
11792
  });
11588
11793
  return response.data;
11589
11794
  }
11795
+ /**
11796
+ * Uploads an attachment to a File-type field of an entity record
11797
+ *
11798
+ * @param entityId - UUID of the entity
11799
+ * @param recordId - UUID of the record to upload the attachment to
11800
+ * @param fieldName - Name of the File-type field
11801
+ * @param file - File to upload (Blob, File, or Uint8Array)
11802
+ * @param options - Optional {@link EntityUploadAttachmentOptions} (e.g. expansionLevel)
11803
+ * @returns Promise resolving to {@link EntityUploadAttachmentResponse}
11804
+ *
11805
+ * @example
11806
+ * ```typescript
11807
+ * import { Entities } from '@uipath/uipath-typescript/entities';
11808
+ *
11809
+ * const entities = new Entities(sdk);
11810
+ *
11811
+ * // Get the entityId from getAll()
11812
+ * const allEntities = await entities.getAll();
11813
+ * const entityId = allEntities[0].id;
11814
+ *
11815
+ * // Get the recordId from getAllRecords()
11816
+ * const records = await entities.getAllRecords(entityId);
11817
+ * const recordId = records[0].id;
11818
+ *
11819
+ * // Upload a file attachment
11820
+ * const response = await entities.uploadAttachment(entityId, recordId, 'Documents', file);
11821
+ * ```
11822
+ */
11823
+ async uploadAttachment(entityId, recordId, fieldName, file, options) {
11824
+ const formData = new FormData();
11825
+ if (file instanceof Uint8Array) {
11826
+ formData.append('file', new Blob([file.buffer]));
11827
+ }
11828
+ else {
11829
+ formData.append('file', file);
11830
+ }
11831
+ const params = createParams({ expansionLevel: options?.expansionLevel });
11832
+ const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPLOAD_ATTACHMENT(entityId, recordId, fieldName), formData, { params });
11833
+ // Convert PascalCase response to camelCase
11834
+ const camelResponse = pascalToCamelCaseKeys(response.data);
11835
+ return camelResponse;
11836
+ }
11837
+ /**
11838
+ * Removes an attachment from a File-type field of an entity record
11839
+ *
11840
+ * @param entityId - UUID of the entity
11841
+ * @param recordId - UUID of the record containing the attachment
11842
+ * @param fieldName - Name of the File-type field containing the attachment
11843
+ * @returns Promise resolving to {@link EntityDeleteAttachmentResponse}
11844
+ *
11845
+ * @example
11846
+ * ```typescript
11847
+ * import { Entities } from '@uipath/uipath-typescript/entities';
11848
+ *
11849
+ * const entities = new Entities(sdk);
11850
+ *
11851
+ * // Get the entityId from getAll()
11852
+ * const allEntities = await entities.getAll();
11853
+ * const entityId = allEntities[0].id;
11854
+ *
11855
+ * // Get the recordId from getAllRecords()
11856
+ * const records = await entities.getAllRecords(entityId);
11857
+ * const recordId = records[0].id;
11858
+ *
11859
+ * // Delete attachment for a specific record and field
11860
+ * await entities.deleteAttachment(entityId, recordId, 'Documents');
11861
+ * ```
11862
+ */
11863
+ async deleteAttachment(entityId, recordId, fieldName) {
11864
+ const response = await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_ATTACHMENT(entityId, recordId, fieldName));
11865
+ return response.data;
11866
+ }
11590
11867
  /**
11591
11868
  * @hidden
11592
11869
  * @deprecated Use {@link getAllRecords} instead.
@@ -11720,6 +11997,12 @@
11720
11997
  __decorate([
11721
11998
  track('Entities.DownloadAttachment')
11722
11999
  ], EntityService.prototype, "downloadAttachment", null);
12000
+ __decorate([
12001
+ track('Entities.UploadAttachment')
12002
+ ], EntityService.prototype, "uploadAttachment", null);
12003
+ __decorate([
12004
+ track('Entities.DeleteAttachment')
12005
+ ], EntityService.prototype, "deleteAttachment", null);
11723
12006
 
11724
12007
  class ChoiceSetService extends BaseService {
11725
12008
  /**