@seamapi/cli 0.19.0 → 0.20.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 +4 -4
- package/bin/cli.js +2 -2
- package/bin/cli.js.map +1 -1
- package/lib/auth/operations.d.ts +14 -14
- package/lib/auth/operations.js +39 -32
- package/lib/auth/operations.js.map +1 -1
- package/lib/auth/validate-token.js +1 -1
- package/lib/auth/validate-token.js.map +1 -1
- package/lib/blueprint/index.d.ts +1 -1
- package/lib/blueprint/index.js +2 -2
- package/lib/blueprint/index.js.map +1 -1
- package/lib/blueprint/source-remote.d.ts +2 -2
- package/lib/blueprint/source-remote.js +3 -3
- package/lib/blueprint/source-remote.js.map +1 -1
- package/lib/commands/local/login.js +3 -3
- package/lib/commands/local/login.js.map +1 -1
- package/lib/commands/local/{select-server.d.ts → select-endpoint.d.ts} +1 -1
- package/lib/commands/local/select-endpoint.js +27 -0
- package/lib/commands/local/select-endpoint.js.map +1 -0
- package/lib/commands/registry.js +2 -4
- package/lib/commands/registry.js.map +1 -1
- package/lib/context.d.ts +5 -5
- package/lib/context.js +9 -7
- package/lib/context.js.map +1 -1
- package/lib/env.d.ts +2 -2
- package/lib/env.js +2 -2
- package/lib/env.js.map +1 -1
- package/lib/http/client.js +2 -2
- package/lib/http/client.js.map +1 -1
- package/lib/interactions/endpoint-selection.d.ts +1 -0
- package/lib/interactions/endpoint-selection.js +39 -0
- package/lib/interactions/endpoint-selection.js.map +1 -0
- package/lib/interactions/index.d.ts +1 -1
- package/lib/interactions/index.js +1 -1
- package/lib/interactions/index.js.map +1 -1
- package/lib/interactions/login.js +2 -2
- package/lib/interactions/login.js.map +1 -1
- package/lib/interactions/workspace-id.js +1 -1
- package/lib/interactions/workspace-id.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
- package/src/bin/cli.ts +2 -2
- package/src/lib/auth/operations.ts +43 -35
- package/src/lib/auth/validate-token.ts +1 -1
- package/src/lib/blueprint/index.ts +3 -3
- package/src/lib/blueprint/source-remote.ts +3 -3
- package/src/lib/commands/local/login.ts +3 -3
- package/src/lib/commands/local/select-endpoint.ts +30 -0
- package/src/lib/commands/registry.ts +2 -4
- package/src/lib/context.ts +17 -13
- package/src/lib/env.ts +2 -2
- package/src/lib/http/client.ts +2 -2
- package/src/lib/interactions/{server-selection.ts → endpoint-selection.ts} +16 -13
- package/src/lib/interactions/index.ts +1 -1
- package/src/lib/interactions/login.ts +2 -2
- package/src/lib/interactions/workspace-id.ts +1 -1
- package/src/lib/version.ts +1 -1
- package/lib/commands/local/config-set-fake-server.d.ts +0 -3
- package/lib/commands/local/config-set-fake-server.js +0 -20
- package/lib/commands/local/config-set-fake-server.js.map +0 -1
- package/lib/commands/local/select-server.js +0 -27
- package/lib/commands/local/select-server.js.map +0 -1
- package/lib/interactions/server-selection.d.ts +0 -1
- package/lib/interactions/server-selection.js +0 -36
- package/lib/interactions/server-selection.js.map +0 -1
- package/src/lib/commands/local/config-set-fake-server.ts +0 -21
- package/src/lib/commands/local/select-server.ts +0 -30
|
@@ -2,44 +2,47 @@ import { randomBytes } from 'node:crypto'
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
assertMutable,
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
selectEndpoint,
|
|
6
|
+
selectFakeEndpoint,
|
|
7
7
|
} from 'lib/auth/operations.js'
|
|
8
8
|
import { getConfigStore } from 'lib/config/index.js'
|
|
9
9
|
import { resolveAuth } from 'lib/context.js'
|
|
10
10
|
import { getOutput } from 'lib/output/get-output.js'
|
|
11
11
|
import { promptAutocomplete, promptText } from 'lib/prompt.js'
|
|
12
12
|
|
|
13
|
-
export async function
|
|
13
|
+
export async function interactForEndpointSelection() {
|
|
14
14
|
const config = getConfigStore()
|
|
15
|
-
assertMutable(resolveAuth(config), '
|
|
15
|
+
assertMutable(resolveAuth(config), 'endpoint', 'select an endpoint')
|
|
16
16
|
|
|
17
|
-
const
|
|
17
|
+
const endpoints = [
|
|
18
18
|
'http://localhost:3020',
|
|
19
19
|
'https://connect.getseam.com',
|
|
20
20
|
'https://fakeseamconnect.seam.vc',
|
|
21
21
|
]
|
|
22
22
|
|
|
23
23
|
// Searchable, as selecting a device or a command is.
|
|
24
|
-
const
|
|
25
|
-
message: 'Select
|
|
26
|
-
choices:
|
|
24
|
+
const endpoint = await promptAutocomplete({
|
|
25
|
+
message: 'Select an endpoint:',
|
|
26
|
+
choices: endpoints.map((endpoint) => ({
|
|
27
|
+
label: endpoint,
|
|
28
|
+
value: endpoint,
|
|
29
|
+
})),
|
|
27
30
|
})
|
|
28
31
|
|
|
29
32
|
const output = getOutput()
|
|
30
|
-
if (
|
|
33
|
+
if (endpoint === endpoints[2]) {
|
|
31
34
|
let userUrlSeed = await promptText({
|
|
32
35
|
message:
|
|
33
|
-
'You can input a custom
|
|
36
|
+
'You can input a custom endpoint URL or leave this field empty to use a new fakeserver.',
|
|
34
37
|
})
|
|
35
38
|
|
|
36
39
|
if (userUrlSeed.trim().length === 0) {
|
|
37
40
|
userUrlSeed = randomBytes(5).toString('hex')
|
|
38
41
|
}
|
|
39
|
-
|
|
42
|
+
selectFakeEndpoint({ urlSeed: userUrlSeed, config })
|
|
40
43
|
output.info(`PAT set to use fakeseamconnect with "seam_apikey1_token"`)
|
|
41
44
|
} else {
|
|
42
|
-
|
|
45
|
+
selectEndpoint(endpoint, config)
|
|
43
46
|
}
|
|
44
|
-
output.info(`
|
|
47
|
+
output.info(`Endpoint set to ${endpoint}`)
|
|
45
48
|
}
|
|
@@ -10,9 +10,9 @@ export * from './command-selection.js'
|
|
|
10
10
|
export * from './connected-account.js'
|
|
11
11
|
export * from './custom-metadata.js'
|
|
12
12
|
export * from './device.js'
|
|
13
|
+
export * from './endpoint-selection.js'
|
|
13
14
|
export * from './login.js'
|
|
14
15
|
export * from './resource.js'
|
|
15
|
-
export * from './server-selection.js'
|
|
16
16
|
export * from './timestamp.js'
|
|
17
17
|
export * from './use-remote-api-defs.js'
|
|
18
18
|
export * from './user-identity.js'
|
|
@@ -19,9 +19,9 @@ export const interactForLogin = async () => {
|
|
|
19
19
|
// Refuse before prompting: nothing typed here could be stored.
|
|
20
20
|
assertMutable(auth, 'token', 'log in')
|
|
21
21
|
|
|
22
|
-
if (auth.
|
|
22
|
+
if (auth.endpoint.includes('localhost')) {
|
|
23
23
|
output.info(
|
|
24
|
-
`You're using a local Seam Connect instance, you can enter the API Key to your local user, you can create a new user from:\n\n${auth.
|
|
24
|
+
`You're using a local Seam Connect instance, you can enter the API Key to your local user, you can create a new user from:\n\n${auth.endpoint}/admin/create_user_with_api_key`,
|
|
25
25
|
)
|
|
26
26
|
} else {
|
|
27
27
|
output.info(
|
|
@@ -15,7 +15,7 @@ export const interactForWorkspaceId = async (personalAccessToken?: string) => {
|
|
|
15
15
|
|
|
16
16
|
const seam = personalAccessToken
|
|
17
17
|
? SeamHttpWithoutWorkspace.fromPersonalAccessToken(personalAccessToken, {
|
|
18
|
-
endpoint: resolveAuth(config).
|
|
18
|
+
endpoint: resolveAuth(config).endpoint,
|
|
19
19
|
})
|
|
20
20
|
: await getSeamMultiWorkspace()
|
|
21
21
|
|
package/src/lib/version.ts
CHANGED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { selectFakeServer } from '../../auth/operations.js';
|
|
2
|
-
/** Hidden: a development shortcut, kept out of help and completion. */
|
|
3
|
-
export const configSetFakeServerCommand = {
|
|
4
|
-
definition: {
|
|
5
|
-
path: ['config', 'set', 'fake-server'],
|
|
6
|
-
kind: 'cli',
|
|
7
|
-
title: 'Point the CLI at a fake Seam Connect server.',
|
|
8
|
-
description: '',
|
|
9
|
-
flags: [],
|
|
10
|
-
},
|
|
11
|
-
requiresAuth: false,
|
|
12
|
-
hidden: true,
|
|
13
|
-
execute: async (_invocation, ctx) => {
|
|
14
|
-
const { server } = selectFakeServer({ config: ctx.config });
|
|
15
|
-
ctx.output.info(`Server URL set to ${server}`);
|
|
16
|
-
ctx.output.info(`PAT set to use fakeseamconnect with "seam_apikey1_token"`);
|
|
17
|
-
return { kind: 'done' };
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=config-set-fake-server.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config-set-fake-server.js","sourceRoot":"","sources":["../../../src/lib/commands/local/config-set-fake-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAGzD,uEAAuE;AACvE,MAAM,CAAC,MAAM,0BAA0B,GAAY;IACjD,UAAU,EAAE;QACV,IAAI,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,aAAa,CAAC;QACtC,IAAI,EAAE,KAAK;QACX,KAAK,EAAE,8CAA8C;QACrD,WAAW,EAAE,EAAE;QACf,KAAK,EAAE,EAAE;KACV;IACD,YAAY,EAAE,KAAK;IACnB,MAAM,EAAE,IAAI;IACZ,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,EAAE;QAClC,MAAM,EAAE,MAAM,EAAE,GAAG,gBAAgB,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAA;QAC3D,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,MAAM,EAAE,CAAC,CAAA;QAC9C,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,0DAA0D,CAAC,CAAA;QAC3E,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;IACzB,CAAC;CACF,CAAA"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { assertMutable, selectServer } from '../../auth/operations.js';
|
|
2
|
-
import { stringFlag } from '../../commands/spec.js';
|
|
3
|
-
import { NonInteractiveError } from '../../errors.js';
|
|
4
|
-
import { interactForServerSelection } from '../../interactions/index.js';
|
|
5
|
-
export const selectServerCommand = {
|
|
6
|
-
definition: {
|
|
7
|
-
path: ['select', 'server'],
|
|
8
|
-
kind: 'cli',
|
|
9
|
-
title: 'Select the Seam API server.',
|
|
10
|
-
description: '',
|
|
11
|
-
flags: [stringFlag('server', 'Seam API server to select.')],
|
|
12
|
-
},
|
|
13
|
-
requiresAuth: false,
|
|
14
|
-
execute: async ({ args }, ctx) => {
|
|
15
|
-
assertMutable(ctx.auth, 'server', 'select a server');
|
|
16
|
-
if (args['server']) {
|
|
17
|
-
selectServer(args['server'], ctx.config);
|
|
18
|
-
return { kind: 'done' };
|
|
19
|
-
}
|
|
20
|
-
if (ctx.interactivity === 'non-interactive') {
|
|
21
|
-
throw new NonInteractiveError('Missing required parameter for select server: --server');
|
|
22
|
-
}
|
|
23
|
-
await interactForServerSelection();
|
|
24
|
-
return { kind: 'done' };
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
//# sourceMappingURL=select-server.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"select-server.js","sourceRoot":"","sources":["../../../src/lib/commands/local/select-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAEpE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAA;AAEtE,MAAM,CAAC,MAAM,mBAAmB,GAAY;IAC1C,UAAU,EAAE;QACV,IAAI,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC;QAC1B,IAAI,EAAE,KAAK;QACX,KAAK,EAAE,6BAA6B;QACpC,WAAW,EAAE,EAAE;QACf,KAAK,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,4BAA4B,CAAC,CAAC;KAC5D;IACD,YAAY,EAAE,KAAK;IACnB,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,EAAE;QAC/B,aAAa,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAA;QACpD,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnB,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;YACxC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;QACzB,CAAC;QACD,IAAI,GAAG,CAAC,aAAa,KAAK,iBAAiB,EAAE,CAAC;YAC5C,MAAM,IAAI,mBAAmB,CAC3B,wDAAwD,CACzD,CAAA;QACH,CAAC;QACD,MAAM,0BAA0B,EAAE,CAAA;QAClC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;IACzB,CAAC;CACF,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function interactForServerSelection(): Promise<void>;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { randomBytes } from 'node:crypto';
|
|
2
|
-
import { assertMutable, selectFakeServer, selectServer, } from '../auth/operations.js';
|
|
3
|
-
import { getConfigStore } from '../config/index.js';
|
|
4
|
-
import { resolveAuth } from '../context.js';
|
|
5
|
-
import { getOutput } from '../output/get-output.js';
|
|
6
|
-
import { promptAutocomplete, promptText } from '../prompt.js';
|
|
7
|
-
export async function interactForServerSelection() {
|
|
8
|
-
const config = getConfigStore();
|
|
9
|
-
assertMutable(resolveAuth(config), 'server', 'select a server');
|
|
10
|
-
const servers = [
|
|
11
|
-
'http://localhost:3020',
|
|
12
|
-
'https://connect.getseam.com',
|
|
13
|
-
'https://fakeseamconnect.seam.vc',
|
|
14
|
-
];
|
|
15
|
-
// Searchable, as selecting a device or a command is.
|
|
16
|
-
const server = await promptAutocomplete({
|
|
17
|
-
message: 'Select a server:',
|
|
18
|
-
choices: servers.map((server) => ({ label: server, value: server })),
|
|
19
|
-
});
|
|
20
|
-
const output = getOutput();
|
|
21
|
-
if (server === servers[2]) {
|
|
22
|
-
let userUrlSeed = await promptText({
|
|
23
|
-
message: 'You can input a custom server URL or leave this field empty to use a new fakeserver.',
|
|
24
|
-
});
|
|
25
|
-
if (userUrlSeed.trim().length === 0) {
|
|
26
|
-
userUrlSeed = randomBytes(5).toString('hex');
|
|
27
|
-
}
|
|
28
|
-
selectFakeServer({ urlSeed: userUrlSeed, config });
|
|
29
|
-
output.info(`PAT set to use fakeseamconnect with "seam_apikey1_token"`);
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
selectServer(server, config);
|
|
33
|
-
}
|
|
34
|
-
output.info(`Server set to ${server}`);
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=server-selection.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server-selection.js","sourceRoot":"","sources":["../../src/lib/interactions/server-selection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEzC,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,YAAY,GACb,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE9D,MAAM,CAAC,KAAK,UAAU,0BAA0B;IAC9C,MAAM,MAAM,GAAG,cAAc,EAAE,CAAA;IAC/B,aAAa,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAA;IAE/D,MAAM,OAAO,GAAG;QACd,uBAAuB;QACvB,6BAA6B;QAC7B,iCAAiC;KAClC,CAAA;IAED,qDAAqD;IACrD,MAAM,MAAM,GAAG,MAAM,kBAAkB,CAAC;QACtC,OAAO,EAAE,kBAAkB;QAC3B,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;KACrE,CAAC,CAAA;IAEF,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAC1B,IAAI,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1B,IAAI,WAAW,GAAG,MAAM,UAAU,CAAC;YACjC,OAAO,EACL,sFAAsF;SACzF,CAAC,CAAA;QAEF,IAAI,WAAW,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACpC,WAAW,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QAC9C,CAAC;QACD,gBAAgB,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAA;QAClD,MAAM,CAAC,IAAI,CAAC,0DAA0D,CAAC,CAAA;IACzE,CAAC;SAAM,CAAC;QACN,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC9B,CAAC;IACD,MAAM,CAAC,IAAI,CAAC,iBAAiB,MAAM,EAAE,CAAC,CAAA;AACxC,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { selectFakeServer } from 'lib/auth/operations.js'
|
|
2
|
-
import type { Command } from 'lib/commands/registry.js'
|
|
3
|
-
|
|
4
|
-
/** Hidden: a development shortcut, kept out of help and completion. */
|
|
5
|
-
export const configSetFakeServerCommand: Command = {
|
|
6
|
-
definition: {
|
|
7
|
-
path: ['config', 'set', 'fake-server'],
|
|
8
|
-
kind: 'cli',
|
|
9
|
-
title: 'Point the CLI at a fake Seam Connect server.',
|
|
10
|
-
description: '',
|
|
11
|
-
flags: [],
|
|
12
|
-
},
|
|
13
|
-
requiresAuth: false,
|
|
14
|
-
hidden: true,
|
|
15
|
-
execute: async (_invocation, ctx) => {
|
|
16
|
-
const { server } = selectFakeServer({ config: ctx.config })
|
|
17
|
-
ctx.output.info(`Server URL set to ${server}`)
|
|
18
|
-
ctx.output.info(`PAT set to use fakeseamconnect with "seam_apikey1_token"`)
|
|
19
|
-
return { kind: 'done' }
|
|
20
|
-
},
|
|
21
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { assertMutable, selectServer } from 'lib/auth/operations.js'
|
|
2
|
-
import type { Command } from 'lib/commands/registry.js'
|
|
3
|
-
import { stringFlag } from 'lib/commands/spec.js'
|
|
4
|
-
import { NonInteractiveError } from 'lib/errors.js'
|
|
5
|
-
import { interactForServerSelection } from 'lib/interactions/index.js'
|
|
6
|
-
|
|
7
|
-
export const selectServerCommand: Command = {
|
|
8
|
-
definition: {
|
|
9
|
-
path: ['select', 'server'],
|
|
10
|
-
kind: 'cli',
|
|
11
|
-
title: 'Select the Seam API server.',
|
|
12
|
-
description: '',
|
|
13
|
-
flags: [stringFlag('server', 'Seam API server to select.')],
|
|
14
|
-
},
|
|
15
|
-
requiresAuth: false,
|
|
16
|
-
execute: async ({ args }, ctx) => {
|
|
17
|
-
assertMutable(ctx.auth, 'server', 'select a server')
|
|
18
|
-
if (args['server']) {
|
|
19
|
-
selectServer(args['server'], ctx.config)
|
|
20
|
-
return { kind: 'done' }
|
|
21
|
-
}
|
|
22
|
-
if (ctx.interactivity === 'non-interactive') {
|
|
23
|
-
throw new NonInteractiveError(
|
|
24
|
-
'Missing required parameter for select server: --server',
|
|
25
|
-
)
|
|
26
|
-
}
|
|
27
|
-
await interactForServerSelection()
|
|
28
|
-
return { kind: 'done' }
|
|
29
|
-
},
|
|
30
|
-
}
|