@sohcah/openapi-generator 0.0.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.
@@ -0,0 +1,26 @@
1
+ import { NotImplementedError, OpenApiGenerator } from "./types-7ABKlnLu.js";
2
+ import { Effect } from "effect";
3
+ import { FileSystem } from "@effect/platform/FileSystem";
4
+ import * as _effect_platform_Error0 from "@effect/platform/Error";
5
+ import { OpenAPIV2, OpenAPIV3, OpenAPIV3_1 } from "openapi-types";
6
+
7
+ //#region src/generator.d.ts
8
+ type GeneratorOptions = {
9
+ generators: OpenApiGenerator[];
10
+ };
11
+ //#endregion
12
+ //#region src/index.d.ts
13
+ type APIDocument<T extends object> = OpenAPIV2.Document<T> | OpenAPIV3_1.Document<T> | OpenAPIV3.Document<T>;
14
+ type OpenapiGenerateOptions = GeneratorOptions & {
15
+ schema: APIDocument<object> | string;
16
+ };
17
+ type OpenapiGenerateToFileOptions = OpenapiGenerateOptions & {
18
+ output: string;
19
+ watch?: boolean;
20
+ onGenerated?: () => void;
21
+ };
22
+ declare const generate: (args_0: OpenapiGenerateOptions) => Effect.Effect<string, NotImplementedError, never>;
23
+ declare const generateToFile: (args_0: OpenapiGenerateToFileOptions) => Effect.Effect<void, NotImplementedError | _effect_platform_Error0.PlatformError, FileSystem>;
24
+ //#endregion
25
+ export { OpenapiGenerateOptions, OpenapiGenerateToFileOptions, generate, generateToFile };
26
+ //# sourceMappingURL=index-COF3JXv1.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-COF3JXv1.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"}
@@ -0,0 +1,3 @@
1
+ import "./types-7ABKlnLu.js";
2
+ import { OpenapiGenerateOptions, OpenapiGenerateToFileOptions, generate, generateToFile } from "./index-COF3JXv1.js";
3
+ export { OpenapiGenerateOptions, OpenapiGenerateToFileOptions, generate, generateToFile };
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ import "./helpers-ChEkrLHV.js";
2
+ import { generate, generateToFile } from "./src-UQLWBWmZ.js";
3
+
4
+ export { generate, generateToFile };
@@ -0,0 +1,167 @@
1
+ import { __toESM } from "./chunk-51aI8Tpl.js";
2
+ import { DocumentContext, NotImplementedError, getKey, require_lib } from "./helpers-ChEkrLHV.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.0.1";
11
+ var type = "module";
12
+ var license = "MIT";
13
+ var author = "Sam Hindess <mail@sohcah.dev>";
14
+ var publishConfig = { "access": "public" };
15
+ var files = ["dist"];
16
+ var main = "./dist/index.js";
17
+ var module = "./dist/index.js";
18
+ var types = "./dist/index.d.ts";
19
+ var bin = { "openapi-generator": "./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
+ "openapi-types": "^12.1.3",
48
+ "tsdown": "^0.14.1",
49
+ "typescript": "^5.9.2",
50
+ "vitest": "^3.2.4"
51
+ };
52
+ var dependencies = {
53
+ "@babel/generator": "^7.28.3",
54
+ "@effect/cli": "^0.69.0",
55
+ "@effect/cluster": "^0.48.0",
56
+ "@effect/experimental": "^0.54.6",
57
+ "@effect/platform": "^0.90.3",
58
+ "@effect/platform-node": "^0.96.0",
59
+ "@effect/printer-ansi": "^0.45.0",
60
+ "@effect/rpc": "^0.69.0",
61
+ "@effect/sql": "^0.44.1",
62
+ "@effect/typeclass": "^0.36.0",
63
+ "@readme/openapi-parser": "^5.0.1",
64
+ "effect": "^3.17.7",
65
+ "zod": "^4.1.11"
66
+ };
67
+ var volta = { "extends": "../../package.json" };
68
+ var package_default = {
69
+ name,
70
+ version,
71
+ type,
72
+ license,
73
+ author,
74
+ publishConfig,
75
+ files,
76
+ main,
77
+ module,
78
+ types,
79
+ bin,
80
+ exports,
81
+ engines,
82
+ scripts,
83
+ devDependencies,
84
+ dependencies,
85
+ volta
86
+ };
87
+
88
+ //#endregion
89
+ //#region src/generator.ts
90
+ var import_lib = /* @__PURE__ */ __toESM(require_lib(), 1);
91
+ const build = Effect.fn(function* (options) {
92
+ const ctx = yield* DocumentContext;
93
+ for (const generator of options.generators) {
94
+ if (!generator.initialize) continue;
95
+ yield* generator.initialize();
96
+ }
97
+ for (const [pathKey, path] of Object.entries(ctx.document.paths ?? {})) {
98
+ if (!path) continue;
99
+ if (path.$ref) return yield* new NotImplementedError({ message: "$ref in path" });
100
+ for (const methodKey of [
101
+ "get",
102
+ "post",
103
+ "put",
104
+ "delete"
105
+ ]) {
106
+ const method = path[methodKey];
107
+ if (!method) continue;
108
+ const operationKey = yield* getKey(method.operationId ?? `${methodKey}${pathKey.replace(/\/(.?)/g, (_, g) => g.toUpperCase())}`);
109
+ for (const generator of options.generators) {
110
+ if (!generator.processOperation) continue;
111
+ yield* generator.processOperation(operationKey, pathKey, methodKey, method);
112
+ }
113
+ }
114
+ }
115
+ for (const schema of Object.values(ctx.document.components?.schemas ?? {})) for (const generator of options.generators) {
116
+ if (!generator.processSchema) continue;
117
+ yield* generator.processSchema(schema);
118
+ }
119
+ const program = import_lib.program([...ctx.imports, ...[...ctx.schemas.values()].flat()]);
120
+ import_lib.addComment(program, "leading", "eslint-disable", false);
121
+ import_lib.addComment(program, "leading", "prettier-ignore", false);
122
+ import_lib.addComment(program, "leading", ` Version: ${package_default.version}`, true);
123
+ import_lib.addComment(program, "leading", ` Generated by @sohcah/openapi-generator`, true);
124
+ return program;
125
+ });
126
+ const generate$1 = Effect.fn(function* (document, options) {
127
+ const context = {
128
+ document,
129
+ imports: [],
130
+ schemas: /* @__PURE__ */ new Map(),
131
+ processingSchemas: /* @__PURE__ */ new Set(),
132
+ processingSchemaTypes: /* @__PURE__ */ new Set()
133
+ };
134
+ return yield* build(options).pipe(Effect.provideService(DocumentContext, context));
135
+ });
136
+
137
+ //#endregion
138
+ //#region src/index.ts
139
+ const generate$2 = Effect.fn(function* ({ schema,...options }) {
140
+ const result = yield* Effect.tryPromise(() => bundle(schema));
141
+ if (!("components" in result)) return yield* Effect.die(/* @__PURE__ */ new Error("Not a valid OpenAPI 3.x document"));
142
+ const program = yield* generate$1(result, options);
143
+ return generate(program).code;
144
+ });
145
+ const generateToFile = Effect.fn(function* ({ onGenerated, output, watch,...options }) {
146
+ const fs = yield* FileSystem;
147
+ let lastCode = yield* generate$2(options);
148
+ yield* fs.writeFileString(output, lastCode);
149
+ onGenerated?.();
150
+ if (watch) {
151
+ if (typeof options.schema !== "string") throw new Error("Schema must a file path to use watch mode");
152
+ yield* Stream.runForEach(fs.watch(options.schema), Effect.fn(function* (event) {
153
+ if (event._tag === "Update") {
154
+ const outputCode = yield* generate$2(options);
155
+ if (outputCode !== lastCode) {
156
+ yield* fs.writeFileString(output, outputCode);
157
+ onGenerated?.();
158
+ lastCode = outputCode;
159
+ }
160
+ }
161
+ }));
162
+ }
163
+ });
164
+
165
+ //#endregion
166
+ export { generate$2 as generate, generateToFile };
167
+ //# sourceMappingURL=src-UQLWBWmZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"src-UQLWBWmZ.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.0.1\",\n \"type\": \"module\",\n \"license\": \"MIT\",\n \"author\": \"Sam Hindess <mail@sohcah.dev>\",\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"files\": [\n \"dist\"\n ],\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"bin\": {\n \"openapi-generator\": \"./dist/cli.js\"\n },\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 \"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 \"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 [\"get\", \"post\", \"put\", \"delete\"] as const) {\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;oBACO,EACf,UAAU,SACX;YACQ,CACP,MACD;WACO;aACE;YACD;UACF,EACL,qBAAqB,gBACtB;cACU;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,iBA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AS,UAAU;IAC3B,MAAM,aAAa,OAAOH,WAAS,QAAQ;AAC3C,QAAI,eAAe,UAAU;KAC3B,OAAO,GAAG,gBAAgB,QAAQ,WAAW;KAC7C,eAAe;KACf,WAAW;IACZ;GACF;EACF,EAAC,CACH;CACF;AACF,EAAC"}
@@ -0,0 +1,66 @@
1
+ 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 { OperationKey, ensureImport, ensureNamespaceImport, getKey };
27
+ }
28
+ declare const ensureImport: (name: string, from: string) => 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
+ //#endregion
39
+ //#region src/generators/types.d.ts
40
+ interface ImportReference {
41
+ type: "import";
42
+ name: string;
43
+ from: string;
44
+ }
45
+ interface OpenApiGenerator {
46
+ initialize?: () => Effect.Effect<void, NotImplementedError, DocumentContext>;
47
+ processSchema?: (schema: SchemaObject) => Effect.Effect<void, NotImplementedError, DocumentContext>;
48
+ processOperation?: (operationKey: OperationKey, path: string, method: "get" | "post" | "put" | "delete", operation: OperationObject) => Effect.Effect<void, NotImplementedError, DocumentContext>;
49
+ }
50
+ interface OpenApiParametersSchema {
51
+ expression: t.Expression;
52
+ typeReference: t.TSTypeReference;
53
+ }
54
+ interface OpenApiResponseSchema {
55
+ expression: t.Expression;
56
+ typeReference: t.TSTypeReference;
57
+ }
58
+ interface OpenApiSchemaGenerator extends OpenApiGenerator {
59
+ ensureParametersSchema: (operationKey: OperationKey, operation: OperationObject) => Effect.Effect<OpenApiParametersSchema, NotImplementedError, DocumentContext>;
60
+ ensureResponseSchema: (operationKey: OperationKey, operation: OperationObject) => Effect.Effect<OpenApiResponseSchema | null, NotImplementedError, DocumentContext>;
61
+ get schemaType(): t.TSEntityName;
62
+ }
63
+ interface OpenApiClientGenerator extends OpenApiGenerator {}
64
+ //#endregion
65
+ export { DocumentContext, ImportReference, NotImplementedError, OpenApiClientGenerator, OpenApiGenerator, OpenApiParametersSchema, OpenApiResponseSchema, OpenApiSchemaGenerator, OperationKey, OperationObject, SchemaObject, helpers_d_exports };
66
+ //# sourceMappingURL=types-7ABKlnLu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-7ABKlnLu.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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EhE,aAAA,EGuBK,CAAA,CAAE,eHvBQ;;AAAG,UG0Bb,sBAAA,SAA+B,gBH1BN,CAAA;EAAe,sBAAa,EAAA,CAAA,YAAA,EG0B9B,YH1B8B,EAAA,SAAA,EG6BvD,eH7BuD,EAAA,GG8B/D,MAAA,CAAO,MH9BwD,CG+BlE,uBH/BkE,EGgClE,mBHhCkE,EGiClE,eHjCkE,CAAA;EAAe,oBAAA,EAAA,CAAA,YAAA,EG8BjE,YH9BiE,EAAA,SAAA,EGqCtE,eHrCsE,EAAA,GGsC9E,MAAA,CAAO,MHtCuE,CGuCjF,qBHvCiF,GAAA,IAAA,EGwCjF,mBHxCiF,EGyCjF,eHzCiF,CAAA;oBG2CjE,CAAA,CAAE;;UAGL,sBAAA,SAA+B,kBFpDhD"}
package/package.json ADDED
@@ -0,0 +1,71 @@
1
+ {
2
+ "name": "@sohcah/openapi-generator",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "license": "MIT",
6
+ "author": "Sam Hindess <mail@sohcah.dev>",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "main": "./dist/index.js",
14
+ "module": "./dist/index.js",
15
+ "types": "./dist/index.d.ts",
16
+ "bin": {
17
+ "openapi-generator": "./dist/cli.js"
18
+ },
19
+ "exports": {
20
+ ".": {
21
+ "default": "./dist/index.js",
22
+ "types": "./dist/index.d.ts"
23
+ },
24
+ "./config": {
25
+ "default": "./dist/config.js",
26
+ "types": "./dist/config.d.ts"
27
+ },
28
+ "./generators": {
29
+ "default": "./dist/generators/index.js",
30
+ "types": "./dist/generators/index.d.ts"
31
+ },
32
+ "./package.json": "./package.json"
33
+ },
34
+ "engines": {
35
+ "node": ">=22.16.0"
36
+ },
37
+ "scripts": {
38
+ "build": "tsdown",
39
+ "dev": "tsdown --watch",
40
+ "test": "vitest --run",
41
+ "cli": "./dist/cli.js",
42
+ "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"
43
+ },
44
+ "devDependencies": {
45
+ "@tanstack/react-query": "^5.85.3",
46
+ "@types/babel__generator": "^7.27.0",
47
+ "@types/node": "^24.3.0",
48
+ "openapi-types": "^12.1.3",
49
+ "tsdown": "^0.14.1",
50
+ "typescript": "^5.9.2",
51
+ "vitest": "^3.2.4"
52
+ },
53
+ "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
+ "zod": "^4.1.11"
67
+ },
68
+ "volta": {
69
+ "extends": "../../package.json"
70
+ }
71
+ }