@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.92.123",
3
+ "version": "0.92.125",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -124,6 +124,7 @@
124
124
  "./types/geo-json": "./types/geo-json.js",
125
125
  "./utils": "./utils/index.js",
126
126
  "./utils/array": "./utils/array/index.js",
127
+ "./utils/async-hook": "./utils/async-hook/index.js",
127
128
  "./utils/async-iterable-helpers": "./utils/async-iterable-helpers/index.js",
128
129
  "./utils/async-iterable-helpers/parallel": "./utils/async-iterable-helpers/parallel/index.js",
129
130
  "./utils/function": "./utils/function/index.js",
@@ -133,8 +134,6 @@
133
134
  "./utils/string": "./utils/string/index.js"
134
135
  },
135
136
  "dependencies": {
136
- "@google-cloud/storage": "^7.16",
137
- "@google-cloud/vertexai": "^1.9",
138
137
  "disposablestack": "^1.1",
139
138
  "luxon": "^3.6",
140
139
  "reflect-metadata": "^0.2",
@@ -142,52 +141,54 @@
142
141
  "ts-pattern": "^5.7",
143
142
  "type-fest": "4.37"
144
143
  },
145
- "devDependencies": {
146
- "@biomejs/biome": "1.9",
147
- "@stylistic/eslint-plugin": "4.2",
148
- "@types/chroma-js": "2.4",
149
- "@types/koa__router": "12.0",
150
- "@types/luxon": "3.6",
151
- "@types/minio": "7.1",
152
- "@types/mjml": "4.7",
153
- "@types/node": "22",
154
- "@types/nodemailer": "6.4",
155
- "@types/pg": "8.11",
156
- "@typescript-eslint/eslint-plugin": "8.29",
157
- "concurrently": "9.1",
158
- "drizzle-kit": "0.30",
159
- "eslint": "9.23",
160
- "globals": "16.0",
161
- "tsc-alias": "1.8",
162
- "typescript": "5.8"
163
- },
164
144
  "peerDependencies": {
165
- "@elastic/elasticsearch": "^8.17",
166
- "@google/generative-ai": "^0.24",
145
+ "@elastic/elasticsearch": "^9.0",
146
+ "@google-cloud/storage": "7.16",
147
+ "@google/genai": "^1.0",
167
148
  "@tstdl/angular": "^0.92",
168
149
  "@zxcvbn-ts/core": "^3.0",
169
150
  "@zxcvbn-ts/language-common": "^3.0",
170
151
  "@zxcvbn-ts/language-de": "^3.0",
171
152
  "@zxcvbn-ts/language-en": "^3.0",
172
153
  "chroma-js": "^2.6",
173
- "drizzle-orm": "^0.41",
154
+ "drizzle-orm": "^0.43",
174
155
  "handlebars": "^4.7",
175
156
  "minio": "^8.0",
176
157
  "mjml": "^4.15",
177
- "mongodb": "^6.15",
178
- "nodemailer": "^6.10",
179
- "pg": "^8.14",
180
- "playwright": "^1.51",
158
+ "mongodb": "^6.16",
159
+ "nodemailer": "^7.0",
160
+ "pg": "^8.16",
161
+ "playwright": "^1.52",
181
162
  "preact": "^10.26",
182
163
  "preact-render-to-string": "^6.5",
183
- "undici": "^7.7",
184
- "urlpattern-polyfill": "^10.0"
164
+ "sharp": "^0.34",
165
+ "undici": "^7.10",
166
+ "urlpattern-polyfill": "^10.1"
185
167
  },
186
168
  "peerDependenciesMeta": {
187
169
  "@tstdl/angular": {
188
170
  "optional": true
189
171
  }
190
172
  },
