-
Notifications
You must be signed in to change notification settings - Fork 13
/
interfaces.ts
150 lines (134 loc) · 4.18 KB
/
interfaces.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
import {
APIConstructor,
SlicerConstructor,
ProcessorConstructor,
FetcherConstructor,
ObserverConstructor,
SchemaConstructor
} from '../operations/interfaces';
export const ASSET_KEYWORD = 'ASSETS';
export interface LoaderOptions {
/** Path to teraslice lib directory */
terasliceOpPath?: string;
/** Path to where the assets are stored */
assetPath?: string[] | string;
}
export interface ValidLoaderOptions {
/** Path to teraslice lib directory */
terasliceOpPath?: string;
/** Path to where the assets are stored */
assetPath: string[]
}
export enum AssetBundleType {
/** This represents legacy operations */
LEGACY = 'LEGACY',
/** This represents operations that are in the format
* of ASSET_NAME/OP_NAME/OPERATION_TYPE
*
* @example
* some-asset/myOP/processor.js
* some-asset/myOP/schema.js
*/
STANDARD = 'STANDARD',
/** This represents operations that live in the index file
* of the asset name, and returns an object with the 'ASSETS'
* key which lists all operations and api available
* @example
* some-asset/index.ts
*
* export default {
* // A list of the operations provided by this asset bundle
* ASSETS: {
// The key here would be the current file name
some-processor-name: {
Processor: ProcessorExampleBatcher,
Schema: ProcessorSchema,
},
some-reader-name: {
Fetcher: ExampleFetcher,
Slicer: ExampleSlicer,
Schema: ReaderSchema,
},
some-api-name: {
API: ExampleAPI,
Schema: SchemaAPI,
},
},
};
*/
BUNDLED = 'BUNDLED'
}
export enum OperationLocationType {
asset = 'asset',
/** is located in node_modules */
module = 'module',
/** is located in builtin dir */
builtin = 'builtin',
/** is located natively in teraslice */
'teraslice' = 'teraslice'
}
export enum OperationTypeName {
processor = 'processor',
schema = 'schema',
fetcher = 'fetcher',
slicer = 'slicer',
api = 'api',
observer = 'observer'
}
export const AssetRepositoryKey = {
[OperationTypeName.processor]: 'Processor',
[OperationTypeName.schema]: 'Schema',
[OperationTypeName.fetcher]: 'Fetcher',
[OperationTypeName.slicer]: 'Slicer',
[OperationTypeName.api]: 'API',
[OperationTypeName.observer]: 'Observer'
} as const;
export interface BundledProcessorOperation {
[AssetRepositoryKey.processor]: ProcessorConstructor,
[AssetRepositoryKey.schema]: SchemaConstructor,
[AssetRepositoryKey.api]?: APIConstructor,
}
export interface BundledReaderOperation {
[AssetRepositoryKey.fetcher]: FetcherConstructor,
[AssetRepositoryKey.slicer]: SlicerConstructor,
[AssetRepositoryKey.schema]: SchemaConstructor,
[AssetRepositoryKey.api]?: APIConstructor
}
export interface BundledAPIOperation {
[AssetRepositoryKey.api]: APIConstructor
[AssetRepositoryKey.schema]:SchemaConstructor,
}
export interface BundledObserverOperation {
[AssetRepositoryKey.observer]: ObserverConstructor
[AssetRepositoryKey.schema]: SchemaConstructor,
}
export type RepositoryOperation = BundledProcessorOperation
| BundledReaderOperation
| BundledAPIOperation
| BundledObserverOperation
export interface AssetRepository {
[ASSET_KEYWORD]: {
[key: string]: RepositoryOperation
}
}
/** This map what type of operation the loader is looking for with
* the key listed in the asset bundle
*/
export const OpTypeToRepositoryKey = {
processor: AssetRepositoryKey.processor,
schema: AssetRepositoryKey.schema,
fetcher: AssetRepositoryKey.fetcher,
slicer: AssetRepositoryKey.slicer,
api: AssetRepositoryKey.api,
observer: AssetRepositoryKey.observer
};
export interface OperationResults {
path: string;
location: OperationLocationType;
bundle_type: AssetBundleType
}
export interface FindOperationResults {
path: string|null;
location: OperationLocationType|null;
bundle_type: AssetBundleType|null
}