@infuro/cms-core 1.0.63 → 1.0.65

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 (50) hide show
  1. package/dist/admin.cjs +183 -65
  2. package/dist/admin.js +183 -65
  3. package/dist/api.cjs +40 -40
  4. package/dist/api.d.cts +2 -0
  5. package/dist/api.d.ts +2 -0
  6. package/dist/api.js +8 -8
  7. package/dist/{chunk-KAOHOHCA.js → chunk-6YOQ7G5O.js} +92 -51
  8. package/dist/{chunk-BWOITUNI.js → chunk-ACBN6UWZ.js} +320 -81
  9. package/dist/chunk-BXAKL2TF.cjs +84 -0
  10. package/dist/{chunk-7L556RGL.cjs → chunk-GLD263KW.cjs} +3 -3
  11. package/dist/{chunk-EWXG4E74.cjs → chunk-NIRYYJIJ.cjs} +330 -91
  12. package/dist/{chunk-MWEK7N3F.js → chunk-OPJEV44S.js} +2 -2
  13. package/dist/{chunk-DTUL3Q5L.js → chunk-RDEVZMO5.js} +36 -20
  14. package/dist/{chunk-77YWLP4X.js → chunk-SANKKGB3.js} +68 -32
  15. package/dist/chunk-THL5JDWJ.cjs +101 -0
  16. package/dist/{chunk-RXTUSF3R.js → chunk-TU23GJPJ.js} +2 -2
  17. package/dist/{chunk-JLDHK2QE.cjs → chunk-TZEMLHSP.cjs} +20 -14
  18. package/dist/{chunk-RHYVNRYG.cjs → chunk-V6EYAC7X.cjs} +38 -22
  19. package/dist/{chunk-YVP4NQII.cjs → chunk-VM6OVUUM.cjs} +93 -52
  20. package/dist/{chunk-MXABMVF7.cjs → chunk-XFDIIVZB.cjs} +4 -4
  21. package/dist/chunk-XJNNOSJR.js +98 -0
  22. package/dist/chunk-YEAXE4U2.js +77 -0
  23. package/dist/{chunk-CJEOH6QC.cjs → chunk-YHEITFHR.cjs} +112 -76
  24. package/dist/{chunk-3VZAAQUV.js → chunk-YRCKEGL2.js} +20 -14
  25. package/dist/{email-queue-VTYL2KFA.cjs → email-queue-4OY45JIU.cjs} +7 -7
  26. package/dist/{email-queue-YPRSVG56.js → email-queue-HGXB2FIS.js} +3 -3
  27. package/dist/{email-service-ATCPJFWG.cjs → email-service-5O24BSFR.cjs} +7 -7
  28. package/dist/{email-service-DPKVQOKP.js → email-service-ADDF52PJ.js} +2 -2
  29. package/dist/{emit-order-notification-trigger-WI4HGMKH.cjs → emit-order-notification-trigger-DR74TQXN.cjs} +4 -4
  30. package/dist/{emit-order-notification-trigger-XVG2B5ZF.js → emit-order-notification-trigger-UCKJHDQK.js} +2 -2
  31. package/dist/{erp-order-invoice-3UGWLICU.js → erp-order-invoice-H6HCJ7YS.js} +2 -2
  32. package/dist/{erp-order-invoice-KJYJNWMG.cjs → erp-order-invoice-YUSPZ7CE.cjs} +6 -6
  33. package/dist/index.cjs +279 -265
  34. package/dist/index.d.cts +46 -22
  35. package/dist/index.d.ts +46 -22
  36. package/dist/index.js +43 -29
  37. package/dist/migrations/1783000000000-AddOrderPendingProcessingCompletedTriggers.ts +15 -39
  38. package/dist/migrations/1783300000000-SeedOrderNotificationTriggersAndTemplates.ts +155 -0
  39. package/dist/{order-completion-otp-handlers-WGM7HWG4.js → order-completion-otp-handlers-CH22ZRAI.js} +5 -5
  40. package/dist/{order-completion-otp-handlers-IMMQGHDR.cjs → order-completion-otp-handlers-RW5RSXH3.cjs} +7 -7
  41. package/dist/{order-notification-dispatcher-JKFQJYGG.js → order-notification-dispatcher-3TXUAJ7L.js} +6 -6
  42. package/dist/{order-notification-dispatcher-5TUFCDU7.cjs → order-notification-dispatcher-Y7NZAALH.cjs} +11 -11
  43. package/dist/{pg-boss-service-L6MTF4EQ.cjs → pg-boss-service-BDGOKM2T.cjs} +3 -3
  44. package/dist/pg-boss-service-WCBJD4JB.js +2 -0
  45. package/package.json +1 -1
  46. package/dist/chunk-AYWDQFJZ.js +0 -27
  47. package/dist/chunk-GO7PPYNU.js +0 -76
  48. package/dist/chunk-UEE4PTTB.cjs +0 -30
  49. package/dist/chunk-XQ3QUHWR.cjs +0 -83
  50. package/dist/pg-boss-service-4XF2TQ2E.js +0 -2
