@chkit/plugin-codegen 0.1.0-beta.10
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 +52 -0
- package/dist/errors.d.ts +9 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +17 -0
- package/dist/errors.js.map +1 -0
- package/dist/generators.d.ts +9 -0
- package/dist/generators.d.ts.map +1 -0
- package/dist/generators.js +384 -0
- package/dist/generators.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/naming.d.ts +6 -0
- package/dist/naming.d.ts.map +1 -0
- package/dist/naming.js +61 -0
- package/dist/naming.js.map +1 -0
- package/dist/options.d.ts +42 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/options.js +119 -0
- package/dist/options.js.map +1 -0
- package/dist/plugin.d.ts +4 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +243 -0
- package/dist/plugin.js.map +1 -0
- package/dist/types.d.ts +114 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +37 -0
package/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# @chkit/plugin-codegen
|
|
2
|
+
|
|
3
|
+
Plugin to generate TypeScript row types and optional Zod schemas from your chkit schema definitions.
|
|
4
|
+
|
|
5
|
+
Part of the [chkit](https://github.com/obsessiondb/chkit) monorepo. This plugin extends the [`chkit`](https://www.npmjs.com/package/chkit) CLI with TypeScript code generation.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
bun add -d @chkit/plugin-codegen
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
Register the plugin in your config:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
// clickhouse.config.ts
|
|
19
|
+
import { defineConfig } from '@chkit/core'
|
|
20
|
+
import { codegen } from '@chkit/plugin-codegen'
|
|
21
|
+
|
|
22
|
+
export default defineConfig({
|
|
23
|
+
schema: './src/db/schema/**/*.ts',
|
|
24
|
+
outDir: './chkit',
|
|
25
|
+
plugins: [
|
|
26
|
+
codegen({
|
|
27
|
+
outFile: './src/generated/chkit-types.ts',
|
|
28
|
+
emitZod: false,
|
|
29
|
+
emitIngest: false,
|
|
30
|
+
}),
|
|
31
|
+
],
|
|
32
|
+
clickhouse: {
|
|
33
|
+
url: process.env.CLICKHOUSE_URL ?? 'http://localhost:8123',
|
|
34
|
+
},
|
|
35
|
+
})
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Then run:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
bunx chkit codegen
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Codegen also runs automatically after `chkit generate` when `runOnGenerate` is enabled (default).
|
|
45
|
+
|
|
46
|
+
## Documentation
|
|
47
|
+
|
|
48
|
+
See the [chkit documentation](https://chkit.obsessiondb.com).
|
|
49
|
+
|
|
50
|
+
## License
|
|
51
|
+
|
|
52
|
+
[MIT](../../LICENSE)
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare class CodegenConfigError extends Error {
|
|
2
|
+
constructor(message: string);
|
|
3
|
+
}
|
|
4
|
+
export declare class UnsupportedTypeError extends Error {
|
|
5
|
+
readonly path: string;
|
|
6
|
+
readonly sourceType: string;
|
|
7
|
+
constructor(path: string, sourceType: string);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;gBAEf,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;CAQ7C"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export class CodegenConfigError extends Error {
|
|
2
|
+
constructor(message) {
|
|
3
|
+
super(message);
|
|
4
|
+
this.name = 'CodegenConfigError';
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export class UnsupportedTypeError extends Error {
|
|
8
|
+
path;
|
|
9
|
+
sourceType;
|
|
10
|
+
constructor(path, sourceType) {
|
|
11
|
+
super(`Unsupported column type "${sourceType}" at ${path}. Set failOnUnsupportedType=false to emit unknown.`);
|
|
12
|
+
this.name = 'UnsupportedTypeError';
|
|
13
|
+
this.path = path;
|
|
14
|
+
this.sourceType = sourceType;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAA;IAClC,CAAC;CACF;AAED,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IACpC,IAAI,CAAQ;IACZ,UAAU,CAAQ;IAE3B,YAAY,IAAY,EAAE,UAAkB;QAC1C,KAAK,CACH,4BAA4B,UAAU,QAAQ,IAAI,oDAAoD,CACvG,CAAA;QACD,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAA;QAClC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ColumnDefinition } from '@chkit/core';
|
|
2
|
+
import type { CodegenPluginOptions, GenerateIngestArtifactsInput, GenerateIngestArtifactsOutput, GenerateTypeArtifactsInput, GenerateTypeArtifactsOutput, MapColumnTypeResult } from './types.js';
|
|
3
|
+
export declare function mapColumnType(input: {
|
|
4
|
+
column: ColumnDefinition;
|
|
5
|
+
path: string;
|
|
6
|
+
}, options: Pick<Required<CodegenPluginOptions>, 'bigintMode' | 'failOnUnsupportedType'>): MapColumnTypeResult;
|
|
7
|
+
export declare function generateTypeArtifacts(input: GenerateTypeArtifactsInput): GenerateTypeArtifactsOutput;
|
|
8
|
+
export declare function generateIngestArtifacts(input: GenerateIngestArtifactsInput): GenerateIngestArtifactsOutput;
|
|
9
|
+
//# sourceMappingURL=generators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generators.d.ts","sourceRoot":"","sources":["../src/generators.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,gBAAgB,EAItB,MAAM,aAAa,CAAA;AAEpB,OAAO,KAAK,EAEV,oBAAoB,EACpB,4BAA4B,EAC5B,6BAA6B,EAC7B,0BAA0B,EAC1B,2BAA2B,EAC3B,mBAAmB,EACpB,MAAM,YAAY,CAAA;AA2LnB,wBAAgB,aAAa,CAC3B,KAAK,EAAE;IAAE,MAAM,EAAE,gBAAgB,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EACjD,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,YAAY,GAAG,uBAAuB,CAAC,GACpF,mBAAmB,CAyBrB;AA0DD,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,0BAA0B,GAChC,2BAA2B,CA2C7B;AA8CD,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,4BAA4B,GAClC,6BAA6B,CAkD/B"}
|
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
import { dirname, relative } from 'node:path';
|
|
2
|
+
import { canonicalizeDefinitions, } from '@chkit/core';
|
|
3
|
+
import { UnsupportedTypeError } from './errors.js';
|
|
4
|
+
import { normalizeCodegenOptions } from './options.js';
|
|
5
|
+
import { renderPropertyName, resolveTableNames } from './naming.js';
|
|
6
|
+
const LARGE_INTEGER_TYPES = new Set([
|
|
7
|
+
'Int64',
|
|
8
|
+
'UInt64',
|
|
9
|
+
'Int128',
|
|
10
|
+
'UInt128',
|
|
11
|
+
'Int256',
|
|
12
|
+
'UInt256',
|
|
13
|
+
]);
|
|
14
|
+
const NUMBER_TYPES = new Set([
|
|
15
|
+
'Int8',
|
|
16
|
+
'Int16',
|
|
17
|
+
'Int32',
|
|
18
|
+
'UInt8',
|
|
19
|
+
'UInt16',
|
|
20
|
+
'UInt32',
|
|
21
|
+
'Float32',
|
|
22
|
+
'Float64',
|
|
23
|
+
'BFloat16',
|
|
24
|
+
]);
|
|
25
|
+
const STRING_TYPES = new Set([
|
|
26
|
+
'String',
|
|
27
|
+
'FixedString',
|
|
28
|
+
'Date',
|
|
29
|
+
'Date32',
|
|
30
|
+
'DateTime',
|
|
31
|
+
'DateTime64',
|
|
32
|
+
'UUID',
|
|
33
|
+
'IPv4',
|
|
34
|
+
'IPv6',
|
|
35
|
+
'Enum',
|
|
36
|
+
'Enum8',
|
|
37
|
+
'Enum16',
|
|
38
|
+
'Decimal',
|
|
39
|
+
'Decimal32',
|
|
40
|
+
'Decimal64',
|
|
41
|
+
'Decimal128',
|
|
42
|
+
'Decimal256',
|
|
43
|
+
]);
|
|
44
|
+
const BOOLEAN_TYPES = new Set(['Bool', 'Boolean']);
|
|
45
|
+
function splitTopLevelArgs(input) {
|
|
46
|
+
const args = [];
|
|
47
|
+
let depth = 0;
|
|
48
|
+
let start = 0;
|
|
49
|
+
for (let i = 0; i < input.length; i++) {
|
|
50
|
+
const ch = input[i];
|
|
51
|
+
if (ch === '(')
|
|
52
|
+
depth++;
|
|
53
|
+
else if (ch === ')')
|
|
54
|
+
depth--;
|
|
55
|
+
else if (ch === ',' && depth === 0) {
|
|
56
|
+
args.push(input.slice(start, i).trim());
|
|
57
|
+
start = i + 1;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const last = input.slice(start).trim();
|
|
61
|
+
if (last.length > 0)
|
|
62
|
+
args.push(last);
|
|
63
|
+
return args;
|
|
64
|
+
}
|
|
65
|
+
function parseClickHouseType(typeStr) {
|
|
66
|
+
const trimmed = typeStr.trim();
|
|
67
|
+
const parenIndex = trimmed.indexOf('(');
|
|
68
|
+
if (parenIndex < 0)
|
|
69
|
+
return { base: trimmed, args: [] };
|
|
70
|
+
const base = trimmed.slice(0, parenIndex);
|
|
71
|
+
const closingParen = trimmed.lastIndexOf(')');
|
|
72
|
+
if (closingParen <= parenIndex)
|
|
73
|
+
return { base: trimmed, args: [] };
|
|
74
|
+
const inner = trimmed.slice(parenIndex + 1, closingParen);
|
|
75
|
+
if (inner.trim().length === 0)
|
|
76
|
+
return { base, args: [] };
|
|
77
|
+
return { base, args: splitTopLevelArgs(inner) };
|
|
78
|
+
}
|
|
79
|
+
function mapScalarType(base, bigintMode) {
|
|
80
|
+
if (STRING_TYPES.has(base))
|
|
81
|
+
return 'string';
|
|
82
|
+
if (BOOLEAN_TYPES.has(base))
|
|
83
|
+
return 'boolean';
|
|
84
|
+
if (NUMBER_TYPES.has(base))
|
|
85
|
+
return 'number';
|
|
86
|
+
if (LARGE_INTEGER_TYPES.has(base))
|
|
87
|
+
return bigintMode;
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
function scalarToZod(mapped) {
|
|
91
|
+
if (mapped === 'string')
|
|
92
|
+
return 'z.string()';
|
|
93
|
+
if (mapped === 'number')
|
|
94
|
+
return 'z.number()';
|
|
95
|
+
if (mapped === 'boolean')
|
|
96
|
+
return 'z.boolean()';
|
|
97
|
+
if (mapped === 'bigint')
|
|
98
|
+
return 'z.bigint()';
|
|
99
|
+
return 'z.unknown()';
|
|
100
|
+
}
|
|
101
|
+
function resolveInnerType(typeStr, bigintMode) {
|
|
102
|
+
const parsed = parseClickHouseType(typeStr);
|
|
103
|
+
const scalar = mapScalarType(parsed.base, bigintMode);
|
|
104
|
+
if (scalar)
|
|
105
|
+
return { tsType: scalar, zodType: scalarToZod(scalar) };
|
|
106
|
+
switch (parsed.base) {
|
|
107
|
+
case 'Nullable': {
|
|
108
|
+
const arg = parsed.args[0];
|
|
109
|
+
if (!arg)
|
|
110
|
+
return null;
|
|
111
|
+
const inner = resolveInnerType(arg, bigintMode);
|
|
112
|
+
if (!inner)
|
|
113
|
+
return null;
|
|
114
|
+
return { tsType: `${inner.tsType} | null`, zodType: `${inner.zodType}.nullable()` };
|
|
115
|
+
}
|
|
116
|
+
case 'LowCardinality': {
|
|
117
|
+
const arg = parsed.args[0];
|
|
118
|
+
if (!arg)
|
|
119
|
+
return null;
|
|
120
|
+
return resolveInnerType(arg, bigintMode);
|
|
121
|
+
}
|
|
122
|
+
case 'Array': {
|
|
123
|
+
const arg = parsed.args[0];
|
|
124
|
+
if (!arg)
|
|
125
|
+
return null;
|
|
126
|
+
const inner = resolveInnerType(arg, bigintMode);
|
|
127
|
+
if (!inner)
|
|
128
|
+
return null;
|
|
129
|
+
const needsWrap = inner.tsType.includes('|');
|
|
130
|
+
const tsType = needsWrap ? `(${inner.tsType})[]` : `${inner.tsType}[]`;
|
|
131
|
+
return { tsType, zodType: `z.array(${inner.zodType})` };
|
|
132
|
+
}
|
|
133
|
+
case 'Map': {
|
|
134
|
+
const keyArg = parsed.args[0];
|
|
135
|
+
const valueArg = parsed.args[1];
|
|
136
|
+
if (!keyArg || !valueArg)
|
|
137
|
+
return null;
|
|
138
|
+
const key = resolveInnerType(keyArg, bigintMode);
|
|
139
|
+
const value = resolveInnerType(valueArg, bigintMode);
|
|
140
|
+
if (!key || !value)
|
|
141
|
+
return null;
|
|
142
|
+
return {
|
|
143
|
+
tsType: `Record<${key.tsType}, ${value.tsType}>`,
|
|
144
|
+
zodType: `z.record(${key.zodType}, ${value.zodType})`,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
case 'Tuple': {
|
|
148
|
+
if (parsed.args.length === 0)
|
|
149
|
+
return null;
|
|
150
|
+
const elements = parsed.args.map((a) => resolveInnerType(a, bigintMode));
|
|
151
|
+
if (elements.some((e) => e === null))
|
|
152
|
+
return null;
|
|
153
|
+
const valid = elements;
|
|
154
|
+
return {
|
|
155
|
+
tsType: `[${valid.map((e) => e.tsType).join(', ')}]`,
|
|
156
|
+
zodType: `z.tuple([${valid.map((e) => e.zodType).join(', ')}])`,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
case 'SimpleAggregateFunction': {
|
|
160
|
+
const lastArg = parsed.args[parsed.args.length - 1];
|
|
161
|
+
if (parsed.args.length < 2 || !lastArg)
|
|
162
|
+
return null;
|
|
163
|
+
return resolveInnerType(lastArg, bigintMode);
|
|
164
|
+
}
|
|
165
|
+
case 'JSON': {
|
|
166
|
+
return { tsType: 'Record<string, unknown>', zodType: 'z.record(z.string(), z.unknown())' };
|
|
167
|
+
}
|
|
168
|
+
default:
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
function resolveColumnType(typeStr, bigintMode) {
|
|
173
|
+
const parsed = parseClickHouseType(typeStr);
|
|
174
|
+
const firstArg = parsed.args[0];
|
|
175
|
+
if (parsed.base === 'LowCardinality' && firstArg) {
|
|
176
|
+
return resolveColumnType(firstArg, bigintMode);
|
|
177
|
+
}
|
|
178
|
+
if (parsed.base === 'Nullable' && firstArg) {
|
|
179
|
+
const inner = resolveColumnType(firstArg, bigintMode);
|
|
180
|
+
if (!inner)
|
|
181
|
+
return null;
|
|
182
|
+
return { tsType: inner.tsType, zodType: inner.zodType, nullable: true };
|
|
183
|
+
}
|
|
184
|
+
const resolved = resolveInnerType(typeStr, bigintMode);
|
|
185
|
+
if (!resolved)
|
|
186
|
+
return null;
|
|
187
|
+
return { tsType: resolved.tsType, zodType: resolved.zodType, nullable: false };
|
|
188
|
+
}
|
|
189
|
+
export function mapColumnType(input, options) {
|
|
190
|
+
const resolved = resolveColumnType(input.column.type, options.bigintMode);
|
|
191
|
+
const columnNullable = input.column.nullable === true;
|
|
192
|
+
if (!resolved) {
|
|
193
|
+
if (options.failOnUnsupportedType) {
|
|
194
|
+
throw new UnsupportedTypeError(input.path, input.column.type);
|
|
195
|
+
}
|
|
196
|
+
const unknownType = columnNullable ? 'unknown | null' : 'unknown';
|
|
197
|
+
return {
|
|
198
|
+
tsType: unknownType,
|
|
199
|
+
zodType: 'z.unknown()',
|
|
200
|
+
nullable: columnNullable,
|
|
201
|
+
finding: {
|
|
202
|
+
code: 'codegen_unsupported_type',
|
|
203
|
+
message: `Unsupported type "${input.column.type}" at ${input.path}; emitted unknown.`,
|
|
204
|
+
severity: 'warn',
|
|
205
|
+
path: input.path,
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
const nullable = columnNullable || resolved.nullable;
|
|
210
|
+
const tsType = nullable ? `${resolved.tsType} | null` : resolved.tsType;
|
|
211
|
+
return { tsType, zodType: resolved.zodType, nullable };
|
|
212
|
+
}
|
|
213
|
+
function renderHeader(toolVersion) {
|
|
214
|
+
const lines = [
|
|
215
|
+
'// This file is auto-generated by chkit codegen — do not edit manually.',
|
|
216
|
+
];
|
|
217
|
+
lines.push(`// chkit-codegen-version: ${toolVersion}`);
|
|
218
|
+
return lines;
|
|
219
|
+
}
|
|
220
|
+
function renderTableInterface(table, interfaceName, options) {
|
|
221
|
+
const lines = [`export interface ${interfaceName} {`];
|
|
222
|
+
const findings = [];
|
|
223
|
+
const zodFields = [];
|
|
224
|
+
for (const column of table.columns) {
|
|
225
|
+
const path = `${table.database}.${table.name}.${column.name}`;
|
|
226
|
+
const mapped = mapColumnType({ column, path }, options);
|
|
227
|
+
if (mapped.finding)
|
|
228
|
+
findings.push(mapped.finding);
|
|
229
|
+
lines.push(` ${renderPropertyName(column.name)}: ${mapped.tsType}`);
|
|
230
|
+
const zodExpr = mapped.nullable ? `${mapped.zodType}.nullable()` : mapped.zodType;
|
|
231
|
+
zodFields.push(` ${renderPropertyName(column.name)}: ${zodExpr},`);
|
|
232
|
+
}
|
|
233
|
+
lines.push('}');
|
|
234
|
+
if (options.emitZod) {
|
|
235
|
+
lines.push('');
|
|
236
|
+
lines.push(`export const ${interfaceName}Schema = z.object({`);
|
|
237
|
+
lines.push(...zodFields);
|
|
238
|
+
lines.push('})');
|
|
239
|
+
lines.push('');
|
|
240
|
+
lines.push(`export type ${interfaceName}Input = z.input<typeof ${interfaceName}Schema>`);
|
|
241
|
+
lines.push(`export type ${interfaceName}Output = z.output<typeof ${interfaceName}Schema>`);
|
|
242
|
+
}
|
|
243
|
+
return { lines, findings };
|
|
244
|
+
}
|
|
245
|
+
function renderViewInterface(definition, interfaceName) {
|
|
246
|
+
const kind = definition.kind === 'view' ? 'view' : 'materialized_view';
|
|
247
|
+
return {
|
|
248
|
+
lines: [
|
|
249
|
+
`export interface ${interfaceName} {`,
|
|
250
|
+
' [key: string]: unknown',
|
|
251
|
+
'}',
|
|
252
|
+
'',
|
|
253
|
+
`// ${kind} ${definition.database}.${definition.name} is emitted as unknown-key row shape in v1.`,
|
|
254
|
+
],
|
|
255
|
+
findings: [],
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
export function generateTypeArtifacts(input) {
|
|
259
|
+
const normalized = normalizeCodegenOptions(input.options);
|
|
260
|
+
const definitions = canonicalizeDefinitions(input.definitions);
|
|
261
|
+
const sortedDefinitions = definitions
|
|
262
|
+
.filter((definition) => {
|
|
263
|
+
if (definition.kind === 'table')
|
|
264
|
+
return true;
|
|
265
|
+
if (!normalized.includeViews)
|
|
266
|
+
return false;
|
|
267
|
+
return definition.kind === 'view' || definition.kind === 'materialized_view';
|
|
268
|
+
})
|
|
269
|
+
.sort((a, b) => {
|
|
270
|
+
if (a.database !== b.database)
|
|
271
|
+
return a.database.localeCompare(b.database);
|
|
272
|
+
return a.name.localeCompare(b.name);
|
|
273
|
+
});
|
|
274
|
+
const resolved = resolveTableNames(sortedDefinitions, normalized.tableNameStyle);
|
|
275
|
+
const findings = [];
|
|
276
|
+
const bodyLines = [];
|
|
277
|
+
for (const entry of resolved) {
|
|
278
|
+
const rendered = entry.definition.kind === 'table'
|
|
279
|
+
? renderTableInterface(entry.definition, entry.interfaceName, normalized)
|
|
280
|
+
: renderViewInterface(entry.definition, entry.interfaceName);
|
|
281
|
+
findings.push(...rendered.findings);
|
|
282
|
+
bodyLines.push(...rendered.lines);
|
|
283
|
+
bodyLines.push('');
|
|
284
|
+
}
|
|
285
|
+
const header = renderHeader(input.toolVersion ?? '0.1.0');
|
|
286
|
+
const lines = [
|
|
287
|
+
...header,
|
|
288
|
+
...(normalized.emitZod ? ['', "import { z } from 'zod'"] : []),
|
|
289
|
+
'',
|
|
290
|
+
...bodyLines,
|
|
291
|
+
];
|
|
292
|
+
const content = `${lines.join('\n').trimEnd()}\n`;
|
|
293
|
+
return {
|
|
294
|
+
content,
|
|
295
|
+
outFile: normalized.outFile,
|
|
296
|
+
declarationCount: resolved.length,
|
|
297
|
+
findings,
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
function computeRelativeImportPath(fromFile, toFile) {
|
|
301
|
+
const fromDir = dirname(fromFile);
|
|
302
|
+
let rel = relative(fromDir, toFile);
|
|
303
|
+
if (!rel.startsWith('.'))
|
|
304
|
+
rel = `./${rel}`;
|
|
305
|
+
// Replace .ts extension with .js for ESM imports
|
|
306
|
+
return rel.replace(/\.ts$/, '.js');
|
|
307
|
+
}
|
|
308
|
+
function stripRowSuffix(name) {
|
|
309
|
+
if (name.endsWith('Row'))
|
|
310
|
+
return name.slice(0, -3);
|
|
311
|
+
if (name.endsWith('_row'))
|
|
312
|
+
return name.slice(0, -4);
|
|
313
|
+
return name;
|
|
314
|
+
}
|
|
315
|
+
function renderIngestFunction(table, interfaceName, emitZod) {
|
|
316
|
+
const funcName = `ingest${stripRowSuffix(interfaceName)}`;
|
|
317
|
+
const tableFqn = `${table.database}.${table.name}`;
|
|
318
|
+
const lines = [];
|
|
319
|
+
if (emitZod) {
|
|
320
|
+
lines.push(`export async function ${funcName}(`);
|
|
321
|
+
lines.push(` ingestor: Ingestor,`);
|
|
322
|
+
lines.push(` rows: ${interfaceName}[],`);
|
|
323
|
+
lines.push(` options?: { validate?: boolean }`);
|
|
324
|
+
lines.push(`): Promise<void> {`);
|
|
325
|
+
lines.push(` const data = options?.validate ? rows.map(row => ${interfaceName}Schema.parse(row)) : rows`);
|
|
326
|
+
lines.push(` await ingestor.insert({ table: '${tableFqn}', values: data })`);
|
|
327
|
+
lines.push(`}`);
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
330
|
+
lines.push(`export async function ${funcName}(`);
|
|
331
|
+
lines.push(` ingestor: Ingestor,`);
|
|
332
|
+
lines.push(` rows: ${interfaceName}[]`);
|
|
333
|
+
lines.push(`): Promise<void> {`);
|
|
334
|
+
lines.push(` await ingestor.insert({ table: '${tableFqn}', values: rows })`);
|
|
335
|
+
lines.push(`}`);
|
|
336
|
+
}
|
|
337
|
+
return lines;
|
|
338
|
+
}
|
|
339
|
+
export function generateIngestArtifacts(input) {
|
|
340
|
+
const normalized = normalizeCodegenOptions(input.options);
|
|
341
|
+
const definitions = canonicalizeDefinitions(input.definitions);
|
|
342
|
+
const tables = definitions
|
|
343
|
+
.filter((definition) => definition.kind === 'table')
|
|
344
|
+
.sort((a, b) => {
|
|
345
|
+
if (a.database !== b.database)
|
|
346
|
+
return a.database.localeCompare(b.database);
|
|
347
|
+
return a.name.localeCompare(b.name);
|
|
348
|
+
});
|
|
349
|
+
const resolved = resolveTableNames(tables, normalized.tableNameStyle);
|
|
350
|
+
const importPath = computeRelativeImportPath(normalized.ingestOutFile, normalized.outFile);
|
|
351
|
+
const typeImports = [];
|
|
352
|
+
const valueImports = [];
|
|
353
|
+
for (const entry of resolved) {
|
|
354
|
+
typeImports.push(entry.interfaceName);
|
|
355
|
+
if (normalized.emitZod) {
|
|
356
|
+
valueImports.push(`${entry.interfaceName}Schema`);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
const header = renderHeader(input.toolVersion ?? '0.1.0');
|
|
360
|
+
const lines = [...header, ''];
|
|
361
|
+
if (typeImports.length > 0) {
|
|
362
|
+
lines.push(`import type { ${typeImports.join(', ')} } from '${importPath}'`);
|
|
363
|
+
}
|
|
364
|
+
if (valueImports.length > 0) {
|
|
365
|
+
lines.push(`import { ${valueImports.join(', ')} } from '${importPath}'`);
|
|
366
|
+
}
|
|
367
|
+
lines.push('');
|
|
368
|
+
lines.push('export interface Ingestor {');
|
|
369
|
+
lines.push(' insert(params: { table: string; values: Record<string, unknown>[] }): Promise<void>');
|
|
370
|
+
lines.push('}');
|
|
371
|
+
for (const entry of resolved) {
|
|
372
|
+
if (entry.definition.kind !== 'table')
|
|
373
|
+
continue;
|
|
374
|
+
lines.push('');
|
|
375
|
+
lines.push(...renderIngestFunction(entry.definition, entry.interfaceName, normalized.emitZod));
|
|
376
|
+
}
|
|
377
|
+
const content = `${lines.join('\n').trimEnd()}\n`;
|
|
378
|
+
return {
|
|
379
|
+
content,
|
|
380
|
+
outFile: normalized.ingestOutFile,
|
|
381
|
+
functionCount: resolved.length,
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
//# sourceMappingURL=generators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generators.js","sourceRoot":"","sources":["../src/generators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAE7C,OAAO,EACL,uBAAuB,GAKxB,MAAM,aAAa,CAAA;AAWpB,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AACtD,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAEnE,MAAM,mBAAmB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E,CAAC,CAAA;QACd,KAAK,CAAC,IAAI,CAAC,GAAG,oBAAoB,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,aAAa,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAA;IAChG,CAAC;IAED,MAAM,OAAO,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,IAAI,CAAA;IAEjD,OAAO;QACL,OAAO;QACP,OAAO,EAAE,UAAU,CAAC,aAAa;QACjC,aAAa,EAAE,QAAQ,CAAC,MAAM;KAC/B,CAAA;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { createCodegenPlugin, codegen } from './plugin.js';
|
|
2
|
+
export { normalizeCodegenOptions, isRunOnGenerateEnabled } from './options.js';
|
|
3
|
+
export { mapColumnType, generateTypeArtifacts, generateIngestArtifacts } from './generators.js';
|
|
4
|
+
export type { CodegenPluginOptions, CodegenPluginCommandContext, CodegenPlugin, CodegenFinding, MapColumnTypeResult, GenerateTypeArtifactsInput, GenerateTypeArtifactsOutput, GenerateIngestArtifactsInput, GenerateIngestArtifactsOutput, CodegenPluginCheckContext, CodegenPluginRegistration, CodegenPluginCheckResult, } from './types.js';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAA;AAC9E,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAA;AAC/F,YAAY,EACV,oBAAoB,EACpB,2BAA2B,EAC3B,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,0BAA0B,EAC1B,2BAA2B,EAC3B,4BAA4B,EAC5B,6BAA6B,EAC7B,yBAAyB,EACzB,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,YAAY,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { createCodegenPlugin, codegen } from './plugin.js';
|
|
2
|
+
export { normalizeCodegenOptions, isRunOnGenerateEnabled } from './options.js';
|
|
3
|
+
export { mapColumnType, generateTypeArtifacts, generateIngestArtifacts } from './generators.js';
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAA;AAC9E,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAA"}
|
package/dist/naming.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { MaterializedViewDefinition, TableDefinition, ViewDefinition } from '@chkit/core';
|
|
2
|
+
import type { CodegenPluginOptions, ResolvedTableName } from './types.js';
|
|
3
|
+
export declare function isValidIdentifier(input: string): boolean;
|
|
4
|
+
export declare function renderPropertyName(name: string): string;
|
|
5
|
+
export declare function resolveTableNames(definitions: Array<TableDefinition | ViewDefinition | MaterializedViewDefinition>, style: Required<CodegenPluginOptions>['tableNameStyle']): ResolvedTableName[];
|
|
6
|
+
//# sourceMappingURL=naming.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"naming.d.ts","sourceRoot":"","sources":["../src/naming.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE9F,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AA6BzE,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAExD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGvD;AAiBD,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,KAAK,CAAC,eAAe,GAAG,cAAc,GAAG,0BAA0B,CAAC,EACjF,KAAK,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAAC,gBAAgB,CAAC,GACtD,iBAAiB,EAAE,CAgBrB"}
|
package/dist/naming.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
function toWords(input) {
|
|
2
|
+
return input
|
|
3
|
+
.split(/[^a-zA-Z0-9]+/)
|
|
4
|
+
.map((part) => part.trim())
|
|
5
|
+
.filter((part) => part.length > 0);
|
|
6
|
+
}
|
|
7
|
+
function pascalCase(input) {
|
|
8
|
+
const words = toWords(input);
|
|
9
|
+
if (words.length === 0)
|
|
10
|
+
return 'Item';
|
|
11
|
+
return words.map((part) => part[0]?.toUpperCase() + part.slice(1)).join('');
|
|
12
|
+
}
|
|
13
|
+
function camelCase(input) {
|
|
14
|
+
const words = toWords(input);
|
|
15
|
+
if (words.length === 0)
|
|
16
|
+
return 'item';
|
|
17
|
+
const [head, ...tail] = words;
|
|
18
|
+
return `${head?.toLowerCase() ?? 'item'}${tail
|
|
19
|
+
.map((part) => part[0]?.toUpperCase() + part.slice(1))
|
|
20
|
+
.join('')}`;
|
|
21
|
+
}
|
|
22
|
+
function rawCase(input) {
|
|
23
|
+
const sanitized = input.replace(/[^a-zA-Z0-9_]/g, '_').replace(/_+/g, '_').replace(/^_+|_+$/g, '');
|
|
24
|
+
return sanitized.length > 0 ? sanitized : 'item';
|
|
25
|
+
}
|
|
26
|
+
export function isValidIdentifier(input) {
|
|
27
|
+
return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(input);
|
|
28
|
+
}
|
|
29
|
+
export function renderPropertyName(name) {
|
|
30
|
+
if (isValidIdentifier(name))
|
|
31
|
+
return name;
|
|
32
|
+
return JSON.stringify(name);
|
|
33
|
+
}
|
|
34
|
+
function baseRowTypeName(definition, style) {
|
|
35
|
+
const combined = `${definition.database}_${definition.name}`;
|
|
36
|
+
if (style === 'raw') {
|
|
37
|
+
const candidate = `${rawCase(combined)}_row`;
|
|
38
|
+
return isValidIdentifier(candidate) ? candidate : `_${candidate}`;
|
|
39
|
+
}
|
|
40
|
+
if (style === 'camel') {
|
|
41
|
+
return `${camelCase(combined)}Row`;
|
|
42
|
+
}
|
|
43
|
+
return `${pascalCase(combined)}Row`;
|
|
44
|
+
}
|
|
45
|
+
export function resolveTableNames(definitions, style) {
|
|
46
|
+
const baseNames = definitions.map((definition) => ({
|
|
47
|
+
definition,
|
|
48
|
+
base: baseRowTypeName(definition, style),
|
|
49
|
+
}));
|
|
50
|
+
const counts = new Map();
|
|
51
|
+
return baseNames.map((item) => {
|
|
52
|
+
const seen = counts.get(item.base) ?? 0;
|
|
53
|
+
const nextSeen = seen + 1;
|
|
54
|
+
counts.set(item.base, nextSeen);
|
|
55
|
+
return {
|
|
56
|
+
definition: item.definition,
|
|
57
|
+
interfaceName: nextSeen === 1 ? item.base : `${item.base}_${nextSeen}`,
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=naming.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"naming.js","sourceRoot":"","sources":["../src/naming.ts"],"names":[],"mappings":"AAIA,SAAS,OAAO,CAAC,KAAa;IAC5B,OAAO,KAAK;SACT,KAAK,CAAC,eAAe,CAAC;SACtB,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;SAC1B,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;AACtC,CAAC;A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,IAAI,EAAE,QAAQ,CAAC,CAAA;QAC/B,OAAO;YACL,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,aAAa,EAAE,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,IAAI,QAAQ,EAAE;SACvE,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type ParsedFlags } from '@chkit/core';
|
|
2
|
+
import type { CodegenPluginOptions, FlagOverrides } from './types.js';
|
|
3
|
+
export declare function normalizeRuntimeOptions(options: Record<string, unknown>): CodegenPluginOptions;
|
|
4
|
+
export declare function normalizeCodegenOptions(options?: CodegenPluginOptions): Required<CodegenPluginOptions>;
|
|
5
|
+
export declare const CODEGEN_FLAGS: readonly [{
|
|
6
|
+
readonly name: "--check";
|
|
7
|
+
readonly type: "boolean";
|
|
8
|
+
readonly description: "Check if generated output is up-to-date";
|
|
9
|
+
}, {
|
|
10
|
+
readonly name: "--out-file";
|
|
11
|
+
readonly type: "string";
|
|
12
|
+
readonly description: "Output file path";
|
|
13
|
+
readonly placeholder: "<path>";
|
|
14
|
+
}, {
|
|
15
|
+
readonly name: "--emit-zod";
|
|
16
|
+
readonly type: "boolean";
|
|
17
|
+
readonly description: "Emit Zod schemas alongside TypeScript types";
|
|
18
|
+
readonly negation: true;
|
|
19
|
+
}, {
|
|
20
|
+
readonly name: "--emit-ingest";
|
|
21
|
+
readonly type: "boolean";
|
|
22
|
+
readonly description: "Emit ingest helper functions";
|
|
23
|
+
readonly negation: true;
|
|
24
|
+
}, {
|
|
25
|
+
readonly name: "--ingest-out-file";
|
|
26
|
+
readonly type: "string";
|
|
27
|
+
readonly description: "Ingest output file path";
|
|
28
|
+
readonly placeholder: "<path>";
|
|
29
|
+
}, {
|
|
30
|
+
readonly name: "--bigint-mode";
|
|
31
|
+
readonly type: "string";
|
|
32
|
+
readonly description: "How to represent large integers (string or bigint)";
|
|
33
|
+
readonly placeholder: "<mode>";
|
|
34
|
+
}, {
|
|
35
|
+
readonly name: "--include-views";
|
|
36
|
+
readonly type: "boolean";
|
|
37
|
+
readonly description: "Include views in generated output";
|
|
38
|
+
}];
|
|
39
|
+
export declare function flagsToOverrides(flags: ParsedFlags): FlagOverrides;
|
|
40
|
+
export declare function mergeOptions(baseOptions: Required<CodegenPluginOptions>, runtimeOptions: Record<string, unknown>, overrides: FlagOverrides): Required<CodegenPluginOptions>;
|
|
41
|
+
export declare function isRunOnGenerateEnabled(baseOptions: Required<CodegenPluginOptions>, runtimeOptions: Record<string, unknown>): boolean;
|
|
42
|
+
//# sourceMappingURL=options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAEvE,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAmCrE,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,oBAAoB,CAwC9F;AAED,wBAAgB,uBAAuB,CAAC,OAAO,GAAE,oBAAyB,GAAG,QAAQ,CAAC,oBAAoB,CAAC,CAK1G;AAED,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQf,CAAA;AAEX,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,GAAG,aAAa,CAgBlE;AAED,wBAAgB,YAAY,CAC1B,WAAW,EAAE,QAAQ,CAAC,oBAAoB,CAAC,EAC3C,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvC,SAAS,EAAE,aAAa,GACvB,QAAQ,CAAC,oBAAoB,CAAC,CAahC;AAED,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,QAAQ,CAAC,oBAAoB,CAAC,EAC3C,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACtC,OAAO,CAIT"}
|
package/dist/options.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { defineFlags, typedFlags } from '@chkit/core';
|
|
2
|
+
import { CodegenConfigError } from './errors.js';
|
|
3
|
+
const DEFAULT_OPTIONS = {
|
|
4
|
+
outFile: './src/generated/chkit-types.ts',
|
|
5
|
+
emitZod: false,
|
|
6
|
+
tableNameStyle: 'pascal',
|
|
7
|
+
bigintMode: 'string',
|
|
8
|
+
includeViews: false,
|
|
9
|
+
runOnGenerate: true,
|
|
10
|
+
failOnUnsupportedType: true,
|
|
11
|
+
emitIngest: false,
|
|
12
|
+
ingestOutFile: './src/generated/chkit-ingest.ts',
|
|
13
|
+
};
|
|
14
|
+
function parseBooleanOption(options, key) {
|
|
15
|
+
const value = options[key];
|
|
16
|
+
if (value === undefined)
|
|
17
|
+
return undefined;
|
|
18
|
+
if (typeof value === 'boolean')
|
|
19
|
+
return value;
|
|
20
|
+
throw new CodegenConfigError(`Invalid plugin option "${key}". Expected boolean.`);
|
|
21
|
+
}
|
|
22
|
+
function parseStringOption(options, key) {
|
|
23
|
+
const value = options[key];
|
|
24
|
+
if (value === undefined)
|
|
25
|
+
return undefined;
|
|
26
|
+
if (typeof value === 'string' && value.length > 0)
|
|
27
|
+
return value;
|
|
28
|
+
throw new CodegenConfigError(`Invalid plugin option "${key}". Expected non-empty string.`);
|
|
29
|
+
}
|
|
30
|
+
export function normalizeRuntimeOptions(options) {
|
|
31
|
+
const rawTableNameStyle = options.tableNameStyle;
|
|
32
|
+
if (rawTableNameStyle !== undefined &&
|
|
33
|
+
rawTableNameStyle !== 'pascal' &&
|
|
34
|
+
rawTableNameStyle !== 'camel' &&
|
|
35
|
+
rawTableNameStyle !== 'raw') {
|
|
36
|
+
throw new CodegenConfigError('Invalid plugin option "tableNameStyle". Expected one of: pascal, camel, raw.');
|
|
37
|
+
}
|
|
38
|
+
const rawBigintMode = options.bigintMode;
|
|
39
|
+
if (rawBigintMode !== undefined && rawBigintMode !== 'string' && rawBigintMode !== 'bigint') {
|
|
40
|
+
throw new CodegenConfigError('Invalid plugin option "bigintMode". Expected one of: string, bigint.');
|
|
41
|
+
}
|
|
42
|
+
const normalized = {};
|
|
43
|
+
const outFile = parseStringOption(options, 'outFile');
|
|
44
|
+
const emitZod = parseBooleanOption(options, 'emitZod');
|
|
45
|
+
const includeViews = parseBooleanOption(options, 'includeViews');
|
|
46
|
+
const runOnGenerate = parseBooleanOption(options, 'runOnGenerate');
|
|
47
|
+
const failOnUnsupportedType = parseBooleanOption(options, 'failOnUnsupportedType');
|
|
48
|
+
const emitIngest = parseBooleanOption(options, 'emitIngest');
|
|
49
|
+
const ingestOutFile = parseStringOption(options, 'ingestOutFile');
|
|
50
|
+
if (outFile !== undefined)
|
|
51
|
+
normalized.outFile = outFile;
|
|
52
|
+
if (emitZod !== undefined)
|
|
53
|
+
normalized.emitZod = emitZod;
|
|
54
|
+
if (rawTableNameStyle !== undefined)
|
|
55
|
+
normalized.tableNameStyle = rawTableNameStyle;
|
|
56
|
+
if (rawBigintMode !== undefined)
|
|
57
|
+
normalized.bigintMode = rawBigintMode;
|
|
58
|
+
if (includeViews !== undefined)
|
|
59
|
+
normalized.includeViews = includeViews;
|
|
60
|
+
if (runOnGenerate !== undefined)
|
|
61
|
+
normalized.runOnGenerate = runOnGenerate;
|
|
62
|
+
if (failOnUnsupportedType !== undefined)
|
|
63
|
+
normalized.failOnUnsupportedType = failOnUnsupportedType;
|
|
64
|
+
if (emitIngest !== undefined)
|
|
65
|
+
normalized.emitIngest = emitIngest;
|
|
66
|
+
if (ingestOutFile !== undefined)
|
|
67
|
+
normalized.ingestOutFile = ingestOutFile;
|
|
68
|
+
return normalized;
|
|
69
|
+
}
|
|
70
|
+
export function normalizeCodegenOptions(options = {}) {
|
|
71
|
+
return {
|
|
72
|
+
...DEFAULT_OPTIONS,
|
|
73
|
+
...options,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export const CODEGEN_FLAGS = defineFlags([
|
|
77
|
+
{ name: '--check', type: 'boolean', description: 'Check if generated output is up-to-date' },
|
|
78
|
+
{ name: '--out-file', type: 'string', description: 'Output file path', placeholder: '<path>' },
|
|
79
|
+
{ name: '--emit-zod', type: 'boolean', description: 'Emit Zod schemas alongside TypeScript types', negation: true },
|
|
80
|
+
{ name: '--emit-ingest', type: 'boolean', description: 'Emit ingest helper functions', negation: true },
|
|
81
|
+
{ name: '--ingest-out-file', type: 'string', description: 'Ingest output file path', placeholder: '<path>' },
|
|
82
|
+
{ name: '--bigint-mode', type: 'string', description: 'How to represent large integers (string or bigint)', placeholder: '<mode>' },
|
|
83
|
+
{ name: '--include-views', type: 'boolean', description: 'Include views in generated output' },
|
|
84
|
+
]);
|
|
85
|
+
export function flagsToOverrides(flags) {
|
|
86
|
+
const f = typedFlags(flags, CODEGEN_FLAGS);
|
|
87
|
+
const rawBigintMode = f['--bigint-mode'];
|
|
88
|
+
if (rawBigintMode !== undefined && rawBigintMode !== 'string' && rawBigintMode !== 'bigint') {
|
|
89
|
+
throw new CodegenConfigError('Invalid value for --bigint-mode. Expected string or bigint.');
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
check: f['--check'] === true,
|
|
93
|
+
outFile: f['--out-file'],
|
|
94
|
+
emitZod: f['--emit-zod'],
|
|
95
|
+
includeViews: f['--include-views'],
|
|
96
|
+
emitIngest: f['--emit-ingest'],
|
|
97
|
+
ingestOutFile: f['--ingest-out-file'],
|
|
98
|
+
bigintMode: rawBigintMode,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export function mergeOptions(baseOptions, runtimeOptions, overrides) {
|
|
102
|
+
const fromRuntime = normalizeRuntimeOptions(runtimeOptions);
|
|
103
|
+
const withRuntime = normalizeCodegenOptions({ ...baseOptions, ...fromRuntime });
|
|
104
|
+
return normalizeCodegenOptions({
|
|
105
|
+
...withRuntime,
|
|
106
|
+
outFile: overrides.outFile ?? withRuntime.outFile,
|
|
107
|
+
emitZod: overrides.emitZod ?? withRuntime.emitZod,
|
|
108
|
+
bigintMode: overrides.bigintMode ?? withRuntime.bigintMode,
|
|
109
|
+
includeViews: overrides.includeViews ?? withRuntime.includeViews,
|
|
110
|
+
emitIngest: overrides.emitIngest ?? withRuntime.emitIngest,
|
|
111
|
+
ingestOutFile: overrides.ingestOutFile ?? withRuntime.ingestOutFile,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
export function isRunOnGenerateEnabled(baseOptions, runtimeOptions) {
|
|
115
|
+
const fromRuntime = normalizeRuntimeOptions(runtimeOptions);
|
|
116
|
+
const effective = normalizeCodegenOptions({ ...baseOptions, ...fromRuntime });
|
|
117
|
+
return effective.runOnGenerate;
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAoB,MAAM,aAAa,CAAA;AAGvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAEhD,MAAM,eAAe,GAAmC;IACtD,OAAO,EAAE,gCAAgC;IACzC,OAAO,EAAE,KAAK;IACd,cAAc,EAAE,QAAQ;IACxB,UAAU,EAAE,QAAQ;IACpB,YAAY,EAAE,KAAK;IACnB,aAAa,EAAE,IAAI;IACnB,qBAAqB,EAAE,IAAI;IAC3B,UAAU,EAAE,KAAK;IACjB,aAAa,EAAE,iCAAiC;CACjD,CAAA;AAED,SAAS,kBAAkB,CACzB,OAAgC,EAChC,GAA+B;IAE/B,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;IAC1B,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IACzC,IAAI,OAAO,KAAK,KAAK,SAAS;QAAE,O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AC1B,CAAA;AACH,CAAC;AAED,MAAM,UAAU,YAAY,CAC1B,WAA2C,EAC3C,cAAuC,EACvC,SAAwB;IAExB,MAAM,WAAW,GAAG,uBAAuB,CAAC,cAAc,CAAC,CAAA;IAC3D,MAAM,WAAW,GAAG,uBAAuB,CAAC,EAAE,GAAG,WAAW,EAAE,GAAG,WAAW,EAAE,CAAC,CAAA;IAE/E,OAAO,uBAAuB,CAAC;QAC7B,GAAG,WAAW;QACd,OAAO,EAAE,SAAS,CAAC,OAAO,IAAI,WAAW,CAAC,OAAO;QACjD,OAAO,EAAE,SAAS,CAAC,OAAO,IAAI,WAAW,CAAC,OAAO;QACjD,UAAU,EAAE,SAAS,CAAC,UAAU,IAAI,WAAW,CAAC,UAAU;QAC1D,YAAY,EAAE,SAAS,CAAC,YAAY,IAAI,WAAW,CAAC,YAAY;QAChE,UAAU,EAAE,SAAS,CAAC,UAAU,IAAI,WAAW,CAAC,UAAU;QAC1D,aAAa,EAAE,SAAS,CAAC,aAAa,IAAI,WAAW,CAAC,aAAa;KACpE,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,WAA2C,EAC3C,cAAuC;IAEvC,MAAM,WAAW,GAAG,uBAAuB,CAAC,cAAc,CAAC,CAAA;IAC3D,MAAM,SAAS,GAAG,uBAAuB,CAAC,EAAE,GAAG,WAAW,EAAE,GAAG,WAAW,EAAE,CAAC,CAAA;IAC7E,OAAO,SAAS,CAAC,aAAa,CAAA;AAChC,CAAC"}
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CodegenPlugin, CodegenPluginOptions, CodegenPluginRegistration } from './types.js';
|
|
2
|
+
export declare function createCodegenPlugin(options?: CodegenPluginOptions): CodegenPlugin;
|
|
3
|
+
export declare function codegen(options?: CodegenPluginOptions): CodegenPluginRegistration;
|
|
4
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,aAAa,EAEb,oBAAoB,EACpB,yBAAyB,EAE1B,MAAM,YAAY,CAAA;AAyFnB,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,oBAAyB,GAAG,aAAa,CA8KrF;AAED,wBAAgB,OAAO,CAAC,OAAO,GAAE,oBAAyB,GAAG,yBAAyB,CAOrF"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { mkdir, readFile, rename, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { dirname, join, resolve } from 'node:path';
|
|
3
|
+
import { loadSchemaDefinitions, wrapPluginRun } from '@chkit/core';
|
|
4
|
+
import { CodegenConfigError } from './errors.js';
|
|
5
|
+
import { CODEGEN_FLAGS, flagsToOverrides, mergeOptions, normalizeCodegenOptions, normalizeRuntimeOptions } from './options.js';
|
|
6
|
+
import { generateIngestArtifacts, generateTypeArtifacts } from './generators.js';
|
|
7
|
+
async function writeAtomic(targetPath, content) {
|
|
8
|
+
await mkdir(dirname(targetPath), { recursive: true });
|
|
9
|
+
const tempPath = join(dirname(targetPath), `.${Date.now()}-${Math.random().toString(16).slice(2)}.tmp`);
|
|
10
|
+
await writeFile(tempPath, content, 'utf8');
|
|
11
|
+
await rename(tempPath, targetPath);
|
|
12
|
+
}
|
|
13
|
+
async function readMaybe(path) {
|
|
14
|
+
try {
|
|
15
|
+
return await readFile(path, 'utf8');
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function checkGeneratedOutput(input) {
|
|
22
|
+
if (input.current === null) {
|
|
23
|
+
return {
|
|
24
|
+
plugin: 'codegen',
|
|
25
|
+
evaluated: true,
|
|
26
|
+
ok: false,
|
|
27
|
+
findings: [
|
|
28
|
+
{
|
|
29
|
+
code: input.missingCode,
|
|
30
|
+
message: `${input.label} output file is missing: ${input.outFile}`,
|
|
31
|
+
severity: 'error',
|
|
32
|
+
metadata: { outFile: input.outFile },
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
metadata: {
|
|
36
|
+
outFile: input.outFile,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
if (input.current !== input.expected) {
|
|
41
|
+
return {
|
|
42
|
+
plugin: 'codegen',
|
|
43
|
+
evaluated: true,
|
|
44
|
+
ok: false,
|
|
45
|
+
findings: [
|
|
46
|
+
{
|
|
47
|
+
code: input.staleCode,
|
|
48
|
+
message: `${input.label} output is stale: ${input.outFile}`,
|
|
49
|
+
severity: 'error',
|
|
50
|
+
metadata: { outFile: input.outFile },
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
metadata: {
|
|
54
|
+
outFile: input.outFile,
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
plugin: 'codegen',
|
|
60
|
+
evaluated: true,
|
|
61
|
+
ok: true,
|
|
62
|
+
findings: [],
|
|
63
|
+
metadata: {
|
|
64
|
+
outFile: input.outFile,
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function mergeCheckResults(results) {
|
|
69
|
+
const allFindings = results.flatMap((r) => r.findings);
|
|
70
|
+
const allOk = results.every((r) => r.ok);
|
|
71
|
+
return {
|
|
72
|
+
plugin: 'codegen',
|
|
73
|
+
evaluated: true,
|
|
74
|
+
ok: allOk,
|
|
75
|
+
findings: allFindings,
|
|
76
|
+
metadata: Object.assign({}, ...results.map((r) => r.metadata)),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export function createCodegenPlugin(options = {}) {
|
|
80
|
+
const base = normalizeCodegenOptions(options);
|
|
81
|
+
return {
|
|
82
|
+
manifest: {
|
|
83
|
+
name: 'codegen',
|
|
84
|
+
apiVersion: 1,
|
|
85
|
+
},
|
|
86
|
+
commands: [
|
|
87
|
+
{
|
|
88
|
+
name: 'codegen',
|
|
89
|
+
description: 'Generate TypeScript artifacts from chkit schema definitions',
|
|
90
|
+
flags: CODEGEN_FLAGS,
|
|
91
|
+
async run({ flags, jsonMode, print, options: runtimeOptions, config, configPath, }) {
|
|
92
|
+
return wrapPluginRun({
|
|
93
|
+
command: 'codegen',
|
|
94
|
+
label: 'Codegen',
|
|
95
|
+
jsonMode,
|
|
96
|
+
print,
|
|
97
|
+
configErrorClass: CodegenConfigError,
|
|
98
|
+
fn: async () => {
|
|
99
|
+
const overrides = flagsToOverrides(flags);
|
|
100
|
+
const effectiveOptions = mergeOptions(base, runtimeOptions, overrides);
|
|
101
|
+
const configDir = resolve(configPath, '..');
|
|
102
|
+
const outFile = resolve(configDir, effectiveOptions.outFile);
|
|
103
|
+
const definitions = await loadSchemaDefinitions(config.schema, { cwd: configDir });
|
|
104
|
+
const generated = generateTypeArtifacts({
|
|
105
|
+
definitions,
|
|
106
|
+
options: effectiveOptions,
|
|
107
|
+
});
|
|
108
|
+
let ingestGenerated = null;
|
|
109
|
+
let ingestOutFile = null;
|
|
110
|
+
if (effectiveOptions.emitIngest) {
|
|
111
|
+
ingestGenerated = generateIngestArtifacts({
|
|
112
|
+
definitions,
|
|
113
|
+
options: effectiveOptions,
|
|
114
|
+
});
|
|
115
|
+
ingestOutFile = resolve(configDir, effectiveOptions.ingestOutFile);
|
|
116
|
+
}
|
|
117
|
+
if (overrides.check) {
|
|
118
|
+
const current = await readMaybe(outFile);
|
|
119
|
+
const typeCheckResult = checkGeneratedOutput({
|
|
120
|
+
label: 'Codegen',
|
|
121
|
+
outFile,
|
|
122
|
+
expected: generated.content,
|
|
123
|
+
current,
|
|
124
|
+
missingCode: 'codegen_missing_output',
|
|
125
|
+
staleCode: 'codegen_stale_output',
|
|
126
|
+
});
|
|
127
|
+
const results = [typeCheckResult];
|
|
128
|
+
if (ingestGenerated && ingestOutFile) {
|
|
129
|
+
const ingestCurrent = await readMaybe(ingestOutFile);
|
|
130
|
+
results.push(checkGeneratedOutput({
|
|
131
|
+
label: 'Codegen ingest',
|
|
132
|
+
outFile: ingestOutFile,
|
|
133
|
+
expected: ingestGenerated.content,
|
|
134
|
+
current: ingestCurrent,
|
|
135
|
+
missingCode: 'codegen_missing_ingest_output',
|
|
136
|
+
staleCode: 'codegen_stale_ingest_output',
|
|
137
|
+
}));
|
|
138
|
+
}
|
|
139
|
+
const checkResult = mergeCheckResults(results);
|
|
140
|
+
const payload = {
|
|
141
|
+
ok: checkResult.ok,
|
|
142
|
+
findingCodes: checkResult.findings.map((finding) => finding.code),
|
|
143
|
+
outFile,
|
|
144
|
+
mode: 'check',
|
|
145
|
+
};
|
|
146
|
+
if (jsonMode) {
|
|
147
|
+
print(payload);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
if (checkResult.ok) {
|
|
151
|
+
print(`Codegen up-to-date: ${outFile}`);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
const firstCode = checkResult.findings[0]?.code ?? 'codegen_stale_output';
|
|
155
|
+
print(`Codegen check failed (${firstCode}): ${outFile}`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return checkResult.ok ? 0 : 1;
|
|
159
|
+
}
|
|
160
|
+
await writeAtomic(outFile, generated.content);
|
|
161
|
+
if (ingestGenerated && ingestOutFile) {
|
|
162
|
+
await writeAtomic(ingestOutFile, ingestGenerated.content);
|
|
163
|
+
}
|
|
164
|
+
const payload = {
|
|
165
|
+
ok: true,
|
|
166
|
+
outFile,
|
|
167
|
+
declarationCount: generated.declarationCount,
|
|
168
|
+
findingCodes: generated.findings.map((finding) => finding.code),
|
|
169
|
+
mode: 'write',
|
|
170
|
+
};
|
|
171
|
+
if (jsonMode) {
|
|
172
|
+
print(payload);
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
print(`Codegen wrote ${outFile} (${generated.declarationCount} declarations)`);
|
|
176
|
+
}
|
|
177
|
+
return 0;
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
],
|
|
183
|
+
hooks: {
|
|
184
|
+
onConfigLoaded({ options: runtimeOptions }) {
|
|
185
|
+
normalizeRuntimeOptions(runtimeOptions);
|
|
186
|
+
},
|
|
187
|
+
async onCheck({ config, configPath, options: runtimeOptions }) {
|
|
188
|
+
const effectiveOptions = mergeOptions(base, runtimeOptions, { check: false });
|
|
189
|
+
const configDir = resolve(configPath, '..');
|
|
190
|
+
const outFile = resolve(configDir, effectiveOptions.outFile);
|
|
191
|
+
const definitions = await loadSchemaDefinitions(config.schema, { cwd: configDir });
|
|
192
|
+
const generated = generateTypeArtifacts({
|
|
193
|
+
definitions,
|
|
194
|
+
options: effectiveOptions,
|
|
195
|
+
});
|
|
196
|
+
const current = await readMaybe(outFile);
|
|
197
|
+
const typeResult = checkGeneratedOutput({
|
|
198
|
+
label: 'Codegen',
|
|
199
|
+
outFile,
|
|
200
|
+
expected: generated.content,
|
|
201
|
+
current,
|
|
202
|
+
missingCode: 'codegen_missing_output',
|
|
203
|
+
staleCode: 'codegen_stale_output',
|
|
204
|
+
});
|
|
205
|
+
if (!effectiveOptions.emitIngest) {
|
|
206
|
+
return typeResult;
|
|
207
|
+
}
|
|
208
|
+
const ingestOutFile = resolve(configDir, effectiveOptions.ingestOutFile);
|
|
209
|
+
const ingestGenerated = generateIngestArtifacts({
|
|
210
|
+
definitions,
|
|
211
|
+
options: effectiveOptions,
|
|
212
|
+
});
|
|
213
|
+
const ingestCurrent = await readMaybe(ingestOutFile);
|
|
214
|
+
const ingestResult = checkGeneratedOutput({
|
|
215
|
+
label: 'Codegen ingest',
|
|
216
|
+
outFile: ingestOutFile,
|
|
217
|
+
expected: ingestGenerated.content,
|
|
218
|
+
current: ingestCurrent,
|
|
219
|
+
missingCode: 'codegen_missing_ingest_output',
|
|
220
|
+
staleCode: 'codegen_stale_ingest_output',
|
|
221
|
+
});
|
|
222
|
+
return mergeCheckResults([typeResult, ingestResult]);
|
|
223
|
+
},
|
|
224
|
+
onCheckReport({ result, print }) {
|
|
225
|
+
const findingCodes = result.findings.map((finding) => finding.code);
|
|
226
|
+
if (result.ok) {
|
|
227
|
+
print(`codegen check: ok`);
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
print(`codegen check: failed${findingCodes.length > 0 ? ` (${findingCodes.join(', ')})` : ''}`);
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
export function codegen(options = {}) {
|
|
236
|
+
return {
|
|
237
|
+
plugin: createCodegenPlugin(),
|
|
238
|
+
name: 'codegen',
|
|
239
|
+
enabled: true,
|
|
240
|
+
options,
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACrE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAElD,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AASlE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,YAAY,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AAC9H,OAAO,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAEhF,KAAK,UAAU,WAAW,CAAC,UAAkB,EAAE,OAAe;IAC5D,MAAM,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IACrD,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CA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C,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;gBACnE,IAAI,MAAM,CAAC,EAAE,EAAE,CAAC;oBACd,KAAK,CAAC,mBAAmB,CAAC,CAAA;oBAC1B,OAAM;gBACR,CAAC;gBACD,KAAK,CAAC,wBAAwB,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;YACjG,CAAC;SACF;KACF,CAAA;AACH,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,UAAgC,EAAE;IACxD,OAAO;QACL,MAAM,EAAE,mBAAmB,EAAE;QAC7B,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,IAAI;QACb,OAAO;KACR,CAAA;AACH,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { ChxInlinePluginRegistration, FlagDef, MaterializedViewDefinition, ParsedFlags, ResolvedChxConfig, TableDefinition, ViewDefinition } from '@chkit/core';
|
|
2
|
+
export interface CodegenPluginOptions {
|
|
3
|
+
outFile?: string;
|
|
4
|
+
emitZod?: boolean;
|
|
5
|
+
tableNameStyle?: 'pascal' | 'camel' | 'raw';
|
|
6
|
+
bigintMode?: 'string' | 'bigint';
|
|
7
|
+
includeViews?: boolean;
|
|
8
|
+
runOnGenerate?: boolean;
|
|
9
|
+
failOnUnsupportedType?: boolean;
|
|
10
|
+
emitIngest?: boolean;
|
|
11
|
+
ingestOutFile?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface CodegenPluginCommandContext {
|
|
14
|
+
args: string[];
|
|
15
|
+
flags: ParsedFlags;
|
|
16
|
+
jsonMode: boolean;
|
|
17
|
+
options: Record<string, unknown>;
|
|
18
|
+
config: ResolvedChxConfig;
|
|
19
|
+
configPath: string;
|
|
20
|
+
print: (value: unknown) => void;
|
|
21
|
+
}
|
|
22
|
+
export interface CodegenPlugin {
|
|
23
|
+
manifest: {
|
|
24
|
+
name: 'codegen';
|
|
25
|
+
apiVersion: 1;
|
|
26
|
+
version?: string;
|
|
27
|
+
};
|
|
28
|
+
commands: Array<{
|
|
29
|
+
name: 'codegen';
|
|
30
|
+
description: string;
|
|
31
|
+
flags?: readonly FlagDef[];
|
|
32
|
+
run: (context: CodegenPluginCommandContext) => undefined | number | Promise<undefined | number>;
|
|
33
|
+
}>;
|
|
34
|
+
hooks?: {
|
|
35
|
+
onConfigLoaded?: (context: {
|
|
36
|
+
command: string;
|
|
37
|
+
configPath: string;
|
|
38
|
+
options: Record<string, unknown>;
|
|
39
|
+
}) => void;
|
|
40
|
+
onCheck?: (context: CodegenPluginCheckContext) => CodegenPluginCheckResult | undefined | Promise<CodegenPluginCheckResult | undefined>;
|
|
41
|
+
onCheckReport?: (context: {
|
|
42
|
+
result: CodegenPluginCheckResult;
|
|
43
|
+
print: (line: string) => void;
|
|
44
|
+
}) => void | Promise<void>;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export interface CodegenFinding {
|
|
48
|
+
code: 'codegen_unsupported_type' | 'codegen_stale_output' | 'codegen_missing_output' | 'codegen_stale_ingest_output' | 'codegen_missing_ingest_output';
|
|
49
|
+
message: string;
|
|
50
|
+
severity: 'warn' | 'error';
|
|
51
|
+
path?: string;
|
|
52
|
+
}
|
|
53
|
+
export interface MapColumnTypeResult {
|
|
54
|
+
tsType: string;
|
|
55
|
+
zodType: string;
|
|
56
|
+
nullable: boolean;
|
|
57
|
+
finding?: CodegenFinding;
|
|
58
|
+
}
|
|
59
|
+
export interface GenerateTypeArtifactsInput {
|
|
60
|
+
definitions: import('@chkit/core').SchemaDefinition[];
|
|
61
|
+
options?: CodegenPluginOptions;
|
|
62
|
+
now?: Date;
|
|
63
|
+
toolVersion?: string;
|
|
64
|
+
}
|
|
65
|
+
export interface GenerateTypeArtifactsOutput {
|
|
66
|
+
content: string;
|
|
67
|
+
outFile: string;
|
|
68
|
+
declarationCount: number;
|
|
69
|
+
findings: CodegenFinding[];
|
|
70
|
+
}
|
|
71
|
+
export interface GenerateIngestArtifactsInput {
|
|
72
|
+
definitions: import('@chkit/core').SchemaDefinition[];
|
|
73
|
+
options?: CodegenPluginOptions;
|
|
74
|
+
toolVersion?: string;
|
|
75
|
+
}
|
|
76
|
+
export interface GenerateIngestArtifactsOutput {
|
|
77
|
+
content: string;
|
|
78
|
+
outFile: string;
|
|
79
|
+
functionCount: number;
|
|
80
|
+
}
|
|
81
|
+
export interface CodegenPluginCheckContext {
|
|
82
|
+
command: 'check';
|
|
83
|
+
config: ResolvedChxConfig;
|
|
84
|
+
configPath: string;
|
|
85
|
+
jsonMode: boolean;
|
|
86
|
+
options: Record<string, unknown>;
|
|
87
|
+
}
|
|
88
|
+
export type CodegenPluginRegistration = ChxInlinePluginRegistration<CodegenPlugin, CodegenPluginOptions>;
|
|
89
|
+
export interface CodegenPluginCheckResult {
|
|
90
|
+
plugin: string;
|
|
91
|
+
evaluated: boolean;
|
|
92
|
+
ok: boolean;
|
|
93
|
+
findings: Array<{
|
|
94
|
+
code: string;
|
|
95
|
+
message: string;
|
|
96
|
+
severity: 'info' | 'warn' | 'error';
|
|
97
|
+
metadata?: Record<string, unknown>;
|
|
98
|
+
}>;
|
|
99
|
+
metadata?: Record<string, unknown>;
|
|
100
|
+
}
|
|
101
|
+
export interface ResolvedTableName {
|
|
102
|
+
definition: TableDefinition | ViewDefinition | MaterializedViewDefinition;
|
|
103
|
+
interfaceName: string;
|
|
104
|
+
}
|
|
105
|
+
export interface FlagOverrides {
|
|
106
|
+
check: boolean;
|
|
107
|
+
outFile?: string;
|
|
108
|
+
emitZod?: boolean;
|
|
109
|
+
bigintMode?: 'string' | 'bigint';
|
|
110
|
+
includeViews?: boolean;
|
|
111
|
+
emitIngest?: boolean;
|
|
112
|
+
ingestOutFile?: string;
|
|
113
|
+
}
|
|
114
|
+
//# source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AU,EAAE,eAAe,GAAG,cAAc,GAAG,0BAA0B,CAAA;IACzE,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,OAAO,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,UAAU,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAChC,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@chkit/plugin-codegen",
|
|
3
|
+
"version": "0.1.0-beta.10",
|
|
4
|
+
"homepage": "https://chkit.obsessiondb.com",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/obsessiondb/chkit.git",
|
|
8
|
+
"directory": "packages/plugin-codegen"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"source": "./src/index.ts",
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsc -p tsconfig.json",
|
|
25
|
+
"dev": "tsc -p tsconfig.json --watch",
|
|
26
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
27
|
+
"lint": "biome lint src",
|
|
28
|
+
"test": "bun test src",
|
|
29
|
+
"clean": "rm -rf dist"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@chkit/core": "0.1.0-beta.10"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"zod": "^4.3.6"
|
|
36
|
+
}
|
|
37
|
+
}
|