@aderis-erp/cli 1.0.1 → 1.0.2
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 +1 -1
- package/dist/commands/{access-groups.js → access-groups 2.js } +6 -4
- package/dist/commands/bank-integrations.d.ts +2 -0
- package/dist/commands/bank-integrations.js +11 -1
- package/dist/commands/documents.js +6 -4
- package/dist/commands/inbox.js +1 -1
- package/dist/commands/processing-logs.js +3 -2
- package/dist/commands/{audit-log.d.ts → pubsub.d.ts} +2 -2
- package/dist/commands/{audit-log.js → pubsub.js} +10 -14
- package/dist/commands/sales-invoices.js +2 -1
- package/dist/commands/sales-orders.js +2 -1
- package/dist/lib/auth.js +16 -7
- package/oclif.manifest.json +660 -2403
- package/package.json +1 -1
- package/dist/commands/access-groups.d.ts +0 -39
- package/dist/commands/account-statement-runs.d.ts +0 -40
- package/dist/commands/account-statement-runs.js +0 -1004
- package/dist/commands/account-transactions.d.ts +0 -41
- package/dist/commands/account-transactions.js +0 -1020
- package/dist/commands/accounts.d.ts +0 -40
- package/dist/commands/accounts.js +0 -1012
- package/dist/commands/agent-runs.d.ts +0 -39
- package/dist/commands/agent-runs.js +0 -1001
- package/dist/commands/auth/login.d.ts +0 -14
- package/dist/commands/auth/login.js +0 -116
- package/dist/commands/auth/logout.d.ts +0 -10
- package/dist/commands/auth/logout.js +0 -58
- package/dist/commands/auth/status.d.ts +0 -12
- package/dist/commands/auth/status.js +0 -101
- package/dist/commands/auth/tenant.d.ts +0 -18
- package/dist/commands/auth/tenant.js +0 -168
- package/dist/commands/auth.d.ts +0 -37
- package/dist/commands/auth.js +0 -871
- package/dist/commands/bank-accounts.d.ts +0 -41
- package/dist/commands/bank-accounts.js +0 -1020
- package/dist/commands/bank-statements.d.ts +0 -40
- package/dist/commands/bank-statements.js +0 -998
- package/dist/commands/config/add.d.ts +0 -13
- package/dist/commands/config/add.js +0 -120
- package/dist/commands/config/current.d.ts +0 -9
- package/dist/commands/config/current.js +0 -43
- package/dist/commands/config/delete.d.ts +0 -12
- package/dist/commands/config/delete.js +0 -67
- package/dist/commands/config/list.d.ts +0 -9
- package/dist/commands/config/list.js +0 -50
- package/dist/commands/config/use.d.ts +0 -9
- package/dist/commands/config/use.js +0 -40
- package/dist/commands/salary-types.js +0 -1006
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Command } from '@oclif/core';
|
|
2
|
-
export default class AuthLogin extends Command {
|
|
3
|
-
static description: string;
|
|
4
|
-
static examples: string[];
|
|
5
|
-
static flags: {
|
|
6
|
-
'client-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
-
context: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
-
environment: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
-
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
-
new: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
-
};
|
|
12
|
-
run(): Promise<void>;
|
|
13
|
-
private createNewContext;
|
|
14
|
-
}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { input, select } from '@inquirer/prompts';
|
|
2
|
-
import { Command, Flags } from '@oclif/core';
|
|
3
|
-
import ora from 'ora';
|
|
4
|
-
import { login, testAuth } from '../../lib/auth.js';
|
|
5
|
-
import { addContext, DEFAULT_CLIENT_IDS, getContext, getCurrentContext, } from '../../lib/config.js';
|
|
6
|
-
export default class AuthLogin extends Command {
|
|
7
|
-
static description = 'Login to an Aderis environment using OAuth';
|
|
8
|
-
static examples = [
|
|
9
|
-
'<%= config.bin %> auth login',
|
|
10
|
-
'<%= config.bin %> auth login --context my-client',
|
|
11
|
-
'<%= config.bin %> auth login --new --name my-client --environment dev',
|
|
12
|
-
];
|
|
13
|
-
static flags = {
|
|
14
|
-
'client-id': Flags.string({
|
|
15
|
-
description: 'OAuth client ID (uses default if not specified)',
|
|
16
|
-
}),
|
|
17
|
-
context: Flags.string({
|
|
18
|
-
char: 'c',
|
|
19
|
-
description: 'Context to login with (uses current context if not specified)',
|
|
20
|
-
}),
|
|
21
|
-
environment: Flags.string({
|
|
22
|
-
char: 'e',
|
|
23
|
-
description: 'Environment (dev, test, live)',
|
|
24
|
-
options: ['dev', 'test', 'live'],
|
|
25
|
-
}),
|
|
26
|
-
name: Flags.string({
|
|
27
|
-
description: 'Name for the new context (required with --new)',
|
|
28
|
-
}),
|
|
29
|
-
new: Flags.boolean({
|
|
30
|
-
char: 'n',
|
|
31
|
-
default: false,
|
|
32
|
-
description: 'Create a new context before logging in',
|
|
33
|
-
}),
|
|
34
|
-
};
|
|
35
|
-
async run() {
|
|
36
|
-
const { flags } = await this.parse(AuthLogin);
|
|
37
|
-
let context = null;
|
|
38
|
-
if (flags.new) {
|
|
39
|
-
context = await this.createNewContext(flags);
|
|
40
|
-
}
|
|
41
|
-
else if (flags.context) {
|
|
42
|
-
context = getContext(flags.context);
|
|
43
|
-
if (!context) {
|
|
44
|
-
this.error(`Context "${flags.context}" not found. Use --new to create it.`);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
context = getCurrentContext();
|
|
49
|
-
if (!context) {
|
|
50
|
-
this.log("No context found. Let's create one.");
|
|
51
|
-
context = await this.createNewContext(flags);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
const spinner = ora(`Logging in to ${context.name} (${context.environment})...`).start();
|
|
55
|
-
try {
|
|
56
|
-
spinner.text = 'Waiting for browser authentication...';
|
|
57
|
-
await login(context);
|
|
58
|
-
spinner.text = 'Verifying authentication...';
|
|
59
|
-
const user = await testAuth(context.name);
|
|
60
|
-
spinner.succeed(`Successfully logged in as ${user.email || user.name || 'user'}`);
|
|
61
|
-
this.log(`\nContext: ${context.name}`);
|
|
62
|
-
this.log(`Environment: ${context.environment}`);
|
|
63
|
-
if (context.tenant_id) {
|
|
64
|
-
this.log(`Tenant ID: ${context.tenant_id}`);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
catch (error) {
|
|
68
|
-
spinner.fail('Login failed');
|
|
69
|
-
if (error instanceof Error) {
|
|
70
|
-
this.error(error.message);
|
|
71
|
-
}
|
|
72
|
-
throw error;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
async createNewContext(flags) {
|
|
76
|
-
// Get context name
|
|
77
|
-
let contextName = flags.name;
|
|
78
|
-
if (!contextName) {
|
|
79
|
-
contextName = await input({
|
|
80
|
-
message: 'Context name (e.g., acme-dev, my-company-prod):',
|
|
81
|
-
validate(value) {
|
|
82
|
-
if (!value.trim())
|
|
83
|
-
return 'Name is required';
|
|
84
|
-
if (!/^[\w-]+$/.test(value))
|
|
85
|
-
return 'Name can only contain letters, numbers, and hyphens';
|
|
86
|
-
if (getContext(value))
|
|
87
|
-
return `Context "${value}" already exists`;
|
|
88
|
-
return true;
|
|
89
|
-
},
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
// Get environment
|
|
93
|
-
let environment;
|
|
94
|
-
environment = flags.environment ? flags.environment : (await select({
|
|
95
|
-
choices: [
|
|
96
|
-
{ description: 'Development environment', name: 'dev', value: 'dev' },
|
|
97
|
-
{ description: 'Test/staging environment', name: 'test', value: 'test' },
|
|
98
|
-
{ description: 'Production environment', name: 'live', value: 'live' },
|
|
99
|
-
],
|
|
100
|
-
message: 'Environment:',
|
|
101
|
-
}));
|
|
102
|
-
const defaultClientId = DEFAULT_CLIENT_IDS[environment];
|
|
103
|
-
const clientId = flags['client-id'] || defaultClientId;
|
|
104
|
-
if (!clientId) {
|
|
105
|
-
this.error(`No default client ID configured for ${environment} environment. Please provide --client-id`);
|
|
106
|
-
}
|
|
107
|
-
const context = {
|
|
108
|
-
client_id: clientId,
|
|
109
|
-
environment,
|
|
110
|
-
name: contextName,
|
|
111
|
-
};
|
|
112
|
-
addContext(context);
|
|
113
|
-
this.log(`\nContext "${context.name}" created.`);
|
|
114
|
-
return context;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Command } from '@oclif/core';
|
|
2
|
-
export default class AuthLogout extends Command {
|
|
3
|
-
static description: string;
|
|
4
|
-
static examples: string[];
|
|
5
|
-
static flags: {
|
|
6
|
-
all: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
7
|
-
context: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
-
};
|
|
9
|
-
run(): Promise<void>;
|
|
10
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { Command, Flags } from '@oclif/core';
|
|
2
|
-
import { clearTokens, getContext, getCurrentContext } from '../../lib/config.js';
|
|
3
|
-
export default class AuthLogout extends Command {
|
|
4
|
-
static description = 'Logout from the current or specified context';
|
|
5
|
-
static examples = [
|
|
6
|
-
'<%= config.bin %> auth logout',
|
|
7
|
-
'<%= config.bin %> auth logout --context my-client',
|
|
8
|
-
'<%= config.bin %> auth logout --all',
|
|
9
|
-
];
|
|
10
|
-
static flags = {
|
|
11
|
-
all: Flags.boolean({
|
|
12
|
-
char: 'a',
|
|
13
|
-
default: false,
|
|
14
|
-
description: 'Logout from all contexts',
|
|
15
|
-
}),
|
|
16
|
-
context: Flags.string({
|
|
17
|
-
char: 'c',
|
|
18
|
-
description: 'Specific context to logout from',
|
|
19
|
-
}),
|
|
20
|
-
};
|
|
21
|
-
async run() {
|
|
22
|
-
const { flags } = await this.parse(AuthLogout);
|
|
23
|
-
const { listContexts } = await import('../../lib/config.js');
|
|
24
|
-
if (flags.all) {
|
|
25
|
-
const contexts = listContexts();
|
|
26
|
-
for (const ctx of contexts) {
|
|
27
|
-
if (ctx.tokens) {
|
|
28
|
-
clearTokens(ctx.name);
|
|
29
|
-
this.log(`Logged out from ${ctx.name}`);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
this.log('\nLogged out from all contexts.');
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
let contextName;
|
|
36
|
-
if (flags.context) {
|
|
37
|
-
const ctx = getContext(flags.context);
|
|
38
|
-
if (!ctx) {
|
|
39
|
-
this.error(`Context "${flags.context}" not found.`);
|
|
40
|
-
}
|
|
41
|
-
contextName = flags.context;
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
const current = getCurrentContext();
|
|
45
|
-
if (!current) {
|
|
46
|
-
this.error('No current context. Use --context to specify one.');
|
|
47
|
-
}
|
|
48
|
-
contextName = current.name;
|
|
49
|
-
}
|
|
50
|
-
const context = getContext(contextName);
|
|
51
|
-
if (!context?.tokens) {
|
|
52
|
-
this.log(`Already logged out from ${contextName}`);
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
clearTokens(contextName);
|
|
56
|
-
this.log(`Successfully logged out from ${contextName}`);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Command } from '@oclif/core';
|
|
2
|
-
export default class AuthStatus extends Command {
|
|
3
|
-
static description: string;
|
|
4
|
-
static examples: string[];
|
|
5
|
-
static flags: {
|
|
6
|
-
all: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
7
|
-
context: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
-
};
|
|
9
|
-
run(): Promise<void>;
|
|
10
|
-
private showAllContexts;
|
|
11
|
-
private showContextStatus;
|
|
12
|
-
}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { Command, Flags } from '@oclif/core';
|
|
2
|
-
import { testAuth } from '../../lib/auth.js';
|
|
3
|
-
import { getContext, getCurrentContext, listContexts } from '../../lib/config.js';
|
|
4
|
-
export default class AuthStatus extends Command {
|
|
5
|
-
static description = 'Show authentication status for contexts';
|
|
6
|
-
static examples = [
|
|
7
|
-
'<%= config.bin %> auth status',
|
|
8
|
-
'<%= config.bin %> auth status --context my-client',
|
|
9
|
-
'<%= config.bin %> auth status --all',
|
|
10
|
-
];
|
|
11
|
-
static flags = {
|
|
12
|
-
all: Flags.boolean({
|
|
13
|
-
char: 'a',
|
|
14
|
-
default: false,
|
|
15
|
-
description: 'Show status for all contexts',
|
|
16
|
-
}),
|
|
17
|
-
context: Flags.string({
|
|
18
|
-
char: 'c',
|
|
19
|
-
description: 'Specific context to check',
|
|
20
|
-
}),
|
|
21
|
-
};
|
|
22
|
-
async run() {
|
|
23
|
-
const { flags } = await this.parse(AuthStatus);
|
|
24
|
-
if (flags.all) {
|
|
25
|
-
await this.showAllContexts();
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
let contextName;
|
|
29
|
-
if (flags.context) {
|
|
30
|
-
const ctx = getContext(flags.context);
|
|
31
|
-
if (!ctx) {
|
|
32
|
-
this.error(`Context "${flags.context}" not found.`);
|
|
33
|
-
}
|
|
34
|
-
contextName = flags.context;
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
const current = getCurrentContext();
|
|
38
|
-
if (!current) {
|
|
39
|
-
this.log('No current context configured.');
|
|
40
|
-
this.log('Run: aderis auth login --new');
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
contextName = current.name;
|
|
44
|
-
}
|
|
45
|
-
await this.showContextStatus(contextName, true);
|
|
46
|
-
}
|
|
47
|
-
async showAllContexts() {
|
|
48
|
-
const contexts = listContexts();
|
|
49
|
-
const current = getCurrentContext();
|
|
50
|
-
if (contexts.length === 0) {
|
|
51
|
-
this.log('No contexts configured.');
|
|
52
|
-
this.log('Run: aderis auth login --new');
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
this.log('Contexts:\n');
|
|
56
|
-
for (const ctx of contexts) {
|
|
57
|
-
const isCurrent = current?.name === ctx.name;
|
|
58
|
-
const prefix = isCurrent ? '* ' : ' ';
|
|
59
|
-
const status = ctx.tokens ? '✓ logged in' : '✗ not logged in';
|
|
60
|
-
this.log(`${prefix}${ctx.name} (${ctx.environment}) - ${status}`);
|
|
61
|
-
}
|
|
62
|
-
this.log('\n* = current context');
|
|
63
|
-
}
|
|
64
|
-
async showContextStatus(name, detailed) {
|
|
65
|
-
const context = getContext(name);
|
|
66
|
-
const current = getCurrentContext();
|
|
67
|
-
if (!context) {
|
|
68
|
-
this.error(`Context "${name}" not found.`);
|
|
69
|
-
}
|
|
70
|
-
const isCurrent = current?.name === name;
|
|
71
|
-
this.log(`Context: ${context.name}${isCurrent ? ' (current)' : ''}`);
|
|
72
|
-
this.log(`Environment: ${context.environment}`);
|
|
73
|
-
this.log(`Client ID: ${context.client_id}`);
|
|
74
|
-
if (!context.tokens) {
|
|
75
|
-
this.log(`Status: Not logged in`);
|
|
76
|
-
this.log(`\nRun: aderis auth login${isCurrent ? '' : ` --context ${name}`}`);
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
this.log(`Tenant ID: ${context.tenant_id || 'N/A'}`);
|
|
80
|
-
if (context.tokens.expires_at) {
|
|
81
|
-
const expiresAt = new Date(context.tokens.expires_at);
|
|
82
|
-
const isExpired = expiresAt < new Date();
|
|
83
|
-
this.log(`Token expires: ${expiresAt.toLocaleString()}${isExpired ? ' (EXPIRED)' : ''}`);
|
|
84
|
-
}
|
|
85
|
-
if (detailed) {
|
|
86
|
-
try {
|
|
87
|
-
const user = await testAuth(name);
|
|
88
|
-
this.log(`\nLogged in as: ${user.email || user.name || 'Unknown'}`);
|
|
89
|
-
this.log('Status: ✓ Authenticated');
|
|
90
|
-
}
|
|
91
|
-
catch (error) {
|
|
92
|
-
if (error instanceof Error) {
|
|
93
|
-
this.log(`\nStatus: ✗ ${error.message}`);
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
this.log('\nStatus: ✗ Authentication error');
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Command } from '@oclif/core';
|
|
2
|
-
export default class AuthTenant extends Command {
|
|
3
|
-
static args: {
|
|
4
|
-
action: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
5
|
-
tenantId: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
6
|
-
};
|
|
7
|
-
static description: string;
|
|
8
|
-
static examples: string[];
|
|
9
|
-
static flags: {
|
|
10
|
-
context: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
-
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
-
};
|
|
13
|
-
run(): Promise<void>;
|
|
14
|
-
private interactiveSwitch;
|
|
15
|
-
private listTenants;
|
|
16
|
-
private showCurrentTenant;
|
|
17
|
-
private switchTenant;
|
|
18
|
-
}
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import { select } from '@inquirer/prompts';
|
|
2
|
-
import { Args, Command, Flags } from '@oclif/core';
|
|
3
|
-
import { getCurrentTenant, listTenants, switchTenant } from '../../lib/auth.js';
|
|
4
|
-
import { getContext, getCurrentContext } from '../../lib/config.js';
|
|
5
|
-
export default class AuthTenant extends Command {
|
|
6
|
-
static args = {
|
|
7
|
-
action: Args.string({
|
|
8
|
-
description: 'Action to perform: show, list, or switch',
|
|
9
|
-
options: ['show', 'list', 'switch'],
|
|
10
|
-
required: false,
|
|
11
|
-
}),
|
|
12
|
-
tenantId: Args.string({
|
|
13
|
-
description: 'Tenant ID to switch to (for switch action)',
|
|
14
|
-
required: false,
|
|
15
|
-
}),
|
|
16
|
-
};
|
|
17
|
-
static description = 'Manage tenant selection for multi-tenant access';
|
|
18
|
-
static examples = [
|
|
19
|
-
'<%= config.bin %> auth tenant',
|
|
20
|
-
'<%= config.bin %> auth tenant show',
|
|
21
|
-
'<%= config.bin %> auth tenant list',
|
|
22
|
-
'<%= config.bin %> auth tenant switch <tenant-id>',
|
|
23
|
-
];
|
|
24
|
-
static flags = {
|
|
25
|
-
context: Flags.string({
|
|
26
|
-
char: 'c',
|
|
27
|
-
description: 'Context to use',
|
|
28
|
-
}),
|
|
29
|
-
json: Flags.boolean({
|
|
30
|
-
default: false,
|
|
31
|
-
description: 'Output as JSON',
|
|
32
|
-
}),
|
|
33
|
-
};
|
|
34
|
-
async run() {
|
|
35
|
-
const { args, flags } = await this.parse(AuthTenant);
|
|
36
|
-
const contextName = flags.context || getCurrentContext()?.name;
|
|
37
|
-
if (!contextName) {
|
|
38
|
-
this.error('No context configured. Run: aderis auth login --new');
|
|
39
|
-
}
|
|
40
|
-
const context = getContext(contextName);
|
|
41
|
-
if (!context?.tokens) {
|
|
42
|
-
this.error('Not logged in. Run: aderis auth login');
|
|
43
|
-
}
|
|
44
|
-
const action = args.action || 'interactive';
|
|
45
|
-
switch (action) {
|
|
46
|
-
case 'list': {
|
|
47
|
-
await this.listTenants(contextName, flags.json);
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
case 'show': {
|
|
51
|
-
await this.showCurrentTenant(contextName, flags.json);
|
|
52
|
-
break;
|
|
53
|
-
}
|
|
54
|
-
case 'switch': {
|
|
55
|
-
if (!args.tenantId) {
|
|
56
|
-
this.error('Tenant ID required for switch action. Usage: aderis auth tenant switch <tenant-id>');
|
|
57
|
-
}
|
|
58
|
-
await this.switchTenant(contextName, args.tenantId);
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
|
-
default: {
|
|
62
|
-
await this.interactiveSwitch(contextName);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
async interactiveSwitch(contextName) {
|
|
67
|
-
const tenants = await listTenants(contextName);
|
|
68
|
-
const current = await getCurrentTenant(contextName);
|
|
69
|
-
if (tenants.length === 0) {
|
|
70
|
-
this.log('No tenants available');
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
if (tenants.length === 1) {
|
|
74
|
-
const tenant = tenants[0];
|
|
75
|
-
this.log(`Only one tenant available: ${tenant.name}`);
|
|
76
|
-
if (tenant.tenantId === current?.tenantId) {
|
|
77
|
-
this.log('Already using this tenant');
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
await this.switchTenant(contextName, tenant.tenantId);
|
|
81
|
-
}
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
// Sort tenants: current first, then by name
|
|
85
|
-
const sortedTenants = [...tenants].sort((a, b) => {
|
|
86
|
-
if (a.tenantId === current?.tenantId)
|
|
87
|
-
return -1;
|
|
88
|
-
if (b.tenantId === current?.tenantId)
|
|
89
|
-
return 1;
|
|
90
|
-
return a.name.localeCompare(b.name);
|
|
91
|
-
});
|
|
92
|
-
const choices = sortedTenants.map((t) => {
|
|
93
|
-
const isCurrent = t.tenantId === current?.tenantId;
|
|
94
|
-
const tags = [];
|
|
95
|
-
if (isCurrent)
|
|
96
|
-
tags.push('current');
|
|
97
|
-
if (t.isDefault)
|
|
98
|
-
tags.push('default');
|
|
99
|
-
const tagStr = tags.length > 0 ? ` (${tags.join(', ')})` : '';
|
|
100
|
-
return {
|
|
101
|
-
name: `${t.name}${tagStr}`,
|
|
102
|
-
value: t.tenantId,
|
|
103
|
-
};
|
|
104
|
-
});
|
|
105
|
-
const selectedTenant = await select({
|
|
106
|
-
choices,
|
|
107
|
-
message: 'Select a tenant:',
|
|
108
|
-
});
|
|
109
|
-
if (selectedTenant === current?.tenantId) {
|
|
110
|
-
this.log('Already using this tenant');
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
await this.switchTenant(contextName, selectedTenant);
|
|
114
|
-
}
|
|
115
|
-
async listTenants(contextName, asJson) {
|
|
116
|
-
const tenants = await listTenants(contextName);
|
|
117
|
-
const current = await getCurrentTenant(contextName);
|
|
118
|
-
if (asJson) {
|
|
119
|
-
this.log(JSON.stringify({ currentTenantId: current?.tenantId, tenants }, null, 2));
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
if (tenants.length === 0) {
|
|
123
|
-
this.log('No tenants available');
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
this.log('Available tenants:\n');
|
|
127
|
-
for (const tenant of tenants) {
|
|
128
|
-
const isCurrent = tenant.tenantId === current?.tenantId;
|
|
129
|
-
const marker = isCurrent ? '*' : ' ';
|
|
130
|
-
const defaultTag = tenant.isDefault ? ' (default)' : '';
|
|
131
|
-
this.log(`${marker} ${tenant.name}${defaultTag}`);
|
|
132
|
-
this.log(` ID: ${tenant.tenantId}`);
|
|
133
|
-
}
|
|
134
|
-
this.log('\n* = current tenant');
|
|
135
|
-
}
|
|
136
|
-
async showCurrentTenant(contextName, asJson) {
|
|
137
|
-
const current = await getCurrentTenant(contextName);
|
|
138
|
-
if (!current) {
|
|
139
|
-
if (asJson) {
|
|
140
|
-
this.log(JSON.stringify({ tenant: null }, null, 2));
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
this.log('No tenant selected');
|
|
144
|
-
}
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
if (asJson) {
|
|
148
|
-
this.log(JSON.stringify(current, null, 2));
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
this.log(`Current tenant: ${current.name || current.tenantId}`);
|
|
152
|
-
this.log(`Tenant ID: ${current.tenantId}`);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
async switchTenant(contextName, tenantId) {
|
|
156
|
-
this.log(`Switching to tenant ${tenantId}...`);
|
|
157
|
-
try {
|
|
158
|
-
const tokens = await switchTenant(contextName, tenantId);
|
|
159
|
-
this.log(`Successfully switched to tenant ${tokens.tenant_id}`);
|
|
160
|
-
}
|
|
161
|
-
catch (error) {
|
|
162
|
-
if (error instanceof Error) {
|
|
163
|
-
this.error(`Failed to switch tenant: ${error.message}`);
|
|
164
|
-
}
|
|
165
|
-
throw error;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
package/dist/commands/auth.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Command } from '@oclif/core';
|
|
2
|
-
export default class Auth extends Command {
|
|
3
|
-
static args: {
|
|
4
|
-
action: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
-
id: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
6
|
-
};
|
|
7
|
-
static description: string;
|
|
8
|
-
static examples: never[];
|
|
9
|
-
static flags: {
|
|
10
|
-
context: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
-
csv: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
-
data: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
-
fields: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
-
file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
-
include: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
-
limit: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
-
output: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
-
page: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
-
query: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
20
|
-
sanitize: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
21
|
-
search: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
|
-
set: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
23
|
-
'sort-by': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
24
|
-
table: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
25
|
-
};
|
|
26
|
-
run(): Promise<void>;
|
|
27
|
-
private filterFields;
|
|
28
|
-
private getColumns;
|
|
29
|
-
private getValue;
|
|
30
|
-
private printCsv;
|
|
31
|
-
private printTable;
|
|
32
|
-
private runCamt053Import;
|
|
33
|
-
private runExport;
|
|
34
|
-
private runImport;
|
|
35
|
-
private runNestedImport;
|
|
36
|
-
private sanitizeOutput;
|
|
37
|
-
}
|