@@ -0,0 +1,155 @@
1
+ import type { MigrationInterface, QueryRunner } from 'typeorm';
2
+
3
+ /**
4
+ * Seeds and syncs all default order notification triggers, starter email templates,
5
+ * and default bindings so notification channels work out-of-the-box across all stores.
6
+ */
7
+ export class SeedOrderNotificationTriggersAndTemplates1783300000000 implements MigrationInterface {
8
+ name = 'SeedOrderNotificationTriggersAndTemplates1783300000000';
9
+
10
+ public async up(queryRunner: QueryRunner): Promise<void> {
11
+ const hasTriggersTable = await queryRunner.hasTable('order_notification_triggers');
12
+ if (!hasTriggersTable) return;
13
+
14
+ // 1. Seed or update all 10 order notification triggers
15
+ await queryRunner.query(`
16
+ INSERT INTO "order_notification_triggers" ("triggerKey", "label", "description", "category", "sortOrder")
17
+ VALUES
18
+ ('order_placed', 'Order placed', 'Fires when a new order is created (storefront checkout or admin).', 'order', 1),
19
+ ('order_pending', 'Order pending', 'Fires when an order is in pending status (awaiting payment or review).', 'order', 2),
20
+ ('order_assigned', 'Order assigned (Customer)', 'Fires when a teammate is assigned to the order (notifies customer with assignee details and scheduled time slot).', 'order', 3),
21
+ ('order_assigned_assignee', 'Task assigned (Assignee)', 'Fires when a task is assigned to a teammate (notifies assignee with task description and customer details).', 'order', 4),
22
+ ('order_cancelled', 'Order cancelled', 'Fires when an order is cancelled (includes refund amount when applicable).', 'order', 5),
23
+ ('order_processing', 'Order processing', 'Fires when an order status changes to processing.', 'order', 6),
24
+ ('payment_success', 'Payment success', 'Fires when order is placed and payment status is paid.', 'order', 7),
25
+ ('order_completed', 'Order completed', 'Fires when an order status changes to completed / fulfilled.', 'order', 8),
26
+ ('payment_failed', 'Payment failed', 'Fires when payment status is pending, unpaid, or failed, or when order is cancelled without payment.', 'order', 9),
27
+ ('payment_refund_initiated', 'Payment refund initiated', 'Fires when order is cancelled and its payment status is paid (refund initiated).', 'order', 10)
28
+ ON CONFLICT ("triggerKey") DO UPDATE SET
29
+ "label" = EXCLUDED."label",
30
+ "description" = EXCLUDED."description",
31
+ "category" = EXCLUDED."category",
32
+ "sortOrder" = EXCLUDED."sortOrder",
33
+ "updatedAt" = now();
34
+ `);
35
+
36
+ // 2. Seed starter message templates and bindings if tables exist
37
+ const hasTemplates = await queryRunner.hasTable('message_templates');
38
+ const hasBindings = await queryRunner.hasTable('order_notification_bindings');
39
+ if (hasTemplates && hasBindings) {
40
+ const templates = [
41
+ {
42
+ triggerKey: 'order_placed',
43
+ templateKey: 'order_notification_customer_order_placed',
44
+ name: 'Order placed email',
45
+ subject: 'Your order {{orderNumber}} is confirmed',
46
+ body: `Hi {{customerName}},\n\nThank you for your order! Your order {{orderNumber}} for {{total}} {{currency}} has been confirmed.\n\nOrder Details:\n{{orderDetails}}\n\nYour Tax Invoice PDF is attached to this email for your records.\n\nThank you!`,
47
+ },
48
+ {
49
+ triggerKey: 'order_pending',
50
+ templateKey: 'order_notification_customer_order_pending',
51
+ name: 'Order pending email',
52
+ subject: 'Your order {{orderNumber}} is Pending',
53
+ body: `Hi {{customerName}},\n\nYour order {{orderNumber}} for {{total}} {{currency}} is currently pending.\n\nOrder Details:\n{{orderDetails}}\n\nWe will update you as soon as your order status changes.\n\nThank you!`,
54
+ },
55
+ {
56
+ triggerKey: 'order_assigned',
57
+ templateKey: 'order_notification_customer_order_assigned',
58
+ name: 'Order assigned email (Customer)',
59
+ subject: 'Your service expert has been assigned for order {{orderNumber}}',
60
+ body: `Hi {{customerName}},\n\nA service expert has been assigned to your order {{orderNumber}}.\n\nAssignee Details:\n• Name: {{assigneeName}}\n• Phone: {{assigneePhone}}\n\nYour expert will reach you by your scheduled time slot:\n• Date: {{serviceDate}}\n• Slot: {{timeSlot}}\n\nOrder Details:\n{{orderDetails}}\n\nThank you!`,
61
+ },
62
+ {
63
+ triggerKey: 'order_assigned_assignee',
64
+ templateKey: 'order_notification_assignee_order_assigned',
65
+ name: 'Task assigned email (Assignee)',
66
+ subject: 'New task assigned: Order {{orderNumber}}',
67
+ body: `Hi {{assigneeName}},\n\nA new task has been assigned to you for order {{orderNumber}}.\n\nTask Details:\n{{taskDescription}}\n\nCustomer Details:\n• Name: {{customerName}}\n• Phone: {{customerPhone}}\n• Address: {{customerAddress}}\n\nSchedule:\n• Date: {{serviceDate}}\n• Slot: {{timeSlot}}\n\nPlease arrive promptly within the scheduled time slot.`,
68
+ },
69
+ {
70
+ triggerKey: 'order_cancelled',
71
+ templateKey: 'order_notification_customer_order_cancelled',
72
+ name: 'Order cancelled email',
73
+ subject: 'Your order {{orderNumber}} has been cancelled',
74
+ body: `Hi {{customerName}},\n\nYour order {{orderNumber}} for {{total}} {{currency}} has been cancelled.\n\nIf a refund is due, you will receive {{refundAmount}} {{currency}} back to your original payment method.\n\nIf you have any questions, please contact us.\n\nThank you!`,
75
+ },
76
+ {
77
+ triggerKey: 'order_processing',
78
+ templateKey: 'order_notification_customer_order_processing',
79
+ name: 'Order processing email',
80
+ subject: 'Your order {{orderNumber}} is now Processing',
81
+ body: `Hi {{customerName}},\n\nYour order {{orderNumber}} for {{total}} {{currency}} is currently being processed.\n\nOrder Details:\n{{orderDetails}}\n\nWe will notify you once it is completed.\n\nThank you!`,
82
+ },
83
+ {
84
+ triggerKey: 'payment_success',
85
+ templateKey: 'order_notification_customer_payment_success',
86
+ name: 'Payment success email',
87
+ subject: 'Payment Successful for Order {{orderNumber}}',
88
+ body: `Hi {{customerName}},\n\nWe have received your payment for order {{orderNumber}} of {{total}} {{currency}}.\n\nOrder Details:\n{{orderDetails}}\n\nThank you!`,
89
+ },
90
+ {
91
+ triggerKey: 'order_completed',
92
+ templateKey: 'order_notification_customer_order_completed',
93
+ name: 'Order completed email',
94
+ subject: 'Your order {{orderNumber}} is Completed',
95
+ body: `Hi {{customerName}},\n\nYour order {{orderNumber}} for {{total}} {{currency}} has been completed.\n\nOrder Details:\n{{orderDetails}}\n\nThank you for choosing us!`,
96
+ },
97
+ {
98
+ triggerKey: 'payment_failed',
99
+ templateKey: 'order_notification_customer_payment_failed',
100
+ name: 'Payment failed email',
101
+ subject: 'Payment Failed for Order {{orderNumber}}',
102
+ body: `Hi {{customerName}},\n\nYour payment for order {{orderNumber}} of {{total}} {{currency}} could not be completed or remains unpaid.\n\nIf you were charged, please contact us with your order number {{orderNumber}}.\n\nThank you!`,
103
+ },
104
+ {
105
+ triggerKey: 'payment_refund_initiated',
106
+ templateKey: 'order_notification_customer_payment_refund_initiated',
107
+ name: 'Payment refund initiated email',
108
+ subject: 'Refund Initiated for Order {{orderNumber}}',
109
+ body: `Hi {{customerName}},\n\nYour order {{orderNumber}} has been cancelled and a refund of {{refundAmount}} {{currency}} has been initiated.\n\nThe amount will be credited back to your original payment method.\n\nThank you!`,
110
+ },
111
+ ];
112
+
113
+ for (const t of templates) {
114
+ const insertedRows = await queryRunner.query(
115
+ `INSERT INTO "message_templates" ("channel", "template_key", "name", "subject", "body", "enabled")
116
+ VALUES ('email', $1, $2, $3, $4, true)
117
+ ON CONFLICT ("channel", "template_key") WHERE "deleted" = false
118
+ DO UPDATE SET "name" = EXCLUDED."name", "subject" = EXCLUDED."subject", "body" = EXCLUDED."body", "updatedAt" = now()
119
+ RETURNING "id"`,
120
+ [t.templateKey, t.name, t.subject, t.body]
121
+ );
122
+ const templateId = insertedRows?.[0]?.id;
123
+
124
+ if (templateId) {
125
+ await queryRunner.query(
126
+ `INSERT INTO "order_notification_bindings" ("triggerKey", "channel", "type", "messageTemplateId", "enabled")
127
+ VALUES ($1, 'email', 'customers', $2, true)
128
+ ON CONFLICT ("triggerKey", "channel", "type")
129
+ DO UPDATE SET "messageTemplateId" = EXCLUDED."messageTemplateId"
130
+ WHERE "order_notification_bindings"."messageTemplateId" IS NULL`,
131
+ [t.triggerKey, templateId]
132
+ );
133
+ }
134
+ }
135
+ }
136
+ }
137
+
138
+ public async down(queryRunner: QueryRunner): Promise<void> {
139
+ const hasTriggersTable = await queryRunner.hasTable('order_notification_triggers');
140
+ if (hasTriggersTable) {
141
+ await queryRunner.query(`
142
+ DELETE FROM "order_notification_triggers"
143
+ WHERE "triggerKey" IN ('order_assigned', 'order_assigned_assignee');
144
+ `);
145
+ }
146
+
147
+ const hasTemplates = await queryRunner.hasTable('message_templates');
148
+ if (hasTemplates) {
149
+ await queryRunner.query(`
150
+ DELETE FROM "message_templates"
151
+ WHERE "template_key" LIKE 'order_notification_%';
152
+ `);
153
+ }
154
+ }
155
+ }
@@ -1,11 +1,11 @@
1
- import { fireOrderNotificationTrigger } from './chunk-DTUL3Q5L.js';
1
+ import { fireOrderNotificationTrigger } from './chunk-RDEVZMO5.js';
2
2
  import { verifyAndConsumeOtpChallenge, generateNumericOtp, createOtpChallenge, queueSms } from './chunk-OVTOP42W.js';