173
+ "devDependencies": {
174
+ "@stylistic/eslint-plugin": "4.2",
175
+ "@types/chroma-js": "2.4",
176
+ "@types/koa__router": "12.0",
177
+ "@types/luxon": "3.6",
178
+ "@types/minio": "7.1",
179
+ "@types/mjml": "4.7",
180
+ "@types/node": "22",
181
+ "@types/nodemailer": "6.4",
182
+ "@types/pg": "8.15",
183
+ "@typescript-eslint/eslint-plugin": "8.32",
184
+ "concurrently": "9.1",
185
+ "drizzle-kit": "0.31",
186
+ "eslint": "9.27",
187
+ "globals": "16.1",
188
+ "tsc-alias": "1.8",
189
+ "typedoc-plugin-missing-exports": "4.0",
190
+ "typescript": "5.8"
191
+ },
191
192
  "overrides": {
192
193
  "drizzle-kit": {
193
194
  "@esbuild-kit/esm-loader": "^2.6",
@@ -1,10 +1,12 @@
1
- export declare enum PasswordStrength {
2
- VeryWeak = 0,
3
- Weak = 1,
4
- Medium = 2,
5
- Strong = 3,
6
- VeryStrong = 4
7
- }
1
+ import { type EnumType } from '../enumeration/enumeration.js';
2
+ export declare const PasswordStrength: {
3
+ readonly VeryWeak: 0;
4
+ readonly Weak: 1;
5
+ readonly Medium: 2;
6
+ readonly Strong: 3;
7
+ readonly VeryStrong: 4;
8
+ };
9
+ export type PasswordStrength = EnumType<typeof PasswordStrength>;
8
10
  export declare class PasswordCheckResult {
9
11
  strength: PasswordStrength;
10
12
  /**
@@ -7,17 +7,17 @@ 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 { defineEnum } from '../enumeration/enumeration.js';
10
11
  import { NumberProperty } from '../schema/index.js';
11
12
  import { Array } from '../schema/schemas/array.js';
12
13
  import { Enumeration } from '../schema/schemas/enumeration.js';
13
- export var PasswordStrength;
14
- (function (PasswordStrength) {
15
- PasswordStrength[PasswordStrength["VeryWeak"] = 0] = "VeryWeak";
16
- PasswordStrength[PasswordStrength["Weak"] = 1] = "Weak";
17
- PasswordStrength[PasswordStrength["Medium"] = 2] = "Medium";
18
- PasswordStrength[PasswordStrength["Strong"] = 3] = "Strong";
19
- PasswordStrength[PasswordStrength["VeryStrong"] = 4] = "VeryStrong";
20
- })(PasswordStrength || (PasswordStrength = {}));
14
+ export const PasswordStrength = defineEnum('PasswordStrength', {
15
+ VeryWeak: 0,
16
+ Weak: 1,
17
+ Medium: 2,
18
+ Strong: 3,
19
+ VeryStrong: 4,
20
+ });
21
21
  export class PasswordCheckResult {
22
22
  strength;
23
23
  /**
@@ -7,7 +7,7 @@ export async function checkPassword(password, { checkForPwned = true } = {}) {
7
7
  const zxcvbn = await getZxcvbn();
8
8
  const [zxcvbnResult, pwnedResult] = await Promise.all([
9
9
  zxcvbn(password),
10
- checkForPwned ? Promise.race([haveIBeenPwned(password).catch(() => undefined), timeout(1000).then(() => undefined)]) : undefined
10
+ checkForPwned ? Promise.race([haveIBeenPwned(password).catch(() => undefined), timeout(1000).then(() => undefined)]) : undefined,
11
11
  ]);
12
12
  const pwnedWarnings = (isNotNullOrUndefined(pwnedResult) && (pwnedResult > 0)) ? [passwordCheckLocalizationKeys.tstdl.passwordCheck.warnings.pwned[propertyName]] : [];
13
13
  const warnings = isNotNullOrUndefined(zxcvbnResult.feedback.warning)
@@ -19,7 +19,7 @@ export async function checkPassword(password, { checkForPwned = true } = {}) {
19
19
  strength: ((pwnedResult ?? 0) > 0) ? 0 : zxcvbnResult.score,
20
20
  pwned: pwnedResult,
21
21
  warnings,
22
- suggestions
22
+ suggestions,
23
23
  };
24
24
  }
25
25
  let zxcvbnAsyncInstance;
@@ -32,11 +32,9 @@ async function getZxcvbn() {
32
32
  async function importZxcvbn() {
33
33
  const [{ zxcvbnAsync, zxcvbnOptions }, common, english, german] = await Promise.all([
34
34
  import('@zxcvbn-ts/core'),
35
- /* eslint-disable @typescript-eslint/no-unnecessary-condition */
36
35
  import('@zxcvbn-ts/language-common'),
37
36
  import('@zxcvbn-ts/language-en'),
38
- import('@zxcvbn-ts/language-de')
39
- /* eslint-enable @typescript-eslint/no-unnecessary-condition */
37
+ import('@zxcvbn-ts/language-de'),
40
38
  ]);
41
39
  const options = {
42
40
  graphs: common.adjacencyGraphs,
@@ -44,8 +42,8 @@ async function importZxcvbn() {
44
42
  dictionary: {
45
43
  ...common.dictionary,
46
44
  ...english.dictionary,
47
- ...german.dictionary
48
- }
45
+ ...german.dictionary,
46
+ },
49
47
  };
50
48
  zxcvbnOptions.setOptions(options);
51
49
  return zxcvbnAsync;
@@ -21,7 +21,7 @@ export const germanPasswordCheckLocalization = {
21
21
  namesByThemselves: 'Einzelne Namen oder Nachnamen sind leicht zu erraten.',
22
22
  commonNames: 'Vornamen und Nachnamen sind leicht zu erraten.',
23
23
  userInputs: 'Es sollten keine persönlichen oder Seiten relevanten Daten vorkommen.',
24
- pwned: 'Ihr Kennwort wurde durch eine Datenpanne im Internet offengelegt (https://haveibeenpwned.com/passwords).'
24
+ pwned: 'Ihr Kennwort wurde durch eine Datenpanne im Internet offengelegt (https://haveibeenpwned.com/passwords).',
25
25
  },
26
26
  suggestions: {
27
27
  l33t: 'Vorhersehbare Buchstabenersetzungen wie \'@\' für \'a\' vermeiden.',
@@ -37,12 +37,12 @@ export const germanPasswordCheckLocalization = {
37
37
  anotherWord: 'Weitere Wörter, die weniger häufig vorkommen, hinzufügen.',
38
38
  useWords: 'Mehrere Wörter verwenden, aber allgemeine Phrasen vermeiden.',
39
39
  noNeed: 'Es ist möglich, starke Passwörter zu erstellen, ohne Symbole, Zahlen oder Großbuchstaben zu verwenden.',
40
- pwned: 'Wenn Sie dieses Kennwort an anderer Stelle verwenden, sollten Sie es ändern.'
41
- }
42
- }
43
- }
40
+ pwned: 'Wenn Sie dieses Kennwort an anderer Stelle verwenden, sollten Sie es ändern.',
41
+ },
42
+ },
43
+ },
44
44
  },
