zcatalyst-cli 1.18.0-beta.9 → 1.19.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.
Files changed (148) hide show
  1. package/README.md +11 -6
  2. package/docs/commands/signals/generate/index.toml +19 -0
  3. package/docs/commands/slate/unlink.toml +9 -0
  4. package/docs/endpoints/lib/env.toml +3 -1
  5. package/docs/endpoints/lib/slate.toml +3 -0
  6. package/docs/serve/server/lib/slate/index.toml +14 -0
  7. package/docs/slate-utils.toml +4 -0
  8. package/docs/util_modules/config/lib/slate.toml +4 -0
  9. package/lib/archiver.js +18 -9
  10. package/lib/authentication/login.js +6 -5
  11. package/lib/code-deck.js +5 -6
  12. package/lib/command_needs/auth.js +1 -1
  13. package/lib/command_needs/rc.js +40 -3
  14. package/lib/commands/codelib/install.js +1 -0
  15. package/lib/commands/deploy/index.js +4 -0
  16. package/lib/commands/deploy/slate.js +58 -0
  17. package/lib/commands/event/generate/index.js +8 -2
  18. package/lib/commands/index.js +3 -3
  19. package/lib/commands/init.js +0 -10
  20. package/lib/commands/signals/generate/index.js +214 -0
  21. package/lib/commands/slate/create.js +59 -0
  22. package/lib/commands/slate/link.js +59 -0
  23. package/lib/commands/slate/unlink.js +75 -0
  24. package/lib/commands/zest/generate/index.js +1 -6
  25. package/lib/config-store.js +2 -1
  26. package/lib/deploy/features/index.js +3 -0
  27. package/lib/deploy/features/slate.js +123 -0
  28. package/lib/endpoints/index.js +8 -1
  29. package/lib/endpoints/lib/env.js +2 -1
  30. package/lib/endpoints/lib/sdk.js +2 -2
  31. package/lib/endpoints/lib/slate.js +107 -0
  32. package/lib/event_generate/cache.js +35 -33
  33. package/lib/event_generate/custom.js +15 -19
  34. package/lib/event_generate/datastore.js +60 -56
  35. package/lib/event_generate/filestore.js +51 -47
  36. package/lib/event_generate/github.js +19 -18
  37. package/lib/event_generate/stratus.js +52 -38
  38. package/lib/event_generate/user.js +33 -29
  39. package/lib/event_generate/webapp.js +33 -32
  40. package/lib/fn-utils/lib/common.js +1 -1
  41. package/lib/iac/status/deploy.js +1 -5
  42. package/lib/index.js +1 -1
  43. package/lib/init/features/appsail/index.js +3 -4
  44. package/lib/init/features/index.js +13 -1
  45. package/lib/init/features/project.js +1 -1
  46. package/lib/init/features/slate/index.js +313 -0
  47. package/lib/internal/api.js +1 -1
  48. package/lib/internal/command.js +10 -6
  49. package/lib/port-resolver.js +7 -0
  50. package/lib/prompt/index.js +22 -6
  51. package/lib/prompt/types/file-path.js +10 -7
  52. package/lib/serve/features/index.js +8 -1
  53. package/lib/serve/features/slate.js +47 -0
  54. package/lib/serve/server/index.js +61 -1
  55. package/lib/serve/server/lib/appsail/index.js +1 -1
  56. package/lib/serve/server/lib/master/appsail.js +7 -2
  57. package/lib/serve/server/lib/master/index.js +25 -21
  58. package/lib/serve/server/lib/master/slate.js +45 -0
  59. package/lib/serve/server/lib/master/utils.js +9 -3
  60. package/lib/serve/server/lib/slate/index.js +115 -0
  61. package/lib/serve/server/lib/slate/static-server.js +194 -0
  62. package/lib/serve/server/lib/web_client/server.js +2 -1
  63. package/lib/shell/dependencies/local-function.js +1 -1
  64. package/lib/slate-utils.js +212 -0
  65. package/lib/util_modules/config/index.js +3 -1
  66. package/lib/util_modules/config/lib/slate.js +98 -0
  67. package/lib/util_modules/constants/index.js +7 -1
  68. package/lib/util_modules/constants/lib/cliq-handlers.js +18 -10
  69. package/lib/util_modules/constants/lib/dc-type.js +8 -0
  70. package/lib/util_modules/constants/lib/default.js +4 -0
  71. package/lib/util_modules/constants/lib/file-names.js +7 -1
  72. package/lib/util_modules/constants/lib/folder-names.js +1 -0
  73. package/lib/util_modules/constants/lib/placeholders.js +18 -1
  74. package/lib/util_modules/constants/lib/scopes.js +1 -6
  75. package/lib/util_modules/constants/lib/signals-api-names.js +19 -0
  76. package/lib/util_modules/constants/lib/signals-publishers-type.js +27 -0
  77. package/lib/util_modules/constants/lib/signals-publishers.js +10 -0
  78. package/lib/util_modules/constants/lib/template.js +1 -0
  79. package/lib/util_modules/context-help.js +2 -2
  80. package/lib/util_modules/fs/lib/async.js +14 -3
  81. package/lib/util_modules/fs/lib/sync.js +6 -1
  82. package/lib/util_modules/parser/toml.js +20 -5
  83. package/package.json +3 -3
  84. package/templates/event/integ/cliq/bot/action_handler.json +13 -4
  85. package/templates/event/integ/cliq/bot/call_handler.json +41 -0
  86. package/templates/event/integ/cliq/bot/context_handler.json +11 -3
  87. package/templates/event/integ/cliq/bot/incomingwebhook_handler.json +11 -3
  88. package/templates/event/integ/cliq/bot/mention_handler.json +12 -4
  89. package/templates/event/integ/cliq/bot/message_handler.json +13 -4
  90. package/templates/event/integ/cliq/bot/participation_handler.json +13 -3
  91. package/templates/event/integ/cliq/bot/welcome_handler.json +12 -8
  92. package/templates/event/integ/cliq/command/execution_handler.json +12 -3
  93. package/templates/event/integ/cliq/command/suggestion_handler.json +18 -4
  94. package/templates/event/integ/cliq/{installation → extension}/installation_handler.json +13 -4
  95. package/templates/event/integ/cliq/{installation → extension}/installation_validator.json +13 -5
  96. package/templates/event/integ/cliq/extension/uninstallation_handler.json +37 -0
  97. package/templates/event/integ/cliq/function/button_handler.json +13 -5
  98. package/templates/event/integ/cliq/function/form_change_handler.json +9 -3
  99. package/templates/event/integ/cliq/function/form_handler.json +11 -3
  100. package/templates/event/integ/cliq/function/form_values_handler.json +9 -3
  101. package/templates/event/integ/cliq/function/form_view_handler.json +26 -0
  102. package/templates/event/integ/cliq/function/widget_button_handler.json +14 -5
  103. package/templates/event/integ/cliq/link_preview/action_handler.json +54 -0
  104. package/templates/event/integ/cliq/link_preview/after_send_handler.json +47 -0
  105. package/templates/event/integ/cliq/link_preview/menu_handler.json +47 -0
  106. package/templates/event/integ/cliq/link_preview/preview_handler.json +47 -0
  107. package/templates/event/integ/cliq/messageaction/execution_handler.json +11 -3
  108. package/templates/event/integ/cliq/widget/view_handler.json +12 -4
  109. package/templates/event/signals.json +26 -0
  110. package/templates/init/client/react/react_js/template/src/index.js +3 -3
  111. package/templates/init/client/react/react_ts/template/src/index.tsx +3 -3
  112. package/templates/init/client/react/react_ts/template.json +3 -3
  113. package/templates/init/functions/java/event/sample.java +4 -0
  114. package/templates/init/functions/java/integ/cliq/com/handlers/BotHandler.java +29 -23
  115. package/templates/init/functions/java/integ/cliq/com/handlers/CommandHandler.java +14 -17
  116. package/templates/init/functions/java/integ/cliq/com/handlers/ExtensionHandler.java +41 -0
  117. package/templates/init/functions/java/integ/cliq/com/handlers/FunctionHandler.java +74 -22
  118. package/templates/init/functions/java/integ/cliq/com/handlers/LinkPreviewHandler.java +108 -0
  119. package/templates/init/functions/java/integ/cliq/com/handlers/MessageActionHandler.java +6 -8
  120. package/templates/init/functions/java/integ/cliq/sample.java +10 -0
  121. package/templates/init/functions/node/aio/package.json +1 -1
  122. package/templates/init/functions/node/bio/package.json +1 -1
  123. package/templates/init/functions/node/cron/package.json +1 -1
  124. package/templates/init/functions/node/event/package.json +1 -1
  125. package/templates/init/functions/node/event/sample.js +1 -0
  126. package/templates/init/functions/node/event/types/event.d.ts +7 -0
  127. package/templates/init/functions/node/integ/cliq/handlers/bot-handler.js +4 -0
  128. package/templates/init/functions/node/integ/cliq/handlers/command-handler.js +3 -5
  129. package/templates/init/functions/node/integ/cliq/handlers/{installation-validator.js → extension-handler.js} +20 -3
  130. package/templates/init/functions/node/integ/cliq/handlers/function-handler.js +42 -0
  131. package/templates/init/functions/node/integ/cliq/handlers/link-preview-handler.js +73 -0
  132. package/templates/init/functions/node/integ/cliq/package.json +1 -1
  133. package/templates/init/functions/node/integ/convokraft/package.json +1 -1
  134. package/templates/init/functions/node/job/package.json +1 -1
  135. package/templates/init/functions/python/event/sample.py +9 -5
  136. package/templates/init/functions/python/integ/cliq/handlers/bot_handler.py +13 -3
  137. package/templates/init/functions/python/integ/cliq/handlers/command_handler.py +7 -7
  138. package/templates/init/functions/python/integ/cliq/handlers/extension_handler.py +25 -0
  139. package/templates/init/functions/python/integ/cliq/handlers/function_handler.py +54 -10
  140. package/templates/init/functions/python/integ/cliq/handlers/link_preview_handler.py +76 -0
  141. package/templates/init/functions/python/integ/cliq/handlers/widget_handler.py +10 -9
  142. package/templates/init/functions/python/integ/cliq/sample.py +2 -2
  143. package/templates/init.txt +2 -1
  144. package/templates/init/functions/java/integ/cliq/com/handlers/InstallationHandler.java +0 -20
  145. package/templates/init/functions/java/integ/cliq/com/handlers/InstallationValidator.java +0 -22
  146. package/templates/init/functions/node/integ/cliq/handlers/installation-handler.js +0 -15
  147. package/templates/init/functions/python/integ/cliq/handlers/installation_handler.py +0 -12
  148. package/templates/init/functions/python/integ/cliq/handlers/installation_validator.py +0 -16
