@tstdl/base 0.93.97 → 0.93.99

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.
Files changed (126) hide show
  1. package/audit/auditor.d.ts +1 -1
  2. package/context/context.d.ts +1 -1
  3. package/context/context.js +4 -0
  4. package/cookie/cookie.js +5 -1
  5. package/css/css-variables.d.ts +38 -0
  6. package/css/css-variables.js +38 -0
  7. package/document-management/api/document-management.api.d.ts +17 -3
  8. package/document-management/api/document-management.api.js +8 -1
  9. package/document-management/models/document-category.model.js +0 -1
  10. package/document-management/models/document-property.model.js +0 -1
  11. package/document-management/server/api/document-management.api.d.ts +1 -0
  12. package/document-management/server/api/document-management.api.js +13 -1
  13. package/document-management/server/drizzle/{0000_needy_steel_serpent.sql → 0000_silly_chimera.sql} +0 -2
  14. package/document-management/server/drizzle/meta/0000_snapshot.json +1 -15
  15. package/document-management/server/drizzle/meta/_journal.json +2 -2
  16. package/document-management/server/services/document-statistics.service.d.ts +6 -0
  17. package/document-management/server/services/document-statistics.service.js +167 -0
  18. package/document-management/server/services/index.d.ts +1 -0
  19. package/document-management/server/services/index.js +1 -0
  20. package/document-management/service-models/document-statistics.view-model.d.ts +38 -0
  21. package/document-management/service-models/document-statistics.view-model.js +160 -0
  22. package/document-management/service-models/document.service-model.d.ts +1 -1
  23. package/document-management/service-models/index.d.ts +1 -0
  24. package/document-management/service-models/index.js +1 -0
  25. package/document-management/tests/document-management-core.test.js +2 -2
  26. package/document-management/tests/document-management.api.test.d.ts +1 -0
  27. package/document-management/tests/document-management.api.test.js +102 -0
  28. package/document-management/tests/document-statistics.service.test.d.ts +1 -0
  29. package/document-management/tests/document-statistics.service.test.js +495 -0
  30. package/document-management/tests/enum-helpers.test.js +3 -2
  31. package/enumeration/enumeration.d.ts +24 -0
  32. package/enumeration/enumeration.js +20 -0
  33. package/examples/document-management/main.js +1 -1
  34. package/intl/number-parser.d.ts +16 -9
  35. package/intl/number-parser.js +31 -19
  36. package/module/module.js +3 -0
  37. package/notification/api/notification.api.d.ts +78 -0
  38. package/notification/api/notification.api.js +81 -0
  39. package/notification/enums.d.ts +22 -0
  40. package/notification/enums.js +19 -0
  41. package/notification/index.d.ts +2 -0
  42. package/notification/index.js +2 -0
  43. package/notification/models/in-app-notification.model.d.ts +9 -0
  44. package/notification/models/in-app-notification.model.js +42 -0
  45. package/notification/models/index.d.ts +6 -0
  46. package/notification/models/index.js +6 -0
  47. package/notification/models/notification-category.model.d.ts +17 -0
  48. package/notification/models/notification-category.model.js +41 -0
  49. package/notification/models/notification-log.model.d.ts +13 -0
  50. package/notification/models/notification-log.model.js +59 -0
  51. package/notification/models/notification-preference.model.d.ts +9 -0
  52. package/notification/models/notification-preference.model.js +45 -0
  53. package/notification/models/notification-table.d.ts +3 -0
  54. package/notification/models/notification-table.js +4 -0
  55. package/notification/models/web-push-subscription.model.d.ts +8 -0
  56. package/notification/models/web-push-subscription.model.js +41 -0
  57. package/notification/server/api/notification.api-controller.d.ts +16 -0
  58. package/notification/server/api/notification.api-controller.js +51 -0
  59. package/notification/server/drizzle/0000_glorious_randall.sql +90 -0
  60. package/notification/server/drizzle/meta/0000_snapshot.json +652 -0
  61. package/notification/server/drizzle/meta/_journal.json +13 -0
  62. package/notification/server/drizzle.config.d.ts +2 -0
  63. package/notification/server/drizzle.config.js +11 -0
  64. package/notification/server/index.d.ts +4 -0
  65. package/notification/server/index.js +4 -0
  66. package/notification/server/module.d.ts +12 -0
  67. package/notification/server/module.js +21 -0
  68. package/notification/server/providers/channel-provider.d.ts +4 -0
  69. package/notification/server/providers/channel-provider.js +1 -0
  70. package/notification/server/providers/email-channel-provider.d.ts +6 -0
  71. package/notification/server/providers/email-channel-provider.js +34 -0
  72. package/notification/server/providers/in-app-channel-provider.d.ts +7 -0
  73. package/notification/server/providers/in-app-channel-provider.js +31 -0
  74. package/notification/server/providers/index.d.ts +4 -0
  75. package/notification/server/providers/index.js +4 -0
  76. package/notification/server/providers/web-push-channel-provider.d.ts +6 -0
  77. package/notification/server/providers/web-push-channel-provider.js +26 -0
  78. package/notification/server/schemas.d.ts +25 -0
  79. package/notification/server/schemas.js +12 -0
  80. package/notification/server/services/index.d.ts +8 -0
  81. package/notification/server/services/index.js +8 -0
  82. package/notification/server/services/notification-category.service.d.ts +11 -0
  83. package/notification/server/services/notification-category.service.js +41 -0
  84. package/notification/server/services/notification-delivery.task.d.ts +9 -0
  85. package/notification/server/services/notification-delivery.task.js +1 -0
  86. package/notification/server/services/notification-delivery.worker.d.ts +12 -0
  87. package/notification/server/services/notification-delivery.worker.js +108 -0
  88. package/notification/server/services/notification-sse.service.d.ts +13 -0
  89. package/notification/server/services/notification-sse.service.js +74 -0
  90. package/notification/server/services/notification-template.d.ts +12 -0
  91. package/notification/server/services/notification-template.js +1 -0
  92. package/notification/server/services/notification-template.service.d.ts +7 -0
  93. package/notification/server/services/notification-template.service.js +29 -0
  94. package/notification/server/services/notification.service.d.ts +17 -0
  95. package/notification/server/services/notification.service.js +80 -0
  96. package/notification/server/services/singleton.d.ts +3 -0
  97. package/notification/server/services/singleton.js +10 -0
  98. package/notification/tests/notification-category.service.test.d.ts +1 -0
  99. package/notification/tests/notification-category.service.test.js +36 -0
  100. package/notification/tests/notification-flow.test.d.ts +1 -0
  101. package/notification/tests/notification-flow.test.js +112 -0
  102. package/notification/tests/notification-sse.service.test.d.ts +1 -0
  103. package/notification/tests/notification-sse.service.test.js +20 -0
  104. package/notification/tests/test-notification.model.d.ts +4 -0
  105. package/notification/tests/test-notification.model.js +25 -0
  106. package/object-storage/google/google.object-storage-provider.d.ts +0 -1
  107. package/object-storage/google/google.object-storage-provider.js +0 -1
  108. package/object-storage/index.d.ts +0 -1
  109. package/object-storage/index.js +0 -1
  110. package/object-storage/s3/s3.object-storage-provider.d.ts +0 -1
  111. package/object-storage/s3/s3.object-storage-provider.js +0 -1
  112. package/orm/server/transactional.d.ts +3 -2
  113. package/orm/server/transactional.js +3 -2
  114. package/package.json +4 -2
  115. package/pool/pool.d.ts +1 -1
  116. package/promise/cancelable-promise.d.ts +1 -0
  117. package/promise/cancelable-promise.js +1 -0
  118. package/promise/index.d.ts +1 -0
  119. package/promise/index.js +1 -0
  120. package/random/number-generator/index.d.ts +1 -0
  121. package/random/number-generator/index.js +1 -0
  122. package/sse/data-stream.js +16 -3
  123. package/task-queue/task-queue.d.ts +7 -2
  124. package/task-queue/task-queue.js +4 -1
  125. package/unit-test/integration-setup.d.ts +7 -6
  126. package/unit-test/integration-setup.js +7 -2