45
- enums: []
45
+ enums: [],
46
46
  };
47
47
  export const englishPasswordCheckLocalization = {
48
48
  language: { code: 'en', name: 'English' },
@@ -65,7 +65,7 @@ export const englishPasswordCheckLocalization = {
65
65
  namesByThemselves: 'Single names or surnames are easy to guess.',
66
66
  commonNames: 'Common names and surnames are easy to guess.',
67
67
  userInputs: 'There should not be any personal or page related data.',
68
- pwned: 'Your password was exposed by a data breach on the Internet (https://haveibeenpwned.com/passwords).'
68
+ pwned: 'Your password was exposed by a data breach on the Internet (https://haveibeenpwned.com/passwords).',
69
69
  },
70
70
  suggestions: {
71
71
  l33t: 'Avoid predictable letter substitutions like \'@\' for \'a\'.',
@@ -81,10 +81,10 @@ export const englishPasswordCheckLocalization = {
81
81
  anotherWord: 'Add more words that are less common.',
82
82
  useWords: 'Use multiple words, but avoid common phrases.',
83
83
  noNeed: 'You can create strong passwords without using symbols, numbers, or uppercase letters.',
84
- pwned: 'If you use this password elsewhere, you should change it.'
85
- }
86
- }
87
- }
84
+ pwned: 'If you use this password elsewhere, you should change it.',
85
+ },
86
+ },
87
+ },
88
88
  },
89
- enums: []
89
+ enums: [],
90
90
  };
@@ -21,7 +21,7 @@ import { Logger } from '../logger/logger.js';
21
21
  import { Optional } from '../schema/index.js';
22
22
  import { Template, TemplateService } from '../templates/index.js';
23
23
  import { finalizeStream } from '../utils/stream/finalize-stream.js';
