ogi-addon 3.0.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/SearchEngine.d.cts +2 -31
- package/build/SearchEngine.d.mts +2 -31
- package/build/config/Configuration.cjs.map +1 -1
- package/build/config/Configuration.d.cts +5 -4
- package/build/config/Configuration.d.mts +5 -4
- package/build/config/Configuration.mjs.map +1 -1
- package/build/config/ConfigurationBuilder.cjs +2 -2
- package/build/config/ConfigurationBuilder.cjs.map +1 -1
- package/build/config/ConfigurationBuilder.d.cts +13 -15
- package/build/config/ConfigurationBuilder.d.mts +13 -15
- package/build/config/ConfigurationBuilder.mjs +2 -2
- package/build/config/ConfigurationBuilder.mjs.map +1 -1
- package/build/extraction.cjs +80 -0
- package/build/extraction.cjs.map +1 -0
- package/build/extraction.d.cts +5 -0
- package/build/extraction.d.mts +5 -0
- package/build/extraction.mjs +78 -0
- package/build/extraction.mjs.map +1 -0
- package/build/main.cjs +91 -169
- package/build/main.cjs.map +1 -1
- package/build/main.d.cts +27 -409
- package/build/main.d.mts +27 -409
- package/build/main.mjs +91 -168
- package/build/main.mjs.map +1 -1
- package/package.json +4 -4
- package/src/SearchEngine.ts +1 -34
- package/src/config/Configuration.ts +6 -8
- package/src/config/ConfigurationBuilder.ts +47 -30
- package/src/extraction.ts +87 -0
- package/src/main.ts +358 -765
- package/tsconfig.json +1 -1
package/build/SearchEngine.d.cts
CHANGED
|
@@ -1,31 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
type
|
|
3
|
-
name: string;
|
|
4
|
-
manifest?: Record<string, any>;
|
|
5
|
-
/**
|
|
6
|
-
* Update-only hint for OGI's setup stage.
|
|
7
|
-
* When false, OGI keeps existing files in place instead of moving them to `old_files`
|
|
8
|
-
* before running update setup. Defaults to true/undefined behavior.
|
|
9
|
-
*/
|
|
10
|
-
clearOldFilesBeforeUpdate?: boolean;
|
|
11
|
-
};
|
|
12
|
-
type SearchResult = BaseRequiredFields & ({
|
|
13
|
-
downloadType: 'torrent' | 'magnet';
|
|
14
|
-
filename: string;
|
|
15
|
-
downloadURL: string;
|
|
16
|
-
} | {
|
|
17
|
-
downloadType: 'direct';
|
|
18
|
-
files: {
|
|
19
|
-
name: string;
|
|
20
|
-
downloadURL: string;
|
|
21
|
-
headers?: Record<string, string>;
|
|
22
|
-
}[];
|
|
23
|
-
} | {
|
|
24
|
-
downloadType: 'task';
|
|
25
|
-
taskName: string;
|
|
26
|
-
} | {
|
|
27
|
-
downloadType: 'request' | 'empty';
|
|
28
|
-
});
|
|
29
|
-
//#endregion
|
|
30
|
-
export { SearchResult };
|
|
31
|
-
//# sourceMappingURL=SearchEngine.d.cts.map
|
|
1
|
+
import { SearchResult } from "@ogi-sdk/connect";
|
|
2
|
+
export { type SearchResult };
|
package/build/SearchEngine.d.mts
CHANGED
|
@@ -1,31 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
type
|
|
3
|
-
name: string;
|
|
4
|
-
manifest?: Record<string, any>;
|
|
5
|
-
/**
|
|
6
|
-
* Update-only hint for OGI's setup stage.
|
|
7
|
-
* When false, OGI keeps existing files in place instead of moving them to `old_files`
|
|
8
|
-
* before running update setup. Defaults to true/undefined behavior.
|
|
9
|
-
*/
|
|
10
|
-
clearOldFilesBeforeUpdate?: boolean;
|
|
11
|
-
};
|
|
12
|
-
type SearchResult = BaseRequiredFields & ({
|
|
13
|
-
downloadType: 'torrent' | 'magnet';
|
|
14
|
-
filename: string;
|
|
15
|
-
downloadURL: string;
|
|
16
|
-
} | {
|
|
17
|
-
downloadType: 'direct';
|
|
18
|
-
files: {
|
|
19
|
-
name: string;
|
|
20
|
-
downloadURL: string;
|
|
21
|
-
headers?: Record<string, string>;
|
|
22
|
-
}[];
|
|
23
|
-
} | {
|
|
24
|
-
downloadType: 'task';
|
|
25
|
-
taskName: string;
|
|
26
|
-
} | {
|
|
27
|
-
downloadType: 'request' | 'empty';
|
|
28
|
-
});
|
|
29
|
-
//#endregion
|
|
30
|
-
export { SearchResult };
|
|
31
|
-
//# sourceMappingURL=SearchEngine.d.mts.map
|
|
1
|
+
import { SearchResult } from "@ogi-sdk/connect";
|
|
2
|
+
export { type SearchResult };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Configuration.cjs","names":[],"sources":["../../src/config/Configuration.ts"],"sourcesContent":["import {\n ConfigurationBuilder,\n BooleanOption,\n ConfigurationOption,\n NumberOption,\n StringOption,\n ActionOption,\n isBooleanOption,\n isNumberOption,\n isStringOption,\n isActionOption,\n} from './ConfigurationBuilder';\nimport type {
|
|
1
|
+
{"version":3,"file":"Configuration.cjs","names":[],"sources":["../../src/config/Configuration.ts"],"sourcesContent":["import {\n ConfigurationBuilder,\n BooleanOption,\n ConfigurationOption,\n NumberOption,\n StringOption,\n ActionOption,\n isBooleanOption,\n isNumberOption,\n isStringOption,\n isActionOption,\n} from './ConfigurationBuilder';\nimport type { ConfigurationFile } from './ConfigurationBuilder';\n\ninterface DefiniteConfig {\n [key: string]: string | number | boolean;\n}\nexport class Configuration {\n readonly storedConfigTemplate: ConfigurationFile;\n definiteConfig: DefiniteConfig = {};\n constructor(configTemplate: ConfigurationFile) {\n this.storedConfigTemplate = configTemplate;\n }\n\n updateConfig(\n config: DefiniteConfig,\n validate: boolean = true\n ): [boolean, { [key: string]: string }] {\n this.definiteConfig = config;\n if (validate) {\n const result = this.validateConfig();\n return result;\n }\n return [true, {}];\n }\n // provides falsey or truthy value, and an error message if falsey\n private validateConfig(): [boolean, { [key: string]: string }] {\n const erroredKeys = new Map<string, string>();\n for (const key in this.storedConfigTemplate) {\n if (\n this.storedConfigTemplate[key].type !== 'action' &&\n (this.definiteConfig[key] === null ||\n this.definiteConfig[key] === undefined)\n ) {\n console.warn(\n 'Option ' +\n key +\n ' is not defined. Using default value Value: ' +\n this.storedConfigTemplate[key].defaultValue\n );\n this.definiteConfig[key] = this.storedConfigTemplate[key]\n .defaultValue as string | number | boolean;\n }\n if (\n this.storedConfigTemplate[key].type !== 'action' &&\n this.storedConfigTemplate[key].type !== typeof this.definiteConfig[key]\n ) {\n throw new Error('Option ' + key + ' is not of the correct type.');\n }\n\n if (this.storedConfigTemplate[key].type === 'action') {\n continue;\n }\n\n const result = (\n this.storedConfigTemplate[key] as unknown as ConfigurationOption<string>\n ).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] === undefined) {\n // remove the key from the definite config\n delete this.definiteConfig[key];\n console.warn(\n 'Option ' +\n key +\n ' is not defined in the configuration template. Removing from config.'\n );\n }\n }\n\n if (erroredKeys.size > 0) {\n return [false, Object.fromEntries(erroredKeys)];\n }\n\n return [true, Object.fromEntries(erroredKeys)];\n }\n\n getStringValue(optionName: string): string {\n if (\n this.definiteConfig[optionName] === null ||\n this.definiteConfig[optionName] === undefined\n ) {\n throw new Error('Option ' + optionName + ' is not defined');\n }\n if (typeof this.definiteConfig[optionName] !== 'string') {\n throw new Error('Option ' + optionName + ' is not a string');\n }\n return this.definiteConfig[optionName];\n }\n\n getNumberValue(optionName: string): number {\n if (\n this.definiteConfig[optionName] === null ||\n this.definiteConfig[optionName] === undefined\n ) {\n throw new Error('Option ' + optionName + ' is not defined');\n }\n if (typeof this.definiteConfig[optionName] !== 'number') {\n throw new Error('Option ' + optionName + ' is not a number');\n }\n return this.definiteConfig[optionName];\n }\n\n getBooleanValue(optionName: string): boolean {\n if (\n this.definiteConfig[optionName] === null ||\n this.definiteConfig[optionName] === undefined\n ) {\n throw new Error('Option ' + optionName + ' is not defined');\n }\n if (typeof this.definiteConfig[optionName] !== 'boolean') {\n throw new Error('Option ' + optionName + ' is not a boolean');\n }\n return this.definiteConfig[optionName];\n }\n}\n\nexport {\n ConfigurationBuilder,\n BooleanOption,\n ConfigurationOption,\n NumberOption,\n StringOption,\n ActionOption,\n isBooleanOption,\n isNumberOption,\n isStringOption,\n isActionOption,\n};\n\nexport type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gB,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,13 +1,14 @@
|
|
|
1
|
-
import { ActionOption, BooleanOption, ConfigurationBuilder, ConfigurationFile, ConfigurationOption,
|
|
1
|
+
import { ActionOption, BooleanOption, ConfigurationBuilder, ConfigurationFile as ConfigurationFile$2, ConfigurationOption, NumberOption, StringOption, isActionOption, isBooleanOption, isNumberOption, isStringOption } from "./ConfigurationBuilder.cjs";
|
|
2
|
+
import { ConfigurationFile, ConfigurationOptionWire } from "@ogi-sdk/connect";
|
|
2
3
|
|
|
3
4
|
//#region src/config/Configuration.d.ts
|
|
4
5
|
interface DefiniteConfig {
|
|
5
6
|
[key: string]: string | number | boolean;
|
|
6
7
|
}
|
|
7
8
|
declare class Configuration {
|
|
8
|
-
readonly storedConfigTemplate: ConfigurationFile;
|
|
9
|
+
readonly storedConfigTemplate: ConfigurationFile$2;
|
|
9
10
|
definiteConfig: DefiniteConfig;
|
|
10
|
-
constructor(configTemplate: ConfigurationFile);
|
|
11
|
+
constructor(configTemplate: ConfigurationFile$2);
|
|
11
12
|
updateConfig(config: DefiniteConfig, validate?: boolean): [boolean, {
|
|
12
13
|
[key: string]: string;
|
|
13
14
|
}];
|
|
@@ -17,5 +18,5 @@ declare class Configuration {
|
|
|
17
18
|
getBooleanValue(optionName: string): boolean;
|
|
18
19
|
}
|
|
19
20
|
//#endregion
|
|
20
|
-
export { ActionOption, BooleanOption, Configuration, ConfigurationBuilder, type ConfigurationFile, ConfigurationOption, type
|
|
21
|
+
export { ActionOption, BooleanOption, Configuration, ConfigurationBuilder, type ConfigurationFile, ConfigurationOption, type ConfigurationOptionWire, type DefiniteConfig, NumberOption, StringOption, isActionOption, isBooleanOption, isNumberOption, isStringOption };
|
|
21
22
|
//# sourceMappingURL=Configuration.d.cts.map
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { ActionOption, BooleanOption, ConfigurationBuilder, ConfigurationFile, ConfigurationOption,
|
|
1
|
+
import { ActionOption, BooleanOption, ConfigurationBuilder, ConfigurationFile as ConfigurationFile$2, ConfigurationOption, NumberOption, StringOption, isActionOption, isBooleanOption, isNumberOption, isStringOption } from "./ConfigurationBuilder.mjs";
|
|
2
|
+
import { ConfigurationFile, ConfigurationOptionWire } from "@ogi-sdk/connect";
|
|
2
3
|
|
|
3
4
|
//#region src/config/Configuration.d.ts
|
|
4
5
|
interface DefiniteConfig {
|
|
5
6
|
[key: string]: string | number | boolean;
|
|
6
7
|
}
|
|
7
8
|
declare class Configuration {
|
|
8
|
-
readonly storedConfigTemplate: ConfigurationFile;
|
|
9
|
+
readonly storedConfigTemplate: ConfigurationFile$2;
|
|
9
10
|
definiteConfig: DefiniteConfig;
|
|
10
|
-
constructor(configTemplate: ConfigurationFile);
|
|
11
|
+
constructor(configTemplate: ConfigurationFile$2);
|
|
11
12
|
updateConfig(config: DefiniteConfig, validate?: boolean): [boolean, {
|
|
12
13
|
[key: string]: string;
|
|
13
14
|
}];
|
|
@@ -17,5 +18,5 @@ declare class Configuration {
|
|
|
17
18
|
getBooleanValue(optionName: string): boolean;
|
|
18
19
|
}
|
|
19
20
|
//#endregion
|
|
20
|
-
export { ActionOption, BooleanOption, Configuration, ConfigurationBuilder, type ConfigurationFile, ConfigurationOption, type
|
|
21
|
+
export { ActionOption, BooleanOption, Configuration, ConfigurationBuilder, type ConfigurationFile, ConfigurationOption, type ConfigurationOptionWire, type DefiniteConfig, NumberOption, StringOption, isActionOption, isBooleanOption, isNumberOption, isStringOption };
|
|
21
22
|
//# sourceMappingURL=Configuration.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Configuration.mjs","names":[],"sources":["../../src/config/Configuration.ts"],"sourcesContent":["import {\n ConfigurationBuilder,\n BooleanOption,\n ConfigurationOption,\n NumberOption,\n StringOption,\n ActionOption,\n isBooleanOption,\n isNumberOption,\n isStringOption,\n isActionOption,\n} from './ConfigurationBuilder';\nimport type {
|
|
1
|
+
{"version":3,"file":"Configuration.mjs","names":[],"sources":["../../src/config/Configuration.ts"],"sourcesContent":["import {\n ConfigurationBuilder,\n BooleanOption,\n ConfigurationOption,\n NumberOption,\n StringOption,\n ActionOption,\n isBooleanOption,\n isNumberOption,\n isStringOption,\n isActionOption,\n} from './ConfigurationBuilder';\nimport type { ConfigurationFile } from './ConfigurationBuilder';\n\ninterface DefiniteConfig {\n [key: string]: string | number | boolean;\n}\nexport class Configuration {\n readonly storedConfigTemplate: ConfigurationFile;\n definiteConfig: DefiniteConfig = {};\n constructor(configTemplate: ConfigurationFile) {\n this.storedConfigTemplate = configTemplate;\n }\n\n updateConfig(\n config: DefiniteConfig,\n validate: boolean = true\n ): [boolean, { [key: string]: string }] {\n this.definiteConfig = config;\n if (validate) {\n const result = this.validateConfig();\n return result;\n }\n return [true, {}];\n }\n // provides falsey or truthy value, and an error message if falsey\n private validateConfig(): [boolean, { [key: string]: string }] {\n const erroredKeys = new Map<string, string>();\n for (const key in this.storedConfigTemplate) {\n if (\n this.storedConfigTemplate[key].type !== 'action' &&\n (this.definiteConfig[key] === null ||\n this.definiteConfig[key] === undefined)\n ) {\n console.warn(\n 'Option ' +\n key +\n ' is not defined. Using default value Value: ' +\n this.storedConfigTemplate[key].defaultValue\n );\n this.definiteConfig[key] = this.storedConfigTemplate[key]\n .defaultValue as string | number | boolean;\n }\n if (\n this.storedConfigTemplate[key].type !== 'action' &&\n this.storedConfigTemplate[key].type !== typeof this.definiteConfig[key]\n ) {\n throw new Error('Option ' + key + ' is not of the correct type.');\n }\n\n if (this.storedConfigTemplate[key].type === 'action') {\n continue;\n }\n\n const result = (\n this.storedConfigTemplate[key] as unknown as ConfigurationOption<string>\n ).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] === undefined) {\n // remove the key from the definite config\n delete this.definiteConfig[key];\n console.warn(\n 'Option ' +\n key +\n ' is not defined in the configuration template. Removing from config.'\n );\n }\n }\n\n if (erroredKeys.size > 0) {\n return [false, Object.fromEntries(erroredKeys)];\n }\n\n return [true, Object.fromEntries(erroredKeys)];\n }\n\n getStringValue(optionName: string): string {\n if (\n this.definiteConfig[optionName] === null ||\n this.definiteConfig[optionName] === undefined\n ) {\n throw new Error('Option ' + optionName + ' is not defined');\n }\n if (typeof this.definiteConfig[optionName] !== 'string') {\n throw new Error('Option ' + optionName + ' is not a string');\n }\n return this.definiteConfig[optionName];\n }\n\n getNumberValue(optionName: string): number {\n if (\n this.definiteConfig[optionName] === null ||\n this.definiteConfig[optionName] === undefined\n ) {\n throw new Error('Option ' + optionName + ' is not defined');\n }\n if (typeof this.definiteConfig[optionName] !== 'number') {\n throw new Error('Option ' + optionName + ' is not a number');\n }\n return this.definiteConfig[optionName];\n }\n\n getBooleanValue(optionName: string): boolean {\n if (\n this.definiteConfig[optionName] === null ||\n this.definiteConfig[optionName] === undefined\n ) {\n throw new Error('Option ' + optionName + ' is not defined');\n }\n if (typeof this.definiteConfig[optionName] !== 'boolean') {\n throw new Error('Option ' + optionName + ' is not a boolean');\n }\n return this.definiteConfig[optionName];\n }\n}\n\nexport {\n ConfigurationBuilder,\n BooleanOption,\n ConfigurationOption,\n NumberOption,\n StringOption,\n ActionOption,\n isBooleanOption,\n isNumberOption,\n isStringOption,\n isActionOption,\n};\n\nexport type { ConfigurationFile, ConfigurationOptionWire } from '@ogi-sdk/connect';\nexport type { DefiniteConfig };\n"],"mappings":";;;AAiBA,IAAa,gBAAb,MAA2B;CACzB,AAAS;CACT,iBAAiC,EAAE;CACnC,YAAY,gBAAmC;AAC7C,OAAK,uBAAuB;;CAG9B,aACE,QACA,WAAoB,MACkB;AACtC,OAAK,iBAAiB;AACtB,MAAI,SAEF,QADe,KAAK,gBAAgB;AAGtC,SAAO,CAAC,MAAM,EAAE,CAAC;;CAGnB,AAAQ,iBAAuD;EAC7D,MAAM,8BAAc,IAAI,KAAqB;AAC7C,OAAK,MAAM,OAAO,KAAK,sBAAsB;AAC3C,OACE,KAAK,qBAAqB,KAAK,SAAS,aACvC,KAAK,eAAe,SAAS,QAC5B,KAAK,eAAe,SAAS,SAC/B;AACA,YAAQ,KACN,YACE,MACA,iDACA,KAAK,qBAAqB,KAAK,aAClC;AACD,SAAK,eAAe,OAAO,KAAK,qBAAqB,KAClD;;AAEL,OACE,KAAK,qBAAqB,KAAK,SAAS,YACxC,KAAK,qBAAqB,KAAK,SAAS,OAAO,KAAK,eAAe,KAEnE,OAAM,IAAI,MAAM,YAAY,MAAM,+BAA+B;AAGnE,OAAI,KAAK,qBAAqB,KAAK,SAAS,SAC1C;GAGF,MAAM,SACJ,KAAK,qBAAqB,KAC1B,SAAS,KAAK,eAAe,KAAK;AACpC,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"}
|
|
@@ -25,7 +25,7 @@ function isActionOption(option) {
|
|
|
25
25
|
* A builder for creating configuration screens. The generic type T accumulates
|
|
26
26
|
* the types of all options added to the builder, enabling type-safe access to
|
|
27
27
|
* the configuration values.
|
|
28
|
-
*
|
|
28
|
+
*
|
|
29
29
|
* @template T - The accumulated type of all configuration options
|
|
30
30
|
*/
|
|
31
31
|
var ConfigurationBuilder = class {
|
|
@@ -61,7 +61,7 @@ var ConfigurationBuilder = class {
|
|
|
61
61
|
return this;
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
|
-
* Add an action option to the configuration builder and return the builder for chaining.
|
|
64
|
+
* Add an action option to the configuration builder and return the builder for chaining.
|
|
65
65
|
* Action options contribute a boolean to the return type (true if clicked, false if not).
|
|
66
66
|
* You must provide a name, display name, and description for the option.
|
|
67
67
|
* @param option { (option: ActionOption) => ActionOption<K> }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigurationBuilder.cjs","names":["z","ZodError"],"sources":["../../src/config/ConfigurationBuilder.ts"],"sourcesContent":["import z, { ZodError } from 'zod';\n\nexport interface ConfigurationFile {\n [key: string]: ConfigurationOption<string>;\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 extends string = string>(\n option: ConfigurationOption<N>\n): option is StringOption<N> {\n return option.type === 'string';\n}\n\nexport function isNumberOption<N extends string = string>(\n option: ConfigurationOption<N>\n): option is NumberOption<N> {\n return option.type === 'number';\n}\n\nexport function isBooleanOption<N extends string = string>(\n option: ConfigurationOption<N>\n): option is BooleanOption<N> {\n return option.type === 'boolean';\n}\n\nexport function isActionOption<N extends string = string>(\n option: ConfigurationOption<N>\n): option is ActionOption<N> {\n return option.type === 'action';\n}\n\n/**\n * A builder for creating configuration screens. The generic type T accumulates\n * the types of all options added to the builder, enabling type-safe access to\n * the configuration values.\n * \n * @template T - The accumulated type of all configuration options\n */\nexport class ConfigurationBuilder<\n T extends Record<string, string | number | boolean> = {}\n> {\n private options: ConfigurationOption<string>[] = [];\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<K> }\n * @returns A new ConfigurationBuilder with the number option's type added\n */\n public addNumberOption<K extends string>(\n option: (option: NumberOption) => NumberOption<K>\n ): ConfigurationBuilder<T & { [P in K]: number }> {\n let newOption = new NumberOption();\n const configuredOption = option(newOption);\n this.options.push(configuredOption);\n return this as unknown as ConfigurationBuilder<T & { [P in K]: number }>;\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<K> }\n * @returns A new ConfigurationBuilder with the string option's type added\n */\n public addStringOption<K extends string>(\n option: (option: StringOption) => StringOption<K>\n ): ConfigurationBuilder<T & { [P in K]: string }> {\n let newOption = new StringOption();\n const configuredOption = option(newOption);\n this.options.push(configuredOption);\n return this as unknown as ConfigurationBuilder<T & { [P in K]: string }>;\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<K> }\n * @returns A new ConfigurationBuilder with the boolean option's type added\n */\n public addBooleanOption<K extends string>(\n option: (option: BooleanOption) => BooleanOption<K>\n ): ConfigurationBuilder<T & { [P in K]: boolean }> {\n let newOption = new BooleanOption();\n const configuredOption = option(newOption);\n this.options.push(configuredOption);\n return this as unknown as ConfigurationBuilder<T & { [P in K]: boolean }>;\n }\n\n /**\n * Add an action option to the configuration builder and return the builder for chaining. \n * Action options contribute a boolean to the return type (true if clicked, false if not).\n * You must provide a name, display name, and description for the option.\n * @param option { (option: ActionOption) => ActionOption<K> }\n * @returns A new ConfigurationBuilder with the action option's type added as boolean\n */\n public addActionOption<K extends string>(\n option: (option: ActionOption) => ActionOption<K>\n ): ConfigurationBuilder<T & { [P in K]: boolean }> {\n let newOption = new ActionOption();\n const configuredOption = option(newOption);\n this.options.push(configuredOption);\n return this as unknown as ConfigurationBuilder<T & { [P in K]: boolean }>;\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 =\n | 'string'\n | 'number'\n | 'boolean'\n | 'action'\n | 'unset';\nexport class ConfigurationOption<N extends string = string> {\n public name: N = '' as N;\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<K extends string>(name: K): ConfigurationOption<K> {\n this.name = name as unknown as N;\n return this as unknown as ConfigurationOption<K>;\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): this {\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): this {\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<N extends string = string> extends ConfigurationOption<N> {\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 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 override setName<K extends string>(name: K): StringOption<K> {\n this.name = name as unknown as N;\n return this as unknown as StringOption<K>;\n }\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<N extends string = string> extends ConfigurationOption<N> {\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 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 override setName<K extends string>(name: K): NumberOption<K> {\n this.name = name as unknown as N;\n return this as unknown as NumberOption<K>;\n }\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<N extends string = string> extends ConfigurationOption<N> {\n public type: ConfigurationOptionType = 'boolean';\n public defaultValue: boolean = false;\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 override setName<K extends string>(name: K): BooleanOption<K> {\n this.name = name as unknown as N;\n return this as unknown as BooleanOption<K>;\n }\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\nexport class ActionOption<N extends string = string> extends ConfigurationOption<N> {\n public type: ConfigurationOptionType = 'action';\n public manifest: Record<string, unknown> = {};\n public buttonText: string = 'Run';\n public taskName: string = '';\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 override setName<K extends string>(name: K): ActionOption<K> {\n this.name = name as unknown as N;\n return this as unknown as ActionOption<K>;\n }\n\n /**\n * Set the task name that will be used to identify which task handler to run. This should match the name used in `addon.onTask()`.\n * @param taskName {string} The task name to identify the handler.\n */\n setTaskName(taskName: string): this {\n this.taskName = taskName;\n return this;\n }\n\n /**\n * Set the manifest object that will be passed to the task-run handler. The task name should be set via setTaskName() rather than in the manifest.\n * @param manifest {Record<string, unknown>} The manifest object to pass to the task handler.\n */\n setManifest(manifest: Record<string, unknown>): this {\n this.manifest = manifest;\n return this;\n }\n\n /**\n * Set the text displayed on the action button.\n * @param text {string} The button text.\n */\n setButtonText(text: string): this {\n this.buttonText = text;\n return this;\n }\n\n override validate(_input: unknown): [boolean, string] {\n return [true, ''];\n }\n}\n"],"mappings":";;;;;;AAMA,MAAM,mBAAmBA,YAAE,OAAO;CAChC,MAAMA,YAAE,QAAQ,CAAC,IAAI,EAAE;CACvB,aAAaA,YAAE,QAAQ,CAAC,IAAI,EAAE;CAC9B,aAAaA,YAAE,QAAQ,CAAC,IAAI,EAAE;CAC/B,CAAC;AAEF,SAAgB,eACd,QAC2B;AAC3B,QAAO,OAAO,SAAS;;AAGzB,SAAgB,eACd,QAC2B;AAC3B,QAAO,OAAO,SAAS;;AAGzB,SAAgB,gBACd,QAC4B;AAC5B,QAAO,OAAO,SAAS;;AAGzB,SAAgB,eACd,QAC2B;AAC3B,QAAO,OAAO,SAAS;;;;;;;;;AAUzB,IAAa,uBAAb,MAEE;CACA,AAAQ,UAAyC,EAAE;;;;;;CAOnD,AAAO,gBACL,QACgD;EAEhD,MAAM,mBAAmB,OADT,IAAI,cAAc,CACQ;AAC1C,OAAK,QAAQ,KAAK,iBAAiB;AACnC,SAAO;;;;;;;CAQT,AAAO,gBACL,QACgD;EAEhD,MAAM,mBAAmB,OADT,IAAI,cAAc,CACQ;AAC1C,OAAK,QAAQ,KAAK,iBAAiB;AACnC,SAAO;;;;;;;CAQT,AAAO,iBACL,QACiD;EAEjD,MAAM,mBAAmB,OADT,IAAI,eAAe,CACO;AAC1C,OAAK,QAAQ,KAAK,iBAAiB;AACnC,SAAO;;;;;;;;;CAUT,AAA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A0B,MAA2B;AAC5D,OAAK,OAAO;AACZ,SAAO;;;;;;CAOT,gBAAgB,cAA6B;AAC3C,OAAK,eAAe;AACpB,SAAO;;CAGT,AAAS,SAAS,OAAmC;AACnD,MAAI,OAAO,UAAU,UACnB,QAAO,CAAC,OAAO,yBAAyB;AAE1C,SAAO,CAAC,MAAM,GAAG;;;AAIrB,IAAa,eAAb,cAA6D,oBAAuB;CAClF,AAAO,OAAgC;CACvC,AAAO,WAAoC,EAAE;CAC7C,AAAO,aAAqB;CAC5B,AAAO,WAAmB;;;;;CAM1B,AAAS,QAA0B,MAA0B;AAC3D,OAAK,OAAO;AACZ,SAAO;;;;;;CAOT,YAAY,UAAwB;AAClC,OAAK,WAAW;AAChB,SAAO;;;;;;CAOT,YAAY,UAAyC;AACnD,OAAK,WAAW;AAChB,SAAO;;;;;;CAOT,cAAc,MAAoB;AAChC,OAAK,aAAa;AAClB,SAAO;;CAGT,AAAS,SAAS,QAAoC;AACpD,SAAO,CAAC,MAAM,GAAG"}
|
|
1
|
+
{"version":3,"file":"ConfigurationBuilder.cjs","names":["z","ZodError"],"sources":["../../src/config/ConfigurationBuilder.ts"],"sourcesContent":["import type {\n ActionConfigurationOption,\n BooleanConfigurationOption,\n ConfigurationFile,\n ConfigurationOptionType,\n ConfigurationOptionWire,\n NumberConfigurationOption,\n StringConfigurationOption,\n} from '@ogi-sdk/connect';\nimport z, { ZodError } from 'zod';\n\nexport type {\n ActionConfigurationOption,\n BooleanConfigurationOption,\n ConfigurationFile,\n ConfigurationOptionType,\n ConfigurationOptionWire,\n NumberConfigurationOption,\n StringConfigurationOption,\n} from '@ogi-sdk/connect';\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: ConfigurationOptionWire\n): option is StringConfigurationOption {\n return option.type === 'string';\n}\n\nexport function isNumberOption(\n option: ConfigurationOptionWire\n): option is NumberConfigurationOption {\n return option.type === 'number';\n}\n\nexport function isBooleanOption(\n option: ConfigurationOptionWire\n): option is BooleanConfigurationOption {\n return option.type === 'boolean';\n}\n\nexport function isActionOption(\n option: ConfigurationOptionWire\n): option is ActionConfigurationOption {\n return option.type === 'action';\n}\n\n/**\n * A builder for creating configuration screens. The generic type T accumulates\n * the types of all options added to the builder, enabling type-safe access to\n * the configuration values.\n *\n * @template T - The accumulated type of all configuration options\n */\nexport class ConfigurationBuilder<\n T extends Record<string, string | number | boolean> = {},\n> {\n private options: ConfigurationOption<string>[] = [];\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<K> }\n * @returns A new ConfigurationBuilder with the number option's type added\n */\n public addNumberOption<K extends string>(\n option: (option: NumberOption) => NumberOption<K>\n ): ConfigurationBuilder<T & { [P in K]: number }> {\n let newOption = new NumberOption();\n const configuredOption = option(newOption);\n this.options.push(configuredOption);\n return this as unknown as ConfigurationBuilder<T & { [P in K]: number }>;\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<K> }\n * @returns A new ConfigurationBuilder with the string option's type added\n */\n public addStringOption<K extends string>(\n option: (option: StringOption) => StringOption<K>\n ): ConfigurationBuilder<T & { [P in K]: string }> {\n let newOption = new StringOption();\n const configuredOption = option(newOption);\n this.options.push(configuredOption);\n return this as unknown as ConfigurationBuilder<T & { [P in K]: string }>;\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<K> }\n * @returns A new ConfigurationBuilder with the boolean option's type added\n */\n public addBooleanOption<K extends string>(\n option: (option: BooleanOption) => BooleanOption<K>\n ): ConfigurationBuilder<T & { [P in K]: boolean }> {\n let newOption = new BooleanOption();\n const configuredOption = option(newOption);\n this.options.push(configuredOption);\n return this as unknown as ConfigurationBuilder<T & { [P in K]: boolean }>;\n }\n\n /**\n * Add an action option to the configuration builder and return the builder for chaining.\n * Action options contribute a boolean to the return type (true if clicked, false if not).\n * You must provide a name, display name, and description for the option.\n * @param option { (option: ActionOption) => ActionOption<K> }\n * @returns A new ConfigurationBuilder with the action option's type added as boolean\n */\n public addActionOption<K extends string>(\n option: (option: ActionOption) => ActionOption<K>\n ): ConfigurationBuilder<T & { [P in K]: boolean }> {\n let newOption = new ActionOption();\n const configuredOption = option(newOption);\n this.options.push(configuredOption);\n return this as unknown as ConfigurationBuilder<T & { [P in K]: boolean }>;\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 as unknown as ConfigurationFile[string];\n } else {\n config[option.name] = option as unknown as ConfigurationFile[string];\n }\n });\n return config;\n }\n}\n\nexport class ConfigurationOption<N extends string = string> {\n public name: N = '' as N;\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<K extends string>(name: K): ConfigurationOption<K> {\n this.name = name as unknown as N;\n return this as unknown as ConfigurationOption<K>;\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): this {\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): this {\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<\n N extends string = string,\n> extends ConfigurationOption<N> {\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 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 override setName<K extends string>(name: K): StringOption<K> {\n this.name = name as unknown as N;\n return this as unknown as StringOption<K>;\n }\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<\n N extends string = string,\n> extends ConfigurationOption<N> {\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 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 override setName<K extends string>(name: K): NumberOption<K> {\n this.name = name as unknown as N;\n return this as unknown as NumberOption<K>;\n }\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<\n N extends string = string,\n> extends ConfigurationOption<N> {\n public type: ConfigurationOptionType = 'boolean';\n public defaultValue: boolean = false;\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 override setName<K extends string>(name: K): BooleanOption<K> {\n this.name = name as unknown as N;\n return this as unknown as BooleanOption<K>;\n }\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\nexport class ActionOption<\n N extends string = string,\n> extends ConfigurationOption<N> {\n public type: ConfigurationOptionType = 'action';\n public manifest: Record<string, unknown> = {};\n public buttonText: string = 'Run';\n public taskName: string = '';\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 override setName<K extends string>(name: K): ActionOption<K> {\n this.name = name as unknown as N;\n return this as unknown as ActionOption<K>;\n }\n\n /**\n * Set the task name that will be used to identify which task handler to run. This should match the name used in `addon.onTask()`.\n * @param taskName {string} The task name to identify the handler.\n */\n setTaskName(taskName: string): this {\n this.taskName = taskName;\n return this;\n }\n\n /**\n * Set the manifest object that will be passed to the task-run handler. The task name should be set via setTaskName() rather than in the manifest.\n * @param manifest {Record<string, unknown>} The manifest object to pass to the task handler.\n */\n setManifest(manifest: Record<string, unknown>): this {\n this.manifest = manifest;\n return this;\n }\n\n /**\n * Set the text displayed on the action button.\n * @param text {string} The button text.\n */\n setButtonText(text: string): this {\n this.buttonText = text;\n return this;\n }\n\n override validate(_input: unknown): [boolean, string] {\n return [true, ''];\n }\n}\n"],"mappings":";;;;;;AAqBA,MAAM,mBAAmBA,YAAE,OAAO;CAChC,MAAMA,YAAE,QAAQ,CAAC,IAAI,EAAE;CACvB,aAAaA,YAAE,QAAQ,CAAC,IAAI,EAAE;CAC9B,aAAaA,YAAE,QAAQ,CAAC,IAAI,EAAE;CAC/B,CAAC;AAEF,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AAoC;AACpD,SAAO,CAAC,MAAM,GAAG"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
import { ActionConfigurationOption, ActionConfigurationOption as ActionConfigurationOption$1, BooleanConfigurationOption, BooleanConfigurationOption as BooleanConfigurationOption$1, ConfigurationFile, ConfigurationFile as ConfigurationFile$1, ConfigurationOptionType, ConfigurationOptionType as ConfigurationOptionType$1, ConfigurationOptionWire, ConfigurationOptionWire as ConfigurationOptionWire$1, NumberConfigurationOption, NumberConfigurationOption as NumberConfigurationOption$1, StringConfigurationOption, StringConfigurationOption as StringConfigurationOption$1 } from "@ogi-sdk/connect";
|
|
2
|
+
|
|
1
3
|
//#region src/config/ConfigurationBuilder.d.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare function
|
|
6
|
-
declare function isNumberOption<N extends string = string>(option: ConfigurationOption<N>): option is NumberOption<N>;
|
|
7
|
-
declare function isBooleanOption<N extends string = string>(option: ConfigurationOption<N>): option is BooleanOption<N>;
|
|
8
|
-
declare function isActionOption<N extends string = string>(option: ConfigurationOption<N>): option is ActionOption<N>;
|
|
4
|
+
declare function isStringOption(option: ConfigurationOptionWire$1): option is StringConfigurationOption$1;
|
|
5
|
+
declare function isNumberOption(option: ConfigurationOptionWire$1): option is NumberConfigurationOption$1;
|
|
6
|
+
declare function isBooleanOption(option: ConfigurationOptionWire$1): option is BooleanConfigurationOption$1;
|
|
7
|
+
declare function isActionOption(option: ConfigurationOptionWire$1): option is ActionConfigurationOption$1;
|
|
9
8
|
/**
|
|
10
9
|
* A builder for creating configuration screens. The generic type T accumulates
|
|
11
10
|
* the types of all options added to the builder, enabling type-safe access to
|
|
@@ -41,15 +40,14 @@ declare class ConfigurationBuilder<T extends Record<string, string | number | bo
|
|
|
41
40
|
* @returns A new ConfigurationBuilder with the action option's type added as boolean
|
|
42
41
|
*/
|
|
43
42
|
addActionOption<K extends string>(option: (option: ActionOption) => ActionOption<K>): ConfigurationBuilder<T & { [P in K]: boolean }>;
|
|
44
|
-
build(includeFunctions: boolean): ConfigurationFile;
|
|
43
|
+
build(includeFunctions: boolean): ConfigurationFile$1;
|
|
45
44
|
}
|
|
46
|
-
type ConfigurationOptionType = 'string' | 'number' | 'boolean' | 'action' | 'unset';
|
|
47
45
|
declare class ConfigurationOption<N extends string = string> {
|
|
48
46
|
name: N;
|
|
49
47
|
defaultValue: unknown;
|
|
50
48
|
displayName: string;
|
|
51
49
|
description: string;
|
|
52
|
-
type: ConfigurationOptionType;
|
|
50
|
+
type: ConfigurationOptionType$1;
|
|
53
51
|
/**
|
|
54
52
|
* Set the name of the option. **REQUIRED**
|
|
55
53
|
* @param name {string} The name of the option. This is used to reference the option in the configuration file.
|
|
@@ -79,7 +77,7 @@ declare class StringOption<N extends string = string> extends ConfigurationOptio
|
|
|
79
77
|
maxTextLength: number;
|
|
80
78
|
defaultValue: string;
|
|
81
79
|
inputType: 'text' | 'file' | 'password' | 'folder';
|
|
82
|
-
type: ConfigurationOptionType;
|
|
80
|
+
type: ConfigurationOptionType$1;
|
|
83
81
|
/**
|
|
84
82
|
* Set the name of the option. **REQUIRED**
|
|
85
83
|
* @param name {string} The name of the option. This is used to reference the option in the configuration file.
|
|
@@ -116,7 +114,7 @@ declare class NumberOption<N extends string = string> extends ConfigurationOptio
|
|
|
116
114
|
min: number;
|
|
117
115
|
max: number;
|
|
118
116
|
defaultValue: number;
|
|
119
|
-
type: ConfigurationOptionType;
|
|
117
|
+
type: ConfigurationOptionType$1;
|
|
120
118
|
inputType: 'range' | 'number';
|
|
121
119
|
/**
|
|
122
120
|
* Set the name of the option. **REQUIRED**
|
|
@@ -146,7 +144,7 @@ declare class NumberOption<N extends string = string> extends ConfigurationOptio
|
|
|
146
144
|
validate(input: unknown): [boolean, string];
|
|
147
145
|
}
|
|
148
146
|
declare class BooleanOption<N extends string = string> extends ConfigurationOption<N> {
|
|
149
|
-
type: ConfigurationOptionType;
|
|
147
|
+
type: ConfigurationOptionType$1;
|
|
150
148
|
defaultValue: boolean;
|
|
151
149
|
/**
|
|
152
150
|
* Set the name of the option. **REQUIRED**
|
|
@@ -161,7 +159,7 @@ declare class BooleanOption<N extends string = string> extends ConfigurationOpti
|
|
|
161
159
|
validate(input: unknown): [boolean, string];
|
|
162
160
|
}
|
|
163
161
|
declare class ActionOption<N extends string = string> extends ConfigurationOption<N> {
|
|
164
|
-
type: ConfigurationOptionType;
|
|
162
|
+
type: ConfigurationOptionType$1;
|
|
165
163
|
manifest: Record<string, unknown>;
|
|
166
164
|
buttonText: string;
|
|
167
165
|
taskName: string;
|
|
@@ -188,5 +186,5 @@ declare class ActionOption<N extends string = string> extends ConfigurationOptio
|
|
|
188
186
|
validate(_input: unknown): [boolean, string];
|
|
189
187
|
}
|
|
190
188
|
//#endregion
|
|
191
|
-
export { ActionOption, BooleanOption, ConfigurationBuilder, ConfigurationFile, ConfigurationOption, ConfigurationOptionType, NumberOption, StringOption, isActionOption, isBooleanOption, isNumberOption, isStringOption };
|
|
189
|
+
export { type ActionConfigurationOption, ActionOption, type BooleanConfigurationOption, BooleanOption, ConfigurationBuilder, type ConfigurationFile, ConfigurationOption, type ConfigurationOptionType, type ConfigurationOptionWire, type NumberConfigurationOption, NumberOption, type StringConfigurationOption, StringOption, isActionOption, isBooleanOption, isNumberOption, isStringOption };
|
|
192
190
|
//# sourceMappingURL=ConfigurationBuilder.d.cts.map
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
import { ActionConfigurationOption, ActionConfigurationOption as ActionConfigurationOption$1, BooleanConfigurationOption, BooleanConfigurationOption as BooleanConfigurationOption$1, ConfigurationFile, ConfigurationFile as ConfigurationFile$1, ConfigurationOptionType, ConfigurationOptionType as ConfigurationOptionType$1, ConfigurationOptionWire, ConfigurationOptionWire as ConfigurationOptionWire$1, NumberConfigurationOption, NumberConfigurationOption as NumberConfigurationOption$1, StringConfigurationOption, StringConfigurationOption as StringConfigurationOption$1 } from "@ogi-sdk/connect";
|
|
2
|
+
|
|
1
3
|
//#region src/config/ConfigurationBuilder.d.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare function
|
|
6
|
-
declare function isNumberOption<N extends string = string>(option: ConfigurationOption<N>): option is NumberOption<N>;
|
|
7
|
-
declare function isBooleanOption<N extends string = string>(option: ConfigurationOption<N>): option is BooleanOption<N>;
|
|
8
|
-
declare function isActionOption<N extends string = string>(option: ConfigurationOption<N>): option is ActionOption<N>;
|
|
4
|
+
declare function isStringOption(option: ConfigurationOptionWire$1): option is StringConfigurationOption$1;
|
|
5
|
+
declare function isNumberOption(option: ConfigurationOptionWire$1): option is NumberConfigurationOption$1;
|
|
6
|
+
declare function isBooleanOption(option: ConfigurationOptionWire$1): option is BooleanConfigurationOption$1;
|
|
7
|
+
declare function isActionOption(option: ConfigurationOptionWire$1): option is ActionConfigurationOption$1;
|
|
9
8
|
/**
|
|
10
9
|
* A builder for creating configuration screens. The generic type T accumulates
|
|
11
10
|
* the types of all options added to the builder, enabling type-safe access to
|
|
@@ -41,15 +40,14 @@ declare class ConfigurationBuilder<T extends Record<string, string | number | bo
|
|
|
41
40
|
* @returns A new ConfigurationBuilder with the action option's type added as boolean
|
|
42
41
|
*/
|
|
43
42
|
addActionOption<K extends string>(option: (option: ActionOption) => ActionOption<K>): ConfigurationBuilder<T & { [P in K]: boolean }>;
|
|
44
|
-
build(includeFunctions: boolean): ConfigurationFile;
|
|
43
|
+
build(includeFunctions: boolean): ConfigurationFile$1;
|
|
45
44
|
}
|
|
46
|
-
type ConfigurationOptionType = 'string' | 'number' | 'boolean' | 'action' | 'unset';
|
|
47
45
|
declare class ConfigurationOption<N extends string = string> {
|
|
48
46
|
name: N;
|
|
49
47
|
defaultValue: unknown;
|
|
50
48
|
displayName: string;
|
|
51
49
|
description: string;
|
|
52
|
-
type: ConfigurationOptionType;
|
|
50
|
+
type: ConfigurationOptionType$1;
|
|
53
51
|
/**
|
|
54
52
|
* Set the name of the option. **REQUIRED**
|
|
55
53
|
* @param name {string} The name of the option. This is used to reference the option in the configuration file.
|
|
@@ -79,7 +77,7 @@ declare class StringOption<N extends string = string> extends ConfigurationOptio
|
|
|
79
77
|
maxTextLength: number;
|
|
80
78
|
defaultValue: string;
|
|
81
79
|
inputType: 'text' | 'file' | 'password' | 'folder';
|
|
82
|
-
type: ConfigurationOptionType;
|
|
80
|
+
type: ConfigurationOptionType$1;
|
|
83
81
|
/**
|
|
84
82
|
* Set the name of the option. **REQUIRED**
|
|
85
83
|
* @param name {string} The name of the option. This is used to reference the option in the configuration file.
|
|
@@ -116,7 +114,7 @@ declare class NumberOption<N extends string = string> extends ConfigurationOptio
|
|
|
116
114
|
min: number;
|
|
117
115
|
max: number;
|
|
118
116
|
defaultValue: number;
|
|
119
|
-
type: ConfigurationOptionType;
|
|
117
|
+
type: ConfigurationOptionType$1;
|
|
120
118
|
inputType: 'range' | 'number';
|
|
121
119
|
/**
|
|
122
120
|
* Set the name of the option. **REQUIRED**
|
|
@@ -146,7 +144,7 @@ declare class NumberOption<N extends string = string> extends ConfigurationOptio
|
|
|
146
144
|
validate(input: unknown): [boolean, string];
|
|
147
145
|
}
|
|
148
146
|
declare class BooleanOption<N extends string = string> extends ConfigurationOption<N> {
|
|
149
|
-
type: ConfigurationOptionType;
|
|
147
|
+
type: ConfigurationOptionType$1;
|
|
150
148
|
defaultValue: boolean;
|
|
151
149
|
/**
|
|
152
150
|
* Set the name of the option. **REQUIRED**
|
|
@@ -161,7 +159,7 @@ declare class BooleanOption<N extends string = string> extends ConfigurationOpti
|
|
|
161
159
|
validate(input: unknown): [boolean, string];
|
|
162
160
|
}
|
|
163
161
|
declare class ActionOption<N extends string = string> extends ConfigurationOption<N> {
|
|
164
|
-
type: ConfigurationOptionType;
|
|
162
|
+
type: ConfigurationOptionType$1;
|
|
165
163
|
manifest: Record<string, unknown>;
|
|
166
164
|
buttonText: string;
|
|
167
165
|
taskName: string;
|
|
@@ -188,5 +186,5 @@ declare class ActionOption<N extends string = string> extends ConfigurationOptio
|
|
|
188
186
|
validate(_input: unknown): [boolean, string];
|
|
189
187
|
}
|
|
190
188
|
//#endregion
|
|
191
|
-
export { ActionOption, BooleanOption, ConfigurationBuilder, ConfigurationFile, ConfigurationOption, ConfigurationOptionType, NumberOption, StringOption, isActionOption, isBooleanOption, isNumberOption, isStringOption };
|
|
189
|
+
export { type ActionConfigurationOption, ActionOption, type BooleanConfigurationOption, BooleanOption, ConfigurationBuilder, type ConfigurationFile, ConfigurationOption, type ConfigurationOptionType, type ConfigurationOptionWire, type NumberConfigurationOption, NumberOption, type StringConfigurationOption, StringOption, isActionOption, isBooleanOption, isNumberOption, isStringOption };
|
|
192
190
|
//# sourceMappingURL=ConfigurationBuilder.d.mts.map
|
|
@@ -22,7 +22,7 @@ function isActionOption(option) {
|
|
|
22
22
|
* A builder for creating configuration screens. The generic type T accumulates
|
|
23
23
|
* the types of all options added to the builder, enabling type-safe access to
|
|
24
24
|
* the configuration values.
|
|
25
|
-
*
|
|
25
|
+
*
|
|
26
26
|
* @template T - The accumulated type of all configuration options
|
|
27
27
|
*/
|
|
28
28
|
var ConfigurationBuilder = class {
|
|
@@ -58,7 +58,7 @@ var ConfigurationBuilder = class {
|
|
|
58
58
|
return this;
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
|
-
* Add an action option to the configuration builder and return the builder for chaining.
|
|
61
|
+
* Add an action option to the configuration builder and return the builder for chaining.
|
|
62
62
|
* Action options contribute a boolean to the return type (true if clicked, false if not).
|
|
63
63
|
* You must provide a name, display name, and description for the option.
|
|
64
64
|
* @param option { (option: ActionOption) => ActionOption<K> }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigurationBuilder.mjs","names":[],"sources":["../../src/config/ConfigurationBuilder.ts"],"sourcesContent":["import z, { ZodError } from 'zod';\n\nexport interface ConfigurationFile {\n [key: string]: ConfigurationOption<string>;\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 extends string = string>(\n option: ConfigurationOption<N>\n): option is StringOption<N> {\n return option.type === 'string';\n}\n\nexport function isNumberOption<N extends string = string>(\n option: ConfigurationOption<N>\n): option is NumberOption<N> {\n return option.type === 'number';\n}\n\nexport function isBooleanOption<N extends string = string>(\n option: ConfigurationOption<N>\n): option is BooleanOption<N> {\n return option.type === 'boolean';\n}\n\nexport function isActionOption<N extends string = string>(\n option: ConfigurationOption<N>\n): option is ActionOption<N> {\n return option.type === 'action';\n}\n\n/**\n * A builder for creating configuration screens. The generic type T accumulates\n * the types of all options added to the builder, enabling type-safe access to\n * the configuration values.\n * \n * @template T - The accumulated type of all configuration options\n */\nexport class ConfigurationBuilder<\n T extends Record<string, string | number | boolean> = {}\n> {\n private options: ConfigurationOption<string>[] = [];\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<K> }\n * @returns A new ConfigurationBuilder with the number option's type added\n */\n public addNumberOption<K extends string>(\n option: (option: NumberOption) => NumberOption<K>\n ): ConfigurationBuilder<T & { [P in K]: number }> {\n let newOption = new NumberOption();\n const configuredOption = option(newOption);\n this.options.push(configuredOption);\n return this as unknown as ConfigurationBuilder<T & { [P in K]: number }>;\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<K> }\n * @returns A new ConfigurationBuilder with the string option's type added\n */\n public addStringOption<K extends string>(\n option: (option: StringOption) => StringOption<K>\n ): ConfigurationBuilder<T & { [P in K]: string }> {\n let newOption = new StringOption();\n const configuredOption = option(newOption);\n this.options.push(configuredOption);\n return this as unknown as ConfigurationBuilder<T & { [P in K]: string }>;\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<K> }\n * @returns A new ConfigurationBuilder with the boolean option's type added\n */\n public addBooleanOption<K extends string>(\n option: (option: BooleanOption) => BooleanOption<K>\n ): ConfigurationBuilder<T & { [P in K]: boolean }> {\n let newOption = new BooleanOption();\n const configuredOption = option(newOption);\n this.options.push(configuredOption);\n return this as unknown as ConfigurationBuilder<T & { [P in K]: boolean }>;\n }\n\n /**\n * Add an action option to the configuration builder and return the builder for chaining. \n * Action options contribute a boolean to the return type (true if clicked, false if not).\n * You must provide a name, display name, and description for the option.\n * @param option { (option: ActionOption) => ActionOption<K> }\n * @returns A new ConfigurationBuilder with the action option's type added as boolean\n */\n public addActionOption<K extends string>(\n option: (option: ActionOption) => ActionOption<K>\n ): ConfigurationBuilder<T & { [P in K]: boolean }> {\n let newOption = new ActionOption();\n const configuredOption = option(newOption);\n this.options.push(configuredOption);\n return this as unknown as ConfigurationBuilder<T & { [P in K]: boolean }>;\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 =\n | 'string'\n | 'number'\n | 'boolean'\n | 'action'\n | 'unset';\nexport class ConfigurationOption<N extends string = string> {\n public name: N = '' as N;\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<K extends string>(name: K): ConfigurationOption<K> {\n this.name = name as unknown as N;\n return this as unknown as ConfigurationOption<K>;\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): this {\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): this {\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<N extends string = string> extends ConfigurationOption<N> {\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 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 override setName<K extends string>(name: K): StringOption<K> {\n this.name = name as unknown as N;\n return this as unknown as StringOption<K>;\n }\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<N extends string = string> extends ConfigurationOption<N> {\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 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 override setName<K extends string>(name: K): NumberOption<K> {\n this.name = name as unknown as N;\n return this as unknown as NumberOption<K>;\n }\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<N extends string = string> extends ConfigurationOption<N> {\n public type: ConfigurationOptionType = 'boolean';\n public defaultValue: boolean = false;\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 override setName<K extends string>(name: K): BooleanOption<K> {\n this.name = name as unknown as N;\n return this as unknown as BooleanOption<K>;\n }\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\nexport class ActionOption<N extends string = string> extends ConfigurationOption<N> {\n public type: ConfigurationOptionType = 'action';\n public manifest: Record<string, unknown> = {};\n public buttonText: string = 'Run';\n public taskName: string = '';\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 override setName<K extends string>(name: K): ActionOption<K> {\n this.name = name as unknown as N;\n return this as unknown as ActionOption<K>;\n }\n\n /**\n * Set the task name that will be used to identify which task handler to run. This should match the name used in `addon.onTask()`.\n * @param taskName {string} The task name to identify the handler.\n */\n setTaskName(taskName: string): this {\n this.taskName = taskName;\n return this;\n }\n\n /**\n * Set the manifest object that will be passed to the task-run handler. The task name should be set via setTaskName() rather than in the manifest.\n * @param manifest {Record<string, unknown>} The manifest object to pass to the task handler.\n */\n setManifest(manifest: Record<string, unknown>): this {\n this.manifest = manifest;\n return this;\n }\n\n /**\n * Set the text displayed on the action button.\n * @param text {string} The button text.\n */\n setButtonText(text: string): this {\n this.buttonText = text;\n return this;\n }\n\n override validate(_input: unknown): [boolean, string] {\n return [true, ''];\n }\n}\n"],"mappings":";;;AAMA,MAAM,mBAAmB,EA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UAAwB;AAClC,OAAK,WAAW;AAChB,SAAO;;;;;;CAOT,YAAY,UAAyC;AACnD,OAAK,WAAW;AAChB,SAAO;;;;;;CAOT,cAAc,MAAoB;AAChC,OAAK,aAAa;AAClB,SAAO;;CAGT,AAAS,SAAS,QAAoC;AACpD,SAAO,CAAC,MAAM,GAAG"}
|
|
1
|
+
{"version":3,"file":"ConfigurationBuilder.mjs","names":[],"sources":["../../src/config/ConfigurationBuilder.ts"],"sourcesContent":["import type {\n ActionConfigurationOption,\n BooleanConfigurationOption,\n ConfigurationFile,\n ConfigurationOptionType,\n ConfigurationOptionWire,\n NumberConfigurationOption,\n StringConfigurationOption,\n} from '@ogi-sdk/connect';\nimport z, { ZodError } from 'zod';\n\nexport type {\n ActionConfigurationOption,\n BooleanConfigurationOption,\n ConfigurationFile,\n ConfigurationOptionType,\n ConfigurationOptionWire,\n NumberConfigurationOption,\n StringConfigurationOption,\n} from '@ogi-sdk/connect';\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: ConfigurationOptionWire\n): option is StringConfigurationOption {\n return option.type === 'string';\n}\n\nexport function isNumberOption(\n option: ConfigurationOptionWire\n): option is NumberConfigurationOption {\n return option.type === 'number';\n}\n\nexport function isBooleanOption(\n option: ConfigurationOptionWire\n): option is BooleanConfigurationOption {\n return option.type === 'boolean';\n}\n\nexport function isActionOption(\n option: ConfigurationOptionWire\n): option is ActionConfigurationOption {\n return option.type === 'action';\n}\n\n/**\n * A builder for creating configuration screens. The generic type T accumulates\n * the types of all options added to the builder, enabling type-safe access to\n * the configuration values.\n *\n * @template T - The accumulated type of all configuration options\n */\nexport class ConfigurationBuilder<\n T extends Record<string, string | number | boolean> = {},\n> {\n private options: ConfigurationOption<string>[] = [];\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<K> }\n * @returns A new ConfigurationBuilder with the number option's type added\n */\n public addNumberOption<K extends string>(\n option: (option: NumberOption) => NumberOption<K>\n ): ConfigurationBuilder<T & { [P in K]: number }> {\n let newOption = new NumberOption();\n const configuredOption = option(newOption);\n this.options.push(configuredOption);\n return this as unknown as ConfigurationBuilder<T & { [P in K]: number }>;\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<K> }\n * @returns A new ConfigurationBuilder with the string option's type added\n */\n public addStringOption<K extends string>(\n option: (option: StringOption) => StringOption<K>\n ): ConfigurationBuilder<T & { [P in K]: string }> {\n let newOption = new StringOption();\n const configuredOption = option(newOption);\n this.options.push(configuredOption);\n return this as unknown as ConfigurationBuilder<T & { [P in K]: string }>;\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<K> }\n * @returns A new ConfigurationBuilder with the boolean option's type added\n */\n public addBooleanOption<K extends string>(\n option: (option: BooleanOption) => BooleanOption<K>\n ): ConfigurationBuilder<T & { [P in K]: boolean }> {\n let newOption = new BooleanOption();\n const configuredOption = option(newOption);\n this.options.push(configuredOption);\n return this as unknown as ConfigurationBuilder<T & { [P in K]: boolean }>;\n }\n\n /**\n * Add an action option to the configuration builder and return the builder for chaining.\n * Action options contribute a boolean to the return type (true if clicked, false if not).\n * You must provide a name, display name, and description for the option.\n * @param option { (option: ActionOption) => ActionOption<K> }\n * @returns A new ConfigurationBuilder with the action option's type added as boolean\n */\n public addActionOption<K extends string>(\n option: (option: ActionOption) => ActionOption<K>\n ): ConfigurationBuilder<T & { [P in K]: boolean }> {\n let newOption = new ActionOption();\n const configuredOption = option(newOption);\n this.options.push(configuredOption);\n return this as unknown as ConfigurationBuilder<T & { [P in K]: boolean }>;\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 as unknown as ConfigurationFile[string];\n } else {\n config[option.name] = option as unknown as ConfigurationFile[string];\n }\n });\n return config;\n }\n}\n\nexport class ConfigurationOption<N extends string = string> {\n public name: N = '' as N;\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<K extends string>(name: K): ConfigurationOption<K> {\n this.name = name as unknown as N;\n return this as unknown as ConfigurationOption<K>;\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): this {\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): this {\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<\n N extends string = string,\n> extends ConfigurationOption<N> {\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 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 override setName<K extends string>(name: K): StringOption<K> {\n this.name = name as unknown as N;\n return this as unknown as StringOption<K>;\n }\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<\n N extends string = string,\n> extends ConfigurationOption<N> {\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 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 override setName<K extends string>(name: K): NumberOption<K> {\n this.name = name as unknown as N;\n return this as unknown as NumberOption<K>;\n }\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<\n N extends string = string,\n> extends ConfigurationOption<N> {\n public type: ConfigurationOptionType = 'boolean';\n public defaultValue: boolean = false;\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 override setName<K extends string>(name: K): BooleanOption<K> {\n this.name = name as unknown as N;\n return this as unknown as BooleanOption<K>;\n }\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\nexport class ActionOption<\n N extends string = string,\n> extends ConfigurationOption<N> {\n public type: ConfigurationOptionType = 'action';\n public manifest: Record<string, unknown> = {};\n public buttonText: string = 'Run';\n public taskName: string = '';\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 override setName<K extends string>(name: K): ActionOption<K> {\n this.name = name as unknown as N;\n return this as unknown as ActionOption<K>;\n }\n\n /**\n * Set the task name that will be used to identify which task handler to run. This should match the name used in `addon.onTask()`.\n * @param taskName {string} The task name to identify the handler.\n */\n setTaskName(taskName: string): this {\n this.taskName = taskName;\n return this;\n }\n\n /**\n * Set the manifest object that will be passed to the task-run handler. The task name should be set via setTaskName() rather than in the manifest.\n * @param manifest {Record<string, unknown>} The manifest object to pass to the task handler.\n */\n setManifest(manifest: Record<string, unknown>): this {\n this.manifest = manifest;\n return this;\n }\n\n /**\n * Set the text displayed on the action button.\n * @param text {string} The button text.\n */\n setButtonText(text: string): this {\n this.buttonText = text;\n return this;\n }\n\n override validate(_input: unknown): [boolean, string] {\n return [true, ''];\n }\n}\n"],"mappings":";;;AAqBA,MAAM,mBAAmB,EAAE,OAAO;CAChC,MAAM,EAAE,QAAQ,CAAC,IAAI,EAAE;CACvB,aAAa,EAAE,QAAQ,CAAC,IAAI,EAAE;CAC9B,aAAa,EAAE,QAAQ,CAAC,IAAI,EAAE;CAC/B,CAAC;AAEF,SAAgB,eACd,QACqC;AACrC,QAAO,OAAO,SAAS;;AAGzB,SAAgB,eACd,QACqC;AACrC,QAAO,OAAO,SAAS;;AAGzB,SAAgB,gBACd,QACsC;AACtC,QAAO,OAAO,SAAS;;AAGzB,SAAgB,eACd,QACqC;AACrC,QAAO,OAAO,SAAS;;;;;;;;;AAUzB,IAAa,uBAAb,MAEE;CACA,AAAQ,UAAyC,EAAE;;;;;;CAOnD,AAAO,gBACL,QACgD;EAEhD,MAAM,mBAAmB,OADT,IAAI,cAAc,CACQ;AAC1C,OAAK,QAAQ,KAAK,iBAAiB;AACnC,SAAO;;;;;;;CAQT,AAAO,gBACL,QACgD;EAEhD,MAAM,mBAAmB,OADT,I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