@@ -0,0 +1,107 @@
1
+ 'use strict';
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const error_1 = __importDefault(require("../../error"));
16
+ const api_1 = __importDefault(require("../../internal/api"));
17
+ const logger_1 = require("../../util_modules/logger");
18
+ const ansi_colors_1 = require("ansi-colors");
19
+ const config_store_1 = __importDefault(require("../../config-store"));
20
+ class Slate {
21
+ constructor(projectId, opts) {
22
+ this.opts = opts;
23
+ this.projectId = projectId;
24
+ }
25
+ getFrameworks() {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ try {
28
+ const response = yield new api_1.default(this.opts).get('/slate/v1/frameworks', {
29
+ log: {
30
+ awaitingSpinner: 'Fetching frameworks from the server ...'
31
+ }
32
+ });
33
+ if (response.body && response.body.data) {
34
+ return response.body.data;
35
+ }
36
+ }
37
+ catch (err) {
38
+ if (err.status === 404) {
39
+ throw new error_1.default('API Error: Slate not accessible', {
40
+ exit: 1,
41
+ errorId: 'SLDC-1',
42
+ arg: [(0, ansi_colors_1.bold)(config_store_1.default.get('active_dc') + ''), (0, ansi_colors_1.bold)('support@zohocatalyst.com')]
43
+ });
44
+ }
45
+ else {
46
+ throw err;
47
+ }
48
+ }
49
+ throw new error_1.default('Error while fetching the frameworks', { exit: 2 });
50
+ });
51
+ }
52
+ getAllApps() {
53
+ return __awaiter(this, void 0, void 0, function* () {
54
+ const response = yield new api_1.default(this.opts).get(`/slate/v1/project/${this.projectId}/app`, {
55
+ log: {
56
+ awaitingSpinner: 'Fetching slate apps'
57
+ }
58
+ });
59
+ if (response.body && response.body.data) {
60
+ return response.body.data;
61
+ }
62
+ throw new error_1.default('Error while fetching the frameworks', { exit: 2 });
63
+ });
64
+ }
65
+ downloadTemplate() {
66
+ return __awaiter(this, void 0, void 0, function* () {
67
+ this.opts.origin = 'https://codeload.github.com';
68
+ this.opts.authNeeded = false;
69
+ const response = yield new api_1.default(Object.assign(Object.assign({}, this.opts), { isExternal: true })).get(`/catalystbyzoho/slate/zip/main`, {
70
+ log: {
71
+ awaitingSpinner: 'Download template from github ...'
72
+ },
73
+ encoding: null
74
+ });
75
+ if (response.body) {
76
+ return response.body;
77
+ }
78
+ throw new error_1.default('Error while downloading the template', { exit: 2 });
79
+ });
80
+ }
81
+ deploy(sourceStream, contentLength, appName, deployId, appId, config, msg) {
82
+ return __awaiter(this, void 0, void 0, function* () {
83
+ const formData = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ file: sourceStream }, (appId && { app_id: appId })), (deployId && { build_id: deployId })), (appId || deployId ? {} : { name: appName })), (config && { configuration: config })), (msg && { message: msg }));
84
+ const res = yield new api_1.default(this.opts).post(`/slate/v1/project/${this.projectId}/app/upload`, {
85
+ formData,
86
+ json: false,
87
+ log: {
88
+ uploadProgress: {
89
+ title: `Slate[${appName}]`,
90
+ total: contentLength,
91
+ progressType: 'upload'
92
+ },
93
+ stream: sourceStream,
94
+ awaitingSpinner: 'deploying slate'
95
+ }
96
+ });
97
+ if (res.body && res.body.data) {
98
+ return res.body.data;
99
+ }
100
+ (0, logger_1.debug)('deploy slate response from server : ' + res.body);
101
+ throw new error_1.default('Server Error: Unexpected Response from server.', {
102
+ exit: 2
103
+ });
104
+ });
105
+ }
106
+ }
107
+ exports.default = Slate;
@@ -12,42 +12,44 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.getData = exports.sourceId = void 0;
15
16
  const ansi_colors_1 = require("ansi-colors");
