jskos-server 2.4.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.
- package/.dockerignore +20 -0
- package/.editorconfig +9 -0
- package/.github/workflows/docker.yml +59 -0
- package/.github/workflows/gh-pages.yml +23 -0
- package/.github/workflows/gh-release.yml +19 -0
- package/.github/workflows/test.yml +39 -0
- package/.husky/pre-commit +1 -0
- package/CHANGELOG.md +18 -0
- package/LICENSE +21 -0
- package/README.md +2710 -0
- package/bin/extra.js +81 -0
- package/bin/import.js +438 -0
- package/bin/mongodb.js +21 -0
- package/bin/reset.js +257 -0
- package/bin/upgrade.js +34 -0
- package/config/config.default.json +88 -0
- package/config/config.schema.json +877 -0
- package/config/config.test.json +107 -0
- package/config/index.js +77 -0
- package/config/setup.js +212 -0
- package/depdendencies.png +0 -0
- package/docker/.env +1 -0
- package/docker/Dockerfile +20 -0
- package/docker/README.md +175 -0
- package/docker/docker-compose.yml +29 -0
- package/docker/docker-entrypoint.sh +8 -0
- package/docker/mongo-initdb.d/mongo_setup.sh +22 -0
- package/ecosystem.example.json +7 -0
- package/errors/index.js +94 -0
- package/eslint.config.js +17 -0
- package/index.js +10 -0
- package/models/annotations.js +13 -0
- package/models/concepts.js +12 -0
- package/models/concordances.js +12 -0
- package/models/index.js +33 -0
- package/models/mappings.js +20 -0
- package/models/meta.js +21 -0
- package/models/registries.js +12 -0
- package/models/schemes.js +12 -0
- package/package.json +91 -0
- package/routes/annotations.js +83 -0
- package/routes/common.js +86 -0
- package/routes/concepts.js +64 -0
- package/routes/concordances.js +86 -0
- package/routes/data.js +19 -0
- package/routes/mappings.js +108 -0
- package/routes/registries.js +24 -0
- package/routes/schemes.js +72 -0
- package/routes/validate.js +37 -0
- package/server.js +190 -0
- package/services/abstract.js +328 -0
- package/services/annotations.js +237 -0
- package/services/concepts.js +459 -0
- package/services/concordances.js +264 -0
- package/services/data.js +30 -0
- package/services/index.js +34 -0
- package/services/mappings.js +978 -0
- package/services/registries.js +319 -0
- package/services/schemes.js +318 -0
- package/services/validate.js +39 -0
- package/status.schema.json +145 -0
- package/test/abstract-service.js +36 -0
- package/test/annotations/annotation.json +13 -0
- package/test/api.js +2481 -0
- package/test/chai.js +14 -0
- package/test/changes.js +179 -0
- package/test/concepts/conceptNoFileEnding +4 -0
- package/test/concepts/concepts-ddc-6-60-61-62.json +123 -0
- package/test/concordances/concordances.ndjson +2 -0
- package/test/config.js +26 -0
- package/test/configs/complex-config.json +90 -0
- package/test/configs/empty-object.json +1 -0
- package/test/configs/fail-array.json +1 -0
- package/test/configs/fail-empty.json +0 -0
- package/test/configs/fail-mapping-only-props1.json +5 -0
- package/test/configs/fail-mapping-only-props2.json +5 -0
- package/test/configs/fail-mapping-only-props3.json +5 -0
- package/test/configs/fail-mapping-only-props4.json +5 -0
- package/test/configs/fail-nonexisting-prop.json +3 -0
- package/test/configs/fail-port-string.json +3 -0
- package/test/configs/fail-registry-types.json +16 -0
- package/test/configs/registry-types.json +16 -0
- package/test/data-write.js +784 -0
- package/test/eslint.js +22 -0
- package/test/import-reset.js +287 -0
- package/test/infer-mappings.js +340 -0
- package/test/ipcheck.js +287 -0
- package/test/mappings/README.md +1 -0
- package/test/mappings/ddc-gnd-1.mapping.json +33 -0
- package/test/mappings/ddc-gnd-2.mapping.json +67 -0
- package/test/mappings/mapping-ddc-gnd-noScheme.json +145 -0
- package/test/mappings/mapping-ddc-gnd.json +175 -0
- package/test/mappings/mappings-ddc.json +214 -0
- package/test/registries/registries.ndjson +2 -0
- package/test/services.js +557 -0
- package/test/terminologies/terminologies.json +94 -0
- package/test/test-utils.js +182 -0
- package/test/utils.js +425 -0
- package/test/validate.js +226 -0
- package/utils/adjust.js +206 -0
- package/utils/auth.js +154 -0
- package/utils/changes.js +88 -0
- package/utils/db.js +106 -0
- package/utils/ipcheck.js +76 -0
- package/utils/middleware.js +636 -0
- package/utils/searchHelper.js +153 -0
- package/utils/status.js +77 -0
- package/utils/users.js +7 -0
- package/utils/utils.js +114 -0
- package/utils/uuid.js +6 -0
- package/utils/version.js +324 -0
- package/views/base.ejs +172 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "https://gbv.github.io/jskos-server/status.schema.json",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
|
+
"title": "Status",
|
|
5
|
+
"description": "Status endpoint for JSKOS API",
|
|
6
|
+
"required": ["ok", "config"],
|
|
7
|
+
"type": "object",
|
|
8
|
+
"definitions": {
|
|
9
|
+
"config": {
|
|
10
|
+
"allOf": [
|
|
11
|
+
{
|
|
12
|
+
"$ref": "https://gbv.github.io/jskos-server/config.schema.json"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"type": "object",
|
|
16
|
+
"required": [
|
|
17
|
+
"baseUrl",
|
|
18
|
+
"version",
|
|
19
|
+
"env"
|
|
20
|
+
],
|
|
21
|
+
"properties": {
|
|
22
|
+
"version": {
|
|
23
|
+
"description": "The version of the JSKOS API specification that is used",
|
|
24
|
+
"type": "string"
|
|
25
|
+
},
|
|
26
|
+
"baseUrl": {
|
|
27
|
+
"description": "The baseUrl of the API",
|
|
28
|
+
"type": "string",
|
|
29
|
+
"format": "uri"
|
|
30
|
+
},
|
|
31
|
+
"mongo": false,
|
|
32
|
+
"verbosity": false,
|
|
33
|
+
"port": false,
|
|
34
|
+
"namespace": false,
|
|
35
|
+
"proxies": false,
|
|
36
|
+
"ips": false
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
"uriOrNull": {
|
|
42
|
+
"oneOf": [
|
|
43
|
+
{
|
|
44
|
+
"type": "string",
|
|
45
|
+
"format": "uri"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"type": "null"
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
"stringOrNull": {
|
|
53
|
+
"$comment": "format: uri is not used here because something like ?search={searchTerms} will not pass validation.",
|
|
54
|
+
"oneOf": [
|
|
55
|
+
{
|
|
56
|
+
"type": "string"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"type": "null"
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"properties": {
|
|
65
|
+
"ok": {
|
|
66
|
+
"description": "Indicates that everything is working correctly, especially the database connection.",
|
|
67
|
+
"type": "integer",
|
|
68
|
+
"minimum": 0,
|
|
69
|
+
"maximum": 1
|
|
70
|
+
},
|
|
71
|
+
"config": {
|
|
72
|
+
"description": "Server configuration object",
|
|
73
|
+
"$ref": "#/definitions/config"
|
|
74
|
+
},
|
|
75
|
+
"data": {
|
|
76
|
+
"description": "API URL for data",
|
|
77
|
+
"$ref": "#/definitions/uriOrNull"
|
|
78
|
+
},
|
|
79
|
+
"schemes": {
|
|
80
|
+
"description": "API URL for concept schemes",
|
|
81
|
+
"$ref": "#/definitions/uriOrNull"
|
|
82
|
+
},
|
|
83
|
+
"top": {
|
|
84
|
+
"description": "API URL for top concepts",
|
|
85
|
+
"$ref": "#/definitions/uriOrNull"
|
|
86
|
+
},
|
|
87
|
+
"voc-concepts": {
|
|
88
|
+
"description": "API URL for a vocabulary's concepts",
|
|
89
|
+
"$ref": "#/definitions/stringOrNull"
|
|
90
|
+
},
|
|
91
|
+
"voc-suggest": {
|
|
92
|
+
"description": "API URL for vocabulary suggest",
|
|
93
|
+
"$ref": "#/definitions/stringOrNull"
|
|
94
|
+
},
|
|
95
|
+
"voc-search": {
|
|
96
|
+
"description": "API URL for vocabulary search",
|
|
97
|
+
"$ref": "#/definitions/stringOrNull"
|
|
98
|
+
},
|
|
99
|
+
"concepts": {
|
|
100
|
+
"description": "API URL for concepts",
|
|
101
|
+
"$ref": "#/definitions/uriOrNull"
|
|
102
|
+
},
|
|
103
|
+
"narrower": {
|
|
104
|
+
"description": "API URL for narrower concepts",
|
|
105
|
+
"$ref": "#/definitions/uriOrNull"
|
|
106
|
+
},
|
|
107
|
+
"ancestors": {
|
|
108
|
+
"description": "API URL for concept ancestors",
|
|
109
|
+
"$ref": "#/definitions/uriOrNull"
|
|
110
|
+
},
|
|
111
|
+
"suggest": {
|
|
112
|
+
"description": "API URL for concept suggest",
|
|
113
|
+
"$ref": "#/definitions/stringOrNull"
|
|
114
|
+
},
|
|
115
|
+
"search": {
|
|
116
|
+
"description": "API URL for concept search",
|
|
117
|
+
"$ref": "#/definitions/stringOrNull"
|
|
118
|
+
},
|
|
119
|
+
"concordances": {
|
|
120
|
+
"description": "API URL for concordances",
|
|
121
|
+
"$ref": "#/definitions/uriOrNull"
|
|
122
|
+
},
|
|
123
|
+
"mappings": {
|
|
124
|
+
"description": "API URL for mappings",
|
|
125
|
+
"$ref": "#/definitions/uriOrNull"
|
|
126
|
+
},
|
|
127
|
+
"annotations": {
|
|
128
|
+
"description": "API URL for annotations",
|
|
129
|
+
"$ref": "#/definitions/uriOrNull"
|
|
130
|
+
},
|
|
131
|
+
"registries": {
|
|
132
|
+
"description": "API URL for registries",
|
|
133
|
+
"$ref": "#/definitions/uriOrNull"
|
|
134
|
+
},
|
|
135
|
+
"types": {
|
|
136
|
+
"description": "API URL for types",
|
|
137
|
+
"$ref": "#/definitions/uriOrNull"
|
|
138
|
+
},
|
|
139
|
+
"validate": {
|
|
140
|
+
"description": "API URL for types",
|
|
141
|
+
"$ref": "#/definitions/uriOrNull"
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
"additionalProperties": false
|
|
145
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import assert from "node:assert"
|
|
2
|
+
import { isQueryEmpty } from "../services/abstract.js"
|
|
3
|
+
|
|
4
|
+
describe("isQueryEmpty", () => {
|
|
5
|
+
const tests = [
|
|
6
|
+
{
|
|
7
|
+
query: {},
|
|
8
|
+
expected: true,
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
query: { $and: [{}, {}] },
|
|
12
|
+
expected: true,
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
query: { $or: [{}, { $and: [{}, { $or: [{}] }] }] },
|
|
16
|
+
expected: true,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
query: { a: 1 },
|
|
20
|
+
expected: false,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
query: { $or: [{ $and: [{}] }, { $and: [{ a: 0 }] }] },
|
|
24
|
+
expected: false,
|
|
25
|
+
},
|
|
26
|
+
]
|
|
27
|
+
let index = 0
|
|
28
|
+
for (let { expected, query } of tests) {
|
|
29
|
+
it(`should pass test[${index}]`, async () => {
|
|
30
|
+
const actual = isQueryEmpty(query)
|
|
31
|
+
// Should return object reference
|
|
32
|
+
assert.strictEqual(actual, expected)
|
|
33
|
+
})
|
|
34
|
+
index += 1
|
|
35
|
+
}
|
|
36
|
+
})
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_id": "92b778b2-54c5-4802-8822-ce5341b28fce",
|
|
3
|
+
"target": "http://localhost:3000/mappings/13878e75-3521-4ff1-9e04-cd29ee69a164",
|
|
4
|
+
"motivation": "assessing",
|
|
5
|
+
"bodyValue": "+1",
|
|
6
|
+
"creator": {
|
|
7
|
+
"id": "http://localhost:3004/users/0895ee22-cfd3-492a-a84c-f1bb2a2a1bc1",
|
|
8
|
+
"name": "Test-User"
|
|
9
|
+
},
|
|
10
|
+
"created": "2020-10-08T12:10:02.012Z",
|
|
11
|
+
"id": "http://localhost:3000/annotations/92b778b2-54c5-4802-8822-ce5341b28fce",
|
|
12
|
+
"modified": "2020-10-08T12:33:15.059Z"
|
|
13
|
+
}
|