@fluidgrids/cli 2026.1031.1 → 2026.1108.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 +97 -5
- package/dist/code-first/api.d.ts +6 -0
- package/dist/code-first/api.d.ts.map +1 -1
- package/dist/code-first/api.js +8 -2
- package/dist/code-first/api.js.map +1 -1
- package/dist/code-first/code-upload.d.ts +16 -1
- package/dist/code-first/code-upload.d.ts.map +1 -1
- package/dist/code-first/code-upload.js +62 -4
- package/dist/code-first/code-upload.js.map +1 -1
- package/dist/code-first/commands/hotfix.d.ts +2 -1
- package/dist/code-first/commands/hotfix.d.ts.map +1 -1
- package/dist/code-first/commands/hotfix.js +12 -6
- package/dist/code-first/commands/hotfix.js.map +1 -1
- package/dist/code-first/commands/init.js +2 -2
- package/dist/code-first/commands/init.js.map +1 -1
- package/dist/code-first/commands/push.d.ts +9 -2
- package/dist/code-first/commands/push.d.ts.map +1 -1
- package/dist/code-first/commands/push.js +11 -4
- package/dist/code-first/commands/push.js.map +1 -1
- package/dist/code-first/commands/replay.d.ts.map +1 -1
- package/dist/code-first/commands/replay.js +39 -6
- package/dist/code-first/commands/replay.js.map +1 -1
- package/dist/code-first/commands/runs.d.ts +10 -2
- package/dist/code-first/commands/runs.d.ts.map +1 -1
- package/dist/code-first/commands/runs.js +33 -0
- package/dist/code-first/commands/runs.js.map +1 -1
- package/dist/code-first/lowering.d.ts +10 -0
- package/dist/code-first/lowering.d.ts.map +1 -1
- package/dist/code-first/lowering.js +20 -14
- package/dist/code-first/lowering.js.map +1 -1
- package/dist/code-first/project.d.ts +7 -0
- package/dist/code-first/project.d.ts.map +1 -1
- package/dist/code-first/project.js +8 -1
- package/dist/code-first/project.js.map +1 -1
- package/dist/code-first/python-build.d.ts +78 -0
- package/dist/code-first/python-build.d.ts.map +1 -0
- package/dist/code-first/python-build.js +268 -0
- package/dist/code-first/python-build.js.map +1 -0
- package/dist/code-first/python.d.ts +22 -0
- package/dist/code-first/python.d.ts.map +1 -1
- package/dist/code-first/python.js +34 -23
- package/dist/code-first/python.js.map +1 -1
- package/dist/code-first/redact.d.ts.map +1 -1
- package/dist/code-first/redact.js +9 -0
- package/dist/code-first/redact.js.map +1 -1
- package/dist/code-first/register.d.ts.map +1 -1
- package/dist/code-first/register.js +5 -0
- package/dist/code-first/register.js.map +1 -1
- package/dist/code-first/replay.d.ts +2 -2
- package/dist/code-first/replay.d.ts.map +1 -1
- package/dist/code-first/replay.js.map +1 -1
- package/dist/config/apply.d.ts +51 -0
- package/dist/config/apply.d.ts.map +1 -0
- package/dist/config/apply.js +121 -0
- package/dist/config/apply.js.map +1 -0
- package/dist/config/commands.d.ts +58 -0
- package/dist/config/commands.d.ts.map +1 -0
- package/dist/config/commands.js +252 -0
- package/dist/config/commands.js.map +1 -0
- package/dist/config/profiles.d.ts +108 -0
- package/dist/config/profiles.d.ts.map +1 -0
- package/dist/config/profiles.js +339 -0
- package/dist/config/profiles.js.map +1 -0
- package/dist/flag-hint.d.ts +46 -0
- package/dist/flag-hint.d.ts.map +1 -0
- package/dist/flag-hint.js +114 -0
- package/dist/flag-hint.js.map +1 -0
- package/dist/modules.d.ts +3 -1
- package/dist/modules.d.ts.map +1 -1
- package/dist/modules.js +5 -1
- package/dist/modules.js.map +1 -1
- package/dist/phase-c/api.d.ts +433 -0
- package/dist/phase-c/api.d.ts.map +1 -0
- package/dist/phase-c/api.js +334 -0
- package/dist/phase-c/api.js.map +1 -0
- package/dist/phase-c/commands/activities.d.ts +119 -0
- package/dist/phase-c/commands/activities.d.ts.map +1 -0
- package/dist/phase-c/commands/activities.js +287 -0
- package/dist/phase-c/commands/activities.js.map +1 -0
- package/dist/phase-c/commands/batch.d.ts +90 -0
- package/dist/phase-c/commands/batch.d.ts.map +1 -0
- package/dist/phase-c/commands/batch.js +296 -0
- package/dist/phase-c/commands/batch.js.map +1 -0
- package/dist/phase-c/commands/queues.d.ts +67 -0
- package/dist/phase-c/commands/queues.d.ts.map +1 -0
- package/dist/phase-c/commands/queues.js +183 -0
- package/dist/phase-c/commands/queues.js.map +1 -0
- package/dist/phase-c/commands/run-control.d.ts +76 -0
- package/dist/phase-c/commands/run-control.d.ts.map +1 -0
- package/dist/phase-c/commands/run-control.js +245 -0
- package/dist/phase-c/commands/run-control.js.map +1 -0
- package/dist/phase-c/commands/schedules.d.ts +63 -0
- package/dist/phase-c/commands/schedules.d.ts.map +1 -0
- package/dist/phase-c/commands/schedules.js +198 -0
- package/dist/phase-c/commands/schedules.js.map +1 -0
- package/dist/phase-c/commands/search-attributes.d.ts +30 -0
- package/dist/phase-c/commands/search-attributes.d.ts.map +1 -0
- package/dist/phase-c/commands/search-attributes.js +70 -0
- package/dist/phase-c/commands/search-attributes.js.map +1 -0
- package/dist/phase-c/commands/signal-tokens.d.ts +27 -0
- package/dist/phase-c/commands/signal-tokens.d.ts.map +1 -0
- package/dist/phase-c/commands/signal-tokens.js +68 -0
- package/dist/phase-c/commands/signal-tokens.js.map +1 -0
- package/dist/phase-c/commands/worker-run.d.ts +109 -0
- package/dist/phase-c/commands/worker-run.d.ts.map +1 -0
- package/dist/phase-c/commands/worker-run.js +484 -0
- package/dist/phase-c/commands/worker-run.js.map +1 -0
- package/dist/phase-c/commands/workers.d.ts +46 -0
- package/dist/phase-c/commands/workers.d.ts.map +1 -0
- package/dist/phase-c/commands/workers.js +140 -0
- package/dist/phase-c/commands/workers.js.map +1 -0
- package/dist/phase-c/index.d.ts +16 -0
- package/dist/phase-c/index.d.ts.map +1 -0
- package/dist/phase-c/index.js +25 -0
- package/dist/phase-c/index.js.map +1 -0
- package/dist/phase-c/operations.d.ts +67 -0
- package/dist/phase-c/operations.d.ts.map +1 -0
- package/dist/phase-c/operations.js +559 -0
- package/dist/phase-c/operations.js.map +1 -0
- package/dist/phase-c/register.d.ts +39 -0
- package/dist/phase-c/register.d.ts.map +1 -0
- package/dist/phase-c/register.js +678 -0
- package/dist/phase-c/register.js.map +1 -0
- package/dist/phase-c/shared.d.ts +44 -0
- package/dist/phase-c/shared.d.ts.map +1 -0
- package/dist/phase-c/shared.js +146 -0
- package/dist/phase-c/shared.js.map +1 -0
- package/dist/program.d.ts +6 -1
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +20 -4
- package/dist/program.js.map +1 -1
- package/package.json +8 -5
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `fluidgrids config set|get|list|delete|migrate` (spec code-first 11 §2.36,
|
|
3
|
+
* Temporal's `temporal config` and environment profiles): the client profiles
|
|
4
|
+
* of `~/.fluidgrids/config.toml`, which the CLI and both workflow SDKs read.
|
|
5
|
+
*
|
|
6
|
+
* - `config set <key> <value> [--profile p]` sets a profile key;
|
|
7
|
+
* `config set token [--profile p] [--from-env VAR]` stores a token in the OS
|
|
8
|
+
* keychain (read from the variable, or from standard input) and points the
|
|
9
|
+
* profile's `tokenRef` at it; `config set defaultProfile <name>` picks the
|
|
10
|
+
* profile used when none is named.
|
|
11
|
+
* - `config get [key]` shows the resolved profile (the environment's
|
|
12
|
+
* `FLUIDGRIDS_<KEY>` overrides included); a token is never printed.
|
|
13
|
+
* - `config list` shows every profile.
|
|
14
|
+
* - `config delete [key] [--profile p]` removes a key, or the whole profile
|
|
15
|
+
* (and the keychain token the CLI stored for it).
|
|
16
|
+
* - `config migrate [--profile p]` writes the CLI's current workspace
|
|
17
|
+
* endpoint and workspace into a profile; tokens are never copied into the file.
|
|
18
|
+
*
|
|
19
|
+
* These commands work offline and never apply a profile themselves. A file that
|
|
20
|
+
* is not valid TOML is refused with a hint naming it: rewriting it would lose
|
|
21
|
+
* what it holds, so it is fixed by hand (or moved away to start again).
|
|
22
|
+
*/
|
|
23
|
+
import { type CLIContext } from '@burdenoff/cli-sdk/core';
|
|
24
|
+
import { type Keychain, type ProfileKey } from './profiles.js';
|
|
25
|
+
export interface ConfigEnv {
|
|
26
|
+
ctx: CLIContext;
|
|
27
|
+
env: Readonly<Record<string, string | undefined>>;
|
|
28
|
+
keychain: Keychain;
|
|
29
|
+
/** Standard input as text (a token piped to `config set token`). */
|
|
30
|
+
readStdin: () => Promise<string>;
|
|
31
|
+
}
|
|
32
|
+
export interface ConfigOptions {
|
|
33
|
+
format?: string;
|
|
34
|
+
/** The program's `--profile`. */
|
|
35
|
+
profile?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface SetOptions extends ConfigOptions {
|
|
38
|
+
/** `config set token`: read the token from this environment variable. */
|
|
39
|
+
fromEnv?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface DeleteOptions extends ConfigOptions {
|
|
42
|
+
/** Keep the keychain entry when the profile is deleted. */
|
|
43
|
+
keepToken?: boolean;
|
|
44
|
+
}
|
|
45
|
+
export interface MigrateOptions extends ConfigOptions {
|
|
46
|
+
/** Point the profile's tokenRef at this environment variable. */
|
|
47
|
+
tokenEnv?: string;
|
|
48
|
+
/** Make the profile the default one. */
|
|
49
|
+
setDefault?: boolean;
|
|
50
|
+
}
|
|
51
|
+
/** Check a value for its key. */
|
|
52
|
+
export declare function checkProfileValue(key: ProfileKey, value: string, profile: string): string;
|
|
53
|
+
export declare function runConfigSet(env: ConfigEnv, key: string, value: string | undefined, options: SetOptions): Promise<Record<string, unknown>>;
|
|
54
|
+
export declare function runConfigGet(env: ConfigEnv, key: string | undefined, options: ConfigOptions): Promise<Record<string, unknown>>;
|
|
55
|
+
export declare function runConfigList(env: ConfigEnv, options: ConfigOptions): Promise<Record<string, unknown>>;
|
|
56
|
+
export declare function runConfigDelete(env: ConfigEnv, key: string | undefined, options: DeleteOptions): Promise<Record<string, unknown>>;
|
|
57
|
+
export declare function runConfigMigrate(env: ConfigEnv, options: MigrateOptions): Promise<Record<string, unknown>>;
|
|
58
|
+
//# sourceMappingURL=commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/config/commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;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SAAS,EACvB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAmClC;AAED,wBAAsB,aAAa,CACjC,GAAG,EAAE,SAAS,EACd,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAuBlC;AAED,wBAAsB,eAAe,CACnC,GAAG,EAAE,SAAS,EACd,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAiClC;AAED,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,SAAS,EACd,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAkClC"}
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `fluidgrids config set|get|list|delete|migrate` (spec code-first 11 §2.36,
|
|
3
|
+
* Temporal's `temporal config` and environment profiles): the client profiles
|
|
4
|
+
* of `~/.fluidgrids/config.toml`, which the CLI and both workflow SDKs read.
|
|
5
|
+
*
|
|
6
|
+
* - `config set <key> <value> [--profile p]` sets a profile key;
|
|
7
|
+
* `config set token [--profile p] [--from-env VAR]` stores a token in the OS
|
|
8
|
+
* keychain (read from the variable, or from standard input) and points the
|
|
9
|
+
* profile's `tokenRef` at it; `config set defaultProfile <name>` picks the
|
|
10
|
+
* profile used when none is named.
|
|
11
|
+
* - `config get [key]` shows the resolved profile (the environment's
|
|
12
|
+
* `FLUIDGRIDS_<KEY>` overrides included); a token is never printed.
|
|
13
|
+
* - `config list` shows every profile.
|
|
14
|
+
* - `config delete [key] [--profile p]` removes a key, or the whole profile
|
|
15
|
+
* (and the keychain token the CLI stored for it).
|
|
16
|
+
* - `config migrate [--profile p]` writes the CLI's current workspace
|
|
17
|
+
* endpoint and workspace into a profile; tokens are never copied into the file.
|
|
18
|
+
*
|
|
19
|
+
* These commands work offline and never apply a profile themselves. A file that
|
|
20
|
+
* is not valid TOML is refused with a hint naming it: rewriting it would lose
|
|
21
|
+
* what it holds, so it is fixed by hand (or moved away to start again).
|
|
22
|
+
*/
|
|
23
|
+
import { CliUserError } from '@burdenoff/cli-sdk/core';
|
|
24
|
+
import { checkProfileName, configPath, DEFAULT_PROFILE, envNameOf, isProfileKey, KEYCHAIN_SERVICE, parseTokenRef, PROFILE_ENV, PROFILE_KEYS, profileTable, profilesTable, readConfig, resolveProfile, updateConfig, } from './profiles.js';
|
|
25
|
+
const ENV_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
26
|
+
const ENVIRONMENTS = ['DEV', 'STAGING', 'PROD'];
|
|
27
|
+
function output(env, options, data, rows, headers) {
|
|
28
|
+
env.ctx.output.formatAndOutput(options, data, { headers, rows });
|
|
29
|
+
}
|
|
30
|
+
function profileName(env, options) {
|
|
31
|
+
const raw = options.profile ?? (env.env[PROFILE_ENV]?.trim() || undefined);
|
|
32
|
+
if (raw !== undefined)
|
|
33
|
+
return checkProfileName(raw);
|
|
34
|
+
return readConfig(configPath(env.env)).defaultProfile ?? DEFAULT_PROFILE;
|
|
35
|
+
}
|
|
36
|
+
function isLocal(url) {
|
|
37
|
+
return url.hostname === 'localhost' || url.hostname === '127.0.0.1' || url.hostname === '::1';
|
|
38
|
+
}
|
|
39
|
+
/** Check a value for its key. */
|
|
40
|
+
export function checkProfileValue(key, value, profile) {
|
|
41
|
+
const trimmed = value.trim();
|
|
42
|
+
if (trimmed === '' || trimmed.length > 2048) {
|
|
43
|
+
throw new CliUserError(`${key} must be 1 to 2048 characters.`);
|
|
44
|
+
}
|
|
45
|
+
switch (key) {
|
|
46
|
+
case 'apiUrl':
|
|
47
|
+
case 'codecServerUrl': {
|
|
48
|
+
let url;
|
|
49
|
+
try {
|
|
50
|
+
url = new URL(trimmed);
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
throw new CliUserError(`${key} must be a URL.`);
|
|
54
|
+
}
|
|
55
|
+
if (url.protocol !== 'https:' && !(url.protocol === 'http:' && isLocal(url))) {
|
|
56
|
+
throw new CliUserError(`${key} must use https (http only for localhost).`);
|
|
57
|
+
}
|
|
58
|
+
if (url.username || url.password) {
|
|
59
|
+
throw new CliUserError(`${key} must not carry credentials.`);
|
|
60
|
+
}
|
|
61
|
+
return trimmed;
|
|
62
|
+
}
|
|
63
|
+
case 'environment': {
|
|
64
|
+
const upper = trimmed.toUpperCase();
|
|
65
|
+
if (!ENVIRONMENTS.includes(upper)) {
|
|
66
|
+
throw new CliUserError(`environment must be one of ${ENVIRONMENTS.join(', ')}.`);
|
|
67
|
+
}
|
|
68
|
+
return upper;
|
|
69
|
+
}
|
|
70
|
+
case 'tokenRef':
|
|
71
|
+
parseTokenRef(trimmed, profile);
|
|
72
|
+
return trimmed;
|
|
73
|
+
default:
|
|
74
|
+
return trimmed;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async function readToken(env, fromEnv) {
|
|
78
|
+
if (fromEnv !== undefined) {
|
|
79
|
+
if (!ENV_NAME.test(fromEnv))
|
|
80
|
+
throw new CliUserError('Invalid environment variable name for --from-env.');
|
|
81
|
+
const value = env.env[fromEnv]?.trim() ?? '';
|
|
82
|
+
if (value === '')
|
|
83
|
+
throw new CliUserError(`The environment variable ${fromEnv} is empty or unset.`);
|
|
84
|
+
return value;
|
|
85
|
+
}
|
|
86
|
+
const piped = (await env.readStdin()).trim();
|
|
87
|
+
if (piped === '') {
|
|
88
|
+
throw new CliUserError('Pipe the token on standard input, or pass --from-env <VAR>.', {
|
|
89
|
+
hint: 'For example: `printf %s "$TOKEN" | fluidgrids config set token --profile prod`.',
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
return piped;
|
|
93
|
+
}
|
|
94
|
+
export async function runConfigSet(env, key, value, options) {
|
|
95
|
+
const file = configPath(env.env);
|
|
96
|
+
if (key === 'defaultProfile') {
|
|
97
|
+
const name = checkProfileName(value?.trim() ?? '');
|
|
98
|
+
updateConfig(file, (document) => {
|
|
99
|
+
document['defaultProfile'] = name;
|
|
100
|
+
});
|
|
101
|
+
const out = { file, defaultProfile: name };
|
|
102
|
+
output(env, options, out, [['defaultProfile', name]], ['Key', 'Value']);
|
|
103
|
+
return out;
|
|
104
|
+
}
|
|
105
|
+
const profile = profileName(env, options);
|
|
106
|
+
if (key === 'token') {
|
|
107
|
+
if (value !== undefined) {
|
|
108
|
+
throw new CliUserError('A token is never given on the command line.', {
|
|
109
|
+
hint: 'Pipe it on standard input, or pass --from-env <VAR>.',
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
const token = await readToken(env, options.fromEnv);
|
|
113
|
+
env.keychain.set(KEYCHAIN_SERVICE, profile, token);
|
|
114
|
+
const ref = `keychain:${KEYCHAIN_SERVICE}/${profile}`;
|
|
115
|
+
updateConfig(file, (document) => {
|
|
116
|
+
const table = profileTable(document, profile, true);
|
|
117
|
+
if (table)
|
|
118
|
+
table['tokenRef'] = ref;
|
|
119
|
+
});
|
|
120
|
+
const out = { file, profile, tokenRef: ref };
|
|
121
|
+
output(env, options, out, [['tokenRef', ref]], ['Key', 'Value']);
|
|
122
|
+
return out;
|
|
123
|
+
}
|
|
124
|
+
if (!isProfileKey(key)) {
|
|
125
|
+
throw new CliUserError(`Unknown profile key ${key}.`, {
|
|
126
|
+
hint: `Keys: ${PROFILE_KEYS.join(', ')}, token, defaultProfile.`,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
if (value === undefined)
|
|
130
|
+
throw new CliUserError(`Give a value for ${key}.`);
|
|
131
|
+
const checked = checkProfileValue(key, value, profile);
|
|
132
|
+
updateConfig(file, (document) => {
|
|
133
|
+
const table = profileTable(document, profile, true);
|
|
134
|
+
if (table)
|
|
135
|
+
table[key] = checked;
|
|
136
|
+
});
|
|
137
|
+
const out = { file, profile, [key]: checked };
|
|
138
|
+
output(env, options, out, [[key, checked]], ['Key', 'Value']);
|
|
139
|
+
return out;
|
|
140
|
+
}
|
|
141
|
+
export async function runConfigGet(env, key, options) {
|
|
142
|
+
const file = configPath(env.env);
|
|
143
|
+
const config = readConfig(file);
|
|
144
|
+
const resolved = resolveProfile(config, env.env, options.profile, file);
|
|
145
|
+
if (key !== undefined && !isProfileKey(key)) {
|
|
146
|
+
throw new CliUserError(`Unknown profile key ${key}.`, {
|
|
147
|
+
hint: `Keys: ${PROFILE_KEYS.join(', ')}.`,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
const keys = key !== undefined && isProfileKey(key) ? [key] : PROFILE_KEYS;
|
|
151
|
+
const values = {};
|
|
152
|
+
for (const name of keys)
|
|
153
|
+
values[name] = resolved.values[name] ?? null;
|
|
154
|
+
const out = {
|
|
155
|
+
file,
|
|
156
|
+
profile: resolved.name,
|
|
157
|
+
defined: resolved.defined,
|
|
158
|
+
values,
|
|
159
|
+
fromEnv: resolved.fromEnv,
|
|
160
|
+
};
|
|
161
|
+
output(env, options, out, keys.map((name) => [
|
|
162
|
+
name,
|
|
163
|
+
resolved.values[name] ?? '-',
|
|
164
|
+
resolved.fromEnv.includes(name)
|
|
165
|
+
? envNameOf(name)
|
|
166
|
+
: resolved.defined && resolved.values[name] !== undefined
|
|
167
|
+
? 'file'
|
|
168
|
+
: '-',
|
|
169
|
+
]), ['Key', 'Value', 'From']);
|
|
170
|
+
return out;
|
|
171
|
+
}
|
|
172
|
+
export async function runConfigList(env, options) {
|
|
173
|
+
const file = configPath(env.env);
|
|
174
|
+
const config = readConfig(file);
|
|
175
|
+
const defaultProfile = config.defaultProfile ?? DEFAULT_PROFILE;
|
|
176
|
+
const names = Object.keys(config.profiles).sort();
|
|
177
|
+
const out = { file, defaultProfile, profiles: config.profiles };
|
|
178
|
+
output(env, options, out, names.map((name) => {
|
|
179
|
+
const values = config.profiles[name] ?? {};
|
|
180
|
+
return [
|
|
181
|
+
name === defaultProfile ? `${name} (default)` : name,
|
|
182
|
+
values.apiUrl ?? '-',
|
|
183
|
+
values.workspace ?? '-',
|
|
184
|
+
values.environment ?? '-',
|
|
185
|
+
values.tokenRef ?? '-',
|
|
186
|
+
];
|
|
187
|
+
}), ['Profile', 'API URL', 'Workspace', 'Environment', 'Token']);
|
|
188
|
+
return out;
|
|
189
|
+
}
|
|
190
|
+
export async function runConfigDelete(env, key, options) {
|
|
191
|
+
const file = configPath(env.env);
|
|
192
|
+
const profile = profileName(env, options);
|
|
193
|
+
const existing = readConfig(file).profiles[profile];
|
|
194
|
+
if (existing === undefined)
|
|
195
|
+
throw new CliUserError(`There is no profile ${profile} in ${file}.`);
|
|
196
|
+
if (key !== undefined) {
|
|
197
|
+
if (!isProfileKey(key))
|
|
198
|
+
throw new CliUserError(`Unknown profile key ${key}.`);
|
|
199
|
+
updateConfig(file, (document) => {
|
|
200
|
+
const table = profileTable(document, profile, false);
|
|
201
|
+
if (table)
|
|
202
|
+
delete table[key];
|
|
203
|
+
});
|
|
204
|
+
const out = { file, profile, deleted: key };
|
|
205
|
+
output(env, options, out, [[profile, key]], ['Profile', 'Deleted']);
|
|
206
|
+
return out;
|
|
207
|
+
}
|
|
208
|
+
const ownRef = `keychain:${KEYCHAIN_SERVICE}/${profile}`;
|
|
209
|
+
let tokenDeleted = false;
|
|
210
|
+
if (existing.tokenRef === ownRef && !options.keepToken) {
|
|
211
|
+
tokenDeleted = env.keychain.delete(KEYCHAIN_SERVICE, profile);
|
|
212
|
+
}
|
|
213
|
+
updateConfig(file, (document) => {
|
|
214
|
+
delete profilesTable(document)[profile];
|
|
215
|
+
if (document['defaultProfile'] === profile)
|
|
216
|
+
delete document['defaultProfile'];
|
|
217
|
+
});
|
|
218
|
+
const out = { file, profile, deleted: 'profile', tokenDeleted };
|
|
219
|
+
output(env, options, out, [[profile, tokenDeleted ? 'profile and keychain token' : 'profile']], ['Profile', 'Deleted']);
|
|
220
|
+
return out;
|
|
221
|
+
}
|
|
222
|
+
export async function runConfigMigrate(env, options) {
|
|
223
|
+
const file = configPath(env.env);
|
|
224
|
+
const profile = profileName(env, options);
|
|
225
|
+
const endpoint = env.ctx.config.read().workspaceEndpoint;
|
|
226
|
+
const workspace = env.ctx.auth.read()?.workspaceId;
|
|
227
|
+
const values = {
|
|
228
|
+
apiUrl: checkProfileValue('apiUrl', endpoint, profile),
|
|
229
|
+
product: 'fluidgrids',
|
|
230
|
+
};
|
|
231
|
+
if (workspace)
|
|
232
|
+
values.workspace = workspace;
|
|
233
|
+
if (options.tokenEnv !== undefined) {
|
|
234
|
+
if (!ENV_NAME.test(options.tokenEnv))
|
|
235
|
+
throw new CliUserError('Invalid environment variable name for --token-env.');
|
|
236
|
+
values.tokenRef = `env:${options.tokenEnv}`;
|
|
237
|
+
}
|
|
238
|
+
updateConfig(file, (document) => {
|
|
239
|
+
const table = profileTable(document, profile, true);
|
|
240
|
+
if (table)
|
|
241
|
+
Object.assign(table, values);
|
|
242
|
+
if (options.setDefault)
|
|
243
|
+
document['defaultProfile'] = profile;
|
|
244
|
+
});
|
|
245
|
+
const out = { file, profile, values, default: options.setDefault === true };
|
|
246
|
+
output(env, options, out, Object.entries(values).map(([name, value]) => [name, value ?? '-']), ['Key', 'Value']);
|
|
247
|
+
if (env.ctx.output.getFormat(options) === 'table' && !values.tokenRef) {
|
|
248
|
+
console.log(`The stored login was not copied (tokens never live in ${file}); set one with \`fluidgrids config set token --profile ${profile}\`.`);
|
|
249
|
+
}
|
|
250
|
+
return out;
|
|
251
|
+
}
|
|
252
|
+
//# sourceMappingURL=commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/config/commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,YAAY,EAAmB,MAAM,yBAAyB,CAAC;AAExE,OAAO,EACL,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,SAAS,EACT,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,WAA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gBAAgB,CAAC,GAAG,OAAO,CAAC;IAC/D,CAAC,CAAC,CAAC;IACH,MAAM,GAAG,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,UAAU,KAAK,IAAI,EAAE,CAAC;IAC5E,MAAM,CACJ,GAAG,EACH,OAAO,EACP,GAAG,EACH,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,IAAI,GAAG,CAAC,CAAC,EACnE,CAAC,KAAK,EAAE,OAAO,CAAC,CACjB,CAAC;IACF,IAAI,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;QACtE,OAAO,CAAC,GAAG,CACT,yDAAyD,IAAI,2DAA2D,OAAO,KAAK,CACrI,CAAC;IACJ,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client profiles (spec code-first 11 §2.36, DCP10): `~/.fluidgrids/config.toml`.
|
|
3
|
+
*
|
|
4
|
+
* The CLI and both workflow SDKs read the same file, in the format the Python
|
|
5
|
+
* SDK's `fluidgrids_workflows.profiles` defines:
|
|
6
|
+
*
|
|
7
|
+
* defaultProfile = "prod"
|
|
8
|
+
*
|
|
9
|
+
* [profiles.prod]
|
|
10
|
+
* apiUrl = "https://graphqlworkspaces.burdenoff.com/workspaces/graphql"
|
|
11
|
+
* workspace = "ws-123"
|
|
12
|
+
* tokenRef = "keychain:fluidgrids/prod"
|
|
13
|
+
*
|
|
14
|
+
* - A profile sets only the keys in {@link PROFILE_KEYS}.
|
|
15
|
+
* - `FLUIDGRIDS_PROFILE` (or `--profile`) selects a profile; otherwise
|
|
16
|
+
* `defaultProfile`, otherwise `default`.
|
|
17
|
+
* - `FLUIDGRIDS_<KEY>` environment variables (`FLUIDGRIDS_API_URL`,
|
|
18
|
+
* `FLUIDGRIDS_WORKSPACE`, …) override single keys.
|
|
19
|
+
* - Tokens never live in the file. `tokenRef` says where the token is:
|
|
20
|
+
* `env:<VAR>` or `keychain:<service>/<account>` (the OS keychain, through
|
|
21
|
+
* `@napi-rs/keyring`). Any other form, `file:` included, is refused, and so
|
|
22
|
+
* is a key in the file that looks like a secret.
|
|
23
|
+
*
|
|
24
|
+
* `FLUIDGRIDS_CONFIG` points at another file (tests, CI).
|
|
25
|
+
*/
|
|
26
|
+
export declare const CONFIG_ENV = "FLUIDGRIDS_CONFIG";
|
|
27
|
+
export declare const PROFILE_ENV = "FLUIDGRIDS_PROFILE";
|
|
28
|
+
export declare const TOKEN_ENV = "FLUIDGRIDS_TOKEN";
|
|
29
|
+
export declare const DEFAULT_PROFILE = "default";
|
|
30
|
+
export declare const PROFILE_FLAG = "--profile";
|
|
31
|
+
/** The keychain service the CLI stores tokens under (`config set token`). */
|
|
32
|
+
export declare const KEYCHAIN_SERVICE = "fluidgrids";
|
|
33
|
+
/** The keys a profile may set (spec 11 §2.36), in the order they are listed. */
|
|
34
|
+
export declare const PROFILE_KEYS: readonly ["apiUrl", "workspace", "product", "environment", "tokenRef", "codecServerUrl", "payloadConverter"];
|
|
35
|
+
export type ProfileKey = (typeof PROFILE_KEYS)[number];
|
|
36
|
+
export type ProfileValues = Partial<Record<ProfileKey, string>>;
|
|
37
|
+
export interface ConfigFile {
|
|
38
|
+
defaultProfile?: string;
|
|
39
|
+
profiles: Record<string, ProfileValues>;
|
|
40
|
+
}
|
|
41
|
+
/** One resolved profile: the file's values with the environment's overrides. */
|
|
42
|
+
export interface ResolvedProfile {
|
|
43
|
+
name: string;
|
|
44
|
+
/** True when the file defines the profile (an env-only profile has no table). */
|
|
45
|
+
defined: boolean;
|
|
46
|
+
values: ProfileValues;
|
|
47
|
+
/** Keys whose value came from a `FLUIDGRIDS_<KEY>` variable. */
|
|
48
|
+
fromEnv: ProfileKey[];
|
|
49
|
+
}
|
|
50
|
+
/** Where a token is: an environment variable or a keychain entry. */
|
|
51
|
+
export type TokenRef = {
|
|
52
|
+
kind: 'env';
|
|
53
|
+
variable: string;
|
|
54
|
+
} | {
|
|
55
|
+
kind: 'keychain';
|
|
56
|
+
service: string;
|
|
57
|
+
account: string;
|
|
58
|
+
};
|
|
59
|
+
/** The OS keychain, narrowed to what the CLI uses; tests substitute it. */
|
|
60
|
+
export interface Keychain {
|
|
61
|
+
get(service: string, account: string): string | null;
|
|
62
|
+
set(service: string, account: string, secret: string): void;
|
|
63
|
+
delete(service: string, account: string): boolean;
|
|
64
|
+
}
|
|
65
|
+
export declare function isProfileKey(key: string): key is ProfileKey;
|
|
66
|
+
/** `apiUrl` → `FLUIDGRIDS_API_URL` (the Python SDK's mapping). */
|
|
67
|
+
export declare function envNameOf(key: ProfileKey): string;
|
|
68
|
+
/** The config file: `FLUIDGRIDS_CONFIG`, else `~/.fluidgrids/config.toml`. */
|
|
69
|
+
export declare function configPath(env?: Readonly<Record<string, string | undefined>>, home?: string): string;
|
|
70
|
+
export declare function checkProfileName(name: string): string;
|
|
71
|
+
/** Parse a `tokenRef`; anything but `env:` and `keychain:` (a `file:` path included) is refused. */
|
|
72
|
+
export declare function parseTokenRef(ref: string, profile: string): TokenRef;
|
|
73
|
+
/** Parse the text of a config file (an empty file is an empty config). */
|
|
74
|
+
export declare function parseConfig(text: string, file: string): ConfigFile;
|
|
75
|
+
/** The config file's contents; an absent file is an empty config. */
|
|
76
|
+
export declare function readConfig(file: string): ConfigFile;
|
|
77
|
+
/** The parsed TOML document of the file (keys the CLI does not manage included). */
|
|
78
|
+
export declare function readRawConfig(file: string): Record<string, unknown>;
|
|
79
|
+
/**
|
|
80
|
+
* Change the file: `change` edits the parsed document (keys the CLI does not
|
|
81
|
+
* manage stay as they are), the result is checked like a read, then written
|
|
82
|
+
* atomically (a temporary file renamed over it), readable by the owner only.
|
|
83
|
+
*/
|
|
84
|
+
export declare function updateConfig(file: string, change: (document: Record<string, unknown>) => void): ConfigFile;
|
|
85
|
+
/** The `profiles` table of a parsed document, created when absent. */
|
|
86
|
+
export declare function profilesTable(document: Record<string, unknown>): Record<string, unknown>;
|
|
87
|
+
/** One profile's table of a parsed document, created when `create` is set. */
|
|
88
|
+
export declare function profileTable(document: Record<string, unknown>, name: string, create: boolean): Record<string, unknown> | undefined;
|
|
89
|
+
/** The profile name in argv (`--profile <name>` or `--profile=<name>`), if given. */
|
|
90
|
+
export declare function profileFromArgv(argv: readonly string[]): string | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* The profile in effect: `name`, else `FLUIDGRIDS_PROFILE`, else the file's
|
|
93
|
+
* `defaultProfile`, else `default`. A profile named explicitly must exist; the
|
|
94
|
+
* fallback `default` may be absent (then only the environment sets keys).
|
|
95
|
+
*/
|
|
96
|
+
export declare function resolveProfile(config: ConfigFile, env: Readonly<Record<string, string | undefined>>, name?: string, file?: string): ResolvedProfile;
|
|
97
|
+
/**
|
|
98
|
+
* The OS keychain through `@napi-rs/keyring`, loaded on first use so a
|
|
99
|
+
* platform without its native binary only fails when a profile names the
|
|
100
|
+
* keychain.
|
|
101
|
+
*/
|
|
102
|
+
export declare function osKeychain(): Keychain;
|
|
103
|
+
/**
|
|
104
|
+
* The token a profile names, or undefined when it names none; `FLUIDGRIDS_TOKEN`
|
|
105
|
+
* always wins. A tokenRef whose variable or keychain entry holds no token is an error.
|
|
106
|
+
*/
|
|
107
|
+
export declare function resolveProfileToken(profile: ResolvedProfile, env: Readonly<Record<string, string | undefined>>, keychain: Keychain): string | undefined;
|
|
108
|
+
//# sourceMappingURL=profiles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiles.d.ts","sourceRoot":"","sources":["../../src/config/profiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAUH,eAAO,MAA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