zcatalyst-cli 1.22.1 → 1.22.2

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,27 +1,4 @@
1
1
  'use strict';
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -35,180 +12,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
35
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
36
13
  };
37
14
  Object.defineProperty(exports, "__esModule", { value: true });
38
- const ansi_colors_1 = require("ansi-colors");
39
- const error_1 = __importDefault(require("../../../error"));
40
15
  const command_1 = __importDefault(require("../../../internal/command"));
41
- const constants_1 = require("../../../util_modules/constants");
42
- const fs_1 = require("../../../util_modules/fs");
43
- const logger_1 = require("../../../util_modules/logger");
44
- const project_1 = require("../../../util_modules/project");
45
- const js_1 = require("../../../util_modules/js");
46
- const option_1 = require("../../../util_modules/option");
16
+ const signals_1 = require("../../../signals");
47
17
  exports.default = new command_1.default('signals:generate <publisher_service> <event_name>')
48
18
  .description('Generate sample payloads from different components or custom event publishers to test Event functions')
49
19
  .allowUnknownOpts()
50
20
  .needs('rc')
51
21
  .needs('auth')
52
- .action(function generate(publisher, event) {
53
- return __awaiter(this, void 0, void 0, function* () {
54
- var _a;
55
- const unknownArgs = (0, option_1.getUnknownOpts)([]);
56
- if (unknownArgs.length % 2 !== 0) {
57
- throw new error_1.default('Unknown options are not provided as key value pairs', {
58
- exit: 1,
59
- errorId: 'IDX-1',
60
- arg: [(0, ansi_colors_1.bold)(publisher), (0, ansi_colors_1.bold)(event), (0, ansi_colors_1.bold)('--key value')]
61
- });
62
- }
63
- const remotePublisherName = constants_1.SIGNALS_PUBLISHERS[publisher];
64
- if (remotePublisherName === undefined) {
65
- throw new error_1.default('Invalid publisher service', {
66
- exit: 1,
67
- errorId: 'IDX-2',
68
- arg: [
69
- (0, ansi_colors_1.bold)(Object.keys(constants_1.SIGNALS_PUBLISHERS)
70
- .map((src) => '* ' + src)
71
- .join('\n'))
72
- ]
73
- });
74
- }
75
- if (constants_1.SIGNALS_API_NAMES[remotePublisherName] === undefined) {
76
- throw new error_1.default('Signal reference is not found for the publisher service provided', {
77
- exit: 2
78
- });
79
- }
80
- let eventJsonContent = yield fs_1.ASYNC.readFile(constants_1.TEMPLATE.signal_event_data);
81
- if (eventJsonContent === undefined) {
82
- throw new error_1.default('Signal template json is undefined', { exit: 2 });
83
- }
84
- const eventDataPlaceHolder = constants_1.PLACEHOLDER.signal_event_data;
85
- const optionMap = unknownArgs.reduce((previousValue, currentValue, currentIndex, optionArr) => {
86
- if (currentIndex % 2 === 0) {
87
- if (!currentValue.startsWith('--') &&
88
- currentValue !== '-e' &&
89
- currentValue !== '-rid' &&
90
- currentValue !== '--verbose') {
91
- const fault = unknownArgs === null || unknownArgs === void 0 ? void 0 : unknownArgs.map((arg) => {
92
- if (arg === currentValue) {
93
- return (0, ansi_colors_1.red)(arg);
94
- }
95
- return arg;
96
- }).join(' ');
97
- throw new error_1.default('Invalid option format detected', {
98
- exit: 1,
99
- errorId: 'IDX-3',
100
- arg: [(0, ansi_colors_1.italic)(fault), (0, ansi_colors_1.bold)('--<option> <value>')]
101
- });
102
- }
103
- previousValue[currentValue.slice(2)] = optionArr[currentIndex + 1];
104
- }
105
- return previousValue;
106
- }, {});
107
- let data = {};
108
- if (publisher !== 'custom') {
109
- const publisherModule = yield (_a = '../../../event_generate/' + (publisher === 'authentication' ? 'user' : publisher), Promise.resolve().then(() => __importStar(require(_a))));
110
- data = yield publisherModule.getData(optionMap);
111
- if (publisher === 'datastore') {
112
- data = Object.assign(Object.assign({}, data), { table_details: {
113
- table_id: publisherModule.sourceId,
114
- table_name: 'Default'
115
- } });
116
- }
117
- if (publisher === 'authentication' && event !== 'user_signedup') {
118
- data = data.user_details;
119
- }
120
- }
121
- Object.keys(eventDataPlaceHolder).forEach((placeholderKey) => {
122
- switch (placeholderKey) {
123
- case 'version':
124
- eventJsonContent = eventJsonContent === null || eventJsonContent === void 0 ? void 0 : eventJsonContent.replace(new RegExp(eventDataPlaceHolder[placeholderKey], 'g'), 1 + '');
125
- break;
126
- case 'org_id':
127
- eventJsonContent = eventJsonContent === null || eventJsonContent === void 0 ? void 0 : eventJsonContent.replace(new RegExp(eventDataPlaceHolder[placeholderKey], 'g'), (0, project_1.getEnvId)() + '');
128
- break;
129
- case 'project_id':
130
- eventJsonContent = eventJsonContent === null || eventJsonContent === void 0 ? void 0 : eventJsonContent.replace(new RegExp(eventDataPlaceHolder[placeholderKey], 'g'), (0, project_1.getProjectId)() + '');
131
- break;
132
- case 'project_name':
133
- eventJsonContent = eventJsonContent === null || eventJsonContent === void 0 ? void 0 : eventJsonContent.replace(new RegExp(eventDataPlaceHolder[placeholderKey], 'g'), (0, project_1.getProjectName)() + '');
134
- break;
135
- case 'environment':
136
- eventJsonContent = eventJsonContent === null || eventJsonContent === void 0 ? void 0 : eventJsonContent.replace(new RegExp(eventDataPlaceHolder[placeholderKey], 'g'), (0, project_1.getEnvName)() + '');
137
- break;
138
- case 'rule_id':
139
- eventJsonContent = eventJsonContent === null || eventJsonContent === void 0 ? void 0 : eventJsonContent.replace(new RegExp(eventDataPlaceHolder[placeholderKey], 'g'), js_1.JS.randomNumber(18) + '');
140
- break;
141
- case 'uuid':
142
- eventJsonContent = eventJsonContent === null || eventJsonContent === void 0 ? void 0 : eventJsonContent.replace(new RegExp(eventDataPlaceHolder[placeholderKey], 'g'), js_1.JS.randomString(8) +
143
- '-' +
144
- js_1.JS.randomString(4) +
145
- '-' +
146
- js_1.JS.randomString(4) +
147
- '-' +
148
- js_1.JS.randomString(4) +
149
- '-' +
150
- js_1.JS.randomString(11));
151
- break;
152
- case 'target_id':
153
- eventJsonContent = eventJsonContent === null || eventJsonContent === void 0 ? void 0 : eventJsonContent.replace(new RegExp(eventDataPlaceHolder[placeholderKey], 'g'), js_1.JS.randomNumber(8) + '');
154
- break;
155
- case 'signal_id':
156
- eventJsonContent = eventJsonContent === null || eventJsonContent === void 0 ? void 0 : eventJsonContent.replace(new RegExp(eventDataPlaceHolder[placeholderKey], 'g'), js_1.JS.randomNumber(17) + '');
157
- break;
158
- case 'signal_api_name':
159
- if (publisher !== 'custom') {
160
- const eventRefArr = constants_1.SIGNALS_API_NAMES[remotePublisherName];
161
- const remoteRefevent = event;
162
- (0, logger_1.debug)(`event name provided is : ${remoteRefevent}`);
163
- const indexOfevent = eventRefArr.indexOf(remoteRefevent);
164
- if (indexOfevent < 0) {
165
- const availableEvents = eventRefArr
166
- .map((act) => {
167
- return '* ' + act;
168
- })
169
- .join('\n');
170
- throw new error_1.default('Event name incompatible with the publisher service' + eventRefArr, {
171
- exit: 1,
172
- errorId: 'IDX-4',
173
- arg: [
174
- (0, ansi_colors_1.bold)(event),
175
- ansi_colors_1.bold.red('X'),
176
- (0, ansi_colors_1.bold)(publisher),
177
- (0, ansi_colors_1.bold)(availableEvents)
178
- ]
179
- });
180
- }
181
- event = constants_1.SIGNALS_API_NAMES[remotePublisherName][indexOfevent];
182
- }
183
- eventJsonContent = eventJsonContent === null || eventJsonContent === void 0 ? void 0 : eventJsonContent.replace(new RegExp(eventDataPlaceHolder[placeholderKey], 'g'), event);
184
- break;
185
- case 'attempt':
186
- eventJsonContent = eventJsonContent === null || eventJsonContent === void 0 ? void 0 : eventJsonContent.replace(new RegExp(eventDataPlaceHolder[placeholderKey], 'g'), 1 + '');
187
- break;
188
- case 'source':
189
- const publisherDetails = `publisher_id:${js_1.JS.randomNumber(17)}` +
190
- `/service:${getPublisherType(publisher)}${publisher === 'custom'
191
- ? ''
192
- : publisher + '/account:' + js_1.JS.randomNumber(8)}`;
193
- eventJsonContent = eventJsonContent === null || eventJsonContent === void 0 ? void 0 : eventJsonContent.replace(new RegExp(eventDataPlaceHolder[placeholderKey], 'g'), publisherDetails);
194
- break;
195
- case 'time_in_ms':
196
- eventJsonContent = eventJsonContent === null || eventJsonContent === void 0 ? void 0 : eventJsonContent.replace(new RegExp(eventDataPlaceHolder[placeholderKey], 'g'), Date.now().toString());
197
- break;
198
- default:
199
- break;
200
- }
201
- });
202
- eventJsonContent = eventJsonContent.replace(new RegExp(constants_1.PLACEHOLDER.signal_event_data.data, 'g'), JSON.stringify(data));
203
- const jsonContent = JSON.parse(eventJsonContent);
204
- process.stdout.write(JSON.stringify(jsonContent) + '\n');
205
- });
206
- });
207
- function getPublisherType(publisher) {
208
- for (const [category, services] of Object.entries(constants_1.SIGNALS_PUBLISHERS_TYPE)) {
209
- if (services.includes(publisher)) {
210
- return category;
211
- }
212
- }
213
- return null;
214
- }
22
+ .action((publisher, event) => __awaiter(void 0, void 0, void 0, function* () {
23
+ const jsonContent = yield (0, signals_1.generate)(publisher, event);
24
+ process.stdout.write(JSON.stringify(jsonContent) + '\n');
25
+ }));
@@ -196,18 +196,21 @@ function getStandAloneTarget() {
196
196
  return tag;
197
197
  }))();
