arocapi 4.0.1 → 5.0.0-beta.10
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/LICENSE.md +1 -1
- package/README.md +37 -781
- package/dist/app.d.ts +38 -21
- package/dist/app.js +63 -45
- package/dist/app.js.map +1 -1
- package/dist/routes/capabilities.d.ts +7 -0
- package/dist/routes/capabilities.js +13 -0
- package/dist/routes/capabilities.js.map +1 -0
- package/dist/routes/entities.d.ts +5 -2
- package/dist/routes/entities.js +38 -58
- package/dist/routes/entities.js.map +1 -1
- package/dist/routes/entity.d.ts +7 -2
- package/dist/routes/entity.js +14 -30
- package/dist/routes/entity.js.map +1 -1
- package/dist/routes/file.d.ts +8 -2
- package/dist/routes/file.js +38 -73
- package/dist/routes/file.js.map +1 -1
- package/dist/routes/files.d.ts +5 -2
- package/dist/routes/files.js +25 -40
- package/dist/routes/files.js.map +1 -1
- package/dist/routes/metadata.d.ts +15 -0
- package/dist/routes/metadata.js +38 -0
- package/dist/routes/metadata.js.map +1 -0
- package/dist/routes/search.d.ts +8 -7
- package/dist/routes/search.js +91 -120
- package/dist/routes/search.js.map +1 -1
- package/dist/search/advanced.d.ts +8 -0
- package/dist/search/advanced.js +198 -0
- package/dist/search/advanced.js.map +1 -0
- package/dist/search/backend.d.ts +95 -0
- package/dist/search/backend.js +5 -0
- package/dist/search/backend.js.map +1 -0
- package/dist/search/fields.d.ts +63 -0
- package/dist/search/fields.js +203 -0
- package/dist/search/fields.js.map +1 -0
- package/dist/search/opensearch/advanced.d.ts +4 -0
- package/dist/search/opensearch/advanced.js +28 -0
- package/dist/search/opensearch/advanced.js.map +1 -0
- package/dist/search/opensearch/opensearch.d.ts +16 -0
- package/dist/search/opensearch/opensearch.js +187 -0
- package/dist/search/opensearch/opensearch.js.map +1 -0
- package/dist/search/opensearch/visibility.d.ts +3 -0
- package/dist/search/opensearch/visibility.js +27 -0
- package/dist/search/opensearch/visibility.js.map +1 -0
- package/dist/search/postgres/advanced.d.ts +7 -0
- package/dist/search/postgres/advanced.js +54 -0
- package/dist/search/postgres/advanced.js.map +1 -0
- package/dist/search/postgres/facets.d.ts +2 -0
- package/dist/search/postgres/facets.js +27 -0
- package/dist/search/postgres/facets.js.map +1 -0
- package/dist/search/postgres/geo.d.ts +6 -0
- package/dist/search/postgres/geo.js +42 -0
- package/dist/search/postgres/geo.js.map +1 -0
- package/dist/search/postgres/postgres.d.ts +19 -0
- package/dist/search/postgres/postgres.js +157 -0
- package/dist/search/postgres/postgres.js.map +1 -0
- package/dist/search/postgres/values.d.ts +8 -0
- package/dist/search/postgres/values.js +20 -0
- package/dist/search/postgres/values.js.map +1 -0
- package/dist/search/postgres/visibility.d.ts +4 -0
- package/dist/search/postgres/visibility.js +38 -0
- package/dist/search/postgres/visibility.js.map +1 -0
- package/dist/search/requestFilters.d.ts +39 -0
- package/dist/search/requestFilters.js +125 -0
- package/dist/search/requestFilters.js.map +1 -0
- package/dist/search/visibility.d.ts +51 -0
- package/dist/search/visibility.js +100 -0
- package/dist/search/visibility.js.map +1 -0
- package/dist/storage/backend.d.ts +58 -0
- package/dist/storage/backend.js +2 -0
- package/dist/storage/backend.js.map +1 -0
- package/dist/storage/deliver.d.ts +12 -0
- package/dist/storage/deliver.js +34 -0
- package/dist/storage/deliver.js.map +1 -0
- package/dist/storage/directory/directory.d.ts +6 -0
- package/dist/storage/directory/directory.js +24 -0
- package/dist/storage/directory/directory.js.map +1 -0
- package/dist/storage/entity-meta/entity-meta.d.ts +5 -0
- package/dist/storage/entity-meta/entity-meta.js +14 -0
- package/dist/storage/entity-meta/entity-meta.js.map +1 -0
- package/dist/storage/location.d.ts +19 -0
- package/dist/storage/location.js +36 -0
- package/dist/storage/location.js.map +1 -0
- package/dist/storage/ocfl/ocfl.d.ts +6 -0
- package/dist/storage/ocfl/ocfl.js +45 -0
- package/dist/storage/ocfl/ocfl.js.map +1 -0
- package/dist/storage/results.d.ts +7 -0
- package/dist/storage/results.js +22 -0
- package/dist/storage/results.js.map +1 -0
- package/dist/storage/s3/s3.d.ts +10 -0
- package/dist/storage/s3/s3.js +47 -0
- package/dist/storage/s3/s3.js.map +1 -0
- package/dist/transformers/default.d.ts +11 -22
- package/dist/transformers/default.js +41 -15
- package/dist/transformers/default.js.map +1 -1
- package/dist/types/access.d.ts +9 -0
- package/dist/types/access.js +2 -0
- package/dist/types/access.js.map +1 -0
- package/dist/types/context.d.ts +6 -0
- package/dist/types/context.js +2 -0
- package/dist/types/context.js.map +1 -0
- package/dist/types/transformers.d.ts +4 -10
- package/dist/types/visibility.d.ts +6 -0
- package/dist/types/visibility.js +2 -0
- package/dist/types/visibility.js.map +1 -0
- package/dist/utils/access.d.ts +17 -0
- package/dist/utils/access.js +41 -0
- package/dist/utils/access.js.map +1 -0
- package/dist/utils/errors.d.ts +19 -10
- package/dist/utils/errors.js +44 -8
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/headers.d.ts +1 -1
- package/dist/utils/headers.js +10 -1
- package/dist/utils/headers.js.map +1 -1
- package/dist/utils/validation.d.ts +2 -0
- package/dist/utils/validation.js +8 -0
- package/dist/utils/validation.js.map +1 -0
- package/dist/utils/visibility.d.ts +18 -0
- package/dist/utils/visibility.js +16 -0
- package/dist/utils/visibility.js.map +1 -0
- package/package.json +84 -45
- package/prisma/models/entity.prisma +9 -8
- package/prisma/models/entitySearch.prisma +21 -0
- package/prisma/models/file.prisma +3 -3
- package/src/app.ts +169 -102
- package/src/routes/capabilities.ts +22 -0
- package/src/routes/entities.ts +49 -68
- package/src/routes/entity.ts +22 -36
- package/src/routes/file.ts +54 -104
- package/src/routes/files.ts +32 -48
- package/src/routes/metadata.ts +67 -0
- package/src/routes/search.ts +132 -152
- package/src/search/advanced.ts +258 -0
- package/src/search/backend.ts +91 -0
- package/src/search/fields.ts +320 -0
- package/src/search/opensearch/advanced.ts +36 -0
- package/src/search/opensearch/opensearch.ts +290 -0
- package/src/search/opensearch/visibility.ts +38 -0
- package/src/search/postgres/advanced.ts +76 -0
- package/src/search/postgres/facets.ts +34 -0
- package/src/search/postgres/geo.ts +58 -0
- package/src/search/postgres/postgres.ts +232 -0
- package/src/search/postgres/values.ts +33 -0
- package/src/search/postgres/visibility.ts +54 -0
- package/src/search/requestFilters.ts +178 -0
- package/src/search/visibility.ts +193 -0
- package/src/storage/backend.ts +75 -0
- package/src/storage/deliver.ts +65 -0
- package/src/storage/directory/directory.ts +39 -0
- package/src/storage/entity-meta/entity-meta.ts +25 -0
- package/src/storage/location.ts +78 -0
- package/src/storage/ocfl/ocfl.ts +71 -0
- package/src/storage/results.ts +32 -0
- package/src/storage/s3/s3.ts +79 -0
- package/src/transformers/default.ts +115 -85
- package/src/types/access.ts +25 -0
- package/src/types/context.ts +15 -0
- package/src/types/transformers.ts +8 -34
- package/src/types/visibility.ts +21 -0
- package/src/utils/access.ts +80 -0
- package/src/utils/errors.ts +68 -11
- package/src/utils/headers.ts +22 -2
- package/src/utils/validation.ts +11 -0
- package/src/utils/visibility.ts +56 -0
- package/dist/app.test.d.ts +0 -1
- package/dist/app.test.js +0 -89
- package/dist/app.test.js.map +0 -1
- package/dist/express.d.ts +0 -4
- package/dist/express.js +0 -14
- package/dist/express.js.map +0 -1
- package/dist/index.dev.d.ts +0 -1
- package/dist/index.dev.js +0 -156
- package/dist/index.dev.js.map +0 -1
- package/dist/routes/crate.d.ts +0 -9
- package/dist/routes/crate.js +0 -82
- package/dist/routes/crate.js.map +0 -1
- package/dist/routes/crate.test.d.ts +0 -1
- package/dist/routes/crate.test.js +0 -342
- package/dist/routes/crate.test.js.map +0 -1
- package/dist/routes/entities.test.d.ts +0 -1
- package/dist/routes/entities.test.js +0 -273
- package/dist/routes/entities.test.js.map +0 -1
- package/dist/routes/entity.test.d.ts +0 -1
- package/dist/routes/entity.test.js +0 -130
- package/dist/routes/entity.test.js.map +0 -1
- package/dist/routes/file.test.d.ts +0 -1
- package/dist/routes/file.test.js +0 -315
- package/dist/routes/file.test.js.map +0 -1
- package/dist/routes/files.test.d.ts +0 -1
- package/dist/routes/files.test.js +0 -222
- package/dist/routes/files.test.js.map +0 -1
- package/dist/routes/search.test.d.ts +0 -1
- package/dist/routes/search.test.js +0 -780
- package/dist/routes/search.test.js.map +0 -1
- package/dist/test/helpers/fastify.d.ts +0 -9
- package/dist/test/helpers/fastify.js +0 -18
- package/dist/test/helpers/fastify.js.map +0 -1
- package/dist/test/integration.setup.d.ts +0 -29
- package/dist/test/integration.setup.js +0 -188
- package/dist/test/integration.setup.js.map +0 -1
- package/dist/test/integration.test.d.ts +0 -1
- package/dist/test/integration.test.js +0 -396
- package/dist/test/integration.test.js.map +0 -1
- package/dist/transformers/default.test.d.ts +0 -1
- package/dist/transformers/default.test.js +0 -163
- package/dist/transformers/default.test.js.map +0 -1
- package/dist/transformers/transformer.test.d.ts +0 -1
- package/dist/transformers/transformer.test.js +0 -187
- package/dist/transformers/transformer.test.js.map +0 -1
- package/dist/types/fileHandlers.d.ts +0 -41
- package/dist/types/fileHandlers.js +0 -2
- package/dist/types/fileHandlers.js.map +0 -1
- package/dist/utils/errors.test.d.ts +0 -1
- package/dist/utils/errors.test.js +0 -66
- package/dist/utils/errors.test.js.map +0 -1
- package/dist/utils/queryBuilder.d.ts +0 -35
- package/dist/utils/queryBuilder.js +0 -98
- package/dist/utils/queryBuilder.js.map +0 -1
- package/prisma.config.ts +0 -9
- package/src/app.test.ts +0 -119
- package/src/express.ts +0 -21
- package/src/index.dev.ts +0 -200
- package/src/reset.d.ts +0 -1
- package/src/routes/__snapshots__/entities.test.ts.snap +0 -96
- package/src/routes/__snapshots__/entity.test.ts.snap +0 -74
- package/src/routes/__snapshots__/search.test.ts.snap +0 -165
- package/src/routes/crate.test.ts +0 -423
- package/src/routes/crate.ts +0 -123
- package/src/routes/entities.test.ts +0 -320
- package/src/routes/entity.test.ts +0 -160
- package/src/routes/file.test.ts +0 -395
- package/src/routes/files.test.ts +0 -278
- package/src/routes/search.test.ts +0 -903
- package/src/test/__snapshots__/integration.test.ts.snap +0 -18
- package/src/test/helpers/fastify.ts +0 -27
- package/src/test/integration.setup.ts +0 -210
- package/src/test/integration.test.ts +0 -482
- package/src/transformers/default.test.ts +0 -184
- package/src/transformers/transformer.test.ts +0 -252
- package/src/types/fileHandlers.ts +0 -65
- package/src/utils/errors.test.ts +0 -75
- package/src/utils/queryBuilder.ts +0 -132
package/src/index.dev.ts
DELETED
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
import { createReadStream, existsSync, readFileSync, statSync } from 'node:fs';
|
|
2
|
-
import { Readable } from 'node:stream';
|
|
3
|
-
import { Client } from '@opensearch-project/opensearch';
|
|
4
|
-
import { PrismaMariaDb } from '@prisma/adapter-mariadb';
|
|
5
|
-
import Fastify from 'fastify';
|
|
6
|
-
|
|
7
|
-
import arocapi, {
|
|
8
|
-
AllPublicAccessTransformer,
|
|
9
|
-
AllPublicFileAccessTransformer,
|
|
10
|
-
type EntityTransformer,
|
|
11
|
-
type FileHandler,
|
|
12
|
-
type RoCrateHandler,
|
|
13
|
-
} from './app.js';
|
|
14
|
-
import type { Entity, File } from './generated/prisma/client.js';
|
|
15
|
-
import { PrismaClient } from './generated/prisma/client.js';
|
|
16
|
-
|
|
17
|
-
const adapter = new PrismaMariaDb({
|
|
18
|
-
host: 'localhost',
|
|
19
|
-
user: 'root',
|
|
20
|
-
password: 'password',
|
|
21
|
-
database: 'catalog',
|
|
22
|
-
port: 3306,
|
|
23
|
-
connectionLimit: 5,
|
|
24
|
-
// NOTE: This is required when using the default MariaDB server configuration with SSL disabled. In production, you should properly configure SSL and remove this option.
|
|
25
|
-
allowPublicKeyRetrieval: true,
|
|
26
|
-
});
|
|
27
|
-
const prisma = new PrismaClient({ adapter });
|
|
28
|
-
|
|
29
|
-
if (!process.env.OPENSEARCH_URL) {
|
|
30
|
-
throw new Error('OPENSEARCH_URL environment variable is not set');
|
|
31
|
-
}
|
|
32
|
-
const opensearchUrl = process.env.OPENSEARCH_URL;
|
|
33
|
-
const opensearch = new Client({ node: opensearchUrl });
|
|
34
|
-
|
|
35
|
-
const fileHandler: FileHandler = {
|
|
36
|
-
head: async (file: File) => {
|
|
37
|
-
const filePath = (file.meta as { storagePath: string }).storagePath;
|
|
38
|
-
|
|
39
|
-
if (!existsSync(filePath)) {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const stats = statSync(filePath);
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
contentType: file.mediaType,
|
|
47
|
-
contentLength: Number(file.size),
|
|
48
|
-
lastModified: stats.mtime,
|
|
49
|
-
};
|
|
50
|
-
},
|
|
51
|
-
get: async (file: File) => {
|
|
52
|
-
const filePath = (file.meta as { storagePath: string }).storagePath;
|
|
53
|
-
|
|
54
|
-
if (!existsSync(filePath)) {
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const stats = statSync(filePath);
|
|
59
|
-
|
|
60
|
-
return {
|
|
61
|
-
type: 'stream',
|
|
62
|
-
stream: createReadStream(filePath),
|
|
63
|
-
metadata: {
|
|
64
|
-
contentType: file.mediaType,
|
|
65
|
-
contentLength: Number(file.size),
|
|
66
|
-
lastModified: stats.mtime,
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
const transformRoCrate = (filePath: string, remapRootTo: string): { rocrate: unknown; jsonString: string } | false => {
|
|
73
|
-
const fileContents = readFileSync(filePath, 'utf-8');
|
|
74
|
-
const rocrate = JSON.parse(fileContents) as {
|
|
75
|
-
'@context'?: unknown;
|
|
76
|
-
'@graph'?: Array<{ '@id': string; [key: string]: unknown }>;
|
|
77
|
-
[key: string]: unknown;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
const graph = rocrate['@graph'] || [];
|
|
81
|
-
const rootNode = graph.find((node) => node['@id'] === 'ro-crate-metadata.json') as
|
|
82
|
-
| { about: { '@id': string } }
|
|
83
|
-
| undefined;
|
|
84
|
-
|
|
85
|
-
if (!rootNode) {
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
rootNode.about['@id'] = remapRootTo;
|
|
90
|
-
|
|
91
|
-
const jsonString = JSON.stringify(rocrate);
|
|
92
|
-
|
|
93
|
-
return { rocrate, jsonString };
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const roCrateHandler: RoCrateHandler = {
|
|
97
|
-
head: async (entity: Entity) => {
|
|
98
|
-
const meta = entity.meta as { storagePath: string; remapRootTo: string };
|
|
99
|
-
const filePath = meta.storagePath;
|
|
100
|
-
|
|
101
|
-
if (!existsSync(filePath)) {
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (meta.remapRootTo) {
|
|
106
|
-
const result = transformRoCrate(filePath, meta.remapRootTo);
|
|
107
|
-
|
|
108
|
-
if (!result) {
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return {
|
|
113
|
-
contentType: 'application/ld+json',
|
|
114
|
-
contentLength: Buffer.byteLength(result.jsonString),
|
|
115
|
-
lastModified: statSync(filePath).mtime,
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
const stats = statSync(filePath);
|
|
120
|
-
|
|
121
|
-
return {
|
|
122
|
-
contentType: 'application/ld+json',
|
|
123
|
-
contentLength: stats.size,
|
|
124
|
-
lastModified: stats.mtime,
|
|
125
|
-
};
|
|
126
|
-
},
|
|
127
|
-
get: async (entity: Entity) => {
|
|
128
|
-
const meta = entity.meta as { storagePath: string; remapRootTo: string };
|
|
129
|
-
const filePath = meta.storagePath;
|
|
130
|
-
|
|
131
|
-
if (!existsSync(filePath)) {
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (meta.remapRootTo) {
|
|
136
|
-
const result = transformRoCrate(filePath, meta.remapRootTo);
|
|
137
|
-
|
|
138
|
-
if (!result) {
|
|
139
|
-
return false;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return {
|
|
143
|
-
type: 'stream',
|
|
144
|
-
stream: Readable.from(result.jsonString),
|
|
145
|
-
metadata: {
|
|
146
|
-
contentType: 'application/ld+json',
|
|
147
|
-
contentLength: Buffer.byteLength(result.jsonString),
|
|
148
|
-
lastModified: statSync(filePath).mtime,
|
|
149
|
-
},
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
const stats = statSync(filePath);
|
|
154
|
-
|
|
155
|
-
return {
|
|
156
|
-
type: 'stream',
|
|
157
|
-
stream: createReadStream(filePath),
|
|
158
|
-
metadata: {
|
|
159
|
-
contentType: 'application/ld+json',
|
|
160
|
-
contentLength: stats.size,
|
|
161
|
-
lastModified: stats.mtime,
|
|
162
|
-
},
|
|
163
|
-
};
|
|
164
|
-
},
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
const oniTransformer: EntityTransformer = (entity) => {
|
|
168
|
-
return {
|
|
169
|
-
...entity,
|
|
170
|
-
accessControl: 'Public',
|
|
171
|
-
counts: {
|
|
172
|
-
collections: 0,
|
|
173
|
-
objects: 0,
|
|
174
|
-
files: 0,
|
|
175
|
-
},
|
|
176
|
-
};
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
const fastify = Fastify({
|
|
180
|
-
logger: true,
|
|
181
|
-
});
|
|
182
|
-
fastify.register(arocapi, {
|
|
183
|
-
prisma,
|
|
184
|
-
opensearch,
|
|
185
|
-
fileHandler,
|
|
186
|
-
roCrateHandler,
|
|
187
|
-
accessTransformer: AllPublicAccessTransformer,
|
|
188
|
-
entityTransformers: [oniTransformer],
|
|
189
|
-
fileAccessTransformer: AllPublicFileAccessTransformer,
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
const start = async () => {
|
|
193
|
-
try {
|
|
194
|
-
await fastify.listen({ port: 9000 });
|
|
195
|
-
} catch (err) {
|
|
196
|
-
fastify.log.error(err);
|
|
197
|
-
process.exit(1);
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
start();
|
package/src/reset.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import '@total-typescript/ts-reset';
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
-
|
|
3
|
-
exports[`Entities Route > GET /entities > should apply custom entity transformers 1`] = `
|
|
4
|
-
{
|
|
5
|
-
"entities": [
|
|
6
|
-
{
|
|
7
|
-
"access": {
|
|
8
|
-
"content": true,
|
|
9
|
-
"metadata": true,
|
|
10
|
-
},
|
|
11
|
-
"contentLicenseId": "https://creativecommons.org/licenses/by/4.0/",
|
|
12
|
-
"description": "First test entity",
|
|
13
|
-
"entityType": "http://pcdm.org/models#Collection",
|
|
14
|
-
"id": "http://example.com/entity/1",
|
|
15
|
-
"memberOf": null,
|
|
16
|
-
"metadataLicenseId": "https://creativecommons.org/licenses/by/4.0/",
|
|
17
|
-
"name": "Test Entity 1",
|
|
18
|
-
"rootCollection": null,
|
|
19
|
-
"tested": true,
|
|
20
|
-
},
|
|
21
|
-
],
|
|
22
|
-
}
|
|
23
|
-
`;
|
|
24
|
-
|
|
25
|
-
exports[`Entities Route > GET /entities > should return 500 when database error occurs 1`] = `
|
|
26
|
-
{
|
|
27
|
-
"error": {
|
|
28
|
-
"code": "INTERNAL_ERROR",
|
|
29
|
-
"message": "Internal server error",
|
|
30
|
-
},
|
|
31
|
-
}
|
|
32
|
-
`;
|
|
33
|
-
|
|
34
|
-
exports[`Entities Route > GET /entities > should return entities with default pagination 1`] = `
|
|
35
|
-
{
|
|
36
|
-
"entities": [
|
|
37
|
-
{
|
|
38
|
-
"access": {
|
|
39
|
-
"content": true,
|
|
40
|
-
"metadata": true,
|
|
41
|
-
},
|
|
42
|
-
"contentLicenseId": "https://creativecommons.org/licenses/by/4.0/",
|
|
43
|
-
"description": "First test entity",
|
|
44
|
-
"entityType": "http://pcdm.org/models#Collection",
|
|
45
|
-
"id": "http://example.com/entity/1",
|
|
46
|
-
"memberOf": null,
|
|
47
|
-
"metadataLicenseId": "https://creativecommons.org/licenses/by/4.0/",
|
|
48
|
-
"name": "Test Entity 1",
|
|
49
|
-
"rootCollection": null,
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
"access": {
|
|
53
|
-
"content": true,
|
|
54
|
-
"metadata": true,
|
|
55
|
-
},
|
|
56
|
-
"contentLicenseId": "https://creativecommons.org/licenses/by/4.0/",
|
|
57
|
-
"description": "Second test entity",
|
|
58
|
-
"entityType": "http://pcdm.org/models#Object",
|
|
59
|
-
"id": "http://example.com/entity/2",
|
|
60
|
-
"memberOf": {
|
|
61
|
-
"id": "http://example.com/entity/1",
|
|
62
|
-
"name": "Test Entity 1",
|
|
63
|
-
},
|
|
64
|
-
"metadataLicenseId": "https://creativecommons.org/licenses/by/4.0/",
|
|
65
|
-
"name": "Test Entity 2",
|
|
66
|
-
"rootCollection": {
|
|
67
|
-
"id": "http://example.com/entity/1",
|
|
68
|
-
"name": "Test Entity 1",
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
],
|
|
72
|
-
"total": 2,
|
|
73
|
-
}
|
|
74
|
-
`;
|
|
75
|
-
|
|
76
|
-
exports[`Entities Route > GET /entities > should return null for memberOf/rootCollection when parent entity not found 1`] = `
|
|
77
|
-
{
|
|
78
|
-
"entities": [
|
|
79
|
-
{
|
|
80
|
-
"access": {
|
|
81
|
-
"content": true,
|
|
82
|
-
"metadata": true,
|
|
83
|
-
},
|
|
84
|
-
"contentLicenseId": "https://creativecommons.org/licenses/by/4.0/",
|
|
85
|
-
"description": "Entity with missing parent",
|
|
86
|
-
"entityType": "http://pcdm.org/models#Object",
|
|
87
|
-
"id": "http://example.com/entity/1",
|
|
88
|
-
"memberOf": null,
|
|
89
|
-
"metadataLicenseId": "https://creativecommons.org/licenses/by/4.0/",
|
|
90
|
-
"name": "Test Entity 1",
|
|
91
|
-
"rootCollection": null,
|
|
92
|
-
},
|
|
93
|
-
],
|
|
94
|
-
"total": 1,
|
|
95
|
-
}
|
|
96
|
-
`;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
-
|
|
3
|
-
exports[`Entity Route > GET /entity/:id > should apply custom entity transformers 1`] = `
|
|
4
|
-
{
|
|
5
|
-
"access": {
|
|
6
|
-
"content": true,
|
|
7
|
-
"metadata": true,
|
|
8
|
-
},
|
|
9
|
-
"contentLicenseId": "https://creativecommons.org/licenses/by/4.0/",
|
|
10
|
-
"description": "A test entity",
|
|
11
|
-
"entityType": "http://pcdm.org/models#Collection",
|
|
12
|
-
"id": "http://example.com/entity/123",
|
|
13
|
-
"memberOf": null,
|
|
14
|
-
"metadataLicenseId": "https://creativecommons.org/licenses/by/4.0/",
|
|
15
|
-
"name": "Test Entity",
|
|
16
|
-
"rootCollection": null,
|
|
17
|
-
"tested": true,
|
|
18
|
-
}
|
|
19
|
-
`;
|
|
20
|
-
|
|
21
|
-
exports[`Entity Route > GET /entity/:id > should return 404 when entity not found 1`] = `
|
|
22
|
-
{
|
|
23
|
-
"error": {
|
|
24
|
-
"code": "NOT_FOUND",
|
|
25
|
-
"details": {
|
|
26
|
-
"entityId": "http://example.com/entity/nonexistent",
|
|
27
|
-
},
|
|
28
|
-
"message": "The requested entity was not found",
|
|
29
|
-
},
|
|
30
|
-
}
|
|
31
|
-
`;
|
|
32
|
-
|
|
33
|
-
exports[`Entity Route > GET /entity/:id > should return 500 when database error occurs 1`] = `
|
|
34
|
-
{
|
|
35
|
-
"error": {
|
|
36
|
-
"code": "INTERNAL_ERROR",
|
|
37
|
-
"message": "Internal server error",
|
|
38
|
-
},
|
|
39
|
-
}
|
|
40
|
-
`;
|
|
41
|
-
|
|
42
|
-
exports[`Entity Route > GET /entity/:id > should return entity when found 1`] = `
|
|
43
|
-
{
|
|
44
|
-
"access": {
|
|
45
|
-
"content": true,
|
|
46
|
-
"metadata": true,
|
|
47
|
-
},
|
|
48
|
-
"contentLicenseId": "https://creativecommons.org/licenses/by/4.0/",
|
|
49
|
-
"description": "A test entity",
|
|
50
|
-
"entityType": "http://schema.org/Person",
|
|
51
|
-
"id": "http://example.com/entity/123",
|
|
52
|
-
"memberOf": null,
|
|
53
|
-
"metadataLicenseId": "https://creativecommons.org/licenses/by/4.0/",
|
|
54
|
-
"name": "Test Entity",
|
|
55
|
-
"rootCollection": null,
|
|
56
|
-
}
|
|
57
|
-
`;
|
|
58
|
-
|
|
59
|
-
exports[`Entity Route > GET /entity/:id > should return null for memberOf/rootCollection when parent entity not found 1`] = `
|
|
60
|
-
{
|
|
61
|
-
"access": {
|
|
62
|
-
"content": true,
|
|
63
|
-
"metadata": true,
|
|
64
|
-
},
|
|
65
|
-
"contentLicenseId": "https://creativecommons.org/licenses/by/4.0/",
|
|
66
|
-
"description": "A test entity",
|
|
67
|
-
"entityType": "http://pcdm.org/models#Object",
|
|
68
|
-
"id": "http://example.com/entity/123",
|
|
69
|
-
"memberOf": null,
|
|
70
|
-
"metadataLicenseId": "https://creativecommons.org/licenses/by/4.0/",
|
|
71
|
-
"name": "Test Entity",
|
|
72
|
-
"rootCollection": null,
|
|
73
|
-
}
|
|
74
|
-
`;
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
-
|
|
3
|
-
exports[`Search Route > POST /search > should apply custom entity transformers 1`] = `
|
|
4
|
-
{
|
|
5
|
-
"entities": [
|
|
6
|
-
{
|
|
7
|
-
"access": {
|
|
8
|
-
"content": true,
|
|
9
|
-
"metadata": true,
|
|
10
|
-
},
|
|
11
|
-
"contentLicenseId": null,
|
|
12
|
-
"description": "A test entity",
|
|
13
|
-
"entityType": "http://pcdm.org/models#Collection",
|
|
14
|
-
"id": "http://example.com/entity/1",
|
|
15
|
-
"memberOf": null,
|
|
16
|
-
"metadataLicenseId": null,
|
|
17
|
-
"name": "Test Entity 1",
|
|
18
|
-
"rootCollection": null,
|
|
19
|
-
"searchExtra": {
|
|
20
|
-
"highlight": {},
|
|
21
|
-
"score": 1.5,
|
|
22
|
-
},
|
|
23
|
-
"tested": true,
|
|
24
|
-
},
|
|
25
|
-
],
|
|
26
|
-
"searchTime": 10,
|
|
27
|
-
"total": 1,
|
|
28
|
-
}
|
|
29
|
-
`;
|
|
30
|
-
|
|
31
|
-
exports[`Search Route > POST /search > should handle id explicitly set to undefined 1`] = `
|
|
32
|
-
{
|
|
33
|
-
"error": {
|
|
34
|
-
"code": "INTERNAL_ERROR",
|
|
35
|
-
"message": "Search failed",
|
|
36
|
-
},
|
|
37
|
-
}
|
|
38
|
-
`;
|
|
39
|
-
|
|
40
|
-
exports[`Search Route > POST /search > should handle opensearch errors 1`] = `
|
|
41
|
-
{
|
|
42
|
-
"error": {
|
|
43
|
-
"code": "INTERNAL_ERROR",
|
|
44
|
-
"message": "Search failed",
|
|
45
|
-
},
|
|
46
|
-
}
|
|
47
|
-
`;
|
|
48
|
-
|
|
49
|
-
exports[`Search Route > POST /search > should perform basic search successfully 1`] = `
|
|
50
|
-
{
|
|
51
|
-
"entities": [
|
|
52
|
-
{
|
|
53
|
-
"access": {
|
|
54
|
-
"content": true,
|
|
55
|
-
"metadata": true,
|
|
56
|
-
},
|
|
57
|
-
"contentLicenseId": null,
|
|
58
|
-
"description": "A test entity",
|
|
59
|
-
"entityType": "http://pcdm.org/models#Collection",
|
|
60
|
-
"id": "http://example.com/entity/1",
|
|
61
|
-
"memberOf": null,
|
|
62
|
-
"metadataLicenseId": null,
|
|
63
|
-
"name": "Test Entity 1",
|
|
64
|
-
"rootCollection": null,
|
|
65
|
-
"searchExtra": {
|
|
66
|
-
"highlight": {
|
|
67
|
-
"name": [
|
|
68
|
-
"<em>Test</em> Entity 1",
|
|
69
|
-
],
|
|
70
|
-
},
|
|
71
|
-
"score": 1.5,
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
"access": {
|
|
76
|
-
"content": true,
|
|
77
|
-
"metadata": true,
|
|
78
|
-
},
|
|
79
|
-
"contentLicenseId": null,
|
|
80
|
-
"description": "Another test entity",
|
|
81
|
-
"entityType": "http://pcdm.org/models#Object",
|
|
82
|
-
"id": "http://example.com/entity/2",
|
|
83
|
-
"memberOf": null,
|
|
84
|
-
"metadataLicenseId": null,
|
|
85
|
-
"name": "Test Entity 2",
|
|
86
|
-
"rootCollection": null,
|
|
87
|
-
"searchExtra": {
|
|
88
|
-
"highlight": {
|
|
89
|
-
"description": [
|
|
90
|
-
"Another <em>test</em> entity",
|
|
91
|
-
],
|
|
92
|
-
},
|
|
93
|
-
"score": 1.2,
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
],
|
|
97
|
-
"facets": {
|
|
98
|
-
"entityType": [
|
|
99
|
-
{
|
|
100
|
-
"count": 1,
|
|
101
|
-
"name": "http://pcdm.org/models#Collection",
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
"count": 1,
|
|
105
|
-
"name": "http://pcdm.org/models#Object",
|
|
106
|
-
},
|
|
107
|
-
],
|
|
108
|
-
},
|
|
109
|
-
"searchTime": 10,
|
|
110
|
-
"total": 2,
|
|
111
|
-
}
|
|
112
|
-
`;
|
|
113
|
-
|
|
114
|
-
exports[`Search Route > POST /search > should return null for memberOf/rootCollection when parent entity not found 1`] = `
|
|
115
|
-
{
|
|
116
|
-
"entities": [
|
|
117
|
-
{
|
|
118
|
-
"access": {
|
|
119
|
-
"content": true,
|
|
120
|
-
"metadata": true,
|
|
121
|
-
},
|
|
122
|
-
"contentLicenseId": "https://creativecommons.org/licenses/by/4.0/",
|
|
123
|
-
"description": "Entity with missing parent",
|
|
124
|
-
"entityType": "http://pcdm.org/models#Object",
|
|
125
|
-
"id": "http://example.com/entity/1",
|
|
126
|
-
"memberOf": null,
|
|
127
|
-
"metadataLicenseId": "https://creativecommons.org/licenses/by/4.0/",
|
|
128
|
-
"name": "Test Entity 1",
|
|
129
|
-
"rootCollection": null,
|
|
130
|
-
"searchExtra": {
|
|
131
|
-
"score": 1.5,
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
],
|
|
135
|
-
"searchTime": 10,
|
|
136
|
-
"total": 1,
|
|
137
|
-
}
|
|
138
|
-
`;
|
|
139
|
-
|
|
140
|
-
exports[`Search Route > POST /search > should skip entities not found in database and log warning 1`] = `
|
|
141
|
-
{
|
|
142
|
-
"entities": [
|
|
143
|
-
{
|
|
144
|
-
"access": {
|
|
145
|
-
"content": true,
|
|
146
|
-
"metadata": true,
|
|
147
|
-
},
|
|
148
|
-
"contentLicenseId": null,
|
|
149
|
-
"description": "A test entity",
|
|
150
|
-
"entityType": "http://pcdm.org/models#Collection",
|
|
151
|
-
"id": "http://example.com/entity/1",
|
|
152
|
-
"memberOf": null,
|
|
153
|
-
"metadataLicenseId": null,
|
|
154
|
-
"name": "Test Entity 1",
|
|
155
|
-
"rootCollection": null,
|
|
156
|
-
"searchExtra": {
|
|
157
|
-
"highlight": {},
|
|
158
|
-
"score": 1.5,
|
|
159
|
-
},
|
|
160
|
-
},
|
|
161
|
-
],
|
|
162
|
-
"searchTime": 10,
|
|
163
|
-
"total": 2,
|
|
164
|
-
}
|
|
165
|
-
`;
|