@effect/openapi-generator 4.0.0-beta.65 → 4.0.0-beta.67
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/HttpApiTransformer.d.ts +31 -0
- package/dist/HttpApiTransformer.d.ts.map +1 -1
- package/dist/HttpApiTransformer.js +20 -0
- package/dist/HttpApiTransformer.js.map +1 -1
- package/dist/JsonSchemaGenerator.d.ts +10 -0
- package/dist/JsonSchemaGenerator.d.ts.map +1 -1
- package/dist/JsonSchemaGenerator.js +30 -0
- package/dist/JsonSchemaGenerator.js.map +1 -1
- package/dist/OpenApiGenerator.d.ts +38 -0
- package/dist/OpenApiGenerator.d.ts.map +1 -1
- package/dist/OpenApiGenerator.js +25 -0
- package/dist/OpenApiGenerator.js.map +1 -1
- package/dist/OpenApiPatch.d.ts +26 -21
- package/dist/OpenApiPatch.d.ts.map +1 -1
- package/dist/OpenApiPatch.js +25 -20
- package/dist/OpenApiPatch.js.map +1 -1
- package/dist/OpenApiTransformer.d.ts +63 -0
- package/dist/OpenApiTransformer.d.ts.map +1 -1
- package/dist/OpenApiTransformer.js +63 -0
- package/dist/OpenApiTransformer.js.map +1 -1
- package/dist/ParsedOperation.d.ts +51 -0
- package/dist/ParsedOperation.d.ts.map +1 -1
- package/dist/ParsedOperation.js +3 -0
- package/dist/ParsedOperation.js.map +1 -1
- package/dist/Utils.d.ts +28 -0
- package/dist/Utils.d.ts.map +1 -1
- package/dist/Utils.js +38 -0
- package/dist/Utils.js.map +1 -1
- package/dist/main.d.ts +7 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +17 -0
- package/dist/main.js.map +1 -1
- package/package.json +5 -5
- package/src/HttpApiTransformer.ts +31 -0
- package/src/JsonSchemaGenerator.ts +30 -0
- package/src/OpenApiGenerator.ts +38 -0
- package/src/OpenApiPatch.ts +26 -21
- package/src/OpenApiTransformer.ts +63 -0
- package/src/ParsedOperation.ts +51 -0
- package/src/Utils.ts +38 -0
- package/src/main.ts +17 -0
package/dist/OpenApiPatch.d.ts
CHANGED
|
@@ -6,8 +6,6 @@
|
|
|
6
6
|
* - JSON files (.json)
|
|
7
7
|
* - YAML files (.yaml, .yml)
|
|
8
8
|
* - Inline JSON strings
|
|
9
|
-
*
|
|
10
|
-
* @module OpenApiPatch
|
|
11
9
|
*/
|
|
12
10
|
import * as Effect from "effect/Effect";
|
|
13
11
|
import * as FileSystem from "effect/FileSystem";
|
|
@@ -27,7 +25,8 @@ declare const JsonPatchParseError_base: Schema.Class<JsonPatchParseError, Schema
|
|
|
27
25
|
* - JSON or YAML syntax is invalid
|
|
28
26
|
* - The file format is unsupported
|
|
29
27
|
*
|
|
30
|
-
*
|
|
28
|
+
* **Example** (Creating a parse error)
|
|
29
|
+
*
|
|
31
30
|
* ```ts
|
|
32
31
|
* import * as OpenApiPatch from "@effect/openapi-generator/OpenApiPatch"
|
|
33
32
|
*
|
|
@@ -40,8 +39,8 @@ declare const JsonPatchParseError_base: Schema.Class<JsonPatchParseError, Schema
|
|
|
40
39
|
* // "Failed to parse patch from ./patches/fix.json: Unexpected token at position 42"
|
|
41
40
|
* ```
|
|
42
41
|
*
|
|
43
|
-
* @since 1.0.0
|
|
44
42
|
* @category errors
|
|
43
|
+
* @since 4.0.0
|
|
45
44
|
*/
|
|
46
45
|
export declare class JsonPatchParseError extends JsonPatchParseError_base {
|
|
47
46
|
get message(): string;
|
|
@@ -60,7 +59,8 @@ declare const JsonPatchValidationError_base: Schema.Class<JsonPatchValidationErr
|
|
|
60
59
|
* - An operation has an unsupported op value
|
|
61
60
|
* - An add/replace operation is missing the value field
|
|
62
61
|
*
|
|
63
|
-
*
|
|
62
|
+
* **Example** (Creating a validation error)
|
|
63
|
+
*
|
|
64
64
|
* ```ts
|
|
65
65
|
* import * as OpenApiPatch from "@effect/openapi-generator/OpenApiPatch"
|
|
66
66
|
*
|
|
@@ -73,8 +73,8 @@ declare const JsonPatchValidationError_base: Schema.Class<JsonPatchValidationErr
|
|
|
73
73
|
* // "Invalid JSON Patch from inline: Expected 'add' | 'remove' | 'replace' at [0].op, got 'copy'"
|
|
74
74
|
* ```
|
|
75
75
|
*
|
|
76
|
-
* @since 1.0.0
|
|
77
76
|
* @category errors
|
|
77
|
+
* @since 4.0.0
|
|
78
78
|
*/
|
|
79
79
|
export declare class JsonPatchValidationError extends JsonPatchValidationError_base {
|
|
80
80
|
get message(): string;
|
|
@@ -95,7 +95,8 @@ declare const JsonPatchApplicationError_base: Schema.Class<JsonPatchApplicationE
|
|
|
95
95
|
* - An array index is out of bounds
|
|
96
96
|
* - The target location is not a valid container
|
|
97
97
|
*
|
|
98
|
-
*
|
|
98
|
+
* **Example** (Creating an application error)
|
|
99
|
+
*
|
|
99
100
|
* ```ts
|
|
100
101
|
* import * as OpenApiPatch from "@effect/openapi-generator/OpenApiPatch"
|
|
101
102
|
*
|
|
@@ -111,8 +112,8 @@ declare const JsonPatchApplicationError_base: Schema.Class<JsonPatchApplicationE
|
|
|
111
112
|
* // "Failed to apply patch from ./patches/fix.json: operation 2 (remove at /paths/~1users): Property \"users\" does not exist"
|
|
112
113
|
* ```
|
|
113
114
|
*
|
|
114
|
-
* @since 1.0.0
|
|
115
115
|
* @category errors
|
|
116
|
+
* @since 4.0.0
|
|
116
117
|
*/
|
|
117
118
|
export declare class JsonPatchApplicationError extends JsonPatchApplicationError_base {
|
|
118
119
|
get message(): string;
|
|
@@ -127,7 +128,8 @@ declare const JsonPatchAggregateError_base: Schema.Class<JsonPatchAggregateError
|
|
|
127
128
|
* This error aggregates all application errors so users can see every
|
|
128
129
|
* failing operation at once instead of fixing them one at a time.
|
|
129
130
|
*
|
|
130
|
-
*
|
|
131
|
+
* **Example** (Creating an aggregate error)
|
|
132
|
+
*
|
|
131
133
|
* ```ts
|
|
132
134
|
* import * as OpenApiPatch from "@effect/openapi-generator/OpenApiPatch"
|
|
133
135
|
*
|
|
@@ -154,8 +156,8 @@ declare const JsonPatchAggregateError_base: Schema.Class<JsonPatchAggregateError
|
|
|
154
156
|
* // "2 patch operations failed:\n 1. ..."
|
|
155
157
|
* ```
|
|
156
158
|
*
|
|
157
|
-
* @since 1.0.0
|
|
158
159
|
* @category errors
|
|
160
|
+
* @since 4.0.0
|
|
159
161
|
*/
|
|
160
162
|
export declare class JsonPatchAggregateError extends JsonPatchAggregateError_base {
|
|
161
163
|
get message(): string;
|
|
@@ -163,8 +165,8 @@ export declare class JsonPatchAggregateError extends JsonPatchAggregateError_bas
|
|
|
163
165
|
/**
|
|
164
166
|
* Schema for a JSON Patch "add" operation.
|
|
165
167
|
*
|
|
166
|
-
* @since 1.0.0
|
|
167
168
|
* @category schemas
|
|
169
|
+
* @since 4.0.0
|
|
168
170
|
*/
|
|
169
171
|
export declare const JsonPatchAdd: Schema.Codec<Extract<JsonPatch.JsonPatchOperation, {
|
|
170
172
|
op: "add";
|
|
@@ -172,8 +174,8 @@ export declare const JsonPatchAdd: Schema.Codec<Extract<JsonPatch.JsonPatchOpera
|
|
|
172
174
|
/**
|
|
173
175
|
* Schema for a JSON Patch "remove" operation.
|
|
174
176
|
*
|
|
175
|
-
* @since 1.0.0
|
|
176
177
|
* @category schemas
|
|
178
|
+
* @since 4.0.0
|
|
177
179
|
*/
|
|
178
180
|
export declare const JsonPatchRemove: Schema.Codec<Extract<JsonPatch.JsonPatchOperation, {
|
|
179
181
|
op: "remove";
|
|
@@ -181,8 +183,8 @@ export declare const JsonPatchRemove: Schema.Codec<Extract<JsonPatch.JsonPatchOp
|
|
|
181
183
|
/**
|
|
182
184
|
* Schema for a JSON Patch "replace" operation.
|
|
183
185
|
*
|
|
184
|
-
* @since 1.0.0
|
|
185
186
|
* @category schemas
|
|
187
|
+
* @since 4.0.0
|
|
186
188
|
*/
|
|
187
189
|
export declare const JsonPatchReplace: Schema.Codec<Extract<JsonPatch.JsonPatchOperation, {
|
|
188
190
|
op: "replace";
|
|
@@ -193,8 +195,8 @@ export declare const JsonPatchReplace: Schema.Codec<Extract<JsonPatch.JsonPatchO
|
|
|
193
195
|
* Supports the subset of RFC 6902 operations that Effect's JsonPatch module
|
|
194
196
|
* implements: `add`, `remove`, and `replace`.
|
|
195
197
|
*
|
|
196
|
-
* @since 1.0.0
|
|
197
198
|
* @category schemas
|
|
199
|
+
* @since 4.0.0
|
|
198
200
|
*/
|
|
199
201
|
export declare const JsonPatchOperation: Schema.Codec<JsonPatch.JsonPatchOperation>;
|
|
200
202
|
/**
|
|
@@ -204,7 +206,8 @@ export declare const JsonPatchOperation: Schema.Codec<JsonPatch.JsonPatchOperati
|
|
|
204
206
|
* document. Operations are applied in sequence, with each operation seeing
|
|
205
207
|
* the result of previous operations.
|
|
206
208
|
*
|
|
207
|
-
*
|
|
209
|
+
* **Example** (Decoding a patch document)
|
|
210
|
+
*
|
|
208
211
|
* ```ts
|
|
209
212
|
* import { Schema } from "effect"
|
|
210
213
|
* import * as OpenApiPatch from "@effect/openapi-generator/OpenApiPatch"
|
|
@@ -216,15 +219,15 @@ export declare const JsonPatchOperation: Schema.Codec<JsonPatch.JsonPatchOperati
|
|
|
216
219
|
* ])
|
|
217
220
|
* ```
|
|
218
221
|
*
|
|
219
|
-
* @since 1.0.0
|
|
220
222
|
* @category schemas
|
|
223
|
+
* @since 4.0.0
|
|
221
224
|
*/
|
|
222
225
|
export declare const JsonPatchDocument: Schema.$Array<Schema.Codec<JsonPatch.JsonPatchOperation, JsonPatch.JsonPatchOperation, never, never>>;
|
|
223
226
|
/**
|
|
224
227
|
* Type for a JSON Patch document.
|
|
225
228
|
*
|
|
226
|
-
* @since 1.0.0
|
|
227
229
|
* @category types
|
|
230
|
+
* @since 4.0.0
|
|
228
231
|
*/
|
|
229
232
|
export type JsonPatchDocument = typeof JsonPatchDocument.Type;
|
|
230
233
|
/**
|
|
@@ -234,7 +237,8 @@ export type JsonPatchDocument = typeof JsonPatchDocument.Type;
|
|
|
234
237
|
* and parsed based on its extension (.json, .yaml, .yml). Otherwise, the
|
|
235
238
|
* input is parsed as inline JSON.
|
|
236
239
|
*
|
|
237
|
-
*
|
|
240
|
+
* **Example** (Parsing patch input)
|
|
241
|
+
*
|
|
238
242
|
* ```ts
|
|
239
243
|
* import { Effect } from "effect"
|
|
240
244
|
* import * as OpenApiPatch from "@effect/openapi-generator/OpenApiPatch"
|
|
@@ -254,8 +258,8 @@ export type JsonPatchDocument = typeof JsonPatchDocument.Type;
|
|
|
254
258
|
* })
|
|
255
259
|
* ```
|
|
256
260
|
*
|
|
257
|
-
* @since 1.0.0
|
|
258
261
|
* @category parsing
|
|
262
|
+
* @since 4.0.0
|
|
259
263
|
*/
|
|
260
264
|
export declare const parsePatchInput: (input: string) => Effect.Effect<readonly JsonPatch.JsonPatchOperation[], JsonPatchParseError | JsonPatchValidationError, Path.Path | FileSystem.FileSystem>;
|
|
261
265
|
/**
|
|
@@ -265,7 +269,8 @@ export declare const parsePatchInput: (input: string) => Effect.Effect<readonly
|
|
|
265
269
|
* the previous one. All operations are attempted, and if any fail, the errors
|
|
266
270
|
* are accumulated and reported together so users can fix all issues at once.
|
|
267
271
|
*
|
|
268
|
-
*
|
|
272
|
+
* **Example** (Applying patches)
|
|
273
|
+
*
|
|
269
274
|
* ```ts
|
|
270
275
|
* import { Effect } from "effect"
|
|
271
276
|
* import * as OpenApiPatch from "@effect/openapi-generator/OpenApiPatch"
|
|
@@ -285,8 +290,8 @@ export declare const parsePatchInput: (input: string) => Effect.Effect<readonly
|
|
|
285
290
|
* })
|
|
286
291
|
* ```
|
|
287
292
|
*
|
|
288
|
-
* @since 1.0.0
|
|
289
293
|
* @category application
|
|
294
|
+
* @since 4.0.0
|
|
290
295
|
*/
|
|
291
296
|
export declare const applyPatches: (patches: readonly {
|
|
292
297
|
readonly source: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenApiPatch.d.ts","sourceRoot":"","sources":["../src/OpenApiPatch.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"OpenApiPatch.d.ts","sourceRoot":"","sources":["../src/OpenAp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AQG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,kBAAkB,CAIxE,CAAA;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,iBAAiB,uGAAmC,CAAA;AAEjE;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,OAAO,iBAAiB,CAAC,IAAI,CAAA;AAsH7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,eAAe,8JAQ1B,CAAA;AAMF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,YAAY;qBACmB,MAAM;oBAAkB,iBAAiB;yFAgCnF,CAAA"}
|
package/dist/OpenApiPatch.js
CHANGED
|
@@ -6,8 +6,6 @@
|
|
|
6
6
|
* - JSON files (.json)
|
|
7
7
|
* - YAML files (.yaml, .yml)
|
|
8
8
|
* - Inline JSON strings
|
|
9
|
-
*
|
|
10
|
-
* @module OpenApiPatch
|
|
11
9
|
*/
|
|
12
10
|
import * as Effect from "effect/Effect";
|
|
13
11
|
import * as FileSystem from "effect/FileSystem";
|
|
@@ -28,7 +26,8 @@ import * as Yaml from "yaml";
|
|
|
28
26
|
* - JSON or YAML syntax is invalid
|
|
29
27
|
* - The file format is unsupported
|
|
30
28
|
*
|
|
31
|
-
*
|
|
29
|
+
* **Example** (Creating a parse error)
|
|
30
|
+
*
|
|
32
31
|
* ```ts
|
|
33
32
|
* import * as OpenApiPatch from "@effect/openapi-generator/OpenApiPatch"
|
|
34
33
|
*
|
|
@@ -41,8 +40,8 @@ import * as Yaml from "yaml";
|
|
|
41
40
|
* // "Failed to parse patch from ./patches/fix.json: Unexpected token at position 42"
|
|
42
41
|
* ```
|
|
43
42
|
*
|
|
44
|
-
* @since 1.0.0
|
|
45
43
|
* @category errors
|
|
44
|
+
* @since 4.0.0
|
|
46
45
|
*/
|
|
47
46
|
export class JsonPatchParseError extends /*#__PURE__*/Schema.ErrorClass("JsonPatchParseError")({
|
|
48
47
|
_tag: /*#__PURE__*/Schema.tag("JsonPatchParseError"),
|
|
@@ -62,7 +61,8 @@ export class JsonPatchParseError extends /*#__PURE__*/Schema.ErrorClass("JsonPat
|
|
|
62
61
|
* - An operation has an unsupported op value
|
|
63
62
|
* - An add/replace operation is missing the value field
|
|
64
63
|
*
|
|
65
|
-
*
|
|
64
|
+
* **Example** (Creating a validation error)
|
|
65
|
+
*
|
|
66
66
|
* ```ts
|
|
67
67
|
* import * as OpenApiPatch from "@effect/openapi-generator/OpenApiPatch"
|
|
68
68
|
*
|
|
@@ -75,8 +75,8 @@ export class JsonPatchParseError extends /*#__PURE__*/Schema.ErrorClass("JsonPat
|
|
|
75
75
|
* // "Invalid JSON Patch from inline: Expected 'add' | 'remove' | 'replace' at [0].op, got 'copy'"
|
|
76
76
|
* ```
|
|
77
77
|
*
|
|
78
|
-
* @since 1.0.0
|
|
79
78
|
* @category errors
|
|
79
|
+
* @since 4.0.0
|
|
80
80
|
*/
|
|
81
81
|
export class JsonPatchValidationError extends /*#__PURE__*/Schema.ErrorClass("JsonPatchValidationError")({
|
|
82
82
|
_tag: /*#__PURE__*/Schema.tag("JsonPatchValidationError"),
|
|
@@ -95,7 +95,8 @@ export class JsonPatchValidationError extends /*#__PURE__*/Schema.ErrorClass("Js
|
|
|
95
95
|
* - An array index is out of bounds
|
|
96
96
|
* - The target location is not a valid container
|
|
97
97
|
*
|
|
98
|
-
*
|
|
98
|
+
* **Example** (Creating an application error)
|
|
99
|
+
*
|
|
99
100
|
* ```ts
|
|
100
101
|
* import * as OpenApiPatch from "@effect/openapi-generator/OpenApiPatch"
|
|
101
102
|
*
|
|
@@ -111,8 +112,8 @@ export class JsonPatchValidationError extends /*#__PURE__*/Schema.ErrorClass("Js
|
|
|
111
112
|
* // "Failed to apply patch from ./patches/fix.json: operation 2 (remove at /paths/~1users): Property \"users\" does not exist"
|
|
112
113
|
* ```
|
|
113
114
|
*
|
|
114
|
-
* @since 1.0.0
|
|
115
115
|
* @category errors
|
|
116
|
+
* @since 4.0.0
|
|
116
117
|
*/
|
|
117
118
|
export class JsonPatchApplicationError extends /*#__PURE__*/Schema.ErrorClass("JsonPatchApplicationError")({
|
|
118
119
|
_tag: /*#__PURE__*/Schema.tag("JsonPatchApplicationError"),
|
|
@@ -132,7 +133,8 @@ export class JsonPatchApplicationError extends /*#__PURE__*/Schema.ErrorClass("J
|
|
|
132
133
|
* This error aggregates all application errors so users can see every
|
|
133
134
|
* failing operation at once instead of fixing them one at a time.
|
|
134
135
|
*
|
|
135
|
-
*
|
|
136
|
+
* **Example** (Creating an aggregate error)
|
|
137
|
+
*
|
|
136
138
|
* ```ts
|
|
137
139
|
* import * as OpenApiPatch from "@effect/openapi-generator/OpenApiPatch"
|
|
138
140
|
*
|
|
@@ -159,8 +161,8 @@ export class JsonPatchApplicationError extends /*#__PURE__*/Schema.ErrorClass("J
|
|
|
159
161
|
* // "2 patch operations failed:\n 1. ..."
|
|
160
162
|
* ```
|
|
161
163
|
*
|
|
162
|
-
* @since 1.0.0
|
|
163
164
|
* @category errors
|
|
165
|
+
* @since 4.0.0
|
|
164
166
|
*/
|
|
165
167
|
export class JsonPatchAggregateError extends /*#__PURE__*/Schema.ErrorClass("JsonPatchAggregateError")({
|
|
166
168
|
_tag: /*#__PURE__*/Schema.tag("JsonPatchAggregateError"),
|
|
@@ -180,8 +182,8 @@ export class JsonPatchAggregateError extends /*#__PURE__*/Schema.ErrorClass("Jso
|
|
|
180
182
|
/**
|
|
181
183
|
* Schema for a JSON Patch "add" operation.
|
|
182
184
|
*
|
|
183
|
-
* @since 1.0.0
|
|
184
185
|
* @category schemas
|
|
186
|
+
* @since 4.0.0
|
|
185
187
|
*/
|
|
186
188
|
export const JsonPatchAdd = /*#__PURE__*/Schema.Struct({
|
|
187
189
|
op: /*#__PURE__*/Schema.Literal("add"),
|
|
@@ -192,8 +194,8 @@ export const JsonPatchAdd = /*#__PURE__*/Schema.Struct({
|
|
|
192
194
|
/**
|
|
193
195
|
* Schema for a JSON Patch "remove" operation.
|
|
194
196
|
*
|
|
195
|
-
* @since 1.0.0
|
|
196
197
|
* @category schemas
|
|
198
|
+
* @since 4.0.0
|
|
197
199
|
*/
|
|
198
200
|
export const JsonPatchRemove = /*#__PURE__*/Schema.Struct({
|
|
199
201
|
op: /*#__PURE__*/Schema.Literal("remove"),
|
|
@@ -203,8 +205,8 @@ export const JsonPatchRemove = /*#__PURE__*/Schema.Struct({
|
|
|
203
205
|
/**
|
|
204
206
|
* Schema for a JSON Patch "replace" operation.
|
|
205
207
|
*
|
|
206
|
-
* @since 1.0.0
|
|
207
208
|
* @category schemas
|
|
209
|
+
* @since 4.0.0
|
|
208
210
|
*/
|
|
209
211
|
export const JsonPatchReplace = /*#__PURE__*/Schema.Struct({
|
|
210
212
|
op: /*#__PURE__*/Schema.Literal("replace"),
|
|
@@ -218,8 +220,8 @@ export const JsonPatchReplace = /*#__PURE__*/Schema.Struct({
|
|
|
218
220
|
* Supports the subset of RFC 6902 operations that Effect's JsonPatch module
|
|
219
221
|
* implements: `add`, `remove`, and `replace`.
|
|
220
222
|
*
|
|
221
|
-
* @since 1.0.0
|
|
222
223
|
* @category schemas
|
|
224
|
+
* @since 4.0.0
|
|
223
225
|
*/
|
|
224
226
|
export const JsonPatchOperation = /*#__PURE__*/Schema.Union([JsonPatchAdd, JsonPatchRemove, JsonPatchReplace]);
|
|
225
227
|
/**
|
|
@@ -229,7 +231,8 @@ export const JsonPatchOperation = /*#__PURE__*/Schema.Union([JsonPatchAdd, JsonP
|
|
|
229
231
|
* document. Operations are applied in sequence, with each operation seeing
|
|
230
232
|
* the result of previous operations.
|
|
231
233
|
*
|
|
232
|
-
*
|
|
234
|
+
* **Example** (Decoding a patch document)
|
|
235
|
+
*
|
|
233
236
|
* ```ts
|
|
234
237
|
* import { Schema } from "effect"
|
|
235
238
|
* import * as OpenApiPatch from "@effect/openapi-generator/OpenApiPatch"
|
|
@@ -241,8 +244,8 @@ export const JsonPatchOperation = /*#__PURE__*/Schema.Union([JsonPatchAdd, JsonP
|
|
|
241
244
|
* ])
|
|
242
245
|
* ```
|
|
243
246
|
*
|
|
244
|
-
* @since 1.0.0
|
|
245
247
|
* @category schemas
|
|
248
|
+
* @since 4.0.0
|
|
246
249
|
*/
|
|
247
250
|
export const JsonPatchDocument = /*#__PURE__*/Schema.Array(JsonPatchOperation);
|
|
248
251
|
// =============================================================================
|
|
@@ -350,7 +353,8 @@ const parseInlinePatch = /*#__PURE__*/Effect.fn("parseInlinePatch")(function* (i
|
|
|
350
353
|
* and parsed based on its extension (.json, .yaml, .yml). Otherwise, the
|
|
351
354
|
* input is parsed as inline JSON.
|
|
352
355
|
*
|
|
353
|
-
*
|
|
356
|
+
* **Example** (Parsing patch input)
|
|
357
|
+
*
|
|
354
358
|
* ```ts
|
|
355
359
|
* import { Effect } from "effect"
|
|
356
360
|
* import * as OpenApiPatch from "@effect/openapi-generator/OpenApiPatch"
|
|
@@ -370,8 +374,8 @@ const parseInlinePatch = /*#__PURE__*/Effect.fn("parseInlinePatch")(function* (i
|
|
|
370
374
|
* })
|
|
371
375
|
* ```
|
|
372
376
|
*
|
|
373
|
-
* @since 1.0.0
|
|
374
377
|
* @category parsing
|
|
378
|
+
* @since 4.0.0
|
|
375
379
|
*/
|
|
376
380
|
export const parsePatchInput = /*#__PURE__*/Effect.fn("parsePatchInput")(function* (input) {
|
|
377
381
|
if (looksLikeFilePath(input)) {
|
|
@@ -392,7 +396,8 @@ export const parsePatchInput = /*#__PURE__*/Effect.fn("parsePatchInput")(functio
|
|
|
392
396
|
* the previous one. All operations are attempted, and if any fail, the errors
|
|
393
397
|
* are accumulated and reported together so users can fix all issues at once.
|
|
394
398
|
*
|
|
395
|
-
*
|
|
399
|
+
* **Example** (Applying patches)
|
|
400
|
+
*
|
|
396
401
|
* ```ts
|
|
397
402
|
* import { Effect } from "effect"
|
|
398
403
|
* import * as OpenApiPatch from "@effect/openapi-generator/OpenApiPatch"
|
|
@@ -412,8 +417,8 @@ export const parsePatchInput = /*#__PURE__*/Effect.fn("parsePatchInput")(functio
|
|
|
412
417
|
* })
|
|
413
418
|
* ```
|
|
414
419
|
*
|
|
415
|
-
* @since 1.0.0
|
|
416
420
|
* @category application
|
|
421
|
+
* @since 4.0.0
|
|
417
422
|
*/
|
|
418
423
|
export const applyPatches = /*#__PURE__*/Effect.fn("applyPatches")(function* (patches, document) {
|
|
419
424
|
let result = document;
|
package/dist/OpenApiPatch.js.map
CHANGED
|
@@ -1 +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"],"sources":["../src/OpenApiPatch.ts"],"sourcesContent":[null],"mappings":"AAAA
|
|
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"],"sources":["../src/OpenApiPatch.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;AAUA,OAAO,KAAKA,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,UAAU,MAAM,mBAAmB;AAC/C,SAASC,UAAU,EAAEC,cAAc,QAAQ,iBAAiB;AAC5D,OAAO,KAAKC,SAAS,MAAM,kBAAkB;AAC7C,OAAO,KAAKC,IAAI,MAAM,aAAa;AACnC,OAAO,KAAKC,SAAS,MAAM,kBAAkB;AAC7C,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,IAAI,MAAM,MAAM;AAE5B;AACA;AACA;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,OAAM,MAAOC,mBAAoB,sBAAQF,MAAM,CAACG,UAAU,CAAsB,qBAAqB,CAAC,CAAC;EACrGC,IAAI,eAAEJ,MAAM,CAACK,GAAG,CAAC,qBAAqB,CAAC;EACvCC,MAAM,EAAEN,MAAM,CAACO,MAAM;EACrBC,MAAM,EAAER,MAAM,CAACO;CAChB,CAAC;EACA,IAAaE,OAAOA,CAAA;IAClB,OAAO,8BAA8B,IAAI,CAACH,MAAM,KAAK,IAAI,CAACE,MAAM,EAAE;EACpE;;AAGF;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,OAAM,MAAOE,wBAAyB,sBAAQV,MAAM,CAACG,UAAU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EAAK,CAAE,IAAIH,OAAO,EAAE;IACvC,KAAK,IAAI1D,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAG6D,KAAK,CAAClE,MAAM,EAAEK,CAAC,EAAE,EAAE;MACrC,MAAMI,EAAE,GAAGyD,KAAK,CAAC7D,CAAC,CAAC;MACnB,OAAOjC,MAAM,CAAC+F,MAAM,CAAC/F,MAAM,CAAC4E,GAAG,CAAC;QAC9BA,GAAG,EAAEA,CAAA,KAAK;UACRiB,MAAM,GAAGzF,SAAS,CAAC4F,KAAK,CAAC,CAAC3D,EAAE,CAAC,EAAEwD,MAAM,CAAC;QACxC,CAAC;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":[]}
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAPI-to-HttpClient code generation for the OpenAPI generator.
|
|
3
|
+
*
|
|
4
|
+
* This module defines the `OpenApiTransformer` service used to render parsed
|
|
5
|
+
* OpenAPI operations into Effect `HttpClient` modules. It provides both
|
|
6
|
+
* schema-backed and type-only transformer implementations, including generated
|
|
7
|
+
* imports, public client interfaces, operation implementations, typed API
|
|
8
|
+
* errors, optional response handling, and helpers for server-sent events and
|
|
9
|
+
* binary response streams.
|
|
10
|
+
*
|
|
11
|
+
* @since 4.0.0
|
|
12
|
+
*/
|
|
1
13
|
import * as Context from "effect/Context";
|
|
2
14
|
import * as Layer from "effect/Layer";
|
|
3
15
|
import type { ParsedOpenApi } from "./ParsedOperation.ts";
|
|
@@ -6,19 +18,70 @@ declare const OpenApiTransformer_base: Context.ServiceClass<OpenApiTransformer,
|
|
|
6
18
|
readonly toTypes: (importName: string, name: string, parsed: ParsedOpenApi) => string;
|
|
7
19
|
readonly toImplementation: (importName: string, name: string, parsed: ParsedOpenApi) => string;
|
|
8
20
|
}>;
|
|
21
|
+
/**
|
|
22
|
+
* Service used by the OpenAPI generator to render parsed operations as an
|
|
23
|
+
* Effect HttpClient module.
|
|
24
|
+
*
|
|
25
|
+
* A transformer owns the code-generation dialect for imports, public client
|
|
26
|
+
* types, and the implementation body. The generator swaps implementations to
|
|
27
|
+
* choose between schema-backed clients and type-only clients.
|
|
28
|
+
*
|
|
29
|
+
* @category code generation
|
|
30
|
+
* @since 4.0.0
|
|
31
|
+
*/
|
|
9
32
|
export declare class OpenApiTransformer extends OpenApiTransformer_base {
|
|
10
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Create the transformer used for schema-backed HttpClient output.
|
|
36
|
+
*
|
|
37
|
+
* Generated clients import Effect Schema values and use them at runtime to
|
|
38
|
+
* decode successful responses and typed API errors. Request parameters and
|
|
39
|
+
* payloads are typed against each schema's encoded representation.
|
|
40
|
+
*
|
|
41
|
+
* @category code generation
|
|
42
|
+
* @since 4.0.0
|
|
43
|
+
*/
|
|
11
44
|
export declare const makeTransformerSchema: () => {
|
|
12
45
|
readonly imports: (importName: string, parsed: ParsedOpenApi) => string;
|
|
13
46
|
readonly toTypes: (importName: string, name: string, parsed: ParsedOpenApi) => string;
|
|
14
47
|
readonly toImplementation: (importName: string, name: string, parsed: ParsedOpenApi) => string;
|
|
15
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
* Layer that provides the schema-backed OpenApiTransformer service.
|
|
51
|
+
*
|
|
52
|
+
* Use this layer when generated HttpClient code should perform runtime response
|
|
53
|
+
* decoding with generated Effect Schema values.
|
|
54
|
+
*
|
|
55
|
+
* @category code generation
|
|
56
|
+
* @since 4.0.0
|
|
57
|
+
*/
|
|
16
58
|
export declare const layerTransformerSchema: Layer.Layer<OpenApiTransformer, never, never>;
|
|
59
|
+
/**
|
|
60
|
+
* Create the transformer used for type-only HttpClient output.
|
|
61
|
+
*
|
|
62
|
+
* Generated clients reference emitted TypeScript types directly and do not
|
|
63
|
+
* import schema decoders for JSON response bodies. Responses are typed as the
|
|
64
|
+
* declared operation result while preserving generated error and stream method
|
|
65
|
+
* shapes.
|
|
66
|
+
*
|
|
67
|
+
* @category code generation
|
|
68
|
+
* @since 4.0.0
|
|
69
|
+
*/
|
|
17
70
|
export declare const makeTransformerTs: () => {
|
|
18
71
|
readonly imports: (importName: string, parsed: ParsedOpenApi) => string;
|
|
19
72
|
readonly toTypes: (importName: string, name: string, parsed: ParsedOpenApi) => string;
|
|
20
73
|
readonly toImplementation: (importName: string, name: string, parsed: ParsedOpenApi) => string;
|
|
21
74
|
};
|
|
75
|
+
/**
|
|
76
|
+
* Layer that provides the type-only OpenApiTransformer service.
|
|
77
|
+
*
|
|
78
|
+
* Use this layer for the `httpclient-type-only` generator format, where the
|
|
79
|
+
* generated client relies on TypeScript types instead of runtime Schema
|
|
80
|
+
* decoding.
|
|
81
|
+
*
|
|
82
|
+
* @category code generation
|
|
83
|
+
* @since 4.0.0
|
|
84
|
+
*/
|
|
22
85
|
export declare const layerTransformerTs: Layer.Layer<OpenApiTransformer, never, never>;
|
|
23
86
|
export {};
|
|
24
87
|
//# sourceMappingURL=OpenApiTransformer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenApiTransformer.d.ts","sourceRoot":"","sources":["../src/OpenApiTransformer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,KAAK,M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,MAAM;+BAC1D,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,KAAK,MAAM;CAszBjG,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,+CAG9B,CAAA"}
|
|
@@ -1,7 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAPI-to-HttpClient code generation for the OpenAPI generator.
|
|
3
|
+
*
|
|
4
|
+
* This module defines the `OpenApiTransformer` service used to render parsed
|
|
5
|
+
* OpenAPI operations into Effect `HttpClient` modules. It provides both
|
|
6
|
+
* schema-backed and type-only transformer implementations, including generated
|
|
7
|
+
* imports, public client interfaces, operation implementations, typed API
|
|
8
|
+
* errors, optional response handling, and helpers for server-sent events and
|
|
9
|
+
* binary response streams.
|
|
10
|
+
*
|
|
11
|
+
* @since 4.0.0
|
|
12
|
+
*/
|
|
1
13
|
import * as Context from "effect/Context";
|
|
2
14
|
import * as Layer from "effect/Layer";
|
|
3
15
|
import * as Predicate from "effect/Predicate";
|
|
4
16
|
import * as Utils from "./Utils.js";
|
|
17
|
+
/**
|
|
18
|
+
* Service used by the OpenAPI generator to render parsed operations as an
|
|
19
|
+
* Effect HttpClient module.
|
|
20
|
+
*
|
|
21
|
+
* A transformer owns the code-generation dialect for imports, public client
|
|
22
|
+
* types, and the implementation body. The generator swaps implementations to
|
|
23
|
+
* choose between schema-backed clients and type-only clients.
|
|
24
|
+
*
|
|
25
|
+
* @category code generation
|
|
26
|
+
* @since 4.0.0
|
|
27
|
+
*/
|
|
5
28
|
export class OpenApiTransformer extends /*#__PURE__*/Context.Service()("OpenApiTransformer") {}
|
|
6
29
|
const computeImportRequirements = operations => {
|
|
7
30
|
let eventStream = false;
|
|
@@ -20,6 +43,16 @@ const computeImportRequirements = operations => {
|
|
|
20
43
|
};
|
|
21
44
|
};
|
|
22
45
|
const requiresStreaming = requirements => requirements.eventStream || requirements.octetStream;
|
|
46
|
+
/**
|
|
47
|
+
* Create the transformer used for schema-backed HttpClient output.
|
|
48
|
+
*
|
|
49
|
+
* Generated clients import Effect Schema values and use them at runtime to
|
|
50
|
+
* decode successful responses and typed API errors. Request parameters and
|
|
51
|
+
* payloads are typed against each schema's encoded representation.
|
|
52
|
+
*
|
|
53
|
+
* @category code generation
|
|
54
|
+
* @since 4.0.0
|
|
55
|
+
*/
|
|
23
56
|
export const makeTransformerSchema = () => {
|
|
24
57
|
const operationsToInterface = (_importName, name, operations) => {
|
|
25
58
|
const methods = [];
|
|
@@ -315,7 +348,27 @@ export const make = (
|
|
|
315
348
|
toImplementation: (importName, name, parsed) => operationsToImpl(importName, name, parsed.operations)
|
|
316
349
|
});
|
|
317
350
|
};
|
|
351
|
+
/**
|
|
352
|
+
* Layer that provides the schema-backed OpenApiTransformer service.
|
|
353
|
+
*
|
|
354
|
+
* Use this layer when generated HttpClient code should perform runtime response
|
|
355
|
+
* decoding with generated Effect Schema values.
|
|
356
|
+
*
|
|
357
|
+
* @category code generation
|
|
358
|
+
* @since 4.0.0
|
|
359
|
+
*/
|
|
318
360
|
export const layerTransformerSchema = /*#__PURE__*/Layer.sync(OpenApiTransformer, makeTransformerSchema);
|
|
361
|
+
/**
|
|
362
|
+
* Create the transformer used for type-only HttpClient output.
|
|
363
|
+
*
|
|
364
|
+
* Generated clients reference emitted TypeScript types directly and do not
|
|
365
|
+
* import schema decoders for JSON response bodies. Responses are typed as the
|
|
366
|
+
* declared operation result while preserving generated error and stream method
|
|
367
|
+
* shapes.
|
|
368
|
+
*
|
|
369
|
+
* @category code generation
|
|
370
|
+
* @since 4.0.0
|
|
371
|
+
*/
|
|
319
372
|
export const makeTransformerTs = () => {
|
|
320
373
|
const operationsToInterface = (_importName, name, operations) => {
|
|
321
374
|
const methods = [];
|
|
@@ -612,6 +665,16 @@ export const make = (
|
|
|
612
665
|
toImplementation: (importName, name, parsed) => operationsToImpl(importName, name, parsed.operations)
|
|
613
666
|
});
|
|
614
667
|
};
|
|
668
|
+
/**
|
|
669
|
+
* Layer that provides the type-only OpenApiTransformer service.
|
|
670
|
+
*
|
|
671
|
+
* Use this layer for the `httpclient-type-only` generator format, where the
|
|
672
|
+
* generated client relies on TypeScript types instead of runtime Schema
|
|
673
|
+
* decoding.
|
|
674
|
+
*
|
|
675
|
+
* @category code generation
|
|
676
|
+
* @since 4.0.0
|
|
677
|
+
*/
|
|
615
678
|
export const layerTransformerTs = /*#__PURE__*/Layer.sync(OpenApiTransformer, makeTransformerTs);
|
|
616
679
|
const commonSource = `const unexpectedStatus = (response: HttpClientResponse.HttpClientResponse) =>
|
|
617
680
|
Effect.flatMap(
|