24
- import { readableStreamFromPromise } from '../utils/stream/readable-stream-from-promise.js';
24
+ import { readableStreamFromPromise } from '../utils/stream/from-promise.js';
25
25
  import { readBinaryStream } from '../utils/stream/stream-reader.js';
26
26
  import { timeout } from '../utils/timing.js';
27
27
  import { isDefined } from '../utils/type-guards.js';
package/pdf/utils.d.ts CHANGED
@@ -1,3 +1,12 @@
1
1
  export declare function getPdfPageCount(file: string | Uint8Array | ReadableStream<Uint8Array>): Promise<number>;
2
2
  export declare function mergePdfs(pdfs: (string | Uint8Array | ReadableStream<Uint8Array>)[]): Promise<Uint8Array>;
3
3
  export declare function mergePdfsStream(pdfs: (string | Uint8Array | ReadableStream<Uint8Array>)[]): Promise<ReadableStream<Uint8Array>>;
4
+ /**
5
+ * Convert a PDF page to an image.
6
+ * @param file The PDF file to convert.
7
+ * @param page The page number to convert.
8
+ * @param size The size of the output image.
9
+ * @param format The format of the output image.
10
+ * @returns The converted image as a byte array.
11
+ */
12
+ export declare function pdfToImage(file: string | Uint8Array | ReadableStream<Uint8Array>, page: number, size: number, format: 'png' | 'jpeg' | 'tiff' | 'ps' | 'eps' | 'pdf' | 'svg'): Promise<Uint8Array>;
package/pdf/utils.js CHANGED
@@ -52,12 +52,12 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
52
52
  });
53
53
  import { TemporaryFile } from '../file/server/temporary-file.js';
54
54
  import { spawnCommand } from '../process/spawn.js';
