@tstdl/base 0.92.123 → 0.92.125

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 (221) hide show
  1. package/ai/ai-file.service.js +23 -18
  2. package/ai/ai.service.d.ts +4 -12
  3. package/ai/ai.service.js +79 -147
  4. package/ai/functions.d.ts +1 -1
  5. package/ai/types.d.ts +3 -1
  6. package/api/server/gateway.js +6 -6
  7. package/authentication/authentication.api.js +24 -24
  8. package/authentication/server/authentication.service.js +20 -20
  9. package/browser/page-controller.js +1 -1
  10. package/context/context.js +5 -5
  11. package/document-management/api/document-management.api.d.ts +60 -215
  12. package/document-management/api/document-management.api.js +32 -68
  13. package/document-management/models/document-assignment-scope.model.d.ts +11 -0
  14. package/document-management/models/{document-request-assignment-task-collection.model.js → document-assignment-scope.model.js} +14 -10
  15. package/document-management/models/document-assignment-task.model.d.ts +13 -0
  16. package/document-management/models/document-assignment-task.model.js +38 -0
  17. package/document-management/models/document-category.model.d.ts +2 -0
  18. package/document-management/models/document-category.model.js +7 -1
  19. package/document-management/models/{document-collection-document.model.d.ts → document-collection-assignment.model.d.ts} +1 -1
  20. package/document-management/models/{document-collection-document.model.js → document-collection-assignment.model.js} +7 -7
  21. package/document-management/models/document-collection.model.d.ts +2 -0
  22. package/document-management/models/document-collection.model.js +10 -0
  23. package/document-management/models/document-property-value.model.d.ts +3 -11
  24. package/document-management/models/document-property-value.model.js +15 -46
  25. package/document-management/models/document-property.model.d.ts +2 -1
  26. package/document-management/models/document-property.model.js +2 -2
  27. package/document-management/models/document-request-submission.model.d.ts +7 -0
  28. package/document-management/models/document-request-submission.model.js +34 -0
  29. package/document-management/models/document-request-template.d.ts +2 -4
  30. package/document-management/models/document-request-template.js +3 -8
  31. package/document-management/models/document-request.model.d.ts +14 -6
  32. package/document-management/models/document-request.model.js +22 -12
  33. package/document-management/models/document-type-validation.model.d.ts +6 -0
  34. package/document-management/models/document-type-validation.model.js +34 -0
  35. package/document-management/models/document-type.model.d.ts +0 -1
  36. package/document-management/models/document-type.model.js +0 -5
  37. package/document-management/models/document-validation-definition.model.d.ts +10 -0
  38. package/document-management/models/document-validation-definition.model.js +39 -0
  39. package/document-management/models/document-validation-execution-related-document.model.d.ts +7 -0
  40. package/document-management/models/document-validation-execution-related-document.model.js +34 -0
  41. package/document-management/models/document-validation-execution.model.d.ts +26 -0
  42. package/document-management/models/document-validation-execution.model.js +72 -0
  43. package/document-management/models/document-workflow.model.d.ts +35 -0
  44. package/document-management/models/document-workflow.model.js +70 -0
  45. package/document-management/models/document.model.d.ts +12 -1
  46. package/document-management/models/document.model.js +21 -5
  47. package/document-management/models/index.d.ts +10 -5
  48. package/document-management/models/index.js +10 -5
  49. package/document-management/models/service-models/categories-and-types.view-model.d.ts +3 -3
  50. package/document-management/models/service-models/categories-and-types.view-model.js +2 -21
  51. package/document-management/models/service-models/document-folders.view-model.d.ts +7 -14
  52. package/document-management/models/service-models/document-folders.view-model.js +20 -44
  53. package/document-management/models/service-models/document-management.view-model.d.ts +41 -0
  54. package/document-management/models/service-models/{document.view-model.js → document-management.view-model.js} +43 -26
  55. package/document-management/models/service-models/document.service-model.d.ts +51 -81
  56. package/document-management/models/service-models/document.service-model.js +30 -28
  57. package/document-management/models/service-models/enriched/enriched-document-assignment.view.d.ts +11 -0
  58. package/document-management/models/service-models/enriched/enriched-document-assignment.view.js +12 -0
  59. package/document-management/models/service-models/enriched/enriched-document-category.view.d.ts +13 -0
  60. package/document-management/models/service-models/enriched/enriched-document-category.view.js +47 -0
  61. package/document-management/models/service-models/enriched/enriched-document-collection.view.d.ts +22 -0
  62. package/document-management/models/service-models/enriched/enriched-document-collection.view.js +89 -0
  63. package/document-management/models/service-models/enriched/enriched-document-file.view.d.ts +12 -0
  64. package/document-management/models/service-models/enriched/enriched-document-file.view.js +16 -0
  65. package/document-management/models/service-models/enriched/enriched-document-management-data.view.d.ts +41 -0
  66. package/document-management/models/service-models/enriched/enriched-document-management-data.view.js +130 -0
  67. package/document-management/models/service-models/enriched/enriched-document-request.view.d.ts +17 -0
  68. package/document-management/models/service-models/enriched/enriched-document-request.view.js +52 -0
  69. package/document-management/models/service-models/enriched/enriched-document-type.view.d.ts +9 -0
  70. package/document-management/models/service-models/enriched/enriched-document-type.view.js +10 -0
  71. package/document-management/models/service-models/enriched/enriched-document.view.d.ts +28 -0
  72. package/document-management/models/service-models/enriched/enriched-document.view.js +77 -0
  73. package/document-management/models/service-models/enriched/enriched.d.ts +18 -0
  74. package/document-management/models/service-models/enriched/enriched.js +39 -0
  75. package/document-management/models/service-models/enriched/index.d.ts +9 -0
  76. package/document-management/models/service-models/enriched/index.js +9 -0
  77. package/document-management/models/service-models/index.d.ts +2 -2
  78. package/document-management/models/service-models/index.js +2 -2
  79. package/document-management/models/service-models/normalized-requests-template-data.model.d.ts +12 -10
  80. package/document-management/models/service-models/normalized-requests-template-data.model.js +5 -4
  81. package/document-management/models/service-models/stats.view-model.d.ts +7 -5
  82. package/document-management/models/service-models/stats.view-model.js +19 -9
  83. package/document-management/server/module.d.ts +2 -2
  84. package/document-management/server/module.js +3 -7
  85. package/document-management/server/schemas.d.ts +18 -23
  86. package/document-management/server/schemas.js +18 -23
  87. package/document-management/server/services/document-category-type.service.d.ts +25 -0
  88. package/document-management/server/services/document-category-type.service.js +66 -0
  89. package/document-management/server/services/document-collection.service.d.ts +13 -0
  90. package/document-management/server/services/document-collection.service.js +41 -0
  91. package/document-management/server/services/document-file.service.d.ts +17 -0
  92. package/document-management/server/services/document-file.service.js +204 -0
  93. package/document-management/server/services/document-management-ai.service.d.ts +22 -0
  94. package/document-management/server/services/document-management-ai.service.js +340 -0
  95. package/document-management/server/services/document-management-ancillary.service.d.ts +127 -3
  96. package/document-management/server/services/document-management-ancillary.service.js +24 -0
  97. package/document-management/server/services/document-management.service.d.ts +10 -122
  98. package/document-management/server/services/document-management.service.js +106 -888
  99. package/document-management/server/services/document-property.service.d.ts +84 -0
  100. package/document-management/server/services/document-property.service.js +87 -0
  101. package/document-management/server/services/document-request.service.d.ts +30 -0
  102. package/document-management/server/services/document-request.service.js +138 -0
  103. package/document-management/server/services/document-validation.service.d.ts +20 -0
  104. package/document-management/server/services/document-validation.service.js +145 -0
  105. package/document-management/server/services/document-workflow.service.d.ts +20 -0
  106. package/document-management/server/services/document-workflow.service.js +132 -0
  107. package/document-management/server/services/document.service.d.ts +16 -0
  108. package/document-management/server/services/document.service.js +81 -0
  109. package/document-management/server/services/index.d.ts +9 -0
  110. package/document-management/server/services/index.js +9 -0
  111. package/document-management/server/validators/ai-validation-executor.d.ts +19 -0
  112. package/document-management/server/validators/ai-validation-executor.js +51 -0
  113. package/document-management/server/validators/index.d.ts +2 -0
  114. package/document-management/server/validators/index.js +2 -0
  115. package/document-management/server/validators/single-document-validation-executor.d.ts +16 -0
  116. package/document-management/server/validators/single-document-validation-executor.js +20 -0
  117. package/document-management/server/validators/validator.d.ts +21 -0
  118. package/document-management/server/validators/validator.js +2 -0
  119. package/eslint.config.js +31 -17
  120. package/examples/document-management/main.d.ts +18 -3
  121. package/examples/document-management/main.js +28 -12
  122. package/file/mime-type.js +2 -9
  123. package/formats.d.ts +5 -2
  124. package/formats.js +32 -23
  125. package/http/client/http-client.js +1 -1
  126. package/injector/injector.js +2 -2
  127. package/object-storage/s3/s3.object-storage.js +1 -1
  128. package/orm/data-types/bytea.d.ts +8 -0
  129. package/orm/data-types/bytea.js +8 -0
  130. package/orm/data-types/index.d.ts +4 -0
  131. package/orm/data-types/index.js +4 -0
  132. package/orm/data-types/numeric-date.d.ts +9 -0
  133. package/orm/data-types/numeric-date.js +9 -0
  134. package/orm/data-types/timestamp.d.ts +9 -0
  135. package/orm/data-types/timestamp.js +9 -0
  136. package/orm/decorators.d.ts +139 -5
  137. package/orm/decorators.js +50 -0
  138. package/orm/entity.d.ts +19 -0
  139. package/orm/entity.js +19 -0
  140. package/orm/index.d.ts +5 -0
  141. package/orm/index.js +5 -0
  142. package/orm/query.d.ts +51 -0
  143. package/orm/query.js +6 -0
  144. package/orm/repository.types.d.ts +54 -2
  145. package/orm/server/database-schema.d.ts +34 -0
  146. package/orm/server/database-schema.js +29 -0
  147. package/orm/server/database.d.ts +19 -1
  148. package/orm/server/database.js +17 -3
  149. package/orm/server/drizzle/schema-converter.d.ts +2 -1
  150. package/orm/server/drizzle/schema-converter.js +12 -1
  151. package/orm/server/encryption.d.ts +16 -0
  152. package/orm/server/encryption.js +29 -4
  153. package/orm/server/index.d.ts +7 -0
  154. package/orm/server/index.js +7 -0
  155. package/orm/server/module.d.ts +20 -0
  156. package/orm/server/module.js +9 -0
  157. package/orm/server/query-converter.d.ts +17 -0
  158. package/orm/server/query-converter.js +66 -11
  159. package/orm/server/repository.d.ts +324 -18
  160. package/orm/server/repository.js +344 -73
  161. package/orm/server/transaction.d.ts +5 -5
  162. package/orm/server/transaction.js +5 -5
  163. package/orm/server/transactional.d.ts +75 -0
  164. package/orm/server/transactional.js +134 -0
  165. package/orm/server/types.d.ts +1 -0
  166. package/orm/sqls.d.ts +55 -0
  167. package/orm/sqls.js +60 -0
  168. package/orm/types.d.ts +67 -4
  169. package/orm/utils.d.ts +19 -3
  170. package/orm/utils.js +12 -0
  171. package/package.json +32 -31
  172. package/password/password-check-result.model.d.ts +9 -7
  173. package/password/password-check-result.model.js +8 -8
  174. package/password/password-check.js +5 -7
  175. package/password/password-check.localization.js +12 -12
  176. package/pdf/pdf.service.js +1 -1
  177. package/pdf/utils.d.ts +9 -0
  178. package/pdf/utils.js +19 -2
  179. package/process/spawn.d.ts +11 -4
  180. package/process/spawn.js +42 -5
  181. package/queue/postgres/queue.js +5 -5
  182. package/queue/queue.d.ts +6 -4
  183. package/queue/queue.js +6 -6
  184. package/schema/schemas/one-or-many.d.ts +2 -1
  185. package/schema/schemas/one-or-many.js +1 -1
  186. package/search-index/elastic/model/index-mapping.d.ts +1 -1
  187. package/search-index/elastic/model/index-mapping.js +0 -1
  188. package/search-index/elastic/search-index.d.ts +1 -2
  189. package/search-index/elastic/search-index.js +3 -3
  190. package/types.d.ts +1 -0
  191. package/utils/async-hook/async-hook.d.ts +9 -0
  192. package/utils/async-hook/async-hook.js +21 -0
  193. package/utils/async-hook/index.d.ts +1 -0
  194. package/utils/async-hook/index.js +1 -0
  195. package/utils/compression.js +1 -1
  196. package/utils/function/class.d.ts +6 -0
  197. package/utils/function/class.js +9 -0
  198. package/utils/function/index.d.ts +1 -0
  199. package/utils/function/index.js +1 -0
  200. package/utils/function/memoize.d.ts +18 -0
  201. package/utils/function/memoize.js +41 -2
  202. package/utils/jwt.d.ts +1 -1
  203. package/utils/jwt.js +5 -5
  204. package/utils/object/forward-ref.d.ts +3 -2
  205. package/utils/object/forward-ref.js +12 -12
  206. package/utils/object/lazy-property.js +2 -2
  207. package/utils/proxy.js +1 -1
  208. package/utils/stream/{readable-stream-from-promise.d.ts → from-promise.d.ts} +1 -0
  209. package/utils/stream/from-promise.js +27 -0
  210. package/utils/stream/index.d.ts +1 -1
  211. package/utils/stream/index.js +1 -1
  212. package/utils/stream/stream-reader.js +71 -31
  213. package/document-management/models/document-request-assignment-task-collection.model.d.ts +0 -7
  214. package/document-management/models/document-request-assignment-task.model.d.ts +0 -14
  215. package/document-management/models/document-request-assignment-task.model.js +0 -77
  216. package/document-management/models/document-request-file.model.d.ts +0 -16
  217. package/document-management/models/document-request-file.model.js +0 -86
  218. package/document-management/models/service-models/document.view-model.d.ts +0 -41
  219. package/document-management/models/service-models/normalized-document-collection-view.model.d.ts +0 -73
  220. package/document-management/models/service-models/normalized-document-collection-view.model.js +0 -110
  221. package/utils/stream/readable-stream-from-promise.js +0 -8
