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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/OpenApiCodecs.d.ts +4 -207
  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 +55 -33
  7. package/dist/OpenApiSchemaImporter.unit.test.js +13 -24
  8. package/dist/OpenApiSchemaTransformer.d.ts +2 -2
  9. package/dist/OpenApiSchemaTransformer.d.ts.map +1 -1
  10. package/dist/OpenApiSchemaTransformer.js +25 -2
  11. package/dist/OpenApiSchemaTransformer.unit.test.js +44 -30
  12. package/dist/OpenApiTypeDescriptors.d.ts +32 -389
  13. package/dist/OpenApiTypeDescriptors.d.ts.map +1 -1
  14. package/dist/OpenApiTypeDescriptors.js +109 -80
  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 +78 -75
  18. package/dist/file-generators/GenerateHandler.unit.test.js +97 -73
  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 +76 -69
  22. package/dist/file-generators/GenerateHandlerTest.unit.test.js +230 -206
  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 +29 -4
  26. package/dist/file-generators/GenerateOperationJson.unit.test.js +49 -25
  27. package/dist/file-generators/SchemaGenerator.d.ts.map +1 -1
  28. package/dist/file-generators/SchemaGenerator.js +37 -14
  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 +95 -88
  32. package/dist/file-generators/types/GenerateInputSchema.test.js +91 -60
  33. package/dist/file-generators/types/GenerateInputType.test.js +169 -143
  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 +28 -7
  37. package/dist/file-generators/types/GenerateOutput.d.ts +6 -4
  38. package/dist/file-generators/types/GenerateOutput.d.ts.map +1 -1
  39. package/dist/file-generators/types/GenerateOutput.js +57 -46
  40. package/dist/file-generators/types/GenerateOutput.test.js +62 -35
  41. package/package.json +8 -6
@@ -1,6 +1,31 @@
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
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const effect_1 = require("effect");
26
+ const E = __importStar(require("fp-ts/Either"));
27
+ const TE = __importStar(require("fp-ts/TaskEither"));
28
+ const O = __importStar(require("fp-ts/Option"));
4
29
  const GenerateInputSchema_1 = require("./GenerateInputSchema");
5
30
  const GenerateInputTypes_1 = require("./GenerateInputTypes");
6
31
  const SchemaGenerator_1 = require("../SchemaGenerator");
@@ -8,178 +33,175 @@ describe('GenerateInputType', () => {
8
33
  it('it should generate a schema from an endpoint with body parameters', async () => {
9
34
  const endpoint = {
10
35
  operationId: 'createPost',
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({
36
+ description: O.some('Create a new post'),
37
+ summary: O.none,
38
+ tags: O.some([]),
39
+ parameters: O.none,
40
+ requestBody: O.some({
16
41
  content: {
17
42
  'application/json': {
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({
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({
22
47
  id: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
23
- type: effect_1.Option.some('integer'),
24
- additionalProperties: effect_1.Option.some(false),
48
+ type: O.some('integer'),
49
+ additionalProperties: O.some(false),
25
50
  }),
26
51
  userId: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
27
- type: effect_1.Option.some('integer'),
28
- additionalProperties: effect_1.Option.some(false),
52
+ type: O.some('integer'),
53
+ additionalProperties: O.some(false),
29
54
  }),
30
55
  title: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
31
- title: effect_1.Option.none(),
32
- type: effect_1.Option.some('string'),
33
- additionalProperties: effect_1.Option.some(false),
56
+ title: O.none,
57
+ type: O.some('string'),
58
+ additionalProperties: O.some(false),
34
59
  }),
35
60
  body: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
36
- type: effect_1.Option.some('string'),
37
- additionalProperties: effect_1.Option.some(false),
61
+ type: O.some('string'),
62
+ additionalProperties: O.some(false),
38
63
  }),
39
64
  }),
40
- additionalProperties: effect_1.Option.some(false),
65
+ additionalProperties: O.some(false),
41
66
  })),
42
67
  },
43
68
  },
44
69
  }),
45
- responses: effect_1.Option.none(),
70
+ responses: O.none,
46
71
  };
