@trayio/tray-openapi 5.33.0 → 5.35.0-unstable.fd7158a

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 (41) hide show
  1. package/dist/OpenApiCodecs.d.ts +207 -4
  2. package/dist/OpenApiCodecs.d.ts.map +1 -1
  3. package/dist/OpenApiCodecs.js +3 -3
  4. package/dist/OpenApiSchemaImporter.d.ts +2 -2
  5. package/dist/OpenApiSchemaImporter.d.ts.map +1 -1
  6. package/dist/OpenApiSchemaImporter.js +33 -55
  7. package/dist/OpenApiSchemaImporter.unit.test.js +24 -13
  8. package/dist/OpenApiSchemaTransformer.d.ts +2 -2
  9. package/dist/OpenApiSchemaTransformer.d.ts.map +1 -1
  10. package/dist/OpenApiSchemaTransformer.js +2 -25
  11. package/dist/OpenApiSchemaTransformer.unit.test.js +30 -44
  12. package/dist/OpenApiTypeDescriptors.d.ts +389 -32
  13. package/dist/OpenApiTypeDescriptors.d.ts.map +1 -1
  14. package/dist/OpenApiTypeDescriptors.js +80 -109
  15. package/dist/file-generators/GenerateHandler.d.ts +2 -2
  16. package/dist/file-generators/GenerateHandler.d.ts.map +1 -1
  17. package/dist/file-generators/GenerateHandler.js +75 -78
  18. package/dist/file-generators/GenerateHandler.unit.test.js +73 -97
  19. package/dist/file-generators/GenerateHandlerTest.d.ts +2 -2
  20. package/dist/file-generators/GenerateHandlerTest.d.ts.map +1 -1
  21. package/dist/file-generators/GenerateHandlerTest.js +69 -76
  22. package/dist/file-generators/GenerateHandlerTest.unit.test.js +206 -230
  23. package/dist/file-generators/GenerateOperationJson.d.ts +2 -2
  24. package/dist/file-generators/GenerateOperationJson.d.ts.map +1 -1
  25. package/dist/file-generators/GenerateOperationJson.js +4 -29
  26. package/dist/file-generators/GenerateOperationJson.unit.test.js +25 -49
  27. package/dist/file-generators/SchemaGenerator.d.ts.map +1 -1
  28. package/dist/file-generators/SchemaGenerator.js +14 -37
  29. package/dist/file-generators/types/GenerateInputSchema.d.ts +2 -2
  30. package/dist/file-generators/types/GenerateInputSchema.d.ts.map +1 -1
  31. package/dist/file-generators/types/GenerateInputSchema.js +88 -95
  32. package/dist/file-generators/types/GenerateInputSchema.test.js +60 -91
  33. package/dist/file-generators/types/GenerateInputType.test.js +143 -169
  34. package/dist/file-generators/types/GenerateInputTypes.d.ts +2 -2
  35. package/dist/file-generators/types/GenerateInputTypes.d.ts.map +1 -1
  36. package/dist/file-generators/types/GenerateInputTypes.js +7 -28
  37. package/dist/file-generators/types/GenerateOutput.d.ts +4 -6
  38. package/dist/file-generators/types/GenerateOutput.d.ts.map +1 -1
  39. package/dist/file-generators/types/GenerateOutput.js +46 -57
  40. package/dist/file-generators/types/GenerateOutput.test.js +35 -62
  41. package/package.json +6 -8
@@ -1,31 +1,6 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
- const E = __importStar(require("fp-ts/Either"));
27
- const TE = __importStar(require("fp-ts/TaskEither"));
28
- const O = __importStar(require("fp-ts/Option"));
3
+ const effect_1 = require("effect");
29
4
  const GenerateInputSchema_1 = require("./GenerateInputSchema");
30
5
  const GenerateInputTypes_1 = require("./GenerateInputTypes");
31
6
  const SchemaGenerator_1 = require("../SchemaGenerator");
