@contractspec/lib.source-extractors 0.11.0 → 0.13.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/dist/browser/codegen/index.js +225 -0
- package/dist/browser/extractors/index.js +835 -0
- package/dist/browser/index.js +1215 -0
- package/dist/browser/types.js +0 -0
- package/dist/codegen/index.d.ts +9 -11
- package/dist/codegen/index.d.ts.map +1 -1
- package/dist/codegen/index.js +223 -14
- package/dist/codegen/operation-gen.d.ts +9 -8
- package/dist/codegen/operation-gen.d.ts.map +1 -1
- package/dist/codegen/registry-gen.d.ts +7 -6
- package/dist/codegen/registry-gen.d.ts.map +1 -1
- package/dist/codegen/schema-gen.d.ts +9 -8
- package/dist/codegen/schema-gen.d.ts.map +1 -1
- package/dist/codegen/types.d.ts +29 -32
- package/dist/codegen/types.d.ts.map +1 -1
- package/dist/detect.d.ts +19 -17
- package/dist/detect.d.ts.map +1 -1
- package/dist/extract.d.ts +10 -8
- package/dist/extract.d.ts.map +1 -1
- package/dist/extractors/base.d.ts +76 -75
- package/dist/extractors/base.d.ts.map +1 -1
- package/dist/extractors/elysia/extractor.d.ts +15 -12
- package/dist/extractors/elysia/extractor.d.ts.map +1 -1
- package/dist/extractors/express/extractor.d.ts +16 -12
- package/dist/extractors/express/extractor.d.ts.map +1 -1
- package/dist/extractors/fastify/extractor.d.ts +16 -12
- package/dist/extractors/fastify/extractor.d.ts.map +1 -1
- package/dist/extractors/hono/extractor.d.ts +15 -12
- package/dist/extractors/hono/extractor.d.ts.map +1 -1
- package/dist/extractors/index.d.ts +16 -17
- package/dist/extractors/index.d.ts.map +1 -1
- package/dist/extractors/index.js +834 -40
- package/dist/extractors/nestjs/extractor.d.ts +28 -23
- package/dist/extractors/nestjs/extractor.d.ts.map +1 -1
- package/dist/extractors/next-api/extractor.d.ts +16 -13
- package/dist/extractors/next-api/extractor.d.ts.map +1 -1
- package/dist/extractors/trpc/extractor.d.ts +16 -12
- package/dist/extractors/trpc/extractor.d.ts.map +1 -1
- package/dist/extractors/zod/extractor.d.ts +15 -13
- package/dist/extractors/zod/extractor.d.ts.map +1 -1
- package/dist/index.d.ts +30 -7
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1215 -6
- package/dist/node/codegen/index.js +225 -0
- package/dist/node/extractors/index.js +835 -0
- package/dist/node/index.js +1215 -0
- package/dist/node/types.js +0 -0
- package/dist/registry.d.ts +69 -68
- package/dist/registry.d.ts.map +1 -1
- package/dist/types.d.ts +182 -185
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -0
- package/package.json +60 -21
- package/dist/_virtual/_rolldown/runtime.js +0 -18
- package/dist/codegen/index.js.map +0 -1
- package/dist/codegen/operation-gen.js +0 -91
- package/dist/codegen/operation-gen.js.map +0 -1
- package/dist/codegen/registry-gen.js +0 -47
- package/dist/codegen/registry-gen.js.map +0 -1
- package/dist/codegen/schema-gen.js +0 -93
- package/dist/codegen/schema-gen.js.map +0 -1
- package/dist/detect.js +0 -177
- package/dist/detect.js.map +0 -1
- package/dist/extract.js +0 -125
- package/dist/extract.js.map +0 -1
- package/dist/extractors/base.js +0 -152
- package/dist/extractors/base.js.map +0 -1
- package/dist/extractors/elysia/extractor.js +0 -58
- package/dist/extractors/elysia/extractor.js.map +0 -1
- package/dist/extractors/express/extractor.js +0 -61
- package/dist/extractors/express/extractor.js.map +0 -1
- package/dist/extractors/fastify/extractor.js +0 -61
- package/dist/extractors/fastify/extractor.js.map +0 -1
- package/dist/extractors/hono/extractor.js +0 -57
- package/dist/extractors/hono/extractor.js.map +0 -1
- package/dist/extractors/index.js.map +0 -1
- package/dist/extractors/nestjs/extractor.js +0 -118
- package/dist/extractors/nestjs/extractor.js.map +0 -1
- package/dist/extractors/next-api/extractor.js +0 -80
- package/dist/extractors/next-api/extractor.js.map +0 -1
- package/dist/extractors/trpc/extractor.js +0 -71
- package/dist/extractors/trpc/extractor.js.map +0 -1
- package/dist/extractors/zod/extractor.js +0 -69
- package/dist/extractors/zod/extractor.js.map +0 -1
- package/dist/registry.js +0 -87
- package/dist/registry.js.map +0 -1
|
File without changes
|
package/dist/codegen/index.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
//#endregion
|
|
11
|
-
export { type GeneratedFile, type GenerationOptions, type GenerationResult, generateOperation, generateOperations, generateRegistry, generateSchema, generateSchemas, index_d_exports };
|
|
1
|
+
/**
|
|
2
|
+
* Code generation module.
|
|
3
|
+
*
|
|
4
|
+
* Generates ContractSpec definitions from the Intermediate Representation.
|
|
5
|
+
*/
|
|
6
|
+
export { generateOperation, generateOperations } from './operation-gen';
|
|
7
|
+
export { generateSchema, generateSchemas } from './schema-gen';
|
|
8
|
+
export { generateRegistry } from './registry-gen';
|
|
9
|
+
export type { GeneratedFile, GenerationOptions, GenerationResult, } from './types';
|
|
12
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/codegen/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGxE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAG/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGlD,YAAY,EACV,aAAa,EACb,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,SAAS,CAAC"}
|
package/dist/codegen/index.js
CHANGED
|
@@ -1,17 +1,226 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
// @bun
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __export = (target, all) => {
|
|
4
|
+
for (var name in all)
|
|
5
|
+
__defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true,
|
|
8
|
+
configurable: true,
|
|
9
|
+
set: (newValue) => all[name] = () => newValue
|
|
10
|
+
});
|
|
11
|
+
};
|
|
5
12
|
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
// src/codegen/index.ts
|
|
14
|
+
var exports_codegen = {};
|
|
15
|
+
__export(exports_codegen, {
|
|
16
|
+
generateSchemas: () => generateSchemas,
|
|
17
|
+
generateSchema: () => generateSchema,
|
|
18
|
+
generateRegistry: () => generateRegistry,
|
|
19
|
+
generateOperations: () => generateOperations,
|
|
20
|
+
generateOperation: () => generateOperation
|
|
13
21
|
});
|
|
14
22
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
23
|
+
// src/codegen/operation-gen.ts
|
|
24
|
+
function generateOperation(endpoint, options) {
|
|
25
|
+
const specName = toSpecName(endpoint);
|
|
26
|
+
const fileName = `${toFileName(endpoint)}.ts`;
|
|
27
|
+
const code = generateOperationCode(endpoint, specName, options);
|
|
28
|
+
return {
|
|
29
|
+
path: fileName,
|
|
30
|
+
content: code,
|
|
31
|
+
type: "operation"
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function generateOperations(ir, options) {
|
|
35
|
+
return ir.endpoints.map((endpoint) => generateOperation(endpoint, options));
|
|
36
|
+
}
|
|
37
|
+
function toSpecName(endpoint) {
|
|
38
|
+
const parts = endpoint.path.replace(/^\//, "").split("/").filter((p) => p && !p.startsWith(":") && !p.startsWith("{"));
|
|
39
|
+
const methodPart = endpoint.method.toLowerCase();
|
|
40
|
+
const pathPart = parts.map((p) => p.charAt(0).toUpperCase() + p.slice(1)).join("");
|
|
41
|
+
return `${methodPart}${pathPart}Spec`;
|
|
42
|
+
}
|
|
43
|
+
function toFileName(endpoint) {
|
|
44
|
+
const parts = endpoint.path.replace(/^\//, "").split("/").filter((p) => p && !p.startsWith(":") && !p.startsWith("{"));
|
|
45
|
+
const methodPart = endpoint.method.toLowerCase();
|
|
46
|
+
const pathPart = parts.join("-");
|
|
47
|
+
return `${methodPart}-${pathPart}`.replace(/--+/g, "-");
|
|
48
|
+
}
|
|
49
|
+
function generateOperationCode(endpoint, specName, options) {
|
|
50
|
+
const isCommand = endpoint.kind === "command";
|
|
51
|
+
const defineFunc = isCommand ? "defineCommand" : "defineQuery";
|
|
52
|
+
const auth = options.defaultAuth ?? "user";
|
|
53
|
+
const owners = options.defaultOwners ?? ["team"];
|
|
54
|
+
const lines = [
|
|
55
|
+
`/**`,
|
|
56
|
+
` * ${endpoint.method} ${endpoint.path}`,
|
|
57
|
+
` *`,
|
|
58
|
+
` * Generated from: ${endpoint.source.file}:${endpoint.source.startLine}`,
|
|
59
|
+
` * Confidence: ${endpoint.confidence.level}`,
|
|
60
|
+
` */`,
|
|
61
|
+
``,
|
|
62
|
+
`import { ${defineFunc} } from '@contractspec/lib.contracts';`,
|
|
63
|
+
`import { fromZod } from '@contractspec/lib.schema';`,
|
|
64
|
+
`import { z } from 'zod';`,
|
|
65
|
+
``,
|
|
66
|
+
`// TODO: Define input schema based on extracted information`,
|
|
67
|
+
`const inputSchema = fromZod(z.object({`,
|
|
68
|
+
` // Add fields here`,
|
|
69
|
+
`}));`,
|
|
70
|
+
``,
|
|
71
|
+
`// TODO: Define output schema`,
|
|
72
|
+
`const outputSchema = fromZod(z.object({`,
|
|
73
|
+
` // Add fields here`,
|
|
74
|
+
`}));`,
|
|
75
|
+
``,
|
|
76
|
+
`export const ${specName} = ${defineFunc}({`,
|
|
77
|
+
` meta: {`,
|
|
78
|
+
` name: '${endpoint.handlerName ?? endpoint.id}',`,
|
|
79
|
+
` version: 1,`,
|
|
80
|
+
` stability: 'experimental',`,
|
|
81
|
+
` owners: ${JSON.stringify(owners)},`,
|
|
82
|
+
` goal: 'TODO: Describe the business goal',`,
|
|
83
|
+
` context: 'Generated from ${endpoint.source.file}',`,
|
|
84
|
+
` },`,
|
|
85
|
+
` io: {`,
|
|
86
|
+
` input: inputSchema,`,
|
|
87
|
+
` output: outputSchema,`,
|
|
88
|
+
` },`,
|
|
89
|
+
` policy: {`,
|
|
90
|
+
` auth: '${auth}',`,
|
|
91
|
+
` },`,
|
|
92
|
+
` transport: {`,
|
|
93
|
+
` rest: {`,
|
|
94
|
+
` method: '${endpoint.method}',`,
|
|
95
|
+
` path: '${endpoint.path}',`,
|
|
96
|
+
` },`,
|
|
97
|
+
` },`,
|
|
98
|
+
`});`,
|
|
99
|
+
``
|
|
100
|
+
];
|
|
101
|
+
return lines.join(`
|
|
102
|
+
`);
|
|
103
|
+
}
|
|
104
|
+
// src/codegen/schema-gen.ts
|
|
105
|
+
function generateSchema(schema, _options) {
|
|
106
|
+
const fileName = `${toFileName2(schema.name)}.ts`;
|
|
107
|
+
const code = generateSchemaCode(schema);
|
|
108
|
+
return {
|
|
109
|
+
path: `schemas/${fileName}`,
|
|
110
|
+
content: code,
|
|
111
|
+
type: "schema"
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function generateSchemas(ir, options) {
|
|
115
|
+
return ir.schemas.map((schema) => generateSchema(schema, options));
|
|
116
|
+
}
|
|
117
|
+
function toFileName2(name) {
|
|
118
|
+
return name.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/([A-Z])([A-Z][a-z])/g, "$1-$2").toLowerCase();
|
|
119
|
+
}
|
|
120
|
+
function generateSchemaCode(schema) {
|
|
121
|
+
const lines = [
|
|
122
|
+
`/**`,
|
|
123
|
+
` * ${schema.name}`,
|
|
124
|
+
` *`,
|
|
125
|
+
` * Generated from: ${schema.source.file}:${schema.source.startLine}`,
|
|
126
|
+
` * Schema type: ${schema.schemaType}`,
|
|
127
|
+
` * Confidence: ${schema.confidence.level}`,
|
|
128
|
+
` */`,
|
|
129
|
+
``,
|
|
130
|
+
`import { fromZod } from '@contractspec/lib.schema';`,
|
|
131
|
+
`import { z } from 'zod';`,
|
|
132
|
+
``
|
|
133
|
+
];
|
|
134
|
+
if (schema.rawDefinition && schema.schemaType === "zod") {
|
|
135
|
+
lines.push(`// Original definition from source:`);
|
|
136
|
+
lines.push(`// ${schema.rawDefinition.split(`
|
|
137
|
+
`)[0]}`);
|
|
138
|
+
lines.push(``);
|
|
139
|
+
}
|
|
140
|
+
lines.push(`export const ${schema.name}Schema = fromZod(z.object({`);
|
|
141
|
+
if (schema.fields && schema.fields.length > 0) {
|
|
142
|
+
for (const field of schema.fields) {
|
|
143
|
+
const zodType = mapToZodType(field.type, field.optional);
|
|
144
|
+
lines.push(` ${field.name}: ${zodType},`);
|
|
145
|
+
}
|
|
146
|
+
} else {
|
|
147
|
+
lines.push(` // TODO: Define schema fields`);
|
|
148
|
+
}
|
|
149
|
+
lines.push(`}));`);
|
|
150
|
+
lines.push(``);
|
|
151
|
+
lines.push(`export type ${schema.name} = z.infer<typeof ${schema.name}Schema.zodSchema>;`);
|
|
152
|
+
lines.push(``);
|
|
153
|
+
return lines.join(`
|
|
154
|
+
`);
|
|
155
|
+
}
|
|
156
|
+
function mapToZodType(tsType, optional) {
|
|
157
|
+
let zodType;
|
|
158
|
+
switch (tsType.toLowerCase()) {
|
|
159
|
+
case "string":
|
|
160
|
+
zodType = "z.string()";
|
|
161
|
+
break;
|
|
162
|
+
case "number":
|
|
163
|
+
zodType = "z.number()";
|
|
164
|
+
break;
|
|
165
|
+
case "boolean":
|
|
166
|
+
zodType = "z.boolean()";
|
|
167
|
+
break;
|
|
168
|
+
case "date":
|
|
169
|
+
zodType = "z.date()";
|
|
170
|
+
break;
|
|
171
|
+
case "string[]":
|
|
172
|
+
case "array<string>":
|
|
173
|
+
zodType = "z.array(z.string())";
|
|
174
|
+
break;
|
|
175
|
+
case "number[]":
|
|
176
|
+
case "array<number>":
|
|
177
|
+
zodType = "z.array(z.number())";
|
|
178
|
+
break;
|
|
179
|
+
default:
|
|
180
|
+
zodType = "z.unknown()";
|
|
181
|
+
}
|
|
182
|
+
return optional ? `${zodType}.optional()` : zodType;
|
|
183
|
+
}
|
|
184
|
+
// src/codegen/registry-gen.ts
|
|
185
|
+
function generateRegistry(operationFiles) {
|
|
186
|
+
const operationImports = operationFiles.filter((f) => f.type === "operation").map((f) => {
|
|
187
|
+
const name = f.path.replace(".ts", "").replace(/-/g, "_");
|
|
188
|
+
const specName = toPascalCase(name) + "Spec";
|
|
189
|
+
return { path: f.path, name, specName };
|
|
190
|
+
});
|
|
191
|
+
const lines = [
|
|
192
|
+
`/**`,
|
|
193
|
+
` * Generated operation registry.`,
|
|
194
|
+
` */`,
|
|
195
|
+
``,
|
|
196
|
+
`import { OperationSpecRegistry } from '@contractspec/lib.contracts';`,
|
|
197
|
+
``
|
|
198
|
+
];
|
|
199
|
+
for (const op of operationImports) {
|
|
200
|
+
const importPath = `./${op.path.replace(".ts", "")}`;
|
|
201
|
+
lines.push(`import { ${op.specName} } from '${importPath}';`);
|
|
202
|
+
}
|
|
203
|
+
lines.push(``);
|
|
204
|
+
lines.push(`export const operationRegistry = new OperationSpecRegistry();`);
|
|
205
|
+
lines.push(``);
|
|
206
|
+
for (const op of operationImports) {
|
|
207
|
+
lines.push(`operationRegistry.register(${op.specName});`);
|
|
208
|
+
}
|
|
209
|
+
lines.push(``);
|
|
210
|
+
return {
|
|
211
|
+
path: "registry.ts",
|
|
212
|
+
content: lines.join(`
|
|
213
|
+
`),
|
|
214
|
+
type: "registry"
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
function toPascalCase(str) {
|
|
218
|
+
return str.split(/[-_]/).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
|
|
219
|
+
}
|
|
220
|
+
export {
|
|
221
|
+
generateSchemas,
|
|
222
|
+
generateSchema,
|
|
223
|
+
generateRegistry,
|
|
224
|
+
generateOperations,
|
|
225
|
+
generateOperation
|
|
226
|
+
};
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Operation code generator.
|
|
3
|
+
*
|
|
4
|
+
* Generates defineCommand/defineQuery specs from endpoint candidates.
|
|
5
|
+
*/
|
|
6
|
+
import type { EndpointCandidate, ImportIR } from '../types';
|
|
7
|
+
import type { GeneratedFile, GenerationOptions } from './types';
|
|
5
8
|
/**
|
|
6
9
|
* Generate a single operation spec file.
|
|
7
10
|
*/
|
|
8
|
-
declare function generateOperation(endpoint: EndpointCandidate, options: GenerationOptions): GeneratedFile;
|
|
11
|
+
export declare function generateOperation(endpoint: EndpointCandidate, options: GenerationOptions): GeneratedFile;
|
|
9
12
|
/**
|
|
10
13
|
* Generate all operation spec files from IR.
|
|
11
14
|
*/
|
|
12
|
-
declare function generateOperations(ir: ImportIR, options: GenerationOptions): GeneratedFile[];
|
|
13
|
-
//#endregion
|
|
14
|
-
export { generateOperation, generateOperations };
|
|
15
|
+
export declare function generateOperations(ir: ImportIR, options: GenerationOptions): GeneratedFile[];
|
|
15
16
|
//# sourceMappingURL=operation-gen.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation-gen.d.ts","
|
|
1
|
+
{"version":3,"file":"operation-gen.d.ts","sourceRoot":"","sources":["../../src/codegen/operation-gen.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEhE;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,EAAE,iBAAiB,GACzB,aAAa,CAWf;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,EAAE,EAAE,QAAQ,EACZ,OAAO,EAAE,iBAAiB,GACzB,aAAa,EAAE,CAEjB"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Registry code generator.
|
|
3
|
+
*
|
|
4
|
+
* Generates OperationSpecRegistry from generated operations.
|
|
5
|
+
*/
|
|
6
|
+
import type { GeneratedFile } from './types';
|
|
4
7
|
/**
|
|
5
8
|
* Generate a registry file for the generated operations.
|
|
6
9
|
*/
|
|
7
|
-
declare function generateRegistry(operationFiles: GeneratedFile[]): GeneratedFile;
|
|
8
|
-
//#endregion
|
|
9
|
-
export { generateRegistry };
|
|
10
|
+
export declare function generateRegistry(operationFiles: GeneratedFile[]): GeneratedFile;
|
|
10
11
|
//# sourceMappingURL=registry-gen.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry-gen.d.ts","
|
|
1
|
+
{"version":3,"file":"registry-gen.d.ts","sourceRoot":"","sources":["../../src/codegen/registry-gen.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,cAAc,EAAE,aAAa,EAAE,GAC9B,aAAa,CAwCf"}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Schema code generator.
|
|
3
|
+
*
|
|
4
|
+
* Generates defineSchemaModel specs from schema candidates.
|
|
5
|
+
*/
|
|
6
|
+
import type { SchemaCandidate, ImportIR } from '../types';
|
|
7
|
+
import type { GeneratedFile, GenerationOptions } from './types';
|
|
5
8
|
/**
|
|
6
9
|
* Generate a single schema file.
|
|
7
10
|
*/
|
|
8
|
-
declare function generateSchema(schema: SchemaCandidate, _options: GenerationOptions): GeneratedFile;
|
|
11
|
+
export declare function generateSchema(schema: SchemaCandidate, _options: GenerationOptions): GeneratedFile;
|
|
9
12
|
/**
|
|
10
13
|
* Generate all schema files from IR.
|
|
11
14
|
*/
|
|
12
|
-
declare function generateSchemas(ir: ImportIR, options: GenerationOptions): GeneratedFile[];
|
|
13
|
-
//#endregion
|
|
14
|
-
export { generateSchema, generateSchemas };
|
|
15
|
+
export declare function generateSchemas(ir: ImportIR, options: GenerationOptions): GeneratedFile[];
|
|
15
16
|
//# sourceMappingURL=schema-gen.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-gen.d.ts","
|
|
1
|
+
{"version":3,"file":"schema-gen.d.ts","sourceRoot":"","sources":["../../src/codegen/schema-gen.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEhE;;GAEG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,iBAAiB,GAC1B,aAAa,CASf;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,EAAE,EAAE,QAAQ,EACZ,OAAO,EAAE,iBAAiB,GACzB,aAAa,EAAE,CAEjB"}
|
package/dist/codegen/types.d.ts
CHANGED
|
@@ -1,48 +1,45 @@
|
|
|
1
|
-
//#region src/codegen/types.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Code generation types.
|
|
4
3
|
*/
|
|
5
4
|
/**
|
|
6
5
|
* A generated file.
|
|
7
6
|
*/
|
|
8
|
-
interface GeneratedFile {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
export interface GeneratedFile {
|
|
8
|
+
/** Relative path from output directory */
|
|
9
|
+
path: string;
|
|
10
|
+
/** File content */
|
|
11
|
+
content: string;
|
|
12
|
+
/** Type of generated file */
|
|
13
|
+
type: 'operation' | 'schema' | 'registry' | 'index';
|
|
15
14
|
}
|
|
16
15
|
/**
|
|
17
16
|
* Options for code generation.
|
|
18
17
|
*/
|
|
19
|
-
interface GenerationOptions {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
18
|
+
export interface GenerationOptions {
|
|
19
|
+
/** Output directory */
|
|
20
|
+
outputDir: string;
|
|
21
|
+
/** Whether to overwrite existing files */
|
|
22
|
+
overwrite?: boolean;
|
|
23
|
+
/** Schema format to use */
|
|
24
|
+
schemaFormat?: 'zod' | 'typescript';
|
|
25
|
+
/** Default auth level */
|
|
26
|
+
defaultAuth?: 'anonymous' | 'user' | 'admin';
|
|
27
|
+
/** Default owners */
|
|
28
|
+
defaultOwners?: string[];
|
|
29
|
+
/** Prefix for generated names */
|
|
30
|
+
prefix?: string;
|
|
32
31
|
}
|
|
33
32
|
/**
|
|
34
33
|
* Result of code generation.
|
|
35
34
|
*/
|
|
36
|
-
interface GenerationResult {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
export interface GenerationResult {
|
|
36
|
+
/** Generated files */
|
|
37
|
+
files: GeneratedFile[];
|
|
38
|
+
/** Number of operations generated */
|
|
39
|
+
operationsGenerated: number;
|
|
40
|
+
/** Number of schemas generated */
|
|
41
|
+
schemasGenerated: number;
|
|
42
|
+
/** Warnings during generation */
|
|
43
|
+
warnings: string[];
|
|
45
44
|
}
|
|
46
|
-
//#endregion
|
|
47
|
-
export { GeneratedFile, GenerationOptions, GenerationResult };
|
|
48
45
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/codegen/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,mBAAmB;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,6BAA6B;IAC7B,IAAI,EAAE,WAAW,GAAG,QAAQ,GAAG,UAAU,GAAG,OAAO,CAAC;CACrD;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,uBAAuB;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,0CAA0C;IAC1C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,2BAA2B;IAC3B,YAAY,CAAC,EAAE,KAAK,GAAG,YAAY,CAAC;IACpC,yBAAyB;IACzB,WAAW,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,OAAO,CAAC;IAC7C,qBAAqB;IACrB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,iCAAiC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,sBAAsB;IACtB,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,qCAAqC;IACrC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,kCAAkC;IAClC,gBAAgB,EAAE,MAAM,CAAC;IACzB,iCAAiC;IACjC,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB"}
|
package/dist/detect.d.ts
CHANGED
|
@@ -1,46 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Framework detection utilities.
|
|
3
|
+
*
|
|
4
|
+
* Analyzes a project to detect which frameworks are in use.
|
|
5
|
+
*/
|
|
6
|
+
import type { FrameworkInfo, ProjectInfo } from './types';
|
|
4
7
|
/**
|
|
5
8
|
* Dependencies from package.json.
|
|
6
9
|
*/
|
|
7
10
|
interface PackageDependencies {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
dependencies?: Record<string, string>;
|
|
12
|
+
devDependencies?: Record<string, string>;
|
|
13
|
+
peerDependencies?: Record<string, string>;
|
|
11
14
|
}
|
|
12
15
|
/**
|
|
13
16
|
* Detect frameworks from package.json dependencies.
|
|
14
17
|
*/
|
|
15
|
-
declare function detectFrameworksFromPackageJson(packageJson: PackageDependencies): FrameworkInfo[];
|
|
18
|
+
export declare function detectFrameworksFromPackageJson(packageJson: PackageDependencies): FrameworkInfo[];
|
|
16
19
|
/**
|
|
17
20
|
* Detect frameworks from source code imports.
|
|
18
21
|
*/
|
|
19
|
-
declare function detectFrameworksFromCode(sourceCode: string): FrameworkInfo[];
|
|
22
|
+
export declare function detectFrameworksFromCode(sourceCode: string): FrameworkInfo[];
|
|
20
23
|
/**
|
|
21
24
|
* Detect frameworks from file paths.
|
|
22
25
|
*/
|
|
23
|
-
declare function detectFrameworksFromPaths(filePaths: string[]): FrameworkInfo[];
|
|
26
|
+
export declare function detectFrameworksFromPaths(filePaths: string[]): FrameworkInfo[];
|
|
24
27
|
/**
|
|
25
28
|
* Merge framework detections, preferring higher confidence.
|
|
26
29
|
*/
|
|
27
|
-
declare function mergeFrameworkDetections(...detections: FrameworkInfo[][]): FrameworkInfo[];
|
|
30
|
+
export declare function mergeFrameworkDetections(...detections: FrameworkInfo[][]): FrameworkInfo[];
|
|
28
31
|
/**
|
|
29
32
|
* Detect frameworks for a project.
|
|
30
33
|
* This is a convenience function that combines all detection methods.
|
|
31
34
|
*/
|
|
32
|
-
declare function detectFramework(rootPath: string, options?: {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
export declare function detectFramework(rootPath: string, options?: {
|
|
36
|
+
readFile?: (path: string) => Promise<string>;
|
|
37
|
+
glob?: (pattern: string) => Promise<string[]>;
|
|
35
38
|
}): Promise<ProjectInfo>;
|
|
36
39
|
/**
|
|
37
40
|
* Get all supported framework IDs.
|
|
38
41
|
*/
|
|
39
|
-
declare function getSupportedFrameworks(): string[];
|
|
42
|
+
export declare function getSupportedFrameworks(): string[];
|
|
40
43
|
/**
|
|
41
44
|
* Check if a framework ID is supported.
|
|
42
45
|
*/
|
|
43
|
-
declare function isFrameworkSupported(id: string): boolean;
|
|
44
|
-
|
|
45
|
-
export { detectFramework, detectFrameworksFromCode, detectFrameworksFromPackageJson, detectFrameworksFromPaths, getSupportedFrameworks, isFrameworkSupported, mergeFrameworkDetections };
|
|
46
|
+
export declare function isFrameworkSupported(id: string): boolean;
|
|
47
|
+
export {};
|
|
46
48
|
//# sourceMappingURL=detect.d.ts.map
|
package/dist/detect.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detect.d.ts","
|
|
1
|
+
{"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../src/detect.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAmB,aAAa,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AA4E3E;;GAEG;AACH,UAAU,mBAAmB;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC3C;AAED;;GAEG;AACH,wBAAgB,+BAA+B,CAC7C,WAAW,EAAE,mBAAmB,GAC/B,aAAa,EAAE,CAwBjB;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,GAAG,aAAa,EAAE,CAqB5E;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,MAAM,EAAE,GAClB,aAAa,EAAE,CAuBjB;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,UAAU,EAAE,aAAa,EAAE,EAAE,GAC/B,aAAa,EAAE,CAuBjB;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE;IACR,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7C,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;CAC/C,GACA,OAAO,CAAC,WAAW,CAAC,CA+BtB;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,EAAE,CAEjD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAExD"}
|
package/dist/extract.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Main extraction function.
|
|
3
|
+
*
|
|
4
|
+
* Orchestrates the extraction process using detected frameworks
|
|
5
|
+
* and registered extractors.
|
|
6
|
+
*/
|
|
7
|
+
import type { ExtractOptions, ExtractResult, ImportIR, ProjectInfo } from './types';
|
|
4
8
|
/**
|
|
5
9
|
* Extract contracts from a project.
|
|
6
10
|
*
|
|
@@ -8,16 +12,14 @@ import { ExtractOptions, ExtractResult, ImportIR, ProjectInfo } from "./types.js
|
|
|
8
12
|
* @param options Extraction options
|
|
9
13
|
* @returns Extraction result with IR
|
|
10
14
|
*/
|
|
11
|
-
declare function extractFromProject(project: ProjectInfo, options?: ExtractOptions): Promise<ExtractResult>;
|
|
15
|
+
export declare function extractFromProject(project: ProjectInfo, options?: ExtractOptions): Promise<ExtractResult>;
|
|
12
16
|
/**
|
|
13
17
|
* Merge multiple IRs into one.
|
|
14
18
|
* Useful when extracting from multiple sources or frameworks.
|
|
15
19
|
*/
|
|
16
|
-
declare function mergeIRs(irs: ImportIR[]): ImportIR;
|
|
20
|
+
export declare function mergeIRs(irs: ImportIR[]): ImportIR;
|
|
17
21
|
/**
|
|
18
22
|
* Create an empty IR structure.
|
|
19
23
|
*/
|
|
20
|
-
declare function createEmptyIR(project: ProjectInfo): ImportIR;
|
|
21
|
-
//#endregion
|
|
22
|
-
export { createEmptyIR, extractFromProject, mergeIRs };
|
|
24
|
+
export declare function createEmptyIR(project: ProjectInfo): ImportIR;
|
|
23
25
|
//# sourceMappingURL=extract.d.ts.map
|
package/dist/extract.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract.d.ts","
|
|
1
|
+
{"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../src/extract.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,QAAQ,EACR,WAAW,EACZ,MAAM,SAAS,CAAC;AAGjB;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,WAAW,EACpB,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,aAAa,CAAC,CAuDxB;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAqDlD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,WAAW,GAAG,QAAQ,CAsB5D"}
|