zcatalyst-cli 1.15.0-beta.1 → 1.15.0-beta.3

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.
@@ -64,20 +64,25 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
64
64
  if (target.type !== undefined && target.type === constants_1.FN_TYPE.advanced) {
65
65
  resp = (yield appAPI.deploy(target.zip_stream, {
66
66
  stack: target.stack,
67
- name: target.name
67
+ name: target.name,
68
+ memory: target.memory,
69
+ envVariables: target.env_var
68
70
  }));
69
71
  }
70
72
  else {
71
73
  resp = (yield fnAPI.deploy(target.zip_stream, {
72
74
  stack: target.stack,
73
75
  name: target.name,
74
- type: constants_1.REMOTE_REF.functions.type[target.type]
76
+ type: constants_1.REMOTE_REF.functions.type[target.type],
77
+ memory: target.type === constants_1.FN_TYPE.browserLogic
78
+ ? !target.memory && !target.id
79
+ ? 512
80
+ : target.memory
81
+ : target.memory,
82
+ envVariables: target.env_var
75
83
  }));
76
84
  }
77
85
  target.id = resp.id + '';
78
- if (target.id && target.env_var && Object.keys(target.env_var).length > 0) {
79
- yield fnAPI.updateConfig(target.id, target.env_var);
80
- }
81
86
  fn_utils_1.fnUtils.common.generateUrlForTarget(target);
82
87
  }
