ogi-addon 1.9.3 → 1.9.5

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 (58) hide show
  1. package/build/Configuration-CdRZbO6z.d.mts +21 -0
  2. package/build/Configuration-WeOm-F0_.d.cts +21 -0
  3. package/build/ConfigurationBuilder-BSuJ4rSI.cjs +302 -0
  4. package/build/ConfigurationBuilder-BSuJ4rSI.cjs.map +1 -0
  5. package/build/ConfigurationBuilder-BbZDA_xx.d.mts +132 -0
  6. package/build/ConfigurationBuilder-CfHLKMTO.d.cts +132 -0
  7. package/build/EventResponse-CQhmdz3C.d.mts +430 -0
  8. package/build/EventResponse-D1c-Df5W.d.cts +430 -0
  9. package/build/EventResponse.cjs +55 -79
  10. package/build/EventResponse.cjs.map +1 -1
  11. package/build/EventResponse.d.cts +2 -45
  12. package/build/EventResponse.d.mts +2 -0
  13. package/build/EventResponse.mjs +58 -0
  14. package/build/EventResponse.mjs.map +1 -0
  15. package/build/SearchEngine-CRQWXfo6.d.mts +22 -0
  16. package/build/SearchEngine-DBSUNM4A.d.cts +22 -0
  17. package/build/SearchEngine.cjs +0 -19
  18. package/build/SearchEngine.d.cts +2 -20
  19. package/build/SearchEngine.d.mts +2 -0
  20. package/build/SearchEngine.mjs +1 -0
  21. package/build/config/Configuration.cjs +56 -370
  22. package/build/config/Configuration.cjs.map +1 -1
  23. package/build/config/Configuration.d.cts +3 -20
  24. package/build/config/Configuration.d.mts +3 -0
  25. package/build/config/Configuration.mjs +52 -0
  26. package/build/config/Configuration.mjs.map +1 -0
  27. package/build/config/ConfigurationBuilder.cjs +9 -292
  28. package/build/config/ConfigurationBuilder.d.cts +2 -130
  29. package/build/config/ConfigurationBuilder.d.mts +2 -0
  30. package/build/config/ConfigurationBuilder.mjs +221 -0
  31. package/build/config/ConfigurationBuilder.mjs.map +1 -0
  32. package/build/main.cjs +510 -1074
  33. package/build/main.cjs.map +1 -1
  34. package/build/main.d.cts +5 -387
  35. package/build/main.d.mts +5 -0
  36. package/build/main.mjs +510 -0
  37. package/build/main.mjs.map +1 -0
  38. package/package.json +9 -9
  39. package/src/config/Configuration.ts +18 -7
  40. package/src/main.ts +4 -3
  41. package/{tsup.config.js → tsdown.config.js} +2 -1
  42. package/build/EventResponse.d.ts +0 -45
  43. package/build/EventResponse.js +0 -62
  44. package/build/EventResponse.js.map +0 -1
  45. package/build/SearchEngine.cjs.map +0 -1
  46. package/build/SearchEngine.d.ts +0 -20
  47. package/build/SearchEngine.js +0 -1
  48. package/build/SearchEngine.js.map +0 -1
  49. package/build/config/Configuration.d.ts +0 -20
  50. package/build/config/Configuration.js +0 -329
  51. package/build/config/Configuration.js.map +0 -1
  52. package/build/config/ConfigurationBuilder.cjs.map +0 -1
  53. package/build/config/ConfigurationBuilder.d.ts +0 -130
  54. package/build/config/ConfigurationBuilder.js +0 -251
  55. package/build/config/ConfigurationBuilder.js.map +0 -1
  56. package/build/main.d.ts +0 -387
  57. package/build/main.js +0 -1045
  58. package/build/main.js.map +0 -1
