@sjcrh/proteinpaint-types 2.84.0 → 2.85.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.
Files changed (135) hide show
  1. package/dist/routes.ts +28847 -0
  2. package/package.json +17 -13
  3. package/src/Mclass.js +0 -0
  4. package/src/checkers/routes.js +167 -0
  5. package/src/dataset.js +0 -0
  6. package/src/fileOrUrl.js +0 -0
  7. package/src/filter.js +0 -0
  8. package/src/genome.js +0 -0
  9. package/src/index.js +66 -0
  10. package/src/routes/brainImaging.js +11 -0
  11. package/src/routes/brainImagingSamples.js +11 -0
  12. package/src/routes/burden.js +44 -0
  13. package/src/routes/dataset.js +12 -0
  14. package/src/routes/dsdata.js +12 -0
  15. package/src/routes/dzimages.js +12 -0
  16. package/src/routes/errorResponse.js +0 -0
  17. package/src/routes/filter.gdc.js +0 -0
  18. package/src/routes/gdc.maf.js +17 -0
  19. package/src/routes/gdc.mafBuild.js +12 -0
  20. package/src/routes/gdc.topMutatedGenes.js +12 -0
  21. package/src/routes/genelookup.js +12 -0
  22. package/src/routes/genesetEnrichment.js +12 -0
  23. package/src/routes/genesetOverrepresentation.js +12 -0
  24. package/src/routes/healthcheck.js +23 -0
  25. package/src/routes/hicdata.js +12 -0
  26. package/src/routes/hicgenome.js +29 -0
  27. package/src/routes/hicstat.js +12 -0
  28. package/src/routes/isoformlst.js +12 -0
  29. package/src/routes/ntseq.js +12 -0
  30. package/src/routes/pdomain.js +12 -0
  31. package/src/routes/routeApi.js +0 -0
  32. package/src/routes/samplewsimages.js +12 -0
  33. package/src/routes/snp.js +11 -0
  34. package/src/routes/termdb.DE.js +13 -0
  35. package/src/routes/termdb.boxplot.js +12 -0
  36. package/src/routes/termdb.categories.js +48 -0
  37. package/src/routes/termdb.cluster.js +12 -0
  38. package/src/routes/termdb.cohort.summary.js +12 -0
  39. package/src/routes/termdb.cohorts.js +12 -0
  40. package/src/routes/termdb.descrstats.js +48 -0
  41. package/src/routes/termdb.numericcategories.js +12 -0
  42. package/src/routes/termdb.percentile.js +49 -0
  43. package/src/routes/termdb.rootterm.js +27 -0
  44. package/src/routes/termdb.sampleImages.js +12 -0
  45. package/src/routes/termdb.singleSampleMutation.js +12 -0
  46. package/src/routes/termdb.singlecellDEgenes.js +12 -0
  47. package/src/routes/termdb.singlecellData.js +12 -0
  48. package/src/routes/termdb.singlecellSamples.js +12 -0
  49. package/src/routes/termdb.termchildren.js +28 -0
  50. package/src/routes/termdb.termsbyids.js +12 -0
  51. package/src/routes/termdb.topTermsByType.js +12 -0
  52. package/src/routes/termdb.topVariablyExpressedGenes.js +12 -0
  53. package/src/routes/termdb.violin.js +49 -0
  54. package/src/routes/tileserver.js +12 -0
  55. package/src/routes/wsimages.js +12 -0
  56. package/src/terms/categorical.js +0 -0
  57. package/src/terms/condition.js +0 -0
  58. package/src/terms/geneExpression.js +0 -0
  59. package/src/terms/geneVariant.js +0 -0
  60. package/src/terms/metaboliteIntensity.js +0 -0
  61. package/src/terms/numeric.js +0 -0
  62. package/src/terms/q.js +0 -0
  63. package/src/terms/samplelst.js +0 -0
  64. package/src/terms/singleCellCellType.js +0 -0
  65. package/src/terms/singleCellGeneExpression.js +0 -0
  66. package/src/terms/snp.js +0 -0
  67. package/src/terms/snps.js +0 -0
  68. package/src/terms/term.js +0 -0
  69. package/src/terms/tw.js +0 -0
  70. package/src/terms/updated-types.js +0 -0
  71. package/src/termsetting.js +0 -0
  72. package/src/test/numeric.type.spec.js +117 -0
  73. package/src/vocab.js +0 -0
  74. package/src/Mclass.ts +0 -8
  75. package/src/dataset.ts +0 -1575
  76. package/src/docs.json +0 -16417
  77. package/src/fileOrUrl.ts +0 -15
  78. package/src/filter.ts +0 -125
  79. package/src/genome.ts +0 -123
  80. package/src/index.ts +0 -57
  81. package/src/routes/brainImaging.ts +0 -42
  82. package/src/routes/burden.ts +0 -69
  83. package/src/routes/dzimages.ts +0 -9
  84. package/src/routes/errorResponse.ts +0 -6
  85. package/src/routes/filter.gdc.ts +0 -15
  86. package/src/routes/gdc.maf.ts +0 -41
  87. package/src/routes/gdc.mafBuild.ts +0 -13
  88. package/src/routes/gdc.topMutatedGenes.ts +0 -25
  89. package/src/routes/genelookup.ts +0 -10
  90. package/src/routes/genesetEnrichment.ts +0 -46
  91. package/src/routes/genesetOverrepresentation.ts +0 -36
  92. package/src/routes/healthcheck.ts +0 -57
  93. package/src/routes/hicdata.ts +0 -37
  94. package/src/routes/hicgenome.ts +0 -22
  95. package/src/routes/hicstat.ts +0 -45
  96. package/src/routes/sampledzimages.ts +0 -1
  97. package/src/routes/samplewsimages.ts +0 -15
  98. package/src/routes/termdb.DE.ts +0 -44
  99. package/src/routes/termdb.boxplot.ts +0 -49
  100. package/src/routes/termdb.categories.ts +0 -26
  101. package/src/routes/termdb.cluster.ts +0 -86
  102. package/src/routes/termdb.getSampleImages.ts +0 -14
  103. package/src/routes/termdb.getTopTermsByType.ts +0 -21
  104. package/src/routes/termdb.getdescrstats.ts +0 -31
  105. package/src/routes/termdb.getnumericcategories.ts +0 -21
  106. package/src/routes/termdb.getpercentile.ts +0 -17
  107. package/src/routes/termdb.getrootterm.ts +0 -22
  108. package/src/routes/termdb.gettermchildren.ts +0 -21
  109. package/src/routes/termdb.singleSampleMutation.ts +0 -18
  110. package/src/routes/termdb.singlecellDEgenes.ts +0 -30
  111. package/src/routes/termdb.singlecellData.ts +0 -58
  112. package/src/routes/termdb.singlecellSamples.ts +0 -35
  113. package/src/routes/termdb.termsbyids.ts +0 -15
  114. package/src/routes/termdb.topVariablyExpressedGenes.ts +0 -45
  115. package/src/routes/termdb.violin.ts +0 -74
  116. package/src/routes/wsimages.ts +0 -12
  117. package/src/terms/categorical.ts +0 -106
  118. package/src/terms/condition.ts +0 -55
  119. package/src/terms/geneExpression.ts +0 -32
  120. package/src/terms/geneVariant.ts +0 -51
  121. package/src/terms/metaboliteIntensity.ts +0 -31
  122. package/src/terms/numeric.ts +0 -253
  123. package/src/terms/q.ts +0 -38
  124. package/src/terms/samplelst.ts +0 -41
  125. package/src/terms/singleCellCellType.ts +0 -22
  126. package/src/terms/singleCellGeneExpression.ts +0 -28
  127. package/src/terms/snp.ts +0 -28
  128. package/src/terms/snps.ts +0 -110
  129. package/src/terms/term.ts +0 -184
  130. package/src/terms/tw.ts +0 -38
  131. package/src/terms/updated-types.ts +0 -9
  132. package/src/termsetting.ts +0 -197
  133. package/src/test/numeric.type.spec.ts +0 -275
  134. package/src/typedoc.js +0 -30
  135. package/src/vocab.ts +0 -37
