ogi-addon 1.2.2 → 1.3.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.
package/README.md CHANGED
@@ -1,32 +1,39 @@
1
1
  # OGI-Addon
2
+
2
3
  A library to interface with OpenGameInstaller's addon system.
3
4
 
4
5
  # Installation
6
+
5
7
  ```bash
6
8
  $ npm install ogi-addon
7
9
  ```
8
10
 
9
11
  # Examples
12
+
10
13
  Check out the [test-addon](https://github.com/Nat3z/OpenGameInstaller/tree/main/test-addon) folder to see how to use the addon library.
11
14
 
12
15
  # Boilerplate
16
+
13
17
  Your addon should include an `addon.json` file which describes how to setup your addon. It should always include a `run` script so OpenGameInstaller will know how to start your addon.
18
+
14
19
  ```typescript
15
20
  interface AddonFileConfigurationSchema {
16
- author: string,
21
+ author: string;
17
22
  scripts: {
18
- setup?: string,
19
- run: string,
20
- preSetup?: string,
21
- postSetup?: string
22
- }
23
+ setup?: string;
24
+ run: string;
25
+ preSetup?: string;
26
+ postSetup?: string;
27
+ };
23
28
  }
24
29
  ```
25
30
 
26
31
  ## How to Develop
32
+
27
33
  In OpenGameInstaller, go to `Settings > General` and use the **local:** prefix to define that your addon is hosted locally instead of through a remote git repository.
28
34
 
29
35
  For Example:
36
+
30
37
  ```
31
38
  local:C:\Users\[you]\Documents\Addon\
32
39
  ```
@@ -34,8 +41,9 @@ local:C:\Users\[you]\Documents\Addon\
34
41
  This will allow OpenGameInstaller to launch your addon securely instead of opening up the addon server for unsigned connections.
35
42
 
36
43
  ### Disable Signature Requirement for Addons
44
+
37
45
  If you want to debug your addon without relying on OpenGameInstaller to launch it, you can disable the signature requirement.
38
46
 
39
47
  ⚠️ **WARNING** This is VERY unsafe to do, as it allows for any malicious program to connect to the addon server without needing to provide the addon secret. We recommend enabling this temporarily for debugging purposes and disabling it once you can.
40
48
 
41
- To disable the signature requirement, go to `Settings > Developer` and select **Disable Server Secret Check**. Restart OpenGameInstaller.
49
+ To disable the signature requirement, go to `Settings > Developer` and select **Disable Server Secret Check**. Restart OpenGameInstaller.
@@ -41,7 +41,7 @@ var EventResponse = class {
41
41
  }
42
42
  }
43
43
  /**
44
- * 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.**
44
+ * 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.**
45
45
  * @param data {T}
46
46
  */