@@ -1,20 +1,3 @@
1
- import { ConfigurationFile } from './ConfigurationBuilder.cjs';
2
- export { BooleanOption, ConfigurationBuilder, ConfigurationOption, ConfigurationOptionType, NumberOption, StringOption, isBooleanOption, isNumberOption, isStringOption } from './ConfigurationBuilder.cjs';
3
-
4
- interface DefiniteConfig {
5
- [key: string]: string | number | boolean;
6
- }
7
- declare class Configuration {
8
- readonly storedConfigTemplate: ConfigurationFile;
9
- definiteConfig: DefiniteConfig;
10
- constructor(configTemplate: ConfigurationFile);
11
- updateConfig(config: DefiniteConfig, validate?: boolean): [boolean, {
12
- [key: string]: string;
13
- }];
14
- private validateConfig;
15
- getStringValue(optionName: string): string;
16
- getNumberValue(optionName: string): number;
17
- getBooleanValue(optionName: string): boolean;
18
- }
19
-
20
- export { Configuration, ConfigurationFile };
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 };
@@ -0,0 +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 };
@@ -0,0 +1,52 @@
1
+ import { BooleanOption, ConfigurationBuilder, ConfigurationOption, NumberOption, StringOption, isBooleanOption, isNumberOption, isStringOption } from "./ConfigurationBuilder.mjs";
2
+
3
+ //#region src/config/Configuration.ts
4
+ var Configuration = class {
5
+ storedConfigTemplate;
6
+ definiteConfig = {};
7
+ constructor(configTemplate) {
8
+ this.storedConfigTemplate = configTemplate;
9
+ }
10
+ updateConfig(config, validate = true) {
11
+ this.definiteConfig = config;
12
+ if (validate) return this.validateConfig();
13
+ return [true, {}];
14
+ }
15
+ validateConfig() {
16
+ const erroredKeys = /* @__PURE__ */ new Map();
17
+ for (const key in this.storedConfigTemplate) {
18
+ if (this.definiteConfig[key] === null || this.definiteConfig[key] === void 0) {
19
+ console.warn("Option " + key + " is not defined. Using default value Value: " + this.storedConfigTemplate[key].defaultValue);
20
+ this.definiteConfig[key] = this.storedConfigTemplate[key].defaultValue;
21
+ }
22
+ if (this.storedConfigTemplate[key].type !== typeof this.definiteConfig[key]) throw new Error("Option " + key + " is not of the correct type");
23
+ const result = this.storedConfigTemplate[key].validate(this.definiteConfig[key]);
24
+ if (!result[0]) erroredKeys.set(key, result[1]);
25
+ }
26
+ for (const key in this.definiteConfig) if (this.storedConfigTemplate[key] === void 0) {
27
+ delete this.definiteConfig[key];
28
+ console.warn("Option " + key + " is not defined in the configuration template. Removing from config.");
29
+ }
30
+ if (erroredKeys.size > 0) return [false, Object.fromEntries(erroredKeys)];
31
+ return [true, Object.fromEntries(erroredKeys)];
32
+ }
33
+ getStringValue(optionName) {
34
+ if (this.definiteConfig[optionName] === null || this.definiteConfig[optionName] === void 0) throw new Error("Option " + optionName + " is not defined");
35
+ if (typeof this.definiteConfig[optionName] !== "string") throw new Error("Option " + optionName + " is not a string");
36
+ return this.definiteConfig[optionName];
37
+ }
38
+ getNumberValue(optionName) {
39
+ if (this.definiteConfig[optionName] === null || this.definiteConfig[optionName] === void 0) throw new Error("Option " + optionName + " is not defined");
40
+ if (typeof this.definiteConfig[optionName] !== "number") throw new Error("Option " + optionName + " is not a number");
41
+ return this.definiteConfig[optionName];
42
+ }
43
+ getBooleanValue(optionName) {
44
+ if (this.definiteConfig[optionName] === null || this.definiteConfig[optionName] === void 0) throw new Error("Option " + optionName + " is not defined");
45
+ if (typeof this.definiteConfig[optionName] !== "boolean") throw new Error("Option " + optionName + " is not a boolean");
46
+ return this.definiteConfig[optionName];
47
+ }
48
+ };
49
+
50
+ //#endregion
51
+ export { BooleanOption, Configuration, ConfigurationBuilder, ConfigurationOption, NumberOption, StringOption, isBooleanOption, isNumberOption, isStringOption };
52
+ //# sourceMappingURL=Configuration.mjs.map
@@ -0,0 +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,293 +1,10 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ const require_ConfigurationBuilder = require('../ConfigurationBuilder-BSuJ4rSI.cjs');
29
2
 
