@fayz-ai/plugin-conversations 0.23.1 → 0.23.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.
- package/dist/index.js +57 -1
- package/dist/index.js.map +1 -1
- package/dist/migrations/index.d.ts +1 -0
- package/dist/migrations/index.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -5594,6 +5594,61 @@ var MIGRATION_014_CLAIMING_TARGETS_IS_SERVER_ONLY = `-- 014_claiming_targets_is_
|
|
|
5594
5594
|
REVOKE ALL ON FUNCTION public.conversations_claim_targets(uuid, integer) FROM PUBLIC, anon, authenticated;
|
|
5595
5595
|
GRANT EXECUTE ON FUNCTION public.conversations_claim_targets(uuid, integer) TO service_role;
|
|
5596
5596
|
`;
|
|
5597
|
+
var MIGRATION_015_THE_SERVICE_DOOR_FOR_MESSAGING = `-- ============================================================================
|
|
5598
|
+
-- 015_the_service_door_for_messaging \u2014 the WhatsApp edge functions move to the
|
|
5599
|
+
-- integration service (ADR 0003 phase 2, wave 2).
|
|
5600
|
+
--
|
|
5601
|
+
-- Two kinds of table, two kinds of access:
|
|
5602
|
+
--
|
|
5603
|
+
-- * tenant tables a member already writes (conversations, messages,
|
|
5604
|
+
-- campaigns, templates): the service writes them AS the store's owner or
|
|
5605
|
+
-- as the verified caller (core migrations 210/212), under RLS. Nothing
|
|
5606
|
+
-- here.
|
|
5607
|
+
-- * service tables only a machine writes, which service_role wrote until
|
|
5608
|
+
-- now: provider credentials, channels, opt-outs, webhook events, provider
|
|
5609
|
+
-- templates, payment requests. fayz_integration gets exactly that, table
|
|
5610
|
+
-- by table, with an explicit policy. Panels keep their SELECT policies.
|
|
5611
|
+
--
|
|
5612
|
+
-- And the three server-only functions the webhooks call get EXECUTE for the
|
|
5613
|
+
-- service role (they were service_role only, 014).
|
|
5614
|
+
--
|
|
5615
|
+
-- Guarded: the role is an operator step. Replay-safe.
|
|
5616
|
+
-- ============================================================================
|
|
5617
|
+
|
|
5618
|
+
DO $$
|
|
5619
|
+
DECLARE
|
|
5620
|
+
t text;
|
|
5621
|
+
f text;
|
|
5622
|
+
BEGIN
|
|
5623
|
+
IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'fayz_integration') THEN
|
|
5624
|
+
RETURN;
|
|
5625
|
+
END IF;
|
|
5626
|
+
|
|
5627
|
+
FOREACH t IN ARRAY ARRAY[
|
|
5628
|
+
'plg_conversations_providers',
|
|
5629
|
+
'plg_conversations_channels',
|
|
5630
|
+
'plg_conversations_optouts',
|
|
5631
|
+
'plg_conversations_webhook_events',
|
|
5632
|
+
'plg_automations_provider_templates',
|
|
5633
|
+
'plg_conversations_payment_requests'
|
|
5634
|
+
] LOOP
|
|
5635
|
+
IF to_regclass('public.' || t) IS NULL THEN CONTINUE; END IF;
|
|
5636
|
+
EXECUTE format('GRANT SELECT, INSERT, UPDATE, DELETE ON public.%I TO fayz_integration', t);
|
|
5637
|
+
EXECUTE format('DROP POLICY IF EXISTS %I ON public.%I', t || '_service', t);
|
|
5638
|
+
EXECUTE format('CREATE POLICY %I ON public.%I FOR ALL TO fayz_integration USING (true) WITH CHECK (true)', t || '_service', t);
|
|
5639
|
+
END LOOP;
|
|
5640
|
+
|
|
5641
|
+
FOREACH f IN ARRAY ARRAY[
|
|
5642
|
+
'public.conversations_claim_targets(uuid, integer)',
|
|
5643
|
+
'public.plg_booking_apply_channel_reply(uuid, text, uuid)',
|
|
5644
|
+
'public.plg_conversations_match_by_phone(text, text, text, uuid)'
|
|
5645
|
+
] LOOP
|
|
5646
|
+
IF to_regprocedure(f) IS NOT NULL THEN
|
|
5647
|
+
EXECUTE format('GRANT EXECUTE ON FUNCTION %s TO fayz_integration', f);
|
|
5648
|
+
END IF;
|
|
5649
|
+
END LOOP;
|
|
5650
|
+
END $$;
|
|
5651
|
+
`;
|
|
5597
5652
|
var MIGRATIONS = [
|
|
5598
5653
|
{ id: "000_baseline", sql: MIGRATION_000_BASELINE },
|
|
5599
5654
|
{ id: "001_a_caixa_sabe_quem_falou_por_ultimo", sql: MIGRATION_001_A_CAIXA_SABE_QUEM_FALOU_POR_ULTIMO },
|
|
@@ -5609,7 +5664,8 @@ var MIGRATIONS = [
|
|
|
5609
5664
|
{ id: "011_o_anuncio_e_uma_campainha_nao_um_recado", sql: MIGRATION_011_O_ANUNCIO_E_UMA_CAMPAINHA_NAO_UM_RECADO },
|
|
5610
5665
|
{ id: "012_a_rich_message_keeps_its_shape", sql: MIGRATION_012_A_RICH_MESSAGE_KEEPS_ITS_SHAPE },
|
|
5611
5666
|
{ id: "013_a_midia_fica_conosco", sql: MIGRATION_013_A_MIDIA_FICA_CONOSCO },
|
|
5612
|
-
{ id: "014_claiming_targets_is_server_only", sql: MIGRATION_014_CLAIMING_TARGETS_IS_SERVER_ONLY }
|
|
5667
|
+
{ id: "014_claiming_targets_is_server_only", sql: MIGRATION_014_CLAIMING_TARGETS_IS_SERVER_ONLY },
|
|
5668
|
+
{ id: "015_the_service_door_for_messaging", sql: MIGRATION_015_THE_SERVICE_DOOR_FOR_MESSAGING }
|
|
5613
5669
|
];
|
|
5614
5670
|
var conversationsV1SettingsTabs = [
|
|
5615
5671
|
defineSettingsTab({
|