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.d.ts CHANGED
@@ -1,14 +1,102 @@
1
1
  import ws from 'ws';
2
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 {
3
+
4
+ interface ConfigurationFile {
5
+ [key: string]: ConfigurationOption;
6
+ }
7
+ 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
+ type ConfigurationOptionType = 'string' | 'number' | 'boolean' | 'unset';
15
+ 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
+ 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
+ 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
+ declare class BooleanOption extends ConfigurationOption {
51
+ type: ConfigurationOptionType;
52
+ defaultValue: boolean;
53
+ setDefaultValue(defaultValue: boolean): this;
54
+ validate(input: unknown): [boolean, string];
55
+ }
56
+
57
+ interface DefiniteConfig {
58
+ [key: string]: string | number | boolean;
59
+ }
60
+ declare class Configuration {
61
+ readonly storedConfigTemplate: ConfigurationFile;
62
+ definiteConfig: DefiniteConfig;
63
+ constructor(configTemplate: ConfigurationFile);
64
+ updateConfig(config: DefiniteConfig, validate?: boolean): [boolean, {
65
+ [key: string]: string;
66
+ }];
67
+ private validateConfig;
68
+ getStringValue(optionName: string): string;
69
+ getNumberValue(optionName: string): number;
70
+ getBooleanValue(optionName: string): boolean;
71
+ }
72
+
73
+ declare class EventResponse<T> {
74
+ data: T | undefined;
75
+ deffered: boolean;
76
+ resolved: boolean;
77
+ progress: number;
78
+ logs: string[];
79
+ defer(): void;
80
+ resolve(data: T): void;
81
+ complete(): void;
82
+ log(message: string): void;
83
+ }
84
+
85
+ interface SearchResult {
86
+ name: string;
87
+ description: string;
88
+ coverURL: string;
89
+ downloadURL: string;
90
+ downloadType: 'torrent' | 'direct' | 'real-debrid-magnet' | 'real-debrid-torrent';
91
+ downloadSize: number;
92
+ filename?: string;
93
+ }
94
+
95
+ type OGIAddonEvent = 'connect' | 'disconnect' | 'configure' | 'authenticate' | 'search' | 'setup';
96
+ type OGIAddonClientSentEvent = 'response' | 'authenticate' | 'configure' | 'defer-update' | 'notification';
97
+ type OGIAddonServerSentEvent = 'authenticate' | 'configure' | 'config-update' | 'search' | 'setup';
98
+
99
+ interface ClientSentEventTypes {
12
100
  response: any;
13
101
  authenticate: any;
14
102
  configure: ConfigurationFile;
@@ -18,7 +106,7 @@ export interface ClientSentEventTypes {
18
106
  };
19
107
  notification: Notification;
20
108
  }
21
- export interface EventListenerTypes {
109
+ interface EventListenerTypes {
22
110
  connect: (socket: ws) => void;
23
111
  disconnect: (reason: string) => void;
24
112
  configure: (config: ConfigurationBuilder) => ConfigurationBuilder;
@@ -27,17 +115,17 @@ export interface EventListenerTypes {
27
115
  search: (query: string, event: EventResponse<SearchResult[]>) => void;
28
116
  setup: (path: string, event: EventResponse<undefined | null>) => void;
29
117
  }
30
- export interface WebsocketMessageClient {
118
+ interface WebsocketMessageClient {
31
119
  event: OGIAddonClientSentEvent;
32
120
  id?: string;
33
121
  args: any;
34
122
  }
35
- export interface WebsocketMessageServer {
123
+ interface WebsocketMessageServer {
36
124
  event: OGIAddonServerSentEvent;
37
125
  id?: string;
38
126
  args: any;
39
127
  }
40
- export interface OGIAddonConfiguration {
128
+ interface OGIAddonConfiguration {
41
129
  name: string;
42
130
  id: string;
43
131
  description: string;
@@ -45,7 +133,7 @@ export interface OGIAddonConfiguration {
45
133
  author: string;
46
134
  repository: string;
47
135
  }
48
- export default class OGIAddon {
136
+ declare class OGIAddon {
49
137
  eventEmitter: events<[never]>;
50
138
  addonWSListener: OGIAddonWSListener;
51
139
  addonInfo: OGIAddonConfiguration;
@@ -71,3 +159,5 @@ declare class OGIAddonWSListener {
71
159
  send(event: OGIAddonClientSentEvent, args: Parameters<ClientSentEventTypes[OGIAddonClientSentEvent]>): void;
72
160
  close(): void;
73
161
  }
162
+
163
+ export { type ClientSentEventTypes, Configuration, ConfigurationBuilder, type EventListenerTypes, EventResponse, type OGIAddonClientSentEvent, type OGIAddonConfiguration, type OGIAddonEvent, type OGIAddonServerSentEvent, type SearchResult, type WebsocketMessageClient, type WebsocketMessageServer, OGIAddon as default };