@@ -0,0 +1,160 @@
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
+ var _a, _b, _c;
11
+ import { BooleanProperty, Integer, Property, StringProperty } from '../../schema/index.js';
12
+ import { DocumentApproval } from '../models/document.model.js';
13
+ export class DocumentApprovalBreakdown {
14
+ [_a = DocumentApproval.Pending];
15
+ [_b = DocumentApproval.Approved];
16
+ [_c = DocumentApproval.Rejected];
17
+ }
18
+ __decorate([
19
+ Integer(),
20
+ __metadata("design:type", Number)
21
+ ], DocumentApprovalBreakdown.prototype, _a, void 0);
22
+ __decorate([
23
+ Integer(),
24
+ __metadata("design:type", Number)
25
+ ], DocumentApprovalBreakdown.prototype, _b, void 0);
26
+ __decorate([
27
+ Integer(),
28
+ __metadata("design:type", Number)
29
+ ], DocumentApprovalBreakdown.prototype, _c, void 0);
30
+ export class DocumentDataQualityMetrics {
31
+ missingType;
32
+ missingDate;
33
+ missingTitle;
34
+ }
35
+ __decorate([
36
+ Integer(),
37
+ __metadata("design:type", Number)
38
+ ], DocumentDataQualityMetrics.prototype, "missingType", void 0);
39
+ __decorate([
40
+ Integer(),
41
+ __metadata("design:type", Number)
42
+ ], DocumentDataQualityMetrics.prototype, "missingDate", void 0);
43
+ __decorate([
44
+ Integer(),
45
+ __metadata("design:type", Number)
46
+ ], DocumentDataQualityMetrics.prototype, "missingTitle", void 0);
47
+ export class DocumentStatistics {
48
+ totalCount;
49
+ approvalBreakdown;
50
+ typeBreakdown;
51
+ storageUsage;
52
+ mimeTypeDistribution;
53
+ dataQuality;
54
+ createdLast30Days;
55
+ tagUsage;
56
+ totalPages;
57
+ validationFailures;
58
+ }
59
+ __decorate([
60
+ Integer({ optional: true }),
61
+ __metadata("design:type", Number)
62
+ ], DocumentStatistics.prototype, "totalCount", void 0);
63
+ __decorate([
64
+ Property(DocumentApprovalBreakdown, { optional: true }),
65
+ __metadata("design:type", DocumentApprovalBreakdown)
66
+ ], DocumentStatistics.prototype, "approvalBreakdown", void 0);
67
+ __decorate([
68
+ Property(Object, { optional: true }),
69
+ __metadata("design:type", Object)
70
+ ], DocumentStatistics.prototype, "typeBreakdown", void 0);
71
+ __decorate([
72
+ Integer({ optional: true }),
73
+ __metadata("design:type", Number)
74
+ ], DocumentStatistics.prototype, "storageUsage", void 0);
75
+ __decorate([
76
+ Property(Object, { optional: true }),
77
+ __metadata("design:type", Object)
78
+ ], DocumentStatistics.prototype, "mimeTypeDistribution", void 0);
79
+ __decorate([
80
+ Property(DocumentDataQualityMetrics, { optional: true }),
81
+ __metadata("design:type", DocumentDataQualityMetrics)
82
+ ], DocumentStatistics.prototype, "dataQuality", void 0);
83
+ __decorate([
84
+ Integer({ optional: true }),
85
+ __metadata("design:type", Number)
86
+ ], DocumentStatistics.prototype, "createdLast30Days", void 0);
87
+ __decorate([
88
+ Property(Object, { optional: true }),
89
+ __metadata("design:type", Object)
90
+ ], DocumentStatistics.prototype, "tagUsage", void 0);
91
+ __decorate([
92
+ Integer({ optional: true }),
93
+ __metadata("design:type", Number)
94
+ ], DocumentStatistics.prototype, "totalPages", void 0);
95
+ __decorate([
96
+ Integer({ optional: true }),
97
+ __metadata("design:type", Number)
98
+ ], DocumentStatistics.prototype, "validationFailures", void 0);
99
+ export class GetDocumentStatisticsOptions {
100
+ includeTotalCount;
101
+ includeApprovalBreakdown;
102
+ includeTypeBreakdown;
103
+ includeStorageUsage;
104
+ includeMimeTypeDistribution;
105
+ includeDataQuality;
106
+ includeCreatedLast30Days;
107
+ includeTagUsage;
108
+ includeTotalPages;
109
+ includeValidationFailures;
110
+ collectionIds;
111
+ categoryIds;
112
+ }
113
+ __decorate([
114
+ BooleanProperty({ optional: true }),
115
+ __metadata("design:type", Boolean)
116
+ ], GetDocumentStatisticsOptions.prototype, "includeTotalCount", void 0);
117
+ __decorate([
118
+ BooleanProperty({ optional: true }),
119
+ __metadata("design:type", Boolean)
120
+ ], GetDocumentStatisticsOptions.prototype, "includeApprovalBreakdown", void 0);
121
+ __decorate([
122
+ BooleanProperty({ optional: true }),
123
+ __metadata("design:type", Boolean)
124
+ ], GetDocumentStatisticsOptions.prototype, "includeTypeBreakdown", void 0);
125
+ __decorate([
126
+ BooleanProperty({ optional: true }),
127
+ __metadata("design:type", Boolean)
128
+ ], GetDocumentStatisticsOptions.prototype, "includeStorageUsage", void 0);
129
+ __decorate([
130
+ BooleanProperty({ optional: true }),
131
+ __metadata("design:type", Boolean)
132
+ ], GetDocumentStatisticsOptions.prototype, "includeMimeTypeDistribution", void 0);
133
+ __decorate([
134
+ BooleanProperty({ optional: true }),
135
+ __metadata("design:type", Boolean)
136
+ ], GetDocumentStatisticsOptions.prototype, "includeDataQuality", void 0);
137
+ __decorate([
138
+ BooleanProperty({ optional: true }),
139
+ __metadata("design:type", Boolean)
140
+ ], GetDocumentStatisticsOptions.prototype, "includeCreatedLast30Days", void 0);
141
+ __decorate([
142
+ BooleanProperty({ optional: true }),
143
+ __metadata("design:type", Boolean)
144
+ ], GetDocumentStatisticsOptions.prototype, "includeTagUsage", void 0);
145
+ __decorate([
146
+ BooleanProperty({ optional: true }),
147
+ __metadata("design:type", Boolean)
148
+ ], GetDocumentStatisticsOptions.prototype, "includeTotalPages", void 0);
149
+ __decorate([
150
+ BooleanProperty({ optional: true }),
151
+ __metadata("design:type", Boolean)
152
+ ], GetDocumentStatisticsOptions.prototype, "includeValidationFailures", void 0);
153
+ __decorate([
154
+ StringProperty({ array: true }),
155
+ __metadata("design:type", Array)
156
+ ], GetDocumentStatisticsOptions.prototype, "collectionIds", void 0);
157
+ __decorate([
158
+ StringProperty({ array: true, optional: true }),
159
+ __metadata("design:type", Array)
160
+ ], GetDocumentStatisticsOptions.prototype, "categoryIds", void 0);
@@ -236,7 +236,7 @@ export declare const addOrArchiveDocumentToOrFromCollectionParametersSchema: imp
236
236
  }>;
