-
Notifications
You must be signed in to change notification settings - Fork 18
/
types.ts
205 lines (171 loc) · 5.16 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/*!
* Copyright 2021 Cognite AS
*/
import {
AnnotationModel,
AnnotationsCogniteAnnotationTypesImagesAssetLink,
CogniteInternalId,
IdEither
} from '@cognite/sdk';
import * as THREE from 'three';
export type Image360AnnotationFilterDelegate = (annotation: AnnotationModel) => boolean;
export interface JsonFileProvider {
getJsonFile(baseUrl: string, fileName: string): Promise<any>;
}
export interface BinaryFileProvider {
getBinaryFile(baseUrl: string, fileName: string, abortSignal?: AbortSignal): Promise<ArrayBuffer>;
}
export interface Image360AnnotationProvider {
get360ImageAnnotations(descriptors: Image360FileDescriptor[]): Promise<AnnotationModel[]>;
getFilesByAssetRef(assetId: IdEither): Promise<CogniteInternalId[]>;
}
export interface Image360DescriptorProvider<T> {
get360ImageDescriptors(metadataFilter: T, preMultipliedRotation: boolean): Promise<Historical360ImageSet[]>;
}
export interface Image360FileProvider {
get360ImageFiles(
image360FaceDescriptors: Image360FileDescriptor[],
abortSignal?: AbortSignal
): Promise<Image360Face[]>;
getLowResolution360ImageFiles(
image360FaceDescriptors: Image360FileDescriptor[],
abortSignal?: AbortSignal
): Promise<Image360Face[]>;
}
/**
* A CDF AnnotationModel with a narrower type representing an image asset link
*/
export type ImageAssetLinkAnnotationInfo = Omit<AnnotationModel, 'data'> & {
/**
* The data associated with the image asset link
*/
data: AnnotationsCogniteAnnotationTypesImagesAssetLink;
};
export interface Image360AssetProvider {
get360ImageAssets(
image360FileDescriptors: Image360FileDescriptor[],
annotationFilter: Image360AnnotationFilterDelegate
): Promise<ImageAssetLinkAnnotationInfo[]>;
}
export type Historical360ImageSet = Image360EventDescriptor & {
imageRevisions: Image360Descriptor[];
};
export type Image360Descriptor = {
timestamp?: number | string;
faceDescriptors: Image360FileDescriptor[];
};
export type Image360EventDescriptor = {
id: string;
label: string | undefined;
collectionId: string;
collectionLabel: string | undefined;
transform: THREE.Matrix4;
};
export type Image360Face = {
face: 'front' | 'back' | 'left' | 'right' | 'top' | 'bottom';
mimeType: 'image/jpeg' | 'image/png';
data: ArrayBuffer;
};
export type Image360Texture = {
face: 'front' | 'back' | 'left' | 'right' | 'top' | 'bottom';
texture: THREE.Texture;
};
export type Image360FileDescriptor = {
fileId: number;
face: 'front' | 'back' | 'left' | 'right' | 'top' | 'bottom';
mimeType: 'image/jpeg' | 'image/png';
};
export enum File3dFormat {
EptPointCloud = 'ept-pointcloud',
/**
* Reveal v9 and above (GLTF based output)
*/
GltfCadModel = 'gltf-directory',
AnyFormat = 'all-outputs'
}
export interface BlobOutputMetadata {
blobId: number;
format: File3dFormat | string;
version: number;
}
type InstanceType = 'node' | 'edge';
export type Item = {
instanceType: InstanceType;
} & InstanceIdentifier;
export type Source = {
type: 'view';
version: string;
} & InstanceIdentifier;
export type InstanceIdentifier = {
space: string;
externalId: string;
};
export type EdgeItem = {
startNode: InstanceIdentifier;
endNode: InstanceIdentifier;
};
export type Query = {
with: Record<string, ResultSetExpression>;
select: Record<string, QuerySelect>;
parameters?: Record<string, string | number>;
cursors?: Record<string, string>;
};
type QuerySelect = {
sources: readonly SourceProperties[];
};
type SourceProperties = {
source: TestSource;
properties: readonly string[];
};
type TestSource = {
type: 'view';
space: string;
externalId: string;
version: string;
};
export type ResultSetExpression = (NodeResultSetExpression | EdgeResultSetExpression) & {
limit?: number;
sort?: any[];
};
export type NodeResultSetExpression = {
nodes: {
filter?: any;
from?: any;
through?: any;
chainTo?: any;
};
};
export type EdgeResultSetExpression = {
edges: {
filter?: any;
from?: any;
nodeFilter?: any;
maxDistance?: number;
direction?: 'outwards' | 'inwards';
limitEach?: number;
};
};
type SelectKey<T extends Query> = keyof T['select'];
type Sources<T extends Query, K extends SelectKey<T>> = T['select'][K]['sources'][0];
type MainSource<T extends Query, K extends SelectKey<T>> = Sources<T, K>['source'];
type MainSourceProperties<T extends Query, K extends SelectKey<T>> = Sources<T, K>['properties'];
type ResultExpressionProperties<T extends Query, K extends SelectKey<T>> = {
[V in MainSource<T, K>['space']]: {
[Q in `${MainSource<T, K>['externalId']}/${MainSource<T, K>['version']}`]: {
[B in MainSourceProperties<T, K>[number]]: string | number | InstanceIdentifier;
};
};
};
type ResultExpression<T extends Query, K extends SelectKey<T>> = {
instanceType: 'node';
version: number;
space: string;
externalId: string;
createdTime: number;
lastUpdatedTime: number;
properties: ResultExpressionProperties<T, K>;
};
export type QueryNextCursors<T extends Query> = { [K in SelectKey<T>]?: string | undefined };
export type QueryResult<T extends Query> = {
[K in SelectKey<T>]: ResultExpression<T, K>[];
} & { nextCursor?: QueryNextCursors<T> };