@tstdl/base 0.92.141 → 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 (224) 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/css/css-variables.js +1 -1
  21. package/document-management/api/document-management.api.d.ts +122 -24
  22. package/document-management/api/document-management.api.js +17 -0
  23. package/document-management/{server/services → authorization}/document-management-authorization.service.d.ts +7 -7
  24. package/document-management/authorization/document-management-authorization.service.js +2 -0
  25. package/document-management/authorization/index.d.ts +2 -0
  26. package/document-management/authorization/index.js +2 -0
  27. package/document-management/authorization/policies.d.ts +38 -0
  28. package/document-management/authorization/policies.js +2 -0
  29. package/document-management/index.d.ts +1 -0
  30. package/document-management/index.js +1 -0
  31. package/document-management/models/document-assignment-scope.model.d.ts +1 -0
  32. package/document-management/models/document-assignment-scope.model.js +10 -3
  33. package/document-management/models/document-assignment-task.model.d.ts +1 -0
  34. package/document-management/models/document-assignment-task.model.js +8 -2
  35. package/document-management/models/document-category.model.d.ts +1 -0
  36. package/document-management/models/document-category.model.js +7 -1
  37. package/document-management/models/document-collection-assignment.model.d.ts +1 -0
  38. package/document-management/models/document-collection-assignment.model.js +12 -4
  39. package/document-management/models/document-collection.model.d.ts +2 -0
  40. package/document-management/models/document-collection.model.js +8 -2
  41. package/document-management/models/document-management-table.d.ts +3 -1
  42. package/document-management/models/document-management-table.js +2 -2
  43. package/document-management/models/document-property-value.model.d.ts +1 -0
  44. package/document-management/models/document-property-value.model.js +9 -3
  45. package/document-management/models/document-property.model.d.ts +1 -0
  46. package/document-management/models/document-property.model.js +8 -2
  47. package/document-management/models/document-request-collection-assignment.model.d.ts +1 -0
  48. package/document-management/models/document-request-collection-assignment.model.js +12 -4
  49. package/document-management/models/document-request-template.d.ts +1 -0
  50. package/document-management/models/document-request-template.js +6 -1
  51. package/document-management/models/document-request.model.d.ts +1 -0
  52. package/document-management/models/document-request.model.js +10 -1
  53. package/document-management/models/document-requests-template.d.ts +1 -0
  54. package/document-management/models/document-requests-template.js +7 -3
  55. package/document-management/models/document-tag-assignment.model.d.ts +8 -0
  56. package/document-management/models/document-tag-assignment.model.js +40 -0
  57. package/document-management/models/document-tag.model.d.ts +6 -0
  58. package/document-management/models/{document-request-submission.model.js → document-tag.model.js} +14 -18
  59. package/document-management/models/document-type-property.model.d.ts +1 -0
  60. package/document-management/models/document-type-property.model.js +7 -2
  61. package/document-management/models/document-type-validation.model.d.ts +1 -0
  62. package/document-management/models/document-type-validation.model.js +8 -2
  63. package/document-management/models/document-type.model.d.ts +1 -0
  64. package/document-management/models/document-type.model.js +7 -2
  65. package/document-management/models/document-validation-definition.model.d.ts +1 -0
  66. package/document-management/models/document-validation-definition.model.js +7 -2
  67. package/document-management/models/document-validation-execution-related-document.model.d.ts +1 -0
  68. package/document-management/models/document-validation-execution-related-document.model.js +10 -3
  69. package/document-management/models/document-validation-execution.model.d.ts +1 -0
  70. package/document-management/models/document-validation-execution.model.js +9 -3
  71. package/document-management/models/document-workflow.model.d.ts +4 -1
  72. package/document-management/models/document-workflow.model.js +16 -4
  73. package/document-management/models/document.model.d.ts +2 -2
  74. package/document-management/models/document.model.js +9 -8
  75. package/document-management/models/index.d.ts +2 -1
  76. package/document-management/models/index.js +2 -1
  77. package/document-management/server/api/document-management.api.d.ts +4 -1
  78. package/document-management/server/api/document-management.api.js +113 -22
  79. package/document-management/server/configure.d.ts +2 -2
  80. package/document-management/server/configure.js +7 -7
  81. package/document-management/server/drizzle/0000_parallel_mantis.sql +359 -0
  82. package/document-management/server/drizzle/meta/0000_snapshot.json +784 -260
  83. package/document-management/server/drizzle/meta/_journal.json +2 -2
  84. package/document-management/server/module.d.ts +2 -2
  85. package/document-management/server/module.js +2 -2
  86. package/document-management/server/schemas.d.ts +6 -5
  87. package/document-management/server/schemas.js +12 -11
  88. package/document-management/server/services/document-category-type.service.d.ts +19 -10
  89. package/document-management/server/services/document-category-type.service.js +34 -27
  90. package/document-management/server/services/document-collection.service.d.ts +13 -6
  91. package/document-management/server/services/document-collection.service.js +36 -12
  92. package/document-management/server/services/document-file.service.d.ts +8 -7
  93. package/document-management/server/services/document-file.service.js +28 -33
  94. package/document-management/server/services/document-management-ai.service.d.ts +5 -4
  95. package/document-management/server/services/document-management-ai.service.js +51 -28
  96. package/document-management/server/services/document-management-ancillary.service.d.ts +3 -21
  97. package/document-management/server/services/document-management-ancillary.service.js +0 -24
  98. package/document-management/server/services/document-management-observation.service.d.ts +15 -0
  99. package/document-management/server/services/document-management-observation.service.js +160 -0
  100. package/document-management/server/services/document-management.service.d.ts +6 -5
  101. package/document-management/server/services/document-management.service.js +112 -86
  102. package/document-management/server/services/document-property.service.d.ts +15 -7
  103. package/document-management/server/services/document-property.service.js +52 -20
  104. package/document-management/server/services/document-request.service.d.ts +13 -24
  105. package/document-management/server/services/document-request.service.js +39 -62
  106. package/document-management/server/services/document-tag.service.d.ts +10 -0
  107. package/document-management/server/services/document-tag.service.js +59 -0
  108. package/document-management/server/services/document-validation.service.d.ts +8 -8
  109. package/document-management/server/services/document-validation.service.js +41 -40
  110. package/document-management/server/services/document-workflow.service.d.ts +6 -5
  111. package/document-management/server/services/document-workflow.service.js +54 -43
  112. package/document-management/server/services/document.service.d.ts +12 -11
  113. package/document-management/server/services/document.service.js +64 -40
  114. package/document-management/server/services/index.d.ts +2 -1
  115. package/document-management/server/services/index.js +2 -1
  116. package/document-management/server/services/singleton.js +2 -2
  117. package/document-management/server/validators/ai-validation-executor.js +4 -4
  118. package/document-management/service-models/document-collection-metadata.service-model.d.ts +14 -0
  119. package/document-management/service-models/document-collection-metadata.service-model.js +1 -0
  120. package/document-management/service-models/document-folders.view-model.d.ts +1 -7
  121. package/document-management/service-models/document-folders.view-model.js +3 -15
  122. package/document-management/service-models/document-management.view-model.d.ts +20 -6
  123. package/document-management/service-models/document-management.view-model.js +62 -8
  124. package/document-management/service-models/document.service-model.d.ts +14 -11
  125. package/document-management/service-models/document.service-model.js +11 -2
  126. package/document-management/service-models/enriched/enriched-document-assignment.view.d.ts +1 -1
  127. package/document-management/service-models/enriched/enriched-document-assignment.view.js +0 -2
  128. package/document-management/service-models/enriched/enriched-document-category.view.d.ts +11 -1
  129. package/document-management/service-models/enriched/enriched-document-category.view.js +44 -1
  130. package/document-management/service-models/enriched/enriched-document-collection.view.d.ts +4 -2
  131. package/document-management/service-models/enriched/enriched-document-collection.view.js +13 -3
  132. package/document-management/service-models/enriched/enriched-document-management-data.view.d.ts +2 -0
  133. package/document-management/service-models/enriched/enriched-document-management-data.view.js +4 -2
  134. package/document-management/service-models/enriched/enriched-document-request.view.d.ts +1 -0
  135. package/document-management/service-models/enriched/enriched-document-request.view.js +2 -0
  136. package/document-management/service-models/enriched/enriched-document-type.view.d.ts +9 -1
  137. package/document-management/service-models/enriched/enriched-document-type.view.js +28 -1
  138. package/document-management/service-models/enriched/enriched-document.view.d.ts +7 -6
  139. package/document-management/service-models/enriched/enriched-document.view.js +29 -6
  140. package/document-management/service-models/{normalized-requests-template-data.model.d.ts → enriched/enriched-requests-template-data.model.d.ts} +6 -6
  141. package/document-management/service-models/{normalized-requests-template-data.model.js → enriched/enriched-requests-template-data.model.js} +1 -1
  142. package/document-management/service-models/enriched/index.d.ts +1 -0
  143. package/document-management/service-models/enriched/index.js +1 -0
  144. package/document-management/service-models/index.d.ts +2 -2
  145. package/document-management/service-models/index.js +2 -2
  146. package/examples/document-management/categories-and-types.d.ts +33 -31
  147. package/examples/document-management/categories-and-types.js +33 -0
  148. package/examples/document-management/main.d.ts +5 -4
  149. package/examples/document-management/main.js +13 -7
  150. package/function/log.js +2 -2
  151. package/http/server/node/module.d.ts +4 -1
  152. package/http/server/node/module.js +10 -1
  153. package/http/server/node/node-http-server.d.ts +3 -6
  154. package/http/server/node/node-http-server.js +68 -67
  155. package/injector/inject.js +6 -6
  156. package/injector/injector.js +3 -3
  157. package/jsx/is-component-class.js +1 -1
  158. package/key-value-store/key-value.store.d.ts +38 -7
  159. package/key-value-store/key-value.store.js +2 -1
  160. package/key-value-store/mongo/mongo-key-value.store.d.ts +1 -0
  161. package/key-value-store/mongo/mongo-key-value.store.js +14 -5
  162. package/key-value-store/postgres/drizzle/0000_shocking_slipstream.sql +12 -0
  163. package/key-value-store/postgres/drizzle/meta/0000_snapshot.json +97 -0
  164. package/key-value-store/postgres/drizzle/meta/_journal.json +13 -0
  165. package/key-value-store/postgres/drizzle.config.d.ts +2 -0
  166. package/key-value-store/postgres/drizzle.config.js +11 -0
  167. package/key-value-store/postgres/index.d.ts +2 -0
  168. package/key-value-store/postgres/index.js +2 -0
  169. package/key-value-store/postgres/key-value-store.service.d.ts +17 -0
  170. package/key-value-store/postgres/key-value-store.service.js +65 -0
  171. package/key-value-store/postgres/models/index.d.ts +2 -0
  172. package/key-value-store/postgres/models/index.js +2 -0
  173. package/key-value-store/postgres/models/key-value.model.d.ts +7 -0
  174. package/key-value-store/postgres/models/key-value.model.js +35 -0
  175. package/key-value-store/postgres/models/schemas.d.ts +3 -0
  176. package/key-value-store/postgres/models/schemas.js +4 -0
  177. package/key-value-store/postgres/module.d.ts +6 -0
  178. package/key-value-store/postgres/module.js +23 -0
  179. package/lock/web/web-lock.d.ts +0 -1
  180. package/lock/web/web-lock.js +6 -13
  181. package/orm/data-types/timestamp.js +1 -1
  182. package/orm/decorators.d.ts +37 -29
  183. package/orm/decorators.js +44 -24
  184. package/orm/entity.d.ts +1 -0
  185. package/orm/query.d.ts +10 -2
  186. package/orm/repository.types.d.ts +2 -1
  187. package/orm/schemas/json.d.ts +12 -6
  188. package/orm/schemas/json.js +12 -5
  189. package/orm/server/database.js +5 -2
  190. package/orm/server/drizzle/schema-converter.js +40 -11
  191. package/orm/server/query-converter.d.ts +2 -1
  192. package/orm/server/query-converter.js +57 -34
  193. package/orm/server/repository.d.ts +26 -43
  194. package/orm/server/repository.js +106 -39
  195. package/orm/server/transaction.d.ts +2 -1
  196. package/orm/server/transaction.js +3 -0
  197. package/orm/server/transactional.d.ts +5 -1
  198. package/orm/server/transactional.js +34 -4
  199. package/package.json +14 -11
  200. package/process/spawn.js +0 -1
  201. package/promise/deferred-promise.d.ts +4 -3
  202. package/promise/deferred-promise.js +13 -5
  203. package/queue/postgres/queue.js +8 -8
  204. package/reflection/utils.js +3 -3
  205. package/schema/decorators/class.js +0 -1
  206. package/schema/decorators/schema.js +1 -1
  207. package/schema/schemas/boolean.d.ts +1 -1
  208. package/schema/schemas/boolean.js +2 -2
  209. package/schema/schemas/number.js +3 -3
  210. package/schema/schemas/object.js +5 -6
  211. package/sse/server-sent-events-source.js +4 -1
  212. package/utils/compression.js +9 -9
  213. package/utils/date-time.d.ts +1 -0
  214. package/utils/date-time.js +18 -4
  215. package/utils/equals.d.ts +7 -0
  216. package/utils/equals.js +17 -2
  217. package/utils/function/memoize.js +10 -2
  218. package/utils/jwt.js +3 -3
  219. package/utils/object/property-name.d.ts +2 -2
  220. package/utils/timing.d.ts +2 -2
  221. package/utils/timing.js +12 -12
  222. package/document-management/models/document-request-submission.model.d.ts +0 -7
  223. package/document-management/server/drizzle/0000_moaning_luckman.sql +0 -305
  224. package/document-management/server/services/document-management-authorization.service.js +0 -28
