@jbrowse/core 2.4.2 → 2.6.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 (223) hide show
  1. package/BaseFeatureWidget/BaseFeatureDetail/ArrayValue.d.ts +16 -0
  2. package/BaseFeatureWidget/BaseFeatureDetail/ArrayValue.js +45 -0
  3. package/BaseFeatureWidget/BaseFeatureDetail/Attributes.d.ts +15 -0
  4. package/BaseFeatureWidget/BaseFeatureDetail/Attributes.js +52 -0
  5. package/BaseFeatureWidget/BaseFeatureDetail/BasicValue.d.ts +13 -0
  6. package/BaseFeatureWidget/BaseFeatureDetail/BasicValue.js +27 -0
  7. package/BaseFeatureWidget/BaseFeatureDetail/DataGridDetails.d.ts +15 -0
  8. package/BaseFeatureWidget/BaseFeatureDetail/DataGridDetails.js +98 -0
  9. package/BaseFeatureWidget/BaseFeatureDetail/FieldName.d.ts +16 -0
  10. package/BaseFeatureWidget/BaseFeatureDetail/FieldName.js +32 -0
  11. package/BaseFeatureWidget/BaseFeatureDetail/SimpleField.d.ts +17 -0
  12. package/BaseFeatureWidget/BaseFeatureDetail/SimpleField.js +23 -0
  13. package/BaseFeatureWidget/BaseFeatureDetail/UriField.d.ts +18 -0
  14. package/BaseFeatureWidget/BaseFeatureDetail/UriField.js +31 -0
  15. package/BaseFeatureWidget/BaseFeatureDetail/UriLink.d.ts +7 -0
  16. package/BaseFeatureWidget/BaseFeatureDetail/UriLink.js +13 -0
  17. package/BaseFeatureWidget/BaseFeatureDetail/index.d.ts +33 -0
  18. package/BaseFeatureWidget/BaseFeatureDetail/index.js +170 -0
  19. package/BaseFeatureWidget/BaseFeatureDetail/util.d.ts +5 -0
  20. package/BaseFeatureWidget/BaseFeatureDetail/util.js +46 -0
  21. package/BaseFeatureWidget/SequenceFeatureDetails/CDNASequence.d.ts +13 -0
  22. package/BaseFeatureWidget/SequenceFeatureDetails/CDNASequence.js +25 -0
  23. package/BaseFeatureWidget/SequenceFeatureDetails/CDSSequence.d.ts +6 -0
  24. package/BaseFeatureWidget/SequenceFeatureDetails/CDSSequence.js +12 -0
  25. package/BaseFeatureWidget/SequenceFeatureDetails/GenomicSequence.d.ts +6 -0
  26. package/BaseFeatureWidget/SequenceFeatureDetails/GenomicSequence.js +14 -0
  27. package/BaseFeatureWidget/SequenceFeatureDetails/ProteinSequence.d.ts +9 -0
  28. package/BaseFeatureWidget/SequenceFeatureDetails/ProteinSequence.js +18 -0
  29. package/BaseFeatureWidget/SequenceFeatureDetails/SequenceFeatureDetails.d.ts +3 -0
  30. package/BaseFeatureWidget/SequenceFeatureDetails/SequenceFeatureDetails.js +143 -0
  31. package/BaseFeatureWidget/{SequenceFeatureSettingsDialog.d.ts → SequenceFeatureDetails/SequenceFeatureSettingsDialog.d.ts} +2 -2
  32. package/BaseFeatureWidget/{SequenceFeatureSettingsDialog.js → SequenceFeatureDetails/SequenceFeatureSettingsDialog.js} +1 -1
  33. package/BaseFeatureWidget/{SequenceHelpDialog.d.ts → SequenceFeatureDetails/SequenceHelpDialog.d.ts} +2 -2
  34. package/BaseFeatureWidget/{SequenceHelpDialog.js → SequenceFeatureDetails/SequenceHelpDialog.js} +6 -9
  35. package/BaseFeatureWidget/{SequencePanel.d.ts → SequenceFeatureDetails/SequencePanel.d.ts} +1 -1
  36. package/BaseFeatureWidget/{SequencePanel.js → SequenceFeatureDetails/SequencePanel.js} +10 -8
  37. package/BaseFeatureWidget/SequenceFeatureDetails/hooks.d.ts +10 -0
  38. package/BaseFeatureWidget/SequenceFeatureDetails/hooks.js +73 -0
  39. package/BaseFeatureWidget/SequenceFeatureDetails/index.d.ts +3 -0
  40. package/BaseFeatureWidget/SequenceFeatureDetails/index.js +68 -0
  41. package/BaseFeatureWidget/{test_data → SequenceFeatureDetails/test_data}/DLGAP3.d.ts +17 -17
  42. package/BaseFeatureWidget/{test_data → SequenceFeatureDetails/test_data}/NCDN.d.ts +16 -16
  43. package/BaseFeatureWidget/SequenceFeatureDetails/util.d.ts +6 -0
  44. package/BaseFeatureWidget/SequenceFeatureDetails/util.js +11 -0
  45. package/BaseFeatureWidget/index.d.ts +4 -1
  46. package/BaseFeatureWidget/index.js +29 -17
  47. package/BaseFeatureWidget/types.d.ts +2 -2
  48. package/BaseFeatureWidget/util.js +15 -5
  49. package/Plugin.d.ts +1 -1
  50. package/PluginLoader.js +17 -0
  51. package/PluginManager.d.ts +8 -5
  52. package/PluginManager.js +3 -0
  53. package/README.md +0 -2
  54. package/ReExports/list.js +1 -0
  55. package/ReExports/modules.d.ts +8 -5
  56. package/ReExports/modules.js +7 -7
  57. package/TextSearch/TextSearchManager.d.ts +2 -9
  58. package/assemblyManager/assembly.d.ts +91 -8
  59. package/assemblyManager/assembly.js +92 -8
  60. package/assemblyManager/assemblyConfigSchema.d.ts +52 -1
  61. package/assemblyManager/assemblyConfigSchema.js +1 -0
  62. package/assemblyManager/assemblyManager.d.ts +227 -58
  63. package/assemblyManager/assemblyManager.js +72 -13
  64. package/assemblyManager/index.d.ts +1 -0
  65. package/configuration/configurationSchema.d.ts +14 -16
  66. package/configuration/configurationSchema.js +4 -2
  67. package/configuration/index.d.ts +1 -1
  68. package/configuration/types.d.ts +15 -0
  69. package/configuration/types.js +2 -0
  70. package/configuration/util.d.ts +5 -3
  71. package/configuration/util.js +18 -18
  72. package/data_adapters/BaseAdapter/BaseAdapter.d.ts +23 -0
  73. package/data_adapters/BaseAdapter/BaseAdapter.js +37 -0
  74. package/data_adapters/BaseAdapter/BaseFeatureDataAdapter.d.ts +128 -0
  75. package/data_adapters/{BaseAdapter.js → BaseAdapter/BaseFeatureDataAdapter.js} +58 -88
  76. package/data_adapters/BaseAdapter/BaseOptions.d.ts +16 -0
  77. package/data_adapters/BaseAdapter/BaseOptions.js +2 -0
  78. package/data_adapters/BaseAdapter/BaseRefNameAliasAdapter.d.ts +9 -0
  79. package/data_adapters/BaseAdapter/BaseRefNameAliasAdapter.js +2 -0
  80. package/data_adapters/BaseAdapter/BaseSequenceAdapter.d.ts +13 -0
  81. package/data_adapters/BaseAdapter/BaseSequenceAdapter.js +10 -0
  82. package/data_adapters/BaseAdapter/BaseTextSearchAdapter.d.ts +6 -0
  83. package/data_adapters/BaseAdapter/BaseTextSearchAdapter.js +2 -0
  84. package/data_adapters/BaseAdapter/RegionsAdapter.d.ts +6 -0
  85. package/data_adapters/BaseAdapter/RegionsAdapter.js +2 -0
  86. package/data_adapters/BaseAdapter/index.d.ts +15 -0
  87. package/data_adapters/BaseAdapter/index.js +25 -0
  88. package/data_adapters/BaseAdapter/types.d.ts +21 -0
  89. package/data_adapters/BaseAdapter/types.js +2 -0
  90. package/data_adapters/BaseAdapter/util.d.ts +12 -0
  91. package/data_adapters/BaseAdapter/util.js +23 -0
  92. package/data_adapters/CytobandAdapter/configSchema.d.ts +11 -1
  93. package/package.json +4 -4
  94. package/pluggableElementTypes/AdapterType.d.ts +1 -1
  95. package/pluggableElementTypes/ConnectionType.d.ts +1 -1
  96. package/pluggableElementTypes/DisplayType.d.ts +1 -1
  97. package/pluggableElementTypes/InternetAccountType.d.ts +1 -1
  98. package/pluggableElementTypes/RpcMethodType.d.ts +9 -7
  99. package/pluggableElementTypes/RpcMethodType.js +9 -7
  100. package/pluggableElementTypes/TextSearchAdapterType.d.ts +1 -1
  101. package/pluggableElementTypes/models/BaseConnectionModelFactory.d.ts +18 -0
  102. package/pluggableElementTypes/models/BaseConnectionModelFactory.js +9 -0
  103. package/pluggableElementTypes/models/BaseDisplayModel.d.ts +10 -1
  104. package/pluggableElementTypes/models/BaseDisplayModel.js +9 -1
  105. package/pluggableElementTypes/models/BaseTrackModel.d.ts +2 -1
  106. package/pluggableElementTypes/models/BaseTrackModel.js +4 -2
  107. package/pluggableElementTypes/models/BaseViewModel.d.ts +46 -2
  108. package/pluggableElementTypes/models/BaseViewModel.js +6 -0
  109. package/pluggableElementTypes/models/InternetAccountModel.d.ts +36 -2
  110. package/pluggableElementTypes/models/InternetAccountModel.js +33 -21
  111. package/pluggableElementTypes/models/baseConnectionConfig.d.ts +22 -2
  112. package/pluggableElementTypes/models/baseConnectionConfig.js +2 -1
  113. package/pluggableElementTypes/models/baseInternetAccountConfig.d.ts +42 -1
  114. package/pluggableElementTypes/models/baseInternetAccountConfig.js +1 -1
  115. package/pluggableElementTypes/models/baseTrackConfig.d.ts +120 -3
  116. package/pluggableElementTypes/models/baseTrackConfig.js +7 -5
  117. package/pluggableElementTypes/models/index.d.ts +1 -1
  118. package/pluggableElementTypes/renderers/BoxRendererType.js +1 -2
  119. package/pluggableElementTypes/renderers/CircularChordRendererType.d.ts +2 -2
  120. package/pluggableElementTypes/renderers/FeatureRendererType.d.ts +4 -2
  121. package/pluggableElementTypes/renderers/FeatureRendererType.js +4 -6
  122. package/pluggableElementTypes/renderers/RendererType.d.ts +1 -1
  123. package/pluggableElementTypes/renderers/RpcRenderedSvgGroup.d.ts +2 -2
  124. package/pluggableElementTypes/renderers/ServerSideRenderedContent.d.ts +1 -1
  125. package/pluggableElementTypes/renderers/ServerSideRendererType.d.ts +1 -1
  126. package/rpc/BaseRpcDriver.js +1 -7
  127. package/rpc/RpcManager.d.ts +8 -1
  128. package/rpc/RpcManager.js +1 -1
  129. package/rpc/baseRpcConfig.d.ts +10 -1
  130. package/rpc/configSchema.d.ts +14 -1
  131. package/rpc/coreRpcMethods.d.ts +1 -1
  132. package/rpc/coreRpcMethods.js +3 -3
  133. package/rpc/mainThreadRpcConfig.d.ts +7 -1
  134. package/rpc/methods/{CoreEstimateRegionStats.d.ts → CoreGetFeatureDensityStats.d.ts} +2 -2
  135. package/rpc/methods/{CoreEstimateRegionStats.js → CoreGetFeatureDensityStats.js} +4 -4
  136. package/rpc/methods/CoreGetFeatureDetails.js +5 -5
  137. package/rpc/webWorkerRpcConfig.d.ts +7 -1
  138. package/tsconfig.build.tsbuildinfo +1 -1
  139. package/ui/AppLogo.d.ts +2 -2
  140. package/ui/AssemblySelector.d.ts +2 -2
  141. package/ui/AssemblySelector.js +1 -1
  142. package/ui/CascadingMenu.d.ts +2 -2
  143. package/ui/CascadingMenuButton.d.ts +8 -0
  144. package/ui/CascadingMenuButton.js +20 -0
  145. package/ui/ColorPicker.d.ts +4 -4
  146. package/ui/Dialog.d.ts +5 -5
  147. package/ui/Dialog.js +19 -7
  148. package/ui/DropDownMenu.d.ts +2 -2
  149. package/ui/EditableTypography.js +1 -1
  150. package/ui/ErrorMessage.d.ts +2 -2
  151. package/ui/ErrorMessage.js +6 -2
  152. package/ui/FactoryResetDialog.d.ts +2 -2
  153. package/ui/FatalErrorDialog.d.ts +6 -7
  154. package/ui/FatalErrorDialog.js +7 -7
  155. package/ui/FileSelector/FileSelector.d.ts +2 -2
  156. package/ui/FileSelector/FileSelector.js +3 -2
  157. package/ui/FileSelector/LocalFileChooser.d.ts +2 -2
  158. package/ui/FileSelector/UrlChooser.d.ts +3 -4
  159. package/ui/FileSelector/UrlChooser.js +8 -10
  160. package/ui/Icons.d.ts +10 -10
  161. package/ui/LoadingEllipses.d.ts +2 -2
  162. package/ui/Logo.d.ts +3 -3
  163. package/ui/Menu.d.ts +2 -2
  164. package/ui/PrerenderedCanvas.d.ts +2 -2
  165. package/ui/ResizeBar.d.ts +1 -1
  166. package/ui/ResizeBar.js +1 -1
  167. package/ui/ResizeHandle.d.ts +2 -2
  168. package/ui/ReturnToImportFormDialog.d.ts +2 -2
  169. package/ui/SanitizedHTML.d.ts +2 -2
  170. package/ui/SanitizedHTML.js +6 -0
  171. package/ui/Snackbar.d.ts +7 -9
  172. package/ui/Snackbar.js +12 -17
  173. package/ui/SnackbarModel.d.ts +9 -3
  174. package/ui/SnackbarModel.js +3 -3
  175. package/ui/Tooltip.d.ts +2 -2
  176. package/ui/index.d.ts +0 -1
  177. package/ui/index.js +1 -3
  178. package/ui/react-colorful.d.ts +1 -1
  179. package/ui/theme.js +3 -18
  180. package/util/Base1DUtils.js +2 -1
  181. package/util/QuickLRU.d.ts +1 -1
  182. package/util/blockTypes.js +1 -1
  183. package/util/formatFastaStrings.js +1 -1
  184. package/util/index.d.ts +18 -2
  185. package/util/index.js +77 -11
  186. package/util/io/index.js +1 -1
  187. package/util/layouts/PrecomputedMultiLayout.d.ts +1 -1
  188. package/util/mst-reflection.js +1 -2
  189. package/util/offscreenCanvasUtils.d.ts +2 -2
  190. package/util/stats.d.ts +5 -5
  191. package/util/types/index.d.ts +9 -3
  192. package/util/types/index.js +6 -2
  193. package/util/types/mst.d.ts +12 -9
  194. package/util/types/util.d.ts +0 -3
  195. package/BaseFeatureWidget/BaseFeatureDetail.d.ts +0 -62
  196. package/BaseFeatureWidget/BaseFeatureDetail.js +0 -378
  197. package/BaseFeatureWidget/SequenceBox.d.ts +0 -29
  198. package/BaseFeatureWidget/SequenceBox.js +0 -63
  199. package/BaseFeatureWidget/SequenceFeatureDetails.d.ts +0 -3
  200. package/BaseFeatureWidget/SequenceFeatureDetails.js +0 -230
  201. package/data_adapters/BaseAdapter.d.ts +0 -138
  202. package/ui/AboutDialog.d.ts +0 -12
  203. package/ui/AboutDialog.js +0 -125
  204. package/ui/App.d.ts +0 -18
  205. package/ui/App.js +0 -114
  206. package/ui/AppToolbar.d.ts +0 -19
  207. package/ui/AppToolbar.js +0 -56
  208. package/ui/Drawer.d.ts +0 -8
  209. package/ui/Drawer.js +0 -34
  210. package/ui/DrawerWidget.d.ts +0 -6
  211. package/ui/DrawerWidget.js +0 -130
  212. package/ui/ViewContainer.d.ts +0 -9
  213. package/ui/ViewContainer.js +0 -76
  214. package/ui/ViewContainerTitle.d.ts +0 -6
  215. package/ui/ViewContainerTitle.js +0 -42
  216. package/ui/ViewLauncher.d.ts +0 -18
  217. package/ui/ViewLauncher.js +0 -50
  218. package/ui/ViewMenu.d.ts +0 -9
  219. package/ui/ViewMenu.js +0 -69
  220. package/ui/ViewPanel.d.ts +0 -19
  221. package/ui/ViewPanel.js +0 -49
  222. /package/BaseFeatureWidget/{test_data → SequenceFeatureDetails/test_data}/DLGAP3.js +0 -0
  223. /package/BaseFeatureWidget/{test_data → SequenceFeatureDetails/test_data}/NCDN.js +0 -0
