@effect/openapi-generator 4.0.0-beta.66 → 4.0.0-beta.68
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 +62 -0
- package/dist/OpenApiGenerator.d.ts.map +1 -1
- package/dist/OpenApiGenerator.js +37 -0
- package/dist/OpenApiGenerator.js.map +1 -1
- package/dist/OpenApiPatch.d.ts +27 -20
- package/dist/OpenApiPatch.d.ts.map +1 -1
- package/dist/OpenApiPatch.js +26 -19
- 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 +90 -0
- package/dist/ParsedOperation.d.ts.map +1 -1
- package/dist/ParsedOperation.js +6 -0
- package/dist/ParsedOperation.js.map +1 -1
- package/dist/Utils.d.ts +43 -0
- package/dist/Utils.d.ts.map +1 -1
- package/dist/Utils.js +53 -0
- package/dist/Utils.js.map +1 -1
- package/dist/main.d.ts +10 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +20 -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 +62 -0
- package/src/OpenApiPatch.ts +27 -20
- package/src/OpenApiTransformer.ts +63 -0
- package/src/ParsedOperation.ts +90 -0
- package/src/Utils.ts +53 -0
- package/src/main.ts +20 -0
package/dist/OpenApiPatch.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* - YAML files (.yaml, .yml)
|
|
8
8
|
* - Inline JSON strings
|
|
9
9
|
*
|
|
10
|
-
* @
|
|
10
|
+
* @since 4.0.0
|
|
11
11
|
*/
|
|
12
12
|
import * as Effect from "effect/Effect";
|
|
13
13
|
import * as FileSystem from "effect/FileSystem";
|
|
@@ -27,7 +27,8 @@ declare const JsonPatchParseError_base: Schema.Class<JsonPatchParseError, Schema
|
|
|
27
27
|
* - JSON or YAML syntax is invalid
|
|
28
28
|
* - The file format is unsupported
|
|
29
29
|
*
|
|
30
|
-
*
|
|
30
|
+
* **Example** (Creating a parse error)
|
|
31
|
+
*
|
|
31
32
|
* ```ts
|
|
32
33
|
* import * as OpenApiPatch from "@effect/openapi-generator/OpenApiPatch"
|
|
33
34
|
*
|
|
@@ -40,8 +41,8 @@ declare const JsonPatchParseError_base: Schema.Class<JsonPatchParseError, Schema
|
|
|
40
41
|
* // "Failed to parse patch from ./patches/fix.json: Unexpected token at position 42"
|
|
41
42
|
* ```
|
|
42
43
|
*
|
|
43
|
-
* @since 1.0.0
|
|
44
44
|
* @category errors
|
|
45
|
+
* @since 4.0.0
|
|
45
46
|
*/
|
|
46
47
|
export declare class JsonPatchParseError extends JsonPatchParseError_base {
|
|
47
48
|
get message(): string;
|
|
@@ -60,7 +61,8 @@ declare const JsonPatchValidationError_base: Schema.Class<JsonPatchValidationErr
|
|
|
60
61
|
* - An operation has an unsupported op value
|
|
61
62
|
* - An add/replace operation is missing the value field
|
|
62
63
|
*
|
|
63
|
-
*
|
|
64
|
+
* **Example** (Creating a validation error)
|
|
65
|
+
*
|
|
64
66
|
* ```ts
|
|
65
67
|
* import * as OpenApiPatch from "@effect/openapi-generator/OpenApiPatch"
|
|
66
68
|
*
|
|
@@ -73,8 +75,8 @@ declare const JsonPatchValidationError_base: Schema.Class<JsonPatchValidationErr
|
|
|
73
75
|
* // "Invalid JSON Patch from inline: Expected 'add' | 'remove' | 'replace' at [0].op, got 'copy'"
|
|
74
76
|
* ```
|
|
75
77
|
*
|
|
76
|
-
* @since 1.0.0
|
|
77
78
|
* @category errors
|
|
79
|
+
* @since 4.0.0
|
|
78
80
|
*/
|
|
79
81
|
export declare class JsonPatchValidationError extends JsonPatchValidationError_base {
|
|
80
82
|
get message(): string;
|
|
@@ -95,7 +97,8 @@ declare const JsonPatchApplicationError_base: Schema.Class<JsonPatchApplicationE
|
|
|
95
97
|
* - An array index is out of bounds
|
|
96
98
|
* - The target location is not a valid container
|
|
97
99
|
*
|
|
98
|
-
*
|
|
100
|
+
* **Example** (Creating an application error)
|
|
101
|
+
*
|
|
99
102
|
* ```ts
|
|
100
103
|
* import * as OpenApiPatch from "@effect/openapi-generator/OpenApiPatch"
|
|
101
104
|
*
|
|
@@ -111,8 +114,8 @@ declare const JsonPatchApplicationError_base: Schema.Class<JsonPatchApplicationE
|
|
|
111
114
|
* // "Failed to apply patch from ./patches/fix.json: operation 2 (remove at /paths/~1users): Property \"users\" does not exist"
|
|
112
115
|
* ```
|
|
113
116
|
*
|
|
114
|
-
* @since 1.0.0
|
|
115
117
|
* @category errors
|
|
118
|
+
* @since 4.0.0
|
|
116
119
|
*/
|
|
117
120
|
export declare class JsonPatchApplicationError extends JsonPatchApplicationError_base {
|
|
118
121
|
get message(): string;
|
|
@@ -127,7 +130,8 @@ declare const JsonPatchAggregateError_base: Schema.Class<JsonPatchAggregateError
|
|
|
127
130
|
* This error aggregates all application errors so users can see every
|
|
128
131
|
* failing operation at once instead of fixing them one at a time.
|
|
129
132
|
*
|
|
130
|
-
*
|
|
133
|
+
* **Example** (Creating an aggregate error)
|
|
134
|
+
*
|
|
131
135
|
* ```ts
|
|
132
136
|
* import * as OpenApiPatch from "@effect/openapi-generator/OpenApiPatch"
|
|
133
137
|
*
|
|
@@ -154,8 +158,8 @@ declare const JsonPatchAggregateError_base: Schema.Class<JsonPatchAggregateError
|
|
|
154
158
|
* // "2 patch operations failed:\n 1. ..."
|
|
155
159
|
* ```
|
|
156
160
|
*
|
|
157
|
-
* @since 1.0.0
|
|
158
161
|
* @category errors
|
|
162
|
+
* @since 4.0.0
|
|
159
163
|
*/
|
|
160
164
|
export declare class JsonPatchAggregateError extends JsonPatchAggregateError_base {
|
|
161
165
|
get message(): string;
|
|
@@ -163,8 +167,8 @@ export declare class JsonPatchAggregateError extends JsonPatchAggregateError_bas
|
|
|
163
167
|
/**
|
|
164
168
|
* Schema for a JSON Patch "add" operation.
|
|
165
169
|
*
|
|
166
|
-
* @since 1.0.0
|
|
167
170
|
* @category schemas
|
|
171
|
+
* @since 4.0.0
|
|
168
172
|
*/
|
|
169
173
|
export declare const JsonPatchAdd: Schema.Codec<Extract<JsonPatch.JsonPatchOperation, {
|
|
170
174
|
op: "add";
|
|
@@ -172,8 +176,8 @@ export declare const JsonPatchAdd: Schema.Codec<Extract<JsonPatch.JsonPatchOpera
|
|
|
172
176
|
/**
|
|
173
177
|
* Schema for a JSON Patch "remove" operation.
|
|
174
178
|
*
|
|
175
|
-
* @since 1.0.0
|
|
176
179
|
* @category schemas
|
|
180
|
+
* @since 4.0.0
|
|
177
181
|
*/
|
|
178
182
|
export declare const JsonPatchRemove: Schema.Codec<Extract<JsonPatch.JsonPatchOperation, {
|
|
179
183
|
op: "remove";
|
|
@@ -181,8 +185,8 @@ export declare const JsonPatchRemove: Schema.Codec<Extract<JsonPatch.JsonPatchOp
|
|
|
181
185
|
/**
|
|
182
186
|
* Schema for a JSON Patch "replace" operation.
|
|
183
187
|
*
|
|
184
|
-
* @since 1.0.0
|
|
185
188
|
* @category schemas
|
|
189
|
+
* @since 4.0.0
|
|
186
190
|
*/
|
|
187
191
|
export declare const JsonPatchReplace: Schema.Codec<Extract<JsonPatch.JsonPatchOperation, {
|
|
188
192
|
op: "replace";
|
|
@@ -193,8 +197,8 @@ export declare const JsonPatchReplace: Schema.Codec<Extract<JsonPatch.JsonPatchO
|
|
|
193
197
|
* Supports the subset of RFC 6902 operations that Effect's JsonPatch module
|
|
194
198
|
* implements: `add`, `remove`, and `replace`.
|
|
195
199
|
*
|
|
196
|
-
* @since 1.0.0
|
|
197
200
|
* @category schemas
|
|
201
|
+
* @since 4.0.0
|
|
198
202
|
*/
|
|
199
203
|
export declare const JsonPatchOperation: Schema.Codec<JsonPatch.JsonPatchOperation>;
|
|
200
204
|
/**
|
|
@@ -204,7 +208,8 @@ export declare const JsonPatchOperation: Schema.Codec<JsonPatch.JsonPatchOperati
|
|
|
204
208
|
* document. Operations are applied in sequence, with each operation seeing
|
|
205
209
|
* the result of previous operations.
|
|
206
210
|
*
|
|
207
|
-
*
|
|
211
|
+
* **Example** (Decoding a patch document)
|
|
212
|
+
*
|
|
208
213
|
* ```ts
|
|
209
214
|
* import { Schema } from "effect"
|
|
210
215
|
* import * as OpenApiPatch from "@effect/openapi-generator/OpenApiPatch"
|
|
@@ -216,15 +221,15 @@ export declare const JsonPatchOperation: Schema.Codec<JsonPatch.JsonPatchOperati
|
|
|
216
221
|
* ])
|
|
217
222
|
* ```
|
|
218
223
|
*
|
|
219
|
-
* @since 1.0.0
|
|
220
224
|
* @category schemas
|
|
225
|
+
* @since 4.0.0
|
|
221
226
|
*/
|
|
222
227
|
export declare const JsonPatchDocument: Schema.$Array<Schema.Codec<JsonPatch.JsonPatchOperation, JsonPatch.JsonPatchOperation, never, never>>;
|
|
223
228
|
/**
|
|
224
229
|
* Type for a JSON Patch document.
|
|
225
230
|
*
|
|
226
|
-
* @since 1.0.0
|
|
227
231
|
* @category types
|
|
232
|
+
* @since 4.0.0
|
|
228
233
|
*/
|
|
229
234
|
export type JsonPatchDocument = typeof JsonPatchDocument.Type;
|
|
230
235
|
/**
|
|
@@ -234,7 +239,8 @@ export type JsonPatchDocument = typeof JsonPatchDocument.Type;
|
|
|
234
239
|
* and parsed based on its extension (.json, .yaml, .yml). Otherwise, the
|
|
235
240
|
* input is parsed as inline JSON.
|
|
236
241
|
*
|
|
237
|
-
*
|
|
242
|
+
* **Example** (Parsing patch input)
|
|
243
|
+
*
|
|
238
244
|
* ```ts
|
|
239
245
|
* import { Effect } from "effect"
|
|
240
246
|
* import * as OpenApiPatch from "@effect/openapi-generator/OpenApiPatch"
|
|
@@ -254,8 +260,8 @@ export type JsonPatchDocument = typeof JsonPatchDocument.Type;
|
|
|
254
260
|
* })
|
|
255
261
|
* ```
|
|
256
262
|
*
|
|
257
|
-
* @since 1.0.0
|
|
258
263
|
* @category parsing
|
|
264
|
+
* @since 4.0.0
|
|
259
265
|
*/
|
|
260
266
|
export declare const parsePatchInput: (input: string) => Effect.Effect<readonly JsonPatch.JsonPatchOperation[], JsonPatchParseError | JsonPatchValidationError, Path.Path | FileSystem.FileSystem>;
|
|
261
267
|
/**
|
|
@@ -265,7 +271,8 @@ export declare const parsePatchInput: (input: string) => Effect.Effect<readonly
|
|
|
265
271
|
* the previous one. All operations are attempted, and if any fail, the errors
|
|
266
272
|
* are accumulated and reported together so users can fix all issues at once.
|
|
267
273
|
*
|
|
268
|
-
*
|
|
274
|
+
* **Example** (Applying patches)
|
|
275
|
+
*
|
|
269
276
|
* ```ts
|
|
270
277
|
* import { Effect } from "effect"
|
|
271
278
|
* import * as OpenApiPatch from "@effect/openapi-generator/OpenApiPatch"
|
|
@@ -285,8 +292,8 @@ export declare const parsePatchInput: (input: string) => Effect.Effect<readonly
|
|
|
285
292
|
* })
|
|
286
293
|
* ```
|
|
287
294
|
*
|
|
288
|
-
* @since 1.0.0
|
|
289
295
|
* @category application
|
|
296
|
+
* @since 4.0.0
|
|
290
297
|
*/
|
|
291
298
|
export declare const applyPatches: (patches: readonly {
|
|
292
299
|
readonly source: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenApiPatch.d.ts","sourceRoot":"","sources":["../src/OpenApiPatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,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5B;IAAE,EAAE,EAAE,QAAQ,CAAA;CAAE,CACjB,CAKD,CAAA;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,KAAK,CACzC,OAAO,CACL,SAAS,CAAC,kBAAkB,EAC5B;IAAE,EAAE,EAAE,SAAS,CAAA;CAAE,CAClB,CAMD,CAAA;AAEF;;;;;;;;GAQG;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
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* - YAML files (.yaml, .yml)
|
|
8
8
|
* - Inline JSON strings
|
|
9
9
|
*
|
|
10
|
-
* @
|
|
10
|
+
* @since 4.0.0
|
|
11
11
|
*/
|
|
12
12
|
import * as Effect from "effect/Effect";
|
|
13
13
|
import * as FileSystem from "effect/FileSystem";
|
|
@@ -28,7 +28,8 @@ import * as Yaml from "yaml";
|
|
|
28
28
|
* - JSON or YAML syntax is invalid
|
|
29
29
|
* - The file format is unsupported
|
|
30
30
|
*
|
|
31
|
-
*
|
|
31
|
+
* **Example** (Creating a parse error)
|
|
32
|
+
*
|
|
32
33
|
* ```ts
|
|
33
34
|
* import * as OpenApiPatch from "@effect/openapi-generator/OpenApiPatch"
|
|
34
35
|
*
|
|
@@ -41,8 +42,8 @@ import * as Yaml from "yaml";
|
|
|
41
42
|
* // "Failed to parse patch from ./patches/fix.json: Unexpected token at position 42"
|
|
42
43
|
* ```
|
|
43
44
|
*
|
|
44
|
-
* @since 1.0.0
|
|
45
45
|
* @category errors
|
|
46
|
+
* @since 4.0.0
|
|
46
47
|
*/
|
|
47
48
|
export class JsonPatchParseError extends /*#__PURE__*/Schema.ErrorClass("JsonPatchParseError")({
|
|
48
49
|
_tag: /*#__PURE__*/Schema.tag("JsonPatchParseError"),
|
|
@@ -62,7 +63,8 @@ export class JsonPatchParseError extends /*#__PURE__*/Schema.ErrorClass("JsonPat
|
|
|
62
63
|
* - An operation has an unsupported op value
|
|
63
64
|
* - An add/replace operation is missing the value field
|
|
64
65
|
*
|
|
65
|
-
*
|
|
66
|
+
* **Example** (Creating a validation error)
|
|
67
|
+
*
|
|
66
68
|
* ```ts
|
|
67
69
|
* import * as OpenApiPatch from "@effect/openapi-generator/OpenApiPatch"
|
|
68
70
|
*
|
|
@@ -75,8 +77,8 @@ export class JsonPatchParseError extends /*#__PURE__*/Schema.ErrorClass("JsonPat
|
|
|
75
77
|
* // "Invalid JSON Patch from inline: Expected 'add' | 'remove' | 'replace' at [0].op, got 'copy'"
|
|
76
78
|
* ```
|
|
77
79
|
*
|
|
78
|
-
* @since 1.0.0
|
|
79
80
|
* @category errors
|
|
81
|
+
* @since 4.0.0
|
|
80
82
|
*/
|
|
81
83
|
export class JsonPatchValidationError extends /*#__PURE__*/Schema.ErrorClass("JsonPatchValidationError")({
|
|
82
84
|
_tag: /*#__PURE__*/Schema.tag("JsonPatchValidationError"),
|
|
@@ -95,7 +97,8 @@ export class JsonPatchValidationError extends /*#__PURE__*/Schema.ErrorClass("Js
|
|
|
95
97
|
* - An array index is out of bounds
|
|
96
98
|
* - The target location is not a valid container
|
|
97
99
|
*
|
|
98
|
-
*
|
|
100
|
+
* **Example** (Creating an application error)
|
|
101
|
+
*
|
|
99
102
|
* ```ts
|
|
100
103
|
* import * as OpenApiPatch from "@effect/openapi-generator/OpenApiPatch"
|
|
101
104
|
*
|
|
@@ -111,8 +114,8 @@ export class JsonPatchValidationError extends /*#__PURE__*/Schema.ErrorClass("Js
|
|
|
111
114
|
* // "Failed to apply patch from ./patches/fix.json: operation 2 (remove at /paths/~1users): Property \"users\" does not exist"
|
|
112
115
|
* ```
|
|
113
116
|
*
|
|
114
|
-
* @since 1.0.0
|
|
115
117
|
* @category errors
|
|
118
|
+
* @since 4.0.0
|
|
116
119
|
*/
|
|
117
120
|
export class JsonPatchApplicationError extends /*#__PURE__*/Schema.ErrorClass("JsonPatchApplicationError")({
|
|
118
121
|
_tag: /*#__PURE__*/Schema.tag("JsonPatchApplicationError"),
|
|
@@ -132,7 +135,8 @@ export class JsonPatchApplicationError extends /*#__PURE__*/Schema.ErrorClass("J
|
|
|
132
135
|
* This error aggregates all application errors so users can see every
|
|
133
136
|
* failing operation at once instead of fixing them one at a time.
|
|
134
137
|
*
|
|
135
|
-
*
|
|
138
|
+
* **Example** (Creating an aggregate error)
|
|
139
|
+
*
|
|
136
140
|
* ```ts
|
|
137
141
|
* import * as OpenApiPatch from "@effect/openapi-generator/OpenApiPatch"
|
|
138
142
|
*
|
|
@@ -159,8 +163,8 @@ export class JsonPatchApplicationError extends /*#__PURE__*/Schema.ErrorClass("J
|
|
|
159
163
|
* // "2 patch operations failed:\n 1. ..."
|
|
160
164
|
* ```
|
|
161
165
|
*
|
|
162
|
-
* @since 1.0.0
|
|
163
166
|
* @category errors
|
|
167
|
+
* @since 4.0.0
|
|
164
168
|
*/
|
|
165
169
|
export class JsonPatchAggregateError extends /*#__PURE__*/Schema.ErrorClass("JsonPatchAggregateError")({
|
|
166
170
|
_tag: /*#__PURE__*/Schema.tag("JsonPatchAggregateError"),
|
|
@@ -180,8 +184,8 @@ export class JsonPatchAggregateError extends /*#__PURE__*/Schema.ErrorClass("Jso
|
|
|
180
184
|
/**
|
|
181
185
|
* Schema for a JSON Patch "add" operation.
|
|
182
186
|
*
|
|
183
|
-
* @since 1.0.0
|
|
184
187
|
* @category schemas
|
|
188
|
+
* @since 4.0.0
|
|
185
189
|
*/
|
|
186
190
|
export const JsonPatchAdd = /*#__PURE__*/Schema.Struct({
|
|
187
191
|
op: /*#__PURE__*/Schema.Literal("add"),
|
|
@@ -192,8 +196,8 @@ export const JsonPatchAdd = /*#__PURE__*/Schema.Struct({
|
|
|
192
196
|
/**
|
|
193
197
|
* Schema for a JSON Patch "remove" operation.
|
|
194
198
|
*
|
|
195
|
-
* @since 1.0.0
|
|
196
199
|
* @category schemas
|
|
200
|
+
* @since 4.0.0
|
|
197
201
|
*/
|
|
198
202
|
export const JsonPatchRemove = /*#__PURE__*/Schema.Struct({
|
|
199
203
|
op: /*#__PURE__*/Schema.Literal("remove"),
|
|
@@ -203,8 +207,8 @@ export const JsonPatchRemove = /*#__PURE__*/Schema.Struct({
|
|
|
203
207
|
/**
|
|
204
208
|
* Schema for a JSON Patch "replace" operation.
|
|
205
209
|
*
|
|
206
|
-
* @since 1.0.0
|
|
207
210
|
* @category schemas
|
|
211
|
+
* @since 4.0.0
|
|
208
212
|
*/
|
|
209
213
|
export const JsonPatchReplace = /*#__PURE__*/Schema.Struct({
|
|
210
214
|
op: /*#__PURE__*/Schema.Literal("replace"),
|
|
@@ -218,8 +222,8 @@ export const JsonPatchReplace = /*#__PURE__*/Schema.Struct({
|
|
|
218
222
|
* Supports the subset of RFC 6902 operations that Effect's JsonPatch module
|
|
219
223
|
* implements: `add`, `remove`, and `replace`.
|
|
220
224
|
*
|
|
221
|
-
* @since 1.0.0
|
|
222
225
|
* @category schemas
|
|
226
|
+
* @since 4.0.0
|
|
223
227
|
*/
|
|
224
228
|
export const JsonPatchOperation = /*#__PURE__*/Schema.Union([JsonPatchAdd, JsonPatchRemove, JsonPatchReplace]);
|
|
225
229
|
/**
|
|
@@ -229,7 +233,8 @@ export const JsonPatchOperation = /*#__PURE__*/Schema.Union([JsonPatchAdd, JsonP
|
|
|
229
233
|
* document. Operations are applied in sequence, with each operation seeing
|
|
230
234
|
* the result of previous operations.
|
|
231
235
|
*
|
|
232
|
-
*
|
|
236
|
+
* **Example** (Decoding a patch document)
|
|
237
|
+
*
|
|
233
238
|
* ```ts
|
|
234
239
|
* import { Schema } from "effect"
|
|
235
240
|
* import * as OpenApiPatch from "@effect/openapi-generator/OpenApiPatch"
|
|
@@ -241,8 +246,8 @@ export const JsonPatchOperation = /*#__PURE__*/Schema.Union([JsonPatchAdd, JsonP
|
|
|
241
246
|
* ])
|
|
242
247
|
* ```
|
|
243
248
|
*
|
|
244
|
-
* @since 1.0.0
|
|
245
249
|
* @category schemas
|
|
250
|
+
* @since 4.0.0
|
|
246
251
|
*/
|
|
247
252
|
export const JsonPatchDocument = /*#__PURE__*/Schema.Array(JsonPatchOperation);
|
|
248
253
|
// =============================================================================
|
|
@@ -350,7 +355,8 @@ const parseInlinePatch = /*#__PURE__*/Effect.fn("parseInlinePatch")(function* (i
|
|
|
350
355
|
* and parsed based on its extension (.json, .yaml, .yml). Otherwise, the
|
|
351
356
|
* input is parsed as inline JSON.
|
|
352
357
|
*
|
|
353
|
-
*
|
|
358
|
+
* **Example** (Parsing patch input)
|
|
359
|
+
*
|
|
354
360
|
* ```ts
|
|
355
361
|
* import { Effect } from "effect"
|
|
356
362
|
* import * as OpenApiPatch from "@effect/openapi-generator/OpenApiPatch"
|
|
@@ -370,8 +376,8 @@ const parseInlinePatch = /*#__PURE__*/Effect.fn("parseInlinePatch")(function* (i
|
|
|
370
376
|
* })
|
|
371
377
|
* ```
|
|
372
378
|
*
|
|
373
|
-
* @since 1.0.0
|
|
374
379
|
* @category parsing
|
|
380
|
+
* @since 4.0.0
|
|
375
381
|
*/
|
|
376
382
|
export const parsePatchInput = /*#__PURE__*/Effect.fn("parsePatchInput")(function* (input) {
|
|
377
383
|
if (looksLikeFilePath(input)) {
|
|
@@ -392,7 +398,8 @@ export const parsePatchInput = /*#__PURE__*/Effect.fn("parsePatchInput")(functio
|
|
|
392
398
|
* the previous one. All operations are attempted, and if any fail, the errors
|
|
393
399
|
* are accumulated and reported together so users can fix all issues at once.
|
|
394
400
|
*
|
|
395
|
-
*
|
|
401
|
+
* **Example** (Applying patches)
|
|
402
|
+
*
|
|
396
403
|
* ```ts
|
|
397
404
|
* import { Effect } from "effect"
|
|
398
405
|
* import * as OpenApiPatch from "@effect/openapi-generator/OpenApiPatch"
|
|
@@ -412,8 +419,8 @@ export const parsePatchInput = /*#__PURE__*/Effect.fn("parsePatchInput")(functio
|
|
|
412
419
|
* })
|
|
413
420
|
* ```
|
|
414
421
|
*
|
|
415
|
-
* @since 1.0.0
|
|
416
422
|
* @category application
|
|
423
|
+
* @since 4.0.0
|
|
417
424
|
*/
|
|
418
425
|
export const applyPatches = /*#__PURE__*/Effect.fn("applyPatches")(function* (patches, document) {
|
|
419
426
|
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;;;;;;;;;;;AAYA,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
|
|
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;;;;;;;;;;;AAYA,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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AAC/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,MAAM,cAAc,CAAA;AAErC,OAAO,KAAK,EAAE,aAAa,EAAmB,MAAM,sBAAsB,CAAA;;
|
|
1
|
+
{"version":3,"file":"OpenApiTransformer.d.ts","sourceRoot":"","sources":["../src/OpenApiTransformer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,KAAK,EAAE,aAAa,EAAmB,MAAM,sBAAsB,CAAA;;sBAiBpD,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,KAAK,MAAM;sBACrD,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,KAAK,MAAM;+BAC1D,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,KAAK,MAAM;;AAhBlG;;;;;;;;;;GAUG;AACH,qBAAa,kBAAmB,SAAQ,uBAOf;CAAG;AAwB5B;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB;sBAtCZ,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,KAAK,MAAM;sBACrD,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,KAAK,MAAM;+BAC1D,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,KAAK,MAAM;CAgajG,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,+CAGlC,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB;sBA7bR,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,KAAK,MAAM;sBACrD,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,KAAK,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(
|