zcatalyst-cli 1.7.1 → 1.9.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.
- package/README.md +31 -10
- package/docs/apig-utils.toml +69 -0
- package/docs/authentication/index.toml +15 -0
- package/docs/authentication/login.toml +14 -0
- package/docs/client-utils.toml +24 -0
- package/docs/command_needs/auth.toml +4 -0
- package/docs/command_needs/rc.toml +24 -0
- package/docs/commands/apig/disable.toml +4 -0
- package/docs/commands/apig/enable.toml +4 -0
- package/docs/commands/apig/status.toml +4 -0
- package/docs/commands/client/delete.toml +34 -0
- package/docs/commands/ds/export.toml +4 -0
- package/docs/commands/ds/import.toml +15 -0
- package/docs/commands/ds/status.toml +9 -0
- package/docs/commands/event/generate/index.toml +29 -0
- package/docs/commands/event/generate/integ.toml +4 -0
- package/docs/commands/functions/config.toml +11 -0
- package/docs/commands/functions/delete.toml +29 -0
- package/docs/commands/project/use.toml +9 -0
- package/docs/dc.toml +4 -0
- package/docs/deploy/features/apig.toml +4 -0
- package/docs/deploy/features/functions/index.toml +4 -0
- package/docs/event_generate/cache.toml +4 -0
- package/docs/event_generate/custom.toml +4 -0
- package/docs/event_generate/datastore.toml +4 -0
- package/docs/event_generate/filestore.toml +4 -0
- package/docs/event_generate/integration/cliq.toml +9 -0
- package/docs/execute-script.toml +19 -0
- package/docs/fn-utils/lib/common.toml +25 -0
- package/docs/fn-utils/lib/java.toml +34 -0
- package/docs/fn-utils/lib/node.toml +4 -0
- package/docs/init/index.toml +4 -0
- package/docs/internal/command.toml +4 -0
- package/docs/internal/config.toml +9 -0
- package/docs/internal/credential.toml +14 -0
- package/docs/option-filter.toml +45 -0
- package/docs/port-resolver.toml +9 -0
- package/docs/pull/index.toml +4 -0
- package/docs/serve/index.toml +4 -0
- package/docs/shell/index.toml +4 -0
- package/docs/util_modules/project.toml +9 -0
- package/lib/apig-utils.js +133 -43
- package/lib/archiver.js +4 -2
- package/lib/authentication/index.js +44 -9
- package/lib/authentication/login.js +51 -8
- package/lib/bin/catalyst.js +14 -7
- package/lib/client-utils.js +47 -14
- package/lib/client.js +1 -1
- package/lib/command_needs/auth.js +5 -3
- package/lib/command_needs/rc.js +35 -13
- package/lib/commands/apig/disable.js +8 -3
- package/lib/commands/apig/enable.js +8 -3
- package/lib/commands/apig/status.js +29 -9
- package/lib/commands/client/delete.js +65 -26
- package/lib/commands/client/setup.js +2 -2
- package/lib/commands/deploy.js +2 -2
- package/lib/commands/ds/export.js +16 -8
- package/lib/commands/ds/import.js +20 -14
- package/lib/commands/ds/status.js +22 -11
- package/lib/commands/event/generate/index.js +62 -12
- package/lib/commands/event/generate/integ.js +7 -3
- package/lib/commands/functions/add.js +2 -2
- package/lib/commands/functions/config.js +11 -3
- package/lib/commands/functions/delete.js +36 -13
- package/lib/commands/functions/setup.js +2 -2
- package/lib/commands/functions/shell.js +2 -2
- package/lib/commands/help.js +1 -1
- package/lib/commands/index.js +2 -3
- package/lib/commands/init.js +4 -4
- package/lib/commands/login.js +2 -2
- package/lib/commands/logout.js +2 -2
- package/lib/commands/project/list.js +2 -2
- package/lib/commands/project/reset.js +1 -1
- package/lib/commands/project/use.js +18 -2
- package/lib/commands/pull.js +5 -5
- package/lib/commands/run.js +2 -2
- package/lib/commands/serve.js +7 -6
- package/lib/commands/token/generate.js +2 -2
- package/lib/commands/token/list.js +2 -2
- package/lib/commands/token/revoke.js +2 -2
- package/lib/commands/whoami.js +1 -1
- package/lib/dc.js +11 -1
- package/lib/deploy/features/apig.js +33 -33
- package/lib/deploy/features/client.js +12 -19
- package/lib/deploy/features/functions/index.js +14 -4
- package/lib/deploy/features/index.js +1 -1
- package/lib/deploy/index.js +2 -9
- package/lib/endpoints/index.js +5 -2
- package/lib/endpoints/lib/apig.js +15 -5
- package/lib/endpoints/lib/applogic.js +12 -4
- package/lib/endpoints/lib/cache.js +9 -3
- package/lib/endpoints/lib/catalyst-details.js +37 -0
- package/lib/endpoints/lib/client.js +15 -5
- package/lib/endpoints/lib/datastore.js +6 -2
- package/lib/endpoints/lib/ds-bulk.js +15 -5
- package/lib/endpoints/lib/env.js +3 -1
- package/lib/endpoints/lib/event-bus.js +3 -1
- package/lib/endpoints/lib/filestore.js +6 -2
- package/lib/endpoints/lib/functions.js +12 -4
- package/lib/endpoints/lib/project.js +9 -3
- package/lib/endpoints/lib/queue.js +9 -3
- package/lib/endpoints/lib/sdk.js +3 -1
- package/lib/endpoints/lib/zcql.js +3 -1
- package/lib/error.js +18 -0
- package/lib/errorOut.js +10 -7
- package/lib/event_generate/cache.js +9 -1
- package/lib/event_generate/custom.js +6 -1
- package/lib/event_generate/datastore.js +12 -2
- package/lib/event_generate/filestore.js +9 -1
- package/lib/event_generate/integration/cliq.js +10 -2
- package/lib/execute-script.js +35 -6
- package/lib/express_middlewares/unknownReqProxy.js +18 -7
- package/lib/fn-utils/index.js +1 -1
- package/lib/fn-utils/lib/common.js +95 -17
- package/lib/fn-utils/lib/integ.js +4 -3
- package/lib/fn-utils/lib/java.js +49 -13
- package/lib/fn-utils/lib/node.js +15 -6
- package/lib/fn-watcher.js +67 -0
- package/lib/index.js +13 -12
- package/lib/init/dependencies/package-json.js +3 -1
- package/lib/init/features/functions/index.js +41 -29
- package/lib/init/features/functions/languages/java.js +5 -4
- package/lib/init/features/functions/languages/node.js +6 -5
- package/lib/init/features/index.js +8 -4
- package/lib/init/index.js +10 -3
- package/lib/internal/api.js +9 -9
- package/lib/internal/command.js +19 -14
- package/lib/internal/config.js +15 -15
- package/lib/internal/credential.js +33 -7
- package/lib/internal/rc.js +18 -10
- package/lib/migration/global/1.4.0.js +4 -2
- package/lib/migration/global/1.6.2.js +4 -2
- package/lib/migration/index.js +1 -1
- package/lib/option-filter.js +79 -22
- package/lib/optional-import.js +1 -1
- package/lib/plugin-loader.js +1 -1
- package/lib/port-resolver.js +23 -3
- package/lib/prompt.js +1 -1
- package/lib/pull/features/functions/index.js +7 -7
- package/lib/pull/features/index.js +1 -1
- package/lib/pull/index.js +10 -3
- package/lib/repl-server.js +9 -5
- package/lib/serve/features/index.js +11 -2
- package/lib/serve/index.js +19 -9
- package/lib/serve/server/index.js +137 -60
- package/lib/serve/server/lib/client.js +1 -1
- package/lib/serve/server/lib/master.js +16 -3
- package/lib/serve/server/lib/node.js +1 -1
- package/lib/shell/dependencies/http-functions.js +120 -90
- package/lib/shell/dependencies/invoker/integ/node.js +1 -1
- package/lib/shell/dependencies/local-function.js +86 -119
- package/lib/shell/index.js +10 -10
- package/lib/shell/prepare/index.js +1 -4
- package/lib/shell/prepare/languages/index.js +15 -4
- package/lib/track.js +4 -1
- package/lib/util_modules/config/index.js +1 -1
- package/lib/util_modules/config/lib/apig.js +3 -3
- package/lib/util_modules/config/lib/client.js +3 -3
- package/lib/util_modules/config/lib/functions.js +5 -5
- package/lib/util_modules/constants/index.js +22 -20
- package/lib/util_modules/constants/lib/regex.js +3 -2
- package/lib/util_modules/constants/lib/runtime.js +9 -0
- package/lib/util_modules/contextHelp.js +63 -123
- package/lib/util_modules/fs/index.js +1 -1
- package/lib/util_modules/fs/lib/async.js +19 -2
- package/lib/util_modules/fs/lib/sync.js +13 -1
- package/lib/util_modules/logger.js +12 -20
- package/lib/util_modules/option.js +1 -13
- package/lib/util_modules/project.js +75 -26
- package/lib/util_modules/shell.js +8 -2
- package/package.json +45 -45
- package/scripts/postInstall.js +31 -0
- package/lib/cjson.js +0 -20
- package/lib/log-error.js +0 -18
- package/lib/util_modules/big-json.js +0 -16
- package/lib/util_modules/constants/lib/stack.js +0 -6
- package/templates/init/functions/.DS_Store +0 -0
- package/templates/init/functions/node/.DS_Store +0 -0
- package/templates/init/functions/node/integ/.DS_Store +0 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
[OPT-FILTER-1]
|
|
2
|
+
context = '''The ${arg[0]} option cannot contain duplicate targets.'''
|
|
3
|
+
aid = '''Please remove the duplicate target from the option input. \n${arg[1]}'''
|
|
4
|
+
link = ''
|
|
5
|
+
|
|
6
|
+
[OPT-FILTER-2]
|
|
7
|
+
context = '''Invalid target ${arg[0]} provided with the option ${arg[1]}.'''
|
|
8
|
+
aid = '''Please provide a valid target, The valid targets are: \n${arg[2]}'''
|
|
9
|
+
link = ''
|
|
10
|
+
|
|
11
|
+
[OPT-FILTER-3]
|
|
12
|
+
context = '''The target ${arg[0]} is specified with and without a filter for the ${arg[1]} option.'''
|
|
13
|
+
aid = '''Please use the targets either with a filter or without a filter and not both together. \n${arg[2]}'''
|
|
14
|
+
link = ''
|
|
15
|
+
|
|
16
|
+
[OPT-FILTER-4]
|
|
17
|
+
context = '''Cannot specify both the ${arg[0]} option and the ${arg[1]} option in the same command.'''
|
|
18
|
+
aid = '''Use only one of the above options at a time to select you targets.'''
|
|
19
|
+
link = ''
|
|
20
|
+
|
|
21
|
+
[OPT-FILTER-5]
|
|
22
|
+
context = '''The target Client cannot be debugged.'''
|
|
23
|
+
aid = '''Please remove the target Client from the --debug option and execute the command.'''
|
|
24
|
+
link = ''
|
|
25
|
+
|
|
26
|
+
[OPT-FILTER-6]
|
|
27
|
+
context = '''The input for the ${arg[0]} option is in an invalid format: ${arg[1]}'''
|
|
28
|
+
aid = '''Please use only these valid formats to specify the targets: \n${arg[2]}\n${arg[3]}'''
|
|
29
|
+
link = ''
|
|
30
|
+
|
|
31
|
+
[OPT-FILTER-7]
|
|
32
|
+
context = '''The input of the ${arg[0]} option for target ${arg[1]} is in an invalid format: ${arg[2]}'''
|
|
33
|
+
aid = '''Please use only the ${arg[3]} format, to specify your ${arg[1]} targets with the ${arg[0]} option.
|
|
34
|
+
example: --debug advancedio:aio_fn:8001'''
|
|
35
|
+
link = ''
|
|
36
|
+
|
|
37
|
+
[OPT-FILTER-8]
|
|
38
|
+
context = '''Could not understand the targets.'''
|
|
39
|
+
aid = '''Please ensure that ${arg[0]}'''
|
|
40
|
+
link = ''
|
|
41
|
+
|
|
42
|
+
[OPT-FILTER-9]
|
|
43
|
+
context = '''The API Gateway cannot be served seperately in local.'''
|
|
44
|
+
aid = '''Please include atleast one other component like functions or client along with the APIG to serve the APIG in local.'''
|
|
45
|
+
link = ''
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
[PORT-RESOLVER-1]
|
|
2
|
+
context = '''The port ${arg[0]} requested for the ${arg[1]} of ${arg[2]}(${arg[3]}) is not available.'''
|
|
3
|
+
aid = '''Please provide a different port with the ${arg[4]} option.'''
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
[PORT-RESOLVER-2]
|
|
7
|
+
context = '''No ports in the range ${arg[0]} to ${arg[1]} is free.'''
|
|
8
|
+
aid = '''Please specify a port out of the above range with the ${arg[2]} option.'''
|
|
9
|
+
link = 'https://www.zoho.com/catalyst/help/cli-serve.html#Options'
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
[PROJ-1]
|
|
2
|
+
context = '''The "${arg[0]}" file is missing in the project root directory.'''
|
|
3
|
+
aid = '''Please initialize the project using the ${arg[1]} command.'''
|
|
4
|
+
link = 'https://www.zoho.com/catalyst/help/cli-init.html'
|
|
5
|
+
|
|
6
|
+
[PROJ-2]
|
|
7
|
+
context = '''Unable to get the ${arg[0]}'''
|
|
8
|
+
aid = '''Please initialize the project using the ${arg[1]} command'''
|
|
9
|
+
link = 'https://www.zoho.com/catalyst/help/cli-init.html'
|
package/lib/apig-utils.js
CHANGED
|
@@ -40,17 +40,24 @@ const project_1 = require("./util_modules/project");
|
|
|
40
40
|
exports.apigUtils = {
|
|
41
41
|
validate: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
42
|
const ruleFile = project_1.resolveProjectPath(config_1.apigConfig.rules());
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
43
|
+
const ruleArr = (yield fs_1.ASYNC.readJSONFile(ruleFile, {
|
|
44
|
+
checkpath: true,
|
|
45
|
+
throws: true
|
|
46
|
+
}).catch((err) => {
|
|
47
|
+
throw new error_1.default('Unable to read ' + ruleFile + ' file.', {
|
|
48
|
+
exit: 1,
|
|
49
|
+
errorId: 'APIG-UTILS-1',
|
|
50
|
+
arg: [ansi_colors_1.bold(ruleFile), ansi_colors_1.italic.red(err)],
|
|
51
|
+
original: err
|
|
52
|
+
});
|
|
53
|
+
}));
|
|
54
|
+
if (ruleArr === undefined) {
|
|
55
|
+
throw new error_1.default(ruleFile + ' file not found' + constants_1.FILENAME.config, {
|
|
56
|
+
exit: 1,
|
|
57
|
+
errorId: 'APIG-UTILS-2',
|
|
58
|
+
arg: [ansi_colors_1.bold.red(ruleFile), ansi_colors_1.bold(constants_1.FILENAME.config)]
|
|
59
|
+
});
|
|
52
60
|
}
|
|
53
|
-
const ruleArr = JSON.parse(ruleArrayContent);
|
|
54
61
|
let localRuleArr = [];
|
|
55
62
|
let redirectPath;
|
|
56
63
|
try {
|
|
@@ -72,27 +79,47 @@ exports.apigUtils = {
|
|
|
72
79
|
localRuleArr = ruleArr.map((rule, index) => {
|
|
73
80
|
var _a, _b;
|
|
74
81
|
if (rule.name === undefined || rule.name === null) {
|
|
75
|
-
throw new error_1.default(
|
|
82
|
+
throw new error_1.default('Name for an APIG rule is missing', {
|
|
83
|
+
exit: 1,
|
|
84
|
+
errorId: 'APIG-UTILS-3',
|
|
85
|
+
arg: [ansi_colors_1.italic.red(JSON.stringify(rule, null, ' '))]
|
|
86
|
+
});
|
|
76
87
|
}
|
|
77
88
|
if (namesArr.includes(rule.name)) {
|
|
78
|
-
throw new error_1.default(rule
|
|
79
|
-
|
|
89
|
+
throw new error_1.default('Duplicate APIG rule detected', {
|
|
90
|
+
exit: 1,
|
|
91
|
+
errorId: 'APIG-UTILS-4',
|
|
92
|
+
arg: [ansi_colors_1.bold.red(rule.name)]
|
|
93
|
+
});
|
|
80
94
|
}
|
|
81
95
|
namesArr.push(rule.name);
|
|
82
96
|
if (rule.source_endpoint === undefined || rule.source_endpoint === null) {
|
|
83
|
-
throw new error_1.default(
|
|
97
|
+
throw new error_1.default('source_endpoint missing for rule ' + rule.name, {
|
|
98
|
+
exit: 1,
|
|
99
|
+
errorId: 'APIG-UTILS-5',
|
|
100
|
+
arg: [ansi_colors_1.bold.red(rule.name), ansi_colors_1.bold('source_endpoint')]
|
|
101
|
+
});
|
|
84
102
|
}
|
|
85
103
|
if (rule.method === undefined || rule.method === null) {
|
|
86
|
-
throw new error_1.default(
|
|
87
|
-
exit: 1
|
|
104
|
+
throw new error_1.default('method missing for rule ' + rule.name, {
|
|
105
|
+
exit: 1,
|
|
106
|
+
errorId: 'APIG-UTILS-5',
|
|
107
|
+
arg: [ansi_colors_1.bold.red(rule.name), ansi_colors_1.bold('method')]
|
|
88
108
|
});
|
|
89
109
|
}
|
|
90
110
|
if (sourceUrlByConfig[rule.source_endpoint] !== undefined &&
|
|
91
111
|
sourceUrlByConfig[rule.source_endpoint][rule.method] !== undefined) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
'
|
|
112
|
+
const duplicateRuleName = sourceUrlByConfig[rule.source_endpoint][rule.method] || '';
|
|
113
|
+
throw new error_1.default(rule.name + 'has duplicate "source_endpoint" as ' + duplicateRuleName, {
|
|
114
|
+
exit: 1,
|
|
115
|
+
errorId: 'APIG-UTILS-6',
|
|
116
|
+
arg: [
|
|
117
|
+
ansi_colors_1.bold(rule.name),
|
|
118
|
+
ansi_colors_1.bold('source_endpoint'),
|
|
119
|
+
ansi_colors_1.italic.red(rule.source_endpoint),
|
|
120
|
+
ansi_colors_1.bold(duplicateRuleName)
|
|
121
|
+
]
|
|
122
|
+
});
|
|
96
123
|
}
|
|
97
124
|
if (sourceUrlByConfig[rule.source_endpoint] === undefined) {
|
|
98
125
|
sourceUrlByConfig[rule.source_endpoint] = {};
|
|
@@ -100,13 +127,12 @@ exports.apigUtils = {
|
|
|
100
127
|
sourceUrlByConfig[rule.source_endpoint][rule.method] = rule.name;
|
|
101
128
|
if (rule.name === 'Login Redirect') {
|
|
102
129
|
const homepage = runtime_store_1.default.get('context.client.homepage');
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
130
|
+
const clientValidity = runtime_store_1.default.get('context.client.valid', false);
|
|
131
|
+
if (!clientValidity || (redirectPath === undefined && homepage === undefined)) {
|
|
132
|
+
throw new error_1.default('Login Redirect rule cannot be verified since client package is not valid', { exit: 1, errorId: 'APIG-UTILS-7', arg: [ansi_colors_1.bold(rule.name)] });
|
|
133
|
+
}
|
|
134
|
+
else if (!redirectPath) {
|
|
135
|
+
redirectPath = '/app/' + homepage;
|
|
110
136
|
}
|
|
111
137
|
redirectIdx = index;
|
|
112
138
|
runtime_store_1.default.set('context.client.login_redirect', rule.source_endpoint);
|
|
@@ -126,7 +152,11 @@ exports.apigUtils = {
|
|
|
126
152
|
}
|
|
127
153
|
if (rule.target === 'client' || ((_b = rule.target_endpoint) === null || _b === void 0 ? void 0 : _b.startsWith('/app/'))) {
|
|
128
154
|
if (rule.authentication !== undefined && rule.authentication !== null) {
|
|
129
|
-
throw new error_1.default('client target cannot have authentication, for rule name : ' + rule.name, {
|
|
155
|
+
throw new error_1.default('client target cannot have authentication, for rule name : ' + rule.name, {
|
|
156
|
+
exit: 1,
|
|
157
|
+
errorId: 'APIG-UTILS-8',
|
|
158
|
+
arg: [ansi_colors_1.bold(rule.name), ansi_colors_1.italic.red('"authentication"')]
|
|
159
|
+
});
|
|
130
160
|
}
|
|
131
161
|
}
|
|
132
162
|
const { created_by, created_time, modified_by, modified_time, api_id } = rule, remaining = __rest(rule, ["created_by", "created_time", "modified_by", "modified_time", "api_id"]);
|
|
@@ -164,22 +194,37 @@ exports.apigUtils = {
|
|
|
164
194
|
if (part.startsWith('{')) {
|
|
165
195
|
const regexParts = part.slice(1, -1).split(':');
|
|
166
196
|
try {
|
|
167
|
-
new RegExp(regexParts[1]);
|
|
197
|
+
rule.name, new RegExp(regexParts[1]);
|
|
168
198
|
}
|
|
169
199
|
catch (regexError) {
|
|
170
|
-
throw new error_1.default('
|
|
200
|
+
throw new error_1.default('source_endpoint provided for apig rule "' +
|
|
171
201
|
rule.name +
|
|
172
202
|
'" is not valid', {
|
|
173
203
|
exit: 1,
|
|
174
|
-
original: regexError
|
|
204
|
+
original: regexError,
|
|
205
|
+
errorId: 'APIG-UTILS-9',
|
|
206
|
+
arg: [
|
|
207
|
+
ansi_colors_1.bold('source_endpoint'),
|
|
208
|
+
ansi_colors_1.bold(rule.name),
|
|
209
|
+
ansi_colors_1.italic(source_endpoint.replace(part, ansi_colors_1.red(part))),
|
|
210
|
+
ansi_colors_1.bold('Error: ') + ansi_colors_1.italic.red(regexError)
|
|
211
|
+
]
|
|
175
212
|
});
|
|
176
213
|
}
|
|
177
214
|
if (regexParts[1].includes('^') || regexParts[1].includes('$')) {
|
|
178
|
-
throw new error_1.default('
|
|
215
|
+
throw new error_1.default('source_endpoint provided for apig rule "' +
|
|
179
216
|
rule.name +
|
|
180
217
|
'" is not valid. ' +
|
|
181
218
|
'Url should not contain ^ or $ symbols', {
|
|
182
|
-
exit: 1
|
|
219
|
+
exit: 1,
|
|
220
|
+
errorId: 'APIG-UTILS-10',
|
|
221
|
+
arg: [
|
|
222
|
+
ansi_colors_1.bold('source_endpoint'),
|
|
223
|
+
ansi_colors_1.bold(rule.name),
|
|
224
|
+
ansi_colors_1.italic(source_endpoint.replace(part, ansi_colors_1.red(part))),
|
|
225
|
+
ansi_colors_1.bold('Error: ') +
|
|
226
|
+
ansi_colors_1.italic.red('Regular Expression(s) in the source_endpoint should not contain ^ or $ symbols')
|
|
227
|
+
]
|
|
183
228
|
});
|
|
184
229
|
}
|
|
185
230
|
if (regexParts[1].includes('.*') && currentIdx !== allParts.length - 1) {
|
|
@@ -187,7 +232,16 @@ exports.apigUtils = {
|
|
|
187
232
|
rule.name +
|
|
188
233
|
'" is not valid. ' +
|
|
189
234
|
'Url should not contain wildcard character in the mid of path', {
|
|
190
|
-
exit: 1
|
|
235
|
+
exit: 1,
|
|
236
|
+
errorId: 'APIG-UTILS-10',
|
|
237
|
+
arg: [
|
|
238
|
+
ansi_colors_1.bold('source_endpoint'),
|
|
239
|
+
ansi_colors_1.bold(rule.name),
|
|
240
|
+
ansi_colors_1.italic(source_endpoint.replace(part, ansi_colors_1.red(part))),
|
|
241
|
+
ansi_colors_1.bold('Error: ') +
|
|
242
|
+
ansi_colors_1.italic.red('Regular Expression(s) in the source_endpoint with the wildcard character(.*)' +
|
|
243
|
+
' is only allowed to be present at the last section of the endpoint')
|
|
244
|
+
]
|
|
191
245
|
});
|
|
192
246
|
}
|
|
193
247
|
let actualRegex = regexParts[1];
|
|
@@ -202,17 +256,26 @@ exports.apigUtils = {
|
|
|
202
256
|
})
|
|
203
257
|
.join('/');
|
|
204
258
|
if (!otherProps.system && otherProps.name === 'Login Redirect') {
|
|
205
|
-
throw new error_1.default('Login Redirect is a system reserved name.
|
|
259
|
+
throw new error_1.default('Login Redirect is a system reserved name. Please define it as system value', { exit: 2 });
|
|
206
260
|
}
|
|
207
261
|
if (otherProps.target_endpoint === undefined) {
|
|
208
262
|
switch (otherProps.target) {
|
|
209
263
|
case 'client':
|
|
210
264
|
case 'advancedio':
|
|
211
|
-
throw new error_1.default('"target_endpoint" is
|
|
265
|
+
throw new error_1.default('"target_endpoint"(mandatory) is missing, for rule name : ' +
|
|
266
|
+
otherProps.name, {
|
|
267
|
+
exit: 1,
|
|
268
|
+
errorId: 'APIG-UTILS-11',
|
|
269
|
+
arg: [ansi_colors_1.bold(otherProps.name), ansi_colors_1.bold('target_endpoint')]
|
|
270
|
+
});
|
|
212
271
|
case 'basicio':
|
|
213
272
|
if (otherProps.target_id === undefined) {
|
|
214
273
|
throw new error_1.default('If target is function "target_id" is mandatory, for rule name : ' +
|
|
215
|
-
otherProps.name, {
|
|
274
|
+
otherProps.name, {
|
|
275
|
+
exit: 1,
|
|
276
|
+
errorId: 'APIG-UTILS-11',
|
|
277
|
+
arg: [ansi_colors_1.bold(otherProps.name), ansi_colors_1.bold('target_id')]
|
|
278
|
+
});
|
|
216
279
|
}
|
|
217
280
|
const generatedUrl = fn_utils_1.fnUtils.common.generateUrlForTarget({
|
|
218
281
|
name: otherProps.target_id,
|
|
@@ -221,16 +284,36 @@ exports.apigUtils = {
|
|
|
221
284
|
valid: true
|
|
222
285
|
});
|
|
223
286
|
if (generatedUrl === undefined) {
|
|
224
|
-
throw new error_1.default('"
|
|
225
|
-
otherProps.name, { exit:
|
|
287
|
+
throw new error_1.default('"target" provided for function is not a valid one. Please specify if basicio or advancedio, for rule name : ' +
|
|
288
|
+
otherProps.name, { exit: 2 });
|
|
226
289
|
}
|
|
227
290
|
otherProps.target_endpoint =
|
|
228
291
|
'/' +
|
|
229
292
|
generatedUrl.replace('https://', '').split('/').slice(1).join('/');
|
|
230
293
|
break;
|
|
231
294
|
default:
|
|
232
|
-
|
|
233
|
-
|
|
295
|
+
if (otherProps.target === undefined) {
|
|
296
|
+
throw new error_1.default('target_endpoint and target both are undefined for rule name : ' +
|
|
297
|
+
otherProps.name, {
|
|
298
|
+
exit: 1,
|
|
299
|
+
errorId: 'APIG-UTILS-12',
|
|
300
|
+
arg: [
|
|
301
|
+
ansi_colors_1.bold(otherProps.name),
|
|
302
|
+
ansi_colors_1.bold('target_endpoint'),
|
|
303
|
+
ansi_colors_1.bold('target')
|
|
304
|
+
]
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
throw new error_1.default('invalid target in APIG rule: ' + otherProps.name, {
|
|
308
|
+
exit: 1,
|
|
309
|
+
errorId: 'APIG-UTILS-13',
|
|
310
|
+
arg: [
|
|
311
|
+
ansi_colors_1.bold('target'),
|
|
312
|
+
ansi_colors_1.italic.red(otherProps.target),
|
|
313
|
+
ansi_colors_1.bold(otherProps.name),
|
|
314
|
+
ansi_colors_1.bold(['* client', '* advancedio', '* basicio'].join('\n'))
|
|
315
|
+
]
|
|
316
|
+
});
|
|
234
317
|
}
|
|
235
318
|
}
|
|
236
319
|
if (!otherProps.target_endpoint.startsWith('/baas/') &&
|
|
@@ -238,8 +321,15 @@ exports.apigUtils = {
|
|
|
238
321
|
!otherProps.target_endpoint.startsWith('/server/') &&
|
|
239
322
|
!otherProps.target_endpoint.startsWith('/oauthorize') &&
|
|
240
323
|
!otherProps.target_endpoint.startsWith('/__catalyst/')) {
|
|
241
|
-
throw new error_1.default('target_endpoint is not recognized
|
|
242
|
-
|
|
324
|
+
throw new error_1.default('target_endpoint is not recognized for rule name : ' + otherProps.name, {
|
|
325
|
+
exit: 1,
|
|
326
|
+
errorId: 'APIG-UTILS-14',
|
|
327
|
+
arg: [
|
|
328
|
+
ansi_colors_1.bold('target_endpoint'),
|
|
329
|
+
ansi_colors_1.italic.red(otherProps.target_endpoint),
|
|
330
|
+
ansi_colors_1.bold(otherProps.name)
|
|
331
|
+
]
|
|
332
|
+
});
|
|
243
333
|
}
|
|
244
334
|
if (method === 'ANY') {
|
|
245
335
|
js_1.JS.set(localConfig, [sourceUrl, 'all'], otherProps);
|
package/lib/archiver.js
CHANGED
|
@@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
14
14
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
15
|
if (mod && mod.__esModule) return mod;
|
|
16
16
|
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
18
|
__setModuleDefault(result, mod);
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
@@ -123,7 +123,9 @@ class Archiver {
|
|
|
123
123
|
}));
|
|
124
124
|
}
|
|
125
125
|
if (fromFileObj.length === 0) {
|
|
126
|
-
throw new error_1.default('Unable to extract zip, FileObj is null', {
|
|
126
|
+
throw new error_1.default('Unable to extract zip, FileObj is null', {
|
|
127
|
+
exit: 2
|
|
128
|
+
});
|
|
127
129
|
}
|
|
128
130
|
while (fromFileObj.length > 0) {
|
|
129
131
|
const limit = fromFileObj.length < 20 ? fromFileObj.length : 20;
|
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
22
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
23
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -13,7 +32,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
32
|
};
|
|
14
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
34
|
exports.logout = exports.login = exports.revoke = exports.list = exports.create = void 0;
|
|
16
|
-
const ansi_colors_1 =
|
|
35
|
+
const ansi_colors_1 = __importStar(require("ansi-colors"));
|
|
17
36
|
const moment_1 = __importDefault(require("moment"));
|
|
18
37
|
const config_store_1 = __importDefault(require("../config-store"));
|
|
19
38
|
const dc_1 = require("../dc");
|
|
@@ -41,9 +60,11 @@ exports.create = create;
|
|
|
41
60
|
function list() {
|
|
42
61
|
const tokens = config_store_1.default.get(`${dc_1.getActiveDC()}.tokens`, null);
|
|
43
62
|
if (tokens === null || Object.keys(tokens).length === 0) {
|
|
44
|
-
throw new error_1.default('No tokens found,
|
|
45
|
-
|
|
46
|
-
|
|
63
|
+
throw new error_1.default('No tokens found', {
|
|
64
|
+
exit: 0,
|
|
65
|
+
errorId: 'IDX-1',
|
|
66
|
+
arg: [ansi_colors_1.bold('catalyst token:generate')]
|
|
67
|
+
});
|
|
47
68
|
}
|
|
48
69
|
const tableData = [];
|
|
49
70
|
for (const tokenId in tokens) {
|
|
@@ -65,9 +86,16 @@ function revoke(id) {
|
|
|
65
86
|
const tokens = config_store_1.default.get(`${dc_1.getActiveDC()}.tokens`, {});
|
|
66
87
|
const tokenKey = Object.keys(tokens).find((key) => key === id);
|
|
67
88
|
if (tokenKey === undefined) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
89
|
+
const allTokenKeys = Object.keys(tokens);
|
|
90
|
+
throw new error_1.default('Unable to retrive token', {
|
|
91
|
+
exit: 1,
|
|
92
|
+
errorId: 'IDX-2',
|
|
93
|
+
arg: [
|
|
94
|
+
id,
|
|
95
|
+
allTokenKeys.length > 0 ? '* ' + allTokenKeys.join('\n* ') : 'None',
|
|
96
|
+
ansi_colors_1.bold('catalyst token:list')
|
|
97
|
+
]
|
|
98
|
+
});
|
|
71
99
|
}
|
|
72
100
|
const credential = credential_1.default.init(tokens[tokenKey]);
|
|
73
101
|
return new revoke_1.default(credential, 'tokens.' + id).init();
|
|
@@ -83,7 +111,10 @@ function login() {
|
|
|
83
111
|
logger_1.message('No need to login. Already logged as: ' + ansi_colors_1.default.cyan.bold(user.Email));
|
|
84
112
|
return;
|
|
85
113
|
}
|
|
86
|
-
const ans = yield prompt_1.default.ask(prompt_1.default.question('collectUsage', 'Allow Catalyst to collect CLI error reporting information?', {
|
|
114
|
+
const ans = yield prompt_1.default.ask(prompt_1.default.question('collectUsage', 'Allow Catalyst to collect CLI error reporting information?', {
|
|
115
|
+
type: 'confirm',
|
|
116
|
+
defaultAns: true
|
|
117
|
+
}), prompt_1.default.question('dc', 'Select the datacenter to which you have access: ', {
|
|
87
118
|
type: 'list',
|
|
88
119
|
choices: Object.keys(constants_1.DC_TYPE).map((dc) => {
|
|
89
120
|
const dcObj = constants_1.DC_TYPE[dc];
|
|
@@ -114,7 +145,11 @@ function logout() {
|
|
|
114
145
|
const activeDC = dc_1.getActiveDC();
|
|
115
146
|
const tokenObj = config_store_1.default.get(`${activeDC}.credential`, null);
|
|
116
147
|
if (tokenObj === null) {
|
|
117
|
-
throw new error_1.default('
|
|
148
|
+
throw new error_1.default('Not logged in', {
|
|
149
|
+
exit: 0,
|
|
150
|
+
errorId: 'IDX-3',
|
|
151
|
+
arg: [ansi_colors_1.bold('catalyst login')]
|
|
152
|
+
});
|
|
118
153
|
}
|
|
119
154
|
const user = config_store_1.default.get(`${activeDC}.user`, null);
|
|
120
155
|
const ans = user === null
|
|
@@ -28,6 +28,7 @@ const constants_1 = require("../util_modules/constants");
|
|
|
28
28
|
const fs_1 = require("../util_modules/fs");
|
|
29
29
|
const js_1 = require("../util_modules/js");
|
|
30
30
|
const logger_1 = require("../util_modules/logger");
|
|
31
|
+
const option_1 = require("../util_modules/option");
|
|
31
32
|
class Login {
|
|
32
33
|
constructor(localhost = true, user = true) {
|
|
33
34
|
this.localhost = localhost;
|
|
@@ -67,7 +68,8 @@ class Login {
|
|
|
67
68
|
}
|
|
68
69
|
_getTokenFromAuthorizationCode(code, callbackUrl) {
|
|
69
70
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
const authCodeResponse = yield new api_1.default()
|
|
71
|
+
const authCodeResponse = yield new api_1.default()
|
|
72
|
+
.post('/oauth/v2/token', {
|
|
71
73
|
origin: constants_1.ORIGIN.auth,
|
|
72
74
|
qs: {
|
|
73
75
|
code,
|
|
@@ -80,6 +82,12 @@ class Login {
|
|
|
80
82
|
skipQuery: true
|
|
81
83
|
},
|
|
82
84
|
authNeeded: false
|
|
85
|
+
})
|
|
86
|
+
.catch((err) => {
|
|
87
|
+
throw new error_1.default('Error when getting the token from authorization code', {
|
|
88
|
+
exit: 2,
|
|
89
|
+
original: err
|
|
90
|
+
});
|
|
83
91
|
});
|
|
84
92
|
if (!js_1.JS.hasIn(authCodeResponse, 'body.access_token') ||
|
|
85
93
|
!js_1.JS.hasIn(authCodeResponse, 'body.refresh_token')) {
|
|
@@ -100,7 +108,8 @@ class Login {
|
|
|
100
108
|
}
|
|
101
109
|
_getTokenFromDeviceCode(code, retryCount = 0) {
|
|
102
110
|
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
-
const deviceCodeResponse = yield new api_1.default()
|
|
111
|
+
const deviceCodeResponse = yield new api_1.default()
|
|
112
|
+
.post('/oauth/v3/device/token', {
|
|
104
113
|
origin: constants_1.ORIGIN.auth,
|
|
105
114
|
qs: {
|
|
106
115
|
client_id: constants_1.AUTH.mobile.id,
|
|
@@ -113,6 +122,12 @@ class Login {
|
|
|
113
122
|
skipQuery: true
|
|
114
123
|
},
|
|
115
124
|
authNeeded: false
|
|
125
|
+
})
|
|
126
|
+
.catch((err) => {
|
|
127
|
+
throw new error_1.default('Error when getting access token from device code', {
|
|
128
|
+
exit: 2,
|
|
129
|
+
original: err
|
|
130
|
+
});
|
|
116
131
|
});
|
|
117
132
|
if (!js_1.JS.hasIn(deviceCodeResponse, 'body.access_token') ||
|
|
118
133
|
!js_1.JS.hasIn(deviceCodeResponse, 'body.refresh_token')) {
|
|
@@ -123,7 +138,19 @@ class Login {
|
|
|
123
138
|
JSON.stringify(deviceCodeResponse.body));
|
|
124
139
|
logger_1.debug('> polling <');
|
|
125
140
|
if (++retryCount > 30) {
|
|
126
|
-
|
|
141
|
+
if (option_1.getCurrentCommand() === 'login') {
|
|
142
|
+
throw new error_1.default('Unable to get refresh_token from code', {
|
|
143
|
+
exit: 0,
|
|
144
|
+
errorId: 'LOGIN-1'
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
throw new error_1.default('Unable to get refresh_token from code', {
|
|
149
|
+
exit: 1,
|
|
150
|
+
errorId: 'LOGIN-2',
|
|
151
|
+
arg: [ansi_colors_1.bold('catalyst token:generate')]
|
|
152
|
+
});
|
|
153
|
+
}
|
|
127
154
|
}
|
|
128
155
|
yield js_1.JS.sleep(2000);
|
|
129
156
|
return this._getTokenFromDeviceCode(code, retryCount);
|
|
@@ -152,9 +179,16 @@ class Login {
|
|
|
152
179
|
if (!this.user) {
|
|
153
180
|
return undefined;
|
|
154
181
|
}
|
|
155
|
-
const userInfoResponse = yield new api_1.default()
|
|
182
|
+
const userInfoResponse = yield new api_1.default()
|
|
183
|
+
.get('/oauth/user/info', {
|
|
156
184
|
origin: constants_1.ORIGIN.auth,
|
|
157
185
|
authNeeded: true
|
|
186
|
+
})
|
|
187
|
+
.catch((err) => {
|
|
188
|
+
throw new error_1.default('Error when trying to get the user details', {
|
|
189
|
+
exit: 2,
|
|
190
|
+
original: err
|
|
191
|
+
});
|
|
158
192
|
});
|
|
159
193
|
if (!js_1.JS.hasIn(userInfoResponse, 'body.Email') && !js_1.JS.hasIn(userInfoResponse, 'body.ZUID')) {
|
|
160
194
|
logger_1.debug('User Details Fetch Error:\n' +
|
|
@@ -175,7 +209,8 @@ class Login {
|
|
|
175
209
|
this.salt = 'm';
|
|
176
210
|
const throbber = throbber_1.default.getInstance();
|
|
177
211
|
const throbberName = 'authentication';
|
|
178
|
-
const deviceCodeResponse = yield new api_1.default()
|
|
212
|
+
const deviceCodeResponse = yield new api_1.default()
|
|
213
|
+
.post('/oauth/v3/device/code', {
|
|
179
214
|
origin: constants_1.ORIGIN.auth,
|
|
180
215
|
qs: {
|
|
181
216
|
client_id: constants_1.AUTH.mobile.id,
|
|
@@ -185,6 +220,12 @@ class Login {
|
|
|
185
220
|
prompt: 'consent'
|
|
186
221
|
},
|
|
187
222
|
authNeeded: false
|
|
223
|
+
})
|
|
224
|
+
.catch((err) => {
|
|
225
|
+
throw new error_1.default('Error when getting code from zoho', {
|
|
226
|
+
exit: 2,
|
|
227
|
+
original: err
|
|
228
|
+
});
|
|
188
229
|
});
|
|
189
230
|
if (!js_1.JS.hasIn(deviceCodeResponse, 'body.user_code') ||
|
|
190
231
|
!js_1.JS.hasIn(deviceCodeResponse, 'body.device_code')) {
|
|
@@ -193,8 +234,10 @@ class Login {
|
|
|
193
234
|
deviceCodeResponse.status +
|
|
194
235
|
', Body: ' +
|
|
195
236
|
JSON.stringify(deviceCodeResponse.body));
|
|
196
|
-
throw new error_1.default('Unable to get code from zoho
|
|
197
|
-
|
|
237
|
+
throw new error_1.default('Unable to get code from zoho', {
|
|
238
|
+
exit: 1,
|
|
239
|
+
errorId: 'LOGIN-3'
|
|
240
|
+
});
|
|
198
241
|
}
|
|
199
242
|
logger_1.info();
|
|
200
243
|
logger_1.info('Visit this URL on any device: \n');
|
|
@@ -205,7 +248,7 @@ class Login {
|
|
|
205
248
|
' and click verify to continue.');
|
|
206
249
|
const deviceCode = js_1.JS.get(deviceCodeResponse, 'body.device_code');
|
|
207
250
|
yield js_1.JS.sleep(10000);
|
|
208
|
-
throbber.add(throbberName, { text: 'checking if the code has been
|
|
251
|
+
throbber.add(throbberName, { text: 'checking if the code has been entered' });
|
|
209
252
|
try {
|
|
210
253
|
const result = yield this._getTokenFromDeviceCode(deviceCode);
|
|
211
254
|
js_1.JS.set(result, 'token', this.salt + '_' + result.refresh_token);
|