@tstdl/base 0.93.95 → 0.93.96
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/document-management/api/document-management.api.d.ts +19 -1
- package/document-management/api/document-management.api.js +8 -4
- package/document-management/models/document-category.model.d.ts +1 -0
- package/document-management/models/document-category.model.js +7 -1
- package/document-management/models/document-property.model.d.ts +1 -0
- package/document-management/models/document-property.model.js +7 -1
- package/document-management/models/document-type.model.d.ts +1 -0
- package/document-management/models/document-type.model.js +7 -1
- package/document-management/models/document-workflow.model.d.ts +1 -0
- package/document-management/models/document-workflow.model.js +6 -1
- package/document-management/server/api/document-management.api.d.ts +1 -0
- package/document-management/server/api/document-management.api.js +8 -7
- package/document-management/server/drizzle/{0000_glamorous_lorna_dane.sql → 0000_needy_steel_serpent.sql} +7 -0
- package/document-management/server/drizzle/meta/0000_snapshot.json +49 -1
- package/document-management/server/drizzle/meta/_journal.json +2 -2
- package/document-management/server/module.d.ts +1 -0
- package/document-management/server/module.js +1 -0
- package/document-management/server/services/document-category-type.service.d.ts +8 -3
- package/document-management/server/services/document-category-type.service.js +49 -6
- package/document-management/server/services/document-management.service.js +17 -15
- package/document-management/server/services/document-property.service.d.ts +3 -1
- package/document-management/server/services/document-property.service.js +23 -2
- package/document-management/server/services/document-validation.service.js +2 -1
- package/document-management/server/services/document-workflow.service.d.ts +3 -3
- package/document-management/server/services/document-workflow.service.js +34 -15
- package/document-management/server/services/document.service.d.ts +1 -1
- package/document-management/server/services/document.service.js +7 -2
- package/document-management/service-models/categories-and-types.view-model.d.ts +6 -0
- package/document-management/service-models/categories-and-types.view-model.js +18 -0
- package/document-management/service-models/document-management.view-model.d.ts +1 -0
- package/document-management/service-models/document-management.view-model.js +5 -0
- package/document-management/service-models/document.service-model.d.ts +7 -0
- package/document-management/service-models/document.service-model.js +7 -1
- package/document-management/service-models/enriched/enriched-document-category.view.d.ts +1 -0
- package/document-management/service-models/enriched/enriched-document-category.view.js +2 -0
- package/document-management/service-models/enriched/enriched-document-type.view.d.ts +1 -0
- package/document-management/service-models/enriched/enriched-document-type.view.js +2 -0
- package/document-management/tests/document-management-core.test.d.ts +1 -0
- package/document-management/tests/document-management-core.test.js +162 -0
- package/document-management/tests/document.service.test.d.ts +1 -0
- package/document-management/tests/document.service.test.js +139 -0
- package/document-management/tests/enum-helpers.test.d.ts +1 -0
- package/document-management/tests/enum-helpers.test.js +452 -0
- package/document-management/tests/helper.d.ts +24 -0
- package/document-management/tests/helper.js +39 -0
- package/package.json +5 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DataStream } from '../../sse/index.js';
|
|
2
2
|
import { Document, DocumentCategory, DocumentRequest, DocumentRequestsTemplate, DocumentRequestTemplate, DocumentType } from '../models/index.js';
|
|
3
|
-
import { DocumentCategoryView, DocumentManagementData, DocumentRequestsTemplateData } from '../service-models/index.js';
|
|
3
|
+
import { CategoriesAndTypesData, DocumentCategoryView, DocumentManagementData, DocumentRequestsTemplateData } from '../service-models/index.js';
|
|
4
4
|
export type DocumentManagementApiDefinition = typeof documentManagementApiDefinition;
|
|
5
5
|
export declare const documentManagementApiDefinition: {
|
|
6
6
|
resource: string;
|
|
@@ -14,6 +14,12 @@ export declare const documentManagementApiDefinition: {
|
|
|
14
14
|
result: typeof DocumentManagementData;
|
|
15
15
|
credentials: true;
|
|
16
16
|
};
|
|
17
|
+
getCategoriesAndTypes: {
|
|
18
|
+
resource: string;
|
|
19
|
+
method: "GET";
|
|
20
|
+
result: typeof CategoriesAndTypesData;
|
|
21
|
+
credentials: true;
|
|
22
|
+
};
|
|
17
23
|
loadDataStream: {
|
|
18
24
|
resource: string;
|
|
19
25
|
method: "GET";
|
|
@@ -153,6 +159,8 @@ export declare const documentManagementApiDefinition: {
|
|
|
153
159
|
}> | undefined;
|
|
154
160
|
}[] | undefined;
|
|
155
161
|
tags?: string[] | undefined;
|
|
162
|
+
skipAi?: boolean | undefined;
|
|
163
|
+
skipWorkflow?: boolean | undefined;
|
|
156
164
|
metadata?: Partial<{
|
|
157
165
|
attributes: import("../../orm/types.js").HasDefault<import("../../orm/types.js").Json<import("../../orm/entity.js").EntityMetadataAttributes>>;
|
|
158
166
|
}> | undefined;
|
|
@@ -354,6 +362,7 @@ export declare const documentManagementApiDefinition: {
|
|
|
354
362
|
method: "POST";
|
|
355
363
|
parameters: import("../../schema/index.js").ObjectSchema<{
|
|
356
364
|
id: string;
|
|
365
|
+
state: "error" | "pending" | "running" | "completed" | "review" | "failed";
|
|
357
366
|
}>;
|
|
358
367
|
result: import("../../schema/index.js").LiteralSchema<"ok">;
|
|
359
368
|
credentials: true;
|
|
@@ -414,6 +423,12 @@ declare const _DocumentManagementApi: import("../../api/client/index.js").ApiCli
|
|
|
414
423
|
result: typeof DocumentManagementData;
|
|
415
424
|
credentials: true;
|
|
416
425
|
};
|
|
426
|
+
getCategoriesAndTypes: {
|
|
427
|
+
resource: string;
|
|
428
|
+
method: "GET";
|
|
429
|
+
result: typeof CategoriesAndTypesData;
|
|
430
|
+
credentials: true;
|
|
431
|
+
};
|
|
417
432
|
loadDataStream: {
|
|
418
433
|
resource: string;
|
|
419
434
|
method: "GET";
|
|
@@ -553,6 +568,8 @@ declare const _DocumentManagementApi: import("../../api/client/index.js").ApiCli
|
|
|
553
568
|
}> | undefined;
|
|
554
569
|
}[] | undefined;
|
|
555
570
|
tags?: string[] | undefined;
|
|
571
|
+
skipAi?: boolean | undefined;
|
|
572
|
+
skipWorkflow?: boolean | undefined;
|
|
556
573
|
metadata?: Partial<{
|
|
557
574
|
attributes: import("../../orm/types.js").HasDefault<import("../../orm/types.js").Json<import("../../orm/entity.js").EntityMetadataAttributes>>;
|
|
558
575
|
}> | undefined;
|
|
@@ -754,6 +771,7 @@ declare const _DocumentManagementApi: import("../../api/client/index.js").ApiCli
|
|
|
754
771
|
method: "POST";
|
|
755
772
|
parameters: import("../../schema/index.js").ObjectSchema<{
|
|
756
773
|
id: string;
|
|
774
|
+
state: "error" | "pending" | "running" | "completed" | "review" | "failed";
|
|
757
775
|
}>;
|
|
758
776
|
result: import("../../schema/index.js").LiteralSchema<"ok">;
|
|
759
777
|
credentials: true;
|
|
@@ -13,7 +13,7 @@ import { array, boolean, literal, number, object, optional, string } from '../..
|
|
|
13
13
|
import { DataStream } from '../../sse/index.js';
|
|
14
14
|
import { policy } from '../authorization/index.js';
|
|
15
15
|
import { Document, DocumentCategory, DocumentRequest, DocumentRequestsTemplate, DocumentRequestTemplate, DocumentType } from '../models/index.js';
|
|
16
|
-
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';
|
|
16
|
+
import { addOrArchiveDocumentToOrFromCollectionParametersSchema, applyDocumentRequestsTemplateParametersSchema, CategoriesAndTypesData, createDocumentCategoryParametersSchema, createDocumentParametersSchema, createDocumentRequestParametersSchema, createDocumentRequestsTemplateParametersSchema, createDocumentRequestTemplateParametersSchema, createDocumentTypeParametersSchema, deleteDocumentRequestParametersSchema, deleteDocumentRequestsTemplateParametersSchema, deleteDocumentRequestTemplateParametersSchema, DocumentCategoryView, DocumentManagementData, DocumentRequestsTemplateData, loadDataParametersSchema, proceedDocumentWorkflowParametersSchema, updateDocumentParametersSchema, updateDocumentRequestParametersSchema, updateDocumentRequestsTemplateParametersSchema, updateDocumentRequestTemplateParametersSchema } from '../service-models/index.js';
|
|
17
17
|
export const documentManagementApiDefinition = defineApi({
|
|
18
18
|
resource: 'document-management',
|
|
19
19
|
endpoints: {
|
|
@@ -24,6 +24,12 @@ export const documentManagementApiDefinition = defineApi({
|
|
|
24
24
|
result: DocumentManagementData,
|
|
25
25
|
credentials: true,
|
|
26
26
|
},
|
|
27
|
+
getCategoriesAndTypes: {
|
|
28
|
+
resource: 'categories-and-types',
|
|
29
|
+
method: 'GET',
|
|
30
|
+
result: CategoriesAndTypesData,
|
|
31
|
+
credentials: true,
|
|
32
|
+
},
|
|
27
33
|
loadDataStream: {
|
|
28
34
|
resource: 'data/stream',
|
|
29
35
|
method: 'GET',
|
|
@@ -212,9 +218,7 @@ export const documentManagementApiDefinition = defineApi({
|
|
|
212
218
|
proceedDocumentWorkflow: {
|
|
213
219
|
resource: 'documents/:id/proceed-workflow',
|
|
214
220
|
method: 'POST',
|
|
215
|
-
parameters:
|
|
216
|
-
id: string(),
|
|
217
|
-
}),
|
|
221
|
+
parameters: proceedDocumentWorkflowParametersSchema,
|
|
218
222
|
result: literal('ok'),
|
|
219
223
|
credentials: true,
|
|
220
224
|
},
|
|
@@ -14,6 +14,7 @@ let DocumentCategory = class DocumentCategory extends TenantEntity {
|
|
|
14
14
|
static entityName = 'DocumentCategory';
|
|
15
15
|
parentId;
|
|
16
16
|
label;
|
|
17
|
+
key;
|
|
17
18
|
};
|
|
18
19
|
__decorate([
|
|
19
20
|
UuidProperty({ nullable: true }),
|
|
@@ -25,8 +26,13 @@ __decorate([
|
|
|
25
26
|
Unique(),
|
|
26
27
|
__metadata("design:type", String)
|
|
27
28
|
], DocumentCategory.prototype, "label", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
StringProperty({ nullable: true }),
|
|
31
|
+
__metadata("design:type", Object)
|
|
32
|
+
], DocumentCategory.prototype, "key", void 0);
|
|
28
33
|
DocumentCategory = __decorate([
|
|
29
34
|
DocumentManagementTable({ name: 'category' }),
|
|
30
|
-
Unique(['tenantId', 'parentId', 'label'])
|
|
35
|
+
Unique(['tenantId', 'parentId', 'label']),
|
|
36
|
+
Unique(['tenantId', 'key'])
|
|
31
37
|
], DocumentCategory);
|
|
32
38
|
export { DocumentCategory };
|
|
@@ -11,5 +11,6 @@ export type DocumentPropertyDataType = EnumType<typeof DocumentPropertyDataType>
|
|
|
11
11
|
export declare class DocumentProperty extends TenantEntity {
|
|
12
12
|
static readonly entityName = "DocumentProperty";
|
|
13
13
|
label: string;
|
|
14
|
+
key: string | null;
|
|
14
15
|
dataType: Enum<DocumentPropertyDataType>;
|
|
15
16
|
}
|
|
@@ -21,6 +21,7 @@ export const DocumentPropertyDataType = defineEnum('DocumentPropertyDataType', {
|
|
|
21
21
|
let DocumentProperty = class DocumentProperty extends TenantEntity {
|
|
22
22
|
static entityName = 'DocumentProperty';
|
|
23
23
|
label;
|
|
24
|
+
key;
|
|
24
25
|
dataType;
|
|
25
26
|
};
|
|
26
27
|
__decorate([
|
|
@@ -28,12 +29,17 @@ __decorate([
|
|
|
28
29
|
Unique(),
|
|
29
30
|
__metadata("design:type", String)
|
|
30
31
|
], DocumentProperty.prototype, "label", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
StringProperty({ nullable: true }),
|
|
34
|
+
__metadata("design:type", Object)
|
|
35
|
+
], DocumentProperty.prototype, "key", void 0);
|
|
31
36
|
__decorate([
|
|
32
37
|
Enumeration(DocumentPropertyDataType),
|
|
33
38
|
__metadata("design:type", Object)
|
|
34
39
|
], DocumentProperty.prototype, "dataType", void 0);
|
|
35
40
|
DocumentProperty = __decorate([
|
|
36
41
|
DocumentManagementTable({ name: 'property' }),
|
|
37
|
-
Unique(['tenantId', 'label'])
|
|
42
|
+
Unique(['tenantId', 'label']),
|
|
43
|
+
Unique(['tenantId', 'key'])
|
|
38
44
|
], DocumentProperty);
|
|
39
45
|
export { DocumentProperty };
|
|
@@ -15,6 +15,7 @@ let DocumentType = class DocumentType extends TenantEntity {
|
|
|
15
15
|
static entityName = 'DocumentType';
|
|
16
16
|
categoryId;
|
|
17
17
|
label;
|
|
18
|
+
key;
|
|
18
19
|
};
|
|
19
20
|
__decorate([
|
|
20
21
|
UuidProperty(),
|
|
@@ -25,8 +26,13 @@ __decorate([
|
|
|
25
26
|
StringProperty(),
|
|
26
27
|
__metadata("design:type", String)
|
|
27
28
|
], DocumentType.prototype, "label", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
StringProperty({ nullable: true }),
|
|
31
|
+
__metadata("design:type", Object)
|
|
32
|
+
], DocumentType.prototype, "key", void 0);
|
|
28
33
|
DocumentType = __decorate([
|
|
29
34
|
DocumentManagementTable({ name: 'type' }),
|
|
30
|
-
Unique(['tenantId', 'categoryId', 'label'])
|
|
35
|
+
Unique(['tenantId', 'categoryId', 'label']),
|
|
36
|
+
Unique(['tenantId', 'key'])
|
|
31
37
|
], DocumentType);
|
|
32
38
|
export { DocumentType };
|
|
@@ -30,6 +30,7 @@ export declare class DocumentWorkflow extends TenantEntity {
|
|
|
30
30
|
documentId: Uuid;
|
|
31
31
|
step: DocumentWorkflowStep;
|
|
32
32
|
state: DocumentWorkflowState;
|
|
33
|
+
skipAi: boolean;
|
|
33
34
|
failReason: DocumentWorkflowFailReason | null;
|
|
34
35
|
completeTimestamp: Timestamp | null;
|
|
35
36
|
completeUserId: Uuid | null;
|
|
@@ -9,7 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
};
|
|
10
10
|
import { defineEnum } from '../../enumeration/enumeration.js';
|
|
11
11
|
import { ForeignKey, Index, TenantEntity, TenantReference, TimestampProperty, Unique, UuidProperty } from '../../orm/index.js';
|
|
12
|
-
import { Enumeration } from '../../schema/index.js';
|
|
12
|
+
import { BooleanProperty, Enumeration } from '../../schema/index.js';
|
|
13
13
|
import { DocumentManagementTable } from './document-management-table.js';
|
|
14
14
|
import { Document } from './document.model.js';
|
|
15
15
|
export const DocumentWorkflowStep = defineEnum('DocumentWorkflowStep', {
|
|
@@ -39,6 +39,7 @@ let DocumentWorkflow = class DocumentWorkflow extends TenantEntity {
|
|
|
39
39
|
documentId;
|
|
40
40
|
step;
|
|
41
41
|
state;
|
|
42
|
+
skipAi;
|
|
42
43
|
failReason;
|
|
43
44
|
completeTimestamp;
|
|
44
45
|
completeUserId;
|
|
@@ -56,6 +57,10 @@ __decorate([
|
|
|
56
57
|
Enumeration(DocumentWorkflowState),
|
|
57
58
|
__metadata("design:type", String)
|
|
58
59
|
], DocumentWorkflow.prototype, "state", void 0);
|
|
60
|
+
__decorate([
|
|
61
|
+
BooleanProperty(),
|
|
62
|
+
__metadata("design:type", Boolean)
|
|
63
|
+
], DocumentWorkflow.prototype, "skipAi", void 0);
|
|
59
64
|
__decorate([
|
|
60
65
|
Enumeration(DocumentWorkflowFailReason, { nullable: true }),
|
|
61
66
|
__metadata("design:type", Object)
|
|
@@ -5,6 +5,7 @@ export declare class DocumentManagementApiController implements ApiController<Do
|
|
|
5
5
|
loadData(context: ApiRequestContext<DocumentManagementApiDefinition, 'loadData'>): Promise<ApiServerResult<DocumentManagementApiDefinition, 'loadData'>>;
|
|
6
6
|
loadDataStream(context: ApiRequestContext<DocumentManagementApiDefinition, 'loadDataStream'>): ApiServerResult<DocumentManagementApiDefinition, 'loadDataStream'>;
|
|
7
7
|
loadDocumentRequestsTemplateData(context: ApiRequestContext<DocumentManagementApiDefinition, 'loadDocumentRequestsTemplateData'>): Promise<ApiServerResult<DocumentManagementApiDefinition, 'loadDocumentRequestsTemplateData'>>;
|
|
8
|
+
getCategoriesAndTypes(context: ApiRequestContext<DocumentManagementApiDefinition, 'getCategoriesAndTypes'>): Promise<ApiServerResult<DocumentManagementApiDefinition, 'getCategoriesAndTypes'>>;
|
|
8
9
|
loadAvailableCategories(context: ApiRequestContext<DocumentManagementApiDefinition, 'loadAvailableCategories'>): Promise<ApiServerResult<DocumentManagementApiDefinition, 'loadAvailableCategories'>>;
|
|
9
10
|
loadContent(context: ApiRequestContext<DocumentManagementApiDefinition, 'loadContent'>): Promise<ApiServerResult<DocumentManagementApiDefinition, 'loadContent'>>;
|
|
10
11
|
getContentUrl(context: ApiRequestContext<DocumentManagementApiDefinition, 'getContentUrl'>): Promise<ApiServerResult<DocumentManagementApiDefinition, 'getContentUrl'>>;
|
|
@@ -4,22 +4,19 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
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
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
var _a;
|
|
8
|
-
var DocumentManagementApiController_1;
|
|
9
7
|
import { match, P } from 'ts-pattern';
|
|
10
8
|
import { apiController } from '../../../api/server/index.js';
|
|
11
9
|
import { CancellationSignal } from '../../../cancellation/token.js';
|
|
12
10
|
import { ForbiddenError, NotImplementedError } from '../../../errors/index.js';
|
|
13
11
|
import { HttpServerResponse } from '../../../http/index.js';
|
|
14
12
|
import { inject } from '../../../injector/index.js';
|
|
15
|
-
import { Logger } from '../../../logger/logger.js';
|
|
16
13
|
import { injectRepository } from '../../../orm/server/index.js';
|
|
17
14
|
import { toArray } from '../../../utils/array/index.js';
|
|
18
15
|
import { documentManagementApiDefinition } from '../../api/index.js';
|
|
19
16
|
import { DocumentManagementAuthorizationService } from '../../authorization/index.js';
|
|
20
17
|
import { DocumentRequestCollectionAssignment } from '../../models/document-request-collection-assignment.model.js';
|
|
21
18
|
import { DocumentCategoryTypeService, DocumentFileService, DocumentManagementService, DocumentRequestService, DocumentService, DocumentWorkflowService } from '../services/index.js';
|
|
22
|
-
let DocumentManagementApiController =
|
|
19
|
+
let DocumentManagementApiController = class DocumentManagementApiController {
|
|
23
20
|
#documentManagementService = inject(DocumentManagementService);
|
|
24
21
|
#authorizationService = inject(DocumentManagementAuthorizationService);
|
|
25
22
|
#documentCategoryTypeService = inject(DocumentCategoryTypeService);
|
|
@@ -29,7 +26,6 @@ let DocumentManagementApiController = DocumentManagementApiController_1 = class
|
|
|
29
26
|
#documentService = inject(DocumentService);
|
|
30
27
|
#workflowService = inject(DocumentWorkflowService);
|
|
31
28
|
#cancellationSignal = inject(CancellationSignal);
|
|
32
|
-
#logger = inject(Logger, DocumentManagementApiController_1.name);
|
|
33
29
|
async loadData(context) {
|
|
34
30
|
const token = await context.getToken();
|
|
35
31
|
const tenantId = await this.#authorizationService.getTenantId(token);
|
|
@@ -63,6 +59,11 @@ let DocumentManagementApiController = DocumentManagementApiController_1 = class
|
|
|
63
59
|
}
|
|
64
60
|
return await this.#documentManagementService.loadDocumentRequestsTemplateData(tenantId);
|
|
65
61
|
}
|
|
62
|
+
async getCategoriesAndTypes(context) {
|
|
63
|
+
const token = await context.getToken();
|
|
64
|
+
const tenantId = await this.#authorizationService.getTenantId(token);
|
|
65
|
+
return await this.#documentCategoryTypeService.loadCategoriesAndTypes(tenantId);
|
|
66
|
+
}
|
|
66
67
|
async loadAvailableCategories(context) {
|
|
67
68
|
const token = await context.getToken();
|
|
68
69
|
const tenantId = await this.#authorizationService.getTenantId(token);
|
|
@@ -216,7 +217,7 @@ let DocumentManagementApiController = DocumentManagementApiController_1 = class
|
|
|
216
217
|
const token = await getToken();
|
|
217
218
|
const tenantId = await this.#authorizationService.getTenantId(token);
|
|
218
219
|
const userId = await this.#authorizationService.getSubject(token);
|
|
219
|
-
await this.#workflowService.proceedWorkflow(tenantId, parameters.id, userId);
|
|
220
|
+
await this.#workflowService.proceedWorkflow(tenantId, parameters.id, userId, parameters.state);
|
|
220
221
|
return 'ok';
|
|
221
222
|
}
|
|
222
223
|
async testAuthorization({ parameters, getToken }) {
|
|
@@ -250,7 +251,7 @@ let DocumentManagementApiController = DocumentManagementApiController_1 = class
|
|
|
250
251
|
return false;
|
|
251
252
|
}
|
|
252
253
|
};
|
|
253
|
-
DocumentManagementApiController =
|
|
254
|
+
DocumentManagementApiController = __decorate([
|
|
254
255
|
apiController(documentManagementApiDefinition)
|
|
255
256
|
], DocumentManagementApiController);
|
|
256
257
|
export { DocumentManagementApiController };
|
|
@@ -65,6 +65,7 @@ CREATE TABLE "document_management"."category" (
|
|
|
65
65
|
"tenant_id" uuid NOT NULL,
|
|
66
66
|
"parent_id" uuid,
|
|
67
67
|
"label" text NOT NULL,
|
|
68
|
+
"key" text,
|
|
68
69
|
"revision" integer NOT NULL,
|
|
69
70
|
"revision_timestamp" timestamp with time zone NOT NULL,
|
|
70
71
|
"create_timestamp" timestamp with time zone NOT NULL,
|
|
@@ -72,6 +73,7 @@ CREATE TABLE "document_management"."category" (
|
|
|
72
73
|
"attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
73
74
|
CONSTRAINT "category_tenant_id_id_pk" PRIMARY KEY("tenant_id","id"),
|
|
74
75
|
CONSTRAINT "category_label_unique" UNIQUE("label"),
|
|
76
|
+
CONSTRAINT "category_tenant_id_key_unique" UNIQUE("tenant_id","key"),
|
|
75
77
|
CONSTRAINT "category_tenant_id_parent_id_label_unique" UNIQUE("tenant_id","parent_id","label")
|
|
76
78
|
);
|
|
77
79
|
--> statement-breakpoint
|
|
@@ -107,6 +109,7 @@ CREATE TABLE "document_management"."property" (
|
|
|
107
109
|
"id" uuid DEFAULT gen_random_uuid() NOT NULL,
|
|
108
110
|
"tenant_id" uuid NOT NULL,
|
|
109
111
|
"label" text NOT NULL,
|
|
112
|
+
"key" text,
|
|
110
113
|
"data_type" "document_management"."property_data_type" NOT NULL,
|
|
111
114
|
"revision" integer NOT NULL,
|
|
112
115
|
"revision_timestamp" timestamp with time zone NOT NULL,
|
|
@@ -115,6 +118,7 @@ CREATE TABLE "document_management"."property" (
|
|
|
115
118
|
"attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
116
119
|
CONSTRAINT "property_tenant_id_id_pk" PRIMARY KEY("tenant_id","id"),
|
|
117
120
|
CONSTRAINT "property_label_unique" UNIQUE("label"),
|
|
121
|
+
CONSTRAINT "property_tenant_id_key_unique" UNIQUE("tenant_id","key"),
|
|
118
122
|
CONSTRAINT "property_tenant_id_label_unique" UNIQUE("tenant_id","label")
|
|
119
123
|
);
|
|
120
124
|
--> statement-breakpoint
|
|
@@ -228,12 +232,14 @@ CREATE TABLE "document_management"."type" (
|
|
|
228
232
|
"tenant_id" uuid NOT NULL,
|
|
229
233
|
"category_id" uuid NOT NULL,
|
|
230
234
|
"label" text NOT NULL,
|
|
235
|
+
"key" text,
|
|
231
236
|
"revision" integer NOT NULL,
|
|
232
237
|
"revision_timestamp" timestamp with time zone NOT NULL,
|
|
233
238
|
"create_timestamp" timestamp with time zone NOT NULL,
|
|
234
239
|
"delete_timestamp" timestamp with time zone,
|
|
235
240
|
"attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
236
241
|
CONSTRAINT "type_tenant_id_id_pk" PRIMARY KEY("tenant_id","id"),
|
|
242
|
+
CONSTRAINT "type_tenant_id_key_unique" UNIQUE("tenant_id","key"),
|
|
237
243
|
CONSTRAINT "type_tenant_id_category_id_label_unique" UNIQUE("tenant_id","category_id","label")
|
|
238
244
|
);
|
|
239
245
|
--> statement-breakpoint
|
|
@@ -320,6 +326,7 @@ CREATE TABLE "document_management"."workflow" (
|
|
|
320
326
|
"document_id" uuid NOT NULL,
|
|
321
327
|
"step" "document_management"."workflow_step" NOT NULL,
|
|
322
328
|
"state" "document_management"."workflow_state" NOT NULL,
|
|
329
|
+
"skip_ai" boolean NOT NULL,
|
|
323
330
|
"fail_reason" "document_management"."workflow_fail_reason",
|
|
324
331
|
"complete_timestamp" timestamp with time zone,
|
|
325
332
|
"complete_user_id" uuid,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"id": "
|
|
2
|
+
"id": "bc835c07-b4ae-40f1-9d65-cfca1dcca765",
|
|
3
3
|
"prevId": "00000000-0000-0000-0000-000000000000",
|
|
4
4
|
"version": "7",
|
|
5
5
|
"dialect": "postgresql",
|
|
@@ -475,6 +475,12 @@
|
|
|
475
475
|
"primaryKey": false,
|
|
476
476
|
"notNull": true
|
|
477
477
|
},
|
|
478
|
+
"key": {
|
|
479
|
+
"name": "key",
|
|
480
|
+
"type": "text",
|
|
481
|
+
"primaryKey": false,
|
|
482
|
+
"notNull": false
|
|
483
|
+
},
|
|
478
484
|
"revision": {
|
|
479
485
|
"name": "revision",
|
|
480
486
|
"type": "integer",
|
|
@@ -543,6 +549,14 @@
|
|
|
543
549
|
"label"
|
|
544
550
|
]
|
|
545
551
|
},
|
|
552
|
+
"category_tenant_id_key_unique": {
|
|
553
|
+
"name": "category_tenant_id_key_unique",
|
|
554
|
+
"nullsNotDistinct": false,
|
|
555
|
+
"columns": [
|
|
556
|
+
"tenant_id",
|
|
557
|
+
"key"
|
|
558
|
+
]
|
|
559
|
+
},
|
|
546
560
|
"category_tenant_id_parent_id_label_unique": {
|
|
547
561
|
"name": "category_tenant_id_parent_id_label_unique",
|
|
548
562
|
"nullsNotDistinct": false,
|
|
@@ -851,6 +865,12 @@
|
|
|
851
865
|
"primaryKey": false,
|
|
852
866
|
"notNull": true
|
|
853
867
|
},
|
|
868
|
+
"key": {
|
|
869
|
+
"name": "key",
|
|
870
|
+
"type": "text",
|
|
871
|
+
"primaryKey": false,
|
|
872
|
+
"notNull": false
|
|
873
|
+
},
|
|
854
874
|
"data_type": {
|
|
855
875
|
"name": "data_type",
|
|
856
876
|
"type": "property_data_type",
|
|
@@ -909,6 +929,14 @@
|
|
|
909
929
|
"label"
|
|
910
930
|
]
|
|
911
931
|
},
|
|
932
|
+
"property_tenant_id_key_unique": {
|
|
933
|
+
"name": "property_tenant_id_key_unique",
|
|
934
|
+
"nullsNotDistinct": false,
|
|
935
|
+
"columns": [
|
|
936
|
+
"tenant_id",
|
|
937
|
+
"key"
|
|
938
|
+
]
|
|
939
|
+
},
|
|
912
940
|
"property_tenant_id_label_unique": {
|
|
913
941
|
"name": "property_tenant_id_label_unique",
|
|
914
942
|
"nullsNotDistinct": false,
|
|
@@ -1885,6 +1913,12 @@
|
|
|
1885
1913
|
"primaryKey": false,
|
|
1886
1914
|
"notNull": true
|
|
1887
1915
|
},
|
|
1916
|
+
"key": {
|
|
1917
|
+
"name": "key",
|
|
1918
|
+
"type": "text",
|
|
1919
|
+
"primaryKey": false,
|
|
1920
|
+
"notNull": false
|
|
1921
|
+
},
|
|
1888
1922
|
"revision": {
|
|
1889
1923
|
"name": "revision",
|
|
1890
1924
|
"type": "integer",
|
|
@@ -1946,6 +1980,14 @@
|
|
|
1946
1980
|
}
|
|
1947
1981
|
},
|
|
1948
1982
|
"uniqueConstraints": {
|
|
1983
|
+
"type_tenant_id_key_unique": {
|
|
1984
|
+
"name": "type_tenant_id_key_unique",
|
|
1985
|
+
"nullsNotDistinct": false,
|
|
1986
|
+
"columns": [
|
|
1987
|
+
"tenant_id",
|
|
1988
|
+
"key"
|
|
1989
|
+
]
|
|
1990
|
+
},
|
|
1949
1991
|
"type_tenant_id_category_id_label_unique": {
|
|
1950
1992
|
"name": "type_tenant_id_category_id_label_unique",
|
|
1951
1993
|
"nullsNotDistinct": false,
|
|
@@ -2670,6 +2712,12 @@
|
|
|
2670
2712
|
"primaryKey": false,
|
|
2671
2713
|
"notNull": true
|
|
2672
2714
|
},
|
|
2715
|
+
"skip_ai": {
|
|
2716
|
+
"name": "skip_ai",
|
|
2717
|
+
"type": "boolean",
|
|
2718
|
+
"primaryKey": false,
|
|
2719
|
+
"notNull": true
|
|
2720
|
+
},
|
|
2673
2721
|
"fail_reason": {
|
|
2674
2722
|
"name": "fail_reason",
|
|
2675
2723
|
"type": "workflow_fail_reason",
|
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
import { Transactional } from '../../../orm/server/index.js';
|
|
2
2
|
import { DocumentCategory, DocumentType } from '../../models/index.js';
|
|
3
|
-
import type { DocumentCategoryView } from '../../service-models/index.js';
|
|
3
|
+
import type { DocumentCategoryView, DocumentPropertyView } from '../../service-models/index.js';
|
|
4
4
|
export declare class DocumentCategoryTypeService extends Transactional {
|
|
5
|
+
#private;
|
|
5
6
|
readonly categoryRepository: import("../../../orm/server/index.js").EntityRepository<DocumentCategory>;
|
|
6
7
|
readonly typeRepository: import("../../../orm/server/index.js").EntityRepository<DocumentType>;
|
|
8
|
+
invalidateCache(tenantId: string): void;
|
|
9
|
+
getCategoryId(tenantId: string, key: string): Promise<string>;
|
|
10
|
+
getTypeId(tenantId: string, key: string): Promise<string>;
|
|
7
11
|
loadCategory(tenantId: string, id: string): Promise<DocumentCategory>;
|
|
8
12
|
loadType(tenantId: string, id: string): Promise<DocumentType>;
|
|
9
13
|
createCategory(data: {
|
|
10
14
|
tenantId: string;
|
|
11
15
|
label: string;
|
|
12
16
|
parentId: string | null;
|
|
13
|
-
|
|
17
|
+
key?: string;
|
|
14
18
|
}): Promise<DocumentCategory>;
|
|
15
19
|
createType(data: {
|
|
16
20
|
tenantId: string;
|
|
17
21
|
label: string;
|
|
18
22
|
categoryId: string;
|
|
19
|
-
|
|
23
|
+
key?: string;
|
|
20
24
|
}): Promise<DocumentType>;
|
|
21
25
|
updateCategory(tenantId: string, id: string, update: {
|
|
22
26
|
label?: string;
|
|
@@ -30,6 +34,7 @@ export declare class DocumentCategoryTypeService extends Transactional {
|
|
|
30
34
|
loadCategoriesAndTypes(tenantId: string): Promise<{
|
|
31
35
|
categories: DocumentCategory[];
|
|
32
36
|
types: DocumentType[];
|
|
37
|
+
properties: DocumentPropertyView[];
|
|
33
38
|
}>;
|
|
34
39
|
loadCategoryViews(tenantId: string): Promise<DocumentCategoryView[]>;
|
|
35
40
|
}
|
|
@@ -4,15 +4,39 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
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
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
7
|
+
import { NotFoundError } from '../../../errors/not-found.error.js';
|
|
8
|
+
import { injectRepository, injectTransactional, Transactional } from '../../../orm/server/index.js';
|
|
8
9
|
import { groupToMap } from '../../../utils/iterable-helpers/group-to-map.js';
|
|
9
10
|
import { isUndefined } from '../../../utils/type-guards.js';
|
|
10
11
|
import { DocumentCategory, DocumentType } from '../../models/index.js';
|
|
11
|
-
import {
|
|
12
|
+
import { DocumentPropertyService } from './document-property.service.js';
|
|
12
13
|
import { DocumentManagementSingleton } from './singleton.js';
|
|
13
14
|
let DocumentCategoryTypeService = class DocumentCategoryTypeService extends Transactional {
|
|
15
|
+
#documentPropertyService = injectTransactional(DocumentPropertyService);
|
|
14
16
|
categoryRepository = injectRepository(DocumentCategory);
|
|
15
17
|
typeRepository = injectRepository(DocumentType);
|
|
18
|
+
#categoryCache = new Map();
|
|
19
|
+
#typeCache = new Map();
|
|
20
|
+
invalidateCache(tenantId) {
|
|
21
|
+
this.#categoryCache.delete(tenantId);
|
|
22
|
+
this.#typeCache.delete(tenantId);
|
|
23
|
+
}
|
|
24
|
+
async getCategoryId(tenantId, key) {
|
|
25
|
+
const cache = await this.#getCategoryCache(tenantId);
|
|
26
|
+
const id = cache.get(key);
|
|
27
|
+
if (isUndefined(id)) {
|
|
28
|
+
throw new NotFoundError(`Document category with key "${key}" not found for tenant "${tenantId}".`);
|
|
29
|
+
}
|
|
30
|
+
return id;
|
|
31
|
+
}
|
|
32
|
+
async getTypeId(tenantId, key) {
|
|
33
|
+
const cache = await this.#getTypeCache(tenantId);
|
|
34
|
+
const id = cache.get(key);
|
|
35
|
+
if (isUndefined(id)) {
|
|
36
|
+
throw new NotFoundError(`Document type with key "${key}" not found for tenant "${tenantId}".`);
|
|
37
|
+
}
|
|
38
|
+
return id;
|
|
39
|
+
}
|
|
16
40
|
async loadCategory(tenantId, id) {
|
|
17
41
|
return await this.categoryRepository.loadByQuery({ tenantId, id });
|
|
18
42
|
}
|
|
@@ -24,7 +48,7 @@ let DocumentCategoryTypeService = class DocumentCategoryTypeService extends Tran
|
|
|
24
48
|
tenantId: data.tenantId,
|
|
25
49
|
label: data.label,
|
|
26
50
|
parentId: data.parentId,
|
|
27
|
-
|
|
51
|
+
key: data.key ?? null,
|
|
28
52
|
});
|
|
29
53
|
}
|
|
30
54
|
async createType(data) {
|
|
@@ -34,7 +58,7 @@ let DocumentCategoryTypeService = class DocumentCategoryTypeService extends Tran
|
|
|
34
58
|
tenantId: data.tenantId,
|
|
35
59
|
label: data.label,
|
|
36
60
|
categoryId: data.categoryId,
|
|
37
|
-
|
|
61
|
+
key: data.key ?? null,
|
|
38
62
|
});
|
|
39
63
|
}
|
|
40
64
|
async updateCategory(tenantId, id, update) {
|
|
@@ -52,11 +76,12 @@ let DocumentCategoryTypeService = class DocumentCategoryTypeService extends Tran
|
|
|
52
76
|
return [...parents, category];
|
|
53
77
|
}
|
|
54
78
|
async loadCategoriesAndTypes(tenantId) {
|
|
55
|
-
const [categories, types] = await Promise.all([
|
|
79
|
+
const [categories, types, properties] = await Promise.all([
|
|
56
80
|
this.categoryRepository.loadManyByQuery({ tenantId }, { order: 'label' }),
|
|
57
81
|
this.typeRepository.loadManyByQuery({ tenantId }, { order: 'label' }),
|
|
82
|
+
this.#documentPropertyService.withSession(this.session).loadViews(tenantId),
|
|
58
83
|
]);
|
|
59
|
-
return { categories, types };
|
|
84
|
+
return { categories, types, properties };
|
|
60
85
|
}
|
|
61
86
|
async loadCategoryViews(tenantId) {
|
|
62
87
|
const { categories, types } = await this.loadCategoriesAndTypes(tenantId);
|
|
@@ -68,6 +93,24 @@ let DocumentCategoryTypeService = class DocumentCategoryTypeService extends Tran
|
|
|
68
93
|
}
|
|
69
94
|
return rootCategories.map((category) => getView(category, categoryChildrenMap, categoryTypesMap));
|
|
70
95
|
}
|
|
96
|
+
async #getCategoryCache(tenantId) {
|
|
97
|
+
let cache = this.#categoryCache.get(tenantId);
|
|
98
|
+
if (isUndefined(cache)) {
|
|
99
|
+
const categories = await this.categoryRepository.loadManyByQuery({ tenantId, key: { $neq: null } });
|
|
100
|
+
cache = new Map(categories.map((category) => [category.key, category.id]));
|
|
101
|
+
this.#categoryCache.set(tenantId, cache);
|
|
102
|
+
}
|
|
103
|
+
return cache;
|
|
104
|
+
}
|
|
105
|
+
async #getTypeCache(tenantId) {
|
|
106
|
+
let cache = this.#typeCache.get(tenantId);
|
|
107
|
+
if (isUndefined(cache)) {
|
|
108
|
+
const types = await this.typeRepository.loadManyByQuery({ tenantId, key: { $neq: null } });
|
|
109
|
+
cache = new Map(types.map((type) => [type.key, type.id]));
|
|
110
|
+
this.#typeCache.set(tenantId, cache);
|
|
111
|
+
}
|
|
112
|
+
return cache;
|
|
113
|
+
}
|
|
71
114
|
};
|
|
72
115
|
DocumentCategoryTypeService = __decorate([
|
|
73
116
|
DocumentManagementSingleton()
|