scout-types 1.0.4 → 1.0.6

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.
@@ -2,14 +2,36 @@ import { Tweet } from "./Tweet.js";
2
2
  export declare class ScoutDocument {
3
3
  readonly scout_id: string;
4
4
  readonly document_id: string;
5
- readonly type: "URL" | "TWEET" | "TWITTER" | "PRESS";
5
+ readonly type: "URL" | "TWEET" | "TWITTER" | "PRESS" | "FILE";
6
6
  readonly s3_filename?: string;
7
7
  readonly s3_text_filename?: string;
8
- readonly url?: string;
9
- readonly username?: string;
10
8
  readonly vector_keys?: string[];
11
- readonly tweet?: Tweet;
12
- readonly text?: string;
9
+ readonly [x: string]: any;
13
10
  constructor(scout_document: any);
14
11
  static is(scout_document: any): scout_document is ScoutDocument;
15
12
  }
13
+ export declare class ScoutURLDocument extends ScoutDocument {
14
+ readonly url: string;
15
+ constructor(scout_document: any);
16
+ static is(scout_document: any): scout_document is ScoutURLDocument;
17
+ }
18
+ export declare class ScoutTwitterDocument extends ScoutDocument {
19
+ readonly username: string;
20
+ constructor(scout_document: any);
21
+ static is(scout_document: any): scout_document is ScoutTwitterDocument;
22
+ }
23
+ export declare class ScoutTweetDocument extends ScoutDocument {
24
+ readonly tweet: Tweet;
25
+ constructor(scout_document: any);
26
+ static is(scout_document: any): scout_document is ScoutTweetDocument;
27
+ }
28
+ export declare class ScoutPressDocument extends ScoutDocument {
29
+ constructor(scout_document: any);
30
+ static is(scout_document: any): scout_document is ScoutPressDocument;
31
+ }
32
+ export declare class ScoutFileDocument extends ScoutDocument {
33
+ readonly file_type: string;
34
+ readonly filename: string;
35
+ constructor(scout_document: any);
36
+ static is(scout_document: any): scout_document is ScoutFileDocument;
37
+ }
@@ -5,11 +5,7 @@ export class ScoutDocument {
5
5
  type;
6
6
  s3_filename;
7
7
  s3_text_filename;
8
- url;
9
- username;
10
8
  vector_keys;
11
- tweet;
12
- text;
13
9
  constructor(scout_document) {
14
10
  if (!ScoutDocument.is(scout_document)) {
15
11
  throw Error("Invalid input.");
@@ -19,11 +15,7 @@ export class ScoutDocument {
19
15
  this.type = scout_document.type;
20
16
  this.s3_filename = scout_document.s3_filename;
21
17
  this.s3_text_filename = scout_document.s3_text_filename;
22
- this.url = scout_document.url;
23
- this.username = scout_document.username;
24
18
  this.vector_keys = scout_document.vector_keys;
25
- this.tweet = scout_document.tweet;
26
- this.text = scout_document.text;
27
19
  }
28
20
  static is(scout_document) {
29
21
  return (scout_document !== undefined &&
@@ -32,10 +24,81 @@ export class ScoutDocument {
32
24
  typeof scout_document.type === "string" &&
33
25
  (scout_document.s3_filename === undefined || typeof scout_document.s3_filename === "string") &&
34
26
  (scout_document.s3_text_filename === undefined || typeof scout_document.s3_text_filename === "string") &&
35
- (scout_document.url === undefined || typeof scout_document.url === "string") &&
36
- (scout_document.username === undefined || typeof scout_document.username === "string") &&
37
- (scout_document.vector_keys === undefined || Array.isArray(scout_document.vector_keys) && scout_document.vector_keys.every((vector_key) => typeof vector_key === "string")) &&
38
- (scout_document.tweet === undefined || Tweet.is(scout_document.tweet)) &&
39
- (scout_document.text === undefined || typeof scout_document.text === "string"));
27
+ (scout_document.vector_keys === undefined || Array.isArray(scout_document.vector_keys) && scout_document.vector_keys.every((vector_key) => typeof vector_key === "string")));
28
+ }
29
+ }
30
+ export class ScoutURLDocument extends ScoutDocument {
31
+ url;
32
+ constructor(scout_document) {
33
+ if (!ScoutURLDocument.is(scout_document)) {
34
+ throw Error("Invalid input.");
35
+ }
36
+ super(scout_document);
37
+ this.url = scout_document.url;
38
+ }
39
+ static is(scout_document) {
40
+ return (ScoutDocument.is(scout_document) &&
41
+ scout_document.type === "URL" &&
42
+ typeof scout_document.url === "string");
43
+ }
44
+ }
45
+ export class ScoutTwitterDocument extends ScoutDocument {
46
+ username;
47
+ constructor(scout_document) {
48
+ if (!ScoutTwitterDocument.is(scout_document)) {
49
+ throw Error("Invalid input.");
50
+ }
51
+ super(scout_document);
52
+ this.username = scout_document.username;
53
+ }
54
+ static is(scout_document) {
55
+ return (ScoutDocument.is(scout_document) &&
56
+ scout_document.type === "TWITTER" &&
57
+ typeof scout_document.username === "string");
58
+ }
59
+ }
60
+ export class ScoutTweetDocument extends ScoutDocument {
61
+ tweet;
62
+ constructor(scout_document) {
63
+ if (!ScoutTweetDocument.is(scout_document)) {
64
+ throw Error("Invalid input.");
65
+ }
66
+ super(scout_document);
67
+ this.tweet = scout_document.tweet;
68
+ }
69
+ static is(scout_document) {
70
+ return (ScoutDocument.is(scout_document) &&
71
+ scout_document.type === "TWEET" &&
72
+ Tweet.is(scout_document.tweet));
73
+ }
74
+ }
75
+ export class ScoutPressDocument extends ScoutDocument {
76
+ constructor(scout_document) {
77
+ if (!ScoutPressDocument.is(scout_document)) {
78
+ throw Error("Invalid input.");
79
+ }
80
+ super(scout_document);
81
+ }
82
+ static is(scout_document) {
83
+ return (ScoutDocument.is(scout_document) &&
84
+ scout_document.type === "PRESS");
85
+ }
86
+ }
87
+ export class ScoutFileDocument extends ScoutDocument {
88
+ file_type;
89
+ filename;
90
+ constructor(scout_document) {
91
+ if (!ScoutFileDocument.is(scout_document)) {
92
+ throw Error("Invalid input.");
93
+ }
94
+ super(scout_document);
95
+ this.file_type = scout_document.file_type;
96
+ this.filename = scout_document.filename;
97
+ }
98
+ static is(scout_document) {
99
+ return (ScoutDocument.is(scout_document) &&
100
+ scout_document.type === "FILE" &&
101
+ typeof scout_document.file_type === "string" &&
102
+ typeof scout_document.filename === "string");
40
103
  }
41
104
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scout-types",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "directories": {
@@ -3,14 +3,11 @@ import { Tweet } from "./Tweet"
3
3
  export class ScoutDocument {
4
4
  readonly scout_id : string
5
5
  readonly document_id : string
6
- readonly type : "URL" | "TWEET" | "TWITTER" | "PRESS"
6
+ readonly type : "URL" | "TWEET" | "TWITTER" | "PRESS" | "FILE"
7
7
  readonly s3_filename? : string
8
8
  readonly s3_text_filename? : string
9
- readonly url? : string
10
- readonly username? : string
11
9
  readonly vector_keys? : string[]
12
- readonly tweet? : Tweet
13
- readonly text? : string
10
+ readonly [x : string] : any
14
11
 
15
12
  constructor(scout_document : any) {
16
13
  if (!ScoutDocument.is(scout_document)) {
@@ -21,11 +18,7 @@ export class ScoutDocument {
21
18
  this.type = scout_document.type
22
19
  this.s3_filename = scout_document.s3_filename
23
20
  this.s3_text_filename = scout_document.s3_text_filename
24
- this.url = scout_document.url
25
- this.username = scout_document.username
26
21
  this.vector_keys = scout_document.vector_keys
27
- this.tweet = scout_document.tweet
28
- this.text = scout_document.text
29
22
  }
30
23
 
31
24
  static is(scout_document : any) : scout_document is ScoutDocument {
@@ -36,11 +29,112 @@ export class ScoutDocument {
36
29
  typeof scout_document.type === "string" &&
37
30
  (scout_document.s3_filename === undefined || typeof scout_document.s3_filename === "string") &&
38
31
  (scout_document.s3_text_filename === undefined || typeof scout_document.s3_text_filename === "string") &&
39
- (scout_document.url === undefined || typeof scout_document.url === "string") &&
40
- (scout_document.username === undefined || typeof scout_document.username === "string") &&
41
- (scout_document.vector_keys === undefined || Array.isArray(scout_document.vector_keys) && scout_document.vector_keys.every((vector_key : any) => typeof vector_key === "string")) &&
42
- (scout_document.tweet === undefined || Tweet.is(scout_document.tweet)) &&
43
- (scout_document.text === undefined || typeof scout_document.text === "string")
32
+ (scout_document.vector_keys === undefined || Array.isArray(scout_document.vector_keys) && scout_document.vector_keys.every((vector_key : any) => typeof vector_key === "string"))
33
+ )
34
+ }
35
+ }
36
+
37
+ export class ScoutURLDocument extends ScoutDocument {
38
+ readonly url : string
39
+
40
+ constructor(scout_document : any) {
41
+ if (!ScoutURLDocument.is(scout_document)) {
42
+ throw Error("Invalid input.")
43
+ }
44
+ super(scout_document)
45
+ this.url = scout_document.url
46
+
47
+ }
48
+
49
+ static is(scout_document : any) : scout_document is ScoutURLDocument {
50
+ return (
51
+ ScoutDocument.is(scout_document) &&
52
+ scout_document.type === "URL" &&
53
+ typeof scout_document.url === "string"
54
+ )
55
+ }
56
+ }
57
+
58
+ export class ScoutTwitterDocument extends ScoutDocument {
59
+ readonly username : string
60
+
61
+ constructor(scout_document : any) {
62
+ if (!ScoutTwitterDocument.is(scout_document)) {
63
+ throw Error("Invalid input.")
64
+ }
65
+ super(scout_document)
66
+ this.username = scout_document.username
67
+
68
+ }
69
+
70
+ static is(scout_document : any) : scout_document is ScoutTwitterDocument {
71
+ return (
72
+ ScoutDocument.is(scout_document) &&
73
+ scout_document.type === "TWITTER" &&
74
+ typeof scout_document.username === "string"
75
+ )
76
+ }
77
+ }
78
+
79
+ export class ScoutTweetDocument extends ScoutDocument {
80
+ readonly tweet : Tweet
81
+
82
+ constructor(scout_document : any) {
83
+ if (!ScoutTweetDocument.is(scout_document)) {
84
+ throw Error("Invalid input.")
85
+ }
86
+ super(scout_document)
87
+ this.tweet = scout_document.tweet
88
+
89
+ }
90
+
91
+ static is(scout_document : any) : scout_document is ScoutTweetDocument {
92
+ return (
93
+ ScoutDocument.is(scout_document) &&
94
+ scout_document.type === "TWEET" &&
95
+ Tweet.is(scout_document.tweet)
96
+ )
97
+ }
98
+ }
99
+
100
+ export class ScoutPressDocument extends ScoutDocument {
101
+
102
+ constructor(scout_document : any) {
103
+ if (!ScoutPressDocument.is(scout_document)) {
104
+ throw Error("Invalid input.")
105
+ }
106
+ super(scout_document)
107
+
108
+ }
109
+
110
+ static is(scout_document : any) : scout_document is ScoutPressDocument {
111
+ return (
112
+ ScoutDocument.is(scout_document) &&
113
+ scout_document.type === "PRESS"
114
+ )
115
+ }
116
+ }
117
+
118
+ export class ScoutFileDocument extends ScoutDocument {
119
+ readonly file_type : string
120
+ readonly filename : string
121
+
122
+ constructor(scout_document : any) {
123
+ if (!ScoutFileDocument.is(scout_document)) {
124
+ throw Error("Invalid input.")
125
+ }
126
+ super(scout_document)
127
+ this.file_type = scout_document.file_type
128
+ this.filename = scout_document.filename
129
+
130
+ }
131
+
132
+ static is(scout_document : any) : scout_document is ScoutFileDocument {
133
+ return (
134
+ ScoutDocument.is(scout_document) &&
135
+ scout_document.type === "FILE" &&
136
+ typeof scout_document.file_type === "string" &&
137
+ typeof scout_document.filename === "string"
44
138
  )
45
139
  }
46
140
  }