@tstdl/base 0.92.142 → 0.92.143

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 (223) hide show
  1. package/ai/ai-file.service.js +1 -1
  2. package/ai/ai.service.js +3 -3
  3. package/ai/types.d.ts +1 -1
  4. package/api/client/client.d.ts +1 -1
  5. package/api/client/client.js +10 -4
  6. package/api/server/middlewares/content-type.middleware.js +8 -7
  7. package/api/types.js +1 -1
  8. package/authentication/client/authentication.service.js +3 -3
  9. package/authentication/server/authentication-ancillary.service.d.ts +11 -1
  10. package/authentication/server/authentication-ancillary.service.js +1 -1
  11. package/authentication/server/authentication-secret-requirements.validator.js +1 -1
  12. package/authentication/server/authentication.api-controller.js +22 -10
  13. package/authentication/server/authentication.service.d.ts +11 -5
  14. package/authentication/server/authentication.service.js +97 -49
  15. package/authentication/server/drizzle.config.js +2 -2
  16. package/authentication/server/module.js +1 -1
  17. package/cancellation/token.d.ts +2 -2
  18. package/cancellation/token.js +4 -4
  19. package/cookie/cookie.js +2 -2
  20. package/document-management/api/document-management.api.d.ts +122 -24
  21. package/document-management/api/document-management.api.js +17 -0
  22. package/document-management/{server/services → authorization}/document-management-authorization.service.d.ts +7 -7
  23. package/document-management/authorization/document-management-authorization.service.js +2 -0
  24. package/document-management/authorization/index.d.ts +2 -0
  25. package/document-management/authorization/index.js +2 -0
  26. package/document-management/authorization/policies.d.ts +38 -0
  27. package/document-management/authorization/policies.js +2 -0
  28. package/document-management/index.d.ts +1 -0
  29. package/document-management/index.js +1 -0
  30. package/document-management/models/document-assignment-scope.model.d.ts +1 -0
  31. package/document-management/models/document-assignment-scope.model.js +10 -3
  32. package/document-management/models/document-assignment-task.model.d.ts +1 -0
  33. package/document-management/models/document-assignment-task.model.js +8 -2
  34. package/document-management/models/document-category.model.d.ts +1 -0
  35. package/document-management/models/document-category.model.js +7 -1
  36. package/document-management/models/document-collection-assignment.model.d.ts +1 -0
  37. package/document-management/models/document-collection-assignment.model.js +12 -4
  38. package/document-management/models/document-collection.model.d.ts +2 -0
  39. package/document-management/models/document-collection.model.js +8 -2
  40. package/document-management/models/document-management-table.d.ts +3 -1
  41. package/document-management/models/document-management-table.js +2 -2
  42. package/document-management/models/document-property-value.model.d.ts +1 -0
  43. package/document-management/models/document-property-value.model.js +9 -3
  44. package/document-management/models/document-property.model.d.ts +1 -0
  45. package/document-management/models/document-property.model.js +8 -2
  46. package/document-management/models/document-request-collection-assignment.model.d.ts +1 -0
  47. package/document-management/models/document-request-collection-assignment.model.js +12 -4
  48. package/document-management/models/document-request-template.d.ts +1 -0
  49. package/document-management/models/document-request-template.js +6 -1
  50. package/document-management/models/document-request.model.d.ts +1 -0
  51. package/document-management/models/document-request.model.js +10 -1
  52. package/document-management/models/document-requests-template.d.ts +1 -0
  53. package/document-management/models/document-requests-template.js +7 -3
  54. package/document-management/models/document-tag-assignment.model.d.ts +8 -0
  55. package/document-management/models/document-tag-assignment.model.js +40 -0
  56. package/document-management/models/document-tag.model.d.ts +6 -0
  57. package/document-management/models/{document-request-submission.model.js → document-tag.model.js} +14 -18
  58. package/document-management/models/document-type-property.model.d.ts +1 -0
  59. package/document-management/models/document-type-property.model.js +7 -2
  60. package/document-management/models/document-type-validation.model.d.ts +1 -0
  61. package/document-management/models/document-type-validation.model.js +8 -2
  62. package/document-management/models/document-type.model.d.ts +1 -0
  63. package/document-management/models/document-type.model.js +7 -2
  64. package/document-management/models/document-validation-definition.model.d.ts +1 -0
  65. package/document-management/models/document-validation-definition.model.js +7 -2
  66. package/document-management/models/document-validation-execution-related-document.model.d.ts +1 -0
  67. package/document-management/models/document-validation-execution-related-document.model.js +10 -3
  68. package/document-management/models/document-validation-execution.model.d.ts +1 -0
  69. package/document-management/models/document-validation-execution.model.js +9 -3
  70. package/document-management/models/document-workflow.model.d.ts +4 -1
  71. package/document-management/models/document-workflow.model.js +16 -4
  72. package/document-management/models/document.model.d.ts +2 -2
  73. package/document-management/models/document.model.js +9 -8
  74. package/document-management/models/index.d.ts +2 -1
  75. package/document-management/models/index.js +2 -1
  76. package/document-management/server/api/document-management.api.d.ts +4 -1
  77. package/document-management/server/api/document-management.api.js +113 -22
  78. package/document-management/server/configure.d.ts +2 -2
  79. package/document-management/server/configure.js +7 -7
  80. package/document-management/server/drizzle/0000_parallel_mantis.sql +359 -0
  81. package/document-management/server/drizzle/meta/0000_snapshot.json +784 -260
  82. package/document-management/server/drizzle/meta/_journal.json +2 -2
  83. package/document-management/server/module.d.ts +2 -2
  84. package/document-management/server/module.js +2 -2
  85. package/document-management/server/schemas.d.ts +6 -5
  86. package/document-management/server/schemas.js +12 -11
  87. package/document-management/server/services/document-category-type.service.d.ts +19 -10
  88. package/document-management/server/services/document-category-type.service.js +34 -27
  89. package/document-management/server/services/document-collection.service.d.ts +13 -6
  90. package/document-management/server/services/document-collection.service.js +36 -12
  91. package/document-management/server/services/document-file.service.d.ts +8 -7
  92. package/document-management/server/services/document-file.service.js +28 -33
  93. package/document-management/server/services/document-management-ai.service.d.ts +5 -4
  94. package/document-management/server/services/document-management-ai.service.js +51 -28
  95. package/document-management/server/services/document-management-ancillary.service.d.ts +3 -21
  96. package/document-management/server/services/document-management-ancillary.service.js +0 -24
  97. package/document-management/server/services/document-management-observation.service.d.ts +15 -0
  98. package/document-management/server/services/document-management-observation.service.js +160 -0
  99. package/document-management/server/services/document-management.service.d.ts +6 -5
  100. package/document-management/server/services/document-management.service.js +112 -86
  101. package/document-management/server/services/document-property.service.d.ts +15 -7
  102. package/document-management/server/services/document-property.service.js +52 -20
  103. package/document-management/server/services/document-request.service.d.ts +13 -24
  104. package/document-management/server/services/document-request.service.js +39 -62
  105. package/document-management/server/services/document-tag.service.d.ts +10 -0
  106. package/document-management/server/services/document-tag.service.js +59 -0
  107. package/document-management/server/services/document-validation.service.d.ts +8 -8
  108. package/document-management/server/services/document-validation.service.js +41 -40
  109. package/document-management/server/services/document-workflow.service.d.ts +6 -5
  110. package/document-management/server/services/document-workflow.service.js +54 -43
  111. package/document-management/server/services/document.service.d.ts +12 -11
  112. package/document-management/server/services/document.service.js +64 -40
  113. package/document-management/server/services/index.d.ts +2 -1
  114. package/document-management/server/services/index.js +2 -1
  115. package/document-management/server/services/singleton.js +2 -2
  116. package/document-management/server/validators/ai-validation-executor.js +4 -4
  117. package/document-management/service-models/document-collection-metadata.service-model.d.ts +14 -0
  118. package/document-management/service-models/document-collection-metadata.service-model.js +1 -0
  119. package/document-management/service-models/document-folders.view-model.d.ts +1 -7
  120. package/document-management/service-models/document-folders.view-model.js +3 -15
  121. package/document-management/service-models/document-management.view-model.d.ts +20 -6
  122. package/document-management/service-models/document-management.view-model.js +62 -8
  123. package/document-management/service-models/document.service-model.d.ts +14 -11
  124. package/document-management/service-models/document.service-model.js +11 -2
  125. package/document-management/service-models/enriched/enriched-document-assignment.view.d.ts +1 -1
  126. package/document-management/service-models/enriched/enriched-document-assignment.view.js +0 -2
  127. package/document-management/service-models/enriched/enriched-document-category.view.d.ts +11 -1
  128. package/document-management/service-models/enriched/enriched-document-category.view.js +44 -1
  129. package/document-management/service-models/enriched/enriched-document-collection.view.d.ts +4 -2
  130. package/document-management/service-models/enriched/enriched-document-collection.view.js +13 -3
  131. package/document-management/service-models/enriched/enriched-document-management-data.view.d.ts +2 -0
  132. package/document-management/service-models/enriched/enriched-document-management-data.view.js +4 -2
  133. package/document-management/service-models/enriched/enriched-document-request.view.d.ts +1 -0
  134. package/document-management/service-models/enriched/enriched-document-request.view.js +2 -0
  135. package/document-management/service-models/enriched/enriched-document-type.view.d.ts +9 -1
  136. package/document-management/service-models/enriched/enriched-document-type.view.js +28 -1
  137. package/document-management/service-models/enriched/enriched-document.view.d.ts +7 -6
  138. package/document-management/service-models/enriched/enriched-document.view.js +29 -6
  139. package/document-management/service-models/{normalized-requests-template-data.model.d.ts → enriched/enriched-requests-template-data.model.d.ts} +6 -6
  140. package/document-management/service-models/{normalized-requests-template-data.model.js → enriched/enriched-requests-template-data.model.js} +1 -1
  141. package/document-management/service-models/enriched/index.d.ts +1 -0
  142. package/document-management/service-models/enriched/index.js +1 -0
  143. package/document-management/service-models/index.d.ts +2 -2
  144. package/document-management/service-models/index.js +2 -2
  145. package/examples/document-management/categories-and-types.d.ts +33 -31
  146. package/examples/document-management/categories-and-types.js +33 -0
  147. package/examples/document-management/main.d.ts +5 -4
  148. package/examples/document-management/main.js +13 -7
  149. package/function/log.js +2 -2
  150. package/http/server/node/module.d.ts +4 -1
  151. package/http/server/node/module.js +10 -1
  152. package/http/server/node/node-http-server.d.ts +3 -6
  153. package/http/server/node/node-http-server.js +68 -67
  154. package/injector/inject.js +6 -6
  155. package/injector/injector.js +3 -3
  156. package/jsx/is-component-class.js +1 -1
  157. package/key-value-store/key-value.store.d.ts +38 -7
  158. package/key-value-store/key-value.store.js +2 -1
  159. package/key-value-store/mongo/mongo-key-value.store.d.ts +1 -0
  160. package/key-value-store/mongo/mongo-key-value.store.js +14 -5
  161. package/key-value-store/postgres/drizzle/0000_shocking_slipstream.sql +12 -0
  162. package/key-value-store/postgres/drizzle/meta/0000_snapshot.json +97 -0
  163. package/key-value-store/postgres/drizzle/meta/_journal.json +13 -0
  164. package/key-value-store/postgres/drizzle.config.d.ts +2 -0
  165. package/key-value-store/postgres/drizzle.config.js +11 -0
  166. package/key-value-store/postgres/index.d.ts +2 -0
  167. package/key-value-store/postgres/index.js +2 -0
  168. package/key-value-store/postgres/key-value-store.service.d.ts +17 -0
  169. package/key-value-store/postgres/key-value-store.service.js +65 -0
  170. package/key-value-store/postgres/models/index.d.ts +2 -0
  171. package/key-value-store/postgres/models/index.js +2 -0
  172. package/key-value-store/postgres/models/key-value.model.d.ts +7 -0
  173. package/key-value-store/postgres/models/key-value.model.js +35 -0
  174. package/key-value-store/postgres/models/schemas.d.ts +3 -0
  175. package/key-value-store/postgres/models/schemas.js +4 -0
  176. package/key-value-store/postgres/module.d.ts +6 -0
  177. package/key-value-store/postgres/module.js +23 -0
  178. package/lock/web/web-lock.d.ts +0 -1
  179. package/lock/web/web-lock.js +6 -13
  180. package/orm/data-types/timestamp.js +1 -1
  181. package/orm/decorators.d.ts +37 -29
  182. package/orm/decorators.js +44 -24
  183. package/orm/entity.d.ts +1 -0
  184. package/orm/query.d.ts +10 -2
  185. package/orm/repository.types.d.ts +2 -1
  186. package/orm/schemas/json.d.ts +12 -6
  187. package/orm/schemas/json.js +12 -5
  188. package/orm/server/database.js +5 -2
  189. package/orm/server/drizzle/schema-converter.js +40 -11
  190. package/orm/server/query-converter.d.ts +2 -1
  191. package/orm/server/query-converter.js +57 -34
  192. package/orm/server/repository.d.ts +26 -43
  193. package/orm/server/repository.js +106 -39
  194. package/orm/server/transaction.d.ts +2 -1
  195. package/orm/server/transaction.js +3 -0
  196. package/orm/server/transactional.d.ts +5 -1
  197. package/orm/server/transactional.js +34 -4
  198. package/package.json +14 -11
  199. package/process/spawn.js +0 -1
  200. package/promise/deferred-promise.d.ts +4 -3
  201. package/promise/deferred-promise.js +13 -5
  202. package/queue/postgres/queue.js +8 -8
  203. package/reflection/utils.js +3 -3
  204. package/schema/decorators/class.js +0 -1
  205. package/schema/decorators/schema.js +1 -1
  206. package/schema/schemas/boolean.d.ts +1 -1
  207. package/schema/schemas/boolean.js +2 -2
  208. package/schema/schemas/number.js +3 -3
  209. package/schema/schemas/object.js +5 -6
  210. package/sse/server-sent-events-source.js +4 -1
  211. package/utils/compression.js +9 -9
  212. package/utils/date-time.d.ts +1 -0
  213. package/utils/date-time.js +18 -4
  214. package/utils/equals.d.ts +7 -0
  215. package/utils/equals.js +17 -2
  216. package/utils/function/memoize.js +10 -2
  217. package/utils/jwt.js +3 -3
  218. package/utils/object/property-name.d.ts +2 -2
  219. package/utils/timing.d.ts +2 -2
  220. package/utils/timing.js +12 -12
  221. package/document-management/models/document-request-submission.model.d.ts +0 -7
  222. package/document-management/server/drizzle/0000_moaning_luckman.sql +0 -305
  223. package/document-management/server/services/document-management-authorization.service.js +0 -28
