@tstdl/base 0.92.99 → 0.92.101
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/server/middlewares/cors.middleware.js +7 -8
- package/document-management/api/document-management.api.d.ts +4 -0
- package/document-management/models/document.model.d.ts +1 -0
- package/document-management/models/document.model.js +6 -1
- package/document-management/models/service-models/document.service-model.d.ts +2 -0
- package/document-management/models/service-models/document.service-model.js +1 -1
- package/document-management/models/service-models/document.view-model.d.ts +8 -0
- package/document-management/models/service-models/document.view-model.js +12 -1
- package/document-management/server/drizzle/0001_concerned_quentin_quire.sql +1 -0
- package/document-management/server/drizzle/meta/0001_snapshot.json +1932 -0
- package/document-management/server/drizzle/meta/_journal.json +7 -0
- package/document-management/server/services/document-management.service.d.ts +12 -1
- package/document-management/server/services/document-management.service.js +114 -24
- package/message-bus/message-bus-base.d.ts +0 -1
- package/message-bus/message-bus-base.js +2 -9
- package/orm/decorators.d.ts +5 -4
- package/package.json +1 -1
- package/queue/mongo/queue.d.ts +3 -2
- package/queue/mongo/queue.js +8 -2
- package/queue/postgres/drizzle/0001_certain_wild_pack.sql +2 -0
- package/queue/postgres/drizzle/meta/0001_snapshot.json +103 -0
- package/queue/postgres/drizzle/meta/_journal.json +7 -0
- package/queue/postgres/job.model.js +3 -3
- package/queue/postgres/queue.d.ts +3 -0
- package/queue/postgres/queue.js +13 -6
- package/queue/queue.d.ts +6 -0
- package/utils/try-ignore.d.ts +4 -4
- package/utils/try-ignore.js +2 -2
|
@@ -2,7 +2,6 @@ import { resolveApiEndpointDataProvider } from '../../../api/types.js';
|
|
|
2
2
|
import { toArray } from '../../../utils/array/array.js';
|
|
3
3
|
import { isDefined } from '../../../utils/type-guards.js';
|
|
4
4
|
export function corsMiddleware(options = {}) {
|
|
5
|
-
// eslint-disable-next-line max-statements, @typescript-eslint/no-shadow
|
|
6
5
|
async function corsMiddleware(context, next) {
|
|
7
6
|
try {
|
|
8
7
|
await next();
|
|
@@ -15,18 +14,18 @@ export function corsMiddleware(options = {}) {
|
|
|
15
14
|
const cors = { ...options.default, ...endpointDefinition?.cors };
|
|
16
15
|
if (isOptions) {
|
|
17
16
|
const allowMethods = (await resolveApiEndpointDataProvider(request, context, cors.accessControlAllowMethods)) ?? [...context.api.endpoints.keys()].join(', ');
|
|
18
|
-
response.headers.
|
|
17
|
+
response.headers.set('Access-Control-Allow-Methods', allowMethods);
|
|
19
18
|
if (isDefined(cors.accessControlAllowHeaders) && !request.headers.has('Access-Control-Allow-Headers')) {
|
|
20
19
|
const value = await resolveApiEndpointDataProvider(request, context, cors.accessControlAllowHeaders);
|
|
21
|
-
response.headers.
|
|
20
|
+
response.headers.set('Access-Control-Allow-Headers', value);
|
|
22
21
|
}
|
|
23
22
|
if (isDefined(cors.accessControlExposeHeaders) && !request.headers.has('Access-Control-Expose-Headers')) {
|
|
24
23
|
const value = await resolveApiEndpointDataProvider(request, context, cors.accessControlExposeHeaders);
|
|
25
|
-
response.headers.
|
|
24
|
+
response.headers.set('Access-Control-Expose-Headers', value);
|
|
26
25
|
}
|
|
27
26
|
if (isDefined(cors.accessControlMaxAge) && !request.headers.has('Access-Control-Max-Age')) {
|
|
28
27
|
const value = await resolveApiEndpointDataProvider(request, context, cors.accessControlMaxAge);
|
|
29
|
-
response.headers.
|
|
28
|
+
response.headers.set('Access-Control-Max-Age', value);
|
|
30
29
|
}
|
|
31
30
|
}
|
|
32
31
|
if (!request.headers.has('Access-Control-Allow-Credentials')) {
|
|
@@ -34,19 +33,19 @@ export function corsMiddleware(options = {}) {
|
|
|
34
33
|
? await resolveApiEndpointDataProvider(request, context, cors.accessControlAllowCredentials)
|
|
35
34
|
: endpointDefinition?.credentials;
|
|
36
35
|
if (allowCredentials == true) {
|
|
37
|
-
response.headers.
|
|
36
|
+
response.headers.set('Access-Control-Allow-Credentials', 'true');
|
|
38
37
|
}
|
|
39
38
|
}
|
|
40
39
|
if (isDefined(cors.accessControlAllowOrigin) && !response.headers.has('Access-Control-Allow-Origin')) {
|
|
41
40
|
const value = await resolveApiEndpointDataProvider(request, context, cors.accessControlAllowOrigin);
|
|
42
|
-
response.headers.
|
|
41
|
+
response.headers.set('Access-Control-Allow-Origin', value);
|
|
43
42
|
}
|
|
44
43
|
if (isDefined(cors.autoAccessControlAllowOrigin) && !response.headers.has('Access-Control-Allow-Origin')) {
|
|
45
44
|
const value = await resolveApiEndpointDataProvider(request, context, cors.autoAccessControlAllowOrigin);
|
|
46
45
|
const origin = request.headers.tryGetSingle('Origin');
|
|
47
46
|
const allowed = isDefined(value) && toArray(value).includes(origin);
|
|
48
47
|
if (allowed) {
|
|
49
|
-
response.headers.
|
|
48
|
+
response.headers.set('Access-Control-Allow-Origin', origin);
|
|
50
49
|
}
|
|
51
50
|
}
|
|
52
51
|
}
|
|
@@ -98,6 +98,7 @@ export declare const documentManagementApiDefinition: {
|
|
|
98
98
|
typeId: import("../../orm/schemas/uuid.js").Uuid | null;
|
|
99
99
|
subtitle: string | null;
|
|
100
100
|
pages: number | null;
|
|
101
|
+
validated: boolean;
|
|
101
102
|
originalFileName: string | null;
|
|
102
103
|
collectionIds: string | string[];
|
|
103
104
|
properties?: {
|
|
@@ -374,6 +375,7 @@ export declare const documentManagementApiDefinition: {
|
|
|
374
375
|
typeId?: import("../../orm/types.js").Uuid | null | undefined;
|
|
375
376
|
subtitle?: string | null | undefined;
|
|
376
377
|
pages?: number | null | undefined;
|
|
378
|
+
validated?: boolean | undefined;
|
|
377
379
|
properties?: {
|
|
378
380
|
propertyId: import("../../orm/schemas/uuid.js").Uuid;
|
|
379
381
|
value: unknown;
|
|
@@ -488,6 +490,7 @@ declare const _DocumentManagementApi: import("../../api/index.js").ApiClient<{
|
|
|
488
490
|
typeId: import("../../orm/schemas/uuid.js").Uuid | null;
|
|
489
491
|
subtitle: string | null;
|
|
490
492
|
pages: number | null;
|
|
493
|
+
validated: boolean;
|
|
491
494
|
originalFileName: string | null;
|
|
492
495
|
collectionIds: string | string[];
|
|
493
496
|
properties?: {
|
|
@@ -764,6 +767,7 @@ declare const _DocumentManagementApi: import("../../api/index.js").ApiClient<{
|
|
|
764
767
|
typeId?: import("../../orm/types.js").Uuid | null | undefined;
|
|
765
768
|
subtitle?: string | null | undefined;
|
|
766
769
|
pages?: number | null | undefined;
|
|
770
|
+
validated?: boolean | undefined;
|
|
767
771
|
properties?: {
|
|
768
772
|
propertyId: import("../../orm/schemas/uuid.js").Uuid;
|
|
769
773
|
value: unknown;
|
|
@@ -10,7 +10,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
import { References } from '../../orm/decorators.js';
|
|
11
11
|
import { Entity } from '../../orm/entity.js';
|
|
12
12
|
import { NumericDate, Uuid } from '../../orm/types.js';
|
|
13
|
-
import { Array, Integer, string, StringProperty } from '../../schema/index.js';
|
|
13
|
+
import { Array, BooleanProperty, Integer, string, StringProperty } from '../../schema/index.js';
|
|
14
14
|
import { DocumentFile } from './document-file.model.js';
|
|
15
15
|
import { DocumentManagementTable } from './document-management-table.js';
|
|
16
16
|
import { DocumentType } from './document-type.model.js';
|
|
@@ -23,6 +23,7 @@ let Document = class Document extends Entity {
|
|
|
23
23
|
date;
|
|
24
24
|
summary;
|
|
25
25
|
tags;
|
|
26
|
+
validated;
|
|
26
27
|
};
|
|
27
28
|
__decorate([
|
|
28
29
|
Uuid(),
|
|
@@ -58,6 +59,10 @@ __decorate([
|
|
|
58
59
|
Array(string(), { nullable: true }),
|
|
59
60
|
__metadata("design:type", Object)
|
|
60
61
|
], Document.prototype, "tags", void 0);
|
|
62
|
+
__decorate([
|
|
63
|
+
BooleanProperty(),
|
|
64
|
+
__metadata("design:type", Boolean)
|
|
65
|
+
], Document.prototype, "validated", void 0);
|
|
61
66
|
Document = __decorate([
|
|
62
67
|
DocumentManagementTable()
|
|
63
68
|
], Document);
|
|
@@ -22,6 +22,7 @@ export declare const createDocumentParametersSchema: import("../../../schema/ind
|
|
|
22
22
|
typeId: import("../../../orm/schemas/uuid.js").Uuid | null;
|
|
23
23
|
subtitle: string | null;
|
|
24
24
|
pages: number | null;
|
|
25
|
+
validated: boolean;
|
|
25
26
|
originalFileName: string | null;
|
|
26
27
|
collectionIds: string | string[];
|
|
27
28
|
properties?: {
|
|
@@ -45,6 +46,7 @@ export declare const updateDocumentParametersSchema: import("../../../schema/ind
|
|
|
45
46
|
typeId?: import("../../../orm/types.js").Uuid | null | undefined;
|
|
46
47
|
subtitle?: string | null | undefined;
|
|
47
48
|
pages?: number | null | undefined;
|
|
49
|
+
validated?: boolean | undefined;
|
|
48
50
|
properties?: {
|
|
49
51
|
propertyId: import("../../../orm/schemas/uuid.js").Uuid;
|
|
50
52
|
value: unknown;
|
|
@@ -15,7 +15,7 @@ import { Document } from '../document.model.js';
|
|
|
15
15
|
export const metadataParameterSchema = optional(partial(pick(EntityMetadata, 'attributes')));
|
|
16
16
|
export const metadataParameterObjectSchema = object({ metadata: metadataParameterSchema });
|
|
17
17
|
export const setDocumentPropertyParametersSchema = assign(pick(DocumentPropertyValueBase, ['propertyId']), object({ value: unknown() }), metadataParameterObjectSchema);
|
|
18
|
-
export const createDocumentParametersSchema = assign(pick(Document, ['typeId', 'title', 'subtitle', 'pages', 'date', 'summary', 'tags']), pick(DocumentFile, ['originalFileName']), object({
|
|
18
|
+
export const createDocumentParametersSchema = assign(pick(Document, ['typeId', 'title', 'subtitle', 'pages', 'date', 'summary', 'tags', 'validated']), pick(DocumentFile, ['originalFileName']), object({
|
|
19
19
|
collectionIds: oneOrMany(string()),
|
|
20
20
|
properties: optional(array(setDocumentPropertyParametersSchema))
|
|
21
21
|
}), metadataParameterObjectSchema);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type EnumType } from '../../../enumeration/enumeration.js';
|
|
1
2
|
import { Timestamp } from '../../../orm/types.js';
|
|
2
3
|
import { DocumentCategory } from '../document-category.model.js';
|
|
3
4
|
import { DocumentCollection } from '../document-collection.model.js';
|
|
@@ -7,6 +8,12 @@ import { DocumentRequestFile } from '../document-request-file.model.js';
|
|
|
7
8
|
import { DocumentRequest } from '../document-request.model.js';
|
|
8
9
|
import { DocumentType } from '../document-type.model.js';
|
|
9
10
|
import { Document } from '../document.model.js';
|
|
11
|
+
export declare const ExtractionStatus: {
|
|
12
|
+
readonly Pending: "pending";
|
|
13
|
+
readonly Extracting: "extracting";
|
|
14
|
+
readonly Error: "error";
|
|
15
|
+
};
|
|
16
|
+
export type ExtractionStatus = EnumType<typeof ExtractionStatus>;
|
|
10
17
|
export declare class DocumentCollectionView extends DocumentCollection {
|
|
11
18
|
name: string | null;
|
|
12
19
|
group: string | null;
|
|
@@ -18,6 +25,7 @@ export declare class DocumentViewCollectionAssignment {
|
|
|
18
25
|
export declare class DocumentView extends Document {
|
|
19
26
|
collectionAssignments: DocumentViewCollectionAssignment[];
|
|
20
27
|
properties: DocumentPropertyValue[];
|
|
28
|
+
extractionStatus: ExtractionStatus | null;
|
|
21
29
|
}
|
|
22
30
|
export declare class DocumentRequestView extends DocumentRequest {
|
|
23
31
|
collectionIds: string[];
|
|
@@ -7,8 +7,9 @@ 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 { defineEnum } from '../../../enumeration/enumeration.js';
|
|
10
11
|
import { Timestamp } from '../../../orm/types.js';
|
|
11
|
-
import { Array, StringProperty } from '../../../schema/index.js';
|
|
12
|
+
import { Array, Enumeration, StringProperty } from '../../../schema/index.js';
|
|
12
13
|
import { DocumentCategory } from '../document-category.model.js';
|
|
13
14
|
import { DocumentCollection } from '../document-collection.model.js';
|
|
14
15
|
import { DocumentFile } from '../document-file.model.js';
|
|
@@ -17,6 +18,11 @@ import { DocumentRequestFile } from '../document-request-file.model.js';
|
|
|
17
18
|
import { DocumentRequest } from '../document-request.model.js';
|
|
18
19
|
import { DocumentType } from '../document-type.model.js';
|
|
19
20
|
import { Document } from '../document.model.js';
|
|
21
|
+
export const ExtractionStatus = defineEnum('ExtractionStatus', {
|
|
22
|
+
Pending: 'pending',
|
|
23
|
+
Extracting: 'extracting',
|
|
24
|
+
Error: 'error'
|
|
25
|
+
});
|
|
20
26
|
export class DocumentCollectionView extends DocumentCollection {
|
|
21
27
|
name;
|
|
22
28
|
group;
|
|
@@ -44,6 +50,7 @@ __decorate([
|
|
|
44
50
|
export class DocumentView extends Document {
|
|
45
51
|
collectionAssignments;
|
|
46
52
|
properties;
|
|
53
|
+
extractionStatus;
|
|
47
54
|
}
|
|
48
55
|
__decorate([
|
|
49
56
|
Array(DocumentViewCollectionAssignment),
|
|
@@ -53,6 +60,10 @@ __decorate([
|
|
|
53
60
|
Array(DocumentPropertyValue),
|
|
54
61
|
__metadata("design:type", Array)
|
|
55
62
|
], DocumentView.prototype, "properties", void 0);
|
|
63
|
+
__decorate([
|
|
64
|
+
Enumeration(ExtractionStatus, { nullable: true }),
|
|
65
|
+
__metadata("design:type", Object)
|
|
66
|
+
], DocumentView.prototype, "extractionStatus", void 0);
|
|
56
67
|
export class DocumentRequestView extends DocumentRequest {
|
|
57
68
|
collectionIds;
|
|
58
69
|
requestFiles;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE "document_management"."document" ADD COLUMN "validated" boolean NOT NULL;
|