@apollo-annotation/common 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.
- package/dist/ApolloPlugin.d.ts +1 -1
- package/dist/AssemblySpecificChange.d.ts +1 -1
- package/dist/AssemblySpecificChange.js.map +1 -1
- package/dist/Change.d.ts +3 -3
- package/dist/ChangeTypeRegistry.d.ts +1 -1
- package/dist/Check.d.ts +1 -1
- package/dist/CheckRegistry.d.ts +1 -1
- package/dist/FeatureChange.d.ts +13 -4
- package/dist/FeatureChange.js +57 -0
- package/dist/FeatureChange.js.map +1 -1
- package/dist/Operation.d.ts +6 -6
- package/dist/OperationTypeRegistry.d.ts +1 -1
- package/dist/Validation.d.ts +5 -5
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/ApolloPlugin.ts +1 -1
- package/src/AssemblySpecificChange.ts +6 -1
- package/src/Change.ts +10 -10
- package/src/ChangeTypeRegistry.ts +1 -1
- package/src/Check.ts +2 -2
- package/src/CheckRegistry.ts +1 -1
- package/src/FeatureChange.ts +70 -5
- package/src/Operation.ts +13 -13
- package/src/OperationTypeRegistry.ts +1 -1
- package/src/Validation.ts +5 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apollo-annotation/common",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.7",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/GMOD/Apollo3.git",
|
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
"build": "tsc"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@apollo-annotation/schemas": "^0.3.
|
|
14
|
+
"@apollo-annotation/schemas": "^0.3.7",
|
|
15
15
|
"@jbrowse/core": "^3.0.1",
|
|
16
16
|
"bson-objectid": "^2.0.4",
|
|
17
17
|
"tslib": "^2.3.1"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@apollo-annotation/mst": "^0.3.
|
|
20
|
+
"@apollo-annotation/mst": "^0.3.7",
|
|
21
21
|
"@nestjs/common": "^10.1.0",
|
|
22
22
|
"@nestjs/core": "^10.1.0",
|
|
23
23
|
"@types/node": "^18.14.2",
|
package/src/ApolloPlugin.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Change,
|
|
4
|
+
type ChangeOptions,
|
|
5
|
+
type SerializedChange,
|
|
6
|
+
isChange,
|
|
7
|
+
} from './Change'
|
|
3
8
|
|
|
4
9
|
export interface SerializedAssemblySpecificChange extends SerializedChange {
|
|
5
10
|
assembly: string
|
package/src/Change.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
|
|
2
2
|
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
|
3
3
|
import {
|
|
4
|
-
AnnotationFeature,
|
|
5
|
-
AnnotationFeatureSnapshot,
|
|
6
|
-
ApolloAssemblyI,
|
|
7
|
-
BackendDriverType,
|
|
8
|
-
CheckResultI,
|
|
9
|
-
CheckResultSnapshot,
|
|
4
|
+
type AnnotationFeature,
|
|
5
|
+
type AnnotationFeatureSnapshot,
|
|
6
|
+
type ApolloAssemblyI,
|
|
7
|
+
type BackendDriverType,
|
|
8
|
+
type CheckResultI,
|
|
9
|
+
type CheckResultSnapshot,
|
|
10
10
|
} from '@apollo-annotation/mst'
|
|
11
|
-
import { AppRootModel, Region } from '@jbrowse/core/util'
|
|
11
|
+
import { type AppRootModel, type Region } from '@jbrowse/core/util'
|
|
12
12
|
|
|
13
13
|
import { changeRegistry } from './ChangeTypeRegistry'
|
|
14
14
|
import {
|
|
15
|
-
BackendDataStore,
|
|
15
|
+
type BackendDataStore,
|
|
16
16
|
Operation,
|
|
17
|
-
OperationOptions,
|
|
18
|
-
SerializedOperation,
|
|
17
|
+
type OperationOptions,
|
|
18
|
+
type SerializedOperation,
|
|
19
19
|
} from './Operation'
|
|
20
20
|
|
|
21
21
|
export interface ClientDataStore {
|
package/src/Check.ts
CHANGED
package/src/CheckRegistry.ts
CHANGED
package/src/FeatureChange.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
3
|
-
import type
|
|
4
|
-
import { Feature } from '@apollo-annotation/schemas'
|
|
3
|
+
import { type AnnotationFeatureSnapshot } from '@apollo-annotation/mst'
|
|
4
|
+
import { type Feature } from '@apollo-annotation/schemas'
|
|
5
5
|
import ObjectID from 'bson-objectid'
|
|
6
|
-
import type
|
|
6
|
+
import { type Types } from 'mongoose'
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
9
|
AssemblySpecificChange,
|
|
10
|
-
SerializedAssemblySpecificChange,
|
|
10
|
+
type SerializedAssemblySpecificChange,
|
|
11
11
|
isAssemblySpecificChange,
|
|
12
12
|
} from './AssemblySpecificChange'
|
|
13
|
-
import { ChangeOptions } from './Change'
|
|
13
|
+
import { type ChangeOptions } from './Change'
|
|
14
14
|
|
|
15
15
|
export interface SerializedFeatureChange
|
|
16
16
|
extends SerializedAssemblySpecificChange {
|
|
@@ -116,4 +116,69 @@ export abstract class FeatureChange extends AssemblySpecificChange {
|
|
|
116
116
|
_id: newId,
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
+
|
|
120
|
+
addChild(parentFeature: Feature, child: AnnotationFeatureSnapshot) {
|
|
121
|
+
if (!parentFeature.attributes?._id) {
|
|
122
|
+
let { attributes } = parentFeature
|
|
123
|
+
if (!attributes) {
|
|
124
|
+
attributes = {}
|
|
125
|
+
}
|
|
126
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
127
|
+
attributes = {
|
|
128
|
+
_id: [parentFeature._id.toString()],
|
|
129
|
+
// eslint-disable-next-line unicorn/prefer-structured-clone
|
|
130
|
+
...JSON.parse(JSON.stringify(attributes)),
|
|
131
|
+
}
|
|
132
|
+
parentFeature.attributes = attributes
|
|
133
|
+
}
|
|
134
|
+
const { _id } = child
|
|
135
|
+
if (!parentFeature.children) {
|
|
136
|
+
parentFeature.children = new Map()
|
|
137
|
+
}
|
|
138
|
+
parentFeature.children.set(_id, {
|
|
139
|
+
allIds: [],
|
|
140
|
+
...child,
|
|
141
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
142
|
+
// @ts-expect-error
|
|
143
|
+
_id,
|
|
144
|
+
})
|
|
145
|
+
// Child features should be sorted for click and drag of gene glyphs to work properly
|
|
146
|
+
parentFeature.children = new Map(
|
|
147
|
+
[...parentFeature.children.entries()].sort((a, b) => a[1].min - b[1].min),
|
|
148
|
+
)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Delete feature's subfeatures that match an ID and return the IDs of any
|
|
153
|
+
* sub-subfeatures that were deleted
|
|
154
|
+
* @param feature -
|
|
155
|
+
* @param featureIdToDelete -
|
|
156
|
+
* @returns - list of deleted feature IDs
|
|
157
|
+
*/
|
|
158
|
+
findAndDeleteChildFeature(
|
|
159
|
+
feature: Feature,
|
|
160
|
+
featureIdToDelete: string,
|
|
161
|
+
): string[] {
|
|
162
|
+
if (!feature.children) {
|
|
163
|
+
throw new Error(`Feature ${feature._id.toHexString()} has no children`)
|
|
164
|
+
}
|
|
165
|
+
const { _id, children } = feature
|
|
166
|
+
const child = children.get(featureIdToDelete)
|
|
167
|
+
if (child) {
|
|
168
|
+
const deletedIds = this.getChildFeatureIds(child)
|
|
169
|
+
children.delete(featureIdToDelete)
|
|
170
|
+
return deletedIds
|
|
171
|
+
}
|
|
172
|
+
for (const [, childFeature] of children) {
|
|
173
|
+
try {
|
|
174
|
+
return this.findAndDeleteChildFeature(childFeature, featureIdToDelete)
|
|
175
|
+
} catch {
|
|
176
|
+
// pass
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
throw new Error(
|
|
181
|
+
`Feature "${featureIdToDelete}" not found in ${_id.toHexString()}`,
|
|
182
|
+
)
|
|
183
|
+
}
|
|
119
184
|
}
|
package/src/Operation.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-confusing-void-expression */
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
|
|
3
3
|
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
|
4
|
-
import type
|
|
5
|
-
import type
|
|
4
|
+
import { type ReadStream } from 'node:fs'
|
|
5
|
+
import { type FileHandle } from 'node:fs/promises'
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
|
-
AssemblyDocument,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
type AssemblyDocument,
|
|
9
|
+
type CheckDocument,
|
|
10
|
+
type FeatureDocument,
|
|
11
|
+
type FileDocument,
|
|
12
|
+
type JBrowseConfigDocument,
|
|
13
|
+
type RefSeqChunkDocument,
|
|
14
|
+
type RefSeqDocument,
|
|
15
|
+
type UserDocument,
|
|
16
16
|
} from '@apollo-annotation/schemas'
|
|
17
|
-
import type
|
|
18
|
-
import
|
|
19
|
-
import {
|
|
17
|
+
import { type LoggerService } from '@nestjs/common'
|
|
18
|
+
import { type GenericFilehandle } from 'generic-filehandle'
|
|
19
|
+
import { type ClientSession, type Model } from 'mongoose'
|
|
20
20
|
|
|
21
21
|
export interface LocalGFF3DataStore {
|
|
22
22
|
typeName: 'LocalGFF3'
|
package/src/Validation.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/require-await */
|
|
2
|
-
import { FeatureDocument } from '@apollo-annotation/schemas'
|
|
3
|
-
import type
|
|
4
|
-
import type
|
|
5
|
-
import { ClientSession, Model } from 'mongoose'
|
|
2
|
+
import { type FeatureDocument } from '@apollo-annotation/schemas'
|
|
3
|
+
import { type ExecutionContext } from '@nestjs/common'
|
|
4
|
+
import { type Reflector } from '@nestjs/core'
|
|
5
|
+
import { type ClientSession, type Model } from 'mongoose'
|
|
6
6
|
|
|
7
|
-
import { Change, ClientDataStore } from './Change'
|
|
7
|
+
import { type Change, type ClientDataStore } from './Change'
|
|
8
8
|
|
|
9
9
|
export interface Context {
|
|
10
10
|
context: ExecutionContext
|