@@ -4,7 +4,11 @@ import { Document, DocumentAssignmentTarget, DocumentCategory, DocumentCollectio
4
4
  export const metadataParameterSchema = optional(partial(pick(EntityMetadata, 'attributes')));
5
5
  export const metadataParameterObjectSchema = object({ metadata: metadataParameterSchema });
6
6
  export const setDocumentPropertyParametersSchema = assign(pick(DocumentPropertyValue, ['propertyId']), object({ value: union(string(), number(), boolean(), nullable(never())) }), metadataParameterObjectSchema);
7
- export const createDocumentParametersSchema = assign(partial(pick(Document, ['typeId', 'title', 'subtitle', 'date', 'summary', 'tags', 'approval', 'comment', 'originalFileName'])), object({
7
+ export const updateDocumentCollectionsParametersSchema = object({
8
+ assign: optional(array(string())),
9
+ archive: optional(array(string())),
10
+ });
11
+ export const createDocumentParametersSchema = assign(partial(pick(Document, ['typeId', 'title', 'subtitle', 'date', 'summary', 'approval', 'comment', 'originalFileName'])), object({
8
12
  uploadId: string(),
9
13
  assignment: union(object({ collections: oneOrMany(string(), { minimum: 1 }) }), object({ request: string() }), object({
10
14
  automatic: object({
@@ -13,9 +17,14 @@ export const createDocumentParametersSchema = assign(partial(pick(Document, ['ty
13
17
  target: enumeration(DocumentAssignmentTarget),
14
18
  }),
15
19
  })),
20
+ tags: array(string()),
21
+ properties: optional(array(setDocumentPropertyParametersSchema)),
22
+ }), metadataParameterObjectSchema);
23
+ export const updateDocumentParametersSchema = assign(pick(Document, ['id']), partial(pick(Document, ['title', 'subtitle', 'date', 'comment', 'typeId'])), object({
24
+ tags: optional(array(string())),
16
25
  properties: optional(array(setDocumentPropertyParametersSchema)),
26
+ collections: optional(updateDocumentCollectionsParametersSchema),
17
27
  }), metadataParameterObjectSchema);
18
- export const updateDocumentParametersSchema = assign(pick(Document, ['id']), partial(omit(Document, ['id', 'metadata'])), object({ properties: optional(array(setDocumentPropertyParametersSchema)) }), metadataParameterObjectSchema);
19
28
  export const approveDocumentParametersSchema = assign(pick(Document, ['id', 'comment']), metadataParameterObjectSchema);
20
29
  export const rejectDocumentParametersSchema = assign(pick(Document, ['id', 'comment']), metadataParameterObjectSchema);
21
30
  export const createDocumentRequestsTemplateParametersSchema = assign(pick(DocumentRequestsTemplate, ['label', 'description']), metadataParameterObjectSchema);
@@ -4,7 +4,7 @@ import type { DocumentAssignmentTaskView, DocumentAssignmentView, DocumentCollec
4
4
  import type { EnrichedDocumentCollection } from './enriched-document-collection.view.js';
5
5
  import type { EnrichedDocumentManagementData } from './enriched-document-management-data.view.js';
6
6
  import type { EnrichedDocument } from './enriched-document.view.js';
7
- export declare class EnrichedDocumentCollectionAssignment implements TypedOmit<DocumentCollectionAssignment, 'id' | 'collectionId' | 'documentId' | 'metadata'> {
7
+ export declare class EnrichedDocumentCollectionAssignment implements TypedOmit<DocumentCollectionAssignment, 'id' | 'tenantId' | 'collectionId' | 'documentId' | 'metadata'> {
8
8
  #private;
9
9
  get collection(): EnrichedDocumentCollection;
10
10
  readonly document: EnrichedDocument;
@@ -15,7 +15,6 @@ export class EnrichedDocumentCollectionAssignment {
15
15
  }
16
16
  }
17
17
  export class EnrichedDocumentAssignment {
18
- #data;
19
18
  #collections;
20
19
  #document;
21
20
  get collections() {
@@ -26,7 +25,6 @@ export class EnrichedDocumentAssignment {
26
25
  }
27
26
  assignmentTask;
28
27
  constructor(data, document, assignment) {
29
- this.#data = data;
30
28
  this.#document = document;
31
29
  this.#collections = assignment.collections.map((assignment) => new EnrichedDocumentCollectionAssignment(data, assignment, document));
32
30
  this.assignmentTask = assignment.assignmentTask;
@@ -1,14 +1,24 @@
1
+ import type { TypedOmit } from '../../../types.js';
1
2
  import type { DocumentCategory } from '../../models/index.js';
2
3
  import type { EnrichedDocumentManagementData } from './enriched-document-management-data.view.js';
3
4
  import { EnrichedDocumentType } from './enriched-document-type.view.js';
4
- export declare class EnrichedDocumentCategory implements Pick<DocumentCategory, 'id' | 'label'> {
5
+ import type { EnrichedDocument } from './enriched-document.view.js';
6
+ export declare class EnrichedDocumentCategory implements TypedOmit<DocumentCategory, 'parentId' | 'metadata'> {
5
7
  #private;
6
8
  readonly id: string;
9
+ readonly tenantId: string | null;
7
10
  readonly label: string;
8
11
  readonly parent: EnrichedDocumentCategory | null;
12
+ readonly helper: {
13
+ normalizedLabel: string;
14
+ };
9
15
  get rootCategory(): EnrichedDocumentCategory;
16
+ get parents(): EnrichedDocumentCategory[];
10
17
  get children(): EnrichedDocumentCategory[];
11
18
  get childrenDeep(): EnrichedDocumentCategory[];
12
19
  get types(): EnrichedDocumentType[];
20
+ get typesDeep(): EnrichedDocumentType[];
21
+ get documents(): EnrichedDocument[];
22
+ get documentsDeep(): EnrichedDocument[];
13
23
  constructor(data: EnrichedDocumentManagementData, category: DocumentCategory, parent: EnrichedDocumentCategory | null);
14
24
  }
@@ -8,15 +8,28 @@ var __metadata = (this && this.__metadata) || function (k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
10
  import { Memoize } from '../../../utils/function/memoize.js';
11
+ import { lazyObject } from '../../../utils/object/index.js';
12
+ import { normalizeText } from '../../../utils/string/index.js';
13
+ import { isNull } from '../../../utils/type-guards.js';
11
14
  import { EnrichedDocumentType } from './enriched-document-type.view.js';
12
15
  export class EnrichedDocumentCategory {
13
16
  #data;
14
17
  id;
18
+ tenantId;
15
19
  label;
16
20
  parent;
21
+ helper = lazyObject({
22
+ normalizedLabel: () => normalizeText(this.label),
23
+ });
17
24
  get rootCategory() {
18
25
  return (this.parent?.rootCategory ?? this);
19
26
  }
27
+ get parents() {
28
+ if (isNull(this.parent)) {
29
+ return [];
30
+ }
31
+ return [this.parent, ...this.parent.parents];
32
+ }
20
33
  get children() {
21
34
  return this.#data.rawData.categories.filter((category) => category.parentId == this.id).map((category) => new EnrichedDocumentCategory(this.#data, category, this));
22
35
  }
@@ -24,11 +37,21 @@ export class EnrichedDocumentCategory {
24
37
  return this.children.flatMap((child) => [child, ...child.childrenDeep]);
25
38
  }
26
39
  get types() {
27
- return this.#data.rawData.types.filter((type) => type.categoryId == this.id).map((type) => new EnrichedDocumentType(type, this));
40
+ return this.#data.rawData.types.filter((type) => type.categoryId == this.id).map((type) => new EnrichedDocumentType(this.#data, type, this));
41
+ }
42
+ get typesDeep() {
43
+ return [this, ...this.childrenDeep].flatMap((category) => category.types);
44
+ }
45
+ get documents() {
46
+ return this.#data.documents.filter((document) => document.type?.category.id == this.id);
47
+ }
48
+ get documentsDeep() {
49
+ return [this, ...this.childrenDeep].flatMap((category) => category.documentsDeep);
28
50
  }
29
51
  constructor(data, category, parent) {
30
52
  this.#data = data;
31
53
  this.id = category.id;
54
+ this.tenantId = category.tenantId;
32
55
  this.label = category.label;
33
56
  this.parent = parent;
34
57
  }
@@ -38,6 +61,11 @@ __decorate([
38
61
  __metadata("design:type", EnrichedDocumentCategory),
39
62
  __metadata("design:paramtypes", [])
40
63
  ], EnrichedDocumentCategory.prototype, "rootCategory", null);
64
+ __decorate([
65
+ Memoize(),
66
+ __metadata("design:type", Array),
67
+ __metadata("design:paramtypes", [])
68
+ ], EnrichedDocumentCategory.prototype, "parents", null);
41
69
  __decorate([
42
70
  Memoize(),
43
71
  __metadata("design:type", Array),
@@ -53,3 +81,18 @@ __decorate([
53
81
  __metadata("design:type", Array),
54
82
  __metadata("design:paramtypes", [])
55
83
  ], EnrichedDocumentCategory.prototype, "types", null);
84
+ __decorate([
85
+ Memoize(),
86
+ __metadata("design:type", Array),
87
+ __metadata("design:paramtypes", [])
88
+ ], EnrichedDocumentCategory.prototype, "typesDeep", null);
89
+ __decorate([
90
+ Memoize(),
91
+ __metadata("design:type", Array),
92
+ __metadata("design:paramtypes", [])
93
+ ], EnrichedDocumentCategory.prototype, "documents", null);
94
+ __decorate([
95
+ Memoize(),
96
+ __metadata("design:type", Array),
97
+ __metadata("design:paramtypes", [])
98
+ ], EnrichedDocumentCategory.prototype, "documentsDeep", null);
@@ -7,9 +7,11 @@ import { type RequestsStats } from './enriched.js';
7
7
  export declare class EnrichedDocumentCollection implements TypedOmit<DocumentCollectionView, 'parentId' | 'metadata'> {
8
8
  #private;
9
9
  readonly id: string;
10
+ readonly tenantId: string;
11
+ readonly parentId: string | null;
10
12
  readonly name: string;
11
13
  readonly group: string | null;
12
- readonly parent: EnrichedDocumentCollection | null;
14
+ get parent(): EnrichedDocumentCollection | null;
13
15
  get children(): EnrichedDocumentCollection[];
14
16
  get childrenDeep(): EnrichedDocumentCollection[];
15
17
  get documents(): EnrichedDocument[];
@@ -18,5 +20,5 @@ export declare class EnrichedDocumentCollection implements TypedOmit<DocumentCol
18
20
  get requestsDeep(): EnrichedDocumentRequest[];
19
21
  get requestsStats(): RequestsStats;
20
22
  get requestsStatsDeep(): RequestsStats;
21
- constructor(data: EnrichedDocumentManagementData, collectionView: DocumentCollectionView, parent: EnrichedDocumentCollection | null);
23
+ constructor(data: EnrichedDocumentManagementData, collectionView: DocumentCollectionView);
22
24
  }
@@ -12,9 +12,13 @@ import { calculateRequestsStats, mergeRequestsStats } from './enriched.js';
12
12
  export class EnrichedDocumentCollection {
13
13
  #data;
14
14
  id;
15
+ tenantId;
16
+ parentId;
15
17
  name;
16
18
  group;
17
- parent;
19
+ get parent() {
20
+ return this.#data.collections.find((collection) => collection.id == this.parentId) ?? null;
21
+ }
18
22
  get children() {
19
23
  return this.#data.collections.filter((collection) => collection.parent?.id == this.id);
20
24
  }
@@ -39,14 +43,20 @@ export class EnrichedDocumentCollection {
39
43
  get requestsStatsDeep() {
40
44
  return mergeRequestsStats(this.children.map((child) => child.requestsStatsDeep));
41
45
  }
42
- constructor(data, collectionView, parent) {
46
+ constructor(data, collectionView) {
43
47
  this.#data = data;
44
48
  this.id = collectionView.id;
49
+ this.tenantId = collectionView.tenantId;
50
+ this.parentId = collectionView.parentId;
45
51
  this.name = collectionView.name;
46
52
  this.group = collectionView.group;
47
- this.parent = parent;
48
53
  }
49
54
  }
55
+ __decorate([
56
+ Memoize(),
57
+ __metadata("design:type", Object),
58
+ __metadata("design:paramtypes", [])
59
+ ], EnrichedDocumentCollection.prototype, "parent", null);
50
60
  __decorate([
51
61
  Memoize(),
52
62
  __metadata("design:type", Array),
@@ -19,6 +19,8 @@ export declare class EnrichedDocumentManagementData {
19
19
  requests: Map<string, import("../document-management.view-model.js").DocumentRequestView>;
20
20
  categories: Map<string, import("../../index.js").DocumentCategory>;
21
21
  types: Map<string, import("../../index.js").DocumentType>;
22
+ properties: Map<string, import("../document-management.view-model.js").DocumentPropertyView>;
23
+ tags: Map<string, import("../../index.js").DocumentTag>;
22
24
  };
23
25
  readonly maps: {
24
26
  collections: Map<string, EnrichedDocumentCollection>;
@@ -42,6 +42,8 @@ export class EnrichedDocumentManagementData {
42
42
  requests: () => getEntityMap(this.rawData.requests),
43
43
  categories: () => getEntityMap(this.rawData.categories),
44
44
  types: () => getEntityMap(this.rawData.types),
45
+ properties: () => getEntityMap(this.rawData.properties),
46
+ tags: () => getEntityMap(this.rawData.tags),
45
47
  });
46
48
  maps = lazyObject({
47
49
  collections: () => getEntityMap(this.collections),
@@ -54,10 +56,10 @@ export class EnrichedDocumentManagementData {
54
56
  return this.rawData.collections.map((collection) => collection.id);
55
57
  }
56
58
  get rootCollections() {
57
- return this.rawData.collections.filter((collection) => isNull(collection.parentId)).map((collection) => new EnrichedDocumentCollection(this, collection, null));
59
+ return this.rootCollections.filter((collection) => isNull(collection.parent));
58
60
  }
59
61
  get collections() {
60
- return this.rootCollections.flatMap((collection) => [collection, ...collection.childrenDeep]);
62
+ return this.rawData.collections.map((collection) => new EnrichedDocumentCollection(this, collection));
61
63
  }
62
64
  get collectionGroups() {
63
65
  const groups = [...group(this.collections, (collection) => collection.group)];
@@ -8,6 +8,7 @@ import type { EnrichedDocument } from './enriched-document.view.js';
8
8
  export declare class EnrichedDocumentRequest implements TypedOmit<DocumentRequestView, 'typeId' | 'documentId' | 'collectionIds' | 'metadata'> {
9
9
  #private;
10
10
  readonly id: string;
11
+ readonly tenantId: string;
11
12
  readonly comment: string | null;
12
13
  readonly state: DocumentRequestState;
13
14
  get type(): EnrichedDocumentType;
@@ -13,6 +13,7 @@ export class EnrichedDocumentRequest {
13
13
  #data;
14
14
  #documentRequestView;
15
15
  id;
16
+ tenantId;
16
17
  comment;
17
18
  state;
18
19
  get type() {
@@ -31,6 +32,7 @@ export class EnrichedDocumentRequest {
31
32
  this.#data = data;
32
33
  this.#documentRequestView = request;
33
34
  this.id = request.id;
35
+ this.tenantId = request.tenantId;
34
36
  this.comment = request.comment;
35
37
  this.state = request.state;
36
38
  }
@@ -1,9 +1,17 @@
1
1
  import type { TypedOmit } from '../../../types.js';
2
2
  import type { DocumentType } from '../../models/index.js';
3
+ import type { DocumentPropertyView } from '../document-management.view-model.js';
3
4
  import type { EnrichedDocumentCategory } from './enriched-document-category.view.js';
5
+ import type { EnrichedDocumentManagementData } from './enriched-document-management-data.view.js';
4
6
  export declare class EnrichedDocumentType implements TypedOmit<DocumentType, 'categoryId' | 'metadata'> {
7
+ #private;
5
8
  readonly id: string;
9
+ readonly tenantId: string | null;
6
10
  readonly label: string;
7
11
  readonly category: EnrichedDocumentCategory;
8
- constructor(type: DocumentType, category: EnrichedDocumentCategory);
12
+ readonly helper: {
13
+ normalizedLabel: string;
14
+ };
15
+ get properties(): DocumentPropertyView[];
16
+ constructor(data: EnrichedDocumentManagementData, type: DocumentType, category: EnrichedDocumentCategory);
9
17
  }
@@ -1,10 +1,37 @@
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 { Memoize } from '../../../utils/function/memoize.js';
11
+ import { lazyObject } from '../../../utils/object/index.js';
12
+ import { normalizeText } from '../../../utils/string/index.js';
1
13
  export class EnrichedDocumentType {
14
+ #data;
2
15
  id;
16
+ tenantId;
3
17
  label;
4
18
  category;
5
- constructor(type, category) {
19
+ helper = lazyObject({
20
+ normalizedLabel: () => normalizeText(this.label),
21
+ });
22
+ get properties() {
23
+ return this.#data.rawData.properties.filter((property) => property.typeIds.includes(this.id));
24
+ }
25
+ constructor(data, type, category) {
26
+ this.#data = data;
6
27
  this.id = type.id;
28
+ this.tenantId = type.tenantId;
7
29
  this.label = type.label;
8
30
  this.category = category;
9
31
  }
10
32
  }
33
+ __decorate([
34
+ Memoize(),
35
+ __metadata("design:type", Array),
36
+ __metadata("design:paramtypes", [])
37
+ ], EnrichedDocumentType.prototype, "properties", null);
@@ -1,30 +1,31 @@
1
1
  import type { EntityMetadata } from '../../../orm/entity.js';
2
2
  import type { TypedOmit } from '../../../types.js';
3
- import type { DocumentApproval, DocumentValidationExecution, DocumentWorkflow } from '../../models/index.js';
3
+ import type { DocumentApproval, DocumentTag, DocumentValidationExecution, DocumentWorkflow } from '../../models/index.js';
4
4
  import type { DocumentPropertyValueView, DocumentView } from '../document-management.view-model.js';
5
5
  import { EnrichedDocumentAssignment } from './enriched-document-assignment.view.js';
6
6
  import type { EnrichedDocumentManagementData } from './enriched-document-management-data.view.js';
7
7
  import type { EnrichedDocumentType } from './enriched-document-type.view.js';
8
- export declare class EnrichedDocument implements TypedOmit<DocumentView, 'typeId' | 'assignment' | 'createUserId'> {
8
+ export declare class EnrichedDocument implements TypedOmit<DocumentView, 'typeId' | 'assignment' | 'tagIds' | 'createUserId'> {
9
9
  #private;
10
10
  readonly id: string;
11
+ readonly tenantId: string;
11
12
  readonly title: string | null;
12
13
  readonly subtitle: string | null;
13
14
  readonly pages: number | null;
14
15
  readonly date: number | null;
15
16
  readonly summary: string | null;
16
- readonly tags: string[] | null;
17
17
  readonly approval: DocumentApproval;
18
18
  readonly comment: string | null;
19
19
  readonly originalFileName: string | null;
20
20
  readonly mimeType: string;
21
21
  readonly hash: string;
22
22
  readonly size: number;
23
- readonly properties: DocumentPropertyValueView[];
24
- readonly currentWorkflow: DocumentWorkflow | null;
25
- readonly validations: DocumentValidationExecution[] | null;
23
+ readonly workflows: DocumentWorkflow[];
24
+ readonly validations: DocumentValidationExecution[];
26
25
  readonly metadata: EntityMetadata;
27
26
  get type(): EnrichedDocumentType | null;
28
27
  get assignments(): EnrichedDocumentAssignment;
28
+ get tags(): DocumentTag[];
29
+ get properties(): DocumentPropertyValueView[];
29
30
  constructor(data: EnrichedDocumentManagementData, document: DocumentView);
30
31
  }
@@ -14,20 +14,19 @@ export class EnrichedDocument {
14
14
  #data;
15
15
  #documentView;
16
16
  id;
17
+ tenantId;
17
18
  title;
18
19
  subtitle;
19
20
  pages;
20
21
  date;
21
22
  summary;
22
- tags;
23
23
  approval;
24
24
  comment;
25
25
  originalFileName;
26
26
  mimeType;
27
27
  hash;
28
28
  size;
29
- properties;
30
- currentWorkflow;
29
+ workflows;
31
30
  validations;
32
31
  metadata;
33
32
  get type() {
@@ -39,24 +38,38 @@ export class EnrichedDocument {
39
38
  get assignments() {
40
39
  return new EnrichedDocumentAssignment(this.#data, this, this.#documentView.assignment);
41
40
  }
41
+ get tags() {
42
+ return this.#documentView.tagIds.map((tagId) => assertDefinedPass(this.#data.rawDataMaps.tags.get(tagId), `Tag ${tagId} not found.`));
43
+ }
44
+ get properties() {
45
+ return this.#documentView.properties.map((documentPropertyValueView) => {
46
+ const property = assertDefinedPass(this.#data.rawDataMaps.properties.get(documentPropertyValueView.propertyId), `Property ${documentPropertyValueView.propertyId} not found.`);
47
+ return {
48
+ documentId: this.id,
49
+ propertyId: property.id,
50
+ label: property.label,
51
+ dataType: property.dataType,
52
+ value: documentPropertyValueView.value ?? null,
53
+ };
54
+ });
55
+ }
42
56
  constructor(data, document) {
43
57
  this.#data = data;
44
58
  this.#documentView = document;
45
59
  this.id = document.id;
60
+ this.tenantId = document.tenantId;
46
61
  this.title = document.title;
47
62
  this.subtitle = document.subtitle;
48
63
  this.pages = document.pages;
49
64
  this.date = document.date;
50
65
  this.summary = document.summary;
51
- this.tags = document.tags;
52
66
  this.approval = document.approval;
53
67
  this.comment = document.comment;
54
68
  this.originalFileName = document.originalFileName;
55
69
  this.mimeType = document.mimeType;
56
70
  this.hash = document.hash;
57
71
  this.size = document.size;
58
- this.properties = document.properties;
59
- this.currentWorkflow = document.currentWorkflow;
72
+ this.workflows = document.workflows;
60
73
  this.validations = document.validations;
61
74
  this.metadata = document.metadata;
62
75
  }
@@ -71,3 +84,13 @@ __decorate([
71
84
  __metadata("design:type", EnrichedDocumentAssignment),
72
85
  __metadata("design:paramtypes", [])
73
86
  ], EnrichedDocument.prototype, "assignments", null);
87
+ __decorate([
88
+ Memoize(),
89
+ __metadata("design:type", Array),
90
+ __metadata("design:paramtypes", [])
91
+ ], EnrichedDocument.prototype, "tags", null);
92
+ __decorate([
93
+ Memoize(),
94
+ __metadata("design:type", Array),
95
+ __metadata("design:paramtypes", [])
96
+ ], EnrichedDocument.prototype, "properties", null);
@@ -1,9 +1,9 @@
1
- import type { TypedOmit } from '../../types.js';
2
- import type { DocumentRequestTemplate } from '../models/index.js';
3
- import type { DocumentRequestsTemplateData, DocumentRequestsTemplateView } from './document-requests-template.view-model.js';
4
- import type { EnrichedDocumentCategory } from './enriched/enriched-document-category.view.js';
5
- import type { EnrichedDocumentManagementData } from './enriched/enriched-document-management-data.view.js';
6
- import type { EnrichedDocumentType } from './enriched/enriched-document-type.view.js';
1
+ import type { TypedOmit } from '../../../types.js';
2
+ import type { DocumentRequestTemplate } from '../../models/index.js';
3
+ import type { DocumentRequestsTemplateData, DocumentRequestsTemplateView } from '../document-requests-template.view-model.js';
4
+ import type { EnrichedDocumentCategory } from '../enriched/enriched-document-category.view.js';
5
+ import type { EnrichedDocumentManagementData } from '../enriched/enriched-document-management-data.view.js';
6
+ import type { EnrichedDocumentType } from '../enriched/enriched-document-type.view.js';
7
7
  export type EnrichedDocumentRequestsTemplateData = TypedOmit<DocumentRequestsTemplateData, 'templates'> & {
8
8
  templates: EnrichedDocumentRequestsTemplateView[];
9
9
  categories: EnrichedDocumentCategory[];
@@ -1,4 +1,4 @@
1
- import { assertDefinedPass } from '../../utils/type-guards.js';
1
+ import { assertDefinedPass } from '../../../utils/type-guards.js';
2
2
  export function toEnrichedDocumentRequestsTemplateData(templateData, documentManagementData) {
3
3
  return {
4
4
  templates: templateData.templates.map((template) => ({
@@ -5,4 +5,5 @@ export * from './enriched-document-management-data.view.js';
5
5
  export * from './enriched-document-request.view.js';
6
6
  export * from './enriched-document-type.view.js';
7
7
  export * from './enriched-document.view.js';
8
+ export * from './enriched-requests-template-data.model.js';
8
9
  export * from './enriched.js';
@@ -5,4 +5,5 @@ export * from './enriched-document-management-data.view.js';
5
5
  export * from './enriched-document-request.view.js';
6
6
  export * from './enriched-document-type.view.js';
7
7
  export * from './enriched-document.view.js';
8
+ export * from './enriched-requests-template-data.model.js';
8
9
  export * from './enriched.js';
@@ -1,8 +1,8 @@
1
1
  export * from './categories-and-types.view-model.js';
2
+ export * from './document-collection-metadata.service-model.js';
2
3
  export * from './document-folders.view-model.js';
4
+ export * from './document-management.view-model.js';
3
5
  export * from './document-requests-template.view-model.js';
4
6
  export * from './document.service-model.js';
5
- export * from './document-management.view-model.js';
6
7
  export * from './enriched/index.js';
7
- export * from './normalized-requests-template-data.model.js';
8
8
  export * from './stats.view-model.js';
@@ -1,8 +1,8 @@
1
1
  export * from './categories-and-types.view-model.js';
2
+ export * from './document-collection-metadata.service-model.js';
2
3
  export * from './document-folders.view-model.js';
4
+ export * from './document-management.view-model.js';
3
5
  export * from './document-requests-template.view-model.js';
4
6
  export * from './document.service-model.js';
5
- export * from './document-management.view-model.js';
6
7
  export * from './enriched/index.js';
7
- export * from './normalized-requests-template-data.model.js';
8
8
  export * from './stats.view-model.js';