16
17
  const moment_1 = __importDefault(require("moment"));
17
18
  const endpoints_1 = require("../endpoints");
18
19
  const error_1 = __importDefault(require("../error"));
19
- const constants_1 = require("../util_modules/constants");
20
20
  const js_1 = require("../util_modules/js");
21
- const project_1 = require("../util_modules/project");
22
- exports.default = (eventJson, options = {}) => __awaiter(void 0, void 0, void 0, function* () {
23
- const segmentId = options.segment;
24
- const allSegments = (yield (yield (0, endpoints_1.cacheAPI)()).getAllSegments());
25
- const selectedSegment = segmentId !== undefined
26
- ? allSegments.find((segment) => segment.segment_name === segmentId || segment.id + '' === segmentId)
27
- : allSegments.find((segment) => segment.segment_name === 'Default');
28
- if (selectedSegment === undefined) {
29
- if (!allSegments.find((segment) => segment.segment_name === 'Default')) {
30
- throw new error_1.default('Default segment is missing !!!', { exit: 2 });
21
+ exports.sourceId = 'NULL';
22
+ function getData(options = {}) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ const segmentId = options.segment;
25
+ const allSegments = (yield (yield (0, endpoints_1.cacheAPI)()).getAllSegments());
26
+ const selectedSegment = segmentId !== undefined
27
+ ? allSegments.find((segment) => segment.segment_name === segmentId || segment.id + '' === segmentId)
28
+ : allSegments.find((segment) => segment.segment_name === 'Default');
29
+ if (selectedSegment === undefined) {
30
+ if (!allSegments.find((segment) => segment.segment_name === 'Default')) {
31
+ throw new error_1.default('Default segment is missing !!!', { exit: 2 });
32
+ }
33
+ throw new error_1.default('Unknown segment identifier', {
34
+ exit: 1,
35
+ errorId: 'CACHE-1',
36
+ arg: [(0, ansi_colors_1.bold)(segmentId || ''), (0, ansi_colors_1.bold)('--segment')]
37
+ });
31
38
  }
32
- throw new error_1.default('Unknown segment identifier', {
33
- exit: 1,
34
- errorId: 'CACHE-1',
35
- arg: [(0, ansi_colors_1.bold)(segmentId || ''), (0, ansi_colors_1.bold)('--segment')]
36
- });
37
- }
38
- eventJson = eventJson.replace(new RegExp(constants_1.PLACEHOLDER.event_data.source_id, 'g'), selectedSegment.id);
39
- const expiryInHours = js_1.JS.random(1, 48);
40
- const data = {
41
- cache_name: js_1.JS.randomString(js_1.JS.random(5, 10)),
42
- cache_value: js_1.JS.randomString(10),
43
- project_details: {
44
- id: (0, project_1.getProjectId)(),
45
- project_name: (0, project_1.getProjectName)()
46
- },
47
- segment_details: selectedSegment,
48
- expiry_in_hours: expiryInHours,
49
- expires_in: (0, moment_1.default)(moment_1.default.now() + expiryInHours * 60 * 60 * 1000).format('MMM DD, YYYY hh:mm A')
50
- };
51
- eventJson = eventJson.replace(new RegExp(constants_1.PLACEHOLDER.event_data.rule_id, 'g'), 'NULL');
52
- return eventJson.replace(new RegExp(constants_1.PLACEHOLDER.event_data.data, 'g'), JSON.stringify(data));
53
- });
39
+ exports.sourceId = selectedSegment.id;
40
+ const expiryInHours = js_1.JS.random(1, 48);
41
+ return {
42
+ cache_name: js_1.JS.randomString(js_1.JS.random(5, 10)),
43
+ cache_value: js_1.JS.randomString(10),
44
+ project_details: selectedSegment.project_details,
45
+ segment_details: {
46
+ segment_name: selectedSegment.segment_name,
47
+ id: selectedSegment.id
48
+ },
49
+ expiry_in_hours: expiryInHours,
50
+ expires_in: (0, moment_1.default)(moment_1.default.now() + expiryInHours * 60 * 60 * 1000).format('MMM DD, YYYY hh:mm A'),
51
+ ttl_in_milliseconds: expiryInHours * 60 * 60 * 1000 + ''
52
+ };
53
+ });
54
+ }
55
+ exports.getData = getData;
@@ -12,25 +12,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.getRuleId = void 0;
15
16
  const ansi_colors_1 = require("ansi-colors");
