@malyuga/aether-cli 0.1.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/LICENSE +21 -0
- package/README.md +117 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +119 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/check.d.ts +4 -0
- package/dist/commands/check.d.ts.map +1 -0
- package/dist/commands/check.js +45 -0
- package/dist/commands/check.js.map +1 -0
- package/dist/commands/doctor.d.ts +8 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +62 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/generate.d.ts +15 -0
- package/dist/commands/generate.d.ts.map +1 -0
- package/dist/commands/generate.js +51 -0
- package/dist/commands/generate.js.map +1 -0
- package/dist/commands/help.d.ts +6 -0
- package/dist/commands/help.d.ts.map +1 -0
- package/dist/commands/help.js +60 -0
- package/dist/commands/help.js.map +1 -0
- package/dist/commands/init.d.ts +7 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +24 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/upgrade.d.ts +5 -0
- package/dist/commands/upgrade.d.ts.map +1 -0
- package/dist/commands/upgrade.js +42 -0
- package/dist/commands/upgrade.js.map +1 -0
- package/dist/core/ast.d.ts +7 -0
- package/dist/core/ast.d.ts.map +1 -0
- package/dist/core/ast.js +90 -0
- package/dist/core/ast.js.map +1 -0
- package/dist/core/constants.d.ts +133 -0
- package/dist/core/constants.d.ts.map +1 -0
- package/dist/core/constants.js +135 -0
- package/dist/core/constants.js.map +1 -0
- package/dist/core/diff.d.ts +20 -0
- package/dist/core/diff.d.ts.map +1 -0
- package/dist/core/diff.js +39 -0
- package/dist/core/diff.js.map +1 -0
- package/dist/core/errors.d.ts +19 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +37 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/naming.d.ts +10 -0
- package/dist/core/naming.d.ts.map +1 -0
- package/dist/core/naming.js +50 -0
- package/dist/core/naming.js.map +1 -0
- package/dist/core/paths.d.ts +10 -0
- package/dist/core/paths.d.ts.map +1 -0
- package/dist/core/paths.js +38 -0
- package/dist/core/paths.js.map +1 -0
- package/dist/core/plan.d.ts +37 -0
- package/dist/core/plan.d.ts.map +1 -0
- package/dist/core/plan.js +126 -0
- package/dist/core/plan.js.map +1 -0
- package/dist/core/project.d.ts +16 -0
- package/dist/core/project.d.ts.map +1 -0
- package/dist/core/project.js +66 -0
- package/dist/core/project.js.map +1 -0
- package/dist/core/render.d.ts +4 -0
- package/dist/core/render.d.ts.map +1 -0
- package/dist/core/render.js +44 -0
- package/dist/core/render.js.map +1 -0
- package/dist/generators/middleware.d.ts +11 -0
- package/dist/generators/middleware.d.ts.map +1 -0
- package/dist/generators/middleware.js +41 -0
- package/dist/generators/middleware.js.map +1 -0
- package/dist/generators/openapi.d.ts +9 -0
- package/dist/generators/openapi.d.ts.map +1 -0
- package/dist/generators/openapi.js +46 -0
- package/dist/generators/openapi.js.map +1 -0
- package/dist/generators/project.d.ts +9 -0
- package/dist/generators/project.d.ts.map +1 -0
- package/dist/generators/project.js +76 -0
- package/dist/generators/project.js.map +1 -0
- package/dist/generators/resource-context.d.ts +18 -0
- package/dist/generators/resource-context.d.ts.map +1 -0
- package/dist/generators/resource-context.js +21 -0
- package/dist/generators/resource-context.js.map +1 -0
- package/dist/generators/resource-file.d.ts +8 -0
- package/dist/generators/resource-file.d.ts.map +1 -0
- package/dist/generators/resource-file.js +9 -0
- package/dist/generators/resource-file.js.map +1 -0
- package/dist/generators/resource-tests.d.ts +5 -0
- package/dist/generators/resource-tests.d.ts.map +1 -0
- package/dist/generators/resource-tests.js +17 -0
- package/dist/generators/resource-tests.js.map +1 -0
- package/dist/generators/resource.d.ts +21 -0
- package/dist/generators/resource.d.ts.map +1 -0
- package/dist/generators/resource.js +64 -0
- package/dist/generators/resource.js.map +1 -0
- package/dist/generators/types.d.ts +7 -0
- package/dist/generators/types.d.ts.map +1 -0
- package/dist/generators/types.js +2 -0
- package/dist/generators/types.js.map +1 -0
- package/dist/help/guide.txt +126 -0
- package/dist/openapi/extract-resources.d.ts +3 -0
- package/dist/openapi/extract-resources.d.ts.map +1 -0
- package/dist/openapi/extract-resources.js +130 -0
- package/dist/openapi/extract-resources.js.map +1 -0
- package/dist/openapi/load-spec.d.ts +3 -0
- package/dist/openapi/load-spec.d.ts.map +1 -0
- package/dist/openapi/load-spec.js +19 -0
- package/dist/openapi/load-spec.js.map +1 -0
- package/dist/openapi/types.d.ts +51 -0
- package/dist/openapi/types.d.ts.map +1 -0
- package/dist/openapi/types.js +2 -0
- package/dist/openapi/types.js.map +1 -0
- package/dist/templates/init/aether.config.json.eta +5 -0
- package/dist/templates/init/astraeus.config.json.eta +5 -0
- package/dist/templates/init/chisel.config.json.eta +5 -0
- package/dist/templates/init/env.eta +8 -0
- package/dist/templates/init/env.example.eta +8 -0
- package/dist/templates/init/gitignore.eta +5 -0
- package/dist/templates/init/package.json.eta +14 -0
- package/dist/templates/init/src-app-composition.ts.eta +6 -0
- package/dist/templates/init/src-app-config.ts.eta +105 -0
- package/dist/templates/init/src-app-http.ts.eta +74 -0
- package/dist/templates/init/src-app-list.ts.eta +35 -0
- package/dist/templates/init/src-app-logger.ts.eta +35 -0
- package/dist/templates/init/src-app-middleware-bearer-auth.ts.eta +60 -0
- package/dist/templates/init/src-app-middleware-body-limit.ts.eta +37 -0
- package/dist/templates/init/src-app-middleware-cors.ts.eta +53 -0
- package/dist/templates/init/src-app-middleware-error-handler.ts.eta +15 -0
- package/dist/templates/init/src-app-middleware-request-logger.ts.eta +8 -0
- package/dist/templates/init/src-app-middleware-types.ts.eta +7 -0
- package/dist/templates/init/src-app-router.ts.eta +72 -0
- package/dist/templates/init/src-app-server.ts.eta +16 -0
- package/dist/templates/init/src-app.ts.eta +36 -0
- package/dist/templates/init/src-health-health.routes.ts.eta +12 -0
- package/dist/templates/init/src-main.ts.eta +37 -0
- package/dist/templates/init/tsconfig.json.eta +14 -0
- package/dist/templates/middleware/middleware.ts.eta +6 -0
- package/dist/templates/resource/controller.ts.eta +135 -0
- package/dist/templates/resource/module.test.ts.eta +16 -0
- package/dist/templates/resource/module.ts.eta +25 -0
- package/dist/templates/resource/repository.fake.ts.eta +33 -0
- package/dist/templates/resource/repository.ts.eta +14 -0
- package/dist/templates/resource/routes.ts.eta +18 -0
- package/dist/templates/resource/service.ts.eta +45 -0
- package/dist/templates/resource/types.ts.eta +12 -0
- package/dist/templates/resource/validate.ts.eta +64 -0
- package/llms.txt +57 -0
- package/package.json +67 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.js","sourceRoot":"","sources":["../../src/generators/project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EACL,OAAO,EACP,YAAY,EACZ,WAAW,EACX,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACR,OAAO,EACP,SAAS,EACT,SAAS,EACT,UAAU,EACV,sBAAsB,EACtB,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,aAAa,GACd,MAAM,sBAAsB,CAAC;AAO9B,MAAM,YAAY,GAAG,CAAC,YAAY,EAAE,iBAAiB,EAAE,YAAY,CAAC,CAAC;AAErE,MAAM,OAAO,GAAG,GAAG,eAAe,IAAI,OAAO,EAAE,CAAC;AAChD,MAAM,cAAc,GAAG,GAAG,OAAO,IAAI,cAAc,EAAE,CAAC;AAEtD,MAAM,UAAU,GAA6C;IAC3D,EAAE,GAAG,EAAE,YAAY,EAAE,QA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G,OAAO,CAAC,WAAW,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,oBAAoB,CAAC;QAClF,MAAM,IAAI,GAAG;YACX,WAAW;YACX,aAAa,EAAE,cAAc;YAC7B,MAAM,EAAE,eAAe;YACvB,QAAQ,EAAE,iBAAiB;SAC5B,CAAC;QAEF,MAAM,GAAG,GAAa,EAAE,CAAC;QACzB,KAAK,MAAM,CAAC,IAAI,UAAU,EAAE,CAAC;YAC3B,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,CAAC,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;YACxD,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC5D,CAAC;QACD,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,CAAC;YAChC,MAAM,WAAW,GAAG,MAAM,cAAc,CAAC,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YAClE,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC,CAAC;QAC5E,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { TsScalarType } from "../core/constants.js";
|
|
2
|
+
export interface ResourceField {
|
|
3
|
+
name: string;
|
|
4
|
+
tsType: TsScalarType;
|
|
5
|
+
required: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface ResourceTemplateContext {
|
|
8
|
+
resourceKebab: string;
|
|
9
|
+
resourceCamel: string;
|
|
10
|
+
entityPascal: string;
|
|
11
|
+
crud: boolean;
|
|
12
|
+
fields: ResourceField[];
|
|
13
|
+
routePrefix: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function buildResourceContext(name: string, crud: boolean, singular?: string, fields?: ResourceField[], routePrefix?: string): ResourceTemplateContext;
|
|
16
|
+
export declare function moduleFactoryName(entityPascal: string): string;
|
|
17
|
+
export declare function routesExportName(resourceCamel: string): string;
|
|
18
|
+
//# sourceMappingURL=resource-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-context.d.ts","sourceRoot":"","sources":["../../src/generators/resource-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAQzD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,YAAY,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,uBAAuB;IACtC,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,EACb,QAAQ,CAAC,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,aAAa,EAAE,EACxB,WAAW,SAAK,GACf,uBAAuB,CAYzB;AAED,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAE9D"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { resolveSingularPascal, toCamel, toKebab, validateResourceName, } from "../core/naming.js";
|
|
2
|
+
export function buildResourceContext(name, crud, singular, fields, routePrefix = "") {
|
|
3
|
+
const resourceKebab = toKebab(name);
|
|
4
|
+
validateResourceName(resourceKebab);
|
|
5
|
+
const resolvedFields = crud ? (fields ?? []) : [];
|
|
6
|
+
return {
|
|
7
|
+
resourceKebab,
|
|
8
|
+
resourceCamel: toCamel(resourceKebab),
|
|
9
|
+
entityPascal: resolveSingularPascal(resourceKebab, singular),
|
|
10
|
+
crud,
|
|
11
|
+
fields: resolvedFields,
|
|
12
|
+
routePrefix,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export function moduleFactoryName(entityPascal) {
|
|
16
|
+
return `create${entityPascal}Module`;
|
|
17
|
+
}
|
|
18
|
+
export function routesExportName(resourceCamel) {
|
|
19
|
+
return `${resourceCamel}Routes`;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=resource-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-context.js","sourceRoot":"","sources":["../../src/generators/resource-context.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,OAAO,EACP,OAAO,EACP,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAiB3B,MAAM,UAAU,oBAAoB,CAClC,IAAY,EACZ,IAAa,EACb,QAAiB,EACjB,MAAwB,EACxB,WAAW,GAAG,EAAE;IAEhB,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC,oBAAoB,CAAC,aAAa,CAAC,CAAC;IACpC,MAAM,cAAc,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAClD,OAAO;QACL,aAAa;QACb,aAAa,EAAE,OAAO,CAAC,aAAa,CAAC;QACrC,YAAY,EAAE,qBAAqB,CAAC,aAAa,EAAE,QAAQ,CAAC;QAC5D,IAAI;QACJ,MAAM,EAAE,cAAc;QACtB,WAAW;KACZ,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,YAAoB;IACpD,OAAO,SAAS,YAAY,QAAQ,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,aAAqB;IACpD,OAAO,GAAG,aAAa,QAAQ,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FileOp } from "../core/plan.js";
|
|
2
|
+
import { type ResourceLayer } from "../core/constants.js";
|
|
3
|
+
import type { ProjectContext } from "../core/project.js";
|
|
4
|
+
import type { ResourceTemplateContext } from "./resource-context.js";
|
|
5
|
+
export declare function planResourceLayer(project: ProjectContext, ctx: ResourceTemplateContext, layer: ResourceLayer, options?: {
|
|
6
|
+
overwrite?: boolean;
|
|
7
|
+
}): Promise<FileOp>;
|
|
8
|
+
//# sourceMappingURL=resource-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-file.d.ts","sourceRoot":"","sources":["../../src/generators/resource-file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAA8B,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGtF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAErE,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,cAAc,EACvB,GAAG,EAAE,uBAAuB,EAC5B,KAAK,EAAE,aAAa,EACpB,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,GAChC,OAAO,CAAC,MAAM,CAAC,CAIjB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FILE_OP, RESOURCE_TEMPLATE } from "../core/constants.js";
|
|
2
|
+
import { resourceFileRel } from "../core/paths.js";
|
|
3
|
+
import { renderTemplate } from "../core/render.js";
|
|
4
|
+
export async function planResourceLayer(project, ctx, layer, options) {
|
|
5
|
+
const rel = resourceFileRel(project, ctx.resourceKebab, layer);
|
|
6
|
+
const contents = await renderTemplate(RESOURCE_TEMPLATE[layer], ctx);
|
|
7
|
+
return { kind: FILE_OP.create, path: rel, contents, overwrite: options?.overwrite };
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=resource-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-file.js","sourceRoot":"","sources":["../../src/generators/resource-file.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAsB,MAAM,sBAAsB,CAAC;AACtF,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAInD,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,OAAuB,EACvB,GAA4B,EAC5B,KAAoB,EACpB,OAAiC;IAEjC,MAAM,GAAG,GAAG,eAAe,CAAC,OAAO,EAAE,GAAG,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;IAC/D,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,iBAAiB,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC;IACrE,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AACtF,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { FileOp } from "../core/plan.js";
|
|
2
|
+
import type { ProjectContext } from "../core/project.js";
|
|
3
|
+
import type { ResourceTemplateContext } from "./resource-context.js";
|
|
4
|
+
export declare function planResourceTests(_project: ProjectContext, ctx: ResourceTemplateContext): Promise<FileOp[]>;
|
|
5
|
+
//# sourceMappingURL=resource-tests.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-tests.d.ts","sourceRoot":"","sources":["../../src/generators/resource-tests.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAG9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAErE,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,cAAc,EACxB,GAAG,EAAE,uBAAuB,GAC3B,OAAO,CAAC,MAAM,EAAE,CAAC,CAYnB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { FILE_OP, RESOURCE_TEST_SUFFIX, TEMPLATE, TESTS_DIR } from "../core/constants.js";
|
|
3
|
+
import { renderTemplate } from "../core/render.js";
|
|
4
|
+
export async function planResourceTests(_project, ctx) {
|
|
5
|
+
if (!ctx.crud) {
|
|
6
|
+
return [];
|
|
7
|
+
}
|
|
8
|
+
const rel = join(TESTS_DIR, `${ctx.resourceKebab}.${RESOURCE_TEST_SUFFIX.repositoryFake}.ts`);
|
|
9
|
+
const contents = await renderTemplate(TEMPLATE.resourceTestsFake, ctx);
|
|
10
|
+
const testRel = join(TESTS_DIR, `${ctx.resourceKebab}.${RESOURCE_TEST_SUFFIX.moduleTest}.ts`);
|
|
11
|
+
const testContents = await renderTemplate(TEMPLATE.resourceTestsModule, ctx);
|
|
12
|
+
return [
|
|
13
|
+
{ kind: FILE_OP.create, path: rel, contents },
|
|
14
|
+
{ kind: FILE_OP.create, path: testRel, contents: testContents },
|
|
15
|
+
];
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=resource-tests.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-tests.js","sourceRoot":"","sources":["../../src/generators/resource-tests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC1F,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAInD,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,QAAwB,EACxB,GAA4B;IAE5B,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;QACd,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,EAAE,GAAG,GAAG,CAAC,aAAa,IAAI,oBAAoB,CAAC,cAAc,KAAK,CAAC,CAAC;IAC9F,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,QAAQ,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC;IACvE,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,EAAE,GAAG,GAAG,CAAC,aAAa,IAAI,oBAAoB,CAAC,UAAU,KAAK,CAAC,CAAC;IAC9F,MAAM,YAAY,GAAG,MAAM,cAAc,CAAC,QAAQ,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC;IAC7E,OAAO;QACL,EAAE,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE;QAC7C,EAAE,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE;KAChE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { FileOp } from "../core/plan.js";
|
|
2
|
+
import { type ResourcePlanMode } from "../core/constants.js";
|
|
3
|
+
import type { ProjectContext } from "../core/project.js";
|
|
4
|
+
import { importPathFromAppEntry, resourceFileRel } from "../core/paths.js";
|
|
5
|
+
import type { Generator } from "./types.js";
|
|
6
|
+
import { buildResourceContext, type ResourceField } from "./resource-context.js";
|
|
7
|
+
export interface ResourceOptions {
|
|
8
|
+
name: string;
|
|
9
|
+
crud?: boolean;
|
|
10
|
+
singular?: string;
|
|
11
|
+
fields?: ResourceField[];
|
|
12
|
+
force?: boolean;
|
|
13
|
+
tests?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function planResourceFiles(project: ProjectContext, tpl: ReturnType<typeof buildResourceContext>, mode?: ResourcePlanMode): Promise<FileOp[]>;
|
|
16
|
+
export declare function planCompositionRegistration(ctx: ProjectContext, tpl: ReturnType<typeof buildResourceContext>): FileOp;
|
|
17
|
+
/** @deprecated Use planCompositionRegistration */
|
|
18
|
+
export declare function planAppRouteRegistration(ctx: ProjectContext, tpl: ReturnType<typeof buildResourceContext>): FileOp;
|
|
19
|
+
export declare const resourceGenerator: Generator<ResourceOptions>;
|
|
20
|
+
export { resourceFileRel, importPathFromAppEntry };
|
|
21
|
+
//# sourceMappingURL=resource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../src/generators/resource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAG9C,OAAO,EAKL,KAAK,gBAAgB,EACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EACL,sBAAsB,EAEtB,eAAe,EAIhB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EACL,oBAAoB,EAEpB,KAAK,aAAa,EACnB,MAAM,uBAAuB,CAAC;AAI/B,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,aAAa,EAAE,CAAC;IACzB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,cAAc,EACvB,GAAG,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAAC,EAC5C,IAAI,GAAE,gBAA0C,GAC/C,OAAO,CAAC,MAAM,EAAE,CAAC,CAiBnB;AAED,wBAAgB,2BAA2B,CACzC,GAAG,EAAE,cAAc,EACnB,GAAG,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAAC,GAC3C,MAAM,CAcR;AAED,kDAAkD;AAClD,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,cAAc,EACnB,GAAG,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAAC,GAC3C,MAAM,CAER;AAED,eAAO,MAAM,iBAAiB,EAAE,SAAS,CAAC,eAAe,CAyCxD,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { pathExists } from "../core/plan.js";
|
|
2
|
+
import { ErrorCode, ChiselError } from "../core/errors.js";
|
|
3
|
+
import { FILE_OP, GENERATOR, RESOURCE_LAYER, RESOURCE_PLAN_MODE, } from "../core/constants.js";
|
|
4
|
+
import { importPathFromAppEntry, resourceDirRel, resourceFileRel, compositionRel, importPathFromComposition, resourceModuleFileBase, } from "../core/paths.js";
|
|
5
|
+
import { addNamedImportIfMissing, appendModuleRoutesSpreadIfMissing } from "../core/ast.js";
|
|
6
|
+
import { buildResourceContext, moduleFactoryName, } from "./resource-context.js";
|
|
7
|
+
import { planResourceLayer } from "./resource-file.js";
|
|
8
|
+
import { planResourceTests } from "./resource-tests.js";
|
|
9
|
+
export async function planResourceFiles(project, tpl, mode = RESOURCE_PLAN_MODE.full) {
|
|
10
|
+
const overwrite = mode === RESOURCE_PLAN_MODE.schema;
|
|
11
|
+
const ops = [await planResourceLayer(project, tpl, RESOURCE_LAYER.types, { overwrite })];
|
|
12
|
+
if (tpl.crud) {
|
|
13
|
+
ops.push(await planResourceLayer(project, tpl, RESOURCE_LAYER.validate, { overwrite }));
|
|
14
|
+
}
|
|
15
|
+
if (mode === RESOURCE_PLAN_MODE.schema) {
|
|
16
|
+
return ops;
|
|
17
|
+
}
|
|
18
|
+
ops.push(await planResourceLayer(project, tpl, RESOURCE_LAYER.repository), await planResourceLayer(project, tpl, RESOURCE_LAYER.service), await planResourceLayer(project, tpl, RESOURCE_LAYER.controller), await planResourceLayer(project, tpl, RESOURCE_LAYER.routes), await planResourceLayer(project, tpl, RESOURCE_LAYER.module));
|
|
19
|
+
return ops;
|
|
20
|
+
}
|
|
21
|
+
export function planCompositionRegistration(ctx, tpl) {
|
|
22
|
+
const factory = moduleFactoryName(tpl.entityPascal);
|
|
23
|
+
const moduleImport = importPathFromComposition(ctx, tpl.resourceKebab, resourceModuleFileBase(tpl.resourceKebab));
|
|
24
|
+
const compRel = compositionRel(ctx);
|
|
25
|
+
const callArgs = tpl.crud ? "{}" : "";
|
|
26
|
+
return {
|
|
27
|
+
kind: FILE_OP.modify,
|
|
28
|
+
path: compRel,
|
|
29
|
+
edit(sf) {
|
|
30
|
+
addNamedImportIfMissing(sf, moduleImport, [factory]);
|
|
31
|
+
appendModuleRoutesSpreadIfMissing(sf, factory, callArgs);
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** @deprecated Use planCompositionRegistration */
|
|
36
|
+
export function planAppRouteRegistration(ctx, tpl) {
|
|
37
|
+
return planCompositionRegistration(ctx, tpl);
|
|
38
|
+
}
|
|
39
|
+
export const resourceGenerator = {
|
|
40
|
+
name: GENERATOR.resource,
|
|
41
|
+
async plan(ctx, options) {
|
|
42
|
+
const tpl = buildResourceContext(options.name, Boolean(options.crud), options.singular, options.fields);
|
|
43
|
+
const dirRel = resourceDirRel(ctx, tpl.resourceKebab);
|
|
44
|
+
if (pathExists(ctx.root, dirRel) && !options.force) {
|
|
45
|
+
if (options.tests) {
|
|
46
|
+
const validateRel = resourceFileRel(ctx, tpl.resourceKebab, RESOURCE_LAYER.validate);
|
|
47
|
+
if (!pathExists(ctx.root, validateRel)) {
|
|
48
|
+
throw new ChiselError(ErrorCode.VALIDATION, `Cannot generate tests: ${dirRel} is not a CRUD resource (missing validate).`);
|
|
49
|
+
}
|
|
50
|
+
const crudTpl = buildResourceContext(options.name, true, options.singular, options.fields);
|
|
51
|
+
return planResourceTests(ctx, crudTpl);
|
|
52
|
+
}
|
|
53
|
+
throw new ChiselError(ErrorCode.ALREADY_EXISTS, `Resource directory already exists: ${dirRel}. Use --force to overwrite.`);
|
|
54
|
+
}
|
|
55
|
+
const ops = await planResourceFiles(ctx, tpl);
|
|
56
|
+
ops.push(planCompositionRegistration(ctx, tpl));
|
|
57
|
+
if (options.tests) {
|
|
58
|
+
ops.push(...(await planResourceTests(ctx, tpl)));
|
|
59
|
+
}
|
|
60
|
+
return ops;
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
export { resourceFileRel, importPathFromAppEntry };
|
|
64
|
+
//# sourceMappingURL=resource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.js","sourceRoot":"","sources":["../../src/generators/resource.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EACL,OAAO,EACP,SAAS,EACT,cAAc,EACd,kBAAkB,GAEnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,eAAe,EACf,cAAc,EACd,yBAAyB,EACzB,sBAAsB,GACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,uBAAuB,EAAE,iCAAiC,EAAE,MAAM,gBAAgB,CAAC;AAE5F,OAAO,EACL,oBAAoB,EACpB,iBAAiB,GAElB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAWxD,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,OAAuB,EACvB,GAA4C,EAC5C,IAAI,GAAqB,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version":3,"file":"types.js","sourceRoot":"","sources":["../../src/generators/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
|
|
2
|
+
┌─────────────────────────────────────────────────────────────────────┐
|
|
3
|
+
│ │
|
|
4
|
+
│ Aether · scaffold Node.js HTTP backends in plain TypeScript │
|
|
5
|
+
│ │
|
|
6
|
+
│ Generated apps run without Aether · zero runtime dependencies │
|
|
7
|
+
│ │
|
|
8
|
+
└─────────────────────────────────────────────────────────────────────┘
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
QUICK START
|
|
12
|
+
───────────────────────────────────────────────────────────────────────
|
|
13
|
+
|
|
14
|
+
mkdir my-api && cd my-api
|
|
15
|
+
aether init
|
|
16
|
+
npm install
|
|
17
|
+
aether g resource users --crud
|
|
18
|
+
npm run dev
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
WHAT YOU GET
|
|
22
|
+
───────────────────────────────────────────────────────────────────────
|
|
23
|
+
|
|
24
|
+
init HTTP server, router, composition, config from env,
|
|
25
|
+
structured logging, request logger, error handler,
|
|
26
|
+
health check, CORS, body limit, optional bearer auth,
|
|
27
|
+
list query helper (limit/offset)
|
|
28
|
+
|
|
29
|
+
resource types → validate → repository → service →
|
|
30
|
+
controller → routes → module (wired in composition)
|
|
31
|
+
|
|
32
|
+
middleware passthrough stub; optional global registration
|
|
33
|
+
|
|
34
|
+
openapi OpenAPI 3.0 JSON/YAML → CRUD resources (batch).
|
|
35
|
+
Re-run syncs types + validate; --force rewrites the module
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
COMMANDS
|
|
39
|
+
───────────────────────────────────────────────────────────────────────
|
|
40
|
+
|
|
41
|
+
aether init [options]
|
|
42
|
+
Scaffold a new project in the current directory.
|
|
43
|
+
|
|
44
|
+
-f, --force Overwrite scaffold files (never overwrites .env)
|
|
45
|
+
--dry-run Show planned files without writing
|
|
46
|
+
|
|
47
|
+
aether generate … alias: g
|
|
48
|
+
Generate application source under an initialized project.
|
|
49
|
+
|
|
50
|
+
g resource <name> [options]
|
|
51
|
+
--crud Full CRUD stack + validate layer
|
|
52
|
+
--singular <name> Entity name (default from resource name)
|
|
53
|
+
--tests With --crud on create; on existing CRUD,
|
|
54
|
+
adds tests/ only (fake repo + smoke test)
|
|
55
|
+
-f, --force Overwrite generated files
|
|
56
|
+
--dry-run
|
|
57
|
+
|
|
58
|
+
g middleware <name> [options]
|
|
59
|
+
--global Append to global chain in src/app.ts
|
|
60
|
+
--dry-run Without --global: file only, you wire routes
|
|
61
|
+
|
|
62
|
+
g openapi <spec> [options]
|
|
63
|
+
--strict Fail if any collection path is skipped
|
|
64
|
+
--only a,b Generate subset of resources
|
|
65
|
+
-f, --force
|
|
66
|
+
--dry-run
|
|
67
|
+
|
|
68
|
+
aether check
|
|
69
|
+
Verify project matches Aether layout (composition, config).
|
|
70
|
+
|
|
71
|
+
aether doctor
|
|
72
|
+
Node version, project context, packaged templates on disk.
|
|
73
|
+
|
|
74
|
+
aether upgrade
|
|
75
|
+
Human-readable checklist if the project drifted from the contract
|
|
76
|
+
(no automatic code migration).
|
|
77
|
+
|
|
78
|
+
aether help
|
|
79
|
+
This guide.
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
GLOBAL OPTIONS
|
|
83
|
+
───────────────────────────────────────────────────────────────────────
|
|
84
|
+
|
|
85
|
+
--json Machine-readable output (errors too)
|
|
86
|
+
--diff With --dry-run: unified diff preview
|
|
87
|
+
-V, --version
|
|
88
|
+
-h, --help Short command list (Commander)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
EXAMPLES
|
|
92
|
+
───────────────────────────────────────────────────────────────────────
|
|
93
|
+
|
|
94
|
+
Preview before write
|
|
95
|
+
aether init --dry-run --diff
|
|
96
|
+
|
|
97
|
+
CRUD + tests in one step
|
|
98
|
+
aether g resource orders --crud --tests
|
|
99
|
+
|
|
100
|
+
Add tests after the fact
|
|
101
|
+
aether g resource orders --tests
|
|
102
|
+
|
|
103
|
+
Auth on every request except /health
|
|
104
|
+
Set BEARER_TOKEN in .env (no extra generate step)
|
|
105
|
+
|
|
106
|
+
CORS for a browser origin
|
|
107
|
+
CORS_ORIGIN=http://localhost:5173
|
|
108
|
+
|
|
109
|
+
From API spec (re-run syncs fields, keeps your service)
|
|
110
|
+
aether g openapi ./api.yaml --strict
|
|
111
|
+
|
|
112
|
+
CI-friendly failure
|
|
113
|
+
aether check --json
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
NOTES
|
|
117
|
+
───────────────────────────────────────────────────────────────────────
|
|
118
|
+
|
|
119
|
+
· CommonJS output, local imports without .ts extensions
|
|
120
|
+
· CRUD repository is an interface — wire a real store in composition
|
|
121
|
+
· Collection GET: ?limit=1..100&offset=0 (defaults 50 / 0)
|
|
122
|
+
· OpenAPI: 3.0.x, JSON bodies, in-spec $ref to #/components/schemas
|
|
123
|
+
· OpenAPI re-run updates types/validate only; --force regenerates the module
|
|
124
|
+
· Per-route middleware: not generated; use route handlers or extend router
|
|
125
|
+
|
|
126
|
+
More for CLI contributors: AGENTS.md and specs/ in the repository.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-resources.d.ts","sourceRoot":"","sources":["../../src/openapi/extract-resources.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EAGb,eAAe,EAGhB,MAAM,YAAY,CAAC;AA8FpB,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,eAAe,EAAE,OAAO,GAAE,cAAmB,GAAG,aAAa,CAmDlG"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { ENTITY_ID_FIELD, JSON_MIME, OPENAPI_HTTP_METHOD, OPENAPI_SCHEMA_REF_PREFIX, OPENAPI_SCHEMA_TYPE, TS_SCALAR_TYPE, } from "../core/constants.js";
|
|
2
|
+
function mapOpenApiType(schema) {
|
|
3
|
+
if (schema.enum && schema.enum.length > 0) {
|
|
4
|
+
return TS_SCALAR_TYPE.string;
|
|
5
|
+
}
|
|
6
|
+
if (schema.type === OPENAPI_SCHEMA_TYPE.string)
|
|
7
|
+
return TS_SCALAR_TYPE.string;
|
|
8
|
+
if (schema.type === OPENAPI_SCHEMA_TYPE.boolean)
|
|
9
|
+
return TS_SCALAR_TYPE.boolean;
|
|
10
|
+
if (schema.type === OPENAPI_SCHEMA_TYPE.number || schema.type === OPENAPI_SCHEMA_TYPE.integer) {
|
|
11
|
+
return TS_SCALAR_TYPE.number;
|
|
12
|
+
}
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
function resolveSchema(doc, schema) {
|
|
16
|
+
if (!schema)
|
|
17
|
+
return undefined;
|
|
18
|
+
const ref = schema.$ref;
|
|
19
|
+
if (!ref)
|
|
20
|
+
return schema;
|
|
21
|
+
const prefix = OPENAPI_SCHEMA_REF_PREFIX;
|
|
22
|
+
if (!ref.startsWith(prefix)) {
|
|
23
|
+
throw new Error(`Unsupported $ref: ${ref}. Only ${prefix}{Name} is supported.`);
|
|
24
|
+
}
|
|
25
|
+
const name = ref.slice(prefix.length);
|
|
26
|
+
return doc.components?.schemas?.[name];
|
|
27
|
+
}
|
|
28
|
+
function fieldsFromRequestSchema(doc, item, method) {
|
|
29
|
+
const op = item[method];
|
|
30
|
+
const schema = resolveSchema(doc, op?.requestBody?.content?.[JSON_MIME]?.schema);
|
|
31
|
+
if (!schema?.properties)
|
|
32
|
+
return undefined;
|
|
33
|
+
const requiredSet = new Set(schema.required ?? []);
|
|
34
|
+
const fields = [];
|
|
35
|
+
for (const [name, propSchema] of Object.entries(schema.properties)) {
|
|
36
|
+
if (name === ENTITY_ID_FIELD)
|
|
37
|
+
continue;
|
|
38
|
+
const resolved = resolveSchema(doc, propSchema) ?? propSchema;
|
|
39
|
+
const tsType = mapOpenApiType(resolved);
|
|
40
|
+
if (!tsType)
|
|
41
|
+
continue;
|
|
42
|
+
const required = requiredSet.has(name) && !resolved.nullable;
|
|
43
|
+
fields.push({ name, tsType, required });
|
|
44
|
+
}
|
|
45
|
+
return fields.length > 0 ? fields : undefined;
|
|
46
|
+
}
|
|
47
|
+
function mergeFieldSets(post, patch) {
|
|
48
|
+
const map = new Map();
|
|
49
|
+
for (const f of post) {
|
|
50
|
+
map.set(f.name, f);
|
|
51
|
+
}
|
|
52
|
+
for (const f of patch) {
|
|
53
|
+
if (!map.has(f.name)) {
|
|
54
|
+
map.set(f.name, { ...f, required: false });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return [...map.values()];
|
|
58
|
+
}
|
|
59
|
+
function normalizePath(path) {
|
|
60
|
+
if (path.length > 1 && path.endsWith("/")) {
|
|
61
|
+
return path.slice(0, -1);
|
|
62
|
+
}
|
|
63
|
+
return path;
|
|
64
|
+
}
|
|
65
|
+
function collectionNameAndPrefix(path) {
|
|
66
|
+
const segments = path.split("/").filter(Boolean);
|
|
67
|
+
if (segments.length === 0)
|
|
68
|
+
return null;
|
|
69
|
+
const name = segments[segments.length - 1];
|
|
70
|
+
const prefixSegments = segments.slice(0, -1);
|
|
71
|
+
const routePrefix = prefixSegments.length > 0 ? `/${prefixSegments.join("/")}` : "";
|
|
72
|
+
return { name, routePrefix };
|
|
73
|
+
}
|
|
74
|
+
function findItemPathForCollection(paths, collectionPath) {
|
|
75
|
+
for (const rawPath of Object.keys(paths)) {
|
|
76
|
+
const path = normalizePath(rawPath);
|
|
77
|
+
const match = path.match(/^(.+)\/\{[^}]+\}$/);
|
|
78
|
+
if (!match)
|
|
79
|
+
continue;
|
|
80
|
+
if (normalizePath(match[1]) === collectionPath) {
|
|
81
|
+
return rawPath;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
export function extractResources(doc, options = {}) {
|
|
87
|
+
const paths = doc.paths ?? {};
|
|
88
|
+
const skipped = [];
|
|
89
|
+
const resources = [];
|
|
90
|
+
const onlySet = options.only ? new Set(options.only.map((n) => n.toLowerCase())) : undefined;
|
|
91
|
+
for (const rawPath of Object.keys(paths)) {
|
|
92
|
+
const path = normalizePath(rawPath);
|
|
93
|
+
const parsed = collectionNameAndPrefix(path);
|
|
94
|
+
if (!parsed)
|
|
95
|
+
continue;
|
|
96
|
+
const collectionItem = paths[rawPath];
|
|
97
|
+
if (!collectionItem)
|
|
98
|
+
continue;
|
|
99
|
+
const itemRaw = findItemPathForCollection(paths, path);
|
|
100
|
+
if (!itemRaw) {
|
|
101
|
+
skipped.push({ path: rawPath, reason: "missing item path with path parameter" });
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
const postFields = fieldsFromRequestSchema(doc, collectionItem, OPENAPI_HTTP_METHOD.post);
|
|
105
|
+
if (!postFields) {
|
|
106
|
+
skipped.push({ path: rawPath, reason: "missing POST JSON request body schema" });
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
const itemPath = paths[itemRaw];
|
|
110
|
+
const patchFields = fieldsFromRequestSchema(doc, itemPath, OPENAPI_HTTP_METHOD.patch) ??
|
|
111
|
+
fieldsFromRequestSchema(doc, itemPath, OPENAPI_HTTP_METHOD.put) ??
|
|
112
|
+
[];
|
|
113
|
+
const fields = mergeFieldSets(postFields, patchFields);
|
|
114
|
+
if (onlySet && !onlySet.has(parsed.name.toLowerCase())) {
|
|
115
|
+
skipped.push({ path: rawPath, reason: "filtered by --only" });
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
resources.push({
|
|
119
|
+
name: parsed.name,
|
|
120
|
+
fields,
|
|
121
|
+
routePrefix: parsed.routePrefix,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
if (options.strict && skipped.length > 0) {
|
|
125
|
+
const detail = skipped.map((s) => `${s.path}: ${s.reason}`).join("; ");
|
|
126
|
+
throw new Error(`OpenAPI strict mode: skipped paths — ${detail}`);
|
|
127
|
+
}
|
|
128
|
+
return { resources, skipped };
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=extract-resources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
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AM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvE,MAAM,IAAI,KAAK,CAAC,wCAAwC,MAAM,EAAE,CAAC,CAAC;IACpE,CAAC;IAED,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-spec.d.ts","sourceRoot":"","sources":["../../src/openapi/load-spec.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,CAehE"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { extname } from "node:path";
|
|
3
|
+
import { parse as parseYaml } from "yaml";
|
|
4
|
+
import { OPENAPI_VERSION_PREFIX } from "../core/constants.js";
|
|
5
|
+
export function loadOpenApiSpec(absPath) {
|
|
6
|
+
const raw = readFileSync(absPath, "utf8");
|
|
7
|
+
const ext = extname(absPath).toLowerCase();
|
|
8
|
+
const doc = ext === ".yaml" || ext === ".yml"
|
|
9
|
+
? parseYaml(raw)
|
|
10
|
+
: JSON.parse(raw);
|
|
11
|
+
if (!doc.openapi?.startsWith(OPENAPI_VERSION_PREFIX)) {
|
|
12
|
+
throw new Error("Only OpenAPI 3.x documents are supported.");
|
|
13
|
+
}
|
|
14
|
+
if (!doc.paths || typeof doc.paths !== "object") {
|
|
15
|
+
throw new Error("OpenAPI document has no paths.");
|
|
16
|
+
}
|
|
17
|
+
return doc;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=load-spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-spec.js","sourceRoot":"","sources":["../../src/openapi/load-spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAG9D,MAAM,UAAU,eAAe,CAAC,OAAe;IAC7C,MAAM,GAAG,GAAG,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC1C,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;IAC3C,MAAM,GAAG,GACP,GAAG,KAAK,OAAO,IAAI,GAAG,KAAK,MAAM;QAC/B,CAAC,CAAE,SAAS,CAAC,GAAG,CAAqB;QACrC,CAAC,CAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAqB,CAAC;IAE3C,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,UAAU,CAAC,sBAAsB,CAAC,EAAE,CAAC;QACrD,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC/D,CAAC;IACD,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,OAAO,GAAG,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACpD,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { JSON_MIME } from "../core/constants.js";
|
|
2
|
+
import type { ResourceField } from "../generators/resource-context.js";
|
|
3
|
+
export interface OpenApiDocument {
|
|
4
|
+
openapi?: string;
|
|
5
|
+
paths?: Record<string, PathItem>;
|
|
6
|
+
components?: {
|
|
7
|
+
schemas?: Record<string, JsonSchema>;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export interface PathItem {
|
|
11
|
+
get?: Operation;
|
|
12
|
+
post?: Operation;
|
|
13
|
+
put?: Operation;
|
|
14
|
+
patch?: Operation;
|
|
15
|
+
delete?: Operation;
|
|
16
|
+
}
|
|
17
|
+
export interface Operation {
|
|
18
|
+
requestBody?: {
|
|
19
|
+
content?: {
|
|
20
|
+
[JSON_MIME]?: {
|
|
21
|
+
schema?: JsonSchema;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export interface JsonSchema {
|
|
27
|
+
type?: string;
|
|
28
|
+
properties?: Record<string, JsonSchema>;
|
|
29
|
+
required?: string[];
|
|
30
|
+
$ref?: string;
|
|
31
|
+
enum?: unknown[];
|
|
32
|
+
nullable?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface ExtractedResource {
|
|
35
|
+
name: string;
|
|
36
|
+
fields: ResourceField[];
|
|
37
|
+
routePrefix: string;
|
|
38
|
+
}
|
|
39
|
+
export interface SkippedPath {
|
|
40
|
+
path: string;
|
|
41
|
+
reason: string;
|
|
42
|
+
}
|
|
43
|
+
export interface ExtractResult {
|
|
44
|
+
resources: ExtractedResource[];
|
|
45
|
+
skipped: SkippedPath[];
|
|
46
|
+
}
|
|
47
|
+
export interface ExtractOptions {
|
|
48
|
+
strict?: boolean;
|
|
49
|
+
only?: string[];
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/openapi/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAEvE,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACjC,UAAU,CAAC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