47
- const inputSchema = effect_1.Either.getOrElse(() => {
72
+ const inputSchema = E.getOrElse(() => {
48
73
  throw new Error('Should have been right');
49
74
  })((0, GenerateInputSchema_1.generateInputSchema)(endpoint));
50
75
  const expectedInputSchema = {
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({
76
+ title: O.none,
77
+ type: O.some('object'),
78
+ required: O.some(['id', 'userId', 'title', 'body']),
79
+ properties: O.some({
55
80
  id: {
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(),
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,
69
93
  },
70
94
  userId: {
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(),
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,
84
107
  },
85
108
  title: {
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(),
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,
99
121
  },
100
122
  body: {
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(),
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,
114
135
  },
115
136
  }),
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(),
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,
125
145
  };
126
146
  expect(inputSchema).toEqual(expectedInputSchema);
127
147
  });
128
148
  it('it should process an endpoint with path, query string and body parameters and generate input.ts file contents', async () => {
129
149
  const endpoint = {
130
150
  operationId: 'getPost',
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([
151
+ description: O.some('Get a post by id'),
152
+ summary: O.none,
153
+ tags: O.some([]),
154
+ parameters: O.some([
135
155
  {
136
156
  name: 'id',
137
157
  in: 'path',
138
- required: effect_1.Option.some(true),
139
- description: effect_1.Option.some('The user id.'),
158
+ required: O.some(true),
159
+ description: O.some('The user id.'),
140
160
  schema: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
141
- type: effect_1.Option.some('integer'),
161
+ type: O.some('integer'),
142
162
  }),
143
163
  },
144
164
  {
145
165
  name: 'categoryId',
146
166
  in: 'path',
147
- required: effect_1.Option.some(false),
148
- description: effect_1.Option.some('The category id.'),
167
+ required: O.some(false),
168
+ description: O.some('The category id.'),
149
169
  schema: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
150
- title: effect_1.Option.none(),
151
- type: effect_1.Option.some('integer'),
170
+ title: O.none,
171
+ type: O.some('integer'),
152
172
  }),
153
173
  },
154
174
  ]),
155
- requestBody: effect_1.Option.some({
175
+ requestBody: O.some({
156
176
  content: {
157
177
  'application/json': {
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({
178
+ schema: O.some((0, SchemaGenerator_1.generateNonArraySchemaObject)({
179
+ type: O.some('object'),
180
+ required: O.some(['userId', 'body']),
181
+ properties: O.some({
162
182
  userId: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
163
- type: effect_1.Option.some('integer'),
183
+ type: O.some('integer'),
164
184
  }),
165
185
  title: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
166
- type: effect_1.Option.some('string'),
186
+ type: O.some('string'),
167
187
  }),
168
188
  body: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
169
- type: effect_1.Option.some('string'),
189
+ type: O.some('string'),
170
190
  }),
171
191
  }),
172
192
  })),
173
193
  },
174
194
  },
175
195
  }),
176
- responses: effect_1.Option.none(),
196
+ responses: O.none,
177
197
  };
178
- const inputSchema = effect_1.Either.getOrElse(() => {
198
+ const inputSchema = E.getOrElse(() => {
179
199
  throw new Error('Should have been right');
180
200
  })((0, GenerateInputSchema_1.generateInputSchema)(endpoint));
181
201
  const inputTypes = (0, GenerateInputTypes_1.generateInputTypes)(endpoint.operationId, inputSchema);
182
- const generatedInputFile = await effect_1.Effect.runPromise(inputTypes);
202
+ const generatedInputFile = await TE.getOrElse((error) => {
203
+ throw new Error('Should have been right');
204
+ })(inputTypes)();
183
205
  const expectedInputFile = `export interface GetPostInput {
184
206
  userId: number;
185
207
  title?: string;
@@ -199,18 +221,20 @@ describe('GenerateInputType', () => {
199
221
  it('it should process an endpoint with no parameters and generate empty input.ts file contents', async () => {
200
222
  const endpoint = {
201
223
  operationId: 'getPosts',
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(),
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,
208
230
  };
209
- const inputSchema = effect_1.Either.getOrElse(() => {
231
+ const inputSchema = E.getOrElse(() => {
210
232
  throw new Error('Should have been right');
211
233
  })((0, GenerateInputSchema_1.generateInputSchema)(endpoint));
212
234
  const inputTypes = (0, GenerateInputTypes_1.generateInputTypes)(endpoint.operationId, inputSchema);
213
- const generatedInputFile = await effect_1.Effect.runPromise(inputTypes);
235
+ const generatedInputFile = await TE.getOrElse((error) => {
236
+ throw new Error('Should have been right');
237
+ })(inputTypes)();
214
238
  const expectedInputFile = `export interface GetPostsInput {}
215
239
  `;
216
240
  expect(generatedInputFile).toEqual(expectedInputFile);
@@ -218,27 +242,29 @@ describe('GenerateInputType', () => {
218
242
  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 () => {
219
243
  const endpoint = {
220
244
  operationId: 'getPosts',
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({
245
+ description: O.some('Get all posts'),
246
+ summary: O.none,
247
+ tags: O.some([]),
248
+ parameters: O.none,
249
+ requestBody: O.some({
226
250
  content: {
227
251
  'application/json': {
228
- schema: effect_1.Option.some((0, SchemaGenerator_1.generateNonArraySchemaObject)({
229
- type: effect_1.Option.some('object'),
230
- additionalProperties: effect_1.Option.some(true),
252
+ schema: O.some((0, SchemaGenerator_1.generateNonArraySchemaObject)({
253
+ type: O.some('object'),
254
+ additionalProperties: O.some(true),
231
255
  })),
232
256
  },
233
257
  },
234
258
  }),
235
- responses: effect_1.Option.none(),
259
+ responses: O.none,
236
260
  };
237
- const inputSchema = effect_1.Either.getOrElse(() => {
261
+ const inputSchema = E.getOrElse(() => {
238
262
  throw new Error('Should have been right');
239
263
  })((0, GenerateInputSchema_1.generateInputSchema)(endpoint));
240
264
  const inputTypes = (0, GenerateInputTypes_1.generateInputTypes)(endpoint.operationId, inputSchema);
241
- const generatedInputFile = await effect_1.Effect.runPromise(inputTypes);
265
+ const generatedInputFile = await TE.getOrElse((error) => {
266
+ throw new Error('Should have been right');
267
+ })(inputTypes)();
242
268
  const expectedInputFile = `export interface GetPostsInput {
243
269
  [k: string]: unknown;
244
270
  }
@@ -248,38 +274,38 @@ describe('GenerateInputType', () => {
248
274
  it('it should throw an exception when finding an unsupported media type', async () => {
249
275
  const endpoint = {
250
276
  operationId: 'createPost',
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({
277
+ description: O.some('Create a new post'),
278
+ summary: O.none,
279
+ tags: O.some([]),
280
+ parameters: O.none,
281
+ requestBody: O.some({
256
282
  content: {
257
283
  'unsupported-media-type': {
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({
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({
262
288
  id: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
263
- type: effect_1.Option.some('integer'),
289
+ type: O.some('integer'),
264
290
  }),
265
291
  userId: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
266
- type: effect_1.Option.some('integer'),
292
+ type: O.some('integer'),
267
293
  }),
268
294
  title: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
269
- type: effect_1.Option.some('string'),
295
+ type: O.some('string'),
270
296
  }),
271
297
  body: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
272
- type: effect_1.Option.some('string'),
298
+ type: O.some('string'),
273
299
  }),
274
300
  }),
275
301
  })),
276
302
  },
277
303
  },
278
304
  }),
