ogi-addon 1.9.5 → 2.0.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 (42) hide show
  1. package/build/{Configuration-CdRZbO6z.d.mts → Configuration-DdkCGFMU.d.cts} +2 -2
  2. package/build/{Configuration-WeOm-F0_.d.cts → Configuration-fDtr2bmH.d.mts} +2 -2
  3. package/build/{ConfigurationBuilder-BbZDA_xx.d.mts → ConfigurationBuilder-C83EP5v2.d.cts} +81 -21
  4. package/build/{ConfigurationBuilder-BSuJ4rSI.cjs → ConfigurationBuilder-CFXi6UwU.cjs} +112 -14
  5. package/build/ConfigurationBuilder-CFXi6UwU.cjs.map +1 -0
  6. package/build/{ConfigurationBuilder-CfHLKMTO.d.cts → ConfigurationBuilder-lzKf9gHw.d.mts} +81 -21
  7. package/build/{EventResponse-CQhmdz3C.d.mts → EventResponse-D0TZjAVC.d.mts} +88 -31
  8. package/build/{EventResponse-D1c-Df5W.d.cts → EventResponse-DgSuJPu8.d.cts} +88 -31
  9. package/build/EventResponse.cjs +5 -4
  10. package/build/EventResponse.cjs.map +1 -1
  11. package/build/EventResponse.d.cts +1 -1
  12. package/build/EventResponse.d.mts +1 -1
  13. package/build/EventResponse.mjs +5 -4
  14. package/build/EventResponse.mjs.map +1 -1
  15. package/build/{SearchEngine-CRQWXfo6.d.mts → SearchEngine-Cn_-M-at.d.cts} +5 -2
  16. package/build/{SearchEngine-DBSUNM4A.d.cts → SearchEngine-lZioNunY.d.mts} +5 -2
  17. package/build/SearchEngine.d.cts +1 -1
  18. package/build/SearchEngine.d.mts +1 -1
  19. package/build/config/Configuration.cjs +6 -3
  20. package/build/config/Configuration.cjs.map +1 -1
  21. package/build/config/Configuration.d.cts +3 -3
  22. package/build/config/Configuration.d.mts +3 -3
  23. package/build/config/Configuration.mjs +5 -4
  24. package/build/config/Configuration.mjs.map +1 -1
  25. package/build/config/ConfigurationBuilder.cjs +3 -1
  26. package/build/config/ConfigurationBuilder.d.cts +2 -2
  27. package/build/config/ConfigurationBuilder.d.mts +2 -2
  28. package/build/config/ConfigurationBuilder.mjs +100 -14
  29. package/build/config/ConfigurationBuilder.mjs.map +1 -1
  30. package/build/main.cjs +116 -14
  31. package/build/main.cjs.map +1 -1
  32. package/build/main.d.cts +5 -5
  33. package/build/main.d.mts +5 -5
  34. package/build/main.mjs +115 -14
  35. package/build/main.mjs.map +1 -1
  36. package/package.json +1 -1
  37. package/src/EventResponse.ts +14 -13
  38. package/src/SearchEngine.ts +5 -1
  39. package/src/config/Configuration.ts +13 -3
  40. package/src/config/ConfigurationBuilder.ts +157 -41
  41. package/src/main.ts +194 -36
  42. package/build/ConfigurationBuilder-BSuJ4rSI.cjs.map +0 -1
@@ -1,12 +1,12 @@
1
- import { n as ConfigurationBuilder, r as ConfigurationFile } from "./ConfigurationBuilder-BbZDA_xx.mjs";
2
- import { t as Configuration } from "./Configuration-CdRZbO6z.mjs";
3
- import { t as SearchResult } from "./SearchEngine-CRQWXfo6.mjs";
1
+ import { i as ConfigurationFile, r as ConfigurationBuilder } from "./ConfigurationBuilder-lzKf9gHw.mjs";
2
+ import { t as Configuration } from "./Configuration-fDtr2bmH.mjs";
3
+ import { t as SearchResult } from "./SearchEngine-lZioNunY.mjs";
4
4
  import events from "node:events";
5
5
  import { z as z$1 } from "zod";
6
6
  import { IFuseOptions } from "fuse.js";
7
7
 
8
8
  //#region src/main.d.ts
9
- type OGIAddonEvent = 'connect' | 'disconnect' | 'configure' | 'authenticate' | 'search' | 'setup' | 'library-search' | 'game-details' | 'exit' | 'check-for-updates' | 'task-run' | 'request-dl' | 'catalog';
9
+ type OGIAddonEvent = 'connect' | 'disconnect' | 'configure' | 'authenticate' | 'search' | 'setup' | 'library-search' | 'game-details' | 'exit' | 'check-for-updates' | 'request-dl' | 'catalog';
10
10
  type OGIAddonClientSentEvent = 'response' | 'authenticate' | 'configure' | 'defer-update' | 'notification' | 'input-asked' | 'get-app-details' | 'search-app-name' | 'flag' | 'task-update';
11
11
  type OGIAddonServerSentEvent = 'authenticate' | 'configure' | 'config-update' | 'search' | 'setup' | 'response' | 'library-search' | 'check-for-updates' | 'task-run' | 'game-details' | 'request-dl' | 'catalog';
12
12
  declare const VERSION: string;
@@ -25,7 +25,7 @@ interface ClientSentEventTypes {
25
25
  progress: number;
26
26
  };
27
27
  notification: Notification;
