@flowscripter/dynamic-cli-framework 12.1.0 → 12.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/src/cli/BaseCLI.d.ts.map +1 -1
  2. package/dist/src/cli/BaseCLI.js +1 -1
  3. package/dist/src/runtime/runner.d.ts.map +1 -1
  4. package/dist/src/runtime/runner.js +4 -1
  5. package/dist/src/service/configuration/ConfigurationServiceProvider.d.ts +23 -13
  6. package/dist/src/service/configuration/ConfigurationServiceProvider.d.ts.map +1 -1
  7. package/dist/src/service/configuration/ConfigurationServiceProvider.js +69 -179
  8. package/dist/src/service/configuration/DefaultConfigurationService.d.ts +78 -0
  9. package/dist/src/service/configuration/DefaultConfigurationService.d.ts.map +1 -0
  10. package/dist/src/service/configuration/DefaultConfigurationService.js +296 -0
  11. package/dist/src/service/configuration/DefaultKeyValueService.d.ts.map +1 -1
  12. package/dist/src/service/configuration/DefaultKeyValueService.js +7 -3
  13. package/dist/src/service/configuration/DefaultSecretService.d.ts +17 -2
  14. package/dist/src/service/configuration/DefaultSecretService.d.ts.map +1 -1
  15. package/dist/src/service/configuration/DefaultSecretService.js +44 -5
  16. package/dist/src/service/configuration/KeyValueServiceProvider.d.ts +3 -1
  17. package/dist/src/service/configuration/KeyValueServiceProvider.d.ts.map +1 -1
  18. package/dist/src/service/configuration/KeyValueServiceProvider.js +6 -3
  19. package/dist/src/service/configuration/command/ConfigDumpSubCommand.d.ts +3 -7
  20. package/dist/src/service/configuration/command/ConfigDumpSubCommand.d.ts.map +1 -1
  21. package/dist/src/service/configuration/command/ConfigDumpSubCommand.js +5 -10
  22. package/dist/src/service/configuration/command/ConfigGetSubCommand.d.ts +16 -0
  23. package/dist/src/service/configuration/command/ConfigGetSubCommand.d.ts.map +1 -0
  24. package/dist/src/service/configuration/command/ConfigGetSubCommand.js +137 -0
  25. package/dist/src/service/configuration/command/ConfigSetSubCommand.d.ts +18 -0
  26. package/dist/src/service/configuration/command/ConfigSetSubCommand.d.ts.map +1 -0
  27. package/dist/src/service/configuration/command/ConfigSetSubCommand.js +289 -0
  28. package/dist/src/service/configuration/command/ConfigUnsetSubCommand.d.ts +15 -0
  29. package/dist/src/service/configuration/command/ConfigUnsetSubCommand.d.ts.map +1 -0
  30. package/dist/src/service/configuration/command/ConfigUnsetSubCommand.js +101 -0
  31. package/dist/src/service/configuration/configTargets.d.ts +91 -0
  32. package/dist/src/service/configuration/configTargets.d.ts.map +1 -0
  33. package/dist/src/service/configuration/configTargets.js +348 -0
  34. package/dist/src/service/configuration/resolveSecrets.d.ts.map +1 -1
  35. package/dist/src/service/configuration/resolveSecrets.js +7 -1
  36. package/package.json +1 -1
  37. package/src/cli/BaseCLI.ts +1 -0
  38. package/src/runtime/runner.ts +4 -1
  39. package/src/service/configuration/ConfigurationServiceProvider.ts +95 -227
  40. package/src/service/configuration/DefaultConfigurationService.ts +378 -0
  41. package/src/service/configuration/DefaultKeyValueService.ts +9 -3
  42. package/src/service/configuration/DefaultSecretService.ts +51 -8
  43. package/src/service/configuration/KeyValueServiceProvider.ts +7 -2
  44. package/src/service/configuration/command/ConfigDumpSubCommand.ts +6 -10
  45. package/src/service/configuration/command/ConfigGetSubCommand.ts +198 -0
  46. package/src/service/configuration/command/ConfigSetSubCommand.ts +401 -0
  47. package/src/service/configuration/command/ConfigUnsetSubCommand.ts +126 -0
  48. package/src/service/configuration/configTargets.ts +481 -0
  49. package/src/service/configuration/resolveSecrets.ts +7 -1