279
- responses: effect_1.Option.none(),
305
+ responses: O.none,
280
306
  };
281
307
  const inputSchema = (0, GenerateInputSchema_1.generateInputSchema)(endpoint);
282
- if (effect_1.Either.isRight(inputSchema)) {
308
+ if (E.isRight(inputSchema)) {
283
309
  throw new Error('Should have been left');
284
310
  }
285
311
  expect(inputSchema.left.message).toEqual('Unsupported media type: unsupported-media-type');
@@ -1,4 +1,4 @@
1
- import { Effect } from 'effect';
1
+ import * as TE from 'fp-ts/TaskEither';
2
2
  import { SchemaObject } from '../../OpenApiTypeDescriptors';
3
- export declare const generateInputTypes: (operationNameCamelCase: string, parameters: SchemaObject) => Effect.Effect<string, Error>;
3
+ export declare const generateInputTypes: (operationNameCamelCase: string, parameters: SchemaObject) => TE.TaskEither<Error, string>;
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":"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
+ {"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,8 +1,32 @@
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
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.generateInputTypes = void 0;
4
- const effect_1 = require("effect");
5
27
  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"));
6
30
  const CompositeCodec_1 = require("@trayio/commons/codec/CompositeCodec");
7
31
  const RemoveNullValuesCodec_1 = require("@trayio/commons/codec/RemoveNullValuesCodec");
8
32
  const JsonSchemaToTypescriptOptions_1 = require("./JsonSchemaToTypescriptOptions");
@@ -12,13 +36,10 @@ const encodeInputSchema = (inputSchema) => {
12
36
  return codecWithNullValueRemoval.encode(inputSchema);
13
37
  };
14
38
  const generateInputTypes = (operationNameCamelCase, parameters) => {
15
- if (effect_1.Option.isSome(parameters.title)) {
16
- parameters.title = effect_1.Option.none();
39
+ if (O.isSome(parameters.title)) {
40
+ parameters.title = O.none;
17
41
  }
18
42
  const resolvedInputSchema = encodeInputSchema(parameters);
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
- });
43
+ return TE.tryCatch(() => (0, json_schema_to_typescript_1.compile)(resolvedInputSchema, `${operationNameCamelCase}Input`, JsonSchemaToTypescriptOptions_1.JsonSchemaToTypescriptOptions), (reason) => new Error(`${reason}`));
23
44
  };
24
45
  exports.generateInputTypes = generateInputTypes;
@@ -1,6 +1,8 @@
1
- import { Effect, Either, Option } from 'effect';
1
+ import * as TE from 'fp-ts/TaskEither';
2
+ import * as E from 'fp-ts/Either';
3
+ import * as O from 'fp-ts/Option';
2
4
  import { Responses, MediaTypeObject, SchemaObject } from '../../OpenApiTypeDescriptors';
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>;
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>;
6
8
  //# sourceMappingURL=GenerateOutput.d.ts.map
@@ -1 +1 @@
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"}
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"}