@supalive/core 1.13.1 → 1.15.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 +1 -2
- package/dist/helper-CUSGbt2A.d.ts +15 -0
- package/dist/helper-CUSGbt2A.d.ts.map +1 -0
- package/dist/helper-CVcjwD3k.js +73 -0
- package/dist/helper-CVcjwD3k.js.map +1 -0
- package/dist/index-Ddr4NiPf.d.ts +2295 -0
- package/dist/index-Ddr4NiPf.d.ts.map +1 -0
- package/dist/index-f7mNbMhq.d.ts +2301 -0
- package/dist/index-f7mNbMhq.d.ts.map +1 -0
- package/dist/mysql-BX5hfgfE.d.ts +114 -0
- package/dist/mysql-BX5hfgfE.d.ts.map +1 -0
- package/dist/mysql-DWj2q3qR.d.ts +114 -0
- package/dist/mysql-DWj2q3qR.d.ts.map +1 -0
- package/dist/mysql-v_0U0NU4.js +623 -0
- package/dist/mysql-v_0U0NU4.js.map +1 -0
- package/dist/overlap-checker-DVbh0YC4.js +259 -0
- package/dist/overlap-checker-DVbh0YC4.js.map +1 -0
- package/dist/postgres-D0M1ri-C.d.ts +118 -0
- package/dist/postgres-D0M1ri-C.d.ts.map +1 -0
- package/dist/postgres-EUz8TYFn.d.ts +118 -0
- package/dist/postgres-EUz8TYFn.d.ts.map +1 -0
- package/dist/postgres-vYRyZJZd.js +868 -0
- package/dist/postgres-vYRyZJZd.js.map +1 -0
- package/dist/query-Bk2W-ynQ.js +730 -0
- package/dist/query-Bk2W-ynQ.js.map +1 -0
- package/dist/realtime_db-DnZKn_FZ.js +312 -0
- package/dist/realtime_db-DnZKn_FZ.js.map +1 -0
- package/dist/router-DP2ThAwh.js +274 -0
- package/dist/router-DP2ThAwh.js.map +1 -0
- package/dist/router-Dfnwka7K.js +337 -0
- package/dist/router-Dfnwka7K.js.map +1 -0
- package/dist/schema-DRtz5h5l.js +131 -0
- package/dist/schema-DRtz5h5l.js.map +1 -0
- package/dist/src/client/index.d.ts +1 -1
- package/dist/src/client/index.js +2 -2
- package/dist/src/exports/mysql.d.ts +1 -1
- package/dist/src/exports/postgres.d.ts +1 -1
- package/dist/src/exports/procedure.d.ts +12 -9
- package/dist/src/exports/procedure.d.ts.map +1 -1
- package/dist/src/exports/procedure.js +65 -6
- package/dist/src/exports/procedure.js.map +1 -1
- package/dist/src/exports/schema-sql.d.ts +2 -2
- package/dist/src/exports/schema-sql.js +3 -3
- package/dist/src/exports/schema-sql.js.map +1 -1
- package/dist/src/exports/server.d.ts +4 -4
- package/dist/src/exports/server.d.ts.map +1 -1
- package/dist/src/exports/server.js +4 -4
- package/dist/src/exports/server.js.map +1 -1
- package/dist/src/exports/sub-manager-worker-entry.js +1 -1
- package/dist/src/exports/types.d.ts +8 -3
- package/dist/src/exports/types.d.ts.map +1 -0
- package/dist/src/exports/types.js +20 -1
- package/dist/src/exports/types.js.map +1 -0
- package/dist/sub-worker-dispatch-CC0w_sx0.js +826 -0
- package/dist/sub-worker-dispatch-CC0w_sx0.js.map +1 -0
- package/dist/sub-worker-dispatch-UGC9vwQJ.js +826 -0
- package/dist/sub-worker-dispatch-UGC9vwQJ.js.map +1 -0
- package/dist/types_db-Dw2RHWrd.js +172 -0
- package/dist/types_db-Dw2RHWrd.js.map +1 -0
- package/dist/types_server-B7elBQyz.d.ts +523 -0
- package/dist/types_server-B7elBQyz.d.ts.map +1 -0
- package/dist/types_server-BSiGxbqb.d.ts +523 -0
- package/dist/types_server-BSiGxbqb.d.ts.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -155,10 +155,9 @@ Supalive is code-first: your `defineSchema` calls are the source of truth for th
|
|
|
155
155
|
|
|
156
156
|
```ts
|
|
157
157
|
// schema-gen.ts
|
|
158
|
-
import { generateSchemaSql
|
|
158
|
+
import { generateSchemaSql } from "@supalive/core/schema-sql";
|
|
159
159
|
import { writeFileSync } from "node:fs";
|
|
160
160
|
|
|
161
|
-
trackSchema(); // register every defineSchema on import
|
|
162
161
|
await import("./procedures.js"); // side-effect: runs your defineSchema calls
|
|
163
162
|
|
|
164
163
|
writeFileSync("schema.sql", generateSchemaSql(undefined, { dialect: "postgres" }));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/helper.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Synchronous deterministic JSON stringification.
|
|
4
|
+
* Keys are sorted; `undefined` values are dropped.
|
|
5
|
+
*
|
|
6
|
+
* Suitable for React `useEffect` dependency keys — calling this on the same
|
|
7
|
+
* logical input always produces the same string, regardless of property order.
|
|
8
|
+
*/
|
|
9
|
+
declare function stableStringify(input: unknown): string;
|
|
10
|
+
declare function supaliveStringify(input: unknown): string;
|
|
11
|
+
declare function groupByToMap<T, K>(items: Iterable<T>, getKey: (item: T) => K): Map<K, T[]>;
|
|
12
|
+
declare function envBool(name: string, defaultValue?: boolean): boolean;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { supaliveStringify as i, groupByToMap as n, stableStringify as r, envBool as t };
|
|
15
|
+
//# sourceMappingURL=helper-CUSGbt2A.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helper-CUSGbt2A.d.ts","names":[],"sources":["../src/helper.ts"],"mappings":";;AASA;;;;AAA8C;AAS9C;iBATgB,eAAA,CAAgB,KAAc;AAAA,iBAS9B,iBAAA,CAAkB,KAAc;AAAA,iBAchC,YAAA,OACd,KAAA,EAAO,QAAA,CAAS,CAAA,GAChB,MAAA,GAAS,IAAA,EAAM,CAAA,KAAM,CAAA,GACpB,GAAA,CAAI,CAAA,EAAG,CAAA;AAAA,iBAkBM,OAAA,CAAQ,IAAA,UAAc,YAAoB"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import stableStringifyFn from "json-stable-stringify";
|
|
2
|
+
//#region src/db/bytes.ts
|
|
3
|
+
function bytesEqual(a, b) {
|
|
4
|
+
if (a === b) return true;
|
|
5
|
+
if (a.byteLength !== b.byteLength) return false;
|
|
6
|
+
for (let i = 0; i < a.byteLength; i++) if (a[i] !== b[i]) return false;
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
const _enc = new TextEncoder();
|
|
10
|
+
const _dec = new TextDecoder("utf-8");
|
|
11
|
+
function utf8Encode(s) {
|
|
12
|
+
return _enc.encode(s);
|
|
13
|
+
}
|
|
14
|
+
function utf8Decode(b) {
|
|
15
|
+
return _dec.decode(b);
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/helper.ts
|
|
19
|
+
/**
|
|
20
|
+
* Synchronous deterministic JSON stringification.
|
|
21
|
+
* Keys are sorted; `undefined` values are dropped.
|
|
22
|
+
*
|
|
23
|
+
* Suitable for React `useEffect` dependency keys — calling this on the same
|
|
24
|
+
* logical input always produces the same string, regardless of property order.
|
|
25
|
+
*/
|
|
26
|
+
function stableStringify(input) {
|
|
27
|
+
return stableStringifyFn(input, { replacer: (_, v) => {
|
|
28
|
+
if (typeof v === "bigint") return v.toString();
|
|
29
|
+
return v ?? void 0;
|
|
30
|
+
} }) ?? "";
|
|
31
|
+
}
|
|
32
|
+
function supaliveStringify(input) {
|
|
33
|
+
return JSON.stringify(input, (_, v) => {
|
|
34
|
+
if (typeof v === "bigint") return v.toString();
|
|
35
|
+
if (v instanceof Uint8Array) return {
|
|
36
|
+
type: "Buffer",
|
|
37
|
+
data: Array.from(v)
|
|
38
|
+
};
|
|
39
|
+
return v ?? void 0;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function groupByToMap(items, getKey) {
|
|
43
|
+
const map = /* @__PURE__ */ new Map();
|
|
44
|
+
for (const item of items) {
|
|
45
|
+
const key = getKey(item);
|
|
46
|
+
let group = map.get(key);
|
|
47
|
+
if (!group) {
|
|
48
|
+
group = [];
|
|
49
|
+
map.set(key, group);
|
|
50
|
+
}
|
|
51
|
+
group.push(item);
|
|
52
|
+
}
|
|
53
|
+
return map;
|
|
54
|
+
}
|
|
55
|
+
function envBool(name, defaultValue = false) {
|
|
56
|
+
const value = process.env[name];
|
|
57
|
+
if (value == null) return defaultValue;
|
|
58
|
+
switch (value.trim().toLowerCase()) {
|
|
59
|
+
case "true":
|
|
60
|
+
case "1":
|
|
61
|
+
case "yes":
|
|
62
|
+
case "on": return true;
|
|
63
|
+
case "false":
|
|
64
|
+
case "0":
|
|
65
|
+
case "no":
|
|
66
|
+
case "off": return false;
|
|
67
|
+
default: return defaultValue;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { bytesEqual as a, supaliveStringify as i, groupByToMap as n, utf8Decode as o, stableStringify as r, utf8Encode as s, envBool as t };
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=helper-CVcjwD3k.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helper-CVcjwD3k.js","names":[],"sources":["../src/db/bytes.ts","../src/helper.ts"],"sourcesContent":["// Small helpers for byte arrays. We standardize on Uint8Array internally so\n// values survive structured clone (worker_threads postMessage) and stay\n// browser-safe. Buffer is a Uint8Array subclass, so values from pg/mysql\n// drivers satisfy Uint8Array fields automatically.\n\nexport function bytesEqual(a: Uint8Array, b: Uint8Array): boolean {\n if (a === b) return true;\n if (a.byteLength !== b.byteLength) return false;\n for (let i = 0; i < a.byteLength; i++) {\n if (a[i] !== b[i]) return false;\n }\n return true;\n}\n\nconst _enc = new TextEncoder();\nconst _dec = new TextDecoder(\"utf-8\");\n\nexport function utf8Encode(s: string): Uint8Array {\n return _enc.encode(s);\n}\n\nexport function utf8Decode(b: Uint8Array): string {\n return _dec.decode(b);\n}\n","import stableStringifyFn from \"json-stable-stringify\";\n\n/**\n * Synchronous deterministic JSON stringification.\n * Keys are sorted; `undefined` values are dropped.\n *\n * Suitable for React `useEffect` dependency keys — calling this on the same\n * logical input always produces the same string, regardless of property order.\n */\nexport function stableStringify(input: unknown): string {\n return stableStringifyFn(input, {\n replacer: (_, v) => {\n if (typeof v === \"bigint\") return v.toString();\n return v ?? undefined;\n }\n }) ?? \"\";\n}\n\nexport function supaliveStringify(input: unknown): string {\n return JSON.stringify(input, (_, v) => {\n if (typeof v === \"bigint\") return v.toString();\n // Emit a stable wire shape for byte arrays regardless of whether the\n // producer holds a Buffer or a plain Uint8Array (the latter is what\n // crosses worker_threads postMessage). The matching decoder lives in\n // `bytesFromJson` in db/types_db.ts.\n if (v instanceof Uint8Array) {\n return { type: \"Buffer\", data: Array.from(v) };\n }\n return v ?? undefined;\n });\n}\n\nexport function groupByToMap<T, K>(\n items: Iterable<T>,\n getKey: (item: T) => K,\n): Map<K, T[]> {\n const map = new Map<K, T[]>();\n\n for (const item of items) {\n const key = getKey(item);\n\n let group = map.get(key);\n if (!group) {\n group = [];\n map.set(key, group);\n }\n\n group.push(item);\n }\n\n return map;\n}\n\nexport function envBool(name: string, defaultValue = false): boolean {\n const value = process.env[name];\n if (value == null) return defaultValue;\n\n switch (value.trim().toLowerCase()) {\n case \"true\":\n case \"1\":\n case \"yes\":\n case \"on\":\n return true;\n case \"false\":\n case \"0\":\n case \"no\":\n case \"off\":\n return false;\n default:\n return defaultValue;\n }\n}"],"mappings":";;AAKA,SAAgB,WAAW,GAAe,GAAwB;CAChE,IAAI,MAAM,GAAG,OAAO;CACpB,IAAI,EAAE,eAAe,EAAE,YAAY,OAAO;CAC1C,KAAK,IAAI,IAAI,GAAG,IAAI,EAAE,YAAY,KAChC,IAAI,EAAE,OAAO,EAAE,IAAI,OAAO;CAE5B,OAAO;AACT;AAEA,MAAM,OAAO,IAAI,YAAY;AAC7B,MAAM,OAAO,IAAI,YAAY,OAAO;AAEpC,SAAgB,WAAW,GAAuB;CAChD,OAAO,KAAK,OAAO,CAAC;AACtB;AAEA,SAAgB,WAAW,GAAuB;CAChD,OAAO,KAAK,OAAO,CAAC;AACtB;;;;;;;;;;ACdA,SAAgB,gBAAgB,OAAwB;CACtD,OAAO,kBAAkB,OAAO,EAC9B,WAAW,GAAG,MAAM;EAClB,IAAI,OAAO,MAAM,UAAU,OAAO,EAAE,SAA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