arocapi 5.0.0-beta.5 → 5.0.0-beta.6
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 +2 -2
- package/dist/app.d.ts +19 -13
- package/dist/app.js +13 -10
- package/dist/app.js.map +1 -1
- package/dist/routes/capabilities.d.ts +2 -2
- package/dist/routes/capabilities.js +2 -2
- package/dist/routes/capabilities.js.map +1 -1
- package/dist/routes/entities.js +8 -9
- package/dist/routes/entities.js.map +1 -1
- package/dist/routes/search.d.ts +2 -4
- package/dist/routes/search.js +75 -97
- 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/types/visibility.d.ts +3 -2
- package/dist/utils/visibility.js +1 -1
- package/dist/utils/visibility.js.map +1 -1
- package/package.json +46 -26
- 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 +53 -24
- package/src/routes/capabilities.ts +4 -4
- package/src/routes/entities.ts +10 -9
- package/src/routes/search.ts +104 -118
- 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/types/visibility.ts +6 -3
- package/src/utils/visibility.ts +1 -1
- package/dist/app.test.d.ts +0 -1
- package/dist/app.test.js +0 -67
- package/dist/app.test.js.map +0 -1
- package/dist/errorHandling.test.d.ts +0 -1
- package/dist/errorHandling.test.js +0 -222
- package/dist/errorHandling.test.js.map +0 -1
- package/dist/index.dev.d.ts +0 -1
- package/dist/index.dev.js +0 -157
- package/dist/index.dev.js.map +0 -1
- package/dist/routes/capabilities.test.d.ts +0 -1
- package/dist/routes/capabilities.test.js +0 -81
- package/dist/routes/capabilities.test.js.map +0 -1
- package/dist/routes/crate.test.d.ts +0 -1
- package/dist/routes/crate.test.js +0 -390
- 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 -277
- 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 -136
- 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 -435
- 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 -245
- 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 -833
- 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 -17
- package/dist/test/helpers/fastify.js.map +0 -1
- package/dist/test/integration.setup.d.ts +0 -47
- package/dist/test/integration.setup.js +0 -195
- 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 -762
- 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 -225
- 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 -165
- package/dist/transformers/transformer.test.js.map +0 -1
- package/dist/utils/errors.test.d.ts +0 -1
- package/dist/utils/errors.test.js +0 -79
- package/dist/utils/errors.test.js.map +0 -1
- package/dist/utils/queryBuilder.d.ts +0 -47
- package/dist/utils/queryBuilder.js +0 -107
- package/dist/utils/queryBuilder.js.map +0 -1
- package/prisma.config.ts +0 -9
- package/src/app.test.ts +0 -91
- package/src/errorHandling.test.ts +0 -288
- package/src/index.dev.ts +0 -202
- package/src/reset.d.ts +0 -1
- package/src/routes/__snapshots__/capabilities.test.ts.snap +0 -34
- 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/capabilities.test.ts +0 -102
- package/src/routes/crate.test.ts +0 -484
- package/src/routes/entities.test.ts +0 -324
- package/src/routes/entity.test.ts +0 -166
- package/src/routes/file.test.ts +0 -538
- package/src/routes/files.test.ts +0 -304
- package/src/routes/search.test.ts +0 -959
- package/src/test/__snapshots__/integration.test.ts.snap +0 -18
- package/src/test/helpers/fastify.ts +0 -26
- package/src/test/integration.setup.ts +0 -220
- package/src/test/integration.test.ts +0 -953
- package/src/transformers/default.test.ts +0 -276
- package/src/transformers/transformer.test.ts +0 -226
- package/src/utils/errors.test.ts +0 -90
- package/src/utils/queryBuilder.ts +0 -157
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
-
|
|
3
|
-
exports[`Integration Tests > GET /entity/:id > should return entity from database 1`] = `
|
|
4
|
-
{
|
|
5
|
-
"access": {
|
|
6
|
-
"content": true,
|
|
7
|
-
"metadata": true,
|
|
8
|
-
},
|
|
9
|
-
"contentLicenseId": "https://creativecommons.org/licenses/by/4.0/",
|
|
10
|
-
"description": "First test entity",
|
|
11
|
-
"entityType": "http://pcdm.org/models#Collection",
|
|
12
|
-
"id": "http://example.com/entity/1",
|
|
13
|
-
"memberOf": null,
|
|
14
|
-
"metadataLicenseId": "https://creativecommons.org/licenses/by/4.0/",
|
|
15
|
-
"name": "Test Collection",
|
|
16
|
-
"rootCollection": null,
|
|
17
|
-
}
|
|
18
|
-
`;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { Client } from '@opensearch-project/opensearch';
|
|
2
|
-
import type { FastifyInstance } from 'fastify';
|
|
3
|
-
import Fastify from 'fastify';
|
|
4
|
-
import { mockDeep, mockReset } from 'vitest-mock-extended';
|
|
5
|
-
|
|
6
|
-
import type { PrismaClient } from '../../generated/prisma/client.js';
|
|
7
|
-
import { setupValidation } from '../../utils/validation.js';
|
|
8
|
-
|
|
9
|
-
export let fastify: FastifyInstance;
|
|
10
|
-
export const prisma = mockDeep<PrismaClient>();
|
|
11
|
-
export const opensearch = mockDeep<Client>();
|
|
12
|
-
|
|
13
|
-
export const fastifyBefore = async () => {
|
|
14
|
-
mockReset(prisma);
|
|
15
|
-
mockReset(opensearch);
|
|
16
|
-
|
|
17
|
-
fastify = Fastify({ logger: false });
|
|
18
|
-
|
|
19
|
-
setupValidation(fastify);
|
|
20
|
-
|
|
21
|
-
return fastify;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const fastifyAfter = async () => {
|
|
25
|
-
await fastify.close();
|
|
26
|
-
};
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
import { Client } from '@opensearch-project/opensearch';
|
|
2
|
-
import { PrismaMariaDb } from '@prisma/adapter-mariadb';
|
|
3
|
-
import type { FastifyInstance } from 'fastify';
|
|
4
|
-
import Fastify from 'fastify';
|
|
5
|
-
import type { Options } from '../app.js';
|
|
6
|
-
import app, { AllPublicAccess, AllVisibleEntityFilter, AllVisibleSearchFilter } from '../app.js';
|
|
7
|
-
import { PrismaClient } from '../generated/prisma/client.js';
|
|
8
|
-
|
|
9
|
-
let fastify: FastifyInstance;
|
|
10
|
-
let prisma: PrismaClient;
|
|
11
|
-
let opensearch: Client;
|
|
12
|
-
|
|
13
|
-
export const getTestApp = () => fastify;
|
|
14
|
-
|
|
15
|
-
export async function setupIntegrationTests() {
|
|
16
|
-
process.env.DATABASE_URL = 'mysql://root:password@localhost:3307/catalog_test';
|
|
17
|
-
process.env.OPENSEARCH_URL = 'http://localhost:9201';
|
|
18
|
-
process.env.NODE_ENV = 'test';
|
|
19
|
-
|
|
20
|
-
const adapter = new PrismaMariaDb({
|
|
21
|
-
host: 'localhost',
|
|
22
|
-
user: 'root',
|
|
23
|
-
password: 'password',
|
|
24
|
-
database: 'catalog_test',
|
|
25
|
-
port: 3307,
|
|
26
|
-
connectionLimit: 5,
|
|
27
|
-
// 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.
|
|
28
|
-
allowPublicKeyRetrieval: true,
|
|
29
|
-
});
|
|
30
|
-
prisma = new PrismaClient({ adapter });
|
|
31
|
-
|
|
32
|
-
opensearch = new Client({
|
|
33
|
-
node: process.env.OPENSEARCH_URL,
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
fastify = await buildTestApp();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export async function buildTestApp(overrides: Partial<Options> = {}) {
|
|
40
|
-
const instance = Fastify({ logger: false });
|
|
41
|
-
|
|
42
|
-
await instance.register(app, {
|
|
43
|
-
prisma,
|
|
44
|
-
opensearch,
|
|
45
|
-
access: AllPublicAccess,
|
|
46
|
-
entityVisibilityFilter: AllVisibleEntityFilter,
|
|
47
|
-
searchVisibilityFilter: AllVisibleSearchFilter,
|
|
48
|
-
fileHandler: {
|
|
49
|
-
get: async () => {
|
|
50
|
-
throw new Error('File handler not implemented in integration tests');
|
|
51
|
-
},
|
|
52
|
-
head: async () => {
|
|
53
|
-
throw new Error('File handler not implemented in integration tests');
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
roCrateHandler: {
|
|
57
|
-
get: async () => {
|
|
58
|
-
throw new Error('RO-Crate handler not implemented in integration tests');
|
|
59
|
-
},
|
|
60
|
-
head: async () => {
|
|
61
|
-
throw new Error('RO-Crate head handler not implemented in integration tests');
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
...overrides,
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
await instance.ready();
|
|
68
|
-
|
|
69
|
-
return instance;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export async function teardownIntegrationTests() {
|
|
73
|
-
await cleanupTestData();
|
|
74
|
-
|
|
75
|
-
await fastify.close();
|
|
76
|
-
await prisma.$disconnect();
|
|
77
|
-
opensearch.close();
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export async function cleanupTestData() {
|
|
81
|
-
await prisma.file.deleteMany({});
|
|
82
|
-
await prisma.entity.deleteMany({});
|
|
83
|
-
|
|
84
|
-
await opensearch.indices.delete({
|
|
85
|
-
index: 'entities',
|
|
86
|
-
ignore_unavailable: true,
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export async function seedTestData() {
|
|
91
|
-
await cleanupTestData();
|
|
92
|
-
|
|
93
|
-
const testEntities = [
|
|
94
|
-
{
|
|
95
|
-
id: 'http://example.com/entity/1',
|
|
96
|
-
name: 'Test Collection',
|
|
97
|
-
description: 'First test entity',
|
|
98
|
-
entityType: 'http://pcdm.org/models#Collection',
|
|
99
|
-
memberOf: null,
|
|
100
|
-
rootCollection: null,
|
|
101
|
-
metadataLicenseId: 'https://creativecommons.org/licenses/by/4.0/',
|
|
102
|
-
contentLicenseId: 'https://creativecommons.org/licenses/by/4.0/',
|
|
103
|
-
createdAt: new Date(),
|
|
104
|
-
updatedAt: new Date(),
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
id: 'http://example.com/entity/2',
|
|
108
|
-
name: 'Test Object',
|
|
109
|
-
description: 'Second test entity',
|
|
110
|
-
entityType: 'http://pcdm.org/models#Object',
|
|
111
|
-
memberOf: 'http://example.com/entity/1',
|
|
112
|
-
rootCollection: 'http://example.com/entity/1',
|
|
113
|
-
metadataLicenseId: 'https://creativecommons.org/licenses/by/4.0/',
|
|
114
|
-
contentLicenseId: 'https://creativecommons.org/licenses/by/4.0/',
|
|
115
|
-
meta: { draft: true },
|
|
116
|
-
createdAt: new Date(),
|
|
117
|
-
updatedAt: new Date(),
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
id: 'http://example.com/entity/3',
|
|
121
|
-
name: 'Test Person',
|
|
122
|
-
description: 'Third test entity',
|
|
123
|
-
entityType: 'http://schema.org/Person',
|
|
124
|
-
memberOf: 'http://example.com/entity/1',
|
|
125
|
-
rootCollection: 'http://example.com/entity/1',
|
|
126
|
-
metadataLicenseId: 'https://creativecommons.org/licenses/by/4.0/',
|
|
127
|
-
contentLicenseId: 'https://creativecommons.org/licenses/by/4.0/',
|
|
128
|
-
createdAt: new Date(),
|
|
129
|
-
updatedAt: new Date(),
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
id: 'http://example.com/entity/4',
|
|
133
|
-
name: 'test-audio.wav',
|
|
134
|
-
description: 'Test audio file',
|
|
135
|
-
entityType: 'http://schema.org/MediaObject',
|
|
136
|
-
memberOf: 'http://example.com/entity/2',
|
|
137
|
-
rootCollection: 'http://example.com/entity/1',
|
|
138
|
-
metadataLicenseId: 'https://creativecommons.org/licenses/by/4.0/',
|
|
139
|
-
contentLicenseId: 'https://example.com/licences/restricted',
|
|
140
|
-
createdAt: new Date(),
|
|
141
|
-
updatedAt: new Date(),
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
id: 'http://example.com/entity/5',
|
|
145
|
-
name: 'collection-metadata.csv',
|
|
146
|
-
description: 'Collection metadata file',
|
|
147
|
-
entityType: 'http://schema.org/MediaObject',
|
|
148
|
-
memberOf: 'http://example.com/entity/1',
|
|
149
|
-
rootCollection: 'http://example.com/entity/1',
|
|
150
|
-
metadataLicenseId: 'https://creativecommons.org/licenses/by/4.0/',
|
|
151
|
-
contentLicenseId: 'https://creativecommons.org/licenses/by/4.0/',
|
|
152
|
-
meta: { draft: true },
|
|
153
|
-
createdAt: new Date(),
|
|
154
|
-
updatedAt: new Date(),
|
|
155
|
-
},
|
|
156
|
-
];
|
|
157
|
-
|
|
158
|
-
await prisma.entity.createMany({
|
|
159
|
-
data: testEntities,
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
const testFiles = [
|
|
163
|
-
{
|
|
164
|
-
id: 'http://example.com/entity/4',
|
|
165
|
-
filename: 'test-audio.wav',
|
|
166
|
-
mediaType: 'audio/wav',
|
|
167
|
-
size: BigInt(2048),
|
|
168
|
-
meta: {},
|
|
169
|
-
createdAt: new Date(),
|
|
170
|
-
updatedAt: new Date(),
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
id: 'http://example.com/entity/5',
|
|
174
|
-
filename: 'collection-metadata.csv',
|
|
175
|
-
mediaType: 'text/csv',
|
|
176
|
-
size: BigInt(512),
|
|
177
|
-
meta: {},
|
|
178
|
-
createdAt: new Date(),
|
|
179
|
-
updatedAt: new Date(),
|
|
180
|
-
},
|
|
181
|
-
];
|
|
182
|
-
|
|
183
|
-
await prisma.file.createMany({
|
|
184
|
-
data: testFiles,
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
await opensearch.indices.create({
|
|
188
|
-
index: 'entities',
|
|
189
|
-
body: {
|
|
190
|
-
mappings: {
|
|
191
|
-
properties: {
|
|
192
|
-
id: { type: 'keyword' },
|
|
193
|
-
name: {
|
|
194
|
-
type: 'text',
|
|
195
|
-
fields: {
|
|
196
|
-
keyword: { type: 'keyword' },
|
|
197
|
-
},
|
|
198
|
-
},
|
|
199
|
-
description: { type: 'text' },
|
|
200
|
-
entityType: { type: 'keyword' },
|
|
201
|
-
memberOf: { type: 'keyword' },
|
|
202
|
-
rootCollection: { type: 'keyword' },
|
|
203
|
-
location: { type: 'geo_point' },
|
|
204
|
-
inLanguage: { type: 'keyword' },
|
|
205
|
-
mediaType: { type: 'keyword' },
|
|
206
|
-
communicationMode: { type: 'keyword' },
|
|
207
|
-
},
|
|
208
|
-
},
|
|
209
|
-
},
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
const testDocs = testEntities.flatMap((entity) => [{ index: { _index: 'entities', _id: entity.id } }, entity]);
|
|
213
|
-
|
|
214
|
-
await opensearch.bulk({
|
|
215
|
-
body: testDocs,
|
|
216
|
-
refresh: true,
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
return testEntities;
|
|
220
|
-
}
|