ogi-addon 0.1.0 → 0.1.1
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.d.ts +11 -0
- package/build/EventResponse.js +23 -0
- package/build/EventResponse.js.map +1 -0
- package/build/SearchEngine.d.ts +9 -0
- package/build/SearchEngine.js +2 -0
- package/build/SearchEngine.js.map +1 -0
- package/build/config/Configuration.d.ts +17 -0
- package/build/config/Configuration.js +67 -0
- package/build/config/Configuration.js.map +1 -0
- package/build/config/ConfigurationBuilder.d.ts +55 -0
- package/build/config/ConfigurationBuilder.js +170 -0
- package/build/config/ConfigurationBuilder.js.map +1 -0
- package/build/main.d.ts +73 -0
- package/build/main.js +156 -0
- package/build/main.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,23 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchEngine.js","sourceRoot":"/","sources":["SearchEngine.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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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,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IACzC,CAAC;CACF"}
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,CA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qB;QACnC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;IAEQ,QAAQ,CAAC,KAAc;QAC9B,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;YAC/B,OAAO,CAAE,KAAK,EAAE,wBAAwB,CAAE,CAAC;QAC7C,CAAC;QACD,OAAO,CAAE,IAAI,EAAE,EAAE,CAAE,CAAC;IACtB,CAAC;CAEF"}
|
package/build/main.d.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import ws from 'ws';
|
|
2
|
+
import events from 'node:events';
|
|
3
|
+
import { ConfigurationBuilder, ConfigurationFile } from './config/ConfigurationBuilder';
|
|
4
|
+
import { Configuration } from './config/Configuration';
|
|
5
|
+
import EventResponse from './EventResponse';
|
|
6
|
+
import { SearchResult } from './SearchEngine';
|
|
7
|
+
export type OGIAddonEvent = 'connect' | 'disconnect' | 'configure' | 'authenticate' | 'search' | 'setup';
|
|
8
|
+
export type OGIAddonClientSentEvent = 'response' | 'authenticate' | 'configure' | 'defer-update' | 'notification';
|
|
9
|
+
export type OGIAddonServerSentEvent = 'authenticate' | 'configure' | 'config-update' | 'search' | 'setup';
|
|
10
|
+
export { ConfigurationBuilder, Configuration, EventResponse, SearchResult };
|
|
11
|
+
export interface ClientSentEventTypes {
|
|
12
|
+
response: any;
|
|
13
|
+
authenticate: any;
|
|
14
|
+
configure: ConfigurationFile;
|
|
15
|
+
'defer-update': {
|
|
16
|
+
logs: string[];
|
|
17
|
+
progress: number;
|
|
18
|
+
};
|
|
19
|
+
notification: Notification;
|
|
20
|
+
}
|
|
21
|
+
export interface EventListenerTypes {
|
|
22
|
+
connect: (socket: ws) => void;
|
|
23
|
+
disconnect: (reason: string) => void;
|
|
24
|
+
configure: (config: ConfigurationBuilder) => ConfigurationBuilder;
|
|
25
|
+
response: (response: any) => void;
|
|
26
|
+
authenticate: (config: any) => void;
|
|
27
|
+
search: (query: string, event: EventResponse<SearchResult[]>) => void;
|
|
28
|
+
setup: (path: string, event: EventResponse<undefined | null>) => void;
|
|
29
|
+
}
|
|
30
|
+
export interface WebsocketMessageClient {
|
|
31
|
+
event: OGIAddonClientSentEvent;
|
|
32
|
+
id?: string;
|
|
33
|
+
args: any;
|
|
34
|
+
}
|
|
35
|
+
export interface WebsocketMessageServer {
|
|
36
|
+
event: OGIAddonServerSentEvent;
|
|
37
|
+
id?: string;
|
|
38
|
+
args: any;
|
|
39
|
+
}
|
|
40
|
+
export interface OGIAddonConfiguration {
|
|
41
|
+
name: string;
|
|
42
|
+
id: string;
|
|
43
|
+
description: string;
|
|
44
|
+
version: string;
|
|
45
|
+
author: string;
|
|
46
|
+
repository: string;
|
|
47
|
+
}
|
|
48
|
+
export default class OGIAddon {
|
|
49
|
+
eventEmitter: events<[never]>;
|
|
50
|
+
addonWSListener: OGIAddonWSListener;
|
|
51
|
+
addonInfo: OGIAddonConfiguration;
|
|
52
|
+
config: Configuration;
|
|
53
|
+
constructor(addonInfo: OGIAddonConfiguration);
|
|
54
|
+
on<T extends OGIAddonEvent>(event: T, listener: EventListenerTypes[T]): void;
|
|
55
|
+
emit<T extends OGIAddonEvent>(event: T, ...args: Parameters<EventListenerTypes[T]>): void;
|
|
56
|
+
notify(notification: Notification): void;
|
|
57
|
+
}
|
|
58
|
+
interface Notification {
|
|
59
|
+
type: 'warning' | 'error' | 'info' | 'success';
|
|
60
|
+
message: string;
|
|
61
|
+
id: string;
|
|
62
|
+
}
|
|
63
|
+
declare class OGIAddonWSListener {
|
|
64
|
+
private socket;
|
|
65
|
+
eventEmitter: events.EventEmitter;
|
|
66
|
+
addon: OGIAddon;
|
|
67
|
+
constructor(ogiAddon: OGIAddon, eventEmitter: events.EventEmitter);
|
|
68
|
+
private registerMessageReceiver;
|
|
69
|
+
private waitForEventToRespond;
|
|
70
|
+
respondToMessage(messageID: string, response: any): void;
|
|
71
|
+
send(event: OGIAddonClientSentEvent, args: Parameters<ClientSentEventTypes[OGIAddonClientSentEvent]>): void;
|
|
72
|
+
close(): void;
|
|
73
|
+
}
|
package/build/main.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import ws from 'ws';
|
|
11
|
+
import events from 'node:events';
|
|
12
|
+
import { ConfigurationBuilder } from './config/ConfigurationBuilder';
|
|
13
|
+
import { Configuration } from './config/Configuration';
|
|
14
|
+
import EventResponse from './EventResponse';
|
|
15
|
+
export { ConfigurationBuilder, Configuration, EventResponse };
|
|
16
|
+
const defaultPort = 7654;
|
|
17
|
+
export default class OGIAddon {
|
|
18
|
+
constructor(addonInfo) {
|
|
19
|
+
this.eventEmitter = new events.EventEmitter();
|
|
20
|
+
this.config = new Configuration({});
|
|
21
|
+
this.addonInfo = addonInfo;
|
|
22
|
+
this.addonWSListener = new OGIAddonWSListener(this, this.eventEmitter);
|
|
23
|
+
}
|
|
24
|
+
on(event, listener) {
|
|
25
|
+
this.eventEmitter.on(event, listener);
|
|
26
|
+
}
|
|
27
|
+
emit(event, ...args) {
|
|
28
|
+
this.eventEmitter.emit(event, ...args);
|
|
29
|
+
}
|
|
30
|
+
notify(notification) {
|
|
31
|
+
this.addonWSListener.send('notification', [notification]);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
class OGIAddonWSListener {
|
|
35
|
+
constructor(ogiAddon, eventEmitter) {
|
|
36
|
+
if (process.argv[process.argv.length - 1].split('=')[0] !== '--addonSecret') {
|
|
37
|
+
throw new Error('No secret provided. This usually happens because the addon was not started by the OGI Addon Server.');
|
|
38
|
+
}
|
|
39
|
+
this.addon = ogiAddon;
|
|
40
|
+
this.eventEmitter = eventEmitter;
|
|
41
|
+
this.socket = new ws('ws://localhost:' + defaultPort);
|
|
42
|
+
this.socket.on('open', () => {
|
|
43
|
+
console.log('Connected to OGI Addon Server');
|
|
44
|
+
this.socket.send(JSON.stringify({
|
|
45
|
+
event: 'authenticate',
|
|
46
|
+
args: Object.assign(Object.assign({}, this.addon.addonInfo), { secret: process.argv[process.argv.length - 1].split('=')[1] })
|
|
47
|
+
}));
|
|
48
|
+
this.eventEmitter.emit('connect');
|
|
49
|
+
let configBuilder = new ConfigurationBuilder();
|
|
50
|
+
this.eventEmitter.emit('configure', configBuilder);
|
|
51
|
+
this.socket.send(JSON.stringify({
|
|
52
|
+
event: 'configure',
|
|
53
|
+
args: configBuilder.build(false)
|
|
54
|
+
}));
|
|
55
|
+
this.addon.config = new Configuration(configBuilder.build(true));
|
|
56
|
+
});
|
|
57
|
+
this.socket.on('error', (error) => {
|
|
58
|
+
if (error.message.includes('Failed to connect')) {
|
|
59
|
+
throw new Error('OGI Addon Server is not running/is unreachable. Please start the server and try again.');
|
|
60
|
+
}
|
|
61
|
+
console.error('An error occurred:', error);
|
|
62
|
+
});
|
|
63
|
+
this.socket.on('close', (code, reason) => {
|
|
64
|
+
if (code === 1008) {
|
|
65
|
+
console.error('Authentication failed:', reason);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
this.eventEmitter.emit('disconnect', reason);
|
|
69
|
+
console.log("Disconnected from OGI Addon Server");
|
|
70
|
+
this.socket.close();
|
|
71
|
+
});
|
|
72
|
+
this.registerMessageReceiver();
|
|
73
|
+
}
|
|
74
|
+
registerMessageReceiver() {
|
|
75
|
+
this.socket.on('message', (data) => __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
const message = JSON.parse(data);
|
|
77
|
+
switch (message.event) {
|
|
78
|
+
case 'config-update':
|
|
79
|
+
const result = this.addon.config.updateConfig(message.args);
|
|
80
|
+
if (!result[0]) {
|
|
81
|
+
this.respondToMessage(message.id, { success: false, error: result[1] });
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
this.respondToMessage(message.id, { success: true });
|
|
85
|
+
}
|
|
86
|
+
break;
|
|
87
|
+
case 'search':
|
|
88
|
+
let searchResultEvent = new EventResponse();
|
|
89
|
+
this.eventEmitter.emit('search', message.args, searchResultEvent);
|
|
90
|
+
const searchResult = yield this.waitForEventToRespond(searchResultEvent);
|
|
91
|
+
console.log(searchResult.data);
|
|
92
|
+
this.respondToMessage(message.id, searchResult.data);
|
|
93
|
+
break;
|
|
94
|
+
case 'setup':
|
|
95
|
+
let setupEvent = new EventResponse();
|
|
96
|
+
this.eventEmitter.emit('setup', message.args.path, setupEvent);
|
|
97
|
+
const interval = setInterval(() => {
|
|
98
|
+
if (setupEvent.resolved) {
|
|
99
|
+
clearInterval(interval);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
this.send('defer-update', {
|
|
103
|
+
logs: setupEvent.logs,
|
|
104
|
+
deferID: message.args.deferID,
|
|
105
|
+
progress: setupEvent.progress
|
|
106
|
+
});
|
|
107
|
+
}, 100);
|
|
108
|
+
const setupResult = yield this.waitForEventToRespond(setupEvent);
|
|
109
|
+
this.respondToMessage(message.id, setupResult.data);
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
114
|
+
waitForEventToRespond(event) {
|
|
115
|
+
return new Promise((resolve, reject) => {
|
|
116
|
+
const dataGet = setInterval(() => {
|
|
117
|
+
if (event.resolved) {
|
|
118
|
+
resolve(event);
|
|
119
|
+
clearTimeout(timeout);
|
|
120
|
+
}
|
|
121
|
+
}, 5);
|
|
122
|
+
const timeout = setTimeout(() => {
|
|
123
|
+
if (event.deffered) {
|
|
124
|
+
clearInterval(dataGet);
|
|
125
|
+
const interval = setInterval(() => {
|
|
126
|
+
if (event.resolved) {
|
|
127
|
+
clearInterval(interval);
|
|
128
|
+
resolve(event);
|
|
129
|
+
}
|
|
130
|
+
}, 100);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
reject('Event did not respond in time');
|
|
134
|
+
}
|
|
135
|
+
}, 5000);
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
respondToMessage(messageID, response) {
|
|
139
|
+
this.socket.send(JSON.stringify({
|
|
140
|
+
event: 'response',
|
|
141
|
+
id: messageID,
|
|
142
|
+
args: response
|
|
143
|
+
}));
|
|
144
|
+
console.log("dispatched response to " + messageID);
|
|
145
|
+
}
|
|
146
|
+
send(event, args) {
|
|
147
|
+
this.socket.send(JSON.stringify({
|
|
148
|
+
event,
|
|
149
|
+
args
|
|
150
|
+
}));
|
|
151
|
+
}
|
|
152
|
+
close() {
|
|
153
|
+
this.socket.close();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"/","sources":["main.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAiB,MAAM,IAAI,CAAC;AACnC,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,oBAAoB,EAAqB,MAAM,+BAA+B,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAO5C,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,aAAa,EAAgB,CAAC;AAC5E,MAAM,WAAW,GAAG,IAAI,CAAC;AA0CzB,MAAM,CAAC,OAAO,OAAO,QAAQ;IAM3B,YAAY,SAAgC;QALrC,iBAAY,GAAG,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;QAGzC,WAAM,GAAkB,IAAI,aAAa,CAA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AE;gBAC9B,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;oBACnB,aAAa,CAAC,OAAO,CAAC,CAAC;oBACvB,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE;wBAChC,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;4BACnB,aAAa,CAAC,QAAQ,CAAC,CAAC;4BACxB,OAAO,CAAC,KAAK,CAAC,CAAC;wBACjB,CAAC;oBACH,CAAC,EAAE,GAAG,CAAC,CAAC;gBACV,CAAC;qBACI,CAAC;oBACJ,MAAM,CAAC,+BAA+B,CAAC,CAAC;gBAC1C,CAAC;YACH,CAAC,EAAE,IAAI,CAAC,CAAA;QACV,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,gBAAgB,CAAC,SAAiB,EAAE,QAAa;QACtD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;YAC9B,KAAK,EAAE,UAAU;YACjB,EAAE,EAAE,SAAS;YACb,IAAI,EAAE,QAAQ;SACf,CAAC,CAAC,CAAC;QACJ,OAAO,CAAC,GAAG,CAAC,yBAAyB,GAAG,SAAS,CAAC,CAAA;IACpD,CAAC;IAEM,IAAI,CAAC,KAA8B,EAAE,IAA+D;QACzG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;YAC9B,KAAK;YACL,IAAI;SACL,CAAC,CAAC,CAAC;IACN,CAAC;IAEM,KAAK;QACV,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;CAGF"}
|
package/package.json
CHANGED
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
"email": "me@nat3z.com",
|
|
9
9
|
"url": "https://nat3z.com/"
|
|
10
10
|
},
|
|
11
|
-
"version": "0.1.
|
|
11
|
+
"version": "0.1.1",
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"ws": "^8.4.0",
|
|
14
14
|
"zod": "^3.23.8"
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
17
|
"auto-build": "tsc -w",
|
|
18
|
-
"
|
|
18
|
+
"release": "bunx tsc && npm publish"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@types/ws": "^8.4.0",
|