@trayio/tray-openapi 4.18.0 → 4.18.1

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 (29) hide show
  1. package/dist/OpenApiSchemaImporter.unit.test.d.ts +2 -0
  2. package/dist/OpenApiSchemaImporter.unit.test.d.ts.map +1 -0
  3. package/dist/{OpenApiSchemaImporter.test.js → OpenApiSchemaImporter.unit.test.js} +8 -6
  4. package/dist/OpenApiSchemaTransformer.unit.test.d.ts +2 -0
  5. package/dist/OpenApiSchemaTransformer.unit.test.d.ts.map +1 -0
  6. package/dist/file-generators/GenerateHandler.d.ts.map +1 -1
  7. package/dist/file-generators/GenerateHandler.js +7 -5
  8. package/dist/file-generators/GenerateHandler.unit.test.d.ts +2 -0
  9. package/dist/file-generators/GenerateHandler.unit.test.d.ts.map +1 -0
  10. package/dist/file-generators/{GenerateHandler.test.js → GenerateHandler.unit.test.js} +20 -10
  11. package/dist/file-generators/GenerateHandlerTest.unit.test.d.ts +2 -0
  12. package/dist/file-generators/GenerateHandlerTest.unit.test.d.ts.map +1 -0
  13. package/dist/file-generators/GenerateOperationJson.unit.test.d.ts +2 -0
  14. package/dist/file-generators/GenerateOperationJson.unit.test.d.ts.map +1 -0
  15. package/dist/templates/connector-template.zip +0 -0
  16. package/package.json +1 -1
  17. package/dist/OpenApiSchemaImporter.test.d.ts +0 -2
  18. package/dist/OpenApiSchemaImporter.test.d.ts.map +0 -1
  19. package/dist/OpenApiSchemaTransformer.test.d.ts +0 -2
  20. package/dist/OpenApiSchemaTransformer.test.d.ts.map +0 -1
  21. package/dist/file-generators/GenerateHandler.test.d.ts +0 -2
  22. package/dist/file-generators/GenerateHandler.test.d.ts.map +0 -1
  23. package/dist/file-generators/GenerateHandlerTest.test.d.ts +0 -2
  24. package/dist/file-generators/GenerateHandlerTest.test.d.ts.map +0 -1
  25. package/dist/file-generators/GenerateOperationJson.test.d.ts +0 -2
  26. package/dist/file-generators/GenerateOperationJson.test.d.ts.map +0 -1
  27. /package/dist/{OpenApiSchemaTransformer.test.js → OpenApiSchemaTransformer.unit.test.js} +0 -0
  28. /package/dist/file-generators/{GenerateHandlerTest.test.js → GenerateHandlerTest.unit.test.js} +0 -0
  29. /package/dist/file-generators/{GenerateOperationJson.test.js → GenerateOperationJson.unit.test.js} +0 -0
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=OpenApiSchemaImporter.unit.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpenApiSchemaImporter.unit.test.d.ts","sourceRoot":"","sources":["../src/OpenApiSchemaImporter.unit.test.ts"],"names":[],"mappings":""}
@@ -52,25 +52,27 @@ describe('openApiSchemaImporter', () => {
52
52
  console.error(error);
53
53
  throw new Error('Should have been right');
54
54
  })(result);
55
+ console.log(buildConnectorResponse);
56
+ console.log(fileStorage.files);
55
57
  expect(buildConnectorResponse.successes.length).toEqual(1);
56
58
  expect(buildConnectorResponse.errors.length).toEqual(1);
57
59
  });
58
60
  it('should generate a operation handler', () => {
59
- expect(fileStorage.files.has(`/test-connector/src/get-post/handler.ts`)).toEqual(true);
61
+ expect(fileStorage.files.has(`/test-connector/src/get_post/handler.ts`)).toEqual(true);
60
62
  });
61
63
  it('should generate an operation handler test', () => {
62
- expect(fileStorage.files.has(`/test-connector/src/get-post/handler.test.ts`)).toEqual(true);
64
+ expect(fileStorage.files.has(`/test-connector/src/get_post/handler.test.ts`)).toEqual(true);
63
65
  });
64
66
  it('should generate an operation.json', () => {
65
- expect(fileStorage.files.has(`/test-connector/src/get-post/operation.json`)).toEqual(true);
67
+ expect(fileStorage.files.has(`/test-connector/src/get_post/operation.json`)).toEqual(true);
66
68
  });