16
17
  const error_1 = __importDefault(require("../error"));
17
- const constants_1 = require("../util_modules/constants");
18
- const js_1 = require("../util_modules/js");
19
18
  const option_1 = require("../util_modules/option");
20
- exports.default = (eventJson, options = {}) => __awaiter(void 0, void 0, void 0, function* () {
21
- let data = options.payload;
22
- if (data === undefined) {
23
- data = js_1.JS.randomString(15);
24
- }
25
- eventJson = eventJson.replace(new RegExp(constants_1.PLACEHOLDER.event_data.data, 'g'), JSON.stringify(data));
26
- const ruleId = (0, option_1.getOptionValue)('ruleId', false);
27
- if (!ruleId) {
28
- throw new error_1.default('no rule-id provided', {
29
- exit: 1,
30
- errorId: 'CUSTOM-1',
31
- arg: [(0, ansi_colors_1.bold)('-rid'), (0, ansi_colors_1.bold)('--rule-id')]
32
- });
33
- }
34
- eventJson = eventJson.replace(new RegExp(constants_1.PLACEHOLDER.event_data.source_id, 'g'), 'NULL');
35
- return eventJson.replace(new RegExp(constants_1.PLACEHOLDER.event_data.rule_id, 'g'), ruleId);
36
- });
19
+ function getRuleId() {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ const ruleId = (0, option_1.getOptionValue)('ruleId', false);
22
+ if (!ruleId) {
23
+ throw new error_1.default('no rule-id provided', {
24
+ exit: 1,
25
+ errorId: 'CUSTOM-1',
26
+ arg: [(0, ansi_colors_1.bold)('-rid'), (0, ansi_colors_1.bold)('--rule-id')]
27
+ });
28
+ }
29
+ return ruleId;
30
+ });
31
+ }
32
+ exports.getRuleId = getRuleId;
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.getData = exports.sourceId = void 0;
15
16
  const ansi_colors_1 = require("ansi-colors");
