triangle-types 1.0.37 → 1.0.38

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.
@@ -1,8 +1,12 @@
1
1
  declare const fragment_type_ids: readonly ["LINE", "CHAR"];
2
2
  export type FragmentTypeID = typeof fragment_type_ids[number];
3
3
  export declare function is_fragment_type_id(fragment_type_id: any): fragment_type_id is FragmentTypeID;
4
+ declare const document_type_ids: readonly ["federal_congress_bill_document", "legistar_document", "press_article_tag", "scout_document", "twitter_tweet"];
5
+ export type DocumentTypeID = typeof document_type_ids[number];
6
+ export declare function is_document_type_id(document_type_id: any): document_type_id is DocumentTypeID;
4
7
  export declare class Fragment {
5
8
  readonly fragment_id: string;
9
+ readonly document_type_id: DocumentTypeID;
6
10
  readonly fragment_type_id: FragmentTypeID;
7
11
  readonly max_size: number;
8
12
  readonly min_index: number;
@@ -14,27 +18,32 @@ export declare class Fragment {
14
18
  static is(fragment: any): fragment is Fragment;
15
19
  }
16
20
  export declare class FederalCongressBillDocumentFragment extends Fragment {
21
+ readonly document_type_id: "federal_congress_bill_document";
17
22
  readonly federal_congress_bill_document_id: string;
18
23
  constructor(fragment: FederalCongressBillDocumentFragment);
19
24
  static is(fragment: any): fragment is FederalCongressBillDocumentFragment;
20
25
  }
21
26
  export declare class LegistarDocumentFragment extends Fragment {
27
+ readonly document_type_id: "legistar_document";
22
28
  readonly legistar_document_id: string;
23
29
  constructor(fragment: LegistarDocumentFragment);
24
30
  static is(fragment: any): fragment is LegistarDocumentFragment;
25
31
  }
26
32
  export declare class PressArticleTagFragment extends Fragment {
33
+ readonly document_type_id: "press_article_tag";
27
34
  readonly press_article_id: string;
28
35
  readonly tag_id: string;
29
36
  constructor(fragment: PressArticleTagFragment);
30
37
  static is(fragment: any): fragment is PressArticleTagFragment;
31
38
  }
32
39
  export declare class ScoutDocumentFragment extends Fragment {
40
+ readonly document_type_id: "scout_document";
33
41
  readonly scout_document_id: string;
34
42
  constructor(fragment: ScoutDocumentFragment);
35
43
  static is(fragment: any): fragment is ScoutDocumentFragment;
36
44
  }
37
45
  export declare class TwitterTweetFragment extends Fragment {
46
+ readonly document_type_id: "twitter_tweet";
38
47
  readonly twitter_tweet_id: string;
39
48
  constructor(fragment: TwitterTweetFragment);
40
49
  static is(fragment: any): fragment is TwitterTweetFragment;
@@ -2,8 +2,13 @@ const fragment_type_ids = ["LINE", "CHAR"];
2
2
  export function is_fragment_type_id(fragment_type_id) {
3
3
  return fragment_type_ids.includes(fragment_type_id);
4
4
  }
5
+ const document_type_ids = ["federal_congress_bill_document", "legistar_document", "press_article_tag", "scout_document", "twitter_tweet"];
6
+ export function is_document_type_id(document_type_id) {
7
+ return document_type_ids.includes(document_type_id);
8
+ }
5
9
  export class Fragment {
6
10
  fragment_id;
11
+ document_type_id;
7
12
  fragment_type_id;
8
13
  max_size;
9
14
  min_index;
@@ -15,6 +20,7 @@ export class Fragment {
15
20
  throw Error("Invalid input.");
16
21
  }
17
22
  this.fragment_id = fragment.fragment_id;
23
+ this.document_type_id = fragment.document_type_id;
18
24
  this.fragment_type_id = fragment.fragment_type_id;
19
25
  this.max_size = fragment.max_size;
20
26
  this.min_index = fragment.min_index;
@@ -25,6 +31,7 @@ export class Fragment {
25
31
  static is(fragment) {
26
32
  return (fragment !== undefined &&
27
33
  typeof fragment.fragment_id === "string" &&
34
+ is_document_type_id(fragment.document_type_id) &&
28
35
  is_fragment_type_id(fragment.fragment_type_id) &&
29
36
  typeof fragment.max_size === "number" &&
30
37
  typeof fragment.min_index === "number" &&
@@ -34,34 +41,41 @@ export class Fragment {
34
41
  }
35
42
  }
36
43
  export class FederalCongressBillDocumentFragment extends Fragment {
44
+ document_type_id;
37
45
  federal_congress_bill_document_id;
38
46
  constructor(fragment) {
39
47
  if (!FederalCongressBillDocumentFragment.is(fragment)) {
40
48
  throw Error("Invalid input.");
41
49
  }
42
50
  super(fragment);
51
+ this.document_type_id = fragment.document_type_id;
43
52
  this.federal_congress_bill_document_id = fragment.federal_congress_bill_document_id;
44
53
  }
45
54
  static is(fragment) {
46
55
  return (Fragment.is(fragment) &&
56
+ fragment.document_type_id === "federal_congress_bill_document" &&
47
57
  typeof fragment.federal_congress_bill_document_id === "string");
48
58
  }
49
59
  }
50
60
  export class LegistarDocumentFragment extends Fragment {
61
+ document_type_id;
51
62
  legistar_document_id;
52
63
  constructor(fragment) {
53
64
  if (!LegistarDocumentFragment.is(fragment)) {
54
65
  throw Error("Invalid input.");
55
66
  }
56
67
  super(fragment);
68
+ this.document_type_id = fragment.document_type_id;
57
69
  this.legistar_document_id = fragment.legistar_document_id;
58
70
  }
59
71
  static is(fragment) {
60
72
  return (Fragment.is(fragment) &&
73
+ fragment.document_type_id === "legistar_document" &&
61
74
  typeof fragment.legistar_document_id === "string");
62
75
  }
63
76
  }
64
77
  export class PressArticleTagFragment extends Fragment {
78
+ document_type_id;
65
79
  press_article_id;
66
80
  tag_id;
67
81
  constructor(fragment) {
@@ -69,40 +83,48 @@ export class PressArticleTagFragment extends Fragment {
69
83
  throw Error("Invalid input.");
70
84
  }
71
85
  super(fragment);
86
+ this.document_type_id = fragment.document_type_id;
72
87
  this.press_article_id = fragment.press_article_id;
73
88
  this.tag_id = fragment.tag_id;
74
89
  }
75
90
  static is(fragment) {
76
91
  return (Fragment.is(fragment) &&
92
+ fragment.document_type_id === "press_article_tag" &&
77
93
  typeof fragment.press_article_id === "string" &&
78
94
  typeof fragment.tag_id === "string");
79
95
  }
80
96
  }
81
97
  export class ScoutDocumentFragment extends Fragment {
98
+ document_type_id;
82
99
  scout_document_id;
83
100
  constructor(fragment) {
84
101
  if (!ScoutDocumentFragment.is(fragment)) {
85
102
  throw Error("Invalid input.");
86
103
  }
87
104
  super(fragment);
105
+ this.document_type_id = fragment.document_type_id;
88
106
  this.scout_document_id = fragment.scout_document_id;
89
107
  }
90
108
  static is(fragment) {
91
109
  return (Fragment.is(fragment) &&
110
+ fragment.document_type_id === "scout_document" &&
92
111
  typeof fragment.scout_document_id === "string");
93
112
  }
94
113
  }
95
114
  export class TwitterTweetFragment extends Fragment {
115
+ document_type_id;
96
116
  twitter_tweet_id;
97
117
  constructor(fragment) {
98
118
  if (!TwitterTweetFragment.is(fragment)) {
99
119
  throw Error("Invalid input.");
100
120
  }
101
121
  super(fragment);
122
+ this.document_type_id = fragment.document_type_id;
102
123
  this.twitter_tweet_id = fragment.twitter_tweet_id;
103
124
  }
104
125
  static is(fragment) {
105
126
  return (Fragment.is(fragment) &&
127
+ fragment.document_type_id === "twitter_tweet" &&
106
128
  typeof fragment.twitter_tweet_id === "string");
107
129
  }
108
130
  }
@@ -1,7 +1,9 @@
1
+ import { DocumentTypeID } from "./Fragment.js";
1
2
  export declare class FragmentVector {
2
3
  readonly fragment_vector_id: string;
3
4
  readonly fragment_id: string;
4
5
  readonly vector_id: string;
6
+ readonly document_type_id: DocumentTypeID;
5
7
  readonly coordinates: number[];
6
8
  readonly headers: Record<string, any>;
7
9
  readonly s3_vector_id?: string;
@@ -2,6 +2,7 @@ export class FragmentVector {
2
2
  fragment_vector_id;
3
3
  fragment_id;
4
4
  vector_id;
5
+ document_type_id;
5
6
  // readonly s3_vector_bucket_id : string
6
7
  // readonly s3_vector_index_id : string
7
8
  coordinates;
@@ -14,6 +15,7 @@ export class FragmentVector {
14
15
  this.fragment_vector_id = fragment_vector.fragment_vector_id;
15
16
  this.fragment_id = fragment_vector.fragment_id;
16
17
  this.vector_id = fragment_vector.vector_id;
18
+ this.document_type_id = fragment_vector.document_type_id;
17
19
  // this.s3_vector_bucket_id = fragment_vector.s3_vector_bucket_id
18
20
  // this.s3_vector_index_id = fragment_vector.s3_vector_index_id
19
21
  this.coordinates = fragment_vector.coordinates;
@@ -25,6 +27,7 @@ export class FragmentVector {
25
27
  typeof fragment_vector.fragment_vector_id === "string" &&
26
28
  typeof fragment_vector.fragment_id === "string" &&
27
29
  typeof fragment_vector.vector_id === "string" &&
30
+ typeof fragment_vector.document_type_id === "string" &&
28
31
  // typeof fragment_vector.s3_vector_bucket_id === "string" &&
29
32
  // typeof fragment_vector.s3_vector_index_id === "string" &&
30
33
  Array.isArray(fragment_vector.coordinates) && fragment_vector.coordinates.every((coordinate) => typeof coordinate === "number") &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triangle-types",
3
- "version": "1.0.37",
3
+ "version": "1.0.38",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "scripts": {
@@ -6,8 +6,17 @@ export function is_fragment_type_id(fragment_type_id : any) : fragment_type_id i
6
6
  return fragment_type_ids.includes(fragment_type_id)
7
7
  }
8
8
 
9
+ const document_type_ids = ["federal_congress_bill_document", "legistar_document", "press_article_tag", "scout_document", "twitter_tweet"] as const
10
+
11
+ export type DocumentTypeID = typeof document_type_ids[number]
12
+
13
+ export function is_document_type_id(document_type_id : any) : document_type_id is DocumentTypeID {
14
+ return document_type_ids.includes(document_type_id)
15
+ }
16
+
9
17
  export class Fragment {
10
18
  readonly fragment_id : string
19
+ readonly document_type_id : DocumentTypeID
11
20
  readonly fragment_type_id : FragmentTypeID
12
21
  readonly max_size : number
13
22
  readonly min_index : number
@@ -21,6 +30,7 @@ export class Fragment {
21
30
  throw Error("Invalid input.")
22
31
  }
23
32
  this.fragment_id = fragment.fragment_id
33
+ this.document_type_id = fragment.document_type_id
24
34
  this.fragment_type_id = fragment.fragment_type_id
25
35
  this.max_size = fragment.max_size
26
36
  this.min_index = fragment.min_index
@@ -33,6 +43,7 @@ export class Fragment {
33
43
  return (
34
44
  fragment !== undefined &&
35
45
  typeof fragment.fragment_id === "string" &&
46
+ is_document_type_id(fragment.document_type_id) &&
36
47
  is_fragment_type_id(fragment.fragment_type_id) &&
37
48
  typeof fragment.max_size === "number" &&
38
49
  typeof fragment.min_index === "number" &&
@@ -44,6 +55,7 @@ export class Fragment {
44
55
  }
45
56
 
46
57
  export class FederalCongressBillDocumentFragment extends Fragment {
58
+ readonly document_type_id : "federal_congress_bill_document"
47
59
  readonly federal_congress_bill_document_id : string
48
60
 
49
61
  constructor(fragment : FederalCongressBillDocumentFragment) {
@@ -51,18 +63,21 @@ export class FederalCongressBillDocumentFragment extends Fragment {
51
63
  throw Error("Invalid input.")
52
64
  }
53
65
  super(fragment)
66
+ this.document_type_id = fragment.document_type_id
54
67
  this.federal_congress_bill_document_id = fragment.federal_congress_bill_document_id
55
68
  }
56
69
 
57
70
  static is(fragment : any) : fragment is FederalCongressBillDocumentFragment {
58
71
  return (
59
72
  Fragment.is(fragment) &&
73
+ fragment.document_type_id === "federal_congress_bill_document" &&
60
74
  typeof fragment.federal_congress_bill_document_id === "string"
61
75
  )
62
76
  }
63
77
  }
64
78
 
65
79
  export class LegistarDocumentFragment extends Fragment {
80
+ readonly document_type_id : "legistar_document"
66
81
  readonly legistar_document_id : string
67
82
 
68
83
  constructor(fragment : LegistarDocumentFragment) {
@@ -70,18 +85,21 @@ export class LegistarDocumentFragment extends Fragment {
70
85
  throw Error("Invalid input.")
71
86
  }
72
87
  super(fragment)
88
+ this.document_type_id = fragment.document_type_id
73
89
  this.legistar_document_id = fragment.legistar_document_id
74
90
  }
75
91
 
76
92
  static is(fragment : any) : fragment is LegistarDocumentFragment {
77
93
  return (
78
94
  Fragment.is(fragment) &&
95
+ fragment.document_type_id === "legistar_document" &&
79
96
  typeof fragment.legistar_document_id === "string"
80
97
  )
81
98
  }
82
99
  }
83
100
 
84
101
  export class PressArticleTagFragment extends Fragment {
102
+ readonly document_type_id : "press_article_tag"
85
103
  readonly press_article_id : string
86
104
  readonly tag_id : string
87
105
 
@@ -90,6 +108,7 @@ export class PressArticleTagFragment extends Fragment {
90
108
  throw Error("Invalid input.")
91
109
  }
92
110
  super(fragment)
111
+ this.document_type_id = fragment.document_type_id
93
112
  this.press_article_id = fragment.press_article_id
94
113
  this.tag_id = fragment.tag_id
95
114
  }
@@ -97,6 +116,7 @@ export class PressArticleTagFragment extends Fragment {
97
116
  static is(fragment : any) : fragment is PressArticleTagFragment {
98
117
  return (
99
118
  Fragment.is(fragment) &&
119
+ fragment.document_type_id === "press_article_tag" &&
100
120
  typeof fragment.press_article_id === "string" &&
101
121
  typeof fragment.tag_id === "string"
102
122
  )
@@ -104,6 +124,7 @@ export class PressArticleTagFragment extends Fragment {
104
124
  }
105
125
 
106
126
  export class ScoutDocumentFragment extends Fragment {
127
+ readonly document_type_id : "scout_document"
107
128
  readonly scout_document_id : string
108
129
 
109
130
  constructor(fragment : ScoutDocumentFragment) {
@@ -111,18 +132,21 @@ export class ScoutDocumentFragment extends Fragment {
111
132
  throw Error("Invalid input.")
112
133
  }
113
134
  super(fragment)
135
+ this.document_type_id = fragment.document_type_id
114
136
  this.scout_document_id = fragment.scout_document_id
115
137
  }
116
138
 
117
139
  static is(fragment : any) : fragment is ScoutDocumentFragment {
118
140
  return (
119
141
  Fragment.is(fragment) &&
142
+ fragment.document_type_id === "scout_document" &&
120
143
  typeof fragment.scout_document_id === "string"
121
144
  )
122
145
  }
123
146
  }
124
147
 
125
148
  export class TwitterTweetFragment extends Fragment {
149
+ readonly document_type_id : "twitter_tweet"
126
150
  readonly twitter_tweet_id : string
127
151
 
128
152
  constructor(fragment : TwitterTweetFragment) {
@@ -130,12 +154,14 @@ export class TwitterTweetFragment extends Fragment {
130
154
  throw Error("Invalid input.")
131
155
  }
132
156
  super(fragment)
157
+ this.document_type_id = fragment.document_type_id
133
158
  this.twitter_tweet_id = fragment.twitter_tweet_id
134
159
  }
135
160
 
136
161
  static is(fragment : any) : fragment is TwitterTweetFragment {
137
162
  return (
138
163
  Fragment.is(fragment) &&
164
+ fragment.document_type_id === "twitter_tweet" &&
139
165
  typeof fragment.twitter_tweet_id === "string"
140
166
  )
141
167
  }
@@ -1,7 +1,10 @@
1
+ import { DocumentTypeID, FragmentTypeID } from "./Fragment"
2
+
1
3
  export class FragmentVector {
2
4
  readonly fragment_vector_id : string
3
5
  readonly fragment_id : string
4
6
  readonly vector_id : string
7
+ readonly document_type_id : DocumentTypeID
5
8
  // readonly s3_vector_bucket_id : string
6
9
  // readonly s3_vector_index_id : string
7
10
  readonly coordinates : number[]
@@ -16,6 +19,7 @@ export class FragmentVector {
16
19
  this.fragment_vector_id = fragment_vector.fragment_vector_id
17
20
  this.fragment_id = fragment_vector.fragment_id
18
21
  this.vector_id = fragment_vector.vector_id
22
+ this.document_type_id = fragment_vector.document_type_id
19
23
  // this.s3_vector_bucket_id = fragment_vector.s3_vector_bucket_id
20
24
  // this.s3_vector_index_id = fragment_vector.s3_vector_index_id
21
25
  this.coordinates = fragment_vector.coordinates
@@ -29,6 +33,7 @@ export class FragmentVector {
29
33
  typeof fragment_vector.fragment_vector_id === "string" &&
30
34
  typeof fragment_vector.fragment_id === "string" &&
31
35
  typeof fragment_vector.vector_id === "string" &&
36
+ typeof fragment_vector.document_type_id === "string" &&
32
37
  // typeof fragment_vector.s3_vector_bucket_id === "string" &&
33
38
  // typeof fragment_vector.s3_vector_index_id === "string" &&
34
39
  Array.isArray(fragment_vector.coordinates) && fragment_vector.coordinates.every((coordinate : any) => typeof coordinate === "number") &&