package/src/terms/tw.ts DELETED
@@ -1,38 +0,0 @@
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
- }
@@ -1,9 +0,0 @@
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
@@ -1,197 +0,0 @@
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
- }
@@ -1,275 +0,0 @@
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/typedoc.js DELETED
@@ -1,30 +0,0 @@
1
- const types = require('./index')
2
- const test = require('../doc').test
3
-
4
- module.exports = {
5
- entryPoints: ['./index.ts'],
6
- out: '../../../public/docs',
7
- groupOrder: ['Termdb', 'Termdb - TW', 'TW', '*'],
8
- categoryOrder: ['Termdb', 'Termdb - TW', 'TW', '*'],
9
- categorizeByGroup: true,
10
- plugin: ['typedoc-plugin-replace-text'],
11
- replaceText: {
12
- inCodeCommentText: true,
13
- inCodeCommentTags: true,
14
- replacements: [
15
- {
16
- pattern: 'Type alias',
17
- flags: 'gi',
18
- replace: 'Type'
19
- },
20
- {
21
- pattern: /^test\:.*\:$/,
22
- flags: 'gm',
23
- replace: match => {
24
- const name = match.slice(5, -1)
25
- return 'Test:\n```ts\n' + test[name] + '\n```'
26
- }
27
- }
28
- ]
29
- }
30
- }
package/src/vocab.ts DELETED
@@ -1,37 +0,0 @@
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
- }