@@ -65,7 +65,7 @@ export class CancellationSignal {
65
65
  * @see {@link connect}
66
66
  */
67
67
  createChild(config) {
68
- const child = new CancellationToken(); // eslint-disable-line @typescript-eslint/no-use-before-define
68
+ const child = new CancellationToken();
69
69
  this.connect(child, config);
70
70
  return child;
71
71
  }
@@ -74,7 +74,7 @@ export class CancellationSignal {
74
74
  * @param target receiver to connect
75
75
  */
76
76
  connect(target, config) {
77
- CancellationToken.connect(this.state$, target, config); // eslint-disable-line @typescript-eslint/no-use-before-define
77
+ CancellationToken.connect(this.state$, target, config);
78
78
  }
79
79
  async then(onfulfilled) {
80
80
  await this.$set;
@@ -117,11 +117,11 @@ export class CancellationToken extends CancellationSignal {
117
117
  const subscription = stateObservable.subscribe({
118
118
  next: (state) => target.setState(state),
119
119
  error: error ? ((errorValue) => target.error(errorValue)) : noop,
120
- complete: complete ? (() => target.complete()) : noop
120
+ complete: complete ? (() => target.complete()) : noop,
121
121
  });
122
122
  target.#stateSubject.subscribe({
123
123
  error: () => subscription.unsubscribe(),
124
- complete: () => subscription.unsubscribe()
124
+ complete: () => subscription.unsubscribe(),
125
125
  });
126
126
  }
127
127
  /**
package/cookie/cookie.js CHANGED
@@ -4,12 +4,12 @@ import { isDefined, isNumber, isUndefined } from '../utils/type-guards.js';
4
4
  const sameSiteMap = {
5
5
  none: 'None',
6
6
  lax: 'Lax',
7
- strict: 'Strict'
7
+ strict: 'Strict',
8
8
  };
9
9
  const priorityMap = {
10
10
  low: 'Low',
11
11
  medium: 'Medium',
12
- high: 'High'
12
+ high: 'High',
13
13
  };
14
14
  export function formatSetCookie(name, value, options = {}) {
15
15
  let cookie = `${name}=${encodeURIComponent(value)}`;
@@ -44,7 +44,7 @@ export class CssVariables {
44
44
  }
45
45
  _prefix(name) {
46
46
  const prefixed = `${this.prefix}${name}`;
47
- return name.startsWith('--') ? prefixed : `--${prefixed}`;
47
+ return prefixed.startsWith('--') ? prefixed : `--${prefixed}`;
48
48
  }
49
49
  }
50
50
  export function cssVariables(selector = null, prefix = '') {
@@ -122,7 +122,6 @@ export declare const documentManagementApiDefinition: {
122
122
  title?: string | null | undefined;
123
123
  typeId?: import("../../orm/types.js").Uuid | null | undefined;
124
124
  subtitle?: string | null | undefined;
125
- tags?: string[] | null | undefined;
126
125
  comment?: string | null | undefined;
127
126
  approval?: import("../models/document.model.js").DocumentApproval | undefined;
128
127
  originalFileName?: string | null | undefined;
@@ -136,6 +135,7 @@ export declare const documentManagementApiDefinition: {
136
135
  scope: string | string[];
137
136
  };
138
137
  };
138
+ tags: string[];
139
139
  uploadId: string;
140
140
  properties?: {
141
141
  propertyId: import("../../orm/schemas/uuid.js").Uuid;
@@ -171,6 +171,7 @@ export declare const documentManagementApiDefinition: {
171
171
  id: import("../../orm/types.js").IsPrimaryKey<import("../../orm/types.js").HasDefault<import("../../orm/schemas/uuid.js").Uuid>>;
172
172
  description?: string | null | undefined;
173
173
  label?: string | undefined;
174
+ tenantId?: string | null | undefined;
174
175
  metadata?: Partial<{
175
176
  attributes: import("../../orm/types.js").HasDefault<import("../../orm/schemas/json.js").Json<import("../../orm/entity.js").EntityMetadataAttributes>>;
176
177
  }> | undefined;
@@ -222,6 +223,7 @@ export declare const documentManagementApiDefinition: {
222
223
  method: "PATCH";
223
224
  parameters: import("../../schema/index.js").ObjectSchema<{
224
225
  id: import("../../orm/types.js").IsPrimaryKey<import("../../orm/types.js").HasDefault<import("../../orm/schemas/uuid.js").Uuid>>;
226
+ tenantId?: string | null | undefined;
225
227
  typeId?: import("../../orm/types.js").Uuid | undefined;
226
228
  comment?: string | null | undefined;
227
229
  metadata?: Partial<{
@@ -287,8 +289,8 @@ export declare const documentManagementApiDefinition: {
287
289
  resource: string;
288
290
  method: "PUT";
289
291
  parameters: import("../../schema/index.js").ObjectSchema<{
290
- documentId: import("../../orm/schemas/uuid.js").Uuid;
291
292
  collectionId: import("../../orm/schemas/uuid.js").Uuid;
293
+ documentId: import("../../orm/schemas/uuid.js").Uuid;
292
294
  metadata?: Partial<{
293
295
  attributes: import("../../orm/types.js").HasDefault<import("../../orm/schemas/json.js").Json<import("../../orm/entity.js").EntityMetadataAttributes>>;
294
296
  }> | undefined;
@@ -300,8 +302,8 @@ export declare const documentManagementApiDefinition: {
300
302
  resource: string;
301
303
  method: "DELETE";
302
304
  parameters: import("../../schema/index.js").ObjectSchema<{
303
- documentId: import("../../orm/schemas/uuid.js").Uuid;
304
305
  collectionId: import("../../orm/schemas/uuid.js").Uuid;
306
+ documentId: import("../../orm/schemas/uuid.js").Uuid;
305
307
  metadata?: Partial<{
306
308
  attributes: import("../../orm/types.js").HasDefault<import("../../orm/schemas/json.js").Json<import("../../orm/entity.js").EntityMetadataAttributes>>;
307
309
  }> | undefined;
@@ -315,19 +317,10 @@ export declare const documentManagementApiDefinition: {
315
317
  parameters: import("../../schema/index.js").ObjectSchema<{
316
318
  id: import("../../orm/types.js").IsPrimaryKey<import("../../orm/types.js").HasDefault<import("../../orm/schemas/uuid.js").Uuid>>;
317
319
  date?: import("../../orm/types.js").NumericDate | null | undefined;
318
- size?: number | undefined;
319
- hash?: string | undefined;
320
- summary?: string | null | undefined;
321
320
  title?: string | null | undefined;
322
- mimeType?: string | undefined;
323
321
  typeId?: import("../../orm/types.js").Uuid | null | undefined;
324
322
  subtitle?: string | null | undefined;
325
- tags?: string[] | null | undefined;
326
323
  comment?: string | null | undefined;
327
- pages?: number | null | undefined;
328
- approval?: import("../models/document.model.js").DocumentApproval | undefined;
329
- originalFileName?: string | null | undefined;
330
- createUserId?: import("../../orm/types.js").Uuid | null | undefined;
331
324
  properties?: {
332
325
  propertyId: import("../../orm/schemas/uuid.js").Uuid;
333
326
  value: string | number | boolean | null;
@@ -335,6 +328,11 @@ export declare const documentManagementApiDefinition: {
335
328
  attributes: import("../../orm/types.js").HasDefault<import("../../orm/schemas/json.js").Json<import("../../orm/entity.js").EntityMetadataAttributes>>;
336
329
  }> | undefined;
337
330
  }[] | undefined;
331
+ collections?: {
332
+ assign?: string[] | undefined;
333
+ archive?: string[] | undefined;
334
+ } | undefined;
335
+ tags?: string[] | undefined;
338
336
  metadata?: Partial<{
339
337
  attributes: import("../../orm/types.js").HasDefault<import("../../orm/schemas/json.js").Json<import("../../orm/entity.js").EntityMetadataAttributes>>;
340
338
  }> | undefined;
@@ -342,6 +340,57 @@ export declare const documentManagementApiDefinition: {
342
340
  result: import("../../schema/index.js").LiteralSchema<"ok">;
343
341
  credentials: true;
344
342
  };
343
+ proceedDocumentWorkflow: {
344
+ resource: string;
345
+ method: "POST";
346
+ parameters: import("../../schema/index.js").ObjectSchema<{
347
+ id: string;
348
+ }>;
349
+ result: import("../../schema/index.js").LiteralSchema<"ok">;
350
+ credentials: true;
351
+ };
352
+ testAuthorization: {
353
+ resource: string;
354
+ method: "POST";
355
+ parameters: import("../../schema/index.js").UnionSchema<[import("../../schema/index.js").ObjectSchema<{
356
+ type: "canReadCollection";
357
+ collectionId: string;
358
+ }>, import("../../schema/index.js").ObjectSchema<{
359
+ type: "canCreateDocuments";
360
+ collectionId: string;
361
+ }>, import("../../schema/index.js").ObjectSchema<{
362
+ type: "canDeleteDocuments";
363
+ collectionId: string;
364
+ }>, import("../../schema/index.js").ObjectSchema<{
365
+ type: "canAssignDocuments";
366
+ collectionId: string;
367
+ }>, import("../../schema/index.js").ObjectSchema<{
368
+ type: "canManageRequests";
369
+ collectionId: string;
370
+ }>, import("../../schema/index.js").ObjectSchema<{
371
+ type: "canUpdateDocument";
372
+ documentId: string;
373
+ }>, import("../../schema/index.js").ObjectSchema<{
374
+ type: "canApproveDocument";
375
+ documentId: string;
376
+ }>, import("../../schema/index.js").ObjectSchema<{
377
+ type: "canRejectDocument";
378
+ documentId: string;
379
+ }>, import("../../schema/index.js").ObjectSchema<{
380
+ type: "canProgressDocumentWorkflow";
381
+ documentId: string;
382
+ }>, import("../../schema/index.js").ObjectSchema<{
383
+ type: "canManageCategoriesAndTypes";
384
+ }>, import("../../schema/index.js").ObjectSchema<{
385
+ type: "canReadDocumentRequestsTemplates";
386
+ }>, import("../../schema/index.js").ObjectSchema<{
387
+ type: "canManageDocumentRequestsTemplates";
388
+ }>, import("../../schema/index.js").ObjectSchema<{
389
+ type: "canManageValidationDefinitions";
390
+ }>]>;
391
+ result: import("../../schema/index.js").BooleanSchema;
392
+ credentials: true;
393
+ };
345
394
  };
346
395
  };
347
396
  declare const _DocumentManagementApi: import("../../api/client/index.js").ApiClient<{
@@ -464,7 +513,6 @@ declare const _DocumentManagementApi: import("../../api/client/index.js").ApiCli
464
513
  title?: string | null | undefined;
465
514
  typeId?: import("../../orm/types.js").Uuid | null | undefined;
466
515
  subtitle?: string | null | undefined;
467
- tags?: string[] | null | undefined;
468
516
  comment?: string | null | undefined;
469
517
  approval?: import("../models/document.model.js").DocumentApproval | undefined;
470
518
  originalFileName?: string | null | undefined;
@@ -478,6 +526,7 @@ declare const _DocumentManagementApi: import("../../api/client/index.js").ApiCli
478
526
  scope: string | string[];
479
527
  };
480
528
  };
529
+ tags: string[];
481
530
  uploadId: string;
482
531
  properties?: {
483
532
  propertyId: import("../../orm/schemas/uuid.js").Uuid;
@@ -513,6 +562,7 @@ declare const _DocumentManagementApi: import("../../api/client/index.js").ApiCli
513
562
  id: import("../../orm/types.js").IsPrimaryKey<import("../../orm/types.js").HasDefault<import("../../orm/schemas/uuid.js").Uuid>>;
514
563
  description?: string | null | undefined;
515
564
  label?: string | undefined;
565
+ tenantId?: string | null | undefined;
516
566
  metadata?: Partial<{
517
567
  attributes: import("../../orm/types.js").HasDefault<import("../../orm/schemas/json.js").Json<import("../../orm/entity.js").EntityMetadataAttributes>>;
518
568
  }> | undefined;
@@ -564,6 +614,7 @@ declare const _DocumentManagementApi: import("../../api/client/index.js").ApiCli
564
614
  method: "PATCH";
565
615
  parameters: import("../../schema/index.js").ObjectSchema<{
566
616
  id: import("../../orm/types.js").IsPrimaryKey<import("../../orm/types.js").HasDefault<import("../../orm/schemas/uuid.js").Uuid>>;
617
+ tenantId?: string | null | undefined;
567
618
  typeId?: import("../../orm/types.js").Uuid | undefined;
568
619
  comment?: string | null | undefined;
569
620
  metadata?: Partial<{
@@ -629,8 +680,8 @@ declare const _DocumentManagementApi: import("../../api/client/index.js").ApiCli
629
680
  resource: string;
630
681
  method: "PUT";
631
682
  parameters: import("../../schema/index.js").ObjectSchema<{
632
- documentId: import("../../orm/schemas/uuid.js").Uuid;
633
683
  collectionId: import("../../orm/schemas/uuid.js").Uuid;
684
+ documentId: import("../../orm/schemas/uuid.js").Uuid;
634
685
  metadata?: Partial<{
635
686
  attributes: import("../../orm/types.js").HasDefault<import("../../orm/schemas/json.js").Json<import("../../orm/entity.js").EntityMetadataAttributes>>;
636
687
  }> | undefined;
@@ -642,8 +693,8 @@ declare const _DocumentManagementApi: import("../../api/client/index.js").ApiCli
642
693
  resource: string;
643
694
  method: "DELETE";
644
695
  parameters: import("../../schema/index.js").ObjectSchema<{
645
- documentId: import("../../orm/schemas/uuid.js").Uuid;
646
696
  collectionId: import("../../orm/schemas/uuid.js").Uuid;
697
+ documentId: import("../../orm/schemas/uuid.js").Uuid;
647
698
  metadata?: Partial<{
648
699
  attributes: import("../../orm/types.js").HasDefault<import("../../orm/schemas/json.js").Json<import("../../orm/entity.js").EntityMetadataAttributes>>;
649
700
  }> | undefined;
@@ -657,19 +708,10 @@ declare const _DocumentManagementApi: import("../../api/client/index.js").ApiCli
657
708
  parameters: import("../../schema/index.js").ObjectSchema<{
658
709
  id: import("../../orm/types.js").IsPrimaryKey<import("../../orm/types.js").HasDefault<import("../../orm/schemas/uuid.js").Uuid>>;
659
710
  date?: import("../../orm/types.js").NumericDate | null | undefined;
660
- size?: number | undefined;
661
- hash?: string | undefined;
662
- summary?: string | null | undefined;
663
711
  title?: string | null | undefined;
664
- mimeType?: string | undefined;
665
712
  typeId?: import("../../orm/types.js").Uuid | null | undefined;
666
713
  subtitle?: string | null | undefined;
667
- tags?: string[] | null | undefined;
668
714
  comment?: string | null | undefined;
669
- pages?: number | null | undefined;
670
- approval?: import("../models/document.model.js").DocumentApproval | undefined;
671
- originalFileName?: string | null | undefined;
672
- createUserId?: import("../../orm/types.js").Uuid | null | undefined;
673
715
  properties?: {
674
716
  propertyId: import("../../orm/schemas/uuid.js").Uuid;
675
717
  value: string | number | boolean | null;
@@ -677,6 +719,11 @@ declare const _DocumentManagementApi: import("../../api/client/index.js").ApiCli
677
719
  attributes: import("../../orm/types.js").HasDefault<import("../../orm/schemas/json.js").Json<import("../../orm/entity.js").EntityMetadataAttributes>>;
678
720
  }> | undefined;
679
721
  }[] | undefined;
722
+ collections?: {
723
+ assign?: string[] | undefined;
724
+ archive?: string[] | undefined;
725
+ } | undefined;
726
+ tags?: string[] | undefined;
680
727
  metadata?: Partial<{
681
728
  attributes: import("../../orm/types.js").HasDefault<import("../../orm/schemas/json.js").Json<import("../../orm/entity.js").EntityMetadataAttributes>>;
682
729
  }> | undefined;
@@ -684,6 +731,57 @@ declare const _DocumentManagementApi: import("../../api/client/index.js").ApiCli
684
731
  result: import("../../schema/index.js").LiteralSchema<"ok">;
685
732
  credentials: true;
686
733
  };
734
+ proceedDocumentWorkflow: {
735
+ resource: string;
736
+ method: "POST";
737
+ parameters: import("../../schema/index.js").ObjectSchema<{
738
+ id: string;
739
+ }>;
740
+ result: import("../../schema/index.js").LiteralSchema<"ok">;
741
+ credentials: true;
742
+ };
743
+ testAuthorization: {
744
+ resource: string;
745
+ method: "POST";
746
+ parameters: import("../../schema/index.js").UnionSchema<[import("../../schema/index.js").ObjectSchema<{
747
+ type: "canReadCollection";
748
+ collectionId: string;
749
+ }>, import("../../schema/index.js").ObjectSchema<{
750
+ type: "canCreateDocuments";
751
+ collectionId: string;
752
+ }>, import("../../schema/index.js").ObjectSchema<{
753
+ type: "canDeleteDocuments";
754
+ collectionId: string;
755
+ }>, import("../../schema/index.js").ObjectSchema<{
756
+ type: "canAssignDocuments";
757
+ collectionId: string;
758
+ }>, import("../../schema/index.js").ObjectSchema<{
759
+ type: "canManageRequests";
760
+ collectionId: string;
761
+ }>, import("../../schema/index.js").ObjectSchema<{
762
+ type: "canUpdateDocument";
763
+ documentId: string;
764
+ }>, import("../../schema/index.js").ObjectSchema<{
765
+ type: "canApproveDocument";
766
+ documentId: string;
767
+ }>, import("../../schema/index.js").ObjectSchema<{
768
+ type: "canRejectDocument";
769
+ documentId: string;
770
+ }>, import("../../schema/index.js").ObjectSchema<{
771
+ type: "canProgressDocumentWorkflow";
772
+ documentId: string;
773
+ }>, import("../../schema/index.js").ObjectSchema<{
774
+ type: "canManageCategoriesAndTypes";
775
+ }>, import("../../schema/index.js").ObjectSchema<{
776
+ type: "canReadDocumentRequestsTemplates";
777
+ }>, import("../../schema/index.js").ObjectSchema<{
778
+ type: "canManageDocumentRequestsTemplates";
779
+ }>, import("../../schema/index.js").ObjectSchema<{
780
+ type: "canManageValidationDefinitions";
781
+ }>]>;
782
+ result: import("../../schema/index.js").BooleanSchema;
783
+ credentials: true;
784
+ };
687
785
  };
688
786
  }>;
689
787
  export declare class DocumentManagementApi extends _DocumentManagementApi {
@@ -9,6 +9,7 @@ import { defineApi } from '../../api/index.js';
9
9
  import { ReplaceClass } from '../../injector/decorators.js';
10
10
  import { array, boolean, literal, number, object, optional, string } from '../../schema/index.js';
11
11
  import { ServerSentEvents } from '../../sse/server-sent-events.js';
12
+ import { policy } from '../authorization/index.js';
12
13
  import { Document, DocumentCategory, DocumentRequest, DocumentRequestsTemplate, DocumentRequestTemplate, DocumentType } from '../models/index.js';
13
14
  import { addOrArchiveDocumentToOrFromCollectionParametersSchema, applyDocumentRequestsTemplateParametersSchema, createDocumentCategoryParametersSchema, createDocumentParametersSchema, createDocumentRequestParametersSchema, createDocumentRequestsTemplateParametersSchema, createDocumentRequestTemplateParametersSchema, createDocumentTypeParametersSchema, deleteDocumentRequestParametersSchema, deleteDocumentRequestsTemplateParametersSchema, deleteDocumentRequestTemplateParametersSchema, DocumentCategoryView, DocumentManagementData, DocumentRequestsTemplateData, loadDataParametersSchema, updateDocumentParametersSchema, updateDocumentRequestParametersSchema, updateDocumentRequestsTemplateParametersSchema, updateDocumentRequestTemplateParametersSchema } from '../service-models/index.js';
14
15
  export const documentManagementApiDefinition = defineApi({
@@ -204,6 +205,22 @@ export const documentManagementApiDefinition = defineApi({
204
205
  result: literal('ok'),
205
206
  credentials: true,
206
207
  },
208
+ proceedDocumentWorkflow: {
209
+ resource: 'documents/:id/proceed-workflow',
210
+ method: 'POST',
211
+ parameters: object({
212
+ id: string(),
213
+ }),
214
+ result: literal('ok'),
215
+ credentials: true,
216
+ },
217
+ testAuthorization: {
218
+ resource: 'authorization/test',
219
+ method: 'POST',
220
+ parameters: policy,
221
+ result: boolean(),
222
+ credentials: true,
223
+ },
207
224
  },
208
225
  });
209
226
  const _DocumentManagementApi = compileClient(documentManagementApiDefinition);
@@ -1,8 +1,9 @@
1
- import { type DocumentWorkflowStep } from '../../models/index.js';
2
1
  export declare abstract class DocumentManagementAuthorizationService<Token = unknown> {
3
- #private;
4
- canReadDocument(documentId: string, token?: Token): Promise<boolean>;
5
- canManageRequest(requestId: string, token?: Token): Promise<boolean>;
2
+ /**
3
+ * Gets the tenant from the request token.
4
+ * @param token The token of the request
5
+ */
6
+ abstract getTenantId(token?: Token): string | Promise<string>;
6
7
  /**
7
8
  * Gets the subject from the request token.
8
9
  * @param token The token of the request
@@ -20,7 +21,6 @@ export declare abstract class DocumentManagementAuthorizationService<Token = unk
20
21
  * @param token The token of the request.
21
22
  */
22
23
  abstract canCreateDocuments(collectionId: string, token?: Token): boolean | Promise<boolean>;
23
- abstract canUpdateDocuments(collectionId: string, token?: Token): boolean | Promise<boolean>;
24
24
  abstract canDeleteDocuments(collectionId: string, token?: Token): boolean | Promise<boolean>;
25
25
  /**
26
26
  * Checks if a user can assign documents to requests in the collection or directly to the collection.
@@ -28,6 +28,7 @@ export declare abstract class DocumentManagementAuthorizationService<Token = unk
28
28
  * @param token The token of the request.
29
29
  */
30
30
  abstract canAssignDocuments(collectionId: string, token?: Token): boolean | Promise<boolean>;
31
+ abstract canUpdateDocument(collectionId: string, token?: Token): boolean | Promise<boolean>;
31
32
  /**
32
33
  * Checks if a user can approve a specific document. This implicitly allows fulfilling document requests by approving their linked document.
33
34
  * This is usually a privileged action for staff members.
@@ -78,8 +79,7 @@ export declare abstract class DocumentManagementAuthorizationService<Token = unk
78
79
  * This implies reviewing the current step's output, making corrections if necessary,
79
80
  * and then confirming to proceed to the next phase or finalization.
80
81
  * @param documentId The ID of the document.
81
- * @param currentWorkflowStep The current step of the workflow the user is interacting with.
82
82
  * @param token The token of the request.
83
83
  */
84
- abstract canProgressDocumentWorkflow(documentId: string, currentWorkflowStep: DocumentWorkflowStep, token?: Token): boolean | Promise<boolean>;
84
+ abstract canProgressDocumentWorkflow(documentId: string, token?: Token): boolean | Promise<boolean>;
85
85
  }
