arocapi 5.0.0-beta.5 → 5.0.0-beta.7

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.
Files changed (205) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +2 -2
  3. package/dist/app.d.ts +22 -17
  4. package/dist/app.js +22 -16
  5. package/dist/app.js.map +1 -1
  6. package/dist/routes/capabilities.d.ts +2 -2
  7. package/dist/routes/capabilities.js +2 -2
  8. package/dist/routes/capabilities.js.map +1 -1
  9. package/dist/routes/entities.js +8 -9
  10. package/dist/routes/entities.js.map +1 -1
  11. package/dist/routes/file.d.ts +2 -2
  12. package/dist/routes/file.js +25 -72
  13. package/dist/routes/file.js.map +1 -1
  14. package/dist/routes/metadata.d.ts +5 -5
  15. package/dist/routes/metadata.js +22 -61
  16. package/dist/routes/metadata.js.map +1 -1
  17. package/dist/routes/search.d.ts +2 -4
  18. package/dist/routes/search.js +75 -97
  19. package/dist/routes/search.js.map +1 -1
  20. package/dist/search/advanced.d.ts +8 -0
  21. package/dist/search/advanced.js +198 -0
  22. package/dist/search/advanced.js.map +1 -0
  23. package/dist/search/backend.d.ts +95 -0
  24. package/dist/search/backend.js +5 -0
  25. package/dist/search/backend.js.map +1 -0
  26. package/dist/search/fields.d.ts +63 -0
  27. package/dist/search/fields.js +203 -0
  28. package/dist/search/fields.js.map +1 -0
  29. package/dist/search/opensearch/advanced.d.ts +4 -0
  30. package/dist/search/opensearch/advanced.js +28 -0
  31. package/dist/search/opensearch/advanced.js.map +1 -0
  32. package/dist/search/opensearch/opensearch.d.ts +16 -0
  33. package/dist/search/opensearch/opensearch.js +187 -0
  34. package/dist/search/opensearch/opensearch.js.map +1 -0
  35. package/dist/search/opensearch/visibility.d.ts +3 -0
  36. package/dist/search/opensearch/visibility.js +27 -0
  37. package/dist/search/opensearch/visibility.js.map +1 -0
  38. package/dist/search/postgres/advanced.d.ts +7 -0
  39. package/dist/search/postgres/advanced.js +54 -0
  40. package/dist/search/postgres/advanced.js.map +1 -0
  41. package/dist/search/postgres/facets.d.ts +2 -0
  42. package/dist/search/postgres/facets.js +27 -0
  43. package/dist/search/postgres/facets.js.map +1 -0
  44. package/dist/search/postgres/geo.d.ts +6 -0
  45. package/dist/search/postgres/geo.js +42 -0
  46. package/dist/search/postgres/geo.js.map +1 -0
  47. package/dist/search/postgres/postgres.d.ts +19 -0
  48. package/dist/search/postgres/postgres.js +157 -0
  49. package/dist/search/postgres/postgres.js.map +1 -0
  50. package/dist/search/postgres/values.d.ts +8 -0
  51. package/dist/search/postgres/values.js +20 -0
  52. package/dist/search/postgres/values.js.map +1 -0
  53. package/dist/search/postgres/visibility.d.ts +4 -0
  54. package/dist/search/postgres/visibility.js +38 -0
  55. package/dist/search/postgres/visibility.js.map +1 -0
  56. package/dist/search/requestFilters.d.ts +39 -0
  57. package/dist/search/requestFilters.js +125 -0
  58. package/dist/search/requestFilters.js.map +1 -0
  59. package/dist/search/visibility.d.ts +51 -0
  60. package/dist/search/visibility.js +100 -0
  61. package/dist/search/visibility.js.map +1 -0
  62. package/dist/storage/backend.d.ts +58 -0
  63. package/dist/storage/backend.js +2 -0
  64. package/dist/storage/backend.js.map +1 -0
  65. package/dist/storage/deliver.d.ts +12 -0
  66. package/dist/storage/deliver.js +34 -0
  67. package/dist/storage/deliver.js.map +1 -0
  68. package/dist/storage/directory/directory.d.ts +6 -0
  69. package/dist/storage/directory/directory.js +24 -0
  70. package/dist/storage/directory/directory.js.map +1 -0
  71. package/dist/storage/entity-meta/entity-meta.d.ts +5 -0
  72. package/dist/storage/entity-meta/entity-meta.js +14 -0
  73. package/dist/storage/entity-meta/entity-meta.js.map +1 -0
  74. package/dist/storage/location.d.ts +20 -0
  75. package/dist/storage/location.js +40 -0
  76. package/dist/storage/location.js.map +1 -0
  77. package/dist/storage/ocfl/ocfl.d.ts +7 -0
  78. package/dist/storage/ocfl/ocfl.js +79 -0
  79. package/dist/storage/ocfl/ocfl.js.map +1 -0
  80. package/dist/storage/ocfl/ocflFs.d.ts +7 -0
  81. package/dist/storage/ocfl/ocflFs.js +33 -0
  82. package/dist/storage/ocfl/ocflFs.js.map +1 -0
  83. package/dist/storage/results.d.ts +7 -0
  84. package/dist/storage/results.js +22 -0
  85. package/dist/storage/results.js.map +1 -0
  86. package/dist/storage/s3/s3.d.ts +10 -0
  87. package/dist/storage/s3/s3.js +47 -0
  88. package/dist/storage/s3/s3.js.map +1 -0
  89. package/dist/types/visibility.d.ts +3 -2
  90. package/dist/utils/visibility.js +1 -1
  91. package/dist/utils/visibility.js.map +1 -1
  92. package/package.json +66 -26
  93. package/prisma/models/entity.prisma +9 -8
  94. package/prisma/models/entitySearch.prisma +21 -0
  95. package/prisma/models/file.prisma +3 -3
  96. package/src/app.ts +85 -48
  97. package/src/routes/capabilities.ts +4 -4
  98. package/src/routes/entities.ts +10 -9
  99. package/src/routes/file.ts +23 -99
  100. package/src/routes/metadata.ts +24 -86
  101. package/src/routes/search.ts +104 -118
  102. package/src/search/advanced.ts +258 -0
  103. package/src/search/backend.ts +91 -0
  104. package/src/search/fields.ts +320 -0
  105. package/src/search/opensearch/advanced.ts +36 -0
  106. package/src/search/opensearch/opensearch.ts +290 -0
  107. package/src/search/opensearch/visibility.ts +38 -0
  108. package/src/search/postgres/advanced.ts +76 -0
  109. package/src/search/postgres/facets.ts +34 -0
  110. package/src/search/postgres/geo.ts +58 -0
  111. package/src/search/postgres/postgres.ts +232 -0
  112. package/src/search/postgres/values.ts +33 -0
  113. package/src/search/postgres/visibility.ts +54 -0
  114. package/src/search/requestFilters.ts +178 -0
  115. package/src/search/visibility.ts +193 -0
  116. package/src/storage/backend.ts +75 -0
  117. package/src/storage/deliver.ts +65 -0
  118. package/src/storage/directory/directory.ts +39 -0
  119. package/src/storage/entity-meta/entity-meta.ts +25 -0
  120. package/src/storage/location.ts +85 -0
  121. package/src/storage/ocfl/ocfl.ts +129 -0
  122. package/src/storage/ocfl/ocflFs.ts +67 -0
  123. package/src/storage/results.ts +32 -0
  124. package/src/storage/s3/s3.ts +79 -0
  125. package/src/types/visibility.ts +6 -3
  126. package/src/utils/visibility.ts +1 -1
  127. package/dist/app.test.d.ts +0 -1
  128. package/dist/app.test.js +0 -67
  129. package/dist/app.test.js.map +0 -1
  130. package/dist/errorHandling.test.d.ts +0 -1
  131. package/dist/errorHandling.test.js +0 -222
  132. package/dist/errorHandling.test.js.map +0 -1
  133. package/dist/index.dev.d.ts +0 -1
  134. package/dist/index.dev.js +0 -157
  135. package/dist/index.dev.js.map +0 -1
  136. package/dist/routes/capabilities.test.d.ts +0 -1
  137. package/dist/routes/capabilities.test.js +0 -81
  138. package/dist/routes/capabilities.test.js.map +0 -1
  139. package/dist/routes/crate.test.d.ts +0 -1
  140. package/dist/routes/crate.test.js +0 -390
  141. package/dist/routes/crate.test.js.map +0 -1
  142. package/dist/routes/entities.test.d.ts +0 -1
  143. package/dist/routes/entities.test.js +0 -277
  144. package/dist/routes/entities.test.js.map +0 -1
  145. package/dist/routes/entity.test.d.ts +0 -1
  146. package/dist/routes/entity.test.js +0 -136
  147. package/dist/routes/entity.test.js.map +0 -1
  148. package/dist/routes/file.test.d.ts +0 -1
  149. package/dist/routes/file.test.js +0 -435
  150. package/dist/routes/file.test.js.map +0 -1
  151. package/dist/routes/files.test.d.ts +0 -1
  152. package/dist/routes/files.test.js +0 -245
  153. package/dist/routes/files.test.js.map +0 -1
  154. package/dist/routes/search.test.d.ts +0 -1
  155. package/dist/routes/search.test.js +0 -833
  156. package/dist/routes/search.test.js.map +0 -1
  157. package/dist/test/helpers/fastify.d.ts +0 -9
  158. package/dist/test/helpers/fastify.js +0 -17
  159. package/dist/test/helpers/fastify.js.map +0 -1
  160. package/dist/test/integration.setup.d.ts +0 -47
  161. package/dist/test/integration.setup.js +0 -195
  162. package/dist/test/integration.setup.js.map +0 -1
  163. package/dist/test/integration.test.d.ts +0 -1
  164. package/dist/test/integration.test.js +0 -762
  165. package/dist/test/integration.test.js.map +0 -1
  166. package/dist/transformers/default.test.d.ts +0 -1
  167. package/dist/transformers/default.test.js +0 -225
  168. package/dist/transformers/default.test.js.map +0 -1
  169. package/dist/transformers/transformer.test.d.ts +0 -1
  170. package/dist/transformers/transformer.test.js +0 -165
  171. package/dist/transformers/transformer.test.js.map +0 -1
  172. package/dist/types/fileHandlers.d.ts +0 -37
  173. package/dist/types/fileHandlers.js +0 -2
  174. package/dist/types/fileHandlers.js.map +0 -1
  175. package/dist/utils/errors.test.d.ts +0 -1
  176. package/dist/utils/errors.test.js +0 -79
  177. package/dist/utils/errors.test.js.map +0 -1
  178. package/dist/utils/queryBuilder.d.ts +0 -47
  179. package/dist/utils/queryBuilder.js +0 -107
  180. package/dist/utils/queryBuilder.js.map +0 -1
  181. package/prisma.config.ts +0 -9
  182. package/src/app.test.ts +0 -91
  183. package/src/errorHandling.test.ts +0 -288
  184. package/src/index.dev.ts +0 -202
  185. package/src/reset.d.ts +0 -1
  186. package/src/routes/__snapshots__/capabilities.test.ts.snap +0 -34
  187. package/src/routes/__snapshots__/entities.test.ts.snap +0 -96
  188. package/src/routes/__snapshots__/entity.test.ts.snap +0 -74
  189. package/src/routes/__snapshots__/search.test.ts.snap +0 -165
  190. package/src/routes/capabilities.test.ts +0 -102
  191. package/src/routes/crate.test.ts +0 -484
  192. package/src/routes/entities.test.ts +0 -324
  193. package/src/routes/entity.test.ts +0 -166
  194. package/src/routes/file.test.ts +0 -538
  195. package/src/routes/files.test.ts +0 -304
  196. package/src/routes/search.test.ts +0 -959
  197. package/src/test/__snapshots__/integration.test.ts.snap +0 -18
  198. package/src/test/helpers/fastify.ts +0 -26
  199. package/src/test/integration.setup.ts +0 -220
  200. package/src/test/integration.test.ts +0 -953
  201. package/src/transformers/default.test.ts +0 -276
  202. package/src/transformers/transformer.test.ts +0 -226
  203. package/src/types/fileHandlers.ts +0 -57
  204. package/src/utils/errors.test.ts +0 -90
  205. 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
- }