@@ -1,4 +1,128 @@
1
- import type { DocumentCollection } from '../../models/document-collection.model.js';
2
- export declare abstract class DocumentManagementAncillaryService {
3
- abstract resolveNames(collections: DocumentCollection[]): Promise<string[]>;
1
+ import { DocumentCollection, type DocumentWorkflowStep } from '../../models/index.js';
2
+ export type DocumentCollectionMetadata = {
3
+ /**
4
+ * User-friendly name of the collection
5
+ * @example <name of person>
6
+ * @example <address of real estate>
7
+ */
8
+ name: string;
9
+ /**
10
+ * Group of the collection, used to group multiple collections to the same "type"
11
+ * @example 'Applicants'
12
+ * @example 'Real estates'
13
+ */
14
+ group: string | null;
15
+ };
16
+ export declare abstract class DocumentManagementAncillaryService<Token = unknown> {
17
+ #private;
18
+ resolveMetadata<const T extends (DocumentCollection | string)[]>(...collectionsOrIds: T): Promise<{
19
+ [K in keyof T]: DocumentCollectionMetadata;
20
+ }>;
21
+ resolveMetadataMap(...collectionsOrIds: (DocumentCollection | string)[]): Promise<Record<string, DocumentCollectionMetadata>>;
22
+ /**
23
+ * Resolves application-specific metadata for a list of document collections.
24
+ * @param collections An array of DocumentCollection entities.
25
+ * @returns A promise that resolves to an array of DocumentCollectionMetadata, corresponding to the input collections.
26
+ */
27
+ abstract _resolveMetadata(collections: DocumentCollection[]): DocumentCollectionMetadata[] | Promise<DocumentCollectionMetadata[]>;
28
+ /**
29
+ * Checks if a user can read/view a specific document collection and its documents.
30
+ * @param collectionId The ID of the document collection.
31
+ * @param token The token of the request
32
+ */
33
+ abstract canReadCollection(collectionId: string, token?: Token): boolean | Promise<boolean>;
34
+ /**
35
+ * Checks if a user can write to/modify a specific document collection.
36
+ * This could include changing collection metadata or managing documents within it,
37
+ * such as adding documents or creating document requests for this collection.
38
+ * @param collectionId The ID of the document collection.
39
+ * @param token The token of the request
40
+ */
41
+ abstract canWriteCollection(collectionId: string, token?: Token): boolean | Promise<boolean>;
42
+ /**
43
+ * Checks if a user can approve a specific document. This implicitly allows fulfilling document requests by approving their linked document.
44
+ * This is usually a privileged action for staff members.
45
+ * @param documentId The ID of the document.
46
+ * @param token The token of the request
47
+ * @returns A promise that resolves to true if approval is allowed, false otherwise.
48
+ */
49
+ abstract canApproveDocument(documentId: string, token?: Token): boolean | Promise<boolean>;
50
+ /**
51
+ * Checks if a user can reject a specific document.
52
+ * This is usually a privileged action for staff members, often an alternative to approval.
53
+ * @param documentId The ID of the document.
54
+ * @param token The token of the request.
55
+ * @returns A promise that resolves to true if rejection is allowed, false otherwise.
56
+ */
57
+ abstract canRejectDocument(documentId: string, token?: Token): boolean | Promise<boolean>;
58
+ /**
59
+ * Checks if a user can read/view a specific document request.
60
+ * @param requestId The ID of the document request.
61
+ * @param token The token of the request
62
+ */
63
+ abstract canReadDocumentRequest(requestId: string, token?: Token): boolean | Promise<boolean>;
64
+ /**
65
+ * Checks if a user can assign an existing document to a document request.
66
+ * This links the document to the request, usually before final fulfillment.
67
+ * @param requestId The ID of the document request.
68
+ * @param documentId The ID of the document to be assigned.
69
+ * @param token The token of the request
70
+ * @returns A promise that resolves to true if assignment is allowed, false otherwise.
71
+ */
72
+ abstract canAssignDocumentToRequest(requestId: string, documentId: string, token?: Token): boolean | Promise<boolean>;
73
+ /**
74
+ * Checks if a user can manage document categories, types and their properties (create, update, delete).
75
+ * Typically an administrator function.
76
+ * @param token The token of the request.
77
+ */
78
+ abstract canManageCategoriesAndTypes(token?: Token): boolean | Promise<boolean>;
79
+ /**
80
+ * Checks if a user can read document request templates.
81
+ * @param token The token of the request.
82
+ */
83
+ abstract canReadDocumentRequestsTemplates(token?: Token): boolean | Promise<boolean>;
84
+ /**
85
+ * Checks if a user can manage document request templates (create, update, delete).
86
+ * Typically an administrator function.
87
+ * @param token The token of the request.
88
+ */
89
+ abstract canManageDocumentRequestsTemplates(token?: Token): boolean | Promise<boolean>;
90
+ /**
91
+ * Checks if a user can create/upload a new unassigned document (which then requires assigning to request/collection).
92
+ * @param token The token of the request.
93
+ */
94
+ abstract canCreateUnassignedDocument(token?: Token): boolean | Promise<boolean>;
95
+ /**
96
+ * Checks if a user can create/upload a new document assigned to an request.
97
+ * @param token The token of the request.
98
+ */
99
+ abstract canCreateRequestAssignedDocument(token?: Token): boolean | Promise<boolean>;
100
+ /**
101
+ * Checks if a user can delete a document.
102
+ * This might be restricted (e.g., only for documents not yet approved, or by administrators).
103
+ * @param documentId The ID of the document.
104
+ * @param token The token of the request.
105
+ * @returns A promise that resolves to true if deletion is allowed, false otherwise.
106
+ */
107
+ abstract canDeleteDocument(documentId: string, token?: Token): boolean | Promise<boolean>;
108
+ /**
109
+ * Checks if a user can create and close document requests.
110
+ * @param token The token of the request.
111
+ */
112
+ abstract canManageDocumentRequest(token?: Token): boolean | Promise<boolean>;
113
+ /**
114
+ * Checks if a user can manage document validation definitions and their assignment to types.
115
+ * Typically an administrator function.
116
+ * @param token The token of the request.
117
+ */
118
+ abstract canManageValidationDefinitions(token?: Token): boolean | Promise<boolean>;
119
+ /**
120
+ * Checks if a user can progress a document through its workflow.
121
+ * This implies reviewing the current step's output, making corrections if necessary,
122
+ * and then confirming to proceed to the next phase or finalization.
123
+ * @param documentId The ID of the document.
124
+ * @param currentWorkflowStep The current step of the workflow the user is interacting with.
125
+ * @param token The token of the request.
126
+ */
127
+ abstract canProgressDocumentWorkflow(documentId: string, currentWorkflowStep: DocumentWorkflowStep, token?: Token): boolean | Promise<boolean>;
4
128
  }
@@ -5,7 +5,31 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import { Singleton } from '../../../injector/index.js';
8
+ import { injectRepository } from '../../../orm/server/index.js';
9
+ import { fromEntries } from '../../../utils/object/index.js';
10
+ import { assertDefinedPass, isString } from '../../../utils/type-guards.js';
11
+ import { DocumentCollection } from '../../models/index.js';
8
12
  let DocumentManagementAncillaryService = class DocumentManagementAncillaryService {
13
+ #documentCollectionRepository = injectRepository(DocumentCollection);
14
+ async resolveMetadata(...collectionsOrIds) {
15
+ if (collectionsOrIds.length == 0) {
16
+ return [];
17
+ }
18
+ const loadIds = collectionsOrIds.filter((collection) => isString(collection));
19
+ if (loadIds.length == 0) {
20
+ return this._resolveMetadata(collectionsOrIds);
21
+ }
22
+ const loadedCollections = await this.#documentCollectionRepository.loadManyByQuery({ id: { $in: loadIds } });
23
+ const collections = collectionsOrIds.map((collectionOrId) => isString(collectionOrId)
24
+ ? assertDefinedPass(loadedCollections.find((collection) => collection.id == collectionOrId), `Could not load collection "${collectionOrId}".`)
25
+ : collectionOrId);
26
+ return this._resolveMetadata(collections);
27
+ }
28
+ async resolveMetadataMap(...collectionsOrIds) {
29
+ const names = await this.resolveMetadata(...collectionsOrIds);
30
+ const entries = collectionsOrIds.map((collectionOrId, index) => [isString(collectionOrId) ? collectionOrId : collectionOrId.id, names[index]]);
31
+ return fromEntries(entries);
32
+ }
9
33
  };
10
34
  DocumentManagementAncillaryService = __decorate([
11
35
  Singleton()
@@ -1,125 +1,13 @@
1
- import type { RequireExactlyOne, Stringified } from 'type-fest';
2
- import type { CancellationSignal } from '../../../cancellation/token.js';
3
- import { type AfterResolveContext, afterResolve } from '../../../injector/index.js';
4
- import { Logger } from '../../../logger/logger.js';
5
- import { MessageBus } from '../../../message-bus/message-bus.js';
6
- import { ObjectStorage } from '../../../object-storage/index.js';
7
- import type { Query } from '../../../orm/index.js';
8
- import { type Transaction } from '../../../orm/server/index.js';
9
- import { Queue } from '../../../queue/queue.js';
10
- import type { OneOrMany, Record } from '../../../types.js';
11
- import { type Observable } from 'rxjs';
12
- import { type AddOrArchiveDocumentToOrFromCollectionParameters, type ApplyDocumentRequestsTemplateParameters, type ApproveDocumentRequestFileParameters, type AssignPropertyToTypeParameters, type CategoryAndTypesView, type CreateCollectionParameters, type CreateDocumentCategoryParameters, type CreateDocumentParameters, type CreateDocumentPropertyParameters, type CreateDocumentRequestFileParameters, type CreateDocumentRequestParameters, type CreateDocumentRequestTemplateParameters, type CreateDocumentRequestsTemplateParameters, type CreateDocumentTypeParameters, type DeleteDocumentRequestFileParameters, type DeleteDocumentRequestParameters, type DeleteDocumentRequestTemplateParameters, type DeleteDocumentRequestsTemplateParameters, Document, DocumentCategory, DocumentCollection, DocumentCollectionDocument, DocumentFile, type DocumentManagementData, DocumentProperty, DocumentPropertyDataType, DocumentPropertyValue, DocumentRequest, DocumentRequestAssignmentTask, DocumentRequestAssignmentTaskCollection, DocumentRequestAssignmentTaskPropertyValue, DocumentRequestCollection, DocumentRequestFile, DocumentRequestFilePropertyValue, DocumentRequestTemplate, DocumentRequestsTemplate, type DocumentRequestsTemplateData, DocumentType, DocumentTypeProperty, type LoadDataCollectionsMetadataParameters, type RejectDocumentRequestFileParameters, type RequestFilesStats, type SetDocumentPropertiesParameters, type UpdateDocumentParameters, type UpdateDocumentRequestFileParameters, type UpdateDocumentRequestParameters, type UpdateDocumentRequestTemplateParameters, type UpdateDocumentRequestsTemplateParameters } from '../../models/index.js';
13
- import { DocumentManagementAncillaryService } from './document-management-ancillary.service.js';
14
- type DocumentInformationExtractionPropertyResult = {
15
- propertyId: string;
16
- dataType: DocumentPropertyDataType;
17
- value: string | number | boolean;
18
- };
19
- export type DocumentInformationExtractionResult = {
20
- typeId: string | null;
21
- title: string;
22
- subtitle: string | null;
23
- pages: number | null;
24
- date: number | null;
25
- summary: string;
26
- tags: string[];
27
- properties: DocumentInformationExtractionPropertyResult[];
28
- };
29
- type ExtractionJobData = RequireExactlyOne<{
30
- documentId: string;
31
- requestFileId: string;
32
- requestAssignmentTaskId: string;
33
- }>;
34
- type AssignmentJobData = RequireExactlyOne<{
35
- requestAssignmentTaskId: string;
36
- }>;
37
- declare const DocumentManagementService_base: import("../../../types.js").Type<import("../../../orm/server/index.js").EntityRepository<DocumentCollection>>;
38
- export declare class DocumentManagementService extends DocumentManagementService_base {
1
+ import type { DocumentManagementData, DocumentRequestsTemplateData } from '../../../document-management/models/service-models/index.js';
2
+ import { Transactional } from '../../../orm/server/index.js';
3
+ import type { Record } from '../../../types.js';
4
+ import { DocumentCategory, DocumentType } from '../../models/index.js';
5
+ export declare class DocumentManagementService extends Transactional {
39
6
  #private;
40
- protected readonly ancillaryService: DocumentManagementAncillaryService;
41
- protected readonly documentCategoryService: import("../../../orm/server/index.js").EntityRepository<DocumentCategory>;
42
- protected readonly documentCollectionDocumentService: import("../../../orm/server/index.js").EntityRepository<DocumentCollectionDocument>;
43
- protected readonly documentFileService: import("../../../orm/server/index.js").EntityRepository<DocumentFile>;
44
- protected readonly documentPropertyService: import("../../../orm/server/index.js").EntityRepository<DocumentProperty>;
45
- protected readonly documentPropertyValueService: import("../../../orm/server/index.js").EntityRepository<DocumentPropertyValue>;
46
- protected readonly documentRequestAssignmentTaskCollectionService: import("../../../orm/server/index.js").EntityRepository<DocumentRequestAssignmentTaskCollection>;
47
- protected readonly documentRequestAssignmentTaskService: import("../../../orm/server/index.js").EntityRepository<DocumentRequestAssignmentTask>;
48
- protected readonly documentRequestCollectionService: import("../../../orm/server/index.js").EntityRepository<DocumentRequestCollection>;
49
- protected readonly documentRequestFilePropertyValueService: import("../../../orm/server/index.js").EntityRepository<DocumentRequestFilePropertyValue>;
50
- protected readonly documentRequestAssignmentTaskPropertyValueService: import("../../../orm/server/index.js").EntityRepository<DocumentRequestAssignmentTaskPropertyValue>;
51
- protected readonly documentRequestFileService: import("../../../orm/server/index.js").EntityRepository<DocumentRequestFile>;
52
- protected readonly documentRequestService: import("../../../orm/server/index.js").EntityRepository<DocumentRequest>;
53
- protected readonly documentRequestsTemplateService: import("../../../orm/server/index.js").EntityRepository<DocumentRequestsTemplate>;
54
- protected readonly documentRequestTemplateService: import("../../../orm/server/index.js").EntityRepository<DocumentRequestTemplate>;
55
- protected readonly documentService: import("../../../orm/server/index.js").EntityRepository<Document>;
56
- protected readonly documentTypePropertyService: import("../../../orm/server/index.js").EntityRepository<DocumentTypeProperty>;
57
- protected readonly documentTypeService: import("../../../orm/server/index.js").EntityRepository<DocumentType>;
58
- protected readonly fileObjectStorage: ObjectStorage;
59
- protected readonly extractionQueue: Queue<ExtractionJobData>;
60
- protected readonly assignmentQueue: Queue<AssignmentJobData>;
61
- protected readonly collectionChangeMessageBus: MessageBus<string[] | undefined>;
62
- protected readonly logger: Logger;
63
- [afterResolve](_: unknown, { cancellationSignal }: AfterResolveContext<any>): void;
64
- changes$(collectionIds: OneOrMany<string>): Observable<void>;
65
- processQueues(cancellationSignal: CancellationSignal): void;
66
- resolveNames<const T extends (DocumentCollection | string)[]>(...collectionsOrIds: T): Promise<Stringified<T>>;
67
- resolveNamesMap(...collectionsOrIds: (DocumentCollection | string)[]): Promise<Record<string, string>>;
68
- loadData(collectionIds: string[], collectionsMetadata?: LoadDataCollectionsMetadataParameters): Promise<DocumentManagementData>;
7
+ loadData(collectionIds: string[]): Promise<DocumentManagementData>;
69
8
  loadDocumentRequestsTemplateData(): Promise<DocumentRequestsTemplateData>;
70
- loadCategoriesAndTypes(): Promise<CategoryAndTypesView>;
71
- loadDocument(id: string): Promise<Document>;
72
- loadDocumentFile(id: string): Promise<DocumentFile>;
73
- loadType(id: string): Promise<DocumentType>;
74
- getFileContent(fileId: string): Promise<Uint8Array>;
75
- getFileContentStream(fileId: string): ReadableStream<Uint8Array>;
76
- getFileContentUrl(fileId: string, title: string | null, download?: boolean): Promise<string>;
77
- createCategory(parameters: CreateDocumentCategoryParameters): Promise<DocumentCategory>;
78
- createType(parameters: CreateDocumentTypeParameters): Promise<DocumentType>;
79
- createCollection(parameters?: CreateCollectionParameters): Promise<DocumentCollection>;
80
- collectionHasDocumentByFilter(collectionId: string, filter: Query<Document>): Promise<boolean>;
81
- getRequestFilesStats(collectionIds: OneOrMany<string>): Promise<RequestFilesStats>;
82
- createDocumentRequestsTemplate(parameters: CreateDocumentRequestsTemplateParameters): Promise<DocumentRequestsTemplate>;
83
- updateDocumentRequestsTemplate({ id, label, metadata }: UpdateDocumentRequestsTemplateParameters): Promise<DocumentRequestsTemplate>;
84
- applyDocumentRequestsTemplate({ id, collectionIds, metadata }: ApplyDocumentRequestsTemplateParameters): Promise<void>;
85
- deleteDocumentRequestsTemplate(parameters: DeleteDocumentRequestsTemplateParameters): Promise<DocumentRequestsTemplate>;
86
- createDocumentRequestTemplate(parameters: CreateDocumentRequestTemplateParameters): Promise<DocumentRequestTemplate>;
87
- updateDocumentRequestTemplate({ id, typeId, requiredFilesCount, comment, metadata }: UpdateDocumentRequestTemplateParameters): Promise<DocumentRequestTemplate>;
88
- deleteDocumentRequestTemplate(parameters: DeleteDocumentRequestTemplateParameters): Promise<DocumentRequestTemplate>;
89
- createDocument({ typeId, title, subtitle, pages, date, summary, tags, validated, originalFileName, collectionIds, properties, metadata }: CreateDocumentParameters, content: Uint8Array | ReadableStream<Uint8Array>): Promise<Document>;
90
- approveDocumentRequestFile({ id, approvalComment, documentMetadata, requestFileMetadata }: ApproveDocumentRequestFileParameters): Promise<Document>;
91
- rejectDocumentRequestFile({ id, approvalComment, metadata }: RejectDocumentRequestFileParameters): Promise<void>;
92
- updateDocumentRequestFile({ id, title, approvalComment, metadata }: UpdateDocumentRequestFileParameters): Promise<DocumentRequestFile>;
93
- deleteDocumentRequestFile({ id, metadata }: DeleteDocumentRequestFileParameters): Promise<void>;
94
- createDocumentFile(content: Uint8Array | ReadableStream<Uint8Array>, originalFileName: string | null, transaction?: Transaction): Promise<DocumentFile>;
95
- createDocumentRequestFile({ requestId, title, subtitle, date, summary, tags, originalFileName, metadata }: CreateDocumentRequestFileParameters, content: Uint8Array | ReadableStream<Uint8Array>): Promise<DocumentRequestFile>;
96
- createDocumentRequest(parameters: CreateDocumentRequestParameters, transaction?: Transaction): Promise<DocumentRequest>;
97
- createDocumentRequestAssignmentTask({ originalFileName, collectionIds }: {
98
- originalFileName: string;
99
- collectionIds: string[];
100
- }, content: Uint8Array | ReadableStream<Uint8Array>): Promise<DocumentRequestAssignmentTask>;
101
- updateDocument(parameters: UpdateDocumentParameters, transaction?: Transaction): Promise<void>;
102
- updateDocumentRequest(parameters: UpdateDocumentRequestParameters, transaction?: Transaction): Promise<void>;
103
- deleteDocumentRequest({ id, metadata }: DeleteDocumentRequestParameters, transaction?: Transaction): Promise<void>;
104
- setPropertyValues({ documentId, requestFileId, requestAssignmentTaskId, properties: items }: SetDocumentPropertiesParameters, transaction?: Transaction): Promise<void>;
105
- addDocumentToCollection(parameters: AddOrArchiveDocumentToOrFromCollectionParameters, transaction?: Transaction): Promise<void>;
106
- archiveDocument({ collectionId, documentId, metadata }: AddOrArchiveDocumentToOrFromCollectionParameters): Promise<void>;
107
- createProperty(parameters: CreateDocumentPropertyParameters): Promise<DocumentProperty>;
108
- assignPropertyToType(parameters: AssignPropertyToTypeParameters): Promise<void>;
109
- protected enrichDocument(documentId: string): Promise<void>;
110
- protected enrichDocumentRequestFile(requestFileId: string): Promise<void>;
111
- protected enrichDocumentRequestAssignmentTask(requestAssignmentTaskId: string): Promise<void>;
112
- protected assignDocumentRequest(requestAssignmentTaskId: string): Promise<void>;
113
- protected extractFileInformation(fileId: string, assumeTypeId?: string | null): Promise<DocumentInformationExtractionResult>;
114
- protected getDocumentFileContent(fileId: string): Promise<Uint8Array>;
115
- protected getDocumentFileContentStream(fileId: string): ReadableStream<Uint8Array>;
116
- protected getDocumentFileContentObjectUrl(title: string, file: DocumentFile, download: boolean): Promise<string>;
117
- protected publishChange({ collectionIds, documentIds, requestIds, requestFileIds, requestAssignmentTaskIds: requestAssignmentTasksIds }: {
118
- collectionIds?: string[];
119
- documentIds?: string[];
120
- requestIds?: string[];
121
- requestFileIds?: string[];
122
- requestAssignmentTaskIds?: string[];
123
- }): void;
9
+ initializeCategoriesAndTypes<CategoryKey extends string, TypeKey extends string>(categoryNames: Record<CategoryKey, string>, categoryParents: Record<CategoryKey, CategoryKey | null>, typeNames: Record<TypeKey, string>, typeCategories: Record<TypeKey, CategoryKey>): Promise<{
10
+ categories: Record<CategoryKey, DocumentCategory>;
11
+ types: Record<TypeKey, DocumentType>;
12
+ }>;
124
13
  }
125
- export {};