@@ -0,0 +1,2 @@
1
+ export class DocumentManagementAuthorizationService {
2
+ }
@@ -0,0 +1,2 @@
1
+ export * from './document-management-authorization.service.js';
2
+ export * from './policies.js';
@@ -0,0 +1,2 @@
1
+ export * from './document-management-authorization.service.js';
2
+ export * from './policies.js';
@@ -0,0 +1,38 @@
1
+ import { type SchemaOutput } from '../../schema/index.js';
2
+ export declare const policy: import("../../schema/index.js").UnionSchema<[import("../../schema/index.js").ObjectSchema<{
3
+ type: "canReadCollection";
4
+ collectionId: string;
5
+ }>, import("../../schema/index.js").ObjectSchema<{
6
+ type: "canCreateDocuments";
7
+ collectionId: string;
8
+ }>, import("../../schema/index.js").ObjectSchema<{
9
+ type: "canDeleteDocuments";
10
+ collectionId: string;
11
+ }>, import("../../schema/index.js").ObjectSchema<{
12
+ type: "canAssignDocuments";
13
+ collectionId: string;
14
+ }>, import("../../schema/index.js").ObjectSchema<{
15
+ type: "canManageRequests";
16
+ collectionId: string;
17
+ }>, import("../../schema/index.js").ObjectSchema<{
18
+ type: "canUpdateDocument";
19
+ documentId: string;
20
+ }>, import("../../schema/index.js").ObjectSchema<{
21
+ type: "canApproveDocument";
22
+ documentId: string;
23
+ }>, import("../../schema/index.js").ObjectSchema<{
24
+ type: "canRejectDocument";
25
+ documentId: string;
26
+ }>, import("../../schema/index.js").ObjectSchema<{
27
+ type: "canProgressDocumentWorkflow";
28
+ documentId: string;
29
+ }>, import("../../schema/index.js").ObjectSchema<{
30
+ type: "canManageCategoriesAndTypes";
31
+ }>, import("../../schema/index.js").ObjectSchema<{
32
+ type: "canReadDocumentRequestsTemplates";
33
+ }>, import("../../schema/index.js").ObjectSchema<{
34
+ type: "canManageDocumentRequestsTemplates";
35
+ }>, import("../../schema/index.js").ObjectSchema<{
36
+ type: "canManageValidationDefinitions";
37
+ }>]>;
38
+ export type Policy = SchemaOutput<typeof policy>;
@@ -0,0 +1,2 @@
1
+ import { literal, object, string, union } from '../../schema/index.js';
2
+ export const policy = union(object({ type: literal('canReadCollection'), collectionId: string() }), object({ type: literal('canCreateDocuments'), collectionId: string() }), object({ type: literal('canDeleteDocuments'), collectionId: string() }), object({ type: literal('canAssignDocuments'), collectionId: string() }), object({ type: literal('canManageRequests'), collectionId: string() }), object({ type: literal('canUpdateDocument'), documentId: string() }), object({ type: literal('canApproveDocument'), documentId: string() }), object({ type: literal('canRejectDocument'), documentId: string() }), object({ type: literal('canProgressDocumentWorkflow'), documentId: string() }), object({ type: literal('canManageCategoriesAndTypes') }), object({ type: literal('canReadDocumentRequestsTemplates') }), object({ type: literal('canManageDocumentRequestsTemplates') }), object({ type: literal('canManageValidationDefinitions') }));
@@ -1,4 +1,5 @@
1
1
  export * from './api/index.js';
