@automagik/omni 2.260729.3 → 2.260730.1
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.
- package/db/drizzle/0042_whatsapp_cloud_channel.sql +65 -0
- package/db/drizzle/meta/_journal.json +7 -0
- package/dist/commands/instances.d.ts.map +1 -1
- package/dist/index.js +380 -4
- package/dist/sdk/types.generated.d.ts +24 -0
- package/dist/sdk/types.generated.d.ts.map +1 -1
- package/dist/server/index.js +130405 -126484
- package/package.json +2 -1
|
@@ -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
|
+
|
|
@@ -295,6 +295,13 @@
|
|
|
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
|
|
298
305
|
}
|
|
299
306
|
]
|
|
300
307
|
}
|
|
@@ -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,
|
|
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"}
|
package/dist/index.js
CHANGED
|
@@ -8184,7 +8184,9 @@ var init_types2 = __esm(() => {
|
|
|
8184
8184
|
"voice.stream_ended",
|
|
8185
8185
|
"voice.session_ended",
|
|
8186
8186
|
"voice.user_joined_channel",
|
|
8187
|
-
"voice.user_left_channel"
|
|
8187
|
+
"voice.user_left_channel",
|
|
8188
|
+
"template.status_changed",
|
|
8189
|
+
"channel.alert"
|
|
8188
8190
|
];
|
|
8189
8191
|
});
|
|
8190
8192
|
// ../core/src/events/envelope.ts
|
|
@@ -32227,6 +32229,268 @@ var init_person = __esm(() => {
|
|
|
32227
32229
|
});
|
|
32228
32230
|
});
|
|
32229
32231
|
|
|
32232
|
+
// ../core/src/schemas/whatsapp-cloud.ts
|
|
32233
|
+
var MetaTemplateCategorySchema, MetaTemplateStatusSchema, MetaTemplateQualityScoreSchema, MetaTemplateHeaderComponentSchema, MetaTemplateBodyComponentSchema, MetaTemplateFooterComponentSchema, MetaTemplateButtonSchema, MetaTemplateButtonsComponentSchema, WhatsAppTemplateComponentSchema, InboundContextSchema, InboundMediaSchema, MetaInboundTextMessageSchema, MetaInboundMediaMessageSchema, MetaInboundLocationMessageSchema, MetaInboundContactsMessageSchema, MetaInboundReactionMessageSchema, MetaInboundInteractiveMessageSchema, MetaInboundButtonMessageSchema, MetaInboundMessageSchema, MetaWebhookStatusEntrySchema, MetaTemplateStatusUpdateSchema, MetaWebhookValueSchema, MetaWebhookChangeSchema, MetaWebhookEntrySchema, MetaWebhookPayloadSchema, EmbeddedSignupExchangeRequestSchema, EmbeddedSignupExchangeResponseSchema, WhatsAppCloudConnectRequestSchema, WhatsAppFlowSendSchema, WhatsAppCloudRegisterRequestSchema, SendTemplateRequestSchema;
|
|
32234
|
+
var init_whatsapp_cloud = __esm(() => {
|
|
32235
|
+
init_zod();
|
|
32236
|
+
init_common();
|
|
32237
|
+
MetaTemplateCategorySchema = exports_external.enum(["MARKETING", "UTILITY", "AUTHENTICATION"]);
|
|
32238
|
+
MetaTemplateStatusSchema = exports_external.enum(["APPROVED", "PENDING", "REJECTED", "PAUSED", "DELETED"]);
|
|
32239
|
+
MetaTemplateQualityScoreSchema = exports_external.enum(["GREEN", "YELLOW", "RED", "UNKNOWN"]);
|
|
32240
|
+
MetaTemplateHeaderComponentSchema = exports_external.object({
|
|
32241
|
+
type: exports_external.literal("HEADER"),
|
|
32242
|
+
format: exports_external.enum(["TEXT", "IMAGE", "VIDEO", "DOCUMENT", "LOCATION"]),
|
|
32243
|
+
text: exports_external.string().optional(),
|
|
32244
|
+
example: exports_external.object({
|
|
32245
|
+
header_text: exports_external.array(exports_external.string()).optional(),
|
|
32246
|
+
header_handle: exports_external.array(exports_external.string()).optional()
|
|
32247
|
+
}).optional()
|
|
32248
|
+
});
|
|
32249
|
+
MetaTemplateBodyComponentSchema = exports_external.object({
|
|
32250
|
+
type: exports_external.literal("BODY"),
|
|
32251
|
+
text: exports_external.string(),
|
|
32252
|
+
example: exports_external.object({
|
|
32253
|
+
body_text: exports_external.array(exports_external.array(exports_external.string())).optional()
|
|
32254
|
+
}).optional()
|
|
32255
|
+
});
|
|
32256
|
+
MetaTemplateFooterComponentSchema = exports_external.object({
|
|
32257
|
+
type: exports_external.literal("FOOTER"),
|
|
32258
|
+
text: exports_external.string()
|
|
32259
|
+
});
|
|
32260
|
+
MetaTemplateButtonSchema = exports_external.discriminatedUnion("type", [
|
|
32261
|
+
exports_external.object({ type: exports_external.literal("QUICK_REPLY"), text: exports_external.string() }),
|
|
32262
|
+
exports_external.object({
|
|
32263
|
+
type: exports_external.literal("URL"),
|
|
32264
|
+
text: exports_external.string(),
|
|
32265
|
+
url: exports_external.string().url(),
|
|
32266
|
+
example: exports_external.array(exports_external.string()).optional()
|
|
32267
|
+
}),
|
|
32268
|
+
exports_external.object({ type: exports_external.literal("PHONE_NUMBER"), text: exports_external.string(), phone_number: exports_external.string() }),
|
|
32269
|
+
exports_external.object({ type: exports_external.literal("COPY_CODE"), example: exports_external.string() })
|
|
32270
|
+
]);
|
|
32271
|
+
MetaTemplateButtonsComponentSchema = exports_external.object({
|
|
32272
|
+
type: exports_external.literal("BUTTONS"),
|
|
32273
|
+
buttons: exports_external.array(MetaTemplateButtonSchema).min(1).max(10)
|
|
32274
|
+
});
|
|
32275
|
+
WhatsAppTemplateComponentSchema = exports_external.discriminatedUnion("type", [
|
|
32276
|
+
MetaTemplateHeaderComponentSchema,
|
|
32277
|
+
MetaTemplateBodyComponentSchema,
|
|
32278
|
+
MetaTemplateFooterComponentSchema,
|
|
32279
|
+
MetaTemplateButtonsComponentSchema
|
|
32280
|
+
]);
|
|
32281
|
+
InboundContextSchema = exports_external.object({
|
|
32282
|
+
id: exports_external.string().optional(),
|
|
32283
|
+
from: exports_external.string().optional(),
|
|
32284
|
+
forwarded: exports_external.boolean().optional(),
|
|
32285
|
+
frequently_forwarded: exports_external.boolean().optional()
|
|
32286
|
+
});
|
|
32287
|
+
InboundMediaSchema = exports_external.object({
|
|
32288
|
+
id: exports_external.string(),
|
|
32289
|
+
mime_type: exports_external.string().optional(),
|
|
32290
|
+
sha256: exports_external.string().optional(),
|
|
32291
|
+
caption: exports_external.string().optional(),
|
|
32292
|
+
filename: exports_external.string().optional(),
|
|
32293
|
+
voice: exports_external.boolean().optional()
|
|
32294
|
+
});
|
|
32295
|
+
MetaInboundTextMessageSchema = exports_external.object({
|
|
32296
|
+
type: exports_external.literal("text"),
|
|
32297
|
+
from: exports_external.string(),
|
|
32298
|
+
id: exports_external.string(),
|
|
32299
|
+
timestamp: exports_external.string(),
|
|
32300
|
+
text: exports_external.object({ body: exports_external.string() }),
|
|
32301
|
+
context: InboundContextSchema.optional()
|
|
32302
|
+
});
|
|
32303
|
+
MetaInboundMediaMessageSchema = exports_external.object({
|
|
32304
|
+
type: exports_external.enum(["image", "audio", "video", "document", "sticker"]),
|
|
32305
|
+
from: exports_external.string(),
|
|
32306
|
+
id: exports_external.string(),
|
|
32307
|
+
timestamp: exports_external.string(),
|
|
32308
|
+
image: InboundMediaSchema.optional(),
|
|
32309
|
+
audio: InboundMediaSchema.optional(),
|
|
32310
|
+
video: InboundMediaSchema.optional(),
|
|
32311
|
+
document: InboundMediaSchema.optional(),
|
|
32312
|
+
sticker: InboundMediaSchema.optional(),
|
|
32313
|
+
context: InboundContextSchema.optional()
|
|
32314
|
+
});
|
|
32315
|
+
MetaInboundLocationMessageSchema = exports_external.object({
|
|
32316
|
+
type: exports_external.literal("location"),
|
|
32317
|
+
from: exports_external.string(),
|
|
32318
|
+
id: exports_external.string(),
|
|
32319
|
+
timestamp: exports_external.string(),
|
|
32320
|
+
location: exports_external.object({
|
|
32321
|
+
latitude: exports_external.number(),
|
|
32322
|
+
longitude: exports_external.number(),
|
|
32323
|
+
name: exports_external.string().optional(),
|
|
32324
|
+
address: exports_external.string().optional()
|
|
32325
|
+
}),
|
|
32326
|
+
context: InboundContextSchema.optional()
|
|
32327
|
+
});
|
|
32328
|
+
MetaInboundContactsMessageSchema = exports_external.object({
|
|
32329
|
+
type: exports_external.literal("contacts"),
|
|
32330
|
+
from: exports_external.string(),
|
|
32331
|
+
id: exports_external.string(),
|
|
32332
|
+
timestamp: exports_external.string(),
|
|
32333
|
+
contacts: exports_external.array(exports_external.object({
|
|
32334
|
+
name: exports_external.object({ formatted_name: exports_external.string().optional(), first_name: exports_external.string().optional() }).passthrough(),
|
|
32335
|
+
phones: exports_external.array(exports_external.object({ phone: exports_external.string().optional(), wa_id: exports_external.string().optional() }).passthrough()).optional()
|
|
32336
|
+
}).passthrough()),
|
|
32337
|
+
context: InboundContextSchema.optional()
|
|
32338
|
+
});
|
|
32339
|
+
MetaInboundReactionMessageSchema = exports_external.object({
|
|
32340
|
+
type: exports_external.literal("reaction"),
|
|
32341
|
+
from: exports_external.string(),
|
|
32342
|
+
id: exports_external.string(),
|
|
32343
|
+
timestamp: exports_external.string(),
|
|
32344
|
+
reaction: exports_external.object({
|
|
32345
|
+
message_id: exports_external.string(),
|
|
32346
|
+
emoji: exports_external.string()
|
|
32347
|
+
})
|
|
32348
|
+
});
|
|
32349
|
+
MetaInboundInteractiveMessageSchema = exports_external.object({
|
|
32350
|
+
type: exports_external.literal("interactive"),
|
|
32351
|
+
from: exports_external.string(),
|
|
32352
|
+
id: exports_external.string(),
|
|
32353
|
+
timestamp: exports_external.string(),
|
|
32354
|
+
interactive: exports_external.object({
|
|
32355
|
+
type: exports_external.enum(["button_reply", "list_reply", "nfm_reply"]),
|
|
32356
|
+
button_reply: exports_external.object({ id: exports_external.string(), title: exports_external.string() }).optional(),
|
|
32357
|
+
list_reply: exports_external.object({ id: exports_external.string(), title: exports_external.string(), description: exports_external.string().optional() }).optional(),
|
|
32358
|
+
nfm_reply: exports_external.object({ response_json: exports_external.string(), body: exports_external.string().optional(), name: exports_external.string().optional() }).optional()
|
|
32359
|
+
}),
|
|
32360
|
+
context: InboundContextSchema.optional()
|
|
32361
|
+
});
|
|
32362
|
+
MetaInboundButtonMessageSchema = exports_external.object({
|
|
32363
|
+
type: exports_external.literal("button"),
|
|
32364
|
+
from: exports_external.string(),
|
|
32365
|
+
id: exports_external.string(),
|
|
32366
|
+
timestamp: exports_external.string(),
|
|
32367
|
+
button: exports_external.object({ payload: exports_external.string(), text: exports_external.string() }),
|
|
32368
|
+
context: InboundContextSchema.optional()
|
|
32369
|
+
});
|
|
32370
|
+
MetaInboundMessageSchema = exports_external.union([
|
|
32371
|
+
MetaInboundTextMessageSchema,
|
|
32372
|
+
MetaInboundMediaMessageSchema,
|
|
32373
|
+
MetaInboundLocationMessageSchema,
|
|
32374
|
+
MetaInboundContactsMessageSchema,
|
|
32375
|
+
MetaInboundReactionMessageSchema,
|
|
32376
|
+
MetaInboundInteractiveMessageSchema,
|
|
32377
|
+
MetaInboundButtonMessageSchema
|
|
32378
|
+
]);
|
|
32379
|
+
MetaWebhookStatusEntrySchema = exports_external.object({
|
|
32380
|
+
id: exports_external.string(),
|
|
32381
|
+
status: exports_external.enum(["sent", "delivered", "read", "failed"]),
|
|
32382
|
+
timestamp: exports_external.string(),
|
|
32383
|
+
recipient_id: exports_external.string(),
|
|
32384
|
+
errors: exports_external.array(exports_external.object({
|
|
32385
|
+
code: exports_external.number(),
|
|
32386
|
+
title: exports_external.string(),
|
|
32387
|
+
message: exports_external.string().optional(),
|
|
32388
|
+
error_data: exports_external.object({ details: exports_external.string().optional() }).passthrough().optional()
|
|
32389
|
+
}).passthrough()).optional(),
|
|
32390
|
+
conversation: exports_external.object({
|
|
32391
|
+
id: exports_external.string(),
|
|
32392
|
+
origin: exports_external.object({ type: exports_external.string() }).passthrough().optional()
|
|
32393
|
+
}).passthrough().optional(),
|
|
32394
|
+
pricing: exports_external.object({
|
|
32395
|
+
pricing_model: exports_external.string(),
|
|
32396
|
+
billable: exports_external.boolean(),
|
|
32397
|
+
category: exports_external.string()
|
|
32398
|
+
}).passthrough().optional()
|
|
32399
|
+
});
|
|
32400
|
+
MetaTemplateStatusUpdateSchema = exports_external.object({
|
|
32401
|
+
message_template_id: exports_external.string(),
|
|
32402
|
+
message_template_name: exports_external.string(),
|
|
32403
|
+
message_template_language: exports_external.string(),
|
|
32404
|
+
event: exports_external.enum(["APPROVED", "REJECTED", "FLAGGED", "PAUSED", "DISABLED"]),
|
|
32405
|
+
reason: exports_external.string().optional()
|
|
32406
|
+
});
|
|
32407
|
+
MetaWebhookValueSchema = exports_external.object({
|
|
32408
|
+
messaging_product: exports_external.literal("whatsapp").optional(),
|
|
32409
|
+
metadata: exports_external.object({
|
|
32410
|
+
display_phone_number: exports_external.string(),
|
|
32411
|
+
phone_number_id: exports_external.string()
|
|
32412
|
+
}).optional(),
|
|
32413
|
+
contacts: exports_external.array(exports_external.object({
|
|
32414
|
+
profile: exports_external.object({ name: exports_external.string().optional() }).passthrough().optional(),
|
|
32415
|
+
wa_id: exports_external.string().optional()
|
|
32416
|
+
}).passthrough()).optional(),
|
|
32417
|
+
messages: exports_external.array(MetaInboundMessageSchema).optional(),
|
|
32418
|
+
statuses: exports_external.array(MetaWebhookStatusEntrySchema).optional(),
|
|
32419
|
+
errors: exports_external.array(exports_external.object({
|
|
32420
|
+
code: exports_external.number(),
|
|
32421
|
+
title: exports_external.string(),
|
|
32422
|
+
message: exports_external.string().optional()
|
|
32423
|
+
}).passthrough()).optional()
|
|
32424
|
+
});
|
|
32425
|
+
MetaWebhookChangeSchema = exports_external.object({
|
|
32426
|
+
field: exports_external.string(),
|
|
32427
|
+
value: exports_external.union([MetaWebhookValueSchema, MetaTemplateStatusUpdateSchema, exports_external.record(exports_external.string(), exports_external.unknown())])
|
|
32428
|
+
});
|
|
32429
|
+
MetaWebhookEntrySchema = exports_external.object({
|
|
32430
|
+
id: exports_external.string(),
|
|
32431
|
+
changes: exports_external.array(MetaWebhookChangeSchema),
|
|
32432
|
+
time: exports_external.number().optional()
|
|
32433
|
+
});
|
|
32434
|
+
MetaWebhookPayloadSchema = exports_external.object({
|
|
32435
|
+
object: exports_external.literal("whatsapp_business_account"),
|
|
32436
|
+
entry: exports_external.array(MetaWebhookEntrySchema)
|
|
32437
|
+
});
|
|
32438
|
+
EmbeddedSignupExchangeRequestSchema = exports_external.object({
|
|
32439
|
+
code: exports_external.string().min(1)
|
|
32440
|
+
});
|
|
32441
|
+
EmbeddedSignupExchangeResponseSchema = exports_external.object({
|
|
32442
|
+
exchangeHandle: exports_external.string(),
|
|
32443
|
+
wabaIds: exports_external.array(exports_external.string()),
|
|
32444
|
+
phoneNumbers: exports_external.array(exports_external.object({
|
|
32445
|
+
phone_number_id: exports_external.string(),
|
|
32446
|
+
wabaId: exports_external.string(),
|
|
32447
|
+
display_phone_number: exports_external.string().optional(),
|
|
32448
|
+
verified_name: exports_external.string().optional(),
|
|
32449
|
+
quality_rating: exports_external.string().optional()
|
|
32450
|
+
}))
|
|
32451
|
+
});
|
|
32452
|
+
WhatsAppCloudConnectRequestSchema = exports_external.object({
|
|
32453
|
+
accessToken: exports_external.string().min(1).optional(),
|
|
32454
|
+
exchangeHandle: exports_external.string().min(1).optional(),
|
|
32455
|
+
phoneNumberId: exports_external.string().min(1),
|
|
32456
|
+
wabaId: exports_external.string().min(1),
|
|
32457
|
+
appId: exports_external.string().optional(),
|
|
32458
|
+
businessId: exports_external.string().optional()
|
|
32459
|
+
}).refine((v) => Boolean(v.accessToken) !== Boolean(v.exchangeHandle), {
|
|
32460
|
+
message: "Provide exactly one of `accessToken` (manual flow) or `exchangeHandle` (Embedded Signup flow)",
|
|
32461
|
+
path: ["accessToken"]
|
|
32462
|
+
});
|
|
32463
|
+
WhatsAppFlowSendSchema = exports_external.object({
|
|
32464
|
+
flowId: exports_external.string().min(1).optional(),
|
|
32465
|
+
flowName: exports_external.string().min(1).optional(),
|
|
32466
|
+
cta: exports_external.string().min(1).max(30),
|
|
32467
|
+
bodyText: exports_external.string().min(1).max(1024),
|
|
32468
|
+
headerText: exports_external.string().max(60).optional(),
|
|
32469
|
+
footerText: exports_external.string().max(60).optional(),
|
|
32470
|
+
screen: exports_external.string().optional(),
|
|
32471
|
+
data: exports_external.record(exports_external.string(), exports_external.unknown()).optional(),
|
|
32472
|
+
flowToken: exports_external.string().optional(),
|
|
32473
|
+
draft: exports_external.boolean().optional()
|
|
32474
|
+
}).refine((v) => Boolean(v.flowId) !== Boolean(v.flowName), {
|
|
32475
|
+
message: "Provide exactly one of flowId or flowName",
|
|
32476
|
+
path: ["flowId"]
|
|
32477
|
+
});
|
|
32478
|
+
WhatsAppCloudRegisterRequestSchema = exports_external.object({
|
|
32479
|
+
pin: exports_external.string().regex(/^\d{6}$/, "PIN must be exactly 6 digits").optional()
|
|
32480
|
+
});
|
|
32481
|
+
SendTemplateRequestSchema = exports_external.object({
|
|
32482
|
+
to: PhoneSchema,
|
|
32483
|
+
templateName: exports_external.string().min(1),
|
|
32484
|
+
language: exports_external.string().min(2).default("pt_BR"),
|
|
32485
|
+
variables: exports_external.record(exports_external.string(), exports_external.string()).default({}),
|
|
32486
|
+
headerMedia: exports_external.object({
|
|
32487
|
+
type: exports_external.enum(["image", "video", "document"]),
|
|
32488
|
+
url: exports_external.string().url().optional(),
|
|
32489
|
+
handle: exports_external.string().optional()
|
|
32490
|
+
}).optional()
|
|
32491
|
+
});
|
|
32492
|
+
});
|
|
32493
|
+
|
|
32230
32494
|
// ../core/src/schemas/index.ts
|
|
32231
32495
|
var init_schemas = __esm(() => {
|
|
32232
32496
|
init_agent2();
|
|
@@ -32240,6 +32504,7 @@ var init_schemas = __esm(() => {
|
|
|
32240
32504
|
init_instance();
|
|
32241
32505
|
init_message();
|
|
32242
32506
|
init_person();
|
|
32507
|
+
init_whatsapp_cloud();
|
|
32243
32508
|
});
|
|
32244
32509
|
|
|
32245
32510
|
// ../core/src/types/channel.ts
|
|
@@ -32272,6 +32537,9 @@ var init_channel = __esm(() => {
|
|
|
32272
32537
|
"live_location",
|
|
32273
32538
|
"product",
|
|
32274
32539
|
"pix",
|
|
32540
|
+
"template",
|
|
32541
|
+
"location_request",
|
|
32542
|
+
"flow",
|
|
32275
32543
|
"edit",
|
|
32276
32544
|
"delete",
|
|
32277
32545
|
"unknown"
|
|
@@ -32281,6 +32549,14 @@ var init_channel = __esm(() => {
|
|
|
32281
32549
|
RULE_TYPES = ["allow", "deny"];
|
|
32282
32550
|
});
|
|
32283
32551
|
|
|
32552
|
+
// ../core/src/types/whatsapp-cloud.ts
|
|
32553
|
+
var META_TEMPLATE_CATEGORIES, META_TEMPLATE_STATUSES, META_TEMPLATE_QUALITY_SCORES;
|
|
32554
|
+
var init_whatsapp_cloud2 = __esm(() => {
|
|
32555
|
+
META_TEMPLATE_CATEGORIES = ["MARKETING", "UTILITY", "AUTHENTICATION"];
|
|
32556
|
+
META_TEMPLATE_STATUSES = ["APPROVED", "PENDING", "REJECTED", "PAUSED", "DELETED"];
|
|
32557
|
+
META_TEMPLATE_QUALITY_SCORES = ["GREEN", "YELLOW", "RED", "UNKNOWN"];
|
|
32558
|
+
});
|
|
32559
|
+
|
|
32284
32560
|
// ../core/src/types/index.ts
|
|
32285
32561
|
function ok(value) {
|
|
32286
32562
|
return { ok: true, value };
|
|
@@ -32292,6 +32568,7 @@ var SETTING_VALUE_TYPES;
|
|
|
32292
32568
|
var init_types5 = __esm(() => {
|
|
32293
32569
|
init_channel();
|
|
32294
32570
|
init_agent();
|
|
32571
|
+
init_whatsapp_cloud2();
|
|
32295
32572
|
SETTING_VALUE_TYPES = ["string", "integer", "boolean", "json", "secret"];
|
|
32296
32573
|
});
|
|
32297
32574
|
|
|
@@ -66871,6 +67148,10 @@ __export(exports_src, {
|
|
|
66871
67148
|
armSequence: () => armSequence,
|
|
66872
67149
|
appUptime: () => appUptime,
|
|
66873
67150
|
agentStateKey: () => agentStateKey,
|
|
67151
|
+
WhatsAppTemplateComponentSchema: () => WhatsAppTemplateComponentSchema,
|
|
67152
|
+
WhatsAppFlowSendSchema: () => WhatsAppFlowSendSchema,
|
|
67153
|
+
WhatsAppCloudRegisterRequestSchema: () => WhatsAppCloudRegisterRequestSchema,
|
|
67154
|
+
WhatsAppCloudConnectRequestSchema: () => WhatsAppCloudConnectRequestSchema,
|
|
66874
67155
|
WebhookAgentProvider: () => WebhookAgentProvider,
|
|
66875
67156
|
ValidationError: () => ValidationError2,
|
|
66876
67157
|
UuidSchema: () => UuidSchema,
|
|
@@ -66891,6 +67172,7 @@ __export(exports_src, {
|
|
|
66891
67172
|
SplitDelayModeSchema: () => SplitDelayModeSchema,
|
|
66892
67173
|
SettingValueTypeSchema: () => SettingValueTypeSchema,
|
|
66893
67174
|
SetAgentStateSchema: () => SetAgentStateSchema,
|
|
67175
|
+
SendTemplateRequestSchema: () => SendTemplateRequestSchema,
|
|
66894
67176
|
SendResultSchema: () => SendResultSchema,
|
|
66895
67177
|
Scheduler: () => Scheduler,
|
|
66896
67178
|
STREAM_NAMES: () => STREAM_NAMES,
|
|
@@ -66922,7 +67204,32 @@ __export(exports_src, {
|
|
|
66922
67204
|
NatsGenieProvider: () => NatsGenieProvider,
|
|
66923
67205
|
NatsEventBus: () => NatsEventBus,
|
|
66924
67206
|
MetadataSchema: () => MetadataSchema,
|
|
67207
|
+
MetaWebhookValueSchema: () => MetaWebhookValueSchema,
|
|
67208
|
+
MetaWebhookStatusEntrySchema: () => MetaWebhookStatusEntrySchema,
|
|
67209
|
+
MetaWebhookPayloadSchema: () => MetaWebhookPayloadSchema,
|
|
67210
|
+
MetaWebhookEntrySchema: () => MetaWebhookEntrySchema,
|
|
67211
|
+
MetaWebhookChangeSchema: () => MetaWebhookChangeSchema,
|
|
67212
|
+
MetaTemplateStatusUpdateSchema: () => MetaTemplateStatusUpdateSchema,
|
|
67213
|
+
MetaTemplateStatusSchema: () => MetaTemplateStatusSchema,
|
|
67214
|
+
MetaTemplateQualityScoreSchema: () => MetaTemplateQualityScoreSchema,
|
|
67215
|
+
MetaTemplateHeaderComponentSchema: () => MetaTemplateHeaderComponentSchema,
|
|
67216
|
+
MetaTemplateFooterComponentSchema: () => MetaTemplateFooterComponentSchema,
|
|
67217
|
+
MetaTemplateCategorySchema: () => MetaTemplateCategorySchema,
|
|
67218
|
+
MetaTemplateButtonsComponentSchema: () => MetaTemplateButtonsComponentSchema,
|
|
67219
|
+
MetaTemplateButtonSchema: () => MetaTemplateButtonSchema,
|
|
67220
|
+
MetaTemplateBodyComponentSchema: () => MetaTemplateBodyComponentSchema,
|
|
67221
|
+
MetaInboundTextMessageSchema: () => MetaInboundTextMessageSchema,
|
|
67222
|
+
MetaInboundReactionMessageSchema: () => MetaInboundReactionMessageSchema,
|
|
67223
|
+
MetaInboundMessageSchema: () => MetaInboundMessageSchema,
|
|
67224
|
+
MetaInboundMediaMessageSchema: () => MetaInboundMediaMessageSchema,
|
|
67225
|
+
MetaInboundLocationMessageSchema: () => MetaInboundLocationMessageSchema,
|
|
67226
|
+
MetaInboundInteractiveMessageSchema: () => MetaInboundInteractiveMessageSchema,
|
|
67227
|
+
MetaInboundContactsMessageSchema: () => MetaInboundContactsMessageSchema,
|
|
67228
|
+
MetaInboundButtonMessageSchema: () => MetaInboundButtonMessageSchema,
|
|
66925
67229
|
MIN_HOOK_PRIORITY: () => MIN_HOOK_PRIORITY,
|
|
67230
|
+
META_TEMPLATE_STATUSES: () => META_TEMPLATE_STATUSES,
|
|
67231
|
+
META_TEMPLATE_QUALITY_SCORES: () => META_TEMPLATE_QUALITY_SCORES,
|
|
67232
|
+
META_TEMPLATE_CATEGORIES: () => META_TEMPLATE_CATEGORIES,
|
|
66926
67233
|
MESSAGING_WINDOW_MS: () => MESSAGING_WINDOW_MS,
|
|
66927
67234
|
MAX_HOOK_PRIORITY: () => MAX_HOOK_PRIORITY,
|
|
66928
67235
|
MAX_HOOKS_PER_INSTANCE: () => MAX_HOOKS_PER_INSTANCE,
|
|
@@ -66957,6 +67264,8 @@ __export(exports_src, {
|
|
|
66957
67264
|
EventStatusSchema: () => EventStatusSchema,
|
|
66958
67265
|
EventRegistry: () => EventRegistry,
|
|
66959
67266
|
EventQuerySchema: () => EventQuerySchema,
|
|
67267
|
+
EmbeddedSignupExchangeResponseSchema: () => EmbeddedSignupExchangeResponseSchema,
|
|
67268
|
+
EmbeddedSignupExchangeRequestSchema: () => EmbeddedSignupExchangeRequestSchema,
|
|
66960
67269
|
EmailSchema: () => EmailSchema,
|
|
66961
67270
|
EgressLimitError: () => EgressLimitError,
|
|
66962
67271
|
EgressBlockedError: () => EgressBlockedError,
|
|
@@ -72319,6 +72628,7 @@ var init_pg_core = __esm(() => {
|
|
|
72319
72628
|
// ../db/src/schema.ts
|
|
72320
72629
|
var exports_schema = {};
|
|
72321
72630
|
__export(exports_schema, {
|
|
72631
|
+
whatsappTemplates: () => whatsappTemplates,
|
|
72322
72632
|
webhookSources: () => webhookSources,
|
|
72323
72633
|
turnsRelations: () => turnsRelations,
|
|
72324
72634
|
turns: () => turns,
|
|
@@ -72448,7 +72758,7 @@ __export(exports_schema, {
|
|
|
72448
72758
|
accessRules: () => accessRules,
|
|
72449
72759
|
accessModes: () => accessModes
|
|
72450
72760
|
});
|
|
72451
|
-
var channelTypes, agentTypes, agentSystems, agentEntityTypes, debounceMode, splitDelayMode, supersedeMode, replyFilterMode, agentSessionStrategies, ruleTypes, accessModes, settingValueTypes, apiKeyStatuses, apiKeyProfiles, eventTypes, contentTypes, chatTypes, messageSources, messageTypes, messageStatuses, deliveryStatuses, jobStatuses, providerSchemas, agentProviders, agents, agentRoutes, agentSessions, apiKeys, apiKeyAuditLogs, apiKeysRelations, apiKeyAuditLogsRelations, instances, persons, platformIdentities, conversations, chats, chatParticipants, omniGroups, messages2, omniEvents, handoffLogs, closeContactOutcomes, closeContactLogs, accessRules, globalSettings, settingChangeHistory, batchJobs, syncJobTypes, syncJobs, mediaContent, chatIdMappings, pluginStorage, agentProvidersRelations, agentsRelations, instancesRelations, syncJobsRelations, personsRelations, platformIdentitiesRelations, conversationsRelations, chatsRelations, chatParticipantsRelations, messagesRelations, omniEventsRelations, accessRulesRelations, globalSettingsRelations, settingChangeHistoryRelations, batchJobsRelations, mediaContentRelations, chatIdMappingsRelations, deadLetterStatuses, deadLetterEvents, payloadStorageConfig, payloadStages, eventPayloads, webhookSources, conditionOperators, actionTypes, automationDebounceModes, automations2, automationLogStatuses, automationLogs, consumerOffsets, automationsRelations, automationLogsRelations, triggerLogs, triggerLogsRelations, agentRoutesRelations, agentTaskStatuses, agentTasks, agentTasksRelations, turnStatuses, turnActions, turns, turnsRelations, followUpDisarmReasons, chatFollowUpState, chatFollowUpStateRelations, processedEvents, genieHosts, tenantStatuses, principalTypes, principalStatuses, tenantRoles, membershipStatuses, credentialClasses, authCredentialStatuses, platformApiKeyStatuses, tenants, principals, tenantMemberships, tenantRolePolicies, platformApiKeys, tenantKeyLineage, authCredentials, tenantAuditLogs, platformAuditLogs, platformProviderCatalog, tenantProviderConfig, platformSettings, tenantSettings, platformSettingChangeHistory, tenantSettingChangeHistory, platformPluginStorage, tenantPluginStorage, platformPayloadStorageConfig, tenantPayloadStorageOverrides, tenantMigrationLedger, tenantMigrationLedgerHistory;
|
|
72761
|
+
var channelTypes, agentTypes, agentSystems, agentEntityTypes, debounceMode, splitDelayMode, supersedeMode, replyFilterMode, agentSessionStrategies, ruleTypes, accessModes, settingValueTypes, apiKeyStatuses, apiKeyProfiles, eventTypes, contentTypes, chatTypes, messageSources, messageTypes, messageStatuses, deliveryStatuses, jobStatuses, providerSchemas, agentProviders, agents, agentRoutes, agentSessions, apiKeys, apiKeyAuditLogs, apiKeysRelations, apiKeyAuditLogsRelations, instances, whatsappTemplates, persons, platformIdentities, conversations, chats, chatParticipants, omniGroups, messages2, omniEvents, handoffLogs, closeContactOutcomes, closeContactLogs, accessRules, globalSettings, settingChangeHistory, batchJobs, syncJobTypes, syncJobs, mediaContent, chatIdMappings, pluginStorage, agentProvidersRelations, agentsRelations, instancesRelations, syncJobsRelations, personsRelations, platformIdentitiesRelations, conversationsRelations, chatsRelations, chatParticipantsRelations, messagesRelations, omniEventsRelations, accessRulesRelations, globalSettingsRelations, settingChangeHistoryRelations, batchJobsRelations, mediaContentRelations, chatIdMappingsRelations, deadLetterStatuses, deadLetterEvents, payloadStorageConfig, payloadStages, eventPayloads, webhookSources, conditionOperators, actionTypes, automationDebounceModes, automations2, automationLogStatuses, automationLogs, consumerOffsets, automationsRelations, automationLogsRelations, triggerLogs, triggerLogsRelations, agentRoutesRelations, agentTaskStatuses, agentTasks, agentTasksRelations, turnStatuses, turnActions, turns, turnsRelations, followUpDisarmReasons, chatFollowUpState, chatFollowUpStateRelations, processedEvents, genieHosts, tenantStatuses, principalTypes, principalStatuses, tenantRoles, membershipStatuses, credentialClasses, authCredentialStatuses, platformApiKeyStatuses, tenants, principals, tenantMemberships, tenantRolePolicies, platformApiKeys, tenantKeyLineage, authCredentials, tenantAuditLogs, platformAuditLogs, platformProviderCatalog, tenantProviderConfig, platformSettings, tenantSettings, platformSettingChangeHistory, tenantSettingChangeHistory, platformPluginStorage, tenantPluginStorage, platformPayloadStorageConfig, tenantPayloadStorageOverrides, tenantMigrationLedger, tenantMigrationLedgerHistory;
|
|
72452
72762
|
var init_schema2 = __esm(() => {
|
|
72453
72763
|
init_events();
|
|
72454
72764
|
init_drizzle_orm();
|
|
@@ -72748,6 +73058,15 @@ var init_schema2 = __esm(() => {
|
|
|
72748
73058
|
twilioStatusCallbackUrl: text("twilio_status_callback_url"),
|
|
72749
73059
|
twilioWebhookUrl: text("twilio_webhook_url"),
|
|
72750
73060
|
twilioValidateSignature: boolean("twilio_validate_signature").notNull().default(true),
|
|
73061
|
+
metaPhoneNumberId: varchar("meta_phone_number_id", { length: 64 }),
|
|
73062
|
+
metaWabaId: varchar("meta_waba_id", { length: 64 }),
|
|
73063
|
+
metaAccessToken: text("meta_access_token"),
|
|
73064
|
+
metaAppId: varchar("meta_app_id", { length: 64 }),
|
|
73065
|
+
metaBusinessId: varchar("meta_business_id", { length: 64 }),
|
|
73066
|
+
metaApiVersion: varchar("meta_api_version", { length: 16 }).notNull().default("v25.0"),
|
|
73067
|
+
metaConnectionMethod: varchar("meta_connection_method", { length: 32 }).default("manual"),
|
|
73068
|
+
metaDisplayPhoneNumber: varchar("meta_display_phone_number", { length: 32 }),
|
|
73069
|
+
metaConnectedAt: timestamp("meta_connected_at", { withTimezone: true }),
|
|
72751
73070
|
agentId: uuid("agent_id").references(() => agents.id, { onDelete: "set null" }),
|
|
72752
73071
|
agentTimeout: integer("agent_timeout").notNull().default(600),
|
|
72753
73072
|
agentStreamMode: boolean("agent_stream_mode").notNull().default(false),
|
|
@@ -72828,8 +73147,29 @@ var init_schema2 = __esm(() => {
|
|
|
72828
73147
|
isActiveIdx: index("instances_is_active_idx").on(table3.isActive),
|
|
72829
73148
|
isDefaultIdx: index("instances_is_default_idx").on(table3.isDefault),
|
|
72830
73149
|
agentIdIdx: index("instances_agent_id_idx").on(table3.agentId),
|
|
73150
|
+
metaPhoneNumberIdx: index("instances_meta_phone_number_idx").on(table3.metaPhoneNumberId),
|
|
72831
73151
|
chainModeCheck: check("instances_chain_mode_check", sql`${table3.chainMode} IN ('off', 'forward', 'bidirectional')`)
|
|
72832
73152
|
}));
|
|
73153
|
+
whatsappTemplates = pgTable("whatsapp_templates", {
|
|
73154
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
73155
|
+
instanceId: uuid("instance_id").notNull().references(() => instances.id, { onDelete: "cascade" }),
|
|
73156
|
+
metaId: varchar("meta_id", { length: 64 }),
|
|
73157
|
+
wabaId: varchar("waba_id", { length: 64 }).notNull(),
|
|
73158
|
+
name: varchar("name", { length: 255 }).notNull(),
|
|
73159
|
+
language: varchar("language", { length: 16 }).notNull().default("pt_BR"),
|
|
73160
|
+
category: varchar("category", { length: 32 }).notNull(),
|
|
73161
|
+
status: varchar("status", { length: 32 }).notNull().default("PENDING"),
|
|
73162
|
+
components: jsonb("components").$type(),
|
|
73163
|
+
variableMapping: jsonb("variable_mapping").$type(),
|
|
73164
|
+
rejectionReason: text("rejection_reason"),
|
|
73165
|
+
qualityScore: varchar("quality_score", { length: 16 }),
|
|
73166
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
73167
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
73168
|
+
}, (t) => ({
|
|
73169
|
+
instanceIdx: index("idx_wa_tpl_instance").on(t.instanceId),
|
|
73170
|
+
instanceNameLangUnique: uniqueIndex("idx_wa_tpl_instance_name_lang").on(t.instanceId, t.name, t.language),
|
|
73171
|
+
statusIdx: index("idx_wa_tpl_status").on(t.status)
|
|
73172
|
+
}));
|
|
72833
73173
|
persons = pgTable("persons", {
|
|
72834
73174
|
id: uuid("id").primaryKey().defaultRandom(),
|
|
72835
73175
|
displayName: varchar("display_name", { length: 255 }),
|
|
@@ -127312,7 +127652,7 @@ import { fileURLToPath } from "url";
|
|
|
127312
127652
|
// package.json
|
|
127313
127653
|
var package_default = {
|
|
127314
127654
|
name: "@automagik/omni",
|
|
127315
|
-
version: "2.
|
|
127655
|
+
version: "2.260730.1",
|
|
127316
127656
|
description: "LLM-optimized CLI for Omni",
|
|
127317
127657
|
type: "module",
|
|
127318
127658
|
bin: {
|
|
@@ -127373,6 +127713,7 @@ var package_default = {
|
|
|
127373
127713
|
"@omni/channel-slack": "workspace:*",
|
|
127374
127714
|
"@omni/channel-telegram": "workspace:*",
|
|
127375
127715
|
"@omni/channel-whatsapp": "workspace:*",
|
|
127716
|
+
"@omni/channel-whatsapp-cloud": "workspace:*",
|
|
127376
127717
|
"@omni/core": "workspace:*",
|
|
127377
127718
|
"@omni/sdk": "workspace:*",
|
|
127378
127719
|
"@types/node": "^22.10.3",
|
|
@@ -135169,10 +135510,45 @@ function createInstancesCommand() {
|
|
|
135169
135510
|
error(`Failed to request pairing code: ${message}`);
|
|
135170
135511
|
}
|
|
135171
135512
|
});
|
|
135172
|
-
instances.command("connect <id>").description("Connect an instance").option("--force-new-qr", "Force generation of new QR code").option("--token <token>", "Discord bot token (for Discord instances)").option("--twilio-account-sid <sid>", "Twilio Account SID").option("--twilio-auth-token <token>", "Twilio Auth Token").option("--twilio-from <address>", "Twilio WhatsApp sender address (whatsapp:+E164)").option("--twilio-messaging-service-sid <sid>", "Twilio Messaging Service SID").option("--twilio-status-callback-url <url>", "Twilio outbound status callback URL").option("--twilio-webhook-url <url>", "Public Twilio webhook URL for signature validation").option("--twilio-validate-signature", "Validate X-Twilio-Signature on webhooks").option("--no-twilio-validate-signature", "Disable X-Twilio-Signature validation").action(async (rawId, options) => {
|
|
135513
|
+
instances.command("connect <id>").description("Connect an instance").option("--force-new-qr", "Force generation of new QR code").option("--token <token>", "Discord bot token (for Discord instances)").option("--twilio-account-sid <sid>", "Twilio Account SID").option("--twilio-auth-token <token>", "Twilio Auth Token").option("--twilio-from <address>", "Twilio WhatsApp sender address (whatsapp:+E164)").option("--twilio-messaging-service-sid <sid>", "Twilio Messaging Service SID").option("--twilio-status-callback-url <url>", "Twilio outbound status callback URL").option("--twilio-webhook-url <url>", "Public Twilio webhook URL for signature validation").option("--twilio-validate-signature", "Validate X-Twilio-Signature on webhooks").option("--no-twilio-validate-signature", "Disable X-Twilio-Signature validation").option("--access-token <token>", "WhatsApp Cloud (Meta) access token \u2014 pair with --phone-number-id + --waba-id").option("--phone-number-id <id>", "WhatsApp Cloud phone_number_id (Graph API id, not E.164)").option("--waba-id <id>", "WhatsApp Business Account id (WABA id)").option("--meta-app-id <id>", "Optional override for META_APP_ID (when the tenant owns its own Meta App)").option("--meta-business-id <id>", "Optional Meta Business Manager id").action(async (rawId, options) => {
|
|
135173
135514
|
const client = getClient();
|
|
135174
135515
|
try {
|
|
135175
135516
|
const id = await resolveInstanceId(rawId);
|
|
135517
|
+
const wantsWhatsAppCloud = options.accessToken && options.phoneNumberId && options.wabaId;
|
|
135518
|
+
if (wantsWhatsAppCloud) {
|
|
135519
|
+
const instance = await client.instances.get(id);
|
|
135520
|
+
if (instance.channel !== "whatsapp-cloud") {
|
|
135521
|
+
error(`Instance ${id} is not a whatsapp-cloud instance (channel=${instance.channel}). --access-token/--phone-number-id/--waba-id only apply to whatsapp-cloud.`);
|
|
135522
|
+
return;
|
|
135523
|
+
}
|
|
135524
|
+
const { loadConfig: loadConfig2 } = await Promise.resolve().then(() => (init_config(), exports_config));
|
|
135525
|
+
const cfg = loadConfig2();
|
|
135526
|
+
const baseUrl = cfg.apiUrl ?? "http://localhost:8882";
|
|
135527
|
+
const apiKey = cfg.apiKey ?? "";
|
|
135528
|
+
const resp = await fetch(`${baseUrl}/api/v2/instances/${id}/whatsapp-cloud/connect`, {
|
|
135529
|
+
method: "POST",
|
|
135530
|
+
headers: { "Content-Type": "application/json", "x-api-key": apiKey },
|
|
135531
|
+
body: JSON.stringify({
|
|
135532
|
+
accessToken: options.accessToken,
|
|
135533
|
+
phoneNumberId: options.phoneNumberId,
|
|
135534
|
+
wabaId: options.wabaId,
|
|
135535
|
+
appId: options.metaAppId,
|
|
135536
|
+
businessId: options.metaBusinessId
|
|
135537
|
+
})
|
|
135538
|
+
});
|
|
135539
|
+
if (!resp.ok) {
|
|
135540
|
+
const err = await resp.json().catch(() => ({}));
|
|
135541
|
+
error(`Failed to connect: ${err?.error?.message ?? `HTTP ${resp.status}`}`);
|
|
135542
|
+
return;
|
|
135543
|
+
}
|
|
135544
|
+
const result2 = await resp.json();
|
|
135545
|
+
success("Instance connected via WhatsApp Cloud (manual)", {
|
|
135546
|
+
status: result2.data?.status ?? "connected",
|
|
135547
|
+
displayPhoneNumber: result2.data?.displayPhoneNumber ?? null,
|
|
135548
|
+
qualityRating: result2.data?.qualityRating ?? null
|
|
135549
|
+
});
|
|
135550
|
+
return;
|
|
135551
|
+
}
|
|
135176
135552
|
const result = await client.instances.connect(id, {
|
|
135177
135553
|
forceNewQr: options.forceNewQr,
|
|
135178
135554
|
token: options.token,
|
|
@@ -2852,6 +2852,18 @@ export interface components {
|
|
|
2852
2852
|
text: string;
|
|
2853
2853
|
/** @description Message ID to reply to */
|
|
2854
2854
|
replyTo?: string;
|
|
2855
|
+
/** @description Inline buttons — mapped natively per channel (WhatsApp Cloud: up to 3 reply buttons, 4-10 become a list; Telegram: inline keyboard) */
|
|
2856
|
+
buttons?: {
|
|
2857
|
+
/** @description Button label */
|
|
2858
|
+
text: string;
|
|
2859
|
+
/** @description Callback payload (reply button / list row id) */
|
|
2860
|
+
data?: string;
|
|
2861
|
+
/**
|
|
2862
|
+
* Format: uri
|
|
2863
|
+
* @description Link button URL (mutually exclusive with data)
|
|
2864
|
+
*/
|
|
2865
|
+
url?: string;
|
|
2866
|
+
}[];
|
|
2855
2867
|
};
|
|
2856
2868
|
TTSVoice: {
|
|
2857
2869
|
/** @description ElevenLabs voice ID */
|
|
@@ -7401,6 +7413,18 @@ export interface operations {
|
|
|
7401
7413
|
text: string;
|
|
7402
7414
|
/** @description Message ID to reply to */
|
|
7403
7415
|
replyTo?: string;
|
|
7416
|
+
/** @description Inline buttons — mapped natively per channel (WhatsApp Cloud: up to 3 reply buttons, 4-10 become a list; Telegram: inline keyboard) */
|
|
7417
|
+
buttons?: {
|
|
7418
|
+
/** @description Button label */
|
|
7419
|
+
text: string;
|
|
7420
|
+
/** @description Callback payload (reply button / list row id) */
|
|
7421
|
+
data?: string;
|
|
7422
|
+
/**
|
|
7423
|
+
* Format: uri
|
|
7424
|
+
* @description Link button URL (mutually exclusive with data)
|
|
7425
|
+
*/
|
|
7426
|
+
url?: string;
|
|
7427
|
+
}[];
|
|
7404
7428
|
};
|
|
7405
7429
|
};
|
|
7406
7430
|
};
|