16
17
  const moment_1 = __importDefault(require("moment"));
17
18
  const endpoints_1 = require("../endpoints");
@@ -19,63 +20,66 @@ const error_1 = __importDefault(require("../error"));
19
20
  const constants_1 = require("../util_modules/constants");
20
21
  const js_1 = require("../util_modules/js");
21
22
  const logger_1 = require("../util_modules/logger");
22
- exports.default = (eventJson, options = {}) => __awaiter(void 0, void 0, void 0, function* () {
23
- const tableId = options.table;
24
- let columnDetails = constants_1.DEFAULT.datastore.column_details;
25
- if (tableId !== undefined) {
26
- columnDetails = (yield (yield (0, endpoints_1.datastoreAPI)()).getColumnDetails(tableId).catch((err) => {
27
- if (err.status && err.status === 404) {
28
- throw new error_1.default('Invalid table identifier', {
29
- exit: 1,
30
- errorId: 'DSTORE-1',
31
- arg: [(0, ansi_colors_1.bold)(tableId), (0, ansi_colors_1.bold)('--table')]
23
+ exports.sourceId = 'NULL';
24
+ function getData(options = {}) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ const tableId = options.table;
27
+ let columnDetails = constants_1.DEFAULT.datastore.column_details;
28
+ if (tableId !== undefined) {
29
+ columnDetails = (yield (yield (0, endpoints_1.datastoreAPI)()).getColumnDetails(tableId).catch((err) => {
30
+ if (err.status && err.status === 404) {
31
+ throw new error_1.default('Invalid table identifier', {
32
+ exit: 1,
33
+ errorId: 'DSTORE-1',
34
+ arg: [(0, ansi_colors_1.bold)(tableId), (0, ansi_colors_1.bold)('--table')]
35
+ });
36
+ }
37
+ throw err;
38
+ }));
39
+ if (!Array.isArray(columnDetails)) {
40
+ throw new error_1.default('Invalid column details', { exit: 2 });
41
+ }
42
+ const rowColumn = columnDetails.find((col) => col.column_name === 'ROWID');
43
+ if (rowColumn === undefined) {
44
+ throw new error_1.default('There is no ROWID column present in the column details', {
45
+ exit: 2
32
46
  });
33
47
  }
34
- throw err;
35
- }));
36
- if (!Array.isArray(columnDetails)) {
37
- throw new error_1.default('Invalid column details', { exit: 2 });
38
- }
39
- const rowColumn = columnDetails.find((col) => col.column_name === 'ROWID');
40
- if (rowColumn === undefined) {
41
- throw new error_1.default('There is no ROWID column present in the column details', {
42
- exit: 2
43
- });
48
+ exports.sourceId = rowColumn.table_id;
44
49
  }
45
- eventJson = eventJson.replace(new RegExp(constants_1.PLACEHOLDER.event_data.source_id, 'g'), rowColumn.table_id);
46
- }
47
- else {
48
- eventJson = eventJson.replace(new RegExp(constants_1.PLACEHOLDER.event_data.source_id, 'g'), js_1.JS.randomNumber(15).toString());
49
- }
50
- const data = columnDetails.reduce((accumulator, current) => {
51
- switch (current.data_type) {
52
- case 'bigint':
53
- case 'foreignkey':
54
- accumulator[0][current.column_name] = js_1.JS.randomNumber(15);
55
- break;
56
- case 'datetime':
57
- accumulator[0][current.column_name] = (0, moment_1.default)().format('YYYY-MM-DD HH:mm:ss');
58
- break;
59
- case 'text':
60
- case 'varchar':
61
- accumulator[0][current.column_name] = js_1.JS.randomString(10);
62
- break;
63
- case 'date':
64
- accumulator[0][current.column_name] = (0, moment_1.default)().format('YYYY-MM-DD');
65
- break;
66
- case 'boolean':
67
- accumulator[0][current.column_name] = js_1.JS.random(0, 1) === 1 ? true : false;
68
- break;
69
- case 'int':
70
- case 'double':
71
- accumulator[0][current.column_name] = js_1.JS.randomNumber(5);
72
- break;
73
- default:
74
- (0, logger_1.debug)('Unknown data_type received: ' + current.data_type);
75
- break;
50
+ else {
51
+ exports.sourceId = js_1.JS.randomNumber(15).toString();
76
52
  }
77
- return accumulator;
78
- }, [{}]);
79
- eventJson = eventJson.replace(new RegExp(constants_1.PLACEHOLDER.event_data.rule_id, 'g'), 'NULL');
80
- return eventJson.replace(new RegExp(constants_1.PLACEHOLDER.event_data.data, 'g'), JSON.stringify(data));
81
- });
53
+ return columnDetails.reduce((accumulator, current) => {
54
+ switch (current.data_type) {
55
+ case 'bigint':
56
+ case 'foreignkey':
57
+ accumulator[0][current.column_name] = js_1.JS.randomNumber(15);
58
+ break;
59
+ case 'datetime':
60
+ accumulator[0][current.column_name] =
61
+ (0, moment_1.default)().format('YYYY-MM-DD HH:mm:ss:SSS');
62
+ break;
63
+ case 'text':
64
+ case 'varchar':
65
+ accumulator[0][current.column_name] = js_1.JS.randomString(10);
66
+ break;
67
+ case 'date':
68
+ accumulator[0][current.column_name] = (0, moment_1.default)().format('YYYY-MM-DD');
69
+ break;
70
+ case 'boolean':
71
+ accumulator[0][current.column_name] = js_1.JS.random(0, 1) === 1 ? true : false;
72
+ break;
73
+ case 'int':
74
+ case 'double':
75
+ accumulator[0][current.column_name] = js_1.JS.randomNumber(5);
76
+ break;
77
+ default:
78
+ (0, logger_1.debug)('Unknown data_type received: ' + current.data_type);
79
+ break;
80
+ }
81
+ return accumulator;
82
+ }, [{}])[0];
83
+ });
84
+ }
85
+ exports.getData = getData;
@@ -12,58 +12,62 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.getData = exports.sourceId = void 0;
15
16
  const ansi_colors_1 = require("ansi-colors");
16
17
  const moment_1 = __importDefault(require("moment"));
17
18
  const endpoints_1 = require("../endpoints");
18
19
  const error_1 = __importDefault(require("../error"));
19
20
  const runtime_store_1 = __importDefault(require("../runtime-store"));
20
- const constants_1 = require("../util_modules/constants");
21
21
  const js_1 = require("../util_modules/js");
22
22
  const project_1 = require("../util_modules/project");
23
- exports.default = (eventJson, options = {}) => __awaiter(void 0, void 0, void 0, function* () {
24
- const folderId = options.folder;
25
- const allFolders = (yield (yield (0, endpoints_1.filestoreAPI)()).getAllFolders());
26
- const selectedFolder = folderId !== undefined
27
- ? allFolders.find((folder) => folder.folder_name === folderId || folder.id + '' === folderId)
28
- : {
29
- folder_name: js_1.JS.randomString(js_1.JS.random(5, 10)),
30
- id: js_1.JS.randomNumber(15) + ''
23
+ exports.sourceId = 'NULL';
24
+ function getData(options = {}) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ const folderId = options.folder;
27
+ const allFolders = (yield (yield (0, endpoints_1.filestoreAPI)()).getAllFolders());
28
+ const selectedFolder = folderId !== undefined
29
+ ? allFolders.find((folder) => folder.folder_name === folderId || folder.id + '' === folderId)
30
+ : {
31
+ folder_name: js_1.JS.randomString(js_1.JS.random(5, 10)),
32
+ id: js_1.JS.randomNumber(15) + ''
33
+ };
34
+ if (selectedFolder === undefined) {
35
+ const allFoldersFormatted = allFolders.length > 0
36
+ ? allFolders.map((folder) => '* ' + folder.folder_name).join('\n')
37
+ : 'None';
38
+ throw new error_1.default('Invalid folder identifier', {
39
+ exit: 1,
40
+ errorId: 'FSTORE-1',
41
+ arg: [(0, ansi_colors_1.bold)('--folder'), (0, ansi_colors_1.bold)(allFoldersFormatted)]
42
+ });
43
+ }
44
+ exports.sourceId = selectedFolder.id;
45
+ const userDetails = {
46
+ email_id: runtime_store_1.default.get('user.Email'),
47
+ user_type: 'Admin',
48
+ user_id: js_1.JS.randomNumber(15),
49
+ is_confirmed: js_1.JS.random(0, 1) === 1 ? true : false,
50
+ last_name: js_1.JS.randomString(5),
51
+ first_name: js_1.JS.randomString(10),
52
+ zuid: js_1.JS.randomNumber(10)
31
53
  };
32
- if (selectedFolder === undefined) {
33
- const allFoldersFormatted = allFolders.length > 0
34
- ? allFolders.map((folder) => '* ' + folder.folder_name).join('\n')
35
- : 'None';
36
- throw new error_1.default('Invalid folder identifier', {
37
- exit: 1,
38
- errorId: 'FSTORE-1',
39
- arg: [(0, ansi_colors_1.bold)('--folder'), (0, ansi_colors_1.bold)(allFoldersFormatted)]
40
- });
41
- }
42
- eventJson = eventJson.replace(new RegExp(constants_1.PLACEHOLDER.event_data.source_id, 'g'), selectedFolder.id);
43
- const userDetails = {
44
- email_id: runtime_store_1.default.get('user.Email'),
45
- user_id: js_1.JS.randomNumber(15),
46
- is_confirmed: js_1.JS.random(0, 1) === 1 ? true : false,
47
- last_name: js_1.JS.randomString(5),
48
- first_name: js_1.JS.randomString(10),
49
- zuid: js_1.JS.randomNumber(10)
50
- };
51
- const time = (0, moment_1.default)().format('MMM DD, YYYY hh:mm A');
52
- const data = {
53
- project_details: {
54
- id: (0, project_1.getProjectId)(),
55
- project_name: (0, project_1.getProjectName)()
56
- },
57
- folder_details: selectedFolder.id,
58
- created_time: time,
59
- file_location: null,
60
- modified_time: time,
61
- file_name: js_1.JS.randomString(10) + (js_1.JS.random(0, 1) === 1) ? '.js' : '.txt',
62
- modified_by: userDetails,
63
- id: selectedFolder.id,
64
- created_by: userDetails,
65
- file_size: parseInt(js_1.JS.randomNumber(6), 10)
66
- };
67
- eventJson = eventJson.replace(new RegExp(constants_1.PLACEHOLDER.event_data.rule_id, 'g'), 'NULL');
68
- return eventJson.replace(new RegExp(constants_1.PLACEHOLDER.event_data.data, 'g'), JSON.stringify(data));
69
- });
54
+ const time = (0, moment_1.default)().format('MMM DD, YYYY hh:mm A');
55
+ return {
56
+ project_details: {
57
+ project_type: 'Live',
58
+ id: (0, project_1.getProjectId)(),
59
+ project_name: (0, project_1.getProjectName)()
60
+ },
61
+ folder_details: selectedFolder === null || selectedFolder === void 0 ? void 0 : selectedFolder.id,
62
+ created_time: time,
63
+ file_location: null,
64
+ modified_time: time,
65
+ file_name: js_1.JS.randomString(10) + (js_1.JS.random(0, 1) === 1) ? '.js' : '.txt',
66
+ modified_by: userDetails,
67
+ id: selectedFolder === null || selectedFolder === void 0 ? void 0 : selectedFolder.id,
68
+ created_by: userDetails,
69
+ file_size: parseInt(js_1.JS.randomNumber(6), 10) + ''
70
+ };
71
+ });
72
+ }
73
+ exports.getData = getData;
@@ -12,23 +12,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.getData = exports.sourceId = void 0;
15
16
  const runtime_store_1 = __importDefault(require("../runtime-store"));
