@zintrust/core 0.1.15 → 0.1.17

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 (120) hide show
  1. package/README.md +2 -2
  2. package/package.json +1 -1
  3. package/public/index.html +1 -1
  4. package/src/cli/CLI.d.ts.map +1 -1
  5. package/src/cli/CLI.js +6 -0
  6. package/src/cli/commands/BroadcastWorkCommand.d.ts +10 -0
  7. package/src/cli/commands/BroadcastWorkCommand.d.ts.map +1 -0
  8. package/src/cli/commands/BroadcastWorkCommand.js +16 -0
  9. package/src/cli/commands/NotificationWorkCommand.d.ts +10 -0
  10. package/src/cli/commands/NotificationWorkCommand.d.ts.map +1 -0
  11. package/src/cli/commands/NotificationWorkCommand.js +16 -0
  12. package/src/cli/commands/QueueCommand.d.ts +10 -0
  13. package/src/cli/commands/QueueCommand.d.ts.map +1 -0
  14. package/src/cli/commands/QueueCommand.js +63 -0
  15. package/src/cli/commands/QueueWorkCommandUtils.d.ts +10 -0
  16. package/src/cli/commands/QueueWorkCommandUtils.d.ts.map +1 -0
  17. package/src/cli/commands/QueueWorkCommandUtils.js +43 -0
  18. package/src/cli/commands/createKindWorkCommand.d.ts +9 -0
  19. package/src/cli/commands/createKindWorkCommand.d.ts.map +1 -0
  20. package/src/cli/commands/createKindWorkCommand.js +33 -0
  21. package/src/cli/commands/index.d.ts +3 -0
  22. package/src/cli/commands/index.d.ts.map +1 -1
  23. package/src/cli/commands/index.js +3 -0
  24. package/src/cli/scaffolding/ModelGenerator.d.ts.map +1 -1
  25. package/src/cli/scaffolding/ModelGenerator.js +1 -0
  26. package/src/cli/scaffolding/ProjectScaffolder.d.ts.map +1 -1
  27. package/src/cli/scaffolding/ProjectScaffolder.js +2 -1
  28. package/src/cli/workers/QueueWorkRunner.d.ts +23 -0
  29. package/src/cli/workers/QueueWorkRunner.d.ts.map +1 -0
  30. package/src/cli/workers/QueueWorkRunner.js +142 -0
  31. package/src/collections/Collection.d.ts +30 -0
  32. package/src/collections/Collection.d.ts.map +1 -0
  33. package/src/collections/Collection.js +146 -0
  34. package/src/collections/index.d.ts +3 -0
  35. package/src/collections/index.d.ts.map +1 -0
  36. package/src/collections/index.js +1 -0
  37. package/src/config/env.d.ts +2 -0
  38. package/src/config/env.d.ts.map +1 -1
  39. package/src/config/env.js +4 -0
  40. package/src/config/index.d.ts +3 -0
  41. package/src/config/index.d.ts.map +1 -1
  42. package/src/config/security.d.ts +4 -1
  43. package/src/config/security.d.ts.map +1 -1
  44. package/src/config/security.js +9 -1
  45. package/src/events/EventDispatcher.d.ts +16 -0
  46. package/src/events/EventDispatcher.d.ts.map +1 -0
  47. package/src/events/EventDispatcher.js +90 -0
  48. package/src/events/index.d.ts +3 -0
  49. package/src/events/index.d.ts.map +1 -0
  50. package/src/events/index.js +1 -0
  51. package/src/features/Queue.d.ts +1 -1
  52. package/src/features/Queue.d.ts.map +1 -1
  53. package/src/features/Queue.js +2 -2
  54. package/src/http/Response.d.ts +2 -2
  55. package/src/http/Response.d.ts.map +1 -1
  56. package/src/index.d.ts +12 -0
  57. package/src/index.d.ts.map +1 -1
  58. package/src/index.js +12 -0
  59. package/src/middleware/CsrfMiddleware.d.ts.map +1 -1
  60. package/src/middleware/CsrfMiddleware.js +20 -25
  61. package/src/middleware/SessionMiddleware.d.ts +8 -0
  62. package/src/middleware/SessionMiddleware.d.ts.map +1 -0
  63. package/src/middleware/SessionMiddleware.js +15 -0
  64. package/src/node-singletons/crypto.d.ts +1 -1
  65. package/src/node-singletons/crypto.d.ts.map +1 -1
  66. package/src/node-singletons/crypto.js +1 -1
  67. package/src/orm/Model.d.ts +15 -0
  68. package/src/orm/Model.d.ts.map +1 -1
  69. package/src/orm/Model.js +57 -8
  70. package/src/orm/QueryBuilder.d.ts +9 -1
  71. package/src/orm/QueryBuilder.d.ts.map +1 -1
  72. package/src/orm/QueryBuilder.js +54 -2
  73. package/src/scripts/TemplateSync.js +23 -1
  74. package/src/security/EncryptedEnvelope.d.ts +77 -0
  75. package/src/security/EncryptedEnvelope.d.ts.map +1 -0
  76. package/src/security/EncryptedEnvelope.js +256 -0
  77. package/src/security/PasswordResetTokenBroker.d.ts +39 -0
  78. package/src/security/PasswordResetTokenBroker.d.ts.map +1 -0
  79. package/src/security/PasswordResetTokenBroker.js +131 -0
  80. package/src/security/StartupSecretValidation.d.ts.map +1 -1
  81. package/src/security/StartupSecretValidation.js +72 -0
  82. package/src/session/SessionManager.d.ts +39 -0
  83. package/src/session/SessionManager.d.ts.map +1 -0
  84. package/src/session/SessionManager.js +149 -0
  85. package/src/session/index.d.ts +3 -0
  86. package/src/session/index.d.ts.map +1 -0
  87. package/src/session/index.js +1 -0
  88. package/src/templates/features/Queue.ts.tpl +5 -4
  89. package/src/templates/project/basic/config/FileLogWriter.ts.tpl +4 -3
  90. package/src/templates/project/basic/config/SecretsManager.ts.tpl +1 -1
  91. package/src/templates/project/basic/config/broadcast.ts.tpl +2 -2
  92. package/src/templates/project/basic/config/cache.ts.tpl +2 -2
  93. package/src/templates/project/basic/config/database.ts.tpl +2 -2
  94. package/src/templates/project/basic/config/env.ts.tpl +5 -0
  95. package/src/templates/project/basic/config/features.ts.tpl +2 -2
  96. package/src/templates/project/basic/config/logger.ts.tpl +0 -2
  97. package/src/templates/project/basic/config/logging/HttpLogger.ts.tpl +1 -1
  98. package/src/templates/project/basic/config/logging/SlackLogger.ts.tpl +1 -1
  99. package/src/templates/project/basic/config/mail.ts.tpl +2 -2
  100. package/src/templates/project/basic/config/microservices.ts.tpl +1 -1
  101. package/src/templates/project/basic/config/middleware.ts.tpl +6 -9
  102. package/src/templates/project/basic/config/notification.ts.tpl +2 -2
  103. package/src/templates/project/basic/config/security.ts.tpl +12 -3
  104. package/src/templates/project/basic/config/storage.ts.tpl +2 -2
  105. package/src/templates/project/basic/config/type.ts.tpl +2 -2
  106. package/src/tools/broadcast/Broadcast.d.ts +8 -0
  107. package/src/tools/broadcast/Broadcast.d.ts.map +1 -1
  108. package/src/tools/broadcast/Broadcast.js +23 -0
  109. package/src/tools/notification/Notification.d.ts +10 -0
  110. package/src/tools/notification/Notification.d.ts.map +1 -1
  111. package/src/tools/notification/Notification.js +21 -0
  112. package/src/workers/BroadcastWorker.d.ts +22 -0
  113. package/src/workers/BroadcastWorker.d.ts.map +1 -0
  114. package/src/workers/BroadcastWorker.js +24 -0
  115. package/src/workers/NotificationWorker.d.ts +22 -0
  116. package/src/workers/NotificationWorker.d.ts.map +1 -0
  117. package/src/workers/NotificationWorker.js +23 -0
  118. package/src/workers/createQueueWorker.d.ts +24 -0
  119. package/src/workers/createQueueWorker.d.ts.map +1 -0
  120. package/src/workers/createQueueWorker.js +114 -0
