zeed 1.3.1 → 1.5.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/AGENTS.md +50 -211
- package/README.md +16 -0
- package/dist/_experiments/bitcask.cjs +2 -2
- package/dist/{args-FLoL3OKJ.d.cts → args-CEjib9V9.d.mts} +1 -1
- package/dist/{args-WC9q5kz2.d.mts → args-DEig-jw4.d.cts} +1 -1
- package/dist/{clipboard-BkUO-syY.d.mts → clipboard-BusqmLLY.d.cts} +1 -1
- package/dist/{clipboard-Cfpr331X.d.cts → clipboard-DcuuFRwa.d.mts} +1 -1
- package/dist/common/exec/index.d.cts +3 -3
- package/dist/common/exec/index.d.mts +3 -3
- package/dist/common/exec/pool.d.cts +1 -1
- package/dist/common/exec/pool.d.mts +1 -1
- package/dist/common/exec/progress.d.cts +1 -1
- package/dist/common/exec/progress.d.mts +1 -1
- package/dist/common/exec/promise.d.cts +1 -1
- package/dist/common/exec/promise.d.mts +1 -1
- package/dist/common/exec/queue.d.cts +1 -1
- package/dist/common/exec/queue.d.mts +1 -1
- package/dist/common/exec/throttle-debounce.d.cts +1 -1
- package/dist/common/exec/throttle-debounce.d.mts +1 -1
- package/dist/common/index.cjs +21 -0
- package/dist/common/index.d.cts +15 -12
- package/dist/common/index.d.mts +16 -13
- package/dist/common/index.mjs +4 -1
- package/dist/common/msg/channel-debug.d.cts +1 -1
- package/dist/common/msg/channel-debug.d.mts +1 -1
- package/dist/common/msg/channel-local.d.cts +1 -1
- package/dist/common/msg/channel-local.d.mts +1 -1
- package/dist/common/msg/channel-resilient.d.cts +1 -1
- package/dist/common/msg/channel-resilient.d.mts +1 -1
- package/dist/common/msg/channel-wkwebview.d.cts +2 -1
- package/dist/common/msg/channel-wkwebview.d.mts +2 -1
- package/dist/common/msg/channel.d.cts +1 -1
- package/dist/common/msg/channel.d.mts +1 -1
- package/dist/common/msg/emitter.d.cts +1 -1
- package/dist/common/msg/emitter.d.mts +1 -1
- package/dist/common/msg/index.d.cts +1 -1
- package/dist/common/msg/index.d.mts +1 -1
- package/dist/common/msg/messages.d.cts +1 -1
- package/dist/common/msg/messages.d.mts +1 -1
- package/dist/common/msg/pubsub.d.cts +1 -1
- package/dist/common/msg/pubsub.d.mts +1 -1
- package/dist/common/msg/rpc.cjs +8 -8
- package/dist/common/msg/rpc.cjs.map +1 -1
- package/dist/common/msg/rpc.mjs +8 -8
- package/dist/common/msg/rpc.mjs.map +1 -1
- package/dist/common/schema/export-json-schema.cjs +40 -31
- package/dist/common/schema/export-json-schema.cjs.map +1 -1
- package/dist/common/schema/export-json-schema.mjs +40 -31
- package/dist/common/schema/export-json-schema.mjs.map +1 -1
- package/dist/common/schema/index.cjs +21 -0
- package/dist/common/schema/index.d.cts +6 -3
- package/dist/common/schema/index.d.mts +7 -4
- package/dist/common/schema/index.mjs +4 -1
- package/dist/common/schema/sql/expr.cjs +128 -0
- package/dist/common/schema/sql/expr.cjs.map +1 -0
- package/dist/common/schema/sql/expr.d.cts +2 -0
- package/dist/common/schema/sql/expr.d.mts +2 -0
- package/dist/common/schema/sql/expr.mjs +115 -0
- package/dist/common/schema/sql/expr.mjs.map +1 -0
- package/dist/common/schema/sql/index.cjs +23 -0
- package/dist/common/schema/sql/index.d.cts +4 -0
- package/dist/common/schema/sql/index.d.mts +4 -0
- package/dist/common/schema/sql/index.mjs +5 -0
- package/dist/common/schema/sql/select.cjs +143 -0
- package/dist/common/schema/sql/select.cjs.map +1 -0
- package/dist/common/schema/sql/select.d.cts +2 -0
- package/dist/common/schema/sql/select.d.mts +2 -0
- package/dist/common/schema/sql/select.mjs +139 -0
- package/dist/common/schema/sql/select.mjs.map +1 -0
- package/dist/common/schema/sql/table.cjs +23 -0
- package/dist/common/schema/sql/table.cjs.map +1 -0
- package/dist/common/schema/sql/table.d.cts +2 -0
- package/dist/common/schema/sql/table.d.mts +2 -0
- package/dist/common/schema/sql/table.mjs +20 -0
- package/dist/common/schema/sql/table.mjs.map +1 -0
- package/dist/common/schema/type-test.d.cts +1 -1
- package/dist/common/schema/type-test.d.mts +1 -1
- package/dist/common/schema/utils.d.cts +1 -1
- package/dist/common/schema/utils.d.mts +1 -1
- package/dist/common/schema/z.d.mts +1 -1
- package/dist/common/storage/index.d.cts +1 -1
- package/dist/common/storage/index.d.mts +1 -1
- package/dist/common/storage/memstorage.d.cts +1 -1
- package/dist/common/storage/memstorage.d.mts +1 -1
- package/dist/common/test.d.cts +1 -1
- package/dist/common/test.d.mts +1 -1
- package/dist/common/time.d.cts +1 -1
- package/dist/common/time.d.mts +1 -1
- package/dist/common/timeout.d.cts +1 -1
- package/dist/common/timeout.d.mts +1 -1
- package/dist/common/utils.d.cts +1 -1
- package/dist/common/utils.d.mts +1 -1
- package/dist/common/uuid.d.cts +1 -1
- package/dist/common/uuid.d.mts +1 -1
- package/dist/{crypto-CyTV7Qce.d.cts → crypto-D68rVmvU.d.mts} +1 -1
- package/dist/{crypto-LT7EC5_d.d.mts → crypto-KzGHoCJE.d.cts} +1 -1
- package/dist/{env-B3vOiVY8.d.cts → env-BJXdwBKq.d.mts} +1 -1
- package/dist/{env-C3npYe8w.d.mts → env-HsOnA_yK.d.cts} +1 -1
- package/dist/expr-CCKrqOw1.d.mts +25 -0
- package/dist/expr-yYgSeBZ3.d.cts +25 -0
- package/dist/{files-CDNKX9VI.d.mts → files-4O-PxnAC.d.cts} +1 -1
- package/dist/{files-DdI9UZvg.d.cts → files-BlpxqSTT.d.mts} +1 -1
- package/dist/{files-async-1V0bu_ca.d.cts → files-async-DFLC-Nkd.d.cts} +1 -1
- package/dist/{files-async-cBMkRwsu.d.mts → files-async-DfuEEDjH.d.mts} +1 -1
- package/dist/{filestorage-CXQ9MzeW.d.cts → filestorage-BjeBZEAs.d.cts} +1 -1
- package/dist/{filestorage-YzM2z9sU.d.mts → filestorage-CmfztpWm.d.mts} +1 -1
- package/dist/{fs-DHJ9AqUk.d.cts → fs-D837bjRT.d.cts} +1 -1
- package/dist/{fs-DgjZdpuF.d.mts → fs-DlYLapik.d.mts} +1 -1
- package/dist/{glob-Bfs7ZS_i.d.mts → glob-5yW09dkR.d.mts} +1 -1
- package/dist/{glob-Bt150jOY.d.cts → glob-CZaZPqiy.d.cts} +1 -1
- package/dist/{index-DHXVOH8h.d.cts → index-CFkMqHvX.d.cts} +1 -2
- package/dist/{index-DMaPyx9O.d.mts → index-C_3Y_s6f.d.mts} +1 -2
- package/dist/index.all.cjs +21 -0
- package/dist/index.all.d.cts +29 -26
- package/dist/index.all.d.mts +30 -27
- package/dist/index.all.mjs +4 -1
- package/dist/index.browser.cjs +21 -0
- package/dist/index.browser.d.cts +15 -12
- package/dist/index.browser.d.mts +16 -13
- package/dist/index.browser.mjs +4 -1
- package/dist/index.jsr.d.cts +4 -4
- package/dist/index.jsr.d.mts +4 -4
- package/dist/index.node.cjs +21 -0
- package/dist/index.node.d.cts +29 -26
- package/dist/index.node.d.mts +30 -27
- package/dist/index.node.mjs +4 -1
- package/dist/{log-file-bsTsc9KM.d.cts → log-file-DwEDms1F.d.cts} +2 -2
- package/dist/{log-file-DTuImomJ.d.mts → log-file-QV1unm3z.d.mts} +2 -2
- package/dist/{log-file-rotation-_YruAcNc.d.cts → log-file-rotation-BpZxXYlU.d.cts} +2 -2
- package/dist/{log-file-rotation-FBmtp_Uz.d.mts → log-file-rotation-DanrO_2y.d.mts} +2 -2
- package/dist/{log-node-DlrXl3QO.d.mts → log-node-BSn7RqAc.d.mts} +1 -1
- package/dist/{log-node-Dk948mHX.d.cts → log-node-D_fiJL6x.d.cts} +1 -1
- package/dist/{log-rotation-CkyjZbK5.d.mts → log-rotation-BdGakFya.d.cts} +1 -1
- package/dist/{log-rotation-_d7iRm9s.d.cts → log-rotation-Ce4e-8LN.d.mts} +1 -1
- package/dist/{log-util-2Ls76P-0.d.cts → log-util-C0U3zCjw.d.cts} +1 -1
- package/dist/{log-util-Da_d19f8.d.mts → log-util-Da_UCcmt.d.mts} +1 -1
- package/dist/{memstorage-D5A9FwiP.d.mts → memstorage-BhWXthO8.d.mts} +1 -1
- package/dist/{memstorage-BcjQLdaQ.d.cts → memstorage-tvlWDYgS.d.cts} +1 -1
- package/dist/node/args.cjs +1 -1
- package/dist/node/args.d.cts +1 -1
- package/dist/node/args.d.mts +1 -1
- package/dist/node/clipboard.d.cts +1 -1
- package/dist/node/clipboard.d.mts +1 -1
- package/dist/node/crypto.cjs +1 -1
- package/dist/node/crypto.d.cts +1 -1
- package/dist/node/crypto.d.mts +1 -1
- package/dist/node/env.cjs +2 -2
- package/dist/node/env.d.cts +1 -1
- package/dist/node/env.d.mts +1 -1
- package/dist/node/files-async.cjs +1 -1
- package/dist/node/files-async.d.cts +1 -1
- package/dist/node/files-async.d.mts +1 -1
- package/dist/node/files.cjs +1 -1
- package/dist/node/files.d.cts +1 -1
- package/dist/node/files.d.mts +1 -1
- package/dist/node/filestorage.cjs +1 -1
- package/dist/node/filestorage.d.cts +1 -1
- package/dist/node/filestorage.d.mts +1 -1
- package/dist/node/fs.cjs +1 -1
- package/dist/node/fs.d.cts +1 -1
- package/dist/node/fs.d.mts +1 -1
- package/dist/node/glob.d.cts +1 -1
- package/dist/node/glob.d.mts +1 -1
- package/dist/node/index.d.cts +14 -14
- package/dist/node/index.d.mts +14 -14
- package/dist/node/log/index.d.cts +5 -5
- package/dist/node/log/index.d.mts +5 -5
- package/dist/node/log/log-context-node.cjs +1 -1
- package/dist/node/log/log-file-rotation.d.cts +1 -1
- package/dist/node/log/log-file-rotation.d.mts +1 -1
- package/dist/node/log/log-file.cjs +1 -1
- package/dist/node/log/log-file.d.cts +1 -1
- package/dist/node/log/log-file.d.mts +1 -1
- package/dist/node/log/log-node.cjs +6 -15
- package/dist/node/log/log-node.cjs.map +1 -1
- package/dist/node/log/log-node.d.cts +1 -1
- package/dist/node/log/log-node.d.mts +1 -1
- package/dist/node/log/log-node.mjs +4 -13
- package/dist/node/log/log-node.mjs.map +1 -1
- package/dist/node/log/log-rotation.cjs +1 -1
- package/dist/node/log/log-rotation.d.cts +1 -1
- package/dist/node/log/log-rotation.d.mts +1 -1
- package/dist/node/log/log-util.cjs +1 -1
- package/dist/node/log/log-util.d.cts +1 -1
- package/dist/node/log/log-util.d.mts +1 -1
- package/dist/{promise-DGgiRckN.d.cts → promise-CU_CENbU.d.cts} +1 -1
- package/dist/{promise-MH3xAy4S.d.mts → promise-CoWXgo4w.d.mts} +1 -1
- package/dist/select-DrciHdk_.d.cts +52 -0
- package/dist/select-F2KpP6mo.d.mts +52 -0
- package/dist/table-Cr8tjDIL.d.mts +19 -0
- package/dist/table-IkLXirT-.d.cts +19 -0
- package/dist/{test-CAhm15f4.d.mts → test-DcXa0MeX.d.cts} +1 -1
- package/dist/{test-D2plOVHF.d.cts → test-jZsc7P2c.d.mts} +1 -1
- package/dist/{throttle-debounce-BLFxAZ8W.d.mts → throttle-debounce-CCh0F100.d.mts} +1 -1
- package/dist/{throttle-debounce-Psb0ay1r.d.cts → throttle-debounce-DyFiyoAk.d.cts} +1 -1
- package/dist/{time-BfKJBbym.d.cts → time-BgFZe9ys.d.cts} +1 -1
- package/dist/{time-DxE-vjjw.d.mts → time-DSV_k3mG.d.mts} +1 -1
- package/dist/{timeout-CnUk6Ruj.d.mts → timeout-DDSSNZY8.d.mts} +1 -1
- package/dist/{timeout-CpFcK8MD.d.cts → timeout-E3ZQbJgK.d.cts} +1 -1
- package/dist/{type-test-BiKyEZkc.d.mts → type-test-BvzWDJz3.d.mts} +1 -1
- package/dist/{type-test-sM7QpfQU.d.cts → type-test-CBK-iJ9d.d.cts} +1 -1
- package/dist/{utils-B8DsVgFr.d.mts → utils-1RyCGkpQ.d.mts} +1 -1
- package/dist/{utils-BfZkD2Pt.d.mts → utils-6Culwiaf.d.cts} +1 -1
- package/dist/{utils-DHQBNh-Z.d.cts → utils-CDJihcg3.d.mts} +1 -1
- package/dist/{utils-Bctk_WhH.d.cts → utils-nCQklGHV.d.cts} +1 -1
- package/dist/{uuid-Cusm2nIK.d.cts → uuid-CKFZfSff.d.mts} +1 -1
- package/dist/{uuid-ININPGKB.d.mts → uuid-D42A8UdP.d.cts} +1 -1
- package/dist/z-C0fpNWZg.d.cts +1 -0
- package/dist/z-D_jezYmm.d.mts +1 -0
- package/dist/{z-collection-BmuBin--.d.mts → z-collection-BSfgRU0Q.d.mts} +1 -1
- package/package.json +17 -18
- package/src/common/schema/README.md +247 -66
- package/src/common/schema/export-json-schema.spec.ts +11 -7
- package/src/common/schema/export-json-schema.ts +59 -52
- package/src/common/schema/index.ts +1 -0
- package/src/common/schema/sql/README.md +254 -0
- package/src/common/schema/sql/expr.ts +99 -0
- package/src/common/schema/sql/index.ts +3 -0
- package/src/common/schema/sql/select.spec.ts +144 -0
- package/src/common/schema/sql/select.ts +207 -0
- package/src/common/schema/sql/table.ts +36 -0
- package/src/common/schema/README-SCHEMA.md +0 -0
- /package/dist/{index-BH1nuHdZ.d.cts → index-CIABef8t.d.mts} +0 -0
- /package/dist/{index-BL7o4fG9.d.cts → index-CliqZ9rj.d.mts} +0 -0
- /package/dist/{index-CP2eJYlK.d.mts → index-D6xqj1Qx.d.cts} +0 -0
- /package/dist/{index-DjOaHFU3.d.mts → index-DHFfG4yr.d.cts} +0 -0
- /package/dist/{index-sViox9YW.d.mts → index-N-OgGgfF.d.mts} +0 -0
- /package/dist/{z-ClMox7qS.d.mts → index-WOw4GVZo.d.cts} +0 -0
- /package/dist/{z-dtM4F8Lo.d.cts → index-luywJTzJ.d.mts} +0 -0
|
@@ -1,46 +1,55 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_common_data_is = require('../data/is.cjs');
|
|
3
|
-
const require_common_data_object = require('../data/object.cjs');
|
|
4
3
|
|
|
5
4
|
//#region src/common/schema/export-json-schema.ts
|
|
6
|
-
const
|
|
5
|
+
const _primitiveMap = {
|
|
7
6
|
string: "string",
|
|
8
7
|
number: "number",
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
int: "integer",
|
|
9
|
+
boolean: "boolean"
|
|
11
10
|
};
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
function transformSchema(schema) {
|
|
12
|
+
const out = {};
|
|
13
|
+
if (schema._enumValues) {
|
|
14
|
+
out.type = _primitiveMap[schema.type] ?? schema.type;
|
|
15
|
+
out.enum = [...schema._enumValues];
|
|
16
|
+
} else if (schema.type === "literal") out.const = schema._default;
|
|
17
|
+
else if (schema.type === "union" && Array.isArray(schema._union)) out.anyOf = schema._union.map((s) => transformSchema(s));
|
|
18
|
+
else if (schema.type === "object" && schema._object) {
|
|
19
|
+
out.type = "object";
|
|
15
20
|
const properties = {};
|
|
16
21
|
const required = [];
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
22
|
+
for (const key of Object.keys(schema._object)) {
|
|
23
|
+
const propSchema = schema._object[key];
|
|
24
|
+
properties[key] = transformSchema(propSchema);
|
|
25
|
+
if (propSchema._optional !== true) required.push(key);
|
|
26
|
+
}
|
|
27
|
+
if (!require_common_data_is.isEmpty(properties)) out.properties = properties;
|
|
28
|
+
out.additionalProperties = false;
|
|
29
|
+
if (required.length > 0) out.required = required;
|
|
30
|
+
} else if (schema.type === "record" && schema._type) {
|
|
31
|
+
out.type = "object";
|
|
32
|
+
out.additionalProperties = transformSchema(schema._type);
|
|
33
|
+
} else if (schema.type === "array" && schema._type) {
|
|
34
|
+
out.type = "array";
|
|
35
|
+
out.items = transformSchema(schema._type);
|
|
36
|
+
} else if (schema.type === "tuple" && Array.isArray(schema._type)) {
|
|
37
|
+
out.type = "array";
|
|
38
|
+
out.items = schema._type.map((s) => transformSchema(s));
|
|
39
|
+
out.minItems = schema._type.length;
|
|
40
|
+
out.maxItems = schema._type.length;
|
|
41
|
+
} else if (schema.type === "none") out.type = "null";
|
|
42
|
+
else if (schema.type === "any") {} else {
|
|
43
|
+
const t = _primitiveMap[schema.type];
|
|
44
|
+
if (t) out.type = t;
|
|
40
45
|
}
|
|
46
|
+
if (schema._default !== void 0 && schema.type !== "literal") out.default = schema._default;
|
|
47
|
+
if (schema._meta?.desc) out.description = schema._meta.desc;
|
|
48
|
+
return out;
|
|
49
|
+
}
|
|
50
|
+
function schemaExportJsonSchema(schema) {
|
|
41
51
|
return {
|
|
42
52
|
$schema: "http://json-schema.org/draft-07/schema#",
|
|
43
|
-
additionalProperties: false,
|
|
44
53
|
...transformSchema(schema)
|
|
45
54
|
};
|
|
46
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export-json-schema.cjs","names":["isEmpty"],"sources":["../../../src/common/schema/export-json-schema.ts"],"sourcesContent":["import type { Type } from './schema'\nimport { isEmpty } from '../data'\
|
|
1
|
+
{"version":3,"file":"export-json-schema.cjs","names":["isEmpty"],"sources":["../../../src/common/schema/export-json-schema.ts"],"sourcesContent":["import type { Type } from './schema'\nimport { isEmpty } from '../data'\n\nconst _primitiveMap: Record<string, string> = {\n string: 'string',\n number: 'number',\n int: 'integer',\n boolean: 'boolean',\n}\n\nfunction transformSchema(schema: Type<any>): Record<string, any> {\n const out: Record<string, any> = {}\n\n if (schema._enumValues) {\n out.type = _primitiveMap[schema.type] ?? schema.type\n out.enum = [...schema._enumValues]\n }\n else if (schema.type === 'literal') {\n out.const = schema._default\n }\n else if (schema.type === 'union' && Array.isArray(schema._union)) {\n out.anyOf = schema._union.map((s: Type<any>) => transformSchema(s))\n }\n else if (schema.type === 'object' && schema._object) {\n out.type = 'object'\n const properties: Record<string, any> = {}\n const required: string[] = []\n for (const key of Object.keys(schema._object)) {\n const propSchema = schema._object[key] as Type<any>\n properties[key] = transformSchema(propSchema)\n if (propSchema._optional !== true)\n required.push(key)\n }\n if (!isEmpty(properties))\n out.properties = properties\n out.additionalProperties = false\n if (required.length > 0)\n out.required = required\n }\n else if (schema.type === 'record' && schema._type) {\n out.type = 'object'\n out.additionalProperties = transformSchema(schema._type)\n }\n else if (schema.type === 'array' && schema._type) {\n out.type = 'array'\n out.items = transformSchema(schema._type)\n }\n else if (schema.type === 'tuple' && Array.isArray(schema._type)) {\n out.type = 'array'\n out.items = (schema._type as Type<any>[]).map(s => transformSchema(s))\n out.minItems = schema._type.length\n out.maxItems = schema._type.length\n }\n else if (schema.type === 'none') {\n out.type = 'null'\n }\n else if (schema.type === 'any') {\n // no constraint\n }\n else {\n const t = _primitiveMap[schema.type]\n if (t)\n out.type = t\n }\n\n if (schema._default !== undefined && schema.type !== 'literal')\n out.default = schema._default\n if (schema._meta?.desc)\n out.description = schema._meta.desc\n\n return out\n}\n\nexport function schemaExportJsonSchema<T>(schema: Type<T>): Record<string, any> {\n return {\n $schema: 'http://json-schema.org/draft-07/schema#',\n ...transformSchema(schema),\n }\n}\n\nexport function schemaExportJsonSchemaString<T>(schema: Type<T>): string {\n const jsonSchema = schemaExportJsonSchema(schema)\n return JSON.stringify(jsonSchema, null, 2)\n}\n"],"mappings":";;;;AAGA,MAAM,gBAAwC;CAC5C,QAAQ;CACR,QAAQ;CACR,KAAK;CACL,SAAS;CACV;AAED,SAAS,gBAAgB,QAAwC;CAC/D,MAAM,MAA2B,EAAE;AAEnC,KAAI,OAAO,aAAa;AACtB,MAAI,OAAO,cAAc,OAAO,SAAS,OAAO;AAChD,MAAI,OAAO,CAAC,GAAG,OAAO,YAAY;YAE3B,OAAO,SAAS,UACvB,KAAI,QAAQ,OAAO;UAEZ,OAAO,SAAS,WAAW,MAAM,QAAQ,OAAO,OAAO,CAC9D,KAAI,QAAQ,OAAO,OAAO,KAAK,MAAiB,gBAAgB,EAAE,CAAC;UAE5D,OAAO,SAAS,YAAY,OAAO,SAAS;AACnD,MAAI,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pty } from "../data/is.mjs";
|
|
2
|
-
import { objectMap } from "../data/object.mjs";
|
|
3
2
|
|
|
4
3
|
//#region src/common/schema/export-json-schema.ts
|
|
5
|
-
const
|
|
4
|
+
const _primitiveMap = {
|
|
6
5
|
string: "string",
|
|
7
6
|
number: "number",
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
int: "integer",
|
|
8
|
+
boolean: "boolean"
|
|
10
9
|
};
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
function transformSchema(schema) {
|
|
11
|
+
const out = {};
|
|
12
|
+
if (schema._enumValues) {
|
|
13
|
+
out.type = _primitiveMap[schema.type] ?? schema.type;
|
|
14
|
+
out.enum = [...schema._enumValues];
|
|
15
|
+
} else if (schema.type === "literal") out.const = schema._default;
|
|
16
|
+
else if (schema.type === "union" && Array.isArray(schema._union)) out.anyOf = schema._union.map((s) => transformSchema(s));
|
|
17
|
+
else if (schema.type === "object" && schema._object) {
|
|
18
|
+
out.type = "object";
|
|
14
19
|
const properties = {};
|
|
15
20
|
const required = [];
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
21
|
+
for (const key of Object.keys(schema._object)) {
|
|
22
|
+
const propSchema = schema._object[key];
|
|
23
|
+
properties[key] = transformSchema(propSchema);
|
|
24
|
+
if (propSchema._optional !== true) required.push(key);
|
|
25
|
+
}
|
|
26
|
+
if (!isEmpty(properties)) out.properties = properties;
|
|
27
|
+
out.additionalProperties = false;
|
|
28
|
+
if (required.length > 0) out.required = required;
|
|
29
|
+
} else if (schema.type === "record" && schema._type) {
|
|
30
|
+
out.type = "object";
|
|
31
|
+
out.additionalProperties = transformSchema(schema._type);
|
|
32
|
+
} else if (schema.type === "array" && schema._type) {
|
|
33
|
+
out.type = "array";
|
|
34
|
+
out.items = transformSchema(schema._type);
|
|
35
|
+
} else if (schema.type === "tuple" && Array.isArray(schema._type)) {
|
|
36
|
+
out.type = "array";
|
|
37
|
+
out.items = schema._type.map((s) => transformSchema(s));
|
|
38
|
+
out.minItems = schema._type.length;
|
|
39
|
+
out.maxItems = schema._type.length;
|
|
40
|
+
} else if (schema.type === "none") out.type = "null";
|
|
41
|
+
else if (schema.type === "any") {} else {
|
|
42
|
+
const t = _primitiveMap[schema.type];
|
|
43
|
+
if (t) out.type = t;
|
|
39
44
|
}
|
|
45
|
+
if (schema._default !== void 0 && schema.type !== "literal") out.default = schema._default;
|
|
46
|
+
if (schema._meta?.desc) out.description = schema._meta.desc;
|
|
47
|
+
return out;
|
|
48
|
+
}
|
|
49
|
+
function schemaExportJsonSchema(schema) {
|
|
40
50
|
return {
|
|
41
51
|
$schema: "http://json-schema.org/draft-07/schema#",
|
|
42
|
-
additionalProperties: false,
|
|
43
52
|
...transformSchema(schema)
|
|
44
53
|
};
|
|
45
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export-json-schema.mjs","names":[],"sources":["../../../src/common/schema/export-json-schema.ts"],"sourcesContent":["import type { Type } from './schema'\nimport { isEmpty } from '../data'\
|
|
1
|
+
{"version":3,"file":"export-json-schema.mjs","names":[],"sources":["../../../src/common/schema/export-json-schema.ts"],"sourcesContent":["import type { Type } from './schema'\nimport { isEmpty } from '../data'\n\nconst _primitiveMap: Record<string, string> = {\n string: 'string',\n number: 'number',\n int: 'integer',\n boolean: 'boolean',\n}\n\nfunction transformSchema(schema: Type<any>): Record<string, any> {\n const out: Record<string, any> = {}\n\n if (schema._enumValues) {\n out.type = _primitiveMap[schema.type] ?? schema.type\n out.enum = [...schema._enumValues]\n }\n else if (schema.type === 'literal') {\n out.const = schema._default\n }\n else if (schema.type === 'union' && Array.isArray(schema._union)) {\n out.anyOf = schema._union.map((s: Type<any>) => transformSchema(s))\n }\n else if (schema.type === 'object' && schema._object) {\n out.type = 'object'\n const properties: Record<string, any> = {}\n const required: string[] = []\n for (const key of Object.keys(schema._object)) {\n const propSchema = schema._object[key] as Type<any>\n properties[key] = transformSchema(propSchema)\n if (propSchema._optional !== true)\n required.push(key)\n }\n if (!isEmpty(properties))\n out.properties = properties\n out.additionalProperties = false\n if (required.length > 0)\n out.required = required\n }\n else if (schema.type === 'record' && schema._type) {\n out.type = 'object'\n out.additionalProperties = transformSchema(schema._type)\n }\n else if (schema.type === 'array' && schema._type) {\n out.type = 'array'\n out.items = transformSchema(schema._type)\n }\n else if (schema.type === 'tuple' && Array.isArray(schema._type)) {\n out.type = 'array'\n out.items = (schema._type as Type<any>[]).map(s => transformSchema(s))\n out.minItems = schema._type.length\n out.maxItems = schema._type.length\n }\n else if (schema.type === 'none') {\n out.type = 'null'\n }\n else if (schema.type === 'any') {\n // no constraint\n }\n else {\n const t = _primitiveMap[schema.type]\n if (t)\n out.type = t\n }\n\n if (schema._default !== undefined && schema.type !== 'literal')\n out.default = schema._default\n if (schema._meta?.desc)\n out.description = schema._meta.desc\n\n return out\n}\n\nexport function schemaExportJsonSchema<T>(schema: Type<T>): Record<string, any> {\n return {\n $schema: 'http://json-schema.org/draft-07/schema#',\n ...transformSchema(schema),\n }\n}\n\nexport function schemaExportJsonSchemaString<T>(schema: Type<T>): string {\n const jsonSchema = schemaExportJsonSchema(schema)\n return JSON.stringify(jsonSchema, null, 2)\n}\n"],"mappings":";;;AAGA,MAAM,gBAAwC;CAC5C,QAAQ;CACR,QAAQ;CACR,KAAK;CACL,SAAS;CACV;AAED,SAAS,gBAAgB,QAAwC;CAC/D,MAAM,MAA2B,EAAE;AAEnC,KAAI,OAAO,aAAa;AACtB,MAAI,OAAO,cAAc,OAAO,SAAS,OAAO;AAChD,MAAI,OAAO,CAAC,GAAG,OAAO,YAAY;Y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AAC9E,QAAO;EACL,SAAS;EACT,GAAG,gBAAgB,OAAO;EAC3B;;AAGH,SAAgB,6BAAgC,QAAyB;CACvE,MAAM,aAAa,uBAAuB,OAAO;AACjD,QAAO,KAAK,UAAU,YAAY,MAAM,EAAE"}
|
|
@@ -8,27 +8,44 @@ const require_common_schema_parse_args = require('./parse-args.cjs');
|
|
|
8
8
|
const require_common_schema_parse_env = require('./parse-env.cjs');
|
|
9
9
|
const require_common_schema_schema = require('./schema.cjs');
|
|
10
10
|
const require_common_schema_serialize = require('./serialize.cjs');
|
|
11
|
+
const require_common_schema_sql_table = require('./sql/table.cjs');
|
|
12
|
+
const require_common_schema_sql_expr = require('./sql/expr.cjs');
|
|
13
|
+
const require_common_schema_sql_select = require('./sql/select.cjs');
|
|
11
14
|
const require_common_schema_z_collection = require('./z-collection.cjs');
|
|
12
15
|
|
|
16
|
+
exports.SelectBuilder = require_common_schema_sql_select.SelectBuilder;
|
|
13
17
|
exports.Type = require_common_schema_schema.Type;
|
|
18
|
+
exports.and = require_common_schema_sql_expr.and;
|
|
14
19
|
exports.any = require_common_schema_schema.any;
|
|
15
20
|
exports.array = require_common_schema_schema.array;
|
|
16
21
|
exports.boolean = require_common_schema_schema.boolean;
|
|
17
22
|
exports.deserializeSchema = require_common_schema_serialize.deserializeSchema;
|
|
18
23
|
exports.double = require_common_schema_schema.double;
|
|
24
|
+
exports.eq = require_common_schema_sql_expr.eq;
|
|
19
25
|
exports.float = require_common_schema_schema.float;
|
|
26
|
+
exports.from = require_common_schema_sql_select.from;
|
|
20
27
|
exports.func = require_common_schema_schema.func;
|
|
28
|
+
exports.gt = require_common_schema_sql_expr.gt;
|
|
29
|
+
exports.gte = require_common_schema_sql_expr.gte;
|
|
21
30
|
exports.helpSchemaArgs = require_common_schema_parse_args.helpSchemaArgs;
|
|
31
|
+
exports.inArray = require_common_schema_sql_expr.inArray;
|
|
22
32
|
exports.int = require_common_schema_schema.int;
|
|
33
|
+
exports.isColumn = require_common_schema_sql_table.isColumn;
|
|
23
34
|
exports.isSchemaDefault = require_common_schema_utils.isSchemaDefault;
|
|
24
35
|
exports.isSchemaObject = require_common_schema_utils.isSchemaObject;
|
|
25
36
|
exports.isSchemaObjectFlat = require_common_schema_utils.isSchemaObjectFlat;
|
|
26
37
|
exports.isSchemaOptional = require_common_schema_utils.isSchemaOptional;
|
|
27
38
|
exports.isSchemaPrimitive = require_common_schema_utils.isSchemaPrimitive;
|
|
39
|
+
exports.like = require_common_schema_sql_expr.like;
|
|
28
40
|
exports.literal = require_common_schema_schema.literal;
|
|
41
|
+
exports.lt = require_common_schema_sql_expr.lt;
|
|
42
|
+
exports.lte = require_common_schema_sql_expr.lte;
|
|
43
|
+
exports.ne = require_common_schema_sql_expr.ne;
|
|
29
44
|
exports.none = require_common_schema_schema.none;
|
|
45
|
+
exports.not = require_common_schema_sql_expr.not;
|
|
30
46
|
exports.number = require_common_schema_schema.number;
|
|
31
47
|
exports.object = require_common_schema_schema.object;
|
|
48
|
+
exports.or = require_common_schema_sql_expr.or;
|
|
32
49
|
exports.parseSchemaArgs = require_common_schema_parse_args.parseSchemaArgs;
|
|
33
50
|
exports.parseSchemaEnv = require_common_schema_parse_env.parseSchemaEnv;
|
|
34
51
|
exports.real = require_common_schema_schema.real;
|
|
@@ -41,10 +58,14 @@ exports.schemaExportSwiftStruct = require_common_schema_export_swift.schemaExpor
|
|
|
41
58
|
exports.schemaExportTypescriptInterface = require_common_schema_export_typescript.schemaExportTypescriptInterface;
|
|
42
59
|
exports.schemaParseObject = require_common_schema_parse_object.schemaParseObject;
|
|
43
60
|
exports.schemaValidateObject = require_common_schema_parse_object.schemaValidateObject;
|
|
61
|
+
exports.select = require_common_schema_sql_select.select;
|
|
44
62
|
exports.serializeSchema = require_common_schema_serialize.serializeSchema;
|
|
63
|
+
exports.sqlIsNotNull = require_common_schema_sql_expr.sqlIsNotNull;
|
|
64
|
+
exports.sqlIsNull = require_common_schema_sql_expr.sqlIsNull;
|
|
45
65
|
exports.string = require_common_schema_schema.string;
|
|
46
66
|
exports.stringFromSchemaEnv = require_common_schema_parse_env.stringFromSchemaEnv;
|
|
47
67
|
exports.stringLiterals = require_common_schema_schema.stringLiterals;
|
|
68
|
+
exports.table = require_common_schema_sql_table.table;
|
|
48
69
|
exports.tuple = require_common_schema_schema.tuple;
|
|
49
70
|
exports.union = require_common_schema_schema.union;
|
|
50
71
|
Object.defineProperty(exports, 'z', {
|
|
@@ -8,6 +8,9 @@ import { i as stringFromSchemaEnv, n as SchemaEnvType, r as parseSchemaEnv, t as
|
|
|
8
8
|
import { i as schemaValidateObject, n as schemaCreateObject, r as schemaParseObject, t as SchemaValidateMessage } from "../../parse-object-D_fCDXxd.cjs";
|
|
9
9
|
import { t as StandardSchemaV1 } from "../../schema-standard-BxRHxZeM.cjs";
|
|
10
10
|
import { n as deserializeSchema, r as serializeSchema, t as SerializedType } from "../../serialize-9GhlcFMv.cjs";
|
|
11
|
-
import { n as
|
|
12
|
-
import { a as
|
|
13
|
-
|
|
11
|
+
import { a as table, i as isColumn, n as TableColumns, r as TableShape, t as Column } from "../../table-IkLXirT-.cjs";
|
|
12
|
+
import { a as gte, c as lt, d as not, f as or, i as gt, l as lte, m as sqlIsNull, n as and, o as inArray, p as sqlIsNotNull, r as eq, s as like, t as Expr, u as ne } from "../../expr-yYgSeBZ3.cjs";
|
|
13
|
+
import { a as RowFromTable, c as select, i as RowFromSelection, n as InferRow, o as SelectBuilder, r as QueryDependencies, s as from, t as CompiledQuery } from "../../select-DrciHdk_.cjs";
|
|
14
|
+
import { n as IsEqual, t as Expect } from "../../type-test-CBK-iJ9d.cjs";
|
|
15
|
+
import { a as isSchemaPrimitive, i as isSchemaOptional, n as isSchemaObject, r as isSchemaObjectFlat, t as isSchemaDefault } from "../../utils-nCQklGHV.cjs";
|
|
16
|
+
export { Column, CompiledQuery, Expect, Expr, Infer, InferRow, IsEqual, QueryDependencies, RowFromSelection, RowFromTable, SchemaEnvOptions, SchemaEnvType, SchemaValidateMessage, SelectBuilder, SerializedType, StandardSchemaV1, TableColumns, TableShape, Type, TypeArray, TypeArrayOutput, TypeLiterals, TypeMeta, TypeObjectFixOptional, TypeTuple, TypeUnion, and, any, array, boolean, deserializeSchema, double, eq, float, from, func, gt, gte, helpSchemaArgs, inArray, int, isColumn, isSchemaDefault, isSchemaObject, isSchemaObjectFlat, isSchemaOptional, isSchemaPrimitive, like, literal, lt, lte, ne, none, not, number, object, or, parseSchemaArgs, parseSchemaEnv, real, record, rpc, schemaCreateObject, schemaExportJsonSchema, schemaExportJsonSchemaString, schemaExportSwiftStruct, schemaExportTypescriptInterface, schemaParseObject, schemaValidateObject, select, serializeSchema, sqlIsNotNull, sqlIsNull, string, stringFromSchemaEnv, stringLiterals, table, tuple, union, z_collection_d_exports as z };
|
|
@@ -7,7 +7,10 @@ import { i as stringFromSchemaEnv, n as SchemaEnvType, r as parseSchemaEnv, t as
|
|
|
7
7
|
import { i as schemaValidateObject, n as schemaCreateObject, r as schemaParseObject, t as SchemaValidateMessage } from "../../parse-object-BRWSD2uh.mjs";
|
|
8
8
|
import { t as StandardSchemaV1 } from "../../schema-standard-Q-bdIO6s.mjs";
|
|
9
9
|
import { n as deserializeSchema, r as serializeSchema, t as SerializedType } from "../../serialize-rRk9F-zH.mjs";
|
|
10
|
-
import { n as
|
|
11
|
-
import { a as
|
|
12
|
-
import { t as
|
|
13
|
-
|
|
10
|
+
import { a as table, i as isColumn, n as TableColumns, r as TableShape, t as Column } from "../../table-Cr8tjDIL.mjs";
|
|
11
|
+
import { a as gte, c as lt, d as not, f as or, i as gt, l as lte, m as sqlIsNull, n as and, o as inArray, p as sqlIsNotNull, r as eq, s as like, t as Expr, u as ne } from "../../expr-CCKrqOw1.mjs";
|
|
12
|
+
import { a as RowFromTable, c as select, i as RowFromSelection, n as InferRow, o as SelectBuilder, r as QueryDependencies, s as from, t as CompiledQuery } from "../../select-F2KpP6mo.mjs";
|
|
13
|
+
import { n as IsEqual, t as Expect } from "../../type-test-BvzWDJz3.mjs";
|
|
14
|
+
import { a as isSchemaPrimitive, i as isSchemaOptional, n as isSchemaObject, r as isSchemaObjectFlat, t as isSchemaDefault } from "../../utils-1RyCGkpQ.mjs";
|
|
15
|
+
import { t as z_collection_d_exports } from "../../z-collection-BSfgRU0Q.mjs";
|
|
16
|
+
export { Column, CompiledQuery, Expect, Expr, Infer, InferRow, IsEqual, QueryDependencies, RowFromSelection, RowFromTable, SchemaEnvOptions, SchemaEnvType, SchemaValidateMessage, SelectBuilder, SerializedType, StandardSchemaV1, TableColumns, TableShape, Type, TypeArray, TypeArrayOutput, TypeLiterals, TypeMeta, TypeObjectFixOptional, TypeTuple, TypeUnion, and, any, array, boolean, deserializeSchema, double, eq, float, from, func, gt, gte, helpSchemaArgs, inArray, int, isColumn, isSchemaDefault, isSchemaObject, isSchemaObjectFlat, isSchemaOptional, isSchemaPrimitive, like, literal, lt, lte, ne, none, not, number, object, or, parseSchemaArgs, parseSchemaEnv, real, record, rpc, schemaCreateObject, schemaExportJsonSchema, schemaExportJsonSchemaString, schemaExportSwiftStruct, schemaExportTypescriptInterface, schemaParseObject, schemaValidateObject, select, serializeSchema, sqlIsNotNull, sqlIsNull, string, stringFromSchemaEnv, stringLiterals, table, tuple, union, z_collection_d_exports as z };
|
|
@@ -7,6 +7,9 @@ import { helpSchemaArgs, parseSchemaArgs } from "./parse-args.mjs";
|
|
|
7
7
|
import { parseSchemaEnv, stringFromSchemaEnv } from "./parse-env.mjs";
|
|
8
8
|
import { Type, any, array, boolean, double, float, func, int, literal, none, number, object, real, record, rpc, string, stringLiterals, tuple, union } from "./schema.mjs";
|
|
9
9
|
import { deserializeSchema, serializeSchema } from "./serialize.mjs";
|
|
10
|
+
import { isColumn, table } from "./sql/table.mjs";
|
|
11
|
+
import { and, eq, gt, gte, inArray, like, lt, lte, ne, not, or, sqlIsNotNull, sqlIsNull } from "./sql/expr.mjs";
|
|
12
|
+
import { SelectBuilder, from, select } from "./sql/select.mjs";
|
|
10
13
|
import { t as z_collection_exports } from "./z-collection.mjs";
|
|
11
14
|
|
|
12
|
-
export { Type, any, array, boolean, deserializeSchema, double, float, func, helpSchemaArgs, int, isSchemaDefault, isSchemaObject, isSchemaObjectFlat, isSchemaOptional, isSchemaPrimitive, literal, none, number, object, parseSchemaArgs, parseSchemaEnv, real, record, rpc, schemaCreateObject, schemaExportJsonSchema, schemaExportJsonSchemaString, schemaExportSwiftStruct, schemaExportTypescriptInterface, schemaParseObject, schemaValidateObject, serializeSchema, string, stringFromSchemaEnv, stringLiterals, tuple, union, z_collection_exports as z };
|
|
15
|
+
export { SelectBuilder, Type, and, any, array, boolean, deserializeSchema, double, eq, float, from, func, gt, gte, helpSchemaArgs, inArray, int, isColumn, isSchemaDefault, isSchemaObject, isSchemaObjectFlat, isSchemaOptional, isSchemaPrimitive, like, literal, lt, lte, ne, none, not, number, object, or, parseSchemaArgs, parseSchemaEnv, real, record, rpc, schemaCreateObject, schemaExportJsonSchema, schemaExportJsonSchemaString, schemaExportSwiftStruct, schemaExportTypescriptInterface, schemaParseObject, schemaValidateObject, select, serializeSchema, sqlIsNotNull, sqlIsNull, string, stringFromSchemaEnv, stringLiterals, table, tuple, union, z_collection_exports as z };
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_common_schema_sql_table = require('./table.cjs');
|
|
3
|
+
|
|
4
|
+
//#region src/common/schema/sql/expr.ts
|
|
5
|
+
function operand(v) {
|
|
6
|
+
if (require_common_schema_sql_table.isColumn(v)) return {
|
|
7
|
+
kind: "expr",
|
|
8
|
+
sql: `"${v._table}"."${v._name}"`,
|
|
9
|
+
params: [],
|
|
10
|
+
refs: [v]
|
|
11
|
+
};
|
|
12
|
+
if (v && v.kind === "expr") return v;
|
|
13
|
+
return {
|
|
14
|
+
kind: "expr",
|
|
15
|
+
sql: "?",
|
|
16
|
+
params: [v],
|
|
17
|
+
refs: []
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function binop(op) {
|
|
21
|
+
return (a, b) => {
|
|
22
|
+
const x = operand(a);
|
|
23
|
+
const y = operand(b);
|
|
24
|
+
return {
|
|
25
|
+
kind: "expr",
|
|
26
|
+
sql: `${x.sql} ${op} ${y.sql}`,
|
|
27
|
+
params: [...x.params, ...y.params],
|
|
28
|
+
refs: [...x.refs, ...y.refs]
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const eq = binop("=");
|
|
33
|
+
const ne = binop("<>");
|
|
34
|
+
const gt = binop(">");
|
|
35
|
+
const gte = binop(">=");
|
|
36
|
+
const lt = binop("<");
|
|
37
|
+
const lte = binop("<=");
|
|
38
|
+
const like = binop("LIKE");
|
|
39
|
+
function and(...parts) {
|
|
40
|
+
const list = parts.filter((p) => !!p);
|
|
41
|
+
if (list.length === 0) return {
|
|
42
|
+
kind: "expr",
|
|
43
|
+
sql: "1=1",
|
|
44
|
+
params: [],
|
|
45
|
+
refs: []
|
|
46
|
+
};
|
|
47
|
+
if (list.length === 1) return list[0];
|
|
48
|
+
return {
|
|
49
|
+
kind: "expr",
|
|
50
|
+
sql: list.map((p) => `(${p.sql})`).join(" AND "),
|
|
51
|
+
params: list.flatMap((p) => p.params),
|
|
52
|
+
refs: list.flatMap((p) => p.refs)
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function or(...parts) {
|
|
56
|
+
const list = parts.filter((p) => !!p);
|
|
57
|
+
if (list.length === 0) return {
|
|
58
|
+
kind: "expr",
|
|
59
|
+
sql: "1=0",
|
|
60
|
+
params: [],
|
|
61
|
+
refs: []
|
|
62
|
+
};
|
|
63
|
+
if (list.length === 1) return list[0];
|
|
64
|
+
return {
|
|
65
|
+
kind: "expr",
|
|
66
|
+
sql: list.map((p) => `(${p.sql})`).join(" OR "),
|
|
67
|
+
params: list.flatMap((p) => p.params),
|
|
68
|
+
refs: list.flatMap((p) => p.refs)
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function not(e) {
|
|
72
|
+
return {
|
|
73
|
+
kind: "expr",
|
|
74
|
+
sql: `NOT (${e.sql})`,
|
|
75
|
+
params: e.params,
|
|
76
|
+
refs: e.refs
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function sqlIsNull(col) {
|
|
80
|
+
const x = operand(col);
|
|
81
|
+
return {
|
|
82
|
+
kind: "expr",
|
|
83
|
+
sql: `${x.sql} IS NULL`,
|
|
84
|
+
params: x.params,
|
|
85
|
+
refs: x.refs
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function sqlIsNotNull(col) {
|
|
89
|
+
const x = operand(col);
|
|
90
|
+
return {
|
|
91
|
+
kind: "expr",
|
|
92
|
+
sql: `${x.sql} IS NOT NULL`,
|
|
93
|
+
params: x.params,
|
|
94
|
+
refs: x.refs
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function inArray(col, values) {
|
|
98
|
+
const x = operand(col);
|
|
99
|
+
if (values.length === 0) return {
|
|
100
|
+
kind: "expr",
|
|
101
|
+
sql: "1=0",
|
|
102
|
+
params: [],
|
|
103
|
+
refs: x.refs
|
|
104
|
+
};
|
|
105
|
+
const placeholders = values.map(() => "?").join(", ");
|
|
106
|
+
return {
|
|
107
|
+
kind: "expr",
|
|
108
|
+
sql: `${x.sql} IN (${placeholders})`,
|
|
109
|
+
params: [...x.params, ...values],
|
|
110
|
+
refs: x.refs
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
//#endregion
|
|
115
|
+
exports.and = and;
|
|
116
|
+
exports.eq = eq;
|
|
117
|
+
exports.gt = gt;
|
|
118
|
+
exports.gte = gte;
|
|
119
|
+
exports.inArray = inArray;
|
|
120
|
+
exports.like = like;
|
|
121
|
+
exports.lt = lt;
|
|
122
|
+
exports.lte = lte;
|
|
123
|
+
exports.ne = ne;
|
|
124
|
+
exports.not = not;
|
|
125
|
+
exports.or = or;
|
|
126
|
+
exports.sqlIsNotNull = sqlIsNotNull;
|
|
127
|
+
exports.sqlIsNull = sqlIsNull;
|
|
128
|
+
//# sourceMappingURL=expr.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expr.cjs","names":["isColumn"],"sources":["../../../../src/common/schema/sql/expr.ts"],"sourcesContent":["import type { Column } from './table'\nimport { isColumn } from './table'\n\nexport interface Expr {\n readonly kind: 'expr'\n readonly sql: string\n readonly params: unknown[]\n readonly refs: Column[]\n}\n\nfunction operand(v: any): Expr {\n if (isColumn(v)) {\n return {\n kind: 'expr',\n sql: `\"${v._table}\".\"${v._name}\"`,\n params: [],\n refs: [v],\n }\n }\n if (v && v.kind === 'expr')\n return v as Expr\n return { kind: 'expr', sql: '?', params: [v], refs: [] }\n}\n\nfunction binop(op: string) {\n return (a: Column | Expr | unknown, b: Column | Expr | unknown): Expr => {\n const x = operand(a)\n const y = operand(b)\n return {\n kind: 'expr',\n sql: `${x.sql} ${op} ${y.sql}`,\n params: [...x.params, ...y.params],\n refs: [...x.refs, ...y.refs],\n }\n }\n}\n\nexport const eq = binop('=')\nexport const ne = binop('<>')\nexport const gt = binop('>')\nexport const gte = binop('>=')\nexport const lt = binop('<')\nexport const lte = binop('<=')\nexport const like = binop('LIKE')\n\nexport function and(...parts: (Expr | undefined | false | null)[]): Expr {\n const list = parts.filter((p): p is Expr => !!p)\n if (list.length === 0)\n return { kind: 'expr', sql: '1=1', params: [], refs: [] }\n if (list.length === 1)\n return list[0]\n return {\n kind: 'expr',\n sql: list.map(p => `(${p.sql})`).join(' AND '),\n params: list.flatMap(p => p.params),\n refs: list.flatMap(p => p.refs),\n }\n}\n\nexport function or(...parts: (Expr | undefined | false | null)[]): Expr {\n const list = parts.filter((p): p is Expr => !!p)\n if (list.length === 0)\n return { kind: 'expr', sql: '1=0', params: [], refs: [] }\n if (list.length === 1)\n return list[0]\n return {\n kind: 'expr',\n sql: list.map(p => `(${p.sql})`).join(' OR '),\n params: list.flatMap(p => p.params),\n refs: list.flatMap(p => p.refs),\n }\n}\n\nexport function not(e: Expr): Expr {\n return { kind: 'expr', sql: `NOT (${e.sql})`, params: e.params, refs: e.refs }\n}\n\nexport function sqlIsNull(col: Column | Expr): Expr {\n const x = operand(col)\n return { kind: 'expr', sql: `${x.sql} IS NULL`, params: x.params, refs: x.refs }\n}\n\nexport function sqlIsNotNull(col: Column | Expr): Expr {\n const x = operand(col)\n return { kind: 'expr', sql: `${x.sql} IS NOT NULL`, params: x.params, refs: x.refs }\n}\n\nexport function inArray(col: Column | Expr, values: unknown[]): Expr {\n const x = operand(col)\n if (values.length === 0)\n return { kind: 'expr', sql: '1=0', params: [], refs: x.refs }\n const placeholders = values.map(() => '?').join(', ')\n return {\n kind: 'expr',\n sql: `${x.sql} IN (${placeholders})`,\n params: [...x.params, ...values],\n refs: x.refs,\n }\n}\n"],"mappings":";;;;AAUA,SAAS,QAAQ,GAAc;AAC7B,KAAIA,yCAAS,EAAE,CACb,QAAO;EACL,MAAM;EACN,KAAK,IAAI,EAAE,OAAO,KAAK,EAAE,MAAM;EAC/B,QAAQ,EAAE;EACV,MAAM,CAAC,EAAE;EACV;AAEH,KAAI,KAAK,EAAE,SAAS,OAClB,QAAO;AACT,QAAO;EAAE,MAAM;EAAQ,KAAK;EAAK,QAAQ,CAAC,EAAE;EAAE,MAAM,EAAE;EAAE;;AAG1D,SAAS,MAAM,IAAY;AACzB,SAAQ,GAA4B,MAAqC;EACvE,MAAM,IAAI,QAAQ,EAAE;EACpB,MAAM,IAAI,QAAQ,EAAE;AACpB,SAAO;GACL,MAAM;GACN,KAAK,GAAG,EAAE,IAAI,GAAG,GAAG,GAAG,EAAE;GACzB,QAAQ,CAAC,GAAG,EAAE,QAAQ,GAAG,EAAE,OAAO;GAClC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,EAAE,KAAK;GAC7B;;;AAIL,MAAa,KAAK,MAAM,IAAI;AAC5B,MAAa,KAAK,MAAM,KAAK;AAC7B,MAAa,KAAK,MAAM,IAAI;A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,EAAE;EAAQ,MAAM,EAAE;EAAM;;AAGlF,SAAgB,aAAa,KAA0B;CACrD,MAAM,IAAI,QAAQ,IAAI;AACtB,QAAO;EAAE,MAAM;EAAQ,KAAK,GAAG,EAAE,IAAI;EAAe,QAAQ,EAAE;EAAQ,MAAM,EAAE;EAAM;;AAGtF,SAAgB,QAAQ,KAAoB,QAAyB;CACnE,MAAM,IAAI,QAAQ,IAAI;AACtB,KAAI,OAAO,WAAW,EACpB,QAAO;EAAE,MAAM;EAAQ,KAAK;EAAO,QAAQ,EAAE;EAAE,MAAM,EAAE;EAAM;CAC/D,MAAM,eAAe,OAAO,UAAU,IAAI,CAAC,KAAK,KAAK;AACrD,QAAO;EACL,MAAM;EACN,KAAK,GAAG,EAAE,IAAI,OAAO,aAAa;EAClC,QAAQ,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO;EAChC,MAAM,EAAE;EACT"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as gte, c as lt, d as not, f as or, i as gt, l as lte, m as sqlIsNull, n as and, o as inArray, p as sqlIsNotNull, r as eq, s as like, t as Expr, u as ne } from "../../../expr-yYgSeBZ3.cjs";
|
|
2
|
+
export { Expr, and, eq, gt, gte, inArray, like, lt, lte, ne, not, or, sqlIsNotNull, sqlIsNull };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as gte, c as lt, d as not, f as or, i as gt, l as lte, m as sqlIsNull, n as and, o as inArray, p as sqlIsNotNull, r as eq, s as like, t as Expr, u as ne } from "../../../expr-CCKrqOw1.mjs";
|
|
2
|
+
export { Expr, and, eq, gt, gte, inArray, like, lt, lte, ne, not, or, sqlIsNotNull, sqlIsNull };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { isColumn } from "./table.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/common/schema/sql/expr.ts
|
|
4
|
+
function operand(v) {
|
|
5
|
+
if (isColumn(v)) return {
|
|
6
|
+
kind: "expr",
|
|
7
|
+
sql: `"${v._table}"."${v._name}"`,
|
|
8
|
+
params: [],
|
|
9
|
+
refs: [v]
|
|
10
|
+
};
|
|
11
|
+
if (v && v.kind === "expr") return v;
|
|
12
|
+
return {
|
|
13
|
+
kind: "expr",
|
|
14
|
+
sql: "?",
|
|
15
|
+
params: [v],
|
|
16
|
+
refs: []
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function binop(op) {
|
|
20
|
+
return (a, b) => {
|
|
21
|
+
const x = operand(a);
|
|
22
|
+
const y = operand(b);
|
|
23
|
+
return {
|
|
24
|
+
kind: "expr",
|
|
25
|
+
sql: `${x.sql} ${op} ${y.sql}`,
|
|
26
|
+
params: [...x.params, ...y.params],
|
|
27
|
+
refs: [...x.refs, ...y.refs]
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const eq = binop("=");
|
|
32
|
+
const ne = binop("<>");
|
|
33
|
+
const gt = binop(">");
|
|
34
|
+
const gte = binop(">=");
|
|
35
|
+
const lt = binop("<");
|
|
36
|
+
const lte = binop("<=");
|
|
37
|
+
const like = binop("LIKE");
|
|
38
|
+
function and(...parts) {
|
|
39
|
+
const list = parts.filter((p) => !!p);
|
|
40
|
+
if (list.length === 0) return {
|
|
41
|
+
kind: "expr",
|
|
42
|
+
sql: "1=1",
|
|
43
|
+
params: [],
|
|
44
|
+
refs: []
|
|
45
|
+
};
|
|
46
|
+
if (list.length === 1) return list[0];
|
|
47
|
+
return {
|
|
48
|
+
kind: "expr",
|
|
49
|
+
sql: list.map((p) => `(${p.sql})`).join(" AND "),
|
|
50
|
+
params: list.flatMap((p) => p.params),
|
|
51
|
+
refs: list.flatMap((p) => p.refs)
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function or(...parts) {
|
|
55
|
+
const list = parts.filter((p) => !!p);
|
|
56
|
+
if (list.length === 0) return {
|
|
57
|
+
kind: "expr",
|
|
58
|
+
sql: "1=0",
|
|
59
|
+
params: [],
|
|
60
|
+
refs: []
|
|
61
|
+
};
|
|
62
|
+
if (list.length === 1) return list[0];
|
|
63
|
+
return {
|
|
64
|
+
kind: "expr",
|
|
65
|
+
sql: list.map((p) => `(${p.sql})`).join(" OR "),
|
|
66
|
+
params: list.flatMap((p) => p.params),
|
|
67
|
+
refs: list.flatMap((p) => p.refs)
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function not(e) {
|
|
71
|
+
return {
|
|
72
|
+
kind: "expr",
|
|
73
|
+
sql: `NOT (${e.sql})`,
|
|
74
|
+
params: e.params,
|
|
75
|
+
refs: e.refs
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function sqlIsNull(col) {
|
|
79
|
+
const x = operand(col);
|
|
80
|
+
return {
|
|
81
|
+
kind: "expr",
|
|
82
|
+
sql: `${x.sql} IS NULL`,
|
|
83
|
+
params: x.params,
|
|
84
|
+
refs: x.refs
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function sqlIsNotNull(col) {
|
|
88
|
+
const x = operand(col);
|
|
89
|
+
return {
|
|
90
|
+
kind: "expr",
|
|
91
|
+
sql: `${x.sql} IS NOT NULL`,
|
|
92
|
+
params: x.params,
|
|
93
|
+
refs: x.refs
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function inArray(col, values) {
|
|
97
|
+
const x = operand(col);
|
|
98
|
+
if (values.length === 0) return {
|
|
99
|
+
kind: "expr",
|
|
100
|
+
sql: "1=0",
|
|
101
|
+
params: [],
|
|
102
|
+
refs: x.refs
|
|
103
|
+
};
|
|
104
|
+
const placeholders = values.map(() => "?").join(", ");
|
|
105
|
+
return {
|
|
106
|
+
kind: "expr",
|
|
107
|
+
sql: `${x.sql} IN (${placeholders})`,
|
|
108
|
+
params: [...x.params, ...values],
|
|
109
|
+
refs: x.refs
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
//#endregion
|
|
114
|
+
export { and, eq, gt, gte, inArray, like, lt, lte, ne, not, or, sqlIsNotNull, sqlIsNull };
|
|
115
|
+
//# sourceMappingURL=expr.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expr.mjs","names":[],"sources":["../../../../src/common/schema/sql/expr.ts"],"sourcesContent":["import type { Column } from './table'\nimport { isColumn } from './table'\n\nexport interface Expr {\n readonly kind: 'expr'\n readonly sql: string\n readonly params: unknown[]\n readonly refs: Column[]\n}\n\nfunction operand(v: any): Expr {\n if (isColumn(v)) {\n return {\n kind: 'expr',\n sql: `\"${v._table}\".\"${v._name}\"`,\n params: [],\n refs: [v],\n }\n }\n if (v && v.kind === 'expr')\n return v as Expr\n return { kind: 'expr', sql: '?', params: [v], refs: [] }\n}\n\nfunction binop(op: string) {\n return (a: Column | Expr | unknown, b: Column | Expr | unknown): Expr => {\n const x = operand(a)\n const y = operand(b)\n return {\n kind: 'expr',\n sql: `${x.sql} ${op} ${y.sql}`,\n params: [...x.params, ...y.params],\n refs: [...x.refs, ...y.refs],\n }\n }\n}\n\nexport const eq = binop('=')\nexport const ne = binop('<>')\nexport const gt = binop('>')\nexport const gte = binop('>=')\nexport const lt = binop('<')\nexport const lte = binop('<=')\nexport const like = binop('LIKE')\n\nexport function and(...parts: (Expr | undefined | false | null)[]): Expr {\n const list = parts.filter((p): p is Expr => !!p)\n if (list.length === 0)\n return { kind: 'expr', sql: '1=1', params: [], refs: [] }\n if (list.length === 1)\n return list[0]\n return {\n kind: 'expr',\n sql: list.map(p => `(${p.sql})`).join(' AND '),\n params: list.flatMap(p => p.params),\n refs: list.flatMap(p => p.refs),\n }\n}\n\nexport function or(...parts: (Expr | undefined | false | null)[]): Expr {\n const list = parts.filter((p): p is Expr => !!p)\n if (list.length === 0)\n return { kind: 'expr', sql: '1=0', params: [], refs: [] }\n if (list.length === 1)\n return list[0]\n return {\n kind: 'expr',\n sql: list.map(p => `(${p.sql})`).join(' OR '),\n params: list.flatMap(p => p.params),\n refs: list.flatMap(p => p.refs),\n }\n}\n\nexport function not(e: Expr): Expr {\n return { kind: 'expr', sql: `NOT (${e.sql})`, params: e.params, refs: e.refs }\n}\n\nexport function sqlIsNull(col: Column | Expr): Expr {\n const x = operand(col)\n return { kind: 'expr', sql: `${x.sql} IS NULL`, params: x.params, refs: x.refs }\n}\n\nexport function sqlIsNotNull(col: Column | Expr): Expr {\n const x = operand(col)\n return { kind: 'expr', sql: `${x.sql} IS NOT NULL`, params: x.params, refs: x.refs }\n}\n\nexport function inArray(col: Column | Expr, values: unknown[]): Expr {\n const x = operand(col)\n if (values.length === 0)\n return { kind: 'expr', sql: '1=0', params: [], refs: x.refs }\n const placeholders = values.map(() => '?').join(', ')\n return {\n kind: 'expr',\n sql: `${x.sql} IN (${placeholders})`,\n params: [...x.params, ...values],\n refs: x.refs,\n }\n}\n"],"mappings":";;;AAUA,SAAS,QAAQ,GAAc;AAC7B,KAAI,SAAS,EAAE,CACb,QAAO;EACL,MAAM;EACN,KAAK,IAAI,EAAE,OAAO,KAAK,EAAE,MAAM;EAC/B,QAAQ,EAAE;EACV,MAAM,CAAC,EAAE;EACV;AAEH,KAAI,KAAK,EAAE,SAAS,OAClB,QAAO;AACT,QAAO;EAAE,MAAM;EAAQ,KAAK;EAAK,QAAQ,CAAC,EAAE;EAAE,MAAM,EAAE;EAAE;;AAG1D,SAAS,MAAM,IAAY;AACzB,SAAQ,GAA4B,MAAqC;EACvE,MAAM,IAAI,QAAQ,EAAE;EACpB,MAAM,IAAI,QAAQ,EAAE;AACpB,SAAO;GACL,MAAM;GACN,KAAK,GAAG,EAAE,IAAI,GAAG,GAAG,GAAG,EAAE;GACzB,QAAQ,CAAC,GAAG,EAAE,QAAQ,GAAG,EAAE,OAAO;GAClC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,EAAE,KAAK;GAC7B;;;AAIL,MAAa,KAAK,MAAM,IAAI;AAC5B,MAAa,KAAK,MAAM,KAAK;AAC7B,MAAa,KAAK,MAAM,IAAI;AAC5B,MAAa,MAAM,MAAM,KAAK;AAC9B,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