16
- const constants_1 = require("../util_modules/constants");
17
17
  const js_1 = require("../util_modules/js");
18
- exports.default = (eventJson) => __awaiter(void 0, void 0, void 0, function* () {
19
- const repoName = js_1.JS.randomString(5);
20
- const displayName = runtime_store_1.default.get('user.Display_Name');
21
- const data = {
22
- archive_url: `https://api.github.com/repos/${displayName}/${repoName}/`,
23
- full_name: `${displayName}/${repoName}`,
24
- clone_url: `https://github.com/${displayName}/${repoName}.git`,
25
- name: `${repoName}`,
26
- created_at: Date.now(),
27
- deployment_status: 'none',
28
- default_branch: 'master',
29
- id: js_1.JS.randomNumber(15)
30
- };
31
- eventJson = eventJson.replace(new RegExp(constants_1.PLACEHOLDER.event_data.source_id, 'g'), 'NULL');
32
- eventJson = eventJson.replace(new RegExp(constants_1.PLACEHOLDER.event_data.rule_id, 'g'), 'NULL');
33
- return eventJson.replace(new RegExp(constants_1.PLACEHOLDER.event_data.data, 'g'), JSON.stringify(data));
34
- });
18
+ exports.sourceId = 'NULL';
19
+ function getData() {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ const repoName = js_1.JS.randomString(5);
22
+ const displayName = runtime_store_1.default.get('user.Display_Name');
23
+ return {
24
+ archive_url: `https://api.github.com/repos/${displayName}/${repoName}/`,
25
+ full_name: `${displayName}/${repoName}`,
26
+ clone_url: `https://github.com/${displayName}/${repoName}.git`,
27
+ name: `${repoName}`,
28
+ created_at: Date.now(),
29
+ deployment_status: 'none',
30
+ default_branch: 'master',
31
+ id: js_1.JS.randomNumber(15)
32
+ };
33
+ });
34
+ }
35
+ exports.getData = getData;
@@ -1,52 +1,66 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
13
  };