@@ -1,31 +1,29 @@
1
- import { Instance, IAnyType } from 'mobx-state-tree';
2
- import ConfigSlot, { ConfigSlotDefinition } from './configurationSlot';
1
+ import { IAnyType } from 'mobx-state-tree';
2
+ import { ConfigSlotDefinition } from './configurationSlot';
3
+ import { AnyConfigurationSchemaType } from './types';
4
+ export type { AnyConfigurationSchemaType, AnyConfigurationModel, AnyConfigurationSlot, AnyConfigurationSlotType, } from './types';
3
5
  export interface ConfigurationSchemaDefinition {
4
6
  [n: string]: ConfigSlotDefinition | ConfigurationSchemaDefinition | string | number | IAnyType;
5
7
  }
6
- interface ConfigurationSchemaOptions {
8
+ export interface ConfigurationSchemaOptions<BASE_SCHEMA extends AnyConfigurationSchemaType | undefined, EXPLICIT_IDENTIFIER extends string | undefined> {
7
9
  explicitlyTyped?: boolean;
8
- explicitIdentifier?: string;
10
+ explicitIdentifier?: EXPLICIT_IDENTIFIER;
9
11
  implicitIdentifier?: string | boolean;
10
- baseConfiguration?: AnyConfigurationSchemaType;
12
+ baseConfiguration?: BASE_SCHEMA;
11
13
  actions?: (self: unknown) => any;
12
14
  views?: (self: unknown) => any;
13
15
  extend?: (self: unknown) => any;
14
16
  preProcessSnapshot?: (snapshot: {}) => {};
15
17
  }
16
- declare function makeConfigurationSchemaModel<DEFINITION extends ConfigurationSchemaDefinition, OPTIONS extends ConfigurationSchemaOptions>(modelName: string, schemaDefinition: DEFINITION, options: OPTIONS): import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IModelType<Record<string, any>, {
18
+ declare function makeConfigurationSchemaModel<DEFINITION extends ConfigurationSchemaDefinition, OPTIONS extends ConfigurationSchemaOptions<any, any>>(modelName: string, schemaDefinition: DEFINITION, options: OPTIONS): import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IModelType<Record<string, any>, {
17
19
  setSubschema(slotName: string, data: unknown): any;
18
20
  }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>, [undefined]>;
19
- export interface AnyConfigurationSchemaType extends ReturnType<typeof makeConfigurationSchemaModel> {
21
+ export interface ConfigurationSchemaType<DEFINITION extends ConfigurationSchemaDefinition, OPTIONS extends ConfigurationSchemaOptions<any, any>> extends ReturnType<typeof makeConfigurationSchemaModel<DEFINITION, OPTIONS>> {
20
22
  isJBrowseConfigurationSchema: boolean;
21
- jbrowseSchemaDefinition: ConfigurationSchemaDefinition;
22
- jbrowseSchemaOptions: ConfigurationSchemaOptions;
23
+ jbrowseSchemaDefinition: DEFINITION;
24
+ jbrowseSchemaOptions: OPTIONS;
23
25
  type: string;
26
+ [key: string]: unknown;
24
27
  }
25
- export type AnyConfigurationModel = Instance<AnyConfigurationSchemaType>;
26
- export type AnyConfigurationSlotType = ReturnType<typeof ConfigSlot>;
27
- export type AnyConfigurationSlot = Instance<AnyConfigurationSlotType>;
28
- export type ConfigurationModel<SCHEMA extends AnyConfigurationSchemaType> = Instance<SCHEMA>;
29
- export declare function ConfigurationSchema<DEFINITION extends ConfigurationSchemaDefinition, OPTIONS extends ConfigurationSchemaOptions>(modelName: string, inputSchemaDefinition: DEFINITION, inputOptions?: OPTIONS): AnyConfigurationSchemaType;
30
- export declare function ConfigurationReference(schemaType: IAnyType): import("mobx-state-tree").ITypeUnion<any, any, any>;
31
- export {};
28
+ export declare function ConfigurationSchema<DEFINITION extends ConfigurationSchemaDefinition, OPTIONS extends ConfigurationSchemaOptions<BASE_SCHEMA, EXPLICIT_IDENTIFIER>, BASE_SCHEMA extends AnyConfigurationSchemaType | undefined = undefined, EXPLICIT_IDENTIFIER extends string | undefined = undefined>(modelName: string, inputSchemaDefinition: DEFINITION, inputOptions?: ConfigurationSchemaOptions<BASE_SCHEMA, EXPLICIT_IDENTIFIER>): ConfigurationSchemaType<DEFINITION, OPTIONS>;
29
+ export declare function ConfigurationReference<SCHEMATYPE extends AnyConfigurationSchemaType>(schemaType: SCHEMATYPE): SCHEMATYPE;
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ConfigurationReference = exports.ConfigurationSchema = void 0;
7
+ /* eslint-disable @typescript-eslint/no-explicit-any */
7
8
  const mobx_state_tree_1 = require("mobx-state-tree");
8
9
  const mst_1 = require("../util/types/mst");
9
10
  const configurationSlot_1 = __importDefault(require("./configurationSlot"));
@@ -41,7 +42,6 @@ function preprocessConfigurationSchemaArguments(modelName, inputSchemaDefinition
41
42
  }
42
43
  function makeConfigurationSchemaModel(modelName, schemaDefinition, options) {
43
44
  // now assemble the MST model of the configuration schema
44
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
45
45
  const modelDefinition = {};
46
46
  let identifier;
47
47
  if (options.explicitlyTyped) {
@@ -70,7 +70,6 @@ function makeConfigurationSchemaModel(modelName, schemaDefinition, options) {
70
70
  identifier = 'id';
71
71
  }
72
72
  }
73
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
74
73
  const volatileConstants = {
75
74
  isJBrowseConfigurationSchema: true,
76
75
  jbrowseSchema: {
@@ -181,6 +180,9 @@ function ConfigurationSchema(modelName, inputSchemaDefinition, inputOptions) {
181
180
  }
182
181
  exports.ConfigurationSchema = ConfigurationSchema;
183
182
  function ConfigurationReference(schemaType) {
183
+ // we cast this to SCHEMATYPE, because the reference *should* behave just
184
+ // like the object it points to. It won't be undefined (this is a
185
+ // `reference`, not a `safeReference`)
184
186
  return mobx_state_tree_1.types.union(mobx_state_tree_1.types.reference(schemaType), schemaType);
185
187
  }
186
188
  exports.ConfigurationReference = ConfigurationReference;
@@ -1,3 +1,3 @@
1
1
  export { ConfigurationSchema, ConfigurationReference, } from './configurationSchema';
2
- export type { AnyConfigurationModel, AnyConfigurationSchemaType, } from './configurationSchema';
2
+ export type { AnyConfigurationSchemaType, AnyConfigurationModel, AnyConfigurationSlot, AnyConfigurationSlotType, AnyConfiguration, } from './types';
3
3
  export * from './util';
@@ -0,0 +1,15 @@
1
+ import type { IStateTreeNode, Instance, SnapshotOut } from 'mobx-state-tree';
2
+ import type { ConfigurationSchemaType, ConfigurationSchemaOptions } from './configurationSchema';
3
+ import type ConfigSlot from './configurationSlot';
4
+ export type GetOptions<SCHEMA> = SCHEMA extends ConfigurationSchemaType<any, infer OPTIONS> ? OPTIONS : never;
5
+ export type GetBase<SCHEMA> = SCHEMA extends undefined ? never : GetOptions<SCHEMA> extends ConfigurationSchemaOptions<undefined, any> ? undefined : GetOptions<SCHEMA> extends ConfigurationSchemaOptions<infer BASE extends AnyConfigurationSchemaType, any> ? BASE : never;
6
+ export type GetExplicitIdentifier<SCHEMA> = GetOptions<SCHEMA> extends ConfigurationSchemaOptions<any, infer EXPLICIT_IDENTIFIER extends string> ? EXPLICIT_IDENTIFIER : never;
7
+ export type ConfigurationSchemaForModel<MODEL> = MODEL extends IStateTreeNode<infer SCHEMA extends AnyConfigurationSchemaType> ? SCHEMA : never;
8
+ export type ConfigurationSlotName<SCHEMA> = SCHEMA extends undefined ? never : SCHEMA extends ConfigurationSchemaType<infer D, any> ? (keyof D & string) | GetExplicitIdentifier<SCHEMA> | (GetBase<SCHEMA> extends ConfigurationSchemaType<any, any> ? ConfigurationSlotName<GetBase<SCHEMA>> : never) : never;
9
+ export type AnyConfigurationSchemaType = ConfigurationSchemaType<any, any>;
10
+ export type AnyConfigurationModel = Instance<AnyConfigurationSchemaType>;
11
+ export type AnyConfigurationSlotType = ReturnType<typeof ConfigSlot>;
12
+ export type AnyConfigurationSlot = Instance<AnyConfigurationSlotType>;
13
+ /** any configuration model, or snapshot thereof */
14
+ export type AnyConfiguration = AnyConfigurationModel | SnapshotOut<AnyConfigurationModel>;
15
+ export type ConfigurationModel<SCHEMA extends AnyConfigurationSchemaType> = Instance<SCHEMA>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,4 @@
1
- import { AnyConfigurationModel, AnyConfigurationSchemaType } from './configurationSchema';
1
+ import { AnyConfigurationModel, AnyConfigurationSchemaType, ConfigurationSlotName, ConfigurationSchemaForModel } from './types';
2
2
  /**
3
3
  * given a configuration model (an instance of a ConfigurationSchema),
4
4
  * read the configuration variable at the given path
@@ -8,7 +8,7 @@ import { AnyConfigurationModel, AnyConfigurationSchemaType } from './configurati
8
8
  * @param args - extra arguments e.g. for a feature callback,
9
9
  * will be sent to each of the slotNames
10
10
  */
11
- export declare function readConfObject(confObject: AnyConfigurationModel, slotPath?: string[] | string | undefined, args?: Record<string, any>): any;
11
+ export declare function readConfObject<CONFMODEL extends AnyConfigurationModel>(confObject: CONFMODEL, slotPath?: ConfigurationSlotName<ConfigurationSchemaForModel<CONFMODEL>> | string[], args?: Record<string, unknown>): any;
12
12
  /**
13
13
  * helper method for readConfObject, reads the config from a mst model
14
14
  *
@@ -17,7 +17,9 @@ export declare function readConfObject(confObject: AnyConfigurationModel, slotPa
17
17
  * @param args - extra arguments e.g. for a feature callback,
18
18
  * will be sent to each of the slotNames
19
19
  */
20
- export declare function getConf(model: unknown, slotPath?: string[] | string | undefined, args?: Record<string, any>): any;
20
+ export declare function getConf<CONFMODEL extends AnyConfigurationModel>(model: {
21
+ configuration: CONFMODEL;
22
+ }, slotPath?: Parameters<typeof readConfObject<CONFMODEL>>[1], args?: Parameters<typeof readConfObject<CONFMODEL>>[2]): any;
21
23
  /**
22
24
  * given a union of explicitly typed configuration schema types,
23
25
  * extract an array of the type names contained in the union
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isConfigurationSlotType = exports.isConfigurationModel = exports.isConfigurationSchemaType = exports.isBareConfigurationSchemaType = exports.getTypeNamesFromExplicitlyTypedUnion = exports.getConf = exports.readConfObject = void 0;
4
+ /* eslint-disable @typescript-eslint/no-explicit-any */
4
5
  const mobx_state_tree_1 = require("mobx-state-tree");
5
6
  const mst_reflection_1 = require("../util/mst-reflection");
6
7
  /**
@@ -12,9 +13,7 @@ const mst_reflection_1 = require("../util/mst-reflection");
12
13
  * @param args - extra arguments e.g. for a feature callback,
13
14
  * will be sent to each of the slotNames
14
15
  */
15
- function readConfObject(confObject, slotPath = undefined,
16
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
- args = {}) {
16
+ function readConfObject(confObject, slotPath, args = {}) {
18
17
  if (!confObject) {
19
18
  throw new TypeError('must provide conf object to read');
20
19
  }
@@ -32,7 +31,7 @@ args = {}) {
32
31
  if (!slot) {
33
32
  return undefined;
34
33
  // if we want to be very strict about config slots, we could uncomment the below
35
- // instead of returning undefine
34
+ // instead of returning undefined
36
35
  //
37
36
  // const modelType = getType(model)
38
37
  // const schemaType = model.configuration && getType(model.configuration)
@@ -54,19 +53,22 @@ args = {}) {
54
53
  }
55
54
  return slot;
56
55
  }
57
- const slotName = slotPath[0];
58
- if (slotPath.length > 1) {
59
- const newPath = slotPath.slice(1);
60
- let subConf = confObject[slotName];
61
- // check for the subconf being a map if we don't find it immediately
62
- if (!subConf &&
63
- (0, mobx_state_tree_1.isStateTreeNode)(confObject) &&
64
- (0, mobx_state_tree_1.isMapType)((0, mobx_state_tree_1.getType)(confObject))) {
65
- subConf = confObject.get(slotName);
56
+ if (Array.isArray(slotPath)) {
57
+ const slotName = slotPath[0];
58
+ if (slotPath.length > 1) {
59
+ const newPath = slotPath.slice(1);
60
+ let subConf = confObject[slotName];
61
+ // check for the subconf being a map if we don't find it immediately
62
+ if (!subConf &&
63
+ (0, mobx_state_tree_1.isStateTreeNode)(confObject) &&
64
+ (0, mobx_state_tree_1.isMapType)((0, mobx_state_tree_1.getType)(confObject))) {
65
+ subConf = confObject.get(slotName);
66
+ }
67
+ return subConf ? readConfObject(subConf, newPath, args) : undefined;
66
68
  }
67
- return subConf ? readConfObject(subConf, newPath, args) : undefined;
69
+ return readConfObject(confObject, slotName, args);
68
70
  }
69
- return readConfObject(confObject, slotName, args);
71
+ throw new TypeError('slotPath must be a string or array');
70
72
  }
71
73
  exports.readConfObject = readConfObject;
72
74
  /**
@@ -77,9 +79,7 @@ exports.readConfObject = readConfObject;
77
79
  * @param args - extra arguments e.g. for a feature callback,
78
80
  * will be sent to each of the slotNames
79
81
  */
80
- function getConf(model, slotPath = undefined,
81
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
82
- args = {}) {
82
+ function getConf(model, slotPath, args) {
83
83
  if (!model) {
84
84
  throw new TypeError('must provide a model object');
85
85
  }
@@ -0,0 +1,23 @@
1
+ import { AnyConfigurationModel } from '../../configuration';
2
+ import { getSubAdapterType } from '../dataAdapterCache';
3
+ import { AugmentedRegion as Region } from '../../util/types';
4
+ import PluginManager from '../../PluginManager';
5
+ export declare abstract class BaseAdapter {
6
+ config: AnyConfigurationModel;
7
+ getSubAdapter?: getSubAdapterType | undefined;
8
+ pluginManager?: PluginManager | undefined;
9
+ id: string;
10
+ static capabilities: string[];
11
+ constructor(config?: AnyConfigurationModel, getSubAdapter?: getSubAdapterType | undefined, pluginManager?: PluginManager | undefined);
12
+ /**
13
+ * Same as `readConfObject(this.config, arg)`.
14
+ * @deprecated Does not offer the same TS type checking as `readConfObject`, consider using that instead.
15
+ */
16
+ getConf(arg: string | string[]): any;
17
+ /**
18
+ * Called to provide a hint that data tied to a certain region will not be
19
+ * needed for the foreseeable future and can be purged from caches, etc
20
+ * @param region - Region
21
+ */
22
+ abstract freeResources(region: Region): void;
23
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.BaseAdapter = void 0;
7
+ const mobx_state_tree_1 = require("mobx-state-tree");
8
+ // locals
9
+ const configuration_1 = require("../../configuration");
10
+ const idMaker_1 = __importDefault(require("../../util/idMaker"));
11
+ const configuration_2 = require("../../configuration");
12
+ const EmptyConfig = (0, configuration_2.ConfigurationSchema)('empty', {});
13
+ class BaseAdapter {
14
+ constructor(config = EmptyConfig.create(), getSubAdapter, pluginManager) {
15
+ this.config = config;
16
+ this.getSubAdapter = getSubAdapter;
17
+ this.pluginManager = pluginManager;
18
+ // note: we use switch on jest here for more simple feature IDs
19
+ // in test environment
20
+ if (typeof jest === 'undefined') {
21
+ const data = (0, mobx_state_tree_1.isStateTreeNode)(config) ? (0, mobx_state_tree_1.getSnapshot)(config) : config;
22
+ this.id = `${(0, idMaker_1.default)(data)}`;
23
+ }
24
+ else {
25
+ this.id = 'test';
26
+ }
27
+ }
28
+ /**
29
+ * Same as `readConfObject(this.config, arg)`.
30
+ * @deprecated Does not offer the same TS type checking as `readConfObject`, consider using that instead.
31
+ */
32
+ getConf(arg) {
33
+ return (0, configuration_1.readConfObject)(this.config, arg);
34
+ }
35
+ }
36
+ exports.BaseAdapter = BaseAdapter;
37
+ BaseAdapter.capabilities = [];
@@ -0,0 +1,128 @@
1
+ import { Observable } from 'rxjs';
2
+ import { BaseAdapter } from './BaseAdapter';
3
+ import { BaseOptions } from './BaseOptions';
4
+ import { FeatureDensityStats } from './types';
5
+ import { Feature } from '../../util/simpleFeature';
6
+ import { AugmentedRegion as Region } from '../../util/types';
7
+ /**
8
+ * Base class for feature adapters to extend. Defines some methods that
9
+ * subclasses must implement.
10
+ */
11
+ export declare abstract class BaseFeatureDataAdapter extends BaseAdapter {
12
+ /**
13
+ * Get all reference sequence names used in the data source
14
+ * Example:
15
+ * public async getRefNames(opts?: BaseOptions): Promise\<string[]\> \}
16
+ * await this.setup()
17
+ * const \{ refNames \} = this.metadata
18
+ * return refNames
19
+ * \}
20
+ *
21
+ *
22
+ * NOTE: If an adapter is unable to determine the reference sequence names,
23
+ * the array will be empty
24
+ * @param opts - Feature adapter options
25
+ */
26
+ abstract getRefNames(opts?: BaseOptions): Promise<string[]>;
27
+ /**
28
+ * Get features from the data source that overlap a region
29
+ * Example:
30
+ * public getFeatures(
31
+ * region: Region,
32
+ * opts: BaseOptions,
33
+ * ): Observable<Feature> \{
34
+ * return ObservableCreate(observer =\> \{
35
+ * const records = getRecords(assembly, refName, start, end)
36
+ * records.forEach(record =\> \{
37
+ * observer.next(this.recordToFeature(record))
38
+ * \})
39
+ * observer.complete()
40
+ * \})
41
+ * \}
42
+ * @param region - Region
43
+ * @param opts - Feature adapter options
44
+ * @returns Observable of Feature objects in the region
45
+ */
46
+ abstract getFeatures(region: Region, opts?: BaseOptions): Observable<Feature>;
47
+ /**
48
+ * Return "header info" that is fetched from the data file, or other info
49
+ * that would not simply be in the config of the file. The return value can
50
+ * be `{tag:string, data: any}[]` e.g. list of tags with their values which
51
+ * is how VCF,BAM,CRAM return values for getInfo or it can be a nested JSON
52
+ * object
53
+ */
54
+ getHeader(_opts?: BaseOptions): Promise<unknown>;
55
+ /**
56
+ * Return info that is primarily used for interpreting the data that is there,
57
+ * primarily in reference to being used for augmenting feature details panels
58
+ */
59
+ getMetadata(_opts?: BaseOptions): Promise<unknown>;
60
+ /**
61
+ * Checks if the store has data for the given assembly and reference
62
+ * sequence, and then gets the features in the region if it does.
63
+ */
64
+ getFeaturesInRegion(region: Region, opts?: BaseOptions): Observable<Feature>;
65
+ /**
66
+ * Checks if the store has data for the given assembly and reference
67
+ * sequence, and then gets the features in the region if it does.
68
+ *
69
+ * Currently this just calls getFeatureInRegion for each region. Adapters that
70
+ * are frequently called on multiple regions simultaneously may want to
71
+ * implement a more efficient custom version of this method.
72
+ *
73
+ * Currently this just calls getFeatureInRegion for each region. Adapters that
74
+ * are frequently called on multiple regions simultaneously may want to
75
+ * implement a more efficient custom version of this method.
76
+ *
77
+ * @param regions - Regions
78
+ * @param opts - Feature adapter options
79
+ * @returns Observable of Feature objects in the regions
80
+ */
81
+ getFeaturesInMultipleRegions(regions: Region[], opts?: BaseOptions): Observable<Feature>;
82
+ /**
83
+ * Check if the store has data for the given reference name.
84
+ * @param refName - Name of the reference sequence
85
+ * @returns Whether data source has data for the given reference name
86
+ */
87
+ hasDataForRefName(refName: string, opts?: BaseOptions): Promise<boolean>;
88
+ /**
89
+ * Calculates the minimum score, maximum score, and other statistics from
90
+ * features over a region, primarily used for quantitative tracks
91
+ */
92
+ getRegionQuantitativeStats(region: Region, opts?: BaseOptions): Promise<import("../../util/stats").QuantitativeStats>;
93
+ /**
94
+ * Calculates the minimum score, maximum score, and other statistics from
95
+ * features over multiple regions, primarily used for quantitative tracks
96
+ */
97
+ getMultiRegionQuantitativeStats(regions?: Region[], opts?: BaseOptions): Promise<import("../../util/stats").QuantitativeStats>;
98
+ /**
99
+ * Calculates the "feature density" of a region. The primary purpose of this
100
+ * API is to alert the user if they are going to be downloading too much
101
+ * information, and give them a hint to zoom in to see more. The default
102
+ * implementation samples from the regions, downloads feature data with
103
+ * getFeatures, and returns an object with the form \{featureDensity:number\}
104
+ *
105
+ * Derived classes can override this to return alternative calculations for
106
+ * featureDensity, or they can also return an object containing a byte size
107
+ * calculation with the format \{bytes:number, fetchSizeLimit:number\} where
108
+ * fetchSizeLimit is the adapter-defined limit for what it thinks is 'too much
109
+ * data' (e.g. CRAM and
110
+ * BAM may vary on what they think too much data is)
111
+ */
112
+ getRegionFeatureDensityStats(region: Region, opts?: BaseOptions): Promise<FeatureDensityStats>;
113
+ /**
114
+ * Calculates the "feature density" of a set of regions. The primary purpose
115
+ * of this API is to alert the user if they are going to be downloading too
116
+ * much information, and give them a hint to zoom in to see more. The default
117
+ * implementation samples from the regions, downloads feature data with
118
+ * getFeatures, and returns an object with the form \{featureDensity:number\}
119
+ *
120
+ * Derived classes can override this to return alternative calculations for
121
+ * featureDensity, or they can also return an object containing a byte size
122
+ * calculation with the format \{bytes:number, fetchSizeLimit:number\} where
123
+ * fetchSizeLimit is the adapter-defined limit for what it thinks is 'too much
124
+ * data' (e.g. CRAM and
125
+ * BAM may vary on what they think too much data is)
126
+ */
127
+ getMultiRegionFeatureDensityStats(regions: Region[], opts?: BaseOptions): Promise<FeatureDensityStats>;
128
+ }
@@ -1,57 +1,18 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isTextSearchAdapter = exports.isRefNameAliasAdapter = exports.isFeatureAdapter = exports.isRegionsAdapter = exports.isSequenceAdapter = exports.BaseSequenceAdapter = exports.BaseFeatureDataAdapter = exports.BaseAdapter = void 0;
3
+ exports.BaseFeatureDataAdapter = void 0;
7
4
  const rxjs_1 = require("rxjs");
8
5
  const operators_1 = require("rxjs/operators");
9
- const mobx_state_tree_1 = require("mobx-state-tree");
10
6
  // locals
11
- const rxjs_2 = require("../util/rxjs");
12
- const util_1 = require("../util");
13
- const configuration_1 = require("../configuration");
14
- const stats_1 = require("../util/stats");
15
- const idMaker_1 = __importDefault(require("../util/idMaker"));
16
- const EmptyConfig = (0, configuration_1.ConfigurationSchema)('empty', {});
17
- class BaseAdapter {
18
- constructor(config = EmptyConfig.create(), getSubAdapter, pluginManager) {
19
- this.config = config;
20
- this.getSubAdapter = getSubAdapter;
21
- this.pluginManager = pluginManager;
22
- // note: we use switch on jest here for more simple feature IDs
23
- // in test environment
24
- if (typeof jest === 'undefined') {
25
- const data = (0, mobx_state_tree_1.isStateTreeNode)(config) ? (0, mobx_state_tree_1.getSnapshot)(config) : config;
26
- this.id = `${(0, idMaker_1.default)(data)}`;
27
- }
28
- else {
29
- this.id = 'test';
30
- }
31
- }
32
- getConf(arg) {
33
- return (0, configuration_1.readConfObject)(this.config, arg);
34
- }
35
- }
36
- exports.BaseAdapter = BaseAdapter;
37
- BaseAdapter.capabilities = [];
7
+ const BaseAdapter_1 = require("./BaseAdapter");
8
+ const rxjs_2 = require("../../util/rxjs");
9
+ const util_1 = require("../../util");
10
+ const stats_1 = require("../../util/stats");
38
11
  /**
39
12
  * Base class for feature adapters to extend. Defines some methods that
40
13
  * subclasses must implement.
41
14
  */
42
- class BaseFeatureDataAdapter extends BaseAdapter {
43
- // public abstract getFeatures(
44
- // region: Region,
45
- // opts: BaseOptions,
46
- // ): Observable<Feature> {
47
- // return ObservableCreate(observer => {
48
- // const records = getRecords(assembly, refName, start, end)
49
- // records.forEach(record => {
50
- // observer.next(this.recordToFeature(record))
51
- // })
52
- // observer.complete()
53
- // })
54
- // }
15
+ class BaseFeatureDataAdapter extends BaseAdapter_1.BaseAdapter {
55
16
  /**
56
17
  * Return "header info" that is fetched from the data file, or other info
57
18
  * that would not simply be in the config of the file. The return value can
@@ -89,9 +50,9 @@ class BaseFeatureDataAdapter extends BaseAdapter {
89
50
  * Checks if the store has data for the given assembly and reference
90
51
  * sequence, and then gets the features in the region if it does.
91
52
  *
92
- * Currently this just calls getFeatureInRegion for each region. Adapters
93
- * that are frequently called on multiple regions simultaneously may
94
- * want to implement a more efficient custom version of this method.
53
+ * Currently this just calls getFeatureInRegion for each region. Adapters that
54
+ * are frequently called on multiple regions simultaneously may want to
55
+ * implement a more efficient custom version of this method.
95
56
  *
96
57
  * Currently this just calls getFeatureInRegion for each region. Adapters that
97
58
  * are frequently called on multiple regions simultaneously may want to
@@ -102,9 +63,7 @@ class BaseFeatureDataAdapter extends BaseAdapter {
102
63
  * @returns Observable of Feature objects in the regions
103
64
  */
104
65
  getFeaturesInMultipleRegions(regions, opts = {}) {
105
- return (0, rxjs_1.merge)(...regions.map(region => {
106
- return this.getFeaturesInRegion(region, opts);
107
- }));
66
+ return (0, rxjs_1.merge)(...regions.map(region => this.getFeaturesInRegion(region, opts)));
108
67
  }
109
68
  /**
110
69
  * Check if the store has data for the given reference name.
@@ -115,15 +74,23 @@ class BaseFeatureDataAdapter extends BaseAdapter {
115
74
  const refNames = await this.getRefNames(opts);
116
75
  return refNames.includes(refName);
117
76
  }
118
- async getRegionStats(region, opts) {
77
+ /**
78
+ * Calculates the minimum score, maximum score, and other statistics from
79
+ * features over a region, primarily used for quantitative tracks
80
+ */
81
+ async getRegionQuantitativeStats(region, opts) {
119
82
  const feats = this.getFeatures(region, opts);
120
83
  return (0, stats_1.scoresToStats)(region, feats);
121
84
  }
122
- async getMultiRegionStats(regions = [], opts) {
85
+ /**
86
+ * Calculates the minimum score, maximum score, and other statistics from
87
+ * features over multiple regions, primarily used for quantitative tracks
88
+ */
89
+ async getMultiRegionQuantitativeStats(regions = [], opts) {
123
90
  if (!regions.length) {
124
91
  return (0, stats_1.blankStats)();
125
92
  }
126
- const feats = await Promise.all(regions.map(region => this.getRegionStats(region, opts)));
93
+ const feats = await Promise.all(regions.map(region => this.getRegionQuantitativeStats(region, opts)));
127
94
  const scoreMax = (0, util_1.max)(feats.map(a => a.scoreMax));
128
95
  const scoreMin = (0, util_1.min)(feats.map(a => a.scoreMin));
129
96
  const scoreSum = (0, util_1.sum)(feats.map(a => a.scoreSum));
@@ -139,21 +106,30 @@ class BaseFeatureDataAdapter extends BaseAdapter {
139
106
  scoreSum,
140
107
  });
141
108
  }
142
- async estimateRegionsStats(regions, opts) {
143
- if (!regions.length) {
144
- throw new Error('No regions to estimate stats for');
145
- }
146
- const region = regions[0];
109
+ /**
110
+ * Calculates the "feature density" of a region. The primary purpose of this
111
+ * API is to alert the user if they are going to be downloading too much
112
+ * information, and give them a hint to zoom in to see more. The default
113
+ * implementation samples from the regions, downloads feature data with
114
+ * getFeatures, and returns an object with the form \{featureDensity:number\}
115
+ *
116
+ * Derived classes can override this to return alternative calculations for
117
+ * featureDensity, or they can also return an object containing a byte size
118
+ * calculation with the format \{bytes:number, fetchSizeLimit:number\} where
119
+ * fetchSizeLimit is the adapter-defined limit for what it thinks is 'too much
120
+ * data' (e.g. CRAM and
121
+ * BAM may vary on what they think too much data is)
122
+ */
123
+ getRegionFeatureDensityStats(region, opts) {
147
124
  let lastTime = +Date.now();
148
125
  const statsFromInterval = async (length, expansionTime) => {
149
126
  const { start, end } = region;
150
127
  const sampleCenter = start * 0.75 + end * 0.25;
151
- const query = {
128
+ const features = await (0, rxjs_1.firstValueFrom)(this.getFeatures({
152
129
  ...region,
153
130
  start: Math.max(0, Math.round(sampleCenter - length / 2)),
154
131
  end: Math.min(Math.round(sampleCenter + length / 2), end),
155
- };
156
- const features = await (0, rxjs_1.firstValueFrom)(this.getFeatures(query, opts).pipe((0, operators_1.toArray)()));
132
+ }, opts).pipe((0, operators_1.toArray)()));
157
133
  return maybeRecordStats(length, { featureDensity: features.length / length }, features.length, expansionTime);
158
134
  };
159
135
  const maybeRecordStats = async (interval, stats, statsSampleFeatures, expansionTime) => {
@@ -174,31 +150,25 @@ class BaseFeatureDataAdapter extends BaseAdapter {
174
150
  };
175
151
  return statsFromInterval(1000, 0);
176
152
  }
177
- }
178
- exports.BaseFeatureDataAdapter = BaseFeatureDataAdapter;
179
- class BaseSequenceAdapter extends BaseFeatureDataAdapter {
180
- async estimateRegionsStats() {
181
- return { featureDensity: 0 };
153
+ /**
154
+ * Calculates the "feature density" of a set of regions. The primary purpose
155
+ * of this API is to alert the user if they are going to be downloading too
156
+ * much information, and give them a hint to zoom in to see more. The default
157
+ * implementation samples from the regions, downloads feature data with
158
+ * getFeatures, and returns an object with the form \{featureDensity:number\}
159
+ *
160
+ * Derived classes can override this to return alternative calculations for
161
+ * featureDensity, or they can also return an object containing a byte size
162
+ * calculation with the format \{bytes:number, fetchSizeLimit:number\} where
163
+ * fetchSizeLimit is the adapter-defined limit for what it thinks is 'too much
164
+ * data' (e.g. CRAM and
165
+ * BAM may vary on what they think too much data is)
166
+ */
167
+ async getMultiRegionFeatureDensityStats(regions, opts) {
168
+ if (!regions.length) {
169
+ throw new Error('No regions supplied');
170
+ }
171
+ return this.getRegionFeatureDensityStats(regions[0], opts);
182
172
  }
183
173
  }
184
- exports.BaseSequenceAdapter = BaseSequenceAdapter;
185
- function isSequenceAdapter(thing) {
186
- return 'getRegions' in thing && 'getFeatures' in thing;
187
- }
188
- exports.isSequenceAdapter = isSequenceAdapter;
189
- function isRegionsAdapter(thing) {
190
- return 'getRegions' in thing;
191
- }
192
- exports.isRegionsAdapter = isRegionsAdapter;
193
- function isFeatureAdapter(thing) {
194
- return 'getFeatures' in thing;
195
- }
196
- exports.isFeatureAdapter = isFeatureAdapter;
197
- function isRefNameAliasAdapter(thing) {
198
- return 'getRefNameAliases' in thing;
199
- }
200
- exports.isRefNameAliasAdapter = isRefNameAliasAdapter;
201
- function isTextSearchAdapter(thing) {
202
- return 'searchIndex' in thing;
203
- }
204
- exports.isTextSearchAdapter = isTextSearchAdapter;
174
+ exports.BaseFeatureDataAdapter = BaseFeatureDataAdapter;
@@ -0,0 +1,16 @@
1
+ export interface BaseOptions {
2
+ signal?: AbortSignal;
3
+ bpPerPx?: number;
4
+ sessionId?: string;
5
+ statusCallback?: (message: string) => void;
6
+ headers?: Record<string, string>;
7
+ [key: string]: unknown;
8
+ }
9
+ export type SearchType = 'full' | 'prefix' | 'exact';
10
+ export interface BaseTextSearchArgs {
11
+ queryString: string;
12
+ searchType?: SearchType;
13
+ signal?: AbortSignal;
14
+ limit?: number;
15
+ pageNumber?: number;
16
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,9 @@
1
+ import { BaseAdapter } from './BaseAdapter';
2
+ import { BaseOptions } from './types';
3
+ export interface Alias {
4
+ refName: string;
5
+ aliases: string[];
6
+ }
7
+ export interface BaseRefNameAliasAdapter extends BaseAdapter {
8
+ getRefNameAliases(opts: BaseOptions): Promise<Alias[]>;
9
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });