@apollo-annotation/shared 0.3.5 → 0.3.7

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 (127) hide show
  1. package/dist/Changes/AddAssemblyAliasesChange.d.ts +16 -0
  2. package/dist/Changes/AddAssemblyAliasesChange.js +50 -0
  3. package/dist/Changes/AddAssemblyAliasesChange.js.map +1 -0
  4. package/dist/Changes/AddAssemblyAndFeaturesFromFileChange.d.ts +1 -1
  5. package/dist/Changes/AddAssemblyFromExternalChange.d.ts +1 -1
  6. package/dist/Changes/AddAssemblyFromFileChange.d.ts +1 -1
  7. package/dist/Changes/AddFeatureChange.d.ts +3 -2
  8. package/dist/Changes/AddFeatureChange.js +5 -25
  9. package/dist/Changes/AddFeatureChange.js.map +1 -1
  10. package/dist/Changes/AddFeaturesFromFileChange.d.ts +1 -1
  11. package/dist/Changes/AddRefSeqAliasesChange.d.ts +1 -1
  12. package/dist/Changes/DeleteAssemblyChange.d.ts +1 -1
  13. package/dist/Changes/DeleteFeatureChange.d.ts +12 -11
  14. package/dist/Changes/DeleteFeatureChange.js +37 -32
  15. package/dist/Changes/DeleteFeatureChange.js.map +1 -1
  16. package/dist/Changes/DeleteUserChange.d.ts +1 -1
  17. package/dist/Changes/FeatureAttributeChange.d.ts +3 -2
  18. package/dist/Changes/FeatureAttributeChange.js +14 -6
  19. package/dist/Changes/FeatureAttributeChange.js.map +1 -1
  20. package/dist/Changes/FromFileBaseChange.d.ts +3 -3
  21. package/dist/Changes/FromFileBaseChange.js.map +1 -1
  22. package/dist/Changes/ImportJBrowseConfigChange.d.ts +4 -1
  23. package/dist/Changes/ImportJBrowseConfigChange.js +17 -13
  24. package/dist/Changes/ImportJBrowseConfigChange.js.map +1 -1
  25. package/dist/Changes/LocationEndChange.d.ts +1 -1
  26. package/dist/Changes/LocationEndChange.js +40 -37
  27. package/dist/Changes/LocationEndChange.js.map +1 -1
  28. package/dist/Changes/LocationStartChange.d.ts +1 -1
  29. package/dist/Changes/LocationStartChange.js +40 -37
  30. package/dist/Changes/LocationStartChange.js.map +1 -1
  31. package/dist/Changes/MergeExonsChange.d.ts +30 -0
  32. package/dist/Changes/MergeExonsChange.js +130 -0
  33. package/dist/Changes/MergeExonsChange.js.map +1 -0
  34. package/dist/Changes/MergeTranscriptsChange.d.ts +36 -0
  35. package/dist/Changes/MergeTranscriptsChange.js +246 -0
  36. package/dist/Changes/MergeTranscriptsChange.js.map +1 -0
  37. package/dist/Changes/SplitExonChange.d.ts +33 -0
  38. package/dist/Changes/SplitExonChange.js +142 -0
  39. package/dist/Changes/SplitExonChange.js.map +1 -0
  40. package/dist/Changes/StrandChange.d.ts +1 -1
  41. package/dist/Changes/TypeChange.d.ts +1 -1
  42. package/dist/Changes/UndoMergeExonsChange.d.ts +27 -0
  43. package/dist/Changes/UndoMergeExonsChange.js +104 -0
  44. package/dist/Changes/UndoMergeExonsChange.js.map +1 -0
  45. package/dist/Changes/UndoMergeTranscriptsChange.d.ts +27 -0
  46. package/dist/Changes/UndoMergeTranscriptsChange.js +104 -0
  47. package/dist/Changes/UndoMergeTranscriptsChange.js.map +1 -0
  48. package/dist/Changes/UndoSplitExonChange.d.ts +32 -0
  49. package/dist/Changes/UndoSplitExonChange.js +111 -0
  50. package/dist/Changes/UndoSplitExonChange.js.map +1 -0
  51. package/dist/Changes/UserChange.d.ts +1 -1
  52. package/dist/Changes/index.d.ts +21 -0
  53. package/dist/Changes/index.js +21 -0
  54. package/dist/Changes/index.js.map +1 -1
  55. package/dist/Checks/CDSCheck.d.ts +1 -1
  56. package/dist/GFF3/annotationFeatureToGFF3.d.ts +2 -2
  57. package/dist/GFF3/annotationFeatureToGFF3.js +7 -1
  58. package/dist/GFF3/annotationFeatureToGFF3.js.map +1 -1
  59. package/dist/GFF3/annotationFeatureToGFF3.test.js +1 -1
  60. package/dist/GFF3/annotationFeatureToGFF3.test.js.map +1 -1
  61. package/dist/GFF3/gff3ToAnnotationFeature.d.ts +2 -2
  62. package/dist/GFF3/gff3ToAnnotationFeature.test.d.ts +1 -1
  63. package/dist/GFF3/gff3ToAnnotationFeature.test.js +1 -1
  64. package/dist/GFF3/gff3ToAnnotationFeature.test.js.map +1 -1
  65. package/dist/GFF3/gffReservedKeys.d.ts +7 -0
  66. package/dist/GFF3/gffReservedKeys.js +21 -1
  67. package/dist/GFF3/gffReservedKeys.js.map +1 -1
  68. package/dist/Messages.d.ts +2 -2
  69. package/dist/Operations/GetAssembliesOperation.d.ts +1 -1
  70. package/dist/Operations/GetFeaturesOperation.d.ts +1 -1
  71. package/dist/Validations/CoreValidation.d.ts +2 -2
  72. package/dist/Validations/CoreValidation.js +1 -1
  73. package/dist/Validations/CoreValidation.js.map +1 -1
  74. package/dist/Validations/ParentChildValidation.d.ts +5 -5
  75. package/dist/Validations/ParentChildValidation.js +3 -1
  76. package/dist/Validations/ParentChildValidation.js.map +1 -1
  77. package/dist/Validations/Validation.d.ts +5 -5
  78. package/dist/Validations/ValidationSet.d.ts +4 -4
  79. package/dist/Validations/ValidationSet.js.map +1 -1
  80. package/dist/tsconfig.tsbuildinfo +1 -1
  81. package/dist/util.d.ts +2 -0
  82. package/dist/util.js +13 -0
  83. package/dist/util.js.map +1 -1
  84. package/package.json +4 -4
  85. package/src/Changes/AddAssemblyAliasesChange.ts +69 -0
  86. package/src/Changes/AddAssemblyAndFeaturesFromFileChange.ts +6 -6
  87. package/src/Changes/AddAssemblyFromExternalChange.ts +5 -5
  88. package/src/Changes/AddAssemblyFromFileChange.ts +5 -5
  89. package/src/Changes/AddFeatureChange.ts +11 -35
  90. package/src/Changes/AddFeaturesFromFileChange.ts +6 -6
  91. package/src/Changes/AddRefSeqAliasesChange.ts +6 -6
  92. package/src/Changes/DeleteAssemblyChange.ts +4 -4
  93. package/src/Changes/DeleteFeatureChange.ts +49 -43
  94. package/src/Changes/DeleteUserChange.ts +5 -5
  95. package/src/Changes/FeatureAttributeChange.ts +22 -13
  96. package/src/Changes/FromFileBaseChange.ts +6 -3
  97. package/src/Changes/ImportJBrowseConfigChange.ts +37 -22
  98. package/src/Changes/LocationEndChange.ts +47 -56
  99. package/src/Changes/LocationStartChange.ts +47 -56
  100. package/src/Changes/MergeExonsChange.ts +185 -0
  101. package/src/Changes/MergeTranscriptsChange.ts +379 -0
  102. package/src/Changes/SplitExonChange.ts +249 -0
  103. package/src/Changes/StrandChange.ts +6 -6
  104. package/src/Changes/TypeChange.ts +6 -6
  105. package/src/Changes/UndoMergeExonsChange.ts +149 -0
  106. package/src/Changes/UndoMergeTranscriptsChange.ts +153 -0
  107. package/src/Changes/UndoSplitExonChange.ts +174 -0
  108. package/src/Changes/UserChange.ts +5 -5
  109. package/src/Changes/index.ts +21 -0
  110. package/src/Checks/CDSCheck.ts +2 -2
  111. package/src/GFF3/annotationFeatureToGFF3.test.ts +4 -2
  112. package/src/GFF3/annotationFeatureToGFF3.ts +11 -5
  113. package/src/GFF3/gff3ToAnnotationFeature.test.ts +3 -3
  114. package/src/GFF3/gff3ToAnnotationFeature.ts +2 -2
  115. package/src/GFF3/gffReservedKeys.ts +25 -0
  116. package/src/Messages.ts +2 -2
  117. package/src/Operations/GetAssembliesOperation.ts +3 -3
  118. package/src/Operations/GetFeaturesOperation.ts +4 -4
  119. package/src/Validations/CoreValidation.ts +4 -3
  120. package/src/Validations/ParentChildValidation.ts +10 -8
  121. package/src/Validations/Validation.ts +5 -5
  122. package/src/Validations/ValidationSet.ts +8 -4
  123. package/src/util.ts +16 -0
  124. package/test_data/example01.json +3 -3
  125. package/test_data/example02.json +3 -3
  126. package/test_data/example04.json +3 -3
  127. package/test_data/gene_representations.gff3 +686 -1686