5
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.getData = exports.sourceId = void 0;
6
16
  const moment_1 = __importDefault(require("moment"));
7
17
  const runtime_store_1 = __importDefault(require("../runtime-store"));
8
- const constants_1 = require("../util_modules/constants");
9
18
  const js_1 = require("../util_modules/js");
10
19
  const project_1 = require("../util_modules/project");
11
- function generateStratusEventJson(eventJson) {
12
- const userDetails = {
13
- email_id: runtime_store_1.default.get('user.Email'),
14
- user_id: js_1.JS.randomNumber(15),
15
- is_confirmed: getRandomBoolean(),
16
- last_name: js_1.JS.randomString(5),
17
- first_name: js_1.JS.randomString(10),
18
- zuid: js_1.JS.randomNumber(10)
19
- };
20
- const time = (0, moment_1.default)().format('MMM DD, YYYY hh:mm A');
21
- const data = {
22
- bucket_details: {
23
- bucket_name: 'sample-bucket',
24
- project_details: {
25
- id: (0, project_1.getProjectId)(),
26
- project_name: (0, project_1.getProjectName)(),
27
- project_type: 'Live'
28
- },
29
- created_by: userDetails,
30
- created_time: time,
31
- modified_by: userDetails,
32
- modified_time: time,
33
- bucket_meta: {
34
- versioning: getRandomBoolean(),
35
- caching: {
36
- status: getRandomBoolean() ? 'Enabled' : 'Disabled'
20
+ exports.sourceId = 'NULL';
21
+ function getData() {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ const userDetails = {
24
+ email_id: runtime_store_1.default.get('user.Email'),
25
+ user_type: 'Admin',
26
+ user_id: js_1.JS.randomNumber(15),
27
+ is_confirmed: getRandomBoolean(),
28
+ last_name: js_1.JS.randomString(5),
29
+ first_name: js_1.JS.randomString(10),
30
+ zuid: js_1.JS.randomNumber(10)
31
+ };
32
+ const time = (0, moment_1.default)().format('MMM DD, YYYY hh:mm A');
33
+ return {
34
+ action_time: js_1.JS.randomNumber(15),
35
+ bucket_details: {
36
+ project_details: {
37
+ id: (0, project_1.getProjectId)(),
38
+ project_name: (0, project_1.getProjectName)(),
39
+ project_type: 'Live'
37
40
  },
38
- encryption: getRandomBoolean(),
39
- audit_consent: getRandomBoolean()
40
- }
41
- },
42
- object_key: 'path1/path2/myfile.png'
43
- };
44
- eventJson = eventJson.replace(new RegExp(constants_1.PLACEHOLDER.event_data.rule_id, 'g'), 'NULL');
45
- eventJson = eventJson.replace(new RegExp(constants_1.PLACEHOLDER.event_data.source_id, 'g'), 'NULL');
46
- eventJson = eventJson.replace(new RegExp(constants_1.PLACEHOLDER.event_data.data, 'g'), JSON.stringify(data));
47
- return eventJson;
41
+ created_time: time,
42
+ modified_time: time,
43
+ bucket_name: 'sample-bucket',
44
+ modified_by: userDetails,
45
+ created_by: userDetails,
46
+ bucket_meta: {
47
+ versioning: getRandomBoolean(),
48
+ encryption: getRandomBoolean(),
49
+ audit_consent: getRandomBoolean(),
50
+ caching: {
51
+ status: getRandomBoolean() ? 'Enabled' : 'Disabled'
52
+ }
53
+ }
54
+ },
55
+ object_details: [
56
+ {
57
+ key: 'sample.txt'
58
+ }
59
+ ]
60
+ };
61
+ });
48
62
  }
49
- exports.default = generateStratusEventJson;
63
+ exports.getData = getData;
50
64
  function getRandomBoolean() {
51
65
  return js_1.JS.random(0, 1) === 1;
52
66
  }