83
88
  catch (e) {
@@ -20,7 +20,7 @@ class Applogic {
20
20
  this.opts = opts;
21
21
  this.projectId = projectId;
22
22
  }
23
- deploy(sourceFsStream, { stack, name, memory }) {
23
+ deploy(sourceFsStream, { stack, name, memory, envVariables }) {
24
24
  return __awaiter(this, void 0, void 0, function* () {
25
25
  const formData = {
26
26
  stack,
@@ -29,8 +29,17 @@ class Applogic {
29
29
  if (sourceFsStream !== undefined) {
30
30
  formData.code = sourceFsStream;
31
31
  }
32
+ const configuration = {};
32
33
  if (memory !== undefined) {
33
- formData.memory = memory;
34
+ configuration.memory = memory;
35
+ }
36
+ if (envVariables !== undefined) {
37
+ configuration.environment = {
38
+ variables: envVariables
39
+ };
40
+ }
41
+ if (Object.keys(configuration).length > 0) {
42
+ formData.configuration = JSON.stringify(configuration);
34
43
  }
35
44
  const res = yield new api_1.default(this.opts).put(`/baas/v1/project/${this.projectId}/server/upsert`, {
36
45
  formData,
@@ -73,18 +73,27 @@ class Functions {
73
73
  });
74
74
  });
75
75
  }
76
- deploy(sourceFsStream, { stack, name, type, memory }) {
76
+ deploy(sourceFsStream, { stack, name, type, memory, envVariables }) {
77
77
  return __awaiter(this, void 0, void 0, function* () {
78
78
  const formData = {
79
79
  stack,
80
80
  name,
81
81
  type
82
82
  };
83
+ const configuration = {};
83
84
  if (sourceFsStream !== undefined) {
84
85
  formData.code = sourceFsStream;
85
86
  }
86
87
  if (memory !== undefined) {
87
- formData.memory = memory;
88
+ configuration.memory = memory;
89
+ }
90
+ if (envVariables !== undefined) {
91
+ configuration.environment = {
92
+ variables: envVariables
93
+ };
94
+ }
95
+ if (Object.keys(configuration).length > 0) {
96
+ formData.configuration = JSON.stringify(configuration);
88
97
  }
89
98
  const res = yield new api_1.default(this.opts).put(`/baas/v1/project/${this.projectId}/function/upsert`, {
90
99
  formData,
@@ -126,7 +126,7 @@ function validate() {
126
126
  exports.validate = validate;
127
127
  function refineTargets(rawTargets, mapRemoteFn = true) {
128
128
  return __awaiter(this, void 0, void 0, function* () {
129
- let remoteFnIdMap = {};
129
+ let remoteFnMap = {};
130
130
  let runtimeDetails = runtime_store_1.default.get('context.catalyst.runtime', { runtimes: [] });
131
131
  if (mapRemoteFn) {
132
132
  const fnAPI = yield (0, endpoints_1.functionsAPI)();
@@ -141,12 +141,13 @@ function refineTargets(rawTargets, mapRemoteFn = true) {
141
141
  if (!Array.isArray(allRemoteFns) || allRemoteFns.length === 0) {
142
142
  allRemoteFns = [];
143
143
  }
144
- remoteFnIdMap = allRemoteFns.reduce((accumulator, fn) => {
145
- accumulator[fn.name] = fn.id + '';
144
+ remoteFnMap = allRemoteFns.reduce((accumulator, fn) => {
145
+ accumulator[fn.name] = fn;
146
146
  return accumulator;
147
- }, remoteFnIdMap);
147
+ }, remoteFnMap);
148
148
  }
149
149
  return Promise.all(rawTargets.map((fnPath) => __awaiter(this, void 0, void 0, function* () {
150
+ var _a;
150
151
  fnPath = (0, project_1.resolveProjectPath)(fnPath);
151
152
  const catalystJsonPth = (0, path_1.join)(fnPath, constants_1.FILENAME.catalyst_config);
152
153
  const catalystJson = yield fs_1.ASYNC.readJSONFile(catalystJsonPth, {
@@ -193,7 +194,7 @@ function refineTargets(rawTargets, mapRemoteFn = true) {
193
194
  switch (eol) {
194
195
  case 1:
195
196
  case 2:
196
- if (eol === 2 && remoteFnIdMap[fnName] === undefined) {
197
+ if (eol === 2 && remoteFnMap[fnName] === undefined) {
197
198
  return {
198
199
  name: fnName,
199
200
  source: fnPath,
@@ -223,6 +224,16 @@ function refineTargets(rawTargets, mapRemoteFn = true) {
223
224
  const catalystJsonString = JSON.stringify(catalystJson, null, 2) + '\n';
224
225
  yield fs_1.ASYNC.writeFile(catalystJsonPth, catalystJsonString, 'utf8');
225
226
  }
227
+ const fnMemory = js_1.JS.get(catalystJson, 'deployment.memory', js_1.JS.get(remoteFnMap[fnName], 'configuration.memory'));
228
+ if (fnMemory && !runtime_1.default.memory.includes(fnMemory)) {
229
+ return {
230
+ name: fnName,
231
+ source: fnPath,
232
+ valid: false,
233
+ type: fnType,
234
+ failure_reason: `The memory configuration ${fnMemory} is not supported. The supported values are ${runtime_1.default.memory.join(', ')}.`
235
+ };
236
+ }
226
237
  const fnTarget = {
227
238
  name: fnName,
228
239
  stack: userStack,
@@ -231,10 +242,11 @@ function refineTargets(rawTargets, mapRemoteFn = true) {
231
242
  source: fnPath,
232
243
  valid: true,
233
244
  integ_config: js_1.JS.get(catalystJson, 'deployment.integration_config'),
234
- env_var: refineEnvVariables(js_1.JS.get(catalystJson, 'deployment.env_variables'))
245
+ env_var: refineEnvVariables(js_1.JS.get(catalystJson, 'deployment.env_variables')),
246
+ memory: fnMemory
235
247
  };
236
- if (mapRemoteFn && remoteFnIdMap[fnTarget.name] !== undefined) {
237
- fnTarget.id = remoteFnIdMap[fnTarget.name];
248
+ if (mapRemoteFn && remoteFnMap[fnTarget.name] !== undefined) {
249
+ fnTarget.id = (_a = remoteFnMap[fnTarget.name]) === null || _a === void 0 ? void 0 : _a.id;
238
250
  }
239
251
  return fnTarget;
240
252
  })));
@@ -94,7 +94,9 @@ function copyIntegHandlers(templatePath, targetPath, lang) {
94
94
  yield fs_1.ASYNC.copyFiles(filePaths, targetPath);
95
95
  const integHandlerConfig = {};
96
96
  const handlerPaths = handlers.map((handler) => {
97
- integHandlerConfig[handler] = (0, path_1.join)(constants_1.CLIQ.java_handlers_path, constants_1.CLIQ.java_handler_file_mapping[handler].replace('.java', ''));
97
+ integHandlerConfig[handler] =
98
+ constants_1.CLIQ.java_handlers_path +
99
+ constants_1.CLIQ.java_handler_file_mapping[handler].replace('.java', '');
98
100
  return (0, path_1.join)(templatePath, constants_1.CLIQ.java_handlers_template_dir, constants_1.CLIQ.java_handler_file_mapping[handler]);
99
101
  });
100
102
  yield fs_1.ASYNC.copyFiles(handlerPaths, (0, path_1.join)(targetPath, constants_1.CLIQ.java_handlers_template_dir));
@@ -31,7 +31,7 @@ function getTemplatePath(fnType, add) {
31
31
  switch (fnType) {
32
32
  case constants_1.FN_TYPE.browserLogic:
33
33
  case constants_1.FN_TYPE.integration: {
34
- return js_1.JS.get(constants_1.TEMPLATE.functions.java[fnType], add.toLowerCase());
34
+ return js_1.JS.get(constants_1.TEMPLATE.functions.java[fnType], add);
35
35
  }
36
36
  default: {
37
37
  return constants_1.TEMPLATE.functions.java[fnType];
@@ -32,7 +32,7 @@ function getTemplatePath(fnType, add) {
32
32
  switch (fnType) {
33
33
  case constants_1.FN_TYPE.browserLogic:
34
34
  case constants_1.FN_TYPE.integration: {
35
- return js_1.JS.get(constants_1.TEMPLATE.functions.node[fnType], add.toLowerCase());
35
+ return js_1.JS.get(constants_1.TEMPLATE.functions.node[fnType], add);
36
36
  }
37
37
  default: {
38
38
  return constants_1.TEMPLATE.functions.node[fnType];
@@ -41,4 +41,4 @@ export const close = async (REQUEST, RESPONSE, driver) => {
41
41
  catch (ERROR) {
42
42
  console.error(ERROR);
43
43
  }
44
- };
44
+ };
@@ -18,4 +18,4 @@ export default class DeferredPromise {
18
18
  get [Symbol.toStringTag]() {
19
19
  return 'Promise';
20
20
  }
21
- };
21
+ };
@@ -31,4 +31,4 @@ async function getBrowser() {
31
31
  })
32
32
  }
33
33
 
34
- export default { getBrowser };
34
+ export default { getBrowser };
@@ -32,4 +32,4 @@ async function getBrowser(path) {
32
32
  })
33
33
  }
34
34
 
35
- export default {getBrowser}
35
+ export default {getBrowser}
@@ -56,4 +56,4 @@ function isConnected()
56
56
  return false;
57
57
  }
58
58
 
59
- export default {getBrowser}
59
+ export default {getBrowser}
@@ -44,7 +44,7 @@ app.all('/server/:fnId/execute', async (req, res) => {
44
44
  }
45
45
  });
46
46
 
47
- app.all('/', async (req, res) => {
47
+ app.all('/*', async (req, res) => {
48
48
  try {
49
49
  if (index === undefined) {
50
50
  throw new Error(`index of ${type} function is undefined`);
@@ -5,6 +5,7 @@ const RUNTIME = Object.freeze({
5
5
  nodejs: 'node',
6
6
  java: 'java',
7
7
  python: 'python'
8
- }
8
+ },
9
+ memory: [128, 256, 512]
9
10
  });
10
11
  exports.default = RUNTIME;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zcatalyst-cli",
3
- "version": "1.15.0-beta.1",
3
+ "version": "1.15.0-beta.3",
4
4
  "description": "Command Line Tool for CATALYST",
5
5
  "main": "./lib/index.js",
6
6
  "bin": {
@@ -8,4 +8,4 @@
8
8
  "execution": {
9
9
  "main": "{{_MAIN_}}"
10
10
  }
11
- }
11
+ }
@@ -8,4 +8,4 @@
8
8
  "execution": {
9
9
  "main": "{{_MAIN_}}"
10
10
  }
11
- }
11
+ }
@@ -8,4 +8,4 @@
8
8
  "execution": {
9
9
  "main": "{{_MAIN_}}"
10
10
  }
11
- }
11
+ }
@@ -3,6 +3,7 @@
3
3
  "version": "1.0.0",
4
4
  "main": "{{_MAIN_}}",
5
5
  "author": "{{_AUTHOR_}}",
6
+ "type": "module",
6
7
  "dependencies": {
7
8
  "zcatalyst-integ-cliq": "latest",
8
9
  "zcatalyst-sdk-node": "^2.1.0"