2
+ export * from './authorization/index.js';
2
3
  export * from './localizations/index.js';
3
4
  export * from './models/index.js';
4
5
  export * from './service-models/index.js';
@@ -1,4 +1,5 @@
1
1
  export * from './api/index.js';
2
+ export * from './authorization/index.js';
2
3
  export * from './localizations/index.js';
3
4
  export * from './models/index.js';
4
5
  export * from './service-models/index.js';
@@ -6,6 +6,7 @@ import { Uuid } from '../../orm/types.js';
6
6
  */
7
7
  export declare class DocumentAssignmentScope extends Entity {
8
8
  static readonly entityName: 'DocumentAssignmentScope';
9
+ tenantId: Uuid;
9
10
  taskId: Uuid;
10
11
  collectionId: Uuid;
11
12
  }
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  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
- import { References } from '../../orm/decorators.js';
10
+ import { ForeignKey, References } from '../../orm/decorators.js';
11
11
  import { Entity } from '../../orm/entity.js';
12
12
  import { Unique, Uuid } from '../../orm/types.js';
13
13
  import { DocumentAssignmentTask } from './document-assignment-task.model.js';
@@ -18,9 +18,14 @@ import { DocumentManagementTable } from './document-management-table.js';
18
18
  * This is used to prevent documents from being assigned to collections/requests that are out of scope/context.