55
- import { isString } from '../utils/type-guards.js';
55
+ import { isNotString, isString } from '../utils/type-guards.js';
56
56
  export async function getPdfPageCount(file) {
57
57
  const env_1 = { stack: [], error: void 0, hasError: false };
58
58
  try {
59
59
  const fileIsPath = isString(file);
60
- const tmpFile = __addDisposableResource(env_1, fileIsPath ? await TemporaryFile.from(file) : undefined, true);
60
+ const tmpFile = __addDisposableResource(env_1, fileIsPath ? undefined : await TemporaryFile.from(file), true);
61
61
  const path = fileIsPath ? file : tmpFile.path;
62
62
  const process = await spawnCommand('qpdf', ['--show-npages', path]);
63
63
  const { code } = await process.wait();
@@ -134,3 +134,20 @@ async function pdfunite(sourceFiles, resultFile) {
134
134
  throw new Error(errorOutput);
135
135
  }
136
136
  }
137
+ /**
138
+ * Convert a PDF page to an image.
139
+ * @param file The PDF file to convert.
140
+ * @param page The page number to convert.
141
+ * @param size The size of the output image.
142
+ * @param format The format of the output image.
143
+ * @returns The converted image as a byte array.
144
+ */
145
+ export async function pdfToImage(file, page, size, format) {
146
+ const path = isString(file) ? file : '-';
147
+ const process = await spawnCommand('pdftocairo', ['-f', String(page), '-l', String(page), '-scale-to', String(size), '-singlefile', `-${format}`, path, '-']);
148
+ process.handleNonZeroExitCode();
149
+ if (isNotString(file)) {
150
+ process.autoWrite(file);
151
+ }
152
+ return process.readOutputBytes();
153
+ }
@@ -1,15 +1,22 @@
1
1
  import type { ChildProcessWithoutNullStreams } from 'node:child_process';
2
+ type WaitOptions = {
3
+ throwOnNonZeroExitCode?: boolean;
4
+ };
5
+ type ProcessResult = {
6
+ code: number | null;
7
+ signal: string | null;
8
+ };
2
9
  export type SpawnCommandResult = TransformStream<Uint8Array, Uint8Array> & {
3
10
  process: ChildProcessWithoutNullStreams;
4
11
  stderr: ReadableStream<Uint8Array>;
5
12
  write(chunk: ReadableStream<Uint8Array> | Uint8Array | string, options?: StreamPipeOptions): Promise<void>;
13
+ autoWrite(chunk: ReadableStream<Uint8Array> | Uint8Array | string, options?: StreamPipeOptions): void;
6
14
  readOutputBytes(): Promise<Uint8Array>;
7
15
  readOutput(): Promise<string>;
8
16
  readErrorBytes(): Promise<Uint8Array>;
9
17
  readError(): Promise<string>;
10
- wait(): Promise<{
11
- code: number | null;
12
- signal: string | null;
13
- }>;
18
+ handleNonZeroExitCode(): void;
19
+ wait(options?: WaitOptions): Promise<ProcessResult>;
14
20
  };
15
21
  export declare function spawnCommand(command: string, args?: string[]): Promise<SpawnCommandResult>;
22
+ export {};
package/process/spawn.js CHANGED
@@ -1,15 +1,16 @@
1
1
  import { dynamicImport } from '../import.js';
2
+ import { LazyPromise } from '../promise/lazy-promise.js';
2
3
  import { decodeTextStream, encodeUtf8Stream } from '../utils/encoding.js';
3
4
  import { readBinaryStream, readTextStream } from '../utils/stream/stream-reader.js';
4
5
  import { toReadableStream } from '../utils/stream/to-readable-stream.js';
5
- import { isReadableStream, isString, isUint8Array } from '../utils/type-guards.js';
6
+ import { assertNotNullOrUndefinedPass, isReadableStream, isString, isUint8Array } from '../utils/type-guards.js';
6
7
  export async function spawnCommand(command, args) {
7
8
  const { spawn } = await dynamicImport('node:child_process');
8
9
  const { Readable, Writable } = await dynamicImport('node:stream');
9
10
  const process = spawn(command, args, { stdio: 'pipe' });
10
11
  await Promise.race([
11
12
  new Promise((resolve) => process.on('spawn', resolve)),
12
- new Promise((_, reject) => process.on('error', reject))
13
+ new Promise((_, reject) => process.on('error', reject)),
13
14
  ]);
14
15
  const readable = Readable.toWeb(process.stdout);
15
16
  const writable = Writable.toWeb(process.stdin);
@@ -25,6 +26,12 @@ export async function spawnCommand(command, args) {
25
26
  await toReadableStream(data).pipeThrough(encodeUtf8Stream()).pipeTo(writable, options);
26
27
  }
27
28
  }
29
+ function autoWrite(data, options) {
30
+ write(data, options).catch((error) => {
31
+ readable.cancel(error).catch(() => { });
32
+ writable.abort(error).catch(() => { });
33
+ });
34
+ }
28
35
  async function readOutputBytes() {
29
36
  return readBinaryStream(readable);
30
37
  }
@@ -38,18 +45,48 @@ export async function spawnCommand(command, args) {
38
45
  return readTextStream(stderr.pipeThrough(decodeTextStream()));
39
46
  }
40
47
  const signalPromise = new Promise((resolve) => process.on('close', (code, signal) => resolve({ code, signal })));
48
+ const nonZeroExitCodeError = new LazyPromise(async () => {
49
+ const result = await signalPromise;
50
+ if (result.code != 0) {
51
+ try {
52
+ const errorOutput = await readError();
53
+ return new Error(errorOutput.trim());
54
+ }
55
+ catch {
56
+ return new Error(`Process exited with code ${result.code} and signal ${result.signal}.`);
57
+ }
58
+ }
59
+ return null;
60
+ });
61
+ async function handleNonZeroExitCode() {
62
+ const error = await nonZeroExitCodeError;
63
+ if (error) {
64
+ console.log('ERROR HAPPENED', error);
65
+ await writable.abort(error).catch(() => { });
66
+ await readable.cancel(error).catch(() => { });
67
+ }
68
+ }
69
+ async function wait({ throwOnNonZeroExitCode = true } = {}) {
70
+ const result = await signalPromise;
71
+ const handleNonZeroExitCode = (result.code != 0) && throwOnNonZeroExitCode;
72
+ if (handleNonZeroExitCode) {
73
+ const error = await nonZeroExitCodeError;
74
+ throw assertNotNullOrUndefinedPass(error);
75
+ }
76
+ return result;
77
+ }
41
78
  return {
42
79
  process,
43
80
  readable,
44
81
  writable,
45
82
  stderr,
46
83
  write,
84
+ autoWrite,
47
85
  readOutputBytes,
48
86
  readOutput,
49
87
  readErrorBytes,
50
88
  readError,
51
- async wait() {
52
- return signalPromise;
53
- }
89
+ handleNonZeroExitCode: () => void handleNonZeroExitCode(),
90
+ wait,
54
91
  };
55
92
  }
