@trayio/cdk-build 3.14.1-unstable → 3.16.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.
@@ -5,8 +5,5 @@ export declare class ConnectorBuilder {
5
5
  generateSchemas(cdkProjectPath: string): TE.TaskEither<Error, undefined>;
6
6
  getOperations(cdkProjectPath: string): Array<string>;
7
7
  private generatePackage;
8
- private injectRawHttpOperation;
9
- private injectGlobalConfigToCdkProjectPath;
10
- private addRawHttpConfig;
11
8
  }
12
9
  //# sourceMappingURL=ConnectorBuilder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConnectorBuilder.d.ts","sourceRoot":"","sources":["../../src/connector/ConnectorBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AASvC,qBAAa,gBAAgB;IAC5B,OAAO,CAAC,wBAAwB,CAA2C;IAE3E,cAAc,CAAC,cAAc,EAAE,MAAM,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC;IAOvE,eAAe,CAAC,cAAc,EAAE,MAAM,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC;IAcxE,aAAa,CAAC,cAAc,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAYpD,OAAO,CAAC,eAAe;IA6DvB,OAAO,CAAC,sBAAsB;IAuC9B,OAAO,CAAC,kCAAkC;IAkB1C,OAAO,CAAC,gBAAgB;CAcxB"}
1
+ {"version":3,"file":"ConnectorBuilder.d.ts","sourceRoot":"","sources":["../../src/connector/ConnectorBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAQvC,qBAAa,gBAAgB;IAC5B,OAAO,CAAC,wBAAwB,CAA2C;IAE3E,cAAc,CAAC,cAAc,EAAE,MAAM,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC;IAOvE,eAAe,CAAC,cAAc,EAAE,MAAM,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC;IAcxE,aAAa,CAAC,cAAc,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAYpD,OAAO,CAAC,eAAe;CAgDvB"}
@@ -33,7 +33,6 @@ const Array_1 = require("fp-ts/Array");
33
33
  const pathLib = __importStar(require("path"));
34
34
  const fse = __importStar(require("fs-extra"));
35
35
  const adm_zip_1 = __importDefault(require("adm-zip"));
36
- const lodash_1 = require("lodash");
37
36
  const ConnectorOperationSchemaGenerator_1 = require("./operation/ConnectorOperationSchemaGenerator");
38
37
  class ConnectorBuilder {
39
38
  operationSchemaGenerator = new ConnectorOperationSchemaGenerator_1.ConnectorOperationSchemaGenerator();
@@ -60,14 +59,8 @@ class ConnectorBuilder {
60
59
  const connectorPackagePath = pathLib.join(cdkProjectPath, 'dist', 'connector.zip');
61
60
  const connectorJsonPath = pathLib.join(cdkProjectPath, 'connector.json');
62
61
  const connectorJson = fse.readJsonSync(connectorJsonPath);
63
- // add rawHttpConfig to connectorJson if it's missing
64
- const connectorJsonWithRawHttpConfig = this.addRawHttpConfig(connectorJson);
65
- fse.writeJsonSync(connectorJsonPath, connectorJsonWithRawHttpConfig);
66
62
  const connectorPackage = new adm_zip_1.default();
67
63
  connectorPackage.addLocalFolder(pathLib.join(cdkProjectPath, 'src'), pathLib.join(connectorJson.name, 'src'));
68
- if (connectorJsonWithRawHttpConfig.rawHttp.enabled) {
69
- this.injectRawHttpOperation(connectorPackage, connectorJson.name, cdkProjectPath);
70
- }
71
64
  const entries = connectorPackage.getEntries();
72
65
  // exclude all the ctx.json files from the zip as it can contain sensitive information
73
66
  for (const entry of entries) {
@@ -82,34 +75,5 @@ class ConnectorBuilder {
82
75
  connectorPackage.writeZip(connectorPackagePath);
83
76
  return TE.right(undefined);
84
77
  }
85
- injectRawHttpOperation(connectorPackage, connectorName, cdkProjectPath) {
86
- const executionDir = __dirname;
87
- const rawHttpOperationWorkPath = pathLib.join(executionDir, './', 'operation', 'raw-http', 'work-path');
88
- const rawHttpZip = new adm_zip_1.default(pathLib.join(rawHttpOperationWorkPath, '../', 'raw_http_request.zip'));
89
- rawHttpZip.extractAllTo(pathLib.join(rawHttpOperationWorkPath), true);
90
- this.injectGlobalConfigToCdkProjectPath(cdkProjectPath, rawHttpOperationWorkPath);
91
- connectorPackage.addLocalFolder(pathLib.join(rawHttpOperationWorkPath), pathLib.join(connectorName, 'src'));
92
- connectorPackage.addLocalFile(pathLib.join(cdkProjectPath, 'src', 'GlobalConfig.ts'), pathLib.join(connectorName, 'src'));
93
- // Cleanup after injecting the Raw HTTP operation
94
- fse.removeSync(pathLib.join(rawHttpOperationWorkPath));
95
- }
96
- injectGlobalConfigToCdkProjectPath(cdkProjectPath, rawHttpOperationWorkPath) {
97
- const connectorDefaultGlobalConfigPath = pathLib.join(cdkProjectPath, 'src', 'GlobalConfig.ts');
98
- if (!fse.existsSync(connectorDefaultGlobalConfigPath)) {
99
- fse.renameSync(pathLib.join(rawHttpOperationWorkPath, 'GlobalConfig.ts'), connectorDefaultGlobalConfigPath);
100
- }
101
- }
102
- addRawHttpConfig(connectorJson) {
103
- if ((0, lodash_1.isUndefined)(connectorJson.rawHttp?.enabled) ||
104
- typeof connectorJson.rawHttp?.enabled !== 'boolean') {
105
- return {
106
- ...connectorJson,
107
- rawHttp: {
108
- enabled: true,
109
- },
110
- };
111
- }
112
- return connectorJson;
113
- }
114
78
  }
115
79
  exports.ConnectorBuilder = ConnectorBuilder;
@@ -45,11 +45,11 @@ class ConnectorOperationSchemaGenerator {
45
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
46
  console.log(`Generating types for operation: ${operationName}`); // TODO: Remove this and use a logger
47
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) => {
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.chain((exists) => {
49
49
  if (exists) {
50
50
  return this.generateSchema(responseFilePath, responseTypeName, responseSchemaFilePath);
51
51
  }
52
- return undefined;
52
+ return TE.right(undefined);
53
53
  }))), TE.chain(() => TE.right(undefined)));
54
54
  }
55
55
  generateSchema(filePath, typeName, schemaFilePath) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trayio/cdk-build",
3
- "version": "3.14.1-unstable",
3
+ "version": "3.16.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": "3.14.1-unstable",
18
- "@trayio/tray-schema": "3.14.1-unstable",
17
+ "@trayio/commons": "3.16.0",
18
+ "@trayio/tray-schema": "3.16.0",
19
19
  "adm-zip": "0.5.10"
20
20
  },
21
21
  "typesVersions": {