@github/copilot-language-server 1.552.0 → 1.554.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/README.md +94 -1
- package/dist/contextWorker.js +14 -14
- package/dist/main.js +1030 -1020
- package/dist/node_modules/@github/copilot-sdk/dist/cjs/cliVersion.js +1 -1
- package/dist/node_modules/@github/copilot-sdk/dist/cjs/client.js +507 -37
- package/dist/node_modules/@github/copilot-sdk/dist/cjs/copilotRequestHandler.js +156 -20
- package/dist/node_modules/@github/copilot-sdk/dist/cjs/extension.js +13 -9
- package/dist/node_modules/@github/copilot-sdk/dist/cjs/ffiRuntimeHost.js +14 -3
- package/dist/node_modules/@github/copilot-sdk/dist/cjs/generated/rpc.js +1366 -304
- package/dist/node_modules/@github/copilot-sdk/dist/cjs/host.js +67 -0
- package/dist/node_modules/@github/copilot-sdk/dist/cjs/index.js +12 -7
- package/dist/node_modules/@github/copilot-sdk/dist/cjs/installationConfirmation.js +98 -0
- package/dist/node_modules/@github/copilot-sdk/dist/cjs/runtimeArtifacts.js +1 -0
- package/dist/node_modules/@github/copilot-sdk/dist/cjs/schema.js +40 -0
- package/dist/node_modules/@github/copilot-sdk/dist/cjs/session.js +474 -151
- package/dist/node_modules/@github/copilot-sdk/dist/cjs/sessionFsProvider.js +57 -0
- package/dist/node_modules/@github/copilot-sdk/dist/cjs/types.js +5 -2
- package/dist/node_modules/@github/copilot-sdk/dist/cjs/{factory.js → workflow.js} +33 -33
- package/dist/node_modules/@github/copilot-sdk/package.json +27 -16
- package/dist/node_modules/zod/locales/package.json +1 -2
- package/dist/node_modules/zod/mini/package.json +1 -2
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/node_modules/zod/v3/package.json +1 -2
- package/dist/node_modules/zod/v4/classic/errors.js +2 -2
- package/dist/node_modules/zod/v4/classic/from-json-schema.cjs +16 -31
- package/dist/node_modules/zod/v4/classic/from-json-schema.js +16 -31
- package/dist/node_modules/zod/v4/classic/package.json +1 -2
- package/dist/node_modules/zod/v4/classic/schemas.cjs +119 -358
- package/dist/node_modules/zod/v4/classic/schemas.js +118 -356
- package/dist/node_modules/zod/v4/core/api.cjs +2 -7
- package/dist/node_modules/zod/v4/core/api.js +2 -7
- package/dist/node_modules/zod/v4/core/core.cjs +1 -3
- package/dist/node_modules/zod/v4/core/core.js +2 -4
- package/dist/node_modules/zod/v4/core/errors.cjs +23 -26
- package/dist/node_modules/zod/v4/core/errors.js +23 -26
- package/dist/node_modules/zod/v4/core/json-schema-processors.cjs +20 -16
- package/dist/node_modules/zod/v4/core/json-schema-processors.js +20 -16
- package/dist/node_modules/zod/v4/core/package.json +1 -2
- package/dist/node_modules/zod/v4/core/parse.cjs +7 -7
- package/dist/node_modules/zod/v4/core/parse.js +7 -7
- package/dist/node_modules/zod/v4/core/regexes.cjs +3 -9
- package/dist/node_modules/zod/v4/core/regexes.js +1 -7
- package/dist/node_modules/zod/v4/core/schemas.cjs +65 -211
- package/dist/node_modules/zod/v4/core/schemas.js +64 -210
- package/dist/node_modules/zod/v4/core/to-json-schema.cjs +1 -12
- package/dist/node_modules/zod/v4/core/to-json-schema.js +1 -12
- package/dist/node_modules/zod/v4/core/util.cjs +30 -54
- package/dist/node_modules/zod/v4/core/util.js +32 -55
- package/dist/node_modules/zod/v4/core/versions.cjs +2 -2
- package/dist/node_modules/zod/v4/core/versions.js +2 -2
- package/dist/node_modules/zod/v4/locales/en.cjs +0 -4
- package/dist/node_modules/zod/v4/locales/en.js +0 -4
- package/dist/node_modules/zod/v4/locales/fr.cjs +7 -24
- package/dist/node_modules/zod/v4/locales/fr.js +7 -24
- package/dist/node_modules/zod/v4/locales/index.cjs +1 -8
- package/dist/node_modules/zod/v4/locales/index.js +0 -3
- package/dist/node_modules/zod/v4/locales/it.cjs +1 -1
- package/dist/node_modules/zod/v4/locales/it.js +1 -1
- package/dist/node_modules/zod/v4/locales/ka.cjs +8 -8
- package/dist/node_modules/zod/v4/locales/ka.js +8 -8
- package/dist/node_modules/zod/v4/locales/package.json +1 -2
- package/dist/node_modules/zod/v4/locales/uz.cjs +0 -1
- package/dist/node_modules/zod/v4/locales/uz.js +0 -1
- package/dist/node_modules/zod/v4/mini/package.json +1 -2
- package/dist/node_modules/zod/v4/mini/schemas.cjs +4 -41
- package/dist/node_modules/zod/v4/mini/schemas.js +4 -40
- package/dist/node_modules/zod/v4/package.json +1 -2
- package/dist/node_modules/zod/v4-mini/package.json +1 -2
- package/package.json +20 -20
- package/dist/node_modules/zod/v4/locales/el.cjs +0 -136
- package/dist/node_modules/zod/v4/locales/el.js +0 -109
- package/dist/node_modules/zod/v4/locales/hr.cjs +0 -149
- package/dist/node_modules/zod/v4/locales/hr.js +0 -122
- package/dist/node_modules/zod/v4/locales/ro.cjs +0 -146
- package/dist/node_modules/zod/v4/locales/ro.js +0 -119
|
@@ -24,7 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.$ZodTuple = exports.$ZodIntersection = exports.$ZodDiscriminatedUnion = exports.$ZodXor = exports.$ZodUnion = exports.$ZodObjectJIT = exports.$ZodObject = exports.$ZodArray = exports.$ZodDate = exports.$ZodVoid = exports.$ZodNever = exports.$ZodUnknown = exports.$ZodAny = exports.$ZodNull = exports.$ZodUndefined = exports.$ZodSymbol = exports.$ZodBigIntFormat = exports.$ZodBigInt = exports.$ZodBoolean = exports.$ZodNumberFormat = exports.$ZodNumber = exports.$ZodCustomStringFormat = exports.$ZodJWT = exports.$ZodE164 = exports.$ZodBase64URL = exports.$ZodBase64 = exports.$ZodCIDRv6 = exports.$ZodCIDRv4 = exports.$ZodMAC = exports.$ZodIPv6 = exports.$ZodIPv4 = exports.$ZodISODuration = exports.$ZodISOTime = exports.$ZodISODate = exports.$ZodISODateTime = exports.$ZodKSUID = exports.$ZodXID = exports.$ZodULID = exports.$ZodCUID2 = exports.$ZodCUID = exports.$ZodNanoID = exports.$ZodEmoji = exports.$ZodURL = exports.$ZodEmail = exports.$ZodUUID = exports.$ZodGUID = exports.$ZodStringFormat = exports.$ZodString = exports.clone = exports.$ZodType = void 0;
|
|
27
|
-
exports.$ZodCustom = exports.$ZodLazy = exports.$ZodPromise = exports.$ZodFunction = exports.$ZodTemplateLiteral = exports.$ZodReadonly = exports.$
|
|
27
|
+
exports.$ZodCustom = exports.$ZodLazy = exports.$ZodPromise = exports.$ZodFunction = exports.$ZodTemplateLiteral = exports.$ZodReadonly = exports.$ZodCodec = exports.$ZodPipe = exports.$ZodNaN = exports.$ZodCatch = exports.$ZodSuccess = exports.$ZodNonOptional = exports.$ZodPrefault = exports.$ZodDefault = exports.$ZodNullable = exports.$ZodExactOptional = exports.$ZodOptional = exports.$ZodTransform = exports.$ZodFile = exports.$ZodLiteral = exports.$ZodEnum = exports.$ZodSet = exports.$ZodMap = exports.$ZodRecord = void 0;
|
|
28
28
|
exports.isValidBase64 = isValidBase64;
|
|
29
29
|
exports.isValidBase64URL = isValidBase64URL;
|
|
30
30
|
exports.isValidJWT = isValidJWT;
|
|
@@ -65,8 +65,6 @@ exports.$ZodType = core.$constructor("$ZodType", (inst, def) => {
|
|
|
65
65
|
let asyncResult;
|
|
66
66
|
for (const ch of checks) {
|
|
67
67
|
if (ch._zod.def.when) {
|
|
68
|
-
if (util.explicitlyAborted(payload))
|
|
69
|
-
continue;
|
|
70
68
|
const shouldRun = ch._zod.def.when(payload);
|
|
71
69
|
if (!shouldRun)
|
|
72
70
|
continue;
|
|
@@ -221,21 +219,6 @@ exports.$ZodURL = core.$constructor("$ZodURL", (inst, def) => {
|
|
|
221
219
|
try {
|
|
222
220
|
// Trim whitespace from input
|
|
223
221
|
const trimmed = payload.value.trim();
|
|
224
|
-
// When normalize is off, require :// for http/https URLs
|
|
225
|
-
// This prevents strings like "http:example.com" or "https:/path" from being silently accepted
|
|
226
|
-
if (!def.normalize && def.protocol?.source === regexes.httpProtocol.source) {
|
|
227
|
-
if (!/^https?:\/\//i.test(trimmed)) {
|
|
228
|
-
payload.issues.push({
|
|
229
|
-
code: "invalid_format",
|
|
230
|
-
format: "url",
|
|
231
|
-
note: "Invalid URL format",
|
|
232
|
-
input: payload.value,
|
|
233
|
-
inst,
|
|
234
|
-
continue: !def.abort,
|
|
235
|
-
});
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
222
|
// @ts-ignore
|
|
240
223
|
const url = new URL(trimmed);
|
|
241
224
|
if (def.hostname) {
|
|
@@ -296,11 +279,6 @@ exports.$ZodNanoID = core.$constructor("$ZodNanoID", (inst, def) => {
|
|
|
296
279
|
def.pattern ?? (def.pattern = regexes.nanoid);
|
|
297
280
|
exports.$ZodStringFormat.init(inst, def);
|
|
298
281
|
});
|
|
299
|
-
/**
|
|
300
|
-
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
301
|
-
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
|
|
302
|
-
* See https://github.com/paralleldrive/cuid.
|
|
303
|
-
*/
|
|
304
282
|
exports.$ZodCUID = core.$constructor("$ZodCUID", (inst, def) => {
|
|
305
283
|
def.pattern ?? (def.pattern = regexes.cuid);
|
|
306
284
|
exports.$ZodStringFormat.init(inst, def);
|
|
@@ -406,9 +384,6 @@ exports.$ZodCIDRv6 = core.$constructor("$ZodCIDRv6", (inst, def) => {
|
|
|
406
384
|
function isValidBase64(data) {
|
|
407
385
|
if (data === "")
|
|
408
386
|
return true;
|
|
409
|
-
// atob ignores whitespace, so reject it up front.
|
|
410
|
-
if (/\s/.test(data))
|
|
411
|
-
return false;
|
|
412
387
|
if (data.length % 4 !== 0)
|
|
413
388
|
return false;
|
|
414
389
|
try {
|
|
@@ -613,6 +588,8 @@ exports.$ZodUndefined = core.$constructor("$ZodUndefined", (inst, def) => {
|
|
|
613
588
|
exports.$ZodType.init(inst, def);
|
|
614
589
|
inst._zod.pattern = regexes.undefined;
|
|
615
590
|
inst._zod.values = new Set([undefined]);
|
|
591
|
+
inst._zod.optin = "optional";
|
|
592
|
+
inst._zod.optout = "optional";
|
|
616
593
|
inst._zod.parse = (payload, _ctx) => {
|
|
617
594
|
const input = payload.value;
|
|
618
595
|
if (typeof input === "undefined")
|
|
@@ -742,28 +719,16 @@ exports.$ZodArray = core.$constructor("$ZodArray", (inst, def) => {
|
|
|
742
719
|
return payload; //handleArrayResultsAsync(parseResults, final);
|
|
743
720
|
};
|
|
744
721
|
});
|
|
745
|
-
function handlePropertyResult(result, final, key, input,
|
|
746
|
-
const isPresent = key in input;
|
|
722
|
+
function handlePropertyResult(result, final, key, input, isOptionalOut) {
|
|
747
723
|
if (result.issues.length) {
|
|
748
|
-
// For optional-
|
|
749
|
-
if (
|
|
724
|
+
// For optional-out schemas, ignore errors on absent keys
|
|
725
|
+
if (isOptionalOut && !(key in input)) {
|
|
750
726
|
return;
|
|
751
727
|
}
|
|
752
728
|
final.issues.push(...util.prefixIssues(key, result.issues));
|
|
753
729
|
}
|
|
754
|
-
if (!isPresent && !isOptionalIn) {
|
|
755
|
-
if (!result.issues.length) {
|
|
756
|
-
final.issues.push({
|
|
757
|
-
code: "invalid_type",
|
|
758
|
-
expected: "nonoptional",
|
|
759
|
-
input: undefined,
|
|
760
|
-
path: [key],
|
|
761
|
-
});
|
|
762
|
-
}
|
|
763
|
-
return;
|
|
764
|
-
}
|
|
765
730
|
if (result.value === undefined) {
|
|
766
|
-
if (
|
|
731
|
+
if (key in input) {
|
|
767
732
|
final.value[key] = undefined;
|
|
768
733
|
}
|
|
769
734
|
}
|
|
@@ -789,16 +754,12 @@ function normalizeDef(def) {
|
|
|
789
754
|
}
|
|
790
755
|
function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
791
756
|
const unrecognized = [];
|
|
757
|
+
// iterate over input keys
|
|
792
758
|
const keySet = def.keySet;
|
|
793
759
|
const _catchall = def.catchall._zod;
|
|
794
760
|
const t = _catchall.def.type;
|
|
795
|
-
const isOptionalIn = _catchall.optin === "optional";
|
|
796
761
|
const isOptionalOut = _catchall.optout === "optional";
|
|
797
762
|
for (const key in input) {
|
|
798
|
-
// skip __proto__ so it can't replace the result prototype via the
|
|
799
|
-
// assignment setter on the plain {} we build into
|
|
800
|
-
if (key === "__proto__")
|
|
801
|
-
continue;
|
|
802
763
|
if (keySet.has(key))
|
|
803
764
|
continue;
|
|
804
765
|
if (t === "never") {
|
|
@@ -807,10 +768,10 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
807
768
|
}
|
|
808
769
|
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
|
|
809
770
|
if (r instanceof Promise) {
|
|
810
|
-
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input,
|
|
771
|
+
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
|
|
811
772
|
}
|
|
812
773
|
else {
|
|
813
|
-
handlePropertyResult(r, payload, key, input,
|
|
774
|
+
handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
814
775
|
}
|
|
815
776
|
}
|
|
816
777
|
if (unrecognized.length) {
|
|
@@ -878,14 +839,13 @@ exports.$ZodObject = core.$constructor("$ZodObject", (inst, def) => {
|
|
|
878
839
|
const shape = value.shape;
|
|
879
840
|
for (const key of value.keys) {
|
|
880
841
|
const el = shape[key];
|
|
881
|
-
const isOptionalIn = el._zod.optin === "optional";
|
|
882
842
|
const isOptionalOut = el._zod.optout === "optional";
|
|
883
843
|
const r = el._zod.run({ value: input[key], issues: [] }, ctx);
|
|
884
844
|
if (r instanceof Promise) {
|
|
885
|
-
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input,
|
|
845
|
+
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
|
|
886
846
|
}
|
|
887
847
|
else {
|
|
888
|
-
handlePropertyResult(r, payload, key, input,
|
|
848
|
+
handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
889
849
|
}
|
|
890
850
|
}
|
|
891
851
|
if (!catchall) {
|
|
@@ -918,11 +878,10 @@ exports.$ZodObjectJIT = core.$constructor("$ZodObjectJIT", (inst, def) => {
|
|
|
918
878
|
const id = ids[key];
|
|
919
879
|
const k = util.esc(key);
|
|
920
880
|
const schema = shape[key];
|
|
921
|
-
const isOptionalIn = schema?._zod?.optin === "optional";
|
|
922
881
|
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
923
882
|
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
924
|
-
if (
|
|
925
|
-
// For optional-
|
|
883
|
+
if (isOptionalOut) {
|
|
884
|
+
// For optional-out schemas, ignore errors on absent keys
|
|
926
885
|
doc.write(`
|
|
927
886
|
if (${id}.issues.length) {
|
|
928
887
|
if (${k} in input) {
|
|
@@ -941,34 +900,6 @@ exports.$ZodObjectJIT = core.$constructor("$ZodObjectJIT", (inst, def) => {
|
|
|
941
900
|
newResult[${k}] = ${id}.value;
|
|
942
901
|
}
|
|
943
902
|
|
|
944
|
-
`);
|
|
945
|
-
}
|
|
946
|
-
else if (!isOptionalIn) {
|
|
947
|
-
doc.write(`
|
|
948
|
-
const ${id}_present = ${k} in input;
|
|
949
|
-
if (${id}.issues.length) {
|
|
950
|
-
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
951
|
-
...iss,
|
|
952
|
-
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
953
|
-
})));
|
|
954
|
-
}
|
|
955
|
-
if (!${id}_present && !${id}.issues.length) {
|
|
956
|
-
payload.issues.push({
|
|
957
|
-
code: "invalid_type",
|
|
958
|
-
expected: "nonoptional",
|
|
959
|
-
input: undefined,
|
|
960
|
-
path: [${k}]
|
|
961
|
-
});
|
|
962
|
-
}
|
|
963
|
-
|
|
964
|
-
if (${id}_present) {
|
|
965
|
-
if (${id}.value === undefined) {
|
|
966
|
-
newResult[${k}] = undefined;
|
|
967
|
-
} else {
|
|
968
|
-
newResult[${k}] = ${id}.value;
|
|
969
|
-
}
|
|
970
|
-
}
|
|
971
|
-
|
|
972
903
|
`);
|
|
973
904
|
}
|
|
974
905
|
else {
|
|
@@ -1064,9 +995,10 @@ exports.$ZodUnion = core.$constructor("$ZodUnion", (inst, def) => {
|
|
|
1064
995
|
}
|
|
1065
996
|
return undefined;
|
|
1066
997
|
});
|
|
1067
|
-
const
|
|
998
|
+
const single = def.options.length === 1;
|
|
999
|
+
const first = def.options[0]._zod.run;
|
|
1068
1000
|
inst._zod.parse = (payload, ctx) => {
|
|
1069
|
-
if (
|
|
1001
|
+
if (single) {
|
|
1070
1002
|
return first(payload, ctx);
|
|
1071
1003
|
}
|
|
1072
1004
|
let async = false;
|
|
@@ -1123,9 +1055,10 @@ function handleExclusiveUnionResults(results, final, inst, ctx) {
|
|
|
1123
1055
|
exports.$ZodXor = core.$constructor("$ZodXor", (inst, def) => {
|
|
1124
1056
|
exports.$ZodUnion.init(inst, def);
|
|
1125
1057
|
def.inclusive = false;
|
|
1126
|
-
const
|
|
1058
|
+
const single = def.options.length === 1;
|
|
1059
|
+
const first = def.options[0]._zod.run;
|
|
1127
1060
|
inst._zod.parse = (payload, ctx) => {
|
|
1128
|
-
if (
|
|
1061
|
+
if (single) {
|
|
1129
1062
|
return first(payload, ctx);
|
|
1130
1063
|
}
|
|
1131
1064
|
let async = false;
|
|
@@ -1203,11 +1136,7 @@ core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
|
1203
1136
|
if (opt) {
|
|
1204
1137
|
return opt._zod.run(payload, ctx);
|
|
1205
1138
|
}
|
|
1206
|
-
|
|
1207
|
-
// - explicitly enabled via unionFallback, or
|
|
1208
|
-
// - during backward direction (encode), since codec-based discriminators
|
|
1209
|
-
// have different values in forward vs backward directions
|
|
1210
|
-
if (def.unionFallback || ctx.direction === "backward") {
|
|
1139
|
+
if (def.unionFallback) {
|
|
1211
1140
|
return _super(payload, ctx);
|
|
1212
1141
|
}
|
|
1213
1142
|
// no matching discriminator
|
|
@@ -1216,7 +1145,6 @@ core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
|
1216
1145
|
errors: [],
|
|
1217
1146
|
note: "No matching discriminator",
|
|
1218
1147
|
discriminator: def.discriminator,
|
|
1219
|
-
options: Array.from(disc.value.keys()),
|
|
1220
1148
|
input,
|
|
1221
1149
|
path: [def.discriminator],
|
|
1222
1150
|
inst,
|
|
@@ -1344,112 +1272,67 @@ exports.$ZodTuple = core.$constructor("$ZodTuple", (inst, def) => {
|
|
|
1344
1272
|
}
|
|
1345
1273
|
payload.value = [];
|
|
1346
1274
|
const proms = [];
|
|
1347
|
-
const
|
|
1348
|
-
const
|
|
1275
|
+
const reversedIndex = [...items].reverse().findIndex((item) => item._zod.optin !== "optional");
|
|
1276
|
+
const optStart = reversedIndex === -1 ? 0 : items.length - reversedIndex;
|
|
1349
1277
|
if (!def.rest) {
|
|
1350
|
-
|
|
1278
|
+
const tooBig = input.length > items.length;
|
|
1279
|
+
const tooSmall = input.length < optStart - 1;
|
|
1280
|
+
if (tooBig || tooSmall) {
|
|
1351
1281
|
payload.issues.push({
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1282
|
+
...(tooBig
|
|
1283
|
+
? { code: "too_big", maximum: items.length, inclusive: true }
|
|
1284
|
+
: { code: "too_small", minimum: items.length }),
|
|
1355
1285
|
input,
|
|
1356
1286
|
inst,
|
|
1357
1287
|
origin: "array",
|
|
1358
1288
|
});
|
|
1359
1289
|
return payload;
|
|
1360
1290
|
}
|
|
1361
|
-
if (input.length > items.length) {
|
|
1362
|
-
payload.issues.push({
|
|
1363
|
-
code: "too_big",
|
|
1364
|
-
maximum: items.length,
|
|
1365
|
-
inclusive: true,
|
|
1366
|
-
input,
|
|
1367
|
-
inst,
|
|
1368
|
-
origin: "array",
|
|
1369
|
-
});
|
|
1370
|
-
}
|
|
1371
1291
|
}
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
const
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1292
|
+
let i = -1;
|
|
1293
|
+
for (const item of items) {
|
|
1294
|
+
i++;
|
|
1295
|
+
if (i >= input.length)
|
|
1296
|
+
if (i >= optStart)
|
|
1297
|
+
continue;
|
|
1298
|
+
const result = item._zod.run({
|
|
1299
|
+
value: input[i],
|
|
1300
|
+
issues: [],
|
|
1301
|
+
}, ctx);
|
|
1302
|
+
if (result instanceof Promise) {
|
|
1303
|
+
proms.push(result.then((result) => handleTupleResult(result, payload, i)));
|
|
1383
1304
|
}
|
|
1384
1305
|
else {
|
|
1385
|
-
|
|
1306
|
+
handleTupleResult(result, payload, i);
|
|
1386
1307
|
}
|
|
1387
1308
|
}
|
|
1388
1309
|
if (def.rest) {
|
|
1389
|
-
let i = items.length - 1;
|
|
1390
1310
|
const rest = input.slice(items.length);
|
|
1391
1311
|
for (const el of rest) {
|
|
1392
1312
|
i++;
|
|
1393
|
-
const result = def.rest._zod.run({
|
|
1313
|
+
const result = def.rest._zod.run({
|
|
1314
|
+
value: el,
|
|
1315
|
+
issues: [],
|
|
1316
|
+
}, ctx);
|
|
1394
1317
|
if (result instanceof Promise) {
|
|
1395
|
-
proms.push(result.then((
|
|
1318
|
+
proms.push(result.then((result) => handleTupleResult(result, payload, i)));
|
|
1396
1319
|
}
|
|
1397
1320
|
else {
|
|
1398
1321
|
handleTupleResult(result, payload, i);
|
|
1399
1322
|
}
|
|
1400
1323
|
}
|
|
1401
1324
|
}
|
|
1402
|
-
if (proms.length)
|
|
1403
|
-
return Promise.all(proms).then(() =>
|
|
1404
|
-
|
|
1405
|
-
return handleTupleResults(itemResults, payload, items, input, optoutStart);
|
|
1325
|
+
if (proms.length)
|
|
1326
|
+
return Promise.all(proms).then(() => payload);
|
|
1327
|
+
return payload;
|
|
1406
1328
|
};
|
|
1407
1329
|
});
|
|
1408
|
-
function getTupleOptStart(items, key) {
|
|
1409
|
-
for (let i = items.length - 1; i >= 0; i--) {
|
|
1410
|
-
if (items[i]._zod[key] !== "optional")
|
|
1411
|
-
return i + 1;
|
|
1412
|
-
}
|
|
1413
|
-
return 0;
|
|
1414
|
-
}
|
|
1415
1330
|
function handleTupleResult(result, final, index) {
|
|
1416
1331
|
if (result.issues.length) {
|
|
1417
1332
|
final.issues.push(...util.prefixIssues(index, result.issues));
|
|
1418
1333
|
}
|
|
1419
1334
|
final.value[index] = result.value;
|
|
1420
1335
|
}
|
|
1421
|
-
function handleTupleResults(itemResults, final, items, input, optoutStart) {
|
|
1422
|
-
// Walk results in order. Mirror $ZodObject's swallow-on-absent-optional
|
|
1423
|
-
// rule, but only after `optoutStart`: the first index where the output
|
|
1424
|
-
// tuple tail can be absent.
|
|
1425
|
-
for (let i = 0; i < items.length; i++) {
|
|
1426
|
-
const r = itemResults[i];
|
|
1427
|
-
const isPresent = i < input.length;
|
|
1428
|
-
if (r.issues.length) {
|
|
1429
|
-
if (!isPresent && i >= optoutStart) {
|
|
1430
|
-
final.value.length = i;
|
|
1431
|
-
break;
|
|
1432
|
-
}
|
|
1433
|
-
final.issues.push(...util.prefixIssues(i, r.issues));
|
|
1434
|
-
}
|
|
1435
|
-
final.value[i] = r.value;
|
|
1436
|
-
}
|
|
1437
|
-
// Drop trailing slots that produced `undefined` for absent input
|
|
1438
|
-
// (the array analog of an absent optional key on an object). The
|
|
1439
|
-
// `i >= input.length` floor is critical: an explicit `undefined`
|
|
1440
|
-
// *inside* the input must be preserved even when the schema is
|
|
1441
|
-
// optional-out (e.g. `z.string().or(z.undefined())` accepting an
|
|
1442
|
-
// explicit undefined value).
|
|
1443
|
-
for (let i = final.value.length - 1; i >= input.length; i--) {
|
|
1444
|
-
if (items[i]._zod.optout === "optional" && final.value[i] === undefined) {
|
|
1445
|
-
final.value.length = i;
|
|
1446
|
-
}
|
|
1447
|
-
else {
|
|
1448
|
-
break;
|
|
1449
|
-
}
|
|
1450
|
-
}
|
|
1451
|
-
return final;
|
|
1452
|
-
}
|
|
1453
1336
|
exports.$ZodRecord = core.$constructor("$ZodRecord", (inst, def) => {
|
|
1454
1337
|
exports.$ZodType.init(inst, def);
|
|
1455
1338
|
inst._zod.parse = (payload, ctx) => {
|
|
@@ -1471,36 +1354,20 @@ exports.$ZodRecord = core.$constructor("$ZodRecord", (inst, def) => {
|
|
|
1471
1354
|
for (const key of values) {
|
|
1472
1355
|
if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
|
|
1473
1356
|
recordKeys.add(typeof key === "number" ? key.toString() : key);
|
|
1474
|
-
const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
1475
|
-
if (keyResult instanceof Promise) {
|
|
1476
|
-
throw new Error("Async schemas not supported in object keys currently");
|
|
1477
|
-
}
|
|
1478
|
-
if (keyResult.issues.length) {
|
|
1479
|
-
payload.issues.push({
|
|
1480
|
-
code: "invalid_key",
|
|
1481
|
-
origin: "record",
|
|
1482
|
-
issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
|
1483
|
-
input: key,
|
|
1484
|
-
path: [key],
|
|
1485
|
-
inst,
|
|
1486
|
-
});
|
|
1487
|
-
continue;
|
|
1488
|
-
}
|
|
1489
|
-
const outKey = keyResult.value;
|
|
1490
1357
|
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
|
1491
1358
|
if (result instanceof Promise) {
|
|
1492
1359
|
proms.push(result.then((result) => {
|
|
1493
1360
|
if (result.issues.length) {
|
|
1494
1361
|
payload.issues.push(...util.prefixIssues(key, result.issues));
|
|
1495
1362
|
}
|
|
1496
|
-
payload.value[
|
|
1363
|
+
payload.value[key] = result.value;
|
|
1497
1364
|
}));
|
|
1498
1365
|
}
|
|
1499
1366
|
else {
|
|
1500
1367
|
if (result.issues.length) {
|
|
1501
1368
|
payload.issues.push(...util.prefixIssues(key, result.issues));
|
|
1502
1369
|
}
|
|
1503
|
-
payload.value[
|
|
1370
|
+
payload.value[key] = result.value;
|
|
1504
1371
|
}
|
|
1505
1372
|
}
|
|
1506
1373
|
}
|
|
@@ -1522,12 +1389,9 @@ exports.$ZodRecord = core.$constructor("$ZodRecord", (inst, def) => {
|
|
|
1522
1389
|
}
|
|
1523
1390
|
else {
|
|
1524
1391
|
payload.value = {};
|
|
1525
|
-
// Reflect.ownKeys for Symbol-key support; filter non-enumerable to match z.object()
|
|
1526
1392
|
for (const key of Reflect.ownKeys(input)) {
|
|
1527
1393
|
if (key === "__proto__")
|
|
1528
1394
|
continue;
|
|
1529
|
-
if (!Object.prototype.propertyIsEnumerable.call(input, key))
|
|
1530
|
-
continue;
|
|
1531
1395
|
let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
1532
1396
|
if (keyResult instanceof Promise) {
|
|
1533
1397
|
throw new Error("Async schemas not supported in object keys currently");
|
|
@@ -1748,7 +1612,6 @@ exports.$ZodFile = core.$constructor("$ZodFile", (inst, def) => {
|
|
|
1748
1612
|
});
|
|
1749
1613
|
exports.$ZodTransform = core.$constructor("$ZodTransform", (inst, def) => {
|
|
1750
1614
|
exports.$ZodType.init(inst, def);
|
|
1751
|
-
inst._zod.optin = "optional";
|
|
1752
1615
|
inst._zod.parse = (payload, ctx) => {
|
|
1753
1616
|
if (ctx.direction === "backward") {
|
|
1754
1617
|
throw new core.$ZodEncodeError(inst.constructor.name);
|
|
@@ -1758,7 +1621,6 @@ exports.$ZodTransform = core.$constructor("$ZodTransform", (inst, def) => {
|
|
|
1758
1621
|
const output = _out instanceof Promise ? _out : Promise.resolve(_out);
|
|
1759
1622
|
return output.then((output) => {
|
|
1760
1623
|
payload.value = output;
|
|
1761
|
-
payload.fallback = true;
|
|
1762
1624
|
return payload;
|
|
1763
1625
|
});
|
|
1764
1626
|
}
|
|
@@ -1766,12 +1628,11 @@ exports.$ZodTransform = core.$constructor("$ZodTransform", (inst, def) => {
|
|
|
1766
1628
|
throw new core.$ZodAsyncError();
|
|
1767
1629
|
}
|
|
1768
1630
|
payload.value = _out;
|
|
1769
|
-
payload.fallback = true;
|
|
1770
1631
|
return payload;
|
|
1771
1632
|
};
|
|
1772
1633
|
});
|
|
1773
1634
|
function handleOptionalResult(result, input) {
|
|
1774
|
-
if (
|
|
1635
|
+
if (result.issues.length && input === undefined) {
|
|
1775
1636
|
return { issues: [], value: undefined };
|
|
1776
1637
|
}
|
|
1777
1638
|
return result;
|
|
@@ -1789,11 +1650,10 @@ exports.$ZodOptional = core.$constructor("$ZodOptional", (inst, def) => {
|
|
|
1789
1650
|
});
|
|
1790
1651
|
inst._zod.parse = (payload, ctx) => {
|
|
1791
1652
|
if (def.innerType._zod.optin === "optional") {
|
|
1792
|
-
const input = payload.value;
|
|
1793
1653
|
const result = def.innerType._zod.run(payload, ctx);
|
|
1794
1654
|
if (result instanceof Promise)
|
|
1795
|
-
return result.then((r) => handleOptionalResult(r,
|
|
1796
|
-
return handleOptionalResult(result,
|
|
1655
|
+
return result.then((r) => handleOptionalResult(r, payload.value));
|
|
1656
|
+
return handleOptionalResult(result, payload.value);
|
|
1797
1657
|
}
|
|
1798
1658
|
if (payload.value === undefined) {
|
|
1799
1659
|
return payload;
|
|
@@ -1920,7 +1780,7 @@ exports.$ZodSuccess = core.$constructor("$ZodSuccess", (inst, def) => {
|
|
|
1920
1780
|
});
|
|
1921
1781
|
exports.$ZodCatch = core.$constructor("$ZodCatch", (inst, def) => {
|
|
1922
1782
|
exports.$ZodType.init(inst, def);
|
|
1923
|
-
inst._zod
|
|
1783
|
+
util.defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
1924
1784
|
util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
1925
1785
|
util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1926
1786
|
inst._zod.parse = (payload, ctx) => {
|
|
@@ -1941,7 +1801,6 @@ exports.$ZodCatch = core.$constructor("$ZodCatch", (inst, def) => {
|
|
|
1941
1801
|
input: payload.value,
|
|
1942
1802
|
});
|
|
1943
1803
|
payload.issues = [];
|
|
1944
|
-
payload.fallback = true;
|
|
1945
1804
|
}
|
|
1946
1805
|
return payload;
|
|
1947
1806
|
});
|
|
@@ -1956,7 +1815,6 @@ exports.$ZodCatch = core.$constructor("$ZodCatch", (inst, def) => {
|
|
|
1956
1815
|
input: payload.value,
|
|
1957
1816
|
});
|
|
1958
1817
|
payload.issues = [];
|
|
1959
|
-
payload.fallback = true;
|
|
1960
1818
|
}
|
|
1961
1819
|
return payload;
|
|
1962
1820
|
};
|
|
@@ -2003,7 +1861,7 @@ function handlePipeResult(left, next, ctx) {
|
|
|
2003
1861
|
left.aborted = true;
|
|
2004
1862
|
return left;
|
|
2005
1863
|
}
|
|
2006
|
-
return next._zod.run({ value: left.value, issues: left.issues
|
|
1864
|
+
return next._zod.run({ value: left.value, issues: left.issues }, ctx);
|
|
2007
1865
|
}
|
|
2008
1866
|
exports.$ZodCodec = core.$constructor("$ZodCodec", (inst, def) => {
|
|
2009
1867
|
exports.$ZodType.init(inst, def);
|
|
@@ -2059,9 +1917,6 @@ function handleCodecTxResult(left, value, nextSchema, ctx) {
|
|
|
2059
1917
|
}
|
|
2060
1918
|
return nextSchema._zod.run({ value, issues: left.issues }, ctx);
|
|
2061
1919
|
}
|
|
2062
|
-
exports.$ZodPreprocess = core.$constructor("$ZodPreprocess", (inst, def) => {
|
|
2063
|
-
exports.$ZodPipe.init(inst, def);
|
|
2064
|
-
});
|
|
2065
1920
|
exports.$ZodReadonly = core.$constructor("$ZodReadonly", (inst, def) => {
|
|
2066
1921
|
exports.$ZodType.init(inst, def);
|
|
2067
1922
|
util.defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
|
|
@@ -2219,15 +2074,14 @@ exports.$ZodPromise = core.$constructor("$ZodPromise", (inst, def) => {
|
|
|
2219
2074
|
});
|
|
2220
2075
|
exports.$ZodLazy = core.$constructor("$ZodLazy", (inst, def) => {
|
|
2221
2076
|
exports.$ZodType.init(inst, def);
|
|
2222
|
-
//
|
|
2223
|
-
//
|
|
2224
|
-
//
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
});
|
|
2077
|
+
// let _innerType!: any;
|
|
2078
|
+
// util.defineLazy(def, "getter", () => {
|
|
2079
|
+
// if (!_innerType) {
|
|
2080
|
+
// _innerType = def.getter();
|
|
2081
|
+
// }
|
|
2082
|
+
// return () => _innerType;
|
|
2083
|
+
// });
|
|
2084
|
+
util.defineLazy(inst._zod, "innerType", () => def.getter());
|
|
2231
2085
|
util.defineLazy(inst._zod, "pattern", () => inst._zod.innerType?._zod?.pattern);
|
|
2232
2086
|
util.defineLazy(inst._zod, "propValues", () => inst._zod.innerType?._zod?.propValues);
|
|
2233
2087
|
util.defineLazy(inst._zod, "optin", () => inst._zod.innerType?._zod?.optin ?? undefined);
|