@tstdl/base 0.93.9 → 0.93.10

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.
@@ -0,0 +1,345 @@
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 { EntityWithoutMetadata, GinIndex, Table } from '../orm/index.js';
11
+ import { StringProperty } from '../schema/index.js';
12
+ let Test = class Test extends EntityWithoutMetadata {
13
+ title;
14
+ content;
15
+ tags;
16
+ language;
17
+ };
18
+ __decorate([
19
+ StringProperty(),
20
+ __metadata("design:type", String)
21
+ ], Test.prototype, "title", void 0);
22
+ __decorate([
23
+ StringProperty(),
24
+ __metadata("design:type", String)
25
+ ], Test.prototype, "content", void 0);
26
+ __decorate([
27
+ StringProperty(),
28
+ __metadata("design:type", String)
29
+ ], Test.prototype, "tags", void 0);
30
+ __decorate([
31
+ StringProperty(),
32
+ __metadata("design:type", String)
33
+ ], Test.prototype, "language", void 0);
34
+ Test = __decorate([
35
+ GinIndex(['title', 'content', 'tags'], {
36
+ weights: { title: 'A', content: 'B', tags: 'C' },
37
+ })
38
+ ], Test);
39
+ export { Test };
40
+ export const testData = [
41
+ {
42
+ title: 'Optimizing PostgreSQL Full-Text Search with GIN Indexes',
43
+ content: 'A deep dive into GIN index performance. We explore how to configure a GIN index and optimize database queries for efficient full-text search. Better performance is key.',
44
+ tags: ['postgresql', 'database', 'performance', 'full-text search', 'gin index'],
45
+ language: 'english',
46
+ },
47
+ {
48
+ title: 'Getting Started with Drizzle ORM and TypeScript',
49
+ content: 'Drizzle ORM is a powerful tool for TypeScript developers. This guide shows how to set up your first project, define a schema, and run queries against your database.',
50
+ tags: ['drizzle orm', 'typescript', 'orm', 'database', 'backend'],
51
+ language: 'english',
52
+ },
53
+ {
54
+ title: 'Advanced Backend Patterns in Node.js',
55
+ content: 'Explore advanced backend architecture patterns for building scalable and maintainable Node.js applications. Topics include microservices, event-driven design, and performance optimization.',
56
+ tags: ['nodejs', 'backend', 'architecture', 'performance'],
57
+ language: 'english',
58
+ },
59
+ {
60
+ title: 'Why weighted search matters for user experience',
61
+ content: 'Ranking search results is crucial. By applying weights to fields like titles, you can provide more relevant results to users, significantly improving their search experience on your platform.',
62
+ tags: ['search', 'ux', 'ranking', 'full-text search'],
63
+ language: 'english',
64
+ },
65
+ {
66
+ title: 'Building a Multi-Language Search Engine',
67
+ content: 'Supporting multiple languages in a search system presents unique challenges. This article covers strategies for handling different text search configurations in PostgreSQL.',
68
+ tags: ['search', 'multi-language', 'postgresql', 'i18n'],
69
+ language: 'english',
70
+ },
71
+ {
72
+ title: 'The Power of SQL for Modern Developers',
73
+ content: 'While ORMs are convenient, understanding raw SQL is a superpower. This post covers advanced SQL queries that can solve complex problems efficiently.',
74
+ tags: ['sql', 'database', 'developer', 'optimization'],
75
+ language: 'english',
76
+ },
77
+ {
78
+ title: 'Migrating from a legacy ORM to Drizzle',
79
+ content: 'A case study on migrating a large-scale application to Drizzle ORM. Learn about the challenges, benefits, and the final performance improvements.',
80
+ tags: ['drizzle orm', 'migration', 'case study', 'performance'],
81
+ language: 'english',
82
+ },
83
+ {
84
+ title: 'Database Schema Design Best Practices',
85
+ content: 'Good schema design is the foundation of a solid application. We cover normalization, indexing strategies, and common pitfalls to avoid.',
86
+ tags: ['database', 'schema design', 'best practices'],
87
+ language: 'english',
88
+ },
89
+ {
90
+ title: 'Introduction to WebAssembly for Backend',
91
+ content: 'WebAssembly (WASM) is not just for the browser. Learn how it can be used to improve backend performance for CPU-intensive tasks.',
92
+ tags: ['webassembly', 'wasm', 'backend', 'performance'],
93
+ language: 'english',
94
+ },
95
+ {
96
+ title: 'Securing Your PostgreSQL Database',
97
+ content: 'A comprehensive checklist for securing your PostgreSQL instance, from network configuration to user roles and data encryption.',
98
+ tags: ['postgresql', 'security', 'database', 'devops'],
99
+ language: 'english',
100
+ },
101
+ {
102
+ title: 'Real-time applications with WebSockets and Node.js',
103
+ content: 'Learn to build real-time features like chat and notifications using WebSockets. This guide provides a practical example with Node.js.',
104
+ tags: ['nodejs', 'websockets', 'real-time', 'backend'],
105
+ language: 'english',
106
+ },
107
+ {
108
+ title: 'Understanding PostgreSQL Extension: pg_trgm',
109
+ content: 'Beyond full-text search, pg_trgm offers powerful trigram matching for fuzzy string search. Ideal for finding similar names or correcting typos.',
110
+ tags: ['postgresql', 'fuzzy search', 'extension', 'database'],
111
+ language: 'english',
112
+ },
113
+ {
114
+ title: 'GraphQL vs REST: A Backend Perspective',
115
+ content: 'An analysis of GraphQL and REST APIs from the viewpoint of a backend developer, focusing on implementation complexity, performance, and caching.',
116
+ tags: ['graphql', 'rest', 'api', 'backend', 'architecture'],
117
+ language: 'english',
118
+ },
119
+ {
120
+ title: 'Containerizing a TypeScript App with Docker',
121
+ content: 'A step-by-step guide to creating a Dockerfile for a TypeScript Node.js application, enabling consistent development and deployment environments.',
122
+ tags: ['docker', 'typescript', 'nodejs', 'devops'],
123
+ language: 'english',
124
+ },
125
+ {
126
+ title: 'Automated Database Testing Strategies',
127
+ content: 'Testing database interactions is critical. This post explores strategies for automated testing, including unit tests, integration tests, and seeding data.',
128
+ tags: ['testing', 'database', 'automation', 'best practices'],
129
+ language: 'english',
130
+ },
131
+ // --- Cooking Posts (16-25) ---
132
+ {
133
+ title: 'The Perfect Weeknight Pasta Recipe',
134
+ content: 'A quick and delicious pasta recipe that you can make in under 30 minutes. Perfect for a busy weeknight. This recipe uses fresh tomatoes and basil.',
135
+ tags: ['recipe', 'pasta', 'cooking', 'quick meal'],
136
+ language: 'english',
137
+ },
138
+ {
139
+ title: 'Healthy and Hearty Vegetarian Chili',
140
+ content: 'This vegetarian chili recipe is packed with flavor and healthy ingredients. A great comfort food for a cold day. Explore the world of spices.',
141
+ tags: ['vegetarian', 'recipe', 'healthy', 'cooking'],
142
+ language: 'english',
143
+ },
144
+ {
145
+ title: 'Baking the Ultimate Chocolate Chip Cookies',
146
+ content: 'Discover the secrets to baking soft, chewy, and delicious chocolate chip cookies every time. A classic recipe for all bakers.',
147
+ tags: ['baking', 'cookies', 'recipe', 'dessert'],
148
+ language: 'english',
149
+ },
150
+ {
151
+ title: 'A Guide to Essential Kitchen Spices',
152
+ content: 'Every home cook needs a good collection of spices. This guide covers the essential spices that will elevate your cooking from good to great.',
153
+ tags: ['spices', 'cooking', 'kitchen', 'guide'],
154
+ language: 'english',
155
+ },
156
+ {
157
+ title: 'Simple Roasted Chicken and Vegetables',
158
+ content: 'A one-pan meal that is both easy and impressive. This roasted chicken recipe is a crowd-pleaser and perfect for a Sunday dinner.',
159
+ tags: ['chicken', 'recipe', 'dinner', 'one-pan meal'],
160
+ language: 'english',
161
+ },
162
+ {
163
+ title: 'Mastering Sourdough Bread: A Beginner\'s Guide',
164
+ content: 'Baking sourdough can be intimidating, but this guide breaks it down step-by-step. Learn about starters, fermentation, and shaping your first loaf.',
165
+ tags: ['baking', 'sourdough', 'bread', 'recipe'],
166
+ language: 'english',
167
+ },
168
+ {
169
+ title: 'Fresh Summer Salad Recipes',
170
+ content: 'Beat the heat with these refreshing and healthy summer salad recipes. From a classic Greek salad to a zesty quinoa salad, there is something for everyone.',
171
+ tags: ['salad', 'recipe', 'healthy', 'summer'],
172
+ language: 'english',
173
+ },
174
+ {
175
+ title: 'How to Make Authentic Italian Pizza Dough',
176
+ content: 'The secret to great pizza is the dough. This authentic Italian recipe will give you a light, airy, and crispy crust. Your search for the perfect pizza is over.',
177
+ tags: ['pizza', 'recipe', 'italian', 'cooking'],
178
+ language: 'english',
179
+ },
180
+ {
181
+ title: 'The Art of Grilling: Perfect Steaks',
182
+ content: 'Learn how to grill the perfect steak with this comprehensive guide. We cover everything from choosing the right cut to seasoning and cooking temperatures.',
183
+ tags: ['grilling', 'steak', 'recipe', 'bbq'],
184
+ language: 'english',
185
+ },
186
+ {
187
+ title: 'Delicious Breakfast Smoothie Ideas',
188
+ content: 'Start your day right with these delicious and nutritious breakfast smoothie recipes. They are quick to make and packed with vitamins and energy.',
189
+ tags: ['smoothie', 'recipe', 'breakfast', 'healthy'],
190
+ language: 'english',
191
+ },
192
+ // --- Travel Posts (26-35) ---
193
+ {
194
+ title: 'A Backpacker\'s Guide to Southeast Asia',
195
+ content: 'Explore the wonders of Southeast Asia on a budget. This guide covers top destinations, packing tips, and how to travel safely and affordably.',
196
+ tags: ['travel', 'backpacking', 'asia', 'budget travel'],
197
+ language: 'english',
198
+ },
199
+ {
200
+ title: 'The Most Beautiful Beaches in the World',
201
+ content: 'A visual journey to the most stunning beaches across the globe. From the white sands of the Maldives to the rugged coasts of Iceland, get ready for an adventure.',
202
+ tags: ['travel', 'beach', 'destination', 'vacation'],
203
+ language: 'english',
204
+ },
205
+ {
206
+ title: 'Hiking in the Rocky Mountains: A Complete Guide',
207
+ content: 'An adventure awaits in the Rocky Mountains. This guide details the best trails for all skill levels, essential gear, and wildlife safety.',
208
+ tags: ['hiking', 'mountains', 'travel', 'adventure', 'guide'],
209
+ language: 'english',
210
+ },
211
+ {
212
+ title: '48 Hours in Tokyo: A City Guide',
213
+ content: 'Making the most of a short trip to Tokyo. This guide provides a packed itinerary to experience the best of the city\'s culture, food, and attractions.',
214
+ tags: ['travel', 'city guide', 'tokyo', 'japan'],
215
+ language: 'english',
216
+ },
217
+ {
218
+ title: 'Essential Packing Tips for Every Traveler',
219
+ content: 'Packing smart can make or break a trip. Learn essential tips to pack lighter, stay organized, and be prepared for any travel situation.',
220
+ tags: ['travel tips', 'packing', 'guide'],
221
+ language: 'english',
222
+ },
223
+ {
224
+ title: 'Exploring the Ancient Ruins of Rome',
225
+ content: 'Step back in time with a tour of Rome\'s ancient ruins. A guide to the Colosseum, Roman Forum, and Palatine Hill, with tips to avoid the crowds.',
226
+ tags: ['travel', 'rome', 'italy', 'history', 'destination'],
227
+ language: 'english',
228
+ },
229
+ {
230
+ title: 'The Ultimate Road Trip Across the USA',
231
+ content: 'Planning an epic cross-country road trip? This guide covers classic routes, must-see stops, and tips for life on the road. A great adventure awaits.',
232
+ tags: ['road trip', 'travel', 'usa', 'adventure'],
233
+ language: 'english',
234
+ },
235
+ {
236
+ title: 'How to Find the Best Travel Deals',
237
+ content: 'Traveling doesn\'t have to be expensive. Learn the secrets to finding cheap flights, affordable accommodation, and saving money while you explore.',
238
+ tags: ['budget travel', 'travel tips', 'deals'],
239
+ language: 'english',
240
+ },
241
+ {
242
+ title: 'A Culinary Tour of Mexico City',
243
+ content: 'Explore the vibrant food scene of Mexico City. From street tacos to fine dining, this guide will take you on a delicious culinary adventure.',
244
+ tags: ['travel', 'food', 'mexico city', 'culinary'],
245
+ language: 'english',
246
+ },
247
+ {
248
+ title: 'Solo Travel: Why You Should Try It',
249
+ content: 'Traveling solo can be one of the most rewarding experiences. This post discusses the benefits of solo travel and provides tips for a safe and enjoyable journey.',
250
+ tags: ['solo travel', 'travel tips', 'adventure'],
251
+ language: 'english',
252
+ },
253
+ // --- Science & Lifestyle Posts (36-45) ---
254
+ {
255
+ title: 'The Mysteries of Black Holes Explained',
256
+ content: 'What are black holes and how do they form? This article provides a simple explanation of one of the universe\'s most fascinating phenomena.',
257
+ tags: ['science', 'astronomy', 'space', 'black hole'],
258
+ language: 'english',
259
+ },
260
+ {
261
+ title: 'The Search for Extraterrestrial Life',
262
+ content: 'Are we alone in the universe? A look at the science behind the search for life beyond Earth, from the Drake equation to the latest discoveries.',
263
+ tags: ['science', 'space', 'aliens', 'astronomy'],
264
+ language: 'english',
265
+ },
266
+ {
267
+ title: 'Building Better Habits for Productivity',
268
+ content: 'Learn how to build and maintain effective habits that will boost your productivity and help you achieve your goals. A search for a better self.',
269
+ tags: ['lifestyle', 'productivity', 'habits', 'self-improvement'],
270
+ language: 'english',
271
+ },
272
+ {
273
+ title: 'An Introduction to Mindfulness and Meditation',
274
+ content: 'Discover the benefits of mindfulness and meditation for reducing stress and improving focus. This guide offers simple exercises to get you started.',
275
+ tags: ['mindfulness', 'meditation', 'wellness', 'lifestyle'],
276
+ language: 'english',
277
+ },
278
+ {
279
+ title: 'Quantum Computing: The Next Revolution',
280
+ content: 'An overview of quantum computing and its potential to revolutionize fields like medicine, materials science, and artificial intelligence.',
281
+ tags: ['science', 'technology', 'quantum computing', 'physics'],
282
+ language: 'english',
283
+ },
284
+ {
285
+ title: 'Minimalist Home Decor Ideas',
286
+ content: 'Create a calm and clutter-free living space with these minimalist home decor ideas. Less is more when it comes to a peaceful home.',
287
+ tags: ['home decor', 'minimalism', 'lifestyle', 'interior design'],
288
+ language: 'english',
289
+ },
290
+ {
291
+ title: 'The Science of Sleep: Why It\'s So Important',
292
+ content: 'Sleep is vital for our physical and mental health. This article explores the science behind sleep and offers tips for getting a better night\'s rest.',
293
+ tags: ['science', 'health', 'wellness', 'sleep'],
294
+ language: 'english',
295
+ },
296
+ {
297
+ title: 'Beginner\'s Guide to Personal Finance',
298
+ content: 'Take control of your finances with this guide to budgeting, saving, and investing. It\'s never too late to start building a secure financial future.',
299
+ tags: ['personal finance', 'budgeting', 'investing', 'lifestyle'],
300
+ language: 'english',
301
+ },
302
+ {
303
+ title: 'The Joy of Indoor Gardening',
304
+ content: 'Bring nature indoors with an indoor garden. This guide covers the best low-maintenance plants for beginners and how to care for them.',
305
+ tags: ['gardening', 'plants', 'home', 'lifestyle'],
306
+ language: 'english',
307
+ },
308
+ {
309
+ title: 'A Fitness Routine You Can Stick To',
310
+ content: 'Finding a fitness routine that works for you is key to long-term success. This post offers tips for creating a sustainable and enjoyable workout plan.',
311
+ tags: ['fitness', 'health', 'wellness', 'exercise'],
312
+ language: 'english',
313
+ },
314
+ // --- Multi-Language Posts (46-50) ---
315
+ {
316
+ title: 'Einführung in die Volltextsuche mit PostgreSQL',
317
+ content: 'Dieser Leitfaden erklärt die Grundlagen der Volltextsuche in einer PostgreSQL Datenbank. Wir behandeln Konfiguration und Abfragen.',
318
+ tags: ['postgresql', 'volltextsuche', 'datenbank', 'technologie'],
319
+ language: 'german',
320
+ },
321
+ {
322
+ title: 'Ein einfaches Rezept für Apfelstrudel',
323
+ content: 'Ein klassisches deutsches Rezept. Dieser Apfelstrudel ist köstlich und einfach zu backen. Perfekt für den Nachmittagskaffee.',
324
+ tags: ['rezept', 'backen', 'deutsch', 'kochen'],
325
+ language: 'german',
326
+ },
327
+ {
328
+ title: 'Búsqueda de texto completo en bases de datos',
329
+ content: 'Una guía para implementar la búsqueda de texto completo en su base de datos. Optimice sus consultas para obtener resultados rápidos y relevantes.',
330
+ tags: ['base de datos', 'búsqueda de texto', 'tecnología', 'español'],
331
+ language: 'spanish',
332
+ },
333
+ {
334
+ title: 'Receta de paella valenciana tradicional',
335
+ content: 'Aprende a cocinar una auténtica paella valenciana con esta receta paso a paso. Un plato delicioso para compartir con familia y amigos.',
336
+ tags: ['receta', 'paella', 'español', 'cocina'],
337
+ language: 'spanish',
338
+ },
339
+ {
340
+ title: 'Guía de viaje para Barcelona',
341
+ content: 'Descubre lo mejor de Barcelona con esta completa guía de viaje. Desde la Sagrada Familia hasta las playas, planifica tu aventura perfecta.',
342
+ tags: ['viaje', 'barcelona', 'españa', 'guía'],
343
+ language: 'spanish',
344
+ },
345
+ ].map((item) => ({ ...item, tags: item.tags.join(', ') }));
package/test1.d.ts ADDED
@@ -0,0 +1 @@
1
+ import './polyfills.js';
package/test1.js ADDED
@@ -0,0 +1,56 @@
1
+ import './polyfills.js';
2
+ import { Application, provideInitializer, provideModule, provideSignalHandler } from './application/index.js';
3
+ import { migrateAuditSchema } from './audit/index.js';
4
+ import { inject, Injector, runInInjectionContext } from './injector/index.js';
5
+ import { configurePostgresLock, migratePostgresLockSchema } from './lock/postgres/index.js';
6
+ import { PrettyPrintLogFormatter, provideConsoleLogTransport } from './logger/index.js';
7
+ import { configureOrm, injectRepository } from './orm/server/index.js';
8
+ import { configurePostgresQueue, migratePostgresQueueSchema } from './queue/postgres/index.js';
9
+ import { migrateTestSchema } from './test/module.js';
10
+ import { Test, testData } from './test/test.model.js';
11
+ import * as configParser from './utils/config-parser.js';
12
+ const config = {
13
+ database: {
14
+ host: configParser.string('DATABASE_HOST', '127.0.0.1'),
15
+ port: configParser.positiveInteger('DATABASE_PORT', 5432),
16
+ user: configParser.string('DATABASE_USER', 'tstdl'),
17
+ pass: configParser.string('DATABASE_PASS', 'wf7rq6glrk5jykne'),
18
+ database: configParser.string('DATABASE_NAME', 'tstdl'),
19
+ },
20
+ };
21
+ async function bootstrap() {
22
+ const injector = inject(Injector);
23
+ configureOrm({
24
+ repositoryConfig: {
25
+ schema: 'test',
26
+ },
27
+ connection: {
28
+ host: config.database.host,
29
+ port: config.database.port,
30
+ user: config.database.user,
31
+ password: config.database.pass,
32
+ database: config.database.database,
33
+ },
34
+ });
35
+ configurePostgresLock();
36
+ configurePostgresQueue();
37
+ await runInInjectionContext(injector, migratePostgresLockSchema);
38
+ await runInInjectionContext(injector, migratePostgresQueueSchema);
39
+ await runInInjectionContext(injector, migrateAuditSchema);
40
+ await runInInjectionContext(injector, migrateTestSchema);
41
+ }
42
+ async function main(_cancellationSignal) {
43
+ const repository = injectRepository(Test);
44
+ // await repository.insertMany(testData);
45
+ const result = await repository.search({
46
+ fields: ['title', 'content', 'tags'],
47
+ query: 'smoothie',
48
+ });
49
+ console.log(result);
50
+ }
51
+ Application.run('Test', [
52
+ provideInitializer(bootstrap),
53
+ provideModule(main),
54
+ provideSignalHandler(),
55
+ provideConsoleLogTransport(PrettyPrintLogFormatter),
56
+ ]);
package/test3.d.ts ADDED
@@ -0,0 +1 @@
1
+ import './polyfills.js';
package/test3.js ADDED
@@ -0,0 +1,47 @@
1
+ import './polyfills.js';
2
+ import { Application } from './application/application.js';
3
+ import { provideInitializer, provideModule, provideSignalHandler } from './application/providers.js';
4
+ import { inject } from './injector/inject.js';
5
+ import { configureLocalMessageBus } from './message-bus/index.js';
6
+ import { configureOrm } from './orm/server/index.js';
7
+ import { configurePostgresQueue, migratePostgresQueueSchema } from './queue/postgres/module.js';
8
+ import { Queue, UniqueTagStrategy } from './queue/queue.js';
9
+ import * as configParser from './utils/config-parser.js';
10
+ if (1 + 1 == 2)
11
+ process.exit();
12
+ const config = {
13
+ database: {
14
+ host: configParser.string('DATABASE_HOST', '127.0.0.1'),
15
+ port: configParser.positiveInteger('DATABASE_PORT', 5432),
16
+ user: configParser.string('DATABASE_USER', 'vitrass'),
17
+ pass: configParser.string('DATABASE_PASS', '6zv7edvqv9vvzz6u4kuk'),
18
+ database: configParser.string('DATABASE_NAME', 'vitrass'),
19
+ schema: configParser.string('DATABASE_SCHEMA', 'vitrass')
20
+ }
21
+ };
22
+ async function bootstrap() {
23
+ configureLocalMessageBus();
24
+ configureOrm({
25
+ connection: {
26
+ host: config.database.host,
27
+ port: config.database.port,
28
+ user: config.database.user,
29
+ password: config.database.pass,
30
+ database: config.database.database
31
+ },
32
+ repositoryConfig: { schema: 'vitrass' }
33
+ });
34
+ configurePostgresQueue({});
35
+ await migratePostgresQueueSchema();
36
+ }
37
+ async function main(_cancellationSignal) {
38
+ const queue = inject((Queue), 'echos');
39
+ await queue.enqueue({ name: 'Max 1' }, { tag: 'foo', uniqueTag: UniqueTagStrategy.TakeNew });
40
+ await queue.enqueue({ name: 'Max 2' }, { tag: 'foo', uniqueTag: UniqueTagStrategy.TakeNew });
41
+ await queue.enqueue({ name: 'Max 3' }, { tag: 'foo', uniqueTag: UniqueTagStrategy.TakeNew });
42
+ }
43
+ Application.run('Test', [
44
+ provideInitializer(bootstrap),
45
+ provideModule(main),
46
+ provideSignalHandler(),
47
+ ]);
package/test4.d.ts ADDED
@@ -0,0 +1,23 @@
1
+ import './polyfills.js';
2
+ import { DocumentManagementAuthorizationService, type DocumentCollection, type DocumentCollectionMetadata } from './document-management/index.js';
3
+ import { DocumentManagementAncillaryService } from './document-management/server/index.js';
4
+ export declare class TestDocumentManagementAncillaryService extends DocumentManagementAncillaryService {
5
+ resolveMetadata(collections: DocumentCollection[]): DocumentCollectionMetadata[];
6
+ }
7
+ export declare class AllowAllDocumentManagementAuthorizationService extends DocumentManagementAuthorizationService {
8
+ getTenantId(): string;
9
+ getSubject(): string;
10
+ canReadCollection(): boolean;
11
+ canCreateDocuments(): boolean;
12
+ canUpdateDocument(): boolean;
13
+ canDeleteDocuments(): boolean;
14
+ canAssignDocuments(): boolean;
15
+ canApproveDocument(): boolean;
16
+ canRejectDocument(): boolean;
17
+ canManageRequests(): boolean;
18
+ canManageCategoriesAndTypes(): boolean;
19
+ canReadDocumentRequestsTemplates(): boolean;
20
+ canManageDocumentRequestsTemplates(): boolean;
21
+ canManageValidationDefinitions(): boolean;
22
+ canProgressDocumentWorkflow(): boolean;
23
+ }
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';