@infuro/cms-core 1.0.35 → 1.0.38

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 (69) hide show
  1. package/dist/admin.cjs +1222 -1024
  2. package/dist/admin.d.cts +6 -0
  3. package/dist/admin.d.ts +6 -0
  4. package/dist/admin.js +1224 -1026
  5. package/dist/api.cjs +40 -39
  6. package/dist/api.js +8 -7
  7. package/dist/auth.cjs +51 -51
  8. package/dist/auth.d.cts +3 -3
  9. package/dist/auth.d.ts +3 -3
  10. package/dist/auth.js +3 -3
  11. package/dist/chunk-22FFHLTO.cjs +2356 -0
  12. package/dist/{chunk-CNTSLED2.cjs → chunk-E6WVP7BK.cjs} +75 -14
  13. package/dist/chunk-HCIRL37O.js +21 -0
  14. package/dist/chunk-HT5DI3XW.cjs +82 -0
  15. package/dist/{chunk-EF2JBPDM.js → chunk-KFFB6EMZ.js} +9 -0
  16. package/dist/chunk-NNQBWDCI.js +2325 -0
  17. package/dist/{chunk-TIAEXJLI.cjs → chunk-OIGCAGH7.cjs} +7 -7
  18. package/dist/{chunk-4TRPKBKO.js → chunk-P7QCLE5W.js} +52 -24
  19. package/dist/{chunk-2XE4X74C.js → chunk-PYUXVU75.js} +7801 -6871
  20. package/dist/{chunk-EQPITOP6.js → chunk-SBRBR3VO.js} +70 -9
  21. package/dist/{chunk-N44BJZ4C.cjs → chunk-SPQFNIYJ.cjs} +9 -0
  22. package/dist/chunk-UCKN4BBY.cjs +24 -0
  23. package/dist/{chunk-6KPQWRFW.js → chunk-UXMDSNIG.js} +1 -1
  24. package/dist/{chunk-BGJAV67S.cjs → chunk-VJDUKAJ3.cjs} +8207 -7261
  25. package/dist/{chunk-3KPNTQBV.cjs → chunk-WMXPKKXU.cjs} +52 -23
  26. package/dist/chunk-X47PBV4I.js +79 -0
  27. package/dist/cli.cjs +4 -2
  28. package/dist/cli.js +4 -2
  29. package/dist/emit-order-notification-trigger-D2N3KFHL.cjs +16 -0
  30. package/dist/emit-order-notification-trigger-IVLWKKJL.js +3 -0
  31. package/dist/{event-order-defaults-DUGDVGJI.cjs → event-order-defaults-EMWBIGL3.cjs} +9 -9
  32. package/dist/{event-order-defaults-6E543227.js → event-order-defaults-SDRNAZHC.js} +1 -1
  33. package/dist/index.cjs +805 -1059
  34. package/dist/index.d.cts +834 -728
  35. package/dist/index.d.ts +834 -728
  36. package/dist/index.js +385 -724
  37. package/dist/migrations/1775500000000-RssFeedsAndArticles.ts +0 -1
  38. package/dist/migrations/1775700000000-JobSchedules.ts +0 -1
  39. package/dist/migrations/1781220000000-AddWhatsappTriggerBindings.ts +23 -0
  40. package/dist/migrations/1781230000000-AddOrderNotificationTriggers.ts +46 -0
  41. package/dist/migrations/1781240000000-DropEventOrderNotificationColumns.ts +29 -0
  42. package/dist/migrations/1781250000000-RemoveOrderRefundedTrigger.ts +36 -0
  43. package/dist/migrations/1781260000000-RenameWhatsappTriggerBindingsToOrderNotificationBindings.ts +92 -0
  44. package/dist/migrations/1781270000000-ComboVendorId.ts +58 -0
  45. package/dist/order-notification-dispatcher-RU7BTGGX.cjs +18 -0
  46. package/dist/order-notification-dispatcher-XWIJYDGA.js +5 -0
  47. package/dist/{rbac-debug-db-D7ME7QUY.cjs → rbac-debug-db-KHG4FJC3.cjs} +2 -2
  48. package/dist/{rbac-debug-db-MTCTVNNM.js → rbac-debug-db-QWHOENBR.js} +1 -1
  49. package/package.json +1 -1
  50. package/dist/chunk-46GKADYE.cjs +0 -84
  51. package/dist/chunk-7YIBMQDR.cjs +0 -86
  52. package/dist/chunk-J7XHLOLO.js +0 -830
  53. package/dist/chunk-JBRR5UYL.js +0 -87
  54. package/dist/chunk-JHF4YYRC.cjs +0 -188
  55. package/dist/chunk-PAMVINEX.cjs +0 -577
  56. package/dist/chunk-QM733NUK.js +0 -186
  57. package/dist/chunk-R73BKDRO.cjs +0 -90
  58. package/dist/chunk-TFUOHI37.cjs +0 -839
  59. package/dist/chunk-XDSNZUW7.js +0 -564
  60. package/dist/chunk-ZQ4X6OAU.js +0 -82
  61. package/dist/chunk-ZSVCP6N3.js +0 -83
  62. package/dist/email-FKR4FXFI.js +0 -5
  63. package/dist/email-KVKVPNCL.cjs +0 -58
  64. package/dist/event-order-notifications-5GSAOYVS.cjs +0 -27
  65. package/dist/event-order-notifications-IIIF23D5.js +0 -10
  66. package/dist/layout-36UFTHC5.cjs +0 -11
  67. package/dist/layout-AOBN26XG.js +0 -2
  68. package/dist/whatsapp-queue-3DXA4MXU.js +0 -2
  69. package/dist/whatsapp-queue-KG65MXD5.cjs +0 -15
