@lunora/sql-store 0.0.0 → 1.0.0-alpha.2

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.
@@ -0,0 +1,69 @@
1
+ const sqliteEncode = (value) => {
2
+ if (typeof value === "boolean") {
3
+ return value ? 1 : 0;
4
+ }
5
+ if (value === null || typeof value === "string" || typeof value === "number") {
6
+ return value;
7
+ }
8
+ if (typeof value === "bigint") {
9
+ return value.toString();
10
+ }
11
+ if (value instanceof Uint8Array) {
12
+ return value;
13
+ }
14
+ if (value instanceof ArrayBuffer) {
15
+ return new Uint8Array(value);
16
+ }
17
+ return JSON.stringify(value);
18
+ };
19
+ const tryJsonParse = (raw) => {
20
+ try {
21
+ return JSON.parse(raw);
22
+ } catch {
23
+ return raw;
24
+ }
25
+ };
26
+ const decodeBigint = (raw) => {
27
+ if (typeof raw !== "string") {
28
+ return raw;
29
+ }
30
+ try {
31
+ return BigInt(raw);
32
+ } catch {
33
+ return raw;
34
+ }
35
+ };
36
+ const effectiveColumnKind = (validator) => {
37
+ if (validator.kind !== "optional") {
38
+ return validator.kind;
39
+ }
40
+ const inner = validator._meta?.inner;
41
+ return inner ? effectiveColumnKind(inner) : validator.kind;
42
+ };
43
+ const sqliteDecode = (raw, kind) => {
44
+ if (raw === null) {
45
+ return raw;
46
+ }
47
+ switch (kind) {
48
+ case "any":
49
+ case "union": {
50
+ return typeof raw === "string" && (raw.startsWith("{") || raw.startsWith("[")) ? tryJsonParse(raw) : raw;
51
+ }
52
+ case "array":
53
+ case "object":
54
+ case "record": {
55
+ return typeof raw === "string" ? tryJsonParse(raw) : raw;
56
+ }
57
+ case "bigint": {
58
+ return decodeBigint(raw);
59
+ }
60
+ case "boolean": {
61
+ return raw === 0 || raw === 1 ? raw === 1 : raw;
62
+ }
63
+ default: {
64
+ return raw;
65
+ }
66
+ }
67
+ };
68
+
69
+ export { decodeBigint, effectiveColumnKind, sqliteDecode, sqliteEncode, tryJsonParse };
package/package.json CHANGED
@@ -1,31 +1,59 @@
1
1
  {
2
2
  "name": "@lunora/sql-store",
3
- "version": "0.0.0",
3
+ "version": "1.0.0-alpha.2",
4
4
  "description": "Internal dialect-parameterized SQL store core for Lunora .global() backends (D1, PlanetScale)",
5
- "license": "FSL-1.1-Apache-2.0",
5
+ "keywords": [
6
+ "cloudflare",
7
+ "dialect",
8
+ "lunora",
9
+ "mysql",
10
+ "orm",
11
+ "postgres",
12
+ "sql",
13
+ "sqlite"
14
+ ],
6
15
  "homepage": "https://lunora.sh",
16
+ "bugs": "https://github.com/anolilab/lunora/issues",
17
+ "license": "FSL-1.1-Apache-2.0",
18
+ "author": {
19
+ "name": "Daniel Bannert",
20
+ "email": "d.bannert@anolilab.de"
21
+ },
7
22
  "repository": {
8
23
  "type": "git",
9
24
  "url": "git+https://github.com/anolilab/lunora.git",
10
25
  "directory": "packages/sql-store"
11
26
  },
12
- "bugs": {
13
- "url": "https://github.com/anolilab/lunora/issues"
14
- },
15
- "keywords": [
16
- "lunora",
17
- "cloudflare",
18
- "sql",
19
- "sqlite",
20
- "postgres",
21
- "mysql",
22
- "dialect",
23
- "orm"
27
+ "files": [
28
+ "dist",
29
+ "README.md",
30
+ "LICENSE.md",
31
+ "__assets__"
24
32
  ],
33
+ "type": "module",
34
+ "sideEffects": false,
35
+ "main": "./dist/index.mjs",
36
+ "module": "./dist/index.mjs",
37
+ "types": "./dist/index.d.ts",
38
+ "exports": {
39
+ ".": {
40
+ "types": "./dist/index.d.ts",
41
+ "import": "./dist/index.mjs"
42
+ },
43
+ "./dialect": {
44
+ "types": "./dist/dialect.d.ts",
45
+ "import": "./dist/dialect.mjs"
46
+ },
47
+ "./package.json": "./package.json"
48
+ },
25
49
  "publishConfig": {
26
50
  "access": "public"
27
51
  },
28
- "files": [
29
- "README.md"
30
- ]
31
- }
52
+ "dependencies": {
53
+ "@lunora/do": "1.0.0-alpha.2",
54
+ "drizzle-orm": "^0.45.2"
55
+ },
56
+ "engines": {
57
+ "node": "^22.15.0 || >=24.11.0"
58
+ }
59
+ }