package/README.md CHANGED
@@ -16,7 +16,7 @@ cd my-app
16
16
  zin add db:sqlite
17
17
 
18
18
  # Start development
19
- npm run dev
19
+ zin start
20
20
  ```
21
21
 
22
22
  Your API is now running at `http://localhost:7777`
@@ -169,7 +169,7 @@ export function registerRoutes(app: Application): void {
169
169
  ### 3. Run Your API
170
170
 
171
171
  ```bash
172
- npm run dev
172
+ zin start
173
173
  ```
174
174
 
175
175
  Test it:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zintrust/core",
3
- "version": "0.1.15",
3
+ "version": "0.1.17",
4
4
  "description": "Production-grade TypeScript backend framework for JavaScript",
5
5
  "homepage": "https://zintrust.com",
6
6
  "repository": {
package/public/index.html CHANGED
@@ -366,7 +366,7 @@
366
366
  >
367
367
  <a
368
368
  class="hover:text-slate-900 dark:hover:text-white"
369
- href="https://linkedin.com/company/zintrust"
369
+ href="https://linkedin.com/company/zintrustjs"
370
370
  target="_blank"
371
371
  >LinkedIn</a
372
372
  >
@@ -1 +1 @@
1
- {"version":3,"file":"CLI.d.ts","sourceRoot":"","sources":["../../../src/cli/CLI.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAyBH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,MAAM,WAAW,IAAI;IACnB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,UAAU,IAAI,OAAO,CAAC;CACvB;AAsLD;;;;;;;GAOG;AACH,eAAO,MAAM,GAAG;cACJ,IAAI;EAed,CAAC"}
1
+ {"version":3,"file":"CLI.d.ts","sourceRoot":"","sources":["../../../src/cli/CLI.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA4BH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,MAAM,WAAW,IAAI;IACnB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,UAAU,IAAI,OAAO,CAAC;CACvB;AAyLD;;;;;;;GAOG;AACH,eAAO,MAAM,GAAG;cACJ,IAAI;EAed,CAAC"}
package/src/cli/CLI.js CHANGED
@@ -3,6 +3,7 @@
3
3
  * Orchestrates all CLI commands using Commander
4
4
  */
5
5
  import { AddCommand } from './commands/AddCommand.js';
6
+ import { BroadcastWorkCommand } from './commands/BroadcastWorkCommand.js';
6
7
  import { ConfigCommand } from './commands/ConfigCommand.js';
7
8
  import { D1MigrateCommand } from './commands/D1MigrateCommand.js';
8
9
  import { DebugCommand } from './commands/DebugCommand.js';
@@ -12,9 +13,11 @@ import { MakeMailTemplateCommand } from './commands/MakeMailTemplateCommand.js';
12
13
  import { MakeNotificationTemplateCommand } from './commands/MakeNotificationTemplateCommand.js';
13
14
  import { MigrateCommand } from './commands/MigrateCommand.js';
14
15
  import { NewCommand } from './commands/NewCommand.js';
16
+ import { NotificationWorkCommand } from './commands/NotificationWorkCommand.js';
15
17
  import { PluginCommand } from './commands/PluginCommand.js';
16
18
  import { PrepareCommand } from './commands/PrepareCommand.js';
17
19
  import { QACommand } from './commands/QACommand.js';
20
+ import { QueueCommand } from './commands/QueueCommand.js';
18
21
  import { SecretsCommand } from './commands/SecretsCommand.js';
19
22
  import { SimulateCommand } from './commands/SimulateCommand.js';
20
23
  import { StartCommand } from './commands/StartCommand.js';
@@ -68,6 +71,9 @@ const registerCommands = (program) => {
68
71
  PrepareCommand,
69
72
  AddCommand.create(),
70
73
  StartCommand.create(),
74
+ QueueCommand.create(),
75
+ BroadcastWorkCommand.create(),
76
+ NotificationWorkCommand.create(),
71
77
  MigrateCommand.create(),
72
78
  D1MigrateCommand.create(),
73
79
  DebugCommand.create(),
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Broadcast Work Command
3
+ * Alias to work a broadcast queue.
4
+ */
5
+ import { type IBaseCommand } from '../BaseCommand';
6
+ export declare const BroadcastWorkCommand: Readonly<{
7
+ create(): IBaseCommand;
8
+ }>;
9
+ export default BroadcastWorkCommand;
10
+ //# sourceMappingURL=BroadcastWorkCommand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BroadcastWorkCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/BroadcastWorkCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGrD,eAAO,MAAM,oBAAoB;cACrB,YAAY;EAQtB,CAAC;AAEH,eAAe,oBAAoB,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Broadcast Work Command
3
+ * Alias to work a broadcast queue.
4
+ */
5
+ import { createKindWorkCommand } from '../commands/createKindWorkCommand.js';
6
+ export const BroadcastWorkCommand = Object.freeze({
7
+ create() {
8
+ return createKindWorkCommand({
9
+ name: 'broadcast:work',
10
+ description: 'Work queued broadcasts',
11
+ kind: 'broadcast',
12
+ helpHint: 'zin broadcast:work --help',
13
+ });
14
+ },
15
+ });
16
+ export default BroadcastWorkCommand;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Notification Work Command
3
+ * Alias to work a notification queue.
4
+ */
5
+ import { type IBaseCommand } from '../BaseCommand';
6
+ export declare const NotificationWorkCommand: Readonly<{
7
+ create(): IBaseCommand;
8
+ }>;
9
+ export default NotificationWorkCommand;
10
+ //# sourceMappingURL=NotificationWorkCommand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotificationWorkCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/NotificationWorkCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGrD,eAAO,MAAM,uBAAuB;cACxB,YAAY;EAQtB,CAAC;AAEH,eAAe,uBAAuB,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Notification Work Command
3
+ * Alias to work a notification queue.
4
+ */
5
+ import { createKindWorkCommand } from '../commands/createKindWorkCommand.js';
6
+ export const NotificationWorkCommand = Object.freeze({
7
+ create() {
8
+ return createKindWorkCommand({
9
+ name: 'notification:work',
10
+ description: 'Work queued notifications',
11
+ kind: 'notification',
12
+ helpHint: 'zin notification:work --help',
13
+ });
14
+ },
15
+ });
16
+ export default NotificationWorkCommand;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Queue Command
3
+ * Run queued jobs via the framework CLI.
4
+ */
5
+ import { type IBaseCommand } from '../BaseCommand';
6
+ export declare const QueueCommand: Readonly<{
7
+ create(): IBaseCommand;
8
+ }>;
9
+ export default QueueCommand;
10
+ //# sourceMappingURL=QueueCommand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QueueCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/QueueCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAoC,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAYvF,eAAO,MAAM,YAAY;cACb,YAAY;EA0EtB,CAAC;AAEH,eAAe,YAAY,CAAC"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Queue Command
3
+ * Run queued jobs via the framework CLI.
4
+ */
5
+ import { BaseCommand } from '../BaseCommand.js';
6
+ import { QueueWorkCommandUtils } from '../commands/QueueWorkCommandUtils.js';
7
+ import { QueueWorkRunner } from '../workers/QueueWorkRunner.js';
8
+ export const QueueCommand = Object.freeze({
9
+ create() {
10
+ return BaseCommand.create({
11
+ name: 'queue',
12
+ description: 'Work queued jobs (broadcast/notification)',
13
+ addOptions: (command) => {
14
+ command
15
+ .argument('<queueName>', 'Queue name to work')
16
+ .option('--timeout <seconds>', 'Stop after this many seconds (default: 10)')
17
+ .option('--retry <count>', 'Retries after first attempt (default: 3)')
18
+ .option('--max-items <count>', 'Max items to process in one run (default: 1000)')
19
+ .option('--driver <name>', 'Queue driver name (default: from QUEUE_DRIVER)');
20
+ command
21
+ .command('work <kind> <queueName>')
22
+ .alias('w')
23
+ .description('Work a queue with explicit kind (broadcast|notification)')
24
+ .option('--timeout <seconds>', 'Stop after this many seconds (default: 10)')
25
+ .option('--retry <count>', 'Retries after first attempt (default: 3)')
26
+ .option('--max-items <count>', 'Max items to process in one run (default: 1000)')
27
+ .option('--driver <name>', 'Queue driver name (default: from QUEUE_DRIVER)')
28
+ .action(async (kindRaw, queueName, subOptions) => {
29
+ const kind = QueueWorkRunner.parseKind(kindRaw);
30
+ const timeoutSeconds = QueueWorkCommandUtils.parsePositiveInt(subOptions['timeout'], '--timeout');
31
+ const retry = QueueWorkCommandUtils.parseNonNegativeInt(subOptions['retry'], '--retry');
32
+ const maxItems = QueueWorkCommandUtils.parsePositiveInt(subOptions['maxItems'], '--max-items');
33
+ const driverName = QueueWorkCommandUtils.normalizeDriverName(subOptions['driver']);
34
+ const result = await QueueWorkRunner.run({
35
+ kind,
36
+ queueName,
37
+ timeoutSeconds,
38
+ retry,
39
+ maxItems,
40
+ driverName,
41
+ });
42
+ QueueWorkCommandUtils.logSummary(queueName, kind, result);
43
+ });
44
+ },
45
+ execute: async (options) => {
46
+ const queueName = QueueWorkCommandUtils.requireQueueNameFromArgs(options.args, 'zin queue --help');
47
+ const timeoutSeconds = QueueWorkCommandUtils.parsePositiveInt(options.timeout, '--timeout');
48
+ const retry = QueueWorkCommandUtils.parseNonNegativeInt(options.retry, '--retry');
49
+ const maxItems = QueueWorkCommandUtils.parsePositiveInt(options.maxItems, '--max-items');
50
+ const driverName = QueueWorkCommandUtils.normalizeDriverName(options.driver);
51
+ const result = await QueueWorkRunner.run({
52
+ queueName,
53
+ timeoutSeconds,
54
+ retry,
55
+ maxItems,
56
+ driverName,
57
+ });
58
+ QueueWorkCommandUtils.logSummary(queueName, 'auto', result);
59
+ },
60
+ });
61
+ },
62
+ });
63
+ export default QueueCommand;
@@ -0,0 +1,10 @@
1
+ import { type QueueWorkRunnerResult } from '../workers/QueueWorkRunner';
2
+ export declare const QueueWorkCommandUtils: Readonly<{
3
+ parsePositiveInt: (value: unknown, flag: string) => number | undefined;
4
+ parseNonNegativeInt: (value: unknown, flag: string) => number | undefined;
5
+ normalizeDriverName: (value: unknown) => string | undefined;
6
+ requireQueueNameFromArgs: (args: unknown[] | undefined, helpHint: string) => string;
7
+ logSummary: (queueName: string, kindLabel: string, result: QueueWorkRunnerResult) => void;
8
+ }>;
9
+ export default QueueWorkCommandUtils;
10
+ //# sourceMappingURL=QueueWorkCommandUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QueueWorkCommandUtils.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/QueueWorkCommandUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAI1E,eAAO,MAAM,qBAAqB;8BACN,OAAO,QAAQ,MAAM,KAAG,MAAM,GAAG,SAAS;iCAcvC,OAAO,QAAQ,MAAM,KAAG,MAAM,GAAG,SAAS;iCAc1C,OAAO,KAAG,MAAM,GAAG,SAAS;qCAKxB,OAAO,EAAE,GAAG,SAAS,YAAY,MAAM,KAAG,MAAM;4BAQzD,MAAM,aAAa,MAAM,UAAU,qBAAqB,KAAG,IAAI;EAKvF,CAAC;AAEH,eAAe,qBAAqB,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { Logger } from '../../config/logger.js';
2
+ import { ErrorFactory } from '../../exceptions/ZintrustError.js';
3
+ export const QueueWorkCommandUtils = Object.freeze({
4
+ parsePositiveInt: (value, flag) => {
5
+ if (value === undefined)
6
+ return undefined;
7
+ const raw = String(value).trim();
8
+ if (raw === '')
9
+ return undefined;
10
+ const n = Number.parseInt(raw, 10);
11
+ if (!Number.isFinite(n) || n <= 0) {
12
+ throw ErrorFactory.createCliError(`Error: Invalid ${flag} '${raw}'. Expected a positive integer.`);
13
+ }
14
+ return n;
15
+ },
16
+ parseNonNegativeInt: (value, flag) => {
17
+ if (value === undefined)
18
+ return undefined;
19
+ const raw = String(value).trim();
20
+ if (raw === '')
21
+ return undefined;
22
+ const n = Number.parseInt(raw, 10);
23
+ if (!Number.isFinite(n) || n < 0) {
24
+ throw ErrorFactory.createCliError(`Error: Invalid ${flag} '${raw}'. Expected a non-negative integer.`);
25
+ }
26
+ return n;
27
+ },
28
+ normalizeDriverName: (value) => {
29
+ const raw = typeof value === 'string' ? value.trim() : '';
30
+ return raw === '' ? undefined : raw;
31
+ },
32
+ requireQueueNameFromArgs: (args, helpHint) => {
33
+ const queueName = typeof args?.[0] === 'string' ? String(args[0]) : '';
34
+ if (queueName.trim() === '') {
35
+ throw ErrorFactory.createCliError(`Error: Missing <queueName>. Try '${helpHint}'.`);
36
+ }
37
+ return queueName;
38
+ },
39
+ logSummary: (queueName, kindLabel, result) => {
40
+ Logger.info(`Queue work complete (${kindLabel}) for '${queueName}': processed=${result.processed} retried=${result.retried} dropped=${result.dropped} notDueRequeued=${result.notDueRequeued} unknown=${result.unknown}`);
41
+ },
42
+ });
43
+ export default QueueWorkCommandUtils;
@@ -0,0 +1,9 @@
1
+ import { type IBaseCommand } from '../BaseCommand';
2
+ import { type QueueWorkKind } from '../workers/QueueWorkRunner';
3
+ export declare function createKindWorkCommand(options: {
4
+ name: string;
5
+ description: string;
6
+ kind: QueueWorkKind;
7
+ helpHint: string;
8
+ }): IBaseCommand;
9
+ //# sourceMappingURL=createKindWorkCommand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createKindWorkCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/createKindWorkCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEvF,OAAO,EAAmB,KAAK,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAUnF,wBAAgB,qBAAqB,CAAC,OAAO,EAAE;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,aAAa,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,YAAY,CAsCf"}
@@ -0,0 +1,33 @@
1
+ import { BaseCommand } from '../BaseCommand.js';
2
+ import { QueueWorkCommandUtils } from '../commands/QueueWorkCommandUtils.js';
3
+ import { QueueWorkRunner } from '../workers/QueueWorkRunner.js';
4
+ export function createKindWorkCommand(options) {
5
+ return BaseCommand.create({
6
+ name: options.name,
7
+ description: options.description,
8
+ addOptions: (command) => {
9
+ command
10
+ .argument('<queueName>', 'Queue name to work')
11
+ .option('--timeout <seconds>', 'Stop after this many seconds (default: 10)')
12
+ .option('--retry <count>', 'Retries after first attempt (default: 3)')
13
+ .option('--max-items <count>', 'Max items to process in one run (default: 1000)')
14
+ .option('--driver <name>', 'Queue driver name (default: from QUEUE_DRIVER)');
15
+ },
16
+ execute: async (cmdOptions) => {
17
+ const queueName = QueueWorkCommandUtils.requireQueueNameFromArgs(cmdOptions.args, options.helpHint);
18
+ const timeoutSeconds = QueueWorkCommandUtils.parsePositiveInt(cmdOptions.timeout, '--timeout');
19
+ const retry = QueueWorkCommandUtils.parseNonNegativeInt(cmdOptions.retry, '--retry');
20
+ const maxItems = QueueWorkCommandUtils.parsePositiveInt(cmdOptions.maxItems, '--max-items');
21
+ const driverName = QueueWorkCommandUtils.normalizeDriverName(cmdOptions.driver);
22
+ const result = await QueueWorkRunner.run({
23
+ kind: options.kind,
24
+ queueName,
25
+ timeoutSeconds,
26
+ retry,
27
+ maxItems,
28
+ driverName,
29
+ });
30
+ QueueWorkCommandUtils.logSummary(queueName, options.kind, result);
31
+ },
32
+ });
33
+ }
@@ -2,6 +2,7 @@
2
2
  * CLI Commands Module Index
3
3
  */
4
4
  export { AddCommand } from '../commands/AddCommand';
5
+ export { BroadcastWorkCommand } from '../commands/BroadcastWorkCommand';
5
6
  export { ConfigCommand } from '../commands/ConfigCommand';
6
7
  export { DebugCommand } from '../commands/DebugCommand';
7
8
  export { LogsCleanupCommand } from '../commands/LogsCleanupCommand';
@@ -9,7 +10,9 @@ export { MakeMailTemplateCommand } from '../commands/MakeMailTemplateCommand';
9
10
  export { MakeNotificationTemplateCommand } from '../commands/MakeNotificationTemplateCommand';
10
11
  export { MigrateCommand } from '../commands/MigrateCommand';
11
12
  export { NewCommand } from '../commands/NewCommand';
13
+ export { NotificationWorkCommand } from '../commands/NotificationWorkCommand';
12
14
  export { PrepareCommand } from '../commands/PrepareCommand';
15
+ export { QueueCommand } from '../commands/QueueCommand';
13
16
  export { SecretsCommand } from '../commands/SecretsCommand';
14
17
  export { StartCommand } from '../commands/StartCommand';
15
18
  export { TemplatesCommand } from '../commands/TemplatesCommand';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,+BAA+B,EAAE,MAAM,+CAA+C,CAAC;AAChG,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,+BAA+B,EAAE,MAAM,+CAA+C,CAAC;AAChG,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC"}
@@ -2,6 +2,7 @@
2
2
  * CLI Commands Module Index
3
3
  */
4
4
  export { AddCommand } from '../commands/AddCommand.js';
5
+ export { BroadcastWorkCommand } from '../commands/BroadcastWorkCommand.js';
5
6
  export { ConfigCommand } from '../commands/ConfigCommand.js';
6
7
  export { DebugCommand } from '../commands/DebugCommand.js';
7
8
  export { LogsCleanupCommand } from '../commands/LogsCleanupCommand.js';
@@ -9,7 +10,9 @@ export { MakeMailTemplateCommand } from '../commands/MakeMailTemplateCommand.js'
9
10
  export { MakeNotificationTemplateCommand } from '../commands/MakeNotificationTemplateCommand.js';
10
11
  export { MigrateCommand } from '../commands/MigrateCommand.js';
11
12
  export { NewCommand } from '../commands/NewCommand.js';
13
+ export { NotificationWorkCommand } from '../commands/NotificationWorkCommand.js';
12
14
  export { PrepareCommand } from '../commands/PrepareCommand.js';
15
+ export { QueueCommand } from '../commands/QueueCommand.js';
13
16
  export { SecretsCommand } from '../commands/SecretsCommand.js';
14
17
  export { StartCommand } from '../commands/StartCommand.js';
15
18
  export { TemplatesCommand } from '../commands/TemplatesCommand.js';
@@ -1 +1 @@
1
- {"version":3,"file":"ModelGenerator.d.ts","sourceRoot":"","sources":["../../../../src/cli/scaffolding/ModelGenerator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,MAAM,MAAM,SAAS,GACjB,QAAQ,GACR,SAAS,GACT,OAAO,GACP,SAAS,GACT,MAAM,GACN,UAAU,GACV,MAAM,GACN,EAAE,CAAC;AAEP,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,QAAQ,GAAG,SAAS,GAAG,WAAW,CAAC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,C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ACH,eAAO,MAAM,cAAc;;;;;;;EAOzB,CAAC"}
1
+ {"version":3,"file":"ModelGenerator.d.ts","sourceRoot":"","sources":["../../../../src/cli/scaffolding/ModelGenerator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,MAAM,MAAM,SAAS,GACjB,QAAQ,GACR,SAAS,GACT,OAAO,GACP,SAAS,GACT,MAAM,GACN,UAAU,GACV,MAAM,GACN,EAAE,CAAC;AAEP,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,QAAQ,GAAG,SAAS,GAAG,WAAW,CAAC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC;IACtB,aAAa,CAAC,EAAE,iBAAiB,EAAE,CAAC;IACpC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,YAAY,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAsB3F;AAED;;GAEG;AAEH,wBAAgB,aAAa,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA0ClF;AAgID;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,SAAS,EAAE,CAEjD;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,UAAU,EAAE,CAW5C;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,UAAU,EAAE,CAU5C;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,UAAU,EAAE,CAU7C;AAED;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;EAOzB,CAAC"}
@@ -92,6 +92,7 @@ export const ${options.name} = Object.freeze(
92
92
  fillable: [${fillable.map((f) => `'${f}'`).join(', ')}],
93
93
  hidden: [${hidden.map((f) => `'${f}'`).join(', ')}],
94
94
  timestamps: ${options.timestamps !== false},
95
+ softDeletes: ${options.softDelete === true},
95
96
  casts: {
96
97
  `;
97
98
  // Add field casts
@@ -1 +1 @@
1
- {"version":3,"file":"ProjectScaffolder.d.ts","sourceRoot":"","sources":["../../../../src/cli/scaffolding/ProjectScaffolder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CA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,CAEhC;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;EAM5B,CAAC"}
@@ -152,7 +152,8 @@ const createEnvFile = (projectPath, variables) => {
152
152
  'JWT_SECRET=',
153
153
  'JWT_EXPIRES_IN=1h',
154
154
  'CSRF_SECRET=',
155
- 'ENCRYPTION_KEY=',
155
+ 'ENCRYPTION_CIPHER=aes-256-cbc',
156
+ 'APP_PREVIOUS_KEYS=',
156
157
  '',
157
158
  '# Cache / Queue',
158
159
  'CACHE_DRIVER=memory',
@@ -0,0 +1,23 @@
1
+ export type QueueWorkKind = 'broadcast' | 'notification';
2
+ export type QueueWorkRunnerOptions = {
3
+ queueName: string;
4
+ kind?: QueueWorkKind;
5
+ driverName?: string;
6
+ timeoutSeconds?: number;
7
+ maxItems?: number;
8
+ /** Max retries after the first attempt (so total attempts = retry + 1) */
9
+ retry?: number;
10
+ };
11
+ export type QueueWorkRunnerResult = {
12
+ processed: number;
13
+ retried: number;
14
+ dropped: number;
15
+ notDueRequeued: number;
16
+ unknown: number;
17
+ };
18
+ export declare const QueueWorkRunner: Readonly<{
19
+ run(options: QueueWorkRunnerOptions): Promise<QueueWorkRunnerResult>;
20
+ parseKind(value: unknown): QueueWorkKind;
21
+ }>;
22
+ export default QueueWorkRunner;
23
+ //# sourceMappingURL=QueueWorkRunner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QueueWorkRunner.d.ts","sourceRoot":"","sources":["../../../../src/cli/workers/QueueWorkRunner.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,cAAc,CAAC;AAoBzD,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0EAA0E;IAC1E,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAyHF,eAAO,MAAM,eAAe;iBACP,sBAAsB,GAAG,OAAO,CAAC,qBAAqB,CAAC;qBAuCzD,OAAO,GAAG,aAAa;EAUxC,CAAC;AAEH,eAAe,eAAe,CAAC"}
@@ -0,0 +1,142 @@
1
+ import { Broadcast } from '../../tools/broadcast/Broadcast.js';
2
+ import { Logger } from '../../config/logger.js';
3
+ import { queueConfig } from '../../config/queue.js';
4
+ import { ErrorFactory } from '../../exceptions/ZintrustError.js';
5
+ import { Notification } from '../../tools/notification/Notification.js';
6
+ import { Queue } from '../../tools/queue/Queue.js';
7
+ import { registerQueuesFromRuntimeConfig } from '../../tools/queue/QueueRuntimeRegistration.js';
8
+ const isKind = (value) => value === 'broadcast' || value === 'notification';
9
+ const detectKindFromPayload = (payload) => {
10
+ if (payload !== null && typeof payload === 'object') {
11
+ const p = payload;
12
+ if (isKind(p['type']))
13
+ return p['type'];
14
+ if (typeof p['channel'] === 'string' && typeof p['event'] === 'string')
15
+ return 'broadcast';
16
+ if (typeof p['recipient'] === 'string' && typeof p['message'] === 'string')
17
+ return 'notification';
18
+ }
19
+ return undefined;
20
+ };
21
+ const normalizeNumber = (value) => {
22
+ if (typeof value === 'number' && Number.isFinite(value))
23
+ return value;
24
+ if (typeof value === 'string' && value.trim() !== '') {
25
+ const n = Number(value);
26
+ if (Number.isFinite(n))
27
+ return n;
28
+ }
29
+ return undefined;
30
+ };
31
+ const getTimestamp = (payload) => {
32
+ return normalizeNumber(payload['timestamp']);
33
+ };
34
+ const getAttempts = (payload) => {
35
+ const n = normalizeNumber(payload['attempts']);
36
+ return typeof n === 'number' && n >= 0 ? Math.floor(n) : 0;
37
+ };
38
+ const withAttempts = (payload, attempts) => {
39
+ return { ...payload, attempts };
40
+ };
41
+ const shouldStop = (startedAtMs, timeoutSeconds) => {
42
+ if (timeoutSeconds === undefined)
43
+ return false;
44
+ const elapsedMs = Date.now() - startedAtMs;
45
+ return elapsedMs >= timeoutSeconds * 1000;
46
+ };
47
+ const processMessage = async (options, msg, maxAttempts, result) => {
48
+ const payload = msg.payload ?? {};
49
+ const kind = options.kind ?? detectKindFromPayload(payload);
50
+ if (kind === undefined) {
51
+ Logger.warn('Queue worker: unknown job payload; dropping', {
52
+ queue: options.queueName,
53
+ messageId: msg.id,
54
+ payloadKeys: Object.keys(payload),
55
+ });
56
+ result.unknown++;
57
+ await Queue.ack(options.queueName, msg.id, options.driverName);
58
+ return 'continue';
59
+ }
60
+ const timestamp = getTimestamp(payload);
61
+ if (typeof timestamp === 'number' && timestamp > Date.now()) {
62
+ // Not due yet: re-enqueue and stop after rotating the head once.
63
+ await Queue.enqueue(options.queueName, payload, options.driverName);
64
+ await Queue.ack(options.queueName, msg.id, options.driverName);
65
+ result.notDueRequeued++;
66
+ return 'break';
67
+ }
68
+ const attempts = getAttempts(payload);
69
+ try {
70
+ if (kind === 'broadcast') {
71
+ const job = payload;
72
+ await Broadcast.send(job.channel, job.event, job.data);
73
+ }
74
+ else {
75
+ const job = payload;
76
+ await Notification.send(job.recipient, job.message, job.options ?? {});
77
+ }
78
+ await Queue.ack(options.queueName, msg.id, options.driverName);
79
+ result.processed++;
80
+ return 'continue';
81
+ }
82
+ catch (error) {
83
+ const nextAttempts = attempts + 1;
84
+ const canRetry = nextAttempts < maxAttempts;
85
+ Logger.error('Queue worker: job failed', {
86
+ queue: options.queueName,
87
+ kind,
88
+ messageId: msg.id,
89
+ attempts: nextAttempts,
90
+ maxAttempts,
91
+ error,
92
+ });
93
+ if (canRetry) {
94
+ await Queue.enqueue(options.queueName, withAttempts(payload, nextAttempts), options.driverName);
95
+ result.retried++;
96
+ }
97
+ else {
98
+ result.dropped++;
99
+ }
100
+ await Queue.ack(options.queueName, msg.id, options.driverName);
101
+ return 'continue';
102
+ }
103
+ };
104
+ export const QueueWorkRunner = Object.freeze({
105
+ async run(options) {
106
+ registerQueuesFromRuntimeConfig(queueConfig);
107
+ const startedAtMs = Date.now();
108
+ const maxItems = typeof options.maxItems === 'number' ? options.maxItems : 1000;
109
+ const timeoutSeconds = typeof options.timeoutSeconds === 'number' ? options.timeoutSeconds : 10;
110
+ const maxRetries = typeof options.retry === 'number' ? options.retry : 3;
111
+ const maxAttempts = Math.max(0, Math.floor(maxRetries)) + 1;
112
+ const result = {
113
+ processed: 0,
114
+ retried: 0,
115
+ dropped: 0,
116
+ notDueRequeued: 0,
117
+ unknown: 0,
118
+ };
119
+ /* eslint-disable no-await-in-loop */
120
+ while (result.processed < maxItems && !shouldStop(startedAtMs, timeoutSeconds)) {
121
+ const msg = await Queue.dequeue(options.queueName, options.driverName);
122
+ if (msg === undefined)
123
+ break;
124
+ const outcome = await processMessage(options, { id: msg.id, payload: msg.payload ?? {} }, maxAttempts, result);
125
+ if (outcome === 'break')
126
+ break;
127
+ }
128
+ /* eslint-enable no-await-in-loop */
129
+ return result;
130
+ },
131
+ parseKind(value) {
132
+ const v = String(value ?? '')
133
+ .trim()
134
+ .toLowerCase();
135
+ if (v === 'broadcast' || v === 'broad')
136
+ return 'broadcast';
137
+ if (v === 'notification' || v === 'notify')
138
+ return 'notification';
139
+ throw ErrorFactory.createCliError(`Invalid kind '${String(value)}'. Expected 'broadcast' or 'notification'.`);
140
+ },
141
+ });
142
+ export default QueueWorkRunner;
@@ -0,0 +1,30 @@
1
+ export type PrimitiveKey = string | number | boolean | null | undefined;
2
+ export type ICollection<T> = Readonly<{
3
+ all: () => T[];
4
+ toArray: () => T[];
5
+ count: () => number;
6
+ isEmpty: () => boolean;
7
+ map: <U>(fn: (item: T, index: number) => U) => ICollection<U>;
8
+ filter: (fn: (item: T, index: number) => boolean) => ICollection<T>;
9
+ reduce: <U>(fn: (acc: U, item: T, index: number) => U, initial: U) => U;
10
+ first: (fn?: (item: T, index: number) => boolean) => T | undefined;
11
+ last: (fn?: (item: T, index: number) => boolean) => T | undefined;
12
+ pluck: <K extends keyof T>(key: K) => ICollection<T[K]>;
13
+ where: <K extends keyof T>(key: K, value: T[K]) => ICollection<T>;
14
+ unique: (keySelector?: (item: T) => PrimitiveKey) => ICollection<T>;
15
+ sortBy: (keySelector: (item: T) => PrimitiveKey) => ICollection<T>;
16
+ chunk: (size: number) => ICollection<T[]>;
17
+ take: (n: number) => ICollection<T>;
18
+ skip: (n: number) => ICollection<T>;
19
+ keyBy: <K extends PropertyKey>(keySelector: (item: T) => K) => ReadonlyMap<K, T>;
20
+ groupBy: <K extends PropertyKey>(keySelector: (item: T) => K) => ReadonlyMap<K, ICollection<T>>;
21
+ tap: (fn: (items: T[]) => void) => ICollection<T>;
22
+ [Symbol.iterator]: () => Iterator<T>;
23
+ }>;
24
+ export declare const Collection: Readonly<{
25
+ from: <T>(items: Iterable<T> | ArrayLike<T> | null | undefined) => ICollection<T>;
26
+ of: <T>(...items: T[]) => ICollection<T>;
27
+ isCollection: (value: unknown) => value is ICollection<unknown>;
28
+ }>;
29
+ export declare function collect<T>(items: Iterable<T> | ArrayLike<T> | null | undefined): ICollection<T>;
30
+ //# sourceMappingURL=Collection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Collection.d.ts","sourceRoot":"","sources":["../../../src/collections/Collection.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;AAExE,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,QAAQ,CAAC;IACpC,GAAG,EAAE,MAAM,CAAC,EAAE,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,EAAE,CAAC;IACnB,KAAK,EAAE,MAAM,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,OAAO,CAAC;IAC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