67
69
  it('should generate an output.ts', () => {
68
- expect(fileStorage.files.has(`/test-connector/src/get-post/output.ts`)).toEqual(true);
70
+ expect(fileStorage.files.has(`/test-connector/src/get_post/output.ts`)).toEqual(true);
69
71
  });
70
72
  it('should generate a operation directory', () => {
71
- expect(fileStorage.files.has(`/test-connector/src/get-post`)).toEqual(true);
73
+ expect(fileStorage.files.has(`/test-connector/src/get_post`)).toEqual(true);
72
74
  });
73
75
  it('should not generate a operation directory when failing to decode', () => {
74
- expect(fileStorage.files.has(`/test-connector/src/update-post`)).toEqual(false);
76
+ expect(fileStorage.files.has(`/test-connector/src/update_post`)).toEqual(false);
75
77
  });
76
78
  });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=OpenApiSchemaTransformer.unit.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpenApiSchemaTransformer.unit.test.d.ts","sourceRoot":"","sources":["../src/OpenApiSchemaTransformer.unit.test.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"GenerateHandler.d.ts","sourceRoot":"","sources":["../../src/file-generators/GenerateHandler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,YAAY,EAAoB,MAAM,2BAA2B,CAAC;AAE3E,KAAK,iBAAiB,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;AAErE,MAAM,MAAM,oBAAoB,GAAG;IAClC,uBAAuB,EAAE,MAAM,CAAC;IAChC,uBAAuB,EAAE,MAAM,CAAC;IAChC,sBAAsB,EAAE,MAAM,CAAC;IAC/B,UAAU,EAAE,iBAAiB,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,YAAY,CAAC;CACpB,CAAC;AAgNF,eAAO,MAAM,eAAe,wHAQzB,oBAAoB,KAAG,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAqB9C,CAAC"}
