@effect/openapi-generator 4.0.0-beta.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.
Files changed (42) hide show
  1. package/LICENSE +21 -0
  2. package/dist/JsonSchemaGenerator.d.ts +8 -0
  3. package/dist/JsonSchemaGenerator.d.ts.map +1 -0
  4. package/dist/JsonSchemaGenerator.js +75 -0
  5. package/dist/JsonSchemaGenerator.js.map +1 -0
  6. package/dist/OpenApiGenerator.d.ts +32 -0
  7. package/dist/OpenApiGenerator.d.ts.map +1 -0
  8. package/dist/OpenApiGenerator.js +206 -0
  9. package/dist/OpenApiGenerator.js.map +1 -0
  10. package/dist/OpenApiPatch.d.ts +296 -0
  11. package/dist/OpenApiPatch.d.ts.map +1 -0
  12. package/dist/OpenApiPatch.js +448 -0
  13. package/dist/OpenApiPatch.js.map +1 -0
  14. package/dist/OpenApiTransformer.d.ts +24 -0
  15. package/dist/OpenApiTransformer.d.ts.map +1 -0
  16. package/dist/OpenApiTransformer.js +740 -0
  17. package/dist/OpenApiTransformer.js.map +1 -0
  18. package/dist/ParsedOperation.d.ts +29 -0
  19. package/dist/ParsedOperation.d.ts.map +1 -0
  20. package/dist/ParsedOperation.js +13 -0
  21. package/dist/ParsedOperation.js.map +1 -0
  22. package/dist/Utils.d.ts +6 -0
  23. package/dist/Utils.d.ts.map +1 -0
  24. package/dist/Utils.js +42 -0
  25. package/dist/Utils.js.map +1 -0
  26. package/dist/bin.d.ts +3 -0
  27. package/dist/bin.d.ts.map +1 -0
  28. package/dist/bin.js +7 -0
  29. package/dist/bin.js.map +1 -0
  30. package/dist/main.d.ts +5 -0
  31. package/dist/main.d.ts.map +1 -0
  32. package/dist/main.js +47 -0
  33. package/dist/main.js.map +1 -0
  34. package/package.json +67 -0
  35. package/src/JsonSchemaGenerator.ts +94 -0
  36. package/src/OpenApiGenerator.ts +309 -0
  37. package/src/OpenApiPatch.ts +514 -0
  38. package/src/OpenApiTransformer.ts +954 -0
  39. package/src/ParsedOperation.ts +43 -0
  40. package/src/Utils.ts +50 -0
  41. package/src/bin.ts +10 -0
  42. package/src/main.ts +68 -0
