@sonisoft/now-sdk-ext-cli 1.1.0-alpha.3 → 2.0.0-alpha.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.
- package/README.md +1825 -34
- package/dist/commands/app/index.d.ts +4 -1
- package/dist/commands/app/index.d.ts.map +1 -1
- package/dist/commands/app/index.js +25 -4
- package/dist/commands/app/index.js.map +1 -1
- package/dist/commands/app/install.d.ts +4 -1
- package/dist/commands/app/install.d.ts.map +1 -1
- package/dist/commands/app/install.js +40 -6
- package/dist/commands/app/install.js.map +1 -1
- package/dist/commands/app/repo-install.d.ts +19 -0
- package/dist/commands/app/repo-install.d.ts.map +1 -0
- package/dist/commands/app/repo-install.js +173 -0
- package/dist/commands/app/repo-install.js.map +1 -0
- package/dist/commands/app/repo-list.d.ts +17 -0
- package/dist/commands/app/repo-list.d.ts.map +1 -0
- package/dist/commands/app/repo-list.js +152 -0
- package/dist/commands/app/repo-list.js.map +1 -0
- package/dist/commands/app/uninstall.d.ts +16 -0
- package/dist/commands/app/uninstall.d.ts.map +1 -0
- package/dist/commands/app/uninstall.js +70 -0
- package/dist/commands/app/uninstall.js.map +1 -0
- package/dist/commands/atf/index.d.ts +71 -0
- package/dist/commands/atf/index.d.ts.map +1 -0
- package/dist/commands/atf/index.js +256 -0
- package/dist/commands/atf/index.js.map +1 -0
- package/dist/commands/exec/index.d.ts +17 -3
- package/dist/commands/exec/index.d.ts.map +1 -1
- package/dist/commands/exec/index.js +286 -26
- package/dist/commands/exec/index.js.map +1 -1
- package/dist/commands/log/index.d.ts +46 -0
- package/dist/commands/log/index.d.ts.map +1 -0
- package/dist/commands/log/index.js +418 -0
- package/dist/commands/log/index.js.map +1 -0
- package/dist/common/authenticated-command.js +2 -2
- package/dist/common/authenticated-command.js.map +1 -1
- package/dist/common/scope-autocomplete.d.ts +20 -0
- package/dist/common/scope-autocomplete.d.ts.map +1 -0
- package/dist/common/scope-autocomplete.js +94 -0
- package/dist/common/scope-autocomplete.js.map +1 -0
- package/oclif.manifest.json +691 -12
- package/package.json +31 -12
|
@@ -1,51 +1,311 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
2
|
/* eslint-disable perfectionist/sort-objects */
|
|
3
|
-
import { Args } from '@oclif/core';
|
|
3
|
+
import { Args, Flags } from '@oclif/core';
|
|
4
4
|
import { BackgroundScriptExecutor, Logger, NowStringUtil } from '@sonisoft/now-sdk-ext-core';
|
|
5
5
|
import fs from 'node:fs';
|
|
6
6
|
import path from 'node:path';
|
|
7
|
+
import * as readline from 'node:readline';
|
|
7
8
|
import { AuthenticatedCommand } from '../../common/authenticated-command.js';
|
|
9
|
+
import { getCachedScopes } from '../../common/scope-autocomplete.js';
|
|
8
10
|
export class Exec extends AuthenticatedCommand {
|
|
9
11
|
static args = {
|
|
10
|
-
scope: Args.string({
|
|
11
|
-
|
|
12
|
+
scope: Args.string({
|
|
13
|
+
description: 'Scope to execute script in. Use "global" for global scope.',
|
|
14
|
+
required: true
|
|
15
|
+
}),
|
|
16
|
+
file: Args.string({ description: 'File to execute in scripts background. If omitted, starts REPL mode.', required: false }),
|
|
12
17
|
};
|
|
13
|
-
|
|
18
|
+
// Autocomplete hook for scope argument
|
|
19
|
+
static autocomplete = {
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
+
async scope(ctx) {
|
|
22
|
+
const authFlag = ctx.flags?.auth;
|
|
23
|
+
try {
|
|
24
|
+
const scopes = await getCachedScopes(authFlag);
|
|
25
|
+
return ['global', ...scopes];
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return ['global'];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
static description = 'Execute JavaScript on a ServiceNow instance remotely using Scripts - Background.\n\n' +
|
|
33
|
+
'This command allows you to run JavaScript either from files or interactively via REPL mode. ' +
|
|
34
|
+
'It mimics the functionality of the Scripts - Background interface in ServiceNow, providing a way to ' +
|
|
35
|
+
'execute scripts programmatically without manual interaction. The output is returned in real-time and can be ' +
|
|
36
|
+
'piped to other commands or saved to files.\n\n' +
|
|
37
|
+
'Modes:\n' +
|
|
38
|
+
' • File Mode: Provide a file path to execute scripts from a file\n' +
|
|
39
|
+
' • REPL Mode: Omit the file path to start an interactive session\n\n' +
|
|
40
|
+
'Features:\n' +
|
|
41
|
+
' • Execute local JavaScript files remotely\n' +
|
|
42
|
+
' • Interactive REPL for ad-hoc script execution\n' +
|
|
43
|
+
' • Script parameterization with {placeholder} replacement\n' +
|
|
44
|
+
' • Multi-line script support in REPL\n' +
|
|
45
|
+
' • Scope-aware execution (global or custom scope)\n' +
|
|
46
|
+
' • Real-time console output capture\n' +
|
|
47
|
+
' • Pipe-able output for command chaining\n' +
|
|
48
|
+
' • Debug logging support\n' +
|
|
49
|
+
' • Useful for data migration, testing, and administrative tasks\n\n' +
|
|
50
|
+
'Script Parameterization:\n' +
|
|
51
|
+
' Use {paramName} placeholders in your script files, then provide values via --params:\n' +
|
|
52
|
+
' • Supports any JSON-serializable values (strings, numbers, booleans)\n' +
|
|
53
|
+
' • Multiple parameters supported\n' +
|
|
54
|
+
' • All occurrences of each placeholder are replaced\n' +
|
|
55
|
+
' • Example: {token}, {username}, {environment}\n\n' +
|
|
56
|
+
'REPL Controls:\n' +
|
|
57
|
+
' • Press Enter to add a new line\n' +
|
|
58
|
+
' • Type .exec or press Ctrl+D to execute the script\n' +
|
|
59
|
+
' • Type .clear to clear the current input\n' +
|
|
60
|
+
' • Type .exit or press Ctrl+C twice to exit REPL\n\n' +
|
|
61
|
+
'⚠️ IMPORTANT SECURITY WARNING:\n' +
|
|
62
|
+
'This command executes scripts with the same permissions and risks as using Scripts - Background directly\n' +
|
|
63
|
+
'in ServiceNow. Always:\n' +
|
|
64
|
+
' • Review scripts before execution\n' +
|
|
65
|
+
' • Test in non-production environments first\n' +
|
|
66
|
+
' • Use appropriate scoping to limit access\n' +
|
|
67
|
+
' • Be aware of data modification risks\n' +
|
|
68
|
+
' • Follow your organization\'s security policies\n' +
|
|
69
|
+
' • Never execute untrusted scripts\n\n' +
|
|
70
|
+
'Script Capabilities:\n' +
|
|
71
|
+
' Scripts run with full GlideSystem API access and can:\n' +
|
|
72
|
+
' • Query and modify database records\n' +
|
|
73
|
+
' • Create, update, and delete data\n' +
|
|
74
|
+
' • Execute business rules and workflows\n' +
|
|
75
|
+
' • Access all APIs available in Scripts - Background\n' +
|
|
76
|
+
' • Use gs, GlideRecord, GlideAggregate, and other server-side APIs';
|
|
14
77
|
static examples = [
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
78
|
+
{
|
|
79
|
+
description: 'Start REPL in global scope',
|
|
80
|
+
command: '<%= config.bin %> <%= command.id %> global --auth dev-instance',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
description: 'Start REPL in custom application scope',
|
|
84
|
+
command: '<%= config.bin %> <%= command.id %> x_my_custom_app --auth dev-instance',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
description: 'Execute a script file in global scope',
|
|
88
|
+
command: '<%= config.bin %> <%= command.id %> global ./scripts/cleanup.js --auth dev-instance',
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
description: 'Execute a script file in a custom application scope',
|
|
92
|
+
command: '<%= config.bin %> <%= command.id %> x_my_custom_app ./scripts/app-config.js --auth dev-instance',
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
description: 'Execute a parameterized script with single parameter',
|
|
96
|
+
command: '<%= config.bin %> <%= command.id %> global ./scripts/query-user.js --auth dev-instance --params \'{"username":"admin"}\'',
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
description: 'Execute a parameterized script with multiple parameters',
|
|
100
|
+
command: '<%= config.bin %> <%= command.id %> global ./scripts/update-record.js --auth dev-instance --params \'{"table":"incident","field":"priority","value":"1"}\'',
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
description: 'Execute and save output to a file',
|
|
104
|
+
command: '<%= config.bin %> <%= command.id %> global ./scripts/report.js --auth dev-instance > report.txt',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
description: 'Execute and pipe output to grep for filtering',
|
|
108
|
+
command: '<%= config.bin %> <%= command.id %> global ./scripts/list-users.js --auth dev-instance | grep "admin"',
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
description: 'Execute with debug logging to troubleshoot issues',
|
|
112
|
+
command: '<%= config.bin %> <%= command.id %> global ./script.js --auth dev-instance --log-level debug',
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
description: 'Execute with parameters for template replacement',
|
|
116
|
+
command: '<%= config.bin %> <%= command.id %> global ./script.js --auth dev-instance --params \'{"token":"abc123","env":"dev"}\'',
|
|
117
|
+
},
|
|
18
118
|
];
|
|
19
119
|
static flags = {
|
|
20
|
-
|
|
120
|
+
params: Flags.string({
|
|
121
|
+
char: 'p',
|
|
122
|
+
description: 'JSON object of parameters to replace in script file. Use {paramName} syntax in your script.',
|
|
123
|
+
required: false
|
|
124
|
+
}),
|
|
21
125
|
};
|
|
22
126
|
_logger = new Logger("ExecCommand");
|
|
23
127
|
async run() {
|
|
24
128
|
const { args, flags } = await this.parse(Exec);
|
|
25
|
-
if (
|
|
129
|
+
if (NowStringUtil.isStringEmpty(args.scope)) {
|
|
130
|
+
this.error("Scope is required.");
|
|
131
|
+
}
|
|
132
|
+
else if (!NowStringUtil.isStringEmpty(args.file) && args.file) {
|
|
133
|
+
// File mode - execute script from file
|
|
134
|
+
await this.executeFromFile(args.file, args.scope, flags.params);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
// REPL mode - interactive script execution
|
|
138
|
+
await this.startREPL(args.scope);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
applyParameters(script, paramsJson) {
|
|
142
|
+
try {
|
|
143
|
+
const params = JSON.parse(paramsJson);
|
|
144
|
+
if (typeof params !== 'object' || params === null) {
|
|
145
|
+
this.error('Parameters must be a valid JSON object');
|
|
146
|
+
return script;
|
|
147
|
+
}
|
|
148
|
+
let processedScript = script;
|
|
149
|
+
// Replace each parameter in the script
|
|
150
|
+
for (const [key, value] of Object.entries(params)) {
|
|
151
|
+
const placeholder = `{${key}}`;
|
|
152
|
+
const replacement = String(value);
|
|
153
|
+
// Replace all occurrences of the placeholder
|
|
154
|
+
processedScript = processedScript.split(placeholder).join(replacement);
|
|
155
|
+
}
|
|
156
|
+
// Log parameter replacements in debug mode
|
|
157
|
+
this._logger.debug(`Applied ${Object.keys(params).length} parameter replacement(s)`, params);
|
|
158
|
+
return processedScript;
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
this._logger.error("Error parsing parameters JSON", error);
|
|
162
|
+
this.error(`Invalid JSON in --params: ${error.message}`);
|
|
163
|
+
return script;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
async executeFromFile(filePath, scope, params) {
|
|
167
|
+
try {
|
|
168
|
+
const resolvedPath = path.resolve(filePath);
|
|
169
|
+
let script = fs.readFileSync(resolvedPath).toString('utf8');
|
|
170
|
+
// Apply parameter replacement if params provided
|
|
171
|
+
if (params) {
|
|
172
|
+
script = this.applyParameters(script, params);
|
|
173
|
+
}
|
|
174
|
+
await this.executeScript(script, scope);
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
this._logger.error("Error occurred when executing background script from file.", error);
|
|
178
|
+
this.error(error);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
async executeScript(script, scope) {
|
|
182
|
+
try {
|
|
183
|
+
const executor = new BackgroundScriptExecutor(this.instance, scope);
|
|
184
|
+
const result = await executor.executeScript(script, scope, this.instance);
|
|
185
|
+
this._logger.debug("Ran background script", result);
|
|
186
|
+
if (result !== null && result.scriptResults !== null) {
|
|
187
|
+
const { scriptResults } = result;
|
|
188
|
+
for (const scriptResult of scriptResults) {
|
|
189
|
+
console.log(scriptResult.line);
|
|
190
|
+
this._logger.debug(scriptResult.line);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
throw new Error("Response from script execution was null or undefined. Please review logs to identify the problem.");
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
catch (error) {
|
|
198
|
+
this._logger.error("Error occurred when executing background script.", error);
|
|
199
|
+
throw error;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
async startREPL(scope) {
|
|
203
|
+
this.log(`\n╔═══════════════════════════════════════════════════════════════╗`);
|
|
204
|
+
this.log(`║ ServiceNow Script Executor REPL ║`);
|
|
205
|
+
this.log(`╚═══════════════════════════════════════════════════════════════╝`);
|
|
206
|
+
this.log(` Scope: ${scope}`);
|
|
207
|
+
this.log(` Instance: ${this.instance.getHost()}`);
|
|
208
|
+
this.log(`\n Commands:`);
|
|
209
|
+
this.log(` .exec - Execute the current script`);
|
|
210
|
+
this.log(` .clear - Clear the current input`);
|
|
211
|
+
this.log(` .exit - Exit REPL`);
|
|
212
|
+
this.log(` Ctrl+D - Execute the current script`);
|
|
213
|
+
this.log(` Ctrl+C - Cancel current input or exit (press twice)`);
|
|
214
|
+
this.log(`\n Type your script below (press Enter for new lines):\n`);
|
|
215
|
+
const rl = readline.createInterface({
|
|
216
|
+
input: process.stdin,
|
|
217
|
+
output: process.stdout,
|
|
218
|
+
prompt: 'sn> ',
|
|
219
|
+
terminal: true
|
|
220
|
+
});
|
|
221
|
+
let scriptBuffer = [];
|
|
222
|
+
let lineCount = 0;
|
|
223
|
+
const executeBufferedScript = async () => {
|
|
224
|
+
if (scriptBuffer.length === 0) {
|
|
225
|
+
this.log(' (No script to execute)\n');
|
|
226
|
+
rl.prompt();
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
const script = scriptBuffer.join('\n');
|
|
230
|
+
this.log(`\n Executing script (${scriptBuffer.length} lines)...\n`);
|
|
231
|
+
this.log(` ${'─'.repeat(63)}\n`);
|
|
26
232
|
try {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
this.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
233
|
+
await this.executeScript(script, scope);
|
|
234
|
+
this.log(`\n ${'─'.repeat(63)}`);
|
|
235
|
+
this.log(` ✓ Script executed successfully\n`);
|
|
236
|
+
}
|
|
237
|
+
catch (error) {
|
|
238
|
+
this.log(`\n ${'─'.repeat(63)}`);
|
|
239
|
+
this.log(` ✗ Script execution failed`);
|
|
240
|
+
this.log(` Error: ${error.message}\n`);
|
|
241
|
+
}
|
|
242
|
+
scriptBuffer = [];
|
|
243
|
+
lineCount = 0;
|
|
244
|
+
rl.setPrompt('sn> ');
|
|
245
|
+
rl.prompt();
|
|
246
|
+
};
|
|
247
|
+
const clearBuffer = () => {
|
|
248
|
+
scriptBuffer = [];
|
|
249
|
+
lineCount = 0;
|
|
250
|
+
this.log(' (Input cleared)\n');
|
|
251
|
+
rl.setPrompt('sn> ');
|
|
252
|
+
rl.prompt();
|
|
253
|
+
};
|
|
254
|
+
rl.on('line', async (line) => {
|
|
255
|
+
const trimmedLine = line.trim();
|
|
256
|
+
// Handle REPL commands
|
|
257
|
+
if (trimmedLine === '.exec') {
|
|
258
|
+
await executeBufferedScript();
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
if (trimmedLine === '.clear') {
|
|
262
|
+
clearBuffer();
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
if (trimmedLine === '.exit') {
|
|
266
|
+
this.log('\n Goodbye! 👋\n');
|
|
267
|
+
rl.close();
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
// Add line to buffer
|
|
271
|
+
scriptBuffer.push(line);
|
|
272
|
+
lineCount++;
|
|
273
|
+
// Update prompt to show continuation
|
|
274
|
+
rl.setPrompt(`... `);
|
|
275
|
+
rl.prompt();
|
|
276
|
+
});
|
|
277
|
+
rl.on('close', async () => {
|
|
278
|
+
// Execute on Ctrl+D
|
|
279
|
+
if (scriptBuffer.length > 0) {
|
|
280
|
+
this.log('\n');
|
|
281
|
+
await executeBufferedScript();
|
|
282
|
+
}
|
|
283
|
+
this.exit(0);
|
|
284
|
+
});
|
|
285
|
+
// Handle Ctrl+C
|
|
286
|
+
let ctrlCCount = 0;
|
|
287
|
+
rl.on('SIGINT', () => {
|
|
288
|
+
ctrlCCount++;
|
|
289
|
+
if (ctrlCCount === 1) {
|
|
290
|
+
if (scriptBuffer.length > 0) {
|
|
291
|
+
// First Ctrl+C: clear buffer
|
|
292
|
+
this.log('\n (Input cancelled. Press Ctrl+C again to exit)\n');
|
|
293
|
+
clearBuffer();
|
|
294
|
+
ctrlCCount = 0;
|
|
39
295
|
}
|
|
40
296
|
else {
|
|
41
|
-
|
|
297
|
+
this.log('\n (Press Ctrl+C again to exit)\n');
|
|
298
|
+
rl.prompt();
|
|
42
299
|
}
|
|
43
300
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
this.
|
|
301
|
+
else {
|
|
302
|
+
// Second Ctrl+C: exit
|
|
303
|
+
this.log('\n Goodbye! 👋\n');
|
|
304
|
+
rl.close();
|
|
305
|
+
this.exit(0);
|
|
47
306
|
}
|
|
48
|
-
}
|
|
307
|
+
});
|
|
308
|
+
rl.prompt();
|
|
49
309
|
}
|
|
50
310
|
}
|
|
51
311
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/exec/index.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,+CAA+C;AAC/C,OAAO,EAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/exec/index.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,+CAA+C;AAC/C,OAAO,EAAC,IAAI,EAAW,KAAK,EAAC,MAAM,aAAa,CAAA;AAChD,OAAO,EAAG,wBAAwB,EAAG,MA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enticatedCommand } from '../../common/authenticated-command.js';
|
|
2
|
+
export declare class Log extends AuthenticatedCommand<typeof Log> {
|
|
3
|
+
static args: {};
|
|
4
|
+
static description: string;
|
|
5
|
+
static examples: {
|
|
6
|
+
description: string;
|
|
7
|
+
command: string;
|
|
8
|
+
}[];
|
|
9
|
+
static flags: {
|
|
10
|
+
output: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
11
|
+
interval: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<number, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
12
|
+
'no-color': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
13
|
+
filter: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
14
|
+
};
|
|
15
|
+
private _logger;
|
|
16
|
+
private filterRules;
|
|
17
|
+
private syslogReader?;
|
|
18
|
+
run(): Promise<void>;
|
|
19
|
+
private displayHeader;
|
|
20
|
+
private displayLog;
|
|
21
|
+
private handleExit;
|
|
22
|
+
private highlightKeywords;
|
|
23
|
+
/**
|
|
24
|
+
* Check if a log record matches a single filter rule
|
|
25
|
+
* @param log The log record to check
|
|
26
|
+
* @param rule The filter rule to apply
|
|
27
|
+
* @returns true if the log matches the filter, false otherwise
|
|
28
|
+
*/
|
|
29
|
+
private matchesFilter;
|
|
30
|
+
/**
|
|
31
|
+
* Check if a log record matches all filter rules
|
|
32
|
+
* @param log The log record to check
|
|
33
|
+
* @returns true if the log matches all filters (AND logic), false otherwise
|
|
34
|
+
*/
|
|
35
|
+
private matchesFilters;
|
|
36
|
+
/**
|
|
37
|
+
* Parse a filter string into a FilterRule object
|
|
38
|
+
* Supports formats:
|
|
39
|
+
* - "field OPERATOR value"
|
|
40
|
+
* - "OPERATOR value" (defaults to message field)
|
|
41
|
+
* @param filterStr The filter string to parse
|
|
42
|
+
* @returns A FilterRule object
|
|
43
|
+
*/
|
|
44
|
+
private parseFilter;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/log/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAA;AAiB5E,qBAAa,GAAI,SAAQ,oBAAoB,CAAC,OAAO,GAAG,CAAC;IAEvD,MAAM,CAAC,IAAI,KAAK;IAEhB,MAAM,CAAC,WAAW,SAoCiD;IAEnE,MAAM,CAAC,QAAQ;;;QAiCd;IAED,MAAM,CAAC,KAAK;;;;;MA0BX;IAED,OAAO,CAAC,OAAO,CAAoC;IACnD,OAAO,CAAC,WAAW,CAAoB;IACvC,OAAO,CAAC,YAAY,CAAC,CAAe;IAE9B,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IA6D1B,OAAO,CAAC,aAAa;IAoDrB,OAAO,CAAC,UAAU;IA0ElB,OAAO,CAAC,UAAU;IAiBlB,OAAO,CAAC,iBAAiB;IAYzB;;;;;OAKG;IACH,OAAO,CAAC,aAAa;IAyErB;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAatB;;;;;;;OAOG;IACH,OAAO,CAAC,WAAW;CAsDpB"}
|