1
+ {"version":3,"file":"GenerateHandler.d.ts","sourceRoot":"","sources":["../../src/file-generators/GenerateHandler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,YAAY,EAAoB,MAAM,2BAA2B,CAAC;AAE3E,KAAK,iBAAiB,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;AAErE,MAAM,MAAM,oBAAoB,GAAG;IAClC,uBAAuB,EAAE,MAAM,CAAC;IAChC,uBAAuB,EAAE,MAAM,CAAC;IAChC,sBAAsB,EAAE,MAAM,CAAC;IAC/B,UAAU,EAAE,iBAAiB,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,YAAY,CAAC;CACpB,CAAC;AAiNF,eAAO,MAAM,eAAe,wHAQzB,oBAAoB,KAAG,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAqB9C,CAAC"}
@@ -84,7 +84,7 @@ const constructInputs = (properties, requiredInputs) => {
84
84
  bodyInputs.push({
85
85
  input: `${name}: input.${name}`,
86
86
  nullable: O.getOrElse(() => {
87
- if (name in requiredInputsArray) {
87
+ if (requiredInputsArray.includes(name)) {
88
88
  return false;
89
89
  }
90
90
  return true;
@@ -116,10 +116,11 @@ const generatePath = (path, inputs) => O.fold(() => path, (properties) => Object
116
116
  const generateImports = (connectorNamePascalCase, operationNamePascalCase, inputs) => {
117
117
  const requiredInputs = O.getOrElse(() => [])(inputs.required);
118
118
  const containsNullable = O.fold(() => false, (properties) => !!Object.entries(properties).find(([name, input]) => O.getOrElse(() => {
119
- if (name in requiredInputs) {
120
- return false;
119
+ const inputIn = O.getOrElse(() => '')(input.in);
120
+ if (!requiredInputs.includes(name) && inputIn === 'body') {
121
+ return true;
121
122
  }
122
- return true;
123
+ return false;
123
124
  })(input.nullable)))(inputs.properties);
124
125
  const imports = [
125
126
  'import { OperationHandlerSetup } from "@trayio/cdk-dsl/connector/operation/OperationHandlerSetup";',
@@ -132,6 +133,7 @@ const generateImports = (connectorNamePascalCase, operationNamePascalCase, input
132
133
  `import { ${connectorNamePascalCase}Auth } from "../${connectorNamePascalCase}Auth";`,
133
134
  `import { ${operationNamePascalCase}Input } from "./input";`,
134
135
  `import { ${operationNamePascalCase}Output } from "./output";`,
136
+ `import { globalConfigHttp } from "../GlobalConfig";`,
135
137
  ].join('\n');
136
138
  };
137
139
  const generateHandler = ({ connectorNamePascalCase, operationNamePascalCase, operationNameCamelCase, httpMethod, baseUrl, httpPath, input, }) => E.tryCatch(() => `${generateImports(connectorNamePascalCase, operationNamePascalCase, input)}
@@ -141,7 +143,7 @@ const generateHandler = ({ connectorNamePascalCase, operationNamePascalCase, ope
141
143
  ${operationNamePascalCase}Input,
142
144
  ${operationNamePascalCase}Output
143
145
  >((handler) =>
144
- handler.usingHttp((http) =>
146
+ handler.withGlobalConfiguration(globalConfigHttp).usingHttp((http) =>
145
147
  http
146
148
  .${httpMethod}("${baseUrl}${generatePath(httpPath, input)}")
147
149
  .handleRequest((ctx, input, request) => ${handleInput(input)})
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=GenerateHandler.unit.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GenerateHandler.unit.test.d.ts","sourceRoot":"","sources":["../../src/file-generators/GenerateHandler.unit.test.ts"],"names":[],"mappings":""}
@@ -45,13 +45,14 @@ describe('GenerateHandler', () => {
45
45
  import { OpenApiTestAuth } from "../OpenApiTestAuth";
46
46
  import { GetPhotoInput } from "./input";
47
47
  import { GetPhotoOutput } from "./output";
48
+ import { globalConfigHttp } from "../GlobalConfig";
48
49
 
49
50
  export const getPhotoHandler = OperationHandlerSetup.configureHandler<
50
51
  OpenApiTestAuth,
51
52
  GetPhotoInput,
52
53
  GetPhotoOutput
53
54
  >((handler) =>
54
- handler.usingHttp((http) =>
55
+ handler.withGlobalConfiguration(globalConfigHttp).usingHttp((http) =>
55
56
  http
56
57
  .get("https://jsonplaceholder.typicode.com/photos")
57
58
  .handleRequest((ctx, input, request) => request.withoutBody())
@@ -80,13 +81,14 @@ import { GetPhotoOutput } from "./output";
80
81
  import { OpenApiTestAuth } from "../OpenApiTestAuth";
81
82
  import { GetPhotoInput } from "./input";
82
83
  import { GetPhotoOutput } from "./output";
84
+ import { globalConfigHttp } from "../GlobalConfig";
83
85
 
84
86
  export const getPhotoHandler = OperationHandlerSetup.configureHandler<
85
87
  OpenApiTestAuth,
86
88
  GetPhotoInput,
87
89
  GetPhotoOutput
88
90
  >((handler) =>
89
- handler.usingHttp((http) =>
91
+ handler.withGlobalConfiguration(globalConfigHttp).usingHttp((http) =>
90
92
  http
91
93
  .get("https://jsonplaceholder.typicode.com/photos/:photoId")
92
94
  .handleRequest((ctx, input, request) => {let requestBuilder = request; requestBuilder = requestBuilder.addPathParameter("photoId", input.photoId); return requestBuilder.withoutBody()})
@@ -112,13 +114,14 @@ import { GetPhotoOutput } from "./output";
112
114
  import { OpenApiTestAuth } from "../OpenApiTestAuth";
113
115
  import { GetPhotoInput } from "./input";
114
116
  import { GetPhotoOutput } from "./output";
117
+ import { globalConfigHttp } from "../GlobalConfig";
115
118
 
116
119
  export const getPhotoHandler = OperationHandlerSetup.configureHandler<
117
120
  OpenApiTestAuth,
118
121
  GetPhotoInput,
119
122
  GetPhotoOutput
120
123
  >((handler) =>
121
- handler.usingHttp((http) =>
124
+ handler.withGlobalConfiguration(globalConfigHttp).usingHttp((http) =>
122
125
  http
123
126
  .get("https://jsonplaceholder.typicode.com/photos")
124
127
  .handleRequest((ctx, input, request) => {let requestBuilder = request; return requestBuilder.withBodyAsJson({ photoId: input.photoId })})
@@ -144,13 +147,14 @@ import { GetPhotoOutput } from "./output";
144
147
  import { OpenApiTestAuth } from "../OpenApiTestAuth";
145
148
  import { GetPhotoInput } from "./input";
146
149
  import { GetPhotoOutput } from "./output";
150
+ import { globalConfigHttp } from "../GlobalConfig";
147
151
 
148
152
  export const getPhotoHandler = OperationHandlerSetup.configureHandler<
149
153
  OpenApiTestAuth,
150
154
  GetPhotoInput,
151
155
  GetPhotoOutput
152
156
  >((handler) =>
153
- handler.usingHttp((http) =>
157
+ handler.withGlobalConfiguration(globalConfigHttp).usingHttp((http) =>
154
158
  http
155
159
  .get("https://jsonplaceholder.typicode.com/photos")
156
160
  .handleRequest((ctx, input, request) => {let requestBuilder = request; requestBuilder = requestBuilder.addQueryString("id", input.id); return requestBuilder.withoutBody()})
@@ -176,13 +180,14 @@ import { GetPhotoOutput } from "./output";
176
180
  import { OpenApiTestAuth } from "../OpenApiTestAuth";
177
181
  import { GetPhotoInput } from "./input";
178
182
  import { GetPhotoOutput } from "./output";
183
+ import { globalConfigHttp } from "../GlobalConfig";
179
184
 
180
185
  export const getPhotoHandler = OperationHandlerSetup.configureHandler<
181
186
  OpenApiTestAuth,
182
187
  GetPhotoInput,
183
188
  GetPhotoOutput
184
189
  >((handler) =>
185
- handler.usingHttp((http) =>
190
+ handler.withGlobalConfiguration(globalConfigHttp).usingHttp((http) =>
186
191
  http
187
192
  .get("https://jsonplaceholder.typicode.com/photos")
188
193
  .handleRequest((ctx, input, request) => {let requestBuilder = request; requestBuilder = requestBuilder.addHeader("Content-Type", input.Content-Type); return requestBuilder.withoutBody()})
@@ -207,13 +212,14 @@ import { GetPhotoOutput } from "./output";
207
212
  import { OpenApiTestAuth } from "../OpenApiTestAuth";
208
213
  import { GetPhotoInput } from "./input";
209
214
  import { GetPhotoOutput } from "./output";
215
+ import { globalConfigHttp } from "../GlobalConfig";
210
216
 
211
217
  export const getPhotoHandler = OperationHandlerSetup.configureHandler<
212
218
  OpenApiTestAuth,
213
219
  GetPhotoInput,
214
220
  GetPhotoOutput
215
221
  >((handler) =>
216
- handler.usingHttp((http) =>
222
+ handler.withGlobalConfiguration(globalConfigHttp).usingHttp((http) =>
217
223
  http
218
224
  .get("https://jsonplaceholder.typicode.com/photos")
219
225
  .handleRequest((ctx, input, request) => {let requestBuilder = request; if(input.Content-Type) {requestBuilder = requestBuilder.addHeader("Content-Type", input.Content-Type.toString());}; return requestBuilder.withoutBody()})
@@ -250,13 +256,14 @@ import { GetPhotoOutput } from "./output";
250
256
  import { OpenApiTestAuth } from "../OpenApiTestAuth";
251
257
  import { GetPhotoInput } from "./input";
252
258
  import { GetPhotoOutput } from "./output";
259
+ import { globalConfigHttp } from "../GlobalConfig";
253
260
 
254
261
  export const getPhotoHandler = OperationHandlerSetup.configureHandler<
255
262
  OpenApiTestAuth,
256
263
  GetPhotoInput,
257
264
  GetPhotoOutput
258
265
  >((handler) =>
259
- handler.usingHttp((http) =>
266
+ handler.withGlobalConfiguration(globalConfigHttp).usingHttp((http) =>
260
267
  http
261
268
  .get("https://jsonplaceholder.typicode.com/photos/:photoId/:commentId")
262
269
  .handleRequest((ctx, input, request) => {let requestBuilder = request; if(input.id) {requestBuilder = requestBuilder.addQueryString("id", input.id);}; requestBuilder = requestBuilder.addPathParameter("photoId", input.photoId); if(input.commentId) {requestBuilder = requestBuilder.addPathParameter("commentId", input.commentId);}; return requestBuilder.withoutBody()})
@@ -286,13 +293,14 @@ import { GetPhotoOutput } from "./output";
286
293
  import { OpenApiTestAuth } from "../OpenApiTestAuth";
287
294
  import { GetPhotoInput } from "./input";
288
295
  import { GetPhotoOutput } from "./output";
296
+ import { globalConfigHttp } from "../GlobalConfig";
289
297
 
290
298
  export const getPhotoHandler = OperationHandlerSetup.configureHandler<
291
299
  OpenApiTestAuth,
292
300
  GetPhotoInput,
293
301
  GetPhotoOutput
294
302
  >((handler) =>
295
- handler.usingHttp((http) =>
303
+ handler.withGlobalConfiguration(globalConfigHttp).usingHttp((http) =>
296
304
  http
297
305
  .get("https://jsonplaceholder.typicode.com/photos")
298
306
  .handleRequest((ctx, input, request) => {let requestBuilder = request; requestBuilder = requestBuilder.addQueryString("id", input.id); return requestBuilder.withBodyAsJson({ photoId: input.photoId })})
@@ -322,13 +330,14 @@ import { GetPhotoOutput } from "./output";
322
330
  import { OpenApiTestAuth } from "../OpenApiTestAuth";
323
331
  import { GetPhotoInput } from "./input";
324
332
  import { GetPhotoOutput } from "./output";
333
+ import { globalConfigHttp } from "../GlobalConfig";
325
334
 
326
335
  export const getPhotoHandler = OperationHandlerSetup.configureHandler<
327
336
  OpenApiTestAuth,
328
337
  GetPhotoInput,
329
338
  GetPhotoOutput
330
339
  >((handler) =>
331
- handler.usingHttp((http) =>
340
+ handler.withGlobalConfiguration(globalConfigHttp).usingHttp((http) =>
332
341
  http
333
342
  .get("https://jsonplaceholder.typicode.com/photos")
334
343
  .handleRequest((ctx, input, request) => {let requestBuilder = request; if(input.id) {requestBuilder = requestBuilder.addQueryString("id", input.id);}; return requestBuilder.withBodyAsJson({ photoId: input.photoId })})
@@ -356,13 +365,14 @@ import { castUndefinedPropertyToNull } from "@trayio/commons/dynamictype/Dynamic
356
365
  import { OpenApiTestAuth } from "../OpenApiTestAuth";
357
366
  import { GetPhotoInput } from "./input";
358
367
  import { GetPhotoOutput } from "./output";
368
+ import { globalConfigHttp } from "../GlobalConfig";
359
369
 
360
370
  export const getPhotoHandler = OperationHandlerSetup.configureHandler<
361
371
  OpenApiTestAuth,
362
372
  GetPhotoInput,
363
373
  GetPhotoOutput
364
374
  >((handler) =>
365
- handler.usingHttp((http) =>
375
+ handler.withGlobalConfiguration(globalConfigHttp).usingHttp((http) =>
366
376
  http
367
377
  .get("https://jsonplaceholder.typicode.com/photos")
368
378
  .handleRequest((ctx, input, request) => {let requestBuilder = request; return requestBuilder.withBodyAsJson(castUndefinedPropertyToNull({ photoId: input.photoId }))})
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=GenerateHandlerTest.unit.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GenerateHandlerTest.unit.test.d.ts","sourceRoot":"","sources":["../../src/file-generators/GenerateHandlerTest.unit.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=GenerateOperationJson.unit.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GenerateOperationJson.unit.test.d.ts","sourceRoot":"","sources":["../../src/file-generators/GenerateOperationJson.unit.test.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trayio/tray-openapi",
3
- "version": "4.18.0",
3
+ "version": "4.18.1",
4
4
  "description": "Creating CDK Projects from OpenAPI 3.0 Schemas",
5
5
  "exports": {
6
6
  "./*": "./dist/*.js"
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=OpenApiSchemaImporter.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OpenApiSchemaImporter.test.d.ts","sourceRoot":"","sources":["../src/OpenApiSchemaImporter.test.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=OpenApiSchemaTransformer.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OpenApiSchemaTransformer.test.d.ts","sourceRoot":"","sources":["../src/OpenApiSchemaTransformer.test.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=GenerateHandler.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"GenerateHandler.test.d.ts","sourceRoot":"","sources":["../../src/file-generators/GenerateHandler.test.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=GenerateHandlerTest.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"GenerateHandlerTest.test.d.ts","sourceRoot":"","sources":["../../src/file-generators/GenerateHandlerTest.test.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=GenerateOperationJson.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"GenerateOperationJson.test.d.ts","sourceRoot":"","sources":["../../src/file-generators/GenerateOperationJson.test.ts"],"names":[],"mappings":""}