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