@@ -34,12 +34,12 @@ let PostgresQueue = class PostgresQueue extends Queue {
34
34
  tries: 0,
35
35
  enqueueTimestamp: TRANSACTION_TIMESTAMP,
36
36
  lastDequeueTimestamp: null,
37
- data: sql `excluded.data`
37
+ data: sql `excluded.data`,
38
38
  };
39
39
  #dequeueQuery = and(eq(job.queue, this.#queueName), lt(job.tries, this.maxTries), or(isSqlNull(job.lastDequeueTimestamp), lte(sql `${job.lastDequeueTimestamp} + ${interval(this.processTimeout, 'milliseconds')}`, TRANSACTION_TIMESTAMP)));
40
40
  #dequeueUpdate = {
41
41
  tries: sql `${job.tries} + 1`,
42
- lastDequeueTimestamp: TRANSACTION_TIMESTAMP
42
+ lastDequeueTimestamp: TRANSACTION_TIMESTAMP,
43
43
  };
44
44
  async enqueue(data, options) {
45
45
  const jobs = await this.enqueueMany([{ data, tag: options?.tag, priority: options?.priority }], { uniqueTag: options?.uniqueTag, returnJobs: true });
@@ -53,7 +53,7 @@ let PostgresQueue = class PostgresQueue extends Queue {
53
53
  tries: 0,
54
54
  enqueueTimestamp: TRANSACTION_TIMESTAMP,
55
55
  lastDequeueTimestamp: null,
56
- data: item.data
56
+ data: item.data,
57
57
  }));
58
58
  const update = (options?.uniqueTag == UniqueTagStrategy.TakeNew)
59
59
  ? this.#takeNewUpdate
@@ -157,8 +157,8 @@ PostgresQueue = __decorate([
157
157
  argumentIdentityProvider: JSON.stringify,
158
158
  providers: [
159
159
  provide(EntityRepositoryConfig, { useValue: { schema: 'queue' } }),
160
- provide(DatabaseConfig, { useFactory: (_, context) => context.resolve(PostgresQueueModuleConfig).database ?? context.resolve(DatabaseConfig, undefined, { skipSelf: true }) })
161
- ]
160
+ provide(DatabaseConfig, { useFactory: (_, context) => context.resolve(PostgresQueueModuleConfig).database ?? context.resolve(DatabaseConfig, undefined, { skipSelf: true }) }),
161
+ ],
162
162
  })
163
163
  ], PostgresQueue);
164
164
  export { PostgresQueue };
package/queue/queue.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { CancellationSignal } from '../cancellation/token.js';
2
+ import { type EnumType } from '../enumeration/enumeration.js';
2
3
  import type { Resolvable, resolveArgumentType } from '../injector/interfaces.js';
3
4
  import type { Logger } from '../logger/logger.js';
4
5
  import { QueueEnqueueBatch } from './enqueue-batch.js';
@@ -19,10 +20,11 @@ export type Job<T> = {
19
20
  tries: number;
20
21
  };
21
22
  export declare const defaultJobPriority = 1000;
