@tstdl/base 0.92.132 → 0.92.135
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/response.js +6 -6
- package/api/server/api-request-token.provider.d.ts +3 -0
- package/api/server/api-request-token.provider.js +9 -0
- package/api/server/module.js +1 -1
- package/database/mongo/module.js +6 -6
- package/document-management/api/document-management.api.d.ts +20 -4
- package/document-management/api/document-management.api.js +9 -3
- package/document-management/server/api/document-management.api.d.ts +1 -0
- package/document-management/server/api/document-management.api.js +9 -2
- package/document-management/server/module.d.ts +1 -0
- package/document-management/server/module.js +1 -0
- package/document-management/server/services/document-file.service.d.ts +16 -0
- package/document-management/server/services/document-file.service.js +55 -25
- package/document-management/server/services/document-management-ai.service.js +1 -1
- package/document-management/server/services/document-management-ancillary.service.d.ts +2 -2
- package/document-management/server/services/document-management.service.js +23 -11
- package/document-management/server/services/document-workflow.service.d.ts +1 -0
- package/document-management/server/services/document-workflow.service.js +15 -4
- package/document-management/server/services/document.service.d.ts +5 -1
- package/document-management/server/services/document.service.js +13 -10
- package/document-management/service-models/document-management.view-model.d.ts +15 -4
- package/document-management/service-models/document-management.view-model.js +42 -12
- package/document-management/service-models/document.service-model.d.ts +1 -0
- package/document-management/service-models/document.service-model.js +1 -0
- package/document-management/service-models/enriched/enriched-document-assignment.view.d.ts +13 -4
- package/document-management/service-models/enriched/enriched-document-assignment.view.js +29 -7
- package/document-management/service-models/enriched/enriched-document-collection.view.js +1 -1
- package/document-management/service-models/enriched/enriched-document-request.view.d.ts +1 -1
- package/document-management/service-models/enriched/enriched-document.view.d.ts +2 -2
- package/document-management/service-models/enriched/enriched-document.view.js +2 -6
- package/examples/document-management/main.d.ts +1 -1
- package/examples/document-management/main.js +20 -8
- package/http/client/adapters/undici.adapter.js +3 -3
- package/http/client/http-client.js +29 -30
- package/http/http-body.js +4 -4
- package/http/http.error.d.ts +5 -1
- package/http/http.error.js +6 -6
- package/http/utils.js +4 -4
- package/injector/decorators.d.ts +1 -1
- package/injector/injector.d.ts +1 -1
- package/injector/interfaces.d.ts +1 -1
- package/injector/provider.d.ts +4 -4
- package/object-storage/object-storage.d.ts +38 -2
- package/object-storage/s3/s3.object-storage-provider.js +1 -1
- package/object-storage/s3/s3.object-storage.d.ts +6 -3
- package/object-storage/s3/s3.object-storage.js +88 -14
- package/object-storage/s3/s3.object.js +2 -3
- package/orm/server/repository.js +37 -37
- package/package.json +1 -1
- package/schema/schema.error.js +4 -7
- package/search-index/elastic/module.js +5 -5
- package/utils/cryptography.js +18 -18
- package/utils/object/object.d.ts +3 -2
- package/utils/object/object.js +5 -2
- package/utils/stream/size-limited-stream.js +1 -1
- package/utils/type-guards.d.ts +7 -1
- package/utils/type-guards.js +13 -1
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { type UpdatableDocumentProperties } from '../../../document-management/models/index.js';
|
|
2
2
|
import type { CreateDocumentParameters, SetDocumentPropertyParameters } from '../../../document-management/service-models/index.js';
|
|
3
3
|
import { Transactional } from '../../../orm/server/index.js';
|
|
4
|
+
import type { TypedOmit } from '../../../types.js';
|
|
4
5
|
import { Document } from '../../models/index.js';
|
|
5
6
|
export declare class DocumentService extends Transactional {
|
|
6
7
|
#private;
|
|
7
8
|
readonly repository: import("../../../orm/server/repository.js").EntityRepository<Document>;
|
|
8
|
-
create({ typeId, title, subtitle, date, summary, tags, approval, comment, originalFileName, assignment, properties, metadata }: CreateDocumentParameters,
|
|
9
|
+
create({ typeId, title, subtitle, date, summary, tags, approval, comment, originalFileName, assignment, properties, metadata }: TypedOmit<CreateDocumentParameters, 'uploadId'>, contentSource: Uint8Array | ReadableStream<Uint8Array> | {
|
|
10
|
+
uploadId: string;
|
|
11
|
+
uploadKey: string;
|
|
12
|
+
}, { createUserId }: {
|
|
9
13
|
createUserId?: string;
|
|
10
14
|
}): Promise<Document>;
|
|
11
15
|
update(id: string, update: Partial<Pick<Document, UpdatableDocumentProperties>> & {
|
|
@@ -18,7 +18,7 @@ import { toArray } from '../../../utils/array/index.js';
|
|
|
18
18
|
import { objectKeys } from '../../../utils/object/object.js';
|
|
19
19
|
import { readableStreamFromPromise } from '../../../utils/stream/from-promise.js';
|
|
20
20
|
import { tryIgnoreLogAsync } from '../../../utils/try-ignore.js';
|
|
21
|
-
import { isDefined, isString, isUndefined } from '../../../utils/type-guards.js';
|
|
21
|
+
import { isDefined, isNotReadableStream, isNotUint8Array, isString, isUndefined } from '../../../utils/type-guards.js';
|
|
22
22
|
import { Document } from '../../models/index.js';
|
|
23
23
|
import { DocumentCollectionService } from './document-collection.service.js';
|
|
24
24
|
import { DocumentFileService } from './document-file.service.js';
|
|
@@ -29,17 +29,20 @@ import { DocumentManagementSingleton } from './singleton.js';
|
|
|
29
29
|
let DocumentService = DocumentService_1 = class DocumentService extends Transactional {
|
|
30
30
|
#documentFileService = inject(DocumentFileService);
|
|
31
31
|
#requestService = inject(DocumentRequestService);
|
|
32
|
-
#workflowService = inject(DocumentWorkflowService
|
|
32
|
+
#workflowService = inject(DocumentWorkflowService);
|
|
33
33
|
#documentPropertyService = inject(DocumentPropertyService);
|
|
34
34
|
#documentCollectionService = inject(DocumentCollectionService);
|
|
35
35
|
#documentAssignmentTaskRepository = injectRepository(DocumentAssignmentTask);
|
|
36
36
|
#documentAssignmentScopeRepository = injectRepository(DocumentAssignmentScope);
|
|
37
37
|
#logger = inject(Logger, DocumentService_1.name);
|
|
38
38
|
repository = injectRepository(Document).withSession(this.session);
|
|
39
|
-
async create({ typeId, title, subtitle, date, summary, tags, approval, comment, originalFileName, assignment, properties, metadata },
|
|
39
|
+
async create({ typeId, title, subtitle, date, summary, tags, approval, comment, originalFileName, assignment, properties, metadata }, contentSource, { createUserId }) {
|
|
40
40
|
const document = await this.transaction(async (tx) => {
|
|
41
|
-
const
|
|
42
|
-
const
|
|
41
|
+
const isUpload = isNotUint8Array(contentSource) && isNotReadableStream(contentSource);
|
|
42
|
+
const [documentFile, content] = isUpload
|
|
43
|
+
? await this.#documentFileService.withTransaction(tx).create(contentSource, originalFileName)
|
|
44
|
+
: [await this.#documentFileService.withTransaction(tx).create(contentSource, originalFileName), contentSource];
|
|
45
|
+
const pages = documentFile.mimeType.includes('pdf') ? await tryIgnoreLogAsync(this.#logger, async () => await getPdfPageCount(content), null) : null;
|
|
43
46
|
const document = await this.repository.withTransaction(tx).insert({
|
|
44
47
|
fileId: documentFile.id,
|
|
45
48
|
typeId: typeId ?? null,
|
|
@@ -80,7 +83,7 @@ let DocumentService = DocumentService_1 = class DocumentService extends Transact
|
|
|
80
83
|
}
|
|
81
84
|
async getContent(documentOrId) {
|
|
82
85
|
const document = isString(documentOrId) ? await this.repository.load(documentOrId) : documentOrId;
|
|
83
|
-
return this.#documentFileService.getContent(document.fileId);
|
|
86
|
+
return await this.#documentFileService.getContent(document.fileId);
|
|
84
87
|
}
|
|
85
88
|
getContentStream(documentOrId) {
|
|
86
89
|
return readableStreamFromPromise(async () => {
|
|
@@ -90,11 +93,11 @@ let DocumentService = DocumentService_1 = class DocumentService extends Transact
|
|
|
90
93
|
}
|
|
91
94
|
async getContentUrl(documentOrId, download = false) {
|
|
92
95
|
const document = isString(documentOrId) ? await this.repository.load(documentOrId) : documentOrId;
|
|
93
|
-
return this.#documentFileService.getContentUrl(document.fileId, document.title, download);
|
|
96
|
+
return await this.#documentFileService.getContentUrl(document.fileId, document.title, download);
|
|
94
97
|
}
|
|
95
98
|
async getPreview(documentOrId, page = 1) {
|
|
96
99
|
const document = isString(documentOrId) ? await this.repository.load(documentOrId) : documentOrId;
|
|
97
|
-
return this.#documentFileService.getPreview(document.fileId, page);
|
|
100
|
+
return await this.#documentFileService.getPreview(document.fileId, page);
|
|
98
101
|
}
|
|
99
102
|
getPreviewStream(documentOrId, page = 1) {
|
|
100
103
|
return readableStreamFromPromise(async () => {
|
|
@@ -104,13 +107,13 @@ let DocumentService = DocumentService_1 = class DocumentService extends Transact
|
|
|
104
107
|
}
|
|
105
108
|
async getPreviewUrl(documentOrId, page = 1) {
|
|
106
109
|
const document = isString(documentOrId) ? await this.repository.load(documentOrId) : documentOrId;
|
|
107
|
-
return this.#documentFileService.getPreviewUrl(document.fileId, page);
|
|
110
|
+
return await this.#documentFileService.getPreviewUrl(document.fileId, page);
|
|
108
111
|
}
|
|
109
112
|
/**
|
|
110
113
|
* @returns collectionIds from either direct assignment or automatic assignment scope
|
|
111
114
|
*/
|
|
112
115
|
async createAssignment(documentId, assignment, transaction) {
|
|
113
|
-
return match(assignment)
|
|
116
|
+
return await match(assignment)
|
|
114
117
|
.with({ collections: P.select() }, async (collectionIds) => {
|
|
115
118
|
const collectionIdsArray = toArray(collectionIds);
|
|
116
119
|
await this.#documentCollectionService.withTransaction(transaction).assignDocument(documentId, collectionIdsArray);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { TypedOmit } from '../../types.js';
|
|
2
|
+
import { Document, DocumentAssignmentTarget, DocumentAssignmentTask, DocumentCategory, DocumentCollection, DocumentCollectionAssignment, DocumentFile, DocumentPropertyDataType, DocumentRequest, DocumentType, DocumentValidationExecution, DocumentWorkflow } from '../models/index.js';
|
|
2
3
|
export declare class DocumentCollectionView extends DocumentCollection {
|
|
3
4
|
name: string;
|
|
4
5
|
group: string | null;
|
|
@@ -10,8 +11,20 @@ export declare class DocumentPropertyValueView {
|
|
|
10
11
|
dataType: DocumentPropertyDataType;
|
|
11
12
|
value: string | number | boolean | null;
|
|
12
13
|
}
|
|
14
|
+
export declare class DocumentCollectionAssignmentView implements TypedOmit<DocumentCollectionAssignment, 'id' | 'documentId' | 'metadata'> {
|
|
15
|
+
collectionId: string;
|
|
16
|
+
archiveTimestamp: number | null;
|
|
17
|
+
}
|
|
18
|
+
export declare class DocumentAssignmentTaskView implements TypedOmit<DocumentAssignmentTask, 'id' | 'documentId' | 'metadata'> {
|
|
19
|
+
target: DocumentAssignmentTarget;
|
|
20
|
+
scope: string[];
|
|
21
|
+
}
|
|
22
|
+
export declare class DocumentAssignmentView {
|
|
23
|
+
collections: DocumentCollectionAssignmentView[];
|
|
24
|
+
assignmentTask: DocumentAssignmentTaskView | null;
|
|
25
|
+
}
|
|
13
26
|
export declare class DocumentView extends Document {
|
|
14
|
-
|
|
27
|
+
assignment: DocumentAssignmentView;
|
|
15
28
|
properties: DocumentPropertyValueView[];
|
|
16
29
|
/** available as long as the document is neither approved nor rejected */
|
|
17
30
|
currentWorkflow: DocumentWorkflow | null;
|
|
@@ -19,8 +32,6 @@ export declare class DocumentView extends Document {
|
|
|
19
32
|
}
|
|
20
33
|
export declare class DocumentRequestView extends DocumentRequest {
|
|
21
34
|
collectionIds: string[];
|
|
22
|
-
/** current approval-pending or approved document */
|
|
23
|
-
document: Document | null;
|
|
24
35
|
}
|
|
25
36
|
export declare class DocumentManagementData {
|
|
26
37
|
collections: DocumentCollectionView[];
|
|
@@ -7,8 +7,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
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
|
-
import { Array, Enumeration, Property, StringProperty, Union } from '../../schema/index.js';
|
|
11
|
-
import { Document, DocumentCategory, DocumentCollection, DocumentCollectionAssignment, DocumentFile, DocumentPropertyDataType, DocumentRequest, DocumentType, DocumentValidationExecution, DocumentWorkflow } from '../models/index.js';
|
|
10
|
+
import { Array, Enumeration, Property, string, StringProperty, Union } from '../../schema/index.js';
|
|
11
|
+
import { Document, DocumentAssignmentTarget, DocumentAssignmentTask, DocumentCategory, DocumentCollection, DocumentCollectionAssignment, DocumentFile, DocumentPropertyDataType, DocumentRequest, DocumentType, DocumentValidationExecution, DocumentWorkflow } from '../models/index.js';
|
|
12
12
|
export class DocumentCollectionView extends DocumentCollection {
|
|
13
13
|
name;
|
|
14
14
|
group;
|
|
@@ -48,17 +48,53 @@ __decorate([
|
|
|
48
48
|
Union(String, Number, Boolean, { nullable: true }),
|
|
49
49
|
__metadata("design:type", Object)
|
|
50
50
|
], DocumentPropertyValueView.prototype, "value", void 0);
|
|
51
|
+
export class DocumentCollectionAssignmentView {
|
|
52
|
+
collectionId;
|
|
53
|
+
archiveTimestamp;
|
|
54
|
+
}
|
|
55
|
+
__decorate([
|
|
56
|
+
StringProperty(),
|
|
57
|
+
__metadata("design:type", String)
|
|
58
|
+
], DocumentCollectionAssignmentView.prototype, "collectionId", void 0);
|
|
59
|
+
__decorate([
|
|
60
|
+
StringProperty({ nullable: true }),
|
|
61
|
+
__metadata("design:type", Object)
|
|
62
|
+
], DocumentCollectionAssignmentView.prototype, "archiveTimestamp", void 0);
|
|
63
|
+
export class DocumentAssignmentTaskView {
|
|
64
|
+
target;
|
|
65
|
+
scope;
|
|
66
|
+
}
|
|
67
|
+
__decorate([
|
|
68
|
+
Enumeration(DocumentAssignmentTarget),
|
|
69
|
+
__metadata("design:type", String)
|
|
70
|
+
], DocumentAssignmentTaskView.prototype, "target", void 0);
|
|
71
|
+
__decorate([
|
|
72
|
+
Array(string()),
|
|
73
|
+
__metadata("design:type", Array)
|
|
74
|
+
], DocumentAssignmentTaskView.prototype, "scope", void 0);
|
|
75
|
+
export class DocumentAssignmentView {
|
|
76
|
+
collections;
|
|
77
|
+
assignmentTask;
|
|
78
|
+
}
|
|
79
|
+
__decorate([
|
|
80
|
+
Array(DocumentCollectionAssignmentView),
|
|
81
|
+
__metadata("design:type", Array)
|
|
82
|
+
], DocumentAssignmentView.prototype, "collections", void 0);
|
|
83
|
+
__decorate([
|
|
84
|
+
Property(DocumentAssignmentTaskView, { nullable: true }),
|
|
85
|
+
__metadata("design:type", Object)
|
|
86
|
+
], DocumentAssignmentView.prototype, "assignmentTask", void 0);
|
|
51
87
|
export class DocumentView extends Document {
|
|
52
|
-
|
|
88
|
+
assignment;
|
|
53
89
|
properties;
|
|
54
90
|
/** available as long as the document is neither approved nor rejected */
|
|
55
91
|
currentWorkflow;
|
|
56
92
|
validations;
|
|
57
93
|
}
|
|
58
94
|
__decorate([
|
|
59
|
-
|
|
60
|
-
__metadata("design:type",
|
|
61
|
-
], DocumentView.prototype, "
|
|
95
|
+
Property(DocumentAssignmentView),
|
|
96
|
+
__metadata("design:type", DocumentAssignmentView)
|
|
97
|
+
], DocumentView.prototype, "assignment", void 0);
|
|
62
98
|
__decorate([
|
|
63
99
|
Array(DocumentPropertyValueView),
|
|
64
100
|
__metadata("design:type", Array)
|
|
@@ -73,17 +109,11 @@ __decorate([
|
|
|
73
109
|
], DocumentView.prototype, "validations", void 0);
|
|
74
110
|
export class DocumentRequestView extends DocumentRequest {
|
|
75
111
|
collectionIds;
|
|
76
|
-
/** current approval-pending or approved document */
|
|
77
|
-
document;
|
|
78
112
|
}
|
|
79
113
|
__decorate([
|
|
80
114
|
Array(String),
|
|
81
115
|
__metadata("design:type", Array)
|
|
82
116
|
], DocumentRequestView.prototype, "collectionIds", void 0);
|
|
83
|
-
__decorate([
|
|
84
|
-
Property(Document, { nullable: true }),
|
|
85
|
-
__metadata("design:type", Object)
|
|
86
|
-
], DocumentRequestView.prototype, "document", void 0);
|
|
87
117
|
export class DocumentManagementData {
|
|
88
118
|
collections;
|
|
89
119
|
documents;
|
|
@@ -5,6 +5,7 @@ export const metadataParameterSchema = optional(partial(pick(EntityMetadata, 'at
|
|
|
5
5
|
export const metadataParameterObjectSchema = object({ metadata: metadataParameterSchema });
|
|
6
6
|
export const setDocumentPropertyParametersSchema = assign(pick(DocumentPropertyValue, ['propertyId']), object({ value: union(string(), number(), boolean(), nullable(never())) }), metadataParameterObjectSchema);
|
|
7
7
|
export const createDocumentParametersSchema = assign(partial(pick(Document, ['typeId', 'title', 'subtitle', 'date', 'summary', 'tags', 'approval', 'comment'])), pick(DocumentFile, ['originalFileName']), object({
|
|
8
|
+
uploadId: string(),
|
|
8
9
|
assignment: union(object({ collections: oneOrMany(string(), { minimum: 1 }) }), object({ request: string() }), object({
|
|
9
10
|
automatic: object({
|
|
10
11
|
/** collection ids to assign in */
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import type { TypedOmit } from '../../../types.js';
|
|
2
2
|
import type { DocumentCollectionAssignment } from '../../models/index.js';
|
|
3
|
+
import type { DocumentAssignmentTaskView, DocumentAssignmentView, DocumentCollectionAssignmentView } from '../document-management.view-model.js';
|
|
3
4
|
import type { EnrichedDocumentCollection } from './enriched-document-collection.view.js';
|
|
5
|
+
import type { EnrichedDocumentManagementData } from './enriched-document-management-data.view.js';
|
|
4
6
|
import type { EnrichedDocument } from './enriched-document.view.js';
|
|
5
|
-
export declare class
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
export declare class EnrichedDocumentCollectionAssignment implements TypedOmit<DocumentCollectionAssignment, 'id' | 'collectionId' | 'documentId' | 'metadata'> {
|
|
8
|
+
#private;
|
|
9
|
+
get collection(): EnrichedDocumentCollection;
|
|
8
10
|
readonly document: EnrichedDocument;
|
|
9
11
|
readonly archiveTimestamp: number | null;
|
|
10
|
-
constructor(
|
|
12
|
+
constructor(data: EnrichedDocumentManagementData, assignment: DocumentCollectionAssignmentView, document: EnrichedDocument);
|
|
13
|
+
}
|
|
14
|
+
export declare class EnrichedDocumentAssignment implements TypedOmit<DocumentAssignmentView, 'collections' | 'assignmentTask'> {
|
|
15
|
+
#private;
|
|
16
|
+
get collections(): EnrichedDocumentCollectionAssignment[];
|
|
17
|
+
get document(): EnrichedDocument;
|
|
18
|
+
readonly assignmentTask: DocumentAssignmentTaskView | null;
|
|
19
|
+
constructor(data: EnrichedDocumentManagementData, document: EnrichedDocument, assignment: DocumentAssignmentView);
|
|
11
20
|
}
|
|
@@ -1,12 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { assertDefinedPass } from '../../../utils/type-guards.js';
|
|
2
|
+
export class EnrichedDocumentCollectionAssignment {
|
|
3
|
+
#data;
|
|
4
|
+
#assignment;
|
|
5
|
+
get collection() {
|
|
6
|
+
return assertDefinedPass(this.#data.maps.collections.get(this.#assignment.collectionId));
|
|
7
|
+
}
|
|
4
8
|
document;
|
|
5
9
|
archiveTimestamp;
|
|
6
|
-
constructor(
|
|
7
|
-
this
|
|
8
|
-
this
|
|
10
|
+
constructor(data, assignment, document) {
|
|
11
|
+
this.#data = data;
|
|
12
|
+
this.#assignment = assignment;
|
|
9
13
|
this.document = document;
|
|
10
|
-
this.archiveTimestamp = archiveTimestamp;
|
|
14
|
+
this.archiveTimestamp = assignment.archiveTimestamp;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export class EnrichedDocumentAssignment {
|
|
18
|
+
#data;
|
|
19
|
+
#collections;
|
|
20
|
+
#document;
|
|
21
|
+
get collections() {
|
|
22
|
+
return this.#collections;
|
|
23
|
+
}
|
|
24
|
+
get document() {
|
|
25
|
+
return this.#document;
|
|
26
|
+
}
|
|
27
|
+
assignmentTask;
|
|
28
|
+
constructor(data, document, assignment) {
|
|
29
|
+
this.#data = data;
|
|
30
|
+
this.#document = document;
|
|
31
|
+
this.#collections = assignment.collections.map((assignment) => new EnrichedDocumentCollectionAssignment(data, assignment, document));
|
|
32
|
+
this.assignmentTask = assignment.assignmentTask;
|
|
11
33
|
}
|
|
12
34
|
}
|
|
@@ -22,7 +22,7 @@ export class EnrichedDocumentCollection {
|
|
|
22
22
|
return this.children.flatMap((child) => [child, ...child.childrenDeep]);
|
|
23
23
|
}
|
|
24
24
|
get documents() {
|
|
25
|
-
return this.#data.documents.filter((document) => document.assignments.some((assignment) => assignment.collection.id == this.id));
|
|
25
|
+
return this.#data.documents.filter((document) => document.assignments.collections.some((assignment) => assignment.collection.id == this.id));
|
|
26
26
|
}
|
|
27
27
|
get documentsDeep() {
|
|
28
28
|
return [...this.documents, ...this.children.flatMap((child) => child.documentsDeep)];
|
|
@@ -5,7 +5,7 @@ import type { EnrichedDocumentCollection } from './enriched-document-collection.
|
|
|
5
5
|
import type { EnrichedDocumentManagementData } from './enriched-document-management-data.view.js';
|
|
6
6
|
import type { EnrichedDocumentType } from './enriched-document-type.view.js';
|
|
7
7
|
import type { EnrichedDocument } from './enriched-document.view.js';
|
|
8
|
-
export declare class EnrichedDocumentRequest implements TypedOmit<DocumentRequestView, 'typeId' | 'documentId' | '
|
|
8
|
+
export declare class EnrichedDocumentRequest implements TypedOmit<DocumentRequestView, 'typeId' | 'documentId' | 'collectionIds' | 'metadata'> {
|
|
9
9
|
#private;
|
|
10
10
|
readonly id: string;
|
|
11
11
|
readonly comment: string | null;
|
|
@@ -5,7 +5,7 @@ import { EnrichedDocumentAssignment } from './enriched-document-assignment.view.
|
|
|
5
5
|
import { EnrichedDocumentFile } from './enriched-document-file.view.js';
|
|
6
6
|
import type { EnrichedDocumentManagementData } from './enriched-document-management-data.view.js';
|
|
7
7
|
import type { EnrichedDocumentType } from './enriched-document-type.view.js';
|
|
8
|
-
export declare class EnrichedDocument implements TypedOmit<DocumentView, 'typeId' | 'fileId' | '
|
|
8
|
+
export declare class EnrichedDocument implements TypedOmit<DocumentView, 'typeId' | 'fileId' | 'assignment' | 'createUserId' | 'metadata'> {
|
|
9
9
|
#private;
|
|
10
10
|
readonly id: string;
|
|
11
11
|
readonly title: string | null;
|
|
@@ -21,6 +21,6 @@ export declare class EnrichedDocument implements TypedOmit<DocumentView, 'typeId
|
|
|
21
21
|
readonly validations: DocumentValidationExecution[] | null;
|
|
22
22
|
get type(): EnrichedDocumentType | null;
|
|
23
23
|
get file(): EnrichedDocumentFile;
|
|
24
|
-
get assignments(): EnrichedDocumentAssignment
|
|
24
|
+
get assignments(): EnrichedDocumentAssignment;
|
|
25
25
|
constructor(data: EnrichedDocumentManagementData, document: DocumentView);
|
|
26
26
|
}
|
|
@@ -37,11 +37,7 @@ export class EnrichedDocument {
|
|
|
37
37
|
return new EnrichedDocumentFile(file, this);
|
|
38
38
|
}
|
|
39
39
|
get assignments() {
|
|
40
|
-
return this.#documentView.
|
|
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
|
-
});
|
|
40
|
+
return new EnrichedDocumentAssignment(this.#data, this, this.#documentView.assignment);
|
|
45
41
|
}
|
|
46
42
|
constructor(data, document) {
|
|
47
43
|
this.#data = data;
|
|
@@ -72,6 +68,6 @@ __decorate([
|
|
|
72
68
|
], EnrichedDocument.prototype, "file", null);
|
|
73
69
|
__decorate([
|
|
74
70
|
Memoize(),
|
|
75
|
-
__metadata("design:type",
|
|
71
|
+
__metadata("design:type", EnrichedDocumentAssignment),
|
|
76
72
|
__metadata("design:paramtypes", [])
|
|
77
73
|
], EnrichedDocument.prototype, "assignments", null);
|
|
@@ -3,7 +3,7 @@ import type { DocumentCollection, DocumentWorkflowStep } from '../../document-ma
|
|
|
3
3
|
import { DocumentManagementAncillaryService, type DocumentCollectionMetadata } from '../../document-management/server/index.js';
|
|
4
4
|
export declare class ExampleDocumentManagementAncillaryService extends DocumentManagementAncillaryService {
|
|
5
5
|
_resolveMetadata(collections: DocumentCollection[]): DocumentCollectionMetadata[];
|
|
6
|
-
|
|
6
|
+
getSubject(_token?: unknown): string;
|
|
7
7
|
canCreateDocuments(_collectionId: string, _token?: unknown): boolean;
|
|
8
8
|
canUpdateDocuments(_collectionId: string, _token?: unknown): boolean;
|
|
9
9
|
canDeleteDocuments(_collectionId: string, _token?: unknown): boolean;
|
|
@@ -6,20 +6,23 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
import '../../polyfills.js';
|
|
8
8
|
import { configureAiService } from '../../ai/index.js';
|
|
9
|
+
import { MockApiRequestTokenProvider } from '../../api/server/api-request-token.provider.js';
|
|
9
10
|
import { configureApiServer } from '../../api/server/module.js';
|
|
10
11
|
import { Application } from '../../application/application.js';
|
|
11
|
-
import { AuthenticationApiRequestTokenProvider } from '../../authentication/server/authentication-api-request-token.provider.js';
|
|
12
12
|
import { DocumentCategoryTypeService, DocumentCollectionService, DocumentManagementAncillaryService, DocumentManagementApiController, DocumentRequestService } from '../../document-management/server/index.js';
|
|
13
13
|
import { configureDocumentManagement, migrateDocumentManagementSchema } from '../../document-management/server/module.js';
|
|
14
14
|
import { DocumentManagementService } from '../../document-management/server/services/document-management.service.js';
|
|
15
|
+
import { configureNodeHttpServer } from '../../http/server/node/module.js';
|
|
15
16
|
import { Injector, Singleton } from '../../injector/index.js';
|
|
16
17
|
import { inject, injectManyAsync, runInInjectionContext } from '../../injector/inject.js';
|
|
17
18
|
import { configureLocalMessageBus } from '../../message-bus/index.js';
|
|
19
|
+
import { WebServerModule } from '../../module/index.js';
|
|
18
20
|
import { configureS3ObjectStorage } from '../../object-storage/index.js';
|
|
19
21
|
import { configureOrm } from '../../orm/server/index.js';
|
|
20
22
|
import { configurePostgresQueue, migratePostgresQueueSchema } from '../../queue/postgres/index.js';
|
|
21
23
|
import { boolean, positiveInteger, string } from '../../utils/config-parser.js';
|
|
22
24
|
import { TstdlCategoryParents, TstdlDocumentCategoryLabels, TstdlDocumentTypeCategories, TstdlDocumentTypeLabels } from './categories-and-types.js';
|
|
25
|
+
import { configureTstdl } from '../../core.js';
|
|
23
26
|
const config = {
|
|
24
27
|
database: {
|
|
25
28
|
host: string('DATABASE_HOST', '127.0.0.1'),
|
|
@@ -45,11 +48,12 @@ const config = {
|
|
|
45
48
|
bucketPerModule: boolean('S3_BUCKET_PER_MODULE', true),
|
|
46
49
|
},
|
|
47
50
|
};
|
|
51
|
+
const userId = crypto.randomUUID();
|
|
48
52
|
let ExampleDocumentManagementAncillaryService = class ExampleDocumentManagementAncillaryService extends DocumentManagementAncillaryService {
|
|
49
53
|
_resolveMetadata(collections) {
|
|
50
|
-
return collections.map((collection) => ({ name: collection.id, group: null }));
|
|
54
|
+
return collections.map((collection) => ({ name: collection.id.split('-')[0], group: null }));
|
|
51
55
|
}
|
|
52
|
-
|
|
56
|
+
getSubject(_token) { return userId; }
|
|
53
57
|
canCreateDocuments(_collectionId, _token) { return true; }
|
|
54
58
|
canUpdateDocuments(_collectionId, _token) { return true; }
|
|
55
59
|
canDeleteDocuments(_collectionId, _token) { return true; }
|
|
@@ -70,6 +74,8 @@ ExampleDocumentManagementAncillaryService = __decorate([
|
|
|
70
74
|
export { ExampleDocumentManagementAncillaryService };
|
|
71
75
|
async function bootstrap() {
|
|
72
76
|
const injector = inject(Injector);
|
|
77
|
+
configureTstdl();
|
|
78
|
+
configureNodeHttpServer();
|
|
73
79
|
configurePostgresQueue();
|
|
74
80
|
configureLocalMessageBus();
|
|
75
81
|
configureOrm({
|
|
@@ -84,6 +90,7 @@ async function bootstrap() {
|
|
|
84
90
|
configureDocumentManagement({
|
|
85
91
|
ancillaryService: ExampleDocumentManagementAncillaryService,
|
|
86
92
|
fileObjectStorageModule: 'documents',
|
|
93
|
+
fileUploadObjectStorageModule: 'document-uploads',
|
|
87
94
|
filePreviewObjectStorageModule: 'document-previews',
|
|
88
95
|
});
|
|
89
96
|
configureS3ObjectStorage({
|
|
@@ -95,7 +102,7 @@ async function bootstrap() {
|
|
|
95
102
|
});
|
|
96
103
|
configureApiServer({
|
|
97
104
|
controllers: [DocumentManagementApiController],
|
|
98
|
-
requestTokenProvider:
|
|
105
|
+
requestTokenProvider: MockApiRequestTokenProvider,
|
|
99
106
|
gatewayOptions: {
|
|
100
107
|
prefix: null,
|
|
101
108
|
cors: {
|
|
@@ -116,8 +123,13 @@ async function bootstrap() {
|
|
|
116
123
|
async function main() {
|
|
117
124
|
const [documentManagementService, documentCollectionService] = await injectManyAsync(DocumentManagementService, DocumentCollectionService, DocumentCategoryTypeService, DocumentRequestService);
|
|
118
125
|
const { categories, types } = await documentManagementService.initializeCategoriesAndTypes(TstdlDocumentCategoryLabels, TstdlCategoryParents, TstdlDocumentTypeLabels, TstdlDocumentTypeCategories);
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
126
|
+
const collectionCount = await documentCollectionService.repository.count();
|
|
127
|
+
for (let i = 0; i < (3 - collectionCount); i++) {
|
|
128
|
+
await documentCollectionService.createCollection(null);
|
|
129
|
+
}
|
|
130
|
+
const collections = await documentCollectionService.repository.loadAll();
|
|
131
|
+
for (const collection of collections) {
|
|
132
|
+
console.log(`Collection: ${collection.id}`);
|
|
133
|
+
}
|
|
122
134
|
}
|
|
123
|
-
Application.run({ bootstrap }, main);
|
|
135
|
+
Application.run({ bootstrap }, main, WebServerModule);
|
|
@@ -56,7 +56,7 @@ let UndiciHttpClientAdapter = class UndiciHttpClientAdapter extends HttpClientAd
|
|
|
56
56
|
body,
|
|
57
57
|
headersTimeout: httpClientRequest.timeout,
|
|
58
58
|
bodyTimeout: httpClientRequest.timeout,
|
|
59
|
-
dispatcher: this.options.dispatcher
|
|
59
|
+
dispatcher: this.options.dispatcher,
|
|
60
60
|
});
|
|
61
61
|
const httpClientResponse = new HttpClientResponse({
|
|
62
62
|
request: httpClientRequest,
|
|
@@ -64,14 +64,14 @@ let UndiciHttpClientAdapter = class UndiciHttpClientAdapter extends HttpClientAd
|
|
|
64
64
|
statusMessage: '?',
|
|
65
65
|
headers: new HttpHeaders(response.headers),
|
|
66
66
|
body: response.body,
|
|
67
|
-
closeHandler: () => response.body.destroy()
|
|
67
|
+
closeHandler: () => response.body.destroy(),
|
|
68
68
|
});
|
|
69
69
|
return httpClientResponse;
|
|
70
70
|
}
|
|
71
71
|
catch (error) {
|
|
72
72
|
if (error instanceof undiciErrors.UndiciError) {
|
|
73
73
|
const reason = getHttpErrorReason(error);
|
|
74
|
-
throw new HttpError(reason, httpClientRequest,
|
|
74
|
+
throw new HttpError(reason, httpClientRequest, { cause: error });
|
|
75
75
|
}
|
|
76
76
|
throw error;
|
|
77
77
|
}
|