3
3
  import { queueWhatsApp } from './chunk-GWDI752Q.js';
4
- import './chunk-AYWDQFJZ.js';
5
- import { queueEmail } from './chunk-RXTUSF3R.js';
6
- import './chunk-MWEK7N3F.js';
4
+ import './chunk-YEAXE4U2.js';
5
+ import { queueEmail } from './chunk-TU23GJPJ.js';
6
+ import './chunk-OPJEV44S.js';
7
7
  import './chunk-JC6DLWTE.js';
8
- import './chunk-3VZAAQUV.js';
8
+ import './chunk-YRCKEGL2.js';
9
9
  import { __name } from './chunk-SHUYVCID.js';
10
10
 
11
11
  // src/api/order-completion-otp-handlers.ts
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var chunkRHYVNRYG_cjs = require('./chunk-RHYVNRYG.cjs');
3
+ var chunkV6EYAC7X_cjs = require('./chunk-V6EYAC7X.cjs');
4
4
  var chunkWFMVD567_cjs = require('./chunk-WFMVD567.cjs');
5
5
  var chunkH3IVLIPR_cjs = require('./chunk-H3IVLIPR.cjs');
6
- require('./chunk-UEE4PTTB.cjs');
7
- var chunkMXABMVF7_cjs = require('./chunk-MXABMVF7.cjs');
8
- require('./chunk-7L556RGL.cjs');
6
+ require('./chunk-BXAKL2TF.cjs');
7
+ var chunkXFDIIVZB_cjs = require('./chunk-XFDIIVZB.cjs');
8
+ require('./chunk-GLD263KW.cjs');
9
9
  require('./chunk-UPLVMVRX.cjs');
