@trayio/cdk-build 3.19.0 → 4.0.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.
@@ -5,5 +5,8 @@ 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;
8
11
  }
9
12
  //# 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;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"}
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"}
@@ -33,6 +33,7 @@ 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");
36
37
  const ConnectorOperationSchemaGenerator_1 = require("./operation/ConnectorOperationSchemaGenerator");
37
38
  class ConnectorBuilder {
38
39
  operationSchemaGenerator = new ConnectorOperationSchemaGenerator_1.ConnectorOperationSchemaGenerator();
@@ -59,8 +60,14 @@ class ConnectorBuilder {
59
60
  const connectorPackagePath = pathLib.join(cdkProjectPath, 'dist', 'connector.zip');
60
61
  const connectorJsonPath = pathLib.join(cdkProjectPath, 'connector.json');
61
62
  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);
62
66
  const connectorPackage = new adm_zip_1.default();
63
67
  connectorPackage.addLocalFolder(pathLib.join(cdkProjectPath, 'src'), pathLib.join(connectorJson.name, 'src'));
68
+ if (connectorJsonWithRawHttpConfig.rawHttp.enabled) {
69
+ this.injectRawHttpOperation(connectorPackage, connectorJson.name, cdkProjectPath);
70
+ }
64
71
  const entries = connectorPackage.getEntries();
65
72
  // exclude all the ctx.json files from the zip as it can contain sensitive information
66
73
  for (const entry of entries) {
@@ -75,5 +82,34 @@ class ConnectorBuilder {
75
82
  connectorPackage.writeZip(connectorPackagePath);
76
83
  return TE.right(undefined);
77
84
  }
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
+ }
78
114
  }
79
115
  exports.ConnectorBuilder = ConnectorBuilder;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trayio/cdk-build",
3
- "version": "3.19.0",
3
+ "version": "4.0.1",
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.19.0",
18
- "@trayio/tray-schema": "3.19.0",
17
+ "@trayio/commons": "4.0.1",
18
+ "@trayio/tray-schema": "4.0.1",
19
19
  "adm-zip": "0.5.10"
20
20
  },
21
21
  "typesVersions": {