ogi-addon 0.1.1 → 0.1.2
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/main.cjs +434 -0
- package/build/main.cjs.map +1 -0
- package/build/main.d.cts +163 -0
- package/build/main.d.ts +104 -14
- package/build/main.js +391 -150
- package/build/main.js.map +1 -1
- package/package.json +33 -23
- package/tsconfig.json +2 -3
- package/tsup.config.js +11 -0
- package/build/EventResponse.d.ts +0 -11
- package/build/EventResponse.js +0 -23
- package/build/EventResponse.js.map +0 -1
- package/build/SearchEngine.d.ts +0 -9
- package/build/SearchEngine.js +0 -2
- package/build/SearchEngine.js.map +0 -1
- package/build/config/Configuration.d.ts +0 -17
- package/build/config/Configuration.js +0 -67
- package/build/config/Configuration.js.map +0 -1
- package/build/config/ConfigurationBuilder.d.ts +0 -55
- package/build/config/ConfigurationBuilder.js +0 -170
- package/build/config/ConfigurationBuilder.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,24 +1,34 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "ogi-addon",
|
|
3
|
-
"module": "./build/main.js",
|
|
4
|
-
"type": "module",
|
|
5
|
-
"main": "./build/main.
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "ogi-addon",
|
|
3
|
+
"module": "./build/main.js",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./build/main.cjs",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"import": "./build/main.js",
|
|
9
|
+
"require": "./build/main.cjs"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"types": "./build/main.d.ts",
|
|
13
|
+
"author": {
|
|
14
|
+
"name": "Nat3z",
|
|
15
|
+
"email": "me@nat3z.com",
|
|
16
|
+
"url": "https://nat3z.com/"
|
|
17
|
+
},
|
|
18
|
+
"version": "0.1.2",
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"ws": "^8.4.0",
|
|
21
|
+
"zod": "^3.23.8"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"auto-build": "tsc -w",
|
|
25
|
+
"build": "tsup --config tsup.config.js",
|
|
26
|
+
"release": "bun run build && npm publish"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/node": "^20.14.12",
|
|
30
|
+
"@types/ws": "^8.4.0",
|
|
31
|
+
"tsup": "^8.2.3",
|
|
32
|
+
"typescript": "^5.0.0"
|
|
33
|
+
}
|
|
24
34
|
}
|
package/tsconfig.json
CHANGED
|
@@ -5,9 +5,8 @@
|
|
|
5
5
|
"ESNext",
|
|
6
6
|
"DOM"
|
|
7
7
|
], // specifies which default set of type definitions to use ("DOM", "ES6", etc)
|
|
8
|
-
"outDir": "build", // .js (as well as .d.ts, .js.map, etc.) files will be emitted into this directory.,
|
|
9
8
|
"removeComments": true, // Strips all comments from TypeScript files when converting into JavaScript- you rarely read compiled code so this saves space
|
|
10
|
-
"target": "
|
|
9
|
+
"target": "ESNext", // Target environment. Most modern browsers support ES6, but you may want to set it to newer or older. (defaults to ES3)
|
|
11
10
|
"declaration": true,
|
|
12
11
|
|
|
13
12
|
// Module resolution
|
|
@@ -29,7 +28,7 @@
|
|
|
29
28
|
// Linter Checks
|
|
30
29
|
"noImplicitReturns": true,
|
|
31
30
|
"noUnusedLocals": true, // Report errors on unused local variables.
|
|
32
|
-
"noUnusedParameters": true // Report errors on unused parameters in functions
|
|
31
|
+
"noUnusedParameters": true, // Report errors on unused parameters in functions
|
|
33
32
|
},
|
|
34
33
|
"include": ["./**/*.ts"],
|
|
35
34
|
"exclude": [
|
package/tsup.config.js
ADDED
package/build/EventResponse.d.ts
DELETED
package/build/EventResponse.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export default class EventResponse {
|
|
2
|
-
constructor() {
|
|
3
|
-
this.data = undefined;
|
|
4
|
-
this.deffered = false;
|
|
5
|
-
this.resolved = false;
|
|
6
|
-
this.progress = 0;
|
|
7
|
-
this.logs = [];
|
|
8
|
-
}
|
|
9
|
-
defer() {
|
|
10
|
-
this.deffered = true;
|
|
11
|
-
}
|
|
12
|
-
resolve(data) {
|
|
13
|
-
this.resolved = true;
|
|
14
|
-
this.data = data;
|
|
15
|
-
}
|
|
16
|
-
complete() {
|
|
17
|
-
this.resolved = true;
|
|
18
|
-
}
|
|
19
|
-
log(message) {
|
|
20
|
-
this.logs.push(message);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=EventResponse.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EventResponse.js","sourceRoot":"/","sources":["EventResponse.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,aAAa;IAAlC;QACE,SAAI,GAAkB,SAAS,CAAC;QAChC,aAAQ,GAAY,KAAK,CAAC;QAC1B,aAAQ,GAAY,KAAK,CAAC;QAC1B,aAAQ,GAAW,CAAC,CAAC;QACrB,SAAI,GAAa,EAAE,CAAC;IAoBtB,CAAC;IAlBQ,KAAK;QACV,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC;IAEM,OAAO,CAAC,IAAO;QACpB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAEM,QAAQ;QACb,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC;IAEM,GAAG,CAAC,OAAe;QACxB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1B,CAAC;CAGF"}
|
package/build/SearchEngine.d.ts
DELETED
package/build/SearchEngine.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SearchEngine.js","sourceRoot":"/","sources":["SearchEngine.ts"],"names":[],"mappings":""}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { ConfigurationFile } from "./ConfigurationBuilder";
|
|
2
|
-
interface DefiniteConfig {
|
|
3
|
-
[key: string]: string | number | boolean;
|
|
4
|
-
}
|
|
5
|
-
export declare class Configuration {
|
|
6
|
-
readonly storedConfigTemplate: ConfigurationFile;
|
|
7
|
-
definiteConfig: DefiniteConfig;
|
|
8
|
-
constructor(configTemplate: ConfigurationFile);
|
|
9
|
-
updateConfig(config: DefiniteConfig, validate?: boolean): [boolean, {
|
|
10
|
-
[key: string]: string;
|
|
11
|
-
}];
|
|
12
|
-
private validateConfig;
|
|
13
|
-
getStringValue(optionName: string): string;
|
|
14
|
-
getNumberValue(optionName: string): number;
|
|
15
|
-
getBooleanValue(optionName: string): boolean;
|
|
16
|
-
}
|
|
17
|
-
export {};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
export class Configuration {
|
|
2
|
-
constructor(configTemplate) {
|
|
3
|
-
this.definiteConfig = {};
|
|
4
|
-
this.storedConfigTemplate = configTemplate;
|
|
5
|
-
}
|
|
6
|
-
updateConfig(config, validate = true) {
|
|
7
|
-
this.definiteConfig = config;
|
|
8
|
-
if (validate) {
|
|
9
|
-
const result = this.validateConfig();
|
|
10
|
-
return result;
|
|
11
|
-
}
|
|
12
|
-
return [true, {}];
|
|
13
|
-
}
|
|
14
|
-
validateConfig() {
|
|
15
|
-
const erroredKeys = new Map();
|
|
16
|
-
for (const key in this.storedConfigTemplate) {
|
|
17
|
-
if (this.definiteConfig[key] === null || this.definiteConfig[key] === undefined) {
|
|
18
|
-
console.warn('Option ' + key + ' is not defined. Using default value Value: ' + this.definiteConfig[key]);
|
|
19
|
-
this.definiteConfig[key] = this.storedConfigTemplate[key].defaultValue;
|
|
20
|
-
}
|
|
21
|
-
if (this.storedConfigTemplate[key].type !== typeof this.definiteConfig[key]) {
|
|
22
|
-
throw new Error('Option ' + key + ' is not of the correct type');
|
|
23
|
-
}
|
|
24
|
-
const result = this.storedConfigTemplate[key].validate(this.definiteConfig[key]);
|
|
25
|
-
if (!result[0]) {
|
|
26
|
-
erroredKeys.set(key, result[1]);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
for (const key in this.definiteConfig) {
|
|
30
|
-
if (!this.storedConfigTemplate[key]) {
|
|
31
|
-
throw new Error('Option ' + key + ' is not defined in the configuration template');
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
if (erroredKeys.size > 0) {
|
|
35
|
-
return [false, Object.fromEntries(erroredKeys)];
|
|
36
|
-
}
|
|
37
|
-
return [true, Object.fromEntries(erroredKeys)];
|
|
38
|
-
}
|
|
39
|
-
getStringValue(optionName) {
|
|
40
|
-
if (!this.definiteConfig[optionName] === null) {
|
|
41
|
-
throw new Error('Option ' + optionName + ' is not defined');
|
|
42
|
-
}
|
|
43
|
-
if (typeof this.definiteConfig[optionName] !== 'string') {
|
|
44
|
-
throw new Error('Option ' + optionName + ' is not a string');
|
|
45
|
-
}
|
|
46
|
-
return this.definiteConfig[optionName];
|
|
47
|
-
}
|
|
48
|
-
getNumberValue(optionName) {
|
|
49
|
-
if (!this.definiteConfig[optionName] === null) {
|
|
50
|
-
throw new Error('Option ' + optionName + ' is not defined');
|
|
51
|
-
}
|
|
52
|
-
if (typeof this.definiteConfig[optionName] !== 'number') {
|
|
53
|
-
throw new Error('Option ' + optionName + ' is not a number');
|
|
54
|
-
}
|
|
55
|
-
return this.definiteConfig[optionName];
|
|
56
|
-
}
|
|
57
|
-
getBooleanValue(optionName) {
|
|
58
|
-
if (this.definiteConfig[optionName] === null) {
|
|
59
|
-
throw new Error('Option ' + optionName + ' is not defined');
|
|
60
|
-
}
|
|
61
|
-
if (typeof this.definiteConfig[optionName] !== 'boolean') {
|
|
62
|
-
throw new Error('Option ' + optionName + ' is not a boolean');
|
|
63
|
-
}
|
|
64
|
-
return this.definiteConfig[optionName];
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
//# sourceMappingURL=Configuration.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Configuration.js","sourceRoot":"/","sources":["config/Configuration.ts"],"names":[],"mappings":"AAKA,MAAM,OAAO,aAAa;IAGxB,YAAY,cAAiC;QAD7C,mBAAc,GAAmB,EAAE,CAAC;QAElC,IAAI,CAAC,oBAAoB,GAAG,cAAc,CAAC;IAC7C,CAAC;IAED,YAAY,CAAC,MAAsB,EAAE,WAAoB,IAAI;QAC3D,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC;QAC7B,IAAI,QAAQ,EAAE,CAAC;YACb,MAAM,MAAM,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;YACrC,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,OAAO,CAAE,IAAI,EAAE,EAAE,CAAE,CAAC;IACtB,CAAC;IAEO,cAAc;QACpB,MAAM,WAAW,GAAG,IAAI,GAAG,EAAkB,CAAC;QAC9C,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC5C,IAAI,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,IAAI,IAAI,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE,CAAC;gBAChF,OAAO,CAAC,IAAI,CAAC,SAAS,GAAG,GAAG,GAAG,8CAA8C,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;gBAC1G,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC,YAAyC,CAAC;YACtG,CAAC;YACD,IAAI,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,OAAO,IAAI,CAAC,cAAc,CA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I,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IACzC,CAAC;IAED,cAAc,CAAC,UAAkB;QAC/B,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,KAAK,IAAI,EAAE,CAAC;YAC9C,MAAM,IAAI,KAAK,CAAC,SAAS,GAAG,UAAU,GAAG,iBAAiB,CAAC,CAAC;QAC9D,CAAC;QACD,IAAI,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,KAAK,QAAQ,EAAE,CAAC;YACxD,MAAM,IAAI,KAAK,CAAC,SAAS,GAAG,UAAU,GAAG,kBAAkB,CAAC,CAAC;QAC/D,CAAC;QACD,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IACzC,CAAC;IAED,eAAe,CAAC,UAAkB;QAChC,IAAI,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,KAAK,IAAI,EAAE,CAAC;YAC7C,MAAM,IAAI,KAAK,CAAC,SAAS,GAAG,UAAU,GAAG,iBAAiB,CAAC,CAAC;QAC9D,CAAC;QACD,IAAI,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,KAAK,SAAS,EAAE,CAAC;YACzD,MAAM,IAAI,KAAK,CAAC,SAAS,GAAG,UAAU,GAAG,mBAAmB,CAAC,CAAC;QAChE,CAAC;QACD,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IACzC,CAAC;CACF"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
export interface ConfigurationFile {
|
|
2
|
-
[key: string]: ConfigurationOption;
|
|
3
|
-
}
|
|
4
|
-
export declare function isStringOption(option: ConfigurationOption): option is StringOption;
|
|
5
|
-
export declare function isNumberOption(option: ConfigurationOption): option is NumberOption;
|
|
6
|
-
export declare function isBooleanOption(option: ConfigurationOption): option is BooleanOption;
|
|
7
|
-
export declare class ConfigurationBuilder {
|
|
8
|
-
private options;
|
|
9
|
-
addNumberOption(option: (option: NumberOption) => NumberOption): ConfigurationBuilder;
|
|
10
|
-
addStringOption(option: (option: StringOption) => StringOption): this;
|
|
11
|
-
addBooleanOption(option: (option: BooleanOption) => BooleanOption): this;
|
|
12
|
-
build(includeFunctions: boolean): ConfigurationFile;
|
|
13
|
-
}
|
|
14
|
-
export type ConfigurationOptionType = 'string' | 'number' | 'boolean' | 'unset';
|
|
15
|
-
export declare class ConfigurationOption {
|
|
16
|
-
name: string;
|
|
17
|
-
defaultValue: unknown;
|
|
18
|
-
displayName: string;
|
|
19
|
-
description: string;
|
|
20
|
-
type: ConfigurationOptionType;
|
|
21
|
-
setName(name: string): this;
|
|
22
|
-
setDisplayName(displayName: string): this;
|
|
23
|
-
setDescription(description: string): this;
|
|
24
|
-
validate(input: unknown): [boolean, string];
|
|
25
|
-
}
|
|
26
|
-
export declare class StringOption extends ConfigurationOption {
|
|
27
|
-
allowedValues: string[];
|
|
28
|
-
minTextLength: number;
|
|
29
|
-
maxTextLength: number;
|
|
30
|
-
defaultValue: string;
|
|
31
|
-
type: ConfigurationOptionType;
|
|
32
|
-
setAllowedValues(allowedValues: string[]): this;
|
|
33
|
-
setDefaultValue(defaultValue: string): this;
|
|
34
|
-
setMinTextLength(minTextLength: number): this;
|
|
35
|
-
setMaxTextLength(maxTextLength: number): this;
|
|
36
|
-
validate(input: unknown): [boolean, string];
|
|
37
|
-
}
|
|
38
|
-
export declare class NumberOption extends ConfigurationOption {
|
|
39
|
-
min: number;
|
|
40
|
-
max: number;
|
|
41
|
-
defaultValue: number;
|
|
42
|
-
type: ConfigurationOptionType;
|
|
43
|
-
inputType: 'range' | 'number';
|
|
44
|
-
setMin(min: number): this;
|
|
45
|
-
setInputType(type: 'range' | 'number'): this;
|
|
46
|
-
setMax(max: number): this;
|
|
47
|
-
setDefaultValue(defaultValue: number): this;
|
|
48
|
-
validate(input: unknown): [boolean, string];
|
|
49
|
-
}
|
|
50
|
-
export declare class BooleanOption extends ConfigurationOption {
|
|
51
|
-
type: ConfigurationOptionType;
|
|
52
|
-
defaultValue: boolean;
|
|
53
|
-
setDefaultValue(defaultValue: boolean): this;
|
|
54
|
-
validate(input: unknown): [boolean, string];
|
|
55
|
-
}
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import z, { ZodError } from "zod";
|
|
2
|
-
const configValidation = z.object({
|
|
3
|
-
name: z.string().min(1),
|
|
4
|
-
displayName: z.string().min(1),
|
|
5
|
-
description: z.string().min(1),
|
|
6
|
-
});
|
|
7
|
-
export function isStringOption(option) {
|
|
8
|
-
return option.type === 'string';
|
|
9
|
-
}
|
|
10
|
-
export function isNumberOption(option) {
|
|
11
|
-
return option.type === 'number';
|
|
12
|
-
}
|
|
13
|
-
export function isBooleanOption(option) {
|
|
14
|
-
return option.type === 'boolean';
|
|
15
|
-
}
|
|
16
|
-
export class ConfigurationBuilder {
|
|
17
|
-
constructor() {
|
|
18
|
-
this.options = [];
|
|
19
|
-
}
|
|
20
|
-
addNumberOption(option) {
|
|
21
|
-
let newOption = new NumberOption();
|
|
22
|
-
newOption = option(newOption);
|
|
23
|
-
this.options.push(newOption);
|
|
24
|
-
return this;
|
|
25
|
-
}
|
|
26
|
-
addStringOption(option) {
|
|
27
|
-
let newOption = new StringOption();
|
|
28
|
-
newOption = option(newOption);
|
|
29
|
-
this.options.push(newOption);
|
|
30
|
-
return this;
|
|
31
|
-
}
|
|
32
|
-
addBooleanOption(option) {
|
|
33
|
-
let newOption = new BooleanOption();
|
|
34
|
-
newOption = option(newOption);
|
|
35
|
-
this.options.push(newOption);
|
|
36
|
-
return this;
|
|
37
|
-
}
|
|
38
|
-
build(includeFunctions) {
|
|
39
|
-
let config = {};
|
|
40
|
-
this.options.forEach(option => {
|
|
41
|
-
if (!includeFunctions) {
|
|
42
|
-
option = JSON.parse(JSON.stringify(option));
|
|
43
|
-
const optionData = configValidation.safeParse(option);
|
|
44
|
-
if (!optionData.success) {
|
|
45
|
-
throw new ZodError(optionData.error.errors);
|
|
46
|
-
}
|
|
47
|
-
config[option.name] = option;
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
config[option.name] = option;
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
return config;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
export class ConfigurationOption {
|
|
57
|
-
constructor() {
|
|
58
|
-
this.name = '';
|
|
59
|
-
this.defaultValue = '';
|
|
60
|
-
this.displayName = '';
|
|
61
|
-
this.description = '';
|
|
62
|
-
this.type = 'unset';
|
|
63
|
-
}
|
|
64
|
-
setName(name) {
|
|
65
|
-
this.name = name;
|
|
66
|
-
return this;
|
|
67
|
-
}
|
|
68
|
-
setDisplayName(displayName) {
|
|
69
|
-
this.displayName = displayName;
|
|
70
|
-
return this;
|
|
71
|
-
}
|
|
72
|
-
setDescription(description) {
|
|
73
|
-
this.description = description;
|
|
74
|
-
return this;
|
|
75
|
-
}
|
|
76
|
-
validate(input) {
|
|
77
|
-
throw new Error('Validation code not implemented. Value: ' + input);
|
|
78
|
-
}
|
|
79
|
-
;
|
|
80
|
-
}
|
|
81
|
-
export class StringOption extends ConfigurationOption {
|
|
82
|
-
constructor() {
|
|
83
|
-
super(...arguments);
|
|
84
|
-
this.allowedValues = [];
|
|
85
|
-
this.minTextLength = 0;
|
|
86
|
-
this.maxTextLength = Number.MAX_SAFE_INTEGER;
|
|
87
|
-
this.defaultValue = '';
|
|
88
|
-
this.type = 'string';
|
|
89
|
-
}
|
|
90
|
-
setAllowedValues(allowedValues) {
|
|
91
|
-
this.allowedValues = allowedValues;
|
|
92
|
-
return this;
|
|
93
|
-
}
|
|
94
|
-
setDefaultValue(defaultValue) {
|
|
95
|
-
this.defaultValue = defaultValue;
|
|
96
|
-
return this;
|
|
97
|
-
}
|
|
98
|
-
setMinTextLength(minTextLength) {
|
|
99
|
-
this.minTextLength = minTextLength;
|
|
100
|
-
return this;
|
|
101
|
-
}
|
|
102
|
-
setMaxTextLength(maxTextLength) {
|
|
103
|
-
this.maxTextLength = maxTextLength;
|
|
104
|
-
return this;
|
|
105
|
-
}
|
|
106
|
-
validate(input) {
|
|
107
|
-
if (typeof input !== 'string') {
|
|
108
|
-
return [false, 'Input is not a string'];
|
|
109
|
-
}
|
|
110
|
-
if (this.allowedValues.length === 0 && input.length !== 0)
|
|
111
|
-
return [true, ''];
|
|
112
|
-
if (input.length < this.minTextLength || input.length > this.maxTextLength) {
|
|
113
|
-
return [false, 'Input is not within the text length ' + this.minTextLength + ' and ' + this.maxTextLength + ' characters (currently ' + input.length + ' characters)'];
|
|
114
|
-
}
|
|
115
|
-
return [this.allowedValues.includes(input), 'Input is not an allowed value'];
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
export class NumberOption extends ConfigurationOption {
|
|
119
|
-
constructor() {
|
|
120
|
-
super(...arguments);
|
|
121
|
-
this.min = 0;
|
|
122
|
-
this.max = Number.MAX_SAFE_INTEGER;
|
|
123
|
-
this.defaultValue = 0;
|
|
124
|
-
this.type = 'number';
|
|
125
|
-
this.inputType = 'number';
|
|
126
|
-
}
|
|
127
|
-
setMin(min) {
|
|
128
|
-
this.min = min;
|
|
129
|
-
return this;
|
|
130
|
-
}
|
|
131
|
-
setInputType(type) {
|
|
132
|
-
this.inputType = type;
|
|
133
|
-
return this;
|
|
134
|
-
}
|
|
135
|
-
setMax(max) {
|
|
136
|
-
this.max = max;
|
|
137
|
-
return this;
|
|
138
|
-
}
|
|
139
|
-
setDefaultValue(defaultValue) {
|
|
140
|
-
this.defaultValue = defaultValue;
|
|
141
|
-
return this;
|
|
142
|
-
}
|
|
143
|
-
validate(input) {
|
|
144
|
-
if (isNaN(Number(input))) {
|
|
145
|
-
return [false, 'Input is not a number'];
|
|
146
|
-
}
|
|
147
|
-
if (Number(input) < this.min || Number(input) > this.max) {
|
|
148
|
-
return [false, 'Input is not within the range of ' + this.min + ' and ' + this.max];
|
|
149
|
-
}
|
|
150
|
-
return [true, ''];
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
export class BooleanOption extends ConfigurationOption {
|
|
154
|
-
constructor() {
|
|
155
|
-
super(...arguments);
|
|
156
|
-
this.type = 'boolean';
|
|
157
|
-
this.defaultValue = false;
|
|
158
|
-
}
|
|
159
|
-
setDefaultValue(defaultValue) {
|
|
160
|
-
this.defaultValue = defaultValue;
|
|
161
|
-
return this;
|
|
162
|
-
}
|
|
163
|
-
validate(input) {
|
|
164
|
-
if (typeof input !== 'boolean') {
|
|
165
|
-
return [false, 'Input is not a boolean'];
|
|
166
|
-
}
|
|
167
|
-
return [true, ''];
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
//# sourceMappingURL=ConfigurationBuilder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigurationBuilder.js","sourceRoot":"/","sources":["config/ConfigurationBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAA;AAMjC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9B,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CAC/B,CAAC,CAAA;AAEF,MAAM,UAAU,cAAc,CAAC,MAA2B;IACtD,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC;AAClC,CAAC;AAEH,MAAM,UAAU,cAAc,CAAC,MAA2B;IACxD,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,MAA2B;IACzD,OAAO,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC;AACnC,CAAC;AAED,MAAM,OAAO,oBAAoB;IAAjC;QACU,YAAO,GAA0B,EAAE,CAAC;IAyC9C,CAAC;IAxCQ,eAAe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