@@ -33,175 +8,178 @@ describe('GenerateInputType', () => {
33
8
  it('it should generate a schema from an endpoint with body parameters', async () => {
34
9
  const endpoint = {
35
10
  operationId: 'createPost',
36
- description: O.some('Create a new post'),
37
- summary: O.none,
38
- tags: O.some([]),
39
- parameters: O.none,
40
- requestBody: O.some({
11
+ description: effect_1.Option.some('Create a new post'),
12
+ summary: effect_1.Option.none(),
13
+ tags: effect_1.Option.some([]),
14
+ parameters: effect_1.Option.none(),
15
+ requestBody: effect_1.Option.some({
41
16
  content: {
42
17
  'application/json': {
43
- schema: O.some((0, SchemaGenerator_1.generateNonArraySchemaObject)({
44
- type: O.some('object'),
45
- required: O.some(['id', 'userId', 'title', 'body']),
46
- properties: O.some({
18
+ schema: effect_1.Option.some((0, SchemaGenerator_1.generateNonArraySchemaObject)({
19
+ type: effect_1.Option.some('object'),
20
+ required: effect_1.Option.some(['id', 'userId', 'title', 'body']),
21
+ properties: effect_1.Option.some({
47
22
  id: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
48
- type: O.some('integer'),
49
- additionalProperties: O.some(false),
23
+ type: effect_1.Option.some('integer'),
24
+ additionalProperties: effect_1.Option.some(false),
50
25
  }),
51
26
  userId: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
52
- type: O.some('integer'),
53
- additionalProperties: O.some(false),
27
+ type: effect_1.Option.some('integer'),
28
+ additionalProperties: effect_1.Option.some(false),
54
29
  }),
55
30
  title: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
56
- title: O.none,
57
- type: O.some('string'),
58
- additionalProperties: O.some(false),
31
+ title: effect_1.Option.none(),
32
+ type: effect_1.Option.some('string'),
33
+ additionalProperties: effect_1.Option.some(false),
59
34
  }),
60
35
  body: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
61
- type: O.some('string'),
62
- additionalProperties: O.some(false),
36
+ type: effect_1.Option.some('string'),
37
+ additionalProperties: effect_1.Option.some(false),
63
38
  }),
64
39
  }),
65
- additionalProperties: O.some(false),
40
+ additionalProperties: effect_1.Option.some(false),
66
41
  })),
67
42
  },
68
43
  },
69
44
  }),
70
- responses: O.none,
45
+ responses: effect_1.Option.none(),
71
46
  };
72
- const inputSchema = E.getOrElse(() => {
47
+ const inputSchema = effect_1.Either.getOrElse(() => {
73
48
  throw new Error('Should have been right');
74
49
  })((0, GenerateInputSchema_1.generateInputSchema)(endpoint));
75
50
  const expectedInputSchema = {
76
- title: O.none,
77
- type: O.some('object'),
78
- required: O.some(['id', 'userId', 'title', 'body']),
79
- properties: O.some({
51
+ title: effect_1.Option.none(),
52
+ type: effect_1.Option.some('object'),
53
+ required: effect_1.Option.some(['id', 'userId', 'title', 'body']),
54
+ properties: effect_1.Option.some({
80
55
  id: {
81
- title: O.none,
82
- type: O.some('integer'),
83
- properties: O.none,
84
- additionalProperties: O.some(false),
85
- required: O.none,
86
- allOf: O.none,
87
- anyOf: O.none,
88
- oneOf: O.none,
89
- not: O.none,
90
- in: O.some('body'),
91
- default: O.none,
92
- nullable: O.none,
56
+ title: effect_1.Option.none(),
57
+ type: effect_1.Option.some('integer'),
58
+ properties: effect_1.Option.none(),
59
+ additionalProperties: effect_1.Option.some(false),
60
+ required: effect_1.Option.none(),
61
+ allOf: effect_1.Option.none(),
62
+ anyOf: effect_1.Option.none(),
63
+ oneOf: effect_1.Option.none(),
64
+ not: effect_1.Option.none(),
65
+ in: effect_1.Option.some('body'),
66
+ default: effect_1.Option.none(),
67
+ nullable: effect_1.Option.none(),
68
+ enum: effect_1.Option.none(),
93
69
  },
94
70
  userId: {
95
- title: O.none,
96
- type: O.some('integer'),
97
- properties: O.none,
98
- additionalProperties: O.some(false),
99
- required: O.none,
100
- allOf: O.none,
101
- anyOf: O.none,
102
- oneOf: O.none,
103
- not: O.none,
104
- in: O.some('body'),
105
- default: O.none,
106
- nullable: O.none,
71
+ title: effect_1.Option.none(),
72
+ type: effect_1.Option.some('integer'),
73
+ properties: effect_1.Option.none(),
74
+ additionalProperties: effect_1.Option.some(false),
75
+ required: effect_1.Option.none(),
76
+ allOf: effect_1.Option.none(),
77
+ anyOf: effect_1.Option.none(),
78
+ oneOf: effect_1.Option.none(),
79
+ not: effect_1.Option.none(),
80
+ in: effect_1.Option.some('body'),
81
+ default: effect_1.Option.none(),
82
+ nullable: effect_1.Option.none(),
83
+ enum: effect_1.Option.none(),
107
84
  },
108
85
  title: {
109
- title: O.none,
110
- type: O.some('string'),
111
- properties: O.none,
112
- additionalProperties: O.some(false),
113
- required: O.none,
114
- allOf: O.none,
115
- anyOf: O.none,
116
- oneOf: O.none,
117
- not: O.none,
118
- in: O.some('body'),
119
- default: O.none,
120
- nullable: O.none,
86
+ title: effect_1.Option.none(),
87
+ type: effect_1.Option.some('string'),
88
+ properties: effect_1.Option.none(),
89
+ additionalProperties: effect_1.Option.some(false),
90
+ required: effect_1.Option.none(),
91
+ allOf: effect_1.Option.none(),
92
+ anyOf: effect_1.Option.none(),
93
+ oneOf: effect_1.Option.none(),
94
+ not: effect_1.Option.none(),
95
+ in: effect_1.Option.some('body'),
96
+ default: effect_1.Option.none(),
97
+ nullable: effect_1.Option.none(),
98
+ enum: effect_1.Option.none(),
121
99
  },
122
100
  body: {
123
- title: O.none,
124
- type: O.some('string'),
125
- properties: O.none,
126
- additionalProperties: O.some(false),
127
- required: O.none,
128
- allOf: O.none,
129
- anyOf: O.none,
130
- oneOf: O.none,
131
- not: O.none,
132
- in: O.some('body'),
133
- default: O.none,
134
- nullable: O.none,
101
+ title: effect_1.Option.none(),
102
+ type: effect_1.Option.some('string'),
103
+ properties: effect_1.Option.none(),
104
+ additionalProperties: effect_1.Option.some(false),
105
+ required: effect_1.Option.none(),
106
+ allOf: effect_1.Option.none(),
107
+ anyOf: effect_1.Option.none(),
108
+ oneOf: effect_1.Option.none(),
109
+ not: effect_1.Option.none(),
110
+ in: effect_1.Option.some('body'),
111
+ default: effect_1.Option.none(),
112
+ nullable: effect_1.Option.none(),
113
+ enum: effect_1.Option.none(),
135
114
  },
136
115
  }),
137
- additionalProperties: O.some(false),
138
- allOf: O.none,
139
- anyOf: O.none,
140
- oneOf: O.none,
141
- not: O.none,
142
- in: O.none,
143
- default: O.none,
144
- nullable: O.none,
116
+ additionalProperties: effect_1.Option.some(false),
117
+ allOf: effect_1.Option.none(),
118
+ anyOf: effect_1.Option.none(),
119
+ oneOf: effect_1.Option.none(),
120
+ not: effect_1.Option.none(),
121
+ in: effect_1.Option.none(),
122
+ default: effect_1.Option.none(),
123
+ nullable: effect_1.Option.none(),
124
+ enum: effect_1.Option.none(),
145
125
  };
146
126
  expect(inputSchema).toEqual(expectedInputSchema);
147
127
  });
148
128
  it('it should process an endpoint with path, query string and body parameters and generate input.ts file contents', async () => {
149
129
  const endpoint = {
150
130
  operationId: 'getPost',
151
- description: O.some('Get a post by id'),
152
- summary: O.none,
153
- tags: O.some([]),
154
- parameters: O.some([
131
+ description: effect_1.Option.some('Get a post by id'),
132
+ summary: effect_1.Option.none(),
133
+ tags: effect_1.Option.some([]),
134
+ parameters: effect_1.Option.some([
155
135
  {
156
136
  name: 'id',
157
137
  in: 'path',
158
- required: O.some(true),
159
- description: O.some('The user id.'),
138
+ required: effect_1.Option.some(true),
139
+ description: effect_1.Option.some('The user id.'),
160
140
  schema: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
161
- type: O.some('integer'),
141
+ type: effect_1.Option.some('integer'),
162
142
  }),
163
143
  },
164
144
  {
165
145
  name: 'categoryId',
166
146
  in: 'path',
167
- required: O.some(false),
168
- description: O.some('The category id.'),
147
+ required: effect_1.Option.some(false),
148
+ description: effect_1.Option.some('The category id.'),
169
149
  schema: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
170
- title: O.none,
171
- type: O.some('integer'),
150
+ title: effect_1.Option.none(),
151
+ type: effect_1.Option.some('integer'),
172
152
  }),
173
153
  },
174
154
  ]),
175
- requestBody: O.some({
155
+ requestBody: effect_1.Option.some({
176
156
  content: {
177
157
  'application/json': {
178
- schema: O.some((0, SchemaGenerator_1.generateNonArraySchemaObject)({
179
- type: O.some('object'),
180
- required: O.some(['userId', 'body']),
181
- properties: O.some({
158
+ schema: effect_1.Option.some((0, SchemaGenerator_1.generateNonArraySchemaObject)({
159
+ type: effect_1.Option.some('object'),
160
+ required: effect_1.Option.some(['userId', 'body']),
161
+ properties: effect_1.Option.some({
182
162
  userId: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
183
- type: O.some('integer'),
163
+ type: effect_1.Option.some('integer'),
184
164
  }),
185
165
  title: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
186
- type: O.some('string'),
166
+ type: effect_1.Option.some('string'),
187
167
  }),
188
168
  body: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
189
- type: O.some('string'),
169
+ type: effect_1.Option.some('string'),
190
170
  }),
191
171
  }),
192
172
  })),
193
173
  },
194
174
  },
195
175
  }),
196
- responses: O.none,
176
+ responses: effect_1.Option.none(),
197
177
  };
198
- const inputSchema = E.getOrElse(() => {
178
+ const inputSchema = effect_1.Either.getOrElse(() => {
199
179
  throw new Error('Should have been right');
200
180
  })((0, GenerateInputSchema_1.generateInputSchema)(endpoint));
201
181
  const inputTypes = (0, GenerateInputTypes_1.generateInputTypes)(endpoint.operationId, inputSchema);
202
- const generatedInputFile = await TE.getOrElse((error) => {
203
- throw new Error('Should have been right');
204
- })(inputTypes)();
182
+ const generatedInputFile = await effect_1.Effect.runPromise(inputTypes);
205
183
  const expectedInputFile = `export interface GetPostInput {
206
184
  userId: number;
207
185
  title?: string;
@@ -221,20 +199,18 @@ describe('GenerateInputType', () => {
221
199
  it('it should process an endpoint with no parameters and generate empty input.ts file contents', async () => {
222
200
  const endpoint = {
223
201
  operationId: 'getPosts',
224
- description: O.some('Get all posts'),
225
- summary: O.none,
226
- tags: O.some([]),
227
- parameters: O.none,
228
- requestBody: O.none,
229
- responses: O.none,
202
+ description: effect_1.Option.some('Get all posts'),
203
+ summary: effect_1.Option.none(),
204
+ tags: effect_1.Option.some([]),
205
+ parameters: effect_1.Option.none(),
206
+ requestBody: effect_1.Option.none(),
207
+ responses: effect_1.Option.none(),
230
208
  };
231
- const inputSchema = E.getOrElse(() => {
209
+ const inputSchema = effect_1.Either.getOrElse(() => {
232
210
  throw new Error('Should have been right');
233
211
  })((0, GenerateInputSchema_1.generateInputSchema)(endpoint));
234
212
  const inputTypes = (0, GenerateInputTypes_1.generateInputTypes)(endpoint.operationId, inputSchema);
235
- const generatedInputFile = await TE.getOrElse((error) => {
236
- throw new Error('Should have been right');
237
- })(inputTypes)();
213
+ const generatedInputFile = await effect_1.Effect.runPromise(inputTypes);
238
214
  const expectedInputFile = `export interface GetPostsInput {}
239
215
  `;
240
216
  expect(generatedInputFile).toEqual(expectedInputFile);
@@ -242,29 +218,27 @@ describe('GenerateInputType', () => {
242
218
  it('it should process an endpoint with a body schema with no parameters and additionalProperties: true and generate k: string: unknown input.ts file contents', async () => {
243
219
  const endpoint = {
244
220
  operationId: 'getPosts',
245
- description: O.some('Get all posts'),
246
- summary: O.none,
247
- tags: O.some([]),
248
- parameters: O.none,
249
- requestBody: O.some({
221
+ description: effect_1.Option.some('Get all posts'),
222
+ summary: effect_1.Option.none(),
223
+ tags: effect_1.Option.some([]),
224
+ parameters: effect_1.Option.none(),
225
+ requestBody: effect_1.Option.some({
250
226
  content: {
251
227
  'application/json': {
252
- schema: O.some((0, SchemaGenerator_1.generateNonArraySchemaObject)({
253
- type: O.some('object'),
254
- additionalProperties: O.some(true),
228
+ schema: effect_1.Option.some((0, SchemaGenerator_1.generateNonArraySchemaObject)({
229
+ type: effect_1.Option.some('object'),
230
+ additionalProperties: effect_1.Option.some(true),
255
231
  })),
256
232
  },
257
233
  },
258
234
  }),
259
- responses: O.none,
235
+ responses: effect_1.Option.none(),
260
236
  };
261
- const inputSchema = E.getOrElse(() => {
237
+ const inputSchema = effect_1.Either.getOrElse(() => {
262
238
  throw new Error('Should have been right');
263
239
  })((0, GenerateInputSchema_1.generateInputSchema)(endpoint));
264
240
  const inputTypes = (0, GenerateInputTypes_1.generateInputTypes)(endpoint.operationId, inputSchema);
265
- const generatedInputFile = await TE.getOrElse((error) => {
266
- throw new Error('Should have been right');
267
- })(inputTypes)();
241
+ const generatedInputFile = await effect_1.Effect.runPromise(inputTypes);
268
242
  const expectedInputFile = `export interface GetPostsInput {
269
243
  [k: string]: unknown;
270
244
  }
@@ -274,38 +248,38 @@ describe('GenerateInputType', () => {
274
248
  it('it should throw an exception when finding an unsupported media type', async () => {
275
249
  const endpoint = {
276
250
  operationId: 'createPost',
277
- description: O.some('Create a new post'),
278
- summary: O.none,
279
- tags: O.some([]),
280
- parameters: O.none,
281
- requestBody: O.some({
251
+ description: effect_1.Option.some('Create a new post'),
252
+ summary: effect_1.Option.none(),
253
+ tags: effect_1.Option.some([]),
254
+ parameters: effect_1.Option.none(),
255
+ requestBody: effect_1.Option.some({
282
256
  content: {
283
257
  'unsupported-media-type': {
284
- schema: O.some((0, SchemaGenerator_1.generateNonArraySchemaObject)({
285
- type: O.some('object'),
286
- required: O.some(['id', 'userId', 'title', 'body']),
287
- properties: O.some({
258
+ schema: effect_1.Option.some((0, SchemaGenerator_1.generateNonArraySchemaObject)({
259
+ type: effect_1.Option.some('object'),
260
+ required: effect_1.Option.some(['id', 'userId', 'title', 'body']),
261
+ properties: effect_1.Option.some({
288
262
  id: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
289
- type: O.some('integer'),
263
+ type: effect_1.Option.some('integer'),
290
264
  }),
291
265
  userId: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
292
- type: O.some('integer'),
266
+ type: effect_1.Option.some('integer'),
293
267
  }),
294
268
  title: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
295
- type: O.some('string'),
269
+ type: effect_1.Option.some('string'),
296
270
  }),
297
271
  body: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
298
- type: O.some('string'),
272
+ type: effect_1.Option.some('string'),
299
273
  }),
300
274
  }),
301
275
  })),
302
276
  },
303
277
  },
304
278
  }),
305
- responses: O.none,
279
+ responses: effect_1.Option.none(),
306
280
  };
307
281
  const inputSchema = (0, GenerateInputSchema_1.generateInputSchema)(endpoint);
308
- if (E.isRight(inputSchema)) {
282
+ if (effect_1.Either.isRight(inputSchema)) {
309
283
  throw new Error('Should have been left');
310
284
  }
311
285
  expect(inputSchema.left.message).toEqual('Unsupported media type: unsupported-media-type');
@@ -1,4 +1,4 @@
1
- import * as TE from 'fp-ts/TaskEither';
1
+ import { Effect } from 'effect';
2
2
  import { SchemaObject } from '../../OpenApiTypeDescriptors';
3
- export declare const generateInputTypes: (operationNameCamelCase: string, parameters: SchemaObject) => TE.TaskEither<Error, string>;
3
+ export declare const generateInputTypes: (operationNameCamelCase: string, parameters: SchemaObject) => Effect.Effect<string, Error>;
4
4
  //# sourceMappingURL=GenerateInputTypes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GenerateInputTypes.d.ts","sourceRoot":"","sources":["../../../src/file-generators/types/GenerateInputTypes.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAKvC,OAAO,EACN,YAAY,EAEZ,MAAM,8BAA8B,CAAC;AAWtC,eAAO,MAAM,kBAAkB,2BACN,MAAM,cAClB,YAAY,KACtB,GAAG,UAAU,CAAC,KAAK,EAAE,MAAM,CAc7B,CAAC"}
1
+ {"version":3,"file":"GenerateInputTypes.d.ts","sourceRoot":"","sources":["../../../src/file-generators/types/GenerateInputTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AAMxC,OAAO,EACN,YAAY,EAEZ,MAAM,8BAA8B,CAAC;AAWtC,eAAO,MAAM,kBAAkB,GAC9B,wBAAwB,MAAM,EAC9B,YAAY,YAAY,KACtB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAc7B,CAAC"}
@@ -1,32 +1,8 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  exports.generateInputTypes = void 0;
4
+ const effect_1 = require("effect");
27
5
  const json_schema_to_typescript_1 = require("json-schema-to-typescript");
28
- const TE = __importStar(require("fp-ts/TaskEither"));
29
- const O = __importStar(require("fp-ts/Option"));
30
6
  const CompositeCodec_1 = require("@trayio/commons/codec/CompositeCodec");
31
7
  const RemoveNullValuesCodec_1 = require("@trayio/commons/codec/RemoveNullValuesCodec");
32
8
  const JsonSchemaToTypescriptOptions_1 = require("./JsonSchemaToTypescriptOptions");
@@ -36,10 +12,13 @@ const encodeInputSchema = (inputSchema) => {
36
12
  return codecWithNullValueRemoval.encode(inputSchema);
37
13
  };
38
14
  const generateInputTypes = (operationNameCamelCase, parameters) => {
39
- if (O.isSome(parameters.title)) {
40
- parameters.title = O.none;
15
+ if (effect_1.Option.isSome(parameters.title)) {
16
+ parameters.title = effect_1.Option.none();
41
17
  }
42
18
  const resolvedInputSchema = encodeInputSchema(parameters);
43
- return TE.tryCatch(() => (0, json_schema_to_typescript_1.compile)(resolvedInputSchema, `${operationNameCamelCase}Input`, JsonSchemaToTypescriptOptions_1.JsonSchemaToTypescriptOptions), (reason) => new Error(`${reason}`));
19
+ return effect_1.Effect.tryPromise({
20
+ try: () => (0, json_schema_to_typescript_1.compile)(resolvedInputSchema, `${operationNameCamelCase}Input`, JsonSchemaToTypescriptOptions_1.JsonSchemaToTypescriptOptions),
21
+ catch: (reason) => new Error(`${reason}`),
22
+ });
44
23
  };
45
24
  exports.generateInputTypes = generateInputTypes;
@@ -1,8 +1,6 @@
1
- import * as TE from 'fp-ts/TaskEither';
2
- import * as E from 'fp-ts/Either';
3
- import * as O from 'fp-ts/Option';
1
+ import { Effect, Either, Option } from 'effect';
4
2
  import { Responses, MediaTypeObject, SchemaObject } from '../../OpenApiTypeDescriptors';
5
- export declare const getApplicationJsonMediaType: (content: Record<string, MediaTypeObject>) => E.Either<Error, MediaTypeObject>;
6
- export declare const generateOutputSchema: (responses: O.Option<Responses>) => TE.TaskEither<Error, SchemaObject>;
7
- export declare const generateOutputTypes: (operationNameCamelCase: string, outputSchema: SchemaObject) => TE.TaskEither<Error, string>;
3
+ export declare const getApplicationJsonMediaType: (content: Record<string, MediaTypeObject>) => Either.Either<MediaTypeObject, Error>;
4
+ export declare const generateOutputSchema: (responses: Option.Option<Responses>) => Effect.Effect<SchemaObject, Error>;
5
+ export declare const generateOutputTypes: (operationNameCamelCase: string, outputSchema: SchemaObject) => Effect.Effect<string, Error>;
8
6
  //# sourceMappingURL=GenerateOutput.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GenerateOutput.d.ts","sourceRoot":"","sources":["../../../src/file-generators/types/GenerateOutput.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAKlC,OAAO,EACN,SAAS,EAET,eAAe,EACf,YAAY,EAEZ,MAAM,8BAA8B,CAAC;AA2CtC,eAAO,MAAM,2BAA2B,YAC9B,OAAO,MAAM,EAAE,eAAe,CAAC,KACtC,EAAE,MAAM,CAAC,KAAK,EAAE,eAAe,CAWjC,CAAC;AAEF,eAAO,MAAM,oBAAoB,cACrB,EAAE,MAAM,CAAC,SAAS,CAAC,KAC5B,GAAG,UAAU,CAAC,KAAK,EAAE,YAAY,CAelC,CAAC;AAWH,eAAO,MAAM,mBAAmB,2BACP,MAAM,gBAChB,YAAY,KACxB,GAAG,UAAU,CAAC,KAAK,EAAE,MAAM,CAgB7B,CAAC"}
1
+ {"version":3,"file":"GenerateOutput.d.ts","sourceRoot":"","sources":["../../../src/file-generators/types/GenerateOutput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAQ,MAAM,QAAQ,CAAC;AAMtD,OAAO,EACN,SAAS,EAET,eAAe,EACf,YAAY,EAEZ,MAAM,8BAA8B,CAAC;AA6CtC,eAAO,MAAM,2BAA2B,GACvC,SAAS,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,KACtC,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,KAAK,CAatC,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAChC,WAAW,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,KACjC,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,KAAK,CAelC,CAAC;AAWH,eAAO,MAAM,mBAAmB,GAC/B,wBAAwB,MAAM,EAC9B,cAAc,YAAY,KACxB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAgB7B,CAAC"}