10
- require('./chunk-JLDHK2QE.cjs');
10
+ require('./chunk-TZEMLHSP.cjs');
11
11
  var chunkUSNT2KNT_cjs = require('./chunk-USNT2KNT.cjs');
12
12
 
13
13
  // src/api/order-completion-otp-handlers.ts
@@ -226,7 +226,7 @@ function createOrderCompletionOtpHandlers(dataSource, entityMap, getCms) {
226
226
  <p style="color: #6b7280; font-size: 13px;">This code is valid for 10 minutes. If you did not authorize this completion, please contact support immediately.</p>
227
227
  </div>
228
228
  `;
229
- await chunkMXABMVF7_cjs.queueEmail(cms, {
229
+ await chunkXFDIIVZB_cjs.queueEmail(cms, {
230
230
  to: customerEmail,
231
231
  subject: `Completion Code ${code} for Order #${o.orderNumber}`,
232
232
  html,
@@ -339,7 +339,7 @@ function createOrderCompletionOtpHandlers(dataSource, entityMap, getCms) {
339
339
  order.updatedAt = now;
340
340
  await orderRepo.save(order);
341
341
  try {
342
- await chunkRHYVNRYG_cjs.fireOrderNotificationTrigger("order_completed", orderId, {
342
+ await chunkV6EYAC7X_cjs.fireOrderNotificationTrigger("order_completed", orderId, {
343
343
  dataSource,
344
344
  entityMap
345
345
  });
@@ -1,10 +1,10 @@
1
- export { dispatchOrderNotificationDirectly, emitOrderNotificationTrigger, getSettingsGroup, initWhatsappTriggerDispatcher, resendOrderNotification } from './chunk-BWOITUNI.js';
1
+ export { dispatchOrderNotificationDirectly, emitOrderNotificationTrigger, getSettingsGroup, initWhatsappTriggerDispatcher, resendOrderNotification } from './chunk-ACBN6UWZ.js';
2
2
  import './chunk-GWDI752Q.js';
3
- import './chunk-AYWDQFJZ.js';
4
- import './chunk-KAOHOHCA.js';
5
- import './chunk-RXTUSF3R.js';
6
- import './chunk-MWEK7N3F.js';
3
+ import './chunk-YEAXE4U2.js';
4
+ import './chunk-6YOQ7G5O.js';
5
+ import './chunk-TU23GJPJ.js';
6
+ import './chunk-OPJEV44S.js';
7
7
  import './chunk-JC6DLWTE.js';
8
- import './chunk-3VZAAQUV.js';
8
+ import './chunk-YRCKEGL2.js';
9
9
  import './chunk-CRFV5WJK.js';
10
10
  import './chunk-SHUYVCID.js';
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var chunkEWXG4E74_cjs = require('./chunk-EWXG4E74.cjs');
3
+ var chunkNIRYYJIJ_cjs = require('./chunk-NIRYYJIJ.cjs');
4
4
  require('./chunk-H3IVLIPR.cjs');
5
- require('./chunk-UEE4PTTB.cjs');
6
- require('./chunk-YVP4NQII.cjs');
7
- require('./chunk-MXABMVF7.cjs');
8
- require('./chunk-7L556RGL.cjs');
5
+ require('./chunk-BXAKL2TF.cjs');
6
+ require('./chunk-VM6OVUUM.cjs');
7
+ require('./chunk-XFDIIVZB.cjs');
8
+ require('./chunk-GLD263KW.cjs');
9
9
  require('./chunk-UPLVMVRX.cjs');
10
- require('./chunk-JLDHK2QE.cjs');
10
+ require('./chunk-TZEMLHSP.cjs');
11
11
  require('./chunk-OOTLNH63.cjs');
12
12
  require('./chunk-USNT2KNT.cjs');
13
13
 
@@ -15,21 +15,21 @@ require('./chunk-USNT2KNT.cjs');
15
15
 
16
16
  Object.defineProperty(exports, "dispatchOrderNotificationDirectly", {
17
17
  enumerable: true,
18
- get: function () { return chunkEWXG4E74_cjs.dispatchOrderNotificationDirectly; }
18
+ get: function () { return chunkNIRYYJIJ_cjs.dispatchOrderNotificationDirectly; }
19
19
  });
20
20
  Object.defineProperty(exports, "emitOrderNotificationTrigger", {
21
21
  enumerable: true,
22
- get: function () { return chunkEWXG4E74_cjs.emitOrderNotificationTrigger; }
22
+ get: function () { return chunkNIRYYJIJ_cjs.emitOrderNotificationTrigger; }
23
23
  });
24
24
  Object.defineProperty(exports, "getSettingsGroup", {
25
25
  enumerable: true,
26
- get: function () { return chunkEWXG4E74_cjs.getSettingsGroup; }
26
+ get: function () { return chunkNIRYYJIJ_cjs.getSettingsGroup; }
27
27
  });
28
28
  Object.defineProperty(exports, "initWhatsappTriggerDispatcher", {
29
29
  enumerable: true,
30
- get: function () { return chunkEWXG4E74_cjs.initWhatsappTriggerDispatcher; }
30
+ get: function () { return chunkNIRYYJIJ_cjs.initWhatsappTriggerDispatcher; }
31
31
  });
32
32
  Object.defineProperty(exports, "resendOrderNotification", {
33
33
  enumerable: true,
34
- get: function () { return chunkEWXG4E74_cjs.resendOrderNotification; }
34
+ get: function () { return chunkNIRYYJIJ_cjs.resendOrderNotification; }
35
35
  });
@@ -1,15 +1,15 @@
1
1
  'use strict';
2
2
 
3
- var chunkXQ3QUHWR_cjs = require('./chunk-XQ3QUHWR.cjs');
3
+ var chunkTHL5JDWJ_cjs = require('./chunk-THL5JDWJ.cjs');
4
4
  require('./chunk-USNT2KNT.cjs');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, "JOB_RUNNER_QUEUE", {
9
9
  enumerable: true,
10
- get: function () { return chunkXQ3QUHWR_cjs.JOB_RUNNER_QUEUE; }
10
+ get: function () { return chunkTHL5JDWJ_cjs.JOB_RUNNER_QUEUE; }
11
11
  });
12
12
  Object.defineProperty(exports, "PgBossService", {
13
13
  enumerable: true,
14
- get: function () { return chunkXQ3QUHWR_cjs.PgBossService; }
14
+ get: function () { return chunkTHL5JDWJ_cjs.PgBossService; }
15
15
  });
@@ -0,0 +1,2 @@
1
+ export { JOB_RUNNER_QUEUE, PgBossService } from './chunk-XJNNOSJR.js';
2
+ import './chunk-SHUYVCID.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infuro/cms-core",
3
- "version": "1.0.63",
3
+ "version": "1.0.65",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -1,27 +0,0 @@
1
- import { __name } from './chunk-SHUYVCID.js';
2
- import { EventEmitter } from 'events';
3
-
4
- var KNOWN_NOTIFICATION_TRIGGERS = {
5
- ORDER_PENDING: "order_pending",
6
- ORDER_PROCESSING: "order_processing",
7
- ORDER_COMPLETED: "order_completed",
8
- ORDER_PLACED: "order_placed",
9
- ORDER_CANCELLED: "order_cancelled",
10
- PAYMENT_SUCCESS: "payment_success",
11
- PAYMENT_FAILED: "payment_failed",
12
- PAYMENT_REFUND_INITIATED: "payment_refund_initiated"
13
- };
14
- var NotificationTriggerEmitter = class NotificationTriggerEmitter2 extends EventEmitter {
15
- static {
16
- __name(this, "NotificationTriggerEmitter");
17
- }
18
- emitTrigger(triggerKey, payload) {
19
- this.emit("__any__", triggerKey, payload);
20
- }
21
- onAnyTrigger(listener) {
22
- this.on("__any__", listener);
23
- }
24
- };
25
- var notificationTriggerEmitter = new NotificationTriggerEmitter();
26
-
27
- export { KNOWN_NOTIFICATION_TRIGGERS, notificationTriggerEmitter };
@@ -1,76 +0,0 @@
1
- import { __name } from './chunk-SHUYVCID.js';
2
- import PgBoss from 'pg-boss';
3
-
4
- var JOB_RUNNER_QUEUE = "job-runner";
5
- var PgBossService = class {
6
- static {
7
- __name(this, "PgBossService");
8
- }
9
- boss;
10
- started = false;
11
- workRegistered = /* @__PURE__ */ new Set();
12
- constructor(connectionString, schema) {
13
- this.boss = new PgBoss({
14
- connectionString,
15
- ...schema?.trim() ? {
16
- schema: schema.trim()
17
- } : {},
18
- schedule: true
19
- });
20
- this.boss.on("error", (err) => {
21
- console.error("[pg-boss]", err);
22
- });
23
- }
24
- async start() {
25
- if (this.started) return;
26
- await this.boss.start();
27
- await this.ensureQueue(JOB_RUNNER_QUEUE);
28
- this.started = true;
29
- }
30
- async stop() {
31
- if (!this.started) return;
32
- await this.boss.stop({
33
- graceful: true,
34
- timeout: 1e4
35
- });
36
- this.started = false;
37
- this.workRegistered.clear();
38
- }
39
- get raw() {
40
- return this.boss;
41
- }
42
- async ensureQueue(name) {
43
- const existing = await this.boss.getQueue(name);
44
- if (!existing) {
45
- await this.boss.createQueue(name);
46
- }
47
- }
48
- async send(queue, data) {
49
- await this.ensureQueue(queue);
50
- return this.boss.send(queue, data, {
51
- retryLimit: 2
52
- });
53
- }
54
- async schedule(name, cron, data, options) {
55
- await this.ensureQueue(name);
56
- await this.boss.schedule(name, cron, data, options);
57
- }
58
- async unschedule(name) {
59
- try {
60
- await this.boss.unschedule(name);
61
- } catch {
62
- }
63
- }
64
- async registerWork(queue, handler) {
65
- if (this.workRegistered.has(queue)) return;
66
- await this.ensureQueue(queue);
67
- await this.boss.work(queue, async (jobs) => {
68
- for (const job of jobs) {
69
- await handler(job.data);
70
- }
71
- });
72
- this.workRegistered.add(queue);
73
- }
74
- };
75
-
76
- export { JOB_RUNNER_QUEUE, PgBossService };
@@ -1,30 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkUSNT2KNT_cjs = require('./chunk-USNT2KNT.cjs');
4
- var events = require('events');
5
-
6
- var KNOWN_NOTIFICATION_TRIGGERS = {
7
- ORDER_PENDING: "order_pending",
8
- ORDER_PROCESSING: "order_processing",
9
- ORDER_COMPLETED: "order_completed",
10
- ORDER_PLACED: "order_placed",
11
- ORDER_CANCELLED: "order_cancelled",
12
- PAYMENT_SUCCESS: "payment_success",
13
- PAYMENT_FAILED: "payment_failed",
14
- PAYMENT_REFUND_INITIATED: "payment_refund_initiated"
15
- };
16
- var NotificationTriggerEmitter = class NotificationTriggerEmitter2 extends events.EventEmitter {
17
- static {
18
- chunkUSNT2KNT_cjs.__name(this, "NotificationTriggerEmitter");
19
- }
20
- emitTrigger(triggerKey, payload) {
21
- this.emit("__any__", triggerKey, payload);
22
- }
23
- onAnyTrigger(listener) {
24
- this.on("__any__", listener);
25
- }
26
- };
27
- var notificationTriggerEmitter = new NotificationTriggerEmitter();
28
-
29
- exports.KNOWN_NOTIFICATION_TRIGGERS = KNOWN_NOTIFICATION_TRIGGERS;
30
- exports.notificationTriggerEmitter = notificationTriggerEmitter;
@@ -1,83 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkUSNT2KNT_cjs = require('./chunk-USNT2KNT.cjs');
4
- var PgBoss = require('pg-boss');
5
-
6
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
-
8
- var PgBoss__default = /*#__PURE__*/_interopDefault(PgBoss);
9
-
10
- var JOB_RUNNER_QUEUE = "job-runner";
11
- var PgBossService = class {
12
- static {
13
- chunkUSNT2KNT_cjs.__name(this, "PgBossService");
14
- }
15
- boss;
16
- started = false;
17
- workRegistered = /* @__PURE__ */ new Set();
18
- constructor(connectionString, schema) {
19
- this.boss = new PgBoss__default.default({
20
- connectionString,
21
- ...schema?.trim() ? {
22
- schema: schema.trim()
23
- } : {},
24
- schedule: true
25
- });
26
- this.boss.on("error", (err) => {
27
- console.error("[pg-boss]", err);
28
- });
29
- }
30
- async start() {
31
- if (this.started) return;
32
- await this.boss.start();
33
- await this.ensureQueue(JOB_RUNNER_QUEUE);
34
- this.started = true;
35
- }
36
- async stop() {
37
- if (!this.started) return;
38
- await this.boss.stop({
39
- graceful: true,
40
- timeout: 1e4
41
- });
42
- this.started = false;
43
- this.workRegistered.clear();
44
- }
45
- get raw() {
46
- return this.boss;
47
- }
48
- async ensureQueue(name) {
49
- const existing = await this.boss.getQueue(name);
50
- if (!existing) {
51
- await this.boss.createQueue(name);
52
- }
53
- }
54
- async send(queue, data) {
55
- await this.ensureQueue(queue);
56
- return this.boss.send(queue, data, {
57
- retryLimit: 2
58
- });
59
- }
60
- async schedule(name, cron, data, options) {
61
- await this.ensureQueue(name);
62
- await this.boss.schedule(name, cron, data, options);
63
- }
64
- async unschedule(name) {
65
- try {
66
- await this.boss.unschedule(name);
67
- } catch {
68
- }
69
- }
70
- async registerWork(queue, handler) {
71
- if (this.workRegistered.has(queue)) return;
72
- await this.ensureQueue(queue);
73
- await this.boss.work(queue, async (jobs) => {
74
- for (const job of jobs) {
75
- await handler(job.data);
76
- }
77
- });
78
- this.workRegistered.add(queue);
79
- }
80
- };
81
-
82
- exports.JOB_RUNNER_QUEUE = JOB_RUNNER_QUEUE;
83
- exports.PgBossService = PgBossService;
@@ -1,2 +0,0 @@
1
- export { JOB_RUNNER_QUEUE, PgBossService } from './chunk-GO7PPYNU.js';
2
- import './chunk-SHUYVCID.js';