@apollo-annotation/shared 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 +49 -0
- package/src/Changes/AddAssemblyAndFeaturesFromFileChange.ts +135 -0
- package/src/Changes/AddAssemblyFromExternalChange.ts +145 -0
- package/src/Changes/AddAssemblyFromFileChange.ts +125 -0
- package/src/Changes/AddFeatureChange.ts +233 -0
- package/src/Changes/AddFeaturesFromFileChange.ts +120 -0
- package/src/Changes/DeleteAssemblyChange.ts +100 -0
- package/src/Changes/DeleteFeatureChange.ts +200 -0
- package/src/Changes/DeleteUserChange.ts +83 -0
- package/src/Changes/DiscontinuousLocationEndChange.ts +182 -0
- package/src/Changes/DiscontinuousLocationStartChange.ts +182 -0
- package/src/Changes/FeatureAttributeChange.ts +164 -0
- package/src/Changes/LocationEndChange.ts +175 -0
- package/src/Changes/LocationStartChange.ts +175 -0
- package/src/Changes/StrandChange.ts +159 -0
- package/src/Changes/TypeChange.ts +159 -0
- package/src/Changes/UserChange.ts +82 -0
- package/src/Changes/index.ts +52 -0
- package/src/Checks/CDSCheck.ts +275 -0
- package/src/Checks/index.ts +1 -0
- package/src/Common/index.ts +1 -0
- package/src/Common/jwtPayload.ts +25 -0
- package/src/Messages.ts +32 -0
- package/src/Operations/GetAssembliesOperation.ts +28 -0
- package/src/Operations/GetFeaturesOperation.ts +58 -0
- package/src/Operations/index.ts +6 -0
- package/src/Validations/CoreValidation.ts +37 -0
- package/src/Validations/ParentChildValidation.ts +88 -0
- package/src/Validations/Validation.ts +55 -0
- package/src/Validations/ValidationSet.ts +106 -0
- package/src/Validations/index.ts +4 -0
- package/src/Validations/soSequenceTypes.ts +1865 -0
- package/src/index.ts +7 -0
- package/src/util.ts +109 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Change, ClientDataStore } from '@apollo-annotation/common'
|
|
2
|
+
import { FeatureDocument } from '@apollo-annotation/schemas'
|
|
3
|
+
import { ClientSession, Model } from 'mongoose'
|
|
4
|
+
|
|
5
|
+
import { Context, Validation, ValidationResult } from './Validation'
|
|
6
|
+
|
|
7
|
+
export class ValidationResultSet {
|
|
8
|
+
results: ValidationResult[] = []
|
|
9
|
+
get resultsMessages() {
|
|
10
|
+
return this.results
|
|
11
|
+
.map((r) => r.error?.message)
|
|
12
|
+
.filter(Boolean)
|
|
13
|
+
.join(', ')
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
ok = true
|
|
17
|
+
add(result: ValidationResult) {
|
|
18
|
+
this.results.push(result)
|
|
19
|
+
if (result.error) {
|
|
20
|
+
this.ok = false
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export class ValidationSet {
|
|
26
|
+
validations = new Set<Validation>()
|
|
27
|
+
|
|
28
|
+
registerValidation(validation: Validation): void {
|
|
29
|
+
this.validations.add(validation)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async frontendPreValidate(change: Change): Promise<ValidationResultSet> {
|
|
33
|
+
const results = new ValidationResultSet()
|
|
34
|
+
for (const v of this.validations) {
|
|
35
|
+
const result = await v.frontendPreValidate(change)
|
|
36
|
+
results.add(result)
|
|
37
|
+
if (result.error) {
|
|
38
|
+
break
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return results
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async frontendPostValidate(
|
|
45
|
+
change: Change,
|
|
46
|
+
dataStore: ClientDataStore,
|
|
47
|
+
): Promise<ValidationResultSet> {
|
|
48
|
+
const results = new ValidationResultSet()
|
|
49
|
+
for (const v of this.validations) {
|
|
50
|
+
const result = await v.frontendPostValidate(change, dataStore)
|
|
51
|
+
results.add(result)
|
|
52
|
+
if (result.error) {
|
|
53
|
+
break
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return results
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async backendPreValidate(
|
|
60
|
+
change: Change | Context,
|
|
61
|
+
): Promise<ValidationResultSet> {
|
|
62
|
+
const results = new ValidationResultSet()
|
|
63
|
+
for (const v of this.validations) {
|
|
64
|
+
const result = await v.backendPreValidate(change)
|
|
65
|
+
results.add(result)
|
|
66
|
+
if (result.error) {
|
|
67
|
+
break
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return results
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async backendPostValidate(
|
|
74
|
+
change: Change,
|
|
75
|
+
{
|
|
76
|
+
featureModel,
|
|
77
|
+
session,
|
|
78
|
+
}: { session: ClientSession; featureModel: Model<FeatureDocument> },
|
|
79
|
+
): Promise<ValidationResultSet> {
|
|
80
|
+
const results = new ValidationResultSet()
|
|
81
|
+
for (const v of this.validations) {
|
|
82
|
+
const result = await v.backendPostValidate(change, {
|
|
83
|
+
featureModel,
|
|
84
|
+
session,
|
|
85
|
+
})
|
|
86
|
+
results.add(result)
|
|
87
|
+
if (result.error) {
|
|
88
|
+
break
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return results
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async possibleValues(key: string) {
|
|
95
|
+
for (const v of this.validations) {
|
|
96
|
+
const vals = await v.possibleValues(key)
|
|
97
|
+
if (vals) {
|
|
98
|
+
return vals
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** global singleton of all known types of changes */
|
|
106
|
+
export const validationRegistry = new ValidationSet()
|