gps-global-types 1.0.2 → 1.0.4
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.
- package/link.types.tsx +12 -12
- package/mst.types.tsx +68 -86
- package/package.json +2 -1
- package/pie.types.tsx +3 -3
package/link.types.tsx
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import {BaseType,Selection, SimulationLinkDatum, SimulationNodeDatum} from 'd3';
|
|
2
|
-
import { mstGlobalTypes } from './mst.types';
|
|
1
|
+
import type { BaseType, Selection, SimulationLinkDatum, SimulationNodeDatum } from 'd3';
|
|
2
|
+
import type { mstGlobalTypes } from './mst.types.tsx';
|
|
3
3
|
interface coords {
|
|
4
|
-
x:number,
|
|
5
|
-
y:number
|
|
4
|
+
x: number,
|
|
5
|
+
y: number
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
export interface EdgeType { // extends SimulationLinkDatum<NodeType>} anything not defined here was added by d3 (or i fucked up)
|
|
8
|
+
source: coords // node _id edge to
|
|
9
|
+
target: coords // node _id edge from
|
|
10
|
+
value: number // distance between source and target
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export type gLinkType =
|
|
13
|
+
export type gLinkType = Selection<SVGGElement, EdgeType, BaseType, unknown>
|
|
14
14
|
export interface LinkType {
|
|
15
|
-
g:gLinkType
|
|
15
|
+
g: gLinkType
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export interface LinkProps
|
|
18
|
+
export interface LinkProps {
|
|
19
19
|
data: EdgeType[],
|
|
20
|
-
force:mstGlobalTypes
|
|
20
|
+
force: mstGlobalTypes
|
|
21
21
|
}
|
|
22
22
|
export type svgSelection = Selection<BaseType, gLinkType, Element, LinkType>; //Selection<Element,LinkType,Element,any>
|
package/mst.types.tsx
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { armordAccessionNumber, Color, mrsnId, ObjectId, RegexMatchedString } from "./global.types";
|
|
1
|
+
import type { armordAccessionNumber, Color, mrsnId, ObjectId, RegexMatchedString } from "./global.types.js";
|
|
2
|
+
import type { EdgeType } from "./link.types.js";
|
|
3
|
+
import type { NodeType } from "./pie.types.js";
|
|
2
4
|
|
|
3
5
|
export interface mstGlobalTypes {
|
|
4
6
|
//form values
|
|
@@ -11,15 +13,15 @@ export interface mstGlobalTypes {
|
|
|
11
13
|
fuzzyThreshold: number, //= 0, // nodes outside of requested list that are x alleles away from the original mst
|
|
12
14
|
neighbor: number, //= 1, // how many isolate neighbors to return (minimum)
|
|
13
15
|
slim?: boolean, //false //are the node labels collapsed or expanded?
|
|
14
|
-
|
|
16
|
+
|
|
15
17
|
//interactive nodes
|
|
16
18
|
// checkedNodes:mrsnId[], ????
|
|
17
19
|
// highlightedNodes:mrsnId[] ????
|
|
18
20
|
}
|
|
19
21
|
|
|
20
|
-
export const colorFields= ['armordPatientId','mlst','sampleType','armordFacility','armordCountry','custom color'] as const; //no :string[] ! removes 'const'
|
|
21
|
-
export const dateFields= ['armordCultureDate','month','quarter','year'] as const;
|
|
22
|
-
export const labelFields= ['armordMrsnIdLBL','mrsnIdLBL','armordAccessionNumberLBL','armordPatientIdLBL','custom label'] as const;
|
|
22
|
+
export const colorFields = ['armordPatientId', 'mlst', 'sampleType', 'armordFacility', 'armordCountry', 'custom color'] as const; //no :string[] ! removes 'const'
|
|
23
|
+
export const dateFields = ['armordCultureDate', 'month', 'quarter', 'year'] as const;
|
|
24
|
+
export const labelFields = ['armordMrsnIdLBL', 'mrsnIdLBL', 'armordAccessionNumberLBL', 'armordPatientIdLBL', 'custom label'] as const;
|
|
23
25
|
|
|
24
26
|
export type colorKey = typeof colorFields[number];
|
|
25
27
|
export type dateKey = typeof dateFields[number];
|
|
@@ -29,101 +31,81 @@ export type labelKey = typeof labelFields[number];
|
|
|
29
31
|
|
|
30
32
|
|
|
31
33
|
|
|
32
|
-
interface ColorType {
|
|
33
|
-
color:Color, //unique hex of parameter
|
|
34
|
-
value:number //count of how many times value will be represented in the pie
|
|
35
|
-
}
|
|
36
|
-
type LabelType = RegexMatchedString<'(\w&)*'> // if many, seperated by '&' qhich are interpreted as newlines in front-end. var names ends with 'LBL'.
|
|
37
|
-
type DateType = string | Date // must be able to be interpreted as date type by Date js object
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
interface ExtraNodeTypeFields {
|
|
41
|
-
id:ObjectId,//unique identifier referenced by Graph.links and d3 Force. String but it's a string of a mongo id
|
|
42
|
-
beforeAndAfter?:ColorType[] //[=[{color:'#fff',value:1}]] so it doesnt break on recalculation
|
|
43
|
-
dateArr:DateType[], // array of armordCultureDates used for beforeAndAfter coloring
|
|
44
|
-
hover?:String, // [=""] //unique fieldfields \/ \/ list seperated by ', ' (only tier1 alleles for now)
|
|
45
|
-
mrsnIds: String[] // for selection logic between table and node=
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
type NodeType = ExtraNodeTypeFields | Record<colorKey|dateKey, ColorType[]> | Record<labelKey, LabelType[]>;
|
|
49
|
-
|
|
50
|
-
interface EdgeType {
|
|
51
|
-
source:string, //node _id edge to
|
|
52
|
-
target:string, //node _id edge from
|
|
53
|
-
value:number //distance between source and target
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
type CustomDictEntry = Record<colorKey|dateKey,Color> | Record<labelKey,string>;
|
|
57
|
-
type CustomDict = Record<ObjectId,CustomDictEntry>
|
|
58
34
|
|
|
35
|
+
type CustomDictEntry = Record<colorKey | dateKey, Color> | Record<labelKey, string>;
|
|
36
|
+
export type CustomDict = Record<ObjectId, CustomDictEntry>
|
|
59
37
|
|
|
60
38
|
|
|
39
|
+
export interface LatestNodes { armordCultureDate: Date | string, isos: NodeType[], _id: ObjectId[] }
|
|
61
40
|
export interface MSTGraph {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
41
|
+
name?:string,
|
|
42
|
+
snapshotData?:SnapshotType
|
|
43
|
+
nodes: NodeType[] // core parameter of d3tree.js . keeps all isolates collection data
|
|
44
|
+
links: EdgeType[] // core parameter of d3tree.js
|
|
45
|
+
latest: LatestNodes // earliest node for easy toggling
|
|
46
|
+
custom: CustomDict // . I KNOW THIS IS DUMB but from user's pov it results in seamless color transitions across pages
|
|
47
|
+
legend: MSTLegend // saves legend configs across all color fields
|
|
48
|
+
missing:Record<string,any>[] //todo: isolate.types. global
|
|
67
49
|
}interface FlashTable {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
50
|
+
"_id": ObjectId,
|
|
51
|
+
"MRSN ID¹": mrsnId,
|
|
52
|
+
"Cx Date": Date | string,
|
|
53
|
+
"Cx Source": string,
|
|
54
|
+
"Wards": string,
|
|
55
|
+
"Prev Report #²": string,
|
|
56
|
+
"Accession #": armordAccessionNumber,
|
|
57
|
+
"Last Name": "...",
|
|
58
|
+
"DOD ID": "..."
|
|
77
59
|
}
|
|
78
60
|
|
|
79
61
|
interface FlashData { //todo: add 'tier1s' here
|
|
80
|
-
dateCreated:Date,
|
|
81
|
-
first:boolean, //first node added to thec cluster
|
|
82
|
-
isolateCount:number,
|
|
83
|
-
lastModified:Date,
|
|
84
|
-
mostRecent:{
|
|
85
|
-
_id:ObjectId[],
|
|
86
|
-
armordCultureDate:Date|string,
|
|
87
|
-
isos:Record<string,any>[], //todo
|
|
62
|
+
dateCreated: Date,
|
|
63
|
+
first: boolean, //first node added to thec cluster
|
|
64
|
+
isolateCount: number,
|
|
65
|
+
lastModified: Date,
|
|
66
|
+
mostRecent: {
|
|
67
|
+
_id: ObjectId[],
|
|
68
|
+
armordCultureDate: Date | string,
|
|
69
|
+
isos: Record<string, any>[], //todo
|
|
88
70
|
}
|
|
89
|
-
mostCloselyRelated:{
|
|
90
|
-
_id:ObjectId,
|
|
91
|
-
armordCultureDate:Date|string,
|
|
92
|
-
distance:number
|
|
71
|
+
mostCloselyRelated: {
|
|
72
|
+
_id: ObjectId,
|
|
73
|
+
armordCultureDate: Date | string,
|
|
74
|
+
distance: number
|
|
93
75
|
},
|
|
94
|
-
patientCount:number,
|
|
95
|
-
st:string,
|
|
96
|
-
table:FlashTable[],
|
|
97
|
-
wardCount:string,
|
|
98
|
-
wgsId:string
|
|
76
|
+
patientCount: number,
|
|
77
|
+
st: string,
|
|
78
|
+
table: FlashTable[],
|
|
79
|
+
wardCount: string,
|
|
80
|
+
wgsId: string
|
|
99
81
|
}
|
|
100
82
|
|
|
101
83
|
|
|
102
84
|
interface MSTResult {
|
|
103
|
-
flash:FlashData,
|
|
104
|
-
graph:MSTGraph,
|
|
105
|
-
tabular:{
|
|
106
|
-
isolate:Record<string,any>[],
|
|
107
|
-
amr:Record<string,any>[]
|
|
85
|
+
flash: FlashData,
|
|
86
|
+
graph: MSTGraph,
|
|
87
|
+
tabular: {
|
|
88
|
+
isolate: Record<string, any>[],
|
|
89
|
+
amr: Record<string, any>[]
|
|
108
90
|
}
|
|
109
91
|
}
|
|
110
92
|
|
|
111
93
|
interface LegendBullet { //or custom upload data
|
|
112
|
-
color:Color,
|
|
113
|
-
label:string
|
|
94
|
+
color: Color,
|
|
95
|
+
label: string
|
|
114
96
|
}
|
|
115
97
|
|
|
116
|
-
type MSTLegend = Record<colorKey,LegendBullet[]
|
|
98
|
+
export type MSTLegend = Record<colorKey, LegendBullet[]> | Record<dateKey, 'date'> | { 'beforeAndAfter': [{ color: '#666666', label: 'Before ' }, { color: '#4a64aa', label: 'After ' }] }
|
|
117
99
|
|
|
118
100
|
|
|
119
101
|
|
|
120
|
-
interface SnapshotType {
|
|
121
|
-
_id:ObjectId,
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
102
|
+
export interface SnapshotType {
|
|
103
|
+
_id: ObjectId,
|
|
104
|
+
form: mstGlobalTypes,
|
|
105
|
+
legend: LegendBullet[],
|
|
106
|
+
nodes: Record<ObjectId, LegendBullet>,
|
|
107
|
+
scheme: string,
|
|
108
|
+
transforms: Record<ObjectId, { x: number, y: number }>
|
|
127
109
|
}
|
|
128
110
|
/** /mst route RESULT
|
|
129
111
|
|
|
@@ -132,7 +114,7 @@ interface SnapshotType {
|
|
|
132
114
|
* @property {MSTGraph} data except it only requires links,nodes,legend, and custom
|
|
133
115
|
* @property {ForceObject} form
|
|
134
116
|
* @property {String|null} _id cluster _id
|
|
135
|
-
* @property {function(Snapshot)} setSnapshot
|
|
117
|
+
* @property {function(Snapshot)} setSnapshot
|
|
136
118
|
* @property {function(MSTGraph)} setData trigger parent data state which affects variables in parent
|
|
137
119
|
* @property {function([[import('../../typedefs/MSTree').mrsnId[],Boolean ]])} setSelected connects nodes to table rows on click
|
|
138
120
|
*/
|
|
@@ -143,7 +125,7 @@ interface SnapshotType {
|
|
|
143
125
|
*/
|
|
144
126
|
/**string
|
|
145
127
|
* @typedef ItolProps
|
|
146
|
-
* @property {string} scheme
|
|
128
|
+
* @property {string} scheme
|
|
147
129
|
* @property {ObjectId[]} isolates targets centered for analysis
|
|
148
130
|
* @property {int} neighbors min # of nearest samples to include (beyond targets)
|
|
149
131
|
* @property {int} threshold max allelic distance from the targets to include
|
|
@@ -156,13 +138,13 @@ interface SnapshotType {
|
|
|
156
138
|
* @property {Date} lastModified
|
|
157
139
|
* @property {Date} dateModified
|
|
158
140
|
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
141
|
+
*
|
|
142
|
+
*
|
|
143
|
+
*
|
|
144
|
+
*
|
|
145
|
+
*
|
|
164
146
|
* @typedef {{...SplashReq,...MstFields}} MSTreeReq
|
|
165
147
|
*
|
|
166
148
|
*/
|
|
167
|
-
|
|
168
|
-
|
|
149
|
+
// module.exports = { MSTGraph, MSTLegend, NodeType,EdgeType,Hex, ColorField,LabelField}
|
|
150
|
+
// exports.unused = {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gps-global-types",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "types shared between front-end and back-end",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"react": "^19.1.1"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
+
"@types/d3": "^7.4.3",
|
|
17
18
|
"typescript": "^5.9.2"
|
|
18
19
|
}
|
|
19
20
|
}
|
package/pie.types.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BaseType, Selection, SimulationNodeDatum } from "d3"
|
|
2
|
-
import { ObjectId, Color, RegexMatchedString } from "./global.types"
|
|
3
|
-
import { colorKey, dateKey, labelKey } from "./mst.types"
|
|
1
|
+
import type { BaseType, Selection, SimulationNodeDatum } from "d3";
|
|
2
|
+
import type { ObjectId, Color, RegexMatchedString } from "./global.types.tsx"
|
|
3
|
+
import type { colorKey, dateKey, labelKey } from "./mst.types.tsx"
|
|
4
4
|
|
|
5
5
|
export interface ColorField {//TYPES OF GRAPH FIELDS ColorField datefields become colorFields but require additional processing
|
|
6
6
|
color: string, // unique hex or rgb of parameter
|