@newpeak/barista-cli 0.2.339 → 0.2.342

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.
Files changed (90) hide show
  1. package/dist/commands/liberica/credential/get.d.ts +9 -0
  2. package/dist/commands/liberica/credential/get.d.ts.map +1 -0
  3. package/dist/commands/liberica/credential/get.js +75 -0
  4. package/dist/commands/liberica/credential/get.js.map +1 -0
  5. package/dist/commands/liberica/credential/index.d.ts +3 -0
  6. package/dist/commands/liberica/credential/index.d.ts.map +1 -0
  7. package/dist/commands/liberica/credential/index.js +15 -0
  8. package/dist/commands/liberica/credential/index.js.map +1 -0
  9. package/dist/commands/liberica/credential/list.d.ts +3 -0
  10. package/dist/commands/liberica/credential/list.d.ts.map +1 -0
  11. package/dist/commands/liberica/credential/list.js +74 -0
  12. package/dist/commands/liberica/credential/list.js.map +1 -0
  13. package/dist/commands/liberica/credential/rm.d.ts +3 -0
  14. package/dist/commands/liberica/credential/rm.d.ts.map +1 -0
  15. package/dist/commands/liberica/credential/rm.js +74 -0
  16. package/dist/commands/liberica/credential/rm.js.map +1 -0
  17. package/dist/commands/liberica/credential/set.d.ts +3 -0
  18. package/dist/commands/liberica/credential/set.d.ts.map +1 -0
  19. package/dist/commands/liberica/credential/set.js +146 -0
  20. package/dist/commands/liberica/credential/set.js.map +1 -0
  21. package/dist/commands/liberica/credential/shared.d.ts +13 -0
  22. package/dist/commands/liberica/credential/shared.d.ts.map +1 -0
  23. package/dist/commands/liberica/credential/shared.js +49 -0
  24. package/dist/commands/liberica/credential/shared.js.map +1 -0
  25. package/dist/commands/liberica/finance/coa/country.d.ts +7 -0
  26. package/dist/commands/liberica/finance/coa/country.d.ts.map +1 -0
  27. package/dist/commands/liberica/finance/coa/country.js +21 -0
  28. package/dist/commands/liberica/finance/coa/country.js.map +1 -0
  29. package/dist/commands/liberica/finance/coa/create.d.ts.map +1 -1
  30. package/dist/commands/liberica/finance/coa/create.js +43 -1
  31. package/dist/commands/liberica/finance/coa/create.js.map +1 -1
  32. package/dist/commands/liberica/finance/coa/export.d.ts.map +1 -1
  33. package/dist/commands/liberica/finance/coa/export.js +21 -15
  34. package/dist/commands/liberica/finance/coa/export.js.map +1 -1
  35. package/dist/commands/liberica/finance/coa/tree.d.ts.map +1 -1
  36. package/dist/commands/liberica/finance/coa/tree.js +21 -16
  37. package/dist/commands/liberica/finance/coa/tree.js.map +1 -1
  38. package/dist/commands/liberica/index.d.ts.map +1 -1
  39. package/dist/commands/liberica/index.js +2 -0
  40. package/dist/commands/liberica/index.js.map +1 -1
  41. package/dist/commands/liberica/teams/index.d.ts.map +1 -1
  42. package/dist/commands/liberica/teams/index.js +2 -0
  43. package/dist/commands/liberica/teams/index.js.map +1 -1
  44. package/dist/commands/liberica/teams/releases/common.d.ts +7 -0
  45. package/dist/commands/liberica/teams/releases/common.d.ts.map +1 -0
  46. package/dist/commands/liberica/teams/releases/common.js +35 -0
  47. package/dist/commands/liberica/teams/releases/common.js.map +1 -0
  48. package/dist/commands/liberica/teams/releases/create.d.ts +3 -0
  49. package/dist/commands/liberica/teams/releases/create.d.ts.map +1 -0
  50. package/dist/commands/liberica/teams/releases/create.js +90 -0
  51. package/dist/commands/liberica/teams/releases/create.js.map +1 -0
  52. package/dist/commands/liberica/teams/releases/delete.d.ts +3 -0
  53. package/dist/commands/liberica/teams/releases/delete.d.ts.map +1 -0
  54. package/dist/commands/liberica/teams/releases/delete.js +60 -0
  55. package/dist/commands/liberica/teams/releases/delete.js.map +1 -0
  56. package/dist/commands/liberica/teams/releases/get.d.ts +3 -0
  57. package/dist/commands/liberica/teams/releases/get.d.ts.map +1 -0
  58. package/dist/commands/liberica/teams/releases/get.js +62 -0
  59. package/dist/commands/liberica/teams/releases/get.js.map +1 -0
  60. package/dist/commands/liberica/teams/releases/index.d.ts +3 -0
  61. package/dist/commands/liberica/teams/releases/index.d.ts.map +1 -0
  62. package/dist/commands/liberica/teams/releases/index.js +19 -0
  63. package/dist/commands/liberica/teams/releases/index.js.map +1 -0
  64. package/dist/commands/liberica/teams/releases/list.d.ts +3 -0
  65. package/dist/commands/liberica/teams/releases/list.d.ts.map +1 -0
  66. package/dist/commands/liberica/teams/releases/list.js +87 -0
  67. package/dist/commands/liberica/teams/releases/list.js.map +1 -0
  68. package/dist/commands/liberica/teams/releases/transition.d.ts +3 -0
  69. package/dist/commands/liberica/teams/releases/transition.d.ts.map +1 -0
  70. package/dist/commands/liberica/teams/releases/transition.js +87 -0
  71. package/dist/commands/liberica/teams/releases/transition.js.map +1 -0
  72. package/dist/commands/liberica/teams/releases/update.d.ts +3 -0
  73. package/dist/commands/liberica/teams/releases/update.d.ts.map +1 -0
  74. package/dist/commands/liberica/teams/releases/update.js +135 -0
  75. package/dist/commands/liberica/teams/releases/update.js.map +1 -0
  76. package/dist/core/api/client.d.ts +15 -0
  77. package/dist/core/api/client.d.ts.map +1 -1
  78. package/dist/core/api/client.js +215 -0
  79. package/dist/core/api/client.js.map +1 -1
  80. package/dist/types/credential.d.ts +83 -0
  81. package/dist/types/credential.d.ts.map +1 -0
  82. package/dist/types/credential.js +12 -0
  83. package/dist/types/credential.js.map +1 -0
  84. package/dist/types/team-release.d.ts +66 -0
  85. package/dist/types/team-release.d.ts.map +1 -0
  86. package/dist/types/team-release.js +2 -0
  87. package/dist/types/team-release.js.map +1 -0
  88. package/package.json +1 -1
  89. package/skills/barista-cli/data/commands.json +59 -1
  90. package/skills/barista-cli/data/commands.yaml +39 -1
