@apollo-annotation/schemas 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/package.json +26 -0
- package/src/assembly.schema.ts +33 -0
- package/src/change.schema.ts +30 -0
- package/src/check.schema.ts +23 -0
- package/src/checkResult.schema.ts +43 -0
- package/src/counter.schema.ts +15 -0
- package/src/export.schema.ts +18 -0
- package/src/feature.schema.ts +72 -0
- package/src/file.schema.ts +18 -0
- package/src/index.ts +11 -0
- package/src/refSeq.schema.ts +40 -0
- package/src/refSeqChunk.schema.ts +31 -0
- package/src/user.schema.ts +20 -0
- package/tsconfig.json +17 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# apollo-schemas
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@apollo-annotation/schemas",
|
|
3
|
+
"version": "0.1.11",
|
|
4
|
+
"main": "./dist/index.js",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "tsc"
|
|
7
|
+
},
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@nestjs/common": "^10.1.0",
|
|
10
|
+
"@nestjs/core": "^10.1.0",
|
|
11
|
+
"@nestjs/mongoose": "^10.0.0",
|
|
12
|
+
"mongoose": "^6.12.0",
|
|
13
|
+
"reflect-metadata": "^0.1.13",
|
|
14
|
+
"regenerator-runtime": "^0.13.9",
|
|
15
|
+
"rxjs": "^7.4.0",
|
|
16
|
+
"tslib": "^2.3.1"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@apollo-annotation/mst": "^0.1.11",
|
|
20
|
+
"@types/node": "^18.14.2",
|
|
21
|
+
"typescript": "^5.1.6"
|
|
22
|
+
},
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
|
|
2
|
+
import { Schema as MongooseSchema, Types } from 'mongoose'
|
|
3
|
+
|
|
4
|
+
export type AssemblyDocument = Assembly & Document
|
|
5
|
+
|
|
6
|
+
@Schema()
|
|
7
|
+
export class Assembly {
|
|
8
|
+
@Prop({ required: true })
|
|
9
|
+
name: string
|
|
10
|
+
|
|
11
|
+
@Prop()
|
|
12
|
+
displayName: string
|
|
13
|
+
|
|
14
|
+
@Prop({ type: [String] })
|
|
15
|
+
aliases: string[]
|
|
16
|
+
|
|
17
|
+
@Prop()
|
|
18
|
+
description: string
|
|
19
|
+
|
|
20
|
+
@Prop()
|
|
21
|
+
status: number
|
|
22
|
+
|
|
23
|
+
@Prop()
|
|
24
|
+
user: string
|
|
25
|
+
|
|
26
|
+
@Prop({ type: { fa: String, fai: String, gzi: String } })
|
|
27
|
+
externalLocation: { fa: string; fai: string; gzi?: string }
|
|
28
|
+
|
|
29
|
+
@Prop({ type: [{ type: MongooseSchema.Types.ObjectId, ref: 'Check' }] })
|
|
30
|
+
checks: Types.ObjectId[]
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const AssemblySchema = SchemaFactory.createForClass(Assembly)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
|
|
2
|
+
import { Document, Schema as MongooseSchema } from 'mongoose'
|
|
3
|
+
|
|
4
|
+
export type ChangeDocument = Change & Document
|
|
5
|
+
|
|
6
|
+
@Schema({ timestamps: true })
|
|
7
|
+
export class Change {
|
|
8
|
+
@Prop({ type: MongooseSchema.Types.ObjectId }) // We cannot use FK anymore because assembly is deleted outside of transaction concept
|
|
9
|
+
assembly: MongooseSchema.Types.ObjectId
|
|
10
|
+
|
|
11
|
+
@Prop({ required: true })
|
|
12
|
+
typeName: string
|
|
13
|
+
|
|
14
|
+
@Prop({ required: true, index: true })
|
|
15
|
+
changedIds: string[] // featureIds
|
|
16
|
+
|
|
17
|
+
@Prop({ type: JSON })
|
|
18
|
+
changes: unknown // serialized change
|
|
19
|
+
|
|
20
|
+
@Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Change' })
|
|
21
|
+
reverts: Change
|
|
22
|
+
|
|
23
|
+
@Prop({ required: true, index: true })
|
|
24
|
+
user: string
|
|
25
|
+
|
|
26
|
+
@Prop()
|
|
27
|
+
sequence: number
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const ChangeSchema = SchemaFactory.createForClass(Change)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
|
|
2
|
+
import { HydratedDocument, Types } from 'mongoose'
|
|
3
|
+
|
|
4
|
+
export interface CheckDocument extends HydratedDocument<Check> {
|
|
5
|
+
createdAt: Date
|
|
6
|
+
updatedAt: Date
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
@Schema({ timestamps: true })
|
|
10
|
+
export class Check {
|
|
11
|
+
// Don't make this a @Prop since _id is already on a MongoDB document
|
|
12
|
+
_id: Types.ObjectId
|
|
13
|
+
|
|
14
|
+
@Prop()
|
|
15
|
+
name: string
|
|
16
|
+
|
|
17
|
+
@Prop()
|
|
18
|
+
default: boolean
|
|
19
|
+
|
|
20
|
+
@Prop()
|
|
21
|
+
version: number
|
|
22
|
+
}
|
|
23
|
+
export const CheckSchema = SchemaFactory.createForClass(Check)
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { CheckResultSnapshot } from '@apollo-annotation/mst'
|
|
2
|
+
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
|
|
3
|
+
import { HydratedDocument, Schema as MongooseSchema, Types } from 'mongoose'
|
|
4
|
+
|
|
5
|
+
export type CheckResultDocument = HydratedDocument<CheckResult>
|
|
6
|
+
|
|
7
|
+
@Schema()
|
|
8
|
+
export class CheckResult
|
|
9
|
+
implements Omit<CheckResultSnapshot, '_id' | 'ids' | 'refSeq'>
|
|
10
|
+
{
|
|
11
|
+
// Don't make this a @Prop since _id is already on a MongoDB document
|
|
12
|
+
_id: Types.ObjectId
|
|
13
|
+
|
|
14
|
+
@Prop()
|
|
15
|
+
name: string
|
|
16
|
+
|
|
17
|
+
@Prop({ type: [MongooseSchema.Types.ObjectId], required: true, index: true })
|
|
18
|
+
ids: Types.ObjectId[]
|
|
19
|
+
|
|
20
|
+
@Prop({
|
|
21
|
+
required: true,
|
|
22
|
+
index: true,
|
|
23
|
+
type: MongooseSchema.Types.ObjectId,
|
|
24
|
+
ref: 'RefSeq',
|
|
25
|
+
})
|
|
26
|
+
refSeq: Types.ObjectId
|
|
27
|
+
|
|
28
|
+
@Prop({ required: true })
|
|
29
|
+
start: number
|
|
30
|
+
|
|
31
|
+
@Prop({ required: true })
|
|
32
|
+
end: number
|
|
33
|
+
|
|
34
|
+
@Prop({ default: false })
|
|
35
|
+
ignored: boolean
|
|
36
|
+
|
|
37
|
+
@Prop()
|
|
38
|
+
message: string
|
|
39
|
+
}
|
|
40
|
+
export const CheckResultSchema = SchemaFactory.createForClass(CheckResult)
|
|
41
|
+
|
|
42
|
+
CheckResultSchema.index({ refSeq: 1, start: 1 })
|
|
43
|
+
CheckResultSchema.index({ refSeq: 1, end: 1 })
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
|
|
2
|
+
import { Document } from 'mongoose'
|
|
3
|
+
|
|
4
|
+
export type CounterDocument = Counter & Document
|
|
5
|
+
|
|
6
|
+
@Schema()
|
|
7
|
+
export class Counter {
|
|
8
|
+
@Prop({ default: 0, required: true })
|
|
9
|
+
sequenceValue: number
|
|
10
|
+
|
|
11
|
+
@Prop({ required: true })
|
|
12
|
+
id: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const CounterSchema = SchemaFactory.createForClass(Counter)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
|
|
2
|
+
import { Document, Schema as MongooseSchema, Types } from 'mongoose'
|
|
3
|
+
|
|
4
|
+
export type ExportDocument = Export & Document
|
|
5
|
+
|
|
6
|
+
@Schema({ timestamps: true })
|
|
7
|
+
export class Export {
|
|
8
|
+
@Prop({
|
|
9
|
+
type: MongooseSchema.Types.ObjectId,
|
|
10
|
+
ref: 'Assembly',
|
|
11
|
+
required: true,
|
|
12
|
+
})
|
|
13
|
+
assembly: Types.ObjectId
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const ExportSchema = SchemaFactory.createForClass(Export)
|
|
17
|
+
|
|
18
|
+
ExportSchema.index({ createdAt: 1 }, { expireAfterSeconds: 300 })
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { AnnotationFeatureSnapshot } from '@apollo-annotation/mst'
|
|
2
|
+
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
|
|
3
|
+
import { HydratedDocument, Schema as MongooseSchema, Types } from 'mongoose'
|
|
4
|
+
|
|
5
|
+
export interface FeatureDocument extends HydratedDocument<Feature> {
|
|
6
|
+
createdAt?: Date
|
|
7
|
+
updatedAt?: Date
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
@Schema({ timestamps: true })
|
|
11
|
+
export class Feature
|
|
12
|
+
implements Omit<AnnotationFeatureSnapshot, '_id' | 'children' | 'refSeq'>
|
|
13
|
+
{
|
|
14
|
+
// Don't make this a @Prop since _id is already on a MongoDB document
|
|
15
|
+
_id: Types.ObjectId
|
|
16
|
+
|
|
17
|
+
// Here we store feature ID if it's given in attributes, otherwise gffId = _id as string
|
|
18
|
+
@Prop()
|
|
19
|
+
gffId: string
|
|
20
|
+
|
|
21
|
+
@Prop({
|
|
22
|
+
required: true,
|
|
23
|
+
index: true,
|
|
24
|
+
type: MongooseSchema.Types.ObjectId,
|
|
25
|
+
ref: 'RefSeq',
|
|
26
|
+
})
|
|
27
|
+
refSeq: Types.ObjectId
|
|
28
|
+
|
|
29
|
+
@Prop({ type: [String], required: true, index: true })
|
|
30
|
+
allIds: string[]
|
|
31
|
+
|
|
32
|
+
@Prop({ required: true })
|
|
33
|
+
type: string
|
|
34
|
+
|
|
35
|
+
@Prop({ required: true })
|
|
36
|
+
start: number
|
|
37
|
+
|
|
38
|
+
@Prop({ required: true })
|
|
39
|
+
end: number
|
|
40
|
+
|
|
41
|
+
@Prop()
|
|
42
|
+
discontinuousLocations?: { start: number; end: number; phase?: 0 | 1 | 2 }[]
|
|
43
|
+
|
|
44
|
+
@Prop()
|
|
45
|
+
strand?: 1 | -1
|
|
46
|
+
|
|
47
|
+
@Prop()
|
|
48
|
+
score?: number
|
|
49
|
+
|
|
50
|
+
@Prop()
|
|
51
|
+
phase?: 0 | 1 | 2
|
|
52
|
+
|
|
53
|
+
@Prop({ type: Map, of: [String] })
|
|
54
|
+
attributes?: Record<string, string[]>
|
|
55
|
+
|
|
56
|
+
// This is not a @Prop because it needs to be a recursive reference to the
|
|
57
|
+
// schema, which is done with Schema.add below
|
|
58
|
+
children?: Map<string, Feature>
|
|
59
|
+
|
|
60
|
+
@Prop()
|
|
61
|
+
status: number
|
|
62
|
+
|
|
63
|
+
@Prop()
|
|
64
|
+
user: string
|
|
65
|
+
}
|
|
66
|
+
export const FeatureSchema = SchemaFactory.createForClass(Feature)
|
|
67
|
+
|
|
68
|
+
FeatureSchema.add({ children: { type: Map, of: FeatureSchema } })
|
|
69
|
+
|
|
70
|
+
FeatureSchema.index({ refSeq: 1, start: 1 })
|
|
71
|
+
FeatureSchema.index({ refSeq: 1, end: 1 })
|
|
72
|
+
FeatureSchema.index({ '$**': 'text' })
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
|
|
2
|
+
import { Document } from 'mongoose'
|
|
3
|
+
|
|
4
|
+
export type FileDocument = File & Document
|
|
5
|
+
|
|
6
|
+
@Schema()
|
|
7
|
+
export class File {
|
|
8
|
+
@Prop({ required: true })
|
|
9
|
+
basename: string
|
|
10
|
+
|
|
11
|
+
@Prop({ required: true })
|
|
12
|
+
checksum: string
|
|
13
|
+
|
|
14
|
+
@Prop({ required: true, enum: ['text/x-gff3', 'text/x-fasta'] })
|
|
15
|
+
type: 'text/x-gff3' | 'text/x-fasta'
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const FileSchema = SchemaFactory.createForClass(File)
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './assembly.schema'
|
|
2
|
+
export * from './change.schema'
|
|
3
|
+
export * from './check.schema'
|
|
4
|
+
export * from './checkResult.schema'
|
|
5
|
+
export * from './counter.schema'
|
|
6
|
+
export * from './export.schema'
|
|
7
|
+
export * from './feature.schema'
|
|
8
|
+
export * from './file.schema'
|
|
9
|
+
export * from './refSeq.schema'
|
|
10
|
+
export * from './refSeqChunk.schema'
|
|
11
|
+
export * from './user.schema'
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
|
|
2
|
+
import { Document, Schema as MongooseSchema, Types } from 'mongoose'
|
|
3
|
+
|
|
4
|
+
import { Assembly } from './assembly.schema'
|
|
5
|
+
|
|
6
|
+
export type RefSeqDocument = RefSeq & Document
|
|
7
|
+
|
|
8
|
+
@Schema()
|
|
9
|
+
export class RefSeq {
|
|
10
|
+
// Don't make this a @Prop since _id is already on a MongoDB document
|
|
11
|
+
_id: Types.ObjectId
|
|
12
|
+
|
|
13
|
+
@Prop({
|
|
14
|
+
type: MongooseSchema.Types.ObjectId,
|
|
15
|
+
ref: 'Assembly',
|
|
16
|
+
required: true,
|
|
17
|
+
index: true,
|
|
18
|
+
})
|
|
19
|
+
assembly: Assembly
|
|
20
|
+
|
|
21
|
+
@Prop({ required: true })
|
|
22
|
+
name: string
|
|
23
|
+
|
|
24
|
+
@Prop()
|
|
25
|
+
description: string
|
|
26
|
+
|
|
27
|
+
@Prop({ required: true })
|
|
28
|
+
length: number
|
|
29
|
+
|
|
30
|
+
@Prop({ default: 256 * 1024 /* 256 KiB */ })
|
|
31
|
+
chunkSize: number
|
|
32
|
+
|
|
33
|
+
@Prop()
|
|
34
|
+
status: number
|
|
35
|
+
|
|
36
|
+
@Prop()
|
|
37
|
+
user: string
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const RefSeqSchema = SchemaFactory.createForClass(RefSeq)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
|
|
2
|
+
import { Document, Schema as MongooseSchema } from 'mongoose'
|
|
3
|
+
|
|
4
|
+
import { RefSeq } from './refSeq.schema'
|
|
5
|
+
|
|
6
|
+
export type RefSeqChunkDocument = RefSeqChunk & Document
|
|
7
|
+
|
|
8
|
+
@Schema()
|
|
9
|
+
export class RefSeqChunk {
|
|
10
|
+
@Prop({
|
|
11
|
+
type: MongooseSchema.Types.ObjectId,
|
|
12
|
+
ref: 'RefSeq',
|
|
13
|
+
required: true,
|
|
14
|
+
index: true,
|
|
15
|
+
})
|
|
16
|
+
refSeq: RefSeq
|
|
17
|
+
|
|
18
|
+
@Prop({ required: true })
|
|
19
|
+
n: number
|
|
20
|
+
|
|
21
|
+
@Prop({ required: true })
|
|
22
|
+
sequence: string
|
|
23
|
+
|
|
24
|
+
@Prop()
|
|
25
|
+
status: number
|
|
26
|
+
|
|
27
|
+
@Prop()
|
|
28
|
+
user: string
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const RefSeqChunkSchema = SchemaFactory.createForClass(RefSeqChunk)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
|
|
2
|
+
import { Document } from 'mongoose'
|
|
3
|
+
|
|
4
|
+
export type UserDocument = User & Document
|
|
5
|
+
|
|
6
|
+
export type Role = 'readOnly' | 'admin' | 'user'
|
|
7
|
+
|
|
8
|
+
@Schema({ timestamps: true })
|
|
9
|
+
export class User {
|
|
10
|
+
@Prop({ required: true })
|
|
11
|
+
username: string
|
|
12
|
+
|
|
13
|
+
@Prop({ required: true, unique: true })
|
|
14
|
+
email: string
|
|
15
|
+
|
|
16
|
+
@Prop({ type: String, enum: ['readOnly', 'admin', 'user'] })
|
|
17
|
+
role: Role
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const UserSchema = SchemaFactory.createForClass(User)
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"composite": true,
|
|
5
|
+
"incremental": true,
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"rootDir": "./src",
|
|
8
|
+
"target": "ES2022",
|
|
9
|
+
"lib": ["ES2022", "DOM"],
|
|
10
|
+
"module": "CommonJS",
|
|
11
|
+
"tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo",
|
|
12
|
+
"experimentalDecorators": true,
|
|
13
|
+
"emitDecoratorMetadata": true,
|
|
14
|
+
"strictPropertyInitialization": false,
|
|
15
|
+
},
|
|
16
|
+
"include": ["./src"],
|
|
17
|
+
}
|