@svintsow/discord-components 1.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/README.md +8 -0
- package/dist/index.d.mts +289 -0
- package/dist/index.d.ts +289 -0
- package/dist/index.js +923 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +868 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +64 -0
package/README.md
ADDED
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
declare enum ComponentType {
|
|
2
|
+
Container = 1,
|
|
3
|
+
Section = 2,
|
|
4
|
+
TextDisplay = 3,
|
|
5
|
+
Thumbnail = 4,
|
|
6
|
+
MediaGallery = 5,
|
|
7
|
+
MediaGalleryItem = 6,
|
|
8
|
+
Separator = 7,
|
|
9
|
+
File = 8,
|
|
10
|
+
Label = 9
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare const Limits: {
|
|
14
|
+
readonly MAX_COMPONENTS_PER_CONTAINER: 5;
|
|
15
|
+
readonly MAX_TEXT_LENGTH: 2000;
|
|
16
|
+
readonly MAX_DESCRIPTION_LENGTH: 2000;
|
|
17
|
+
readonly MAX_LABEL_LENGTH: 80;
|
|
18
|
+
readonly MAX_FILENAME_LENGTH: 255;
|
|
19
|
+
readonly MAX_GALLERY_ITEMS: 10;
|
|
20
|
+
readonly MAX_URL_LENGTH: 2048;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
declare class ValidationError extends Error {
|
|
24
|
+
constructor(message: string);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
declare class InvalidComponentError extends Error {
|
|
28
|
+
constructor(message: string);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare class InvalidURLException extends Error {
|
|
32
|
+
constructor(message: string);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
declare class ComponentLimitError extends Error {
|
|
36
|
+
constructor(message: string);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface IComponentBuilder {
|
|
40
|
+
toJSON(): Record<string, any>;
|
|
41
|
+
clone(): this;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
declare abstract class ComponentBuilder implements IComponentBuilder {
|
|
45
|
+
abstract toJSON(): Record<string, any>;
|
|
46
|
+
clone(): this;
|
|
47
|
+
static from<T extends ComponentBuilder>(this: new (...args: any[]) => T, data: any): T;
|
|
48
|
+
protected fromJSON(data: any): this;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
declare abstract class AccessoryBuilder extends ComponentBuilder {
|
|
52
|
+
protected type: ComponentType;
|
|
53
|
+
protected style?: string;
|
|
54
|
+
setStyle(style: string): this;
|
|
55
|
+
toJSON(): Record<string, any>;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
declare class ContainerBuilder extends ComponentBuilder {
|
|
59
|
+
private components;
|
|
60
|
+
private type;
|
|
61
|
+
constructor();
|
|
62
|
+
addComponents(...components: ComponentBuilder[]): this;
|
|
63
|
+
spliceComponents(index: number, deleteCount: number, ...components: ComponentBuilder[]): this;
|
|
64
|
+
clearComponents(): this;
|
|
65
|
+
toJSON(): Record<string, any>;
|
|
66
|
+
protected fromJSON(data: any): this;
|
|
67
|
+
clone(): this;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
declare class SectionBuilder extends ComponentBuilder {
|
|
71
|
+
private texts;
|
|
72
|
+
private accessory;
|
|
73
|
+
constructor();
|
|
74
|
+
addText(...textComponents: ComponentBuilder[]): this;
|
|
75
|
+
setAccessory(accessory: AccessoryBuilder): this;
|
|
76
|
+
clearAccessory(): this;
|
|
77
|
+
toJSON(): Record<string, any>;
|
|
78
|
+
protected fromJSON(data: any): this;
|
|
79
|
+
clone(): this;
|
|
80
|
+
private type;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
declare class TextDisplayBuilder extends ComponentBuilder {
|
|
84
|
+
private content;
|
|
85
|
+
constructor();
|
|
86
|
+
setContent(text: string): this;
|
|
87
|
+
toJSON(): Record<string, any>;
|
|
88
|
+
protected fromJSON(data: any): this;
|
|
89
|
+
clone(): this;
|
|
90
|
+
private type;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
declare class ThumbnailBuilder extends ComponentBuilder {
|
|
94
|
+
private url;
|
|
95
|
+
private description;
|
|
96
|
+
private spoiler;
|
|
97
|
+
constructor();
|
|
98
|
+
setURL(url: string): this;
|
|
99
|
+
setDescription(text: string): this;
|
|
100
|
+
setSpoiler(spoiler: boolean): this;
|
|
101
|
+
toJSON(): Record<string, any>;
|
|
102
|
+
protected fromJSON(data: any): this;
|
|
103
|
+
clone(): this;
|
|
104
|
+
private type;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
declare class MediaGalleryItemBuilder extends ComponentBuilder {
|
|
108
|
+
private url;
|
|
109
|
+
private description;
|
|
110
|
+
private spoiler;
|
|
111
|
+
constructor();
|
|
112
|
+
setURL(url: string): this;
|
|
113
|
+
setDescription(text: string): this;
|
|
114
|
+
setSpoiler(spoiler: boolean): this;
|
|
115
|
+
toJSON(): Record<string, any>;
|
|
116
|
+
protected fromJSON(data: any): this;
|
|
117
|
+
clone(): this;
|
|
118
|
+
private type;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
declare class MediaGalleryBuilder extends ComponentBuilder {
|
|
122
|
+
private items;
|
|
123
|
+
constructor();
|
|
124
|
+
addItems(...items: MediaGalleryItemBuilder[]): this;
|
|
125
|
+
spliceItems(index: number, deleteCount: number, ...items: MediaGalleryItemBuilder[]): this;
|
|
126
|
+
clearItems(): this;
|
|
127
|
+
toJSON(): Record<string, any>;
|
|
128
|
+
protected fromJSON(data: any): this;
|
|
129
|
+
clone(): this;
|
|
130
|
+
private type;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
declare class SeparatorBuilder extends ComponentBuilder {
|
|
134
|
+
private spacing;
|
|
135
|
+
private divider;
|
|
136
|
+
constructor();
|
|
137
|
+
setSpacing(spacing: number): this;
|
|
138
|
+
setDivider(divider: boolean): this;
|
|
139
|
+
toJSON(): Record<string, any>;
|
|
140
|
+
protected fromJSON(data: any): this;
|
|
141
|
+
clone(): this;
|
|
142
|
+
private type;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
declare class FileBuilder extends ComponentBuilder {
|
|
146
|
+
private url;
|
|
147
|
+
private filename;
|
|
148
|
+
private description;
|
|
149
|
+
constructor();
|
|
150
|
+
setURL(url: string): this;
|
|
151
|
+
setFilename(name: string): this;
|
|
152
|
+
setDescription(text: string): this;
|
|
153
|
+
toJSON(): Record<string, any>;
|
|
154
|
+
protected fromJSON(data: any): this;
|
|
155
|
+
clone(): this;
|
|
156
|
+
private type;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
declare class LabelBuilder extends ComponentBuilder {
|
|
160
|
+
private label;
|
|
161
|
+
private description;
|
|
162
|
+
constructor();
|
|
163
|
+
setLabel(text: string): this;
|
|
164
|
+
setDescription(text: string): this;
|
|
165
|
+
toJSON(): Record<string, any>;
|
|
166
|
+
protected fromJSON(data: any): this;
|
|
167
|
+
clone(): this;
|
|
168
|
+
private type;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
type AnyComponentBuilder = ContainerBuilder | SectionBuilder | TextDisplayBuilder | ThumbnailBuilder | MediaGalleryBuilder | MediaGalleryItemBuilder | SeparatorBuilder | FileBuilder | LabelBuilder;
|
|
172
|
+
type ComponentJSON = ContainerJSON | SectionJSON | TextDisplayJSON | ThumbnailJSON | MediaGalleryJSON | SeparatorJSON | FileJSON | LabelJSON;
|
|
173
|
+
interface ContainerJSON {
|
|
174
|
+
type: number;
|
|
175
|
+
components: ComponentJSON[];
|
|
176
|
+
}
|
|
177
|
+
interface SectionJSON {
|
|
178
|
+
type: number;
|
|
179
|
+
texts: ComponentJSON[];
|
|
180
|
+
accessory?: AccessoryJSON;
|
|
181
|
+
}
|
|
182
|
+
interface TextDisplayJSON {
|
|
183
|
+
type: number;
|
|
184
|
+
content: string;
|
|
185
|
+
}
|
|
186
|
+
interface ThumbnailJSON {
|
|
187
|
+
type: number;
|
|
188
|
+
url: string;
|
|
189
|
+
description?: string;
|
|
190
|
+
spoiler?: boolean;
|
|
191
|
+
}
|
|
192
|
+
interface MediaGalleryJSON {
|
|
193
|
+
type: number;
|
|
194
|
+
items: MediaGalleryItemJSON[];
|
|
195
|
+
}
|
|
196
|
+
interface MediaGalleryItemJSON {
|
|
197
|
+
type: number;
|
|
198
|
+
url: string;
|
|
199
|
+
description?: string;
|
|
200
|
+
spoiler?: boolean;
|
|
201
|
+
}
|
|
202
|
+
interface SeparatorJSON {
|
|
203
|
+
type: number;
|
|
204
|
+
spacing: number;
|
|
205
|
+
divider?: boolean;
|
|
206
|
+
}
|
|
207
|
+
interface FileJSON {
|
|
208
|
+
type: number;
|
|
209
|
+
url: string;
|
|
210
|
+
filename: string;
|
|
211
|
+
description?: string;
|
|
212
|
+
}
|
|
213
|
+
interface LabelJSON {
|
|
214
|
+
type: number;
|
|
215
|
+
label: string;
|
|
216
|
+
description?: string;
|
|
217
|
+
}
|
|
218
|
+
interface AccessoryJSON {
|
|
219
|
+
type: number;
|
|
220
|
+
style?: string;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
declare class URLValidator {
|
|
224
|
+
static validate(url: string): void;
|
|
225
|
+
static validateOptional(url?: string): void;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
declare class StringValidator {
|
|
229
|
+
static validate(value: any, field: string): void;
|
|
230
|
+
static validateLength(value: string, maxLength: number, field: string): void;
|
|
231
|
+
static validateOptional(value?: any, field?: string): void;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
declare class ComponentValidator {
|
|
235
|
+
static validateType(type: ComponentType): void;
|
|
236
|
+
static validateComponentStructure(obj: any): void;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
declare class LimitRules {
|
|
240
|
+
static validateComponentCount(count: number): void;
|
|
241
|
+
static validateGalleryItems(count: number): void;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
declare class NestingRules {
|
|
245
|
+
static validateContainerNesting(componentType: ComponentType): void;
|
|
246
|
+
static validateSectionNesting(componentType: ComponentType): void;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
declare class UrlUtils {
|
|
250
|
+
static isValidUrl(url: string): boolean;
|
|
251
|
+
static normalizeUrl(url: string): string;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
declare class StringUtils {
|
|
255
|
+
static isString(value: any): value is string;
|
|
256
|
+
static truncate(text: string, maxLength: number): string;
|
|
257
|
+
static validateLength(text: string, maxLength: number, field: string): void;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
declare class ArrayUtils {
|
|
261
|
+
static isValidArray<T>(arr: any): arr is T[];
|
|
262
|
+
static ensureArray<T>(items: T | T[]): T[];
|
|
263
|
+
static splice<T>(arr: T[], index: number, deleteCount: number, ...items: T[]): T[];
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
declare class ObjectUtils {
|
|
267
|
+
static deepClone<T>(obj: T): T;
|
|
268
|
+
static hasOwnProperty(obj: any, prop: string): boolean;
|
|
269
|
+
static mergeDeep<T extends Record<string, any>>(target: T, source: Partial<T>): T;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
declare class ComponentHelper {
|
|
273
|
+
static createTextSection(text: string): SectionBuilder;
|
|
274
|
+
static createContainerFrom(...components: ComponentBuilder[]): ContainerBuilder;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
declare class ComponentParser {
|
|
278
|
+
static parse(data: any): ComponentBuilder;
|
|
279
|
+
static parseMany(dataArray: any[]): ComponentBuilder[];
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
declare class ComponentRegistry {
|
|
283
|
+
private static builders;
|
|
284
|
+
static register(name: string, builder: typeof ComponentBuilder): void;
|
|
285
|
+
static get(name: string): typeof ComponentBuilder | undefined;
|
|
286
|
+
static has(name: string): boolean;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export { AccessoryBuilder, AccessoryJSON, AnyComponentBuilder, ArrayUtils, ComponentBuilder, ComponentHelper, ComponentJSON, ComponentLimitError, ComponentParser, ComponentRegistry, ComponentType, ComponentValidator, ContainerBuilder, ContainerJSON, FileBuilder, FileJSON, IComponentBuilder, InvalidComponentError, InvalidURLException, LabelBuilder, LabelJSON, LimitRules, Limits, MediaGalleryBuilder, MediaGalleryItemBuilder, MediaGalleryItemJSON, MediaGalleryJSON, NestingRules, ObjectUtils, SectionBuilder, SectionJSON, SeparatorBuilder, SeparatorJSON, StringUtils, StringValidator, TextDisplayBuilder, TextDisplayJSON, ThumbnailBuilder, ThumbnailJSON, URLValidator, UrlUtils, ValidationError };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
declare enum ComponentType {
|
|
2
|
+
Container = 1,
|
|
3
|
+
Section = 2,
|
|
4
|
+
TextDisplay = 3,
|
|
5
|
+
Thumbnail = 4,
|
|
6
|
+
MediaGallery = 5,
|
|
7
|
+
MediaGalleryItem = 6,
|
|
8
|
+
Separator = 7,
|
|
9
|
+
File = 8,
|
|
10
|
+
Label = 9
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare const Limits: {
|
|
14
|
+
readonly MAX_COMPONENTS_PER_CONTAINER: 5;
|
|
15
|
+
readonly MAX_TEXT_LENGTH: 2000;
|
|
16
|
+
readonly MAX_DESCRIPTION_LENGTH: 2000;
|
|
17
|
+
readonly MAX_LABEL_LENGTH: 80;
|
|
18
|
+
readonly MAX_FILENAME_LENGTH: 255;
|
|
19
|
+
readonly MAX_GALLERY_ITEMS: 10;
|
|
20
|
+
readonly MAX_URL_LENGTH: 2048;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
declare class ValidationError extends Error {
|
|
24
|
+
constructor(message: string);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
declare class InvalidComponentError extends Error {
|
|
28
|
+
constructor(message: string);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare class InvalidURLException extends Error {
|
|
32
|
+
constructor(message: string);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
declare class ComponentLimitError extends Error {
|
|
36
|
+
constructor(message: string);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface IComponentBuilder {
|
|
40
|
+
toJSON(): Record<string, any>;
|
|
41
|
+
clone(): this;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
declare abstract class ComponentBuilder implements IComponentBuilder {
|
|
45
|
+
abstract toJSON(): Record<string, any>;
|
|
46
|
+
clone(): this;
|
|
47
|
+
static from<T extends ComponentBuilder>(this: new (...args: any[]) => T, data: any): T;
|
|
48
|
+
protected fromJSON(data: any): this;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
declare abstract class AccessoryBuilder extends ComponentBuilder {
|
|
52
|
+
protected type: ComponentType;
|
|
53
|
+
protected style?: string;
|
|
54
|
+
setStyle(style: string): this;
|
|
55
|
+
toJSON(): Record<string, any>;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
declare class ContainerBuilder extends ComponentBuilder {
|
|
59
|
+
private components;
|
|
60
|
+
private type;
|
|
61
|
+
constructor();
|
|
62
|
+
addComponents(...components: ComponentBuilder[]): this;
|
|
63
|
+
spliceComponents(index: number, deleteCount: number, ...components: ComponentBuilder[]): this;
|
|
64
|
+
clearComponents(): this;
|
|
65
|
+
toJSON(): Record<string, any>;
|
|
66
|
+
protected fromJSON(data: any): this;
|
|
67
|
+
clone(): this;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
declare class SectionBuilder extends ComponentBuilder {
|
|
71
|
+
private texts;
|
|
72
|
+
private accessory;
|
|
73
|
+
constructor();
|
|
74
|
+
addText(...textComponents: ComponentBuilder[]): this;
|
|
75
|
+
setAccessory(accessory: AccessoryBuilder): this;
|
|
76
|
+
clearAccessory(): this;
|
|
77
|
+
toJSON(): Record<string, any>;
|
|
78
|
+
protected fromJSON(data: any): this;
|
|
79
|
+
clone(): this;
|
|
80
|
+
private type;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
declare class TextDisplayBuilder extends ComponentBuilder {
|
|
84
|
+
private content;
|
|
85
|
+
constructor();
|
|
86
|
+
setContent(text: string): this;
|
|
87
|
+
toJSON(): Record<string, any>;
|
|
88
|
+
protected fromJSON(data: any): this;
|
|
89
|
+
clone(): this;
|
|
90
|
+
private type;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
declare class ThumbnailBuilder extends ComponentBuilder {
|
|
94
|
+
private url;
|
|
95
|
+
private description;
|
|
96
|
+
private spoiler;
|
|
97
|
+
constructor();
|
|
98
|
+
setURL(url: string): this;
|
|
99
|
+
setDescription(text: string): this;
|
|
100
|
+
setSpoiler(spoiler: boolean): this;
|
|
101
|
+
toJSON(): Record<string, any>;
|
|
102
|
+
protected fromJSON(data: any): this;
|
|
103
|
+
clone(): this;
|
|
104
|
+
private type;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
declare class MediaGalleryItemBuilder extends ComponentBuilder {
|
|
108
|
+
private url;
|
|
109
|
+
private description;
|
|
110
|
+
private spoiler;
|
|
111
|
+
constructor();
|
|
112
|
+
setURL(url: string): this;
|
|
113
|
+
setDescription(text: string): this;
|
|
114
|
+
setSpoiler(spoiler: boolean): this;
|
|
115
|
+
toJSON(): Record<string, any>;
|
|
116
|
+
protected fromJSON(data: any): this;
|
|
117
|
+
clone(): this;
|
|
118
|
+
private type;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
declare class MediaGalleryBuilder extends ComponentBuilder {
|
|
122
|
+
private items;
|
|
123
|
+
constructor();
|
|
124
|
+
addItems(...items: MediaGalleryItemBuilder[]): this;
|
|
125
|
+
spliceItems(index: number, deleteCount: number, ...items: MediaGalleryItemBuilder[]): this;
|
|
126
|
+
clearItems(): this;
|
|
127
|
+
toJSON(): Record<string, any>;
|
|
128
|
+
protected fromJSON(data: any): this;
|
|
129
|
+
clone(): this;
|
|
130
|
+
private type;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
declare class SeparatorBuilder extends ComponentBuilder {
|
|
134
|
+
private spacing;
|
|
135
|
+
private divider;
|
|
136
|
+
constructor();
|
|
137
|
+
setSpacing(spacing: number): this;
|
|
138
|
+
setDivider(divider: boolean): this;
|
|
139
|
+
toJSON(): Record<string, any>;
|
|
140
|
+
protected fromJSON(data: any): this;
|
|
141
|
+
clone(): this;
|
|
142
|
+
private type;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
declare class FileBuilder extends ComponentBuilder {
|
|
146
|
+
private url;
|
|
147
|
+
private filename;
|
|
148
|
+
private description;
|
|
149
|
+
constructor();
|
|
150
|
+
setURL(url: string): this;
|
|
151
|
+
setFilename(name: string): this;
|
|
152
|
+
setDescription(text: string): this;
|
|
153
|
+
toJSON(): Record<string, any>;
|
|
154
|
+
protected fromJSON(data: any): this;
|
|
155
|
+
clone(): this;
|
|
156
|
+
private type;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
declare class LabelBuilder extends ComponentBuilder {
|
|
160
|
+
private label;
|
|
161
|
+
private description;
|
|
162
|
+
constructor();
|
|
163
|
+
setLabel(text: string): this;
|
|
164
|
+
setDescription(text: string): this;
|
|
165
|
+
toJSON(): Record<string, any>;
|
|
166
|
+
protected fromJSON(data: any): this;
|
|
167
|
+
clone(): this;
|
|
168
|
+
private type;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
type AnyComponentBuilder = ContainerBuilder | SectionBuilder | TextDisplayBuilder | ThumbnailBuilder | MediaGalleryBuilder | MediaGalleryItemBuilder | SeparatorBuilder | FileBuilder | LabelBuilder;
|
|
172
|
+
type ComponentJSON = ContainerJSON | SectionJSON | TextDisplayJSON | ThumbnailJSON | MediaGalleryJSON | SeparatorJSON | FileJSON | LabelJSON;
|
|
173
|
+
interface ContainerJSON {
|
|
174
|
+
type: number;
|
|
175
|
+
components: ComponentJSON[];
|
|
176
|
+
}
|
|
177
|
+
interface SectionJSON {
|
|
178
|
+
type: number;
|
|
179
|
+
texts: ComponentJSON[];
|
|
180
|
+
accessory?: AccessoryJSON;
|
|
181
|
+
}
|
|
182
|
+
interface TextDisplayJSON {
|
|
183
|
+
type: number;
|
|
184
|
+
content: string;
|
|
185
|
+
}
|
|
186
|
+
interface ThumbnailJSON {
|
|
187
|
+
type: number;
|
|
188
|
+
url: string;
|
|
189
|
+
description?: string;
|
|
190
|
+
spoiler?: boolean;
|
|
191
|
+
}
|
|
192
|
+
interface MediaGalleryJSON {
|
|
193
|
+
type: number;
|
|
194
|
+
items: MediaGalleryItemJSON[];
|
|
195
|
+
}
|
|
196
|
+
interface MediaGalleryItemJSON {
|
|
197
|
+
type: number;
|
|
198
|
+
url: string;
|
|
199
|
+
description?: string;
|
|
200
|
+
spoiler?: boolean;
|
|
201
|
+
}
|
|
202
|
+
interface SeparatorJSON {
|
|
203
|
+
type: number;
|
|
204
|
+
spacing: number;
|
|
205
|
+
divider?: boolean;
|
|
206
|
+
}
|
|
207
|
+
interface FileJSON {
|
|
208
|
+
type: number;
|
|
209
|
+
url: string;
|
|
210
|
+
filename: string;
|
|
211
|
+
description?: string;
|
|
212
|
+
}
|
|
213
|
+
interface LabelJSON {
|
|
214
|
+
type: number;
|
|
215
|
+
label: string;
|
|
216
|
+
description?: string;
|
|
217
|
+
}
|
|
218
|
+
interface AccessoryJSON {
|
|
219
|
+
type: number;
|
|
220
|
+
style?: string;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
declare class URLValidator {
|
|
224
|
+
static validate(url: string): void;
|
|
225
|
+
static validateOptional(url?: string): void;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
declare class StringValidator {
|
|
229
|
+
static validate(value: any, field: string): void;
|
|
230
|
+
static validateLength(value: string, maxLength: number, field: string): void;
|
|
231
|
+
static validateOptional(value?: any, field?: string): void;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
declare class ComponentValidator {
|
|
235
|
+
static validateType(type: ComponentType): void;
|
|
236
|
+
static validateComponentStructure(obj: any): void;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
declare class LimitRules {
|
|
240
|
+
static validateComponentCount(count: number): void;
|
|
241
|
+
static validateGalleryItems(count: number): void;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
declare class NestingRules {
|
|
245
|
+
static validateContainerNesting(componentType: ComponentType): void;
|
|
246
|
+
static validateSectionNesting(componentType: ComponentType): void;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
declare class UrlUtils {
|
|
250
|
+
static isValidUrl(url: string): boolean;
|
|
251
|
+
static normalizeUrl(url: string): string;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
declare class StringUtils {
|
|
255
|
+
static isString(value: any): value is string;
|
|
256
|
+
static truncate(text: string, maxLength: number): string;
|
|
257
|
+
static validateLength(text: string, maxLength: number, field: string): void;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
declare class ArrayUtils {
|
|
261
|
+
static isValidArray<T>(arr: any): arr is T[];
|
|
262
|
+
static ensureArray<T>(items: T | T[]): T[];
|
|
263
|
+
static splice<T>(arr: T[], index: number, deleteCount: number, ...items: T[]): T[];
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
declare class ObjectUtils {
|
|
267
|
+
static deepClone<T>(obj: T): T;
|
|
268
|
+
static hasOwnProperty(obj: any, prop: string): boolean;
|
|
269
|
+
static mergeDeep<T extends Record<string, any>>(target: T, source: Partial<T>): T;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
declare class ComponentHelper {
|
|
273
|
+
static createTextSection(text: string): SectionBuilder;
|
|
274
|
+
static createContainerFrom(...components: ComponentBuilder[]): ContainerBuilder;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
declare class ComponentParser {
|
|
278
|
+
static parse(data: any): ComponentBuilder;
|
|
279
|
+
static parseMany(dataArray: any[]): ComponentBuilder[];
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
declare class ComponentRegistry {
|
|
283
|
+
private static builders;
|
|
284
|
+
static register(name: string, builder: typeof ComponentBuilder): void;
|
|
285
|
+
static get(name: string): typeof ComponentBuilder | undefined;
|
|
286
|
+
static has(name: string): boolean;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export { AccessoryBuilder, AccessoryJSON, AnyComponentBuilder, ArrayUtils, ComponentBuilder, ComponentHelper, ComponentJSON, ComponentLimitError, ComponentParser, ComponentRegistry, ComponentType, ComponentValidator, ContainerBuilder, ContainerJSON, FileBuilder, FileJSON, IComponentBuilder, InvalidComponentError, InvalidURLException, LabelBuilder, LabelJSON, LimitRules, Limits, MediaGalleryBuilder, MediaGalleryItemBuilder, MediaGalleryItemJSON, MediaGalleryJSON, NestingRules, ObjectUtils, SectionBuilder, SectionJSON, SeparatorBuilder, SeparatorJSON, StringUtils, StringValidator, TextDisplayBuilder, TextDisplayJSON, ThumbnailBuilder, ThumbnailJSON, URLValidator, UrlUtils, ValidationError };
|