@@ -0,0 +1,9 @@
1
+ import { Command } from 'commander';
2
+ /**
3
+ * `get` writes the plaintext to stdout and nothing else. Diagnostics go to
4
+ * stderr so `TOKEN=$(barista liberica credential get KEY)` is safe.
5
+ * Exit code 2 means the plaintext could not be obtained (not found / disabled
6
+ * / expired / not authorized); 1 is reserved for command usage errors.
7
+ */
8
+ export declare function createCredentialGetCommand(): Command;
9
+ //# sourceMappingURL=get.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../../src/commands/liberica/credential/get.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQpC;;;;;GAKG;AACH,wBAAgB,0BAA0B,IAAI,OAAO,CAkEpD"}
@@ -0,0 +1,75 @@
1
+ import { Command } from 'commander';
2
+ import chalk from 'chalk';
3
+ import { configManager } from '../../../core/config/manager.js';
4
+ import { apiClient } from '../../../core/api/client.js';
5
+ import { extractCredentialError, parseScope } from './shared.js';
6
+ /**
7
+ * `get` writes the plaintext to stdout and nothing else. Diagnostics go to
8
+ * stderr so `TOKEN=$(barista liberica credential get KEY)` is safe.
9
+ * Exit code 2 means the plaintext could not be obtained (not found / disabled
10
+ * / expired / not authorized); 1 is reserved for command usage errors.
11
+ */
12
+ export function createCredentialGetCommand() {
13
+ const getCommand = new Command('get');
14
+ getCommand.description('Resolve a credential and print only the plaintext to stdout (exit code 2 when unavailable)');
15
+ getCommand
16
+ .argument('<key>', 'Credential key (e.g. GITLAB_TOKEN)')
17
+ .option('--scope <scope>', 'AUTO | USER | TENANT (default AUTO)', 'AUTO')
18
+ .option('--purpose <text>', 'Audit purpose recorded by the backend', 'cli:credential:get')
19
+ .option('--json', 'Output as JSON on stdout (value still included)')
20
+ .action(async (key, options) => {
21
+ const context = configManager.getCurrentContext();
22
+ const environment = options.env || context.environment;
23
+ const tenant = options.tenant || context.tenant;
24
+ const jsonOutput = Boolean(options.json);
25
+ let scope;
26
+ try {
27
+ scope = parseScope(options.scope);
28
+ }
29
+ catch (error) {
30
+ credentialGetFail(jsonOutput, 'INVALID_SCOPE', error.message);
31
+ }
32
+ const response = await apiClient.resolveCredentials(environment, tenant, {
33
+ items: [{ key, scope }],
34
+ purpose: String(options.purpose),
35
+ });
36
+ if (!response.success) {
37
+ const error = extractCredentialError(response);
38
+ credentialGetFail(jsonOutput, error.code, error.message);
39
+ }
40
+ const data = (response.data || {});
41
+ const item = Array.isArray(data.items) ? data.items[0] : undefined;
42
+ if (!item || item.value === undefined || item.value === null) {
43
+ credentialGetFail(jsonOutput, 'CREDENTIAL_NOT_FOUND', 'Credential unavailable for this key');
44
+ }
45
+ if (jsonOutput) {
46
+ process.stdout.write(JSON.stringify({
47
+ success: true,
48
+ data: {
49
+ key: item.key,
50
+ scope: item.scope,
51
+ type: item.type,
52
+ value: item.value,
53
+ username: item.username ?? null,
54
+ keyVersion: item.keyVersion ?? null,
55
+ expiresAt: item.expiresAt ?? null,
56
+ },
57
+ }, null, 2) + '\n');
58
+ return;
59
+ }
60
+ process.stdout.write(`${item.value}\n`);
61
+ });
62
+ return getCommand;
63
+ }
64
+ function credentialGetFail(outputJson, code, message) {
65
+ if (outputJson) {
66
+ console.error(JSON.stringify({ success: false, error: { code, message } }, null, 2));
67
+ }
68
+ else {
69
+ console.error(chalk.red(`\n✗ ${message}`));
70
+ console.error(chalk.gray(` Error code: ${code}`));
71
+ console.error();
72
+ }
73
+ process.exit(2);
74
+ }
75
+ //# sourceMappingURL=get.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get.js","sourceRoot":"","sources":["../../../../src/commands/liberica/credential/get.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAGxD,OAAO,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEjE;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B;IACxC,MAAM,UAAU,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC;IACtC,UAAU,CAAC,WAAW,CACpB,4FAA4F,CAC7F,CAAC;IAEF,UAAU;SACP,QAAQ,CAAC,OAAO,EAAE,oCAAoC,CAAC;SACvD,MAAM,CAAC,iBAAiB,EAAE,qCAAqC,EAAE,MAAM,CAAC;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O,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,OAAO,EAAE,CAAC,CAAC,CAAC;QAC3C,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC,CAAC;QACnD,OAAO,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare function createCredentialCommand(): Command;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/liberica/credential/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,wBAAgB,uBAAuB,IAAI,OAAO,CAYjD"}
@@ -0,0 +1,15 @@
1
+ import { Command } from 'commander';
2
+ import { createCredentialListCommand } from './list.js';
3
+ import { createCredentialGetCommand } from './get.js';
4
+ import { createCredentialSetCommand } from './set.js';
5
+ import { createCredentialRmCommand } from './rm.js';
6
+ export function createCredentialCommand() {
7
+ const credentialCommand = new Command('credential');
8
+ credentialCommand.description('Manage secure credentials (values are masked on list, plaintext only via stdin/env)');
9
+ credentialCommand.addCommand(createCredentialListCommand());
10
+ credentialCommand.addCommand(createCredentialGetCommand());
11
+ credentialCommand.addCommand(createCredentialSetCommand());
12
+ credentialCommand.addCommand(createCredentialRmCommand());
13
+ return credentialCommand;
14
+ }
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/commands/liberica/credential/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,2BAA2B,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAEpD,MAAM,UAAU,uBAAuB;IACrC,MAAM,iBAAiB,GAAG,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;IACpD,iBAAiB,CAAC,WAAW,CAC3B,qFAAqF,CACtF,CAAC;IAEF,iBAAiB,CAAC,UAAU,CAAC,2BAA2B,EAAE,CAAC,CAAC;IAC5D,iBAAiB,CAAC,UAAU,CAAC,0BAA0B,EAAE,CAAC,CAAC;IAC3D,iBAAiB,CAAC,UAAU,CAAC,0BAA0B,EAAE,CAAC,CAAC;IAC3D,iBAAiB,CAAC,UAAU,CAAC,yBAAyB,EAAE,CAAC,CAAC;IAE1D,OAAO,iBAAiB,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare function createCredentialListCommand(): Command;
3
+ //# sourceMappingURL=list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../../src/commands/liberica/credential/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAgBpC,wBAAgB,2BAA2B,IAAI,OAAO,CA8ErD"}
@@ -0,0 +1,74 @@
1
+ import { Command } from 'commander';
2
+ import chalk from 'chalk';
3
+ import Table from 'cli-table3';
4
+ import { configManager } from '../../../core/config/manager.js';
5
+ import { apiClient } from '../../../core/api/client.js';
6
+ import { credentialFail, credentialRows, extractCredentialError, parseScope, } from './shared.js';
7
+ const MASK = '******';
8
+ export function createCredentialListCommand() {
9
+ const listCommand = new Command('list');
10
+ listCommand.description('List stored credentials (values are always masked)');
11
+ listCommand
12
+ .option('--scope <scope>', 'AUTO | USER | TENANT (default AUTO)', 'AUTO')
13
+ .option('--key <key>', 'Filter by credential key')
14
+ .option('--page <number>', 'Page number (1-based)', '1')
15
+ .option('--size <number>', 'Page size', '20')
16
+ .option('--json', 'Output as JSON')
17
+ .action(async (options) => {
18
+ const context = configManager.getCurrentContext();
19
+ const environment = options.env || context.environment;
20
+ const tenant = options.tenant || context.tenant;
21
+ const jsonOutput = Boolean(options.json);
22
+ let scope;
23
+ try {
24
+ scope = parseScope(options.scope);
25
+ }
26
+ catch (error) {
27
+ credentialFail(jsonOutput, 'INVALID_SCOPE', error.message);
28
+ }
29
+ const request = {
30
+ pageNo: parseInt(options.page, 10),
31
+ pageSize: parseInt(options.size, 10),
32
+ };
33
+ if (scope !== 'AUTO')
34
+ request.ownerType = scope;
35
+ if (options.key)
36
+ request.credentialKey = String(options.key);
37
+ const response = await apiClient.listCredentials(environment, tenant, request);
38
+ if (!response.success) {
39
+ const error = extractCredentialError(response);
40
+ credentialFail(jsonOutput, error.code, error.message);
41
+ }
42
+ const data = (response.data || {});
43
+ const rows = credentialRows(response.data).map((row) => ({ ...row, value: MASK }));
44
+ const total = Number(data.total ?? data.totalRows ?? rows.length);
45
+ if (jsonOutput) {
46
+ console.log(JSON.stringify({
47
+ success: true,
48
+ data: { rows, total, pageNo: request.pageNo, pageSize: request.pageSize },
49
+ }, null, 2));
50
+ return;
51
+ }
52
+ if (rows.length === 0) {
53
+ console.log(chalk.gray('\n No credentials found\n'));
54
+ return;
55
+ }
56
+ const table = new Table({
57
+ head: ['KEY', 'SCOPE', 'TYPE', 'ENABLED', 'EXPIRES', 'LAST USED'],
58
+ });
59
+ for (const row of rows) {
60
+ table.push([
61
+ String(row.credentialKey ?? ''),
62
+ String(row.ownerType ?? ''),
63
+ String(row.credentialType ?? ''),
64
+ row.enabled === false || row.enabled === 0 ? 'no' : 'yes',
65
+ String(row.expiresAt ?? '-'),
66
+ String(row.lastUsedAt ?? '-'),
67
+ ]);
68
+ }
69
+ console.log(`\n${table.toString()}`);
70
+ console.log(chalk.gray(` ${rows.length} of ${total}\n`));
71
+ });
72
+ return listCommand;
73
+ }
74
+ //# sourceMappingURL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MAAM,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;IAEL,OAAO,WAAW,CAAC;AACrB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare function createCredentialRmCommand(): Command;
3
+ //# sourceMappingURL=rm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rm.d.ts","sourceRoot":"","sources":["../../../../src/commands/liberica/credential/rm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAcpC,wBAAgB,yBAAyB,IAAI,OAAO,CA0DnD"}
@@ -0,0 +1,74 @@
1
+ import { Command } from 'commander';
2
+ import chalk from 'chalk';
3
+ import readline from 'node:readline/promises';
4
+ import { configManager } from '../../../core/config/manager.js';
5
+ import { apiClient } from '../../../core/api/client.js';
6
+ import { credentialFail, credentialRows, extractCredentialError, parseScope, } from './shared.js';
7
+ export function createCredentialRmCommand() {
8
+ const rmCommand = new Command('rm');
9
+ rmCommand.description('Delete a credential by key (asks for confirmation unless --force)');
10
+ rmCommand
11
+ .argument('<key>', 'Credential key (e.g. GITLAB_TOKEN)')
12
+ .option('--scope <scope>', 'AUTO | USER | TENANT (default AUTO)', 'AUTO')
13
+ .option('--force', 'Skip the interactive confirmation')
14
+ .option('--json', 'Output as JSON')
15
+ .action(async (key, options) => {
16
+ const context = configManager.getCurrentContext();
17
+ const environment = options.env || context.environment;
18
+ const tenant = options.tenant || context.tenant;
19
+ const jsonOutput = Boolean(options.json);
20
+ let scope;
21
+ try {
22
+ scope = parseScope(options.scope);
23
+ }
24
+ catch (error) {
25
+ credentialFail(jsonOutput, 'INVALID_SCOPE', error.message);
26
+ }
27
+ const credentialId = await findCredentialId(environment, tenant, scope, key, jsonOutput);
28
+ if (!credentialId) {
29
+ credentialFail(jsonOutput, '01001996001', `Credential not found: ${key}`);
30
+ }
31
+ if (!options.force) {
32
+ if (!process.stdin.isTTY) {
33
+ credentialFail(jsonOutput, 'CONFIRMATION_REQUIRED', 'Refusing to delete without confirmation on non-interactive stdin. Use --force.');
34
+ }
35
+ const rl = readline.createInterface({ input: process.stdin, output: process.stderr });
36
+ const answer = await rl.question(`Delete credential "${key}"? [y/N] `);
37
+ rl.close();
38
+ if (!/^y(es)?$/i.test(answer.trim())) {
39
+ console.log(chalk.gray('Cancelled.'));
40
+ process.exit(0);
41
+ }
42
+ }
43
+ const response = await apiClient.deleteCredential(environment, tenant, { credentialId });
44
+ if (!response.success) {
45
+ const error = extractCredentialError(response);
46
+ credentialFail(jsonOutput, error.code, error.message);
47
+ }
48
+ if (jsonOutput) {
49
+ console.log(JSON.stringify({ success: true, data: { key, deleted: true } }, null, 2));
50
+ return;
51
+ }
52
+ console.log(chalk.green(`\n✓ Credential deleted: ${key}\n`));
53
+ });
54
+ return rmCommand;
55
+ }
56
+ async function findCredentialId(environment, tenant, scope, key, outputJson) {
57
+ const ownerType = scope === 'AUTO' ? undefined : scope;
58
+ const response = await apiClient.listCredentials(environment, tenant, {
59
+ ownerType,
60
+ credentialKey: key,
61
+ pageNo: 1,
62
+ pageSize: 10,
63
+ });
64
+ if (!response.success) {
65
+ const error = extractCredentialError(response);
66
+ credentialFail(outputJson, error.code, error.message);
67
+ }
68
+ const row = credentialRows(response.data).find((item) => String(item.credentialKey ?? '').toUpperCase() === key.toUpperCase() &&
69
+ (ownerType === undefined || String(item.ownerType ?? '') === ownerType) &&
70
+ item.credentialId !== undefined &&
71
+ item.credentialId !== null);
72
+ return row ? String(row.credentialId) : undefined;
73
+ }
74
+ //# sourceMappingURL=rm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rm.js","sourceRoot":"","sources":["../../../../src/commands/liberica/credential/rm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,QAAQ,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAA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AG,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACpD,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare function createCredentialSetCommand(): Command;
3
+ //# sourceMappingURL=set.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set.d.ts","sourceRoot":"","sources":["../../../../src/commands/liberica/credential/set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAmBpC,wBAAgB,0BAA0B,IAAI,OAAO,CA6HpD"}
@@ -0,0 +1,146 @@
1
+ import { Command } from 'commander';
2
+ import chalk from 'chalk';
3
+ import { configManager } from '../../../core/config/manager.js';
4
+ import { apiClient } from '../../../core/api/client.js';
5
+ import { credentialFail, credentialRows, extractCredentialError, parseScope, } from './shared.js';
6
+ const MAX_VALUE_BYTES = 16 * 1024;
7
+ export function createCredentialSetCommand() {
8
+ const setCommand = new Command('set');
9
+ setCommand.description('Create or update a credential. Plaintext must come from stdin (--value-stdin) or an ' +
10
+ 'environment variable (--from-env); --value is intentionally not supported so secrets ' +
11
+ 'never reach argv, shell history or container specs');
12
+ setCommand
13
+ .argument('<key>', 'Credential key (e.g. GITLAB_TOKEN)')
14
+ .option('--value-stdin', 'Read plaintext from piped stdin (only the last newline is stripped)')
15
+ .option('--from-env <NAME>', 'Read plaintext from environment variable NAME')
16
+ .option('--scope <scope>', 'USER | TENANT (default USER)', 'USER')
17
+ .option('--type <type>', 'PASSWORD | USERNAME_PASSWORD | TEXT | JSON (default TEXT)', 'TEXT')
18
+ .option('--username <name>', 'Username paired with the secret (USERNAME_PASSWORD only)')
19
+ .option('--description <text>', 'Description')
20
+ .option('--expires-at <datetime>', 'Expiry (backend format, e.g. 2026-12-31 23:59:59)')
21
+ .option('--json', 'Output as JSON')
22
+ .allowUnknownOption(true)
23
+ .action(async (key, options) => {
24
+ const context = configManager.getCurrentContext();
25
+ const environment = options.env || context.environment;
26
+ const tenant = options.tenant || context.tenant;
27
+ const jsonOutput = Boolean(options.json);
28
+ if (process.argv.some((arg) => arg === '--value' || arg.startsWith('--value='))) {
29
+ credentialFail(jsonOutput, 'VALUE_ARG_FORBIDDEN', 'Plaintext credentials are not accepted via --value (it leaks into argv / shell history). ' +
30
+ 'Use --value-stdin or --from-env <NAME>.');
31
+ }
32
+ const stdinSource = Boolean(options.valueStdin);
33
+ const envSource = options.fromEnv ? String(options.fromEnv) : undefined;
34
+ if (stdinSource && envSource) {
35
+ credentialFail(jsonOutput, 'VALUE_SOURCE_MUTUALLY_EXCLUSIVE', 'Use either --value-stdin or --from-env, not both.');
36
+ }
37
+ if (!stdinSource && !envSource) {
38
+ credentialFail(jsonOutput, 'MISSING_VALUE', 'Credential value is required. Use --value-stdin or --from-env <NAME>.');
39
+ }
40
+ let ownerType;
41
+ try {
42
+ const scope = parseScope(options.scope);
43
+ if (scope === 'AUTO')
44
+ throw new Error('set requires --scope USER or TENANT');
45
+ ownerType = scope;
46
+ }
47
+ catch (error) {
48
+ credentialFail(jsonOutput, 'INVALID_SCOPE', error.message);
49
+ }
50
+ const credentialType = String(options.type).toUpperCase();
51
+ if (credentialType === 'USERNAME_PASSWORD' &&
52
+ !options.username) {
53
+ credentialFail(jsonOutput, 'USERNAME_REQUIRED', '--username is required when --type is USERNAME_PASSWORD.');
54
+ }
55
+ const value = envSource
56
+ ? readFromEnv(envSource, jsonOutput)
57
+ : await readFromStdin(jsonOutput);
58
+ const base = {
59
+ ownerType,
60
+ credentialKey: key,
61
+ credentialType,
62
+ value,
63
+ };
64
+ if (options.username)
65
+ base.username = String(options.username);
66
+ if (options.description)
67
+ base.description = String(options.description);
68
+ if (options.expiresAt)
69
+ base.expiresAt = String(options.expiresAt);
70
+ const existing = await findCredentialId(environment, tenant, ownerType, key, jsonOutput);
71
+ const response = existing
72
+ ? await apiClient.editCredential(environment, tenant, { ...base, credentialId: existing })
73
+ : await apiClient.addCredential(environment, tenant, base);
74
+ if (!response.success) {
75
+ const error = extractCredentialError(response);
76
+ credentialFail(jsonOutput, error.code, error.message);
77
+ }
78
+ const data = (response.data || {});
79
+ const result = {
80
+ key: String(data.credentialKey ?? key),
81
+ scope: String(data.ownerType ?? ownerType),
82
+ type: String(data.credentialType ?? credentialType),
83
+ keyVersion: data.keyVersion ?? null,
84
+ created: !existing,
85
+ };
86
+ if (jsonOutput) {
87
+ console.log(JSON.stringify({ success: true, data: result }, null, 2));
88
+ return;
89
+ }
90
+ console.log(chalk.green(`\n✓ Credential ${existing ? 'updated' : 'created'}: ${result.key}`));
91
+ console.log(chalk.gray(` Scope: ${result.scope}`));
92
+ console.log(chalk.gray(` Type: ${result.type}`));
93
+ if (result.keyVersion !== null) {
94
+ console.log(chalk.gray(` Key version: ${String(result.keyVersion)}`));
95
+ }
96
+ console.log();
97
+ });
98
+ return setCommand;
99
+ }
100
+ function readFromEnv(name, outputJson) {
101
+ const value = process.env[name];
102
+ if (value === undefined || value === '') {
103
+ credentialFail(outputJson, 'ENV_NOT_FOUND', `Environment variable not set: ${name}`);
104
+ }
105
+ return value;
106
+ }
107
+ async function readFromStdin(outputJson) {
108
+ if (process.stdin.isTTY) {
109
+ credentialFail(outputJson, 'STDIN_NOT_PIPE', '--value-stdin requires piped input (stdin is a TTY). Example: echo -n "$SECRET" | barista liberica credential set KEY --value-stdin');
110
+ }
111
+ const chunks = [];
112
+ for await (const chunk of process.stdin) {
113
+ chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
114
+ }
115
+ let content = Buffer.concat(chunks).toString('utf-8');
116
+ // Strip only the final newline: secrets may legitimately contain spaces.
117
+ if (content.endsWith('\r\n'))
118
+ content = content.slice(0, -2);
119
+ else if (content.endsWith('\n'))
120
+ content = content.slice(0, -1);
121
+ if (content === '') {
122
+ credentialFail(outputJson, 'STDIN_EMPTY', 'No credential value received on stdin.');
123
+ }
124
+ if (Buffer.byteLength(content, 'utf-8') > MAX_VALUE_BYTES) {
125
+ credentialFail(outputJson, 'VALUE_TOO_LARGE', `Credential value exceeds ${MAX_VALUE_BYTES} bytes.`);
126
+ }
127
+ return content;
128
+ }
129
+ async function findCredentialId(environment, tenant, ownerType, key, outputJson) {
130
+ const response = await apiClient.listCredentials(environment, tenant, {
131
+ ownerType,
132
+ credentialKey: key,
133
+ pageNo: 1,
134
+ pageSize: 10,
135
+ });
136
+ if (!response.success) {
137
+ const error = extractCredentialError(response);
138
+ credentialFail(outputJson, error.code, error.message);
139
+ }
140
+ const row = credentialRows(response.data).find((item) => String(item.credentialKey ?? '').toUpperCase() === key.toUpperCase() &&
141
+ String(item.ownerType ?? ownerType) === ownerType &&
142
+ item.credentialId !== undefined &&
143
+ item.credentialId !== null);
144
+ return row ? String(row.credentialId) : undefined;
145
+ }
146
+ //# sourceMappingURL=set.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set.js","sourceRoot":"","sources":["../../../../src/commands/liberica/credential/set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAOxD,OAAO,EACL,cAAc,EACd,cAAc,EACd,sBAAsB,EACtB,UAAU,GACX,MAAM,aAAa,CAAC;AAErB,MAAM,eAAe,GAAG,EAAE,GAAG,IAAI,CAAC;AAElC,MAAM,UAAU,0BAA0B;IACxC,MAAM,UAAU,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC;IACtC,UAAU,CAAC,WAAW,CACpB,sFAAsF;QACpF,uFAAuF;QACvF,oDAAoD,CACvD,CAAC;IAEF,UAAU;SACP,QAAQ,CAAC,OAAO,EAAE,oCAAoC,CAAC;SACvD,MAAM,CAAC,eAAe,EAAE,qEAAqE,CAAC;SAC9F,MAAM,CAAC,mBAAmB,EAAE,+CAA+C,CAAC;SAC5E,MAAM,CAA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;IACxD,CAAC;IACD,MAAM,GAAG,GAAG,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CAC5C,CAAC,IAAI,EAAE,EAAE,CACP,MAAM,CAAC,IAAI,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,KAAK,GAAG,CAAC,WAAW,EAAE;QACpE,MAAM,CAAC,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,KAAK,SAAS;QACjD,IAAI,CAAC,YAAY,KAAK,SAAS;QAC/B,IAAI,CAAC,YAAY,KAAK,IAAI,CAC7B,CAAC;IACF,OAAO,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACpD,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { CredentialApiResponse, CredentialScope } from '../../../types/credential.js';
2
+ export declare function parseScope(raw: unknown, fallback?: CredentialScope): CredentialScope;
3
+ export declare function extractCredentialError(response: CredentialApiResponse): {
4
+ code: string;
5
+ message: string;
6
+ };
7
+ /**
8
+ * Credential failures use exit code 1, except `get` where 2 means the
9
+ * plaintext could not be obtained (see command help).
10
+ */
11
+ export declare function credentialFail(outputJson: boolean, code: string, message: string, exitCode?: number): never;
12
+ export declare function credentialRows(data: unknown): Record<string, unknown>[];
13
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../../src/commands/liberica/credential/shared.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAiBtF,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,GAAE,eAAwB,GAAG,eAAe,CAI5F;AAED,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,qBAAqB,GAAG;IACvE,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAKA;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,UAAU,EAAE,OAAO,EACnB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,QAAQ,SAAI,GACX,KAAK,CASP;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAKvE"}
@@ -0,0 +1,49 @@
1
+ import chalk from 'chalk';
2
+ const ERROR_HINTS = {
3
+ '01001996001': 'Credential not found',
4
+ '01001996002': 'A credential with this key already exists for this owner',
5
+ '01001996003': 'You are not allowed to use this credential',
6
+ '01001996004': 'Credential is disabled',
7
+ '01001996005': 'Credential is expired',
8
+ '01001996006': 'Credential decryption failed — contact your administrator',
9
+ '01001996007': 'Invalid credential value format',
10
+ '01001996009': 'Credential was modified concurrently — retry',
11
+ '01001996010': 'This credential is not authorized for you — contact your administrator',
12
+ '01001996011': 'You are not allowed to configure grants for this credential',
13
+ B0309: 'Permission not provisioned — ask an administrator to enable this feature in the Arabica product definition',
14
+ };
15
+ export function parseScope(raw, fallback = 'AUTO') {
16
+ const value = String(raw ?? fallback).toUpperCase();
17
+ if (value === 'AUTO' || value === 'USER' || value === 'TENANT')
18
+ return value;
19
+ throw new Error(`Invalid scope: ${raw} (expected AUTO|USER|TENANT)`);
20
+ }
21
+ export function extractCredentialError(response) {
22
+ const code = response.error?.code || response.code || 'API_ERROR';
23
+ const raw = response.error?.message || response.message || 'Unknown error';
24
+ const hint = ERROR_HINTS[code];
25
+ return { code, message: hint ? `${hint} (${raw})` : raw };
26
+ }
27
+ /**
28
+ * Credential failures use exit code 1, except `get` where 2 means the
29
+ * plaintext could not be obtained (see command help).
30
+ */
31
+ export function credentialFail(outputJson, code, message, exitCode = 1) {
32
+ if (outputJson) {
33
+ console.log(JSON.stringify({ success: false, error: { code, message } }, null, 2));
34
+ }
35
+ else {
36
+ console.error(chalk.red(`\n✗ ${message}`));
37
+ console.error(chalk.gray(` Error code: ${code}`));
38
+ console.error();
39
+ }
40
+ process.exit(exitCode);
41
+ }
42
+ export function credentialRows(data) {
43
+ if (!data || typeof data !== 'object')
44
+ return [];
45
+ const obj = data;
46
+ const rows = obj.rows ?? obj.records;
47
+ return Array.isArray(rows) ? rows : [];
48
+ }
49
+ //# sourceMappingURL=shared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../src/commands/liberica/credential/shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,WAAW,GAA2B;IAC1C,aAAa,EAAE,sBAAsB;IACrC,aAAa,EAAE,0DAA0D;IACzE,aAAa,EAAE,4CAA4C;IAC3D,aAAa,EAAE,wBAAwB;IACvC,aAAa,EAAE,uBAAuB;IACtC,aAAa,EAAE,2DAA2D;IAC1E,aAAa,EAAE,iCAAiC;IAChD,aAAa,EAAE,8CAA8C;IAC7D,aAAa,EAAE,wEAAwE;IACvF,aAAa,EAAE,6DAA6D;IAC5E,KAAK,EACH,4GAA4G;CAC/G,CAAC;AAEF,MAAM,UAAU,UAAU,CAAC,GAAY,EAAE,WAA4B,MAAM;IACzE,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,IAAI,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAC;IACpD,IAAI,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC7E,MAAM,IAAI,KAAK,CAAC,kBAAkB,GAAG,8BAA8B,CAAC,CAAC;AACvE,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,QAA+B;IAIpE,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,EAAE,IAAI,IAAI,QAAQ,CAAC,IAAI,IAAI,WAAW,CAAC;IAClE,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,EAAE,OAAO,IAAI,QAAQ,CAAC,OAAO,IAAI,eAAe,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"VN", "COMMON"];
2
+ export type CoaCountry = (typeof COA_COUNTRIES)[number];
3
+ /** Uppercase + validate a COA country code. Returns null for unknown values. */
4
+ export declare function normalizeCoaCountry(value: string): CoaCountry | null;
5
+ /** Merge per-country CSV exports into one file, keeping a single header row. */
6
+ export declare function mergeCsvBuffers(buffers: Buffer[]): Buffer;
7
+ //# sourceMappingURL=country.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"country.d.ts","sourceRoot":"","sources":["../../../../../src/commands/liberica/finance/coa/country.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,6CAA8C,CAAC;AAEzE,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAExD,gFAAgF;AAChF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAKpE;AAED,gFAAgF;AAChF,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CASzD"}
@@ -0,0 +1,21 @@
1
+ export const COA_COUNTRIES = ['CN', 'JP', 'HK', 'VN', 'COMMON'];
2
+ /** Uppercase + validate a COA country code. Returns null for unknown values. */
3
+ export function normalizeCoaCountry(value) {
4
+ const normalized = String(value).trim().toUpperCase();
5
+ return COA_COUNTRIES.includes(normalized)
6
+ ? normalized
7
+ : null;
8
+ }
9
+ /** Merge per-country CSV exports into one file, keeping a single header row. */
10
+ export function mergeCsvBuffers(buffers) {
11
+ if (buffers.length === 0)
12
+ return Buffer.alloc(0);
13
+ const parts = [buffers[0]];
14
+ for (const buffer of buffers.slice(1)) {
15
+ const text = buffer.toString('utf8');
16
+ const firstLineEnd = text.indexOf('\n');
17
+ parts.push(Buffer.from(firstLineEnd >= 0 ? text.slice(firstLineEnd + 1) : '', 'utf8'));
18
+ }
19
+ return Buffer.concat(parts);
20
+ }
21
+ //# sourceMappingURL=country.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"country.js","sourceRoot":"","sources":["../../../../../src/commands/liberica/finance/coa/country.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAU,CAAC;AAIzE,gFAAgF;AAChF,MAAM,UAAU,mBAAmB,CAAC,KAAa;IAC/C,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACtD,OAAQ,aAAmC,CAAC,QAAQ,CAAC,UAAU,CAAC;QAC9D,CAAC,CAAE,UAAyB;QAC5B,CAAC,CAAC,IAAI,CAAC;AACX,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,eAAe,CAAC,OAAiB;IAC/C,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACjD,MAAM,KAAK,GAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IACrC,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACrC,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACxC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;IACzF,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../../src/commands/liberica/finance/coa/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC,wBAAgB,6BAA6B,IAAI,OAAO,CA2EvD"}
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../../src/commands/liberica/finance/coa/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQpC,wBAAgB,6BAA6B,IAAI,OAAO,CAoHvD"}