@automagik/omni 2.260729.3 → 2.260730.2

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.
@@ -0,0 +1,65 @@
1
+ -- WhatsApp Cloud (Meta Cloud API) channel — Group 1 foundation.
2
+ --
3
+ -- Adds:
4
+ -- * Per-instance Meta config columns on `instances` (phone_number_id, waba_id,
5
+ -- access_token, app_id, business_id, api_version, connection_method,
6
+ -- display_phone_number, connected_at).
7
+ -- * New `whatsapp_templates` table for HSM templates (synced with Meta).
8
+ -- * Index on `instances.meta_phone_number_id` for webhook resolution
9
+ -- (Meta webhook is global; instance is looked up by phone_number_id).
10
+ --
11
+ -- Hand-written to mirror the pattern of 0034_instances_require_genie_signature.
12
+ -- Run `bunx drizzle-kit generate` after `bun install` to (re)align the
13
+ -- snapshot if the schema diverges from what's encoded here.
14
+
15
+ -- NOTE: no explicit BEGIN/COMMIT — the boot migrator executes this file on a
16
+ -- pooled postgres-js connection, which rejects raw transaction control
17
+ -- (UNSAFE_TRANSACTION). The file is a single batch (no statement-breakpoints),
18
+ -- so it executes atomically anyway, and every statement is idempotent.
19
+
20
+ -- --------------------------------------------------------------------------
21
+ -- instances: WhatsApp Cloud per-instance config
22
+ -- --------------------------------------------------------------------------
23
+ ALTER TABLE "instances"
24
+ ADD COLUMN IF NOT EXISTS "meta_phone_number_id" varchar(64),
25
+ ADD COLUMN IF NOT EXISTS "meta_waba_id" varchar(64),
26
+ ADD COLUMN IF NOT EXISTS "meta_access_token" text,
27
+ ADD COLUMN IF NOT EXISTS "meta_app_id" varchar(64),
28
+ ADD COLUMN IF NOT EXISTS "meta_business_id" varchar(64),
29
+ ADD COLUMN IF NOT EXISTS "meta_api_version" varchar(16) DEFAULT 'v25.0' NOT NULL,
30
+ ADD COLUMN IF NOT EXISTS "meta_connection_method" varchar(32) DEFAULT 'manual',
31
+ ADD COLUMN IF NOT EXISTS "meta_display_phone_number" varchar(32),
32
+ ADD COLUMN IF NOT EXISTS "meta_connected_at" timestamptz;
33
+
34
+ CREATE INDEX IF NOT EXISTS "instances_meta_phone_number_idx"
35
+ ON "instances" ("meta_phone_number_id");
36
+
37
+ -- --------------------------------------------------------------------------
38
+ -- whatsapp_templates: HSM templates (Meta Graph API mirror)
39
+ -- --------------------------------------------------------------------------
40
+ CREATE TABLE IF NOT EXISTS "whatsapp_templates" (
41
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid(),
42
+ "instance_id" uuid NOT NULL REFERENCES "instances"("id") ON DELETE CASCADE,
43
+ "meta_id" varchar(64),
44
+ "waba_id" varchar(64) NOT NULL,
45
+ "name" varchar(255) NOT NULL,
46
+ "language" varchar(16) DEFAULT 'pt_BR' NOT NULL,
47
+ "category" varchar(32) NOT NULL,
48
+ "status" varchar(32) DEFAULT 'PENDING' NOT NULL,
49
+ "components" jsonb,
50
+ "variable_mapping" jsonb,
51
+ "rejection_reason" text,
52
+ "quality_score" varchar(16),
53
+ "created_at" timestamptz DEFAULT now() NOT NULL,
54
+ "updated_at" timestamptz DEFAULT now() NOT NULL
55
+ );
56
+
57
+ CREATE INDEX IF NOT EXISTS "idx_wa_tpl_instance"
58
+ ON "whatsapp_templates" ("instance_id");
59
+
60
+ CREATE UNIQUE INDEX IF NOT EXISTS "idx_wa_tpl_instance_name_lang"
61
+ ON "whatsapp_templates" ("instance_id", "name", "language");
62
+
63
+ CREATE INDEX IF NOT EXISTS "idx_wa_tpl_status"
64
+ ON "whatsapp_templates" ("status");
65
+
@@ -0,0 +1,27 @@
1
+ -- Hermes (Mutant WhatsApp gateway) channel — per-instance configuration.
2
+ --
3
+ -- Adds the five instance columns the `@omni/channel-hermes` plugin reads:
4
+ -- * hermes_base_url — customer-specific API host
5
+ -- * hermes_username/password — sign_in credentials (JWT auth)
6
+ -- * hermes_media_id — Hermes UUID of the WhatsApp line; the
7
+ -- webhook -> instance resolution key
8
+ -- * hermes_template_namespace — Meta template namespace for HSM sends
9
+ --
10
+ -- Hand-written following the 0042_whatsapp_cloud_channel precedent (additive,
11
+ -- idempotent, no rewrite: ADD COLUMN with no default does not rewrite the
12
+ -- table, and the partial index build is small on `instances`).
13
+
14
+ -- NOTE: no explicit BEGIN/COMMIT — the boot migrator executes this file on a
15
+ -- pooled postgres-js connection, which rejects raw transaction control
16
+ -- (UNSAFE_TRANSACTION). Single batch, idempotent statements.
17
+
18
+ ALTER TABLE "instances"
19
+ ADD COLUMN IF NOT EXISTS "hermes_base_url" text,
20
+ ADD COLUMN IF NOT EXISTS "hermes_username" varchar(255),
21
+ ADD COLUMN IF NOT EXISTS "hermes_password" text,
22
+ ADD COLUMN IF NOT EXISTS "hermes_media_id" varchar(64),
23
+ ADD COLUMN IF NOT EXISTS "hermes_template_namespace" varchar(128);
24
+
25
+ CREATE INDEX IF NOT EXISTS "instances_hermes_media_idx"
26
+ ON "instances" ("hermes_media_id");
27
+
@@ -295,6 +295,20 @@
295
295
  "when": 1784100000000,
296
296
  "tag": "0041_tenant_ownership_columns",
297
297
  "breakpoints": true
298
+ },
299
+ {
300
+ "idx": 42,
301
+ "version": "7",
302
+ "when": 1784200000000,
303
+ "tag": "0042_whatsapp_cloud_channel",
304
+ "breakpoints": true
305
+ },
306
+ {
307
+ "idx": 43,
308
+ "version": "7",
309
+ "when": 1784300000000,
310
+ "tag": "0043_hermes_channel",
311
+ "breakpoints": true
298
312
  }
299
313
  ]
300
314
  }
@@ -1 +1 @@
1
- {"version":3,"file":"instances.d.ts","sourceRoot":"","sources":["../../src/commands/instances.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAqMpC,wBAAgB,sBAAsB,IAAI,OAAO,CA0vChD"}
1
+ {"version":3,"file":"instances.d.ts","sourceRoot":"","sources":["../../src/commands/instances.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAqMpC,wBAAgB,sBAAsB,IAAI,OAAO,CAwzChD"}