@start9labs/start-sdk 0.4.0-beta.54 → 0.4.0-beta.55
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/base/lib/index.d.ts +1 -9
- package/base/lib/index.js +2 -4
- package/base/lib/index.js.map +1 -1
- package/base/lib/zExport.d.ts +14 -0
- package/base/lib/zExport.js +92 -0
- package/package/package.json +1 -1
- package/package.json +1 -1
package/base/lib/index.d.ts
CHANGED
|
@@ -7,13 +7,5 @@ export * as types from './types';
|
|
|
7
7
|
export * as T from './types';
|
|
8
8
|
export * as yaml from 'yaml';
|
|
9
9
|
export * as inits from './inits';
|
|
10
|
-
|
|
11
|
-
import type { DeepPartial } from './types';
|
|
12
|
-
type ZodDeepPartial = <T>(a: _z.ZodType<T>) => _z.ZodType<DeepPartial<T>>;
|
|
13
|
-
declare module 'zod' {
|
|
14
|
-
namespace z {
|
|
15
|
-
const deepPartial: ZodDeepPartial;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
export { _z as z };
|
|
10
|
+
export { z } from './zExport';
|
|
19
11
|
export * as utils from './util';
|
package/base/lib/index.js
CHANGED
|
@@ -47,9 +47,7 @@ exports.types = __importStar(require("./types"));
|
|
|
47
47
|
exports.T = __importStar(require("./types"));
|
|
48
48
|
exports.yaml = __importStar(require("yaml"));
|
|
49
49
|
exports.inits = __importStar(require("./inits"));
|
|
50
|
-
|
|
51
|
-
Object.defineProperty(exports, "z", { enumerable: true, get: function () { return
|
|
52
|
-
const zod_deep_partial_1 = require("zod-deep-partial");
|
|
53
|
-
zod_1.z.deepPartial = (a) => (0, zod_deep_partial_1.zodDeepPartial)(a).passthrough();
|
|
50
|
+
var zExport_1 = require("./zExport");
|
|
51
|
+
Object.defineProperty(exports, "z", { enumerable: true, get: function () { return zExport_1.z; } });
|
|
54
52
|
exports.utils = __importStar(require("./util"));
|
|
55
53
|
//# sourceMappingURL=index.js.map
|
package/base/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../base/lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA6B;AAApB,4FAAA,IAAI,OAAA;AACb,iCAAgE;AAAvD,qGAAA,YAAY,OAAA;AAAE,wGAAA,eAAe,OAAA;AAAE,gGAAA,OAAO,OAAA;AAE/C,6DAA4C;AAC5C,+DAA8C;AAC9C,sEAAqD;AACrD,iDAAgC;AAChC,6CAA4B;AAC5B,6CAA4B;AAC5B,iDAAgC;AAChC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../base/lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA6B;AAApB,4FAAA,IAAI,OAAA;AACb,iCAAgE;AAAvD,qGAAA,YAAY,OAAA;AAAE,wGAAA,eAAe,OAAA;AAAE,gGAAA,OAAO,OAAA;AAE/C,6DAA4C;AAC5C,+DAA8C;AAC9C,sEAAqD;AACrD,iDAAgC;AAChC,6CAA4B;AAC5B,6CAA4B;AAC5B,iDAAgC;AAChC,qCAA6B;AAApB,4FAAA,CAAC,OAAA;AAEV,gDAA+B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z as _z } from 'zod'
|
|
2
|
+
import type { DeepPartial } from './types'
|
|
3
|
+
|
|
4
|
+
type ZodDeepPartial = <T>(a: _z.ZodType<T>) => _z.ZodType<DeepPartial<T>>
|
|
5
|
+
type ZodDeepLoose = <T>(a: _z.ZodType<T>) => _z.ZodType<T>
|
|
6
|
+
|
|
7
|
+
declare module 'zod' {
|
|
8
|
+
namespace z {
|
|
9
|
+
const deepPartial: ZodDeepPartial
|
|
10
|
+
const deepLoose: ZodDeepLoose
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { _z as z }
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const zod_deep_partial_1 = require("zod-deep-partial");
|
|
6
|
+
|
|
7
|
+
// Recursively make all ZodObjects in a schema loose (preserve extra keys at every nesting level).
|
|
8
|
+
// Uses _zod.def.type duck-typing instead of instanceof to avoid issues with mismatched zod versions.
|
|
9
|
+
function deepLoose(schema) {
|
|
10
|
+
const def = schema._zod?.def;
|
|
11
|
+
if (!def) return schema;
|
|
12
|
+
let result;
|
|
13
|
+
switch (def.type) {
|
|
14
|
+
case "optional":
|
|
15
|
+
result = deepLoose(def.innerType).optional();
|
|
16
|
+
break;
|
|
17
|
+
case "nullable":
|
|
18
|
+
result = deepLoose(def.innerType).nullable();
|
|
19
|
+
break;
|
|
20
|
+
case "object": {
|
|
21
|
+
const newShape = {};
|
|
22
|
+
for (const key in schema.shape) {
|
|
23
|
+
newShape[key] = deepLoose(schema.shape[key]);
|
|
24
|
+
}
|
|
25
|
+
result = zod_1.z.looseObject(newShape);
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
case "array":
|
|
29
|
+
result = zod_1.z.array(deepLoose(def.element));
|
|
30
|
+
break;
|
|
31
|
+
case "union":
|
|
32
|
+
result = zod_1.z.union(def.options.map((o) => deepLoose(o)));
|
|
33
|
+
break;
|
|
34
|
+
case "intersection":
|
|
35
|
+
result = zod_1.z.intersection(deepLoose(def.left), deepLoose(def.right));
|
|
36
|
+
break;
|
|
37
|
+
case "record":
|
|
38
|
+
result = zod_1.z.record(def.keyType, deepLoose(def.valueType));
|
|
39
|
+
break;
|
|
40
|
+
case "tuple":
|
|
41
|
+
result = zod_1.z.tuple(def.items.map((i) => deepLoose(i)));
|
|
42
|
+
break;
|
|
43
|
+
case "lazy":
|
|
44
|
+
result = zod_1.z.lazy(() => deepLoose(def.getter()));
|
|
45
|
+
break;
|
|
46
|
+
default:
|
|
47
|
+
return schema;
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Add deepPartial and deepLoose to z at runtime
|
|
53
|
+
zod_1.z.deepPartial = (a) =>
|
|
54
|
+
deepLoose((0, zod_deep_partial_1.zodDeepPartial)(a));
|
|
55
|
+
zod_1.z.deepLoose = deepLoose;
|
|
56
|
+
|
|
57
|
+
// Override z.object to produce loose objects by default (extra keys are preserved, not stripped).
|
|
58
|
+
const _origObject = zod_1.z.object;
|
|
59
|
+
const _patchedObject = (...args) => _origObject(...args).loose();
|
|
60
|
+
|
|
61
|
+
// In CJS (Node.js), patch the source module in require.cache where 'object' is a writable property;
|
|
62
|
+
// the CJS getter chain (index → external → schemas) then relays the patched version.
|
|
63
|
+
// We walk only the zod entry module's dependency tree and match by identity (=== origObject).
|
|
64
|
+
try {
|
|
65
|
+
const _zodModule = require.cache[require.resolve("zod")];
|
|
66
|
+
for (const child of _zodModule?.children ?? []) {
|
|
67
|
+
for (const grandchild of child.children ?? []) {
|
|
68
|
+
const desc = Object.getOwnPropertyDescriptor(
|
|
69
|
+
grandchild.exports,
|
|
70
|
+
"object",
|
|
71
|
+
);
|
|
72
|
+
if (desc?.value === _origObject && desc.writable) {
|
|
73
|
+
grandchild.exports.object = _patchedObject;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
} catch (_) {
|
|
78
|
+
// Not in CJS/Node environment (e.g. browser) — require.cache unavailable
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// z.object is a non-configurable getter on the zod namespace, so we can't override it directly.
|
|
82
|
+
// Shadow it by exporting a new object with _z as prototype and our patched object on the instance.
|
|
83
|
+
const z = Object.create(zod_1.z, {
|
|
84
|
+
object: {
|
|
85
|
+
value: _patchedObject,
|
|
86
|
+
writable: true,
|
|
87
|
+
configurable: true,
|
|
88
|
+
enumerable: true,
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
exports.z = z;
|
package/package/package.json
CHANGED
package/package.json
CHANGED