package/dist/util.d.ts CHANGED
@@ -1 +1,3 @@
1
+ import { type Feature } from '@apollo-annotation/schemas';
1
2
  export declare function splitStringIntoChunks(input: string, chunkSize: number): string[];
3
+ export declare function getPrintableId(feature: Feature): string;
package/dist/util.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.splitStringIntoChunks = splitStringIntoChunks;
4
+ exports.getPrintableId = getPrintableId;
4
5
  function splitStringIntoChunks(input, chunkSize) {
5
6
  const chunks = [];
6
7
  for (let i = 0; i < input.length; i += chunkSize) {
@@ -9,4 +10,16 @@ function splitStringIntoChunks(input, chunkSize) {
9
10
  }
10
11
  return chunks;
11
12
  }
13
+ function getPrintableId(feature) {
14
+ const ff = feature;
15
+ const gff_id = ff.attributes.get('gff_id')?.join(',');
16
+ if (gff_id) {
17
+ return `ID=${gff_id} (_id: ${feature._id.toString()})`;
18
+ }
19
+ const gff_name = ff.attributes.get('gff_name')?.join(',');
20
+ if (gff_name) {
21
+ return `Name=${gff_name} (_id: ${feature._id.toString()})`;
22
+ }
23
+ return `_id: ${feature._id.toString()}`;
24
+ }
12
25
  //# sourceMappingURL=util.js.map
package/dist/util.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;AAAA,sDAUC;AAVD,SAAgB,qBAAqB,CACnC,KAAa,EACb,SAAiB;IAEjB,MAAM,MAAM,GAAa,EAAE,CAAA;IAC3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,SAAS,EAAE,CAAC;QACjD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,CAAA;QAC3C,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACpB,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC"}
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;AAGA,sDAUC;AAED,wCAWC;AAvBD,SAAgB,qBAAqB,CACnC,KAAa,EACb,SAAiB;IAEjB,MAAM,MAAM,GAAa,EAAE,CAAA;IAC3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,SAAS,EAAE,CAAC;QACjD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,CAAA;QAC3C,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACpB,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAED,SAAgB,cAAc,CAAC,OAAgB;IAC7C,MAAM,EAAE,GAAG,OAAuC,CAAA;IAClD,MAAM,MAAM,GAAG,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAA;IACrD,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,MAAM,MAAM,UAAU,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAA;IACxD,CAAC;IACD,MAAM,QAAQ,GAAG,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAA;IACzD,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,QAAQ,QAAQ,UAAU,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAA;IAC5D,CAAC;IACD,OAAO,QAAQ,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAA;AACzC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apollo-annotation/shared",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "main": "./dist/index.js",
5
5
  "scripts": {
6
6
  "build": "yarn clean && tsc --build",
@@ -10,9 +10,9 @@
10
10
  "test:ci": "NODE_V8_COVERAGE=./coverage glob -c \"tsx --test --test-reporter spec --experimental-test-coverage \" \"**/*.test.ts\""
11
11
  },
12
12
  "dependencies": {
13
- "@apollo-annotation/common": "^0.3.5",
14
- "@apollo-annotation/mst": "^0.3.5",
15
- "@apollo-annotation/schemas": "^0.3.5",
13
+ "@apollo-annotation/common": "^0.3.7",
14
+ "@apollo-annotation/mst": "^0.3.7",
15
+ "@apollo-annotation/schemas": "^0.3.7",
16
16
  "@gmod/gff": "1.2.0",
17
17
  "@gmod/indexedfasta": "^2.0.4",
18
18
  "@jbrowse/core": "^3.0.1",
@@ -0,0 +1,69 @@
1
+ import {
2
+ AssemblySpecificChange,
3
+ type Change,
4
+ type ChangeOptions,
5
+ type ClientDataStore,
6
+ type LocalGFF3DataStore,
7
+ type SerializedAssemblySpecificChange,
8
+ type ServerDataStore,
9
+ } from '@apollo-annotation/common'
10
+ import { getSession } from '@jbrowse/core/util'
11
+
12
+ export interface SerializedAssemblyAliasesChange
13
+ extends SerializedAssemblySpecificChange {
14
+ typeName: 'AddAssemblyAliasesChange'
15
+ aliases: string[]
16
+ }
17
+
18
+ export class AddAssemblyAliasesChange extends AssemblySpecificChange {
19
+ typeName = 'AddAssemblyAliasesChange' as const
20
+ aliases: string[]
21
+
22
+ constructor(json: SerializedAssemblyAliasesChange, options?: ChangeOptions) {
23
+ super(json, options)
24
+ this.aliases = json.aliases
25
+ }
26
+
27
+ executeOnClient(clientDataStore: ClientDataStore) {
28
+ const { assemblyManager } = getSession(clientDataStore)
29
+ const assembly = assemblyManager.get(this.assembly)
30
+ if (!assembly) {
31
+ throw new Error(`assembly ${this.assembly} not found`)
32
+ }
33
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
34
+ assembly.configuration.aliases.set(this.aliases)
35
+ return Promise.resolve()
36
+ }
37
+
38
+ getInverse(): Change {
39
+ throw new Error('Method not implemented.')
40
+ }
41
+
42
+ toJSON(): SerializedAssemblyAliasesChange {
43
+ const { assembly, aliases, typeName } = this
44
+ return { assembly, typeName, aliases }
45
+ }
46
+
47
+ async executeOnServer(backend: ServerDataStore) {
48
+ const { assemblyModel } = backend
49
+ const { assembly, logger, aliases } = this
50
+ logger.debug?.(
51
+ `Updating assembly aliases for assembly: ${assembly}, aliases: ${JSON.stringify(aliases)}`,
52
+ )
53
+ const asm = await assemblyModel.findById(assembly)
54
+ if (!asm) {
55
+ throw new Error(`Assembly with ID ${assembly} not found`)
56
+ }
57
+ asm.aliases = aliases
58
+ await asm.save()
59
+ }
60
+
61
+ executeOnLocalGFF3(_backend: LocalGFF3DataStore): Promise<unknown> {
62
+ throw new Error('Method not implemented.')
63
+ }
64
+
65
+ // eslint-disable-next-line @typescript-eslint/class-literal-property-style
66
+ get notification(): string {
67
+ return 'Assembly aliases have been added.'
68
+ }
69
+ }
@@ -1,13 +1,13 @@
1
1
  /* eslint-disable @typescript-eslint/require-await */
2
2
 
3
3
  import {
4
- ChangeOptions,
5
- ClientDataStore,
6
- LocalGFF3DataStore,
7
- SerializedAssemblySpecificChange,
8
- ServerDataStore,
4
+ type ChangeOptions,
5
+ type ClientDataStore,
6
+ type LocalGFF3DataStore,
7
+ type SerializedAssemblySpecificChange,
8
+ type ServerDataStore,
9
9
  } from '@apollo-annotation/common'
10
- import { GFF3Feature } from '@gmod/gff'
10
+ import { type GFF3Feature } from '@gmod/gff'
11
11
 
12
12
  import { FromFileBaseChange } from './FromFileBaseChange'
13
13
 
@@ -4,11 +4,11 @@
4
4
  /* eslint-disable @typescript-eslint/require-await */
5
5
  import {
6
6
  AssemblySpecificChange,
7
- ChangeOptions,
8
- ClientDataStore,
9
- LocalGFF3DataStore,
10
- SerializedAssemblySpecificChange,
11
- ServerDataStore,
7
+ type ChangeOptions,
8
+ type ClientDataStore,
9
+ type LocalGFF3DataStore,
10
+ type SerializedAssemblySpecificChange,
11
+ type ServerDataStore,
12
12
  } from '@apollo-annotation/common'
13
13
  import { BgzipIndexedFasta, IndexedFasta } from '@gmod/indexedfasta'
14
14
  import { RemoteFile } from 'generic-filehandle'
@@ -1,11 +1,11 @@
1
1
  /* eslint-disable @typescript-eslint/restrict-template-expressions */
2
2
  /* eslint-disable @typescript-eslint/require-await */
3
3
  import {
4
- ChangeOptions,
5
- ClientDataStore,
6
- LocalGFF3DataStore,
7
- SerializedAssemblySpecificChange,
8
- ServerDataStore,
4
+ type ChangeOptions,
5
+ type ClientDataStore,
6
+ type LocalGFF3DataStore,
7
+ type SerializedAssemblySpecificChange,
8
+ type ServerDataStore,
9
9
  } from '@apollo-annotation/common'
10
10
  import { BgzipIndexedFasta } from '@gmod/indexedfasta'
11
11
 
@@ -1,16 +1,15 @@
1
1
  /* eslint-disable @typescript-eslint/restrict-template-expressions */
2
- /* eslint-disable @typescript-eslint/no-unsafe-assignment */
3
2
  /* eslint-disable @typescript-eslint/require-await */
4
3
  /* eslint-disable @typescript-eslint/no-unnecessary-condition */
5
4
  import {
6
- ChangeOptions,
7
- ClientDataStore,
5
+ type ChangeOptions,
6
+ type ClientDataStore,
8
7
  FeatureChange,
9
- LocalGFF3DataStore,
10
- SerializedFeatureChange,
11
- ServerDataStore,
8
+ type LocalGFF3DataStore,
9
+ type SerializedFeatureChange,
10
+ type ServerDataStore,
12
11
  } from '@apollo-annotation/common'
13
- import { AnnotationFeatureSnapshot } from '@apollo-annotation/mst'
12
+ import { type AnnotationFeatureSnapshot } from '@apollo-annotation/mst'
14
13
 
15
14
  import { DeleteFeatureChange } from './DeleteFeatureChange'
16
15
 
@@ -46,6 +45,10 @@ export class AddFeatureChange extends FeatureChange {
46
45
  super(json, options)
47
46
  this.changes = 'changes' in json ? json.changes : [json]
48
47
  }
48
+ // eslint-disable-next-line @typescript-eslint/class-literal-property-style
49
+ get notification() {
50
+ return 'Feature added successfully'
51
+ }
49
52
 
50
53
  toJSON(): SerializedAddFeatureChange {
51
54
  const { assembly, changedIds, changes, typeName } = this
@@ -133,34 +136,7 @@ export class AddFeatureChange extends FeatureChange {
133
136
  `Could not find feature with ID "${parentFeatureId}" in feature "${topLevelFeature._id}"`,
134
137
  )
135
138
  }
136
- if (!parentFeature.children) {
137
- parentFeature.children = new Map()
138
- }
139
- if (!parentFeature.attributes?._id) {
140
- let { attributes } = parentFeature
141
- if (!attributes) {
142
- attributes = {}
143
- }
144
- attributes = {
145
- _id: [parentFeature._id.toString()],
146
- // eslint-disable-next-line unicorn/prefer-structured-clone
147
- ...JSON.parse(JSON.stringify(attributes)),
148
- }
149
- parentFeature.attributes = attributes
150
- }
151
- parentFeature.children.set(_id, {
152
- allIds: [],
153
- ...addedFeature,
154
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
155
- // @ts-expect-error
156
- _id,
157
- })
158
- // Child features should be sorted for click and drag of gene glyphs to work properly
159
- parentFeature.children = new Map(
160
- [...parentFeature.children.entries()].sort(
161
- (a, b) => a[1].min - b[1].min,
162
- ),
163
- )
139
+ this.addChild(parentFeature, addedFeature)
164
140
  const childIds = this.getChildFeatureIds(addedFeature)
165
141
  topLevelFeature.allIds.push(_id, ...childIds)
166
142
  await topLevelFeature.save()
@@ -1,12 +1,12 @@
1
1
  /* eslint-disable @typescript-eslint/require-await */
2
2
  import {
3
- ChangeOptions,
4
- ClientDataStore,
5
- LocalGFF3DataStore,
6
- SerializedAssemblySpecificChange,
7
- ServerDataStore,
3
+ type ChangeOptions,
4
+ type ClientDataStore,
5
+ type LocalGFF3DataStore,
6
+ type SerializedAssemblySpecificChange,
7
+ type ServerDataStore,
8
8
  } from '@apollo-annotation/common'
9
- import { GFF3Feature } from '@gmod/gff'
9
+ import { type GFF3Feature } from '@gmod/gff'
10
10
 
11
11
  import { FromFileBaseChange } from './FromFileBaseChange'
12
12
 
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  AssemblySpecificChange,
3
- Change,
4
- ChangeOptions,
5
- ClientDataStore,
6
- LocalGFF3DataStore,
7
- SerializedAssemblySpecificChange,
8
- ServerDataStore,
3
+ type Change,
4
+ type ChangeOptions,
5
+ type ClientDataStore,
6
+ type LocalGFF3DataStore,
7
+ type SerializedAssemblySpecificChange,
8
+ type ServerDataStore,
9
9
  } from '@apollo-annotation/common'
10
10
  import { getSession } from '@jbrowse/core/util'
11
11
 
@@ -4,10 +4,10 @@
4
4
  /* eslint-disable @typescript-eslint/no-unsafe-call */
5
5
  import {
6
6
  AssemblySpecificChange,
7
- ClientDataStore,
8
- LocalGFF3DataStore,
9
- SerializedAssemblySpecificChange,
10
- ServerDataStore,
7
+ type ClientDataStore,
8
+ type LocalGFF3DataStore,
9
+ type SerializedAssemblySpecificChange,
10
+ type ServerDataStore,
11
11
  } from '@apollo-annotation/common'
12
12
  import { getSession } from '@jbrowse/core/util'
13
13
 
@@ -2,15 +2,15 @@
2
2
  /* eslint-disable @typescript-eslint/require-await */
3
3
  /* eslint-disable @typescript-eslint/no-unnecessary-condition */
4
4
  import {
5
- ChangeOptions,
6
- ClientDataStore,
5
+ type ChangeOptions,
6
+ type ClientDataStore,
7
7
  FeatureChange,
8
- LocalGFF3DataStore,
9
- SerializedFeatureChange,
10
- ServerDataStore,
8
+ type LocalGFF3DataStore,
9
+ type SerializedFeatureChange,
10
+ type ServerDataStore,
11
11
  } from '@apollo-annotation/common'
12
- import { AnnotationFeatureSnapshot } from '@apollo-annotation/mst'
13
- import { Feature } from '@apollo-annotation/schemas'
12
+ import { type AnnotationFeatureSnapshot } from '@apollo-annotation/mst'
13
+ import { type Feature } from '@apollo-annotation/schemas'
14
14
 
15
15
  import { AddFeatureChange } from './AddFeatureChange'
16
16
 
@@ -44,6 +44,10 @@ export class DeleteFeatureChange extends FeatureChange {
44
44
  super(json, options)
45
45
  this.changes = 'changes' in json ? json.changes : [json]
46
46
  }
47
+ // eslint-disable-next-line @typescript-eslint/class-literal-property-style
48
+ get notification() {
49
+ return 'Feature deleted successfully'
50
+ }
47
51
 
48
52
  toJSON(): SerializedDeleteFeatureChange {
49
53
  const { assembly, changedIds, changes, typeName } = this
@@ -92,9 +96,10 @@ export class DeleteFeatureChange extends FeatureChange {
92
96
  continue
93
97
  }
94
98
 
95
- const deletedIds = this.findAndDeleteChildFeature(
99
+ const deletedIds = findAndDeleteChildFeature(
96
100
  featureDoc,
97
101
  deletedFeature._id,
102
+ this,
98
103
  )
99
104
  deletedIds.push(deletedFeature._id)
100
105
  featureDoc.allIds = featureDoc.allIds.filter(
@@ -115,38 +120,6 @@ export class DeleteFeatureChange extends FeatureChange {
115
120
  }
116
121
  }
117
122
 
118
- /**
119
- * Delete feature's subfeatures that match an ID and return the IDs of any
120
- * sub-subfeatures that were deleted
121
- * @param feature -
122
- * @param featureIdToDelete -
123
- * @returns - list of deleted feature IDs
124
- */
125
- findAndDeleteChildFeature(
126
- feature: Feature,
127
- featureIdToDelete: string,
128
- ): string[] {
129
- if (!feature.children) {
130
- throw new Error(`Feature ${feature._id} has no children`)
131
- }
132
- const { _id, children } = feature
133
- const child = children.get(featureIdToDelete)
134
- if (child) {
135
- const deletedIds = this.getChildFeatureIds(child)
136
- children.delete(featureIdToDelete)
137
- return deletedIds
138
- }
139
- for (const [, childFeature] of children) {
140
- try {
141
- return this.findAndDeleteChildFeature(childFeature, featureIdToDelete)
142
- } catch {
143
- // pass
144
- }
145
- }
146
-
147
- throw new Error(`Feature "${featureIdToDelete}" not found in ${_id}`)
148
- }
149
-
150
123
  async executeOnLocalGFF3(_backend: LocalGFF3DataStore) {
151
124
  throw new Error('executeOnLocalGFF3 not implemented')
152
125
  }
@@ -176,9 +149,9 @@ export class DeleteFeatureChange extends FeatureChange {
176
149
  const inverseChangedIds = [...changedIds].reverse()
177
150
  const inverseChanges = [...changes]
178
151
  .reverse()
179
- .map((deleteFeatuerChange) => ({
180
- addedFeature: deleteFeatuerChange.deletedFeature,
181
- parentFeatureId: deleteFeatuerChange.parentFeatureId,
152
+ .map((deleteFeatureChange) => ({
153
+ addedFeature: deleteFeatureChange.deletedFeature,
154
+ parentFeatureId: deleteFeatureChange.parentFeatureId,
182
155
  }))
183
156
  logger.debug?.(`INVERSE CHANGE '${JSON.stringify(inverseChanges)}'`)
184
157
  return new AddFeatureChange(
@@ -193,6 +166,39 @@ export class DeleteFeatureChange extends FeatureChange {
193
166
  }
194
167
  }
195
168
 
169
+ /**
170
+ * Delete feature's subfeatures that match an ID and return the IDs of any
171
+ * sub-subfeatures that were deleted
172
+ * @param feature -
173
+ * @param featureIdToDelete -
174
+ * @returns - list of deleted feature IDs
175
+ */
176
+ export function findAndDeleteChildFeature(
177
+ feature: Feature,
178
+ featureIdToDelete: string,
179
+ change: FeatureChange,
180
+ ): string[] {
181
+ if (!feature.children) {
182
+ throw new Error(`Feature ${feature._id} has no children`)
183
+ }
184
+ const { _id, children } = feature
185
+ const child = children.get(featureIdToDelete)
186
+ if (child) {
187
+ const deletedIds = change.getChildFeatureIds(child)
188
+ children.delete(featureIdToDelete)
189
+ return deletedIds
190
+ }
191
+ for (const [, childFeature] of children) {
192
+ try {
193
+ return findAndDeleteChildFeature(childFeature, featureIdToDelete, change)
194
+ } catch {
195
+ // pass
196
+ }
197
+ }
198
+
199
+ throw new Error(`Feature "${featureIdToDelete}" not found in ${_id}`)
200
+ }
201
+
196
202
  export function isDeleteFeatureChange(
197
203
  change: unknown,
198
204
  ): change is DeleteFeatureChange {
@@ -1,11 +1,11 @@
1
1
  /* eslint-disable @typescript-eslint/require-await */
2
2
  import {
3
3
  Change,
4
- ChangeOptions,
5
- ClientDataStore,
6
- LocalGFF3DataStore,
7
- SerializedChange,
8
- ServerDataStore,
4
+ type ChangeOptions,
5
+ type ClientDataStore,
6
+ type LocalGFF3DataStore,
7
+ type SerializedChange,
8
+ type ServerDataStore,
9
9
  } from '@apollo-annotation/common'
10
10
 
11
11
  export interface SerializedDeleteUserChangeBase extends SerializedChange {
@@ -2,14 +2,14 @@
2
2
  /* eslint-disable @typescript-eslint/require-await */
3
3
  /* eslint-disable @typescript-eslint/no-unnecessary-condition */
4
4
  import {
5
- ChangeOptions,
6
- ClientDataStore,
5
+ type ChangeOptions,
6
+ type ClientDataStore,
7
7
  FeatureChange,
8
- LocalGFF3DataStore,
9
- SerializedFeatureChange,
10
- ServerDataStore,
8
+ type LocalGFF3DataStore,
9
+ type SerializedFeatureChange,
10
+ type ServerDataStore,
11
11
  } from '@apollo-annotation/common'
12
- import { Feature, FeatureDocument } from '@apollo-annotation/schemas'
12
+ import { type Feature, type FeatureDocument } from '@apollo-annotation/schemas'
13
13
 
14
14
  interface SerializedFeatureAttributeChangeBase extends SerializedFeatureChange {
15
15
  typeName: 'FeatureAttributeChange'
@@ -17,7 +17,8 @@ interface SerializedFeatureAttributeChangeBase extends SerializedFeatureChange {
17
17
 
18
18
  export interface FeatureAttributeChangeDetails {
19
19
  featureId: string
20
- attributes: Record<string, string[]>
20
+ oldAttributes: Record<string, string[]>
21
+ newAttributes: Record<string, string[]>
21
22
  }
22
23
 
23
24
  interface SerializedFeatureAttributeChangeSingle
@@ -45,8 +46,15 @@ export class FeatureAttributeChange extends FeatureChange {
45
46
  toJSON(): SerializedFeatureAttributeChange {
46
47
  const { assembly, changedIds, changes, typeName } = this
47
48
  if (changes.length === 1) {
48
- const [{ attributes, featureId }] = changes
49
- return { typeName, changedIds, assembly, featureId, attributes }
49
+ const [{ oldAttributes, newAttributes, featureId }] = changes
50
+ return {
51
+ typeName,
52
+ changedIds,
53
+ assembly,
54
+ featureId,
55
+ oldAttributes,
56
+ newAttributes,
57
+ }
50
58
  }
51
59
  return { typeName, changedIds, assembly, changes }
52
60
  }
@@ -94,9 +102,9 @@ export class FeatureAttributeChange extends FeatureChange {
94
102
 
95
103
  // Let's update objects
96
104
  for (const [idx, change] of changes.entries()) {
97
- const { attributes } = change
105
+ const { newAttributes } = change
98
106
  const { feature, topLevelFeature } = featuresForChanges[idx]
99
- feature.attributes = attributes
107
+ feature.attributes = newAttributes
100
108
  if (topLevelFeature._id.equals(feature._id)) {
101
109
  topLevelFeature.markModified('attributes') // Mark as modified. Without this save() -method is not updating data in database
102
110
  } else {
@@ -131,7 +139,7 @@ export class FeatureAttributeChange extends FeatureChange {
131
139
  throw new Error(`Could not find feature with identifier "${changedId}"`)
132
140
  }
133
141
  feature.setAttributes(
134
- new Map(Object.entries(this.changes[idx].attributes)),
142
+ new Map(Object.entries(this.changes[idx].newAttributes)),
135
143
  )
136
144
  }
137
145
  }
@@ -141,7 +149,8 @@ export class FeatureAttributeChange extends FeatureChange {
141
149
  const inverseChangedIds = [...changedIds].reverse()
142
150
  const inverseChanges = [...changes].reverse().map((oneChange) => ({
143
151
  featureId: oneChange.featureId,
144
- attributes: oneChange.attributes,
152
+ oldAttributes: oneChange.newAttributes,
153
+ newAttributes: oneChange.oldAttributes,
145
154
  }))
146
155
  return new FeatureAttributeChange(
147
156
  {
@@ -5,10 +5,13 @@
5
5
  /* eslint-disable @typescript-eslint/no-unsafe-argument */
6
6
  import {
7
7
  AssemblySpecificChange,
8
- ServerDataStore,
8
+ type ServerDataStore,
9
9
  } from '@apollo-annotation/common'
10
- import { FileDocument, RefSeqDocument } from '@apollo-annotation/schemas'
11
- import { GFF3Feature } from '@gmod/gff'
10
+ import {
11
+ type FileDocument,
12
+ type RefSeqDocument,
13
+ } from '@apollo-annotation/schemas'
14
+ import { type GFF3Feature } from '@gmod/gff'
12
15
 
13
16
  import { gff3ToAnnotationFeature } from '../GFF3'
14
17
 
@@ -1,10 +1,10 @@
1
1
  /* eslint-disable @typescript-eslint/require-await */
2
2
  import {
3
3
  Change,
4
- ChangeOptions,
5
- ClientDataStore,
6
- LocalGFF3DataStore,
7
- ServerDataStore,
4
+ type ChangeOptions,
5
+ type ClientDataStore,
6
+ type LocalGFF3DataStore,
7
+ type ServerDataStore,
8
8
  } from '@apollo-annotation/common'
9
9
 
10
10
  interface JBrowseAssembly {
@@ -26,6 +26,9 @@ interface JBrowseInternetAccount {
26
26
 
27
27
  export interface JBrowseConfig {
28
28
  assemblies?: JBrowseAssembly[]
29
+ configuration?: {
30
+ ApolloPlugin?: Record<string, unknown>
31
+ }
29
32
  tracks?: JBrowseTrack[]
30
33
  plugins?: JBrowsePlugin[]
31
34
  internetAccounts?: JBrowseInternetAccount[]
@@ -39,28 +42,40 @@ export interface SerializedImportJBrowseConfigChange {
39
42
  }
40
43
 
41
44
  export function filterJBrowseConfig(config: JBrowseConfig): JBrowseConfig {
42
- const { __v, _id, assemblies, internetAccounts, plugins, tracks, ...rest } =
43
- config
44
- const filteredAssemblies = assemblies?.filter(
45
- (a) => a.sequence.adapter.type !== 'ApolloSequenceAdapter',
46
- )
47
- const filteredTracks = tracks?.filter((t) => t.type !== 'ApolloTrack')
48
- const filteredPlugins = plugins?.filter((p) => p.name !== 'Apollo')
49
- const filteredInternetAccounts = internetAccounts?.filter(
50
- (i) => i.type !== 'ApolloInternetAccount',
51
- )
45
+ const {
46
+ __v,
47
+ _id,
48
+ assemblies,
49
+ configuration,
50
+ internetAccounts,
51
+ plugins,
52
+ tracks,
53
+ ...rest
54
+ } = config
55
+ // Need to make sure that configuration.ApolloPlugin.hasRole isn't set
52
56
  const filteredConfig = rest as JBrowseConfig
53
- if (filteredAssemblies) {
54
- filteredConfig.assemblies = filteredAssemblies
57
+ if (assemblies) {
58
+ filteredConfig.assemblies = assemblies.filter(
59
+ (a) => a.sequence.adapter.type !== 'ApolloSequenceAdapter',
60
+ )
55
61
  }
56
- if (filteredTracks) {
57
- filteredConfig.tracks = filteredTracks
62
+ if (configuration?.ApolloPlugin?.hasRole) {
63
+ const { hasRole, ...apolloPluginRest } = configuration.ApolloPlugin
64
+ filteredConfig.configuration = {
65
+ ...configuration,
66
+ ApolloPlugin: apolloPluginRest,
67
+ }
68
+ }
69
+ if (internetAccounts) {
70
+ filteredConfig.internetAccounts = internetAccounts.filter(
71
+ (i) => i.type !== 'ApolloInternetAccount',
72
+ )
58
73
  }
59
- if (filteredPlugins) {
60
- filteredConfig.plugins = filteredPlugins
74
+ if (plugins) {
75
+ filteredConfig.plugins = plugins.filter((p) => p.name !== 'Apollo')
61
76
  }
62
- if (filteredInternetAccounts) {
63
- filteredConfig.internetAccounts = filteredInternetAccounts
77
+ if (tracks) {
78
+ filteredConfig.trackss = tracks.filter((t) => t.type !== 'ApolloTrack')
64
79
  }
65
80
  return filteredConfig
66
81
  }