@@ -4,7 +4,6 @@ export class RssFeedsAndArticles1775500000000 implements MigrationInterface {
4
4
  name = 'RssFeedsAndArticles1775500000000';
5
5
 
6
6
  public async up(queryRunner: QueryRunner): Promise<void> {
7
- await queryRunner.query(`CREATE EXTENSION IF NOT EXISTS "pgcrypto"`);
8
7
  await queryRunner.query(`
9
8
  CREATE TABLE IF NOT EXISTS "rss_feeds" (
10
9
  "id" uuid NOT NULL DEFAULT gen_random_uuid(),
@@ -4,7 +4,6 @@ export class JobSchedules1775700000000 implements MigrationInterface {
4
4
  name = 'JobSchedules1775700000000';
5
5
 
6
6
  public async up(queryRunner: QueryRunner): Promise<void> {
7
- await queryRunner.query(`CREATE EXTENSION IF NOT EXISTS "pgcrypto"`);
8
7
  await queryRunner.query(`
9
8
  CREATE TABLE IF NOT EXISTS "job_schedules" (
10
9
  "id" uuid NOT NULL DEFAULT gen_random_uuid(),
@@ -0,0 +1,23 @@
1
+ import type { MigrationInterface, QueryRunner } from 'typeorm';
2
+
3
+ export class AddWhatsappTriggerBindings1781220000000 implements MigrationInterface {
4
+ name = 'AddWhatsappTriggerBindings1781220000000';
5
+
6
+ public async up(queryRunner: QueryRunner): Promise<void> {
7
+ await queryRunner.query(`
8
+ CREATE TABLE "whatsapp_trigger_bindings" (
9
+ "id" SERIAL PRIMARY KEY,
10
+ "triggerKey" varchar NOT NULL UNIQUE,
11
+ "messageTemplateId" int NOT NULL,
12
+ "enabled" boolean NOT NULL DEFAULT true,
13
+ "createdAt" timestamp NOT NULL DEFAULT now(),
14
+ "updatedAt" timestamp NOT NULL DEFAULT now(),
15
+ CONSTRAINT "FK_whatsapp_trigger_bindings_template" FOREIGN KEY ("messageTemplateId") REFERENCES "message_templates"("id") ON DELETE CASCADE
16
+ );
17
+ `);
18
+ }
19
+
20
+ public async down(queryRunner: QueryRunner): Promise<void> {
21
+ await queryRunner.query(`DROP TABLE "whatsapp_trigger_bindings";`);
22
+ }
23
+ }
@@ -0,0 +1,46 @@
1
+ import type { MigrationInterface, QueryRunner } from 'typeorm';
2
+
3
+ export class AddOrderNotificationTriggers1781230000000 implements MigrationInterface {
4
+ name = 'AddOrderNotificationTriggers1781230000000';
5
+
6
+ public async up(queryRunner: QueryRunner): Promise<void> {
7
+ await queryRunner.query(`
8
+ CREATE TABLE "order_notification_triggers" (
9
+ "id" SERIAL PRIMARY KEY,
10
+ "triggerKey" varchar NOT NULL UNIQUE,
11
+ "label" varchar NOT NULL,
12
+ "description" text,
13
+ "category" varchar NOT NULL DEFAULT 'order',
14
+ "enabled" boolean NOT NULL DEFAULT true,
15
+ "sortOrder" int NOT NULL DEFAULT 0,
16
+ "createdAt" timestamp NOT NULL DEFAULT now(),
17
+ "updatedAt" timestamp NOT NULL DEFAULT now()
18
+ );
19
+ `);
20
+
21
+ await queryRunner.query(`
22
+ INSERT INTO "order_notification_triggers" ("triggerKey", "label", "description", "category", "sortOrder")
23
+ VALUES
24
+ ('order_placed', 'Order placed', 'Fires when a new order is created (storefront checkout or admin).', 'order', 1),
25
+ ('order_cancelled', 'Order cancelled', 'Fires when an order is cancelled.', 'order', 2),
26
+ ('order_refunded', 'Order refunded', 'Fires when a refund amount is processed on cancellation.', 'order', 3)
27
+ ON CONFLICT ("triggerKey") DO NOTHING;
28
+ `);
29
+
30
+ await queryRunner.query(`
31
+ ALTER TABLE "whatsapp_trigger_bindings"
32
+ ALTER COLUMN "messageTemplateId" DROP NOT NULL;
33
+ `);
34
+ }
35
+
36
+ public async down(queryRunner: QueryRunner): Promise<void> {
37
+ await queryRunner.query(`
38
+ DELETE FROM "whatsapp_trigger_bindings" WHERE "messageTemplateId" IS NULL;
39
+ `);
40
+ await queryRunner.query(`
41
+ ALTER TABLE "whatsapp_trigger_bindings"
42
+ ALTER COLUMN "messageTemplateId" SET NOT NULL;
43
+ `);
44
+ await queryRunner.query(`DROP TABLE "order_notification_triggers";`);
45
+ }
46
+ }
@@ -0,0 +1,29 @@
1
+ import type { MigrationInterface, QueryRunner } from 'typeorm';
2
+
3
+ export class DropEventOrderNotificationColumns1781240000000 implements MigrationInterface {
4
+ name = 'DropEventOrderNotificationColumns1781240000000';
5
+
6
+ public async up(queryRunner: QueryRunner): Promise<void> {
7
+ if (!(await queryRunner.hasTable('events'))) return;
8
+ await queryRunner.query(`ALTER TABLE "events" DROP COLUMN IF EXISTS "orderNotificationTemplates"`);
9
+ await queryRunner.query(`ALTER TABLE "events" DROP COLUMN IF EXISTS "orderNotificationChannels"`);
10
+ await queryRunner.query(`ALTER TABLE "events" DROP COLUMN IF EXISTS "orderNotificationsEnabled"`);
11
+ }
12
+
13
+ public async down(queryRunner: QueryRunner): Promise<void> {
14
+ if (!(await queryRunner.hasTable('events'))) return;
15
+
16
+ const table = await queryRunner.getTable('events');
17
+ if (!table?.findColumnByName('orderNotificationsEnabled')) {
18
+ await queryRunner.query(
19
+ `ALTER TABLE "events" ADD COLUMN "orderNotificationsEnabled" boolean NOT NULL DEFAULT false`,
20
+ );
21
+ }
22
+ if (!table?.findColumnByName('orderNotificationChannels')) {
23
+ await queryRunner.query(`ALTER TABLE "events" ADD COLUMN "orderNotificationChannels" jsonb;`);
24
+ }
25
+ if (!table?.findColumnByName('orderNotificationTemplates')) {
26
+ await queryRunner.query(`ALTER TABLE "events" ADD COLUMN "orderNotificationTemplates" jsonb;`);
27
+ }
28
+ }
29
+ }
@@ -0,0 +1,36 @@
1
+ import type { MigrationInterface, QueryRunner } from 'typeorm';
2
+
3
+ /** Keep only order_placed and order_cancelled notification triggers. */
4
+ export class RemoveOrderRefundedTrigger1781250000000 implements MigrationInterface {
5
+ name = 'RemoveOrderRefundedTrigger1781250000000';
6
+
7
+ public async up(queryRunner: QueryRunner): Promise<void> {
8
+ await queryRunner.query(`
9
+ DELETE FROM "whatsapp_trigger_bindings" WHERE "triggerKey" = 'order_refunded';
10
+ `);
11
+ await queryRunner.query(`
12
+ DELETE FROM "order_notification_triggers" WHERE "triggerKey" = 'order_refunded';
13
+ `);
14
+ await queryRunner.query(`
15
+ UPDATE "order_notification_triggers"
16
+ SET
17
+ "description" = 'Fires when an order is cancelled (includes refund amount when applicable).',
18
+ "updatedAt" = now()
19
+ WHERE "triggerKey" = 'order_cancelled';
20
+ `);
21
+ }
22
+
23
+ public async down(queryRunner: QueryRunner): Promise<void> {
24
+ await queryRunner.query(`
25
+ INSERT INTO "order_notification_triggers" ("triggerKey", "label", "description", "category", "sortOrder")
26
+ VALUES
27
+ ('order_refunded', 'Order refunded', 'Fires when a refund amount is processed on cancellation.', 'order', 3)
28
+ ON CONFLICT ("triggerKey") DO NOTHING;
29
+ `);
30
+ await queryRunner.query(`
31
+ UPDATE "order_notification_triggers"
32
+ SET "description" = 'Fires when an order is cancelled.', "updatedAt" = now()
33
+ WHERE "triggerKey" = 'order_cancelled';
34
+ `);
35
+ }
36
+ }
@@ -0,0 +1,92 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+
3
+ export class RenameWhatsappTriggerBindingsToOrderNotificationBindings1781260000000
4
+ implements MigrationInterface
5
+ {
6
+ name = 'RenameWhatsappTriggerBindingsToOrderNotificationBindings1781260000000';
7
+
8
+ public async up(queryRunner: QueryRunner): Promise<void> {
9
+ // 1. Create the channel enum type.
10
+ await queryRunner.query(`
11
+ CREATE TYPE "order_notification_bindings_channel_enum" AS ENUM ('whatsapp', 'email')
12
+ `);
13
+
14
+ // 2. Rename the table.
15
+ await queryRunner.query(`
16
+ ALTER TABLE "whatsapp_trigger_bindings" RENAME TO "order_notification_bindings"
17
+ `);
18
+
19
+ // 3. Add the channel column, defaulting existing (whatsapp-only) rows to 'whatsapp'.
20
+ await queryRunner.query(`
21
+ ALTER TABLE "order_notification_bindings"
22
+ ADD COLUMN "channel" "order_notification_bindings_channel_enum" NOT NULL DEFAULT 'whatsapp'
23
+ `);
24
+
25
+ // 4. Drop the old UNIQUE(triggerKey) constraint, whatever it's actually named.
26
+ // Looked up dynamically so this migration doesn't depend on guessing
27
+ // TypeORM's auto-generated constraint name correctly.
28
+ await queryRunner.query(`
29
+ DO $$
30
+ DECLARE
31
+ old_constraint_name text;
32
+ BEGIN
33
+ SELECT con.conname INTO old_constraint_name
34
+ FROM pg_constraint con
35
+ JOIN pg_class rel ON rel.oid = con.conrelid
36
+ JOIN pg_attribute attr ON attr.attrelid = con.conrelid AND attr.attnum = ANY(con.conkey)
37
+ WHERE rel.relname = 'order_notification_bindings'
38
+ AND con.contype = 'u'
39
+ AND attr.attname = 'triggerKey'
40
+ AND array_length(con.conkey, 1) = 1
41
+ LIMIT 1;
42
+
43
+ IF old_constraint_name IS NOT NULL THEN
44
+ EXECUTE format('ALTER TABLE "order_notification_bindings" DROP CONSTRAINT %I', old_constraint_name);
45
+ END IF;
46
+ END $$;
47
+ `);
48
+
49
+ // 5. Add the new composite unique constraint.
50
+ await queryRunner.query(`
51
+ ALTER TABLE "order_notification_bindings"
52
+ ADD CONSTRAINT "UQ_order_notification_bindings_triggerKey_channel" UNIQUE ("triggerKey", "channel")
53
+ `);
54
+ }
55
+
56
+ public async down(queryRunner: QueryRunner): Promise<void> {
57
+ // 1. Drop the composite unique constraint.
58
+ await queryRunner.query(`
59
+ ALTER TABLE "order_notification_bindings"
60
+ DROP CONSTRAINT "UQ_order_notification_bindings_triggerKey_channel"
61
+ `);
62
+
63
+ // 2. Drop rows that aren't 'whatsapp' before reverting — the old schema
64
+ // has no channel column and can't represent email bindings. This is a
65
+ // lossy rollback by necessity; back up order_notification_bindings
66
+ // first if you need to preserve email bindings across a rollback.
67
+ await queryRunner.query(`
68
+ DELETE FROM "order_notification_bindings" WHERE "channel" != 'whatsapp'
69
+ `);
70
+
71
+ // 3. Drop the channel column.
72
+ await queryRunner.query(`
73
+ ALTER TABLE "order_notification_bindings" DROP COLUMN "channel"
74
+ `);
75
+
76
+ // 4. Restore the original single-column unique constraint.
77
+ await queryRunner.query(`
78
+ ALTER TABLE "order_notification_bindings"
79
+ ADD CONSTRAINT "UQ_whatsapp_trigger_bindings_triggerKey" UNIQUE ("triggerKey")
80
+ `);
81
+
82
+ // 5. Rename the table back.
83
+ await queryRunner.query(`
84
+ ALTER TABLE "order_notification_bindings" RENAME TO "whatsapp_trigger_bindings"
85
+ `);
86
+
87
+ // 6. Drop the enum type.
88
+ await queryRunner.query(`
89
+ DROP TYPE "order_notification_bindings_channel_enum"
90
+ `);
91
+ }
92
+ }
@@ -0,0 +1,58 @@
1
+ import type { MigrationInterface, QueryRunner } from 'typeorm';
2
+
3
+ /**
4
+ * Scope combos to a vendor store (`vendorId` column, FK, index, RLS),
5
+ * matching products / discounts.
6
+ */
7
+ export class ComboVendorId1781270000000 implements MigrationInterface {
8
+ name = 'ComboVendorId1781270000000';
9
+
10
+ public async up(queryRunner: QueryRunner): Promise<void> {
11
+ await queryRunner.query(`ALTER TABLE "combos" ADD COLUMN IF NOT EXISTS "vendorId" integer`);
12
+
13
+ await queryRunner.query(`
14
+ UPDATE "combos"
15
+ SET "vendorId" = (SELECT id FROM "vendors" WHERE "slug" = 'default' LIMIT 1)
16
+ WHERE "vendorId" IS NULL
17
+ `);
18
+
19
+ await queryRunner.query(`ALTER TABLE "combos" ALTER COLUMN "vendorId" SET NOT NULL`);
20
+
21
+ await queryRunner.query(`
22
+ DO $$ BEGIN
23
+ ALTER TABLE "combos" ADD CONSTRAINT "FK_combos_vendorId"
24
+ FOREIGN KEY ("vendorId") REFERENCES "vendors"("id") ON DELETE RESTRICT ON UPDATE NO ACTION;
25
+ EXCEPTION WHEN duplicate_object THEN NULL;
26
+ END $$
27
+ `);
28
+
29
+ await queryRunner.query(
30
+ `CREATE INDEX IF NOT EXISTS "IDX_combos_vendorId" ON "combos" ("vendorId")`
31
+ );
32
+
33
+ await queryRunner.query(`ALTER TABLE "combos" ENABLE ROW LEVEL SECURITY`);
34
+ await queryRunner.query(`ALTER TABLE "combos" FORCE ROW LEVEL SECURITY`);
35
+ await queryRunner.query(`DROP POLICY IF EXISTS "vendor_isolation" ON "combos"`);
36
+ await queryRunner.query(`
37
+ CREATE POLICY "vendor_isolation" ON "combos"
38
+ USING (
39
+ COALESCE(NULLIF(current_setting('app.vendor_id', true), ''), '0') = '0'
40
+ OR "vendorId" = NULLIF(current_setting('app.vendor_id', true), '')::integer
41
+ )
42
+ WITH CHECK (
43
+ COALESCE(NULLIF(current_setting('app.vendor_id', true), ''), '0') = '0'
44
+ OR "vendorId" = NULLIF(current_setting('app.vendor_id', true), '')::integer
45
+ )
46
+ `);
47
+ }
48
+
49
+ public async down(queryRunner: QueryRunner): Promise<void> {
50
+ await queryRunner.query(`DROP POLICY IF EXISTS "vendor_isolation" ON "combos"`);
51
+ await queryRunner.query(`ALTER TABLE "combos" NO FORCE ROW LEVEL SECURITY`);
52
+ await queryRunner.query(`ALTER TABLE "combos" DISABLE ROW LEVEL SECURITY`);
53
+
54
+ await queryRunner.query(`ALTER TABLE "combos" DROP CONSTRAINT IF EXISTS "FK_combos_vendorId"`);
55
+ await queryRunner.query(`DROP INDEX IF EXISTS "IDX_combos_vendorId"`);
56
+ await queryRunner.query(`ALTER TABLE "combos" DROP COLUMN IF EXISTS "vendorId"`);
57
+ }
58
+ }
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ var chunk22FFHLTO_cjs = require('./chunk-22FFHLTO.cjs');
4
+ require('./chunk-UCKN4BBY.cjs');
5
+ require('./chunk-XW5ATPRW.cjs');
6
+ require('./chunk-OOTLNH63.cjs');
7
+ require('./chunk-USNT2KNT.cjs');
8
+
9
+
10
+
11
+ Object.defineProperty(exports, "initWhatsappTriggerDispatcher", {
12
+ enumerable: true,
13
+ get: function () { return chunk22FFHLTO_cjs.initWhatsappTriggerDispatcher; }
14
+ });
15
+ Object.defineProperty(exports, "resendOrderNotification", {
16
+ enumerable: true,
17
+ get: function () { return chunk22FFHLTO_cjs.resendOrderNotification; }
18
+ });
@@ -0,0 +1,5 @@
1
+ export { initWhatsappTriggerDispatcher, resendOrderNotification } from './chunk-NNQBWDCI.js';
2
+ import './chunk-HCIRL37O.js';
3
+ import './chunk-5ELSW2UP.js';
4
+ import './chunk-CRFV5WJK.js';
5
+ import './chunk-SHUYVCID.js';
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunk3KPNTQBV_cjs = require('./chunk-3KPNTQBV.cjs');
3
+ var chunkWMXPKKXU_cjs = require('./chunk-WMXPKKXU.cjs');
4
4
  var chunkUSNT2KNT_cjs = require('./chunk-USNT2KNT.cjs');
5
5
 
6
6
  // src/auth/rbac-debug-db.ts
@@ -27,7 +27,7 @@ async function loadDbPermissionsForUser(dataSource, userId) {
27
27
  return {
28
28
  groupId,
29
29
  groupName,
30
- dbEntityPerms: chunk3KPNTQBV_cjs.summarizeEntityPerms(chunk3KPNTQBV_cjs.permissionRowsToRecord(permRows))
30
+ dbEntityPerms: chunkWMXPKKXU_cjs.summarizeEntityPerms(chunkWMXPKKXU_cjs.permissionRowsToRecord(permRows))
31
31
  };
32
32
  }
33
33
  chunkUSNT2KNT_cjs.__name(loadDbPermissionsForUser, "loadDbPermissionsForUser");
@@ -1,4 +1,4 @@
1
- import { summarizeEntityPerms, permissionRowsToRecord } from './chunk-4TRPKBKO.js';
1
+ import { summarizeEntityPerms, permissionRowsToRecord } from './chunk-P7QCLE5W.js';
2
2
  import { __name } from './chunk-SHUYVCID.js';
3
3
 
4
4
  // src/auth/rbac-debug-db.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infuro/cms-core",
3
- "version": "1.0.35",
3
+ "version": "1.0.38",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -1,84 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkUSNT2KNT_cjs = require('./chunk-USNT2KNT.cjs');
4
-
5
- // src/plugins/email/templates/layout.ts
6
- function escapeHtml(s) {
7
- return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
8
- }
9
- chunkUSNT2KNT_cjs.__name(escapeHtml, "escapeHtml");
10
- function socialLinkInnerHtml(s) {
11
- if (s.iconUrl?.trim()) {
12
- return `<img src="${escapeHtml(s.iconUrl.trim())}" alt="" width="20" height="20" style="display:inline-block;vertical-align:middle;border:0;" />`;
13
- }
14
- const label = s.icon && s.icon.trim() || "\u{1F517}";
15
- return escapeHtml(label);
16
- }
17
- chunkUSNT2KNT_cjs.__name(socialLinkInnerHtml, "socialLinkInnerHtml");
18
- function supportLinesHtml(supportEmail, supportPhone, opts) {
19
- const parts = [];
20
- const top = opts?.tightTop ? "margin-top:0;" : "margin-top:4px;";
21
- if (supportEmail) {
22
- parts.push(`<div style="font-size:13px;color:#444;${top}">&#128231; ${escapeHtml(supportEmail)}</div>`);
23
- }
24
- if (supportPhone) {
25
- parts.push(`<div style="font-size:13px;color:#444;margin-top:2px;">&#128222; ${escapeHtml(supportPhone)}</div>`);
26
- }
27
- return parts.join("");
28
- }
29
- chunkUSNT2KNT_cjs.__name(supportLinesHtml, "supportLinesHtml");
30
- function renderLayout(options) {
31
- const { bodyHtml, companyDetails } = options;
32
- const { logoUrl, companyName, supportEmail, supportPhone, socialLinks, footerDisclaimer, followUsTitle = "Follow Us" } = companyDetails;
33
- const supportFooterHtml = supportLinesHtml(supportEmail, supportPhone, {
34
- tightTop: true
35
- });
36
- const hasSocial = Boolean(socialLinks?.length);
37
- const brandFooterInner = [];
38
- if (logoUrl) {
39
- brandFooterInner.push(`<img src="${escapeHtml(logoUrl)}" alt="" style="max-height:28px;max-width:160px;height:auto;width:auto;display:inline-block;vertical-align:middle;margin-right:10px;border:0;" />`);
40
- }
41
- if (companyName) {
42
- brandFooterInner.push(`<span style="font-size:14px;font-weight:600;color:#111;vertical-align:middle;">${escapeHtml(companyName)}</span>`);
43
- }
44
- const brandFooterHtml = brandFooterInner.length ? `<div style="line-height:1.4;">${brandFooterInner.join("")}</div>` : "";
45
- const followTitleHtml = hasSocial && followUsTitle ? `<div class="footer-follow-title" style="font-size:13px;font-weight:600;color:#555;margin:0;">${escapeHtml(followUsTitle)}</div>` : "";
46
- const socialRowHtml = hasSocial && socialLinks ? `<div class="footer-social-icons" style="margin-top:6px;text-align:left;font-size:0;line-height:0;">${socialLinks.map((s) => `<a href="${escapeHtml(s.url)}" style="display:inline-block;margin-right:12px;text-decoration:none;color:#333;font-size:18px;line-height:1;vertical-align:middle;">${socialLinkInnerHtml(s)}</a>`).join("")}</div>` : "";
47
- const rowSupport = supportFooterHtml ? `<tr><td class="footer-support-cell" colspan="2" valign="top" style="padding:0 0 10px 0;">${supportFooterHtml}</td></tr>` : "";
48
- let footerBlock = "";
49
- if (brandFooterHtml || followTitleHtml || socialRowHtml || footerDisclaimer || rowSupport) {
50
- const rowBrand = brandFooterHtml ? `<tr><td class="footer-brand-cell" colspan="2" valign="top" style="padding:0 0 10px 0;">${brandFooterHtml}</td></tr>` : "";
51
- const rowFollowTitle = followTitleHtml ? `<tr><td class="footer-follow-cell" colspan="2" valign="top" style="padding:14px 0 0 0;text-align:left;">${followTitleHtml}</td></tr>` : "";
52
- const rowSocial = socialRowHtml ? `<tr><td class="footer-social-cell" colspan="2" style="padding:0;text-align:left;">${socialRowHtml}</td></tr>` : "";
53
- footerBlock = `<table role="presentation" class="footer-main" width="100%" cellpadding="0" cellspacing="0" style="margin-top:28px;padding-top:16px;">${rowBrand}${rowSupport}${rowFollowTitle}${rowSocial}</table>`;
54
- }
55
- const disclaimerBlock = footerDisclaimer ? `<div style="margin-top:20px;padding-top:12px;font-size:11px;line-height:1.5;color:#888;">${escapeHtml(footerDisclaimer).replace(/\n/g, "<br/>")}</div>` : "";
56
- const responsiveCss = `
57
- @media only screen and (max-width: 600px) {
58
- .email-wrap { padding-left: 12px !important; padding-right: 12px !important; }
59
- .footer-follow-cell { padding-top: 12px !important; }
60
- }
61
- `;
62
- return `<!DOCTYPE html>
63
- <html>
64
- <head>
65
- <meta charset="utf-8">
66
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
67
- <style type="text/css">${responsiveCss}</style>
68
- </head>
69
- <body style="margin:0;padding:0;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;font-size:14px;line-height:1.5;color:#333;background:#fff;">
70
- <table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="background:#fff;">
71
- <tr><td class="email-wrap" style="padding:16px;">
72
- <div>
73
- ${bodyHtml}
74
- </div>
75
- ${footerBlock}
76
- ${disclaimerBlock}
77
- </td></tr>
78
- </table>
79
- </body>
80
- </html>`;
81
- }
82
- chunkUSNT2KNT_cjs.__name(renderLayout, "renderLayout");
83
-
84
- exports.renderLayout = renderLayout;
@@ -1,86 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkUSNT2KNT_cjs = require('./chunk-USNT2KNT.cjs');
4
-
5
- // src/plugins/whatsapp/whatsapp-queue.ts
6
- var WHATSAPP_QUEUE_NAME = "whatsapp";
7
- function maskPhone(raw) {
8
- const digits = raw.replace(/\D/g, "");
9
- if (digits.length <= 4) return "****";
10
- return `${"*".repeat(Math.max(0, digits.length - 4))}${digits.slice(-4)}`;
11
- }
12
- chunkUSNT2KNT_cjs.__name(maskPhone, "maskPhone");
13
- function registerWhatsAppQueueProcessor(cms) {
14
- const queue = cms.getPlugin("queue");
15
- const whatsapp = cms.getPlugin("whatsapp");
16
- if (!queue) {
17
- console.warn("[whatsapp] queue processor not registered: queue plugin missing");
18
- return;
19
- }
20
- if (!whatsapp || typeof whatsapp.send !== "function") {
21
- console.warn("[whatsapp] queue processor not registered: whatsapp plugin missing or not configured");
22
- return;
23
- }
24
- queue.registerProcessor(WHATSAPP_QUEUE_NAME, async (data) => {
25
- const payload = data;
26
- if (!payload.to) {
27
- console.warn("[whatsapp] queue job skipped: missing recipient");
28
- return;
29
- }
30
- console.log("[whatsapp] queue job processing", {
31
- to: maskPhone(payload.to),
32
- templateKey: payload.templateKey ?? null,
33
- externalTemplateRef: payload.externalTemplateRef ?? null
34
- });
35
- try {
36
- const ok = await whatsapp.send(payload);
37
- if (ok) {
38
- console.log("[whatsapp] queue job completed", {
39
- to: maskPhone(payload.to),
40
- sent: true
41
- });
42
- } else {
43
- console.warn("[whatsapp] queue job completed without delivery", {
44
- to: maskPhone(payload.to),
45
- sent: false
46
- });
47
- }
48
- } catch (err) {
49
- console.error("[whatsapp] queue job failed", {
50
- to: maskPhone(payload.to),
51
- error: err instanceof Error ? err.message : String(err)
52
- });
53
- }
54
- });
55
- console.log("[whatsapp] queue processor registered", {
56
- queue: WHATSAPP_QUEUE_NAME
57
- });
58
- }
59
- chunkUSNT2KNT_cjs.__name(registerWhatsAppQueueProcessor, "registerWhatsAppQueueProcessor");
60
- async function queueWhatsApp(cms, payload) {
61
- const queue = cms.getPlugin("queue");
62
- if (queue) {
63
- console.log("[whatsapp] enqueue", {
64
- to: maskPhone(payload.to),
65
- templateKey: payload.templateKey ?? null,
66
- externalTemplateRef: payload.externalTemplateRef ?? null
67
- });
68
- await queue.add(WHATSAPP_QUEUE_NAME, payload);
69
- return true;
70
- }
71
- const whatsapp = cms.getPlugin("whatsapp");
72
- if (whatsapp && typeof whatsapp.send === "function") {
73
- console.log("[whatsapp] no queue plugin \u2014 sending immediately", {
74
- to: maskPhone(payload.to)
75
- });
76
- return whatsapp.send(payload);
77
- }
78
- console.warn("[whatsapp] send skipped: neither queue nor whatsapp plugin available", {
79
- to: maskPhone(payload.to)
80
- });
81
- return false;
82
- }
83
- chunkUSNT2KNT_cjs.__name(queueWhatsApp, "queueWhatsApp");
84
-
85
- exports.queueWhatsApp = queueWhatsApp;
86
- exports.registerWhatsAppQueueProcessor = registerWhatsAppQueueProcessor;