19
19
  */
20
20
  let DocumentAssignmentScope = class DocumentAssignmentScope extends Entity {
21
+ tenantId;
21
22
  taskId;
22
23
  collectionId;
23
24
  };
25
+ __decorate([
26
+ Uuid(),
27
+ __metadata("design:type", String)
28
+ ], DocumentAssignmentScope.prototype, "tenantId", void 0);
24
29
  __decorate([
25
30
  Uuid(),
26
31
  References(() => DocumentAssignmentTask),
@@ -32,7 +37,9 @@ __decorate([
32
37
  __metadata("design:type", String)
33
38
  ], DocumentAssignmentScope.prototype, "collectionId", void 0);
34
39
  DocumentAssignmentScope = __decorate([
35
- DocumentManagementTable(),
36
- Unique(['taskId', 'collectionId'], { naming: 'abbreviated-table' })
40
+ DocumentManagementTable({ name: 'assignment_scope' }),
41
+ Unique(['taskId', 'collectionId']),
42
+ ForeignKey(() => DocumentAssignmentTask, ['tenantId', 'taskId'], ['tenantId', 'id']),
43
+ ForeignKey(() => DocumentCollection, ['tenantId', 'collectionId'], ['tenantId', 'id'])
37
44
  ], DocumentAssignmentScope);
38
45
  export { DocumentAssignmentScope };
@@ -8,6 +8,7 @@ export declare const DocumentAssignmentTarget: {
8
8
  export type DocumentAssignmentTarget = EnumType<typeof DocumentAssignmentTarget>;
9
9
  export declare class DocumentAssignmentTask extends Entity {
10
10
  static readonly entityName: 'DocumentAssignmentTask';
11
+ tenantId: Uuid;
11
12
  documentId: Uuid;
12
13
  target: DocumentAssignmentTarget;
13
14
  }
@@ -8,7 +8,7 @@ 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 { defineEnum } from '../../enumeration/enumeration.js';
11
- import { References } from '../../orm/decorators.js';
11
+ import { ForeignKey, References } from '../../orm/decorators.js';
12
12
  import { Entity } from '../../orm/entity.js';
13
13
  import { Unique, Uuid } from '../../orm/types.js';
14
14
  import { Enumeration } from '../../schema/index.js';
@@ -19,9 +19,14 @@ export const DocumentAssignmentTarget = defineEnum('DocumentAssignmentTarget', {
19
19
  Request: 'request',
20
20
  });
21
21
  let DocumentAssignmentTask = class DocumentAssignmentTask extends Entity {
22
+ tenantId;
22
23
  documentId;
23
24
  target;
24
25
  };
26
+ __decorate([
27
+ Uuid(),
28
+ __metadata("design:type", String)
29
+ ], DocumentAssignmentTask.prototype, "tenantId", void 0);
25
30
  __decorate([
26
31
  Uuid(),
27
32
  References(() => Document),
@@ -33,6 +38,7 @@ __decorate([
33
38
  __metadata("design:type", String)
34
39
  ], DocumentAssignmentTask.prototype, "target", void 0);
35
40
  DocumentAssignmentTask = __decorate([
36
- DocumentManagementTable()
41
+ DocumentManagementTable({ name: 'assignment_task' }),
42
+ ForeignKey(() => Document, ['tenantId', 'documentId'], ['tenantId', 'id'])
37
43
  ], DocumentAssignmentTask);
38
44
  export { DocumentAssignmentTask };
@@ -2,6 +2,7 @@ import { Entity } from '../../orm/entity.js';
2
2
  import { Uuid } from '../../orm/types.js';
3
3
  export declare class DocumentCategory extends Entity {
4
4
  static readonly entityName: 'DocumentCategory';
5
+ tenantId: string | null;
5
6
  parentId: Uuid | null;
6
7
  label: string;
7
8
  }
@@ -12,9 +12,14 @@ import { References, Unique, Uuid } from '../../orm/types.js';
12
12
  import { StringProperty } from '../../schema/index.js';
13
13
  import { DocumentManagementTable } from './document-management-table.js';
14
14
  let DocumentCategory = class DocumentCategory extends Entity {
15
+ tenantId;
15
16
  parentId;
16
17
  label;
17
18
  };
19
+ __decorate([
20
+ Uuid({ nullable: true }),
21
+ __metadata("design:type", Object)
22
+ ], DocumentCategory.prototype, "tenantId", void 0);
18
23
  __decorate([
19
24
  Uuid({ nullable: true }),
20
25
  References(() => DocumentCategory),
@@ -26,6 +31,7 @@ __decorate([
26
31
  __metadata("design:type", String)
27
32
  ], DocumentCategory.prototype, "label", void 0);
28
33
  DocumentCategory = __decorate([
29
- DocumentManagementTable()
34
+ DocumentManagementTable({ name: 'category' }),
35
+ Unique(['tenantId', 'parentId', 'label'])
30
36
  ], DocumentCategory);
31
37
  export { DocumentCategory };
@@ -1,6 +1,7 @@
1
1
  import { Entity } from '../../orm/entity.js';
2
2
  import { Timestamp, Uuid } from '../../orm/types.js';
3
3
  export declare class DocumentCollectionAssignment extends Entity {
4
+ tenantId: Uuid;
4
5
  collectionId: Uuid;
5
6
  documentId: Uuid;
6
7
  archiveTimestamp: Timestamp | null;