@tstdl/base 0.92.123 → 0.92.125
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-file.service.js +23 -18
- package/ai/ai.service.d.ts +4 -12
- package/ai/ai.service.js +79 -147
- package/ai/functions.d.ts +1 -1
- package/ai/types.d.ts +3 -1
- package/api/server/gateway.js +6 -6
- package/authentication/authentication.api.js +24 -24
- package/authentication/server/authentication.service.js +20 -20
- package/browser/page-controller.js +1 -1
- package/context/context.js +5 -5
- package/document-management/api/document-management.api.d.ts +60 -215
- package/document-management/api/document-management.api.js +32 -68
- package/document-management/models/document-assignment-scope.model.d.ts +11 -0
- package/document-management/models/{document-request-assignment-task-collection.model.js → document-assignment-scope.model.js} +14 -10
- package/document-management/models/document-assignment-task.model.d.ts +13 -0
- package/document-management/models/document-assignment-task.model.js +38 -0
- package/document-management/models/document-category.model.d.ts +2 -0
- package/document-management/models/document-category.model.js +7 -1
- package/document-management/models/{document-collection-document.model.d.ts → document-collection-assignment.model.d.ts} +1 -1
- package/document-management/models/{document-collection-document.model.js → document-collection-assignment.model.js} +7 -7
- package/document-management/models/document-collection.model.d.ts +2 -0
- package/document-management/models/document-collection.model.js +10 -0
- package/document-management/models/document-property-value.model.d.ts +3 -11
- package/document-management/models/document-property-value.model.js +15 -46
- package/document-management/models/document-property.model.d.ts +2 -1
- package/document-management/models/document-property.model.js +2 -2
- package/document-management/models/document-request-submission.model.d.ts +7 -0
- package/document-management/models/document-request-submission.model.js +34 -0
- package/document-management/models/document-request-template.d.ts +2 -4
- package/document-management/models/document-request-template.js +3 -8
- package/document-management/models/document-request.model.d.ts +14 -6
- package/document-management/models/document-request.model.js +22 -12
- package/document-management/models/document-type-validation.model.d.ts +6 -0
- package/document-management/models/document-type-validation.model.js +34 -0
- package/document-management/models/document-type.model.d.ts +0 -1
- package/document-management/models/document-type.model.js +0 -5
- package/document-management/models/document-validation-definition.model.d.ts +10 -0
- package/document-management/models/document-validation-definition.model.js +39 -0
- package/document-management/models/document-validation-execution-related-document.model.d.ts +7 -0
- package/document-management/models/document-validation-execution-related-document.model.js +34 -0
- package/document-management/models/document-validation-execution.model.d.ts +26 -0
- package/document-management/models/document-validation-execution.model.js +72 -0
- package/document-management/models/document-workflow.model.d.ts +35 -0
- package/document-management/models/document-workflow.model.js +70 -0
- package/document-management/models/document.model.d.ts +12 -1
- package/document-management/models/document.model.js +21 -5
- package/document-management/models/index.d.ts +10 -5
- package/document-management/models/index.js +10 -5
- package/document-management/models/service-models/categories-and-types.view-model.d.ts +3 -3
- package/document-management/models/service-models/categories-and-types.view-model.js +2 -21
- package/document-management/models/service-models/document-folders.view-model.d.ts +7 -14
- package/document-management/models/service-models/document-folders.view-model.js +20 -44
- package/document-management/models/service-models/document-management.view-model.d.ts +41 -0
- package/document-management/models/service-models/{document.view-model.js → document-management.view-model.js} +43 -26
- package/document-management/models/service-models/document.service-model.d.ts +51 -81
- package/document-management/models/service-models/document.service-model.js +30 -28
- package/document-management/models/service-models/enriched/enriched-document-assignment.view.d.ts +11 -0
- package/document-management/models/service-models/enriched/enriched-document-assignment.view.js +12 -0
- package/document-management/models/service-models/enriched/enriched-document-category.view.d.ts +13 -0
- package/document-management/models/service-models/enriched/enriched-document-category.view.js +47 -0
- package/document-management/models/service-models/enriched/enriched-document-collection.view.d.ts +22 -0
- package/document-management/models/service-models/enriched/enriched-document-collection.view.js +89 -0
- package/document-management/models/service-models/enriched/enriched-document-file.view.d.ts +12 -0
- package/document-management/models/service-models/enriched/enriched-document-file.view.js +16 -0
- package/document-management/models/service-models/enriched/enriched-document-management-data.view.d.ts +41 -0
- package/document-management/models/service-models/enriched/enriched-document-management-data.view.js +130 -0
- package/document-management/models/service-models/enriched/enriched-document-request.view.d.ts +17 -0
- package/document-management/models/service-models/enriched/enriched-document-request.view.js +52 -0
- package/document-management/models/service-models/enriched/enriched-document-type.view.d.ts +9 -0
- package/document-management/models/service-models/enriched/enriched-document-type.view.js +10 -0
- package/document-management/models/service-models/enriched/enriched-document.view.d.ts +28 -0
- package/document-management/models/service-models/enriched/enriched-document.view.js +77 -0
- package/document-management/models/service-models/enriched/enriched.d.ts +18 -0
- package/document-management/models/service-models/enriched/enriched.js +39 -0
- package/document-management/models/service-models/enriched/index.d.ts +9 -0
- package/document-management/models/service-models/enriched/index.js +9 -0
- package/document-management/models/service-models/index.d.ts +2 -2
- package/document-management/models/service-models/index.js +2 -2
- package/document-management/models/service-models/normalized-requests-template-data.model.d.ts +12 -10
- package/document-management/models/service-models/normalized-requests-template-data.model.js +5 -4
- package/document-management/models/service-models/stats.view-model.d.ts +7 -5
- package/document-management/models/service-models/stats.view-model.js +19 -9
- package/document-management/server/module.d.ts +2 -2
- package/document-management/server/module.js +3 -7
- package/document-management/server/schemas.d.ts +18 -23
- package/document-management/server/schemas.js +18 -23
- package/document-management/server/services/document-category-type.service.d.ts +25 -0
- package/document-management/server/services/document-category-type.service.js +66 -0
- package/document-management/server/services/document-collection.service.d.ts +13 -0
- package/document-management/server/services/document-collection.service.js +41 -0
- package/document-management/server/services/document-file.service.d.ts +17 -0
- package/document-management/server/services/document-file.service.js +204 -0
- package/document-management/server/services/document-management-ai.service.d.ts +22 -0
- package/document-management/server/services/document-management-ai.service.js +340 -0
- package/document-management/server/services/document-management-ancillary.service.d.ts +127 -3
- package/document-management/server/services/document-management-ancillary.service.js +24 -0
- package/document-management/server/services/document-management.service.d.ts +10 -122
- package/document-management/server/services/document-management.service.js +106 -888
- package/document-management/server/services/document-property.service.d.ts +84 -0
- package/document-management/server/services/document-property.service.js +87 -0
- package/document-management/server/services/document-request.service.d.ts +30 -0
- package/document-management/server/services/document-request.service.js +138 -0
- package/document-management/server/services/document-validation.service.d.ts +20 -0
- package/document-management/server/services/document-validation.service.js +145 -0
- package/document-management/server/services/document-workflow.service.d.ts +20 -0
- package/document-management/server/services/document-workflow.service.js +132 -0
- package/document-management/server/services/document.service.d.ts +16 -0
- package/document-management/server/services/document.service.js +81 -0
- package/document-management/server/services/index.d.ts +9 -0
- package/document-management/server/services/index.js +9 -0
- package/document-management/server/validators/ai-validation-executor.d.ts +19 -0
- package/document-management/server/validators/ai-validation-executor.js +51 -0
- package/document-management/server/validators/index.d.ts +2 -0
- package/document-management/server/validators/index.js +2 -0
- package/document-management/server/validators/single-document-validation-executor.d.ts +16 -0
- package/document-management/server/validators/single-document-validation-executor.js +20 -0
- package/document-management/server/validators/validator.d.ts +21 -0
- package/document-management/server/validators/validator.js +2 -0
- package/eslint.config.js +31 -17
- package/examples/document-management/main.d.ts +18 -3
- package/examples/document-management/main.js +28 -12
- package/file/mime-type.js +2 -9
- package/formats.d.ts +5 -2
- package/formats.js +32 -23
- package/http/client/http-client.js +1 -1
- package/injector/injector.js +2 -2
- package/object-storage/s3/s3.object-storage.js +1 -1
- package/orm/data-types/bytea.d.ts +8 -0
- package/orm/data-types/bytea.js +8 -0
- package/orm/data-types/index.d.ts +4 -0
- package/orm/data-types/index.js +4 -0
- package/orm/data-types/numeric-date.d.ts +9 -0
- package/orm/data-types/numeric-date.js +9 -0
- package/orm/data-types/timestamp.d.ts +9 -0
- package/orm/data-types/timestamp.js +9 -0
- package/orm/decorators.d.ts +139 -5
- package/orm/decorators.js +50 -0
- package/orm/entity.d.ts +19 -0
- package/orm/entity.js +19 -0
- package/orm/index.d.ts +5 -0
- package/orm/index.js +5 -0
- package/orm/query.d.ts +51 -0
- package/orm/query.js +6 -0
- package/orm/repository.types.d.ts +54 -2
- package/orm/server/database-schema.d.ts +34 -0
- package/orm/server/database-schema.js +29 -0
- package/orm/server/database.d.ts +19 -1
- package/orm/server/database.js +17 -3
- package/orm/server/drizzle/schema-converter.d.ts +2 -1
- package/orm/server/drizzle/schema-converter.js +12 -1
- package/orm/server/encryption.d.ts +16 -0
- package/orm/server/encryption.js +29 -4
- package/orm/server/index.d.ts +7 -0
- package/orm/server/index.js +7 -0
- package/orm/server/module.d.ts +20 -0
- package/orm/server/module.js +9 -0
- package/orm/server/query-converter.d.ts +17 -0
- package/orm/server/query-converter.js +66 -11
- package/orm/server/repository.d.ts +324 -18
- package/orm/server/repository.js +344 -73
- package/orm/server/transaction.d.ts +5 -5
- package/orm/server/transaction.js +5 -5
- package/orm/server/transactional.d.ts +75 -0
- package/orm/server/transactional.js +134 -0
- package/orm/server/types.d.ts +1 -0
- package/orm/sqls.d.ts +55 -0
- package/orm/sqls.js +60 -0
- package/orm/types.d.ts +67 -4
- package/orm/utils.d.ts +19 -3
- package/orm/utils.js +12 -0
- package/package.json +32 -31
- package/password/password-check-result.model.d.ts +9 -7
- package/password/password-check-result.model.js +8 -8
- package/password/password-check.js +5 -7
- package/password/password-check.localization.js +12 -12
- package/pdf/pdf.service.js +1 -1
- package/pdf/utils.d.ts +9 -0
- package/pdf/utils.js +19 -2
- package/process/spawn.d.ts +11 -4
- package/process/spawn.js +42 -5
- package/queue/postgres/queue.js +5 -5
- package/queue/queue.d.ts +6 -4
- package/queue/queue.js +6 -6
- package/schema/schemas/one-or-many.d.ts +2 -1
- package/schema/schemas/one-or-many.js +1 -1
- package/search-index/elastic/model/index-mapping.d.ts +1 -1
- package/search-index/elastic/model/index-mapping.js +0 -1
- package/search-index/elastic/search-index.d.ts +1 -2
- package/search-index/elastic/search-index.js +3 -3
- package/types.d.ts +1 -0
- package/utils/async-hook/async-hook.d.ts +9 -0
- package/utils/async-hook/async-hook.js +21 -0
- package/utils/async-hook/index.d.ts +1 -0
- package/utils/async-hook/index.js +1 -0
- package/utils/compression.js +1 -1
- package/utils/function/class.d.ts +6 -0
- package/utils/function/class.js +9 -0
- package/utils/function/index.d.ts +1 -0
- package/utils/function/index.js +1 -0
- package/utils/function/memoize.d.ts +18 -0
- package/utils/function/memoize.js +41 -2
- package/utils/jwt.d.ts +1 -1
- package/utils/jwt.js +5 -5
- package/utils/object/forward-ref.d.ts +3 -2
- package/utils/object/forward-ref.js +12 -12
- package/utils/object/lazy-property.js +2 -2
- package/utils/proxy.js +1 -1
- package/utils/stream/{readable-stream-from-promise.d.ts → from-promise.d.ts} +1 -0
- package/utils/stream/from-promise.js +27 -0
- package/utils/stream/index.d.ts +1 -1
- package/utils/stream/index.js +1 -1
- package/utils/stream/stream-reader.js +71 -31
- package/document-management/models/document-request-assignment-task-collection.model.d.ts +0 -7
- package/document-management/models/document-request-assignment-task.model.d.ts +0 -14
- package/document-management/models/document-request-assignment-task.model.js +0 -77
- package/document-management/models/document-request-file.model.d.ts +0 -16
- package/document-management/models/document-request-file.model.js +0 -86
- package/document-management/models/service-models/document.view-model.d.ts +0 -41
- package/document-management/models/service-models/normalized-document-collection-view.model.d.ts +0 -73
- package/document-management/models/service-models/normalized-document-collection-view.model.js +0 -110
- package/utils/stream/readable-stream-from-promise.js +0 -8
|
@@ -0,0 +1,77 @@
|
|
|
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 __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Memoize } from '../../../../utils/function/memoize.js';
|
|
11
|
+
import { assertDefinedPass, isNull } from '../../../../utils/type-guards.js';
|
|
12
|
+
import { EnrichedDocumentAssignment } from './enriched-document-assignment.view.js';
|
|
13
|
+
import { EnrichedDocumentFile } from './enriched-document-file.view.js';
|
|
14
|
+
export class EnrichedDocument {
|
|
15
|
+
#data;
|
|
16
|
+
#documentView;
|
|
17
|
+
id;
|
|
18
|
+
title;
|
|
19
|
+
subtitle;
|
|
20
|
+
pages;
|
|
21
|
+
date;
|
|
22
|
+
summary;
|
|
23
|
+
tags;
|
|
24
|
+
approval;
|
|
25
|
+
comment;
|
|
26
|
+
properties;
|
|
27
|
+
currentWorkflow;
|
|
28
|
+
validations;
|
|
29
|
+
get type() {
|
|
30
|
+
if (isNull(this.#documentView.typeId)) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return assertDefinedPass(this.#data.maps.types.get(this.#documentView.typeId));
|
|
34
|
+
}
|
|
35
|
+
get file() {
|
|
36
|
+
const file = assertDefinedPass(this.#data.rawDataMaps.files.get(this.#documentView.fileId));
|
|
37
|
+
return new EnrichedDocumentFile(file, this);
|
|
38
|
+
}
|
|
39
|
+
get assignments() {
|
|
40
|
+
return this.#documentView.collectionAssignments
|
|
41
|
+
.map((assignment) => {
|
|
42
|
+
const collection = assertDefinedPass(this.#data.collections.find((collection) => collection.id == assignment.collectionId));
|
|
43
|
+
return new EnrichedDocumentAssignment(assignment.id, collection, assertDefinedPass(this.#data.documents.find((document) => document.id == this.#documentView.id)), assignment.archiveTimestamp);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
constructor(data, document) {
|
|
47
|
+
this.#data = data;
|
|
48
|
+
this.#documentView = document;
|
|
49
|
+
this.id = document.id;
|
|
50
|
+
this.title = document.title;
|
|
51
|
+
this.subtitle = document.subtitle;
|
|
52
|
+
this.pages = document.pages;
|
|
53
|
+
this.date = document.date;
|
|
54
|
+
this.summary = document.summary;
|
|
55
|
+
this.tags = document.tags;
|
|
56
|
+
this.approval = document.approval;
|
|
57
|
+
this.comment = document.comment;
|
|
58
|
+
this.properties = document.properties;
|
|
59
|
+
this.currentWorkflow = document.currentWorkflow;
|
|
60
|
+
this.validations = document.validations;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
__decorate([
|
|
64
|
+
Memoize(),
|
|
65
|
+
__metadata("design:type", Object),
|
|
66
|
+
__metadata("design:paramtypes", [])
|
|
67
|
+
], EnrichedDocument.prototype, "type", null);
|
|
68
|
+
__decorate([
|
|
69
|
+
Memoize(),
|
|
70
|
+
__metadata("design:type", EnrichedDocumentFile),
|
|
71
|
+
__metadata("design:paramtypes", [])
|
|
72
|
+
], EnrichedDocument.prototype, "file", null);
|
|
73
|
+
__decorate([
|
|
74
|
+
Memoize(),
|
|
75
|
+
__metadata("design:type", Array),
|
|
76
|
+
__metadata("design:paramtypes", [])
|
|
77
|
+
], EnrichedDocument.prototype, "assignments", null);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { DocumentManagementData, DocumentRequestView } from '../document-management.view-model.js';
|
|
2
|
+
import { EnrichedDocumentManagementData } from './enriched-document-management-data.view.js';
|
|
3
|
+
import type { EnrichedDocumentRequest } from './enriched-document-request.view.js';
|
|
4
|
+
export type RequestsStats = {
|
|
5
|
+
/** Open without document */
|
|
6
|
+
open: number;
|
|
7
|
+
/** Open with pending approval */
|
|
8
|
+
pending: number;
|
|
9
|
+
/** Closed without document */
|
|
10
|
+
closed: number;
|
|
11
|
+
/** Closed with rejected document */
|
|
12
|
+
rejected: number;
|
|
13
|
+
/** Fulfilled with approved document */
|
|
14
|
+
fulfilled: number;
|
|
15
|
+
};
|
|
16
|
+
export declare function toEnrichedDocumentManagementData(data: DocumentManagementData): EnrichedDocumentManagementData;
|
|
17
|
+
export declare function calculateRequestsStats(requests: Iterable<DocumentRequestView | EnrichedDocumentRequest>): RequestsStats;
|
|
18
|
+
export declare function mergeRequestsStats(stats: Iterable<RequestsStats>): RequestsStats;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { match, P } from 'ts-pattern';
|
|
2
|
+
import { reduce } from '../../../../utils/iterable-helpers/index.js';
|
|
3
|
+
import { _throw } from '../../../../utils/throw.js';
|
|
4
|
+
import { EnrichedDocumentManagementData } from './enriched-document-management-data.view.js';
|
|
5
|
+
export function toEnrichedDocumentManagementData(data) {
|
|
6
|
+
return new EnrichedDocumentManagementData(data);
|
|
7
|
+
}
|
|
8
|
+
export function calculateRequestsStats(requests) {
|
|
9
|
+
let open = 0;
|
|
10
|
+
let pending = 0;
|
|
11
|
+
let closed = 0;
|
|
12
|
+
let rejected = 0;
|
|
13
|
+
let fulfilled = 0;
|
|
14
|
+
for (const request of requests) {
|
|
15
|
+
match(request)
|
|
16
|
+
.with({ state: 'open', document: null }, () => open++)
|
|
17
|
+
.with({ state: 'open', document: P.nonNullable }, () => pending++)
|
|
18
|
+
.with({ state: 'closed', document: null }, () => closed++)
|
|
19
|
+
.with({ state: 'closed', document: { approval: 'rejected' } }, () => rejected++)
|
|
20
|
+
.with({ state: 'fulfilled', document: { approval: 'approved' } }, () => fulfilled++)
|
|
21
|
+
.otherwise(() => _throw('Invalid request state'));
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
open,
|
|
25
|
+
pending,
|
|
26
|
+
closed,
|
|
27
|
+
rejected,
|
|
28
|
+
fulfilled,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export function mergeRequestsStats(stats) {
|
|
32
|
+
return {
|
|
33
|
+
open: reduce(stats, (a, b) => a + b.open, 0),
|
|
34
|
+
pending: reduce(stats, (a, b) => a + b.pending, 0),
|
|
35
|
+
closed: reduce(stats, (a, b) => a + b.closed, 0),
|
|
36
|
+
rejected: reduce(stats, (a, b) => a + b.rejected, 0),
|
|
37
|
+
fulfilled: reduce(stats, (a, b) => a + b.fulfilled, 0),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './enriched-document-assignment.view.js';
|
|
2
|
+
export * from './enriched-document-category.view.js';
|
|
3
|
+
export * from './enriched-document-collection.view.js';
|
|
4
|
+
export * from './enriched-document-file.view.js';
|
|
5
|
+
export * from './enriched-document-management-data.view.js';
|
|
6
|
+
export * from './enriched-document-request.view.js';
|
|
7
|
+
export * from './enriched-document-type.view.js';
|
|
8
|
+
export * from './enriched-document.view.js';
|
|
9
|
+
export * from './enriched.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './enriched-document-assignment.view.js';
|
|
2
|
+
export * from './enriched-document-category.view.js';
|
|
3
|
+
export * from './enriched-document-collection.view.js';
|
|
4
|
+
export * from './enriched-document-file.view.js';
|
|
5
|
+
export * from './enriched-document-management-data.view.js';
|
|
6
|
+
export * from './enriched-document-request.view.js';
|
|
7
|
+
export * from './enriched-document-type.view.js';
|
|
8
|
+
export * from './enriched-document.view.js';
|
|
9
|
+
export * from './enriched.js';
|
|
@@ -2,7 +2,7 @@ export * from './categories-and-types.view-model.js';
|
|
|
2
2
|
export * from './document-folders.view-model.js';
|
|
3
3
|
export * from './document-requests-template.view-model.js';
|
|
4
4
|
export * from './document.service-model.js';
|
|
5
|
-
export * from './document.view-model.js';
|
|
6
|
-
export * from './
|
|
5
|
+
export * from './document-management.view-model.js';
|
|
6
|
+
export * from './enriched/index.js';
|
|
7
7
|
export * from './normalized-requests-template-data.model.js';
|
|
8
8
|
export * from './stats.view-model.js';
|
|
@@ -2,7 +2,7 @@ export * from './categories-and-types.view-model.js';
|
|
|
2
2
|
export * from './document-folders.view-model.js';
|
|
3
3
|
export * from './document-requests-template.view-model.js';
|
|
4
4
|
export * from './document.service-model.js';
|
|
5
|
-
export * from './document.view-model.js';
|
|
6
|
-
export * from './
|
|
5
|
+
export * from './document-management.view-model.js';
|
|
6
|
+
export * from './enriched/index.js';
|
|
7
7
|
export * from './normalized-requests-template-data.model.js';
|
|
8
8
|
export * from './stats.view-model.js';
|
package/document-management/models/service-models/normalized-requests-template-data.model.d.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import type { TypedOmit } from '../../../types.js';
|
|
2
2
|
import type { DocumentRequestTemplate } from '../document-request-template.js';
|
|
3
3
|
import type { DocumentRequestsTemplateData, DocumentRequestsTemplateView } from './document-requests-template.view-model.js';
|
|
4
|
-
import type {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
import type { EnrichedDocumentCategory } from './enriched/enriched-document-category.view.js';
|
|
5
|
+
import type { EnrichedDocumentManagementData } from './enriched/enriched-document-management-data.view.js';
|
|
6
|
+
import type { EnrichedDocumentType } from './enriched/enriched-document-type.view.js';
|
|
7
|
+
export type EnrichedDocumentRequestsTemplateData = TypedOmit<DocumentRequestsTemplateData, 'templates'> & {
|
|
8
|
+
templates: EnrichedDocumentRequestsTemplateView[];
|
|
9
|
+
categories: EnrichedDocumentCategory[];
|
|
10
|
+
types: EnrichedDocumentType[];
|
|
9
11
|
};
|
|
10
|
-
export type
|
|
11
|
-
requestTemplates:
|
|
12
|
+
export type EnrichedDocumentRequestsTemplateView = TypedOmit<DocumentRequestsTemplateView, 'requestTemplates'> & {
|
|
13
|
+
requestTemplates: EnrichedDocumentRequestTemplate[];
|
|
12
14
|
};
|
|
13
|
-
export type
|
|
14
|
-
type:
|
|
15
|
+
export type EnrichedDocumentRequestTemplate = TypedOmit<DocumentRequestTemplate, 'typeId'> & {
|
|
16
|
+
type: EnrichedDocumentType;
|
|
15
17
|
};
|
|
16
|
-
export declare function
|
|
18
|
+
export declare function toEnrichedDocumentRequestsTemplateData(templateData: DocumentRequestsTemplateData, documentManagementData: EnrichedDocumentManagementData): EnrichedDocumentRequestsTemplateData;
|
package/document-management/models/service-models/normalized-requests-template-data.model.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import { assertDefinedPass } from '../../../utils/type-guards.js';
|
|
2
|
+
export function toEnrichedDocumentRequestsTemplateData(templateData, documentManagementData) {
|
|
2
3
|
return {
|
|
3
4
|
templates: templateData.templates.map((template) => ({
|
|
4
5
|
...template,
|
|
5
6
|
requestTemplates: template.requestTemplates.map((requestTemplate) => ({
|
|
6
7
|
...requestTemplate,
|
|
7
|
-
type: documentManagementData.types.
|
|
8
|
-
}))
|
|
8
|
+
type: assertDefinedPass(documentManagementData.maps.types.get(requestTemplate.typeId)),
|
|
9
|
+
})),
|
|
9
10
|
})),
|
|
10
11
|
categories: documentManagementData.categories,
|
|
11
|
-
types: documentManagementData.types
|
|
12
|
+
types: documentManagementData.types,
|
|
12
13
|
};
|
|
13
14
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
export declare class
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
export declare class RequestStats {
|
|
2
|
+
total: number;
|
|
3
|
+
documentPending: number;
|
|
4
|
+
approvalPending: number;
|
|
5
|
+
approvals: number;
|
|
6
|
+
rejections: number;
|
|
7
|
+
closedWithoutDocument: number;
|
|
6
8
|
}
|
|
@@ -8,25 +8,35 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
10
|
import { NumberProperty } from '../../../schema/index.js';
|
|
11
|
-
export class
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
export class RequestStats {
|
|
12
|
+
total;
|
|
13
|
+
documentPending;
|
|
14
|
+
approvalPending;
|
|
15
|
+
approvals;
|
|
16
|
+
rejections;
|
|
17
|
+
closedWithoutDocument;
|
|
16
18
|
}
|
|
17
19
|
__decorate([
|
|
18
20
|
NumberProperty(),
|
|
19
21
|
__metadata("design:type", Number)
|
|
20
|
-
],
|
|
22
|
+
], RequestStats.prototype, "total", void 0);
|
|
21
23
|
__decorate([
|
|
22
24
|
NumberProperty(),
|
|
23
25
|
__metadata("design:type", Number)
|
|
24
|
-
],
|
|
26
|
+
], RequestStats.prototype, "documentPending", void 0);
|
|
25
27
|
__decorate([
|
|
26
28
|
NumberProperty(),
|
|
27
29
|
__metadata("design:type", Number)
|
|
28
|
-
],
|
|
30
|
+
], RequestStats.prototype, "approvalPending", void 0);
|
|
29
31
|
__decorate([
|
|
30
32
|
NumberProperty(),
|
|
31
33
|
__metadata("design:type", Number)
|
|
32
|
-
],
|
|
34
|
+
], RequestStats.prototype, "approvals", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
NumberProperty(),
|
|
37
|
+
__metadata("design:type", Number)
|
|
38
|
+
], RequestStats.prototype, "rejections", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
NumberProperty(),
|
|
41
|
+
__metadata("design:type", Number)
|
|
42
|
+
], RequestStats.prototype, "closedWithoutDocument", void 0);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import './schemas.js';
|
|
2
2
|
import { type InjectionToken } from '../../injector/index.js';
|
|
3
3
|
import type { DatabaseConfig } from '../../orm/server/module.js';
|
|
4
|
-
import { DocumentManagementAncillaryService
|
|
4
|
+
import { DocumentManagementAncillaryService } from './services/document-management-ancillary.service.js';
|
|
5
5
|
export declare class DocumentManagementConfig {
|
|
6
6
|
ancillaryService: InjectionToken<DocumentManagementAncillaryService>;
|
|
7
7
|
fileObjectStorageModule: string;
|
|
8
|
+
filePreviewObjectStorageModule: string;
|
|
8
9
|
database?: DatabaseConfig;
|
|
9
|
-
customService?: InjectionToken<DocumentManagementService>;
|
|
10
10
|
}
|
|
11
11
|
export declare function configureDocumentManagement(config: DocumentManagementConfig): void;
|
|
12
12
|
export declare function migrateDocumentManagementSchema(): Promise<void>;
|
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
import './schemas.js';
|
|
2
2
|
import { inject, Injector } from '../../injector/index.js';
|
|
3
3
|
import { Database, migrate } from '../../orm/server/database.js';
|
|
4
|
-
import {
|
|
5
|
-
import { DocumentManagementAncillaryService, DocumentManagementService } from './services/index.js';
|
|
4
|
+
import { DocumentManagementAncillaryService } from './services/document-management-ancillary.service.js';
|
|
6
5
|
export class DocumentManagementConfig {
|
|
7
6
|
ancillaryService;
|
|
8
7
|
fileObjectStorageModule;
|
|
8
|
+
filePreviewObjectStorageModule;
|
|
9
9
|
database;
|
|
10
|
-
customService;
|
|
11
10
|
}
|
|
12
11
|
;
|
|
13
12
|
export function configureDocumentManagement(config) {
|
|
14
13
|
Injector.register(DocumentManagementConfig, { useValue: config });
|
|
15
14
|
Injector.register(DocumentManagementAncillaryService, { useToken: config.ancillaryService });
|
|
16
|
-
if (isDefined(config.customService)) {
|
|
17
|
-
Injector.register(DocumentManagementService, { useToken: config.customService });
|
|
18
|
-
}
|
|
19
15
|
}
|
|
20
16
|
export async function migrateDocumentManagementSchema() {
|
|
21
17
|
const connection = inject(DocumentManagementConfig, undefined, { optional: true })?.database?.connection;
|
|
@@ -23,6 +19,6 @@ export async function migrateDocumentManagementSchema() {
|
|
|
23
19
|
await migrate(database, {
|
|
24
20
|
migrationsSchema: 'document_management',
|
|
25
21
|
migrationsTable: '_migrations',
|
|
26
|
-
migrationsFolder: import.meta.resolve('./drizzle').replace('file://', '')
|
|
22
|
+
migrationsFolder: import.meta.resolve('./drizzle').replace('file://', ''),
|
|
27
23
|
});
|
|
28
24
|
}
|
|
@@ -1,36 +1,31 @@
|
|
|
1
|
-
import { DocumentCategory } from '../models/
|
|
2
|
-
import { DocumentCollectionDocument } from '../models/document-collection-document.model.js';
|
|
3
|
-
import { DocumentCollection } from '../models/document-collection.model.js';
|
|
4
|
-
import { DocumentFile } from '../models/document-file.model.js';
|
|
5
|
-
import { DocumentPropertyValue, DocumentRequestAssignmentTaskPropertyValue, DocumentRequestFilePropertyValue } from '../models/document-property-value.model.js';
|
|
6
|
-
import { DocumentProperty } from '../models/document-property.model.js';
|
|
7
|
-
import { DocumentRequestAssignmentTaskCollection } from '../models/document-request-assignment-task-collection.model.js';
|
|
8
|
-
import { DocumentRequestAssignmentTask } from '../models/document-request-assignment-task.model.js';
|
|
9
|
-
import { DocumentRequestCollection } from '../models/document-request-collection.model.js';
|
|
10
|
-
import { DocumentRequestFile } from '../models/document-request-file.model.js';
|
|
11
|
-
import { DocumentRequestTemplate } from '../models/document-request-template.js';
|
|
12
|
-
import { DocumentRequest } from '../models/document-request.model.js';
|
|
13
|
-
import { DocumentRequestsTemplate } from '../models/document-requests-template.js';
|
|
14
|
-
import { DocumentTypeProperty } from '../models/document-type-property.model.js';
|
|
15
|
-
import { DocumentType } from '../models/document-type.model.js';
|
|
16
|
-
import { Document } from '../models/document.model.js';
|
|
1
|
+
import { Document, DocumentAssignmentScope, DocumentAssignmentTask, DocumentCategory, DocumentCollection, DocumentCollectionAssignment, DocumentFile, DocumentProperty, DocumentPropertyValue, DocumentRequest, DocumentRequestCollection, DocumentRequestsTemplate, DocumentRequestSubmission, DocumentRequestTemplate, DocumentType, DocumentTypeProperty, DocumentTypeValidation, DocumentValidationDefinition, DocumentValidationExecution, DocumentValidationExecutionRelatedDocument, DocumentWorkflow } from '../models/index.js';
|
|
17
2
|
export declare const documentManagementSchema: import("../../orm/server/database-schema.js").DatabaseSchema<"document_management">;
|
|
18
|
-
export declare const
|
|
3
|
+
export declare const aocumentApproval: import("drizzle-orm/pg-core").PgEnum<["pending", "approved", "rejected"]>;
|
|
4
|
+
export declare const documentAssignmentCollectionTarget: import("drizzle-orm/pg-core").PgEnum<["request", "collection"]>;
|
|
5
|
+
export declare const documentPropertyDataType: import("drizzle-orm/pg-core").PgEnum<["boolean", "date", "decimal", "text", "integer"]>;
|
|
6
|
+
export declare const documentRequestState: import("drizzle-orm/pg-core").PgEnum<["open", "closed", "fulfilled"]>;
|
|
7
|
+
export declare const documentValidationExecutionState: import("drizzle-orm/pg-core").PgEnum<["pending", "error", "running", "completed"]>;
|
|
8
|
+
export declare const documentValidationResultStatus: import("drizzle-orm/pg-core").PgEnum<["warning", "failed", "passed"]>;
|
|
9
|
+
export declare const documentWorkflowState: import("drizzle-orm/pg-core").PgEnum<["pending", "error", "running", "completed", "failed"]>;
|
|
10
|
+
export declare const documentWorkflowStep: import("drizzle-orm/pg-core").PgEnum<["classification", "extraction", "assignment", "validation"]>;
|
|
19
11
|
export declare const document: import("../../orm/server/types.js").PgTableFromType<typeof Document, "document_management">;
|
|
12
|
+
export declare const documentAssignmentScope: import("../../orm/server/types.js").PgTableFromType<typeof DocumentAssignmentScope, "document_management">;
|
|
13
|
+
export declare const documentAssignmentTask: import("../../orm/server/types.js").PgTableFromType<typeof DocumentAssignmentTask, "document_management">;
|
|
20
14
|
export declare const documentCategory: import("../../orm/server/types.js").PgTableFromType<typeof DocumentCategory, "document_management">;
|
|
21
15
|
export declare const documentCollection: import("../../orm/server/types.js").PgTableFromType<typeof DocumentCollection, "document_management">;
|
|
22
|
-
export declare const
|
|
16
|
+
export declare const documentCollectionAssignment: import("../../orm/server/types.js").PgTableFromType<typeof DocumentCollectionAssignment, "document_management">;
|
|
23
17
|
export declare const documentFile: import("../../orm/server/types.js").PgTableFromType<typeof DocumentFile, "document_management">;
|
|
24
18
|
export declare const documentProperty: import("../../orm/server/types.js").PgTableFromType<typeof DocumentProperty, "document_management">;
|
|
25
19
|
export declare const documentPropertyValue: import("../../orm/server/types.js").PgTableFromType<typeof DocumentPropertyValue, "document_management">;
|
|
26
20
|
export declare const documentRequest: import("../../orm/server/types.js").PgTableFromType<typeof DocumentRequest, "document_management">;
|
|
27
|
-
export declare const documentRequestAssignmentTask: import("../../orm/server/types.js").PgTableFromType<typeof DocumentRequestAssignmentTask, "document_management">;
|
|
28
|
-
export declare const documentRequestAssignmentTaskCollection: import("../../orm/server/types.js").PgTableFromType<typeof DocumentRequestAssignmentTaskCollection, "document_management">;
|
|
29
|
-
export declare const documentRequestAssignmentTaskPropertyValue: import("../../orm/server/types.js").PgTableFromType<typeof DocumentRequestAssignmentTaskPropertyValue, "document_management">;
|
|
30
21
|
export declare const documentRequestCollection: import("../../orm/server/types.js").PgTableFromType<typeof DocumentRequestCollection, "document_management">;
|
|
31
|
-
export declare const documentRequestFile: import("../../orm/server/types.js").PgTableFromType<typeof DocumentRequestFile, "document_management">;
|
|
32
|
-
export declare const documentRequestFilePropertyValue: import("../../orm/server/types.js").PgTableFromType<typeof DocumentRequestFilePropertyValue, "document_management">;
|
|
33
22
|
export declare const documentRequestsTemplate: import("../../orm/server/types.js").PgTableFromType<typeof DocumentRequestsTemplate, "document_management">;
|
|
23
|
+
export declare const documentRequestSubmission: import("../../orm/server/types.js").PgTableFromType<typeof DocumentRequestSubmission, "document_management">;
|
|
34
24
|
export declare const documentRequestTemplate: import("../../orm/server/types.js").PgTableFromType<typeof DocumentRequestTemplate, "document_management">;
|
|
35
25
|
export declare const documentType: import("../../orm/server/types.js").PgTableFromType<typeof DocumentType, "document_management">;
|
|
36
26
|
export declare const documentTypeProperty: import("../../orm/server/types.js").PgTableFromType<typeof DocumentTypeProperty, "document_management">;
|
|
27
|
+
export declare const documentTypeValidation: import("../../orm/server/types.js").PgTableFromType<typeof DocumentTypeValidation, "document_management">;
|
|
28
|
+
export declare const documentValidationDefinition: import("../../orm/server/types.js").PgTableFromType<typeof DocumentValidationDefinition, "document_management">;
|
|
29
|
+
export declare const documentValidationExecution: import("../../orm/server/types.js").PgTableFromType<typeof DocumentValidationExecution, "document_management">;
|
|
30
|
+
export declare const documentValidationExecutionRelatedDocument: import("../../orm/server/types.js").PgTableFromType<typeof DocumentValidationExecutionRelatedDocument, "document_management">;
|
|
31
|
+
export declare const documentWorkflow: import("../../orm/server/types.js").PgTableFromType<typeof DocumentWorkflow, "document_management">;
|
|
@@ -1,37 +1,32 @@
|
|
|
1
1
|
import { databaseSchema } from '../../orm/server/database-schema.js';
|
|
2
|
-
import { DocumentCategory } from '../models/
|
|
3
|
-
import { DocumentCollectionDocument } from '../models/document-collection-document.model.js';
|
|
4
|
-
import { DocumentCollection } from '../models/document-collection.model.js';
|
|
5
|
-
import { DocumentFile } from '../models/document-file.model.js';
|
|
6
|
-
import { DocumentPropertyValue, DocumentRequestAssignmentTaskPropertyValue, DocumentRequestFilePropertyValue } from '../models/document-property-value.model.js';
|
|
7
|
-
import { DocumentProperty, DocumentPropertyDataType } from '../models/document-property.model.js';
|
|
8
|
-
import { DocumentRequestAssignmentTaskCollection } from '../models/document-request-assignment-task-collection.model.js';
|
|
9
|
-
import { DocumentRequestAssignmentTask } from '../models/document-request-assignment-task.model.js';
|
|
10
|
-
import { DocumentRequestCollection } from '../models/document-request-collection.model.js';
|
|
11
|
-
import { DocumentRequestFile } from '../models/document-request-file.model.js';
|
|
12
|
-
import { DocumentRequestTemplate } from '../models/document-request-template.js';
|
|
13
|
-
import { DocumentRequest } from '../models/document-request.model.js';
|
|
14
|
-
import { DocumentRequestsTemplate } from '../models/document-requests-template.js';
|
|
15
|
-
import { DocumentTypeProperty } from '../models/document-type-property.model.js';
|
|
16
|
-
import { DocumentType } from '../models/document-type.model.js';
|
|
17
|
-
import { Document } from '../models/document.model.js';
|
|
2
|
+
import { Document, DocumentApproval, DocumentAssignmentScope, DocumentAssignmentTarget, DocumentAssignmentTask, DocumentCategory, DocumentCollection, DocumentCollectionAssignment, DocumentFile, DocumentProperty, DocumentPropertyDataType, DocumentPropertyValue, DocumentRequest, DocumentRequestCollection, DocumentRequestState, DocumentRequestsTemplate, DocumentRequestSubmission, DocumentRequestTemplate, DocumentType, DocumentTypeProperty, DocumentTypeValidation, DocumentValidationDefinition, DocumentValidationExecution, DocumentValidationExecutionRelatedDocument, DocumentValidationExecutionState, DocumentValidationResultStatus, DocumentWorkflow, DocumentWorkflowState, DocumentWorkflowStep } from '../models/index.js';
|
|
18
3
|
export const documentManagementSchema = databaseSchema('document_management');
|
|
19
|
-
export const
|
|
4
|
+
export const aocumentApproval = documentManagementSchema.getEnum(DocumentApproval);
|
|
5
|
+
export const documentAssignmentCollectionTarget = documentManagementSchema.getEnum(DocumentAssignmentTarget);
|
|
6
|
+
export const documentPropertyDataType = documentManagementSchema.getEnum(DocumentPropertyDataType);
|
|
7
|
+
export const documentRequestState = documentManagementSchema.getEnum(DocumentRequestState);
|
|
8
|
+
export const documentValidationExecutionState = documentManagementSchema.getEnum(DocumentValidationExecutionState);
|
|
9
|
+
export const documentValidationResultStatus = documentManagementSchema.getEnum(DocumentValidationResultStatus);
|
|
10
|
+
export const documentWorkflowState = documentManagementSchema.getEnum(DocumentWorkflowState);
|
|
11
|
+
export const documentWorkflowStep = documentManagementSchema.getEnum(DocumentWorkflowStep);
|
|
20
12
|
export const document = documentManagementSchema.getTable(Document);
|
|
13
|
+
export const documentAssignmentScope = documentManagementSchema.getTable(DocumentAssignmentScope);
|
|
14
|
+
export const documentAssignmentTask = documentManagementSchema.getTable(DocumentAssignmentTask);
|
|
21
15
|
export const documentCategory = documentManagementSchema.getTable(DocumentCategory);
|
|
22
16
|
export const documentCollection = documentManagementSchema.getTable(DocumentCollection);
|
|
23
|
-
export const
|
|
17
|
+
export const documentCollectionAssignment = documentManagementSchema.getTable(DocumentCollectionAssignment);
|
|
24
18
|
export const documentFile = documentManagementSchema.getTable(DocumentFile);
|
|
25
19
|
export const documentProperty = documentManagementSchema.getTable(DocumentProperty);
|
|
26
20
|
export const documentPropertyValue = documentManagementSchema.getTable(DocumentPropertyValue);
|
|
27
21
|
export const documentRequest = documentManagementSchema.getTable(DocumentRequest);
|
|
28
|
-
export const documentRequestAssignmentTask = documentManagementSchema.getTable(DocumentRequestAssignmentTask);
|
|
29
|
-
export const documentRequestAssignmentTaskCollection = documentManagementSchema.getTable(DocumentRequestAssignmentTaskCollection);
|
|
30
|
-
export const documentRequestAssignmentTaskPropertyValue = documentManagementSchema.getTable(DocumentRequestAssignmentTaskPropertyValue);
|
|
31
22
|
export const documentRequestCollection = documentManagementSchema.getTable(DocumentRequestCollection);
|
|
32
|
-
export const documentRequestFile = documentManagementSchema.getTable(DocumentRequestFile);
|
|
33
|
-
export const documentRequestFilePropertyValue = documentManagementSchema.getTable(DocumentRequestFilePropertyValue);
|
|
34
23
|
export const documentRequestsTemplate = documentManagementSchema.getTable(DocumentRequestsTemplate);
|
|
24
|
+
export const documentRequestSubmission = documentManagementSchema.getTable(DocumentRequestSubmission);
|
|
35
25
|
export const documentRequestTemplate = documentManagementSchema.getTable(DocumentRequestTemplate);
|
|
36
26
|
export const documentType = documentManagementSchema.getTable(DocumentType);
|
|
37
27
|
export const documentTypeProperty = documentManagementSchema.getTable(DocumentTypeProperty);
|
|
28
|
+
export const documentTypeValidation = documentManagementSchema.getTable(DocumentTypeValidation);
|
|
29
|
+
export const documentValidationDefinition = documentManagementSchema.getTable(DocumentValidationDefinition);
|
|
30
|
+
export const documentValidationExecution = documentManagementSchema.getTable(DocumentValidationExecution);
|
|
31
|
+
export const documentValidationExecutionRelatedDocument = documentManagementSchema.getTable(DocumentValidationExecutionRelatedDocument);
|
|
32
|
+
export const documentWorkflow = documentManagementSchema.getTable(DocumentWorkflow);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { DocumentCategory, DocumentType } from '../../../document-management/models/index.js';
|
|
2
|
+
import type { DocumentCategoryView } from '../../../document-management/models/service-models/index.js';
|
|
3
|
+
import { Transactional } from '../../../orm/server/index.js';
|
|
4
|
+
export declare const enumTypeKey = "enum-type";
|
|
5
|
+
export declare class DocumentCategoryTypeService extends Transactional {
|
|
6
|
+
#private;
|
|
7
|
+
loadCategory(id: string): Promise<DocumentCategory>;
|
|
8
|
+
loadType(id: string): Promise<DocumentType>;
|
|
9
|
+
createCategory(label: string, parentId: string | null, enumKey?: string): Promise<DocumentCategory>;
|
|
10
|
+
createType(label: string, categoryId: string, enumKey?: string): Promise<DocumentType>;
|
|
11
|
+
updateCategory(id: string, update: {
|
|
12
|
+
label?: string;
|
|
13
|
+
parentId?: string | null;
|
|
14
|
+
}): Promise<DocumentCategory>;
|
|
15
|
+
updateType(id: string, update: {
|
|
16
|
+
label?: string;
|
|
17
|
+
categoryId?: string;
|
|
18
|
+
}): Promise<DocumentType>;
|
|
19
|
+
loadCategoryGraph(categoryId: string): Promise<DocumentCategory[]>;
|
|
20
|
+
loadCategoriesAndTypes(): Promise<{
|
|
21
|
+
categories: DocumentCategory[];
|
|
22
|
+
types: DocumentType[];
|
|
23
|
+
}>;
|
|
24
|
+
loadCategoryViews(): Promise<DocumentCategoryView[]>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import { DocumentCategory, DocumentType } from '../../../document-management/models/index.js';
|
|
3
|
+
import { inject } from '../../../injector/inject.js';
|
|
4
|
+
import { Logger } from '../../../logger/logger.js';
|
|
5
|
+
import { Transactional } from '../../../orm/server/index.js';
|
|
6
|
+
import { injectRepository } from '../../../orm/server/repository.js';
|
|
7
|
+
import { groupToMap } from '../../../utils/iterable-helpers/group-to-map.js';
|
|
8
|
+
import { isUndefined } from '../../../utils/type-guards.js';
|
|
9
|
+
export const enumTypeKey = 'enum-type';
|
|
10
|
+
export class DocumentCategoryTypeService extends Transactional {
|
|
11
|
+
#documentCategoryRepository = injectRepository(DocumentCategory);
|
|
12
|
+
#documentTypeRepository = injectRepository(DocumentType);
|
|
13
|
+
#logger = inject(Logger, _a.name);
|
|
14
|
+
async loadCategory(id) {
|
|
15
|
+
return this.#documentCategoryRepository.load(id);
|
|
16
|
+
}
|
|
17
|
+
async loadType(id) {
|
|
18
|
+
return this.#documentTypeRepository.load(id);
|
|
19
|
+
}
|
|
20
|
+
async createCategory(label, parentId, enumKey) {
|
|
21
|
+
return this.#documentCategoryRepository.insert({ label, parentId, metadata: { attributes: { [enumTypeKey]: enumKey } } });
|
|
22
|
+
}
|
|
23
|
+
async createType(label, categoryId, enumKey) {
|
|
24
|
+
return this.#documentTypeRepository.insert({ label, categoryId, metadata: { attributes: { [enumTypeKey]: enumKey } } });
|
|
25
|
+
}
|
|
26
|
+
async updateCategory(id, update) {
|
|
27
|
+
return this.#documentCategoryRepository.update(id, update);
|
|
28
|
+
}
|
|
29
|
+
async updateType(id, update) {
|
|
30
|
+
return this.#documentTypeRepository.update(id, update);
|
|
31
|
+
}
|
|
32
|
+
async loadCategoryGraph(categoryId) {
|
|
33
|
+
const category = await this.#documentCategoryRepository.load(categoryId);
|
|
34
|
+
if (category.parentId == null) {
|
|
35
|
+
return [category];
|
|
36
|
+
}
|
|
37
|
+
const parents = await this.loadCategoryGraph(category.parentId);
|
|
38
|
+
return [...parents, category];
|
|
39
|
+
}
|
|
40
|
+
async loadCategoriesAndTypes() {
|
|
41
|
+
const [categories, types] = await Promise.all([
|
|
42
|
+
this.#documentCategoryRepository.loadManyByQuery({}, { order: 'label' }),
|
|
43
|
+
this.#documentTypeRepository.loadManyByQuery({}, { order: 'label' }),
|
|
44
|
+
]);
|
|
45
|
+
return { categories, types };
|
|
46
|
+
}
|
|
47
|
+
async loadCategoryViews() {
|
|
48
|
+
const { categories, types } = await this.loadCategoriesAndTypes();
|
|
49
|
+
const categoryChildrenMap = groupToMap(categories, (category) => category.parentId);
|
|
50
|
+
const categoryTypesMap = groupToMap(types, (type) => type.categoryId);
|
|
51
|
+
const rootCategories = categoryChildrenMap.get(null);
|
|
52
|
+
if (isUndefined(rootCategories)) {
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
55
|
+
return rootCategories.map((category) => getView(category, categoryChildrenMap, categoryTypesMap));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
_a = DocumentCategoryTypeService;
|
|
59
|
+
function getView(category, categoryChildrenMap, categoryTypesMap) {
|
|
60
|
+
const childCategories = categoryChildrenMap.get(category.id) ?? [];
|
|
61
|
+
return {
|
|
62
|
+
...category,
|
|
63
|
+
children: childCategories.map((c) => getView(c, categoryChildrenMap, categoryTypesMap)),
|
|
64
|
+
types: categoryTypesMap.get(category.id) ?? [],
|
|
65
|
+
};
|
|
66
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Query } from '../../../orm/index.js';
|
|
2
|
+
import { Transactional } from '../../../orm/server/index.js';
|
|
3
|
+
import type { OneOrMany } from '../../../types.js';
|
|
4
|
+
import { Document, DocumentCollection } from '../../models/index.js';
|
|
5
|
+
export declare class DocumentCollectionService extends Transactional {
|
|
6
|
+
#private;
|
|
7
|
+
readonly repository: import("../../../orm/server/repository.js").EntityRepository<DocumentCollection>;
|
|
8
|
+
loadCollectionGraph(collectionId: string): Promise<DocumentCollection[]>;
|
|
9
|
+
createCollection(parentId: string | null): Promise<DocumentCollection>;
|
|
10
|
+
collectionHasDocumentByFilter(collectionId: string, filter: Query<Document>): Promise<boolean>;
|
|
11
|
+
assignDocument(documentId: string, collectionIds: OneOrMany<string>): Promise<void>;
|
|
12
|
+
archiveDocument(documentId: string, collectionIds: OneOrMany<string>): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { and, eq, sql } from 'drizzle-orm';
|
|
2
|
+
import { TRANSACTION_TIMESTAMP } from '../../../orm/index.js';
|
|
3
|
+
import { Transactional } from '../../../orm/server/index.js';
|
|
4
|
+
import { injectRepository } from '../../../orm/server/repository.js';
|
|
5
|
+
import { toArray } from '../../../utils/array/index.js';
|
|
6
|
+
import { Document, DocumentCollection, DocumentCollectionAssignment } from '../../models/index.js';
|
|
7
|
+
import { document, documentCollectionAssignment } from '../schemas.js';
|
|
8
|
+
export class DocumentCollectionService extends Transactional {
|
|
9
|
+
#documentRepository = injectRepository(Document);
|
|
10
|
+
#documentCollectionAssignmentRepository = injectRepository(DocumentCollectionAssignment);
|
|
11
|
+
repository = injectRepository(DocumentCollection);
|
|
12
|
+
async loadCollectionGraph(collectionId) {
|
|
13
|
+
const collection = await this.repository.load(collectionId);
|
|
14
|
+
if (collection.parentId == null) {
|
|
15
|
+
return [collection];
|
|
16
|
+
}
|
|
17
|
+
const parents = await this.loadCollectionGraph(collection.parentId);
|
|
18
|
+
return [...parents, collection];
|
|
19
|
+
}
|
|
20
|
+
async createCollection(parentId) {
|
|
21
|
+
return this.repository.withSession(this.session).insert({ parentId });
|
|
22
|
+
}
|
|
23
|
+
async collectionHasDocumentByFilter(collectionId, filter) {
|
|
24
|
+
const matchingDocuments = this.session
|
|
25
|
+
.select()
|
|
26
|
+
.from(documentCollectionAssignment)
|
|
27
|
+
.leftJoin(document, eq(document.id, documentCollectionAssignment.documentId))
|
|
28
|
+
.where(and(eq(documentCollectionAssignment.collectionId, collectionId), this.#documentRepository.convertQuery(filter)));
|
|
29
|
+
const result = await this.session.execute(sql `SELECT EXISTS(SELECT 1 FROM ${matchingDocuments}))`);
|
|
30
|
+
console.log(result);
|
|
31
|
+
throw new Error('verify');
|
|
32
|
+
// return result[0]!;
|
|
33
|
+
}
|
|
34
|
+
async assignDocument(documentId, collectionIds) {
|
|
35
|
+
const values = toArray(collectionIds).map((collectionId) => ({ collectionId, documentId, archiveTimestamp: null }));
|
|
36
|
+
await this.#documentCollectionAssignmentRepository.withSession(this.session).upsertMany(['collectionId', 'documentId'], values);
|
|
37
|
+
}
|
|
38
|
+
async archiveDocument(documentId, collectionIds) {
|
|
39
|
+
await this.#documentCollectionAssignmentRepository.withSession(this.session).updateManyByQuery({ collectionId: { $in: toArray(collectionIds) }, documentId, archiveTimestamp: null }, { archiveTimestamp: TRANSACTION_TIMESTAMP });
|
|
40
|
+
}
|
|
41
|
+
}
|