@uipath/uipath-typescript 1.1.3 → 1.2.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/assets/index.cjs +1 -4
- package/dist/assets/index.mjs +1 -4
- package/dist/buckets/index.cjs +1 -4
- package/dist/buckets/index.mjs +1 -4
- package/dist/cases/index.cjs +1 -4
- package/dist/cases/index.mjs +1 -4
- package/dist/conversational-agent/index.cjs +38 -10
- package/dist/conversational-agent/index.d.ts +62 -1
- package/dist/conversational-agent/index.mjs +38 -10
- package/dist/core/index.cjs +278 -84
- package/dist/core/index.d.ts +26 -2
- package/dist/core/index.mjs +278 -84
- package/dist/entities/index.cjs +129 -44
- package/dist/entities/index.d.ts +214 -70
- package/dist/entities/index.mjs +129 -44
- package/dist/index.cjs +406 -127
- package/dist/index.d.ts +270 -71
- package/dist/index.mjs +406 -127
- package/dist/index.umd.js +406 -127
- package/dist/maestro-processes/index.cjs +1 -4
- package/dist/maestro-processes/index.mjs +1 -4
- package/dist/processes/index.cjs +1 -4
- package/dist/processes/index.mjs +1 -4
- package/dist/queues/index.cjs +1 -4
- package/dist/queues/index.mjs +1 -4
- package/dist/tasks/index.cjs +1 -4
- package/dist/tasks/index.mjs +1 -4
- package/package.json +5 -4
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
992
|
-
patch:
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1822
|
-
|
|
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
|
+
}
|
|
1888
|
+
}
|
|
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
|
+
}
|
|
1823
1900
|
}
|
|
1824
|
-
|
|
1825
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
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
|
-
*
|
|
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
|
|
|
@@ -4692,10 +4877,12 @@
|
|
|
4692
4877
|
GET_RECORD_BY_ID: (entityId, recordId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/read/${recordId}`,
|
|
4693
4878
|
INSERT_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/insert`,
|
|
4694
4879
|
BATCH_INSERT_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/insert-batch`,
|
|
4880
|
+
UPDATE_RECORD_BY_ID: (entityId, recordId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/update/${recordId}`,
|
|
4695
4881
|
UPDATE_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/update-batch`,
|
|
4696
4882
|
DELETE_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/delete-batch`,
|
|
4697
|
-
DOWNLOAD_ATTACHMENT: (
|
|
4698
|
-
UPLOAD_ATTACHMENT: (
|
|
4883
|
+
DOWNLOAD_ATTACHMENT: (entityId, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/entity/${entityId}/${recordId}/${fieldName}`,
|
|
4884
|
+
UPLOAD_ATTACHMENT: (entityId, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/entity/${entityId}/${recordId}/${fieldName}`,
|
|
4885
|
+
DELETE_ATTACHMENT: (entityId, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/entity/${entityId}/${recordId}/${fieldName}`,
|
|
4699
4886
|
},
|
|
4700
4887
|
CHOICESETS: {
|
|
4701
4888
|
GET_ALL: `${DATAFABRIC_BASE}/api/Entity/choiceset`,
|
|
@@ -8896,7 +9083,7 @@
|
|
|
8896
9083
|
// Connection string placeholder that will be replaced during build
|
|
8897
9084
|
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";
|
|
8898
9085
|
// SDK Version placeholder
|
|
8899
|
-
const SDK_VERSION = "1.1
|
|
9086
|
+
const SDK_VERSION = "1.2.1";
|
|
8900
9087
|
const VERSION = "Version";
|
|
8901
9088
|
const SERVICE = "Service";
|
|
8902
9089
|
const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
|
|
@@ -9427,6 +9614,15 @@
|
|
|
9427
9614
|
__classPrivateFieldGet(this, _UiPath_authService, "f")?.logout();
|
|
9428
9615
|
__classPrivateFieldSet(this, _UiPath_initialized, false, "f");
|
|
9429
9616
|
}
|
|
9617
|
+
/**
|
|
9618
|
+
* Updates the access token used for API requests.
|
|
9619
|
+
* Use this to inject or refresh a token externally.
|
|
9620
|
+
*
|
|
9621
|
+
* @param tokenInfo - The token information containing the access token, type, expiration, and optional refresh token
|
|
9622
|
+
*/
|
|
9623
|
+
updateToken(tokenInfo) {
|
|
9624
|
+
__classPrivateFieldGet(this, _UiPath_authService, "f")?.updateToken(tokenInfo);
|
|
9625
|
+
}
|
|
9430
9626
|
};
|
|
9431
9627
|
_UiPath_config = new WeakMap(), _UiPath_authService = new WeakMap(), _UiPath_initialized = new WeakMap(), _UiPath_partialConfig = new WeakMap(), _UiPath_instances = new WeakSet(), _UiPath_initializeWithConfig = function _UiPath_initializeWithConfig(config) {
|
|
9432
9628
|
// Validate and normalize the configuration
|
|
@@ -9762,11 +9958,8 @@
|
|
|
9762
9958
|
return this.tokenManager.getValidToken();
|
|
9763
9959
|
}
|
|
9764
9960
|
async getDefaultHeaders() {
|
|
9765
|
-
// Get headers from execution context first
|
|
9766
|
-
const contextHeaders = this.executionContext.getHeaders();
|
|
9767
9961
|
const token = await this.getValidToken();
|
|
9768
9962
|
return {
|
|
9769
|
-
...contextHeaders,
|
|
9770
9963
|
'Authorization': `Bearer ${token}`,
|
|
9771
9964
|
'Content-Type': CONTENT_TYPES.JSON,
|
|
9772
9965
|
...this.defaultHeaders,
|
|
@@ -11063,6 +11256,13 @@
|
|
|
11063
11256
|
throw new Error('Entity ID is undefined');
|
|
11064
11257
|
return service.insertRecordsById(entityData.id, data, options);
|
|
11065
11258
|
},
|
|
11259
|
+
async updateRecord(recordId, data, options) {
|
|
11260
|
+
if (!entityData.id)
|
|
11261
|
+
throw new Error('Entity ID is undefined');
|
|
11262
|
+
if (!recordId)
|
|
11263
|
+
throw new Error('Record ID is undefined');
|
|
11264
|
+
return service.updateRecordById(entityData.id, recordId, data, options);
|
|
11265
|
+
},
|
|
11066
11266
|
async updateRecords(data, options) {
|
|
11067
11267
|
if (!entityData.id)
|
|
11068
11268
|
throw new Error('Entity ID is undefined');
|
|
@@ -11086,24 +11286,19 @@
|
|
|
11086
11286
|
return service.getRecordById(entityData.id, recordId, options);
|
|
11087
11287
|
},
|
|
11088
11288
|
async downloadAttachment(recordId, fieldName) {
|
|
11089
|
-
if (!entityData.
|
|
11090
|
-
throw new Error('Entity
|
|
11091
|
-
return service.downloadAttachment(
|
|
11092
|
-
entityName: entityData.name,
|
|
11093
|
-
recordId,
|
|
11094
|
-
fieldName
|
|
11095
|
-
});
|
|
11289
|
+
if (!entityData.id)
|
|
11290
|
+
throw new Error('Entity ID is undefined');
|
|
11291
|
+
return service.downloadAttachment(entityData.id, recordId, fieldName);
|
|
11096
11292
|
},
|
|
11097
|
-
async uploadAttachment(recordId, fieldName, file,
|
|
11098
|
-
if (!entityData.
|
|
11099
|
-
throw new Error('Entity
|
|
11100
|
-
return service.uploadAttachment(
|
|
11101
|
-
|
|
11102
|
-
|
|
11103
|
-
|
|
11104
|
-
|
|
11105
|
-
|
|
11106
|
-
});
|
|
11293
|
+
async uploadAttachment(recordId, fieldName, file, options) {
|
|
11294
|
+
if (!entityData.id)
|
|
11295
|
+
throw new Error('Entity ID is undefined');
|
|
11296
|
+
return service.uploadAttachment(entityData.id, recordId, fieldName, file, options);
|
|
11297
|
+
},
|
|
11298
|
+
async deleteAttachment(recordId, fieldName) {
|
|
11299
|
+
if (!entityData.id)
|
|
11300
|
+
throw new Error('Entity ID is undefined');
|
|
11301
|
+
return service.deleteAttachment(entityData.id, recordId, fieldName);
|
|
11107
11302
|
},
|
|
11108
11303
|
async insert(data, options) {
|
|
11109
11304
|
return this.insertRecord(data, options);
|
|
@@ -11476,6 +11671,42 @@
|
|
|
11476
11671
|
const camelResponse = pascalToCamelCaseKeys(response.data);
|
|
11477
11672
|
return camelResponse;
|
|
11478
11673
|
}
|
|
11674
|
+
/**
|
|
11675
|
+
* Updates a single record in an entity by entity ID
|
|
11676
|
+
*
|
|
11677
|
+
* @param entityId - UUID of the entity
|
|
11678
|
+
* @param recordId - UUID of the record to update
|
|
11679
|
+
* @param data - Key-value pairs of fields to update
|
|
11680
|
+
* @param options - Update options
|
|
11681
|
+
* @returns Promise resolving to the updated record
|
|
11682
|
+
*
|
|
11683
|
+
* @example
|
|
11684
|
+
* ```typescript
|
|
11685
|
+
* import { Entities } from '@uipath/uipath-typescript/entities';
|
|
11686
|
+
*
|
|
11687
|
+
* const entities = new Entities(sdk);
|
|
11688
|
+
*
|
|
11689
|
+
* // Basic usage
|
|
11690
|
+
* const result = await entities.updateRecordById("<entityId>", "<recordId>", { name: "John Updated", age: 31 });
|
|
11691
|
+
*
|
|
11692
|
+
* // With options
|
|
11693
|
+
* const result = await entities.updateRecordById("<entityId>", "<recordId>", { name: "John Updated", age: 31 }, {
|
|
11694
|
+
* expansionLevel: 1
|
|
11695
|
+
* });
|
|
11696
|
+
* ```
|
|
11697
|
+
*/
|
|
11698
|
+
async updateRecordById(entityId, recordId, data, options = {}) {
|
|
11699
|
+
const params = createParams({
|
|
11700
|
+
expansionLevel: options.expansionLevel
|
|
11701
|
+
});
|
|
11702
|
+
const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPDATE_RECORD_BY_ID(entityId, recordId), data, {
|
|
11703
|
+
params,
|
|
11704
|
+
...options
|
|
11705
|
+
});
|
|
11706
|
+
// Convert PascalCase response to camelCase
|
|
11707
|
+
const camelResponse = pascalToCamelCaseKeys(response.data);
|
|
11708
|
+
return camelResponse;
|
|
11709
|
+
}
|
|
11479
11710
|
/**
|
|
11480
11711
|
* Updates data in an entity by entity ID
|
|
11481
11712
|
*
|
|
@@ -11585,7 +11816,9 @@
|
|
|
11585
11816
|
/**
|
|
11586
11817
|
* Downloads an attachment from an entity record field
|
|
11587
11818
|
*
|
|
11588
|
-
* @param
|
|
11819
|
+
* @param entityId - UUID of the entity
|
|
11820
|
+
* @param recordId - UUID of the record containing the attachment
|
|
11821
|
+
* @param fieldName - Name of the File-type field containing the attachment
|
|
11589
11822
|
* @returns Promise resolving to Blob containing the file content
|
|
11590
11823
|
*
|
|
11591
11824
|
* @example
|
|
@@ -11594,16 +11827,20 @@
|
|
|
11594
11827
|
*
|
|
11595
11828
|
* const entities = new Entities(sdk);
|
|
11596
11829
|
*
|
|
11830
|
+
* // Get the entityId from getAll()
|
|
11831
|
+
* const allEntities = await entities.getAll();
|
|
11832
|
+
* const entityId = allEntities[0].id;
|
|
11833
|
+
*
|
|
11834
|
+
* // Get the recordId from getAllRecords()
|
|
11835
|
+
* const records = await entities.getAllRecords(entityId);
|
|
11836
|
+
* const recordId = records[0].id;
|
|
11837
|
+
*
|
|
11597
11838
|
* // Download attachment for a specific record and field
|
|
11598
|
-
* const blob = await entities.downloadAttachment(
|
|
11599
|
-
*
|
|
11600
|
-
* recordId: '<record-uuid>',
|
|
11601
|
-
* fieldName: 'Documents'
|
|
11602
|
-
* });
|
|
11839
|
+
* const blob = await entities.downloadAttachment(entityId, recordId, 'Documents');
|
|
11840
|
+
* ```
|
|
11603
11841
|
*/
|
|
11604
|
-
async downloadAttachment(
|
|
11605
|
-
const
|
|
11606
|
-
const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.DOWNLOAD_ATTACHMENT(entityName, recordId, fieldName), {
|
|
11842
|
+
async downloadAttachment(entityId, recordId, fieldName) {
|
|
11843
|
+
const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.DOWNLOAD_ATTACHMENT(entityId, recordId, fieldName), {
|
|
11607
11844
|
responseType: RESPONSE_TYPES.BLOB
|
|
11608
11845
|
});
|
|
11609
11846
|
return response.data;
|
|
@@ -11611,8 +11848,12 @@
|
|
|
11611
11848
|
/**
|
|
11612
11849
|
* Uploads an attachment to a File-type field of an entity record
|
|
11613
11850
|
*
|
|
11614
|
-
* @param
|
|
11615
|
-
* @
|
|
11851
|
+
* @param entityId - UUID of the entity
|
|
11852
|
+
* @param recordId - UUID of the record to upload the attachment to
|
|
11853
|
+
* @param fieldName - Name of the File-type field
|
|
11854
|
+
* @param file - File to upload (Blob, File, or Uint8Array)
|
|
11855
|
+
* @param options - Optional {@link EntityUploadAttachmentOptions} (e.g. expansionLevel)
|
|
11856
|
+
* @returns Promise resolving to {@link EntityUploadAttachmentResponse}
|
|
11616
11857
|
*
|
|
11617
11858
|
* @example
|
|
11618
11859
|
* ```typescript
|
|
@@ -11620,17 +11861,19 @@
|
|
|
11620
11861
|
*
|
|
11621
11862
|
* const entities = new Entities(sdk);
|
|
11622
11863
|
*
|
|
11864
|
+
* // Get the entityId from getAll()
|
|
11865
|
+
* const allEntities = await entities.getAll();
|
|
11866
|
+
* const entityId = allEntities[0].id;
|
|
11867
|
+
*
|
|
11868
|
+
* // Get the recordId from getAllRecords()
|
|
11869
|
+
* const records = await entities.getAllRecords(entityId);
|
|
11870
|
+
* const recordId = records[0].id;
|
|
11871
|
+
*
|
|
11623
11872
|
* // Upload a file attachment
|
|
11624
|
-
* const response = await entities.uploadAttachment(
|
|
11625
|
-
* entityName: 'Invoice',
|
|
11626
|
-
* recordId: '<record-uuid>',
|
|
11627
|
-
* fieldName: 'Documents',
|
|
11628
|
-
* file: file
|
|
11629
|
-
* });
|
|
11873
|
+
* const response = await entities.uploadAttachment(entityId, recordId, 'Documents', file);
|
|
11630
11874
|
* ```
|
|
11631
11875
|
*/
|
|
11632
|
-
async uploadAttachment(options) {
|
|
11633
|
-
const { entityName, recordId, fieldName, file, expansionLevel } = options;
|
|
11876
|
+
async uploadAttachment(entityId, recordId, fieldName, file, options) {
|
|
11634
11877
|
const formData = new FormData();
|
|
11635
11878
|
if (file instanceof Uint8Array) {
|
|
11636
11879
|
formData.append('file', new Blob([file.buffer]));
|
|
@@ -11638,12 +11881,42 @@
|
|
|
11638
11881
|
else {
|
|
11639
11882
|
formData.append('file', file);
|
|
11640
11883
|
}
|
|
11641
|
-
const params = createParams({ expansionLevel });
|
|
11642
|
-
const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPLOAD_ATTACHMENT(
|
|
11884
|
+
const params = createParams({ expansionLevel: options?.expansionLevel });
|
|
11885
|
+
const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPLOAD_ATTACHMENT(entityId, recordId, fieldName), formData, { params });
|
|
11643
11886
|
// Convert PascalCase response to camelCase
|
|
11644
11887
|
const camelResponse = pascalToCamelCaseKeys(response.data);
|
|
11645
11888
|
return camelResponse;
|
|
11646
11889
|
}
|
|
11890
|
+
/**
|
|
11891
|
+
* Removes an attachment from a File-type field of an entity record
|
|
11892
|
+
*
|
|
11893
|
+
* @param entityId - UUID of the entity
|
|
11894
|
+
* @param recordId - UUID of the record containing the attachment
|
|
11895
|
+
* @param fieldName - Name of the File-type field containing the attachment
|
|
11896
|
+
* @returns Promise resolving to {@link EntityDeleteAttachmentResponse}
|
|
11897
|
+
*
|
|
11898
|
+
* @example
|
|
11899
|
+
* ```typescript
|
|
11900
|
+
* import { Entities } from '@uipath/uipath-typescript/entities';
|
|
11901
|
+
*
|
|
11902
|
+
* const entities = new Entities(sdk);
|
|
11903
|
+
*
|
|
11904
|
+
* // Get the entityId from getAll()
|
|
11905
|
+
* const allEntities = await entities.getAll();
|
|
11906
|
+
* const entityId = allEntities[0].id;
|
|
11907
|
+
*
|
|
11908
|
+
* // Get the recordId from getAllRecords()
|
|
11909
|
+
* const records = await entities.getAllRecords(entityId);
|
|
11910
|
+
* const recordId = records[0].id;
|
|
11911
|
+
*
|
|
11912
|
+
* // Delete attachment for a specific record and field
|
|
11913
|
+
* await entities.deleteAttachment(entityId, recordId, 'Documents');
|
|
11914
|
+
* ```
|
|
11915
|
+
*/
|
|
11916
|
+
async deleteAttachment(entityId, recordId, fieldName) {
|
|
11917
|
+
const response = await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_ATTACHMENT(entityId, recordId, fieldName));
|
|
11918
|
+
return response.data;
|
|
11919
|
+
}
|
|
11647
11920
|
/**
|
|
11648
11921
|
* @hidden
|
|
11649
11922
|
* @deprecated Use {@link getAllRecords} instead.
|
|
@@ -11765,6 +12038,9 @@
|
|
|
11765
12038
|
__decorate([
|
|
11766
12039
|
track('Entities.InsertRecordsById')
|
|
11767
12040
|
], EntityService.prototype, "insertRecordsById", null);
|
|
12041
|
+
__decorate([
|
|
12042
|
+
track('Entities.UpdateRecordById')
|
|
12043
|
+
], EntityService.prototype, "updateRecordById", null);
|
|
11768
12044
|
__decorate([
|
|
11769
12045
|
track('Entities.UpdateRecordsById')
|
|
11770
12046
|
], EntityService.prototype, "updateRecordsById", null);
|
|
@@ -11780,6 +12056,9 @@
|
|
|
11780
12056
|
__decorate([
|
|
11781
12057
|
track('Entities.UploadAttachment')
|
|
11782
12058
|
], EntityService.prototype, "uploadAttachment", null);
|
|
12059
|
+
__decorate([
|
|
12060
|
+
track('Entities.DeleteAttachment')
|
|
12061
|
+
], EntityService.prototype, "deleteAttachment", null);
|
|
11783
12062
|
|
|
11784
12063
|
class ChoiceSetService extends BaseService {
|
|
11785
12064
|
/**
|