@sjcrh/proteinpaint-types 2.86.0 → 2.87.1
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/README.md +22 -0
- package/dist/brainImaging.js +11 -0
- package/dist/brainImagingSamples.js +11 -0
- package/dist/burden.js +11 -0
- package/dist/chunk-37ZPCVP5.js +111 -0
- package/dist/chunk-5GG2FNAY.js +62 -0
- package/dist/chunk-5JWTIWVB.js +222 -0
- package/dist/chunk-5RZYB4M4.js +171 -0
- package/dist/chunk-6EFB6ZMB.js +62 -0
- package/dist/chunk-6LFMFM2C.js +122 -0
- package/dist/chunk-7PMGKVWQ.js +62 -0
- package/dist/chunk-7Z3IHB43.js +152 -0
- package/dist/chunk-B3D26X6X.js +337 -0
- package/dist/chunk-BY2JABTF.js +256 -0
- package/dist/chunk-CETMA2FU.js +144 -0
- package/dist/chunk-DCN75URO.js +1740 -0
- package/dist/chunk-DIDZMC3G.js +96 -0
- package/dist/chunk-DKSPASWZ.js +4058 -0
- package/dist/chunk-EWRK4PKZ.js +62 -0
- package/dist/chunk-FDTUTGQG.js +288 -0
- package/dist/chunk-FZ6QOTGM.js +205 -0
- package/dist/chunk-GU7LIGHN.js +174 -0
- package/dist/chunk-IL33L6MY.js +126 -0
- package/dist/chunk-INDBFC54.js +1538 -0
- package/dist/chunk-IT7IGDC4.js +1697 -0
- package/dist/chunk-IWG5IPXG.js +3409 -0
- package/dist/chunk-JEQ3TBVQ.js +1472 -0
- package/dist/chunk-JPW6LFDQ.js +1507 -0
- package/dist/chunk-K2KQTFQI.js +113 -0
- package/dist/chunk-M33KP65Z.js +3347 -0
- package/dist/chunk-MUJUKENL.js +62 -0
- package/dist/chunk-N45Z3JCY.js +62 -0
- package/dist/chunk-OMHEDUNA.js +62 -0
- package/dist/chunk-OY3EKV7F.js +130 -0
- package/dist/chunk-Q56YNQFK.js +3417 -0
- package/dist/chunk-QDIIM52V.js +165 -0
- package/dist/chunk-QX7QLUKY.js +228 -0
- package/dist/chunk-RLFGMVJZ.js +234 -0
- package/dist/chunk-SDOWCOGK.js +96 -0
- package/dist/chunk-UCG25D2C.js +109 -0
- package/dist/chunk-UIU3IQH4.js +62 -0
- package/dist/chunk-W3F2RMPU.js +3494 -0
- package/dist/chunk-W3QYIXXF.js +273 -0
- package/dist/chunk-XGAOGA3F.js +159 -0
- package/dist/chunk-XJCQEOPB.js +61 -0
- package/dist/chunk-XLBSZOMF.js +117 -0
- package/dist/chunk-XQQ5G6N6.js +109 -0
- package/dist/chunk-Z6B6IQIY.js +1785 -0
- package/dist/dataset.js +11 -0
- package/dist/dsdata.js +11 -0
- package/dist/dzimages.js +11 -0
- package/dist/gdc.maf.js +11 -0
- package/dist/gdc.mafBuild.js +11 -0
- package/dist/gdc.topMutatedGenes.js +11 -0
- package/dist/genelookup.js +11 -0
- package/dist/genesetEnrichment.js +11 -0
- package/dist/genesetOverrepresentation.js +11 -0
- package/dist/healthcheck.js +11 -0
- package/dist/hicdata.js +11 -0
- package/dist/hicgenome.js +11 -0
- package/dist/hicstat.js +11 -0
- package/dist/index.js +347 -0
- package/dist/isoformlst.js +11 -0
- package/dist/ntseq.js +11 -0
- package/dist/pdomain.js +11 -0
- package/dist/samplewsimages.js +11 -0
- package/dist/snp.js +11 -0
- package/dist/termdb.DE.js +11 -0
- package/dist/termdb.boxplot.js +11 -0
- package/dist/termdb.categories.js +11 -0
- package/dist/termdb.cluster.js +11 -0
- package/dist/termdb.cohort.summary.js +11 -0
- package/dist/termdb.cohorts.js +11 -0
- package/dist/termdb.descrstats.js +11 -0
- package/dist/termdb.numericcategories.js +11 -0
- package/dist/termdb.percentile.js +11 -0
- package/dist/termdb.rootterm.js +11 -0
- package/dist/termdb.sampleImages.js +11 -0
- package/dist/termdb.singleSampleMutation.js +11 -0
- package/dist/termdb.singlecellDEgenes.js +11 -0
- package/dist/termdb.singlecellData.js +11 -0
- package/dist/termdb.singlecellSamples.js +11 -0
- package/dist/termdb.termchildren.js +11 -0
- package/dist/termdb.termsbyids.js +11 -0
- package/dist/termdb.topTermsByType.js +11 -0
- package/dist/termdb.topVariablyExpressedGenes.js +11 -0
- package/dist/termdb.violin.js +11 -0
- package/dist/tileserver.js +11 -0
- package/dist/wsimages.js +11 -0
- package/package.json +17 -15
- package/src/Mclass.ts +8 -0
- package/src/dataset.ts +1588 -0
- package/src/docs.json +16417 -0
- package/src/fileOrUrl.ts +15 -0
- package/src/filter.ts +125 -0
- package/src/genome.ts +123 -0
- package/src/index.ts +67 -0
- package/src/routes/brainImaging.ts +47 -0
- package/src/routes/brainImagingSamples.ts +25 -0
- package/src/routes/burden.ts +111 -0
- package/src/routes/dataset.ts +14 -0
- package/src/routes/dsdata.ts +14 -0
- package/src/routes/dzimages.ts +25 -0
- package/src/routes/errorResponse.ts +6 -0
- package/src/routes/filter.gdc.ts +15 -0
- package/src/routes/gdc.maf.ts +52 -0
- package/src/routes/gdc.mafBuild.ts +20 -0
- package/src/routes/gdc.topMutatedGenes.ts +37 -0
- package/src/routes/genelookup.ts +22 -0
- package/src/routes/genesetEnrichment.ts +60 -0
- package/src/routes/genesetOverrepresentation.ts +48 -0
- package/src/routes/healthcheck.ts +79 -0
- package/src/routes/hicdata.ts +48 -0
- package/src/routes/hicgenome.ts +50 -0
- package/src/routes/hicstat.ts +57 -0
- package/src/routes/isoformlst.ts +14 -0
- package/src/routes/ntseq.ts +14 -0
- package/src/routes/pdomain.ts +14 -0
- package/src/routes/routeApi.ts +41 -0
- package/src/routes/samplewsimages.ts +27 -0
- package/src/routes/snp.ts +13 -0
- package/src/routes/termdb.DE.ts +57 -0
- package/src/routes/termdb.boxplot.ts +78 -0
- package/src/routes/termdb.categories.ts +73 -0
- package/src/routes/termdb.cluster.ts +103 -0
- package/src/routes/termdb.cohort.summary.ts +14 -0
- package/src/routes/termdb.cohorts.ts +14 -0
- package/src/routes/termdb.descrstats.ts +78 -0
- package/src/routes/termdb.numericcategories.ts +32 -0
- package/src/routes/termdb.percentile.ts +65 -0
- package/src/routes/termdb.rootterm.ts +49 -0
- package/src/routes/termdb.sampleImages.ts +26 -0
- package/src/routes/termdb.singleSampleMutation.ts +29 -0
- package/src/routes/termdb.singlecellDEgenes.ts +41 -0
- package/src/routes/termdb.singlecellData.ts +69 -0
- package/src/routes/termdb.singlecellSamples.ts +46 -0
- package/src/routes/termdb.termchildren.ts +49 -0
- package/src/routes/termdb.termsbyids.ts +26 -0
- package/src/routes/termdb.topTermsByType.ts +32 -0
- package/src/routes/termdb.topVariablyExpressedGenes.ts +56 -0
- package/src/routes/termdb.violin.ts +122 -0
- package/src/routes/tileserver.ts +14 -0
- package/src/routes/wsimages.ts +24 -0
- package/src/terms/categorical.ts +106 -0
- package/src/terms/condition.ts +55 -0
- package/src/terms/geneExpression.ts +32 -0
- package/src/terms/geneVariant.ts +51 -0
- package/src/terms/metaboliteIntensity.ts +31 -0
- package/src/terms/numeric.ts +253 -0
- package/src/terms/q.ts +38 -0
- package/src/terms/samplelst.ts +41 -0
- package/src/terms/singleCellCellType.ts +22 -0
- package/src/terms/singleCellGeneExpression.ts +28 -0
- package/src/terms/snp.ts +28 -0
- package/src/terms/snps.ts +110 -0
- package/src/terms/term.ts +184 -0
- package/src/terms/tw.ts +38 -0
- package/src/terms/updated-types.ts +9 -0
- package/src/termsetting.ts +197 -0
- package/src/test/numeric.type.spec.ts +275 -0
- package/src/vocab.ts +37 -0
- package/dist/routes.ts +0 -28911
- package/src/Mclass.js +0 -0
- package/src/checkers/routes.js +0 -167
- package/src/dataset.js +0 -0
- package/src/fileOrUrl.js +0 -0
- package/src/filter.js +0 -0
- package/src/genome.js +0 -0
- package/src/index.js +0 -66
- package/src/routes/brainImaging.js +0 -11
- package/src/routes/brainImagingSamples.js +0 -11
- package/src/routes/burden.js +0 -44
- package/src/routes/dataset.js +0 -12
- package/src/routes/dsdata.js +0 -12
- package/src/routes/dzimages.js +0 -12
- package/src/routes/errorResponse.js +0 -0
- package/src/routes/filter.gdc.js +0 -0
- package/src/routes/gdc.maf.js +0 -17
- package/src/routes/gdc.mafBuild.js +0 -12
- package/src/routes/gdc.topMutatedGenes.js +0 -12
- package/src/routes/genelookup.js +0 -12
- package/src/routes/genesetEnrichment.js +0 -12
- package/src/routes/genesetOverrepresentation.js +0 -12
- package/src/routes/healthcheck.js +0 -23
- package/src/routes/hicdata.js +0 -12
- package/src/routes/hicgenome.js +0 -29
- package/src/routes/hicstat.js +0 -12
- package/src/routes/isoformlst.js +0 -12
- package/src/routes/ntseq.js +0 -12
- package/src/routes/pdomain.js +0 -12
- package/src/routes/routeApi.js +0 -0
- package/src/routes/samplewsimages.js +0 -12
- package/src/routes/snp.js +0 -11
- package/src/routes/termdb.DE.js +0 -13
- package/src/routes/termdb.boxplot.js +0 -12
- package/src/routes/termdb.categories.js +0 -48
- package/src/routes/termdb.cluster.js +0 -12
- package/src/routes/termdb.cohort.summary.js +0 -12
- package/src/routes/termdb.cohorts.js +0 -12
- package/src/routes/termdb.descrstats.js +0 -48
- package/src/routes/termdb.numericcategories.js +0 -12
- package/src/routes/termdb.percentile.js +0 -49
- package/src/routes/termdb.rootterm.js +0 -27
- package/src/routes/termdb.sampleImages.js +0 -12
- package/src/routes/termdb.singleSampleMutation.js +0 -12
- package/src/routes/termdb.singlecellDEgenes.js +0 -12
- package/src/routes/termdb.singlecellData.js +0 -12
- package/src/routes/termdb.singlecellSamples.js +0 -12
- package/src/routes/termdb.termchildren.js +0 -28
- package/src/routes/termdb.termsbyids.js +0 -12
- package/src/routes/termdb.topTermsByType.js +0 -12
- package/src/routes/termdb.topVariablyExpressedGenes.js +0 -12
- package/src/routes/termdb.violin.js +0 -49
- package/src/routes/tileserver.js +0 -12
- package/src/routes/wsimages.js +0 -12
- package/src/terms/categorical.js +0 -0
- package/src/terms/condition.js +0 -0
- package/src/terms/geneExpression.js +0 -0
- package/src/terms/geneVariant.js +0 -0
- package/src/terms/metaboliteIntensity.js +0 -0
- package/src/terms/numeric.js +0 -0
- package/src/terms/q.js +0 -0
- package/src/terms/samplelst.js +0 -0
- package/src/terms/singleCellCellType.js +0 -0
- package/src/terms/singleCellGeneExpression.js +0 -0
- package/src/terms/snp.js +0 -0
- package/src/terms/snps.js +0 -0
- package/src/terms/term.js +0 -0
- package/src/terms/tw.js +0 -0
- package/src/terms/updated-types.js +0 -0
- package/src/termsetting.js +0 -0
- package/src/test/numeric.type.spec.js +0 -117
- package/src/vocab.js +0 -0
package/src/terms/tw.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { BaseQ, BaseTW, Term } from './term.ts'
|
|
2
|
+
import { CategoricalQ, CategoricalTW } from './categorical.ts'
|
|
3
|
+
import { NumericQ, NumericTW } from './numeric.ts'
|
|
4
|
+
import { SnpsQ, SnpsTW } from './snps.ts'
|
|
5
|
+
import { ConditionQ } from './condition.ts'
|
|
6
|
+
import { GeneVariantQ } from './geneVariant.ts'
|
|
7
|
+
import { SampleLstQ } from './samplelst.ts'
|
|
8
|
+
|
|
9
|
+
export type TermWrapper = CategoricalTW | NumericTW | SnpsTW | (BaseTW & { term: Term; q: Q })
|
|
10
|
+
export type TwLst = TermWrapper[]
|
|
11
|
+
|
|
12
|
+
export type Q = BaseQ | CategoricalQ | ConditionQ | NumericQ | GeneVariantQ | SampleLstQ | SnpsQ
|
|
13
|
+
|
|
14
|
+
export type RawTW =
|
|
15
|
+
//{ id: string } | RawCatTW
|
|
16
|
+
//
|
|
17
|
+
// BELOW TYPE IS NOT TESTED, only being used to compare tsc type checking behavior
|
|
18
|
+
// between non-union versus type-unions, which way is easier to code against
|
|
19
|
+
{
|
|
20
|
+
id?: string
|
|
21
|
+
term?: {
|
|
22
|
+
type: 'categorical' | 'condition'
|
|
23
|
+
[key: string | number]: any
|
|
24
|
+
}
|
|
25
|
+
q?: {
|
|
26
|
+
//predefined_groupset_idx?: number
|
|
27
|
+
//customset?: any
|
|
28
|
+
[key: string]: any
|
|
29
|
+
//type?: string //'custom-groupset' |
|
|
30
|
+
//customset?: any
|
|
31
|
+
}
|
|
32
|
+
isAtomic?: true
|
|
33
|
+
$id?: string
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface TwHandler {
|
|
37
|
+
render?: (opts?: any) => void
|
|
38
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// temporary code file to hold updated type definitions
|
|
2
|
+
// as part of the tw router/handler refactor
|
|
3
|
+
|
|
4
|
+
import { CatTWTypes, CategoricalQ } from './categorical.ts'
|
|
5
|
+
import { NumTWTypes, NumericQ } from './numeric.ts'
|
|
6
|
+
|
|
7
|
+
export type TermWrapper = CatTWTypes | NumTWTypes
|
|
8
|
+
|
|
9
|
+
export type Q = CategoricalQ | NumericQ // | other q
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
// TODO: will deprecate this code, should use client/termsetting/types.ts instead
|
|
2
|
+
import { VocabApi } from './vocab.ts'
|
|
3
|
+
import { TermWrapper, Q } from './terms/tw.ts'
|
|
4
|
+
import { Term } from './terms/term.ts'
|
|
5
|
+
import { Filter } from './filter.ts'
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
|
|
9
|
+
!!!
|
|
10
|
+
For shared/types:
|
|
11
|
+
- Declare only the types that are used in the request and response payloads, or in *both* client and server-side code
|
|
12
|
+
- Do not track client or server-specific type declarations here, those belong in the corresponding workspace code
|
|
13
|
+
!!!
|
|
14
|
+
|
|
15
|
+
--------EXPORTED--------
|
|
16
|
+
Dom
|
|
17
|
+
Api
|
|
18
|
+
NoTermPromptOptsEntry
|
|
19
|
+
UseCase
|
|
20
|
+
SampleCountsEntry
|
|
21
|
+
Handler
|
|
22
|
+
PillData
|
|
23
|
+
TermSettingOpts
|
|
24
|
+
InstanceDom
|
|
25
|
+
TermSettingInstance
|
|
26
|
+
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/*** types supporting TermSettingOpts & PillData types ***/
|
|
30
|
+
|
|
31
|
+
export type Dom = {
|
|
32
|
+
holder: Selection
|
|
33
|
+
tip: any //TODO Menu type??
|
|
34
|
+
tip2: any //same as above
|
|
35
|
+
nopilldiv?: Selection
|
|
36
|
+
pilldiv?: Selection
|
|
37
|
+
btnDiv?: Selection
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type NoTermPromptOptsEntry = {
|
|
41
|
+
isDictionary?: boolean
|
|
42
|
+
termtype?: string
|
|
43
|
+
text?: string
|
|
44
|
+
html?: string
|
|
45
|
+
q?: Q
|
|
46
|
+
/** whether or not opt is invalid */
|
|
47
|
+
invalid?: boolean
|
|
48
|
+
/** message displayed when opt is invalid */
|
|
49
|
+
invalidMsg?: string
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
type NumericContEditOptsEntry = {
|
|
53
|
+
scale: string
|
|
54
|
+
transform: string
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export type UseCase = {
|
|
58
|
+
target: string
|
|
59
|
+
detail?: string //Maybe?
|
|
60
|
+
regressionType?: string //Maybe?
|
|
61
|
+
term1type?: string //Maybe? not documented
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
type DefaultQ4fillTW = {
|
|
65
|
+
[index: string]: Q
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export type SampleCountsEntry = {
|
|
69
|
+
key: string
|
|
70
|
+
value: number //This maybe a string???
|
|
71
|
+
label?: string //Not documented?? in key or no?
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export type Handler = {
|
|
75
|
+
getPillName: (d: any) => string
|
|
76
|
+
getPillStatus: (f?: any) => any
|
|
77
|
+
showEditMenu: (div: Selection) => void
|
|
78
|
+
validateQ?: (d: Q) => void
|
|
79
|
+
postMain?: () => void
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
type BaseTermSettingOpts = {
|
|
83
|
+
//Optional
|
|
84
|
+
abbrCutoff?: number
|
|
85
|
+
activeCohort?: number
|
|
86
|
+
disable_terms?: string[]
|
|
87
|
+
handler: Handler
|
|
88
|
+
noTermPromptOptions?: NoTermPromptOptsEntry[]
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export type PillData = BaseTermSettingOpts & {
|
|
92
|
+
$id?: string
|
|
93
|
+
doNotHideTipInMain: boolean
|
|
94
|
+
dom: Dom
|
|
95
|
+
error?: string
|
|
96
|
+
filter?: Filter
|
|
97
|
+
q?: Q
|
|
98
|
+
sampleCounts?: SampleCountsEntry[]
|
|
99
|
+
term?: Term
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export type TermSettingOpts = BaseTermSettingOpts & {
|
|
103
|
+
//Required
|
|
104
|
+
holder: any
|
|
105
|
+
vocabApi: VocabApi
|
|
106
|
+
//Optional
|
|
107
|
+
$id?: string
|
|
108
|
+
buttons?: string[] //replace, delete, info
|
|
109
|
+
defaultQ4fillTW?: DefaultQ4fillTW
|
|
110
|
+
menuOptions: string //all, edit, replace, remove
|
|
111
|
+
menuLayout?: string //horizonal, all
|
|
112
|
+
numericEditMenuVersion?: string[]
|
|
113
|
+
geneVariantEditMenuOnlyGrp?: boolean
|
|
114
|
+
numericContinuousEditOptions?: NumericContEditOptsEntry[]
|
|
115
|
+
placeholder?: string
|
|
116
|
+
placeholderIcon?: string //default '+'
|
|
117
|
+
renderAs: string //none
|
|
118
|
+
tip?: any //TODO: Menu type?
|
|
119
|
+
use_bins_less?: boolean
|
|
120
|
+
usecase?: UseCase
|
|
121
|
+
debug?: boolean | number //true or 1
|
|
122
|
+
//'snplocus' types
|
|
123
|
+
genomeObj?: any
|
|
124
|
+
|
|
125
|
+
//vocab??
|
|
126
|
+
|
|
127
|
+
// required callback function. argument is the updated termwrapper object
|
|
128
|
+
callback: (f: TermWrapper | null) => void
|
|
129
|
+
|
|
130
|
+
// ?
|
|
131
|
+
customFillTw?: (f: TermWrapper) => void
|
|
132
|
+
|
|
133
|
+
// to pass in purpose and context-specific arguments that will be merged to client request parameters
|
|
134
|
+
getBodyParams?: () => any
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/*** types supporting TermSettingInstance type ***/
|
|
138
|
+
|
|
139
|
+
export type InstanceDom = {
|
|
140
|
+
//Separate from the Dom outlined in termsetting.ts?????
|
|
141
|
+
//Required
|
|
142
|
+
holder: any
|
|
143
|
+
tip: any //TODO Menu type??
|
|
144
|
+
tip2: any //same as above
|
|
145
|
+
nopilldiv?: any
|
|
146
|
+
pilldiv?: any
|
|
147
|
+
btnDiv?: any
|
|
148
|
+
//Optional
|
|
149
|
+
customBinBoundaryInput?: any
|
|
150
|
+
customBinBoundaryPercentileCheckbox?: any
|
|
151
|
+
customBinLabelInput?: any
|
|
152
|
+
customBinRanges?: any
|
|
153
|
+
cutoff_div?: any
|
|
154
|
+
num_holder?: any
|
|
155
|
+
pill_termname?: any
|
|
156
|
+
rangeAndLabelDiv?: any
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export type TermSettingInstance = {
|
|
160
|
+
activeCohort?: number
|
|
161
|
+
clickNoPillDiv?: any
|
|
162
|
+
dom: InstanceDom
|
|
163
|
+
doNotHideTipInMain?: boolean
|
|
164
|
+
disable_terms?: string[]
|
|
165
|
+
durations: { exit: number }
|
|
166
|
+
filter?: Filter
|
|
167
|
+
handler?: Handler
|
|
168
|
+
handlerByType?: { [index: string]: Handler }
|
|
169
|
+
hasError?: boolean
|
|
170
|
+
noTermPromptOptions?: NoTermPromptOptsEntry[]
|
|
171
|
+
opts: TermSettingOpts
|
|
172
|
+
placeholder: string | undefined
|
|
173
|
+
q: Q
|
|
174
|
+
term: Term
|
|
175
|
+
usecase?: UseCase
|
|
176
|
+
vocabApi: VocabApi
|
|
177
|
+
|
|
178
|
+
//Methods
|
|
179
|
+
/*
|
|
180
|
+
TODOs:
|
|
181
|
+
- Move specifc methods to their own intersection instance type within in termsetting/handler/*.ts, out of main type
|
|
182
|
+
*/
|
|
183
|
+
cancelGroupsetting?: () => void
|
|
184
|
+
enterPill?: () => void
|
|
185
|
+
exitPill?: () => void
|
|
186
|
+
initUI: () => void
|
|
187
|
+
removeTerm?: () => void
|
|
188
|
+
runCallback: (f?: any) => any
|
|
189
|
+
setHandler?: (f: string) => any
|
|
190
|
+
showGeneSearch: (clickedElem: Element | null, event: MouseEvent) => void
|
|
191
|
+
showMenu: (event: MouseEvent, clickedElem: string | null, menuHolder: any) => void
|
|
192
|
+
showReuseMenu?: (div: any) => void
|
|
193
|
+
showTree: (holder: Selection, event?: MouseEvent) => void
|
|
194
|
+
tabCallback?: (event: any, tab: any) => void
|
|
195
|
+
updatePill?: () => void
|
|
196
|
+
updateUI: () => void
|
|
197
|
+
}
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import { StartUnboundedBin, StopUnboundedBin, FullyBoundedBin, NumericTerm } from '../terms/numeric'
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
Non-asserted type definition tests
|
|
5
|
+
|
|
6
|
+
For training only
|
|
7
|
+
- these tests are not meant to be written for all declared types
|
|
8
|
+
|
|
9
|
+
- meant for simple "sanity check", that a declaration makes sense and CATCHES ERRORS
|
|
10
|
+
|
|
11
|
+
- quick tests on lines commented with @ts-expect-error
|
|
12
|
+
- remove a // @ts-expect-error comment to see error message as emitted by the tsc compiler
|
|
13
|
+
- fix the variable declaration value to match the expected type, tsc should emit "Unused '@ts-expect-error' directive"
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/*****************
|
|
17
|
+
* Simple tests
|
|
18
|
+
******************/
|
|
19
|
+
|
|
20
|
+
{
|
|
21
|
+
// in unit and integration spec files, use the numeric type definitions
|
|
22
|
+
// to make sure that test data matches expectations, otherwise incorrect
|
|
23
|
+
// test data can lead to false passing or failing tests.
|
|
24
|
+
const valid: NumericTerm = {
|
|
25
|
+
type: 'float',
|
|
26
|
+
id: 'someid',
|
|
27
|
+
name: 'Some Dosage',
|
|
28
|
+
bins: {
|
|
29
|
+
default: {
|
|
30
|
+
type: 'regular-bin',
|
|
31
|
+
bin_size: 1,
|
|
32
|
+
first_bin: {
|
|
33
|
+
startunbounded: true,
|
|
34
|
+
stop: 1
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
less: {
|
|
38
|
+
type: 'custom-bin',
|
|
39
|
+
lst: [{ start: 0, stop: 1 }]
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// @ts-expect-error, wrong term.type
|
|
45
|
+
const A: NumericTerm = { name: 'test', type: 'categorical' }
|
|
46
|
+
// @ts-expect-error, missing other required properties
|
|
47
|
+
const B: NumericTerm = { type: 'integer' }
|
|
48
|
+
const C: NumericTerm = {
|
|
49
|
+
// @ts-expect-error, should be string
|
|
50
|
+
name: 7,
|
|
51
|
+
type: 'integer',
|
|
52
|
+
bins: {
|
|
53
|
+
default: {
|
|
54
|
+
type: 'regular-bin',
|
|
55
|
+
bin_size: 1,
|
|
56
|
+
// tsc can detect type errors for deeply nested property values
|
|
57
|
+
// @ts-expect-error, does not match either StartUnboundedBin | FullyBoundedBin
|
|
58
|
+
first_bin: {
|
|
59
|
+
stop: 1
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
less: {
|
|
63
|
+
type: 'custom-bin',
|
|
64
|
+
// @ts-expect-error, empty lst array
|
|
65
|
+
lst: []
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/*************************
|
|
72
|
+
* !!! How NOT to type !!!
|
|
73
|
+
**************************/
|
|
74
|
+
|
|
75
|
+
// Example of a bad type declaration, where everything is optional.
|
|
76
|
+
// Avoid declaring types with lots of optional properties, unless that's really expected.
|
|
77
|
+
// In the PP codebase, a union of types is more likely to be the correct way to declare
|
|
78
|
+
// a type with mutually exlusive properties based on, for example, term.type or gene variant value dt number.
|
|
79
|
+
type UselessBinType = {
|
|
80
|
+
startunbounded?: boolean
|
|
81
|
+
startinclusive?: boolean
|
|
82
|
+
start?: number
|
|
83
|
+
stop?: number
|
|
84
|
+
stopinclusive?: boolean
|
|
85
|
+
stopunbounded?: boolean
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
{
|
|
89
|
+
// The UselesBinType matches objects with conflicting property values, which does not make sense.
|
|
90
|
+
// We want tsc to emit an error when unallowed, non-sensical combination of properties exist.
|
|
91
|
+
//
|
|
92
|
+
// For example, it does not make sense for a bin to have these combinations of property-values:
|
|
93
|
+
// - startunbounded: true and startinclusive: true // cannot "contain" infinity
|
|
94
|
+
// - startunbounded: true and start: 0 // conflict, start is supposed to be unbounded and yet is assigned a finite value
|
|
95
|
+
// - startunbounded: true and stopunbounded: true // an infinite bin
|
|
96
|
+
//
|
|
97
|
+
// Many other pairing of the property-values below do not make sense.
|
|
98
|
+
// Note that running the tsc on this file does not emit an error, but it should for values that do not make sense.
|
|
99
|
+
// To get tsc to emit errors, we should use the bin types from server/shared/types/terms/numeric.ts,
|
|
100
|
+
// or from the 'better' bin type examples farther down below (which will require more code changes).
|
|
101
|
+
const A: UselessBinType = {
|
|
102
|
+
startunbounded: true,
|
|
103
|
+
startinclusive: true,
|
|
104
|
+
start: 0,
|
|
105
|
+
stop: 1,
|
|
106
|
+
stopinclusive: true,
|
|
107
|
+
stopunbounded: true
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// no error is thrown by an empty object because all properties are optional,
|
|
111
|
+
// but we want tsc to emit an error in this scenario
|
|
112
|
+
const B: UselessBinType = {}
|
|
113
|
+
// @ts-expect-error, not fully useless since an error is thrown because 'extraProp' is not defined as an optional property
|
|
114
|
+
B.extraProp = 'test'
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/********************************************
|
|
118
|
+
* Testing types that are able to catch errors
|
|
119
|
+
*********************************************/
|
|
120
|
+
|
|
121
|
+
// Start unbounded Bin
|
|
122
|
+
{
|
|
123
|
+
// valid example
|
|
124
|
+
const A: StartUnboundedBin = {
|
|
125
|
+
startunbounded: true,
|
|
126
|
+
stop: 1
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// invalid examples
|
|
130
|
+
// @ts-expect-error, conflict between startunbounded and start values
|
|
131
|
+
const B: StartUnboundedBin = { startunbounded: true, start: 0, stop: 1 }
|
|
132
|
+
// @ts-expect-error, missing start value
|
|
133
|
+
const C: StartUnboundedBin = { startunbounded: true }
|
|
134
|
+
// @ts-expect-error, conflict between unbounded flags and assigned finite values for start, stop
|
|
135
|
+
const D: StartUnboundedBin = { startunbounded: true, start: 0, stop: 1, stopunbounded: true }
|
|
136
|
+
// @ts-expect-error, missing properties
|
|
137
|
+
const E: StartUnboundedBin = {}
|
|
138
|
+
// @ts-expect-error, adding a property that was not defined for this type
|
|
139
|
+
E.extraProp = 'test'
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Stop unbounded bin
|
|
143
|
+
{
|
|
144
|
+
// valid example
|
|
145
|
+
const A: StopUnboundedBin = {
|
|
146
|
+
stopunbounded: true,
|
|
147
|
+
start: 0
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// invalid examples
|
|
151
|
+
// @ts-expect-error, conflict between stopunbounded and stop values
|
|
152
|
+
const B: StopUnboundedBin = { stopunbounded: true, start: 0, stop: 1 }
|
|
153
|
+
// @ts-expect-error, missing stop value
|
|
154
|
+
const C: StopUnboundedBin = { stopunbounded: true }
|
|
155
|
+
// @ts-expect-error, conflict between unbounded flags and assigned finite values for start, stop
|
|
156
|
+
const D: StopUnboundedBin = { startunbounded: true, start: 0, stop: 1, stopunbounded: true }
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Fully bounded bin
|
|
160
|
+
{
|
|
161
|
+
// valid example
|
|
162
|
+
const A: FullyBoundedBin = {
|
|
163
|
+
startinclusive: true,
|
|
164
|
+
start: 0,
|
|
165
|
+
stop: 1
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// invalid examples
|
|
169
|
+
// @ts-expect-error, missing start value
|
|
170
|
+
const B: FullyBoundedBin = { stop: 1 }
|
|
171
|
+
// @ts-expect-error, missing stop value
|
|
172
|
+
const C: FullyBoundedBin = { start: 0 }
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/*** test of union type being fed into a subtype-specific "handler" function ***/
|
|
176
|
+
// to be used as a 'generic' argument
|
|
177
|
+
type NumericBin = StartUnboundedBin | StopUnboundedBin | FullyBoundedBin
|
|
178
|
+
|
|
179
|
+
const handlers = {
|
|
180
|
+
startUnbounded(bin: StartUnboundedBin) {
|
|
181
|
+
console.log(bin)
|
|
182
|
+
},
|
|
183
|
+
fullyBounded(bin: FullyBoundedBin) {
|
|
184
|
+
console.log(bin)
|
|
185
|
+
},
|
|
186
|
+
stopUnbounded(bin: StopUnboundedBin) {
|
|
187
|
+
console.log(bin)
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**********************************************************************
|
|
192
|
+
* Test that tsc can infer that a type can be derived from
|
|
193
|
+
* a union of types. This is important for the general approach
|
|
194
|
+
* in the PP codebase to route arguments to specific handler functions.
|
|
195
|
+
***********************************************************************/
|
|
196
|
+
|
|
197
|
+
// these functions routes the bin argument to the correct handler function
|
|
198
|
+
function correctlyTypedProcessBin(bin: NumericBin) {
|
|
199
|
+
if (bin.startunbounded) handlers.startUnbounded(bin as StartUnboundedBin)
|
|
200
|
+
else if (bin.stopunbounded) handlers.stopUnbounded(bin as StopUnboundedBin)
|
|
201
|
+
else handlers.fullyBounded(bin as FullyBoundedBin)
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// not declared as part of the NumericBin type
|
|
205
|
+
type NonNumericBin = { fake: true }
|
|
206
|
+
// even though has an extra property compared to FullyBoundedBin,
|
|
207
|
+
// the tsc compiler would consider this equivalent
|
|
208
|
+
type LikeFullyBoundedBin = {
|
|
209
|
+
start: number
|
|
210
|
+
stop: number
|
|
211
|
+
test: boolean
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function incorrectProcessBin(bin: FullyBoundedBin) {
|
|
215
|
+
// @ts-expect-error, the argument type is not StartUnboundedBin
|
|
216
|
+
if (bin.startunbounded) handlers.startUnbounded(bin as StartUnboundedBin)
|
|
217
|
+
// @ts-expect-error, the argument type is not StopUnboundedBin
|
|
218
|
+
else if (bin.stopunbounded) handlers.stopUnbounded(bin as StopUnboundedBin)
|
|
219
|
+
else {
|
|
220
|
+
// @ts-expect-error, expects StartUnbounded as argument type
|
|
221
|
+
handlers.startUnbounded(bin as FullyBoundedBin)
|
|
222
|
+
// @ts-expect-error, expects StopUnbounded as argument type
|
|
223
|
+
handlers.stopUnbounded(bin as FullyBoundedBin)
|
|
224
|
+
// @ts-expect-error, since this function's argument type (NumericBin) does not include NonNumericBin
|
|
225
|
+
handlers.fullyBounded(bin as NonNumericBinType)
|
|
226
|
+
// !!! SHOULD WORK !!!
|
|
227
|
+
handlers.fullyBounded(bin as LikeFullyBoundedBin)
|
|
228
|
+
// !!! SHOULD WORK !!!
|
|
229
|
+
handlers.fullyBounded(bin as FullyBoundedBin)
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/************************************************************************
|
|
234
|
+
* Examples of better ways to define data structures to proactively avoid
|
|
235
|
+
* any chance of having flag values that may conflict with each other
|
|
236
|
+
*************************************************************************/
|
|
237
|
+
|
|
238
|
+
// Example of better type declarations
|
|
239
|
+
//
|
|
240
|
+
// NOTE: The bin type declarations in server/shared/types/terms/numeric.ts are good for now,
|
|
241
|
+
// the types below are meant to illustrate that there are different ways to write types that work.
|
|
242
|
+
//
|
|
243
|
+
// TODO: Use these better types, which will require code changes
|
|
244
|
+
//
|
|
245
|
+
type BetterStartUnboundedBin = {
|
|
246
|
+
stop: number
|
|
247
|
+
// by not using a flag, the 'inclusive' property completely avoids unintentionally having
|
|
248
|
+
// `startinclusive: true && stopinclusive: true` at the same time
|
|
249
|
+
inclusive: 'stop'
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// NOTE: This approach also lessens the number of attributes/properties to define.
|
|
253
|
+
// A problem with flags is it's very easy to have too many of them, and each one has to be defined,
|
|
254
|
+
// and if they are mutually exclusive, most of the time that is not readily apparent.
|
|
255
|
+
type BetterStopUnboundedBin = {
|
|
256
|
+
start: number
|
|
257
|
+
inclusive: 'start'
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
type BetterFullyBoundedBin = {
|
|
261
|
+
start: number
|
|
262
|
+
stop: number
|
|
263
|
+
// for numeric bins that are NOT standalone, using `inclusive: 'both'` will lead to conflict,
|
|
264
|
+
// since adjoining bins can both contain the same boundary value
|
|
265
|
+
inclusive: 'start' | 'stop'
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
type StandaloneBin = {
|
|
269
|
+
start: number
|
|
270
|
+
stop: number
|
|
271
|
+
// for standalone bins, the option to include both start and stop values will not lead to conflict
|
|
272
|
+
inclusive: 'start' | 'stop' | 'both'
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
type BetterNumericBin = BetterStartUnboundedBin | BetterStopUnboundedBin | BetterFullyBoundedBin | StandaloneBin
|
package/src/vocab.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { TermWrapper } from './terms/tw.ts'
|
|
2
|
+
import { Term } from './terms/term.ts'
|
|
3
|
+
import { Filter } from './filter.ts'
|
|
4
|
+
import { UseCase } from './termsetting.ts'
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
--------EXPORTED--------
|
|
8
|
+
VocabApi
|
|
9
|
+
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
//type QLst = [Partial<{ nextReuseId?: string }>, ...Q[]]
|
|
13
|
+
|
|
14
|
+
export type VocabApi = {
|
|
15
|
+
termdbConfig: any
|
|
16
|
+
//Methods
|
|
17
|
+
cacheTermQ: (term: Term, q: any) => any
|
|
18
|
+
findTerm: (f: string, activeCohort: number, usecase: UseCase, x: string) => { lst: Term[] }
|
|
19
|
+
getCategories: (term: Term, filer: Filter, body?: any) => any
|
|
20
|
+
getCustomTermQLst: (f: Term) => any
|
|
21
|
+
getPercentile: (term_id: string | number, percentile_lst: number[], filter?: Filter) => any
|
|
22
|
+
getterm: (f: any) => Term
|
|
23
|
+
getTerms: (f: any) => any
|
|
24
|
+
getTermdbConfig: () => any
|
|
25
|
+
getViolinPlotData: (args: any, _body?: any) => any
|
|
26
|
+
getAnnotatedSampleData: (args: any) => any
|
|
27
|
+
getDefaultBins: (args: any) => any
|
|
28
|
+
setTermBins(tw: TermWrapper): any
|
|
29
|
+
getTwMinCopy(tw: TermWrapper): any
|
|
30
|
+
uncacheTermQ: (term: Term, q: any) => any
|
|
31
|
+
hasVerifiedToken: () => boolean
|
|
32
|
+
tokenVerificationMessage: string
|
|
33
|
+
tokenVerificationPayload?: {
|
|
34
|
+
error?: string
|
|
35
|
+
linkKey?: string
|
|
36
|
+
}
|
|
37
|
+
}
|