@tstdl/base 0.93.4 → 0.93.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/api/server/gateway.js
CHANGED
|
@@ -186,14 +186,14 @@ let ApiGateway = ApiGateway_1 = class ApiGateway {
|
|
|
186
186
|
parameters: validatedParameters,
|
|
187
187
|
body,
|
|
188
188
|
request: context.request,
|
|
189
|
-
async
|
|
189
|
+
tryGetToken: async () => {
|
|
190
190
|
return await requestTokenProvider.tryGetToken(requestContext);
|
|
191
191
|
},
|
|
192
|
-
async
|
|
192
|
+
getToken: async () => {
|
|
193
193
|
return await requestTokenProvider.getToken(requestContext);
|
|
194
194
|
},
|
|
195
|
-
async
|
|
196
|
-
const token = await
|
|
195
|
+
getAuditor: async () => {
|
|
196
|
+
const token = await requestContext.tryGetToken();
|
|
197
197
|
return auditor.fork(context.api.resource)
|
|
198
198
|
.withCorrelation()
|
|
199
199
|
.with({
|
|
@@ -220,7 +220,21 @@ let ApiGateway = ApiGateway_1 = class ApiGateway {
|
|
|
220
220
|
.when(isBlob, (value) => ({ stream: value.stream() }))
|
|
221
221
|
.when((isReadableStream), (stream) => ({ stream }))
|
|
222
222
|
.when((value) => value instanceof ServerSentEventsSource, (events) => ({ events }))
|
|
223
|
-
.when(() => (context.endpoint.definition.result == DataStream), (value) =>
|
|
223
|
+
.when(() => (context.endpoint.definition.result == DataStream), (value) => {
|
|
224
|
+
const logger = this.#logger;
|
|
225
|
+
async function* iterableWithError() {
|
|
226
|
+
try {
|
|
227
|
+
for await (const item of value) {
|
|
228
|
+
yield item;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
catch (error) {
|
|
232
|
+
logger.error(error);
|
|
233
|
+
throw error;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return ({ events: DataStreamSource.fromIterable(iterableWithError()).eventSource });
|
|
237
|
+
})
|
|
224
238
|
.when(() => (context.endpoint.definition.result == String), (text) => ({ text: text }))
|
|
225
239
|
.otherwise((json) => ({ json }));
|
|
226
240
|
}
|
|
@@ -9,6 +9,7 @@ var DocumentManagementService_1;
|
|
|
9
9
|
import { and, eq } from 'drizzle-orm';
|
|
10
10
|
import { union } from 'drizzle-orm/pg-core';
|
|
11
11
|
import { Enumerable } from '../../../enumerable/index.js';
|
|
12
|
+
import { BadRequestError } from '../../../errors/bad-request.error.js';
|
|
12
13
|
import { inject } from '../../../injector/index.js';
|
|
13
14
|
import { Logger } from '../../../logger/logger.js';
|
|
14
15
|
import { Transactional, injectRepository, injectTransactional } from '../../../orm/server/index.js';
|
|
@@ -87,6 +88,9 @@ let DocumentManagementService = DocumentManagementService_1 = class DocumentMana
|
|
|
87
88
|
}
|
|
88
89
|
}
|
|
89
90
|
async loadData(tenantId, collectionIds) {
|
|
91
|
+
if (collectionIds.length == 0) {
|
|
92
|
+
throw new BadRequestError('At least one collection ID must be provided to load document management data.');
|
|
93
|
+
}
|
|
90
94
|
return await this.transaction(async (tx) => {
|
|
91
95
|
const [collections, documentCollectionAssignments, requestAssignments, assignmentScopes, { categories, types }] = await Promise.all([
|
|
92
96
|
this.#documentCollectionService.repository.withTransaction(tx).loadManyByQuery({ tenantId, id: { $in: collectionIds } }),
|