237
237
  export declare const proceedDocumentWorkflowParametersSchema: import("../../schema/index.js").ObjectSchema<{
238
238
  id: string;
239
- state: "error" | "pending" | "running" | "completed" | "review" | "failed";
239
+ state: "error" | "pending" | "running" | "completed" | "failed" | "review";
240
240
  }>;
241
241
  export type MetadataParameter = SchemaOutput<typeof metadataParameterObjectSchema>;
242
242
  export type LoadDataParameters = SchemaOutput<typeof loadDataParametersSchema>;
@@ -3,6 +3,7 @@ export * from './document-collection-metadata.service-model.js';
3
3
  export * from './document-folders.view-model.js';
4
4
  export * from './document-management.view-model.js';
5
5
  export * from './document-requests-template.view-model.js';
6
+ export * from './document-statistics.view-model.js';
6
7
  export * from './document.service-model.js';
7
8
  export * from './enriched/index.js';
8
9
  export * from './stats.view-model.js';
@@ -3,6 +3,7 @@ export * from './document-collection-metadata.service-model.js';
3
3
  export * from './document-folders.view-model.js';
4
4
  export * from './document-management.view-model.js';
5
5
  export * from './document-requests-template.view-model.js';
6
+ export * from './document-statistics.view-model.js';
6
7
  export * from './document.service-model.js';
