scout-types 1.0.13 → 1.0.14
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/dist/src/types/Message.d.ts +8 -0
- package/dist/src/types/Message.js +23 -1
- package/package.json +1 -1
- package/src/types/Message.ts +28 -1
|
@@ -5,6 +5,13 @@ export declare class Fragment {
|
|
|
5
5
|
constructor(fragment: any);
|
|
6
6
|
static is(fragment: any): fragment is Fragment;
|
|
7
7
|
}
|
|
8
|
+
export declare class Attachment {
|
|
9
|
+
readonly type: string;
|
|
10
|
+
readonly filename: string;
|
|
11
|
+
readonly s3_filename: string;
|
|
12
|
+
constructor(attachment: any);
|
|
13
|
+
static is(attachment: any): attachment is Attachment;
|
|
14
|
+
}
|
|
8
15
|
export declare class Message {
|
|
9
16
|
readonly user_id: string;
|
|
10
17
|
readonly message_id: string;
|
|
@@ -18,6 +25,7 @@ export declare class Message {
|
|
|
18
25
|
readonly fragments?: Fragment[];
|
|
19
26
|
readonly sources?: Sources;
|
|
20
27
|
readonly text: string;
|
|
28
|
+
readonly attachment?: Attachment;
|
|
21
29
|
constructor(message: any);
|
|
22
30
|
static is(message: any): message is Message;
|
|
23
31
|
}
|
|
@@ -15,6 +15,25 @@ export class Fragment {
|
|
|
15
15
|
Sources.is(fragment.sources));
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
+
export class Attachment {
|
|
19
|
+
type;
|
|
20
|
+
filename;
|
|
21
|
+
s3_filename;
|
|
22
|
+
constructor(attachment) {
|
|
23
|
+
if (!Attachment.is(attachment)) {
|
|
24
|
+
throw Error("Invalid input.");
|
|
25
|
+
}
|
|
26
|
+
this.type = attachment.type;
|
|
27
|
+
this.filename = attachment.filename;
|
|
28
|
+
this.s3_filename = attachment.s3_filename;
|
|
29
|
+
}
|
|
30
|
+
static is(attachment) {
|
|
31
|
+
return (attachment !== undefined &&
|
|
32
|
+
typeof attachment.text === "string" &&
|
|
33
|
+
typeof attachment.filename === "string" &&
|
|
34
|
+
typeof attachment.s3_filename === "string");
|
|
35
|
+
}
|
|
36
|
+
}
|
|
18
37
|
export class Message {
|
|
19
38
|
user_id;
|
|
20
39
|
message_id;
|
|
@@ -28,6 +47,7 @@ export class Message {
|
|
|
28
47
|
fragments;
|
|
29
48
|
sources;
|
|
30
49
|
text;
|
|
50
|
+
attachment;
|
|
31
51
|
constructor(message) {
|
|
32
52
|
if (!Message.is(message)) {
|
|
33
53
|
throw Error("Invalid input.");
|
|
@@ -44,6 +64,7 @@ export class Message {
|
|
|
44
64
|
this.fragments = message.fragments;
|
|
45
65
|
this.sources = message.sources;
|
|
46
66
|
this.text = message.text;
|
|
67
|
+
this.attachment = message.attachment;
|
|
47
68
|
}
|
|
48
69
|
static is(message) {
|
|
49
70
|
return (message !== undefined &&
|
|
@@ -58,6 +79,7 @@ export class Message {
|
|
|
58
79
|
(message.grok_text === undefined || typeof message.grok_text === "string") &&
|
|
59
80
|
(message.fragments === undefined || Array.isArray(message.fragments) && message.fragments.every(Fragment.is)) &&
|
|
60
81
|
(message.sources === undefined || Sources.is(message.sources)) &&
|
|
61
|
-
typeof message.text === "string"
|
|
82
|
+
typeof message.text === "string" &&
|
|
83
|
+
Attachment.is(message.attachment));
|
|
62
84
|
}
|
|
63
85
|
}
|
package/package.json
CHANGED
package/src/types/Message.ts
CHANGED
|
@@ -21,6 +21,30 @@ export class Fragment {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
export class Attachment {
|
|
25
|
+
readonly type : string
|
|
26
|
+
readonly filename : string
|
|
27
|
+
readonly s3_filename : string
|
|
28
|
+
|
|
29
|
+
constructor(attachment : any) {
|
|
30
|
+
if (!Attachment.is(attachment)) {
|
|
31
|
+
throw Error("Invalid input.")
|
|
32
|
+
}
|
|
33
|
+
this.type = attachment.type
|
|
34
|
+
this.filename = attachment.filename
|
|
35
|
+
this.s3_filename = attachment.s3_filename
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
static is(attachment : any) : attachment is Attachment {
|
|
39
|
+
return (
|
|
40
|
+
attachment !== undefined &&
|
|
41
|
+
typeof attachment.text === "string" &&
|
|
42
|
+
typeof attachment.filename === "string" &&
|
|
43
|
+
typeof attachment.s3_filename === "string"
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
24
48
|
export class Message {
|
|
25
49
|
readonly user_id : string
|
|
26
50
|
readonly message_id : string
|
|
@@ -34,6 +58,7 @@ export class Message {
|
|
|
34
58
|
readonly fragments? : Fragment[]
|
|
35
59
|
readonly sources? : Sources
|
|
36
60
|
readonly text : string
|
|
61
|
+
readonly attachment? : Attachment
|
|
37
62
|
|
|
38
63
|
constructor(message : any) {
|
|
39
64
|
if (!Message.is(message)) {
|
|
@@ -51,6 +76,7 @@ export class Message {
|
|
|
51
76
|
this.fragments = message.fragments
|
|
52
77
|
this.sources = message.sources
|
|
53
78
|
this.text = message.text
|
|
79
|
+
this.attachment = message.attachment
|
|
54
80
|
}
|
|
55
81
|
|
|
56
82
|
static is(message : any) : message is Message {
|
|
@@ -67,7 +93,8 @@ export class Message {
|
|
|
67
93
|
(message.grok_text === undefined || typeof message.grok_text === "string") &&
|
|
68
94
|
(message.fragments === undefined || Array.isArray(message.fragments) && message.fragments.every(Fragment.is)) &&
|
|
69
95
|
(message.sources === undefined || Sources.is(message.sources)) &&
|
|
70
|
-
typeof message.text === "string"
|
|
96
|
+
typeof message.text === "string" &&
|
|
97
|
+
Attachment.is(message.attachment)
|
|
71
98
|
)
|
|
72
99
|
}
|
|
73
100
|
}
|