@trayio/cdk-build 2.2.0 → 2.3.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.
@@ -1,7 +1,5 @@
1
1
  import * as TE from 'fp-ts/TaskEither';
2
2
  export declare class ConnectorOperationSchemaGenerator {
3
- private schemaTransformer;
4
- constructor();
5
3
  generateSchemasForOperation(operationPath: string, operationName: string): TE.TaskEither<Error, undefined>;
6
4
  private generateSchema;
7
5
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ConnectorOperationSchemaGenerator.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/ConnectorOperationSchemaGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AASvC,qBAAa,iCAAiC;IAC7C,OAAO,CAAC,iBAAiB,CAAsB;;IAM/C,2BAA2B,CAC1B,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,GACnB,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC;IAgDlC,OAAO,CAAC,cAAc;CActB"}
1
+ {"version":3,"file":"ConnectorOperationSchemaGenerator.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/ConnectorOperationSchemaGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AASvC,qBAAa,iCAAiC;IAC7C,2BAA2B,CAC1B,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,GACnB,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC;IAiElC,OAAO,CAAC,cAAc;CAYtB"}
@@ -32,11 +32,7 @@ const TJSTraySchemaGenerator_1 = require("@trayio/tray-schema/schema/TJSTraySche
32
32
  const fse = __importStar(require("fs-extra"));
33
33
  const DynamicType_1 = require("@trayio/commons/dynamictype/DynamicType");
34
34
  class ConnectorOperationSchemaGenerator {
35
- constructor() {
36
- this.schemaTransformer = new TJSTraySchemaGenerator_1.TJSTraySchemaGenerator();
37
- }
38
35
  generateSchemasForOperation(operationPath, operationName) {
39
- console.log(`Generating schemas for operation ${operationName}`); // TODO: Remove this and use a logger
40
36
  const inputFilePath = pathLib.join(operationPath, 'input.ts');
41
37
  const outputFilePath = pathLib.join(operationPath, 'output.ts');
42
38
  const responseFilePath = pathLib.join(operationPath, 'response.ts');
@@ -46,21 +42,19 @@ class ConnectorOperationSchemaGenerator {
46
42
  const inputSchemaFilePath = pathLib.join(operationPath, 'input.json');
47
43
  const outputSchemaFilePath = pathLib.join(operationPath, 'output.json');
48
44
  const responseSchemaFilePath = pathLib.join(operationPath, 'response.json');
49
- if (!fse.existsSync(inputFilePath)) {
50
- return TE.left(new Error(`Input file not found in ${inputFilePath}`));
51
- }
52
- if (!fse.existsSync(outputFilePath)) {
53
- return TE.left(new Error(`Output file not found in ${outputFilePath}`));
54
- }
55
- return (0, function_1.pipe)(this.generateSchema(inputFilePath, inputTypeName, inputSchemaFilePath), TE.chain(() => this.generateSchema(outputFilePath, outputTypeName, outputSchemaFilePath)), TE.chain(() => {
56
- if (fse.existsSync(responseFilePath)) {
45
+ return (0, function_1.pipe)(TE.tryCatch(() => fse.exists(inputFilePath), (reason) => new Error(String(reason))), TE.chain(() => TE.tryCatch(() => fse.exists(outputFilePath), (reason) => new Error(String(reason)))), TE.chain(() => {
46
+ console.log(`Generating types for operation: ${operationName}`); // TODO: Remove this and use a logger
47
+ return this.generateSchema(inputFilePath, inputTypeName, inputSchemaFilePath);
48
+ }), TE.chain(() => this.generateSchema(outputFilePath, outputTypeName, outputSchemaFilePath)), TE.chain(() => (0, function_1.pipe)(TE.tryCatch(() => fse.exists(responseFilePath), (reason) => new Error(String(reason))), TE.map((exists) => {
49
+ if (exists) {
57
50
  return this.generateSchema(responseFilePath, responseTypeName, responseSchemaFilePath);
58
51
  }
59
- return TE.right(undefined);
60
- }));
52
+ return undefined;
53
+ }))), TE.chain(() => TE.right(undefined)));
61
54
  }
62
55
  generateSchema(filePath, typeName, schemaFilePath) {
63
- return (0, function_1.pipe)(TE.fromEither(this.schemaTransformer.generateFromType(typeName, filePath)), TE.chain((schema) => TE.fromEither(DynamicType_1.DynamicType.writeToFile(schemaFilePath, schema))));
56
+ const schemaTransformer = new TJSTraySchemaGenerator_1.TJSTraySchemaGenerator();
57
+ return (0, function_1.pipe)(TE.fromEither(schemaTransformer.generateFromType(typeName, filePath)), TE.chain((schema) => DynamicType_1.DynamicType.writeToFileAsync(schemaFilePath, schema)));
64
58
  }
65
59
  }
66
60
  exports.ConnectorOperationSchemaGenerator = ConnectorOperationSchemaGenerator;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trayio/cdk-build",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "Build utilities for CDK projects",
5
5
  "exports": {
6
6
  "./*": "./dist/*.js"
@@ -14,8 +14,8 @@
14
14
  "access": "public"
15
15
  },
16
16
  "dependencies": {
17
- "@trayio/commons": "2.2.0",
18
- "@trayio/tray-schema": "2.2.0",
17
+ "@trayio/commons": "2.3.0",
18
+ "@trayio/tray-schema": "2.3.0",
19
19
  "adm-zip": "0.5.10"
20
20
  },
21
21
  "typesVersions": {