@tstdl/base 0.93.61 → 0.93.64
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/genkit/helpers.d.ts +10 -0
- package/ai/genkit/helpers.js +14 -0
- package/ai/genkit/index.d.ts +2 -0
- package/ai/genkit/index.js +2 -0
- package/ai/genkit/module.d.ts +35 -0
- package/ai/genkit/module.js +56 -0
- package/ai/index.d.ts +1 -0
- package/ai/index.js +1 -0
- package/ai/prompts/format.d.ts +15 -0
- package/ai/prompts/format.js +17 -0
- package/ai/prompts/index.d.ts +3 -0
- package/ai/prompts/index.js +3 -0
- package/ai/prompts/instructions-formatter.d.ts +25 -0
- package/ai/prompts/instructions-formatter.js +166 -0
- package/ai/prompts/instructions.d.ts +3 -0
- package/ai/prompts/instructions.js +8 -0
- package/document-management/api/document-management.api.d.ts +8 -8
- package/document-management/models/document-assignment-scope.model.d.ts +3 -4
- package/document-management/models/document-assignment-scope.model.js +5 -9
- package/document-management/models/document-assignment-task.model.d.ts +3 -4
- package/document-management/models/document-assignment-task.model.js +4 -8
- package/document-management/models/document-category.model.d.ts +3 -4
- package/document-management/models/document-category.model.js +4 -8
- package/document-management/models/document-collection-assignment.model.d.ts +2 -3
- package/document-management/models/document-collection-assignment.model.js +4 -9
- package/document-management/models/document-collection.model.d.ts +3 -4
- package/document-management/models/document-collection.model.js +4 -8
- package/document-management/models/document-property-value.model.d.ts +3 -4
- package/document-management/models/document-property-value.model.js +5 -9
- package/document-management/models/document-property.model.d.ts +3 -4
- package/document-management/models/document-property.model.js +3 -7
- package/document-management/models/document-request-collection-assignment.model.d.ts +3 -4
- package/document-management/models/document-request-collection-assignment.model.js +5 -9
- package/document-management/models/document-request-template.d.ts +2 -3
- package/document-management/models/document-request-template.js +4 -9
- package/document-management/models/document-request.model.d.ts +3 -4
- package/document-management/models/document-request.model.js +5 -9
- package/document-management/models/document-requests-template.d.ts +2 -3
- package/document-management/models/document-requests-template.js +2 -7
- package/document-management/models/document-tag-assignment.model.d.ts +3 -4
- package/document-management/models/document-tag-assignment.model.js +5 -9
- package/document-management/models/document-tag.model.d.ts +3 -4
- package/document-management/models/document-tag.model.js +3 -7
- package/document-management/models/document-type-property.model.d.ts +2 -3
- package/document-management/models/document-type-property.model.js +4 -9
- package/document-management/models/document-type-validation.model.d.ts +2 -3
- package/document-management/models/document-type-validation.model.js +4 -9
- package/document-management/models/document-type.model.d.ts +3 -4
- package/document-management/models/document-type.model.js +4 -8
- package/document-management/models/document-validation-definition.model.d.ts +3 -4
- package/document-management/models/document-validation-definition.model.js +3 -7
- package/document-management/models/document-validation-execution-related-document.model.d.ts +3 -4
- package/document-management/models/document-validation-execution-related-document.model.js +5 -9
- package/document-management/models/document-validation-execution.model.d.ts +3 -4
- package/document-management/models/document-validation-execution.model.js +5 -9
- package/document-management/models/document-workflow.model.d.ts +3 -4
- package/document-management/models/document-workflow.model.js +4 -8
- package/document-management/models/document.model.d.ts +3 -4
- package/document-management/models/document.model.js +4 -8
- package/document-management/server/drizzle/0001_lyrical_wong.sql +123 -0
- package/document-management/server/drizzle/meta/0001_snapshot.json +2728 -0
- package/document-management/server/drizzle/meta/_journal.json +7 -0
- package/document-management/server/services/document-category-type.service.d.ts +6 -6
- package/document-management/server/services/document-category-type.service.js +6 -6
- package/document-management/server/services/document-file.service.d.ts +2 -0
- package/document-management/server/services/document-file.service.js +10 -9
- package/document-management/server/services/document-management-ai.service.d.ts +1 -0
- package/document-management/server/services/document-management-ai.service.js +268 -135
- package/document-management/server/services/document-management.service.d.ts +2 -2
- package/document-management/server/services/document-property.service.d.ts +4 -4
- package/document-management/server/services/document-property.service.js +3 -3
- package/document-management/server/services/document-request.service.d.ts +2 -2
- package/document-management/server/services/document-request.service.js +1 -1
- package/document-management/server/services/document-tag.service.d.ts +1 -1
- package/document-management/server/services/document-tag.service.js +2 -2
- package/document-management/server/services/document-validation.service.js +6 -6
- package/document-management/server/services/document.service.js +2 -7
- package/document-management/service-models/document-management.view-model.d.ts +1 -1
- package/document-management/service-models/document-management.view-model.js +1 -1
- package/document-management/service-models/document.service-model.d.ts +4 -4
- package/document-management/service-models/enriched/enriched-document-category.view.d.ts +1 -1
- package/document-management/service-models/enriched/enriched-document-type.view.d.ts +1 -1
- package/examples/document-management/main.js +6 -0
- package/json-path/json-path.js +1 -1
- package/orm/decorators.d.ts +18 -7
- package/orm/decorators.js +10 -2
- package/orm/entity.d.ts +2 -2
- package/orm/entity.js +2 -0
- package/orm/server/drizzle/schema-converter.d.ts +3 -3
- package/orm/server/drizzle/schema-converter.js +22 -5
- package/orm/server/repository.js +4 -6
- package/package.json +11 -7
- package/pdf/utils.js +1 -1
- package/schema/converters/zod-converter.d.ts +1 -1
- package/schema/converters/zod-converter.js +2 -13
- package/schema/converters/zod-v3-converter.d.ts +3 -3
- package/utils/file-reader.d.ts +0 -1
- package/utils/file-reader.js +4 -7
- package/utils/object/object.d.ts +4 -2
- package/utils/object/object.js +30 -21
- package/utils/stream/from-promise.js +2 -2
|
@@ -7,29 +7,29 @@ export declare class DocumentCategoryTypeService extends Transactional {
|
|
|
7
7
|
loadCategory(tenantId: string, id: string): Promise<DocumentCategory>;
|
|
8
8
|
loadType(tenantId: string, id: string): Promise<DocumentType>;
|
|
9
9
|
createCategory(data: {
|
|
10
|
-
tenantId: string
|
|
10
|
+
tenantId: string;
|
|
11
11
|
label: string;
|
|
12
12
|
parentId: string | null;
|
|
13
13
|
enumKey?: string;
|
|
14
14
|
}): Promise<DocumentCategory>;
|
|
15
15
|
createType(data: {
|
|
16
|
-
tenantId: string
|
|
16
|
+
tenantId: string;
|
|
17
17
|
label: string;
|
|
18
18
|
categoryId: string;
|
|
19
19
|
enumKey?: string;
|
|
20
20
|
}): Promise<DocumentType>;
|
|
21
|
-
updateCategory(tenantId: string
|
|
21
|
+
updateCategory(tenantId: string, id: string, update: {
|
|
22
22
|
label?: string;
|
|
23
23
|
parentId?: string | null;
|
|
24
24
|
}): Promise<DocumentCategory>;
|
|
25
|
-
updateType(tenantId: string
|
|
25
|
+
updateType(tenantId: string, id: string, update: {
|
|
26
26
|
label?: string;
|
|
27
27
|
categoryId?: string;
|
|
28
28
|
}): Promise<DocumentType>;
|
|
29
29
|
loadCategoryGraph(tenantId: string, categoryId: string): Promise<DocumentCategory[]>;
|
|
30
|
-
loadCategoriesAndTypes(tenantId: string
|
|
30
|
+
loadCategoriesAndTypes(tenantId: string): Promise<{
|
|
31
31
|
categories: DocumentCategory[];
|
|
32
32
|
types: DocumentType[];
|
|
33
33
|
}>;
|
|
34
|
-
loadCategoryViews(tenantId: string
|
|
34
|
+
loadCategoryViews(tenantId: string): Promise<DocumentCategoryView[]>;
|
|
35
35
|
}
|
|
@@ -14,10 +14,10 @@ let DocumentCategoryTypeService = class DocumentCategoryTypeService extends Tran
|
|
|
14
14
|
categoryRepository = injectRepository(DocumentCategory);
|
|
15
15
|
typeRepository = injectRepository(DocumentType);
|
|
16
16
|
async loadCategory(tenantId, id) {
|
|
17
|
-
return await this.categoryRepository.loadByQuery({
|
|
17
|
+
return await this.categoryRepository.loadByQuery({ tenantId, id });
|
|
18
18
|
}
|
|
19
19
|
async loadType(tenantId, id) {
|
|
20
|
-
return await this.typeRepository.loadByQuery({
|
|
20
|
+
return await this.typeRepository.loadByQuery({ tenantId, id });
|
|
21
21
|
}
|
|
22
22
|
async createCategory(data) {
|
|
23
23
|
return await this.categoryRepository.insert({
|
|
@@ -29,7 +29,7 @@ let DocumentCategoryTypeService = class DocumentCategoryTypeService extends Tran
|
|
|
29
29
|
}
|
|
30
30
|
async createType(data) {
|
|
31
31
|
// Ensure the category exists for the tenant before creating the type
|
|
32
|
-
await this.categoryRepository.loadByQuery({ tenantId:
|
|
32
|
+
await this.categoryRepository.loadByQuery({ tenantId: data.tenantId, id: data.categoryId });
|
|
33
33
|
return await this.typeRepository.insert({
|
|
34
34
|
tenantId: data.tenantId,
|
|
35
35
|
label: data.label,
|
|
@@ -44,7 +44,7 @@ let DocumentCategoryTypeService = class DocumentCategoryTypeService extends Tran
|
|
|
44
44
|
return await this.typeRepository.updateByQuery({ tenantId, id }, update);
|
|
45
45
|
}
|
|
46
46
|
async loadCategoryGraph(tenantId, categoryId) {
|
|
47
|
-
const category = await this.categoryRepository.loadByQuery({ tenantId
|
|
47
|
+
const category = await this.categoryRepository.loadByQuery({ tenantId, id: categoryId });
|
|
48
48
|
if (category.parentId == null) {
|
|
49
49
|
return [category];
|
|
50
50
|
}
|
|
@@ -53,8 +53,8 @@ let DocumentCategoryTypeService = class DocumentCategoryTypeService extends Tran
|
|
|
53
53
|
}
|
|
54
54
|
async loadCategoriesAndTypes(tenantId) {
|
|
55
55
|
const [categories, types] = await Promise.all([
|
|
56
|
-
this.categoryRepository.loadManyByQuery({ tenantId
|
|
57
|
-
this.typeRepository.loadManyByQuery({ tenantId
|
|
56
|
+
this.categoryRepository.loadManyByQuery({ tenantId }, { order: 'label' }),
|
|
57
|
+
this.typeRepository.loadManyByQuery({ tenantId }, { order: 'label' }),
|
|
58
58
|
]);
|
|
59
59
|
return { categories, types };
|
|
60
60
|
}
|
|
@@ -29,6 +29,8 @@ export declare class DocumentFileService extends Transactional {
|
|
|
29
29
|
getContent(document: Document): Promise<Uint8Array>;
|
|
30
30
|
getContentStream(document: Document): ReadableStream<Uint8Array>;
|
|
31
31
|
getContentUrl(document: Document, download?: boolean): Promise<string>;
|
|
32
|
+
/** Gets the underlying object storage object for the document file */
|
|
33
|
+
getObject(document: Document): Promise<import("../../../object-storage/index.js").ObjectStorageObject>;
|
|
32
34
|
getPreview(document: Document, page?: number): Promise<Uint8Array>;
|
|
33
35
|
getPreviewStream(document: Document, page?: number): ReadableStream<Uint8Array>;
|
|
34
36
|
getPreviewUrl(document: Document, page?: number): Promise<string>;
|
|
@@ -56,8 +56,6 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
|
|
|
56
56
|
var e = new Error(message);
|
|
57
57
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
58
58
|
});
|
|
59
|
-
var _a;
|
|
60
|
-
var DocumentFileService_1;
|
|
61
59
|
import sharp, {} from 'sharp';
|
|
62
60
|
import { match } from 'ts-pattern';
|
|
63
61
|
import { AiService } from '../../../ai/ai.service.js';
|
|
@@ -66,7 +64,6 @@ import { NotImplementedError } from '../../../errors/not-implemented.error.js';
|
|
|
66
64
|
import { getMimeType, getMimeTypeExtensions, mimeTypes } from '../../../file/index.js';
|
|
67
65
|
import { TemporaryFile } from '../../../file/server/index.js';
|
|
68
66
|
import { inject } from '../../../injector/inject.js';
|
|
69
|
-
import { Logger } from '../../../logger/logger.js';
|
|
70
67
|
import { ObjectStorage } from '../../../object-storage/index.js';
|
|
71
68
|
import { Transactional } from '../../../orm/server/index.js';
|
|
72
69
|
import { pdfToImage } from '../../../pdf/index.js';
|
|
@@ -80,13 +77,12 @@ import { millisecondsPerMinute, secondsPerMinute } from '../../../utils/units.js
|
|
|
80
77
|
import { Document } from '../../models/index.js';
|
|
81
78
|
import { DocumentManagementConfiguration } from '../module.js';
|
|
82
79
|
import { DocumentManagementSingleton } from './singleton.js';
|
|
83
|
-
let DocumentFileService =
|
|
80
|
+
let DocumentFileService = class DocumentFileService extends Transactional {
|
|
84
81
|
#configuration = inject(DocumentManagementConfiguration);
|
|
85
82
|
#aiService = inject(AiService);
|
|
86
83
|
#fileObjectStorage = inject(ObjectStorage, this.#configuration.fileObjectStorageModule);
|
|
87
84
|
#filePreviewObjectStorage = inject(ObjectStorage, this.#configuration.filePreviewObjectStorageModule);
|
|
88
85
|
#fileUploadObjectStorage = inject(ObjectStorage, { module: this.#configuration.fileUploadObjectStorageModule, configuration: { lifecycle: { expiration: { after: 5 * secondsPerMinute } } } });
|
|
89
|
-
#logger = inject(Logger, DocumentFileService_1.name);
|
|
90
86
|
#aiFilePartCache = new Map();
|
|
91
87
|
/**
|
|
92
88
|
* Initiates a file upload
|
|
@@ -145,6 +141,11 @@ let DocumentFileService = DocumentFileService_1 = class DocumentFileService exte
|
|
|
145
141
|
async getContentUrl(document, download = false) {
|
|
146
142
|
return await this.getDocumentFileContentObjectUrl(document, document.title ?? document.id, download);
|
|
147
143
|
}
|
|
144
|
+
/** Gets the underlying object storage object for the document file */
|
|
145
|
+
async getObject(document) {
|
|
146
|
+
const objectKey = getObjectKey(document.id);
|
|
147
|
+
return await this.#fileObjectStorage.getObject(objectKey);
|
|
148
|
+
}
|
|
148
149
|
async getPreview(document, page = 1) {
|
|
149
150
|
const objectKey = getObjectKey(document.id);
|
|
150
151
|
await this.createPreviewIfNotExists(document, page);
|
|
@@ -197,12 +198,12 @@ let DocumentFileService = DocumentFileService_1 = class DocumentFileService exte
|
|
|
197
198
|
const content = await this.#fileObjectStorage.getContent(key);
|
|
198
199
|
const image = await match(document.mimeType)
|
|
199
200
|
.with('application/pdf', async () => {
|
|
200
|
-
const imageBytes = await pdfToImage(content, page, 768, '
|
|
201
|
+
const imageBytes = await pdfToImage(content, page, 768, 'png');
|
|
201
202
|
return await imageToPreview(imageBytes);
|
|
202
203
|
})
|
|
203
204
|
.with('image/*', async () => await imageToPreview(content))
|
|
204
205
|
.otherwise(() => { throw new NotImplementedError('Preview generation is not implemented for this file type.'); });
|
|
205
|
-
await this.#filePreviewObjectStorage.uploadObject(key, image, { contentLength: image.length, contentType: 'image/
|
|
206
|
+
await this.#filePreviewObjectStorage.uploadObject(key, image, { contentLength: image.length, contentType: 'image/webp' });
|
|
206
207
|
}
|
|
207
208
|
}
|
|
208
209
|
async getDocumentFileContentObjectUrl(document, title, download) {
|
|
@@ -216,7 +217,7 @@ let DocumentFileService = DocumentFileService_1 = class DocumentFileService exte
|
|
|
216
217
|
});
|
|
217
218
|
}
|
|
218
219
|
};
|
|
219
|
-
DocumentFileService =
|
|
220
|
+
DocumentFileService = __decorate([
|
|
220
221
|
DocumentManagementSingleton()
|
|
221
222
|
], DocumentFileService);
|
|
222
223
|
export { DocumentFileService };
|
|
@@ -233,6 +234,6 @@ async function imageToPreview(input) {
|
|
|
233
234
|
withoutEnlargement: true,
|
|
234
235
|
fastShrinkOnLoad: false,
|
|
235
236
|
})
|
|
236
|
-
.toFormat('
|
|
237
|
+
.toFormat('webp', { quality: 75 })
|
|
237
238
|
.toBuffer();
|
|
238
239
|
}
|
|
@@ -15,6 +15,7 @@ export type DocumentInformationExtractionResult = {
|
|
|
15
15
|
};
|
|
16
16
|
export declare class DocumentManagementAiService {
|
|
17
17
|
#private;
|
|
18
|
+
extractDocumentContent(tenantId: string, documentId: string): Promise<string>;
|
|
18
19
|
classifyDocumentType(tenantId: string, documentId: string): Promise<string>;
|
|
19
20
|
extractDocumentInformation(tenantId: string, documentId: string): Promise<DocumentInformationExtractionResult>;
|
|
20
21
|
findSuitableCollectionsForDocument(document: Document, collectionIds: string[]): Promise<string[]>;
|