47
47
  resolve(data) {
@@ -49,7 +49,7 @@ var EventResponse = class {
49
49
  this.data = data;
50
50
  }
51
51
  /**
52
- * 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.**
52
+ * 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.**
53
53
  */
54
54
  complete() {
55
55
  this.resolved = true;
@@ -59,7 +59,7 @@ var EventResponse = class {
59
59
  this.failed = message;
60
60
  }
61
61
  /**
62
- * Logs a message to the event. This is useful for debugging and logging information to the user.
62
+ * Logs a message to the event. This is useful for debugging and logging information to the user.
63
63
  * @param message {string}
64
64
  */
65
65
  log(message) {
@@ -1 +1 @@
1
- {"version":3,"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?: (screen: ConfigurationBuilder, name: string, description: string) => Promise<{ [key: string]: boolean | string | number }>;\n\n constructor(onInputAsked?: (screen: ConfigurationBuilder, name: string, description: string) => Promise<{ [key: string]: boolean | string | number }>) {\n this.onInputAsked = onInputAsked;\n }\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(name: string, description: string, screen: ConfigurationBuilder): 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 \n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAqB,gBAArB,MAAsC;AAAA,EACpC,OAAsB;AAAA,EACtB,WAAoB;AAAA,EACpB,WAAoB;AAAA,EACpB,WAAmB;AAAA,EACnB,OAAiB,CAAC;AAAA,EAClB,SAA6B;AAAA,EAC7B;AAAA,EAEA,YAAY,cAA2I;AACrJ,SAAK,eAAe;AAAA,EACtB;AAAA,EAGO,MAAM,SAA+B;AAC1C,SAAK,WAAW;AAEhB,QAAI,SAAS;AACX,cAAQ;AAAA,IACV;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,QAAQ,MAAS;AACtB,SAAK,WAAW;AAChB,SAAK,OAAO;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKO,WAAW;AAChB,SAAK,WAAW;AAAA,EAClB;AAAA,EAEO,KAAK,SAAiB;AAC3B,SAAK,WAAW;AAChB,SAAK,SAAS;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,IAAI,SAAiB;AAC1B,SAAK,KAAK,KAAK,OAAO;AAAA,EACxB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAa,YAAY,MAAc,aAAqB,QAAsF;AAChJ,QAAI,CAAC,KAAK,cAAc;AACtB,YAAM,IAAI,MAAM,yBAAyB;AAAA,IAC3C;AACA,WAAO,MAAM,KAAK,aAAa,QAAQ,MAAM,WAAW;AAAA,EAC1D;AAGF;","names":[]}
1
+ {"version":3,"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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAqB,gBAArB,MAAsC;AAAA,EACpC,OAAsB;AAAA,EACtB,WAAoB;AAAA,EACpB,WAAoB;AAAA,EACpB,WAAmB;AAAA,EACnB,OAAiB,CAAC;AAAA,EAClB,SAA6B;AAAA,EAC7B;AAAA,EAMA,YACE,cAKA;AACA,SAAK,eAAe;AAAA,EACtB;AAAA,EAEO,MAAM,SAA+B;AAC1C,SAAK,WAAW;AAEhB,QAAI,SAAS;AACX,cAAQ;AAAA,IACV;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,QAAQ,MAAS;AACtB,SAAK,WAAW;AAChB,SAAK,OAAO;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKO,WAAW;AAChB,SAAK,WAAW;AAAA,EAClB;AAAA,EAEO,KAAK,SAAiB;AAC3B,SAAK,WAAW;AAChB,SAAK,SAAS;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,IAAI,SAAiB;AAC1B,SAAK,KAAK,KAAK,OAAO;AAAA,EACxB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAa,YACX,MACA,aACA,QACuD;AACvD,QAAI,CAAC,KAAK,cAAc;AACtB,YAAM,IAAI,MAAM,yBAAyB;AAAA,IAC3C;AACA,WAAO,MAAM,KAAK,aAAa,QAAQ,MAAM,WAAW;AAAA,EAC1D;AACF;","names":[]}
@@ -17,7 +17,7 @@ var EventResponse = class {
17
17
  }
18
18
  }
19
19
  /**
20
- * 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.**
20
+ * 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.**
21
21
  * @param data {T}
22
22
  */
23
23
  resolve(data) {
@@ -25,7 +25,7 @@ var EventResponse = class {
25
25
  this.data = data;
26
26
  }
27
27
  /**
28
- * 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.**
28
+ * 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.**
29
29
  */
30
30
  complete() {
31
31
  this.resolved = true;
@@ -35,7 +35,7 @@ var EventResponse = class {
35
35
  this.failed = message;
36
36
  }
37
37
  /**
38
- * Logs a message to the event. This is useful for debugging and logging information to the user.
38
+ * Logs a message to the event. This is useful for debugging and logging information to the user.
39
39
  * @param message {string}
40
40
  */
41
41
  log(message) {
@@ -1 +1 @@
1
- {"version":3,"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?: (screen: ConfigurationBuilder, name: string, description: string) => Promise<{ [key: string]: boolean | string | number }>;\n\n constructor(onInputAsked?: (screen: ConfigurationBuilder, name: string, description: string) => Promise<{ [key: string]: boolean | string | number }>) {\n this.onInputAsked = onInputAsked;\n }\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(name: string, description: string, screen: ConfigurationBuilder): 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 \n}"],"mappings":";AAEA,IAAqB,gBAArB,MAAsC;AAAA,EACpC,OAAsB;AAAA,EACtB,WAAoB;AAAA,EACpB,WAAoB;AAAA,EACpB,WAAmB;AAAA,EACnB,OAAiB,CAAC;AAAA,EAClB,SAA6B;AAAA,EAC7B;AAAA,EAEA,YAAY,cAA2I;AACrJ,SAAK,eAAe;AAAA,EACtB;AAAA,EAGO,MAAM,SAA+B;AAC1C,SAAK,WAAW;AAEhB,QAAI,SAAS;AACX,cAAQ;AAAA,IACV;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,QAAQ,MAAS;AACtB,SAAK,WAAW;AAChB,SAAK,OAAO;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKO,WAAW;AAChB,SAAK,WAAW;AAAA,EAClB;AAAA,EAEO,KAAK,SAAiB;AAC3B,SAAK,WAAW;AAChB,SAAK,SAAS;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,IAAI,SAAiB;AAC1B,SAAK,KAAK,KAAK,OAAO;AAAA,EACxB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAa,YAAY,MAAc,aAAqB,QAAsF;AAChJ,QAAI,CAAC,KAAK,cAAc;AACtB,YAAM,IAAI,MAAM,yBAAyB;AAAA,IAC3C;AACA,WAAO,MAAM,KAAK,aAAa,QAAQ,MAAM,WAAW;AAAA,EAC1D;AAGF;","names":[]}
1
+ {"version":3,"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;AAAA,EACpC,OAAsB;AAAA,EACtB,WAAoB;AAAA,EACpB,WAAoB;AAAA,EACpB,WAAmB;AAAA,EACnB,OAAiB,CAAC;AAAA,EAClB,SAA6B;AAAA,EAC7B;AAAA,EAMA,YACE,cAKA;AACA,SAAK,eAAe;AAAA,EACtB;AAAA,EAEO,MAAM,SAA+B;AAC1C,SAAK,WAAW;AAEhB,QAAI,SAAS;AACX,cAAQ;AAAA,IACV;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,QAAQ,MAAS;AACtB,SAAK,WAAW;AAChB,SAAK,OAAO;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKO,WAAW;AAChB,SAAK,WAAW;AAAA,EAClB;AAAA,EAEO,KAAK,SAAiB;AAC3B,SAAK,WAAW;AAChB,SAAK,SAAS;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,IAAI,SAAiB;AAC1B,SAAK,KAAK,KAAK,OAAO;AAAA,EACxB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAa,YACX,MACA,aACA,QACuD;AACvD,QAAI,CAAC,KAAK,cAAc;AACtB,YAAM,IAAI,MAAM,yBAAyB;AAAA,IAC3C;AACA,WAAO,MAAM,KAAK,aAAa,QAAQ,MAAM,WAAW;AAAA,EAC1D;AACF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/SearchEngine.ts"],"sourcesContent":["export type SearchResult = {\n name: string;\n downloadType: 'torrent' | 'direct' | 'magnet' | 'request';\n storefront: 'steam' | 'internal';\n filename?: string;\n downloadURL?: string;\n files?: {\n name: string;\n downloadURL: string;\n }[];\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../src/SearchEngine.ts"],"sourcesContent":["export type SearchResult = {\n name: string;\n downloadType: 'torrent' | 'direct' | 'magnet' | 'request';\n storefront: 'steam' | 'internal';\n filename?: string;\n downloadURL?: string;\n files?: {\n name: string;\n downloadURL: string;\n }[];\n manifest?: Record<string, any>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -8,6 +8,7 @@ type SearchResult = {
8
8
  name: string;
9
9
  downloadURL: string;
10
10
  }[];
11
+ manifest?: Record<string, any>;
11
12
  };
12
13
 
13
14
  export type { SearchResult };
@@ -8,6 +8,7 @@ type SearchResult = {
8
8
  name: string;
9
9
  downloadURL: string;
10
10
  }[];
11
+ manifest?: Record<string, any>;
11
12
  };
12
13
 
13
14
  export type { SearchResult };
@@ -63,7 +63,7 @@ var ConfigurationBuilder = class {
63
63
  /**
64
64
  * Add a number option to the configuration builder and return the builder for chaining. You must provide a name, display name, and description for the option.
65
65
  * @param option { (option: NumberOption) => NumberOption }
66
- * @returns
66
+ * @returns
67
67
  */
68
68
  addNumberOption(option) {
69
69
  let newOption = new NumberOption();
@@ -74,7 +74,7 @@ var ConfigurationBuilder = class {
74
74
  /**
75
75
  * Add a string option to the configuration builder and return the builder for chaining. You must provide a name, display name, and description for the option.
76
76
  * @param option { (option: StringOption) => StringOption }
77
- */
77
+ */
78
78
  addStringOption(option) {
79
79
  let newOption = new StringOption();
80
80
  newOption = option(newOption);
@@ -84,7 +84,7 @@ var ConfigurationBuilder = class {
84
84
  /**
85
85
  * Add a boolean option to the configuration builder and return the builder for chaining. You must provide a name, display name, and description for the option.
86
86
  * @param option { (option: BooleanOption) => BooleanOption }
87
- */
87
+ */
88
88
  addBooleanOption(option) {
89
89
  let newOption = new BooleanOption();
90
90
  newOption = option(newOption);
@@ -123,9 +123,9 @@ var ConfigurationOption = class {
123
123
  return this;
124
124
  }
125
125
  /**
126
- * Set the display name of the option. This is used to show the user a human readable version of what the option is. **REQUIRED**
127
- * @param displayName {string} The display name of the option.
128
- * @returns
126
+ * Set the display name of the option. This is used to show the user a human readable version of what the option is. **REQUIRED**
127
+ * @param displayName {string} The display name of the option.
128
+ * @returns
129
129
  */
130
130
  setDisplayName(displayName) {
131
131
  this.displayName = displayName;
@@ -133,8 +133,8 @@ var ConfigurationOption = class {
133
133
  }
134
134
  /**
135
135
  * Set the description of the option. This is to show the user a brief description of what this option does. **REQUIRED**
136
- * @param description {string} The description of the option.
137
- * @returns
136
+ * @param description {string} The description of the option.
137
+ * @returns
138
138
  */
139
139
  setDescription(description) {
140
140
  this.description = description;
@@ -156,7 +156,7 @@ var StringOption = class extends ConfigurationOption {
156
156
  inputType = "text";
157
157
  type = "string";
158
158
  /**
159
- * Set the allowed values for the string. If the array is empty, any value is allowed. When provided, the client will act like this option is a dropdown.
159
+ * Set the allowed values for the string. If the array is empty, any value is allowed. When provided, the client will act like this option is a dropdown.
160
160
  * @param allowedValues {string[]} An array of allowed values for the string. If the array is empty, any value is allowed.
161
161
  */
162
162
  setAllowedValues(allowedValues) {
@@ -172,15 +172,15 @@ var StringOption = class extends ConfigurationOption {
172
172
  return this;
173
173
  }
174
174
  /**
175
- * Set the minimum text length for the string. If the user provides a string that is less than this value, the validation will fail.
176
- * @param minTextLength {number} The minimum text length for the string.
175
+ * Set the minimum text length for the string. If the user provides a string that is less than this value, the validation will fail.
176
+ * @param minTextLength {number} The minimum text length for the string.
177
177
  */
178
178
  setMinTextLength(minTextLength) {
179
179
  this.minTextLength = minTextLength;
180
180
  return this;
181
181
  }
182
182
  /**
183
- * Set the maximum text length for the string. If the user provides a string that is greater than this value, the validation will fail.
183
+ * Set the maximum text length for the string. If the user provides a string that is greater than this value, the validation will fail.
184
184
  * @param maxTextLength {number} The maximum text length for the string.
185
185
  */
186
186
  setMaxTextLength(maxTextLength) {
@@ -188,8 +188,8 @@ var StringOption = class extends ConfigurationOption {
188
188
  return this;
189
189
  }
190
190
  /**
191
- * Set the input type for the string. This will change how the client renders the input.
192
- * @param inputType {'text' | 'file' | 'password' | 'folder'} The input type for the string.
191
+ * Set the input type for the string. This will change how the client renders the input.
192
+ * @param inputType {'text' | 'file' | 'password' | 'folder'} The input type for the string.
193
193
  */
194
194
  setInputType(inputType) {
195
195
  this.inputType = inputType;
@@ -202,9 +202,15 @@ var StringOption = class extends ConfigurationOption {
202
202
  if (this.allowedValues.length === 0 && input.length !== 0)
203
203
  return [true, ""];
204
204
  if (input.length < this.minTextLength || input.length > this.maxTextLength) {
205
- return [false, "Input is not within the text length " + this.minTextLength + " and " + this.maxTextLength + " characters (currently " + input.length + " characters)"];
205
+ return [
206
+ false,
207
+ "Input is not within the text length " + this.minTextLength + " and " + this.maxTextLength + " characters (currently " + input.length + " characters)"
208
+ ];
206
209
  }
207
- return [this.allowedValues.includes(input), "Input is not an allowed value"];
210
+ return [
211
+ this.allowedValues.includes(input),
212
+ "Input is not an allowed value"
213
+ ];
208
214
  }
209
215
  };
210
216
  var NumberOption = class extends ConfigurationOption {
@@ -222,8 +228,8 @@ var NumberOption = class extends ConfigurationOption {
222
228
  return this;
223
229
  }
224
230
  /**
225
- * Set the input type for the number. This will change how the client renders the input.
226
- * @param type {'range' | 'number'} The input type for the number.
231
+ * Set the input type for the number. This will change how the client renders the input.
232
+ * @param type {'range' | 'number'} The input type for the number.
227
233
  */
228
234
  setInputType(type) {
229
235
  this.inputType = type;
@@ -250,7 +256,10 @@ var NumberOption = class extends ConfigurationOption {
250
256
  return [false, "Input is not a number"];
251
257
  }
252
258
  if (Number(input) < this.min || Number(input) > this.max) {
253
- return [false, "Input is not within the range of " + this.min + " and " + this.max];
259
+ return [
260
+ false,
261
+ "Input is not within the range of " + this.min + " and " + this.max
262
+ ];
254
263
  }
255
264
  return [true, ""];
256
265
  }
@@ -294,20 +303,26 @@ var Configuration = class {
294
303
  const erroredKeys = /* @__PURE__ */ new Map();
295
304
  for (const key in this.storedConfigTemplate) {
296
305
  if (this.definiteConfig[key] === null || this.definiteConfig[key] === void 0) {
297
- console.warn("Option " + key + " is not defined. Using default value Value: " + this.definiteConfig[key]);
306
+ console.warn(
307
+ "Option " + key + " is not defined. Using default value Value: " + this.definiteConfig[key]
308
+ );
298
309
  this.definiteConfig[key] = this.storedConfigTemplate[key].defaultValue;
299
310
  }
300
311
  if (this.storedConfigTemplate[key].type !== typeof this.definiteConfig[key]) {
301
312
  throw new Error("Option " + key + " is not of the correct type");
302
313
  }
303
- const result = this.storedConfigTemplate[key].validate(this.definiteConfig[key]);
314
+ const result = this.storedConfigTemplate[key].validate(
315
+ this.definiteConfig[key]
316
+ );
304
317
  if (!result[0]) {
305
318
  erroredKeys.set(key, result[1]);
306
319
  }
307
320
  }
308
321
  for (const key in this.definiteConfig) {
309
322
  if (!this.storedConfigTemplate[key]) {
310
- throw new Error("Option " + key + " is not defined in the configuration template");
323
+ throw new Error(
324
+ "Option " + key + " is not defined in the configuration template"
325
+ );
311
326
  }
312
327
  }
313
328
  if (erroredKeys.size > 0) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/config/Configuration.ts","../../src/config/ConfigurationBuilder.ts"],"sourcesContent":["import { ConfigurationFile, ConfigurationBuilder, BooleanOption, ConfigurationOption, ConfigurationOptionType, NumberOption, StringOption, isBooleanOption, isNumberOption, isStringOption } 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(config: DefiniteConfig, validate: boolean = true): [ 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 (this.definiteConfig[key] === null || this.definiteConfig[key] === undefined) {\n console.warn('Option ' + key + ' is not defined. Using default value Value: ' + this.definiteConfig[key]);\n this.definiteConfig[key] = this.storedConfigTemplate[key].defaultValue as string | number | boolean;\n }\n if (this.storedConfigTemplate[key].type !== typeof this.definiteConfig[key]) {\n throw new Error('Option ' + key + ' is not of the correct type');\n }\n\n const result = this.storedConfigTemplate[key].validate(this.definiteConfig[key]);\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]) {\n throw new Error('Option ' + key + ' is not defined in the configuration template');\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 (!this.definiteConfig[optionName] === null) {\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 (!this.definiteConfig[optionName] === null) {\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 (this.definiteConfig[optionName] === null) {\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 { ConfigurationFile, ConfigurationBuilder, BooleanOption, ConfigurationOption, ConfigurationOptionType, NumberOption, StringOption, isBooleanOption, isNumberOption, isStringOption };","import z, { ZodError } from \"zod\"\n\nexport interface ConfigurationFile {\n [key: string]: ConfigurationOption\n}\n\nconst configValidation = z.object({\n name: z.string().min(1),\n displayName: z.string().min(1),\n description: z.string().min(1),\n})\n\nexport function isStringOption(option: ConfigurationOption): option is StringOption {\n return option.type === 'string';\n }\n\nexport function isNumberOption(option: ConfigurationOption): option is NumberOption {\n return option.type === 'number';\n}\n\nexport function isBooleanOption(option: ConfigurationOption): option is BooleanOption {\n return option.type === 'boolean';\n}\n\nexport class ConfigurationBuilder {\n private options: ConfigurationOption[] = [];\n\n /**\n * Add a number option to the configuration builder and return the builder for chaining. You must provide a name, display name, and description for the option.\n * @param option { (option: NumberOption) => NumberOption }\n * @returns \n */\n public addNumberOption(option: (option: NumberOption) => NumberOption): ConfigurationBuilder {\n let newOption = new NumberOption();\n newOption = option(newOption);\n this.options.push(newOption);\n return this;\n }\n\n /**\n * Add a string option to the configuration builder and return the builder for chaining. You must provide a name, display name, and description for the option.\n * @param option { (option: StringOption) => StringOption }\n */\n public addStringOption(option: (option: StringOption) => StringOption) {\n let newOption = new StringOption();\n newOption = option(newOption);\n this.options.push(newOption);\n return this;\n }\n\n /**\n * Add a boolean option to the configuration builder and return the builder for chaining. You must provide a name, display name, and description for the option.\n * @param option { (option: BooleanOption) => BooleanOption }\n */\n public addBooleanOption(option: (option: BooleanOption) => BooleanOption) {\n let newOption = new BooleanOption();\n newOption = option(newOption);\n this.options.push(newOption);\n return this;\n }\n\n public build(includeFunctions: boolean): ConfigurationFile {\n let config: ConfigurationFile = {};\n this.options.forEach(option => {\n // remove all functions from the option object\n if (!includeFunctions) {\n option = JSON.parse(JSON.stringify(option));\n const optionData = configValidation.safeParse(option)\n if (!optionData.success) {\n throw new ZodError(optionData.error.errors)\n }\n\n config[option.name] = option;\n }\n else {\n config[option.name] = option;\n }\n });\n return config;\n }\n}\n\nexport type ConfigurationOptionType = 'string' | 'number' | 'boolean' | 'unset'\nexport class ConfigurationOption {\n public name: string = '';\n public defaultValue: unknown = '';\n public displayName: string = '';\n public description: string = '';\n public type: ConfigurationOptionType = 'unset'\n \n /**\n * Set the name of the option. **REQUIRED**\n * @param name {string} The name of the option. This is used to reference the option in the configuration file.\n */\n setName(name: string) {\n this.name = name;\n return this;\n }\n\n /**\n * Set the display name of the option. This is used to show the user a human readable version of what the option is. **REQUIRED** \n * @param displayName {string} The display name of the option. \n * @returns \n */\n setDisplayName(displayName: string) {\n this.displayName = displayName;\n return this;\n }\n\n /**\n * Set the description of the option. This is to show the user a brief description of what this option does. **REQUIRED**\n * @param description {string} The description of the option. \n * @returns \n */\n setDescription(description: string) {\n this.description = description;\n return this;\n }\n\n /**\n * Validation code for the option. This is called when the user provides input to the option. If the validation fails, the user will be prompted to provide input again.\n * @param input {unknown} The input to validate\n */\n validate(input: unknown): [ boolean, string ] {\n throw new Error('Validation code not implemented. Value: ' + input)\n };\n}\n\nexport class StringOption extends ConfigurationOption {\n public allowedValues: string[] = [];\n public minTextLength: number = 0;\n public maxTextLength: number = Number.MAX_SAFE_INTEGER;\n public defaultValue: string = '';\n public inputType: 'text' | 'file' | 'password' | 'folder' = 'text';\n public type: ConfigurationOptionType = 'string'\n\n /**\n * Set the allowed values for the string. If the array is empty, any value is allowed. When provided, the client will act like this option is a dropdown. \n * @param allowedValues {string[]} An array of allowed values for the string. If the array is empty, any value is allowed.\n */\n setAllowedValues(allowedValues: string[]): this {\n this.allowedValues = allowedValues;\n return this;\n }\n\n /**\n * Set the default value for the string. This value will be used if the user does not provide a value. **HIGHLY RECOMMENDED**\n * @param defaultValue {string} The default value for the string.\n */\n setDefaultValue(defaultValue: string): this {\n this.defaultValue = defaultValue;\n return this;\n }\n\n /**\n * Set the minimum text length for the string. If the user provides a string that is less than this value, the validation will fail. \n * @param minTextLength {number} The minimum text length for the string. \n */\n setMinTextLength(minTextLength: number): this {\n this.minTextLength = minTextLength;\n return this;\n }\n\n /**\n * Set the maximum text length for the string. If the user provides a string that is greater than this value, the validation will fail. \n * @param maxTextLength {number} The maximum text length for the string.\n */\n setMaxTextLength(maxTextLength: number): this {\n this.maxTextLength = maxTextLength;\n return this;\n }\n\n /**\n * Set the input type for the string. This will change how the client renders the input. \n * @param inputType {'text' | 'file' | 'password' | 'folder'} The input type for the string. \n */\n setInputType(inputType: 'text' | 'file' | 'password' | 'folder'): this {\n this.inputType = inputType;\n return this;\n }\n\n override validate(input: unknown): [ boolean, string ] {\n if (typeof input !== 'string') {\n return [ false, 'Input is not a string' ];\n }\n if (this.allowedValues.length === 0 && input.length !== 0)\n return [ true, '' ];\n if (input.length < this.minTextLength || input.length > this.maxTextLength) {\n return [ false, 'Input is not within the text length ' + this.minTextLength + ' and ' + this.maxTextLength + ' characters (currently ' + input.length + ' characters)' ];\n }\n\n return [ this.allowedValues.includes(input), 'Input is not an allowed value' ];\n }\n}\n\nexport class NumberOption extends ConfigurationOption {\n public min: number = 0;\n public max: number = Number.MAX_SAFE_INTEGER;\n public defaultValue: number = 0;\n public type: ConfigurationOptionType = 'number'\n public inputType: 'range' | 'number' = 'number';\n\n /**\n * Set the minimum value for the number. If the user provides a number that is less than this value, the validation will fail.\n * @param min {number} The minimum value for the number.\n */\n setMin(min: number): this {\n this.min = min;\n return this;\n }\n\n /**\n * Set the input type for the number. This will change how the client renders the input. \n * @param type {'range' | 'number'} The input type for the number. \n */\n setInputType(type: 'range' | 'number'): this {\n this.inputType = type;\n return this;\n }\n\n /**\n * Set the maximum value for the number. If the user provides a number that is greater than this value, the validation will fail.\n * @param max {number} The maximum value for the number.\n */\n setMax(max: number): this {\n this.max = max;\n return this\n }\n\n /**\n * Set the default value for the number. This value will be used if the user does not provide a value. **HIGHLY RECOMMENDED**\n * @param defaultValue {number} The default value for the number.\n */\n setDefaultValue(defaultValue: number): this {\n this.defaultValue = defaultValue;\n return this;\n }\n\n override validate(input: unknown): [ boolean, string ] {\n if (isNaN(Number(input))) {\n return [ false, 'Input is not a number' ];\n }\n if (Number(input) < this.min || Number(input) > this.max) {\n return [ false, 'Input is not within the range of ' + this.min + ' and ' + this.max ];\n }\n return [ true, '' ];\n }\n\n}\n\nexport class BooleanOption extends ConfigurationOption {\n public type: ConfigurationOptionType = 'boolean'\n public defaultValue: boolean = false;\n\n /**\n * Set the default value for the boolean. This value will be used if the user does not provide a value. **HIGHLY RECOMMENDED**\n * @param defaultValue {boolean} The default value for the boolean.\n */\n setDefaultValue(defaultValue: boolean): this {\n this.defaultValue = defaultValue;\n return this;\n }\n\n override validate(input: unknown): [ boolean, string ] {\n if (typeof input !== 'boolean') {\n return [ false, 'Input is not a boolean' ];\n }\n return [ true, '' ];\n }\n\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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 {"version":3,"sources":["../../src/config/Configuration.ts","../../src/config/ConfigurationBuilder.ts"],"sourcesContent":["import {\n ConfigurationFile,\n ConfigurationBuilder,\n BooleanOption,\n ConfigurationOption,\n ConfigurationOptionType,\n NumberOption,\n StringOption,\n isBooleanOption,\n isNumberOption,\n isStringOption,\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.definiteConfig[key]\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]) {\n throw new Error(\n 'Option ' + key + ' is not defined in the configuration template'\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 (!this.definiteConfig[optionName] === null) {\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 (!this.definiteConfig[optionName] === null) {\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 (this.definiteConfig[optionName] === null) {\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 ConfigurationFile,\n ConfigurationBuilder,\n BooleanOption,\n ConfigurationOption,\n ConfigurationOptionType,\n NumberOption,\n StringOption,\n isBooleanOption,\n isNumberOption,\n isStringOption,\n};\n","import z, { ZodError } from 'zod';\n\nexport interface ConfigurationFile {\n [key: string]: ConfigurationOption;\n}\n\nconst configValidation = z.object({\n name: z.string().min(1),\n displayName: z.string().min(1),\n description: z.string().min(1),\n});\n\nexport function isStringOption(\n option: ConfigurationOption\n): option is StringOption {\n return option.type === 'string';\n}\n\nexport function isNumberOption(\n option: ConfigurationOption\n): option is NumberOption {\n return option.type === 'number';\n}\n\nexport function isBooleanOption(\n option: ConfigurationOption\n): option is BooleanOption {\n return option.type === 'boolean';\n}\n\nexport class ConfigurationBuilder {\n private options: ConfigurationOption[] = [];\n\n /**\n * Add a number option to the configuration builder and return the builder for chaining. You must provide a name, display name, and description for the option.\n * @param option { (option: NumberOption) => NumberOption }\n * @returns\n */\n public addNumberOption(\n option: (option: NumberOption) => NumberOption\n ): ConfigurationBuilder {\n let newOption = new NumberOption();\n newOption = option(newOption);\n this.options.push(newOption);\n return this;\n }\n\n /**\n * Add a string option to the configuration builder and return the builder for chaining. You must provide a name, display name, and description for the option.\n * @param option { (option: StringOption) => StringOption }\n */\n public addStringOption(option: (option: StringOption) => StringOption) {\n let newOption = new StringOption();\n newOption = option(newOption);\n this.options.push(newOption);\n return this;\n }\n\n /**\n * Add a boolean option to the configuration builder and return the builder for chaining. You must provide a name, display name, and description for the option.\n * @param option { (option: BooleanOption) => BooleanOption }\n */\n public addBooleanOption(option: (option: BooleanOption) => BooleanOption) {\n let newOption = new BooleanOption();\n newOption = option(newOption);\n this.options.push(newOption);\n return this;\n }\n\n public build(includeFunctions: boolean): ConfigurationFile {\n let config: ConfigurationFile = {};\n this.options.forEach((option) => {\n // remove all functions from the option object\n if (!includeFunctions) {\n option = JSON.parse(JSON.stringify(option));\n const optionData = configValidation.safeParse(option);\n if (!optionData.success) {\n throw new ZodError(optionData.error.errors);\n }\n\n config[option.name] = option;\n } else {\n config[option.name] = option;\n }\n });\n return config;\n }\n}\n\nexport type ConfigurationOptionType = 'string' | 'number' | 'boolean' | 'unset';\nexport class ConfigurationOption {\n public name: string = '';\n public defaultValue: unknown = '';\n public displayName: string = '';\n public description: string = '';\n public type: ConfigurationOptionType = 'unset';\n\n /**\n * Set the name of the option. **REQUIRED**\n * @param name {string} The name of the option. This is used to reference the option in the configuration file.\n */\n setName(name: string) {\n this.name = name;\n return this;\n }\n\n /**\n * Set the display name of the option. This is used to show the user a human readable version of what the option is. **REQUIRED**\n * @param displayName {string} The display name of the option.\n * @returns\n */\n setDisplayName(displayName: string) {\n this.displayName = displayName;\n return this;\n }\n\n /**\n * Set the description of the option. This is to show the user a brief description of what this option does. **REQUIRED**\n * @param description {string} The description of the option.\n * @returns\n */\n setDescription(description: string) {\n this.description = description;\n return this;\n }\n\n /**\n * Validation code for the option. This is called when the user provides input to the option. If the validation fails, the user will be prompted to provide input again.\n * @param input {unknown} The input to validate\n */\n validate(input: unknown): [boolean, string] {\n throw new Error('Validation code not implemented. Value: ' + input);\n }\n}\n\nexport class StringOption extends ConfigurationOption {\n public allowedValues: string[] = [];\n public minTextLength: number = 0;\n public maxTextLength: number = Number.MAX_SAFE_INTEGER;\n public defaultValue: string = '';\n public inputType: 'text' | 'file' | 'password' | 'folder' = 'text';\n public type: ConfigurationOptionType = 'string';\n\n /**\n * Set the allowed values for the string. If the array is empty, any value is allowed. When provided, the client will act like this option is a dropdown.\n * @param allowedValues {string[]} An array of allowed values for the string. If the array is empty, any value is allowed.\n */\n setAllowedValues(allowedValues: string[]): this {\n this.allowedValues = allowedValues;\n return this;\n }\n\n /**\n * Set the default value for the string. This value will be used if the user does not provide a value. **HIGHLY RECOMMENDED**\n * @param defaultValue {string} The default value for the string.\n */\n setDefaultValue(defaultValue: string): this {\n this.defaultValue = defaultValue;\n return this;\n }\n\n /**\n * Set the minimum text length for the string. If the user provides a string that is less than this value, the validation will fail.\n * @param minTextLength {number} The minimum text length for the string.\n */\n setMinTextLength(minTextLength: number): this {\n this.minTextLength = minTextLength;\n return this;\n }\n\n /**\n * Set the maximum text length for the string. If the user provides a string that is greater than this value, the validation will fail.\n * @param maxTextLength {number} The maximum text length for the string.\n */\n setMaxTextLength(maxTextLength: number): this {\n this.maxTextLength = maxTextLength;\n return this;\n }\n\n /**\n * Set the input type for the string. This will change how the client renders the input.\n * @param inputType {'text' | 'file' | 'password' | 'folder'} The input type for the string.\n */\n setInputType(inputType: 'text' | 'file' | 'password' | 'folder'): this {\n this.inputType = inputType;\n return this;\n }\n\n override validate(input: unknown): [boolean, string] {\n if (typeof input !== 'string') {\n return [false, 'Input is not a string'];\n }\n if (this.allowedValues.length === 0 && input.length !== 0)\n return [true, ''];\n if (\n input.length < this.minTextLength ||\n input.length > this.maxTextLength\n ) {\n return [\n false,\n 'Input is not within the text length ' +\n this.minTextLength +\n ' and ' +\n this.maxTextLength +\n ' characters (currently ' +\n input.length +\n ' characters)',\n ];\n }\n\n return [\n this.allowedValues.includes(input),\n 'Input is not an allowed value',\n ];\n }\n}\n\nexport class NumberOption extends ConfigurationOption {\n public min: number = 0;\n public max: number = Number.MAX_SAFE_INTEGER;\n public defaultValue: number = 0;\n public type: ConfigurationOptionType = 'number';\n public inputType: 'range' | 'number' = 'number';\n\n /**\n * Set the minimum value for the number. If the user provides a number that is less than this value, the validation will fail.\n * @param min {number} The minimum value for the number.\n */\n setMin(min: number): this {\n this.min = min;\n return this;\n }\n\n /**\n * Set the input type for the number. This will change how the client renders the input.\n * @param type {'range' | 'number'} The input type for the number.\n */\n setInputType(type: 'range' | 'number'): this {\n this.inputType = type;\n return this;\n }\n\n /**\n * Set the maximum value for the number. If the user provides a number that is greater than this value, the validation will fail.\n * @param max {number} The maximum value for the number.\n */\n setMax(max: number): this {\n this.max = max;\n return this;\n }\n\n /**\n * Set the default value for the number. This value will be used if the user does not provide a value. **HIGHLY RECOMMENDED**\n * @param defaultValue {number} The default value for the number.\n */\n setDefaultValue(defaultValue: number): this {\n this.defaultValue = defaultValue;\n return this;\n }\n\n override validate(input: unknown): [boolean, string] {\n if (isNaN(Number(input))) {\n return [false, 'Input is not a number'];\n }\n if (Number(input) < this.min || Number(input) > this.max) {\n return [\n false,\n 'Input is not within the range of ' + this.min + ' and ' + this.max,\n ];\n }\n return [true, ''];\n }\n}\n\nexport class BooleanOption extends ConfigurationOption {\n public type: ConfigurationOptionType = 'boolean';\n public defaultValue: boolean = false;\n\n /**\n * Set the default value for the boolean. This value will be used if the user does not provide a value. **HIGHLY RECOMMENDED**\n * @param defaultValue {boolean} The default value for the boolean.\n */\n setDefaultValue(defaultValue: boolean): this {\n this.defaultValue = defaultValue;\n return this;\n }\n\n override validate(input: unknown): [boolean, string] {\n if (typeof input !== 'boolean') {\n return [false, 'Input is not a boolean'];\n }\n return [true, ''];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iBAA4B;AAM5B,IAAM,mBAAmB,WAAAA,QAAE,OAAO;AAAA,EAChC,MAAM,WAAAA,QAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACtB,aAAa,WAAAA,QAA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B,GAAG,GAAG;AACnC,cAAM,IAAI;AAAA,UACR,YAAY,MAAM;AAAA,QACpB;AAAA,MACF;AAAA,IACF;AAEA,QAAI,YAAY,OAAO,GAAG;AACxB,aAAO,CAAC,OAAO,OAAO,YAAY,WAAW,CAAC;AAAA,IAChD;AAEA,WAAO,CAAC,MAAM,OAAO,YAAY,WAAW,CAAC;AAAA,EAC/C;AAAA,EAEA,eAAe,YAA4B;AACzC,QAAI,CAAC,KAAK,eAAe,UAAU,MAAM,MAAM;AAC7C,YAAM,IAAI,MAAM,YAAY,aAAa,iBAAiB;AAAA,IAC5D;AACA,QAAI,OAAO,KAAK,eAAe,UAAU,MAAM,UAAU;AACvD,YAAM,IAAI,MAAM,YAAY,aAAa,kBAAkB;AAAA,IAC7D;AACA,WAAO,KAAK,eAAe,UAAU;AAAA,EACvC;AAAA,EAEA,eAAe,YAA4B;AACzC,QAAI,CAAC,KAAK,eAAe,UAAU,MAAM,MAAM;AAC7C,YAAM,IAAI,MAAM,YAAY,aAAa,iBAAiB;AAAA,IAC5D;AACA,QAAI,OAAO,KAAK,eAAe,UAAU,MAAM,UAAU;AACvD,YAAM,IAAI,MAAM,YAAY,aAAa,kBAAkB;AAAA,IAC7D;AACA,WAAO,KAAK,eAAe,UAAU;AAAA,EACvC;AAAA,EAEA,gBAAgB,YAA6B;AAC3C,QAAI,KAAK,eAAe,UAAU,MAAM,MAAM;AAC5C,YAAM,IAAI,MAAM,YAAY,aAAa,iBAAiB;AAAA,IAC5D;AACA,QAAI,OAAO,KAAK,eAAe,UAAU,MAAM,WAAW;AACxD,YAAM,IAAI,MAAM,YAAY,aAAa,mBAAmB;AAAA,IAC9D;AACA,WAAO,KAAK,eAAe,UAAU;AAAA,EACvC;AACF;","names":["z"]}
@@ -19,7 +19,7 @@ var ConfigurationBuilder = class {
19
19
  /**
20
20
  * Add a number option to the configuration builder and return the builder for chaining. You must provide a name, display name, and description for the option.
21
21
  * @param option { (option: NumberOption) => NumberOption }
22
- * @returns
22
+ * @returns
23
23
  */
24
24
  addNumberOption(option) {
25
25
  let newOption = new NumberOption();
@@ -30,7 +30,7 @@ var ConfigurationBuilder = class {
30
30
  /**
31
31
  * Add a string option to the configuration builder and return the builder for chaining. You must provide a name, display name, and description for the option.
32
32
  * @param option { (option: StringOption) => StringOption }
33
- */
33
+ */
34
34
  addStringOption(option) {
35
35
  let newOption = new StringOption();
36
36
  newOption = option(newOption);
@@ -40,7 +40,7 @@ var ConfigurationBuilder = class {
40
40
  /**
41
41
  * Add a boolean option to the configuration builder and return the builder for chaining. You must provide a name, display name, and description for the option.
42
42
  * @param option { (option: BooleanOption) => BooleanOption }
43
- */
43
+ */
44
44
  addBooleanOption(option) {
45
45
  let newOption = new BooleanOption();
46
46
  newOption = option(newOption);
@@ -79,9 +79,9 @@ var ConfigurationOption = class {
79
79
  return this;
80
80
  }
81
81
  /**
82
- * Set the display name of the option. This is used to show the user a human readable version of what the option is. **REQUIRED**
83
- * @param displayName {string} The display name of the option.
84
- * @returns
82
+ * Set the display name of the option. This is used to show the user a human readable version of what the option is. **REQUIRED**
83
+ * @param displayName {string} The display name of the option.
84
+ * @returns
85
85
  */
86
86
  setDisplayName(displayName) {
87
87
  this.displayName = displayName;
@@ -89,8 +89,8 @@ var ConfigurationOption = class {
89
89
  }
90
90
  /**
91
91
  * Set the description of the option. This is to show the user a brief description of what this option does. **REQUIRED**
92
- * @param description {string} The description of the option.
93
- * @returns
92
+ * @param description {string} The description of the option.
93
+ * @returns
94
94
  */
95
95
  setDescription(description) {
96
96
  this.description = description;
@@ -112,7 +112,7 @@ var StringOption = class extends ConfigurationOption {
112
112
  inputType = "text";
113
113
  type = "string";
114
114
  /**
115
- * Set the allowed values for the string. If the array is empty, any value is allowed. When provided, the client will act like this option is a dropdown.
115
+ * Set the allowed values for the string. If the array is empty, any value is allowed. When provided, the client will act like this option is a dropdown.
116
116
  * @param allowedValues {string[]} An array of allowed values for the string. If the array is empty, any value is allowed.
117
117
  */
118
118
  setAllowedValues(allowedValues) {
@@ -128,15 +128,15 @@ var StringOption = class extends ConfigurationOption {
128
128
  return this;
129
129
  }
130
130
  /**
131
- * Set the minimum text length for the string. If the user provides a string that is less than this value, the validation will fail.
132
- * @param minTextLength {number} The minimum text length for the string.
131
+ * Set the minimum text length for the string. If the user provides a string that is less than this value, the validation will fail.
132
+ * @param minTextLength {number} The minimum text length for the string.
133
133
  */
134
134
  setMinTextLength(minTextLength) {
135
135
  this.minTextLength = minTextLength;
136
136
  return this;
137
137
  }
138
138
  /**
139
- * Set the maximum text length for the string. If the user provides a string that is greater than this value, the validation will fail.
139
+ * Set the maximum text length for the string. If the user provides a string that is greater than this value, the validation will fail.
140
140
  * @param maxTextLength {number} The maximum text length for the string.
141
141
  */
142
142
  setMaxTextLength(maxTextLength) {
@@ -144,8 +144,8 @@ var StringOption = class extends ConfigurationOption {
144
144
  return this;
145
145
  }
146
146
  /**
147
- * Set the input type for the string. This will change how the client renders the input.
148
- * @param inputType {'text' | 'file' | 'password' | 'folder'} The input type for the string.
147
+ * Set the input type for the string. This will change how the client renders the input.
148
+ * @param inputType {'text' | 'file' | 'password' | 'folder'} The input type for the string.
149
149
  */
150
150
  setInputType(inputType) {
151
151
  this.inputType = inputType;
@@ -158,9 +158,15 @@ var StringOption = class extends ConfigurationOption {
158
158
  if (this.allowedValues.length === 0 && input.length !== 0)
159
159
  return [true, ""];
160
160
  if (input.length < this.minTextLength || input.length > this.maxTextLength) {
161
- return [false, "Input is not within the text length " + this.minTextLength + " and " + this.maxTextLength + " characters (currently " + input.length + " characters)"];
161
+ return [
162
+ false,
163
+ "Input is not within the text length " + this.minTextLength + " and " + this.maxTextLength + " characters (currently " + input.length + " characters)"
164
+ ];
162
165
  }
163
- return [this.allowedValues.includes(input), "Input is not an allowed value"];
166
+ return [
167
+ this.allowedValues.includes(input),
168
+ "Input is not an allowed value"
169
+ ];
164
170
  }
165
171
  };
166
172
  var NumberOption = class extends ConfigurationOption {
@@ -178,8 +184,8 @@ var NumberOption = class extends ConfigurationOption {
178
184
  return this;
179
185
  }
180
186
  /**
181
- * Set the input type for the number. This will change how the client renders the input.
182
- * @param type {'range' | 'number'} The input type for the number.
187
+ * Set the input type for the number. This will change how the client renders the input.
188
+ * @param type {'range' | 'number'} The input type for the number.
183
189
  */
184
190
  setInputType(type) {
185
191
  this.inputType = type;
@@ -206,7 +212,10 @@ var NumberOption = class extends ConfigurationOption {
206
212
  return [false, "Input is not a number"];
207
213
  }
208
214
  if (Number(input) < this.min || Number(input) > this.max) {
209
- return [false, "Input is not within the range of " + this.min + " and " + this.max];
215
+ return [
216
+ false,
217
+ "Input is not within the range of " + this.min + " and " + this.max
218
+ ];
210
219
  }
211
220
  return [true, ""];
212
221
  }
@@ -250,20 +259,26 @@ var Configuration = class {
250
259
  const erroredKeys = /* @__PURE__ */ new Map();
251
260
  for (const key in this.storedConfigTemplate) {
252
261
  if (this.definiteConfig[key] === null || this.definiteConfig[key] === void 0) {
253
- console.warn("Option " + key + " is not defined. Using default value Value: " + this.definiteConfig[key]);
262
+ console.warn(
263
+ "Option " + key + " is not defined. Using default value Value: " + this.definiteConfig[key]
264
+ );
254
265
  this.definiteConfig[key] = this.storedConfigTemplate[key].defaultValue;
255
266
  }
256
267
  if (this.storedConfigTemplate[key].type !== typeof this.definiteConfig[key]) {
257
268
  throw new Error("Option " + key + " is not of the correct type");
258
269
  }
259
- const result = this.storedConfigTemplate[key].validate(this.definiteConfig[key]);
270
+ const result = this.storedConfigTemplate[key].validate(
271
+ this.definiteConfig[key]
272
+ );
260
273
  if (!result[0]) {
261
274
  erroredKeys.set(key, result[1]);
262
275
  }
263
276
  }
264
277
  for (const key in this.definiteConfig) {
265
278
  if (!this.storedConfigTemplate[key]) {
266
- throw new Error("Option " + key + " is not defined in the configuration template");
279
+ throw new Error(
280
+ "Option " + key + " is not defined in the configuration template"
281
+ );
267
282
  }
268
283
  }
269
284
  if (erroredKeys.size > 0) {