zod-sqlite 0.1.0-alpha.1
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 +895 -0
- package/dist/index.cjs +255 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +478 -0
- package/dist/index.d.ts +478 -0
- package/dist/index.js +253 -0
- package/dist/index.js.map +1 -0
- package/package.json +82 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import 'zod/v4/core';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
// src/utils/format-check-constraint.ts
|
|
5
|
+
function formatCheckConstraint(name, schema) {
|
|
6
|
+
let currentSchema = schema;
|
|
7
|
+
while (true) {
|
|
8
|
+
const def = currentSchema._zod.def;
|
|
9
|
+
if (def.type === "nullable" || def.type === "optional" || def.type === "default") {
|
|
10
|
+
currentSchema = def.innerType;
|
|
11
|
+
} else {
|
|
12
|
+
break;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const definition = currentSchema._zod.def;
|
|
16
|
+
const zodType = definition.type;
|
|
17
|
+
switch (zodType) {
|
|
18
|
+
case "enum": {
|
|
19
|
+
const entries = definition.entries;
|
|
20
|
+
const values = Object.values(entries);
|
|
21
|
+
const quotedValues = values.map((value) => `'${String(value).replace(/'/g, "''")}'`).join(", ");
|
|
22
|
+
return `CHECK(${name} IN (${quotedValues}))`;
|
|
23
|
+
}
|
|
24
|
+
case "literal": {
|
|
25
|
+
const values = definition.values;
|
|
26
|
+
if (values.length === 1) {
|
|
27
|
+
const value = values[0];
|
|
28
|
+
if (typeof value === "string") {
|
|
29
|
+
return `CHECK(${name} = '${value.replace(/'/g, "''")}')`;
|
|
30
|
+
}
|
|
31
|
+
return `CHECK(${name} = ${value})`;
|
|
32
|
+
}
|
|
33
|
+
const quotedValues = values.map((value) => {
|
|
34
|
+
if (typeof value === "string") {
|
|
35
|
+
return `'${value.replace(/'/g, "''")}'`;
|
|
36
|
+
}
|
|
37
|
+
return String(value);
|
|
38
|
+
}).join(", ");
|
|
39
|
+
return `CHECK(${name} IN (${quotedValues}))`;
|
|
40
|
+
}
|
|
41
|
+
case "union": {
|
|
42
|
+
const options = definition.options;
|
|
43
|
+
const allAreLiterals = options.every((option) => option._zod.def.type === "literal");
|
|
44
|
+
if (!allAreLiterals) return null;
|
|
45
|
+
const values = [];
|
|
46
|
+
for (const option of options) {
|
|
47
|
+
values.push(...option._zod.def.values);
|
|
48
|
+
}
|
|
49
|
+
const quotedValues = values.map((value) => {
|
|
50
|
+
if (typeof value === "string") {
|
|
51
|
+
return `'${value.replace(/'/g, "''")}'`;
|
|
52
|
+
}
|
|
53
|
+
return String(value);
|
|
54
|
+
}).join(", ");
|
|
55
|
+
return `CHECK(${name} IN (${quotedValues}))`;
|
|
56
|
+
}
|
|
57
|
+
case "number": {
|
|
58
|
+
const checks = definition.checks;
|
|
59
|
+
const constraints = [];
|
|
60
|
+
if (!checks) return null;
|
|
61
|
+
for (const check of checks) {
|
|
62
|
+
const checkParameters = check._zod.def.check;
|
|
63
|
+
const checkValue = check._zod.def.value;
|
|
64
|
+
switch (checkParameters) {
|
|
65
|
+
case "greater_than":
|
|
66
|
+
constraints.push(`${name} >= ${checkValue}`);
|
|
67
|
+
break;
|
|
68
|
+
case "less_than":
|
|
69
|
+
constraints.push(`${name} <= ${checkValue}`);
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return constraints.length > 0 ? `CHECK(${constraints.join(" AND ")})` : null;
|
|
74
|
+
}
|
|
75
|
+
case "string": {
|
|
76
|
+
const checks = definition.checks;
|
|
77
|
+
const constraints = [];
|
|
78
|
+
if (!checks) return null;
|
|
79
|
+
for (const check of checks) {
|
|
80
|
+
const checkParameters = check._zod.def.check;
|
|
81
|
+
const checkDefinition = check._zod.def;
|
|
82
|
+
switch (checkParameters) {
|
|
83
|
+
case "min_length":
|
|
84
|
+
constraints.push(`length(${name}) >= ${checkDefinition.minimum}`);
|
|
85
|
+
break;
|
|
86
|
+
case "max_length":
|
|
87
|
+
constraints.push(`length(${name}) <= ${checkDefinition.maximum}`);
|
|
88
|
+
break;
|
|
89
|
+
case "length_equals":
|
|
90
|
+
constraints.push(`length(${name}) = ${checkDefinition.length}`);
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return constraints.length > 0 ? `CHECK(${constraints.join(" AND ")})` : null;
|
|
95
|
+
}
|
|
96
|
+
default:
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// src/utils/format-default-value.ts
|
|
102
|
+
function formatDefaultValue(value, SQLiteType) {
|
|
103
|
+
switch (SQLiteType) {
|
|
104
|
+
case "TEXT":
|
|
105
|
+
return `DEFAULT '${String(value).replace(/'/g, "''")}'`;
|
|
106
|
+
case "INTEGER":
|
|
107
|
+
case "REAL":
|
|
108
|
+
return `DEFAULT ${Number(value)}`;
|
|
109
|
+
case "BOOLEAN":
|
|
110
|
+
return `DEFAULT ${Boolean(value) ? 1 : 0}`;
|
|
111
|
+
case "NULL":
|
|
112
|
+
return "DEFAULT NULL";
|
|
113
|
+
default:
|
|
114
|
+
return `DEFAULT '${value}'`;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function mapZodTypeToSQLite(zodType, schema) {
|
|
118
|
+
switch (zodType) {
|
|
119
|
+
case "string": {
|
|
120
|
+
const format = schema._zod.def.format;
|
|
121
|
+
switch (format) {
|
|
122
|
+
case "date":
|
|
123
|
+
return "DATE";
|
|
124
|
+
case "datetime":
|
|
125
|
+
return "DATETIME";
|
|
126
|
+
case "duration":
|
|
127
|
+
return "INTEGER";
|
|
128
|
+
default:
|
|
129
|
+
return "TEXT";
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
case "date":
|
|
133
|
+
return "DATE";
|
|
134
|
+
case "enum":
|
|
135
|
+
case "literal":
|
|
136
|
+
case "template_literal":
|
|
137
|
+
case "array":
|
|
138
|
+
case "object":
|
|
139
|
+
return "TEXT";
|
|
140
|
+
case "number": {
|
|
141
|
+
const format = schema._zod.def.format;
|
|
142
|
+
switch (format) {
|
|
143
|
+
case "safeint":
|
|
144
|
+
case "uint32":
|
|
145
|
+
case "int32":
|
|
146
|
+
return "INTEGER";
|
|
147
|
+
case "float32":
|
|
148
|
+
case "float64":
|
|
149
|
+
return "FLOAT";
|
|
150
|
+
default:
|
|
151
|
+
return "REAL";
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
case "boolean":
|
|
155
|
+
return "BOOLEAN";
|
|
156
|
+
case "bigint":
|
|
157
|
+
return "BIGINT";
|
|
158
|
+
case "null":
|
|
159
|
+
case "undefined":
|
|
160
|
+
return "NULL";
|
|
161
|
+
case "file":
|
|
162
|
+
return "BLOB";
|
|
163
|
+
default:
|
|
164
|
+
return "TEXT";
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// src/utils/zod-to-sqlite.ts
|
|
169
|
+
function zodToSQLite(schema) {
|
|
170
|
+
let nullable = false;
|
|
171
|
+
let defaultValue = void 0;
|
|
172
|
+
let currentSchema = schema;
|
|
173
|
+
while (true) {
|
|
174
|
+
const definition = currentSchema._zod.def;
|
|
175
|
+
const zodType = definition.type;
|
|
176
|
+
if (zodType === "nullable" || zodType === "optional") {
|
|
177
|
+
nullable = true;
|
|
178
|
+
currentSchema = definition.innerType;
|
|
179
|
+
} else if (zodType === "default") {
|
|
180
|
+
defaultValue = typeof definition.defaultValue === "function" ? definition.defaultValue() : definition.defaultValue;
|
|
181
|
+
currentSchema = definition.innerType;
|
|
182
|
+
} else {
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
const mainType = currentSchema._zod.def.type;
|
|
187
|
+
const SQLiteType = mapZodTypeToSQLite(mainType, currentSchema);
|
|
188
|
+
return { SQLiteType, nullable, defaultValue, schema };
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// src/core/column-definitions.ts
|
|
192
|
+
function buildColumnDefinition(column) {
|
|
193
|
+
const { name, schema, unique, references } = column;
|
|
194
|
+
const { SQLiteType, nullable, defaultValue } = zodToSQLite(schema);
|
|
195
|
+
const parts = [name, SQLiteType];
|
|
196
|
+
if (!nullable) parts.push("NOT NULL");
|
|
197
|
+
if (defaultValue !== void 0) parts.push(formatDefaultValue(defaultValue, SQLiteType));
|
|
198
|
+
if (unique) parts.push("UNIQUE");
|
|
199
|
+
const checkConstraint = formatCheckConstraint(name, schema);
|
|
200
|
+
if (checkConstraint) parts.push(checkConstraint);
|
|
201
|
+
if (references) {
|
|
202
|
+
const { table, column: refColumn, onDelete, onUpdate } = references;
|
|
203
|
+
parts.push(`REFERENCES ${table}(${refColumn})`);
|
|
204
|
+
if (onDelete) parts.push(`ON DELETE ${onDelete}`);
|
|
205
|
+
if (onUpdate) parts.push(`ON UPDATE ${onUpdate}`);
|
|
206
|
+
}
|
|
207
|
+
return parts.join(" ");
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// src/core/index-statements.ts
|
|
211
|
+
function buildIndexStatements(tableName, indexes) {
|
|
212
|
+
if (!indexes || indexes.length === 0) return [];
|
|
213
|
+
return indexes.map((index) => {
|
|
214
|
+
const uniqueClause = index.unique ? "UNIQUE " : "";
|
|
215
|
+
const whereClause = index.where ? ` WHERE ${index.where}` : "";
|
|
216
|
+
return `CREATE ${uniqueClause}INDEX ${index.name} ON ${tableName} (${index.columns.join(", ")})${whereClause};`;
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// src/core/primary-key-constraint.ts
|
|
221
|
+
function buildPrimaryKeyConstraint(primaryKeys) {
|
|
222
|
+
if (primaryKeys.length === 0) return "";
|
|
223
|
+
return `PRIMARY KEY (${primaryKeys.join(", ")})`;
|
|
224
|
+
}
|
|
225
|
+
function buildZodSchema(columns) {
|
|
226
|
+
const schemaShape = {};
|
|
227
|
+
for (const column of columns) {
|
|
228
|
+
schemaShape[column.name] = column.schema;
|
|
229
|
+
}
|
|
230
|
+
return z.object(schemaShape);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// src/core/table.ts
|
|
234
|
+
function createTable(config) {
|
|
235
|
+
const { name, columns, primaryKeys, indexes } = config;
|
|
236
|
+
const columnDefs = columns.map(buildColumnDefinition);
|
|
237
|
+
const primaryKeyConstraint = buildPrimaryKeyConstraint(primaryKeys);
|
|
238
|
+
const tableElements = [...columnDefs, primaryKeyConstraint].filter(Boolean);
|
|
239
|
+
const createTableSQL = `CREATE TABLE ${name} (
|
|
240
|
+
${tableElements.join(",\n ")}
|
|
241
|
+
);`;
|
|
242
|
+
const createIndexesSQL = buildIndexStatements(name, indexes);
|
|
243
|
+
const zodSchema = buildZodSchema(columns);
|
|
244
|
+
return {
|
|
245
|
+
table: createTableSQL,
|
|
246
|
+
indexes: createIndexesSQL,
|
|
247
|
+
schema: zodSchema
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export { createTable };
|
|
252
|
+
//# sourceMappingURL=index.js.map
|
|
253
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/format-check-constraint.ts","../src/utils/format-default-value.ts","../src/utils/map-zod-type-to-sqlite.ts","../src/utils/zod-to-sqlite.ts","../src/core/column-definitions.ts","../src/core/index-statements.ts","../src/core/primary-key-constraint.ts","../src/core/zod-schema.ts","../src/core/table.ts"],"names":[],"mappings":";;;;AAeO,SAAS,qBAAA,CAAsB,MAAc,MAAA,EAAqC;AACvF,EAAA,IAAI,aAAA,GAAgB,MAAA;AAGpB,EAAA,OAAO,IAAA,EAAM;AACX,IAAA,MAAM,GAAA,GAAM,cAAc,IAAA,CAAK,GAAA;AAC/B,IAAA,IAAI,GAAA,CAAI,SAAS,UAAA,IAAc,GAAA,CAAI,SAAS,UAAA,IAAc,GAAA,CAAI,SAAS,SAAA,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IAAA,CAAK,IAAI,CAAC,CAAA,CAAA,CAAA;AAC/C;ACEO,SAAS,eAA+E,OAAA,EAAmB;AAChH,EAAA,MAAM,cAA4C,EAAC;AAEnD,EAAA,KAAA,MAAW,UAAU,OAAA,EAAS;AAC5B,IAAA,WAAA,CAAY,MAAA,CAAO,IAAI,CAAA,GAAI,MAAA,CAAO,MAAA;AAAA,EACpC;AAMA,EAAA,OAAO,CAAA,CAAE,OAAO,WAAW,CAAA;AAC7B;;;ACNO,SAAS,YAAsE,MAAA,EAA+B;AACnH,EAAA,MAAM,EAAE,IAAA,EAAM,OAAA,EAAS,WAAA,EAAa,SAAQ,GAAI,MAAA;AAGhD,EAAA,MAAM,UAAA,GAAa,OAAA,CAAQ,GAAA,CAAI,qBAAqB,CAAA;AAGpD,EAAA,MAAM,oBAAA,GAAuB,0BAA0B,WAAW,CAAA;AAGlE,EAAA,MAAM,gBAAgB,CAAC,GAAG,YAAY,oBAAoB,CAAA,CAAE,OAAO,OAAO,CAAA;AAG1E,EAAA,MAAM,cAAA,GAAiB,gBAAgB,IAAI,CAAA;AAAA,EAAA,EACzC,aAAA,CAAc,IAAA,CAAK,OAAO,CAAC;AAAA,EAAA,CAAA;AAI7B,EAAA,MAAM,gBAAA,GAAmB,oBAAA,CAAqB,IAAA,EAAM,OAAO,CAAA;AAG3D,EAAA,MAAM,SAAA,GAAY,eAAe,OAAO,CAAA;AAExC,EAAA,OAAO;AAAA,IACL,KAAA,EAAO,cAAA;AAAA,IACP,OAAA,EAAS,gBAAA;AAAA,IACT,MAAA,EAAQ;AAAA,GACV;AACF","file":"index.js","sourcesContent":["import * as zod from 'zod/v4/core'\r\n\r\n/**\r\n * Generates formatted CHECK constraints for validatable columns.\r\n *\r\n * Supports:\r\n * - `z.enum()`: CHECK(col IN ('a', 'b'))\r\n * - `z.literal()`: CHECK(col = 'val')\r\n * - `z.number().min/max()`: CHECK(col >= min AND col <= max)\r\n * - `z.string().min/max()`: CHECK(length(col) >= min)\r\n *\r\n * @param name - Column name\r\n * @param schema - Zod schema\r\n * @returns SQL CHECK constraint string or null\r\n */\r\nexport function formatCheckConstraint(name: string, schema: zod.$ZodType): string | null {\r\n let currentSchema = schema as zod.$ZodTypes\r\n\r\n // Unwrap wrappers\r\n while (true) {\r\n const def = currentSchema._zod.def\r\n if (def.type === 'nullable' || def.type === 'optional' || def.type === 'default') {\r\n currentSchema = def.innerType as zod.$ZodTypes\r\n } else {\r\n break\r\n }\r\n }\r\n\r\n const definition = currentSchema._zod.def\r\n const zodType = definition.type\r\n\r\n switch (zodType) {\r\n case 'enum': {\r\n const entries = definition.entries\r\n const values = Object.values(entries)\r\n const quotedValues = values.map(value => `'${String(value).replace(/'/g, \"''\")}'`).join(', ')\r\n return `CHECK(${name} IN (${quotedValues}))`\r\n }\r\n\r\n case 'literal': {\r\n const values = definition.values\r\n\r\n // Single value: CHECK(column = 'value')\r\n if (values.length === 1) {\r\n const value = values[0]\r\n if (typeof value === 'string') {\r\n return `CHECK(${name} = '${value.replace(/'/g, \"''\")}')`\r\n }\r\n return `CHECK(${name} = ${value})`\r\n }\r\n\r\n // Multiple values: CHECK(column IN ('value1', 'value2'))\r\n const quotedValues = values.map((value) => {\r\n if (typeof value === 'string') {\r\n return `'${value.replace(/'/g, \"''\")}'`\r\n }\r\n return String(value)\r\n }).join(', ')\r\n return `CHECK(${name} IN (${quotedValues}))`\r\n }\r\n\r\n case 'union': {\r\n const options = definition.options\r\n const allAreLiterals = options.every(option => option._zod.def.type === 'literal')\r\n\r\n if (!allAreLiterals) return null\r\n\r\n const values: unknown[] = []\r\n\r\n for (const option of options) {\r\n values.push(...(option as zod.$ZodLiteral)._zod.def.values)\r\n }\r\n\r\n const quotedValues = values.map((value) => {\r\n if (typeof value === 'string') {\r\n return `'${value.replace(/'/g, \"''\")}'`\r\n }\r\n return String(value)\r\n }).join(', ')\r\n return `CHECK(${name} IN (${quotedValues}))`\r\n }\r\n\r\n case 'number': {\r\n const checks = definition.checks\r\n const constraints: string[] = []\r\n\r\n if (!checks) return null\r\n\r\n for (const check of checks) {\r\n const checkParameters = (check as zod.$ZodChecks)._zod.def.check\r\n const checkValue = (check._zod.def as unknown as { value: number }).value\r\n\r\n switch (checkParameters) {\r\n\r\n case 'greater_than':\r\n constraints.push(`${name} >= ${checkValue}`)\r\n break\r\n\r\n case 'less_than':\r\n constraints.push(`${name} <= ${checkValue}`)\r\n break\r\n }\r\n\r\n }\r\n\r\n return constraints.length > 0 ? `CHECK(${constraints.join(' AND ')})` : null\r\n }\r\n\r\n case 'string': {\r\n const checks = definition.checks\r\n const constraints: string[] = []\r\n\r\n if (!checks) return null\r\n\r\n for (const check of checks) {\r\n const checkParameters = (check as zod.$ZodChecks)._zod.def.check\r\n const checkDefinition = check._zod.def as unknown\r\n\r\n switch (checkParameters) {\r\n case 'min_length':\r\n constraints.push(`length(${name}) >= ${(checkDefinition as { minimum: number }).minimum}`)\r\n break\r\n\r\n case 'max_length':\r\n constraints.push(`length(${name}) <= ${(checkDefinition as { maximum: number }).maximum}`)\r\n break\r\n\r\n case 'length_equals':\r\n constraints.push(`length(${name}) = ${(checkDefinition as { length: number }).length}`)\r\n break\r\n }\r\n\r\n }\r\n\r\n return constraints.length > 0 ? `CHECK(${constraints.join(' AND ')})` : null\r\n }\r\n\r\n default:\r\n return null\r\n }\r\n}\r\n","import type { SQLiteSupportType, SQLiteType } from '../types'\r\n\r\n/**\r\n * Formats a default value for SQL.\r\n *\r\n * Handles string quoting and type conversions for DEFAULT clauses.\r\n *\r\n * @param value - The default value\r\n * @param SQLiteType - Target column type\r\n * @returns Formatted SQL default string (e.g., \"DEFAULT 'val'\", \"DEFAULT 42\")\r\n */\r\nexport function formatDefaultValue(value: unknown, SQLiteType: SQLiteType | SQLiteSupportType) {\r\n switch (SQLiteType) {\r\n case 'TEXT':\r\n return `DEFAULT '${String(value).replace(/'/g, \"''\")}'`\r\n\r\n case 'INTEGER':\r\n case 'REAL':\r\n return `DEFAULT ${Number(value)}`\r\n\r\n case 'BOOLEAN':\r\n return `DEFAULT ${Boolean(value) ? 1 : 0}`\r\n\r\n case 'NULL':\r\n return 'DEFAULT NULL'\r\n\r\n default:\r\n return `DEFAULT '${value}'`\r\n }\r\n}\r\n","import type { SQLiteSupportType, SQLiteType } from '../types'\r\nimport * as zod from 'zod/v4/core'\r\n\r\n/**\r\n * Maps a Zod type to an SQLite column type.\r\n *\r\n * analyzes the Zod schema type and optionally its format (e.g., z.email())\r\n * to determine the most appropriate SQLite storage class or supported type.\r\n *\r\n * @param zodType - Zod type string (e.g., 'string', 'number')\r\n * @param schema - The actual Zod schema instance\r\n * @returns SQLite column type\r\n */\r\nexport function mapZodTypeToSQLite(zodType: zod.$ZodTypes['_zod']['def']['type'], schema: zod.$ZodType): SQLiteType | SQLiteSupportType {\r\n switch (zodType) {\r\n\r\n case 'string': {\r\n\r\n const format = (schema as zod.$ZodStringFormat)._zod.def.format as zod.$ZodStringFormats\r\n\r\n switch (format) {\r\n case 'date':\r\n return 'DATE'\r\n\r\n case 'datetime':\r\n return 'DATETIME'\r\n\r\n case 'duration':\r\n return 'INTEGER'\r\n\r\n default:\r\n return 'TEXT'\r\n }\r\n\r\n }\r\n\r\n case 'date':\r\n return 'DATE'\r\n\r\n case 'enum':\r\n case 'literal':\r\n case 'template_literal':\r\n case 'array':\r\n case 'object':\r\n return 'TEXT'\r\n\r\n case 'number':{\r\n const format = (schema as zod.$ZodNumberFormat)._zod.def.format\r\n\r\n switch (format) {\r\n case 'safeint':\r\n case 'uint32':\r\n case 'int32':\r\n return 'INTEGER'\r\n\r\n case 'float32':\r\n case 'float64':\r\n return 'FLOAT'\r\n\r\n default:\r\n return 'REAL'\r\n }\r\n }\r\n\r\n case 'boolean':\r\n return 'BOOLEAN'\r\n\r\n case 'bigint':\r\n return 'BIGINT'\r\n\r\n case 'null':\r\n case 'undefined':\r\n return 'NULL'\r\n\r\n case 'file':\r\n return 'BLOB'\r\n\r\n default:\r\n return 'TEXT'\r\n }\r\n}\r\n","import * as zod from 'zod/v4/core'\r\nimport { mapZodTypeToSQLite } from './map-zod-type-to-sqlite'\r\n\r\n/**\r\n * Analyzes a Zod schema to extract SQLite metadata.\r\n *\r\n * Unwraps optional/nullable/default layers to find the underlying core type\r\n * and extracts metadata like nullability and default values.\r\n *\r\n * @param schema - Zod schema to analyze\r\n * @returns Object containing SQLite type, nullability, default value, and inner schema\r\n */\r\nexport function zodToSQLite(schema: zod.$ZodType) {\r\n let nullable = false\r\n let defaultValue = undefined\r\n let currentSchema = schema as zod.$ZodTypes\r\n // Unwrap wrapped schemas and collect metadata\r\n while (true) {\r\n const definition = currentSchema._zod.def\r\n const zodType = definition.type\r\n if (zodType === 'nullable' || zodType === 'optional') {\r\n nullable = true\r\n currentSchema = definition.innerType as zod.$ZodTypes\r\n } else if (zodType === 'default') {\r\n defaultValue = typeof definition.defaultValue === 'function'\r\n ? definition.defaultValue()\r\n : definition.defaultValue\r\n currentSchema = definition.innerType as zod.$ZodTypes\r\n } else {\r\n break\r\n }\r\n }\r\n const mainType = currentSchema._zod.def.type\r\n const SQLiteType = mapZodTypeToSQLite(mainType, currentSchema)\r\n return { SQLiteType, nullable, defaultValue, schema }\r\n}\r\n","import { formatCheckConstraint } from '../utils/format-check-constraint'\r\nimport { formatDefaultValue } from '../utils/format-default-value'\r\nimport type { TableConfig } from '../types'\r\nimport { zodToSQLite } from '../utils/zod-to-sqlite'\r\n\r\n/**\r\n * Builds the SQL definition for a single column.\r\n *\r\n * Combines name, type, and constraints into a valid SQL column string.\r\n *\r\n * @param column - Column configuration object\r\n * @returns Complete column definition string (e.g., \"id INTEGER NOT NULL\")\r\n */\r\nexport function buildColumnDefinition(column: TableConfig['columns'][number]): string {\r\n const { name, schema, unique, references } = column\r\n const { SQLiteType, nullable, defaultValue } = zodToSQLite(schema)\r\n\r\n const parts: string[] = [name, SQLiteType]\r\n\r\n // Add constraints\r\n if (!nullable) parts.push('NOT NULL')\r\n if (defaultValue !== undefined) parts.push(formatDefaultValue(defaultValue, SQLiteType))\r\n if (unique) parts.push('UNIQUE')\r\n\r\n // Add CHECK constraint for enums/literals\r\n const checkConstraint = formatCheckConstraint(name, schema)\r\n if (checkConstraint) parts.push(checkConstraint)\r\n\r\n // Add foreign key\r\n if (references) {\r\n const { table, column: refColumn, onDelete, onUpdate } = references\r\n parts.push(`REFERENCES ${table}(${refColumn})`)\r\n if (onDelete) parts.push(`ON DELETE ${onDelete}`)\r\n if (onUpdate) parts.push(`ON UPDATE ${onUpdate}`)\r\n }\r\n\r\n return parts.join(' ')\r\n}\r\n","import type { TableConfig } from '../types'\r\n\r\n/**\r\n * Generates SQL statements for table indexes.\r\n *\r\n * Creates standard, unique, and partial indexes based on configuration.\r\n *\r\n * @param tableName - Name of the table\r\n * @param indexes - Array of index configurations\r\n * @returns Array of CREATE INDEX SQL statements\r\n */\r\nexport function buildIndexStatements(tableName: string, indexes?: TableConfig['indexes']): string[] {\r\n if (!indexes || indexes.length === 0) return []\r\n\r\n return indexes.map((index) => {\r\n const uniqueClause = index.unique ? 'UNIQUE ' : ''\r\n const whereClause = index.where ? ` WHERE ${index.where}` : ''\r\n return `CREATE ${uniqueClause}INDEX ${index.name} ON ${tableName} (${index.columns.join(', ')})${whereClause};`\r\n })\r\n}\r\n","/**\r\n * Builds the PRIMARY KEY constraint string.\r\n *\r\n * Handles both single-column and composite primary keys.\r\n *\r\n * @param primaryKeys - Array of column names forming the primary key\r\n * @returns SQL constraint string (e.g., \"PRIMARY KEY (id, email)\")\r\n */\r\nexport function buildPrimaryKeyConstraint(primaryKeys: string[] | readonly string[]): string {\r\n if (primaryKeys.length === 0) return ''\r\n return `PRIMARY KEY (${primaryKeys.join(', ')})`\r\n}\r\n","import type { ColumnConfig } from '../types'\r\nimport * as zod from 'zod/v4/core'\r\nimport { z } from 'zod'\r\n\r\n/**\r\n * Builds a Zod schema from column definitions.\r\n *\r\n * Creates a Zod object schema where keys are column names and values are\r\n * the corresponding Zod schemas from the column configuration.\r\n *\r\n * @param columns - Array of column configurations\r\n * @returns Zod object schema\r\n */\r\nexport function buildZodSchema<TColumns extends readonly ColumnConfig<string, zod.$ZodType>[]>(columns: TColumns) {\r\n const schemaShape: Record<string, zod.$ZodType> = {}\r\n \r\n for (const column of columns) {\r\n schemaShape[column.name] = column.schema\r\n }\r\n \r\n type SchemaType = {\r\n [K in TColumns[number]['name']]: Extract<TColumns[number], { name: K }>['schema']\r\n }\r\n\r\n return z.object(schemaShape) as z.ZodObject<SchemaType>\r\n}\r\n","import { buildColumnDefinition } from './column-definitions'\r\nimport { buildIndexStatements } from './index-statements'\r\nimport { buildPrimaryKeyConstraint } from './primary-key-constraint'\r\nimport type { ColumnConfig, TableConfig } from '../types'\r\nimport { buildZodSchema } from './zod-schema'\r\n\r\n/**\r\n * Creates a table definition and Zod schema.\r\n *\r\n * This function is the main entry point for defining a table. It takes a configuration object\r\n * and returns:\r\n * 1. `table`: SQL CREATE TABLE statement\r\n * 2. `indexes`: Array of SQL CREATE INDEX statements\r\n * 3. `schema`: Zod object schema matching the table structure\r\n *\r\n * @param config - Table configuration object\r\n * @returns Object containing SQL statements and Zod schema\r\n */\r\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\r\nexport function createTable<const TColumns extends readonly ColumnConfig<any, any>[]>(config: TableConfig<TColumns>) {\r\n const { name, columns, primaryKeys, indexes } = config\r\n\r\n // Build column definitions\r\n const columnDefs = columns.map(buildColumnDefinition)\r\n\r\n // Build primary key constraint\r\n const primaryKeyConstraint = buildPrimaryKeyConstraint(primaryKeys)\r\n\r\n // Combine all table elements\r\n const tableElements = [...columnDefs, primaryKeyConstraint].filter(Boolean)\r\n\r\n // Build CREATE TABLE statement\r\n const createTableSQL = `CREATE TABLE ${name} (\r\n ${tableElements.join(',\\n ')}\r\n);`\r\n\r\n // Build CREATE INDEX statements\r\n const createIndexesSQL = buildIndexStatements(name, indexes)\r\n\r\n // Build Zod schema from columns\r\n const zodSchema = buildZodSchema(columns)\r\n\r\n return {\r\n table: createTableSQL,\r\n indexes: createIndexesSQL,\r\n schema: zodSchema,\r\n }\r\n}\r\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "zod-sqlite",
|
|
3
|
+
"version": "0.1.0-alpha.1",
|
|
4
|
+
"description": "Generate type-safe SQLite table schemas from Zod validation schemas.",
|
|
5
|
+
"private": false,
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "Favour Emeka",
|
|
8
|
+
"email": "favor.emeka@minibase.com",
|
|
9
|
+
"url": "https://github.com/favorodera"
|
|
10
|
+
},
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/favorodera/zod-sqlite.git"
|
|
15
|
+
},
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/favorodera/zod-sqlite/issues"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://github.com/favorodera/zod-sqlite#readme",
|
|
20
|
+
"type": "module",
|
|
21
|
+
"main": "./dist/index.cjs",
|
|
22
|
+
"module": "./dist/index.js",
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"import": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"default": "./dist/index.js"
|
|
29
|
+
},
|
|
30
|
+
"require": {
|
|
31
|
+
"types": "./dist/index.d.cts",
|
|
32
|
+
"default": "./dist/index.cjs"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"./package.json": "./package.json"
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"dist",
|
|
39
|
+
"README.md",
|
|
40
|
+
"LICENSE"
|
|
41
|
+
],
|
|
42
|
+
"sideEffects": false,
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "pnpm clean && tsup",
|
|
45
|
+
"dev": "tsup --watch",
|
|
46
|
+
"test": "vitest",
|
|
47
|
+
"typecheck": "tsc --noEmit",
|
|
48
|
+
"lint": "eslint src --ext .ts --fix",
|
|
49
|
+
"clean": "rm -rf dist",
|
|
50
|
+
"prepublishOnly": "pnpm build && pnpm typecheck && pnpm vitest --watch=false",
|
|
51
|
+
"release": "pnpm build && pnpm dlx @changesets/cli publish"
|
|
52
|
+
},
|
|
53
|
+
"packageManager": "pnpm@10.26.1",
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@changesets/cli": "^2.29.8",
|
|
56
|
+
"@stylistic/eslint-plugin": "^5.6.1",
|
|
57
|
+
"@typescript-eslint/eslint-plugin": "^8.51.0",
|
|
58
|
+
"@typescript-eslint/parser": "^8.51.0",
|
|
59
|
+
"@vitest/ui": "^4.0.16",
|
|
60
|
+
"eslint": "^9.39.2",
|
|
61
|
+
"tsup": "^8.5.1",
|
|
62
|
+
"typescript": "^5.9.3",
|
|
63
|
+
"vitest": "^4.0.16"
|
|
64
|
+
},
|
|
65
|
+
"publishConfig": {
|
|
66
|
+
"access": "public"
|
|
67
|
+
},
|
|
68
|
+
"engines": {
|
|
69
|
+
"node": ">=24.4.0"
|
|
70
|
+
},
|
|
71
|
+
"dependencies": {
|
|
72
|
+
"zod": "^4.3.5"
|
|
73
|
+
},
|
|
74
|
+
"keywords": [
|
|
75
|
+
"zod",
|
|
76
|
+
"sqlite",
|
|
77
|
+
"database",
|
|
78
|
+
"schema",
|
|
79
|
+
"validation",
|
|
80
|
+
"zod-to-sqlite"
|
|
81
|
+
]
|
|
82
|
+
}
|