@@ -0,0 +1,448 @@
1
+ /**
2
+ * OpenAPI spec patching utilities.
3
+ *
4
+ * Handles parsing and applying JSON Patch documents (RFC 6902) to OpenAPI
5
+ * specs. Supports patches from:
6
+ * - JSON files (.json)
7
+ * - YAML files (.yaml, .yml)
8
+ * - Inline JSON strings
9
+ *
10
+ * @module OpenApiPatch
11
+ */
12
+ import * as Effect from "effect/Effect";
13
+ import * as FileSystem from "effect/FileSystem";
14
+ import { constFalse, constUndefined } from "effect/Function";
15
+ import * as JsonPatch from "effect/JsonPatch";
16
+ import * as Path from "effect/Path";
17
+ import * as Predicate from "effect/Predicate";
18
+ import * as Schema from "effect/Schema";
19
+ import * as Yaml from "yaml";
20
+ // =============================================================================
21
+ // Error Types
22
+ // =============================================================================
23
+ /**
24
+ * Error thrown when parsing a JSON Patch input fails.
25
+ *
26
+ * This error occurs when:
27
+ * - A patch file cannot be read
28
+ * - JSON or YAML syntax is invalid
29
+ * - The file format is unsupported
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * import * as OpenApiPatch from "@effect/openapi-generator/OpenApiPatch"
34
+ *
35
+ * const error = new OpenApiPatch.JsonPatchParseError({
36
+ * source: "./patches/fix.json",
37
+ * reason: "Unexpected token at position 42"
38
+ * })
39
+ *
40
+ * console.log(error.message)
41
+ * // "Failed to parse patch from ./patches/fix.json: Unexpected token at position 42"
42
+ * ```
43
+ *
44
+ * @since 1.0.0
45
+ * @category errors
46
+ */
47
+ export class JsonPatchParseError extends /*#__PURE__*/Schema.ErrorClass("JsonPatchParseError")({
48
+ _tag: /*#__PURE__*/Schema.tag("JsonPatchParseError"),
49
+ source: Schema.String,
50
+ reason: Schema.String
51
+ }) {
52
+ get message() {
53
+ return `Failed to parse patch from ${this.source}: ${this.reason}`;
54
+ }
55
+ }
56
+ /**
57
+ * Error thrown when a parsed value does not conform to the JSON Patch schema.
58
+ *
59
+ * This error occurs when:
60
+ * - The patch is not an array
61
+ * - An operation is missing required fields (op, path)
62
+ * - An operation has an unsupported op value
63
+ * - An add/replace operation is missing the value field
64
+ *
65
+ * @example
66
+ * ```ts
67
+ * import * as OpenApiPatch from "@effect/openapi-generator/OpenApiPatch"
68
+ *
69
+ * const error = new OpenApiPatch.JsonPatchValidationError({
70
+ * source: "inline",
71
+ * reason: "Expected 'add' | 'remove' | 'replace' at [0].op, got 'copy'"
72
+ * })
73
+ *
74
+ * console.log(error.message)
75
+ * // "Invalid JSON Patch from inline: Expected 'add' | 'remove' | 'replace' at [0].op, got 'copy'"
76
+ * ```
77
+ *
78
+ * @since 1.0.0
79
+ * @category errors
80
+ */
81
+ export class JsonPatchValidationError extends /*#__PURE__*/Schema.ErrorClass("JsonPatchValidationError")({
82
+ _tag: /*#__PURE__*/Schema.tag("JsonPatchValidationError"),
83
+ source: Schema.String,
84
+ reason: Schema.String
85
+ }) {
86
+ get message() {
87
+ return `Invalid JSON Patch from ${this.source}: ${this.reason}`;
88
+ }
89
+ }
90
+ /**
91
+ * Error thrown when applying a JSON Patch operation fails.
92
+ *
93
+ * This error occurs when:
94
+ * - A path does not exist for remove/replace operations
95
+ * - An array index is out of bounds
96
+ * - The target location is not a valid container
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * import * as OpenApiPatch from "@effect/openapi-generator/OpenApiPatch"
101
+ *
102
+ * const error = new OpenApiPatch.JsonPatchApplicationError({
103
+ * source: "./patches/fix.json",
104
+ * operationIndex: 2,
105
+ * operation: "remove",
106
+ * path: "/paths/~1users",
107
+ * reason: "Property \"users\" does not exist"
108
+ * })
109
+ *
110
+ * console.log(error.message)
111
+ * // "Failed to apply patch from ./patches/fix.json: operation 2 (remove at /paths/~1users): Property \"users\" does not exist"
112
+ * ```
113
+ *
114
+ * @since 1.0.0
115
+ * @category errors
116
+ */
117
+ export class JsonPatchApplicationError extends /*#__PURE__*/Schema.ErrorClass("JsonPatchApplicationError")({
118
+ _tag: /*#__PURE__*/Schema.tag("JsonPatchApplicationError"),
119
+ source: Schema.String,
120
+ operationIndex: Schema.Number,
121
+ operation: Schema.String,
122
+ path: Schema.String,
123
+ reason: Schema.String
124
+ }) {
125
+ get message() {
126
+ return `Failed to apply patch from ${this.source}: operation ${this.operationIndex} ` + `(${this.operation} at ${this.path}): ${this.reason}`;
127
+ }
128
+ }
129
+ /**
130
+ * Error thrown when multiple JSON Patch operations fail.
131
+ *
132
+ * This error aggregates all application errors so users can see every
133
+ * failing operation at once instead of fixing them one at a time.
134
+ *
135
+ * @example
136
+ * ```ts
137
+ * import * as OpenApiPatch from "@effect/openapi-generator/OpenApiPatch"
138
+ *
139
+ * const error = new OpenApiPatch.JsonPatchAggregateError({
140
+ * errors: [
141
+ * new OpenApiPatch.JsonPatchApplicationError({
142
+ * source: "./fix.json",
143
+ * operationIndex: 0,
144
+ * operation: "replace",
145
+ * path: "/info/x",
146
+ * reason: "Property does not exist"
147
+ * }),
148
+ * new OpenApiPatch.JsonPatchApplicationError({
149
+ * source: "./fix.json",
150
+ * operationIndex: 2,
151
+ * operation: "remove",
152
+ * path: "/paths/~1users",
153
+ * reason: "Property does not exist"
154
+ * })
155
+ * ]
156
+ * })
157
+ *
158
+ * console.log(error.message)
159
+ * // "2 patch operations failed:\n 1. ..."
160
+ * ```
161
+ *
162
+ * @since 1.0.0
163
+ * @category errors
164
+ */
165
+ export class JsonPatchAggregateError extends /*#__PURE__*/Schema.ErrorClass("JsonPatchAggregateError")({
166
+ _tag: /*#__PURE__*/Schema.tag("JsonPatchAggregateError"),
167
+ errors: /*#__PURE__*/Schema.Array(Schema.Unknown)
168
+ }) {
169
+ get message() {
170
+ const errors = this.errors;
171
+ const count = errors.length;
172
+ const plural = count === 1 ? "operation" : "operations";
173
+ const details = errors.map((e, i) => ` ${i + 1}. [${e.source}] op ${e.operationIndex} (${e.operation} at ${e.path}): ${e.reason}`).join("\n");
174
+ return `${count} patch ${plural} failed:\n${details}`;
175
+ }
176
+ }
177
+ // =============================================================================
178
+ // Schema
179
+ // =============================================================================
180
+ /**
181
+ * Schema for a JSON Patch "add" operation.
182
+ *
183
+ * @since 1.0.0
184
+ * @category schemas
185
+ */
186
+ export const JsonPatchAdd = /*#__PURE__*/Schema.Struct({
187
+ op: /*#__PURE__*/Schema.Literal("add"),
188
+ path: Schema.String,
189
+ value: Schema.Json,
190
+ description: /*#__PURE__*/Schema.optionalKey(Schema.String)
191
+ });
192
+ /**
193
+ * Schema for a JSON Patch "remove" operation.
194
+ *
195
+ * @since 1.0.0
196
+ * @category schemas
197
+ */
198
+ export const JsonPatchRemove = /*#__PURE__*/Schema.Struct({
199
+ op: /*#__PURE__*/Schema.Literal("remove"),
200
+ path: Schema.String,
201
+ description: /*#__PURE__*/Schema.optionalKey(Schema.String)
202
+ });
203
+ /**
204
+ * Schema for a JSON Patch "replace" operation.
205
+ *
206
+ * @since 1.0.0
207
+ * @category schemas
208
+ */
209
+ export const JsonPatchReplace = /*#__PURE__*/Schema.Struct({
210
+ op: /*#__PURE__*/Schema.Literal("replace"),
211
+ path: Schema.String,
212
+ value: Schema.Json,
213
+ description: /*#__PURE__*/Schema.optionalKey(Schema.String)
214
+ });
215
+ /**
216
+ * Schema for a single JSON Patch operation.
217
+ *
218
+ * Supports the subset of RFC 6902 operations that Effect's JsonPatch module
219
+ * implements: `add`, `remove`, and `replace`.
220
+ *
221
+ * @since 1.0.0
222
+ * @category schemas
223
+ */
224
+ export const JsonPatchOperation = /*#__PURE__*/Schema.Union([JsonPatchAdd, JsonPatchRemove, JsonPatchReplace]);
225
+ /**
226
+ * Schema for a JSON Patch document (array of operations).
227
+ *
228
+ * A JSON Patch document is an ordered list of operations to apply to a JSON
229
+ * document. Operations are applied in sequence, with each operation seeing
230
+ * the result of previous operations.
231
+ *
232
+ * @example
233
+ * ```ts
234
+ * import { Schema } from "effect"
235
+ * import * as OpenApiPatch from "@effect/openapi-generator/OpenApiPatch"
236
+ *
237
+ * const patch = Schema.decodeUnknownSync(OpenApiPatch.JsonPatchDocument)([
238
+ * { op: "add", path: "/foo", value: "bar" },
239
+ * { op: "remove", path: "/baz" },
240
+ * { op: "replace", path: "/qux", value: 42 }
241
+ * ])
242
+ * ```
243
+ *
244
+ * @since 1.0.0
245
+ * @category schemas
246
+ */
247
+ export const JsonPatchDocument = /*#__PURE__*/Schema.Array(JsonPatchOperation);
248
+ // =============================================================================
249
+ // Parsing Functions
250
+ // =============================================================================
251
+ const decodeJsonPatchDocument = /*#__PURE__*/Schema.decodeUnknownEffect(JsonPatchDocument);
252
+ /**
253
+ * Check if a string looks like it could be a file path.
254
+ *
255
+ * Heuristic: contains path separators or ends with a known extension.
256
+ */
257
+ const looksLikeFilePath = input => {
258
+ const trimmed = input.trim();
259
+ if (trimmed.startsWith("[")) return false;
260
+ if (trimmed.includes("/") || trimmed.includes("\\")) return true;
261
+ if (/\.(json|yaml|yml)$/i.test(trimmed)) return true;
262
+ return false;
263
+ };
264
+ /**
265
+ * Determine file format from extension.
266
+ */
267
+ const getFileFormat = /*#__PURE__*/Effect.fn(function* (filePath) {
268
+ const path = yield* Path.Path;
269
+ const {
270
+ ext
271
+ } = path.parse(filePath);
272
+ if (ext === ".json") return "json";
273
+ if (ext === ".yaml" || ext === ".yml") return "yaml";
274
+ return undefined;
275
+ });
276
+ /**
277
+ * Check if a file path exists and is a file.
278
+ */
279
+ const checkFileExists = /*#__PURE__*/Effect.fn("checkFileExists")(function* (filePath) {
280
+ const fs = yield* FileSystem.FileSystem;
281
+ const path = yield* Path.Path;
282
+ const absolutePath = path.isAbsolute(filePath) ? filePath : path.resolve(filePath);
283
+ const exists = yield* Effect.orElseSucceed(fs.exists(absolutePath), constFalse);
284
+ if (!exists) return false;
285
+ const stat = yield* Effect.orElseSucceed(fs.stat(absolutePath), constUndefined);
286
+ return Predicate.isNotUndefined(stat) && stat.type === "File";
287
+ });
288
+ /**
289
+ * Parse content as JSON.
290
+ */
291
+ const parseJsonContent = /*#__PURE__*/Effect.fnUntraced(function* (content, source) {
292
+ return yield* Effect.try({
293
+ try: () => JSON.parse(content),
294
+ catch: error => new JsonPatchParseError({
295
+ source,
296
+ reason: error instanceof Error ? error.message : String(error)
297
+ })
298
+ });
299
+ });
300
+ /**
301
+ * Parse content as YAML.
302
+ */
303
+ const parseYamlContent = /*#__PURE__*/Effect.fnUntraced(function* (content, source) {
304
+ return yield* Effect.try({
305
+ try: () => Yaml.parse(content),
306
+ catch: error => new JsonPatchParseError({
307
+ source,
308
+ reason: error instanceof Error ? error.message : String(error)
309
+ })
310
+ });
311
+ });
312
+ /**
313
+ * Read and parse a patch file.
314
+ */
315
+ const parsePatchFile = /*#__PURE__*/Effect.fn("parsePatchFile")(function* (filePath) {
316
+ const fs = yield* FileSystem.FileSystem;
317
+ const path = yield* Path.Path;
318
+ const absolutePath = path.isAbsolute(filePath) ? filePath : path.resolve(filePath);
319
+ const fileFormat = yield* getFileFormat(filePath);
320
+ if (Predicate.isUndefined(fileFormat)) {
321
+ return yield* new JsonPatchParseError({
322
+ source: filePath,
323
+ reason: `Unsupported file format. Expected .json, .yaml, or .yml`
324
+ });
325
+ }
326
+ const content = yield* Effect.mapError(fs.readFileString(absolutePath), error => new JsonPatchParseError({
327
+ source: filePath,
328
+ reason: `Failed to read file: ${error.message}`
329
+ }));
330
+ const parsed = fileFormat === "json" ? yield* parseJsonContent(content, filePath) : yield* parseYamlContent(content, filePath);
331
+ return yield* Effect.mapError(decodeJsonPatchDocument(parsed), error => new JsonPatchValidationError({
332
+ source: filePath,
333
+ reason: error.message
334
+ }));
335
+ });
336
+ /**
337
+ * Parse inline JSON string as a patch document.
338
+ */
339
+ const parseInlinePatch = /*#__PURE__*/Effect.fn("parseInlinePatch")(function* (input) {
340
+ const parsed = yield* parseJsonContent(input, "inline");
341
+ return yield* Effect.mapError(decodeJsonPatchDocument(parsed), error => new JsonPatchValidationError({
342
+ source: "inline",
343
+ reason: error.message
344
+ }));
345
+ });
346
+ /**
347
+ * Parse a JSON Patch from either a file path or inline JSON string.
348
+ *
349
+ * The input is first checked as a file path. If the file exists, it is read
350
+ * and parsed based on its extension (.json, .yaml, .yml). Otherwise, the
351
+ * input is parsed as inline JSON.
352
+ *
353
+ * @example
354
+ * ```ts
355
+ * import { Effect } from "effect"
356
+ * import * as OpenApiPatch from "@effect/openapi-generator/OpenApiPatch"
357
+ *
358
+ * // From inline JSON
359
+ * const fromInline = OpenApiPatch.parsePatchInput(
360
+ * '[{"op":"replace","path":"/info/title","value":"My API"}]'
361
+ * )
362
+ *
363
+ * // From file path
364
+ * const fromFile = OpenApiPatch.parsePatchInput("./patches/fix-api.json")
365
+ *
366
+ * const program = Effect.gen(function*() {
367
+ * const patch = yield* fromInline
368
+ * console.log(patch)
369
+ * // [{ op: "replace", path: "/info/title", value: "My API" }]
370
+ * })
371
+ * ```
372
+ *
373
+ * @since 1.0.0
374
+ * @category parsing
375
+ */
376
+ export const parsePatchInput = /*#__PURE__*/Effect.fn("parsePatchInput")(function* (input) {
377
+ if (looksLikeFilePath(input)) {
378
+ const exists = yield* checkFileExists(input);
379
+ if (exists) {
380
+ return yield* parsePatchFile(input);
381
+ }
382
+ }
383
+ return yield* parseInlinePatch(input);
384
+ });
385
+ // =============================================================================
386
+ // Application Functions
387
+ // =============================================================================
388
+ /**
389
+ * Apply a sequence of JSON patches to a document.
390
+ *
391
+ * Patches are applied in order, with each patch operating on the result of
392
+ * the previous one. All operations are attempted, and if any fail, the errors
393
+ * are accumulated and reported together so users can fix all issues at once.
394
+ *
395
+ * @example
396
+ * ```ts
397
+ * import { Effect } from "effect"
398
+ * import * as OpenApiPatch from "@effect/openapi-generator/OpenApiPatch"
399
+ *
400
+ * const document = { info: { title: "Old Title" }, paths: {} }
401
+ * const patches = [
402
+ * {
403
+ * source: "inline",
404
+ * patch: [{ op: "replace" as const, path: "/info/title", value: "New Title" }]
405
+ * }
406
+ * ]
407
+ *
408
+ * const program = Effect.gen(function*() {
409
+ * const result = yield* OpenApiPatch.applyPatches(patches, document)
410
+ * console.log(result)
411
+ * // { info: { title: "New Title" }, paths: {} }
412
+ * })
413
+ * ```
414
+ *
415
+ * @since 1.0.0
416
+ * @category application
417
+ */
418
+ export const applyPatches = /*#__PURE__*/Effect.fn("applyPatches")(function* (patches, document) {
419
+ let result = document;
420
+ const errors = [];
421
+ for (const {
422
+ source,
423
+ patch
424
+ } of patches) {
425
+ for (let i = 0; i < patch.length; i++) {
426
+ const op = patch[i];
427
+ yield* Effect.ignore(Effect.try({
428
+ try: () => {
429
+ result = JsonPatch.apply([op], result);
430
+ },
431
+ catch: error => errors.push(new JsonPatchApplicationError({
432
+ source,
433
+ operationIndex: i,
434
+ operation: op.op,
435
+ path: op.path,
436
+ reason: error instanceof Error ? error.message : String(error)
437
+ }))
438
+ }));
439
+ }
440
+ }
441
+ if (errors.length > 0) {
442
+ return yield* new JsonPatchAggregateError({
443
+ errors
444
+ });
445
+ }
446
+ return result;
447
+ });
448
+ //# sourceMappingURL=OpenApiPatch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpenApiPatch.js","names":["Effect","FileSystem","constFalse","constUndefined","JsonPatch","Path","Predicate","Schema","Yaml","JsonPatchParseError","ErrorClass","_tag","tag","source","String","reason","message","JsonPatchValidationError","JsonPatchApplicationError","operationIndex","Number","operation","path","JsonPatchAggregateError","errors","Array","Unknown","count","length","plural","details","map","e","i","join","JsonPatchAdd","Struct","op","Literal","value","Json","description","optionalKey","JsonPatchRemove","JsonPatchReplace","JsonPatchOperation","Union","JsonPatchDocument","decodeJsonPatchDocument","decodeUnknownEffect","looksLikeFilePath","input","trimmed","trim","startsWith","includes","test","getFileFormat","fn","filePath","ext","parse","undefined","checkFileExists","fs","absolutePath","isAbsolute","resolve","exists","orElseSucceed","stat","isNotUndefined","type","parseJsonContent","fnUntraced","content","try","JSON","catch","error","Error","parseYamlContent","parsePatchFile","fileFormat","isUndefined","mapError","readFileString","parsed","parseInlinePatch","parsePatchInput","applyPatches","patches","document","result","patch","ignore","apply","push"],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AAC;QACDf,KAAK,EAAGC,KAAK,IACXvD,MAAM,CAACyE,IAAI,CACT,IAAI/E,yBAAyB,CAAC;UAC5BL,MAAM;UACNM,cAAc,EAAEc,CAAC;UACjBZ,SAAS,EAAEgB,EAAE,CAACA,EAAE;UAChBf,IAAI,EAAEe,EAAE,CAACf,IAAI;UACbP,MAAM,EAAEgE,KAAK,YAAYC,KAAK,GAAGD,KAAK,CAAC/D,OAAO,GAAGF,MAAM,CAACiE,KAAK;SAC9D,CAAC;OAEP,CAAC,CAAC;IACL;EACF;EAEA,IAAIvD,MAAM,CAACI,MAAM,GAAG,CAAC,EAAE;IACrB,OAAO,OAAO,IAAIL,uBAAuB,CAAC;MAAEC;IAAM,CAAE,CAAC;EACvD;EAEA,OAAOqE,MAAM;AACf,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,24 @@
1
+ import * as Layer from "effect/Layer";
2
+ import * as ServiceMap from "effect/ServiceMap";
3
+ import type { ParsedOperation } from "./ParsedOperation.ts";
4
+ declare const OpenApiTransformer_base: ServiceMap.ServiceClass<OpenApiTransformer, "OpenApiTransformer", {
5
+ readonly imports: (importName: string, operations: ReadonlyArray<ParsedOperation>) => string;
6
+ readonly toTypes: (importName: string, name: string, operations: ReadonlyArray<ParsedOperation>) => string;
7
+ readonly toImplementation: (importName: string, name: string, operations: ReadonlyArray<ParsedOperation>) => string;
8
+ }>;
9
+ export declare class OpenApiTransformer extends OpenApiTransformer_base {
10
+ }
11
+ export declare const makeTransformerSchema: () => {
12
+ readonly imports: (importName: string, operations: ReadonlyArray<ParsedOperation>) => string;
13
+ readonly toTypes: (importName: string, name: string, operations: ReadonlyArray<ParsedOperation>) => string;
14
+ readonly toImplementation: (importName: string, name: string, operations: ReadonlyArray<ParsedOperation>) => string;
15
+ };
16
+ export declare const layerTransformerSchema: Layer.Layer<OpenApiTransformer, never, never>;
17
+ export declare const makeTransformerTs: () => {
18
+ readonly imports: (importName: string, operations: ReadonlyArray<ParsedOperation>) => string;
19
+ readonly toTypes: (importName: string, name: string, operations: ReadonlyArray<ParsedOperation>) => string;
20
+ readonly toImplementation: (importName: string, name: string, operations: ReadonlyArray<ParsedOperation>) => string;
21
+ };
22
+ export declare const layerTransformerTs: Layer.Layer<OpenApiTransformer, never, never>;
23
+ export {};
24
+ //# sourceMappingURL=OpenApiTransformer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpenApiTransformer.d.ts","sourceRoot":"","sources":["../src/OpenApiTransformer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAA;AAE/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;;sBAMrC,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,CAAC,eAAe,CAAC,KAAK,MAAM;sBAC1E,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,CAAC,eAAe,CAAC,KAAK,MAAM;+BAC/E,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,CAAC,eAAe,CAAC,KAAK,MAAM;;AALvH,qBAAa,kBAAmB,SAAQ,uBAOf;CAAG;AAmC5B,eAAO,MAAM,qBAAqB;sBAvCZ,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,CAAC,eAAe,CAAC,KAAK,MAAM;sBAC1E,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,CAAC,eAAe,CAAC,KAAK,MAAM;+BAC/E,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,CAAC,eAAe,CAAC,KAAK,MAAM;CA8ZtH,CAAA;AAED,eAAO,MAAM,sBAAsB,+CAGlC,CAAA;AAED,eAAO,MAAM,iBAAiB;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