@sohcah/openapi-generator 0.1.2 → 0.2.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/{chunk-51aI8Tpl.js → chunk-DYFKRlHt.js} +4 -1
- package/dist/cli.js +2 -2
- package/dist/config.d.ts +2 -2
- package/dist/generators/index.d.ts +1 -61
- package/dist/generators/index.d.ts.map +1 -1
- package/dist/generators/index.js +49 -16
- package/dist/generators/index.js.map +1 -1
- package/dist/{helpers-tkoILkcL.js → helpers-CqzmoMek.js} +4 -3
- package/dist/{helpers-tkoILkcL.js.map → helpers-CqzmoMek.js.map} +1 -1
- package/dist/{index-BOme2BJ_.d.ts → index-DY2v-Q37.d.ts} +5 -7
- package/dist/index-DY2v-Q37.d.ts.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/src-CjChjKnL.js +7997 -0
- package/dist/src-CjChjKnL.js.map +1 -0
- package/dist/types-DMB5w9Tt.d.ts +147 -0
- package/dist/types-DMB5w9Tt.d.ts.map +1 -0
- package/package.json +2 -2
- package/dist/index-BOme2BJ_.d.ts.map +0 -1
- package/dist/src-Di4R7y_C.js +0 -164
- package/dist/src-Di4R7y_C.js.map +0 -1
- package/dist/types-DjImZ4S-.d.ts +0 -71
- package/dist/types-DjImZ4S-.d.ts.map +0 -1
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { Context, Data, Effect } from "effect";
|
|
2
|
+
import * as t from "@babel/types";
|
|
3
|
+
import { OpenAPIV3_2 } from "@scalar/openapi-types";
|
|
4
|
+
|
|
5
|
+
//#region src/errors.d.ts
|
|
6
|
+
declare class NotImplementedError extends Data.Error<{
|
|
7
|
+
message: string;
|
|
8
|
+
}> {}
|
|
9
|
+
declare class FailedToUpgradeOpenApiDocumentError extends Data.Error<{
|
|
10
|
+
cause: unknown;
|
|
11
|
+
}> {}
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/types.d.ts
|
|
14
|
+
type APIDocument<T extends object> = OpenAPIV3_2.Document<T>;
|
|
15
|
+
type SchemaObject = OpenAPIV3_2.SchemaObject;
|
|
16
|
+
type OperationObject = OpenAPIV3_2.OperationObject;
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/generators/schema.d.ts
|
|
19
|
+
interface SchemaGeneratorOptions {
|
|
20
|
+
/** @default null */
|
|
21
|
+
custom?: (schema: SchemaObject) => ImportReference | null;
|
|
22
|
+
/** @default false */
|
|
23
|
+
experimental_includeTypes?: boolean;
|
|
24
|
+
/** @default true */
|
|
25
|
+
includeSchemas?: boolean;
|
|
26
|
+
/** @default false */
|
|
27
|
+
includeOperations?: boolean;
|
|
28
|
+
/** @default "unknown" */
|
|
29
|
+
deprecationHandling?: "unknown" | "optional";
|
|
30
|
+
}
|
|
31
|
+
interface DefaultSchemaGeneratorOptions extends SchemaGeneratorOptions {
|
|
32
|
+
modifiers: {
|
|
33
|
+
lazy: (expression: t.Expression) => t.Expression;
|
|
34
|
+
optional: (expression: t.Expression) => t.Expression;
|
|
35
|
+
regex: (expression: t.Expression, pattern: string) => t.Expression;
|
|
36
|
+
immutable: (expression: t.Expression) => t.Expression;
|
|
37
|
+
mutable: (expression: t.Expression) => t.Expression;
|
|
38
|
+
nullable: (expression: t.Expression) => t.Expression;
|
|
39
|
+
};
|
|
40
|
+
types: {
|
|
41
|
+
schema: t.TSQualifiedName;
|
|
42
|
+
typeDecoded: t.TSQualifiedName;
|
|
43
|
+
typeEncoded: t.TSQualifiedName;
|
|
44
|
+
};
|
|
45
|
+
schema: {
|
|
46
|
+
record: (key: t.Expression, value: t.Expression) => t.Expression;
|
|
47
|
+
union: (expressions: t.Expression[]) => t.Expression;
|
|
48
|
+
intersection: (expressions: t.Expression[]) => t.Expression;
|
|
49
|
+
objectExtend: (expressions: t.Expression[]) => t.Expression;
|
|
50
|
+
enum: (expressions: t.Expression[]) => t.Expression;
|
|
51
|
+
instanceOf: t.Expression;
|
|
52
|
+
boolean: t.Expression;
|
|
53
|
+
string: t.Expression;
|
|
54
|
+
number: t.Expression;
|
|
55
|
+
integer: t.Expression;
|
|
56
|
+
array: t.Expression;
|
|
57
|
+
object: t.Expression;
|
|
58
|
+
null: t.Expression;
|
|
59
|
+
unknown: t.Expression;
|
|
60
|
+
};
|
|
61
|
+
transformer: (options: {
|
|
62
|
+
encoded: t.Expression;
|
|
63
|
+
decoded: t.Expression;
|
|
64
|
+
decode: t.Expression | t.BlockStatement;
|
|
65
|
+
decodeAsync?: boolean;
|
|
66
|
+
encode: t.Expression | t.BlockStatement;
|
|
67
|
+
encodeAsync?: boolean;
|
|
68
|
+
}) => t.Expression;
|
|
69
|
+
transformerCatch: (expression: t.Expression) => t.BlockStatement;
|
|
70
|
+
methods: {
|
|
71
|
+
encode: (schema: t.Expression, value: t.Expression) => t.Expression;
|
|
72
|
+
decode: (schema: t.Expression, value: t.Expression) => t.Expression;
|
|
73
|
+
parse: (schema: t.Expression, value: t.Expression) => t.Expression;
|
|
74
|
+
};
|
|
75
|
+
supportsImmutability: boolean;
|
|
76
|
+
}
|
|
77
|
+
type ExpressionWithType = {
|
|
78
|
+
expression: t.Expression;
|
|
79
|
+
typeDecoded: t.TSType;
|
|
80
|
+
typeEncoded: t.TSType;
|
|
81
|
+
typeMeta: {
|
|
82
|
+
readonly?: boolean;
|
|
83
|
+
optional?: boolean;
|
|
84
|
+
isObject?: boolean;
|
|
85
|
+
isNull?: boolean;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
declare function createSchemaGenerator(options: DefaultSchemaGeneratorOptions): OpenApiSchemaGenerator;
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/context.d.ts
|
|
91
|
+
interface DocumentContextData {
|
|
92
|
+
document: APIDocument<object>;
|
|
93
|
+
imports: t.ImportDeclaration[];
|
|
94
|
+
schemas: Map<string, t.Statement[]>;
|
|
95
|
+
schemaTypeMeta: Map<string, ExpressionWithType["typeMeta"]>;
|
|
96
|
+
processingSchemas: Set<string>;
|
|
97
|
+
processingSchemaTypes: Set<string>;
|
|
98
|
+
}
|
|
99
|
+
declare const DocumentContext_base: Context.TagClass<DocumentContext, "DocumentContext", DocumentContextData>;
|
|
100
|
+
declare class DocumentContext extends DocumentContext_base {}
|
|
101
|
+
declare namespace helpers_d_exports {
|
|
102
|
+
export { HttpMethod, OperationKey, ensureImport, ensureNamespaceImport, getKey, httpMethods, notImplementedStatement };
|
|
103
|
+
}
|
|
104
|
+
declare const ensureImport: (name: string, from: string, typeOnly?: boolean | undefined) => Effect.Effect<t.Identifier, never, DocumentContext>;
|
|
105
|
+
declare const ensureNamespaceImport: (name: string, from: string) => Effect.Effect<t.Identifier, never, DocumentContext>;
|
|
106
|
+
declare const getKey: (name: string) => Effect.Effect<{
|
|
107
|
+
lower: string;
|
|
108
|
+
upper: string;
|
|
109
|
+
}, NotImplementedError, never>;
|
|
110
|
+
type OperationKey = {
|
|
111
|
+
lower: string;
|
|
112
|
+
upper: string;
|
|
113
|
+
};
|
|
114
|
+
declare const httpMethods: readonly ["get", "post", "put", "delete", "options", "head", "patch", "trace"];
|
|
115
|
+
type HttpMethod = (typeof httpMethods)[number];
|
|
116
|
+
declare const notImplementedStatement: t.BlockStatement;
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region src/generators/types.d.ts
|
|
119
|
+
interface ImportReference {
|
|
120
|
+
type: "import";
|
|
121
|
+
name: string;
|
|
122
|
+
from: string;
|
|
123
|
+
}
|
|
124
|
+
interface OpenApiGenerator {
|
|
125
|
+
initialize?: () => Effect.Effect<void, NotImplementedError, DocumentContext>;
|
|
126
|
+
processSchema?: (schema: SchemaObject) => Effect.Effect<void, NotImplementedError, DocumentContext>;
|
|
127
|
+
processOperation?: (operationKey: OperationKey, path: string, method: HttpMethod, operation: OperationObject) => Effect.Effect<void, NotImplementedError, DocumentContext>;
|
|
128
|
+
}
|
|
129
|
+
interface OpenApiParametersSchema {
|
|
130
|
+
expression: t.Expression;
|
|
131
|
+
typeReference: t.TSTypeReference;
|
|
132
|
+
}
|
|
133
|
+
interface OpenApiResponseSchema {
|
|
134
|
+
expression: t.Expression;
|
|
135
|
+
typeReference: t.TSTypeReference;
|
|
136
|
+
}
|
|
137
|
+
interface OpenApiSchemaGenerator extends OpenApiGenerator {
|
|
138
|
+
decodeResponse: (schema: t.Expression, response: t.Expression) => Effect.Effect<t.Expression>;
|
|
139
|
+
encodeParameters: (schema: t.Expression, parameters: t.Expression) => Effect.Effect<t.Expression>;
|
|
140
|
+
ensureParametersSchema: (operationKey: OperationKey, operation: OperationObject, path: string) => Effect.Effect<OpenApiParametersSchema, NotImplementedError, DocumentContext>;
|
|
141
|
+
ensureResponseSchema: (operationKey: OperationKey, operation: OperationObject) => Effect.Effect<OpenApiResponseSchema, NotImplementedError, DocumentContext>;
|
|
142
|
+
get schemaType(): t.TSEntityName;
|
|
143
|
+
}
|
|
144
|
+
interface OpenApiClientGenerator extends OpenApiGenerator {}
|
|
145
|
+
//#endregion
|
|
146
|
+
export { DocumentContext, FailedToUpgradeOpenApiDocumentError, HttpMethod, ImportReference, NotImplementedError, OpenApiClientGenerator, OpenApiGenerator, OpenApiParametersSchema, OpenApiResponseSchema, OpenApiSchemaGenerator, OperationKey, OperationObject, SchemaGeneratorOptions, SchemaObject, createSchemaGenerator, helpers_d_exports };
|
|
147
|
+
//# sourceMappingURL=types-DMB5w9Tt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-DMB5w9Tt.d.ts","names":[],"sources":["../../src/errors.ts","../../src/types.ts","../../src/generators/schema.ts","../../src/context.ts","../../src/generators/helpers.ts","../../src/generators/types.ts"],"sourcesContent":[],"mappings":";;;;;cAEa,mBAAA,SAA4B,IAAA,CAAK;;;cAEjC,mCAAA,SAA4C,IAAA,CAAK;EAFjD,KAAA,EAAA,OAAA;AAEb,CAAA,CAAA,CAAA;;;KCFY,gCAAgC,WAAA,CAAG,SAAS;KAI5C,YAAA,GAAe,WAAA,CAAG;KAElB,eAAA,GAAk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A,CAAE,UHDzC,CAAA;EAAA,sBAAA,EAAA,CAAA,YAAA,EGCsC,YHDtC,EAAA,SAAA,EGIhC,eHJgC,EAAA,IAAA,EAAA,MAAA,EAAA,GGMxC,MAAA,CAAO,MHNiC,CGO3C,uBHP2C,EGQ3C,mBHR2C,EGS3C,eHT2C,CAAA;EAAA,oBAEtB,EAAA,CAAA,YAAA,EGIL,YHJK,EAAA,SAAA,EGWV,eHXU,EAAA,GGYlB,MAAA,CAAO,MHZW,CGarB,qBHbqB,EGcrB,mBHdqB,EGerB,eHfqB,CAAA;EAAU,IAAK,UAAE,EAAA,EGiBtB,CAAA,CAAE,YHjBoB;;AACE,UGmB3B,sBAAA,SAA+B,gBHnBF,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sohcah/openapi-generator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Sam Hindess <mail@sohcah.dev>",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@effect/rpc": "^0.69.0",
|
|
61
61
|
"@effect/sql": "^0.44.1",
|
|
62
62
|
"@effect/typeclass": "^0.36.0",
|
|
63
|
-
"@
|
|
63
|
+
"@scalar/openapi-parser": "^0.23.9",
|
|
64
64
|
"effect": "^3.17.7",
|
|
65
65
|
"regex-escape": "^3.4.11",
|
|
66
66
|
"zod": "^4.1.11"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-BOme2BJ_.d.ts","names":[],"sources":["../../src/generator.ts","../../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;KASY,gBAAA;cACE;AADd,CAAA;;;KCEK,gCACD,SAAA,CAAU,SAAS,KACnB,WAAA,CAAY,SAAS,KACrB,SAAA,CAAU,SAAS;KAEX,sBAAA,GAAyB;UAC3B;ADRV,CAAA;KCWY,4BAAA,GAA+B;;;EATtC,WAAA,CAAA,EAAW,GAAA,GAAA,IAAA;CAAA;AACO,cAcV,QAdU,EAAA,CAAA,MAAA,EAcF,sBAdE,EAAA,GAcF,MAAA,CAAA,MAdE,CAAA,MAAA,EAcF,mBAAA,EAdE,KAAA,CAAA;AAAnB,cA8BS,cA9BC,EAAA,CAAA,MAAA,EA8Ba,4BA9Bb,EAAA,GA8Ba,MAAA,CAAA,MA9Bb,CAAA,IAAA,EA8Ba,mBAAA,GAAA,uBAAA,CAAA,aA9Bb,EA8Ba,UA9Bb,CAAA"}
|
package/dist/src-Di4R7y_C.js
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import { __toESM } from "./chunk-51aI8Tpl.js";
|
|
2
|
-
import { DocumentContext, NotImplementedError, getKey, httpMethods, require_lib } from "./helpers-tkoILkcL.js";
|
|
3
|
-
import { Effect, Stream } from "effect";
|
|
4
|
-
import { bundle } from "@readme/openapi-parser";
|
|
5
|
-
import { generate } from "@babel/generator";
|
|
6
|
-
import { FileSystem } from "@effect/platform/FileSystem";
|
|
7
|
-
|
|
8
|
-
//#region package.json
|
|
9
|
-
var name = "@sohcah/openapi-generator";
|
|
10
|
-
var version = "0.1.2";
|
|
11
|
-
var type = "module";
|
|
12
|
-
var license = "MIT";
|
|
13
|
-
var author = "Sam Hindess <mail@sohcah.dev>";
|
|
14
|
-
var files = ["dist"];
|
|
15
|
-
var publishConfig = { "access": "public" };
|
|
16
|
-
var main = "./dist/index.js";
|
|
17
|
-
var module = "./dist/index.js";
|
|
18
|
-
var types = "./dist/index.d.ts";
|
|
19
|
-
var bin = "./dist/cli.js";
|
|
20
|
-
var exports = {
|
|
21
|
-
".": {
|
|
22
|
-
"default": "./dist/index.js",
|
|
23
|
-
"types": "./dist/index.d.ts"
|
|
24
|
-
},
|
|
25
|
-
"./config": {
|
|
26
|
-
"default": "./dist/config.js",
|
|
27
|
-
"types": "./dist/config.d.ts"
|
|
28
|
-
},
|
|
29
|
-
"./generators": {
|
|
30
|
-
"default": "./dist/generators/index.js",
|
|
31
|
-
"types": "./dist/generators/index.d.ts"
|
|
32
|
-
},
|
|
33
|
-
"./package.json": "./package.json"
|
|
34
|
-
};
|
|
35
|
-
var engines = { "node": ">=22.16.0" };
|
|
36
|
-
var scripts = {
|
|
37
|
-
"build": "tsdown",
|
|
38
|
-
"dev": "tsdown --watch",
|
|
39
|
-
"test": "vitest --run",
|
|
40
|
-
"cli": "./dist/cli.js",
|
|
41
|
-
"sample": "yarn build && yarn cli generate -c ./sample/openapi.config.ts && SCHEMA_FORMAT=effect yarn cli generate -c ./sample/openapi.config.ts && SCHEMA_FORMAT=zod-mini yarn cli generate -c ./sample/openapi.config.ts"
|
|
42
|
-
};
|
|
43
|
-
var devDependencies = {
|
|
44
|
-
"@tanstack/react-query": "^5.85.3",
|
|
45
|
-
"@types/babel__generator": "^7.27.0",
|
|
46
|
-
"@types/node": "^24.3.0",
|
|
47
|
-
"@types/regex-escape": "^3",
|
|
48
|
-
"openapi-types": "^12.1.3",
|
|
49
|
-
"tsdown": "^0.14.1",
|
|
50
|
-
"typescript": "^5.9.2",
|
|
51
|
-
"vitest": "^3.2.4"
|
|
52
|
-
};
|
|
53
|
-
var dependencies = {
|
|
54
|
-
"@babel/generator": "^7.28.3",
|
|
55
|
-
"@effect/cli": "^0.69.0",
|
|
56
|
-
"@effect/cluster": "^0.48.0",
|
|
57
|
-
"@effect/experimental": "^0.54.6",
|
|
58
|
-
"@effect/platform": "^0.90.3",
|
|
59
|
-
"@effect/platform-node": "^0.96.0",
|
|
60
|
-
"@effect/printer-ansi": "^0.45.0",
|
|
61
|
-
"@effect/rpc": "^0.69.0",
|
|
62
|
-
"@effect/sql": "^0.44.1",
|
|
63
|
-
"@effect/typeclass": "^0.36.0",
|
|
64
|
-
"@readme/openapi-parser": "^5.0.1",
|
|
65
|
-
"effect": "^3.17.7",
|
|
66
|
-
"regex-escape": "^3.4.11",
|
|
67
|
-
"zod": "^4.1.11"
|
|
68
|
-
};
|
|
69
|
-
var volta = { "extends": "../../package.json" };
|
|
70
|
-
var package_default = {
|
|
71
|
-
name,
|
|
72
|
-
version,
|
|
73
|
-
type,
|
|
74
|
-
license,
|
|
75
|
-
author,
|
|
76
|
-
files,
|
|
77
|
-
publishConfig,
|
|
78
|
-
main,
|
|
79
|
-
module,
|
|
80
|
-
types,
|
|
81
|
-
bin,
|
|
82
|
-
exports,
|
|
83
|
-
engines,
|
|
84
|
-
scripts,
|
|
85
|
-
devDependencies,
|
|
86
|
-
dependencies,
|
|
87
|
-
volta
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
//#endregion
|
|
91
|
-
//#region src/generator.ts
|
|
92
|
-
var import_lib = /* @__PURE__ */ __toESM(require_lib(), 1);
|
|
93
|
-
const build = Effect.fn(function* (options) {
|
|
94
|
-
const ctx = yield* DocumentContext;
|
|
95
|
-
for (const generator of options.generators) {
|
|
96
|
-
if (!generator.initialize) continue;
|
|
97
|
-
yield* generator.initialize();
|
|
98
|
-
}
|
|
99
|
-
for (const [pathKey, path] of Object.entries(ctx.document.paths ?? {})) {
|
|
100
|
-
if (!path) continue;
|
|
101
|
-
if (path.$ref) return yield* new NotImplementedError({ message: "$ref in path" });
|
|
102
|
-
for (const methodKey of httpMethods) {
|
|
103
|
-
const method = path[methodKey];
|
|
104
|
-
if (!method) continue;
|
|
105
|
-
const operationKey = yield* getKey(method.operationId ?? `${methodKey}${pathKey.replace(/\/(.?)/g, (_, g) => g.toUpperCase())}`);
|
|
106
|
-
for (const generator of options.generators) {
|
|
107
|
-
if (!generator.processOperation) continue;
|
|
108
|
-
yield* generator.processOperation(operationKey, pathKey, methodKey, method);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
for (const schema of Object.values(ctx.document.components?.schemas ?? {})) for (const generator of options.generators) {
|
|
113
|
-
if (!generator.processSchema) continue;
|
|
114
|
-
yield* generator.processSchema(schema);
|
|
115
|
-
}
|
|
116
|
-
const program = import_lib.program([...ctx.imports, ...[...ctx.schemas.values()].flat()]);
|
|
117
|
-
import_lib.addComment(program, "leading", "eslint-disable", false);
|
|
118
|
-
import_lib.addComment(program, "leading", "prettier-ignore", false);
|
|
119
|
-
import_lib.addComment(program, "leading", ` Version: ${package_default.version}`, true);
|
|
120
|
-
import_lib.addComment(program, "leading", ` Generated by @sohcah/openapi-generator`, true);
|
|
121
|
-
return program;
|
|
122
|
-
});
|
|
123
|
-
const generate$1 = Effect.fn(function* (document, options) {
|
|
124
|
-
const context = {
|
|
125
|
-
document,
|
|
126
|
-
imports: [],
|
|
127
|
-
schemas: /* @__PURE__ */ new Map(),
|
|
128
|
-
processingSchemas: /* @__PURE__ */ new Set(),
|
|
129
|
-
processingSchemaTypes: /* @__PURE__ */ new Set()
|
|
130
|
-
};
|
|
131
|
-
return yield* build(options).pipe(Effect.provideService(DocumentContext, context));
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
//#endregion
|
|
135
|
-
//#region src/index.ts
|
|
136
|
-
const generate$2 = Effect.fn(function* ({ schema,...options }) {
|
|
137
|
-
const result = yield* Effect.tryPromise(() => bundle(schema));
|
|
138
|
-
if (!("components" in result)) return yield* Effect.die(/* @__PURE__ */ new Error("Not a valid OpenAPI 3.x document"));
|
|
139
|
-
const program = yield* generate$1(result, options);
|
|
140
|
-
return generate(program).code;
|
|
141
|
-
});
|
|
142
|
-
const generateToFile = Effect.fn(function* ({ onGenerated, output, watch,...options }) {
|
|
143
|
-
const fs = yield* FileSystem;
|
|
144
|
-
let lastCode = yield* generate$2(options);
|
|
145
|
-
yield* fs.writeFileString(output, lastCode);
|
|
146
|
-
onGenerated?.();
|
|
147
|
-
if (watch) {
|
|
148
|
-
if (typeof options.schema !== "string") throw new Error("Schema must a file path to use watch mode");
|
|
149
|
-
yield* Stream.runForEach(fs.watch(options.schema), Effect.fn(function* (event) {
|
|
150
|
-
if (event._tag === "Update") {
|
|
151
|
-
const outputCode = yield* generate$2(options);
|
|
152
|
-
if (outputCode !== lastCode) {
|
|
153
|
-
yield* fs.writeFileString(output, outputCode);
|
|
154
|
-
onGenerated?.();
|
|
155
|
-
lastCode = outputCode;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}));
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
//#endregion
|
|
163
|
-
export { generate$2 as generate, generateToFile };
|
|
164
|
-
//# sourceMappingURL=src-Di4R7y_C.js.map
|
package/dist/src-Di4R7y_C.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"src-Di4R7y_C.js","names":["options: GeneratorOptions","t","packageJson","generate","document: APIDocument<object>","context: DocumentContextData","generate","generateEffect","babelGenerate","event: WatchEvent"],"sources":["../package.json","../src/generator.ts","../src/index.ts"],"sourcesContent":["{\n \"name\": \"@sohcah/openapi-generator\",\n \"version\": \"0.1.2\",\n \"type\": \"module\",\n \"license\": \"MIT\",\n \"author\": \"Sam Hindess <mail@sohcah.dev>\",\n \"files\": [\n \"dist\"\n ],\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"bin\": \"./dist/cli.js\",\n \"exports\": {\n \".\": {\n \"default\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\"\n },\n \"./config\": {\n \"default\": \"./dist/config.js\",\n \"types\": \"./dist/config.d.ts\"\n },\n \"./generators\": {\n \"default\": \"./dist/generators/index.js\",\n \"types\": \"./dist/generators/index.d.ts\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"engines\": {\n \"node\": \">=22.16.0\"\n },\n \"scripts\": {\n \"build\": \"tsdown\",\n \"dev\": \"tsdown --watch\",\n \"test\": \"vitest --run\",\n \"cli\": \"./dist/cli.js\",\n \"sample\": \"yarn build && yarn cli generate -c ./sample/openapi.config.ts && SCHEMA_FORMAT=effect yarn cli generate -c ./sample/openapi.config.ts && SCHEMA_FORMAT=zod-mini yarn cli generate -c ./sample/openapi.config.ts\"\n },\n \"devDependencies\": {\n \"@tanstack/react-query\": \"^5.85.3\",\n \"@types/babel__generator\": \"^7.27.0\",\n \"@types/node\": \"^24.3.0\",\n \"@types/regex-escape\": \"^3\",\n \"openapi-types\": \"^12.1.3\",\n \"tsdown\": \"^0.14.1\",\n \"typescript\": \"^5.9.2\",\n \"vitest\": \"^3.2.4\"\n },\n \"dependencies\": {\n \"@babel/generator\": \"^7.28.3\",\n \"@effect/cli\": \"^0.69.0\",\n \"@effect/cluster\": \"^0.48.0\",\n \"@effect/experimental\": \"^0.54.6\",\n \"@effect/platform\": \"^0.90.3\",\n \"@effect/platform-node\": \"^0.96.0\",\n \"@effect/printer-ansi\": \"^0.45.0\",\n \"@effect/rpc\": \"^0.69.0\",\n \"@effect/sql\": \"^0.44.1\",\n \"@effect/typeclass\": \"^0.36.0\",\n \"@readme/openapi-parser\": \"^5.0.1\",\n \"effect\": \"^3.17.7\",\n \"regex-escape\": \"^3.4.11\",\n \"zod\": \"^4.1.11\"\n },\n \"volta\": {\n \"extends\": \"../../package.json\"\n }\n}\n","import * as t from \"@babel/types\";\nimport { Effect } from \"effect\";\nimport type { APIDocument } from \"./types.js\";\nimport { DocumentContext, type DocumentContextData } from \"./context.js\";\nimport { NotImplementedError } from \"./errors.js\";\nimport type { OpenApiGenerator } from \"./generators/types.js\";\nimport * as generationHelpers from \"./generators/helpers.js\";\nimport packageJson from \"../package.json\" with { type: \"json\" };\n\nexport type GeneratorOptions = {\n generators: OpenApiGenerator[];\n};\n\nconst build = Effect.fn(function* (options: GeneratorOptions) {\n const ctx = yield* DocumentContext;\n\n for (const generator of options.generators) {\n if (!generator.initialize) continue;\n yield* generator.initialize();\n }\n\n for (const [pathKey, path] of Object.entries(ctx.document.paths ?? {})) {\n if (!path) continue;\n if (path.$ref) {\n return yield* new NotImplementedError({\n message: \"$ref in path\",\n });\n }\n for (const methodKey of generationHelpers.httpMethods) {\n const method = path[methodKey];\n if (!method) continue;\n\n const operationKey = yield* generationHelpers.getKey(\n method.operationId ??\n `${methodKey}${pathKey.replace(/\\/(.?)/g, (_, g) => g.toUpperCase())}`\n );\n\n for (const generator of options.generators) {\n if (!generator.processOperation) continue;\n yield* generator.processOperation(\n operationKey,\n pathKey,\n methodKey,\n method\n );\n }\n }\n }\n\n for (const schema of Object.values(ctx.document.components?.schemas ?? {})) {\n for (const generator of options.generators) {\n if (!generator.processSchema) continue;\n yield* generator.processSchema(schema);\n }\n }\n\n const program = t.program([\n ...ctx.imports,\n ...[...ctx.schemas.values()].flat(),\n ]);\n t.addComment(program, \"leading\", \"eslint-disable\", false);\n t.addComment(program, \"leading\", \"prettier-ignore\", false);\n t.addComment(program, \"leading\", ` Version: ${packageJson.version}`, true);\n t.addComment(\n program,\n \"leading\",\n ` Generated by @sohcah/openapi-generator`,\n true\n );\n return program;\n});\n\nexport const generate = Effect.fn(function* (\n document: APIDocument<object>,\n options: GeneratorOptions\n) {\n const context: DocumentContextData = {\n document,\n imports: [],\n schemas: new Map(),\n processingSchemas: new Set(),\n processingSchemaTypes: new Set(),\n };\n\n return yield* build(options).pipe(\n Effect.provideService(DocumentContext, context)\n );\n});\n","import fs from \"node:fs/promises\";\nimport { bundle } from \"@readme/openapi-parser\";\nimport type { OpenAPIV2, OpenAPIV3, OpenAPIV3_1 } from \"openapi-types\";\nimport { generate as babelGenerate } from \"@babel/generator\";\nimport {\n generate as generateEffect,\n type GeneratorOptions,\n} from \"./generator.js\";\nimport { Effect, Stream } from \"effect\";\nimport { FileSystem, type WatchEvent } from \"@effect/platform/FileSystem\";\n\ntype APIDocument<T extends object> =\n | OpenAPIV2.Document<T>\n | OpenAPIV3_1.Document<T>\n | OpenAPIV3.Document<T>;\n\nexport type OpenapiGenerateOptions = GeneratorOptions & {\n schema: APIDocument<object> | string;\n};\n\nexport type OpenapiGenerateToFileOptions = OpenapiGenerateOptions & {\n output: string;\n watch?: boolean;\n onGenerated?: () => void;\n};\n\nexport const generate = Effect.fn(function* ({\n schema,\n ...options\n}: OpenapiGenerateOptions) {\n const result = yield* Effect.tryPromise(() => bundle(schema));\n if (!(\"components\" in result)) {\n return yield* Effect.die(\n new Error(\"Not a valid OpenAPI 3.x document\")\n );\n }\n\n const program = yield* generateEffect(result, options);\n\n return babelGenerate(program).code;\n});\n\nexport const generateToFile = Effect.fn(function* ({\n onGenerated,\n output,\n watch,\n ...options\n}: OpenapiGenerateToFileOptions) {\n const fs = yield* FileSystem;\n let lastCode = yield* generate(options);\n yield* fs.writeFileString(output, lastCode);\n onGenerated?.();\n\n if (watch) {\n if (typeof options.schema !== \"string\") {\n throw new Error(\"Schema must a file path to use watch mode\");\n }\n yield* Stream.runForEach(\n fs.watch(options.schema),\n Effect.fn(function* (event: WatchEvent) {\n if (event._tag === \"Update\") {\n const outputCode = yield* generate(options);\n if (outputCode !== lastCode) {\n yield* fs.writeFileString(output, outputCode);\n onGenerated?.();\n lastCode = outputCode;\n }\n }\n })\n );\n }\n});\n"],"mappings":";;;;;;;;WACU;cACG;WACH;cACG;aACD;YACD,CACP,MACD;oBACgB,EACf,UAAU,SACX;WACO;aACE;YACD;UACF;cACI;CACT,KAAK;EACH,WAAW;EACX,SAAS;CACV;CACD,YAAY;EACV,WAAW;EACX,SAAS;CACV;CACD,gBAAgB;EACd,WAAW;EACX,SAAS;CACV;CACD,kBAAkB;AACnB;cACU,EACT,QAAQ,YACT;cACU;CACT,SAAS;CACT,OAAO;CACP,QAAQ;CACR,OAAO;CACP,UAAU;AACX;sBACkB;CACjB,yBAAyB;CACzB,2BAA2B;CAC3B,eAAe;CACf,uBAAuB;CACvB,iBAAiB;CACjB,UAAU;CACV,cAAc;CACd,UAAU;AACX;mBACe;CACd,oBAAoB;CACpB,eAAe;CACf,mBAAmB;CACnB,wBAAwB;CACxB,oBAAoB;CACpB,yBAAyB;CACzB,wBAAwB;CACxB,eAAe;CACf,eAAe;CACf,qBAAqB;CACrB,0BAA0B;CAC1B,UAAU;CACV,gBAAgB;CAChB,OAA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
import { Context, Data, Effect } from "effect";
|
|
2
|
-
import { OpenAPIV3, OpenAPIV3_1 } from "openapi-types";
|
|
3
|
-
import * as t from "@babel/types";
|
|
4
|
-
|
|
5
|
-
//#region src/errors.d.ts
|
|
6
|
-
declare class NotImplementedError extends Data.Error<{
|
|
7
|
-
message: string;
|
|
8
|
-
}> {}
|
|
9
|
-
//#endregion
|
|
10
|
-
//#region src/types.d.ts
|
|
11
|
-
type APIDocument<T extends object> = OpenAPIV3_1.Document<T> | OpenAPIV3.Document<T>;
|
|
12
|
-
type SchemaObject = OpenAPIV3.SchemaObject | OpenAPIV3_1.SchemaObject;
|
|
13
|
-
type OperationObject = OpenAPIV3_1.OperationObject | OpenAPIV3.OperationObject;
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region src/context.d.ts
|
|
16
|
-
interface DocumentContextData {
|
|
17
|
-
document: APIDocument<object>;
|
|
18
|
-
imports: t.ImportDeclaration[];
|
|
19
|
-
schemas: Map<string, t.Statement[]>;
|
|
20
|
-
processingSchemas: Set<string>;
|
|
21
|
-
processingSchemaTypes: Set<string>;
|
|
22
|
-
}
|
|
23
|
-
declare const DocumentContext_base: Context.TagClass<DocumentContext, "DocumentContext", DocumentContextData>;
|
|
24
|
-
declare class DocumentContext extends DocumentContext_base {}
|
|
25
|
-
declare namespace helpers_d_exports {
|
|
26
|
-
export { HttpMethod, OperationKey, ensureImport, ensureNamespaceImport, getKey, httpMethods, notImplementedStatement };
|
|
27
|
-
}
|
|
28
|
-
declare const ensureImport: (name: string, from: string, typeOnly?: boolean | undefined) => Effect.Effect<t.Identifier, never, DocumentContext>;
|
|
29
|
-
declare const ensureNamespaceImport: (name: string, from: string) => Effect.Effect<t.Identifier, never, DocumentContext>;
|
|
30
|
-
declare const getKey: (name: string) => Effect.Effect<{
|
|
31
|
-
lower: string;
|
|
32
|
-
upper: string;
|
|
33
|
-
}, NotImplementedError, never>;
|
|
34
|
-
type OperationKey = {
|
|
35
|
-
lower: string;
|
|
36
|
-
upper: string;
|
|
37
|
-
};
|
|
38
|
-
declare const httpMethods: readonly ["get", "post", "put", "delete", "options", "head", "patch", "trace"];
|
|
39
|
-
type HttpMethod = (typeof httpMethods)[number];
|
|
40
|
-
declare const notImplementedStatement: t.BlockStatement;
|
|
41
|
-
//#endregion
|
|
42
|
-
//#region src/generators/types.d.ts
|
|
43
|
-
interface ImportReference {
|
|
44
|
-
type: "import";
|
|
45
|
-
name: string;
|
|
46
|
-
from: string;
|
|
47
|
-
}
|
|
48
|
-
interface OpenApiGenerator {
|
|
49
|
-
initialize?: () => Effect.Effect<void, NotImplementedError, DocumentContext>;
|
|
50
|
-
processSchema?: (schema: SchemaObject) => Effect.Effect<void, NotImplementedError, DocumentContext>;
|
|
51
|
-
processOperation?: (operationKey: OperationKey, path: string, method: HttpMethod, operation: OperationObject) => Effect.Effect<void, NotImplementedError, DocumentContext>;
|
|
52
|
-
}
|
|
53
|
-
interface OpenApiParametersSchema {
|
|
54
|
-
expression: t.Expression;
|
|
55
|
-
typeReference: t.TSTypeReference;
|
|
56
|
-
}
|
|
57
|
-
interface OpenApiResponseSchema {
|
|
58
|
-
expression: t.Expression;
|
|
59
|
-
typeReference: t.TSTypeReference;
|
|
60
|
-
}
|
|
61
|
-
interface OpenApiSchemaGenerator extends OpenApiGenerator {
|
|
62
|
-
decodeResponse: (schema: t.Expression, response: t.Expression) => Effect.Effect<t.Expression>;
|
|
63
|
-
encodeParameters: (schema: t.Expression, parameters: t.Expression) => Effect.Effect<t.Expression>;
|
|
64
|
-
ensureParametersSchema: (operationKey: OperationKey, operation: OperationObject, path: string) => Effect.Effect<OpenApiParametersSchema, NotImplementedError, DocumentContext>;
|
|
65
|
-
ensureResponseSchema: (operationKey: OperationKey, operation: OperationObject) => Effect.Effect<OpenApiResponseSchema, NotImplementedError, DocumentContext>;
|
|
66
|
-
get schemaType(): t.TSEntityName;
|
|
67
|
-
}
|
|
68
|
-
interface OpenApiClientGenerator extends OpenApiGenerator {}
|
|
69
|
-
//#endregion
|
|
70
|
-
export { DocumentContext, HttpMethod, ImportReference, NotImplementedError, OpenApiClientGenerator, OpenApiGenerator, OpenApiParametersSchema, OpenApiResponseSchema, OpenApiSchemaGenerator, OperationKey, OperationObject, SchemaObject, helpers_d_exports };
|
|
71
|
-
//# sourceMappingURL=types-DjImZ4S-.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types-DjImZ4S-.d.ts","names":[],"sources":["../../src/errors.ts","../../src/types.ts","../../src/context.ts","../../src/generators/helpers.ts","../../src/generators/types.ts"],"sourcesContent":[],"mappings":";;;;;cAEa,mBAAA,SAA4B,IAAA,CAAK;;;;;KCAlC,gCACR,WAAA,CAAY,SAAS,KACrB,SAAA,CAAU,SAAS;KAIX,YAAA,GAAe,SAAA,CAAU,eAAe,WAAA,CAAY;KAEpD,eAAA,GAAkB,WAAA,CAAY,kBAAkB,SAAA,CAAU;;;UCNrD,mBAAA;YACL;WACD,CAAA,CAAE;EFJA,OAAA,EEKF,GFLE,CAAA,MAAA,EEKU,CAAA,CAAE,SFLgB,EAAA,CAAA;qBEMpB;yBACI;;ADPzB,cCQC,oBDRsB,kBAAA,gBAAA,EAAA,iBAAA,qBAAA,CAAA;AAAA,cCUV,eAAA,SAAwB,oBAGlC,CDboB;AAAA;;;cEGV,8EAAY,MAAA,CAAA,OAAA,CAAA,CAAA,mBAAA;cA2BZ,uDAAqB,MAAA,CAAA,OAAA,CAAA,CAAA,mBAAA;AH9BrB,cG2DA,MH3DoB,EAAA,CAAA,IAAA,EAAQ,MAAK,EAAA,GG2D3B,MAAA,CAAA,MH3DgC,CAAA;;;GGsEjD;AFtEU,KEwEA,YAAA,GFxEW;EAAA,KAAA,EAAA,MAAA;EAAA,KACE,EAAA,MAAA;CAAC;AACH,cE2EV,WF3EU,EAAA,SAAA,CAAA,KAAA,EAAA,MAAA,EAAA,KAAA,EAAA,QAAA,EAAA,SAAA,EAAA,MAAA,EAAA,OAAA,EAAA,OAAA,CAAA;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