198
198
  const nameOpt = yield validateOptions(((name) => __awaiter(this, void 0, void 0, function* () {
199
- (0, index_1.info)();
200
- (0, index_1.warning)(`Skipping ${(0, ansi_colors_1.yellow)('--name')} option. Since AppSail name value supplied with the option is invalid`);
201
- (0, index_1.warning)('Name must contain only alphanumeric and hyphen');
202
- (0, index_1.info)();
203
- return name.match(constants_1.REGEX.appsail.name) ? name : false;
199
+ if (!name.match(constants_1.REGEX.appsail.name)) {
200
+ (0, index_1.info)();
201
+ (0, index_1.warning)(`Skipping ${(0, ansi_colors_1.yellow)('--name')} option. Since AppSail name value supplied with the option is invalid`);
202
+ (0, index_1.warning)('Name must contain only alphanumeric and hyphen');
203
+ (0, index_1.info)();
204
+ return false;
205
+ }
206
+ return name;
204
207
  })), 'name');
205
- const appSailName = yield (0, utils_1.getAppSailName)();
208
+ const appSailName = nameOpt ? nameOpt : yield (0, utils_1.getAppSailName)();
206
209
  if (typeof imgSource === 'string') {
207
210
  return {
208
211
  source: imgSource,
209
212
  runtime: 'custom',
210
- name: typeof nameOpt === 'boolean' ? appSailName : nameOpt,
213
+ name: appSailName,
211
214
  validity: {
212
215
  valid: true
213
216
  },
@@ -225,7 +228,7 @@ function getStandAloneTarget() {
225
228
  configJson.stack = configJson.stack.runtime;
226
229
  }
227
230
  return {
228
- name: typeof nameOpt === 'boolean' ? appSailName : nameOpt,
231
+ name: appSailName,
229
232
  runtime: 'catalyst',
230
233
  source: cwd,
231
234
  config: configJson,
@@ -122,7 +122,7 @@ function slateLogger() {
122
122
  deployTargets.forEach((slate) => {
123
123
  var _a, _b;
124
124
  (0, logger_1.labeled)(`Slate(${slate.name})`, 'Deploy is live!').SUCCESS();
125
- (0, logger_1.labeled)((0, ansi_colors_1.cyan)(`Build Url(${slate.name})`), `${urls_1.default.admin}/baas/${(0, project_1.getEnvId)()}/project/${(0, project_1.getProjectId)()}/${getEnvironmentType()}#/slate/app/${(_a = slate.details) === null || _a === void 0 ? void 0 : _a.id}/deployment/${(_b = slate.details) === null || _b === void 0 ? void 0 : _b.deployment_type_config.upcoming_build.deployment_id}/overview`).MESSAGE();
125
+ (0, logger_1.labeled)((0, ansi_colors_1.cyan)(`Build Url(${slate.name})`), `${urls_1.default.console}/baas/${(0, project_1.getEnvId)()}/project/${(0, project_1.getProjectId)()}/${getEnvironmentType()}#/slate/app/${(_a = slate.details) === null || _a === void 0 ? void 0 : _a.id}/deployment/${(_b = slate.details) === null || _b === void 0 ? void 0 : _b.deployment_type_config.upcoming_build.deployment_id}/overview`).MESSAGE();
126
126
  (0, logger_1.info)();
127
127
  });
128
128
  return deployTargets;
@@ -110,7 +110,7 @@ class AppSail {
110
110
  downloadJetty() {
111
111
  return __awaiter(this, void 0, void 0, function* () {
112
112
  const res = yield new api_1.default({
113
- origin: constants_1.ORIGIN.zohoCDN,
113
+ origin: constants_1.ORIGIN.zohoCDNUS,
114
114
  authNeeded: false,
115
115
  json: false,
116
116
  isExternal: true
@@ -35,7 +35,7 @@ class CodeDeck {
35
35
  }
36
36
  const res = yield new api_1.default(this.opts).get(`/catalyst-library/codelib/${manifestData['data.json']}`, {
37
37
  json: true,
38
- origin: constants_1.ORIGIN.zohoCDN,
38
+ origin: constants_1.ORIGIN.zohoCDNUS,
39
39
  headers: {
40
40
  'Cache-Control': 'no-cache'
41
41
  }
@@ -55,7 +55,7 @@ _CodeDeck_instances = new WeakSet(), _CodeDeck_manifest = function _CodeDeck_man
55
55
  return __awaiter(this, void 0, void 0, function* () {
56
56
  const res = yield new api_1.default(this.opts).get('/catalyst-library/codelib/config.json', {
57
57
  json: true,
58
- origin: constants_1.ORIGIN.zohoCDN,
58
+ origin: constants_1.ORIGIN.zohoCDNUS,
59
59
  headers: {
60
60
  'Cache-Control': 'no-cache'
61
61
  }
@@ -46,10 +46,15 @@ class Caller extends fn_execution_handler_1.FnExecutionHandler {
46
46
  throw new error_1.default('Data is not a valid JSON object', { exit: 1 });
47
47
  }
48
48
  if (this.fn.target.type === constants_1.FN_TYPE.event) {
49
- if (!('event_bus_details' in data) && !('events' in data)) {
50
- (0, index_1.info)('For event function kindly use event:generate command to generate the input json.');
51
- (0, index_1.info)('You can also provide event details as per documentation.');
52
- throw new error_1.default('Event bus details missing', { exit: 1, skipHelp: true });
49
+ if (!('event_bus_details' in data)) {
50
+ if (!('events' in data)) {
51
+ (0, index_1.info)('For event function kindly use signals:generate command to generate the input json.');
52
+ (0, index_1.info)('You can also provide event details as per documentation.');
53
+ throw new error_1.default('Event details missing', {
54
+ exit: 1,
55
+ skipHelp: true
56
+ });
57
+ }
53
58
  }
54
59
  else {
55
60
  (0, index_1.warning)('Since the event:generate command is being deprecated and being sunsetted in future releases. Please use signals:generate command here after to get the event details.');
@@ -24,7 +24,7 @@ const common_1 = require("../../util/common");
24
24
  const languages_1 = __importDefault(require("./languages"));
25
25
  const catalyst_details_1 = __importDefault(require("../../../endpoints/lib/catalyst-details"));
26
26
  const path_1 = require("path");
27
- const event_generate_1 = require("../../../event_generate");
27
+ const signals_1 = require("../../../signals");
28
28
  const config_1 = require("../../../util_modules/config");
29
29
  const cliq_1 = __importDefault(require("../../../event_generate/integration/cliq"));
30
30
  const error_1 = __importDefault(require("../../../error"));
@@ -112,7 +112,7 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
112
112
  break;
113
113
  }
114
114
  case constants_1.FN_TYPE.event: {
115
- const jsonContent = yield (0, event_generate_1.generate)('cache', 'put');
115
+ const jsonContent = yield (0, signals_1.generate)('cache', 'cache_item_created');
116
116
  inputsJson.test_event_cache_put = jsonContent;
117
117
  break;
118
118
  }
@@ -105,7 +105,7 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
105
105
  let projectId = null;
106
106
  const userActionError = yield new Promise((res, rej) => __awaiter(void 0, void 0, void 0, function* () {
107
107
  const callbackPort = yield port_resolver_1.default.getFreePort(3000, 10, false);
108
- const accessUrl = new URL(`/baas/${(0, project_1.getEnvId)()}/index#/?port=${callbackPort}&type=cli`, `${constants_1.ORIGIN.admin}`);
108
+ const accessUrl = new URL(`${constants_1.ORIGIN.console}/baas/${(0, project_1.getEnvId)()}/index#/?port=${callbackPort}&type=cli`);
109
109
  const server = (0, http_1.createServer)((req, resp) => __awaiter(void 0, void 0, void 0, function* () {
110
110
  var _c, _d;
111
111
  try {
@@ -54,16 +54,22 @@ class SlaveManager extends fn_execution_handler_1.FnExecutionHandler {
54
54
  data = { data };
55
55
  break;
56
56
  }
57
- case constants_1.FN_TYPE.event:
57
+ case constants_1.FN_TYPE.event: {
58
58
  if (!('event_bus_details' in data)) {
59
- (0, logger_1.info)('For event function kindly use event:generate command to generate the input json.');
60
- (0, logger_1.info)('You can also provide event details as per documentation.');
61
- return new error_1.default('Event bus details missing', {
62
- exit: 1,
63
- skipHelp: true
64
- });
59
+ if (!('events' in data)) {
60
+ (0, logger_1.info)('For event function kindly use signals:generate command to generate the input json.');
61
+ (0, logger_1.info)('You can also provide event details as per documentation.');
62
+ throw new error_1.default('Event details missing', {
63
+ exit: 1,
64
+ skipHelp: true
65
+ });
66
+ }
67
+ }
68
+ else {
69
+ (0, logger_1.warning)('Since the event:generate command is being deprecated and being sunsetted in future releases. Please use signals:generate command here after to get the event details.');
65
70
  }
66
71
  break;
72
+ }
67
73
  }
68
74
  }
69
75
  else {
@@ -77,7 +83,7 @@ class SlaveManager extends fn_execution_handler_1.FnExecutionHandler {
77
83
  }
78
84
  catch (e) {
79
85
  (0, logger_1.info)('the input must be in the form of json or a path to a file containing json data.');
80
- return new error_1.default('Invalid input');
86
+ return new error_1.default('Invalid input: ' + e);
81
87
  }
82
88
  return (() => __awaiter(this, void 0, void 0, function* () {
83
89
  var _b, _c, _d, _e, _f, _g, _h, _j, _k;
@@ -0,0 +1,2 @@
1
+ import { SIGNALS_API_NAMES } from '../util_modules/constants';
2
+ export declare function generate(publisher: keyof typeof SIGNALS_API_NAMES, event: string): Promise<Record<string, unknown>>;
@@ -0,0 +1,208 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.generate = void 0;
39
+ const ansi_colors_1 = require("ansi-colors");
40
+ const error_1 = __importDefault(require("../error"));
41
+ const constants_1 = require("../util_modules/constants");
42
+ const fs_1 = require("../util_modules/fs");
43
+ const logger_1 = require("../util_modules/logger");
44
+ const project_1 = require("../util_modules/project");
45
+ const js_1 = require("../util_modules/js");
46
+ const option_1 = require("../util_modules/option");
47
+ function generate(publisher, event) {
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ var _a;
50
+ const unknownArgs = (0, option_1.getUnknownOpts)([]);
51
+ if (unknownArgs.length % 2 !== 0) {
52
+ throw new error_1.default('Unknown options are not provided as key value pairs', {
53
+ exit: 1,
54
+ errorId: 'IDX-1',
55
+ arg: [(0, ansi_colors_1.bold)(publisher), (0, ansi_colors_1.bold)(event), (0, ansi_colors_1.bold)('--key value')]
56
+ });
57
+ }
58
+ const remotePublisherName = constants_1.SIGNALS_PUBLISHERS[publisher];
59
+ if (remotePublisherName === undefined) {
60
+ throw new error_1.default('Invalid publisher service', {
61
+ exit: 1,
62
+ errorId: 'IDX-2',
63
+ arg: [
64
+ (0, ansi_colors_1.bold)(Object.keys(constants_1.SIGNALS_PUBLISHERS)
65
+ .map((src) => '* ' + src)
66
+ .join('\n'))
67
+ ]
68
+ });
69
+ }
70
+ if (constants_1.SIGNALS_API_NAMES[remotePublisherName] === undefined) {
71
+ throw new error_1.default('Signal reference is not found for the publisher service provided', {
72
+ exit: 2
73
+ });
74
+ }
75
+ let eventJsonContent = yield fs_1.ASYNC.readFile(constants_1.TEMPLATE.signal_event_data);
76
+ if (eventJsonContent === undefined) {
77
+ throw new error_1.default('Signal template json is undefined', { exit: 2 });
78
+ }
79
+ const eventDataPlaceHolder = constants_1.PLACEHOLDER.signal_event_data;
80
+ const optionMap = unknownArgs.reduce((previousValue, currentValue, currentIndex, optionArr) => {
81
+ if (currentIndex % 2 === 0) {
82
+ if (!currentValue.startsWith('--') &&
83
+ currentValue !== '-e' &&
84
+ currentValue !== '-rid' &&
85
+ currentValue !== '--verbose') {
86
+ const fault = unknownArgs === null || unknownArgs === void 0 ? void 0 : unknownArgs.map((arg) => {
87
+ if (arg === currentValue) {
88
+ return (0, ansi_colors_1.red)(arg);
89
+ }
90
+ return arg;
91
+ }).join(' ');
92
+ throw new error_1.default('Invalid option format detected', {
93
+ exit: 1,
94
+ errorId: 'IDX-3',
95
+ arg: [(0, ansi_colors_1.italic)(fault), (0, ansi_colors_1.bold)('--<option> <value>')]
96
+ });
97
+ }
98
+ previousValue[currentValue.slice(2)] = optionArr[currentIndex + 1];
99
+ }
100
+ return previousValue;
101
+ }, {});
102
+ let data = {};
103
+ if (publisher !== 'custom') {
104
+ const publisherModule = yield (_a = '../event_generate/' + (publisher === 'authentication' ? 'user' : publisher), Promise.resolve().then(() => __importStar(require(_a))));
105
+ data = yield publisherModule.getData(optionMap);
106
+ if (publisher === 'datastore') {
107
+ data = Object.assign(Object.assign({}, data), { table_details: {
108
+ table_id: publisherModule.sourceId,
109
+ table_name: 'Default'
110
+ } });
111
+ }
112
+ if (publisher === 'authentication' && event !== 'user_signedup') {
113
+ data = data.user_details;
114
+ }
115
+ }
116
+ Object.keys(eventDataPlaceHolder).forEach((placeholderKey) => {
117
+ switch (placeholderKey) {
118
+ case 'version':
119
+ eventJsonContent = eventJsonContent === null || eventJsonContent === void 0 ? void 0 : eventJsonContent.replace(new RegExp(eventDataPlaceHolder[placeholderKey], 'g'), 1 + '');
120
+ break;
121
+ case 'org_id':
122
+ eventJsonContent = eventJsonContent === null || eventJsonContent === void 0 ? void 0 : eventJsonContent.replace(new RegExp(eventDataPlaceHolder[placeholderKey], 'g'), (0, project_1.getEnvId)() + '');
123
+ break;
124
+ case 'project_id':
125
+ eventJsonContent = eventJsonContent === null || eventJsonContent === void 0 ? void 0 : eventJsonContent.replace(new RegExp(eventDataPlaceHolder[placeholderKey], 'g'), (0, project_1.getProjectId)() + '');
126
+ break;
127
+ case 'project_name':
128
+ eventJsonContent = eventJsonContent === null || eventJsonContent === void 0 ? void 0 : eventJsonContent.replace(new RegExp(eventDataPlaceHolder[placeholderKey], 'g'), (0, project_1.getProjectName)() + '');
129
+ break;
130
+ case 'environment':
131
+ eventJsonContent = eventJsonContent === null || eventJsonContent === void 0 ? void 0 : eventJsonContent.replace(new RegExp(eventDataPlaceHolder[placeholderKey], 'g'), (0, project_1.getEnvName)() + '');
132
+ break;
133
+ case 'rule_id':
134
+ eventJsonContent = eventJsonContent === null || eventJsonContent === void 0 ? void 0 : eventJsonContent.replace(new RegExp(eventDataPlaceHolder[placeholderKey], 'g'), js_1.JS.randomNumber(18) + '');
135
+ break;
136
+ case 'uuid':
137
+ eventJsonContent = eventJsonContent === null || eventJsonContent === void 0 ? void 0 : eventJsonContent.replace(new RegExp(eventDataPlaceHolder[placeholderKey], 'g'), js_1.JS.randomString(8) +
138
+ '-' +
139
+ js_1.JS.randomString(4) +
140
+ '-' +
141
+ js_1.JS.randomString(4) +
142
+ '-' +
143
+ js_1.JS.randomString(4) +
144
+ '-' +
145
+ js_1.JS.randomString(11));
146
+ break;
147
+ case 'target_id':
148
+ eventJsonContent = eventJsonContent === null || eventJsonContent === void 0 ? void 0 : eventJsonContent.replace(new RegExp(eventDataPlaceHolder[placeholderKey], 'g'), js_1.JS.randomNumber(8) + '');
149
+ break;
150
+ case 'signal_id':
151
+ eventJsonContent = eventJsonContent === null || eventJsonContent === void 0 ? void 0 : eventJsonContent.replace(new RegExp(eventDataPlaceHolder[placeholderKey], 'g'), js_1.JS.randomNumber(17) + '');
152
+ break;
153
+ case 'signal_api_name':
154
+ if (publisher !== 'custom') {
155
+ const eventRefArr = constants_1.SIGNALS_API_NAMES[remotePublisherName];
156
+ const remoteRefevent = event;
157
+ (0, logger_1.debug)(`event name provided is : ${remoteRefevent}`);
158
+ const indexOfevent = eventRefArr.indexOf(remoteRefevent);
159
+ if (indexOfevent < 0) {
160
+ const availableEvents = eventRefArr
161
+ .map((act) => {
162
+ return '* ' + act;
163
+ })
164
+ .join('\n');
165
+ throw new error_1.default('Event name incompatible with the publisher service: ' + eventRefArr, {
166
+ exit: 1,
167
+ errorId: 'IDX-4',
168
+ arg: [
169
+ (0, ansi_colors_1.bold)(event),
170
+ ansi_colors_1.bold.red('X'),
171
+ (0, ansi_colors_1.bold)(publisher),
172
+ (0, ansi_colors_1.bold)(availableEvents)
173
+ ]
174
+ });
175
+ }
176
+ event = constants_1.SIGNALS_API_NAMES[remotePublisherName][indexOfevent];
177
+ }
178
+ eventJsonContent = eventJsonContent === null || eventJsonContent === void 0 ? void 0 : eventJsonContent.replace(new RegExp(eventDataPlaceHolder[placeholderKey], 'g'), event);
179
+ break;
180
+ case 'attempt':
181
+ eventJsonContent = eventJsonContent === null || eventJsonContent === void 0 ? void 0 : eventJsonContent.replace(new RegExp(eventDataPlaceHolder[placeholderKey], 'g'), 1 + '');
182
+ break;
183
+ case 'source':
184
+ const publisherDetails = `publisher_id:${js_1.JS.randomNumber(17)}` +
185
+ `/service:${getPublisherType(publisher)}${publisher === 'custom' ? '' : publisher + '/account:' + js_1.JS.randomNumber(8)}`;
186
+ eventJsonContent = eventJsonContent === null || eventJsonContent === void 0 ? void 0 : eventJsonContent.replace(new RegExp(eventDataPlaceHolder[placeholderKey], 'g'), publisherDetails);
187
+ break;
188
+ case 'time_in_ms':
189
+ eventJsonContent = eventJsonContent === null || eventJsonContent === void 0 ? void 0 : eventJsonContent.replace(new RegExp(eventDataPlaceHolder[placeholderKey], 'g'), Date.now().toString());
190
+ break;
191
+ default:
192
+ break;
193
+ }
194
+ });
195
+ eventJsonContent = eventJsonContent.replace(new RegExp(constants_1.PLACEHOLDER.signal_event_data.data, 'g'), JSON.stringify(data));
196
+ const jsonContent = JSON.parse(eventJsonContent);
197
+ return jsonContent;
198
+ });
199
+ }
200
+ exports.generate = generate;
201
+ function getPublisherType(publisher) {
202
+ for (const [category, services] of Object.entries(constants_1.SIGNALS_PUBLISHERS_TYPE)) {
203
+ if (services.includes(publisher)) {
204
+ return category;
205
+ }
206
+ }
207
+ return null;
208
+ }
@@ -9,6 +9,7 @@ export default class URL {
9
9
  private static readonly _stratusSuffixBase;
10
10
  private static readonly _zohoCDNBase;
11
11
  private static readonly _contacts;
12
+ static get zohoCDNUS(): string;
12
13
  static get zohoCDN(): string;
13
14
  static get auth(): string;
14
15
  static get iamPortal(): string;
@@ -7,6 +7,9 @@ const env_js_1 = require("../../env.js");
7
7
  const dc_js_1 = require("../../dc.js");
8
8
  const dc_type_js_1 = __importDefault(require("./dc-type.js"));
9
9
  class URL {
10
+ static get zohoCDNUS() {
11
+ return (0, env_js_1.envOverride)('ZOHO_CDN', URL._zohoCDNBase);
12
+ }
10
13
  static get zohoCDN() {
11
14
  return (0, env_js_1.envOverride)('ZOHO_CDN', mapDataCenterUrl(URL._zohoCDNBase));
12
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zcatalyst-cli",
3
- "version": "1.22.1",
3
+ "version": "1.22.2",
4
4
  "description": "Command Line Tool for CATALYST",
5
5
  "main": "./lib/index.js",
6
6
  "bin": {
@@ -24,9 +24,7 @@ public class {{_CLASS_}} implements CatalystEventHandler{
24
24
 
25
25
  Object rawData = paramEventRequest.getRawData();
26
26
  LOGGER.log(Level.SEVERE,"Raw Data is "+rawData.toString());
27
-
28
- ZCCache.getInstance().putCacheValue("{{_CLASS_}}", "Working", 1l);
29
- LOGGER.log(Level.SEVERE,"Project Details "+paramEventRequest.getProjectDetails().toString());
27
+
30
28
  }
31
29
  catch (Exception e) {
32
30
  LOGGER.log(Level.SEVERE,"Exception in {{_CLASS_}} Function",e);