7
8
  export * from './enriched/index.js';
8
9
  export * from './stats.view-model.js';
@@ -4,7 +4,7 @@ import { AiModuleOptions } from '../../ai/module.js';
4
4
  import { runInInjectionContext } from '../../injector/index.js';
5
5
  import { ObjectStorage } from '../../object-storage/index.js';
6
6
  import { TaskQueue } from '../../task-queue/index.js';
7
- import { setupIntegrationTest, truncateTables } from '../../unit-test/index.js';
7
+ import { setupIntegrationTest, clearTenantData } from '../../unit-test/index.js';
8
8
  import { configureDocumentManagement } from '../server/configure.js';
9
9
  import { migrateDocumentManagementSchema } from '../server/module.js';
10
10
  import { DocumentCategoryTypeService } from '../server/services/document-category-type.service.js';
@@ -72,7 +72,7 @@ describe('Document Management Core', () => {
72
72
  await injector?.dispose();
73
73
  });
74
74
  beforeEach(async () => {
75
- await truncateTables(database, schema, ['request_collection_assignment', 'collection_assignment', 'workflow', 'request', 'document', 'collection', 'type', 'category']);
75
+ await clearTenantData(database, schema, ['request_collection_assignment', 'collection_assignment', 'workflow', 'request', 'document', 'collection', 'type', 'category'], tenantId);
76
76
  });