@@ -1 +1 @@
1
- {"version":3,"file":"BaseCLI.d.ts","sourceRoot":"","sources":["../../../src/cli/BaseCLI.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,yCAAyC,CAAC;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAIzE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AAGvE,OAAO,KAAK,EAAE,e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iceProvider(new PluginServiceProvider(PLUGIN_SERVICE_PRIORITY, this.#options.pluginServiceRemoteConfig, this.#options.pluginServiceLocalConfig, this.#commandRegistry, this.#serviceProviderRegistry));
249
249
  }
250
- const configurationServiceProvider = new ConfigurationServiceProvider(CONFIGURATION_SERVICE_PRIORITY, this.#options.envVarsSupportEnabled, this.#options.configFileSupportEnabled, this.#options.secretServiceEnabled, this.#options.configFormat);
250
+ const configurationServiceProvider = new ConfigurationServiceProvider(CONFIGURATION_SERVICE_PRIORITY, this.#options.envVarsSupportEnabled, this.#options.configFileSupportEnabled, this.#options.secretServiceEnabled, this.#options.configFormat, this.#commandRegistry);
251
251
  this.addServiceProvider(configurationServiceProvider);
252
252
  const keyValueServiceProvider = new KeyValueServiceProvider(KEY_VALUE_SERVICE_PRIORITY, configurationServiceProvider, this.#options.keyValueServiceEnabled, this.#options.secretServiceEnabled);
253
253
  this.addServiceProvider(keyValueServiceProvider);
@@ -1 +1 @@
1
- {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../../src/runtime/runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAkB/E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAEvF,OAAO,KAAK,4BAA4B,MAAM,0DAA0D,CAAC;AACzG,OAAO,KAAK,uBAAuB,MAAM,qDAAqD,CAAC;AAK/F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AAKvE,OAAO,qBAAqB,MAAM,6CAA6C,CAAC;AAMhF;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG;IAAE,QAAQ,CAAC,aAAa,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AAsfzE;;;;;;;;;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AAuB,EAAE,uBAAuB,EAChD,4BAA4B,EAAE,4BAA4B,GAAG,SAAS,EACtE,uBAAuB,EAAE,uBAAuB,GAAG,SAAS,EAC5D,OAAO,EAAE,OAAO,EAChB,cAAc,CAAC,EAAE,OAAO,EACxB,cAAc,CAAC,EAAE,qBAAqB,GACrC,OAAO,CAAC,YAAY,CAAC,CAkKvB"}
@@ -62,8 +62,11 @@ async function executeParsedCommand(parseResult, context, keyValueServiceProvide
62
62
  await parseResult.groupCommand.execute(groupContext);
63
63
  }
64
64
  logger.debug("Executing command with name: %s and args: %O", parseResult.command.name, parseResult.populatedArgumentValues);
65
+ const commandScopeKey = parseResult.groupCommand
66
+ ? `${parseResult.groupCommand.name}:${parseResult.command.name}`
67
+ : parseResult.command.name;
65
68
  const commandContext = keyValueServiceProvider
66
- ? keyValueServiceProvider.getContextForScope(context, "command", parseResult.command.name)
69
+ ? keyValueServiceProvider.getContextForScope(context, "command", commandScopeKey)
67
70
  : context;
68
71
  if (isSubCommand(parseResult.command)) {
69
72
  await parseResult.command.execute(commandContext, parseResult.populatedArgumentValues);
@@ -2,21 +2,22 @@ import type { ServiceInfo, ServiceProvider } from "@flowscripter/dynamic-cli-fra
2
2
  import type { SingleValueType, Values, ValueNode, PopulatedValues, PopulatedValueType } from "@flowscripter/dynamic-cli-framework-api";
3
3
  import type { Context } from "@flowscripter/dynamic-cli-framework-api";
4
4
  import type { GroupCommand } from "@flowscripter/dynamic-cli-framework-api";
5
+ import type { CommandRegistry } from "@flowscripter/dynamic-cli-framework-api";
6
+ import DefaultConfigurationService, { type KeyValueServiceScopeType } from "./DefaultConfigurationService.ts";
7
+ import { type SecretsApi } from "./DefaultSecretService.ts";
5
8
  import type ConfigFormat from "./format/ConfigFormat.ts";
6
9
  import type { Command } from "@flowscripter/dynamic-cli-framework-api";
7
10
  import type { CLIConfig } from "@flowscripter/dynamic-cli-framework-api";
8
- export type KeyValueServiceScopeType = "command" | "service";
11
+ export type { KeyValueServiceScopeType };
9
12
  /**
10
13
  * Provides configuration of default command arguments using a configuration file and/or
11
14
  * environment variables.
12
15
  *
13
16
  * The same configuration file also backs the raw, per-scope key-value data consumed by
14
17
  * {@link KeyValueServiceProvider} (which holds a direct reference to this provider - see
15
- * {@link getKeyValueData} and {@link flushIfDirty} - rather than looking this provider up via
16
- * {@link Context}, since only {@link configLocation}/{@link setConfigLocation} are safe to expose
17
- * generally; {@link getConfigString} is wired directly to {@link ConfigDumpSubCommand} for the same
18
- * reason - a full config dump would leak every other command's/service's key-value data if it
19
- * were reachable through a general lookup).
18
+ * {@link getKeyValueData} and {@link flushIfDirty}). The configuration data and its persistence are
19
+ * owned by {@link DefaultConfigurationService}, which is passed directly to the `config` group commands. Only a
20
+ * view exposing the config file location is registered under {@link CONFIGURATION_SERVICE_ID}.
20
21
  *
21
22
  * **Default Command Arguments**
22
23
  *
@@ -67,10 +68,10 @@ export type KeyValueServiceScopeType = "command" | "service";
67
68
  * default configuration will be used. The location of the configuration file can be modified via the
68
69
  * {@link ConfigCommand}.
69
70
  *
70
- * NOTE: You may store default arguments for secrets by manually configuring secrets in your OS
71
- * credential store and referencing them in the config file using the sentinel format
72
- * `__SECRET__:<bun_secret_name>`. These values will be resolved from the OS secret store
73
- * before being returned as default argument values. See {@link KeyValueServiceProvider} for the
71
+ * NOTE: Secrets in default arguments are referenced in the config file or an environment variable using
72
+ * the sentinel format `__SECRET__:<bun_secret_name>` and resolved from the OS secret store before being
73
+ * returned as default argument values. A command's defaults may only reference secrets stored for that
74
+ * command via `config set` (named `defaults_Z<command>_Z<option path>`, each part escaped). See {@link KeyValueServiceProvider} for the
74
75
  * generic key-value store which uses the same secret sentinel mechanism.
75
76
  *
76
77
  * *Environment Variables*
@@ -120,8 +121,6 @@ export default class ConfigurationServiceProvider implements ServiceProvider {
120
121
  readonly configEnabled: boolean;
121
122
  readonly secretServiceEnabled: boolean;
122
123
  readonly configFormat: ConfigFormat;
123
- configLocation: string | undefined;
124
- defaultsData: Map<string, Values | SingleValueType>;
125
124
  /**
126
125
  * Create an instance of the service provider with the specified details.
127
126
  *
@@ -131,9 +130,20 @@ export default class ConfigurationServiceProvider implements ServiceProvider {
131
130
  * @param secretServiceEnabled optionally enable OS-native secret storage via Bun.secrets for resolving
132
131
  * secrets embedded in default argument values: `configEnabled` must be true in this case
133
132
  * @param configFormat optionally set the syntax of the configuration file, defaults to JSON.
133
+ * @param commandRegistry optionally provide the registry of all commands, required for the `config:get`,
134
+ * `config:set` and `config:unset` commands to be provided.
135
+ * @param secretsApi optionally override the OS secret store used for storing SECRET default values.
134
136
  */
135
- constructor(servicePriority: number, envVarsEnabled?: boolean, configEnabled?: boolean, secretServiceEnabled?: boolean, configFormat?: ConfigFormat);
137
+ constructor(servicePriority: number, envVarsEnabled?: boolean, configEnabled?: boolean, secretServiceEnabled?: boolean, configFormat?: ConfigFormat, commandRegistry?: CommandRegistry, secretsApi?: SecretsApi);
136
138
  getServiceInfo(cliConfig: CLIConfig): Promise<ServiceInfo>;
139
+ /**
140
+ * The {@link DefaultConfigurationService} which owns the configuration data, for trusted wiring and tests.
141
+ */
142
+ get configurationService(): DefaultConfigurationService;
143
+ get configLocation(): string | undefined;
144
+ set configLocation(location: string | undefined);
145
+ get defaultsData(): Map<string, Values | SingleValueType>;
146
+ set defaultsData(data: Map<string, Values | SingleValueType>);
137
147
  setConfigLocation(configLocation: string): void;
138
148
  /**
139
149
  * Retrieve the default command argument values (if any) for the provided {@link Command}.
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigurationServiceProvider.d.ts","sourceRoot":"","sources":["../../../../src/service/configuration/ConfigurationServiceProvider.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAE5F,OAAO,KAAK,EACV,eAAe,EACf,MAAM,EACN,SAAS,EACT,eAAe,EACf,kBAAkB,EACnB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yCAAyC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e,GAAG,kBAAkB,GAAG,SAAS,CAAC,CAsD3D;IAED;;;;;;OAMG;IACI,eAAe,CACpB,SAAS,EAAE,wBAAwB,EACnC,QAAQ,EAAE,MAAM,GACf,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAOxB;IAED;;;;;;OAMG;IACU,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAQzD;IAEY,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CA6CxD;IAgEM,eAAe,IAAI,MAAM,CAE/B;CAmCF"}
1
+ {"version":3,"file":"ConfigurationServiceProvider.d.ts","sourceRoot":"","sources":["../../../../src/service/configuration/ConfigurationServiceProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAE5F,OAAO,KAAK,EACV,eAAe,EACf,MAAM,EACN,SAAS,EACT,eAAe,EACf,kBAAkB,EACnB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,KAAK,EAAc,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAMxF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAK/E,OAAO,2BAA2B,EAAE,EAClC,KAAK,wBAAwB,EAC9B,MAAM,kCAAkC,CAAC;AAC1C,OAA6B,EAAE,KAAK,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAClF,OAAO,KAAK,YAAY,MAAM,0BAA0B,CAAC;AAEzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AAOvE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAMzE,YAAY,EAAE,wBAAwB,EAAE,CAAC;AA0BzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAE,wBAAwB,EACnC,QAAQ,EAAE,MAAM,GACf,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAExB;IAED;;;;;;OAMG;IACI,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnD;IAEY,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAKxD;IAEM,eAAe,IAAI,MAAM,CAE/B;CACF"}
@@ -1,29 +1,34 @@
1
- import process from "node:process";
2
- import path from "node:path";
3
- import fs from "node:fs/promises";
4
- import { Stats } from "node:fs";
5
1
  import ConfigCommand from "./command/ConfigCommand.js";
6
2
  import getLogger from "../../util/logger.js";
7
3
  import ConfigDumpSubCommand from "./command/ConfigDumpSubCommand.js";
8
4
  import ConfigGroupCommand from "./command/ConfigGroupCommand.js";
9
- import { CONFIGURATION_SERVICE_ID, SECRET_SENTINEL_PREFIX, } from "@flowscripter/dynamic-cli-framework-api";
10
- import DefaultSecretService from "./DefaultSecretService.js";
5
+ import ConfigGetSubCommand from "./command/ConfigGetSubCommand.js";
6
+ import ConfigSetSubCommand from "./command/ConfigSetSubCommand.js";
7
+ import ConfigUnsetSubCommand from "./command/ConfigUnsetSubCommand.js";
8
+ import { CONFIGURATION_SERVICE_ID, } from "@flowscripter/dynamic-cli-framework-api";
9
+ import DefaultConfigurationService, {} from "./DefaultConfigurationService.js";
10
+ import DefaultSecretService, {} from "./DefaultSecretService.js";
11
11
  import jsonFormat from "./format/JsonConfigFormat.js";
12
- import resolveSecrets from "./resolveSecrets.js";
13
12
  import argumentValueMerge from "../../runtime/values/argumentValueMerge.js";
14
13
  import { isGlobalCommand, isGlobalModifierCommand, isSubCommand, } from "../../runtime/command/CommandTypeGuards.js";
15
14
  import { getGlobalCommandValueFromEnvVars, getSubCommandValuesFromEnvVars, } from "../../util/envVarHelper.js";
16
15
  const logger = getLogger("ConfigurationServiceProvider");
17
- class ConfigurationServiceImpl {
18
- #provider;
19
- constructor(provider) {
20
- this.#provider = provider;
16
+ /**
17
+ * The only view of the configuration which is registered in the {@link Context}, and therefore reachable by
18
+ * every command and service. It deliberately exposes nothing but the config file location: the
19
+ * {@link DefaultConfigurationService} (default values, per-scope key-value data, secret resolution and
20
+ * persistence) is only handed to the `config` group commands and {@link KeyValueServiceProvider}.
21
+ */
22
+ class ConfigurationLocationService {
23
+ #service;
24
+ constructor(service) {
25
+ this.#service = service;
21
26
  }
22
27
  get configLocation() {
23
- return this.#provider.configLocation;
28
+ return this.#service.configLocation;
24
29
  }
25
30
  setConfigLocation(location) {
26
- this.#provider.setConfigLocation(location);
31
+ this.#service.setConfigLocation(location);
27
32
  }
28
33
  }
29
34
  /**
@@ -32,11 +37,9 @@ class ConfigurationServiceImpl {
32
37
  *
33
38
  * The same configuration file also backs the raw, per-scope key-value data consumed by
34
39
  * {@link KeyValueServiceProvider} (which holds a direct reference to this provider - see
35
- * {@link getKeyValueData} and {@link flushIfDirty} - rather than looking this provider up via
36
- * {@link Context}, since only {@link configLocation}/{@link setConfigLocation} are safe to expose
37
- * generally; {@link getConfigString} is wired directly to {@link ConfigDumpSubCommand} for the same
38
- * reason - a full config dump would leak every other command's/service's key-value data if it
39
- * were reachable through a general lookup).
40
+ * {@link getKeyValueData} and {@link flushIfDirty}). The configuration data and its persistence are
41
+ * owned by {@link DefaultConfigurationService}, which is passed directly to the `config` group commands. Only a
42
+ * view exposing the config file location is registered under {@link CONFIGURATION_SERVICE_ID}.
40
43
  *
41
44
  * **Default Command Arguments**
42
45
  *
@@ -87,10 +90,10 @@ class ConfigurationServiceImpl {
87
90
  * default configuration will be used. The location of the configuration file can be modified via the
88
91
  * {@link ConfigCommand}.
89
92
  *
90
- * NOTE: You may store default arguments for secrets by manually configuring secrets in your OS
91
- * credential store and referencing them in the config file using the sentinel format
92
- * `__SECRET__:<bun_secret_name>`. These values will be resolved from the OS secret store
93
- * before being returned as default argument values. See {@link KeyValueServiceProvider} for the
93
+ * NOTE: Secrets in default arguments are referenced in the config file or an environment variable using
94
+ * the sentinel format `__SECRET__:<bun_secret_name>` and resolved from the OS secret store before being
95
+ * returned as default argument values. A command's defaults may only reference secrets stored for that
96
+ * command via `config set` (named `defaults_Z<command>_Z<option path>`, each part escaped). See {@link KeyValueServiceProvider} for the
94
97
  * generic key-value store which uses the same secret sentinel mechanism.
95
98
  *
96
99
  * *Environment Variables*
@@ -139,30 +142,13 @@ export default class ConfigurationServiceProvider {
139
142
  configEnabled;
140
143
  secretServiceEnabled;
141
144
  configFormat;
142
- // the location of the currently managed configuration data
143
- configLocation;
144
- // the format specific handle for the text last read or written, used to preserve comments and layout on write
145
- #configHandle;
146
- // the configuration data to be used by the CLI runner implementation when setting command defaults.
147
- // SingleValueType is for GlobalCommandArgument values, Values is for
148
- // SubCommandArgument values.
149
- defaultsData = new Map();
150
- // the underlying per-scope key-value data, read from/written to the configuration file. Exposed
151
- // (raw, not wrapped in a KeyValueService) only via getKeyValueData(), for KeyValueServiceProvider's
152
- // exclusive use.
153
- #commandKeyValueData = new Map();
154
- #serviceKeyValueData = new Map();
155
- // secret service used only to resolve secret sentinels embedded in default command argument
156
- // values (getDefaultArgumentValues()) - unrelated to per-command/per-service KV scoping, so it
157
- // uses its own fixed, dedicated scope prefix ("defaults"). Its scope is otherwise irrelevant,
158
- // since only getSecret() (which doesn't consult scope) is ever called on it.
159
- #defaultsSecretService;
160
145
  /**
161
- * A {@link ConfigurationService} view of this provider, registered in the {@link Context} under
162
- * {@link CONFIGURATION_SERVICE_ID}. Its `configLocation` getter always reflects this provider's
163
- * current value.
146
+ * The {@link DefaultConfigurationService} which owns the configuration data. It is never registered
147
+ * in the {@link Context}: it is handed directly to the `config` group commands only.
164
148
  */
165
149
  #configurationService;
150
+ #hasCommandRegistry;
151
+ #secretsApi;
166
152
  /**
167
153
  * Create an instance of the service provider with the specified details.
168
154
  *
@@ -172,8 +158,11 @@ export default class ConfigurationServiceProvider {
172
158
  * @param secretServiceEnabled optionally enable OS-native secret storage via Bun.secrets for resolving
173
159
  * secrets embedded in default argument values: `configEnabled` must be true in this case
174
160
  * @param configFormat optionally set the syntax of the configuration file, defaults to JSON.
161
+ * @param commandRegistry optionally provide the registry of all commands, required for the `config:get`,
162
+ * `config:set` and `config:unset` commands to be provided.
163
+ * @param secretsApi optionally override the OS secret store used for storing SECRET default values.
175
164
  */
176
- constructor(servicePriority, envVarsEnabled = false, configEnabled = false, secretServiceEnabled = false, configFormat = jsonFormat) {
165
+ constructor(servicePriority, envVarsEnabled = false, configEnabled = false, secretServiceEnabled = false, configFormat = jsonFormat, commandRegistry, secretsApi) {
177
166
  if (!configEnabled && secretServiceEnabled) {
178
167
  throw new Error("configEnabled must be true if secretServiceEnabled is true");
179
168
  }
@@ -182,25 +171,49 @@ export default class ConfigurationServiceProvider {
182
171
  this.configEnabled = configEnabled;
183
172
  this.secretServiceEnabled = secretServiceEnabled;
184
173
  this.configFormat = configFormat;
185
- this.#configurationService = new ConfigurationServiceImpl(this);
174
+ this.#hasCommandRegistry = commandRegistry !== undefined;
175
+ this.#secretsApi = secretsApi;
176
+ this.#configurationService = new DefaultConfigurationService(envVarsEnabled, configFormat, commandRegistry);
186
177
  }
187
178
  getServiceInfo(cliConfig) {
188
179
  const commands = [];
189
180
  if (this.configEnabled) {
190
181
  commands.push(new ConfigCommand(this.servicePriority));
191
- commands.push(new ConfigGroupCommand([new ConfigDumpSubCommand(() => this.getConfigString())]));
182
+ const members = [new ConfigDumpSubCommand(this.#configurationService)];
183
+ if (this.#hasCommandRegistry) {
184
+ members.push(new ConfigGetSubCommand(this.#configurationService), new ConfigSetSubCommand(this.#configurationService), new ConfigUnsetSubCommand(this.#configurationService));
185
+ }
186
+ commands.push(new ConfigGroupCommand(members));
192
187
  }
193
188
  if (this.secretServiceEnabled) {
194
- this.#defaultsSecretService = new DefaultSecretService(cliConfig.name, "defaults");
189
+ this.#configurationService.setDefaultsSecretService(new DefaultSecretService(cliConfig.name, ["defaults"], this.#secretsApi));
195
190
  }
196
191
  return Promise.resolve({
197
- service: this.#configurationService,
192
+ service: new ConfigurationLocationService(this.#configurationService),
198
193
  // this may be empty if configEnabled is false
199
194
  commands,
200
195
  });
201
196
  }
197
+ /**
198
+ * The {@link DefaultConfigurationService} which owns the configuration data, for trusted wiring and tests.
199
+ */
200
+ get configurationService() {
201
+ return this.#configurationService;
202
+ }
203
+ get configLocation() {
204
+ return this.#configurationService.configLocation;
205
+ }
206
+ set configLocation(location) {
207
+ this.#configurationService.configLocation = location;
208
+ }
209
+ get defaultsData() {
210
+ return this.#configurationService.defaultsData;
211
+ }
212
+ set defaultsData(data) {
213
+ this.#configurationService.defaultsData = data;
214
+ }
202
215
  setConfigLocation(configLocation) {
203
- this.configLocation = configLocation;
216
+ this.#configurationService.setConfigLocation(configLocation);
204
217
  }
205
218
  /**
206
219
  * Retrieve the default command argument values (if any) for the provided {@link Command}.
@@ -247,14 +260,8 @@ export default class ConfigurationServiceProvider {
247
260
  result = argumentValueMerge(envVarValues, configuredValues);
248
261
  }
249
262
  }
250
- if (result !== undefined && this.#defaultsSecretService) {
251
- result = await resolveSecrets(result, async (bunSecretName) => {
252
- const secretValue = await this.#defaultsSecretService.getSecret(bunSecretName);
253
- if (secretValue === null) {
254
- throw new Error(`Secret not found in OS secret store for sentinel: '${SECRET_SENTINEL_PREFIX}${bunSecretName}'`);
255
- }
256
- return secretValue;
257
- });
263
+ if (result !== undefined) {
264
+ result = await this.#configurationService.resolveDefaultSecrets(result, commandKey);
258
265
  }
259
266
  return result;
260
267
  }
@@ -266,11 +273,7 @@ export default class ConfigurationServiceProvider {
266
273
  * @param scopeKey the command name or service/task ID to scope the key-value data to.
267
274
  */
268
275
  getKeyValueData(scopeType, scopeKey) {
269
- const keyValueData = scopeType === "command" ? this.#commandKeyValueData : this.#serviceKeyValueData;
270
- if (!keyValueData.has(scopeKey)) {
271
- keyValueData.set(scopeKey, new Map());
272
- }
273
- return keyValueData.get(scopeKey);
276
+ return this.#configurationService.getKeyValueData(scopeType, scopeKey);
274
277
  }
275
278
  /**
276
279
  * Write the configuration file, if `isDirty` is true - for {@link KeyValueServiceProvider}'s
@@ -279,129 +282,16 @@ export default class ConfigurationServiceProvider {
279
282
  *
280
283
  * @param isDirty whether any scoped KeyValueService has unwritten changes.
281
284
  */
282
- async flushIfDirty(isDirty) {
283
- if (!isDirty) {
284
- return;
285
- }
286
- if (this.configLocation === undefined) {
287
- throw new Error("Attempt to write updated config with no configLocation set");
288
- }
289
- await this.#writeConfig(this.configLocation);
285
+ flushIfDirty(isDirty) {
286
+ return this.#configurationService.flushIfDirty(isDirty);
290
287
  }
291
288
  async initService(context) {
292
289
  if (!this.configEnabled) {
293
290
  return;
294
291
  }
295
- let isDefault = false;
296
- if (this.configLocation === undefined) {
297
- isDefault = true;
298
- // default to `$HOME/.<application_name>.<format extension>`
299
- const home = process.env["HOME"];
300
- if (home) {
301
- this.configLocation = path.join(home, `.${context.cliConfig.name.replace(/\W/g, "")}.${this.configFormat.fileExtension}`);
302
- }
303
- }
304
- if (this.configLocation === undefined) {
305
- return;
306
- }
307
- let fileInfo;
308
- try {
309
- fileInfo = await fs.lstat(this.configLocation);
310
- }
311
- catch (err) {
312
- const error = err;
313
- if (isDefault) {
314
- logger.debug("Default config file location: %s does not exist or is not visible - ignoring: %s", this.configLocation, error.message);
315
- return;
316
- }
317
- else {
318
- throw new Error(`Config file location: '${this.configLocation}' doesn't exist or not visible: ${error.message}`);
319
- }
320
- }
321
- if (fileInfo.isDirectory()) {
322
- throw new Error(`Config file location: '${this.configLocation}' is a directory and not a file!`);
323
- }
324
- await this.#readConfig(this.configLocation);
325
- }
326
- async #readConfig(location) {
327
- try {
328
- logger.debug("Reading config from: %s", location);
329
- const data = await fs.readFile(location);
330
- const { data: config, handle } = this.configFormat.parse(data.toString());
331
- this.#configHandle = handle;
332
- this.defaultsData.clear();
333
- this.#commandKeyValueData.clear();
334
- this.#serviceKeyValueData.clear();
335
- if (config.defaults !== undefined) {
336
- const defaults = config.defaults;
337
- Object.keys(defaults).forEach((commandName) => {
338
- this.defaultsData.set(commandName, defaults[commandName]);
339
- logger.debug("Set default argument values for command name: %s", commandName);
340
- });
341
- }
342
- if (config["key-values"] !== undefined) {
343
- const keyValues = config["key-values"];
344
- if (keyValues.commands !== undefined) {
345
- const commandKeyValues = keyValues.commands;
346
- Object.keys(commandKeyValues).forEach((commandName) => {
347
- this.#commandKeyValueData.set(commandName, new Map(Object.entries(commandKeyValues[commandName])));
348
- logger.debug("Set default argument values for command name: %s", commandName);
349
- });
350
- }
351
- if (keyValues.services !== undefined) {
352
- const serviceKeyValues = keyValues.services;
353
- Object.keys(serviceKeyValues).forEach((serviceId) => {
354
- this.#serviceKeyValueData.set(serviceId, new Map(Object.entries(serviceKeyValues[serviceId])));
355
- logger.debug("Set default argument values for service ID: %s", serviceId);
356
- });
357
- }
358
- }
359
- }
360
- catch (err) {
361
- throw new Error(`Failed to read config at location: '${this.configLocation}': ${err}`);
362
- }
363
- }
364
- async #writeConfig(location) {
365
- logger.debug("Writing config to: %s", location);
366
- try {
367
- const config = this.#getConfigData();
368
- const text = this.#configHandle === undefined
369
- ? this.configFormat.serialize(config)
370
- : this.configFormat.apply(this.#configHandle, config);
371
- await fs.writeFile(location, text);
372
- this.#configHandle = this.configFormat.parse(text).handle;
373
- }
374
- catch (err) {
375
- throw new Error(`Failed to write config at location: '${this.configLocation}': ${err}`);
376
- }
292
+ await this.#configurationService.init(context.cliConfig.name);
377
293
  }
378
294
  getConfigString() {
379
- return this.configFormat.serialize(this.#getConfigData());
380
- }
381
- #getConfigData() {
382
- const config = {};
383
- if (this.defaultsData.size > 0) {
384
- config.defaults = Object.fromEntries(this.defaultsData);
385
- }
386
- if (this.#commandKeyValueData.size > 0 || this.#serviceKeyValueData.size > 0) {
387
- config["key-values"] = {};
388
- if (this.#commandKeyValueData.size > 0) {
389
- config["key-values"].commands = {};
390
- for (const [commandName, keyValueData] of this.#commandKeyValueData.entries()) {
391
- if (keyValueData.size > 0) {
392
- config["key-values"].commands[commandName] = Object.fromEntries(keyValueData);
393
- }
394
- }
395
- }
396
- if (this.#serviceKeyValueData.size > 0) {
397
- config["key-values"].services = {};
398
- for (const [serviceId, keyValueData] of this.#serviceKeyValueData.entries()) {
399
- if (keyValueData.size > 0) {
400
- config["key-values"].services[serviceId] = Object.fromEntries(keyValueData);
401
- }
402
- }
403
- }
404
- }
405
- return config;
295
+ return this.#configurationService.getConfigString();
406
296
  }
407
297
  }
@@ -0,0 +1,78 @@
1
+ import { type CommandRegistry, type ConfigurationService, type SingleValueType, type ValueNode, type Values } from "@flowscripter/dynamic-cli-framework-api";
2
+ import { type ConfigTarget } from "./configTargets.ts";
3
+ import type DefaultSecretService from "./DefaultSecretService.ts";
4
+ import type ConfigFormat from "./format/ConfigFormat.ts";
5
+ export type KeyValueServiceScopeType = "command" | "service";
6
+ /**
7
+ * Owns the configuration data read from (and written back to) the configuration file: the default
8
+ * command argument values and the raw per-scope key-value data.
9
+ *
10
+ * The `config` group commands are constructed with this instance. It must never be registered in the
11
+ * {@link Context}: it exposes every command's defaults, the raw key-value data of every scope and secret
12
+ * resolution. Only a location-only view is registered under {@link CONFIGURATION_SERVICE_ID}.
13
+ */
14
+ export default class DefaultConfigurationService implements ConfigurationService {
15
+ #private;
16
+ readonly envVarsEnabled: boolean;
17
+ readonly configFormat: ConfigFormat;
18
+ configLocation: string | undefined;
19
+ defaultsData: Map<string, Values | SingleValueType>;
20
+ /**
21
+ * @param envVarsEnabled whether environment variables may override stored default values.
22
+ * @param configFormat the syntax of the configuration file.
23
+ * @param commandRegistry optional registry of all commands, required for {@link getConfigTargets}.
24
+ */
25
+ constructor(envVarsEnabled: boolean, configFormat: ConfigFormat, commandRegistry?: CommandRegistry);
26
+ setConfigLocation(location: string): void;
27
+ setDefaultsSecretService(secretService: DefaultSecretService): void;
28
+ /**
29
+ * Resolve any secret sentinels within the value using the OS secret store (if enabled).
30
+ *
31
+ * @param commandKey the key of the command under `defaults` the value belongs to: a sentinel
32
+ * may only refer to a secret stored for this command.
33
+ */
34
+ resolveDefaultSecrets<T>(value: T, commandKey: string): Promise<T>;
35
+ /**
36
+ * Get-or-create the underlying, raw {@link ValueNode} `Map` for the given scope.
37
+ *
38
+ * @param scopeType whether `scopeKey` is a command name or a service/task ID.
39
+ * @param scopeKey the command name or service/task ID to scope the key-value data to.
40
+ */
41
+ getKeyValueData(scopeType: KeyValueServiceScopeType, scopeKey: string): Map<string, ValueNode>;
42
+ /**
43
+ * Write the configuration file, if `isDirty` is true.
44
+ *
45
+ * @param isDirty whether any scoped KeyValueService has unwritten changes.
46
+ */
47
+ flushIfDirty(isDirty: boolean): Promise<void>;
48
+ /**
49
+ * Determine the configuration location (defaulting to `$HOME/.<application_name>.<format extension>`)
50
+ * and read the configuration from it if it exists.
51
+ *
52
+ * @param applicationName the name of the CLI.
53
+ */
54
+ init(applicationName: string): Promise<void>;
55
+ getConfigString(): string;
56
+ /**
57
+ * The configuration text with secret sentinels and the values of SECRET typed arguments of
58
+ * known commands masked.
59
+ */
60
+ getMaskedConfigString(): string;
61
+ /**
62
+ * The commands whose defaults can be managed via the `config` group commands.
63
+ */
64
+ getConfigTargets(): Map<string, ConfigTarget>;
65
+ /**
66
+ * Replace (or remove, if `build` returns `undefined`) the stored defaults of a command and write the
67
+ * configuration file immediately. Memory, file and secret store are left unchanged if anything fails.
68
+ *
69
+ * @param commandKey the key of the command under `defaults`.
70
+ * @param secrets plain text secrets to store in the OS secret store, keyed to be used for naming.
71
+ * @param build creates the new value given the sentinels (one per secret) to reference the stored secrets.
72
+ */
73
+ commitDefault(commandKey: string, secrets: ReadonlyArray<{
74
+ key: ReadonlyArray<string>;
75
+ value: string;
76
+ }>, build: (sentinels: ReadonlyArray<string>) => Values | SingleValueType | undefined): Promise<void>;
77
+ }
78
+ //# sourceMappingURL=DefaultConfigurationService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DefaultConfigurationService.d.ts","sourceRoot":"","sources":["../../../../src/service/configuration/DefaultConfigurationService.ts"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