@tstdl/base 0.93.9 → 0.93.11
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/audit/module.d.ts +3 -3
- package/audit/module.js +3 -3
- package/document-management/api/document-management.api.d.ts +6 -6
- package/document-management/service-models/document.service-model.d.ts +3 -3
- package/injector/decorators.d.ts +7 -0
- package/injector/decorators.js +10 -6
- package/injector/injector.js +73 -30
- package/orm/decorators.d.ts +35 -3
- package/orm/decorators.js +6 -0
- package/orm/query.d.ts +65 -30
- package/orm/query.js +2 -6
- package/orm/repository.types.d.ts +72 -1
- package/orm/server/drizzle/schema-converter.js +31 -2
- package/orm/server/query-converter.d.ts +5 -7
- package/orm/server/query-converter.js +69 -15
- package/orm/server/repository.d.ts +19 -7
- package/orm/server/repository.js +144 -11
- package/orm/sqls.d.ts +153 -8
- package/orm/sqls.js +161 -8
- package/package.json +5 -5
- package/schema/schemas/object.js +1 -1
- package/test/drizzle/0000_sudden_sphinx.sql +9 -0
- package/test/drizzle/meta/0000_snapshot.json +79 -0
- package/test/drizzle/meta/_journal.json +13 -0
- package/test/drizzle.config.d.ts +2 -0
- package/test/drizzle.config.js +11 -0
- package/test/index.d.ts +3 -0
- package/test/index.js +3 -0
- package/test/module.d.ts +6 -0
- package/test/module.js +17 -0
- package/test/schemas.d.ts +3 -0
- package/test/schemas.js +4 -0
- package/test/test.model.d.ts +8 -0
- package/test/test.model.js +345 -0
- package/test1.d.ts +1 -0
- package/test1.js +59 -0
- package/test2.d.ts +1 -0
- package/test2.js +32 -0
- package/test3.d.ts +1 -0
- package/test3.js +47 -0
- package/test4.d.ts +23 -0
- package/test4.js +168 -0
- package/test5.d.ts +1 -0
- package/test5.js +22 -0
- package/test6.d.ts +1 -0
- package/test6.js +53 -0
package/test4.js
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
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
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import './polyfills.js';
|
|
8
|
+
import { configureAiService } from './ai/index.js';
|
|
9
|
+
import { Application } from './application/application.js';
|
|
10
|
+
import { provideModule, provideSignalHandler } from './application/index.js';
|
|
11
|
+
import { DocumentManagementAuthorizationService } from './document-management/index.js';
|
|
12
|
+
import { configureDocumentManagement } from './document-management/server/configure.js';
|
|
13
|
+
import { DocumentManagementAncillaryService, DocumentManagementService } from './document-management/server/index.js';
|
|
14
|
+
import { migrateDocumentManagementSchema } from './document-management/server/module.js';
|
|
15
|
+
import { Singleton } from './injector/decorators.js';
|
|
16
|
+
import { injectAsync } from './injector/inject.js';
|
|
17
|
+
import { configureLocalMessageBus } from './message-bus/index.js';
|
|
18
|
+
import { configureS3ObjectStorage } from './object-storage/index.js';
|
|
19
|
+
import { configureOrm } from './orm/server/index.js';
|
|
20
|
+
import { configurePostgresQueue } from './queue/postgres/module.js';
|
|
21
|
+
import { boolean, positiveInteger, string } from './utils/config-parser.js';
|
|
22
|
+
import { cancelableTimeout } from './utils/timing.js';
|
|
23
|
+
const config = {
|
|
24
|
+
database: {
|
|
25
|
+
host: string('DATABASE_HOST', '127.0.0.1'),
|
|
26
|
+
port: positiveInteger('DATABASE_PORT', 5432),
|
|
27
|
+
user: string('DATABASE_USER', 'tstdl'),
|
|
28
|
+
pass: string('DATABASE_PASS', 'wf7rq6glrk5jykne'),
|
|
29
|
+
database: string('DATABASE_NAME', 'tstdl'),
|
|
30
|
+
schema: string('DATABASE_SCHEMA', 'tstdl'),
|
|
31
|
+
},
|
|
32
|
+
ai: {
|
|
33
|
+
apiKey: string('AI_API_KEY', undefined),
|
|
34
|
+
keyFile: string('AI_API_KEY_FILE', undefined),
|
|
35
|
+
vertex: {
|
|
36
|
+
project: string('AI_VERTEX_PROJECT', undefined),
|
|
37
|
+
location: string('AI_VERTEX_LOCATION', undefined),
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
s3: {
|
|
41
|
+
endpoint: string('S3_ENDPOINT', 'http://localhost:9000'),
|
|
42
|
+
accessKey: string('S3_ACCESS_KEY', 'tstdl-dev'),
|
|
43
|
+
secretKey: string('S3_SECRET_KEY', 'tstdl-dev'),
|
|
44
|
+
bucket: string('S3_BUCKET', undefined),
|
|
45
|
+
bucketPerModule: boolean('S3_BUCKET_PER_MODULE', true),
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
let TestDocumentManagementAncillaryService = class TestDocumentManagementAncillaryService extends DocumentManagementAncillaryService {
|
|
49
|
+
resolveMetadata(collections) {
|
|
50
|
+
return collections.map((collection) => ({ name: collection.id, group: null }));
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
TestDocumentManagementAncillaryService = __decorate([
|
|
54
|
+
Singleton()
|
|
55
|
+
], TestDocumentManagementAncillaryService);
|
|
56
|
+
export { TestDocumentManagementAncillaryService };
|
|
57
|
+
let AllowAllDocumentManagementAuthorizationService = class AllowAllDocumentManagementAuthorizationService extends DocumentManagementAuthorizationService {
|
|
58
|
+
getTenantId() { return '00000000-0000-0000-0000-000000000000'; }
|
|
59
|
+
getSubject() { return '00000000-0000-0000-0000-000000000000'; }
|
|
60
|
+
canReadCollection() { return true; }
|
|
61
|
+
canCreateDocuments() { return true; }
|
|
62
|
+
canUpdateDocument() { return true; }
|
|
63
|
+
canDeleteDocuments() { return true; }
|
|
64
|
+
canAssignDocuments() { return true; }
|
|
65
|
+
canApproveDocument() { return true; }
|
|
66
|
+
canRejectDocument() { return true; }
|
|
67
|
+
canManageRequests() { return true; }
|
|
68
|
+
canManageCategoriesAndTypes() { return true; }
|
|
69
|
+
canReadDocumentRequestsTemplates() { return true; }
|
|
70
|
+
canManageDocumentRequestsTemplates() { return true; }
|
|
71
|
+
canManageValidationDefinitions() { return true; }
|
|
72
|
+
canProgressDocumentWorkflow() { return true; }
|
|
73
|
+
};
|
|
74
|
+
AllowAllDocumentManagementAuthorizationService = __decorate([
|
|
75
|
+
Singleton()
|
|
76
|
+
], AllowAllDocumentManagementAuthorizationService);
|
|
77
|
+
export { AllowAllDocumentManagementAuthorizationService };
|
|
78
|
+
async function bootstrap() {
|
|
79
|
+
configureOrm({
|
|
80
|
+
connection: {
|
|
81
|
+
host: config.database.host,
|
|
82
|
+
port: config.database.port,
|
|
83
|
+
user: config.database.user,
|
|
84
|
+
password: config.database.pass,
|
|
85
|
+
database: config.database.database,
|
|
86
|
+
},
|
|
87
|
+
repositoryConfig: { schema: 'vitrass' },
|
|
88
|
+
});
|
|
89
|
+
configureS3ObjectStorage({
|
|
90
|
+
endpoint: config.s3.endpoint,
|
|
91
|
+
bucket: config.s3.bucket,
|
|
92
|
+
bucketPerModule: config.s3.bucketPerModule,
|
|
93
|
+
accessKey: config.s3.accessKey,
|
|
94
|
+
secretKey: config.s3.secretKey,
|
|
95
|
+
});
|
|
96
|
+
configureDocumentManagement({
|
|
97
|
+
ancillaryService: TestDocumentManagementAncillaryService,
|
|
98
|
+
authorizationService: AllowAllDocumentManagementAuthorizationService,
|
|
99
|
+
fileObjectStorageModule: 'documents',
|
|
100
|
+
fileUploadObjectStorageModule: 'document-uploads',
|
|
101
|
+
filePreviewObjectStorageModule: 'document-previews',
|
|
102
|
+
});
|
|
103
|
+
configurePostgresQueue();
|
|
104
|
+
configureLocalMessageBus();
|
|
105
|
+
console.log('Configuring AI service');
|
|
106
|
+
configureAiService({
|
|
107
|
+
apiKey: config.ai.apiKey,
|
|
108
|
+
keyFile: config.ai.keyFile,
|
|
109
|
+
});
|
|
110
|
+
await migrateDocumentManagementSchema();
|
|
111
|
+
}
|
|
112
|
+
async function main(cancellationSignal) {
|
|
113
|
+
const documentManagementService = await injectAsync(DocumentManagementService);
|
|
114
|
+
/*
|
|
115
|
+
console.log(await documentManagementService.createCollection({ metadata: { attributes: { name: 'Patrick Hein' } } }));
|
|
116
|
+
console.log(await documentManagementService.createCollection({ metadata: { attributes: { name: 'Merit Klenk' } } }));
|
|
117
|
+
console.log(await documentManagementService.createCollection({ metadata: { attributes: { name: 'Haus' } } }));
|
|
118
|
+
*/
|
|
119
|
+
const patrickHein = '4396c175-0551-4e70-aed8-13f51d307f4f';
|
|
120
|
+
const meritKlenk = '28cec615-b327-43b0-aae6-f049cef9aa26';
|
|
121
|
+
const haus = '32d9895f-476d-41f1-b79e-359c548957d3';
|
|
122
|
+
const personalausweisType = '2c5c2b21-33ba-4262-ab96-24eaf05864a6';
|
|
123
|
+
const lohnabrechnungType = '735d09c1-1ce9-4a29-ad23-3149b6be56ba';
|
|
124
|
+
const bauplanType = '1b813c5d-1e75-4f59-853a-4272bb9d9c20';
|
|
125
|
+
/*
|
|
126
|
+
const personalausweisProperties = await Promise.all([
|
|
127
|
+
await documentManagementService.createProperty({ label: 'Vorname', dataType: DocumentPropertyDataType.Text }),
|
|
128
|
+
await documentManagementService.createProperty({ label: 'Nachname', dataType: DocumentPropertyDataType.Text }),
|
|
129
|
+
await documentManagementService.createProperty({ label: 'Ausweisnummer', dataType: DocumentPropertyDataType.Text }),
|
|
130
|
+
await documentManagementService.createProperty({ label: 'Geburtsdatum', dataType: DocumentPropertyDataType.Date }),
|
|
131
|
+
await documentManagementService.createProperty({ label: 'Geburtsort', dataType: DocumentPropertyDataType.Text }),
|
|
132
|
+
await documentManagementService.createProperty({ label: 'Staatsangehörigkeit', dataType: DocumentPropertyDataType.Text }),
|
|
133
|
+
await documentManagementService.createProperty({ label: 'Gültig bis', dataType: DocumentPropertyDataType.Date }),
|
|
134
|
+
await documentManagementService.createProperty({ label: 'Ausstellende Behörde', dataType: DocumentPropertyDataType.Text }),
|
|
135
|
+
await documentManagementService.createProperty({ label: 'Anschrift Straße', dataType: DocumentPropertyDataType.Text }),
|
|
136
|
+
await documentManagementService.createProperty({ label: 'Anschrift Hausnummer', dataType: DocumentPropertyDataType.Text }),
|
|
137
|
+
await documentManagementService.createProperty({ label: 'Anschrift Postleitzahl', dataType: DocumentPropertyDataType.Text }),
|
|
138
|
+
await documentManagementService.createProperty({ label: 'Anschrift Stadt', dataType: DocumentPropertyDataType.Text })
|
|
139
|
+
]);
|
|
140
|
+
|
|
141
|
+
const propertyIds = personalausweisProperties.map((p) => p.id);
|
|
142
|
+
|
|
143
|
+
for (const id of propertyIds) {
|
|
144
|
+
await documentManagementService.assignPropertyToType({ propertyId: id, typeId: personalausweisType });
|
|
145
|
+
}
|
|
146
|
+
*/
|
|
147
|
+
/*
|
|
148
|
+
await documentManagementService.createDocumentRequest({ collectionIds: [patrickHein], typeId: lohnabrechnungType, requiredFilesCount: 1, comment: 'Abrechnung Feb 2025' });
|
|
149
|
+
await documentManagementService.createDocumentRequest({ collectionIds: [patrickHein], typeId: lohnabrechnungType, requiredFilesCount: 1, comment: 'Abrechnung Jan 2025' });
|
|
150
|
+
await documentManagementService.createDocumentRequest({ collectionIds: [patrickHein], typeId: lohnabrechnungType, requiredFilesCount: 1, comment: 'Abrechnung Dez 2024' });
|
|
151
|
+
await documentManagementService.createDocumentRequest({ collectionIds: [meritKlenk], typeId: personalausweisType, requiredFilesCount: 1, comment: null });
|
|
152
|
+
await documentManagementService.createDocumentRequest({ collectionIds: [patrickHein], typeId: personalausweisType, requiredFilesCount: 1, comment: null });
|
|
153
|
+
await documentManagementService.createDocumentRequest({ collectionIds: [haus], typeId: bauplanType, requiredFilesCount: 1, comment: null });
|
|
154
|
+
*/
|
|
155
|
+
/*
|
|
156
|
+
const file = await openAsBlob('/home/patrick/Downloads/Brutto-Netto-Abrechnung 2025 01 Januar.pdf');
|
|
157
|
+
|
|
158
|
+
const task = await documentManagementService.createDocumentRequestAssignmentTask(
|
|
159
|
+
{ originalFileName: 'Brutto-Netto-Abrechnung 2025 01 Januar.pdf', collectionIds: [patrickHein, meritKlenk, haus] },
|
|
160
|
+
file.stream()
|
|
161
|
+
);
|
|
162
|
+
*/
|
|
163
|
+
await cancelableTimeout(60000, cancellationSignal);
|
|
164
|
+
}
|
|
165
|
+
Application.run('Test', [
|
|
166
|
+
provideModule(main),
|
|
167
|
+
provideSignalHandler(),
|
|
168
|
+
]);
|
package/test5.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './polyfills.js';
|
package/test5.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import './polyfills.js';
|
|
2
|
+
import { Application } from './application/application.js';
|
|
3
|
+
import { provideModule, provideSignalHandler } from './application/index.js';
|
|
4
|
+
import { inject } from './injector/inject.js';
|
|
5
|
+
import { JsonLogFormatter, PrettyPrintLogFormatter } from './logger/index.js';
|
|
6
|
+
import { Logger } from './logger/logger.js';
|
|
7
|
+
import { provideConsoleLogTransport } from './logger/transports/console.js';
|
|
8
|
+
async function main(_cancellationSignal) {
|
|
9
|
+
const logger = inject(Logger, 'Test');
|
|
10
|
+
logger.error('Hello World!', { sessionId: 'abc123' });
|
|
11
|
+
logger.warn('Hello World!');
|
|
12
|
+
logger.info('Hello World!');
|
|
13
|
+
logger.verbose('Hello World!');
|
|
14
|
+
logger.debug('Hello World!');
|
|
15
|
+
logger.trace('Hello World!');
|
|
16
|
+
}
|
|
17
|
+
Application.run('Test', [
|
|
18
|
+
provideConsoleLogTransport(PrettyPrintLogFormatter),
|
|
19
|
+
provideConsoleLogTransport(JsonLogFormatter),
|
|
20
|
+
provideModule(main),
|
|
21
|
+
provideSignalHandler(),
|
|
22
|
+
]);
|
package/test6.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/test6.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
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
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Application } from './application/application.js';
|
|
11
|
+
import { provideModule, provideSignalHandler } from './application/providers.js';
|
|
12
|
+
import { createContextProvider } from './context/context.js';
|
|
13
|
+
import { Class, Integer } from './schema/index.js';
|
|
14
|
+
const { runInschemaContext, isInschemaContext } = createContextProvider('schema');
|
|
15
|
+
function meta(type, data) {
|
|
16
|
+
// store meta somewhere
|
|
17
|
+
console.log('meta', type, data);
|
|
18
|
+
}
|
|
19
|
+
function integer() {
|
|
20
|
+
if (isInschemaContext()) {
|
|
21
|
+
return { type: 'integer' };
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
// current method
|
|
26
|
+
let Foo = class Foo {
|
|
27
|
+
age;
|
|
28
|
+
};
|
|
29
|
+
__decorate([
|
|
30
|
+
Integer(),
|
|
31
|
+
__metadata("design:type", Number)
|
|
32
|
+
], Foo.prototype, "age", void 0);
|
|
33
|
+
Foo = __decorate([
|
|
34
|
+
Class({ description: 'Foo class' })
|
|
35
|
+
], Foo);
|
|
36
|
+
// new method
|
|
37
|
+
class Bar {
|
|
38
|
+
static {
|
|
39
|
+
meta(Bar, { description: 'Bar class' });
|
|
40
|
+
}
|
|
41
|
+
age = integer();
|
|
42
|
+
}
|
|
43
|
+
async function main() {
|
|
44
|
+
console.log(new Foo());
|
|
45
|
+
console.log(new Bar());
|
|
46
|
+
runInschemaContext(undefined, () => {
|
|
47
|
+
console.log(new Bar());
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
Application.run('Test', [
|
|
51
|
+
provideModule(main),
|
|
52
|
+
provideSignalHandler(),
|
|
53
|
+
]);
|