@sonisoft/now-sdk-ext-cli 5.6.0 → 5.7.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 +139 -80
- package/dist/commands/auth/browser-session.js +2 -2
- package/dist/commands/auth/browser-session.js.map +1 -1
- package/dist/commands/auth/open.d.ts +19 -0
- package/dist/commands/auth/open.d.ts.map +1 -0
- package/dist/commands/auth/open.js +88 -0
- package/dist/commands/auth/open.js.map +1 -0
- package/dist/commands/exec/index.d.ts +2 -0
- package/dist/commands/exec/index.d.ts.map +1 -1
- package/dist/commands/exec/index.js +24 -1
- package/dist/commands/exec/index.js.map +1 -1
- package/dist/common/scope-autocomplete.d.ts.map +1 -1
- package/dist/common/scope-autocomplete.js +5 -3
- package/dist/common/scope-autocomplete.js.map +1 -1
- package/dist/common/script-scope-error.d.ts +32 -0
- package/dist/common/script-scope-error.d.ts.map +1 -0
- package/dist/common/script-scope-error.js +46 -0
- package/dist/common/script-scope-error.js.map +1 -0
- package/dist/common/sdk-logger.d.ts +9 -0
- package/dist/common/sdk-logger.d.ts.map +1 -0
- package/dist/common/sdk-logger.js +21 -0
- package/dist/common/sdk-logger.js.map +1 -0
- package/dist/services/desktop-browser.service.d.ts +56 -0
- package/dist/services/desktop-browser.service.d.ts.map +1 -0
- package/dist/services/desktop-browser.service.js +283 -0
- package/dist/services/desktop-browser.service.js.map +1 -0
- package/oclif.manifest.json +529 -438
- package/package.json +6 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Command, Flags } from '@oclif/core';
|
|
2
|
-
import { logger as sdkLogger } from '@servicenow/sdk-cli/dist/logger/index.js';
|
|
3
2
|
import { createBrowserSession } from '@sonisoft/now-sdk-ext-core';
|
|
3
|
+
import { silenceSdkLoggers } from '../../common/sdk-logger.js';
|
|
4
4
|
import { writeBrowserSession } from '../../services/browser-session-writer.js';
|
|
5
5
|
export default class BrowserSessionCommand extends Command {
|
|
6
6
|
static description = 'Create a verified Playwright cookie session using a stored SDK alias.';
|
|
@@ -13,7 +13,7 @@ export default class BrowserSessionCommand extends Command {
|
|
|
13
13
|
};
|
|
14
14
|
async run() {
|
|
15
15
|
const { flags } = await this.parse(BrowserSessionCommand);
|
|
16
|
-
|
|
16
|
+
silenceSdkLoggers();
|
|
17
17
|
if ((flags['cred-store'] || process.env.SN_CRED_STORE_ENABLE) && process.env.NOW_SDK_KEYCHAIN_PATCHED !== '1') {
|
|
18
18
|
this.error('The requested credential store is inactive. Unset SN_CRED_STORE_DISABLE and check nex auth doctor.');
|
|
19
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-session.js","sourceRoot":"","sources":["../../../src/commands/auth/browser-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"browser-session.js","sourceRoot":"","sources":["../../../src/commands/auth/browser-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAC,oBAAoB,EAAC,MAAM,4BAA4B,CAAA;AAE/D,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EAAC,mBAAmB,EAAC,MAAM,0CAA0C,CAAA;AAE5E,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,OAAO;IACxD,MAAM,CAAC,WAAW,GAAG,uEAAuE,CAAA;IAC5F,MAAM,CAAC,cAAc,GAAG,IAAI,CAAA;IAC5B,MAAM,CAAC,KAAK,GAAG;QACb,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,EAAC,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,8BAA8B,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC;QAC5F,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC,EAAC,WAAW,EAAE,oCAAoC,EAAC,CAAC;QAChF,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,EAAC,WAAW,EAAE,0CAA0C,EAAC,CAAC;QAC/E,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,EAAC,WAAW,EAAE,2CAA2C,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC;KACjG,CAAA;IAED,KAAK,CAAC,GAAG;QACP,MAAM,EAAC,KAAK,EAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAA;QACvD,iBAAiB,EAAE,CAAA;QACnB,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,wBAAwB,KAAK,GAAG,EAAE,CAAC;YAC9G,IAAI,CAAC,KAAK,CAAC,oGAAoG,CAAC,CAAA;QAClH,CAAC;QAED,MAAM,OAAO,GAAG,MAAM,oBAAoB,CAAC,EAAC,KAAK,EAAE,KAAK,CAAC,IAAI,EAAC,CAAC,CAAA;QAC/D,MAAM,IAAI,GAAG,MAAM,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,CAAA;QAC1E,MAAM,QAAQ,GAAG;YACf,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW;YACpF,cAAc,EAAE,OAAO,CAAC,cAAc,EAAE,IAAI;SAC7C,CAAA;QACD,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACvC,OAAO,QAAQ,CAAA;IACjB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class AuthOpen extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static enableJsonFlag: boolean;
|
|
5
|
+
static examples: {
|
|
6
|
+
command: string;
|
|
7
|
+
description: string;
|
|
8
|
+
}[];
|
|
9
|
+
static flags: {
|
|
10
|
+
auth: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
11
|
+
browser: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<"brave" | "chrome" | "edge", import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
12
|
+
cdp: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
13
|
+
'cred-store': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
14
|
+
force: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
15
|
+
output: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
16
|
+
};
|
|
17
|
+
run(): Promise<unknown>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=open.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open.d.ts","sourceRoot":"","sources":["../../../src/commands/auth/open.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAQ,MAAM,aAAa,CAAA;AAwB1C,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,OAAO;IAC3C,MAAM,CAAC,WAAW,SAAwF;IAC1G,MAAM,CAAC,cAAc,UAAO;IAC5B,MAAM,CAAC,QAAQ;;;QAId;IACD,MAAM,CAAC,KAAK;;;;;;;MAWX;IAEK,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC;CAmD9B"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Command, Flags } from '@oclif/core';
|
|
2
|
+
import { createBrowserSession, injectBrowserSessionCdp } from '@sonisoft/now-sdk-ext-core';
|
|
3
|
+
import { mkdir } from 'node:fs/promises';
|
|
4
|
+
import { silenceSdkLoggers } from '../../common/sdk-logger.js';
|
|
5
|
+
import { writeBrowserSession } from '../../services/browser-session-writer.js';
|
|
6
|
+
import { allocateLoopbackPort, BROWSER_LABELS, isWindowsBrowserBinary, isWsl, profileDirectory, resolveBrowserBinary, spawnDedicatedBrowser, startWslWindowsCdpBridge, } from '../../services/desktop-browser.service.js';
|
|
7
|
+
function remediationOf(error) {
|
|
8
|
+
if (!error || typeof error !== 'object')
|
|
9
|
+
return;
|
|
10
|
+
const value = error;
|
|
11
|
+
return typeof value.remediation === 'string' ? value.remediation : undefined;
|
|
12
|
+
}
|
|
13
|
+
export default class AuthOpen extends Command {
|
|
14
|
+
static description = 'Open a verified UI session in a dedicated desktop browser using a stored SDK alias.';
|
|
15
|
+
static enableJsonFlag = true;
|
|
16
|
+
static examples = [
|
|
17
|
+
{ command: '<%= config.bin %> <%= command.id %> -a bcbsscdev --cred-store', description: 'Open the alias in Edge' },
|
|
18
|
+
{ command: '<%= config.bin %> <%= command.id %> -a dev206299 --browser chrome', description: 'Open in Chrome' },
|
|
19
|
+
{ command: '<%= config.bin %> <%= command.id %> -a dev206299 --cdp http://127.0.0.1:9222', description: 'Inject into an already-debuggable browser' },
|
|
20
|
+
];
|
|
21
|
+
static flags = {
|
|
22
|
+
auth: Flags.string({ char: 'a', description: 'Stored SDK credential alias.', required: true }),
|
|
23
|
+
browser: Flags.option({
|
|
24
|
+
default: 'edge',
|
|
25
|
+
description: 'Desktop browser to launch. Ignored when --cdp is set.',
|
|
26
|
+
options: ['edge', 'chrome', 'brave'],
|
|
27
|
+
})(),
|
|
28
|
+
cdp: Flags.string({ description: 'Existing DevTools URL. Skips launching a browser.' }),
|
|
29
|
+
'cred-store': Flags.boolean({ description: 'Use the headless credential store.' }),
|
|
30
|
+
force: Flags.boolean({ description: 'Replace an existing regular output file.' }),
|
|
31
|
+
output: Flags.string({ description: 'Optional owner-only Playwright storage-state file.' }),
|
|
32
|
+
};
|
|
33
|
+
async run() {
|
|
34
|
+
const { flags } = await this.parse(AuthOpen);
|
|
35
|
+
silenceSdkLoggers();
|
|
36
|
+
if ((flags['cred-store'] || process.env.SN_CRED_STORE_ENABLE) && process.env.NOW_SDK_KEYCHAIN_PATCHED !== '1') {
|
|
37
|
+
this.error('The requested credential store is inactive. Unset SN_CRED_STORE_DISABLE and check nex auth doctor.');
|
|
38
|
+
}
|
|
39
|
+
const browser = flags.browser;
|
|
40
|
+
let disposeBridge;
|
|
41
|
+
try {
|
|
42
|
+
const session = await createBrowserSession({ alias: flags.auth });
|
|
43
|
+
const path = flags.output ? await writeBrowserSession(session, flags.output, flags.force) : undefined;
|
|
44
|
+
let cdpUrl = flags.cdp;
|
|
45
|
+
if (!cdpUrl) {
|
|
46
|
+
const binary = await resolveBrowserBinary(browser);
|
|
47
|
+
if (isWsl() && isWindowsBrowserBinary(binary)) {
|
|
48
|
+
const bridge = await startWslWindowsCdpBridge(flags.auth, binary);
|
|
49
|
+
cdpUrl = bridge.cdpUrl;
|
|
50
|
+
disposeBridge = bridge.dispose;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
const port = await allocateLoopbackPort();
|
|
54
|
+
const userDataDir = profileDirectory(flags.auth);
|
|
55
|
+
await mkdir(userDataDir, { mode: 0o700, recursive: true });
|
|
56
|
+
spawnDedicatedBrowser({ binary, port, userDataDir });
|
|
57
|
+
cdpUrl = `http://127.0.0.1:${port}`;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
await injectBrowserSessionCdp({
|
|
61
|
+
cdpUrl,
|
|
62
|
+
session,
|
|
63
|
+
...(disposeBridge ? { timeoutMs: 30_000 } : {}),
|
|
64
|
+
});
|
|
65
|
+
const metadata = {
|
|
66
|
+
alias: session.alias,
|
|
67
|
+
browser,
|
|
68
|
+
cdpUrl,
|
|
69
|
+
instanceUrl: session.instanceUrl,
|
|
70
|
+
...(path ? { path } : {}),
|
|
71
|
+
...(session.oauthExpiresAt ? { oauthExpiresAt: session.oauthExpiresAt } : {}),
|
|
72
|
+
};
|
|
73
|
+
if (!this.jsonEnabled())
|
|
74
|
+
this.log(`Opened ${session.instanceUrl} in ${BROWSER_LABELS[browser]}`);
|
|
75
|
+
return metadata;
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
const remediation = remediationOf(error);
|
|
79
|
+
if (remediation)
|
|
80
|
+
this.error(remediation);
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
finally {
|
|
84
|
+
disposeBridge?.();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=open.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open.js","sourceRoot":"","sources":["../../../src/commands/auth/open.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAC,oBAAoB,EAAE,uBAAuB,EAAC,MAAM,4BAA4B,CAAA;AACxF,OAAO,EAAC,KAAK,EAAC,MAAM,kBAAkB,CAAA;AAEtC,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EAAC,mBAAmB,EAAC,MAAM,0CAA0C,CAAA;AAC5E,OAAO,EACL,oBAAoB,EACpB,cAAc,EAEd,sBAAsB,EACtB,KAAK,EACL,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,wBAAwB,GACzB,MAAM,2CAA2C,CAAA;AAElD,SAAS,aAAa,CAAC,KAAc;IACnC,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAM;IAC/C,MAAM,KAAK,GAAG,KAAgC,CAAA;IAC9C,OAAO,OAAO,KAAK,CAAC,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAA;AAC9E,CAAC;AAED,MAAM,CAAC,OAAO,OAAO,Q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,oBAAoB,IAAI,EAAE,CAAA;gBACrC,CAAC;YACH,CAAC;YAED,MAAM,uBAAuB,CAAC;gBAC5B,MAAM;gBACN,OAAO;gBACP,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,EAAC,SAAS,EAAE,MAAM,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC;aAC9C,CAAC,CAAA;YACF,MAAM,QAAQ,GAAG;gBACf,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,OAAO;gBACP,MAAM;gBACN,WAAW,EAAE,OAAO,CAAC,WAAW;gBAChC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAC,IAAI,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBACvB,GAAG,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,EAAC,cAAc,EAAE,OAAO,CAAC,cAAc,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC;aAC5E,CAAA;YACD,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;gBAAE,IAAI,CAAC,GAAG,CAAC,UAAU,OAAO,CAAC,WAAW,OAAO,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;YAChG,OAAO,QAAQ,CAAA;QACjB,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,MAAM,WAAW,GAAG,aAAa,CAAC,KAAK,CAAC,CAAA;YACxC,IAAI,WAAW;gBAAE,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;YACxC,MAAM,KAAK,CAAA;QACb,CAAC;gBAAS,CAAC;YACT,aAAa,EAAE,EAAE,CAAA;QACnB,CAAC;IACH,CAAC"}
|
|
@@ -19,6 +19,8 @@ export declare class Exec extends AuthenticatedCommand<typeof Exec> {
|
|
|
19
19
|
};
|
|
20
20
|
run(): Promise<void>;
|
|
21
21
|
private applyParameters;
|
|
22
|
+
/** The flags that pick this connection, for repeating on a suggested command. */
|
|
23
|
+
private connectionArgs;
|
|
22
24
|
private executeFromFile;
|
|
23
25
|
private executeScript;
|
|
24
26
|
private startREPL;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/exec/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/exec/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAA;AAK5E,qBAAa,IAAK,SAAQ,oBAAoB,CAAC,OAAO,IAAI,CAAC;IAEzD,MAAM,CAAC,IAAI;;;MAMV;IAED,MAAM,CAAC,YAAY;mBAEA;YAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;SAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;MASlE;IACH,MAAM,CAAC,WAAW,SAgDwD;IAC1E,MAAM,CAAC,QAAQ;;;QAyCZ;IACH,MAAM,CAAC,KAAK;;MAMT;IAIK,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAc1B,OAAO,CAAC,eAAe;IAUvB,iFAAiF;IACjF,OAAO,CAAC,cAAc;YAOR,eAAe;YA0Bf,aAAa;YAyBb,SAAS;CAiIxB"}
|
|
@@ -7,11 +7,12 @@ import path from 'node:path';
|
|
|
7
7
|
import * as readline from 'node:readline';
|
|
8
8
|
import { AuthenticatedCommand } from '../../common/authenticated-command.js';
|
|
9
9
|
import { getCachedScopes } from '../../common/scope-autocomplete.js';
|
|
10
|
+
import { isScriptScopeError, scriptScopeSuggestions } from '../../common/script-scope-error.js';
|
|
10
11
|
import { ScriptParameterService } from '../../services/script-parameter.service.js';
|
|
11
12
|
export class Exec extends AuthenticatedCommand {
|
|
12
13
|
static args = {
|
|
13
14
|
scope: Args.string({
|
|
14
|
-
description: 'Scope to execute script in
|
|
15
|
+
description: 'Scope to execute script in: "global", the scope of an application developed on the instance (sys_app), or a scope sys_id. Installed store apps cannot be used.',
|
|
15
16
|
required: true
|
|
16
17
|
}),
|
|
17
18
|
file: Args.string({ description: 'File to execute in scripts background. If omitted, starts REPL mode.', required: false }),
|
|
@@ -53,6 +54,10 @@ export class Exec extends AuthenticatedCommand {
|
|
|
53
54
|
' • Multiple parameters supported\n' +
|
|
54
55
|
' • All occurrences of each placeholder are replaced\n' +
|
|
55
56
|
' • Example: {token}, {username}, {environment}\n\n' +
|
|
57
|
+
'Scopes:\n' +
|
|
58
|
+
' Scripts - Background runs in "global" or in an application developed on the instance (sys_app).\n' +
|
|
59
|
+
' Installed store/repository apps (sys_store_app) cannot be used: run in global and call their\n' +
|
|
60
|
+
' APIs fully qualified (e.g. sn_app.Util). An unusable scope fails before the script is sent.\n\n' +
|
|
56
61
|
'REPL Controls:\n' +
|
|
57
62
|
' • Press Enter to add a new line\n' +
|
|
58
63
|
' • Type .exec or press Ctrl+D to execute the script\n' +
|
|
@@ -148,6 +153,13 @@ export class Exec extends AuthenticatedCommand {
|
|
|
148
153
|
return script;
|
|
149
154
|
}
|
|
150
155
|
}
|
|
156
|
+
/** The flags that pick this connection, for repeating on a suggested command. */
|
|
157
|
+
connectionArgs() {
|
|
158
|
+
return [
|
|
159
|
+
this.flags.auth ? `--auth ${this.flags.auth}` : '',
|
|
160
|
+
this.flags['cred-store'] ? '--cred-store' : '',
|
|
161
|
+
].filter(Boolean).join(' ');
|
|
162
|
+
}
|
|
151
163
|
async executeFromFile(filePath, scope, params) {
|
|
152
164
|
this.log(`Executing script from file: ${filePath}`);
|
|
153
165
|
this.log(`Scope: ${scope}`);
|
|
@@ -163,6 +175,11 @@ export class Exec extends AuthenticatedCommand {
|
|
|
163
175
|
}
|
|
164
176
|
catch (error) {
|
|
165
177
|
this._logger.error("Error occurred when executing background script from file.", error);
|
|
178
|
+
// The message already says what is wrong and what to do; the suggestions turn
|
|
179
|
+
// that into commands. The script was never sent to the instance.
|
|
180
|
+
if (isScriptScopeError(error)) {
|
|
181
|
+
this.error(error.message, { exit: 2, suggestions: scriptScopeSuggestions(error, this.connectionArgs()) });
|
|
182
|
+
}
|
|
166
183
|
this.error(error);
|
|
167
184
|
}
|
|
168
185
|
}
|
|
@@ -228,6 +245,12 @@ export class Exec extends AuthenticatedCommand {
|
|
|
228
245
|
this.log(`\n ${'─'.repeat(63)}`);
|
|
229
246
|
this.log(` ✗ Script execution failed`);
|
|
230
247
|
this.log(` Error: ${error.message}\n`);
|
|
248
|
+
if (isScriptScopeError(error)) {
|
|
249
|
+
for (const suggestion of scriptScopeSuggestions(error, this.connectionArgs())) {
|
|
250
|
+
this.log(` • ${suggestion}`);
|
|
251
|
+
}
|
|
252
|
+
this.log(` (Exit and restart the REPL with a different scope.)\n`);
|
|
253
|
+
}
|
|
231
254
|
}
|
|
232
255
|
scriptBuffer = [];
|
|
233
256
|
lineCount = 0;
|
|
@@ -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,EAAW,KAAK,EAAC,MAAM,aAAa,CAAA;AAChD,OAAO,EAAG,wBAAwB,EAAW,aAAa,EAAuB,MAAM,4BAA4B,CAAC;AACpH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAE1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAA;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAA;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAA;AAEnF,MAAM,OAAO,IAAK,SAAQ,oBAAiC;IAEzD,MAAM,CAAC,IAAI,GAAG;QACZ,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC;YACjB,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js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AEH,gBAAgB;QAChB,IAAI,UAAU,GAAG,CAAC,CAAC;QACnB,EAAE,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;YACnB,UAAU,EAAE,CAAC;YACb,IAAI,UAAU,KAAK,CAAC,EAAE,CAAC;gBACrB,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAC5B,6BAA6B;oBAC7B,IAAI,CAAC,GAAG,CAAC,qDAAqD,CAAC,CAAC;oBAChE,WAAW,EAAE,CAAC;oBACd,UAAU,GAAG,CAAC,CAAC;gBACjB,CAAC;qBAAM,CAAC;oBACN,IAAI,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;oBAC/C,EAAE,CAAC,MAAM,EAAE,CAAC;gBACd,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,sBAAsB;gBACtB,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;gBAC9B,EAAE,CAAC,KAAK,EAAE,CAAC;gBACX,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACf,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,MAAM,EAAE,CAAC;IACd,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope-autocomplete.d.ts","sourceRoot":"","sources":["../../src/common/scope-autocomplete.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AA6BD;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,GAAE,MAAW,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"scope-autocomplete.d.ts","sourceRoot":"","sources":["../../src/common/scope-autocomplete.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AA6BD;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,GAAE,MAAW,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAmEvG;AAQD;;;;;;GAMG;AACH,wBAAsB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,GAAE,MAAW,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAY3G"}
|
|
@@ -42,12 +42,14 @@ export async function queryScopes(authAlias, prefix = '') {
|
|
|
42
42
|
credential
|
|
43
43
|
};
|
|
44
44
|
const instance = new ServiceNowInstance(snSettings);
|
|
45
|
-
// Query sys_scope
|
|
46
|
-
|
|
45
|
+
// Query sys_app, not sys_scope: Scripts - Background only runs in global or an
|
|
46
|
+
// application developed on the instance, so store apps would be offered only to be
|
|
47
|
+
// rejected. Global-scoped sys_apps are excluded — exec already offers "global".
|
|
48
|
+
const url = `${instance.getHost()}/api/now/table/sys_app`;
|
|
47
49
|
const params = new URLSearchParams({
|
|
48
50
|
sysparm_fields: 'scope,name',
|
|
49
51
|
sysparm_limit: '50',
|
|
50
|
-
sysparm_query: prefix ?
|
|
52
|
+
sysparm_query: `scope!=global${prefix ? `^scopeSTARTSWITH${prefix}^ORnameSTARTSWITH${prefix}` : ''}`
|
|
51
53
|
});
|
|
52
54
|
const response = await fetch(`${url}?${params.toString()}`, {
|
|
53
55
|
headers: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope-autocomplete.js","sourceRoot":"","sources":["../../src/common/scope-autocomplete.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAA8B,MAAM,4BAA4B,CAAC;AAgB5F;;;;;GAKG;AACH,SAAS,aAAa,CAAC,UAAiB,EAAE,QAAgB;IACxD,IAAI,UAAU,CAAC,IAAI,KAAK,OAA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AED,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,MAAM,CAAC;QACP,iCAAiC;QACjC,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,GAAG,IAAI,GAAG,EAAmD,CAAC;AAC9E,MAAM,SAAS,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,YAAY;AAE7C;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,SAA6B,EAAE,SAAiB,EAAE;IACtF,MAAM,QAAQ,GAAG,GAAG,SAAS,IAAI,SAAS,IAAI,MAAM,EAAE,CAAC;IACvD,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAExC,IAAI,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,SAAS,CAAC,GAAG,SAAS,EAAE,CAAC;QAC1D,OAAO,MAAM,CAAC,MAAM,CAAC;IACvB,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IACpD,UAAU,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAE5D,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recognising and explaining core's ScriptScopeError — thrown when a script is asked to
|
|
3
|
+
* run in a scope Scripts - Background cannot use (an installed store app, a name that
|
|
4
|
+
* matches nothing, …).
|
|
5
|
+
*
|
|
6
|
+
* Matched on `code` rather than imported from @sonisoft/now-sdk-ext-core: a named import
|
|
7
|
+
* of a symbol the installed core does not export fails the whole module at load time,
|
|
8
|
+
* and `code` is the contract core documents for recognising its errors across copies.
|
|
9
|
+
*/
|
|
10
|
+
export declare const SCRIPT_SCOPE_ERROR_CODE = "NEX_SCRIPT_SCOPE_UNAVAILABLE";
|
|
11
|
+
export interface ScriptScopeErrorLike extends Error {
|
|
12
|
+
code: string;
|
|
13
|
+
/** The record the scope matched when it exists but cannot be used, e.g. a store app. */
|
|
14
|
+
foundAs?: {
|
|
15
|
+
name?: string;
|
|
16
|
+
scope?: string;
|
|
17
|
+
};
|
|
18
|
+
reason?: string;
|
|
19
|
+
remediation?: string;
|
|
20
|
+
/** The scope exactly as passed: a name, or a sys_id. */
|
|
21
|
+
scope?: string;
|
|
22
|
+
}
|
|
23
|
+
export declare function isScriptScopeError(error: unknown): error is ScriptScopeErrorLike;
|
|
24
|
+
/**
|
|
25
|
+
* Next steps a user or agent can act on directly, as `nex` commands.
|
|
26
|
+
*
|
|
27
|
+
* @param error the scope error to explain.
|
|
28
|
+
* @param connectionArgs flags to repeat on each suggested command (`--auth x --cred-store`),
|
|
29
|
+
* so the suggestion can be copied and run as-is.
|
|
30
|
+
*/
|
|
31
|
+
export declare function scriptScopeSuggestions(error: ScriptScopeErrorLike, connectionArgs?: string): string[];
|
|
32
|
+
//# sourceMappingURL=script-scope-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"script-scope-error.d.ts","sourceRoot":"","sources":["../../src/common/script-scope-error.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,eAAO,MAAM,uBAAuB,iCAAiC,CAAA;AAErE,MAAM,WAAW,oBAAqB,SAAQ,KAAK;IACjD,IAAI,EAAE,MAAM,CAAA;IACZ,wFAAwF;IACxF,OAAO,CAAC,EAAE;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAC,CAAA;IACzC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,wDAAwD;IACxD,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,oBAAoB,CAEhF;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,oBAAoB,EAAE,cAAc,GAAE,MAAW,GAAG,MAAM,EAAE,CA4BzG"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recognising and explaining core's ScriptScopeError — thrown when a script is asked to
|
|
3
|
+
* run in a scope Scripts - Background cannot use (an installed store app, a name that
|
|
4
|
+
* matches nothing, …).
|
|
5
|
+
*
|
|
6
|
+
* Matched on `code` rather than imported from @sonisoft/now-sdk-ext-core: a named import
|
|
7
|
+
* of a symbol the installed core does not export fails the whole module at load time,
|
|
8
|
+
* and `code` is the contract core documents for recognising its errors across copies.
|
|
9
|
+
*/
|
|
10
|
+
export const SCRIPT_SCOPE_ERROR_CODE = 'NEX_SCRIPT_SCOPE_UNAVAILABLE';
|
|
11
|
+
export function isScriptScopeError(error) {
|
|
12
|
+
return error instanceof Error && error.code === SCRIPT_SCOPE_ERROR_CODE;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Next steps a user or agent can act on directly, as `nex` commands.
|
|
16
|
+
*
|
|
17
|
+
* @param error the scope error to explain.
|
|
18
|
+
* @param connectionArgs flags to repeat on each suggested command (`--auth x --cred-store`),
|
|
19
|
+
* so the suggestion can be copied and run as-is.
|
|
20
|
+
*/
|
|
21
|
+
export function scriptScopeSuggestions(error, connectionArgs = '') {
|
|
22
|
+
const auth = connectionArgs.trim() ? ` ${connectionArgs.trim()}` : '';
|
|
23
|
+
// When a sys_id was passed, the record it matched supplies the scope name.
|
|
24
|
+
const passedSysId = /^[\dA-Fa-f]{32}$/.test(error.scope ?? '');
|
|
25
|
+
const scopeName = error.foundAs?.scope || (passedSysId ? '' : error.scope ?? '');
|
|
26
|
+
// Letters only: the fragment goes into a quoted encoded query.
|
|
27
|
+
const fragment = scopeName.replace(/^x_/, '').replaceAll(/[^A-Za-z0-9]/g, ' ').trim().split(/\s+/)[0];
|
|
28
|
+
const listScopes = `List the scopes scripts can run in: nex query -t sys_app -f scope,name` +
|
|
29
|
+
`${fragment ? ` -q 'scopeLIKE${fragment}'` : ''}${auth}`;
|
|
30
|
+
switch (error.reason) {
|
|
31
|
+
case 'INVALID_SCOPE_NAME':
|
|
32
|
+
case 'SCOPE_NOT_FOUND': {
|
|
33
|
+
return [listScopes, `Or run in global: nex exec global <file>${auth}`];
|
|
34
|
+
}
|
|
35
|
+
case 'NOT_A_DEVELOPED_APP': {
|
|
36
|
+
return [
|
|
37
|
+
`Run in global and call the app fully qualified, e.g. ${scopeName || '<scope>'}.MyScriptInclude: nex exec global <file>${auth}`,
|
|
38
|
+
listScopes,
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
default: {
|
|
42
|
+
return [error.remediation ?? 'Check that this user can read sys_app and sys_scope, then retry.'];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=script-scope-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"script-scope-error.js","sourceRoot":"","sources":["../../src/common/script-scope-error.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAAG,8BAA8B,CAAA;AAYrE,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,OAAO,KAAK,YAAY,KAAK,IAAK,KAA4B,CAAC,IAAI,KAAK,uBAAuB,CAAA;AACjG,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAA2B,EAAE,iBAAyB,EAAE;IAC7F,MAAM,IAAI,GAAG,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,cAAc,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;IACrE,2EAA2E;IAC3E,MAAM,WAAW,GAAG,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,CAAA;IAC9D,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,EAAE,KAAK,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,CAAA;IAChF,+DAA+D;IAC/D,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;IACrG,MAAM,UAAU,GACd,wEAAwE;QACxE,GAAG,QAAQ,CAAC,CAAC,CAAC,iBAAiB,QAAQ,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,CAAA;IAE1D,QAAQ,KAAK,CAAC,MAAM,EAAE,CAAC;QACrB,KAAK,oBAAoB,CAAC;QAC1B,KAAK,iBAAiB,CAAC,CAAC,CAAC;YACvB,OAAO,CAAC,UAAU,EAAE,2CAA2C,IAAI,EAAE,CAAC,CAAA;QACxE,CAAC;QAED,KAAK,qBAAqB,CAAC,CAAC,CAAC;YAC3B,OAAO;gBACL,wDAAwD,SAAS,IAAI,SAAS,2CAA2C,IAAI,EAAE;gBAC/H,UAAU;aACX,CAAA;QACH,CAAC;QAED,OAAO,CAAC,CAAC,CAAC;YACR,OAAO,CAAC,KAAK,CAAC,WAAW,IAAI,kEAAkE,CAAC,CAAA;QAClG,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Silence every installed SDK logger copy.
|
|
3
|
+
*
|
|
4
|
+
* Core 6.6.0 may nest `@servicenow/sdk-cli` 4.12 beside the CLI's own copy.
|
|
5
|
+
* `createBrowserSession` logs through that nested logger, so silencing only
|
|
6
|
+
* the top-level import leaks `[now-sdk]` refresh lines onto stdout.
|
|
7
|
+
*/
|
|
8
|
+
export declare function silenceSdkLoggers(): void;
|
|
9
|
+
//# sourceMappingURL=sdk-logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk-logger.d.ts","sourceRoot":"","sources":["../../src/common/sdk-logger.ts"],"names":[],"mappings":"AAKA;;;;;;GAMG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAQxC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { logger as sdkLogger } from '@servicenow/sdk-cli/dist/logger/index.js';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
const require = createRequire(import.meta.url);
|
|
4
|
+
/**
|
|
5
|
+
* Silence every installed SDK logger copy.
|
|
6
|
+
*
|
|
7
|
+
* Core 6.6.0 may nest `@servicenow/sdk-cli` 4.12 beside the CLI's own copy.
|
|
8
|
+
* `createBrowserSession` logs through that nested logger, so silencing only
|
|
9
|
+
* the top-level import leaks `[now-sdk]` refresh lines onto stdout.
|
|
10
|
+
*/
|
|
11
|
+
export function silenceSdkLoggers() {
|
|
12
|
+
sdkLogger.setLevel('silent');
|
|
13
|
+
try {
|
|
14
|
+
const coreRequire = createRequire(require.resolve('@sonisoft/now-sdk-ext-core/package.json'));
|
|
15
|
+
coreRequire('@servicenow/sdk-cli/dist/logger/index.js').logger.setLevel('silent');
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
// A single sdk-cli copy is enough.
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=sdk-logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk-logger.js","sourceRoot":"","sources":["../../src/common/sdk-logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,IAAI,SAAS,EAAC,MAAM,0CAA0C,CAAA;AAC5E,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAA;AAEzC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAE9C;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB;IAC/B,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;IAC5B,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,yCAAyC,CAAC,CAAC,CAAA;QAC7F,WAAW,CAAC,0CAA0C,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;IACnF,CAAC;IAAC,MAAM,CAAC;QACP,mCAAmC;IACrC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type ChildProcess, execFile, spawn } from 'node:child_process';
|
|
2
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
|
3
|
+
export type DesktopBrowserName = 'brave' | 'chrome' | 'edge';
|
|
4
|
+
export declare const BROWSER_LABELS: Record<DesktopBrowserName, string>;
|
|
5
|
+
declare const execFileAsync: typeof execFile.__promisify__;
|
|
6
|
+
/** User-mode TCP pipe so WSL can reach a Windows-loopback DevTools port. */
|
|
7
|
+
export declare const CDP_RELAY_SOURCE = "'use strict';\nconst net = require('net');\nconst listenHost = process.argv[2];\nconst port = Number(process.argv[3]);\nif (!listenHost || !Number.isInteger(port)) process.exit(2);\nconst server = net.createServer((client) => {\n const upstream = net.connect(port, '127.0.0.1');\n const close = () => { client.destroy(); upstream.destroy(); };\n client.pipe(upstream);\n upstream.pipe(client);\n client.on('error', close);\n upstream.on('error', close);\n});\nserver.on('error', () => process.exit(1));\nserver.listen(port, listenHost);\n";
|
|
8
|
+
export declare function isWsl(env?: NodeJS.ProcessEnv): boolean;
|
|
9
|
+
export declare function isWindowsBrowserBinary(binary: string): boolean;
|
|
10
|
+
export declare function profileDirectory(alias: string, env?: NodeJS.ProcessEnv): string;
|
|
11
|
+
export declare function toWslPath(windowsPath: string): string;
|
|
12
|
+
export declare function browserCandidates(name: DesktopBrowserName, options?: {
|
|
13
|
+
env?: NodeJS.ProcessEnv;
|
|
14
|
+
platform?: NodeJS.Platform;
|
|
15
|
+
}): string[];
|
|
16
|
+
export declare function resolveBrowserBinary(name: DesktopBrowserName, options?: {
|
|
17
|
+
env?: NodeJS.ProcessEnv;
|
|
18
|
+
exists?: (path: string) => Promise<boolean>;
|
|
19
|
+
platform?: NodeJS.Platform;
|
|
20
|
+
}): Promise<string>;
|
|
21
|
+
export declare function allocateLoopbackPort(): Promise<number>;
|
|
22
|
+
export declare function browserLaunchArgs(port: number, userDataDir: string): string[];
|
|
23
|
+
export declare function spawnDedicatedBrowser(options: {
|
|
24
|
+
binary: string;
|
|
25
|
+
port: number;
|
|
26
|
+
spawn?: typeof spawn;
|
|
27
|
+
userDataDir: string;
|
|
28
|
+
}): ChildProcess;
|
|
29
|
+
export declare function parseDedicatedBrowserPort(commandLine: string, alias: string): number | undefined;
|
|
30
|
+
export declare function findDedicatedWindowsBrowserPort(alias: string, options?: {
|
|
31
|
+
commandLines?: string[];
|
|
32
|
+
execFile?: typeof execFileAsync;
|
|
33
|
+
}): Promise<number | undefined>;
|
|
34
|
+
export declare function windowsProfileDirectory(alias: string, localAppData: string): string;
|
|
35
|
+
export declare function parseProcNetRouteGateway(table: string): string | undefined;
|
|
36
|
+
export declare function wslWindowsHost(env?: NodeJS.ProcessEnv, routeTable?: string): string | undefined;
|
|
37
|
+
export declare function resolveWindowsLocalAppData(env?: NodeJS.ProcessEnv): Promise<string>;
|
|
38
|
+
export declare function readWslWindowsHost(env?: NodeJS.ProcessEnv): Promise<string>;
|
|
39
|
+
export declare function startWslWindowsCdpBridge(alias: string, binary: string, options?: {
|
|
40
|
+
env?: NodeJS.ProcessEnv;
|
|
41
|
+
existingPort?: number;
|
|
42
|
+
exists?: (path: string) => Promise<boolean>;
|
|
43
|
+
host?: string;
|
|
44
|
+
localAppData?: string;
|
|
45
|
+
mkdir?: typeof mkdir;
|
|
46
|
+
nodeBinary?: string;
|
|
47
|
+
port?: number;
|
|
48
|
+
spawn?: typeof spawn;
|
|
49
|
+
writeFile?: typeof writeFile;
|
|
50
|
+
}): Promise<{
|
|
51
|
+
cdpUrl: string;
|
|
52
|
+
dispose: () => void;
|
|
53
|
+
userDataDir: string;
|
|
54
|
+
}>;
|
|
55
|
+
export {};
|
|
56
|
+
//# sourceMappingURL=desktop-browser.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"desktop-browser.service.d.ts","sourceRoot":"","sources":["../../src/services/desktop-browser.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAC,MAAM,oBAAoB,CAAA;AAErE,OAAO,EAAS,KAAK,EAAY,SAAS,EAAC,MAAM,kBAAkB,CAAA;AAMnE,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAA;AAE5D,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAI7D,CAAA;AAGD,QAAA,MAAM,aAAa,+BAAsB,CAAA;AAEzC,4EAA4E;AAC5E,eAAO,MAAM,gBAAgB,qiBAe5B,CAAA;AAED,wBAAgB,KAAK,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,OAAO,CAEnE;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAE9D;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAO5F;AAED,wBAAgB,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAIrD;AA0CD,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,kBAAkB,EACxB,OAAO,GAAE;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAA;CAAM,GAClE,MAAM,EAAE,CASV;AAWD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