28
- 'input-asked': ConfigurationBuilder;
28
+ 'input-asked': ConfigurationBuilder<Record<string, string | number | boolean>>;
29
29
  'task-update': {
30
30
  id: string;
31
31
  progress: number;
@@ -135,17 +135,6 @@ interface EventListenerTypes {
135
135
  * @returns
136
136
  */
137
137
  'library-search': (query: string, event: EventResponse<BasicLibraryInfo[]>) => void;
138
- /**
139
- * This event is emitted when the client requests for a task to be run. Addon should resolve the event with the task.
140
- * @param task
141
- * @param event
142
- * @returns
143
- */
144
- 'task-run': (task: {
145
- manifest: Record<string, unknown>;
146
- downloadPath: string;
147
- name: string;
148
- }, event: EventResponse<void>) => void;
149
138
  /**
150
139
  * This event is emitted when the client requests for a game details to be fetched. Addon should resolve the event with the game details. This is used to generate a store page for the game.
151
140
  * @param appID
@@ -258,6 +247,7 @@ declare class OGIAddon {
258
247
  config: Configuration;
259
248
  private eventsAvailable;
260
249
  private registeredConnectEvent;
250
+ private taskHandlers;
261
251
  constructor(addonInfo: OGIAddonConfiguration);
262
252
  /**
263
253
  * Register an event listener for the addon. (See EventListenerTypes)
@@ -286,6 +276,42 @@ declare class OGIAddon {
286
276
  * @param logs {string[]}
287
277
  */
288
278
  task(): Promise<CustomTask>;
279
+ /**
280
+ * Register a task handler for a specific task name. The task name should match the taskName field in SearchResult or ActionOption.
281
+ * @param taskName {string} The name of the task (should match taskName in SearchResult or ActionOption.setTaskName()).
282
+ * @param handler {(task: Task, data: { manifest: Record<string, unknown>; downloadPath: string; name: string }) => Promise<void> | void} The handler function.
283
+ * @example
284
+ * ```typescript
285
+ * addon.onTask('clearCache', async (task) => {
286
+ * task.log('Clearing cache...');
287
+ * task.setProgress(50);
288
+ * await clearCacheFiles();
289
+ * task.setProgress(100);
290
+ * task.complete();
291
+ * });
292
+ * ```
293
+ */
294
+ onTask(taskName: string, handler: (task: Task, data: {
295
+ manifest: Record<string, unknown>;
296
+ downloadPath: string;
297
+ name: string;
298
+ }) => Promise<void> | void): void;
299
+ /**
300
+ * Check if a task handler is registered for the given task name.
301
+ * @param taskName {string} The task name to check.
302
+ * @returns {boolean} True if a handler is registered.
303
+ */
304
+ hasTaskHandler(taskName: string): boolean;
305
+ /**
306
+ * Get a task handler for the given task name.
307
+ * @param taskName {string} The task name.
308
+ * @returns The handler function or undefined if not found.
309
+ */
310
+ getTaskHandler(taskName: string): ((task: Task, data: {
311
+ manifest: Record<string, unknown>;
312
+ downloadPath: string;
313
+ name: string;
314
+ }) => Promise<void> | void) | undefined;
289
315
  /**
290
316
  * Extract a file using 7-Zip on Windows, unzip on Linux/Mac.
291
317
  * @param path {string}
@@ -309,6 +335,42 @@ declare class CustomTask {
309
335
  setProgress(progress: number): void;
310
336
  update(): void;
311
337
  }
338
+ /**
339
+ * A cleaner API wrapper around EventResponse for task handlers.
340
+ * Provides chainable methods for logging, progress updates, and completion.
341
+ */
342
+ declare class Task {
343
+ private event;
344
+ constructor(event: EventResponse<void>);
345
+ /**
346
+ * Log a message to the task. Returns this for chaining.
347
+ * @param message {string} The message to log.
348
+ */
349
+ log(message: string): this;
350
+ /**
351
+ * Set the progress of the task (0-100). Returns this for chaining.
352
+ * @param progress {number} The progress value (0-100).
353
+ */
354
+ setProgress(progress: number): this;
355
+ /**
356
+ * Complete the task successfully.
357
+ */
358
+ complete(): void;
359
+ /**
360
+ * Fail the task with an error message.
361
+ * @param message {string} The error message.
362
+ */
363
+ fail(message: string): void;
364
+ /**
365
+ * Ask the user for input using a ConfigurationBuilder screen.
366
+ * The return type is inferred from the ConfigurationBuilder's accumulated option types.
367
+ * @param name {string} The name/title of the input prompt.
368
+ * @param description {string} The description of what input is needed.
369
+ * @param screen {ConfigurationBuilder<U>} The configuration builder for the input form.
370
+ * @returns {Promise<U>} The user's input with types matching the configuration options.
371
+ */
372
+ askForInput<U extends Record<string, string | number | boolean>>(name: string, description: string, screen: ConfigurationBuilder<U>): Promise<U>;
373
+ }
312
374
  /**
313
375
  * A search tool wrapper over Fuse.js for the OGI Addon. This tool is used to search for items in the library.
314
376
  * @example
@@ -391,12 +453,8 @@ declare class EventResponse<T> {
391
453
  progress: number;
392
454
  logs: string[];
393
455
  failed: string | undefined;
394
- onInputAsked?: (screen: ConfigurationBuilder, name: string, description: string) => Promise<{
395
- [key: string]: boolean | string | number;
396
- }>;
397
- constructor(onInputAsked?: (screen: ConfigurationBuilder, name: string, description: string) => Promise<{
398
- [key: string]: boolean | string | number;
399
- }>);
456
+ onInputAsked?: <U extends Record<string, string | number | boolean>>(screen: ConfigurationBuilder<U>, name: string, description: string) => Promise<U>;
457
+ constructor(onInputAsked?: <U extends Record<string, string | number | boolean>>(screen: ConfigurationBuilder<U>, name: string, description: string) => Promise<U>);
400
458
  defer(promise?: () => Promise<void>): void;
401
459
  /**
402
460
  * Resolve the event with data. This acts like a promise resolve, and will stop the event from being processed further. **You must always call this method when you are done with the event.**
@@ -415,16 +473,15 @@ declare class EventResponse<T> {
415
473
  log(message: string): void;
416
474
  /**
417
475
  * Send a screen to the client to ask for input. Use the `ConfigurationBuilder` system to build the screen. Once sent to the user, the addon cannot change the screen.
476
+ * The return type is inferred from the ConfigurationBuilder's accumulated option types.
418
477
  * @async
419
- * @param name {string}
420
- * @param description {string}
421
- * @param screen {ConfigurationBuilder}
422
- * @returns {Promise<{ [key: string]: boolean | string | number }>}
478
+ * @param name {string} The name/title of the input prompt.
479
+ * @param description {string} The description of what input is needed.
480
+ * @param screen {ConfigurationBuilder<U>} The configuration builder for the input form.
481
+ * @returns {Promise<U>} The user's input with types matching the configuration options.
423
482
  */
424
- askForInput(name: string, description: string, screen: ConfigurationBuilder): Promise<{
425
- [key: string]: boolean | string | number;
426
- }>;
483
+ askForInput<U extends Record<string, string | number | boolean>>(name: string, description: string, screen: ConfigurationBuilder<U>): Promise<U>;
427
484
  }
428
485
  //#endregion
429
- export { WebsocketMessageServer as _, EventListenerTypes as a, OGIAddonClientSentEvent as c, OGIAddonServerSentEvent as d, SearchTool as f, WebsocketMessageClient as g, VERSION as h, CustomTask as i, OGIAddonConfiguration as l, StoreData as m, BasicLibraryInfo as n, LibraryInfo as o, SetupEventResponse as p, ClientSentEventTypes as r, OGIAddon as s, EventResponse as t, OGIAddonEvent as u, ZodLibraryInfo as v };
430
- //# sourceMappingURL=EventResponse-CQhmdz3C.d.mts.map
486
+ export { WebsocketMessageClient as _, EventListenerTypes as a, OGIAddonClientSentEvent as c, OGIAddonServerSentEvent as d, SearchTool as f, VERSION as g, Task as h, CustomTask as i, OGIAddonConfiguration as l, StoreData as m, BasicLibraryInfo as n, LibraryInfo as o, SetupEventResponse as p, ClientSentEventTypes as r, OGIAddon as s, EventResponse as t, OGIAddonEvent as u, WebsocketMessageServer as v, ZodLibraryInfo as y };
487
+ //# sourceMappingURL=EventResponse-D0TZjAVC.d.mts.map
@@ -1,12 +1,12 @@
1
- import { n as ConfigurationBuilder, r as ConfigurationFile } from "./ConfigurationBuilder-CfHLKMTO.cjs";
2
- import { t as Configuration } from "./Configuration-WeOm-F0_.cjs";
3
- import { t as SearchResult } from "./SearchEngine-DBSUNM4A.cjs";
1
+ import { i as ConfigurationFile, r as ConfigurationBuilder } from "./ConfigurationBuilder-C83EP5v2.cjs";
2
+ import { t as Configuration } from "./Configuration-DdkCGFMU.cjs";
3
+ import { t as SearchResult } from "./SearchEngine-Cn_-M-at.cjs";
4
4
  import events from "node:events";
5
5
  import { IFuseOptions } from "fuse.js";
6
6
  import { z } from "zod";
7
7
 
8
8
  //#region src/main.d.ts
9
- type OGIAddonEvent = 'connect' | 'disconnect' | 'configure' | 'authenticate' | 'search' | 'setup' | 'library-search' | 'game-details' | 'exit' | 'check-for-updates' | 'task-run' | 'request-dl' | 'catalog';
9
+ type OGIAddonEvent = 'connect' | 'disconnect' | 'configure' | 'authenticate' | 'search' | 'setup' | 'library-search' | 'game-details' | 'exit' | 'check-for-updates' | 'request-dl' | 'catalog';
10
10
  type OGIAddonClientSentEvent = 'response' | 'authenticate' | 'configure' | 'defer-update' | 'notification' | 'input-asked' | 'get-app-details' | 'search-app-name' | 'flag' | 'task-update';
11
11
  type OGIAddonServerSentEvent = 'authenticate' | 'configure' | 'config-update' | 'search' | 'setup' | 'response' | 'library-search' | 'check-for-updates' | 'task-run' | 'game-details' | 'request-dl' | 'catalog';
12
12
  declare const VERSION: string;
@@ -25,7 +25,7 @@ interface ClientSentEventTypes {
25
25
  progress: number;
26
26
  };
27
27
  notification: Notification;
28
- 'input-asked': ConfigurationBuilder;
28
+ 'input-asked': ConfigurationBuilder<Record<string, string | number | boolean>>;
29
29
  'task-update': {
30
30
  id: string;
31
31
  progress: number;
@@ -135,17 +135,6 @@ interface EventListenerTypes {
135
135
  * @returns
136
136
  */
137
137
  'library-search': (query: string, event: EventResponse<BasicLibraryInfo[]>) => void;
138
- /**
139
- * This event is emitted when the client requests for a task to be run. Addon should resolve the event with the task.
140
- * @param task
141
- * @param event
142
- * @returns
143
- */
144
- 'task-run': (task: {
145
- manifest: Record<string, unknown>;
146
- downloadPath: string;
147
- name: string;
148
- }, event: EventResponse<void>) => void;
149
138
  /**
150
139
  * This event is emitted when the client requests for a game details to be fetched. Addon should resolve the event with the game details. This is used to generate a store page for the game.
151
140
  * @param appID
@@ -258,6 +247,7 @@ declare class OGIAddon {
258
247
  config: Configuration;
259
248
  private eventsAvailable;
260
249
  private registeredConnectEvent;
250
+ private taskHandlers;
261
251
  constructor(addonInfo: OGIAddonConfiguration);
262
252
  /**
263
253
  * Register an event listener for the addon. (See EventListenerTypes)
@@ -286,6 +276,42 @@ declare class OGIAddon {
286
276
  * @param logs {string[]}
287
277
  */
288
278
  task(): Promise<CustomTask>;
279
+ /**
280
+ * Register a task handler for a specific task name. The task name should match the taskName field in SearchResult or ActionOption.
281
+ * @param taskName {string} The name of the task (should match taskName in SearchResult or ActionOption.setTaskName()).
282
+ * @param handler {(task: Task, data: { manifest: Record<string, unknown>; downloadPath: string; name: string }) => Promise<void> | void} The handler function.
283
+ * @example
284
+ * ```typescript
285
+ * addon.onTask('clearCache', async (task) => {
286
+ * task.log('Clearing cache...');
287
+ * task.setProgress(50);
288
+ * await clearCacheFiles();
289
+ * task.setProgress(100);
290
+ * task.complete();
291
+ * });
292
+ * ```
293
+ */
294
+ onTask(taskName: string, handler: (task: Task, data: {
295
+ manifest: Record<string, unknown>;
296
+ downloadPath: string;
297
+ name: string;
298
+ }) => Promise<void> | void): void;
299
+ /**
300
+ * Check if a task handler is registered for the given task name.
301
+ * @param taskName {string} The task name to check.
302
+ * @returns {boolean} True if a handler is registered.
303
+ */
304
+ hasTaskHandler(taskName: string): boolean;
305
+ /**
306
+ * Get a task handler for the given task name.
307
+ * @param taskName {string} The task name.
308
+ * @returns The handler function or undefined if not found.
309
+ */
310
+ getTaskHandler(taskName: string): ((task: Task, data: {
311
+ manifest: Record<string, unknown>;
312
+ downloadPath: string;
313
+ name: string;
314
+ }) => Promise<void> | void) | undefined;
289
315
  /**
290
316
  * Extract a file using 7-Zip on Windows, unzip on Linux/Mac.
291
317
  * @param path {string}
@@ -309,6 +335,42 @@ declare class CustomTask {
309
335
  setProgress(progress: number): void;
310
336
  update(): void;
311
337
  }
338
+ /**
339
+ * A cleaner API wrapper around EventResponse for task handlers.
340
+ * Provides chainable methods for logging, progress updates, and completion.
341
+ */
342
+ declare class Task {
343
+ private event;
344
+ constructor(event: EventResponse<void>);
345
+ /**
346
+ * Log a message to the task. Returns this for chaining.
347
+ * @param message {string} The message to log.
348
+ */
349
+ log(message: string): this;
350
+ /**
351
+ * Set the progress of the task (0-100). Returns this for chaining.
352
+ * @param progress {number} The progress value (0-100).
353
+ */
354
+ setProgress(progress: number): this;
355
+ /**
356
+ * Complete the task successfully.
357
+ */
358
+ complete(): void;
359
+ /**
360
+ * Fail the task with an error message.
361
+ * @param message {string} The error message.
362
+ */
363
+ fail(message: string): void;
364
+ /**
365
+ * Ask the user for input using a ConfigurationBuilder screen.
366
+ * The return type is inferred from the ConfigurationBuilder's accumulated option types.
367
+ * @param name {string} The name/title of the input prompt.
368
+ * @param description {string} The description of what input is needed.
369
+ * @param screen {ConfigurationBuilder<U>} The configuration builder for the input form.
370
+ * @returns {Promise<U>} The user's input with types matching the configuration options.
371
+ */
372
+ askForInput<U extends Record<string, string | number | boolean>>(name: string, description: string, screen: ConfigurationBuilder<U>): Promise<U>;
373
+ }
312
374
  /**
313
375
  * A search tool wrapper over Fuse.js for the OGI Addon. This tool is used to search for items in the library.
314
376
  * @example
@@ -391,12 +453,8 @@ declare class EventResponse<T> {
391
453
  progress: number;
392
454
  logs: string[];
393
455
  failed: string | undefined;
394
- onInputAsked?: (screen: ConfigurationBuilder, name: string, description: string) => Promise<{
395
- [key: string]: boolean | string | number;
396
- }>;
397
- constructor(onInputAsked?: (screen: ConfigurationBuilder, name: string, description: string) => Promise<{
398
- [key: string]: boolean | string | number;
399
- }>);
456
+ onInputAsked?: <U extends Record<string, string | number | boolean>>(screen: ConfigurationBuilder<U>, name: string, description: string) => Promise<U>;
457
+ constructor(onInputAsked?: <U extends Record<string, string | number | boolean>>(screen: ConfigurationBuilder<U>, name: string, description: string) => Promise<U>);
400
458
  defer(promise?: () => Promise<void>): void;
401
459
  /**
402
460
  * Resolve the event with data. This acts like a promise resolve, and will stop the event from being processed further. **You must always call this method when you are done with the event.**
@@ -415,16 +473,15 @@ declare class EventResponse<T> {
415
473
  log(message: string): void;
416
474
  /**
417
475
  * Send a screen to the client to ask for input. Use the `ConfigurationBuilder` system to build the screen. Once sent to the user, the addon cannot change the screen.
476
+ * The return type is inferred from the ConfigurationBuilder's accumulated option types.
418
477
  * @async
419
- * @param name {string}
420
- * @param description {string}
421
- * @param screen {ConfigurationBuilder}
422
- * @returns {Promise<{ [key: string]: boolean | string | number }>}
478
+ * @param name {string} The name/title of the input prompt.
479
+ * @param description {string} The description of what input is needed.
480
+ * @param screen {ConfigurationBuilder<U>} The configuration builder for the input form.
481
+ * @returns {Promise<U>} The user's input with types matching the configuration options.
423
482
  */
424
- askForInput(name: string, description: string, screen: ConfigurationBuilder): Promise<{
425
- [key: string]: boolean | string | number;
426
- }>;
483
+ askForInput<U extends Record<string, string | number | boolean>>(name: string, description: string, screen: ConfigurationBuilder<U>): Promise<U>;
427
484
  }
428
485
  //#endregion
429
- export { WebsocketMessageServer as _, EventListenerTypes as a, OGIAddonClientSentEvent as c, OGIAddonServerSentEvent as d, SearchTool as f, WebsocketMessageClient as g, VERSION as h, CustomTask as i, OGIAddonConfiguration as l, StoreData as m, BasicLibraryInfo as n, LibraryInfo as o, SetupEventResponse as p, ClientSentEventTypes as r, OGIAddon as s, EventResponse as t, OGIAddonEvent as u, ZodLibraryInfo as v };
430
- //# sourceMappingURL=EventResponse-D1c-Df5W.d.cts.map
486
+ export { WebsocketMessageClient as _, EventListenerTypes as a, OGIAddonClientSentEvent as c, OGIAddonServerSentEvent as d, SearchTool as f, VERSION as g, Task as h, CustomTask as i, OGIAddonConfiguration as l, StoreData as m, BasicLibraryInfo as n, LibraryInfo as o, SetupEventResponse as p, ClientSentEventTypes as r, OGIAddon as s, EventResponse as t, OGIAddonEvent as u, WebsocketMessageServer as v, ZodLibraryInfo as y };
487
+ //# sourceMappingURL=EventResponse-DgSuJPu8.d.cts.map
@@ -42,11 +42,12 @@ var EventResponse = class {
42
42
  }
43
43
  /**
44
44
  * Send a screen to the client to ask for input. Use the `ConfigurationBuilder` system to build the screen. Once sent to the user, the addon cannot change the screen.
45
+ * The return type is inferred from the ConfigurationBuilder's accumulated option types.
45
46
  * @async
46
- * @param name {string}
47
- * @param description {string}
48
- * @param screen {ConfigurationBuilder}
49
- * @returns {Promise<{ [key: string]: boolean | string | number }>}
47
+ * @param name {string} The name/title of the input prompt.
48
+ * @param description {string} The description of what input is needed.
49
+ * @param screen {ConfigurationBuilder<U>} The configuration builder for the input form.
50
+ * @returns {Promise<U>} The user's input with types matching the configuration options.
50
51
  */
51
52
  async askForInput(name, description, screen) {
52
53
  if (!this.onInputAsked) throw new Error("No input asked callback");
@@ -1 +1 @@
1
- {"version":3,"file":"EventResponse.cjs","names":[],"sources":["../src/EventResponse.ts"],"sourcesContent":["import { ConfigurationBuilder } from './main';\n\nexport default class EventResponse<T> {\n data: T | undefined = undefined;\n deffered: boolean = false;\n resolved: boolean = false;\n progress: number = 0;\n logs: string[] = [];\n failed: string | undefined = undefined;\n onInputAsked?: (\n screen: ConfigurationBuilder,\n name: string,\n description: string\n ) => Promise<{ [key: string]: boolean | string | number }>;\n\n constructor(\n onInputAsked?: (\n screen: ConfigurationBuilder,\n name: string,\n description: string\n ) => Promise<{ [key: string]: boolean | string | number }>\n ) {\n this.onInputAsked = onInputAsked;\n }\n\n public defer(promise?: () => Promise<void>) {\n this.deffered = true;\n // include this to make it easier to use the defer method with async functions\n if (promise) {\n promise();\n }\n }\n\n /**\n * Resolve the event with data. This acts like a promise resolve, and will stop the event from being processed further. **You must always call this method when you are done with the event.**\n * @param data {T}\n */\n public resolve(data: T) {\n this.resolved = true;\n this.data = data;\n }\n\n /**\n * Completes the event and resolves it, but does not return any data. **You must always call this method when you are done with the event.**\n */\n public complete() {\n this.resolved = true;\n }\n\n public fail(message: string) {\n this.resolved = true;\n this.failed = message;\n }\n\n /**\n * Logs a message to the event. This is useful for debugging and logging information to the user.\n * @param message {string}\n */\n public log(message: string) {\n this.logs.push(message);\n }\n\n /**\n * Send a screen to the client to ask for input. Use the `ConfigurationBuilder` system to build the screen. Once sent to the user, the addon cannot change the screen.\n * @async\n * @param name {string}\n * @param description {string}\n * @param screen {ConfigurationBuilder}\n * @returns {Promise<{ [key: string]: boolean | string | number }>}\n */\n public async askForInput(\n name: string,\n description: string,\n screen: ConfigurationBuilder\n ): Promise<{ [key: string]: boolean | string | number }> {\n if (!this.onInputAsked) {\n throw new Error('No input asked callback');\n }\n return await this.onInputAsked(screen, name, description);\n }\n}\n"],"mappings":";;AAEA,IAAqB,gBAArB,MAAsC;CACpC,OAAsB;CACtB,WAAoB;CACpB,WAAoB;CACpB,WAAmB;CACnB,OAAiB,EAAE;CACnB,SAA6B;CAC7B;CAMA,YACE,cAKA;AACA,OAAK,eAAe;;CAGtB,AAAO,MAAM,SAA+B;AAC1C,OAAK,WAAW;AAEhB,MAAI,QACF,UAAS;;;;;;CAQb,AAAO,QAAQ,MAAS;AACtB,OAAK,WAAW;AAChB,OAAK,OAAO;;;;;CAMd,AAAO,WAAW;AAChB,OAAK,WAAW;;CAGlB,AAAO,KAAK,SAAiB;AAC3B,OAAK,WAAW;AAChB,OAAK,SAAS;;;;;;CAOhB,AAAO,IAAI,SAAiB;AAC1B,OAAK,KAAK,KAAK,QAAQ;;;;;;;;;;CAWzB,MAAa,YACX,MACA,aACA,QACuD;AACvD,MAAI,CAAC,KAAK,aACR,OAAM,IAAI,MAAM,0BAA0B;AAE5C,SAAO,MAAM,KAAK,aAAa,QAAQ,MAAM,YAAY"}
1
+ {"version":3,"file":"EventResponse.cjs","names":[],"sources":["../src/EventResponse.ts"],"sourcesContent":["import { ConfigurationBuilder } from './main';\n\nexport default class EventResponse<T> {\n data: T | undefined = undefined;\n deffered: boolean = false;\n resolved: boolean = false;\n progress: number = 0;\n logs: string[] = [];\n failed: string | undefined = undefined;\n onInputAsked?: <U extends Record<string, string | number | boolean>>(\n screen: ConfigurationBuilder<U>,\n name: string,\n description: string\n ) => Promise<U>;\n\n constructor(\n onInputAsked?: <U extends Record<string, string | number | boolean>>(\n screen: ConfigurationBuilder<U>,\n name: string,\n description: string\n ) => Promise<U>\n ) {\n this.onInputAsked = onInputAsked;\n }\n\n public defer(promise?: () => Promise<void>) {\n this.deffered = true;\n // include this to make it easier to use the defer method with async functions\n if (promise) {\n promise();\n }\n }\n\n /**\n * Resolve the event with data. This acts like a promise resolve, and will stop the event from being processed further. **You must always call this method when you are done with the event.**\n * @param data {T}\n */\n public resolve(data: T) {\n this.resolved = true;\n this.data = data;\n }\n\n /**\n * Completes the event and resolves it, but does not return any data. **You must always call this method when you are done with the event.**\n */\n public complete() {\n this.resolved = true;\n }\n\n public fail(message: string) {\n this.resolved = true;\n this.failed = message;\n }\n\n /**\n * Logs a message to the event. This is useful for debugging and logging information to the user.\n * @param message {string}\n */\n public log(message: string) {\n this.logs.push(message);\n }\n\n /**\n * Send a screen to the client to ask for input. Use the `ConfigurationBuilder` system to build the screen. Once sent to the user, the addon cannot change the screen.\n * The return type is inferred from the ConfigurationBuilder's accumulated option types.\n * @async\n * @param name {string} The name/title of the input prompt.\n * @param description {string} The description of what input is needed.\n * @param screen {ConfigurationBuilder<U>} The configuration builder for the input form.\n * @returns {Promise<U>} The user's input with types matching the configuration options.\n */\n public async askForInput<U extends Record<string, string | number | boolean>>(\n name: string,\n description: string,\n screen: ConfigurationBuilder<U>\n ): Promise<U> {\n if (!this.onInputAsked) {\n throw new Error('No input asked callback');\n }\n return await this.onInputAsked(screen, name, description);\n }\n}\n"],"mappings":";;AAEA,IAAqB,gBAArB,MAAsC;CACpC,OAAsB;CACtB,WAAoB;CACpB,WAAoB;CACpB,WAAmB;CACnB,OAAiB,EAAE;CACnB,SAA6B;CAC7B;CAMA,YACE,cAKA;AACA,OAAK,eAAe;;CAGtB,AAAO,MAAM,SAA+B;AAC1C,OAAK,WAAW;AAEhB,MAAI,QACF,UAAS;;;;;;CAQb,AAAO,QAAQ,MAAS;AACtB,OAAK,WAAW;AAChB,OAAK,OAAO;;;;;CAMd,AAAO,WAAW;AAChB,OAAK,WAAW;;CAGlB,AAAO,KAAK,SAAiB;AAC3B,OAAK,WAAW;AAChB,OAAK,SAAS;;;;;;CAOhB,AAAO,IAAI,SAAiB;AAC1B,OAAK,KAAK,KAAK,QAAQ;;;;;;;;;;;CAYzB,MAAa,YACX,MACA,aACA,QACY;AACZ,MAAI,CAAC,KAAK,aACR,OAAM,IAAI,MAAM,0BAA0B;AAE5C,SAAO,MAAM,KAAK,aAAa,QAAQ,MAAM,YAAY"}
@@ -1,2 +1,2 @@
1
- import { t as EventResponse } from "./EventResponse-D1c-Df5W.cjs";
1
+ import { t as EventResponse } from "./EventResponse-DgSuJPu8.cjs";
2
2
  export = EventResponse;
@@ -1,2 +1,2 @@
1
- import { t as EventResponse } from "./EventResponse-CQhmdz3C.mjs";
1
+ import { t as EventResponse } from "./EventResponse-D0TZjAVC.mjs";
2
2
  export { EventResponse as default };
@@ -41,11 +41,12 @@ var EventResponse = class {
41
41
  }
42
42
  /**
43
43
  * Send a screen to the client to ask for input. Use the `ConfigurationBuilder` system to build the screen. Once sent to the user, the addon cannot change the screen.
44
+ * The return type is inferred from the ConfigurationBuilder's accumulated option types.
44
45
  * @async
45
- * @param name {string}
46
- * @param description {string}
47
- * @param screen {ConfigurationBuilder}
48
- * @returns {Promise<{ [key: string]: boolean | string | number }>}
46
+ * @param name {string} The name/title of the input prompt.
47
+ * @param description {string} The description of what input is needed.
48
+ * @param screen {ConfigurationBuilder<U>} The configuration builder for the input form.
49
+ * @returns {Promise<U>} The user's input with types matching the configuration options.
49
50
  */
50
51
  async askForInput(name, description, screen) {
51
52
  if (!this.onInputAsked) throw new Error("No input asked callback");
@@ -1 +1 @@
1
- {"version":3,"file":"EventResponse.mjs","names":[],"sources":["../src/EventResponse.ts"],"sourcesContent":["import { ConfigurationBuilder } from './main';\n\nexport default class EventResponse<T> {\n data: T | undefined = undefined;\n deffered: boolean = false;\n resolved: boolean = false;\n progress: number = 0;\n logs: string[] = [];\n failed: string | undefined = undefined;\n onInputAsked?: (\n screen: ConfigurationBuilder,\n name: string,\n description: string\n ) => Promise<{ [key: string]: boolean | string | number }>;\n\n constructor(\n onInputAsked?: (\n screen: ConfigurationBuilder,\n name: string,\n description: string\n ) => Promise<{ [key: string]: boolean | string | number }>\n ) {\n this.onInputAsked = onInputAsked;\n }\n\n public defer(promise?: () => Promise<void>) {\n this.deffered = true;\n // include this to make it easier to use the defer method with async functions\n if (promise) {\n promise();\n }\n }\n\n /**\n * Resolve the event with data. This acts like a promise resolve, and will stop the event from being processed further. **You must always call this method when you are done with the event.**\n * @param data {T}\n */\n public resolve(data: T) {\n this.resolved = true;\n this.data = data;\n }\n\n /**\n * Completes the event and resolves it, but does not return any data. **You must always call this method when you are done with the event.**\n */\n public complete() {\n this.resolved = true;\n }\n\n public fail(message: string) {\n this.resolved = true;\n this.failed = message;\n }\n\n /**\n * Logs a message to the event. This is useful for debugging and logging information to the user.\n * @param message {string}\n */\n public log(message: string) {\n this.logs.push(message);\n }\n\n /**\n * Send a screen to the client to ask for input. Use the `ConfigurationBuilder` system to build the screen. Once sent to the user, the addon cannot change the screen.\n * @async\n * @param name {string}\n * @param description {string}\n * @param screen {ConfigurationBuilder}\n * @returns {Promise<{ [key: string]: boolean | string | number }>}\n */\n public async askForInput(\n name: string,\n description: string,\n screen: ConfigurationBuilder\n ): Promise<{ [key: string]: boolean | string | number }> {\n if (!this.onInputAsked) {\n throw new Error('No input asked callback');\n }\n return await this.onInputAsked(screen, name, description);\n }\n}\n"],"mappings":";AAEA,IAAqB,gBAArB,MAAsC;CACpC,OAAsB;CACtB,WAAoB;CACpB,WAAoB;CACpB,WAAmB;CACnB,OAAiB,EAAE;CACnB,SAA6B;CAC7B;CAMA,YACE,cAKA;AACA,OAAK,eAAe;;CAGtB,AAAO,MAAM,SAA+B;AAC1C,OAAK,WAAW;AAEhB,MAAI,QACF,UAAS;;;;;;CAQb,AAAO,QAAQ,MAAS;AACtB,OAAK,WAAW;AAChB,OAAK,OAAO;;;;;CAMd,AAAO,WAAW;AAChB,OAAK,WAAW;;CAGlB,AAAO,KAAK,SAAiB;AAC3B,OAAK,WAAW;AAChB,OAAK,SAAS;;;;;;CAOhB,AAAO,IAAI,SAAiB;AAC1B,OAAK,KAAK,KAAK,QAAQ;;;;;;;;;;CAWzB,MAAa,YACX,MACA,aACA,QACuD;AACvD,MAAI,CAAC,KAAK,aACR,OAAM,IAAI,MAAM,0BAA0B;AAE5C,SAAO,MAAM,KAAK,aAAa,QAAQ,MAAM,YAAY"}
1
+ {"version":3,"file":"EventResponse.mjs","names":[],"sources":["../src/EventResponse.ts"],"sourcesContent":["import { ConfigurationBuilder } from './main';\n\nexport default class EventResponse<T> {\n data: T | undefined = undefined;\n deffered: boolean = false;\n resolved: boolean = false;\n progress: number = 0;\n logs: string[] = [];\n failed: string | undefined = undefined;\n onInputAsked?: <U extends Record<string, string | number | boolean>>(\n screen: ConfigurationBuilder<U>,\n name: string,\n description: string\n ) => Promise<U>;\n\n constructor(\n onInputAsked?: <U extends Record<string, string | number | boolean>>(\n screen: ConfigurationBuilder<U>,\n name: string,\n description: string\n ) => Promise<U>\n ) {\n this.onInputAsked = onInputAsked;\n }\n\n public defer(promise?: () => Promise<void>) {\n this.deffered = true;\n // include this to make it easier to use the defer method with async functions\n if (promise) {\n promise();\n }\n }\n\n /**\n * Resolve the event with data. This acts like a promise resolve, and will stop the event from being processed further. **You must always call this method when you are done with the event.**\n * @param data {T}\n */\n public resolve(data: T) {\n this.resolved = true;\n this.data = data;\n }\n\n /**\n * Completes the event and resolves it, but does not return any data. **You must always call this method when you are done with the event.**\n */\n public complete() {\n this.resolved = true;\n }\n\n public fail(message: string) {\n this.resolved = true;\n this.failed = message;\n }\n\n /**\n * Logs a message to the event. This is useful for debugging and logging information to the user.\n * @param message {string}\n */\n public log(message: string) {\n this.logs.push(message);\n }\n\n /**\n * Send a screen to the client to ask for input. Use the `ConfigurationBuilder` system to build the screen. Once sent to the user, the addon cannot change the screen.\n * The return type is inferred from the ConfigurationBuilder's accumulated option types.\n * @async\n * @param name {string} The name/title of the input prompt.\n * @param description {string} The description of what input is needed.\n * @param screen {ConfigurationBuilder<U>} The configuration builder for the input form.\n * @returns {Promise<U>} The user's input with types matching the configuration options.\n */\n public async askForInput<U extends Record<string, string | number | boolean>>(\n name: string,\n description: string,\n screen: ConfigurationBuilder<U>\n ): Promise<U> {\n if (!this.onInputAsked) {\n throw new Error('No input asked callback');\n }\n return await this.onInputAsked(screen, name, description);\n }\n}\n"],"mappings":";AAEA,IAAqB,gBAArB,MAAsC;CACpC,OAAsB;CACtB,WAAoB;CACpB,WAAoB;CACpB,WAAmB;CACnB,OAAiB,EAAE;CACnB,SAA6B;CAC7B;CAMA,YACE,cAKA;AACA,OAAK,eAAe;;CAGtB,AAAO,MAAM,SAA+B;AAC1C,OAAK,WAAW;AAEhB,MAAI,QACF,UAAS;;;;;;CAQb,AAAO,QAAQ,MAAS;AACtB,OAAK,WAAW;AAChB,OAAK,OAAO;;;;;CAMd,AAAO,WAAW;AAChB,OAAK,WAAW;;CAGlB,AAAO,KAAK,SAAiB;AAC3B,OAAK,WAAW;AAChB,OAAK,SAAS;;;;;;CAOhB,AAAO,IAAI,SAAiB;AAC1B,OAAK,KAAK,KAAK,QAAQ;;;;;;;;;;;CAYzB,MAAa,YACX,MACA,aACA,QACY;AACZ,MAAI,CAAC,KAAK,aACR,OAAM,IAAI,MAAM,0BAA0B;AAE5C,SAAO,MAAM,KAAK,aAAa,QAAQ,MAAM,YAAY"}
@@ -15,8 +15,11 @@ type SearchResult = BaseRequiredFields & ({
15
15
  headers?: Record<string, string>;
16
16
  }[];
17
17
  } | {
18
- downloadType: 'request' | 'task' | 'empty';
18
+ downloadType: 'task';
19
+ taskName: string;
20
+ } | {
21
+ downloadType: 'request' | 'empty';
19
22
  });
20
23
  //#endregion
21
24
  export { SearchResult as t };
22
- //# sourceMappingURL=SearchEngine-CRQWXfo6.d.mts.map
25
+ //# sourceMappingURL=SearchEngine-Cn_-M-at.d.cts.map
@@ -15,8 +15,11 @@ type SearchResult = BaseRequiredFields & ({
15
15
  headers?: Record<string, string>;
16
16
  }[];
17
17
  } | {
18
- downloadType: 'request' | 'task' | 'empty';
18
+ downloadType: 'task';
19
+ taskName: string;
20
+ } | {
21
+ downloadType: 'request' | 'empty';
19
22
  });
20
23
  //#endregion
21
24
  export { SearchResult as t };
22
- //# sourceMappingURL=SearchEngine-DBSUNM4A.d.cts.map
25
+ //# sourceMappingURL=SearchEngine-lZioNunY.d.mts.map
@@ -1,2 +1,2 @@
1
- import { t as SearchResult } from "./SearchEngine-DBSUNM4A.cjs";
1
+ import { t as SearchResult } from "./SearchEngine-Cn_-M-at.cjs";
2
2
  export { SearchResult };
@@ -1,2 +1,2 @@
1
- import { t as SearchResult } from "./SearchEngine-CRQWXfo6.mjs";
1
+ import { t as SearchResult } from "./SearchEngine-lZioNunY.mjs";
2
2
  export { SearchResult };
@@ -1,4 +1,4 @@
1
- const require_ConfigurationBuilder = require('../ConfigurationBuilder-BSuJ4rSI.cjs');
1
+ const require_ConfigurationBuilder = require('../ConfigurationBuilder-CFXi6UwU.cjs');
2
2
 
3
3
  //#region src/config/Configuration.ts
4
4
  var Configuration = class {
@@ -15,11 +15,12 @@ var Configuration = class {
15
15
  validateConfig() {
16
16
  const erroredKeys = /* @__PURE__ */ new Map();
17
17
  for (const key in this.storedConfigTemplate) {
18
- if (this.definiteConfig[key] === null || this.definiteConfig[key] === void 0) {
18
+ if (this.storedConfigTemplate[key].type !== "action" && (this.definiteConfig[key] === null || this.definiteConfig[key] === void 0)) {
19
19
  console.warn("Option " + key + " is not defined. Using default value Value: " + this.storedConfigTemplate[key].defaultValue);
20
20
  this.definiteConfig[key] = this.storedConfigTemplate[key].defaultValue;
21
21
  }
22
- if (this.storedConfigTemplate[key].type !== typeof this.definiteConfig[key]) throw new Error("Option " + key + " is not of the correct type");
22
+ if (this.storedConfigTemplate[key].type !== "action" && this.storedConfigTemplate[key].type !== typeof this.definiteConfig[key]) throw new Error("Option " + key + " is not of the correct type.");
23
+ if (this.storedConfigTemplate[key].type === "action") continue;
23
24
  const result = this.storedConfigTemplate[key].validate(this.definiteConfig[key]);
24
25
  if (!result[0]) erroredKeys.set(key, result[1]);
25
26
  }
@@ -48,12 +49,14 @@ var Configuration = class {
48
49
  };
49
50
 
50
51
  //#endregion
52
+ exports.ActionOption = require_ConfigurationBuilder.ActionOption;
51
53
  exports.BooleanOption = require_ConfigurationBuilder.BooleanOption;
52
54
  exports.Configuration = Configuration;
53
55
  exports.ConfigurationBuilder = require_ConfigurationBuilder.ConfigurationBuilder;
54
56
  exports.ConfigurationOption = require_ConfigurationBuilder.ConfigurationOption;
55
57
  exports.NumberOption = require_ConfigurationBuilder.NumberOption;
56
58
  exports.StringOption = require_ConfigurationBuilder.StringOption;
59
+ exports.isActionOption = require_ConfigurationBuilder.isActionOption;
57
60
  exports.isBooleanOption = require_ConfigurationBuilder.isBooleanOption;
58
61
  exports.isNumberOption = require_ConfigurationBuilder.isNumberOption;
59
62
  exports.isStringOption = require_ConfigurationBuilder.isStringOption;
@@ -1 +1 @@
1
- {"version":3,"file":"Configuration.cjs","names":[],"sources":["../../src/config/Configuration.ts"],"sourcesContent":["import {\n ConfigurationBuilder,\n BooleanOption,\n ConfigurationOption,\n NumberOption,\n StringOption,\n isBooleanOption,\n isNumberOption,\n isStringOption,\n} from './ConfigurationBuilder';\nimport type {\n ConfigurationFile,\n ConfigurationOptionType,\n} from './ConfigurationBuilder';\n\ninterface DefiniteConfig {\n [key: string]: string | number | boolean;\n}\nexport class Configuration {\n readonly storedConfigTemplate: ConfigurationFile;\n definiteConfig: DefiniteConfig = {};\n constructor(configTemplate: ConfigurationFile) {\n this.storedConfigTemplate = configTemplate;\n }\n\n updateConfig(\n config: DefiniteConfig,\n validate: boolean = true\n ): [boolean, { [key: string]: string }] {\n this.definiteConfig = config;\n if (validate) {\n const result = this.validateConfig();\n return result;\n }\n return [true, {}];\n }\n // provides falsey or truthy value, and an error message if falsey\n private validateConfig(): [boolean, { [key: string]: string }] {\n const erroredKeys = new Map<string, string>();\n for (const key in this.storedConfigTemplate) {\n if (\n this.definiteConfig[key] === null ||\n this.definiteConfig[key] === undefined\n ) {\n console.warn(\n 'Option ' +\n key +\n ' is not defined. Using default value Value: ' +\n this.storedConfigTemplate[key].defaultValue\n );\n this.definiteConfig[key] = this.storedConfigTemplate[key]\n .defaultValue as string | number | boolean;\n }\n if (\n this.storedConfigTemplate[key].type !== typeof this.definiteConfig[key]\n ) {\n throw new Error('Option ' + key + ' is not of the correct type');\n }\n\n const result = this.storedConfigTemplate[key].validate(\n this.definiteConfig[key]\n );\n if (!result[0]) {\n erroredKeys.set(key, result[1]);\n }\n }\n\n for (const key in this.definiteConfig) {\n if (this.storedConfigTemplate[key] === undefined) {\n // remove the key from the definite config\n delete this.definiteConfig[key];\n console.warn(\n 'Option ' +\n key +\n ' is not defined in the configuration template. Removing from config.'\n );\n }\n }\n\n if (erroredKeys.size > 0) {\n return [false, Object.fromEntries(erroredKeys)];\n }\n\n return [true, Object.fromEntries(erroredKeys)];\n }\n\n getStringValue(optionName: string): string {\n if (\n this.definiteConfig[optionName] === null ||\n this.definiteConfig[optionName] === undefined\n ) {\n throw new Error('Option ' + optionName + ' is not defined');\n }\n if (typeof this.definiteConfig[optionName] !== 'string') {\n throw new Error('Option ' + optionName + ' is not a string');\n }\n return this.definiteConfig[optionName];\n }\n\n getNumberValue(optionName: string): number {\n if (\n this.definiteConfig[optionName] === null ||\n this.definiteConfig[optionName] === undefined\n ) {\n throw new Error('Option ' + optionName + ' is not defined');\n }\n if (typeof this.definiteConfig[optionName] !== 'number') {\n throw new Error('Option ' + optionName + ' is not a number');\n }\n return this.definiteConfig[optionName];\n }\n\n getBooleanValue(optionName: string): boolean {\n if (\n this.definiteConfig[optionName] === null ||\n this.definiteConfig[optionName] === undefined\n ) {\n throw new Error('Option ' + optionName + ' is not defined');\n }\n if (typeof this.definiteConfig[optionName] !== 'boolean') {\n throw new Error('Option ' + optionName + ' is not a boolean');\n }\n return this.definiteConfig[optionName];\n }\n}\n\nexport {\n ConfigurationBuilder,\n BooleanOption,\n ConfigurationOption,\n NumberOption,\n StringOption,\n isBooleanOption,\n isNumberOption,\n isStringOption,\n};\n\nexport type { ConfigurationFile, ConfigurationOptionType };\n"],"mappings":";;;AAkBA,IAAa,gBAAb,MAA2B;CACzB,AAAS;CACT,iBAAiC,EAAE;CACnC,YAAY,gBAAmC;AAC7C,OAAK,uBAAuB;;CAG9B,aACE,QACA,WAAoB,MACkB;AACtC,OAAK,iBAAiB;AACtB,MAAI,SAEF,QADe,KAAK,gBAAgB;AAGtC,SAAO,CAAC,MAAM,EAAE,CAAC;;CAGnB,AAAQ,iBAAuD;EAC7D,MAAM,8BAAc,IAAI,KAAqB;AAC7C,OAAK,MAAM,OAAO,KAAK,sBAAsB;AAC3C,OACE,KAAK,eAAe,SAAS,QAC7B,KAAK,eAAe,SAAS,QAC7B;AACA,YAAQ,KACN,YACE,MACA,iDACA,KAAK,qBAAqB,KAAK,aAClC;AACD,SAAK,eAAe,OAAO,KAAK,qBAAqB,KAClD;;AAEL,OACE,KAAK,qBAAqB,KAAK,SAAS,OAAO,KAAK,eAAe,KAEnE,OAAM,IAAI,MAAM,YAAY,MAAM,8BAA8B;GAGlE,MAAM,SAAS,KAAK,qBAAqB,KAAK,SAC5C,KAAK,eAAe,KACrB;AACD,OAAI,CAAC,OAAO,GACV,aAAY,IAAI,KAAK,OAAO,GAAG;;AAInC,OAAK,MAAM,OAAO,KAAK,eACrB,KAAI,KAAK,qBAAqB,SAAS,QAAW;AAEhD,UAAO,KAAK,eAAe;AAC3B,WAAQ,KACN,YACE,MACA,uEACH;;AAIL,MAAI,YAAY,OAAO,EACrB,QAAO,CAAC,OAAO,OAAO,YAAY,YAAY,CAAC;AAGjD,SAAO,CAAC,MAAM,OAAO,YAAY,YAAY,CAAC;;CAGhD,eAAe,YAA4B;AACzC,MACE,KAAK,eAAe,gBAAgB,QACpC,KAAK,eAAe,gBAAgB,OAEpC,OAAM,IAAI,MAAM,YAAY,aAAa,kBAAkB;AAE7D,MAAI,OAAO,KAAK,eAAe,gBAAgB,SAC7C,OAAM,IAAI,MAAM,YAAY,aAAa,mBAAmB;AAE9D,SAAO,KAAK,eAAe;;CAG7B,eAAe,YAA4B;AACzC,MACE,KAAK,eAAe,gBAAgB,QACpC,KAAK,eAAe,gBAAgB,OAEpC,OAAM,IAAI,MAAM,YAAY,aAAa,kBAAkB;AAE7D,MAAI,OAAO,KAAK,eAAe,gBAAgB,SAC7C,OAAM,IAAI,MAAM,YAAY,aAAa,mBAAmB;AAE9D,SAAO,KAAK,eAAe;;CAG7B,gBAAgB,YAA6B;AAC3C,MACE,KAAK,eAAe,gBAAgB,QACpC,KAAK,eAAe,gBAAgB,OAEpC,OAAM,IAAI,MAAM,YAAY,aAAa,kBAAkB;AAE7D,MAAI,OAAO,KAAK,eAAe,gBAAgB,UAC7C,OAAM,IAAI,MAAM,YAAY,aAAa,oBAAoB;AAE/D,SAAO,KAAK,eAAe"}
1
+ {"version":3,"file":"Configuration.cjs","names":[],"sources":["../../src/config/Configuration.ts"],"sourcesContent":["import {\n ConfigurationBuilder,\n BooleanOption,\n ConfigurationOption,\n NumberOption,\n StringOption,\n ActionOption,\n isBooleanOption,\n isNumberOption,\n isStringOption,\n isActionOption,\n} from './ConfigurationBuilder';\nimport type {\n ConfigurationFile,\n ConfigurationOptionType,\n} from './ConfigurationBuilder';\n\ninterface DefiniteConfig {\n [key: string]: string | number | boolean;\n}\nexport class Configuration {\n readonly storedConfigTemplate: ConfigurationFile;\n definiteConfig: DefiniteConfig = {};\n constructor(configTemplate: ConfigurationFile) {\n this.storedConfigTemplate = configTemplate;\n }\n\n updateConfig(\n config: DefiniteConfig,\n validate: boolean = true\n ): [boolean, { [key: string]: string }] {\n this.definiteConfig = config;\n if (validate) {\n const result = this.validateConfig();\n return result;\n }\n return [true, {}];\n }\n // provides falsey or truthy value, and an error message if falsey\n private validateConfig(): [boolean, { [key: string]: string }] {\n const erroredKeys = new Map<string, string>();\n for (const key in this.storedConfigTemplate) {\n if (\n this.storedConfigTemplate[key].type !== 'action' &&\n (this.definiteConfig[key] === null ||\n this.definiteConfig[key] === undefined)\n ) {\n console.warn(\n 'Option ' +\n key +\n ' is not defined. Using default value Value: ' +\n this.storedConfigTemplate[key].defaultValue\n );\n this.definiteConfig[key] = this.storedConfigTemplate[key]\n .defaultValue as string | number | boolean;\n }\n if (\n this.storedConfigTemplate[key].type !== 'action' &&\n this.storedConfigTemplate[key].type !== typeof this.definiteConfig[key]\n ) {\n throw new Error('Option ' + key + ' is not of the correct type.');\n }\n\n if (this.storedConfigTemplate[key].type === 'action') {\n continue;\n }\n\n const result = this.storedConfigTemplate[key].validate(\n this.definiteConfig[key]\n );\n if (!result[0]) {\n erroredKeys.set(key, result[1]);\n }\n }\n\n for (const key in this.definiteConfig) {\n if (this.storedConfigTemplate[key] === undefined) {\n // remove the key from the definite config\n delete this.definiteConfig[key];\n console.warn(\n 'Option ' +\n key +\n ' is not defined in the configuration template. Removing from config.'\n );\n }\n }\n\n if (erroredKeys.size > 0) {\n return [false, Object.fromEntries(erroredKeys)];\n }\n\n return [true, Object.fromEntries(erroredKeys)];\n }\n\n getStringValue(optionName: string): string {\n if (\n this.definiteConfig[optionName] === null ||\n this.definiteConfig[optionName] === undefined\n ) {\n throw new Error('Option ' + optionName + ' is not defined');\n }\n if (typeof this.definiteConfig[optionName] !== 'string') {\n throw new Error('Option ' + optionName + ' is not a string');\n }\n return this.definiteConfig[optionName];\n }\n\n getNumberValue(optionName: string): number {\n if (\n this.definiteConfig[optionName] === null ||\n this.definiteConfig[optionName] === undefined\n ) {\n throw new Error('Option ' + optionName + ' is not defined');\n }\n if (typeof this.definiteConfig[optionName] !== 'number') {\n throw new Error('Option ' + optionName + ' is not a number');\n }\n return this.definiteConfig[optionName];\n }\n\n getBooleanValue(optionName: string): boolean {\n if (\n this.definiteConfig[optionName] === null ||\n this.definiteConfig[optionName] === undefined\n ) {\n throw new Error('Option ' + optionName + ' is not defined');\n }\n if (typeof this.definiteConfig[optionName] !== 'boolean') {\n throw new Error('Option ' + optionName + ' is not a boolean');\n }\n return this.definiteConfig[optionName];\n }\n}\n\nexport {\n ConfigurationBuilder,\n BooleanOption,\n ConfigurationOption,\n NumberOption,\n StringOption,\n ActionOption,\n isBooleanOption,\n isNumberOption,\n isStringOption,\n isActionOption,\n};\n\nexport type { ConfigurationFile, ConfigurationOptionType };\n"],"mappings":";;;AAoBA,IAAa,gBAAb,MAA2B;CACzB,AAAS;CACT,iBAAiC,EAAE;CACnC,YAAY,gBAAmC;AAC7C,OAAK,uBAAuB;;CAG9B,aACE,QACA,WAAoB,MACkB;AACtC,OAAK,iBAAiB;AACtB,MAAI,SAEF,QADe,KAAK,gBAAgB;AAGtC,SAAO,CAAC,MAAM,EAAE,CAAC;;CAGnB,AAAQ,iBAAuD;EAC7D,MAAM,8BAAc,IAAI,KAAqB;AAC7C,OAAK,MAAM,OAAO,KAAK,sBAAsB;AAC3C,OACE,KAAK,qBAAqB,KAAK,SAAS,aACvC,KAAK,eAAe,SAAS,QAC5B,KAAK,eAAe,SAAS,SAC/B;AACA,YAAQ,KACN,YACE,MACA,iDACA,KAAK,qBAAqB,KAAK,aAClC;AACD,SAAK,eAAe,OAAO,KAAK,qBAAqB,KAClD;;AAEL,OACE,KAAK,qBAAqB,KAAK,SAAS,YACxC,KAAK,qBAAqB,KAAK,SAAS,OAAO,KAAK,eAAe,KAEnE,OAAM,IAAI,MAAM,YAAY,MAAM,+BAA+B;AAGnE,OAAI,KAAK,qBAAqB,KAAK,SAAS,SAC1C;GAGF,MAAM,SAAS,KAAK,qBAAqB,KAAK,SAC5C,KAAK,eAAe,KACrB;AACD,OAAI,CAAC,OAAO,GACV,aAAY,IAAI,KAAK,OAAO,GAAG;;AAInC,OAAK,MAAM,OAAO,KAAK,eACrB,KAAI,KAAK,qBAAqB,SAAS,QAAW;AAEhD,UAAO,KAAK,eAAe;AAC3B,WAAQ,KACN,YACE,MACA,uEACH;;AAIL,MAAI,YAAY,OAAO,EACrB,QAAO,CAAC,OAAO,OAAO,YAAY,YAAY,CAAC;AAGjD,SAAO,CAAC,MAAM,OAAO,YAAY,YAAY,CAAC;;CAGhD,eAAe,YAA4B;AACzC,MACE,KAAK,eAAe,gBAAgB,QACpC,KAAK,eAAe,gBAAgB,OAEpC,OAAM,IAAI,MAAM,YAAY,aAAa,kBAAkB;AAE7D,MAAI,OAAO,KAAK,eAAe,gBAAgB,SAC7C,OAAM,IAAI,MAAM,YAAY,aAAa,mBAAmB;AAE9D,SAAO,KAAK,eAAe;;CAG7B,eAAe,YAA4B;AACzC,MACE,KAAK,eAAe,gBAAgB,QACpC,KAAK,eAAe,gBAAgB,OAEpC,OAAM,IAAI,MAAM,YAAY,aAAa,kBAAkB;AAE7D,MAAI,OAAO,KAAK,eAAe,gBAAgB,SAC7C,OAAM,IAAI,MAAM,YAAY,aAAa,mBAAmB;AAE9D,SAAO,KAAK,eAAe;;CAG7B,gBAAgB,YAA6B;AAC3C,MACE,KAAK,eAAe,gBAAgB,QACpC,KAAK,eAAe,gBAAgB,OAEpC,OAAM,IAAI,MAAM,YAAY,aAAa,kBAAkB;AAE7D,MAAI,OAAO,KAAK,eAAe,gBAAgB,UAC7C,OAAM,IAAI,MAAM,YAAY,aAAa,oBAAoB;AAE/D,SAAO,KAAK,eAAe"}
@@ -1,3 +1,3 @@
1
- import { a as ConfigurationOptionType, c as isBooleanOption, i as ConfigurationOption, l as isNumberOption, n as ConfigurationBuilder, o as NumberOption, r as ConfigurationFile, s as StringOption, t as BooleanOption, u as isStringOption } from "../ConfigurationBuilder-CfHLKMTO.cjs";
2
- import { t as Configuration } from "../Configuration-WeOm-F0_.cjs";
3
- export { BooleanOption, Configuration, ConfigurationBuilder, ConfigurationFile, ConfigurationOption, ConfigurationOptionType, NumberOption, StringOption, isBooleanOption, isNumberOption, isStringOption };
1
+ import { a as ConfigurationOption, c as StringOption, d as isNumberOption, f as isStringOption, i as ConfigurationFile, l as isActionOption, n as BooleanOption, o as ConfigurationOptionType, r as ConfigurationBuilder, s as NumberOption, t as ActionOption, u as isBooleanOption } from "../ConfigurationBuilder-C83EP5v2.cjs";
2
+ import { t as Configuration } from "../Configuration-DdkCGFMU.cjs";
3
+ export { ActionOption, BooleanOption, Configuration, ConfigurationBuilder, ConfigurationFile, ConfigurationOption, ConfigurationOptionType, NumberOption, StringOption, isActionOption, isBooleanOption, isNumberOption, isStringOption };
@@ -1,3 +1,3 @@
1
- import { a as ConfigurationOptionType, c as isBooleanOption, i as ConfigurationOption, l as isNumberOption, n as ConfigurationBuilder, o as NumberOption, r as ConfigurationFile, s as StringOption, t as BooleanOption, u as isStringOption } from "../ConfigurationBuilder-BbZDA_xx.mjs";
2
- import { t as Configuration } from "../Configuration-CdRZbO6z.mjs";
3
- export { BooleanOption, Configuration, ConfigurationBuilder, ConfigurationFile, ConfigurationOption, ConfigurationOptionType, NumberOption, StringOption, isBooleanOption, isNumberOption, isStringOption };
1
+ import { a as ConfigurationOption, c as StringOption, d as isNumberOption, f as isStringOption, i as ConfigurationFile, l as isActionOption, n as BooleanOption, o as ConfigurationOptionType, r as ConfigurationBuilder, s as NumberOption, t as ActionOption, u as isBooleanOption } from "../ConfigurationBuilder-lzKf9gHw.mjs";
2
+ import { t as Configuration } from "../Configuration-fDtr2bmH.mjs";
3
+ export { ActionOption, BooleanOption, Configuration, ConfigurationBuilder, ConfigurationFile, ConfigurationOption, ConfigurationOptionType, NumberOption, StringOption, isActionOption, isBooleanOption, isNumberOption, isStringOption };
@@ -1,4 +1,4 @@
1
- import { BooleanOption, ConfigurationBuilder, ConfigurationOption, NumberOption, StringOption, isBooleanOption, isNumberOption, isStringOption } from "./ConfigurationBuilder.mjs";
1
+ import { ActionOption, BooleanOption, ConfigurationBuilder, ConfigurationOption, NumberOption, StringOption, isActionOption, isBooleanOption, isNumberOption, isStringOption } from "./ConfigurationBuilder.mjs";
2
2
 
3
3
  //#region src/config/Configuration.ts
4
4
  var Configuration = class {
@@ -15,11 +15,12 @@ var Configuration = class {
15
15
  validateConfig() {
16
16
  const erroredKeys = /* @__PURE__ */ new Map();
17
17
  for (const key in this.storedConfigTemplate) {
18
- if (this.definiteConfig[key] === null || this.definiteConfig[key] === void 0) {
18
+ if (this.storedConfigTemplate[key].type !== "action" && (this.definiteConfig[key] === null || this.definiteConfig[key] === void 0)) {
19
19
  console.warn("Option " + key + " is not defined. Using default value Value: " + this.storedConfigTemplate[key].defaultValue);
20
20
  this.definiteConfig[key] = this.storedConfigTemplate[key].defaultValue;
21
21
  }
22
- if (this.storedConfigTemplate[key].type !== typeof this.definiteConfig[key]) throw new Error("Option " + key + " is not of the correct type");
22
+ if (this.storedConfigTemplate[key].type !== "action" && this.storedConfigTemplate[key].type !== typeof this.definiteConfig[key]) throw new Error("Option " + key + " is not of the correct type.");
23
+ if (this.storedConfigTemplate[key].type === "action") continue;
23
24
  const result = this.storedConfigTemplate[key].validate(this.definiteConfig[key]);
24
25
  if (!result[0]) erroredKeys.set(key, result[1]);
25
26
  }
@@ -48,5 +49,5 @@ var Configuration = class {
48
49
  };
49
50
 
50
51
  //#endregion
51
- export { BooleanOption, Configuration, ConfigurationBuilder, ConfigurationOption, NumberOption, StringOption, isBooleanOption, isNumberOption, isStringOption };
52
+ export { ActionOption, BooleanOption, Configuration, ConfigurationBuilder, ConfigurationOption, NumberOption, StringOption, isActionOption, isBooleanOption, isNumberOption, isStringOption };
52
53
  //# sourceMappingURL=Configuration.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Configuration.mjs","names":[],"sources":["../../src/config/Configuration.ts"],"sourcesContent":["import {\n ConfigurationBuilder,\n BooleanOption,\n ConfigurationOption,\n NumberOption,\n StringOption,\n isBooleanOption,\n isNumberOption,\n isStringOption,\n} from './ConfigurationBuilder';\nimport type {\n ConfigurationFile,\n ConfigurationOptionType,\n} from './ConfigurationBuilder';\n\ninterface DefiniteConfig {\n [key: string]: string | number | boolean;\n}\nexport class Configuration {\n readonly storedConfigTemplate: ConfigurationFile;\n definiteConfig: DefiniteConfig = {};\n constructor(configTemplate: ConfigurationFile) {\n this.storedConfigTemplate = configTemplate;\n }\n\n updateConfig(\n config: DefiniteConfig,\n validate: boolean = true\n ): [boolean, { [key: string]: string }] {\n this.definiteConfig = config;\n if (validate) {\n const result = this.validateConfig();\n return result;\n }\n return [true, {}];\n }\n // provides falsey or truthy value, and an error message if falsey\n private validateConfig(): [boolean, { [key: string]: string }] {\n const erroredKeys = new Map<string, string>();\n for (const key in this.storedConfigTemplate) {\n if (\n this.definiteConfig[key] === null ||\n this.definiteConfig[key] === undefined\n ) {\n console.warn(\n 'Option ' +\n key +\n ' is not defined. Using default value Value: ' +\n this.storedConfigTemplate[key].defaultValue\n );\n this.definiteConfig[key] = this.storedConfigTemplate[key]\n .defaultValue as string | number | boolean;\n }\n if (\n this.storedConfigTemplate[key].type !== typeof this.definiteConfig[key]\n ) {\n throw new Error('Option ' + key + ' is not of the correct type');\n }\n\n const result = this.storedConfigTemplate[key].validate(\n this.definiteConfig[key]\n );\n if (!result[0]) {\n erroredKeys.set(key, result[1]);\n }\n }\n\n for (const key in this.definiteConfig) {\n if (this.storedConfigTemplate[key] === undefined) {\n // remove the key from the definite config\n delete this.definiteConfig[key];\n console.warn(\n 'Option ' +\n key +\n ' is not defined in the configuration template. Removing from config.'\n );\n }\n }\n\n if (erroredKeys.size > 0) {\n return [false, Object.fromEntries(erroredKeys)];\n }\n\n return [true, Object.fromEntries(erroredKeys)];\n }\n\n getStringValue(optionName: string): string {\n if (\n this.definiteConfig[optionName] === null ||\n this.definiteConfig[optionName] === undefined\n ) {\n throw new Error('Option ' + optionName + ' is not defined');\n }\n if (typeof this.definiteConfig[optionName] !== 'string') {\n throw new Error('Option ' + optionName + ' is not a string');\n }\n return this.definiteConfig[optionName];\n }\n\n getNumberValue(optionName: string): number {\n if (\n this.definiteConfig[optionName] === null ||\n this.definiteConfig[optionName] === undefined\n ) {\n throw new Error('Option ' + optionName + ' is not defined');\n }\n if (typeof this.definiteConfig[optionName] !== 'number') {\n throw new Error('Option ' + optionName + ' is not a number');\n }\n return this.definiteConfig[optionName];\n }\n\n getBooleanValue(optionName: string): boolean {\n if (\n this.definiteConfig[optionName] === null ||\n this.definiteConfig[optionName] === undefined\n ) {\n throw new Error('Option ' + optionName + ' is not defined');\n }\n if (typeof this.definiteConfig[optionName] !== 'boolean') {\n throw new Error('Option ' + optionName + ' is not a boolean');\n }\n return this.definiteConfig[optionName];\n }\n}\n\nexport {\n ConfigurationBuilder,\n BooleanOption,\n ConfigurationOption,\n NumberOption,\n StringOption,\n isBooleanOption,\n isNumberOption,\n isStringOption,\n};\n\nexport type { ConfigurationFile, ConfigurationOptionType };\n"],"mappings":";;;AAkBA,IAAa,gBAAb,MAA2B;CACzB,AAAS;CACT,iBAAiC,EAAE;CACnC,YAAY,gBAAmC;AAC7C,OAAK,uBAAuB;;CAG9B,aACE,QACA,WAAoB,MACkB;AACtC,OAAK,iBAAiB;AACtB,MAAI,SAEF,QADe,KAAK,gBAAgB;AAGtC,SAAO,CAAC,MAAM,EAAE,CAAC;;CAGnB,AAAQ,iBAAuD;EAC7D,MAAM,8BAAc,IAAI,KAAqB;AAC7C,OAAK,MAAM,OAAO,KAAK,sBAAsB;AAC3C,OACE,KAAK,eAAe,SAAS,QAC7B,KAAK,eAAe,SAAS,QAC7B;AACA,YAAQ,KACN,YACE,MACA,iDACA,KAAK,qBAAqB,KAAK,aAClC;AACD,SAAK,eAAe,OAAO,KAAK,qBAAqB,KAClD;;AAEL,OACE,KAAK,qBAAqB,KAAK,SAAS,OAAO,KAAK,eAAe,KAEnE,OAAM,IAAI,MAAM,YAAY,MAAM,8BAA8B;GAGlE,MAAM,SAAS,KAAK,qBAAqB,KAAK,SAC5C,KAAK,eAAe,KACrB;AACD,OAAI,CAAC,OAAO,GACV,aAAY,IAAI,KAAK,OAAO,GAAG;;AAInC,OAAK,MAAM,OAAO,KAAK,eACrB,KAAI,KAAK,qBAAqB,SAAS,QAAW;AAEhD,UAAO,KAAK,eAAe;AAC3B,WAAQ,KACN,YACE,MACA,uEACH;;AAIL,MAAI,YAAY,OAAO,EACrB,QAAO,CAAC,OAAO,OAAO,YAAY,YAAY,CAAC;AAGjD,SAAO,CAAC,MAAM,OAAO,YAAY,YAAY,CAAC;;CAGhD,eAAe,YAA4B;AACzC,MACE,KAAK,eAAe,gBAAgB,QACpC,KAAK,eAAe,gBAAgB,OAEpC,OAAM,IAAI,MAAM,YAAY,aAAa,kBAAkB;AAE7D,MAAI,OAAO,KAAK,eAAe,gBAAgB,SAC7C,OAAM,IAAI,MAAM,YAAY,aAAa,mBAAmB;AAE9D,SAAO,KAAK,eAAe;;CAG7B,eAAe,YAA4B;AACzC,MACE,KAAK,eAAe,gBAAgB,QACpC,KAAK,eAAe,gBAAgB,OAEpC,OAAM,IAAI,MAAM,YAAY,aAAa,kBAAkB;AAE7D,MAAI,OAAO,KAAK,eAAe,gBAAgB,SAC7C,OAAM,IAAI,MAAM,YAAY,aAAa,mBAAmB;AAE9D,SAAO,KAAK,eAAe;;CAG7B,gBAAgB,YAA6B;AAC3C,MACE,KAAK,eAAe,gBAAgB,QACpC,KAAK,eAAe,gBAAgB,OAEpC,OAAM,IAAI,MAAM,YAAY,aAAa,kBAAkB;AAE7D,MAAI,OAAO,KAAK,eAAe,gBAAgB,UAC7C,OAAM,IAAI,MAAM,YAAY,aAAa,oBAAoB;AAE/D,SAAO,KAAK,eAAe"}
1
+ {"version":3,"file":"Configuration.mjs","names":[],"sources":["../../src/config/Configuration.ts"],"sourcesContent":["import {\n ConfigurationBuilder,\n BooleanOption,\n ConfigurationOption,\n NumberOption,\n StringOption,\n ActionOption,\n isBooleanOption,\n isNumberOption,\n isStringOption,\n isActionOption,\n} from './ConfigurationBuilder';\nimport type {\n ConfigurationFile,\n ConfigurationOptionType,\n} from './ConfigurationBuilder';\n\ninterface DefiniteConfig {\n [key: string]: string | number | boolean;\n}\nexport class Configuration {\n readonly storedConfigTemplate: ConfigurationFile;\n definiteConfig: DefiniteConfig = {};\n constructor(configTemplate: ConfigurationFile) {\n this.storedConfigTemplate = configTemplate;\n }\n\n updateConfig(\n config: DefiniteConfig,\n validate: boolean = true\n ): [boolean, { [key: string]: string }] {\n this.definiteConfig = config;\n if (validate) {\n const result = this.validateConfig();\n return result;\n }\n return [true, {}];\n }\n // provides falsey or truthy value, and an error message if falsey\n private validateConfig(): [boolean, { [key: string]: string }] {\n const erroredKeys = new Map<string, string>();\n for (const key in this.storedConfigTemplate) {\n if (\n this.storedConfigTemplate[key].type !== 'action' &&\n (this.definiteConfig[key] === null ||\n this.definiteConfig[key] === undefined)\n ) {\n console.warn(\n 'Option ' +\n key +\n ' is not defined. Using default value Value: ' +\n this.storedConfigTemplate[key].defaultValue\n );\n this.definiteConfig[key] = this.storedConfigTemplate[key]\n .defaultValue as string | number | boolean;\n }\n if (\n this.storedConfigTemplate[key].type !== 'action' &&\n this.storedConfigTemplate[key].type !== typeof this.definiteConfig[key]\n ) {\n throw new Error('Option ' + key + ' is not of the correct type.');\n }\n\n if (this.storedConfigTemplate[key].type === 'action') {\n continue;\n }\n\n const result = this.storedConfigTemplate[key].validate(\n this.definiteConfig[key]\n );\n if (!result[0]) {\n erroredKeys.set(key, result[1]);\n }\n }\n\n for (const key in this.definiteConfig) {\n if (this.storedConfigTemplate[key] === undefined) {\n // remove the key from the definite config\n delete this.definiteConfig[key];\n console.warn(\n 'Option ' +\n key +\n ' is not defined in the configuration template. Removing from config.'\n );\n }\n }\n\n if (erroredKeys.size > 0) {\n return [false, Object.fromEntries(erroredKeys)];\n }\n\n return [true, Object.fromEntries(erroredKeys)];\n }\n\n getStringValue(optionName: string): string {\n if (\n this.definiteConfig[optionName] === null ||\n this.definiteConfig[optionName] === undefined\n ) {\n throw new Error('Option ' + optionName + ' is not defined');\n }\n if (typeof this.definiteConfig[optionName] !== 'string') {\n throw new Error('Option ' + optionName + ' is not a string');\n }\n return this.definiteConfig[optionName];\n }\n\n getNumberValue(optionName: string): number {\n if (\n this.definiteConfig[optionName] === null ||\n this.definiteConfig[optionName] === undefined\n ) {\n throw new Error('Option ' + optionName + ' is not defined');\n }\n if (typeof this.definiteConfig[optionName] !== 'number') {\n throw new Error('Option ' + optionName + ' is not a number');\n }\n return this.definiteConfig[optionName];\n }\n\n getBooleanValue(optionName: string): boolean {\n if (\n this.definiteConfig[optionName] === null ||\n this.definiteConfig[optionName] === undefined\n ) {\n throw new Error('Option ' + optionName + ' is not defined');\n }\n if (typeof this.definiteConfig[optionName] !== 'boolean') {\n throw new Error('Option ' + optionName + ' is not a boolean');\n }\n return this.definiteConfig[optionName];\n }\n}\n\nexport {\n ConfigurationBuilder,\n BooleanOption,\n ConfigurationOption,\n NumberOption,\n StringOption,\n ActionOption,\n isBooleanOption,\n isNumberOption,\n isStringOption,\n isActionOption,\n};\n\nexport type { ConfigurationFile, ConfigurationOptionType };\n"],"mappings":";;;AAoBA,IAAa,gBAAb,MAA2B;CACzB,AAAS;CACT,iBAAiC,EAAE;CACnC,YAAY,gBAAmC;AAC7C,OAAK,uBAAuB;;CAG9B,aACE,QACA,WAAoB,MACkB;AACtC,OAAK,iBAAiB;AACtB,MAAI,SAEF,QADe,KAAK,gBAAgB;AAGtC,SAAO,CAAC,MAAM,EAAE,CAAC;;CAGnB,AAAQ,iBAAuD;EAC7D,MAAM,8BAAc,IAAI,KAAqB;AAC7C,OAAK,MAAM,OAAO,KAAK,sBAAsB;AAC3C,OACE,KAAK,qBAAqB,KAAK,SAAS,aACvC,KAAK,eAAe,SAAS,QAC5B,KAAK,eAAe,SAAS,SAC/B;AACA,YAAQ,KACN,YACE,MACA,iDACA,KAAK,qBAAqB,KAAK,aAClC;AACD,SAAK,eAAe,OAAO,KAAK,qBAAqB,KAClD;;AAEL,OACE,KAAK,qBAAqB,KAAK,SAAS,YACxC,KAAK,qBAAqB,KAAK,SAAS,OAAO,KAAK,eAAe,KAEnE,OAAM,IAAI,MAAM,YAAY,MAAM,+BAA+B;AAGnE,OAAI,KAAK,qBAAqB,KAAK,SAAS,SAC1C;GAGF,MAAM,SAAS,KAAK,qBAAqB,KAAK,SAC5C,KAAK,eAAe,KACrB;AACD,OAAI,CAAC,OAAO,GACV,aAAY,IAAI,KAAK,OAAO,GAAG;;AAInC,OAAK,MAAM,OAAO,KAAK,eACrB,KAAI,KAAK,qBAAqB,SAAS,QAAW;AAEhD,UAAO,KAAK,eAAe;AAC3B,WAAQ,KACN,YACE,MACA,uEACH;;AAIL,MAAI,YAAY,OAAO,EACrB,QAAO,CAAC,OAAO,OAAO,YAAY,YAAY,CAAC;AAGjD,SAAO,CAAC,MAAM,OAAO,YAAY,YAAY,CAAC;;CAGhD,eAAe,YAA4B;AACzC,MACE,KAAK,eAAe,gBAAgB,QACpC,KAAK,eAAe,gBAAgB,OAEpC,OAAM,IAAI,MAAM,YAAY,aAAa,kBAAkB;AAE7D,MAAI,OAAO,KAAK,eAAe,gBAAgB,SAC7C,OAAM,IAAI,MAAM,YAAY,aAAa,mBAAmB;AAE9D,SAAO,KAAK,eAAe;;CAG7B,eAAe,YAA4B;AACzC,MACE,KAAK,eAAe,gBAAgB,QACpC,KAAK,eAAe,gBAAgB,OAEpC,OAAM,IAAI,MAAM,YAAY,aAAa,kBAAkB;AAE7D,MAAI,OAAO,KAAK,eAAe,gBAAgB,SAC7C,OAAM,IAAI,MAAM,YAAY,aAAa,mBAAmB;AAE9D,SAAO,KAAK,eAAe;;CAG7B,gBAAgB,YAA6B;AAC3C,MACE,KAAK,eAAe,gBAAgB,QACpC,KAAK,eAAe,gBAAgB,OAEpC,OAAM,IAAI,MAAM,YAAY,aAAa,kBAAkB;AAE7D,MAAI,OAAO,KAAK,eAAe,gBAAgB,UAC7C,OAAM,IAAI,MAAM,YAAY,aAAa,oBAAoB;AAE/D,SAAO,KAAK,eAAe"}