@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,33 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
11
+ var __export = (target, all) => {
12
+ for (var name in all) __defProp(target, name, {
13
+ get: all[name],
14
+ enumerable: true
15
+ });
16
+ };
17
+ var __copyProps = (to, from, except, desc) => {
18
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
19
+ key = keys[i];
20
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
21
+ get: ((k) => from[k]).bind(null, key),
22
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
23
+ });
24
+ }
25
+ return to;
26
+ };
27
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
+ value: mod,
29
+ enumerable: true
30
+ }) : target, mod));
31
+
32
+ //#endregion
33
+ export { __commonJS, __export, __toESM };
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env node
2
+ import "./helpers-ChEkrLHV.js";
3
+ import { generateToFile } from "./src-UQLWBWmZ.js";
4
+ import { Command, Options } from "@effect/cli";
5
+ import { NodeContext, NodeRuntime } from "@effect/platform-node";
6
+ import { Effect } from "effect";
7
+
8
+ //#region src/cli.ts
9
+ const command = Command.make("@sohcah/openapi-generator", {}).pipe(Command.withSubcommands([Command.make("generate", {
10
+ watch: Options.boolean("watch").pipe(Options.withDefault(false)).pipe(Options.withAlias("w")),
11
+ config: Options.text("config").pipe(Options.withAlias("c")).pipe(Options.withDefault("openapi.config.ts"))
12
+ }, Effect.fn(function* (args) {
13
+ const config = yield* Effect.tryPromise(() => import(`file://${process.cwd()}/${args.config}`)).pipe(Effect.mapError((e) => /* @__PURE__ */ new Error(`Failed to load config: ${e.message}`)));
14
+ yield* generateToFile({
15
+ ...config.default,
16
+ watch: args.watch
17
+ });
18
+ }))]));
19
+ const cli = Command.run(command, {
20
+ name: "@sohcah/openapi-generator",
21
+ version: "v0.0.1"
22
+ });
23
+ cli(process.argv).pipe(Effect.provide(NodeContext.layer), NodeRuntime.runMain);
24
+
25
+ //#endregion
26
+ export { };
27
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","names":[],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { Command, Options } from \"@effect/cli\";\nimport { NodeContext, NodeRuntime } from \"@effect/platform-node\";\nimport { Effect } from \"effect\";\nimport { generateToFile } from \"./index.js\";\n\n// Define the top-level command\nconst command = Command.make(\"@sohcah/openapi-generator\", {}).pipe(\n Command.withSubcommands([\n Command.make(\n \"generate\",\n {\n watch: Options.boolean(\"watch\")\n .pipe(Options.withDefault(false))\n .pipe(Options.withAlias(\"w\")),\n config: Options.text(\"config\")\n .pipe(Options.withAlias(\"c\"))\n .pipe(Options.withDefault(\"openapi.config.ts\")),\n },\n Effect.fn(function* (args) {\n const config = yield* Effect.tryPromise(\n () => import(`file://${process.cwd()}/${args.config}`)\n ).pipe(\n Effect.mapError(\n (e) => new Error(`Failed to load config: ${e.message}`)\n )\n );\n yield* generateToFile({\n ...config.default,\n watch: args.watch,\n });\n })\n ),\n ])\n);\n\n// Set up the CLI application\nconst cli = Command.run(command, {\n name: \"@sohcah/openapi-generator\",\n version: \"v0.0.1\",\n});\n\n// Prepare and run the CLI application\ncli(process.argv).pipe(Effect.provide(NodeContext.layer), NodeRuntime.runMain);\n"],"mappings":";;;;;;;;AAQA,MAAM,UAAU,QAAQ,KAAK,6BAA6B,CAAE,EAAC,CAAC,KAC5D,QAAQ,gBAAgB,CACtB,QAAQ,KACN,YACA;CACE,OAAO,QAAQ,QAAQ,QAAQ,CAC5B,KAAK,QAAQ,YAAY,MAAM,CAAC,CAChC,KAAK,QAAQ,UAAU,IAAI,CAAC;CAC/B,QAAQ,QAAQ,KAAK,SAAS,CAC3B,KAAK,QAAQ,UAAU,IAAI,CAAC,CAC5B,KAAK,QAAQ,YAAY,oBAAoB,CAAC;AAClD,GACD,OAAO,GAAG,WAAW,MAAM;CACzB,MAAM,SAAS,OAAO,OAAO,WAC3B,MAAM,OAAO,CAAC,OAAO,EAAE,QAAQ,KAAK,CAAC,CAAC,EAAE,KAAK,QAAQ,EACtD,CAAC,KACA,OAAO,SACL,CAAC,sBAAM,IAAI,MAAM,CAAC,uBAAuB,EAAE,EAAE,SAAS,EACvD,CACF;CACD,OAAO,eAAe;EACpB,GAAG,OAAO;EACV,OAAO,KAAK;CACb,EAAC;AACH,EAAC,CACH,AACF,EAAC,CACH;AAGD,MAAM,MAAM,QAAQ,IAAI,SAAS;CAC/B,MAAM;CACN,SAAS;AACV,EAAC;AAGF,IAAI,QAAQ,KAAK,CAAC,KAAK,OAAO,QAAQ,YAAY,MAAM,EAAE,YAAY,QAAQ"}
@@ -0,0 +1,8 @@
1
+ import "./types-7ABKlnLu.js";
2
+ import { OpenapiGenerateToFileOptions } from "./index-COF3JXv1.js";
3
+
4
+ //#region src/config.d.ts
5
+ declare const defineConfig: (config: OpenapiGenerateToFileOptions) => OpenapiGenerateToFileOptions;
6
+ //#endregion
7
+ export { defineConfig };
8
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","names":[],"sources":["../../src/config.ts"],"sourcesContent":[],"mappings":";;;;cAEa,uBAAwB,iCAA4B"}
package/dist/config.js ADDED
@@ -0,0 +1,6 @@
1
+ //#region src/config.ts
2
+ const defineConfig = (config) => config;
3
+
4
+ //#endregion
5
+ export { defineConfig };
6
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","names":["config: OpenapiGenerateToFileOptions"],"sources":["../src/config.ts"],"sourcesContent":["import type { OpenapiGenerateToFileOptions } from \"./index.js\";\n\nexport const defineConfig = (config: OpenapiGenerateToFileOptions) => config;"],"mappings":";AAEA,MAAa,eAAe,CAACA,WAAyC"}
@@ -0,0 +1,103 @@
1
+ import { DocumentContext, ImportReference, NotImplementedError, OpenApiClientGenerator, OpenApiGenerator, OpenApiParametersSchema, OpenApiResponseSchema, OpenApiSchemaGenerator, OperationKey, OperationObject, SchemaObject, helpers_d_exports } from "../types-7ABKlnLu.js";
2
+ import { Effect } from "effect";
3
+ import * as t from "@babel/types";
4
+
5
+ //#region src/generators/schema.d.ts
6
+ interface SchemaGeneratorOptions {
7
+ /** @default null */
8
+ custom?: (schema: SchemaObject) => ImportReference | null;
9
+ /** @default false */
10
+ experimental_includeTypes?: boolean;
11
+ /** @default true */
12
+ includeSchemas?: boolean;
13
+ /** @default false */
14
+ includeOperations?: boolean;
15
+ /** @default "unknown" */
16
+ deprecationHandling?: "unknown" | "optional";
17
+ }
18
+ interface DefaultSchemaGeneratorOptions extends SchemaGeneratorOptions {
19
+ modifiers: {
20
+ lazy: (expression: t.Expression) => t.Expression;
21
+ optional: (expression: t.Expression) => t.Expression;
22
+ regex: (expression: t.Expression, pattern: string) => t.Expression;
23
+ immutable: (expression: t.Expression) => t.Expression;
24
+ mutable: (expression: t.Expression) => t.Expression;
25
+ nullable: (expression: t.Expression) => t.Expression;
26
+ };
27
+ types: {
28
+ schema: t.TSQualifiedName;
29
+ typeDecoded: t.TSQualifiedName;
30
+ typeEncoded: t.TSQualifiedName;
31
+ };
32
+ schema: {
33
+ record: (key: t.Expression, value: t.Expression) => t.Expression;
34
+ union: (expressions: t.Expression[]) => t.Expression;
35
+ enum: (expressions: t.Expression[]) => t.Expression;
36
+ instanceOf: t.Expression;
37
+ boolean: t.Expression;
38
+ string: t.Expression;
39
+ number: t.Expression;
40
+ integer: t.Expression;
41
+ array: t.Expression;
42
+ object: t.Expression;
43
+ null: t.Expression;
44
+ unknown: t.Expression;
45
+ };
46
+ transformer: (options: {
47
+ encoded: t.Expression;
48
+ decoded: t.Expression;
49
+ decode: t.Expression | t.BlockStatement;
50
+ encode: t.Expression | t.BlockStatement;
51
+ }) => t.Expression;
52
+ transformerCatch: (expression: t.Expression) => t.BlockStatement;
53
+ builtins: {
54
+ parseJson?: (expression: t.Expression) => t.Expression;
55
+ };
56
+ methods: {
57
+ encode: (schema: t.Expression, value: t.Expression) => t.Expression;
58
+ decode: (schema: t.Expression, value: t.Expression) => t.Expression;
59
+ parse: (schema: t.Expression, value: t.Expression) => t.Expression;
60
+ };
61
+ supportsImmutability: boolean;
62
+ }
63
+ declare function createSchemaGenerator(options: DefaultSchemaGeneratorOptions): OpenApiSchemaGenerator;
64
+ //#endregion
65
+ //#region src/generators/effect.d.ts
66
+ declare const createEffectSchemaGenerator: (options: SchemaGeneratorOptions) => {
67
+ initialize: () => Effect.Effect<void, never, DocumentContext>;
68
+ ensureParametersSchema: (operationKey: OperationKey, operation: OperationObject) => Effect.Effect<OpenApiParametersSchema, NotImplementedError, DocumentContext>;
69
+ ensureResponseSchema: (operationKey: OperationKey, operation: OperationObject) => Effect.Effect<OpenApiResponseSchema | null, NotImplementedError, DocumentContext>;
70
+ schemaType: t.TSEntityName;
71
+ processSchema?: (schema: SchemaObject) => Effect.Effect<void, NotImplementedError, DocumentContext>;
72
+ processOperation?: (operationKey: OperationKey, path: string, method: "get" | "post" | "put" | "delete", operation: OperationObject) => Effect.Effect<void, NotImplementedError, DocumentContext>;
73
+ };
74
+ //#endregion
75
+ //#region src/generators/zod.d.ts
76
+ interface ZodSchemaGeneratorOptions extends SchemaGeneratorOptions {
77
+ /** @default false */
78
+ mini?: boolean;
79
+ }
80
+ declare const createZodSchemaGenerator: ({
81
+ mini,
82
+ ...options
83
+ }: ZodSchemaGeneratorOptions) => {
84
+ initialize: () => Effect.Effect<void, never, DocumentContext>;
85
+ ensureParametersSchema: (operationKey: OperationKey, operation: OperationObject) => Effect.Effect<OpenApiParametersSchema, NotImplementedError, DocumentContext>;
86
+ ensureResponseSchema: (operationKey: OperationKey, operation: OperationObject) => Effect.Effect<OpenApiResponseSchema | null, NotImplementedError, DocumentContext>;
87
+ schemaType: t.TSEntityName;
88
+ processSchema?: (schema: SchemaObject) => Effect.Effect<void, NotImplementedError, DocumentContext>;
89
+ processOperation?: (operationKey: OperationKey, path: string, method: "get" | "post" | "put" | "delete", operation: OperationObject) => Effect.Effect<void, NotImplementedError, DocumentContext>;
90
+ };
91
+ //#endregion
92
+ //#region src/generators/client.d.ts
93
+ interface OpenApiClientGeneratorOptions {
94
+ schema: OpenApiSchemaGenerator;
95
+ /**
96
+ * If provided, responses from the
97
+ */
98
+ responseGeneric?: ImportReference;
99
+ }
100
+ declare function createReactQueryClientGenerator(options: OpenApiClientGeneratorOptions): OpenApiClientGenerator;
101
+ //#endregion
102
+ export { ImportReference, OpenApiClientGenerator, OpenApiGenerator, OpenApiParametersSchema, OpenApiResponseSchema, OpenApiSchemaGenerator, createEffectSchemaGenerator, createReactQueryClientGenerator, createSchemaGenerator, createZodSchemaGenerator, helpers_d_exports as generatorHelpers };
103
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/generators/schema.ts","../../../src/generators/effect.ts","../../../src/generators/zod.ts","../../../src/generators/client.ts"],"sourcesContent":[],"mappings":";;;;;UAaiB,sBAAA;;EAAA,MAAA,CAAA,EAAA,CAAA,MAAA,EAEG,YAFmB,EAA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