30
- // src/config/ConfigurationBuilder.ts
31
- var ConfigurationBuilder_exports = {};
32
- __export(ConfigurationBuilder_exports, {
33
- BooleanOption: () => BooleanOption,
34
- ConfigurationBuilder: () => ConfigurationBuilder,
35
- ConfigurationOption: () => ConfigurationOption,
36
- NumberOption: () => NumberOption,
37
- StringOption: () => StringOption,
38
- isBooleanOption: () => isBooleanOption,
39
- isNumberOption: () => isNumberOption,
40
- isStringOption: () => isStringOption
41
- });
42
- module.exports = __toCommonJS(ConfigurationBuilder_exports);
43
- var import_zod = __toESM(require("zod"), 1);
44
- var configValidation = import_zod.default.object({
45
- name: import_zod.default.string().min(1),
46
- displayName: import_zod.default.string().min(1),
47
- description: import_zod.default.string().min(1)
48
- });
49
- function isStringOption(option) {
50
- return option.type === "string";
51
- }
52
- function isNumberOption(option) {
53
- return option.type === "number";
54
- }
55
- function isBooleanOption(option) {
56
- return option.type === "boolean";
57
- }
58
- var ConfigurationBuilder = class {
59
- options = [];
60
- /**
61
- * 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.
62
- * @param option { (option: NumberOption) => NumberOption }
63
- * @returns
64
- */
65
- addNumberOption(option) {
66
- let newOption = new NumberOption();
67
- newOption = option(newOption);
68
- this.options.push(newOption);
69
- return this;
70
- }
71
- /**
72
- * 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.
73
- * @param option { (option: StringOption) => StringOption }
74
- */
75
- addStringOption(option) {
76
- let newOption = new StringOption();
77
- newOption = option(newOption);
78
- this.options.push(newOption);
79
- return this;
80
- }
81
- /**
82
- * 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.
83
- * @param option { (option: BooleanOption) => BooleanOption }
84
- */
85
- addBooleanOption(option) {
86
- let newOption = new BooleanOption();
87
- newOption = option(newOption);
88
- this.options.push(newOption);
89
- return this;
90
- }
91
- build(includeFunctions) {
92
- let config = {};
93
- this.options.forEach((option) => {
94
- if (!includeFunctions) {
95
- option = JSON.parse(JSON.stringify(option));
96
- const optionData = configValidation.safeParse(option);
97
- if (!optionData.success) {
98
- throw new import_zod.ZodError(optionData.error.errors);
99
- }
100
- config[option.name] = option;
101
- } else {
102
- config[option.name] = option;
103
- }
104
- });
105
- return config;
106
- }
107
- };
108
- var ConfigurationOption = class {
109
- name = "";
110
- defaultValue = "";
111
- displayName = "";
112
- description = "";
113
- type = "unset";
114
- /**
115
- * Set the name of the option. **REQUIRED**
116
- * @param name {string} The name of the option. This is used to reference the option in the configuration file.
117
- */
118
- setName(name) {
119
- this.name = name;
120
- return this;
121
- }
122
- /**
123
- * Set the display name of the option. This is used to show the user a human readable version of what the option is. **REQUIRED**
124
- * @param displayName {string} The display name of the option.
125
- * @returns
126
- */
127
- setDisplayName(displayName) {
128
- this.displayName = displayName;
129
- return this;
130
- }
131
- /**
132
- * Set the description of the option. This is to show the user a brief description of what this option does. **REQUIRED**
133
- * @param description {string} The description of the option.
134
- * @returns
135
- */
136
- setDescription(description) {
137
- this.description = description;
138
- return this;
139
- }
140
- /**
141
- * 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.
142
- * @param input {unknown} The input to validate
143
- */
144
- validate(input) {
145
- throw new Error("Validation code not implemented. Value: " + input);
146
- }
147
- };
148
- var StringOption = class extends ConfigurationOption {
149
- allowedValues = [];
150
- minTextLength = 0;
151
- maxTextLength = Number.MAX_SAFE_INTEGER;
152
- defaultValue = "";
153
- inputType = "text";
154
- type = "string";
155
- /**
156
- * 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.
157
- * @param allowedValues {string[]} An array of allowed values for the string. If the array is empty, any value is allowed.
158
- */
159
- setAllowedValues(allowedValues) {
160
- this.allowedValues = allowedValues;
161
- return this;
162
- }
163
- /**
164
- * Set the default value for the string. This value will be used if the user does not provide a value. **HIGHLY RECOMMENDED**
165
- * @param defaultValue {string} The default value for the string.
166
- */
167
- setDefaultValue(defaultValue) {
168
- this.defaultValue = defaultValue;
169
- return this;
170
- }
171
- /**
172
- * Set the minimum text length for the string. If the user provides a string that is less than this value, the validation will fail.
173
- * @param minTextLength {number} The minimum text length for the string.
174
- */
175
- setMinTextLength(minTextLength) {
176
- this.minTextLength = minTextLength;
177
- return this;
178
- }
179
- /**
180
- * Set the maximum text length for the string. If the user provides a string that is greater than this value, the validation will fail.
181
- * @param maxTextLength {number} The maximum text length for the string.
182
- */
183
- setMaxTextLength(maxTextLength) {
184
- this.maxTextLength = maxTextLength;
185
- return this;
186
- }
187
- /**
188
- * Set the input type for the string. This will change how the client renders the input.
189
- * @param inputType {'text' | 'file' | 'password' | 'folder'} The input type for the string.
190
- */
191
- setInputType(inputType) {
192
- this.inputType = inputType;
193
- return this;
194
- }
195
- validate(input) {
196
- if (typeof input !== "string") {
197
- return [false, "Input is not a string"];
198
- }
199
- if (this.allowedValues.length === 0 && input.length !== 0)
200
- return [true, ""];
201
- if (input.length < this.minTextLength || input.length > this.maxTextLength) {
202
- return [
203
- false,
204
- "Input is not within the text length " + this.minTextLength + " and " + this.maxTextLength + " characters (currently " + input.length + " characters)"
205
- ];
206
- }
207
- return [
208
- this.allowedValues.includes(input),
209
- "Input is not an allowed value"
210
- ];
211
- }
212
- };
213
- var NumberOption = class extends ConfigurationOption {
214
- min = 0;
215
- max = Number.MAX_SAFE_INTEGER;
216
- defaultValue = 0;
217
- type = "number";
218
- inputType = "number";
219
- /**
220
- * Set the minimum value for the number. If the user provides a number that is less than this value, the validation will fail.
221
- * @param min {number} The minimum value for the number.
222
- */
223
- setMin(min) {
224
- this.min = min;
225
- return this;
226
- }
227
- /**
228
- * Set the input type for the number. This will change how the client renders the input.
229
- * @param type {'range' | 'number'} The input type for the number.
230
- */
231
- setInputType(type) {
232
- this.inputType = type;
233
- return this;
234
- }
235
- /**
236
- * Set the maximum value for the number. If the user provides a number that is greater than this value, the validation will fail.
237
- * @param max {number} The maximum value for the number.
238
- */
239
- setMax(max) {
240
- this.max = max;
241
- return this;
242
- }
243
- /**
244
- * Set the default value for the number. This value will be used if the user does not provide a value. **HIGHLY RECOMMENDED**
245
- * @param defaultValue {number} The default value for the number.
246
- */
247
- setDefaultValue(defaultValue) {
248
- this.defaultValue = defaultValue;
249
- return this;
250
- }
251
- validate(input) {
252
- if (isNaN(Number(input))) {
253
- return [false, "Input is not a number"];
254
- }
255
- if (Number(input) < this.min || Number(input) > this.max) {
256
- return [
257
- false,
258
- "Input is not within the range of " + this.min + " and " + this.max
259
- ];
260
- }
261
- return [true, ""];
262
- }
263
- };
264
- var BooleanOption = class extends ConfigurationOption {
265
- type = "boolean";
266
- defaultValue = false;
267
- /**
268
- * Set the default value for the boolean. This value will be used if the user does not provide a value. **HIGHLY RECOMMENDED**
269
- * @param defaultValue {boolean} The default value for the boolean.
270
- */
271
- setDefaultValue(defaultValue) {
272
- this.defaultValue = defaultValue;
273
- return this;
274
- }
275
- validate(input) {
276
- if (typeof input !== "boolean") {
277
- return [false, "Input is not a boolean"];
278
- }
279
- return [true, ""];
280
- }
281
- };
282
- // Annotate the CommonJS export names for ESM import in node:
283
- 0 && (module.exports = {
284
- BooleanOption,
285
- ConfigurationBuilder,
286
- ConfigurationOption,
287
- NumberOption,
288
- StringOption,
289
- isBooleanOption,
290
- isNumberOption,
291
- isStringOption
292
- });
293
- //# sourceMappingURL=ConfigurationBuilder.cjs.map
3
+ exports.BooleanOption = require_ConfigurationBuilder.BooleanOption;
4
+ exports.ConfigurationBuilder = require_ConfigurationBuilder.ConfigurationBuilder;
5
+ exports.ConfigurationOption = require_ConfigurationBuilder.ConfigurationOption;
6
+ exports.NumberOption = require_ConfigurationBuilder.NumberOption;
7
+ exports.StringOption = require_ConfigurationBuilder.StringOption;
8
+ exports.isBooleanOption = require_ConfigurationBuilder.isBooleanOption;
9
+ exports.isNumberOption = require_ConfigurationBuilder.isNumberOption;
10
+ exports.isStringOption = require_ConfigurationBuilder.isStringOption;
@@ -1,130 +1,2 @@
1
- interface ConfigurationFile {
2
- [key: string]: ConfigurationOption;
3
- }
4
- declare function isStringOption(option: ConfigurationOption): option is StringOption;
5
- declare function isNumberOption(option: ConfigurationOption): option is NumberOption;
6
- declare function isBooleanOption(option: ConfigurationOption): option is BooleanOption;
7
- declare class ConfigurationBuilder {
8
- private options;
9
- /**
10
- * 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.
11
- * @param option { (option: NumberOption) => NumberOption }
12
- * @returns
13
- */
14
- addNumberOption(option: (option: NumberOption) => NumberOption): ConfigurationBuilder;
15
- /**
16
- * 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.
17
- * @param option { (option: StringOption) => StringOption }
18
- */
19
- addStringOption(option: (option: StringOption) => StringOption): this;
20
- /**
21
- * 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.
22
- * @param option { (option: BooleanOption) => BooleanOption }
23
- */
24
- addBooleanOption(option: (option: BooleanOption) => BooleanOption): this;
25
- build(includeFunctions: boolean): ConfigurationFile;
26
- }
27
- type ConfigurationOptionType = 'string' | 'number' | 'boolean' | 'unset';
28
- declare class ConfigurationOption {
29
- name: string;
30
- defaultValue: unknown;
31
- displayName: string;
32
- description: string;
33
- type: ConfigurationOptionType;
34
- /**
35
- * Set the name of the option. **REQUIRED**
36
- * @param name {string} The name of the option. This is used to reference the option in the configuration file.
37
- */
38
- setName(name: string): this;
39
- /**
40
- * Set the display name of the option. This is used to show the user a human readable version of what the option is. **REQUIRED**
41
- * @param displayName {string} The display name of the option.
42
- * @returns
43
- */
44
- setDisplayName(displayName: string): this;
45
- /**
46
- * Set the description of the option. This is to show the user a brief description of what this option does. **REQUIRED**
47
- * @param description {string} The description of the option.
48
- * @returns
49
- */
50
- setDescription(description: string): this;
51
- /**
52
- * 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.
53
- * @param input {unknown} The input to validate
54
- */
55
- validate(input: unknown): [boolean, string];
56
- }
57
- declare class StringOption extends ConfigurationOption {
58
- allowedValues: string[];
59
- minTextLength: number;
60
- maxTextLength: number;
61
- defaultValue: string;
62
- inputType: 'text' | 'file' | 'password' | 'folder';
63
- type: ConfigurationOptionType;
64
- /**
65
- * 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.
66
- * @param allowedValues {string[]} An array of allowed values for the string. If the array is empty, any value is allowed.
67
- */
68
- setAllowedValues(allowedValues: string[]): this;
69
- /**
70
- * Set the default value for the string. This value will be used if the user does not provide a value. **HIGHLY RECOMMENDED**
71
- * @param defaultValue {string} The default value for the string.
72
- */
73
- setDefaultValue(defaultValue: string): this;
74
- /**
75
- * Set the minimum text length for the string. If the user provides a string that is less than this value, the validation will fail.
76
- * @param minTextLength {number} The minimum text length for the string.
77
- */
78
- setMinTextLength(minTextLength: number): this;
79
- /**
80
- * Set the maximum text length for the string. If the user provides a string that is greater than this value, the validation will fail.
81
- * @param maxTextLength {number} The maximum text length for the string.
82
- */
83
- setMaxTextLength(maxTextLength: number): this;
84
- /**
85
- * Set the input type for the string. This will change how the client renders the input.
86
- * @param inputType {'text' | 'file' | 'password' | 'folder'} The input type for the string.
87
- */
88
- setInputType(inputType: 'text' | 'file' | 'password' | 'folder'): this;
89
- validate(input: unknown): [boolean, string];
90
- }
91
- declare class NumberOption extends ConfigurationOption {
92
- min: number;
93
- max: number;
94
- defaultValue: number;
95
- type: ConfigurationOptionType;
96
- inputType: 'range' | 'number';
97
- /**
98
- * Set the minimum value for the number. If the user provides a number that is less than this value, the validation will fail.
99
- * @param min {number} The minimum value for the number.
100
- */
101
- setMin(min: number): this;
102
- /**
103
- * Set the input type for the number. This will change how the client renders the input.
104
- * @param type {'range' | 'number'} The input type for the number.
105
- */
106
- setInputType(type: 'range' | 'number'): this;
107
- /**
108
- * Set the maximum value for the number. If the user provides a number that is greater than this value, the validation will fail.
109
- * @param max {number} The maximum value for the number.
110
- */
111
- setMax(max: number): this;
112
- /**
113
- * Set the default value for the number. This value will be used if the user does not provide a value. **HIGHLY RECOMMENDED**
114
- * @param defaultValue {number} The default value for the number.
115
- */
116
- setDefaultValue(defaultValue: number): this;
117
- validate(input: unknown): [boolean, string];
118
- }
119
- declare class BooleanOption extends ConfigurationOption {
120
- type: ConfigurationOptionType;
121
- defaultValue: boolean;
122
- /**
123
- * Set the default value for the boolean. This value will be used if the user does not provide a value. **HIGHLY RECOMMENDED**
124
- * @param defaultValue {boolean} The default value for the boolean.
125
- */
126
- setDefaultValue(defaultValue: boolean): this;
127
- validate(input: unknown): [boolean, string];
128
- }
129
-
130
- export { BooleanOption, ConfigurationBuilder, type ConfigurationFile, ConfigurationOption, type ConfigurationOptionType, NumberOption, StringOption, isBooleanOption, isNumberOption, isStringOption };
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
+ export { BooleanOption, ConfigurationBuilder, ConfigurationFile, ConfigurationOption, ConfigurationOptionType, NumberOption, StringOption, isBooleanOption, isNumberOption, isStringOption };
@@ -0,0 +1,2 @@
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
+ export { BooleanOption, ConfigurationBuilder, ConfigurationFile, ConfigurationOption, ConfigurationOptionType, NumberOption, StringOption, isBooleanOption, isNumberOption, isStringOption };