22
- export declare enum UniqueTagStrategy {
23
- KeepOld = 0,
24
- TakeNew = 1
25
- }
23
+ export declare const UniqueTagStrategy: {
24
+ readonly KeepOld: 0;
25
+ readonly TakeNew: 1;
26
+ };
27
+ export type UniqueTagStrategy = EnumType<typeof UniqueTagStrategy>;
26
28
  export type EnqueueOptions = {
27
29
  tag?: JobTag;
28
30
  priority?: number;
package/queue/queue.js CHANGED
@@ -1,14 +1,14 @@
1
+ import { defineEnum } from '../enumeration/enumeration.js';
1
2
  import { millisecondsPerMinute } from '../utils/units.js';
2
3
  import { QueueEnqueueBatch } from './enqueue-batch.js';
3
4
  export const defaultJobPriority = 1000;
4
- export var UniqueTagStrategy;
5
- (function (UniqueTagStrategy) {
6
- UniqueTagStrategy[UniqueTagStrategy["KeepOld"] = 0] = "KeepOld";
7
- UniqueTagStrategy[UniqueTagStrategy["TakeNew"] = 1] = "TakeNew";
8
- })(UniqueTagStrategy || (UniqueTagStrategy = {}));
5
+ export const UniqueTagStrategy = defineEnum('UniqueTagStrategy', {
6
+ KeepOld: 0,
7
+ TakeNew: 1,
8
+ });
9
9
  export const defaultQueueConfig = {
10
10
  processTimeout: millisecondsPerMinute,
11
- maxTries: 3
11
+ maxTries: 3,
12
12
  };
13
13
  export class Queue {
14
14
  batch() {
@@ -2,7 +2,8 @@ import type { JsonPath } from '../../json-path/json-path.js';
2
2
  import type { OneOrMany as OneOrManyType } from '../../types.js';
3
3
  import { type SchemaDecoratorOptions, type SchemaPropertyDecorator } from '../decorators/index.js';
4
4
  import { Schema, type SchemaOptions, type SchemaTestable, type SchemaTestOptions, type SchemaTestResult } from '../schema.js';
5
- export type OneOrManySchemaOptions<T> = SchemaOptions<T | T[]>;
5
+ import { type ArraySchemaOptions } from './array.js';
6
+ export type OneOrManySchemaOptions<T> = SchemaOptions<T | T[]> & Pick<ArraySchemaOptions<T>, 'minimum' | 'maximum'>;
6
7
  export type OneOrMany<T> = OneOrManyType<T>;
7
8
  export declare class OneOrManySchema<T> extends Schema<T | T[]> {
8
9
  readonly name: string;
@@ -10,7 +10,7 @@ export class OneOrManySchema extends Schema {
10
10
  constructor(schema, options) {
11
11
  super(options);
12
12
  const oneSchema = schemaTestableToSchema(schema);
13
- this.schema = union(oneSchema, array(oneSchema));
13
+ this.schema = union(oneSchema, array(oneSchema, { minimum: options?.minimum, maximum: options?.maximum }));
14
14
  lazyProperty(this, 'name', () => `OneOrMany[${oneSchema.name}]`);
15
15
  }
16
16
  _test(value, path, options) {
@@ -1,6 +1,6 @@
1
+ import type { estypes } from '@elastic/elasticsearch';
1
2
  import type { Entity } from '../../../database/index.js';
2
3
  import type { DeepFlatten, StringMap, TypedOmit } from '../../../types.js';
3
- import type { estypes } from '@elastic/elasticsearch';
4
4
  export type ElasticIndexMapping<T extends Entity = Entity> = TypedOmit<estypes.MappingTypeMapping, 'properties'> & ElasticNestedIndexMapping<TypedOmit<T, 'id'>>;
5
5
  export type ElasticNestedIndexMapping<T> = {
6
6
  properties: {
@@ -1,4 +1,3 @@
1
- /* eslint-disable @typescript-eslint/naming-convention */
2
1
  import { mergeObjects } from '../../../utils/object/merge.js';
3
2
  export function mergeElasticSearchMappings(mappings) {
4
3
  return mergeObjects(mappings);
@@ -1,11 +1,10 @@
1
- import type { Client } from '@elastic/elasticsearch';
1
+ import type { Client, estypes } from '@elastic/elasticsearch';
2
2
  import type { Entity, Query, QueryOptions } from '../../database/index.js';
3
3
  import type { AfterResolve } from '../../injector/interfaces.js';
4
4
  import { afterResolve } from '../../injector/interfaces.js';
5
5
  import type { Logger } from '../../logger/index.js';
6
6
  import type { SearchResult } from '../../search-index/index.js';
7
7
  import { SearchIndex } from '../../search-index/index.js';
8
- import type { estypes } from '@elastic/elasticsearch';
9
8
  import type { ElasticSearchIndexConfig } from './config.js';
10
9
  import { KeywordRewriter } from './keyword-rewriter.js';
11
10
  import type { ElasticIndexMapping } from './model/index.js';
@@ -43,10 +43,10 @@ export class ElasticSearchIndex extends SearchIndex {
43
43
  await this.client.indices.close({ index: this.indexName });
44
44
  this.logger.info(`closed index ${this.indexName} for updates`);
45
45
  this.logger.info(`updating settings for index ${this.indexName}`);
46
- await this.client.indices.putSettings({ index: this.indexName, body: this.indexSettings });
46
+ await this.client.indices.putSettings({ index: this.indexName, settings: this.indexSettings });
47
47
  this.logger.info(`updated settings for index ${this.indexName}`);
48
48
  this.logger.info(`updating mapping for index ${this.indexName}`);
49
- await this.client.indices.putMapping({ index: this.indexName, body: this.indexMapping });
49
+ await this.client.indices.putMapping({ index: this.indexName, ...this.indexMapping });
50
50
  this.logger.info(`updated mapping for index ${this.indexName}`);
51
51
  this.logger.info(`reopening index ${this.indexName}`);
52
52
  await this.client.indices.open({ index: this.indexName });
@@ -82,7 +82,7 @@ export class ElasticSearchIndex extends SearchIndex {
82
82
  }
83
83
  async deleteByQuery(query) {
84
84
  const queryBody = convertQuery(query);
85
- await this.client.deleteByQuery({ index: this.indexName, body: { query: queryBody } });
85
+ await this.client.deleteByQuery({ index: this.indexName, query: queryBody });
86
86
  }
87
87
  // eslint-disable-next-line max-statements
88
88
  async search(searchQueryOrCursor, options) {
package/types.d.ts CHANGED
@@ -100,6 +100,7 @@ export type OptionalKeys<T> = {
100
100
  [K in keyof T]-?: ObjectLiteral extends Pick<T, K> ? K : never;
101
101
  }[keyof T];
102
102
  export type TypedOmit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
103
+ export type TypedExclude<T, U extends T> = T extends U ? never : T;
103
104
  export type TypedExtract<T, U extends T> = T extends U ? T : never;
104
105
  export type ReplaceIfUnknown<T, U> = IfUnknown<T, U, T>;
105
106
  export type OmitNever<T extends Record> = {
@@ -0,0 +1,9 @@
1
+ export type AsyncHook<T, C = never, R = unknown> = {
2
+ register: (handler: AsyncHookHandler<T, C, R>) => AsyncHookHandlerRegistration;
3
+ trigger: [C] extends [never] ? ((value: T) => Promise<R[]>) : ((value: T, context: C) => Promise<R[]>);
4
+ };
5
+ export type AsyncHookHandler<T, C, R> = [C] extends [never] ? ((value: T) => R | Promise<R>) : ((value: T, context: C) => R | Promise<R>);
6
+ export type AsyncHookHandlerRegistration = {
7
+ unregister: () => void;
8
+ };
9
+ export declare function asyncHook<T, C = never, R = unknown>(): AsyncHook<T, C, R>;
@@ -0,0 +1,21 @@
1
+ export function asyncHook() {
2
+ const handlers = [];
3
+ return {
4
+ register: (handler) => {
5
+ handlers.push(handler);
6
+ return {
7
+ unregister() {
8
+ handlers.splice(handlers.indexOf(handler));
9
+ },
10
+ };
11
+ },
12
+ trigger: async (value, context) => {
13
+ let returnValues = [];
14
+ for (const handler of handlers) {
15
+ const returnValue = await handler(value, context);
16
+ returnValues.push(returnValue);
17
+ }
18
+ return returnValues;
19
+ },
20
+ };
21
+ }
@@ -0,0 +1 @@
1
+ export * from './async-hook.js';
@@ -0,0 +1 @@
1
+ export * from './async-hook.js';
@@ -1,7 +1,7 @@
1
1
  import { dynamicImport } from '../import.js';
2
2
  import { encodeBase64, encodeBase64Url } from './base64.js';
3
3
  import { decodeText, encodeHex, encodeUtf8 } from './encoding.js';
4
- import { readableStreamFromPromise } from './stream/readable-stream-from-promise.js';
4
+ import { readableStreamFromPromise } from './stream/from-promise.js';
5
5
  import { assertDefined, isNotNullOrUndefined } from './type-guards.js';
6
6
  import { zBase32Encode } from './z-base32.js';
7
7
  export function compressString(input, algorithm, options) {
@@ -0,0 +1,6 @@
1
+ import type { AbstractConstructor } from '../../types.js';
2
+ declare class EmptyClass {
3
+ }
4
+ export declare function getClassOfName(name: string): typeof EmptyClass;
5
+ export declare function getClassOfName<T extends AbstractConstructor>(name: string, extend: T): T;
6
+ export {};