ogi-addon 0.1.2 → 0.2.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/EventResponse.cjs +46 -0
- package/build/EventResponse.cjs.map +1 -0
- package/build/EventResponse.d.cts +13 -0
- package/build/EventResponse.d.ts +13 -0
- package/build/EventResponse.js +25 -0
- package/build/EventResponse.js.map +1 -0
- package/build/SearchEngine.cjs +19 -0
- package/build/SearchEngine.cjs.map +1 -0
- package/build/SearchEngine.d.cts +15 -0
- package/build/SearchEngine.d.ts +15 -0
- package/build/SearchEngine.js +1 -0
- package/build/SearchEngine.js.map +1 -0
- package/build/config/Configuration.cjs +282 -0
- package/build/config/Configuration.cjs.map +1 -0
- package/build/config/Configuration.d.cts +20 -0
- package/build/config/Configuration.d.ts +20 -0
- package/build/config/Configuration.js +237 -0
- package/build/config/Configuration.js.map +1 -0
- package/build/config/ConfigurationBuilder.cjs +208 -0
- package/build/config/ConfigurationBuilder.cjs.map +1 -0
- package/build/config/ConfigurationBuilder.d.cts +57 -0
- package/build/config/ConfigurationBuilder.d.ts +57 -0
- package/build/config/ConfigurationBuilder.js +166 -0
- package/build/config/ConfigurationBuilder.js.map +1 -0
- package/build/main.cjs +1 -1
- package/build/main.cjs.map +1 -1
- package/build/main.d.cts +15 -93
- package/build/main.d.ts +15 -93
- package/build/main.js +1 -1
- package/build/main.js.map +1 -1
- package/package.json +20 -4
- package/src/SearchEngine.ts +9 -4
- package/src/config/Configuration.ts +4 -2
- package/src/main.ts +13 -2
- package/tsup.config.js +1 -1
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/EventResponse.ts
|
|
21
|
+
var EventResponse_exports = {};
|
|
22
|
+
__export(EventResponse_exports, {
|
|
23
|
+
default: () => EventResponse
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(EventResponse_exports);
|
|
26
|
+
var EventResponse = class {
|
|
27
|
+
data = void 0;
|
|
28
|
+
deffered = false;
|
|
29
|
+
resolved = false;
|
|
30
|
+
progress = 0;
|
|
31
|
+
logs = [];
|
|
32
|
+
defer() {
|
|
33
|
+
this.deffered = true;
|
|
34
|
+
}
|
|
35
|
+
resolve(data) {
|
|
36
|
+
this.resolved = true;
|
|
37
|
+
this.data = data;
|
|
38
|
+
}
|
|
39
|
+
complete() {
|
|
40
|
+
this.resolved = true;
|
|
41
|
+
}
|
|
42
|
+
log(message) {
|
|
43
|
+
this.logs.push(message);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=EventResponse.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/EventResponse.ts"],"sourcesContent":["export default class EventResponse<T> {\r\n data: T | undefined = undefined;\r\n deffered: boolean = false;\r\n resolved: boolean = false;\r\n progress: number = 0;\r\n logs: string[] = [];\r\n\r\n public defer() {\r\n this.deffered = true;\r\n }\r\n\r\n public resolve(data: T) {\r\n this.resolved = true;\r\n this.data = data;\r\n }\r\n\r\n public complete() {\r\n this.resolved = true;\r\n }\r\n\r\n public log(message: string) {\r\n this.logs.push(message);\r\n }\r\n\r\n \r\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAqB,gBAArB,MAAsC;AAAA,EACpC,OAAsB;AAAA,EACtB,WAAoB;AAAA,EACpB,WAAoB;AAAA,EACpB,WAAmB;AAAA,EACnB,OAAiB,CAAC;AAAA,EAEX,QAAQ;AACb,SAAK,WAAW;AAAA,EAClB;AAAA,EAEO,QAAQ,MAAS;AACtB,SAAK,WAAW;AAChB,SAAK,OAAO;AAAA,EACd;AAAA,EAEO,WAAW;AAChB,SAAK,WAAW;AAAA,EAClB;AAAA,EAEO,IAAI,SAAiB;AAC1B,SAAK,KAAK,KAAK,OAAO;AAAA,EACxB;AAGF;","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare class EventResponse<T> {
|
|
2
|
+
data: T | undefined;
|
|
3
|
+
deffered: boolean;
|
|
4
|
+
resolved: boolean;
|
|
5
|
+
progress: number;
|
|
6
|
+
logs: string[];
|
|
7
|
+
defer(): void;
|
|
8
|
+
resolve(data: T): void;
|
|
9
|
+
complete(): void;
|
|
10
|
+
log(message: string): void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { EventResponse as default };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare class EventResponse<T> {
|
|
2
|
+
data: T | undefined;
|
|
3
|
+
deffered: boolean;
|
|
4
|
+
resolved: boolean;
|
|
5
|
+
progress: number;
|
|
6
|
+
logs: string[];
|
|
7
|
+
defer(): void;
|
|
8
|
+
resolve(data: T): void;
|
|
9
|
+
complete(): void;
|
|
10
|
+
log(message: string): void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { EventResponse as default };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// src/EventResponse.ts
|
|
2
|
+
var EventResponse = class {
|
|
3
|
+
data = void 0;
|
|
4
|
+
deffered = false;
|
|
5
|
+
resolved = false;
|
|
6
|
+
progress = 0;
|
|
7
|
+
logs = [];
|
|
8
|
+
defer() {
|
|
9
|
+
this.deffered = true;
|
|
10
|
+
}
|
|
11
|
+
resolve(data) {
|
|
12
|
+
this.resolved = true;
|
|
13
|
+
this.data = data;
|
|
14
|
+
}
|
|
15
|
+
complete() {
|
|
16
|
+
this.resolved = true;
|
|
17
|
+
}
|
|
18
|
+
log(message) {
|
|
19
|
+
this.logs.push(message);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
EventResponse as default
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=EventResponse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/EventResponse.ts"],"sourcesContent":["export default class EventResponse<T> {\r\n data: T | undefined = undefined;\r\n deffered: boolean = false;\r\n resolved: boolean = false;\r\n progress: number = 0;\r\n logs: string[] = [];\r\n\r\n public defer() {\r\n this.deffered = true;\r\n }\r\n\r\n public resolve(data: T) {\r\n this.resolved = true;\r\n this.data = data;\r\n }\r\n\r\n public complete() {\r\n this.resolved = true;\r\n }\r\n\r\n public log(message: string) {\r\n this.logs.push(message);\r\n }\r\n\r\n \r\n}"],"mappings":";AAAA,IAAqB,gBAArB,MAAsC;AAAA,EACpC,OAAsB;AAAA,EACtB,WAAoB;AAAA,EACpB,WAAoB;AAAA,EACpB,WAAmB;AAAA,EACnB,OAAiB,CAAC;AAAA,EAEX,QAAQ;AACb,SAAK,WAAW;AAAA,EAClB;AAAA,EAEO,QAAQ,MAAS;AACtB,SAAK,WAAW;AAChB,SAAK,OAAO;AAAA,EACd;AAAA,EAEO,WAAW;AAChB,SAAK,WAAW;AAAA,EAClB;AAAA,EAEO,IAAI,SAAiB;AAC1B,SAAK,KAAK,KAAK,OAAO;AAAA,EACxB;AAGF;","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/SearchEngine.ts
|
|
17
|
+
var SearchEngine_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(SearchEngine_exports);
|
|
19
|
+
//# sourceMappingURL=SearchEngine.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/SearchEngine.ts"],"sourcesContent":["export type SearchResult = {\r\n name: string;\r\n description: string;\r\n coverURL: string;\r\n downloadType: 'torrent' | 'direct' | 'magnet';\r\n downloadSize: number;\r\n filename?: string;\r\n downloadURL?: string;\r\n files?: {\r\n name: string;\r\n downloadURL: string;\r\n }[];\r\n}\r\n\r\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type SearchResult = {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
coverURL: string;
|
|
5
|
+
downloadType: 'torrent' | 'direct' | 'magnet';
|
|
6
|
+
downloadSize: number;
|
|
7
|
+
filename?: string;
|
|
8
|
+
downloadURL?: string;
|
|
9
|
+
files?: {
|
|
10
|
+
name: string;
|
|
11
|
+
downloadURL: string;
|
|
12
|
+
}[];
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type { SearchResult };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type SearchResult = {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
coverURL: string;
|
|
5
|
+
downloadType: 'torrent' | 'direct' | 'magnet';
|
|
6
|
+
downloadSize: number;
|
|
7
|
+
filename?: string;
|
|
8
|
+
downloadURL?: string;
|
|
9
|
+
files?: {
|
|
10
|
+
name: string;
|
|
11
|
+
downloadURL: string;
|
|
12
|
+
}[];
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type { SearchResult };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=SearchEngine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/config/Configuration.ts
|
|
31
|
+
var Configuration_exports = {};
|
|
32
|
+
__export(Configuration_exports, {
|
|
33
|
+
BooleanOption: () => BooleanOption,
|
|
34
|
+
Configuration: () => Configuration,
|
|
35
|
+
ConfigurationBuilder: () => ConfigurationBuilder,
|
|
36
|
+
ConfigurationOption: () => ConfigurationOption,
|
|
37
|
+
NumberOption: () => NumberOption,
|
|
38
|
+
StringOption: () => StringOption,
|
|
39
|
+
isBooleanOption: () => isBooleanOption,
|
|
40
|
+
isNumberOption: () => isNumberOption,
|
|
41
|
+
isStringOption: () => isStringOption
|
|
42
|
+
});
|
|
43
|
+
module.exports = __toCommonJS(Configuration_exports);
|
|
44
|
+
|
|
45
|
+
// src/config/ConfigurationBuilder.ts
|
|
46
|
+
var import_zod = __toESM(require("zod"), 1);
|
|
47
|
+
var configValidation = import_zod.default.object({
|
|
48
|
+
name: import_zod.default.string().min(1),
|
|
49
|
+
displayName: import_zod.default.string().min(1),
|
|
50
|
+
description: import_zod.default.string().min(1)
|
|
51
|
+
});
|
|
52
|
+
function isStringOption(option) {
|
|
53
|
+
return option.type === "string";
|
|
54
|
+
}
|
|
55
|
+
function isNumberOption(option) {
|
|
56
|
+
return option.type === "number";
|
|
57
|
+
}
|
|
58
|
+
function isBooleanOption(option) {
|
|
59
|
+
return option.type === "boolean";
|
|
60
|
+
}
|
|
61
|
+
var ConfigurationBuilder = class {
|
|
62
|
+
options = [];
|
|
63
|
+
addNumberOption(option) {
|
|
64
|
+
let newOption = new NumberOption();
|
|
65
|
+
newOption = option(newOption);
|
|
66
|
+
this.options.push(newOption);
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
addStringOption(option) {
|
|
70
|
+
let newOption = new StringOption();
|
|
71
|
+
newOption = option(newOption);
|
|
72
|
+
this.options.push(newOption);
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
addBooleanOption(option) {
|
|
76
|
+
let newOption = new BooleanOption();
|
|
77
|
+
newOption = option(newOption);
|
|
78
|
+
this.options.push(newOption);
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
build(includeFunctions) {
|
|
82
|
+
let config = {};
|
|
83
|
+
this.options.forEach((option) => {
|
|
84
|
+
if (!includeFunctions) {
|
|
85
|
+
option = JSON.parse(JSON.stringify(option));
|
|
86
|
+
const optionData = configValidation.safeParse(option);
|
|
87
|
+
if (!optionData.success) {
|
|
88
|
+
throw new import_zod.ZodError(optionData.error.errors);
|
|
89
|
+
}
|
|
90
|
+
config[option.name] = option;
|
|
91
|
+
} else {
|
|
92
|
+
config[option.name] = option;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
return config;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
var ConfigurationOption = class {
|
|
99
|
+
name = "";
|
|
100
|
+
defaultValue = "";
|
|
101
|
+
displayName = "";
|
|
102
|
+
description = "";
|
|
103
|
+
type = "unset";
|
|
104
|
+
setName(name) {
|
|
105
|
+
this.name = name;
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
108
|
+
setDisplayName(displayName) {
|
|
109
|
+
this.displayName = displayName;
|
|
110
|
+
return this;
|
|
111
|
+
}
|
|
112
|
+
setDescription(description) {
|
|
113
|
+
this.description = description;
|
|
114
|
+
return this;
|
|
115
|
+
}
|
|
116
|
+
validate(input) {
|
|
117
|
+
throw new Error("Validation code not implemented. Value: " + input);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
var StringOption = class extends ConfigurationOption {
|
|
121
|
+
allowedValues = [];
|
|
122
|
+
minTextLength = 0;
|
|
123
|
+
maxTextLength = Number.MAX_SAFE_INTEGER;
|
|
124
|
+
defaultValue = "";
|
|
125
|
+
type = "string";
|
|
126
|
+
setAllowedValues(allowedValues) {
|
|
127
|
+
this.allowedValues = allowedValues;
|
|
128
|
+
return this;
|
|
129
|
+
}
|
|
130
|
+
setDefaultValue(defaultValue) {
|
|
131
|
+
this.defaultValue = defaultValue;
|
|
132
|
+
return this;
|
|
133
|
+
}
|
|
134
|
+
setMinTextLength(minTextLength) {
|
|
135
|
+
this.minTextLength = minTextLength;
|
|
136
|
+
return this;
|
|
137
|
+
}
|
|
138
|
+
setMaxTextLength(maxTextLength) {
|
|
139
|
+
this.maxTextLength = maxTextLength;
|
|
140
|
+
return this;
|
|
141
|
+
}
|
|
142
|
+
validate(input) {
|
|
143
|
+
if (typeof input !== "string") {
|
|
144
|
+
return [false, "Input is not a string"];
|
|
145
|
+
}
|
|
146
|
+
if (this.allowedValues.length === 0 && input.length !== 0)
|
|
147
|
+
return [true, ""];
|
|
148
|
+
if (input.length < this.minTextLength || input.length > this.maxTextLength) {
|
|
149
|
+
return [false, "Input is not within the text length " + this.minTextLength + " and " + this.maxTextLength + " characters (currently " + input.length + " characters)"];
|
|
150
|
+
}
|
|
151
|
+
return [this.allowedValues.includes(input), "Input is not an allowed value"];
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
var NumberOption = class extends ConfigurationOption {
|
|
155
|
+
min = 0;
|
|
156
|
+
max = Number.MAX_SAFE_INTEGER;
|
|
157
|
+
defaultValue = 0;
|
|
158
|
+
type = "number";
|
|
159
|
+
inputType = "number";
|
|
160
|
+
setMin(min) {
|
|
161
|
+
this.min = min;
|
|
162
|
+
return this;
|
|
163
|
+
}
|
|
164
|
+
setInputType(type) {
|
|
165
|
+
this.inputType = type;
|
|
166
|
+
return this;
|
|
167
|
+
}
|
|
168
|
+
setMax(max) {
|
|
169
|
+
this.max = max;
|
|
170
|
+
return this;
|
|
171
|
+
}
|
|
172
|
+
setDefaultValue(defaultValue) {
|
|
173
|
+
this.defaultValue = defaultValue;
|
|
174
|
+
return this;
|
|
175
|
+
}
|
|
176
|
+
validate(input) {
|
|
177
|
+
if (isNaN(Number(input))) {
|
|
178
|
+
return [false, "Input is not a number"];
|
|
179
|
+
}
|
|
180
|
+
if (Number(input) < this.min || Number(input) > this.max) {
|
|
181
|
+
return [false, "Input is not within the range of " + this.min + " and " + this.max];
|
|
182
|
+
}
|
|
183
|
+
return [true, ""];
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
var BooleanOption = class extends ConfigurationOption {
|
|
187
|
+
type = "boolean";
|
|
188
|
+
defaultValue = false;
|
|
189
|
+
setDefaultValue(defaultValue) {
|
|
190
|
+
this.defaultValue = defaultValue;
|
|
191
|
+
return this;
|
|
192
|
+
}
|
|
193
|
+
validate(input) {
|
|
194
|
+
if (typeof input !== "boolean") {
|
|
195
|
+
return [false, "Input is not a boolean"];
|
|
196
|
+
}
|
|
197
|
+
return [true, ""];
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
// src/config/Configuration.ts
|
|
202
|
+
var Configuration = class {
|
|
203
|
+
storedConfigTemplate;
|
|
204
|
+
definiteConfig = {};
|
|
205
|
+
constructor(configTemplate) {
|
|
206
|
+
this.storedConfigTemplate = configTemplate;
|
|
207
|
+
}
|
|
208
|
+
updateConfig(config, validate = true) {
|
|
209
|
+
this.definiteConfig = config;
|
|
210
|
+
if (validate) {
|
|
211
|
+
const result = this.validateConfig();
|
|
212
|
+
return result;
|
|
213
|
+
}
|
|
214
|
+
return [true, {}];
|
|
215
|
+
}
|
|
216
|
+
// provides falsey or truthy value, and an error message if falsey
|
|
217
|
+
validateConfig() {
|
|
218
|
+
const erroredKeys = /* @__PURE__ */ new Map();
|
|
219
|
+
for (const key in this.storedConfigTemplate) {
|
|
220
|
+
if (this.definiteConfig[key] === null || this.definiteConfig[key] === void 0) {
|
|
221
|
+
console.warn("Option " + key + " is not defined. Using default value Value: " + this.definiteConfig[key]);
|
|
222
|
+
this.definiteConfig[key] = this.storedConfigTemplate[key].defaultValue;
|
|
223
|
+
}
|
|
224
|
+
if (this.storedConfigTemplate[key].type !== typeof this.definiteConfig[key]) {
|
|
225
|
+
throw new Error("Option " + key + " is not of the correct type");
|
|
226
|
+
}
|
|
227
|
+
const result = this.storedConfigTemplate[key].validate(this.definiteConfig[key]);
|
|
228
|
+
if (!result[0]) {
|
|
229
|
+
erroredKeys.set(key, result[1]);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
for (const key in this.definiteConfig) {
|
|
233
|
+
if (!this.storedConfigTemplate[key]) {
|
|
234
|
+
throw new Error("Option " + key + " is not defined in the configuration template");
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
if (erroredKeys.size > 0) {
|
|
238
|
+
return [false, Object.fromEntries(erroredKeys)];
|
|
239
|
+
}
|
|
240
|
+
return [true, Object.fromEntries(erroredKeys)];
|
|
241
|
+
}
|
|
242
|
+
getStringValue(optionName) {
|
|
243
|
+
if (!this.definiteConfig[optionName] === null) {
|
|
244
|
+
throw new Error("Option " + optionName + " is not defined");
|
|
245
|
+
}
|
|
246
|
+
if (typeof this.definiteConfig[optionName] !== "string") {
|
|
247
|
+
throw new Error("Option " + optionName + " is not a string");
|
|
248
|
+
}
|
|
249
|
+
return this.definiteConfig[optionName];
|
|
250
|
+
}
|
|
251
|
+
getNumberValue(optionName) {
|
|
252
|
+
if (!this.definiteConfig[optionName] === null) {
|
|
253
|
+
throw new Error("Option " + optionName + " is not defined");
|
|
254
|
+
}
|
|
255
|
+
if (typeof this.definiteConfig[optionName] !== "number") {
|
|
256
|
+
throw new Error("Option " + optionName + " is not a number");
|
|
257
|
+
}
|
|
258
|
+
return this.definiteConfig[optionName];
|
|
259
|
+
}
|
|
260
|
+
getBooleanValue(optionName) {
|
|
261
|
+
if (this.definiteConfig[optionName] === null) {
|
|
262
|
+
throw new Error("Option " + optionName + " is not defined");
|
|
263
|
+
}
|
|
264
|
+
if (typeof this.definiteConfig[optionName] !== "boolean") {
|
|
265
|
+
throw new Error("Option " + optionName + " is not a boolean");
|
|
266
|
+
}
|
|
267
|
+
return this.definiteConfig[optionName];
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
271
|
+
0 && (module.exports = {
|
|
272
|
+
BooleanOption,
|
|
273
|
+
Configuration,
|
|
274
|
+
ConfigurationBuilder,
|
|
275
|
+
ConfigurationOption,
|
|
276
|
+
NumberOption,
|
|
277
|
+
StringOption,
|
|
278
|
+
isBooleanOption,
|
|
279
|
+
isNumberOption,
|
|
280
|
+
isStringOption
|
|
281
|
+
});
|
|
282
|
+
//# sourceMappingURL=Configuration.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/config/Configuration.ts","../../src/config/ConfigurationBuilder.ts"],"sourcesContent":["import { ConfigurationFile, ConfigurationBuilder, BooleanOption, ConfigurationOption, ConfigurationOptionType, NumberOption, StringOption, isBooleanOption, isNumberOption, isStringOption } from \"./ConfigurationBuilder\";\r\n\r\ninterface DefiniteConfig {\r\n [key: string]: string | number | boolean;\r\n}\r\nexport class Configuration {\r\n readonly storedConfigTemplate: ConfigurationFile;\r\n definiteConfig: DefiniteConfig = {};\r\n constructor(configTemplate: ConfigurationFile) {\r\n this.storedConfigTemplate = configTemplate;\r\n }\r\n\r\n updateConfig(config: DefiniteConfig, validate: boolean = true): [ boolean, { [key: string]: string } ] {\r\n this.definiteConfig = config;\r\n if (validate) {\r\n const result = this.validateConfig();\r\n return result;\r\n }\r\n return [ true, {} ];\r\n }\r\n // provides falsey or truthy value, and an error message if falsey\r\n private validateConfig(): [ boolean, { [key: string]: string } ] {\r\n const erroredKeys = new Map<string, string>();\r\n for (const key in this.storedConfigTemplate) {\r\n if (this.definiteConfig[key] === null || this.definiteConfig[key] === undefined) {\r\n console.warn('Option ' + key + ' is not defined. Using default value Value: ' + this.definiteConfig[key]);\r\n this.definiteConfig[key] = this.storedConfigTemplate[key].defaultValue as string | number | boolean;\r\n }\r\n if (this.storedConfigTemplate[key].type !== typeof this.definiteConfig[key]) {\r\n throw new Error('Option ' + key + ' is not of the correct type');\r\n }\r\n\r\n const result = this.storedConfigTemplate[key].validate(this.definiteConfig[key]);\r\n if (!result[0]) {\r\n erroredKeys.set(key, result[1]);\r\n }\r\n }\r\n\r\n for (const key in this.definiteConfig) {\r\n if (!this.storedConfigTemplate[key]) {\r\n throw new Error('Option ' + key + ' is not defined in the configuration template');\r\n }\r\n }\r\n\r\n if (erroredKeys.size > 0) {\r\n return [ false, Object.fromEntries(erroredKeys) ];\r\n }\r\n\r\n return [ true, Object.fromEntries(erroredKeys) ];\r\n }\r\n\r\n getStringValue(optionName: string): string {\r\n if (!this.definiteConfig[optionName] === null) {\r\n throw new Error('Option ' + optionName + ' is not defined');\r\n }\r\n if (typeof this.definiteConfig[optionName] !== 'string') {\r\n throw new Error('Option ' + optionName + ' is not a string');\r\n }\r\n return this.definiteConfig[optionName];\r\n }\r\n\r\n getNumberValue(optionName: string): number {\r\n if (!this.definiteConfig[optionName] === null) {\r\n throw new Error('Option ' + optionName + ' is not defined');\r\n }\r\n if (typeof this.definiteConfig[optionName] !== 'number') {\r\n throw new Error('Option ' + optionName + ' is not a number');\r\n }\r\n return this.definiteConfig[optionName];\r\n }\r\n\r\n getBooleanValue(optionName: string): boolean {\r\n if (this.definiteConfig[optionName] === null) {\r\n throw new Error('Option ' + optionName + ' is not defined');\r\n }\r\n if (typeof this.definiteConfig[optionName] !== 'boolean') {\r\n throw new Error('Option ' + optionName + ' is not a boolean');\r\n }\r\n return this.definiteConfig[optionName];\r\n }\r\n}\r\n\r\nexport { ConfigurationFile, ConfigurationBuilder, BooleanOption, ConfigurationOption, ConfigurationOptionType, NumberOption, StringOption, isBooleanOption, isNumberOption, isStringOption };","import z, { ZodError } from \"zod\"\r\n\r\nexport interface ConfigurationFile {\r\n [key: string]: ConfigurationOption\r\n}\r\n\r\nconst configValidation = z.object({\r\n name: z.string().min(1),\r\n displayName: z.string().min(1),\r\n description: z.string().min(1),\r\n})\r\n\r\nexport function isStringOption(option: ConfigurationOption): option is StringOption {\r\n return option.type === 'string';\r\n }\r\n\r\nexport function isNumberOption(option: ConfigurationOption): option is NumberOption {\r\n return option.type === 'number';\r\n}\r\n\r\nexport function isBooleanOption(option: ConfigurationOption): option is BooleanOption {\r\n return option.type === 'boolean';\r\n}\r\n\r\nexport class ConfigurationBuilder {\r\n private options: ConfigurationOption[] = [];\r\n public addNumberOption(option: (option: NumberOption) => NumberOption): ConfigurationBuilder {\r\n let newOption = new NumberOption();\r\n newOption = option(newOption);\r\n this.options.push(newOption);\r\n return this;\r\n }\r\n\r\n public addStringOption(option: (option: StringOption) => StringOption) {\r\n let newOption = new StringOption();\r\n newOption = option(newOption);\r\n this.options.push(newOption);\r\n return this;\r\n }\r\n\r\n public addBooleanOption(option: (option: BooleanOption) => BooleanOption) {\r\n let newOption = new BooleanOption();\r\n newOption = option(newOption);\r\n this.options.push(newOption);\r\n return this;\r\n }\r\n\r\n public build(includeFunctions: boolean): ConfigurationFile {\r\n let config: ConfigurationFile = {};\r\n this.options.forEach(option => {\r\n // remove all functions from the option object\r\n if (!includeFunctions) {\r\n option = JSON.parse(JSON.stringify(option));\r\n const optionData = configValidation.safeParse(option)\r\n if (!optionData.success) {\r\n throw new ZodError(optionData.error.errors)\r\n }\r\n\r\n config[option.name] = option;\r\n }\r\n else {\r\n config[option.name] = option;\r\n }\r\n });\r\n return config;\r\n }\r\n}\r\n\r\nexport type ConfigurationOptionType = 'string' | 'number' | 'boolean' | 'unset'\r\nexport class ConfigurationOption {\r\n public name: string = '';\r\n public defaultValue: unknown = '';\r\n public displayName: string = '';\r\n public description: string = '';\r\n public type: ConfigurationOptionType = 'unset'\r\n \r\n setName(name: string) {\r\n this.name = name;\r\n return this;\r\n }\r\n\r\n setDisplayName(displayName: string) {\r\n this.displayName = displayName;\r\n return this;\r\n }\r\n\r\n setDescription(description: string) {\r\n this.description = description;\r\n return this;\r\n }\r\n\r\n\r\n validate(input: unknown): [ boolean, string ] {\r\n throw new Error('Validation code not implemented. Value: ' + input)\r\n };\r\n}\r\n\r\nexport class StringOption extends ConfigurationOption {\r\n public allowedValues: string[] = [];\r\n public minTextLength: number = 0;\r\n public maxTextLength: number = Number.MAX_SAFE_INTEGER;\r\n public defaultValue: string = '';\r\n public type: ConfigurationOptionType = 'string'\r\n\r\n setAllowedValues(allowedValues: string[]): this {\r\n this.allowedValues = allowedValues;\r\n return this;\r\n }\r\n\r\n setDefaultValue(defaultValue: string): this {\r\n this.defaultValue = defaultValue;\r\n return this;\r\n }\r\n\r\n setMinTextLength(minTextLength: number): this {\r\n this.minTextLength = minTextLength;\r\n return this;\r\n }\r\n\r\n setMaxTextLength(maxTextLength: number): this {\r\n this.maxTextLength = maxTextLength;\r\n return this;\r\n }\r\n\r\n override validate(input: unknown): [ boolean, string ] {\r\n if (typeof input !== 'string') {\r\n return [ false, 'Input is not a string' ];\r\n }\r\n if (this.allowedValues.length === 0 && input.length !== 0)\r\n return [ true, '' ];\r\n if (input.length < this.minTextLength || input.length > this.maxTextLength) {\r\n return [ false, 'Input is not within the text length ' + this.minTextLength + ' and ' + this.maxTextLength + ' characters (currently ' + input.length + ' characters)' ];\r\n }\r\n\r\n return [ this.allowedValues.includes(input), 'Input is not an allowed value' ];\r\n }\r\n}\r\n\r\nexport class NumberOption extends ConfigurationOption {\r\n public min: number = 0;\r\n public max: number = Number.MAX_SAFE_INTEGER;\r\n public defaultValue: number = 0;\r\n public type: ConfigurationOptionType = 'number'\r\n public inputType: 'range' | 'number' = 'number';\r\n setMin(min: number): this {\r\n this.min = min;\r\n return this;\r\n }\r\n\r\n setInputType(type: 'range' | 'number'): this {\r\n this.inputType = type;\r\n return this;\r\n }\r\n\r\n setMax(max: number): this {\r\n this.max = max;\r\n return this\r\n }\r\n\r\n setDefaultValue(defaultValue: number): this {\r\n this.defaultValue = defaultValue;\r\n return this;\r\n }\r\n\r\n override validate(input: unknown): [ boolean, string ] {\r\n if (isNaN(Number(input))) {\r\n return [ false, 'Input is not a number' ];\r\n }\r\n if (Number(input) < this.min || Number(input) > this.max) {\r\n return [ false, 'Input is not within the range of ' + this.min + ' and ' + this.max ];\r\n }\r\n return [ true, '' ];\r\n }\r\n\r\n}\r\n\r\nexport class BooleanOption extends ConfigurationOption {\r\n public type: ConfigurationOptionType = 'boolean'\r\n public defaultValue: boolean = false;\r\n\r\n setDefaultValue(defaultValue: boolean): this {\r\n this.defaultValue = defaultValue;\r\n return this;\r\n }\r\n\r\n override validate(input: unknown): [ boolean, string ] {\r\n if (typeof input !== 'boolean') {\r\n return [ false, 'Input is not a boolean' ];\r\n }\r\n return [ true, '' ];\r\n }\r\n\r\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iBAA4B;AAM5B,IAAM,mBAAmB,WAAAA,QAAE,OAAO;AAAA,EAChC,MAAM,WAAAA,QAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACtB,aAAa,WAAAA,QAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EAC7B,aAAa,WAAAA,QAAE,OAAO,EAAE,IAAI,CAAC;AAC/B,CAAC;AAEM,SAAS,eAAe,QAAqD;AAChF,SAAO,OAAO,SAAS;AACzB;AAEK,SAAS,eAAe,QAAqD;AAClF,SAAO,OAAO,SAAS;AACzB;AAEO,SAAS,gBAAgB,QAAsD;AACpF,SAAO,OAAO,SAAS;AACzB;AAEO,IAAM,uBAAN,MAA2B;AAAA,EACxB,UA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eAAe,UAAU,MAAM,MAAM;AAC5C,YAAM,IAAI,MAAM,YAAY,aAAa,iBAAiB;AAAA,IAC5D;AACA,QAAI,OAAO,KAAK,eAAe,UAAU,MAAM,WAAW;AACxD,YAAM,IAAI,MAAM,YAAY,aAAa,mBAAmB;AAAA,IAC9D;AACA,WAAO,KAAK,eAAe,UAAU;AAAA,EACvC;AACF;","names":["z"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ConfigurationFile } from './ConfigurationBuilder.cjs';
|
|
2
|
+
export { BooleanOption, ConfigurationBuilder, ConfigurationOption, ConfigurationOptionType, NumberOption, StringOption, isBooleanOption, isNumberOption, isStringOption } from './ConfigurationBuilder.cjs';
|
|
3
|
+
|
|
4
|
+
interface DefiniteConfig {
|
|
5
|
+
[key: string]: string | number | boolean;
|
|
6
|
+
}
|
|
7
|
+
declare class Configuration {
|
|
8
|
+
readonly storedConfigTemplate: ConfigurationFile;
|
|
9
|
+
definiteConfig: DefiniteConfig;
|
|
10
|
+
constructor(configTemplate: ConfigurationFile);
|
|
11
|
+
updateConfig(config: DefiniteConfig, validate?: boolean): [boolean, {
|
|
12
|
+
[key: string]: string;
|
|
13
|
+
}];
|
|
14
|
+
private validateConfig;
|
|
15
|
+
getStringValue(optionName: string): string;
|
|
16
|
+
getNumberValue(optionName: string): number;
|
|
17
|
+
getBooleanValue(optionName: string): boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { Configuration, ConfigurationFile };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ConfigurationFile } from './ConfigurationBuilder.js';
|
|
2
|
+
export { BooleanOption, ConfigurationBuilder, ConfigurationOption, ConfigurationOptionType, NumberOption, StringOption, isBooleanOption, isNumberOption, isStringOption } from './ConfigurationBuilder.js';
|
|
3
|
+
|
|
4
|
+
interface DefiniteConfig {
|
|
5
|
+
[key: string]: string | number | boolean;
|
|
6
|
+
}
|
|
7
|
+
declare class Configuration {
|
|
8
|
+
readonly storedConfigTemplate: ConfigurationFile;
|
|
9
|
+
definiteConfig: DefiniteConfig;
|
|
10
|
+
constructor(configTemplate: ConfigurationFile);
|
|
11
|
+
updateConfig(config: DefiniteConfig, validate?: boolean): [boolean, {
|
|
12
|
+
[key: string]: string;
|
|
13
|
+
}];
|
|
14
|
+
private validateConfig;
|
|
15
|
+
getStringValue(optionName: string): string;
|
|
16
|
+
getNumberValue(optionName: string): number;
|
|
17
|
+
getBooleanValue(optionName: string): boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { Configuration, ConfigurationFile };
|