@tstdl/base 0.93.2 → 0.93.4
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.d.ts +2 -1
- package/ai/ai.service.js +11 -3
- package/ai/types.d.ts +3 -1
- package/api/server/api-request-token.provider.d.ts +5 -3
- package/api/server/api-request-token.provider.js +12 -4
- package/api/server/gateway.d.ts +1 -9
- package/api/server/gateway.js +67 -36
- package/api/types.d.ts +5 -1
- package/application/application.d.ts +2 -0
- package/application/application.js +3 -1
- package/application/providers.d.ts +1 -1
- package/application/providers.js +1 -1
- package/audit/audit.model.d.ts +14 -9
- package/audit/audit.model.js +36 -27
- package/audit/auditor.d.ts +32 -23
- package/audit/auditor.js +84 -21
- package/audit/drizzle/{0000_tiny_the_captain.sql → 0000_bored_stick.sql} +5 -4
- package/audit/drizzle/meta/0000_snapshot.json +22 -15
- package/audit/drizzle/meta/_journal.json +2 -2
- package/audit/index.d.ts +3 -1
- package/audit/index.js +3 -1
- package/audit/module.d.ts +1 -1
- package/audit/module.js +1 -2
- package/audit/schemas.d.ts +2 -2
- package/audit/schemas.js +1 -1
- package/audit/types.d.ts +2 -1
- package/audit/types.js +2 -1
- package/authentication/models/authentication-credentials.model.js +1 -2
- package/authentication/models/authentication-session.model.d.ts +2 -2
- package/authentication/models/authentication-session.model.js +3 -5
- package/authentication/server/authentication-api-request-token.provider.d.ts +2 -2
- package/authentication/server/authentication-api-request-token.provider.js +8 -5
- package/authentication/server/authentication.api-controller.d.ts +8 -8
- package/authentication/server/authentication.api-controller.js +16 -16
- package/authentication/server/authentication.audit.d.ts +34 -0
- package/authentication/server/authentication.audit.js +1 -0
- package/authentication/server/authentication.service.d.ts +19 -10
- package/authentication/server/authentication.service.js +158 -43
- package/authentication/server/module.d.ts +1 -1
- package/authentication/server/schemas.d.ts +2 -3
- package/authentication/server/schemas.js +2 -3
- package/constants.d.ts +1 -0
- package/constants.js +1 -0
- package/document-management/api/document-management.api.d.ts +74 -74
- package/document-management/models/document-assignment-scope.model.d.ts +1 -2
- package/document-management/models/document-assignment-scope.model.js +4 -6
- package/document-management/models/document-assignment-task.model.d.ts +1 -2
- package/document-management/models/document-assignment-task.model.js +3 -5
- package/document-management/models/document-category.model.d.ts +1 -2
- package/document-management/models/document-category.model.js +3 -4
- package/document-management/models/document-collection-assignment.model.d.ts +1 -2
- package/document-management/models/document-collection-assignment.model.js +5 -7
- package/document-management/models/document-collection.model.d.ts +1 -2
- package/document-management/models/document-collection.model.js +3 -4
- package/document-management/models/document-management-table.d.ts +1 -1
- package/document-management/models/document-management-table.js +1 -1
- package/document-management/models/document-property-value.model.d.ts +1 -2
- package/document-management/models/document-property-value.model.js +5 -8
- package/document-management/models/document-property.model.d.ts +1 -2
- package/document-management/models/document-property.model.js +2 -3
- package/document-management/models/document-request-collection-assignment.model.d.ts +1 -2
- package/document-management/models/document-request-collection-assignment.model.js +4 -6
- package/document-management/models/document-request-template.d.ts +1 -2
- package/document-management/models/document-request-template.js +4 -6
- package/document-management/models/document-request.model.d.ts +1 -1
- package/document-management/models/document-request.model.js +4 -5
- package/document-management/models/document-requests-template.d.ts +1 -1
- package/document-management/models/document-requests-template.js +2 -3
- package/document-management/models/document-tag-assignment.model.d.ts +1 -2
- package/document-management/models/document-tag-assignment.model.js +4 -6
- package/document-management/models/document-tag.model.d.ts +1 -1
- package/document-management/models/document-tag.model.js +2 -3
- package/document-management/models/document-type-property.model.d.ts +1 -2
- package/document-management/models/document-type-property.model.js +4 -6
- package/document-management/models/document-type-validation.model.d.ts +1 -2
- package/document-management/models/document-type-validation.model.js +4 -6
- package/document-management/models/document-type.model.d.ts +1 -2
- package/document-management/models/document-type.model.js +3 -5
- package/document-management/models/document-validation-definition.model.d.ts +1 -2
- package/document-management/models/document-validation-definition.model.js +3 -4
- package/document-management/models/document-validation-execution-related-document.model.d.ts +1 -2
- package/document-management/models/document-validation-execution-related-document.model.js +4 -6
- package/document-management/models/document-validation-execution.model.d.ts +1 -2
- package/document-management/models/document-validation-execution.model.js +8 -9
- package/document-management/models/document-workflow.model.d.ts +1 -2
- package/document-management/models/document-workflow.model.js +5 -7
- package/document-management/models/document.model.d.ts +1 -2
- package/document-management/models/document.model.js +5 -7
- package/document-management/server/api/document-management.api.js +1 -1
- package/document-management/server/module.d.ts +1 -1
- package/document-management/server/module.js +1 -1
- package/document-management/server/schemas.d.ts +1 -1
- package/document-management/server/schemas.js +1 -1
- package/document-management/server/services/document-category-type.service.d.ts +2 -2
- package/document-management/server/services/document-category-type.service.js +1 -2
- package/document-management/server/services/document-collection.service.d.ts +1 -1
- package/document-management/server/services/document-collection.service.js +1 -2
- package/document-management/server/services/document-management-ai.service.js +3 -3
- package/document-management/server/services/document-management.service.js +6 -6
- package/document-management/server/services/document-property.service.d.ts +1 -1
- package/document-management/server/services/document-property.service.js +1 -2
- package/document-management/server/services/document-validation.service.js +2 -2
- package/document-management/server/services/document-workflow.service.d.ts +2 -2
- package/document-management/server/services/document-workflow.service.js +1 -2
- package/document-management/server/services/document.service.d.ts +1 -1
- package/document-management/server/services/document.service.js +1 -2
- package/document-management/server/services/singleton.js +1 -1
- package/document-management/server/validators/ai-validation-executor.d.ts +2 -2
- package/document-management/server/validators/ai-validation-executor.js +6 -6
- package/document-management/server/validators/single-document-validation-executor.d.ts +2 -1
- package/document-management/server/validators/single-document-validation-executor.js +3 -2
- package/document-management/service-models/document.service-model.d.ts +62 -62
- package/document-management/service-models/document.service-model.js +1 -1
- package/document-management/service-models/enriched/enriched-document-management-data.view.js +1 -1
- package/document-management/service-models/enriched/enriched-document.view.d.ts +1 -1
- package/examples/api/authentication.js +2 -2
- package/examples/api/basic-overview.js +2 -2
- package/examples/api/custom-authentication.js +2 -2
- package/examples/api/streaming.js +2 -2
- package/examples/browser/basic.js +2 -2
- package/examples/document-management/main.js +4 -2
- package/examples/http/client.js +2 -2
- package/examples/mail/basic.js +2 -2
- package/examples/pdf/basic.js +2 -2
- package/examples/template/basic.js +2 -2
- package/http/server/http-server-request.d.ts +3 -3
- package/key-value-store/postgres/key-value-store.service.js +1 -2
- package/key-value-store/postgres/models/key-value.model.d.ts +1 -2
- package/key-value-store/postgres/models/key-value.model.js +2 -4
- package/key-value-store/postgres/models/schemas.d.ts +1 -1
- package/key-value-store/postgres/models/schemas.js +1 -1
- package/lock/postgres/lock.js +1 -1
- package/lock/postgres/models/lock.model.d.ts +1 -2
- package/lock/postgres/models/lock.model.js +3 -5
- package/lock/postgres/models/schemas.d.ts +1 -1
- package/lock/postgres/models/schemas.js +1 -1
- package/lock/postgres/provider.js +1 -2
- package/mail/models/mail-log.model.d.ts +1 -1
- package/mail/models/mail-log.model.js +4 -5
- package/mail/models/schemas.d.ts +1 -1
- package/mail/models/schemas.js +1 -1
- package/openid-connect/oidc-state.model.d.ts +1 -1
- package/openid-connect/oidc-state.model.js +2 -3
- package/openid-connect/oidc.service.js +1 -1
- package/orm/data-types/bytea.js +1 -1
- package/orm/data-types/numeric-date.js +1 -1
- package/orm/decorators.d.ts +65 -72
- package/orm/decorators.js +42 -40
- package/orm/entity.d.ts +1 -1
- package/orm/entity.js +13 -13
- package/orm/index.d.ts +2 -1
- package/orm/index.js +2 -1
- package/orm/schemas/json.d.ts +1 -1
- package/orm/schemas/json.js +1 -1
- package/orm/schemas/numeric-date.d.ts +1 -1
- package/orm/schemas/numeric-date.js +1 -1
- package/orm/schemas/timestamp.d.ts +1 -1
- package/orm/schemas/timestamp.js +1 -1
- package/orm/schemas/uuid.d.ts +2 -2
- package/orm/schemas/uuid.js +1 -1
- package/orm/server/drizzle/index.js +1 -0
- package/orm/server/drizzle/schema-converter.d.ts +15 -0
- package/orm/server/drizzle/schema-converter.js +300 -0
- package/orm/server/repository.d.ts +1 -1
- package/orm/server/repository.js +12 -9
- package/orm/sqls.d.ts +1 -1
- package/orm/sqls.js +1 -1
- package/orm/types.d.ts +2 -6
- package/orm/types.js +1 -4
- package/package.json +12 -10
- package/queue/postgres/job.model.d.ts +3 -3
- package/queue/postgres/job.model.js +5 -6
- package/queue/postgres/queue.js +2 -2
- package/queue/postgres/schemas.d.ts +1 -1
- package/queue/postgres/schemas.js +1 -1
- package/supports.d.ts +1 -0
- package/supports.js +2 -1
- package/types/types.d.ts +12 -1
- package/utils/object/object.d.ts +3 -1
- package/utils/object/object.js +7 -1
- package/orm/server/drizzle/schema-converter.ts +0 -408
- /package/orm/server/drizzle/{index.ts → index.d.ts} +0 -0
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { type EnumType } from '../../enumeration/enumeration.js';
|
|
2
|
-
import { Entity } from '../../orm/
|
|
3
|
-
import { Timestamp, Uuid } from '../../orm/types.js';
|
|
2
|
+
import { Entity, type Timestamp, type Uuid } from '../../orm/index.js';
|
|
4
3
|
export declare const DocumentWorkflowStep: {
|
|
5
4
|
readonly Classification: "classification";
|
|
6
5
|
readonly Extraction: "extraction";
|
|
@@ -8,9 +8,7 @@ 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 { defineEnum } from '../../enumeration/enumeration.js';
|
|
11
|
-
import { ForeignKey, References } from '../../orm/
|
|
12
|
-
import { Entity } from '../../orm/entity.js';
|
|
13
|
-
import { Index, Timestamp, Unique, Uuid } from '../../orm/types.js';
|
|
11
|
+
import { Entity, ForeignKey, Index, References, TimestampProperty, Unique, UuidProperty } from '../../orm/index.js';
|
|
14
12
|
import { Enumeration } from '../../schema/index.js';
|
|
15
13
|
import { DocumentManagementTable } from './document-management-table.js';
|
|
16
14
|
import { Document } from './document.model.js';
|
|
@@ -46,11 +44,11 @@ let DocumentWorkflow = class DocumentWorkflow extends Entity {
|
|
|
46
44
|
completeUserId;
|
|
47
45
|
};
|
|
48
46
|
__decorate([
|
|
49
|
-
|
|
47
|
+
UuidProperty(),
|
|
50
48
|
__metadata("design:type", String)
|
|
51
49
|
], DocumentWorkflow.prototype, "tenantId", void 0);
|
|
52
50
|
__decorate([
|
|
53
|
-
|
|
51
|
+
UuidProperty(),
|
|
54
52
|
References(() => Document),
|
|
55
53
|
__metadata("design:type", String)
|
|
56
54
|
], DocumentWorkflow.prototype, "documentId", void 0);
|
|
@@ -67,11 +65,11 @@ __decorate([
|
|
|
67
65
|
__metadata("design:type", Object)
|
|
68
66
|
], DocumentWorkflow.prototype, "failReason", void 0);
|
|
69
67
|
__decorate([
|
|
70
|
-
|
|
68
|
+
TimestampProperty({ nullable: true }),
|
|
71
69
|
__metadata("design:type", Object)
|
|
72
70
|
], DocumentWorkflow.prototype, "completeTimestamp", void 0);
|
|
73
71
|
__decorate([
|
|
74
|
-
|
|
72
|
+
UuidProperty({ nullable: true }),
|
|
75
73
|
__metadata("design:type", Object)
|
|
76
74
|
], DocumentWorkflow.prototype, "completeUserId", void 0);
|
|
77
75
|
DocumentWorkflow = __decorate([
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { type EnumType } from '../../enumeration/enumeration.js';
|
|
2
|
-
import { Entity } from '../../orm/
|
|
3
|
-
import { NumericDate, Uuid } from '../../orm/types.js';
|
|
2
|
+
import { Entity, type NumericDate, type Uuid } from '../../orm/index.js';
|
|
4
3
|
export declare const DocumentApproval: {
|
|
5
4
|
readonly Pending: "pending";
|
|
6
5
|
readonly Approved: "approved";
|
|
@@ -8,9 +8,7 @@ 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 { defineEnum } from '../../enumeration/enumeration.js';
|
|
11
|
-
import { References } from '../../orm/
|
|
12
|
-
import { Entity } from '../../orm/entity.js';
|
|
13
|
-
import { NumericDate, Unique, Uuid } from '../../orm/types.js';
|
|
11
|
+
import { Entity, NumericDateProperty, References, Unique, UuidProperty } from '../../orm/index.js';
|
|
14
12
|
import { Enumeration, Integer, StringProperty } from '../../schema/index.js';
|
|
15
13
|
import { DocumentManagementTable } from './document-management-table.js';
|
|
16
14
|
import { DocumentType } from './document-type.model.js';
|
|
@@ -36,11 +34,11 @@ let Document = class Document extends Entity {
|
|
|
36
34
|
createUserId;
|
|
37
35
|
};
|
|
38
36
|
__decorate([
|
|
39
|
-
|
|
37
|
+
UuidProperty(),
|
|
40
38
|
__metadata("design:type", String)
|
|
41
39
|
], Document.prototype, "tenantId", void 0);
|
|
42
40
|
__decorate([
|
|
43
|
-
|
|
41
|
+
UuidProperty({ nullable: true }),
|
|
44
42
|
References(() => DocumentType),
|
|
45
43
|
__metadata("design:type", Object)
|
|
46
44
|
], Document.prototype, "typeId", void 0);
|
|
@@ -57,7 +55,7 @@ __decorate([
|
|
|
57
55
|
__metadata("design:type", Object)
|
|
58
56
|
], Document.prototype, "pages", void 0);
|
|
59
57
|
__decorate([
|
|
60
|
-
|
|
58
|
+
NumericDateProperty({ nullable: true, coerce: true }),
|
|
61
59
|
__metadata("design:type", Object)
|
|
62
60
|
], Document.prototype, "date", void 0);
|
|
63
61
|
__decorate([
|
|
@@ -89,7 +87,7 @@ __decorate([
|
|
|
89
87
|
__metadata("design:type", Number)
|
|
90
88
|
], Document.prototype, "size", void 0);
|
|
91
89
|
__decorate([
|
|
92
|
-
|
|
90
|
+
UuidProperty({ nullable: true }),
|
|
93
91
|
__metadata("design:type", Object)
|
|
94
92
|
], Document.prototype, "createUserId", void 0);
|
|
95
93
|
Document = __decorate([
|
|
@@ -13,7 +13,7 @@ import { ForbiddenError, NotImplementedError } from '../../../errors/index.js';
|
|
|
13
13
|
import { HttpServerResponse } from '../../../http/index.js';
|
|
14
14
|
import { inject } from '../../../injector/index.js';
|
|
15
15
|
import { Logger } from '../../../logger/logger.js';
|
|
16
|
-
import { injectRepository } from '../../../orm/server/
|
|
16
|
+
import { injectRepository } from '../../../orm/server/index.js';
|
|
17
17
|
import { toArray } from '../../../utils/array/index.js';
|
|
18
18
|
import { documentManagementApiDefinition } from '../../api/index.js';
|
|
19
19
|
import { DocumentManagementAuthorizationService } from '../../authorization/index.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import './schemas.js';
|
|
2
2
|
import { type InjectionToken } from '../../injector/index.js';
|
|
3
|
-
import type
|
|
3
|
+
import { type DatabaseConfig } from '../../orm/server/index.js';
|
|
4
4
|
import type { DocumentManagementAuthorizationService } from '../authorization/document-management-authorization.service.js';
|
|
5
5
|
import type { DocumentManagementAncillaryService } from './services/document-management-ancillary.service.js';
|
|
6
6
|
export declare class DocumentManagementConfiguration {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import './schemas.js';
|
|
2
2
|
import { inject } from '../../injector/index.js';
|
|
3
|
-
import { Database, migrate } from '../../orm/server/
|
|
3
|
+
import { Database, migrate } from '../../orm/server/index.js';
|
|
4
4
|
export class DocumentManagementConfiguration {
|
|
5
5
|
ancillaryService;
|
|
6
6
|
authorizationService;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Document, DocumentAssignmentScope, DocumentAssignmentTask, DocumentCategory, DocumentCollection, DocumentCollectionAssignment, DocumentProperty, DocumentPropertyValue, DocumentRequest, DocumentRequestCollectionAssignment, DocumentRequestsTemplate, DocumentRequestTemplate, DocumentTag, DocumentTagAssignment, DocumentType, DocumentTypeProperty, DocumentTypeValidation, DocumentValidationDefinition, DocumentValidationExecution, DocumentValidationExecutionRelatedDocument, DocumentWorkflow } from '../models/index.js';
|
|
2
|
-
export declare const documentManagementSchema: import("../../orm/server/
|
|
2
|
+
export declare const documentManagementSchema: import("../../orm/server/index.js").DatabaseSchema<"document_management">;
|
|
3
3
|
export declare const documentApproval: import("drizzle-orm/pg-core").PgEnum<["pending", "approved", "rejected"]>;
|
|
4
4
|
export declare const documentAssignmentTarget: import("drizzle-orm/pg-core").PgEnum<["request", "collection"]>;
|
|
5
5
|
export declare const documentPropertyDataType: import("drizzle-orm/pg-core").PgEnum<["boolean", "date", "text", "decimal", "integer"]>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { databaseSchema } from '../../orm/server/
|
|
1
|
+
import { databaseSchema } from '../../orm/server/index.js';
|
|
2
2
|
import { Document, DocumentApproval, DocumentAssignmentScope, DocumentAssignmentTarget, DocumentAssignmentTask, DocumentCategory, DocumentCollection, DocumentCollectionAssignment, DocumentProperty, DocumentPropertyDataType, DocumentPropertyValue, DocumentRequest, DocumentRequestCollectionAssignment, DocumentRequestState, DocumentRequestsTemplate, DocumentRequestTemplate, DocumentTag, DocumentTagAssignment, DocumentType, DocumentTypeProperty, DocumentTypeValidation, DocumentValidationDefinition, DocumentValidationExecution, DocumentValidationExecutionRelatedDocument, DocumentValidationExecutionState, DocumentValidationResultStatus, DocumentWorkflow, DocumentWorkflowFailReason, DocumentWorkflowState, DocumentWorkflowStep } from '../models/index.js';
|
|
3
3
|
export const documentManagementSchema = databaseSchema('document_management');
|
|
4
4
|
export const documentApproval = documentManagementSchema.getEnum(DocumentApproval);
|
|
@@ -2,8 +2,8 @@ import { Transactional } from '../../../orm/server/index.js';
|
|
|
2
2
|
import { DocumentCategory, DocumentType } from '../../models/index.js';
|
|
3
3
|
import type { DocumentCategoryView } from '../../service-models/index.js';
|
|
4
4
|
export declare class DocumentCategoryTypeService extends Transactional {
|
|
5
|
-
readonly categoryRepository: import("../../../orm/server/
|
|
6
|
-
readonly typeRepository: import("../../../orm/server/
|
|
5
|
+
readonly categoryRepository: import("../../../orm/server/index.js").EntityRepository<DocumentCategory>;
|
|
6
|
+
readonly typeRepository: import("../../../orm/server/index.js").EntityRepository<DocumentType>;
|
|
7
7
|
loadCategory(tenantId: string, id: string): Promise<DocumentCategory>;
|
|
8
8
|
loadType(tenantId: string, id: string): Promise<DocumentType>;
|
|
9
9
|
createCategory(data: {
|
|
@@ -4,8 +4,7 @@ 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 { Transactional } from '../../../orm/server/index.js';
|
|
8
|
-
import { injectRepository } from '../../../orm/server/repository.js';
|
|
7
|
+
import { injectRepository, Transactional } from '../../../orm/server/index.js';
|
|
9
8
|
import { groupToMap } from '../../../utils/iterable-helpers/group-to-map.js';
|
|
10
9
|
import { isUndefined } from '../../../utils/type-guards.js';
|
|
11
10
|
import { DocumentCategory, DocumentType } from '../../models/index.js';
|
|
@@ -5,7 +5,7 @@ import { Document, DocumentCollection } from '../../models/index.js';
|
|
|
5
5
|
import type { DocumentCollectionMetadata } from '../../service-models/index.js';
|
|
6
6
|
export declare class DocumentCollectionService extends Transactional {
|
|
7
7
|
#private;
|
|
8
|
-
readonly repository: import("../../../orm/server/
|
|
8
|
+
readonly repository: import("../../../orm/server/index.js").EntityRepository<DocumentCollection>;
|
|
9
9
|
resolveMetadata<const T extends (DocumentCollection | string)[]>(tenantId: string, collectionsOrIds: T): Promise<{
|
|
10
10
|
[K in keyof T]: DocumentCollectionMetadata;
|
|
11
11
|
}>;
|
|
@@ -7,8 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { and, eq, sql } from 'drizzle-orm';
|
|
8
8
|
import { inject } from '../../../injector/inject.js';
|
|
9
9
|
import { TRANSACTION_TIMESTAMP } from '../../../orm/index.js';
|
|
10
|
-
import { Transactional } from '../../../orm/server/index.js';
|
|
11
|
-
import { injectRepository } from '../../../orm/server/repository.js';
|
|
10
|
+
import { injectRepository, Transactional } from '../../../orm/server/index.js';
|
|
12
11
|
import { toArray } from '../../../utils/array/index.js';
|
|
13
12
|
import { fromEntries } from '../../../utils/object/index.js';
|
|
14
13
|
import { assertDefinedPass, isString } from '../../../utils/type-guards.js';
|
|
@@ -79,9 +79,9 @@ import { DocumentFileService } from './document-file.service.js';
|
|
|
79
79
|
import { DocumentPropertyService } from './document-property.service.js';
|
|
80
80
|
import { DocumentTagService } from './document-tag.service.js';
|
|
81
81
|
import { DocumentManagementSingleton } from './singleton.js';
|
|
82
|
-
const CLASSIFY_MODEL = '
|
|
83
|
-
const EXTRACT_MODEL = '
|
|
84
|
-
const ASSIGN_MODEL = '
|
|
82
|
+
const CLASSIFY_MODEL = 'small';
|
|
83
|
+
const EXTRACT_MODEL = 'medium';
|
|
84
|
+
const ASSIGN_MODEL = 'small';
|
|
85
85
|
let DocumentManagementAiService = DocumentManagementAiService_1 = class DocumentManagementAiService {
|
|
86
86
|
#documentCollectionService = inject(DocumentCollectionService);
|
|
87
87
|
#documentTagService = inject(DocumentTagService);
|
|
@@ -198,12 +198,12 @@ let DocumentManagementService = DocumentManagementService_1 = class DocumentMana
|
|
|
198
198
|
if (isUndefined(category)) {
|
|
199
199
|
const category = await this.#documentCategoryTypeService.withTransaction(tx).createCategory({ tenantId, label, parentId: parentCategoryId, enumKey });
|
|
200
200
|
enumKeyCategoryMap.set(enumKey, category);
|
|
201
|
-
this.#logger.info(`Created category ${category.label}`);
|
|
201
|
+
this.#logger.info(`Created category "${category.label}"`);
|
|
202
202
|
}
|
|
203
203
|
else if ((category.label != label) || (category.parentId != parentCategoryId)) {
|
|
204
204
|
const updatedCategory = await this.#documentCategoryTypeService.withTransaction(tx).updateCategory(tenantId, category.id, { label, parentId: parentCategoryId });
|
|
205
205
|
enumKeyCategoryMap.set(enumKey, updatedCategory);
|
|
206
|
-
this.#logger.info(`Updated category ${updatedCategory.label}`);
|
|
206
|
+
this.#logger.info(`Updated category "${updatedCategory.label}"`);
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
209
|
for (const [enumKey, label] of typeEntries) {
|
|
@@ -213,12 +213,12 @@ let DocumentManagementService = DocumentManagementService_1 = class DocumentMana
|
|
|
213
213
|
if (isUndefined(type)) {
|
|
214
214
|
const type = await this.#documentCategoryTypeService.withTransaction(tx).createType({ tenantId, label, categoryId: category.id, enumKey });
|
|
215
215
|
enumKeyTypeMap.set(enumKey, type);
|
|
216
|
-
this.#logger.info(`Created type ${type.label} in category ${category.label}`);
|
|
216
|
+
this.#logger.info(`Created type "${type.label}" in category "${category.label}"`);
|
|
217
217
|
}
|
|
218
218
|
else if ((type.categoryId != category.id) || (type.label != label)) {
|
|
219
219
|
const updatedType = await this.#documentCategoryTypeService.withTransaction(tx).updateType(tenantId, type.id, { categoryId: category.id, label: label });
|
|
220
220
|
enumKeyTypeMap.set(enumKey, updatedType);
|
|
221
|
-
this.#logger.info(`Updated type ${updatedType.label} in category ${category.label}`);
|
|
221
|
+
this.#logger.info(`Updated type "${updatedType.label}" in category "${category.label}"`);
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
224
|
for (const [enumKey, [dataType, label]] of propertyEntries) {
|
|
@@ -226,12 +226,12 @@ let DocumentManagementService = DocumentManagementService_1 = class DocumentMana
|
|
|
226
226
|
if (isUndefined(property)) {
|
|
227
227
|
const newProperty = await this.#documentPropertyService.withTransaction(tx).createProperty({ tenantId, label, dataType, enumKey });
|
|
228
228
|
enumKeyPropertyMap.set(enumKey, newProperty);
|
|
229
|
-
this.#logger.info(`Created property ${newProperty.label} of type ${dataType}`);
|
|
229
|
+
this.#logger.info(`Created property "${newProperty.label}" of type "${dataType}"`);
|
|
230
230
|
}
|
|
231
231
|
else if ((property.label != label) || (property.dataType != dataType)) {
|
|
232
232
|
const updatedProperty = await this.#documentPropertyService.withTransaction(tx).updateProperty(tenantId, property.id, { label, dataType });
|
|
233
233
|
enumKeyPropertyMap.set(enumKey, updatedProperty);
|
|
234
|
-
this.#logger.info(`Updated property ${updatedProperty.label} of type ${updatedProperty.dataType}`);
|
|
234
|
+
this.#logger.info(`Updated property "${updatedProperty.label}" of type "${updatedProperty.dataType}"`);
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
237
|
for (const [typeKey, propertyKeys] of objectEntries(data.typeProperties)) {
|
|
@@ -4,7 +4,7 @@ import { DocumentProperty, DocumentPropertyDataType, type Document } from '../..
|
|
|
4
4
|
import type { DocumentPropertyValueView, DocumentPropertyView, SetDocumentPropertyParameters } from '../../service-models/index.js';
|
|
5
5
|
export declare class DocumentPropertyService extends Transactional {
|
|
6
6
|
#private;
|
|
7
|
-
readonly repository: import("../../../orm/server/
|
|
7
|
+
readonly repository: import("../../../orm/server/index.js").EntityRepository<DocumentProperty>;
|
|
8
8
|
readonly documentProperties: import("drizzle-orm/pg-core").WithSubqueryWithSelection<{
|
|
9
9
|
documentId: import("drizzle-orm").SQL.Aliased<string>;
|
|
10
10
|
propertyId: import("drizzle-orm").SQL.Aliased<string>;
|
|
@@ -9,8 +9,7 @@ import { BadRequestError } from '../../../errors/bad-request.error.js';
|
|
|
9
9
|
import { NotFoundError } from '../../../errors/not-found.error.js';
|
|
10
10
|
import { inject } from '../../../injector/index.js';
|
|
11
11
|
import { autoAlias, coalesce, getEntityMap, toJsonb } from '../../../orm/index.js';
|
|
12
|
-
import { Transactional } from '../../../orm/server/index.js';
|
|
13
|
-
import { injectRepository } from '../../../orm/server/repository.js';
|
|
12
|
+
import { injectRepository, Transactional } from '../../../orm/server/index.js';
|
|
14
13
|
import { toArray } from '../../../utils/array/index.js';
|
|
15
14
|
import { assertBooleanPass, assertNumberPass, assertStringPass, isBoolean, isNotNull, isNull, isNumber, isString, isUndefined } from '../../../utils/type-guards.js';
|
|
16
15
|
import { DocumentProperty, DocumentPropertyDataType, DocumentPropertyValue, DocumentTypeProperty } from '../../models/index.js';
|
|
@@ -12,8 +12,8 @@ import { Injector } from '../../../injector/injector.js';
|
|
|
12
12
|
import { afterResolve } from '../../../injector/interfaces.js';
|
|
13
13
|
import { injectionToken } from '../../../injector/token.js';
|
|
14
14
|
import { Logger } from '../../../logger/logger.js';
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
15
|
+
import { getEntityIds } from '../../../orm/index.js';
|
|
16
|
+
import { injectRepository } from '../../../orm/server/index.js';
|
|
17
17
|
import { Queue } from '../../../queue/queue.js';
|
|
18
18
|
import { currentTimestamp } from '../../../utils/date-time.js';
|
|
19
19
|
import { isNull, isUndefined } from '../../../utils/type-guards.js';
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { AfterResolveContext } from '../../../injector/index.js';
|
|
2
2
|
import { afterResolve } from '../../../injector/interfaces.js';
|
|
3
|
-
import { Transactional } from '../../../orm/server/
|
|
3
|
+
import { Transactional } from '../../../orm/server/index.js';
|
|
4
4
|
import type { OneOrMany } from '../../../types/index.js';
|
|
5
5
|
import { DocumentWorkflow, DocumentWorkflowStep } from '../../models/document-workflow.model.js';
|
|
6
6
|
export declare class DocumentWorkflowService extends Transactional {
|
|
7
7
|
#private;
|
|
8
8
|
private readonly documentService;
|
|
9
|
-
readonly repository: import("../../../orm/server/
|
|
9
|
+
readonly repository: import("../../../orm/server/index.js").EntityRepository<DocumentWorkflow>;
|
|
10
10
|
[afterResolve](_: unknown, { cancellationSignal }: AfterResolveContext<any>): void;
|
|
11
11
|
loadLatestWorkflow(tenantId: string, documentId: string): Promise<DocumentWorkflow>;
|
|
12
12
|
loadLatestWorkflows(tenantId: string, documentIds: string[]): Promise<DocumentWorkflow[]>;
|
|
@@ -12,8 +12,7 @@ import { NotImplementedError } from '../../../errors/not-implemented.error.js';
|
|
|
12
12
|
import { inject } from '../../../injector/inject.js';
|
|
13
13
|
import { afterResolve } from '../../../injector/interfaces.js';
|
|
14
14
|
import { Logger } from '../../../logger/index.js';
|
|
15
|
-
import { injectRepository } from '../../../orm/server/
|
|
16
|
-
import { injectTransactional, Transactional } from '../../../orm/server/transactional.js';
|
|
15
|
+
import { injectRepository, injectTransactional, Transactional } from '../../../orm/server/index.js';
|
|
17
16
|
import { Queue } from '../../../queue/queue.js';
|
|
18
17
|
import { toArray } from '../../../utils/array/array.js';
|
|
19
18
|
import { currentTimestamp } from '../../../utils/date-time.js';
|
|
@@ -4,7 +4,7 @@ import { Document, type UpdatableDocumentProperties } from '../../models/index.j
|
|
|
4
4
|
import type { CreateDocumentParameters, SetDocumentPropertyParameters, UpdateDocumentCollectionsParameters } from '../../service-models/index.js';
|
|
5
5
|
export declare class DocumentService extends Transactional {
|
|
6
6
|
#private;
|
|
7
|
-
readonly repository: import("../../../orm/server/
|
|
7
|
+
readonly repository: import("../../../orm/server/index.js").EntityRepository<Document>;
|
|
8
8
|
create(tenantId: string, { typeId, title, subtitle, date, summary, tags, approval, comment, originalFileName, assignment, properties, metadata }: TypedOmit<CreateDocumentParameters, 'uploadId'>, contentSource: Uint8Array<ArrayBuffer> | ReadableStream<Uint8Array<ArrayBuffer>> | {
|
|
9
9
|
uploadId: string;
|
|
10
10
|
uploadKey: string;
|
|
@@ -10,8 +10,7 @@ import { match, P } from 'ts-pattern';
|
|
|
10
10
|
import { BadRequestError } from '../../../errors/bad-request.error.js';
|
|
11
11
|
import { inject } from '../../../injector/inject.js';
|
|
12
12
|
import { Logger } from '../../../logger/logger.js';
|
|
13
|
-
import { injectTransactional, Transactional } from '../../../orm/server/index.js';
|
|
14
|
-
import { injectRepository } from '../../../orm/server/repository.js';
|
|
13
|
+
import { injectRepository, injectTransactional, Transactional } from '../../../orm/server/index.js';
|
|
15
14
|
import { getPdfPageCount } from '../../../pdf/utils.js';
|
|
16
15
|
import { toArray } from '../../../utils/array/index.js';
|
|
17
16
|
import { objectKeys } from '../../../utils/object/object.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Singleton } from '../../../injector/decorators.js';
|
|
2
2
|
import { factoryProvider } from '../../../injector/provider.js';
|
|
3
|
-
import { DatabaseConfig } from '../../../orm/server/
|
|
3
|
+
import { DatabaseConfig } from '../../../orm/server/index.js';
|
|
4
4
|
import { DocumentManagementConfiguration } from '../module.js';
|
|
5
5
|
export const documentManagementDatabaseConfigFactoryProvider = factoryProvider((_, context) => context.resolve(DocumentManagementConfiguration).database ?? context.resolve(DatabaseConfig, undefined, { skipSelf: true }));
|
|
6
6
|
export const documentManagementDatabaseConfigProvider = {
|
|
@@ -4,8 +4,7 @@ import type { SchemaTestable } from '../../../schema/schema.js';
|
|
|
4
4
|
import { DocumentValidationExecutor, type DocumentValidationExecutorContext, type DocumentValidationExecutorResult } from './validator.js';
|
|
5
5
|
export declare const AiValidationDifficulty: {
|
|
6
6
|
readonly Easy: "easy";
|
|
7
|
-
readonly
|
|
8
|
-
readonly MediumHigh: "medium-high";
|
|
7
|
+
readonly Medium: "medium";
|
|
9
8
|
readonly Hard: "hard";
|
|
10
9
|
};
|
|
11
10
|
export type AiValidationDifficulty = EnumType<typeof AiValidationDifficulty>;
|
|
@@ -13,6 +12,7 @@ export declare abstract class AiValidationExecutor<R> extends DocumentValidation
|
|
|
13
12
|
protected readonly aiService: AiService;
|
|
14
13
|
abstract readonly schema: SchemaTestable<R>;
|
|
15
14
|
abstract readonly difficulty: AiValidationDifficulty;
|
|
15
|
+
abstract readonly thinking: boolean;
|
|
16
16
|
execute(context: DocumentValidationExecutorContext): Promise<DocumentValidationExecutorResult>;
|
|
17
17
|
abstract getPrompt(context: DocumentValidationExecutorContext): string | Promise<string>;
|
|
18
18
|
abstract getResult(output: R): DocumentValidationExecutorResult | Promise<DocumentValidationExecutorResult>;
|
|
@@ -12,8 +12,7 @@ import { match } from 'ts-pattern';
|
|
|
12
12
|
import { DocumentValidationExecutor } from './validator.js';
|
|
13
13
|
export const AiValidationDifficulty = defineEnum('AiValidationDifficulty', {
|
|
14
14
|
Easy: 'easy',
|
|
15
|
-
|
|
16
|
-
MediumHigh: 'medium-high',
|
|
15
|
+
Medium: 'medium',
|
|
17
16
|
Hard: 'hard',
|
|
18
17
|
});
|
|
19
18
|
let AiValidationExecutor = class AiValidationExecutor extends DocumentValidationExecutor {
|
|
@@ -21,11 +20,11 @@ let AiValidationExecutor = class AiValidationExecutor extends DocumentValidation
|
|
|
21
20
|
async execute(context) {
|
|
22
21
|
const validationPrompt = await this.getPrompt(context);
|
|
23
22
|
const model = match(this.difficulty)
|
|
24
|
-
.with('easy', () => '
|
|
25
|
-
.with('medium
|
|
26
|
-
.with('
|
|
27
|
-
.with('hard', () => 'gemini-2.5-pro')
|
|
23
|
+
.with('easy', () => 'small')
|
|
24
|
+
.with('medium', () => 'medium')
|
|
25
|
+
.with('hard', () => 'large')
|
|
28
26
|
.exhaustive();
|
|
27
|
+
const thinkingBudget = this.thinking ? -1 : 0;
|
|
29
28
|
const prompt = `Deine Aufgabe ist es ein Dokument zu validieren.
|
|
30
29
|
|
|
31
30
|
Validierungsaufgabe:
|
|
@@ -33,6 +32,7 @@ ${validationPrompt}`;
|
|
|
33
32
|
const generation = await this.aiService.generate({
|
|
34
33
|
model,
|
|
35
34
|
generationOptions: {
|
|
35
|
+
thinkingBudget,
|
|
36
36
|
temperature: 0.2,
|
|
37
37
|
topK: 20,
|
|
38
38
|
},
|
|
@@ -6,7 +6,8 @@ export declare class SingleDocumentValidationExecutor extends AiValidationExecut
|
|
|
6
6
|
reason?: string;
|
|
7
7
|
}> {
|
|
8
8
|
readonly identifier = "single-document";
|
|
9
|
-
readonly difficulty: "medium
|
|
9
|
+
readonly difficulty: "medium";
|
|
10
|
+
readonly thinking = true;
|
|
10
11
|
schema: import("../../../schema/index.js").ObjectSchema<{
|
|
11
12
|
hasMultipleDocuments: boolean;
|
|
12
13
|
reason?: string | undefined;
|
|
@@ -3,13 +3,14 @@ import { DocumentValidationResultStatus } from '../../models/document-validation
|
|
|
3
3
|
import { AiValidationDifficulty, AiValidationExecutor } from './ai-validation-executor.js';
|
|
4
4
|
export class SingleDocumentValidationExecutor extends AiValidationExecutor {
|
|
5
5
|
identifier = 'single-document';
|
|
6
|
-
difficulty = AiValidationDifficulty.
|
|
6
|
+
difficulty = AiValidationDifficulty.Medium;
|
|
7
|
+
thinking = true;
|
|
7
8
|
schema = object({
|
|
8
9
|
hasMultipleDocuments: boolean(),
|
|
9
10
|
reason: optional(string()),
|
|
10
11
|
});
|
|
11
12
|
getPrompt() {
|
|
12
|
-
return 'Überprüfe ob das Dokument aus mehreren Dokumenten zusammengesetzt ist. Falls ja, begründe in wenigen Worten. Antworte auf deutsch.';
|
|
13
|
+
return 'Überprüfe ob das Dokument aus mehreren einzelnen Dokumenten zusammengesetzt ist. Falls ja, begründe in wenigen Worten. Antworte auf deutsch.';
|
|
13
14
|
}
|
|
14
15
|
getResult(output) {
|
|
15
16
|
if (output.hasMultipleDocuments) {
|