77
77
  // --- Collection Management ---
78
78
  test('Create and load collection', async () => {
@@ -0,0 +1,102 @@
1
+ import { afterAll, beforeAll, beforeEach, describe, expect, test, vi } from 'vitest';
2
+ import { AiService } from '../../ai/ai.service.js';
3
+ import { AiModuleOptions } from '../../ai/module.js';
4
+ import { runInInjectionContext } from '../../injector/index.js';
5
+ import { ObjectStorage } from '../../object-storage/index.js';
6
+ import { TaskQueue } from '../../task-queue/index.js';
7
+ import { clearTenantData, setupIntegrationTest } from '../../unit-test/index.js';
8
+ import { DocumentManagementAuthorizationService } from '../authorization/document-management-authorization.service.js';
9
+ import { DocumentManagementApiController } from '../server/api/document-management.api.js';
10
+ import { configureDocumentManagement } from '../server/configure.js';
11
+ import { migrateDocumentManagementSchema } from '../server/module.js';
12
+ import { DocumentCollectionService } from '../server/services/document-collection.service.js';
13
+ import { DocumentService } from '../server/services/document.service.js';
14
+ import { TestDocumentManagementAncillaryService, TestDocumentManagementAuthorizationService } from './helper.js';
15
+ describe('DocumentManagementApi Stats', () => {
16
+ let injector;
17
+ let database;
18
+ let controller;
19
+ let documentService;
20
+ let collectionService;
21
+ const schema = 'document_management';
22
+ const tenantId = crypto.randomUUID();
23
+ beforeAll(async () => {
24
+ ({ injector, database } = await setupIntegrationTest({
25
+ modules: { taskQueue: false, messageBus: true },
26
+ orm: { schema },
27
+ }));
28
+ injector.register(AiModuleOptions, { useValue: {} });
29
+ injector.register(AiService, { useValue: { processFile: vi.fn() } });
30
+ injector.register(ObjectStorage, {
31
+ useValue: {
32
+ uploadObject: vi.fn(),
33
+ getDownloadUrl: vi.fn(),
34
+ getContent: vi.fn(),
35
+ getContentStream: vi.fn(),
36
+ getObject: vi.fn(),
37
+ exists: vi.fn(),
38
+ },
39
+ });
40
+ injector.register(TaskQueue, {
41
+ useValue: {
42
+ enqueue: vi.fn(),
43
+ enqueueMany: vi.fn(),
44
+ process: vi.fn(),
45
+ },
46
+ });
47
+ configureDocumentManagement({
48
+ ancillaryService: TestDocumentManagementAncillaryService,
49
+ authorizationService: TestDocumentManagementAuthorizationService,
50
+ fileObjectStorageModule: 'documents',
51
+ fileUploadObjectStorageModule: 'document-uploads',
52
+ filePreviewObjectStorageModule: 'document-previews',
53
+ });
54
+ await runInInjectionContext(injector, migrateDocumentManagementSchema);
55
+ controller = await injector.resolveAsync(DocumentManagementApiController);
56
+ documentService = await injector.resolveAsync(DocumentService);
57
+ collectionService = await injector.resolveAsync(DocumentCollectionService);
58
+ });
59
+ afterAll(async () => {
60
+ await injector?.dispose();
61
+ });
62
+ beforeEach(async () => {
63
+ await clearTenantData(database, schema, ['collection_assignment', 'workflow', 'document', 'collection', 'tag', 'type', 'category'], tenantId);
64
+ });
65
+ test('getStatistics API endpoint', async () => {
66
+ await runInInjectionContext(injector, async () => {
67
+ const collection = await collectionService.createCollection(tenantId, null);
68
+ const authService = injector.resolve(DocumentManagementAuthorizationService);
69
+ vi.spyOn(authService, 'getTenantId').mockResolvedValue(tenantId);
70
+ await documentService.create(tenantId, {
71
+ assignment: { collections: [collection.id] },
72
+ skipWorkflow: true,
73
+ }, new Uint8Array([1, 2, 3]));
74
+ const mockContext = {
75
+ getToken: async () => ({ payload: { tenantId } }),
76
+ parameters: {
77
+ includeTotalCount: true,
78
+ includeStorageUsage: true,
79
+ collectionIds: [collection.id]
80
+ }
81
+ };
82
+ const stats = await controller.getStatistics(mockContext);
83
+ expect(stats.totalCount).toBe(1);
84
+ expect(stats.storageUsage).toBe(3);
85
+ });
86
+ });
87
+ test('getStatistics API endpoint should deny access if collection is restricted', async () => {
88
+ await runInInjectionContext(injector, async () => {
89
+ const authService = injector.resolve(DocumentManagementAuthorizationService);
90
+ vi.spyOn(authService, 'getTenantId').mockResolvedValue(tenantId);
91
+ vi.spyOn(authService, 'canReadCollection').mockResolvedValue(false);
92
+ const mockContext = {
93
+ getToken: async () => ({ payload: { tenantId } }),
94
+ parameters: {
95
+ includeTotalCount: true,
96
+ collectionIds: ['some-collection-id']
97
+ }
98
+ };
99
+ await expect(controller.getStatistics(mockContext)).rejects.toThrow('You are not allowed to read collection some-collection-id');
100
+ });
101
+ });
102
+ });