Skip to content
This repository was archived by the owner on Mar 28, 2025. It is now read-only.

Commit 8ea8f9c

Browse files
feat: used typescript grammar to reduce redundant types
Signed-off-by: Adithya Krishna <[email protected]>
1 parent dc981e2 commit 8ea8f9c

File tree

1 file changed

+26
-33
lines changed

1 file changed

+26
-33
lines changed

src/types.ts

Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
import ExtractionGraph from "./ExtractionGraph";
22

3+
interface IBase {
4+
id: string;
5+
namespace: string;
6+
}
7+
8+
interface IMetadata extends IBase {
9+
name: string;
10+
labels: Record<string, string>;
11+
created_at: number;
12+
}
13+
314
export interface INamespace {
415
name: string;
516
extraction_graphs: ExtractionGraph[];
@@ -11,21 +22,19 @@ export interface IEmbeddingSchema {
1122
}
1223

1324
export interface IExtractorSchema {
14-
outputs: { [key: string]: IEmbeddingSchema | { [key: string]: any } };
25+
outputs: Record<string, IEmbeddingSchema | Record<string, any>>;
1526
}
1627

1728
export interface IExtractor {
1829
name: string;
1930
input_mime_types: string[];
2031
description: string;
21-
input_params: { [key: string]: any };
32+
input_params: Record<string, any>;
2233
outputs: IExtractorSchema;
2334
}
2435

25-
export interface ISchema {
26-
id: string;
36+
export interface ISchema extends IBase {
2737
extraction_graph_name: string;
28-
namespace: string;
2938
columns: Record<
3039
string,
3140
{
@@ -34,21 +43,17 @@ export interface ISchema {
3443
}
3544
>;
3645
}
46+
3747
export interface IIndex {
3848
name: string;
3949
schema: Record<string, string | number | boolean>;
4050
}
4151

42-
export interface IBaseContentMetadata {
43-
id: string;
52+
export interface IBaseContentMetadata extends IMetadata {
4453
parent_id: string;
4554
ingested_content_id: string;
46-
namespace: string;
47-
name: string;
4855
mime_type: string;
49-
labels: Record<string, string>;
5056
storage_url: string;
51-
created_at: number;
5257
source: string;
5358
size: number;
5459
hash: string;
@@ -59,10 +64,9 @@ export interface IContentMetadata extends IBaseContentMetadata {
5964
content_url: string;
6065
}
6166

62-
export interface IExtractedMetadata {
63-
id: string;
67+
export interface IExtractedMetadata extends IBase {
6468
content_id: string;
65-
metadata: { [key: string]: any };
69+
metadata: Record<string, any>;
6670
extractor_name: string;
6771
}
6872

@@ -76,16 +80,11 @@ export interface IExtractionPolicy {
7680
graph_name?: string;
7781
}
7882

79-
export interface ITaskContentMetadata {
80-
id: string;
83+
export interface ITaskContentMetadata extends IMetadata {
8184
parent_id: string;
8285
root_content_id: string;
83-
namespace: string;
84-
name: string;
8586
content_type: string;
86-
labels: Record<string, string>;
8787
storage_url: string;
88-
created_at: number;
8988
source: string;
9089
size_bytes: number;
9190
tombstoned: boolean;
@@ -99,14 +98,12 @@ export enum TaskStatus {
9998
Success = 2,
10099
}
101100

102-
export interface ITask {
103-
id: string;
101+
export interface ITask extends IBase {
104102
extractor: string;
105103
extraction_policy_id: string;
106104
output_index_table_mapping: Record<string, string>;
107-
namespace: string;
108105
content_metadata: ITaskContentMetadata;
109-
input_params: { [key: string]: any };
106+
input_params: Record<string, any>;
110107
outcome: TaskStatus;
111108
index_tables: string[];
112109
}
@@ -120,7 +117,7 @@ export interface IDocument {
120117
export interface IFeature {
121118
feature_type: "embedding" | "metadata" | "unknown";
122119
name: string;
123-
data: { [key: string]: any };
120+
data: Record<string, any>;
124121
}
125122

126123
export interface IContent {
@@ -130,17 +127,15 @@ export interface IContent {
130127
labels?: Record<string, string>;
131128
}
132129

133-
export interface IContentResp {
134-
content_type: string;
130+
export interface IContentResp extends Omit<IContent, 'bytes'> {
135131
bytes: number[];
136-
features?: IFeature[];
137-
labels?: Record<string, string>;
138132
}
139133

140134
export interface IExtractResponse {
141135
features: IFeature[];
142136
content: IContentResp[];
143137
}
138+
144139
export interface ISearchIndexResponse {
145140
content_id: string;
146141
text: string;
@@ -160,11 +155,9 @@ export interface IMtlsConfig {
160155
caPath?: string; // Optional, only if using a custom CA
161156
}
162157

163-
export interface StateChange {
164-
id: number;
165-
object_id: string;
158+
export interface StateChange extends IBase {
166159
change_type: string;
167160
created_at: number;
168161
processed_at: number;
169162
refcnt_object_id: string | null;
170-
}
163+
}

0 commit comments

Comments
 (0)