dataset-types 3.4.2 → 3.5.0

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.
@@ -0,0 +1,738 @@
1
+ import {
2
+ //Vector/Matrix
3
+
4
+ IVector,
5
+ IMatrix,
6
+
7
+ // Value Data
8
+ IExpression,
9
+ IValueMetadata,
10
+ IValueData,
11
+ IValueMatrix,
12
+
13
+ //Neuron
14
+ INeuron,
15
+
16
+ //Network
17
+ INetwork,
18
+ INNValue,
19
+ INNLayer,
20
+ IValueNetworkDisplayOption,
21
+ INNMatrix,
22
+
23
+ //Architecture Specification
24
+ INNSpecification,
25
+ IMatrixSpecification,
26
+
27
+ //Learning
28
+ INNTrainable,
29
+ ITrainingExample,
30
+ IOptimizer,
31
+ ILearningConfig,
32
+ ILearnable,
33
+ IEventCollector,
34
+ ITrainingDataSet,
35
+
36
+ // Transformer
37
+ ITransformerSpecification,
38
+ IValueTransformer,
39
+ IValueTransformerInstance,
40
+
41
+
42
+ } from './valuedata'
43
+
44
+ import {
45
+ // Attention
46
+ IAttention2Model,
47
+ IAttention2ModelFactory,
48
+ IForwardResult,
49
+ IModelSpecification,
50
+ IEmbedding,
51
+ IEmbeddingRecord,
52
+ INamedEmbedding,
53
+ ISequenceEmbeddings,
54
+ ISequenceMatrix,
55
+ ITransformerExample,
56
+ ITransformerModel,
57
+ IDenseLayer, IMLP, ISGD,
58
+ ITransformerTraining,
59
+ ITrainData, ITrainer,
60
+ IAttentionModelInputs,
61
+ IAttentionModelContextInputs
62
+
63
+ } from './attention2'
64
+
65
+ import {
66
+ INode,
67
+ ILink,
68
+ ITopology,
69
+ INodeLink,
70
+ NODETYPE_TYPE
71
+
72
+ } from './topology'
73
+
74
+ export {
75
+ IVector,
76
+ IMatrix,
77
+
78
+ // Value Data
79
+ IExpression,
80
+ IValueMetadata,
81
+ IValueData,
82
+ IValueMatrix,
83
+
84
+ //Neuron
85
+ INeuron,
86
+
87
+ //Network
88
+ INetwork,
89
+ INNValue,
90
+ INNLayer,
91
+ IValueNetworkDisplayOption,
92
+ INNMatrix,
93
+
94
+ //Architecture Specification
95
+ INNSpecification,
96
+ IMatrixSpecification,
97
+
98
+ //Learning
99
+ INNTrainable,
100
+ ITrainingExample,
101
+ IOptimizer,
102
+ ILearningConfig,
103
+ ILearnable,
104
+ IEventCollector,
105
+ ITrainingDataSet,
106
+
107
+ // Transformer
108
+ ITransformerSpecification,
109
+ IValueTransformer,
110
+ IValueTransformerInstance,
111
+
112
+ // Attention
113
+ IAttention2Model,
114
+ IAttention2ModelFactory,
115
+ IForwardResult,
116
+ IModelSpecification,
117
+ IEmbedding,
118
+ IEmbeddingRecord,
119
+ INamedEmbedding,
120
+ ISequenceEmbeddings,
121
+ ISequenceMatrix,
122
+ ITransformerExample,
123
+ ITransformerModel,
124
+ ITransformerTraining,
125
+ IDenseLayer, IMLP, ISGD, ITrainData, ITrainer,
126
+ IAttentionModelInputs,
127
+ IAttentionModelContextInputs,
128
+
129
+ //Node Type
130
+ INode,
131
+ ILink,
132
+ ITopology,
133
+ INodeLink,
134
+ NODETYPE_TYPE
135
+ }
136
+
137
+ type BufferEncoding =
138
+ | "ascii"
139
+ | "utf8"
140
+ | "utf-8"
141
+ | "utf16le"
142
+ | "ucs2"
143
+ | "ucs-2"
144
+ | "base64"
145
+ | "latin1"
146
+ | "binary"
147
+ | "hex";
148
+
149
+ export interface ICommandResult {
150
+ status: string;
151
+ msg: string;
152
+ entity?: any;
153
+ log?: any[];
154
+ }
155
+
156
+ export interface IResults<Type> {
157
+ isLoading: boolean;
158
+ rows: Type[];
159
+ pageInfo?: any;
160
+ }
161
+
162
+ export interface IContext {
163
+ context: string;
164
+ projectcontext: string;
165
+ }
166
+ export interface IName {
167
+ name: string;
168
+ }
169
+
170
+ export interface IDataRow {
171
+ id: string;
172
+ }
173
+
174
+ export interface INamedDataRow extends IDataRow, IName { }
175
+
176
+ export interface IEntity extends IDataRow {
177
+ type: string;
178
+ delete?: string;
179
+ }
180
+
181
+ export interface INamedEntity extends IEntity, IName, IContext { }
182
+
183
+ export interface ITimed {
184
+ createdBy: string;
185
+ createdAt: Date | string;
186
+ effective?: string;
187
+ }
188
+
189
+ export interface IDocumentReference extends IDataRow {
190
+ filetype: string;
191
+ documenttype: string;
192
+ }
193
+
194
+ export interface IDocument extends INamedEntity, ITimed {
195
+ entity: string;
196
+ filetype: string;
197
+ documenttype: string;
198
+ title?: string;
199
+ authoringcompany?: string;
200
+ }
201
+
202
+ export interface IDocumentEntityLink {
203
+ entity: string;
204
+ documentId: string;
205
+ documentName?: string;
206
+ }
207
+
208
+ export interface IConfigurationItem extends INamedEntity, ITimed {
209
+ itemtype: string;
210
+ active: boolean;
211
+ level: string;
212
+ monitored: string;
213
+ baseline: string;
214
+ dimension: string;
215
+ datatypes: string;
216
+ group?: string; //deprecated as this doesnt work with Duck DB
217
+ grouping: string;
218
+ }
219
+
220
+ export type IPermission = String;
221
+
222
+ export interface IRolePermission {
223
+ permission: string;
224
+ role: string;
225
+ }
226
+
227
+ export interface IDataService { }
228
+
229
+ export interface IModel {
230
+ close: any;
231
+ }
232
+
233
+ export interface IModelService {
234
+ model: IModel;
235
+ seed: any;
236
+ upsert: (type: string, entity: any[]) => Promise<IPersistResult>;
237
+ upsertBatch: (type: string, entity: any[]) => Promise<IPersistResult>;
238
+ }
239
+
240
+ export interface IColumn {
241
+ name: string;
242
+ displayName?: string;
243
+ tooltip?: string;
244
+ type: string;
245
+ label: string;
246
+ options: string[];
247
+ valueRange?: string;
248
+ default?: string;
249
+ derivation?: string;
250
+ required?: boolean;
251
+ distinct?: boolean;
252
+ width?: string;
253
+ truncate?: boolean;
254
+ defaultValue?: string | number;
255
+ groupName?: string;
256
+ }
257
+
258
+ export interface IColumnGroup {
259
+ name: string;
260
+ columns: string[];
261
+ }
262
+
263
+ export interface ITable {
264
+ file: string;
265
+ name: string;
266
+ dataname?: string;
267
+ options: string[];
268
+ rows?: string[];
269
+ columns: IColumn[];
270
+ columnGroups?: IColumnGroup[];
271
+ helpFileName?: string;
272
+ }
273
+
274
+ export interface IFileResult {
275
+ content: string;
276
+ contenttype: string;
277
+ filename: string;
278
+ metadata: any;
279
+ }
280
+
281
+ export interface IFileService {
282
+ download2: (
283
+ tenant: string,
284
+ projectcontext: string,
285
+ log: boolean,
286
+ txmode: string, //production/development/test
287
+ filetype: string,
288
+ level: string,
289
+ reference: string,
290
+ encoding: BufferEncoding, //base64,utf-8
291
+ ) => Promise<IFileResult>;
292
+ downloadToFile: (
293
+ localfilename: string,
294
+ tenantid: string,
295
+ projectcontext: string,
296
+ log: boolean,
297
+ filetype: string,
298
+ level: string,
299
+ reference: string,
300
+ txmode: string, //production/development/test
301
+ ) => Promise<IFileResult>;
302
+ sendBlock: (
303
+ tenantid: string,
304
+ projectcontext: string,
305
+ log: boolean, //NOLOG or LOG file. This results in a different container
306
+ txmode: string, //production/development/test
307
+ filetype: string, //CSV, PDF,...
308
+ level: string, //Whether the files are stored at the LEVEL_TENANT or LEVEL_PROJECTCONTEXT
309
+ content: string, //This content to save
310
+ key: string, //blob id or filename
311
+ sliceNumber: number,
312
+ totalSlices: number,
313
+ meta: any, //meta data
314
+ tags: any, //tags
315
+ ) => void;
316
+ copy: (
317
+ sourceContainer: string,
318
+ sourceFile: string,
319
+ targetContainer: string,
320
+ targetFile: string,
321
+ ) => Promise<void>;
322
+ list: (
323
+ tenantid: string,
324
+ projectcontext: string,
325
+ log: boolean,
326
+ page: number,
327
+ pageSize: number,
328
+ term: string,
329
+ mode: string,
330
+ recordtype: string,
331
+ level: string,
332
+ enabled: boolean,
333
+ order: string,
334
+ ) => Promise<IDatasetFiles>;
335
+ remove: (
336
+ tenantid: string,
337
+ projectcontext: string,
338
+ level: string,
339
+ mode: string,
340
+ name: string,
341
+ ) => Promise<boolean>;
342
+ setMeta: (
343
+ tenantid: string,
344
+ projectcontext: string,
345
+ level: string,
346
+ mode: string,
347
+ name: string,
348
+ status: string,
349
+ ) => Promise<boolean>;
350
+ getContainerName: (
351
+ tenantid: string,
352
+ projectcontext: string,
353
+ level: string,
354
+ log: boolean,
355
+ txMode: string,
356
+ ) => string;
357
+ }
358
+
359
+ export interface ILogService {
360
+ archive: (
361
+ context: string,
362
+ projectcontext: string,
363
+ level: string,
364
+ submissionid: string,
365
+ username: string,
366
+ log: ILog[],
367
+ processingtype?: string,
368
+ ) => Promise<string>;
369
+ list: () => Promise<string[]>;
370
+ }
371
+
372
+ export interface ISecurityMonitorService {
373
+ hasPermission: (
374
+ permission: string,
375
+ roles: string[],
376
+ context: string,
377
+ ) => Promise<boolean>;
378
+ }
379
+
380
+ export type IChannel = "Email" | "SMS" | "WHATSAPP"; //How to refer to domain constants
381
+
382
+ export interface IProcessingConfig {
383
+ remove?: boolean; //controls if the file is to be processed as a delete
384
+ record?: boolean; //Controls if files are uploaded to storage account. Used when replaying files. Used during unit tests to skip upload.
385
+ modes?: IChannel[];
386
+ notificationenabled?: boolean;
387
+ }
388
+
389
+ export interface IPersistResult {
390
+ data: any[] | any;
391
+ error?: string;
392
+ }
393
+
394
+ export interface ILogStatus {
395
+ archiveid: string;
396
+ error?: string;
397
+ }
398
+
399
+ export interface ILog {
400
+ processingType: string;
401
+ processingConfig?: IProcessingConfig;
402
+ //An ILog represents the information collected while handling a file
403
+ blobid?: string; //id in storage account
404
+ documentId?: string; //when log is submitted from browser it can have a document id (TODO make this just id)
405
+ name?: string; //Original name of the document when originally loaded
406
+ localfilename?: string; //filename on node process
407
+ user: string; //upn of user
408
+ meta: {
409
+ documenttype: string; //Record or Data Type
410
+ context: string; //Tenant Id
411
+ projectcontext: string; //Project Id
412
+ entity?: string; //Entity Id which contains this document
413
+ recordstatus?: string;
414
+ level?: string;
415
+ user?: string;
416
+ createdat?: string;
417
+ effective?: string;
418
+ };
419
+
420
+ document?: IDocument; //The document details
421
+ processing?: any[];
422
+ rawdata?: any[];
423
+ transformeddata?: any[];
424
+ content_mappings?: any[]; //Mappings from csv reference to blobid
425
+ enriched_contentmappings?: any[]; //DocumentDataLinks reified
426
+ enricheddata?: any[]; //Enriched Data extracted from the document
427
+ persisted_data_result?: any[];
428
+ classifieddata?: any[];
429
+ filetype?: string; //csv,pdf or other
430
+ filter?: any; //Used to associate filtering metadata
431
+ error?: string;
432
+ archiveid?: string;
433
+ }
434
+
435
+ export interface IUser {
436
+ id: string;
437
+ name: string;
438
+ email: string;
439
+ mobile: string;
440
+ roles: string;
441
+ context: string;
442
+ }
443
+
444
+ export type IDatasetFile = {
445
+ context: string;
446
+ id: string;
447
+ filename: string;
448
+ lastModified: string;
449
+ filetype: string;
450
+ recordtype: string;
451
+ entity: string;
452
+ };
453
+
454
+ export type IDatasetFiles = {
455
+ count: number;
456
+ files: IDatasetFile[];
457
+ };
458
+
459
+ export type IDayRange = number[];
460
+
461
+ export interface IDataLockable extends IEntity {
462
+ locked: boolean;
463
+ lockedBy?: string;
464
+ }
465
+ export interface IDataArchivable extends IEntity {
466
+ archived: boolean;
467
+ archivedBy?: string;
468
+ }
469
+
470
+ export type IProject = IDataLockable &
471
+ IDataArchivable &
472
+ IName & {
473
+ description: string;
474
+ updatedBy: string;
475
+ updatedAt: Date;
476
+ createdBy: string;
477
+ createdAt: Date;
478
+ Categories?: ICategory[];
479
+ };
480
+ export interface ICategory extends INamedEntity {
481
+ colour: number;
482
+ // Projects?: IProject[];
483
+ }
484
+
485
+ export interface IAction {
486
+ name: (item: any) => string; // eslint-disable-line
487
+ icon: (item: any) => string; // eslint-disable-line
488
+ action: (item: any) => void; // eslint-disable-line
489
+ }
490
+
491
+ export interface IActionContext {
492
+ callback: () => void;
493
+ permissions: IPermission[];
494
+ logidsSet: (logs: ILogStatus[]) => void;
495
+ }
496
+
497
+ export type IGridAction<Type> = (
498
+ d: Type,
499
+ ac: IActionContext | null,
500
+ ) => Promise<boolean>;
501
+ export type IGridActionDisabled<Type> = (
502
+ d: Type,
503
+ ac: IActionContext | null,
504
+ ) => boolean;
505
+
506
+ export interface IDataGridAction<Type> {
507
+ label: string;
508
+ disabled?: IGridActionDisabled<Type>;
509
+ onClick?: IGridAction<Type>;
510
+ }
511
+
512
+ //----Dataset Manage Data Set----
513
+
514
+ export type API_POST_FILE_SLICE = (
515
+ filetype: string,
516
+ content: string | ArrayBuffer,
517
+ name: string,
518
+ documenttype: string,
519
+ level: string,
520
+ sliceNumber: number,
521
+ totalSlices: number,
522
+ meta: any,
523
+ ) => Promise<ICommandResult>;
524
+
525
+ export interface IManageDataSetConfiguration {
526
+ context: string;
527
+ projectcontext: string;
528
+ name: string;
529
+ datatype: string;
530
+ datatypeSet: (type: string) => void;
531
+ datatype_meta?: IDataTypeMeta[];
532
+
533
+ columns: { [datatype: string]: any[] };
534
+
535
+ required_permission: string;
536
+ permissions: IPermission[];
537
+
538
+ actions?: IDataGridAction<IDocument>[];
539
+ dataactions?: { [datatype: string]: IDataGridAction<any>[] };
540
+
541
+ cleantransform?: ICleanTransformCallback;
542
+
543
+ filter?: {
544
+ name: string;
545
+ filter: IFilterCallback;
546
+ };
547
+
548
+ idtransform: (d: any) => any;
549
+ getIDsforData?: IGetIdsForDataCallback;
550
+ getDataByID?: IGetDataByIdsCallback;
551
+ combineExistingAndUpdate?: ICombineExistingAndUpdateCallback;
552
+ filechooser?: IFileChoiceCallback;
553
+
554
+ createDocument?: (d: IDocument, stuff: any) => Promise<ICommandResult>;
555
+ queryValidationData?: (
556
+ datatype: string,
557
+ entities: string[],
558
+ ) => Promise<ICommandResult>;
559
+ queryRecords?: (
560
+ documenttype: string,
561
+ datatype: string,
562
+ encoding: string,
563
+ ) => Promise<ICommandResult>;
564
+
565
+ postFileSlice?: API_POST_FILE_SLICE;
566
+ postReplay: { [datatype: string]: API_POST_REPLAY };
567
+
568
+ useConfigurationItems?: (
569
+ context: string,
570
+ itemtype: string,
571
+ hash: number,
572
+ page: number,
573
+ pageSize: number,
574
+ ) => IResults<IConfigurationItem>;
575
+ useDocuments?: (
576
+ context: string,
577
+ projectcontext: string,
578
+ associated: string[],
579
+ entity_type: string,
580
+ entities: string[],
581
+ entity: string,
582
+ filetype: string,
583
+ search: string,
584
+ hash: number,
585
+ page: number,
586
+ pageSize: number,
587
+ timeperiod: IDayRange | null,
588
+ ) => IResults<IDocument>;
589
+ // useValidation: (doctype: string) => IResults<any>
590
+ useData: { [datatype: string]: HOOK_USE_DATA };
591
+ validators: any;
592
+ groupColumns?: (dt: IDatasetTable, b: boolean) => ITable | undefined;
593
+ datatypeLevels?: {
594
+ //Levels (Tenant/Project) for data types such that files are saved to the right containers
595
+ [datatype: string]: string;
596
+ };
597
+ }
598
+
599
+ export type API_POST_SAMPLE = (source: string) => Promise<ICommandResult>;
600
+ export type API_POST_REPLAY = (
601
+ source: string,
602
+ logs: ILog[],
603
+ ) => Promise<ICommandResult>;
604
+ export type HOOK_USE_DATA = (
605
+ context: string,
606
+ projectcontext: string,
607
+ datatype: string | undefined,
608
+ documenttype: string | undefined,
609
+ entity: string,
610
+ entities: string[],
611
+ timeperiod: IDayRange | null,
612
+ hash: number,
613
+ page: number,
614
+ pageSize: number,
615
+ transform: ((d: any) => any) | null,
616
+ allentities: boolean,
617
+ where: any,
618
+ ) => IResults<any>;
619
+
620
+ export interface IDataTypeMeta {
621
+ property: string;
622
+ description: string;
623
+ label: string;
624
+ tooltip: string;
625
+ value: (ci: IConfigurationItem) => string;
626
+ }
627
+
628
+ // ----Dataset Replay---
629
+ export type HOOK_USE_FILES = (
630
+ context: string,
631
+ projectcontext: string,
632
+ term: string,
633
+ recordtype: string,
634
+ onlyenabled: boolean,
635
+ level: string,
636
+ hash: number,
637
+ page: number,
638
+ pageSize: number,
639
+ ) => IResults<any>;
640
+
641
+ export type POST_SUBMIT_SAMPLE = () => any;
642
+
643
+ export interface IManageDatasetReplayConfiguration {
644
+ context: string;
645
+ projectcontext: string;
646
+ name: string;
647
+ columns: { [datatype: string]: any[] };
648
+
649
+ required_permission: string;
650
+ permissions: IPermission[];
651
+
652
+ role: string;
653
+
654
+ actions?: IDataGridAction<IDocument>[];
655
+ dataactions?: { [datatype: string]: IDataGridAction<any>[] };
656
+ postSample: API_POST_SAMPLE;
657
+ postReplay: { [datatype: string]: API_POST_REPLAY };
658
+ useFiles?: { [datatype: string]: HOOK_USE_FILES };
659
+
660
+ customReplay?: {
661
+ name: string;
662
+ process: (log: ILog, base64content: string) => Promise<ILog[]>;
663
+ };
664
+ }
665
+
666
+ export interface IMenuLink {
667
+ path: string;
668
+ label: string;
669
+ match?: RegExp;
670
+ }
671
+
672
+ export interface IMenuGroup {
673
+ label: string;
674
+ links: IMenuLink[];
675
+ }
676
+
677
+ export interface IMenuAction {
678
+ icon?: string;
679
+ label?: string;
680
+ size?: "small" | "large" | "extra small" | "medium";
681
+ isActive?: boolean;
682
+ click?: () => void;
683
+ }
684
+
685
+ export interface ITenant extends IEntity, IName, ITimed, IContext {
686
+ systemscontext: string; //Which system the tenant record relates to
687
+ lat: string;
688
+ lon: string;
689
+ underlay: string;
690
+ epsg: string;
691
+ }
692
+
693
+ export interface IFileSelection {
694
+ id: string;
695
+ name: string;
696
+ datasource: any;
697
+ }
698
+
699
+ //This is a table of data in JSON format
700
+ export type IDatasetTable = any[];
701
+
702
+ //This type is used in the right type of the ICleanTransformCallback function and represents a set of named tables
703
+ export type IDatasetsPackage = { [datatype: string]: IDatasetTable };
704
+
705
+ //This type if the callback signature for the cleantransform callback. A dataset table and datatype are provided. A datasets package is returned
706
+ export type ICleanTransformCallback = (
707
+ data: IDatasetTable,
708
+ datatype: string,
709
+ ) => IDatasetsPackage;
710
+
711
+ //This callback allows filtering of data types
712
+ export type IFilterCallback = (
713
+ datatype: string,
714
+ row: any,
715
+ links: IDocumentEntityLink[],
716
+ ) => boolean;
717
+
718
+ // Used to derive primary keys for data
719
+ export type IGetIdsForDataCallback = (
720
+ datatype: string,
721
+ data: IDatasetTable,
722
+ ) => string[];
723
+
724
+ // Used in the update to get existing data by id which is then merged with the incoming updates
725
+ export type IGetDataByIdsCallback = (
726
+ datatype: string,
727
+ ids: string[],
728
+ ) => Promise<IDatasetTable>;
729
+
730
+ // Used in the update to combine existing and incoming updates to provide updates ready to overwrite existing data.
731
+ export type ICombineExistingAndUpdateCallback = (
732
+ datatype: string,
733
+ updatedata: IDatasetTable,
734
+ existing: IDatasetTable,
735
+ ) => Promise<IDatasetTable>;
736
+
737
+ // Used in the update to combine existing and incoming updates to provide updates ready to overwrite existing data.
738
+ export type IFileChoiceCallback = () => IFileSelection[];