@tstdl/base 0.92.130 → 0.92.132
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/ai/ai.service.js +4 -4
- package/api/server/api-controller.js +1 -2
- package/document-management/api/document-management.api.d.ts +9 -37
- package/document-management/api/document-management.api.js +9 -18
- package/document-management/models/document-request-collection-assignment.model.d.ts +7 -0
- package/document-management/models/{document-request-collection.model.js → document-request-collection-assignment.model.js} +6 -6
- package/document-management/models/index.d.ts +1 -1
- package/document-management/models/index.js +1 -1
- package/document-management/server/api/document-management.api.d.ts +26 -0
- package/document-management/server/api/document-management.api.js +169 -0
- package/document-management/server/api/index.d.ts +1 -0
- package/document-management/server/api/index.js +1 -0
- package/document-management/server/drizzle/{0000_cool_victor_mancha.sql → 0000_magical_madame_hydra.sql} +128 -96
- package/document-management/server/drizzle/meta/0000_snapshot.json +768 -492
- package/document-management/server/drizzle/meta/_journal.json +2 -9
- package/document-management/server/index.d.ts +1 -0
- package/document-management/server/index.js +1 -0
- package/document-management/server/schemas.d.ts +3 -2
- package/document-management/server/schemas.js +3 -2
- package/document-management/server/services/document-category-type.service.d.ts +2 -0
- package/document-management/server/services/document-category-type.service.js +26 -15
- package/document-management/server/services/document-collection.service.js +13 -2
- package/document-management/server/services/document-file.service.js +15 -4
- package/document-management/server/services/document-management-ai.service.js +19 -8
- package/document-management/server/services/document-management-ancillary.service.d.ts +21 -40
- package/document-management/server/services/document-management-ancillary.service.js +25 -14
- package/document-management/server/services/document-management.service.d.ts +1 -1
- package/document-management/server/services/document-management.service.js +53 -34
- package/document-management/server/services/document-property.service.d.ts +2 -34
- package/document-management/server/services/document-property.service.js +20 -8
- package/document-management/server/services/document-request.service.js +11 -11
- package/document-management/server/services/document-validation.service.js +15 -4
- package/document-management/server/services/document-workflow.service.js +27 -16
- package/document-management/server/services/document.service.d.ts +8 -2
- package/document-management/server/services/document.service.js +47 -7
- package/document-management/server/services/index.d.ts +1 -0
- package/document-management/server/services/index.js +1 -0
- package/document-management/server/services/singleton.d.ts +4 -0
- package/document-management/server/services/singleton.js +12 -0
- package/document-management/service-models/enriched/enriched-document-management-data.view.d.ts +2 -1
- package/document-management/service-models/enriched/enriched-document-management-data.view.js +10 -2
- package/eslint.config.js +1 -0
- package/examples/document-management/categories-and-types.d.ts +324 -0
- package/examples/document-management/categories-and-types.js +363 -0
- package/examples/document-management/main.d.ts +7 -8
- package/examples/document-management/main.js +86 -27
- package/injector/decorators.d.ts +1 -0
- package/injector/decorators.js +41 -12
- package/injector/inject.d.ts +12 -2
- package/injector/injector.d.ts +3 -2
- package/injector/injector.js +87 -36
- package/injector/symbols.d.ts +1 -0
- package/injector/symbols.js +1 -0
- package/module/modules/web-server.module.js +4 -4
- package/orm/server/database.d.ts +0 -4
- package/orm/server/database.js +0 -4
- package/orm/server/drizzle/schema-converter.js +5 -4
- package/orm/server/module.d.ts +0 -4
- package/orm/server/module.js +0 -2
- package/orm/server/query-converter.js +11 -38
- package/orm/server/repository.d.ts +3 -2
- package/orm/server/repository.js +2 -2
- package/orm/server/transaction.d.ts +5 -4
- package/orm/server/transaction.js +8 -3
- package/orm/server/transactional.js +3 -3
- package/orm/sqls.d.ts +4 -1
- package/orm/sqls.js +4 -1
- package/package.json +4 -4
- package/reflection/registry.js +6 -6
- package/document-management/models/document-request-collection.model.d.ts +0 -7
- package/document-management/server/drizzle/0001_concerned_quentin_quire.sql +0 -2
- package/document-management/server/drizzle/meta/0001_snapshot.json +0 -1932
package/ai/ai.service.js
CHANGED
|
@@ -58,10 +58,10 @@ let AiService = AiService_1 = class AiService {
|
|
|
58
58
|
return new AiSession(this);
|
|
59
59
|
}
|
|
60
60
|
async processFile(fileInput) {
|
|
61
|
-
return this.#fileService.processFile(fileInput);
|
|
61
|
+
return await this.#fileService.processFile(fileInput);
|
|
62
62
|
}
|
|
63
63
|
async processFiles(fileInputs) {
|
|
64
|
-
return this.#fileService.processFiles(fileInputs);
|
|
64
|
+
return await this.#fileService.processFiles(fileInputs);
|
|
65
65
|
}
|
|
66
66
|
getFileById(id) {
|
|
67
67
|
return { file: id };
|
|
@@ -256,14 +256,14 @@ let AiService = AiService_1 = class AiService {
|
|
|
256
256
|
async getModelOutputTokenLimit(model) {
|
|
257
257
|
const existingValue = this.#maxOutputTokensCache.get(model);
|
|
258
258
|
if (isDefined(existingValue)) {
|
|
259
|
-
return existingValue;
|
|
259
|
+
return await existingValue;
|
|
260
260
|
}
|
|
261
261
|
const promise = this._getModelOutputTokenLimit(model);
|
|
262
262
|
this.#maxOutputTokensCache.set(model, promise);
|
|
263
263
|
promise
|
|
264
264
|
.then((limit) => this.#maxOutputTokensCache.set(model, limit))
|
|
265
265
|
.catch(() => this.#maxOutputTokensCache.delete(model));
|
|
266
|
-
return promise;
|
|
266
|
+
return await promise;
|
|
267
267
|
}
|
|
268
268
|
async _getModelOutputTokenLimit(model) {
|
|
269
269
|
const modelInfo = await this.#genAI.models.get({ model });
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable max-classes-per-file */
|
|
2
1
|
import { Singleton } from '../../injector/decorators.js';
|
|
3
2
|
import { objectEntries } from '../../utils/object/object.js';
|
|
4
3
|
import { isFunction } from '../../utils/type-guards.js';
|
|
@@ -43,7 +42,7 @@ export function implementApi(definition, implementation) {
|
|
|
43
42
|
enumerable: true,
|
|
44
43
|
configurable: true,
|
|
45
44
|
writable: true,
|
|
46
|
-
value: handler
|
|
45
|
+
value: handler,
|
|
47
46
|
});
|
|
48
47
|
}
|
|
49
48
|
return api;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Document, DocumentCategory,
|
|
1
|
+
import { Document, DocumentCategory, DocumentRequest, DocumentRequestsTemplate, DocumentRequestTemplate, DocumentType } from '../models/index.js';
|
|
2
2
|
import { DocumentCategoryView, DocumentManagementData, DocumentRequestsTemplateData } from '../service-models/index.js';
|
|
3
3
|
export type DocumentManagementApiDefinition = typeof documentManagementApiDefinition;
|
|
4
4
|
export declare const documentManagementApiDefinition: {
|
|
@@ -25,22 +25,20 @@ export declare const documentManagementApiDefinition: {
|
|
|
25
25
|
result: import("../../schema/index.js").ArraySchema<DocumentCategoryView>;
|
|
26
26
|
credentials: true;
|
|
27
27
|
};
|
|
28
|
-
|
|
28
|
+
loadContent: {
|
|
29
29
|
resource: string;
|
|
30
30
|
method: "GET";
|
|
31
31
|
parameters: import("../../schema/index.js").ObjectSchema<{
|
|
32
|
-
title: string | null;
|
|
33
32
|
id: string;
|
|
34
33
|
download?: boolean | undefined;
|
|
35
34
|
}>;
|
|
36
35
|
result: Uint8ArrayConstructor;
|
|
37
36
|
credentials: true;
|
|
38
37
|
};
|
|
39
|
-
|
|
38
|
+
getContentUrl: {
|
|
40
39
|
resource: string;
|
|
41
40
|
method: "GET";
|
|
42
41
|
parameters: import("../../schema/index.js").ObjectSchema<{
|
|
43
|
-
title: string | null;
|
|
44
42
|
id: string;
|
|
45
43
|
download?: boolean | undefined;
|
|
46
44
|
}>;
|
|
@@ -73,18 +71,6 @@ export declare const documentManagementApiDefinition: {
|
|
|
73
71
|
result: typeof DocumentType;
|
|
74
72
|
credentials: true;
|
|
75
73
|
};
|
|
76
|
-
createCollection: {
|
|
77
|
-
resource: string;
|
|
78
|
-
method: "POST";
|
|
79
|
-
parameters: import("../../schema/index.js").ObjectSchema<{
|
|
80
|
-
parentId: import("../../orm/schemas/uuid.js").Uuid | null;
|
|
81
|
-
metadata?: Partial<{
|
|
82
|
-
attributes: import("../../orm/types.js").HasDefault<import("../../orm/schemas/json.js").Json<import("../../orm/entity.js").EntityMetadataAttributes>>;
|
|
83
|
-
}> | undefined;
|
|
84
|
-
}>;
|
|
85
|
-
result: typeof DocumentCollection;
|
|
86
|
-
credentials: true;
|
|
87
|
-
};
|
|
88
74
|
createDocument: {
|
|
89
75
|
resource: string;
|
|
90
76
|
method: "POST";
|
|
@@ -256,7 +242,7 @@ export declare const documentManagementApiDefinition: {
|
|
|
256
242
|
result: import("../../schema/index.js").LiteralSchema<"ok">;
|
|
257
243
|
credentials: true;
|
|
258
244
|
};
|
|
259
|
-
|
|
245
|
+
assignDocumentToCollection: {
|
|
260
246
|
resource: string;
|
|
261
247
|
method: "PUT";
|
|
262
248
|
parameters: import("../../schema/index.js").ObjectSchema<{
|
|
@@ -269,7 +255,7 @@ export declare const documentManagementApiDefinition: {
|
|
|
269
255
|
result: import("../../schema/index.js").LiteralSchema<"ok">;
|
|
270
256
|
credentials: true;
|
|
271
257
|
};
|
|
272
|
-
|
|
258
|
+
archiveDocumentInCollection: {
|
|
273
259
|
resource: string;
|
|
274
260
|
method: "DELETE";
|
|
275
261
|
parameters: import("../../schema/index.js").ObjectSchema<{
|
|
@@ -338,22 +324,20 @@ declare const _DocumentManagementApi: import("../../api/client/index.js").ApiCli
|
|
|
338
324
|
result: import("../../schema/index.js").ArraySchema<DocumentCategoryView>;
|
|
339
325
|
credentials: true;
|
|
340
326
|
};
|
|
341
|
-
|
|
327
|
+
loadContent: {
|
|
342
328
|
resource: string;
|
|
343
329
|
method: "GET";
|
|
344
330
|
parameters: import("../../schema/index.js").ObjectSchema<{
|
|
345
|
-
title: string | null;
|
|
346
331
|
id: string;
|
|
347
332
|
download?: boolean | undefined;
|
|
348
333
|
}>;
|
|
349
334
|
result: Uint8ArrayConstructor;
|
|
350
335
|
credentials: true;
|
|
351
336
|
};
|
|
352
|
-
|
|
337
|
+
getContentUrl: {
|
|
353
338
|
resource: string;
|
|
354
339
|
method: "GET";
|
|
355
340
|
parameters: import("../../schema/index.js").ObjectSchema<{
|
|
356
|
-
title: string | null;
|
|
357
341
|
id: string;
|
|
358
342
|
download?: boolean | undefined;
|
|
359
343
|
}>;
|
|
@@ -386,18 +370,6 @@ declare const _DocumentManagementApi: import("../../api/client/index.js").ApiCli
|
|
|
386
370
|
result: typeof DocumentType;
|
|
387
371
|
credentials: true;
|
|
388
372
|
};
|
|
389
|
-
createCollection: {
|
|
390
|
-
resource: string;
|
|
391
|
-
method: "POST";
|
|
392
|
-
parameters: import("../../schema/index.js").ObjectSchema<{
|
|
393
|
-
parentId: import("../../orm/schemas/uuid.js").Uuid | null;
|
|
394
|
-
metadata?: Partial<{
|
|
395
|
-
attributes: import("../../orm/types.js").HasDefault<import("../../orm/schemas/json.js").Json<import("../../orm/entity.js").EntityMetadataAttributes>>;
|
|
396
|
-
}> | undefined;
|
|
397
|
-
}>;
|
|
398
|
-
result: typeof DocumentCollection;
|
|
399
|
-
credentials: true;
|
|
400
|
-
};
|
|
401
373
|
createDocument: {
|
|
402
374
|
resource: string;
|
|
403
375
|
method: "POST";
|
|
@@ -569,7 +541,7 @@ declare const _DocumentManagementApi: import("../../api/client/index.js").ApiCli
|
|
|
569
541
|
result: import("../../schema/index.js").LiteralSchema<"ok">;
|
|
570
542
|
credentials: true;
|
|
571
543
|
};
|
|
572
|
-
|
|
544
|
+
assignDocumentToCollection: {
|
|
573
545
|
resource: string;
|
|
574
546
|
method: "PUT";
|
|
575
547
|
parameters: import("../../schema/index.js").ObjectSchema<{
|
|
@@ -582,7 +554,7 @@ declare const _DocumentManagementApi: import("../../api/client/index.js").ApiCli
|
|
|
582
554
|
result: import("../../schema/index.js").LiteralSchema<"ok">;
|
|
583
555
|
credentials: true;
|
|
584
556
|
};
|
|
585
|
-
|
|
557
|
+
archiveDocumentInCollection: {
|
|
586
558
|
resource: string;
|
|
587
559
|
method: "DELETE";
|
|
588
560
|
parameters: import("../../schema/index.js").ObjectSchema<{
|
|
@@ -7,10 +7,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { compileClient } from '../../api/client/index.js';
|
|
8
8
|
import { defineApi } from '../../api/index.js';
|
|
9
9
|
import { ReplaceClass } from '../../injector/decorators.js';
|
|
10
|
-
import { array, boolean, literal,
|
|
10
|
+
import { array, boolean, literal, object, optional, string } from '../../schema/index.js';
|
|
11
11
|
import { megabyte } from '../../utils/units.js';
|
|
12
|
-
import { Document, DocumentCategory,
|
|
13
|
-
import { addOrArchiveDocumentToOrFromCollectionParametersSchema, applyDocumentRequestsTemplateParametersSchema,
|
|
12
|
+
import { Document, DocumentCategory, DocumentRequest, DocumentRequestsTemplate, DocumentRequestTemplate, DocumentType } from '../models/index.js';
|
|
13
|
+
import { addOrArchiveDocumentToOrFromCollectionParametersSchema, applyDocumentRequestsTemplateParametersSchema, createDocumentCategoryParametersSchema, createDocumentParametersSchema, createDocumentRequestParametersSchema, createDocumentRequestsTemplateParametersSchema, createDocumentRequestTemplateParametersSchema, createDocumentTypeParametersSchema, deleteDocumentRequestParametersSchema, deleteDocumentRequestsTemplateParametersSchema, deleteDocumentRequestTemplateParametersSchema, DocumentCategoryView, DocumentManagementData, DocumentRequestsTemplateData, loadDataParametersSchema, updateDocumentParametersSchema, updateDocumentRequestParametersSchema, updateDocumentRequestsTemplateParametersSchema, updateDocumentRequestTemplateParametersSchema } from '../service-models/index.js';
|
|
14
14
|
export const documentManagementApiDefinition = defineApi({
|
|
15
15
|
resource: 'document-management',
|
|
16
16
|
endpoints: {
|
|
@@ -33,23 +33,21 @@ export const documentManagementApiDefinition = defineApi({
|
|
|
33
33
|
result: array(DocumentCategoryView),
|
|
34
34
|
credentials: true,
|
|
35
35
|
},
|
|
36
|
-
|
|
37
|
-
resource: '
|
|
36
|
+
loadContent: {
|
|
37
|
+
resource: 'documents/:id/content',
|
|
38
38
|
method: 'GET',
|
|
39
39
|
parameters: object({
|
|
40
40
|
id: string(),
|
|
41
|
-
title: nullable(string()),
|
|
42
41
|
download: optional(boolean({ coerce: true })),
|
|
43
42
|
}),
|
|
44
43
|
result: Uint8Array,
|
|
45
44
|
credentials: true,
|
|
46
45
|
},
|
|
47
|
-
|
|
48
|
-
resource: '
|
|
46
|
+
getContentUrl: {
|
|
47
|
+
resource: 'documents/:id/content/url',
|
|
49
48
|
method: 'GET',
|
|
50
49
|
parameters: object({
|
|
51
50
|
id: string(),
|
|
52
|
-
title: nullable(string()),
|
|
53
51
|
download: optional(boolean({ coerce: true })),
|
|
54
52
|
}),
|
|
55
53
|
result: string(),
|
|
@@ -69,13 +67,6 @@ export const documentManagementApiDefinition = defineApi({
|
|
|
69
67
|
result: DocumentType,
|
|
70
68
|
credentials: true,
|
|
71
69
|
},
|
|
72
|
-
createCollection: {
|
|
73
|
-
resource: 'collections',
|
|
74
|
-
method: 'POST',
|
|
75
|
-
parameters: createCollectionParametersSchema,
|
|
76
|
-
result: DocumentCollection,
|
|
77
|
-
credentials: true,
|
|
78
|
-
},
|
|
79
70
|
createDocument: {
|
|
80
71
|
resource: 'documents',
|
|
81
72
|
method: 'POST',
|
|
@@ -155,14 +146,14 @@ export const documentManagementApiDefinition = defineApi({
|
|
|
155
146
|
result: literal('ok'),
|
|
156
147
|
credentials: true,
|
|
157
148
|
},
|
|
158
|
-
|
|
149
|
+
assignDocumentToCollection: {
|
|
159
150
|
resource: 'collections/:collectionId/documents/:documentId',
|
|
160
151
|
method: 'PUT',
|
|
161
152
|
parameters: addOrArchiveDocumentToOrFromCollectionParametersSchema,
|
|
162
153
|
result: literal('ok'),
|
|
163
154
|
credentials: true,
|
|
164
155
|
},
|
|
165
|
-
|
|
156
|
+
archiveDocumentInCollection: {
|
|
166
157
|
resource: 'collections/:collectionId/documents/:documentId',
|
|
167
158
|
method: 'DELETE',
|
|
168
159
|
parameters: addOrArchiveDocumentToOrFromCollectionParametersSchema,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Entity } from '../../orm/entity.js';
|
|
2
|
+
import { Uuid } from '../../orm/types.js';
|
|
3
|
+
export declare class DocumentRequestCollectionAssignment extends Entity {
|
|
4
|
+
static readonly entityName: 'DocumentRequestCollectionAssignment';
|
|
5
|
+
requestId: Uuid;
|
|
6
|
+
collectionId: Uuid;
|
|
7
|
+
}
|
|
@@ -13,7 +13,7 @@ import { Unique, Uuid } from '../../orm/types.js';
|
|
|
13
13
|
import { DocumentCollection } from './document-collection.model.js';
|
|
14
14
|
import { DocumentManagementTable } from './document-management-table.js';
|
|
15
15
|
import { DocumentRequest } from './document-request.model.js';
|
|
16
|
-
let
|
|
16
|
+
let DocumentRequestCollectionAssignment = class DocumentRequestCollectionAssignment extends Entity {
|
|
17
17
|
requestId;
|
|
18
18
|
collectionId;
|
|
19
19
|
};
|
|
@@ -21,14 +21,14 @@ __decorate([
|
|
|
21
21
|
Uuid(),
|
|
22
22
|
References(() => DocumentRequest),
|
|
23
23
|
__metadata("design:type", String)
|
|
24
|
-
],
|
|
24
|
+
], DocumentRequestCollectionAssignment.prototype, "requestId", void 0);
|
|
25
25
|
__decorate([
|
|
26
26
|
Uuid(),
|
|
27
27
|
References(() => DocumentCollection),
|
|
28
28
|
__metadata("design:type", String)
|
|
29
|
-
],
|
|
30
|
-
|
|
29
|
+
], DocumentRequestCollectionAssignment.prototype, "collectionId", void 0);
|
|
30
|
+
DocumentRequestCollectionAssignment = __decorate([
|
|
31
31
|
DocumentManagementTable(),
|
|
32
32
|
Unique(['requestId', 'collectionId'])
|
|
33
|
-
],
|
|
34
|
-
export {
|
|
33
|
+
], DocumentRequestCollectionAssignment);
|
|
34
|
+
export { DocumentRequestCollectionAssignment };
|
|
@@ -7,7 +7,7 @@ export * from './document-file.model.js';
|
|
|
7
7
|
export * from './document-management-table.js';
|
|
8
8
|
export * from './document-property-value.model.js';
|
|
9
9
|
export * from './document-property.model.js';
|
|
10
|
-
export * from './document-request-collection.model.js';
|
|
10
|
+
export * from './document-request-collection-assignment.model.js';
|
|
11
11
|
export * from './document-request-submission.model.js';
|
|
12
12
|
export * from './document-request-template.js';
|
|
13
13
|
export * from './document-request.model.js';
|
|
@@ -7,7 +7,7 @@ export * from './document-file.model.js';
|
|
|
7
7
|
export * from './document-management-table.js';
|
|
8
8
|
export * from './document-property-value.model.js';
|
|
9
9
|
export * from './document-property.model.js';
|
|
10
|
-
export * from './document-request-collection.model.js';
|
|
10
|
+
export * from './document-request-collection-assignment.model.js';
|
|
11
11
|
export * from './document-request-submission.model.js';
|
|
12
12
|
export * from './document-request-template.js';
|
|
13
13
|
export * from './document-request.model.js';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ApiController, ApiRequestContext, ApiServerResult } from '../../../api/index.js';
|
|
2
|
+
import { type DocumentManagementApiDefinition } from '../../../document-management/api/index.js';
|
|
3
|
+
export declare class DocumentManagementApiController implements ApiController<DocumentManagementApiDefinition> {
|
|
4
|
+
#private;
|
|
5
|
+
loadData(context: ApiRequestContext<DocumentManagementApiDefinition, 'loadData'>): Promise<ApiServerResult<DocumentManagementApiDefinition, 'loadData'>>;
|
|
6
|
+
loadDocumentRequestsTemplateData(context: ApiRequestContext<DocumentManagementApiDefinition, 'loadDocumentRequestsTemplateData'>): Promise<ApiServerResult<DocumentManagementApiDefinition, 'loadDocumentRequestsTemplateData'>>;
|
|
7
|
+
loadAvailableCategories(context: ApiRequestContext<DocumentManagementApiDefinition, 'loadAvailableCategories'>): Promise<ApiServerResult<DocumentManagementApiDefinition, 'loadAvailableCategories'>>;
|
|
8
|
+
loadContent(context: ApiRequestContext<DocumentManagementApiDefinition, 'loadContent'>): Promise<ApiServerResult<DocumentManagementApiDefinition, 'loadContent'>>;
|
|
9
|
+
getContentUrl(context: ApiRequestContext<DocumentManagementApiDefinition, 'getContentUrl'>): Promise<ApiServerResult<DocumentManagementApiDefinition, 'getContentUrl'>>;
|
|
10
|
+
createCategory(context: ApiRequestContext<DocumentManagementApiDefinition, 'createCategory'>): Promise<ApiServerResult<DocumentManagementApiDefinition, 'createCategory'>>;
|
|
11
|
+
createType(context: ApiRequestContext<DocumentManagementApiDefinition, 'createType'>): Promise<ApiServerResult<DocumentManagementApiDefinition, 'createType'>>;
|
|
12
|
+
createDocument(context: ApiRequestContext<DocumentManagementApiDefinition, 'createDocument'>): Promise<ApiServerResult<DocumentManagementApiDefinition, 'createDocument'>>;
|
|
13
|
+
createDocumentRequestsTemplate(context: ApiRequestContext<DocumentManagementApiDefinition, 'createDocumentRequestsTemplate'>): Promise<ApiServerResult<DocumentManagementApiDefinition, 'createDocumentRequestsTemplate'>>;
|
|
14
|
+
updateDocumentRequestsTemplate(_context: ApiRequestContext<DocumentManagementApiDefinition, 'updateDocumentRequestsTemplate'>): Promise<ApiServerResult<DocumentManagementApiDefinition, 'updateDocumentRequestsTemplate'>>;
|
|
15
|
+
applyDocumentRequestsTemplate(_context: ApiRequestContext<DocumentManagementApiDefinition, 'applyDocumentRequestsTemplate'>): Promise<ApiServerResult<DocumentManagementApiDefinition, 'applyDocumentRequestsTemplate'>>;
|
|
16
|
+
deleteDocumentRequestsTemplate(_context: ApiRequestContext<DocumentManagementApiDefinition, 'deleteDocumentRequestsTemplate'>): Promise<ApiServerResult<DocumentManagementApiDefinition, 'deleteDocumentRequestsTemplate'>>;
|
|
17
|
+
createDocumentRequestTemplate(_context: ApiRequestContext<DocumentManagementApiDefinition, 'createDocumentRequestTemplate'>): Promise<ApiServerResult<DocumentManagementApiDefinition, 'createDocumentRequestTemplate'>>;
|
|
18
|
+
updateDocumentRequestTemplate(_context: ApiRequestContext<DocumentManagementApiDefinition, 'updateDocumentRequestTemplate'>): Promise<ApiServerResult<DocumentManagementApiDefinition, 'updateDocumentRequestTemplate'>>;
|
|
19
|
+
deleteDocumentRequestTemplate(_context: ApiRequestContext<DocumentManagementApiDefinition, 'deleteDocumentRequestTemplate'>): Promise<ApiServerResult<DocumentManagementApiDefinition, 'deleteDocumentRequestTemplate'>>;
|
|
20
|
+
createDocumentRequest(_context: ApiRequestContext<DocumentManagementApiDefinition, 'createDocumentRequest'>): Promise<ApiServerResult<DocumentManagementApiDefinition, 'createDocumentRequest'>>;
|
|
21
|
+
updateDocumentRequest(_context: ApiRequestContext<DocumentManagementApiDefinition, 'updateDocumentRequest'>): Promise<ApiServerResult<DocumentManagementApiDefinition, 'updateDocumentRequest'>>;
|
|
22
|
+
deleteDocumentRequest(_context: ApiRequestContext<DocumentManagementApiDefinition, 'deleteDocumentRequest'>): Promise<ApiServerResult<DocumentManagementApiDefinition, 'deleteDocumentRequest'>>;
|
|
23
|
+
assignDocumentToCollection(_context: ApiRequestContext<DocumentManagementApiDefinition, 'assignDocumentToCollection'>): Promise<ApiServerResult<DocumentManagementApiDefinition, 'assignDocumentToCollection'>>;
|
|
24
|
+
archiveDocumentInCollection(_context: ApiRequestContext<DocumentManagementApiDefinition, 'archiveDocumentInCollection'>): Promise<ApiServerResult<DocumentManagementApiDefinition, 'archiveDocumentInCollection'>>;
|
|
25
|
+
updateDocument(_context: ApiRequestContext<DocumentManagementApiDefinition, 'updateDocument'>): Promise<ApiServerResult<DocumentManagementApiDefinition, 'updateDocument'>>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var _a;
|
|
8
|
+
var DocumentManagementApiController_1;
|
|
9
|
+
import { apiController } from '../../../api/server/index.js';
|
|
10
|
+
import { CancellationSignal } from '../../../cancellation/index.js';
|
|
11
|
+
import { documentManagementApiDefinition } from '../../../document-management/api/index.js';
|
|
12
|
+
import { DocumentRequestCollectionAssignment } from '../../../document-management/models/document-request-collection-assignment.model.js';
|
|
13
|
+
import { ForbiddenError, NotImplementedError } from '../../../errors/index.js';
|
|
14
|
+
import { HttpServerResponse } from '../../../http/index.js';
|
|
15
|
+
import { inject } from '../../../injector/index.js';
|
|
16
|
+
import { Logger } from '../../../logger/index.js';
|
|
17
|
+
import { injectRepository } from '../../../orm/server/repository.js';
|
|
18
|
+
import { toArray } from '../../../utils/array/index.js';
|
|
19
|
+
import { match, P } from 'ts-pattern';
|
|
20
|
+
import { DocumentCategoryTypeService, DocumentCollectionService, DocumentFileService, DocumentManagementAncillaryService, DocumentManagementService, DocumentPropertyService, DocumentRequestService, DocumentService, DocumentWorkflowService } from '../services/index.js';
|
|
21
|
+
let DocumentManagementApiController = DocumentManagementApiController_1 = class DocumentManagementApiController {
|
|
22
|
+
#ancillaryService = inject(DocumentManagementAncillaryService);
|
|
23
|
+
#documentCategoryTypeService = inject(DocumentCategoryTypeService);
|
|
24
|
+
#documentCollectionService = inject(DocumentCollectionService);
|
|
25
|
+
#documentFileService = inject(DocumentFileService);
|
|
26
|
+
#documentManagementAncillaryService = inject(DocumentManagementAncillaryService);
|
|
27
|
+
#documentManagementService = inject(DocumentManagementService);
|
|
28
|
+
#documentPropertyService = inject(DocumentPropertyService);
|
|
29
|
+
#documentRequestService = inject(DocumentRequestService);
|
|
30
|
+
#documentRequestCollectionAssignmentRepository = injectRepository(DocumentRequestCollectionAssignment);
|
|
31
|
+
#documentService = inject(DocumentService);
|
|
32
|
+
#documentWorkflowService = inject(DocumentWorkflowService);
|
|
33
|
+
#cancellationSignal = inject(CancellationSignal);
|
|
34
|
+
#logger = inject(Logger, DocumentManagementApiController_1.name);
|
|
35
|
+
async loadData(context) {
|
|
36
|
+
const token = await context.getToken();
|
|
37
|
+
for (const collectionId of context.parameters.collectionIds) {
|
|
38
|
+
const allowed = await this.#documentManagementAncillaryService.canReadCollection(collectionId, token);
|
|
39
|
+
if (!allowed) {
|
|
40
|
+
throw new ForbiddenError(`You are not allowed to read collection ${collectionId}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return await this.#documentManagementService.loadData(toArray(context.parameters.collectionIds));
|
|
44
|
+
}
|
|
45
|
+
async loadDocumentRequestsTemplateData(context) {
|
|
46
|
+
const token = await context.getToken();
|
|
47
|
+
const allowed = await this.#documentManagementAncillaryService.canReadDocumentRequestsTemplates(token);
|
|
48
|
+
if (!allowed) {
|
|
49
|
+
throw new ForbiddenError('You are not allowed to load document requests template data.');
|
|
50
|
+
}
|
|
51
|
+
return await this.#documentManagementService.loadDocumentRequestsTemplateData();
|
|
52
|
+
}
|
|
53
|
+
async loadAvailableCategories(context) {
|
|
54
|
+
const token = await context.getToken();
|
|
55
|
+
return await this.#documentCategoryTypeService.loadCategoryViews();
|
|
56
|
+
}
|
|
57
|
+
async loadContent(context) {
|
|
58
|
+
const token = await context.getToken();
|
|
59
|
+
const allowed = await this.#documentManagementAncillaryService.canReadDocument(context.parameters.id, token);
|
|
60
|
+
if (!allowed) {
|
|
61
|
+
throw new ForbiddenError(`You are not allowed to load content for file ${context.parameters.id}.`);
|
|
62
|
+
}
|
|
63
|
+
const url = await this.#documentService.getContentUrl(context.parameters.id, context.parameters.download);
|
|
64
|
+
return HttpServerResponse.fromObject({
|
|
65
|
+
statusCode: 303,
|
|
66
|
+
headers: {
|
|
67
|
+
Location: url,
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
async getContentUrl(context) {
|
|
72
|
+
const token = await context.getToken();
|
|
73
|
+
const allowed = await this.#documentManagementAncillaryService.canReadDocument(context.parameters.id, token);
|
|
74
|
+
if (!allowed) {
|
|
75
|
+
throw new ForbiddenError(`You are not allowed to get content URL for file ${context.parameters.id}.`);
|
|
76
|
+
}
|
|
77
|
+
return await this.#documentService.getContentUrl(context.parameters.id, context.parameters.download);
|
|
78
|
+
}
|
|
79
|
+
async createCategory(context) {
|
|
80
|
+
const token = await context.getToken();
|
|
81
|
+
const allowed = await this.#documentManagementAncillaryService.canManageCategoriesAndTypes(token);
|
|
82
|
+
if (!allowed) {
|
|
83
|
+
throw new ForbiddenError('You are not allowed to create document categories.');
|
|
84
|
+
}
|
|
85
|
+
return await this.#documentCategoryTypeService.createCategory(context.parameters.label, context.parameters.parentId);
|
|
86
|
+
}
|
|
87
|
+
async createType(context) {
|
|
88
|
+
const token = await context.getToken();
|
|
89
|
+
const allowed = await this.#documentManagementAncillaryService.canManageCategoriesAndTypes(token);
|
|
90
|
+
if (!allowed) {
|
|
91
|
+
throw new ForbiddenError('You are not allowed to create document types.');
|
|
92
|
+
}
|
|
93
|
+
return await this.#documentCategoryTypeService.createType(context.parameters.label, context.parameters.categoryId);
|
|
94
|
+
}
|
|
95
|
+
async createDocument(context) {
|
|
96
|
+
const token = await context.getToken();
|
|
97
|
+
const [collectionIds, requiresAssign] = await match(context.parameters.assignment)
|
|
98
|
+
.with({ collections: P.select() }, (collectionIds) => [toArray(collectionIds), true])
|
|
99
|
+
.with({ request: P.select() }, async (requestId) => {
|
|
100
|
+
const assignments = await this.#documentRequestCollectionAssignmentRepository.loadManyByQuery({ requestId });
|
|
101
|
+
const collectionIds = assignments.map((assignment) => assignment.collectionId);
|
|
102
|
+
return [collectionIds, true];
|
|
103
|
+
})
|
|
104
|
+
.with({ automatic: P.select() }, ({ scope }) => [toArray(scope), false])
|
|
105
|
+
.exhaustive();
|
|
106
|
+
for (const collectionId of collectionIds) {
|
|
107
|
+
const createDocumentsAllowed = await this.#documentManagementAncillaryService.canCreateDocuments(collectionId, token);
|
|
108
|
+
if (!createDocumentsAllowed) {
|
|
109
|
+
throw new ForbiddenError(`You are not allowed to create documents in collection ${collectionId}.`);
|
|
110
|
+
}
|
|
111
|
+
if (requiresAssign) {
|
|
112
|
+
const assignDocumentsAllowed = await this.#documentManagementAncillaryService.canAssignDocuments(collectionId, token);
|
|
113
|
+
if (!assignDocumentsAllowed) {
|
|
114
|
+
throw new ForbiddenError(`You are not allowed to assign documents in collection ${collectionId}.`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
const actionUserId = await this.#ancillaryService.getUserId(token);
|
|
119
|
+
return await this.#documentService.create(context.parameters, context.body, { createUserId: actionUserId });
|
|
120
|
+
}
|
|
121
|
+
async createDocumentRequestsTemplate(context) {
|
|
122
|
+
const token = await context.getToken();
|
|
123
|
+
const allowed = await this.#documentManagementAncillaryService.canManageDocumentRequestsTemplates(token);
|
|
124
|
+
if (!allowed) {
|
|
125
|
+
throw new ForbiddenError('You are not allowed to create document requests template.');
|
|
126
|
+
}
|
|
127
|
+
return await this.#documentRequestService.createRequestsTemplate(context.parameters);
|
|
128
|
+
}
|
|
129
|
+
async updateDocumentRequestsTemplate(_context) {
|
|
130
|
+
throw new NotImplementedError();
|
|
131
|
+
}
|
|
132
|
+
async applyDocumentRequestsTemplate(_context) {
|
|
133
|
+
throw new NotImplementedError();
|
|
134
|
+
}
|
|
135
|
+
async deleteDocumentRequestsTemplate(_context) {
|
|
136
|
+
throw new NotImplementedError();
|
|
137
|
+
}
|
|
138
|
+
async createDocumentRequestTemplate(_context) {
|
|
139
|
+
throw new NotImplementedError();
|
|
140
|
+
}
|
|
141
|
+
async updateDocumentRequestTemplate(_context) {
|
|
142
|
+
throw new NotImplementedError();
|
|
143
|
+
}
|
|
144
|
+
async deleteDocumentRequestTemplate(_context) {
|
|
145
|
+
throw new NotImplementedError();
|
|
146
|
+
}
|
|
147
|
+
async createDocumentRequest(_context) {
|
|
148
|
+
throw new NotImplementedError();
|
|
149
|
+
}
|
|
150
|
+
async updateDocumentRequest(_context) {
|
|
151
|
+
throw new NotImplementedError();
|
|
152
|
+
}
|
|
153
|
+
async deleteDocumentRequest(_context) {
|
|
154
|
+
throw new NotImplementedError();
|
|
155
|
+
}
|
|
156
|
+
async assignDocumentToCollection(_context) {
|
|
157
|
+
throw new NotImplementedError();
|
|
158
|
+
}
|
|
159
|
+
async archiveDocumentInCollection(_context) {
|
|
160
|
+
throw new NotImplementedError();
|
|
161
|
+
}
|
|
162
|
+
async updateDocument(_context) {
|
|
163
|
+
throw new NotImplementedError();
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
DocumentManagementApiController = DocumentManagementApiController_1 = __decorate([
|
|
167
|
+
apiController(documentManagementApiDefinition)
|
|
168
|
+
], DocumentManagementApiController);
|
|
169
|
+
export { DocumentManagementApiController };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './document-management.api.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './document-management.api.js';
|