@fayz-ai/plugin-conversations 0.40.1 → 0.42.0
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/{CampaignsSurface-WTX45XRZ.js → CampaignsSurface-UI7NSM6U.js} +23 -10
- package/dist/CampaignsSurface-UI7NSM6U.js.map +1 -0
- package/dist/{ConversationsPage-OA5UAMU3.js → ConversationsPage-Z3YKLAOJ.js} +124 -108
- package/dist/ConversationsPage-Z3YKLAOJ.js.map +1 -0
- package/dist/index.js +3 -3
- package/dist/migrations/index.d.ts +1 -0
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/main.browser.js +2 -1
- package/dist/migrations/main.browser.js.map +1 -1
- package/dist/migrations/main.js +58 -2
- package/dist/migrations/main.js.map +1 -1
- package/dist/views/ConversationList.d.ts.map +1 -1
- package/dist/views/campaigns/CampaignBreakdown.d.ts.map +1 -1
- package/dist/views/campaigns/CampaignsSurface.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/CampaignsSurface-WTX45XRZ.js.map +0 -1
- package/dist/ConversationsPage-OA5UAMU3.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -2330,11 +2330,11 @@ function createConversationsPlugin(options) {
|
|
|
2330
2330
|
locales: conversationsLocales
|
|
2331
2331
|
};
|
|
2332
2332
|
}
|
|
2333
|
-
var ConversationsPage = React__default.lazy(() => import('./ConversationsPage-
|
|
2333
|
+
var ConversationsPage = React__default.lazy(() => import('./ConversationsPage-Z3YKLAOJ.js').then((m) => ({ default: m.ConversationsPage })));
|
|
2334
2334
|
var AtendeAIPage = React__default.lazy(() => import('./AtendeAIPage-PBBMWIDW.js').then((m) => ({ default: m.AtendeAIPage })));
|
|
2335
2335
|
var ConversationsSettingsTab = lazyComponent(() => import('./ConversationsSettings-GORCWUHD.js').then((m) => m.ConversationsSettingsTab));
|
|
2336
|
-
var CampaignsSurface = React__default.lazy(() => import('./CampaignsSurface-
|
|
2337
|
-
var SendHistorySurface = React__default.lazy(() => import('./CampaignsSurface-
|
|
2336
|
+
var CampaignsSurface = React__default.lazy(() => import('./CampaignsSurface-UI7NSM6U.js').then((m) => ({ default: m.CampaignsSurface })));
|
|
2337
|
+
var SendHistorySurface = React__default.lazy(() => import('./CampaignsSurface-UI7NSM6U.js').then((m) => ({ default: m.SendHistorySurface })));
|
|
2338
2338
|
var TemplatesSurface = React__default.lazy(() => import('./TemplatesSurface-D6UMF5XE.js').then((m) => ({ default: m.TemplatesSurface })));
|
|
2339
2339
|
|
|
2340
2340
|
export { CampaignsSurface, PAYMENT_PREFLIGHT_FUNCTION, SendHistorySurface, TYXTER_CONNECTOR_ID, TYXTER_LATENCY_BUDGET_MS, TemplatesSurface, WhatsAppProviders, campaignsApi, canOfferPayment, createConversationsPlugin, createMockConversationsProvider, createSupabaseConversationsProvider, openPaymentSetupSession, readPaymentReadiness, tyxterConnectorDef };
|
|
@@ -28,6 +28,7 @@ export declare const MIGRATION_026_A_BLOCKED_TOUCH_FALLS_BACK_TO_THE_EVERYDAY_NU
|
|
|
28
28
|
export declare const MIGRATION_027_A_DELIVERED_TOUCH_MOVES_THE_DEAL_FORWARD = "-- 027_a_delivered_touch_moves_the_deal_forward.sql\n--\n-- The house's rule (10-28): once a campaign touch reaches the person, the\n-- deal is no longer a fresh lead nobody spoke to. A deal still in its\n-- pipeline's INITIAL stage (flagged, else the first by order: \"Novo (feira)\") moves to the next working stage\n-- (\"Contato feito\": the next by order that is not won, lost or a waiting\n-- stage). A deal anywhere else never moves, so a campaign can never drag a\n-- deal backwards or past what a seller decided.\n--\n-- \"Reached\" = delivered, read or replied, whichever number sent it (the\n-- Tyxter and Evolution receipts both land on the target). The move is a\n-- plain stage update, so the CRM's own triggers (stage history, outcome\n-- events) run as for a seller's drag.\n--\n-- The deals table belongs to the CRM, which this plugin does not require:\n-- the function reads it dynamically and does nothing without it.\n-- Replay-safe: CREATE OR REPLACE, trigger dropped and recreated by name.\n\nCREATE OR REPLACE FUNCTION public.conversations_touch_moves_deal()\nRETURNS trigger\nLANGUAGE plpgsql SECURITY DEFINER SET search_path TO ''\nAS $function$\nDECLARE\n v_deal uuid;\nBEGIN\n IF NEW.state NOT IN ('delivered', 'read', 'replied')\n OR OLD.state IN ('delivered', 'read', 'replied')\n OR NEW.enrollment_id IS NULL\n OR to_regclass('public.plg_crm_deals') IS NULL\n OR to_regclass('public.plg_crm_pipeline_stages') IS NULL THEN\n RETURN NEW;\n END IF;\n\n SELECT e.deal_id INTO v_deal\n FROM public.plg_conversations_campaign_enrollments e WHERE e.id = NEW.enrollment_id;\n IF v_deal IS NULL THEN RETURN NEW; END IF;\n\n EXECUTE $q$\n UPDATE public.plg_crm_deals d\n SET stage_id = nxt.id\n FROM public.plg_crm_pipeline_stages cur,\n LATERAL (\n SELECT s.id FROM public.plg_crm_pipeline_stages s\n WHERE s.pipeline_id = cur.pipeline_id\n AND s.\"order\" > cur.\"order\"\n AND NOT coalesce(s.is_won, false) AND NOT coalesce(s.is_lost, false)\n AND NOT coalesce(s.is_parked, false)\n ORDER BY s.\"order\" LIMIT 1\n ) nxt\n WHERE d.id = $1 AND d.status = 'open'\n AND cur.id = d.stage_id\n -- The initial stage: the one flagged so, else the first by order.\n AND cur.id = coalesce(\n (SELECT i.id FROM public.plg_crm_pipeline_stages i\n WHERE i.pipeline_id = cur.pipeline_id AND i.is_initial LIMIT 1),\n (SELECT f.id FROM public.plg_crm_pipeline_stages f\n WHERE f.pipeline_id = cur.pipeline_id ORDER BY f.\"order\" LIMIT 1))\n $q$ USING v_deal;\n RETURN NEW;\nEND\n$function$;\n\nDROP TRIGGER IF EXISTS plg_conversations_campaign_targets_move_deal ON public.plg_conversations_campaign_targets;\nCREATE TRIGGER plg_conversations_campaign_targets_move_deal\n AFTER UPDATE OF state ON public.plg_conversations_campaign_targets\n FOR EACH ROW EXECUTE FUNCTION public.conversations_touch_moves_deal();\n";
|
|
29
29
|
export declare const MIGRATION_028_THE_SELLER_HEARS_THE_LEAD_AWAY_FROM_THE_SCREEN = "-- 028_the_seller_hears_the_lead_away_from_the_screen.sql\n--\n-- Sellers away from the computer never knew a lead had answered. When a\n-- lead writes in a COMMERCIAL thread, the lead's owner (the seller on the\n-- card) gets a notice on their own WhatsApp and e-mail, with a link straight\n-- to the conversation. The integration service sends them; this file only\n-- says WHO and WHAT, and keeps the record.\n--\n-- The seller's contacts come from their staff record (Cadastros \u203A\n-- Profissionais): the membership's person \u2014 phone and e-mail \u2014 with the\n-- login e-mail as the e-mail fallback. No phone there = e-mail only.\n--\n-- One notice per conversation and seller every 10 minutes: a lead typing\n-- five lines must not ring five times.\n--\n-- Replay-safe: IF NOT EXISTS, CREATE OR REPLACE.\n\nCREATE TABLE IF NOT EXISTS public.plg_conversations_staff_notices (\n id uuid PRIMARY KEY DEFAULT gen_random_uuid(),\n tenant_id uuid NOT NULL REFERENCES public.tenants(id) ON DELETE CASCADE,\n user_id uuid NOT NULL,\n conversation_id uuid NOT NULL,\n message_id uuid NOT NULL,\n channel text NOT NULL CHECK (channel IN ('whatsapp', 'email')),\n to_address text NOT NULL,\n body text NOT NULL,\n state text NOT NULL DEFAULT 'queued' CHECK (state IN ('queued', 'sent', 'failed')),\n detail text,\n created_at timestamptz NOT NULL DEFAULT now(),\n sent_at timestamptz\n);\n\nCREATE UNIQUE INDEX IF NOT EXISTS uq_plg_conversations_staff_notices_once\n ON public.plg_conversations_staff_notices (message_id, user_id, channel);\nCREATE INDEX IF NOT EXISTS idx_plg_conversations_staff_notices_queue\n ON public.plg_conversations_staff_notices (tenant_id, channel, state) WHERE state = 'queued';\nCREATE INDEX IF NOT EXISTS idx_plg_conversations_staff_notices_recent\n ON public.plg_conversations_staff_notices (conversation_id, user_id, created_at);\n\n-- Server-only, like the other service tables: no tenant role reads it.\nALTER TABLE public.plg_conversations_staff_notices ENABLE ROW LEVEL SECURITY;\n\nCOMMENT ON TABLE public.plg_conversations_staff_notices IS\n 'A seller told on their own WhatsApp/e-mail that a lead wrote (028). Written and sent by the integration service.';\n\n-- The lead messages still waiting for their notice: inbound, in a commercial\n-- thread, recent, with an owner, and no notice to that seller about that\n-- conversation in the last 10 minutes.\nCREATE OR REPLACE FUNCTION public.conversations_staff_notices_due(p_since interval DEFAULT interval '30 minutes')\nRETURNS TABLE (\n message_id uuid, tenant_id uuid, conversation_id uuid, contact_name text, company text,\n preview text, owner_id uuid, owner_name text, owner_phone text, owner_email text\n)\nLANGUAGE sql STABLE SECURITY DEFINER SET search_path TO ''\nAS $function$\n SELECT DISTINCT ON (c.id)\n m.id, c.tenant_id, c.id, coalesce(nullif(c.contact_name, ''), c.contact_handle),\n l.company,\n left(coalesce(nullif(m.body, ''), '(m\u00EDdia)'), 160),\n mem.user_id, p.name, p.phone, coalesce(nullif(p.email, ''), u.email::text)\n FROM public.plg_conversation_messages m\n JOIN public.plg_conversations c ON c.id = m.conversation_id\n JOIN public.v_leads l ON l.id = c.contact_person_id\n JOIN app.memberships mem ON mem.tenant_id = c.tenant_id AND mem.active\n AND mem.user_id::text = l.assigned_to_id\n LEFT JOIN public.people p ON p.id = mem.person_id\n LEFT JOIN auth.users u ON u.id = mem.user_id\n WHERE m.direction = 'inbound'\n AND m.at > now() - p_since\n AND c.inbox = 'commercial'\n AND NOT EXISTS (SELECT 1 FROM public.plg_conversations_staff_notices n\n WHERE n.conversation_id = c.id AND n.user_id = mem.user_id\n AND (n.message_id = m.id OR n.created_at > now() - interval '10 minutes'))\n ORDER BY c.id, m.at DESC\n$function$;\n\nREVOKE ALL ON FUNCTION public.conversations_staff_notices_due(interval) FROM PUBLIC;\nDO $$\nBEGIN\n IF EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'anon') THEN\n REVOKE ALL ON FUNCTION public.conversations_staff_notices_due(interval) FROM anon;\n END IF;\n IF EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'authenticated') THEN\n REVOKE ALL ON FUNCTION public.conversations_staff_notices_due(interval) FROM authenticated;\n END IF;\n IF EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'service_role') THEN\n GRANT EXECUTE ON FUNCTION public.conversations_staff_notices_due(interval) TO service_role;\n GRANT ALL ON public.plg_conversations_staff_notices TO service_role;\n END IF;\n IF EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'fayz_integration') THEN\n GRANT EXECUTE ON FUNCTION public.conversations_staff_notices_due(interval) TO fayz_integration;\n GRANT SELECT, INSERT, UPDATE ON public.plg_conversations_staff_notices TO fayz_integration;\n -- RLS is on and the service does not bypass it: the same open policy\n -- the other service tables give it (optouts, providers).\n DROP POLICY IF EXISTS plg_conversations_staff_notices_service ON public.plg_conversations_staff_notices;\n CREATE POLICY plg_conversations_staff_notices_service ON public.plg_conversations_staff_notices\n FOR ALL TO fayz_integration USING (true) WITH CHECK (true);\n END IF;\nEND\n$$;\n";
|
|
30
30
|
export declare const MIGRATION_029_A_SELLER_CAN_STOP_A_JOURNEY = "-- 029_a_seller_can_stop_a_journey.sql\n--\n-- Contact disposition, the journey half.\n--\n-- A journey stopped by itself only when someone replied or opted out (017).\n-- When the seller learns the number is wrong, or the person said \"no thanks\"\n-- on a call, the next touch still went out in three days. This lets a person\n-- (the seller, or the integration service on a provider signal) stop every\n-- active journey of a person \u2014 or every journey whose routes carry a phone \u2014\n-- and say why, so the monitor can tell \"stopped: wrong number\" from \"failed\".\n--\n-- The phone match reads the enrollment's own routes, not the CRM: a database\n-- without the CRM still migrates and still stops journeys.\n\nALTER TABLE public.plg_conversations_campaign_enrollments\n ADD COLUMN IF NOT EXISTS stop_reason text,\n ADD COLUMN IF NOT EXISTS stopped_at timestamptz,\n ADD COLUMN IF NOT EXISTS stopped_by_name text;\n\nDO $$ BEGIN\n ALTER TABLE public.plg_conversations_campaign_enrollments\n ADD CONSTRAINT plg_conversations_campaign_enrollments_stop_reason CHECK (\n stop_reason IS NULL OR stop_reason IN\n ('opted_out', 'replied', 'wrong_number', 'not_interested', 'no_response', 'converted', 'seller_stopped'));\nEXCEPTION WHEN duplicate_object THEN NULL; END $$;\n\n-- 'stopped' joins the states. Dropped and re-added by name: replay-safe.\nALTER TABLE public.plg_conversations_campaign_enrollments\n DROP CONSTRAINT IF EXISTS plg_conversations_campaign_enrollments_state;\nALTER TABLE public.plg_conversations_campaign_enrollments\n ADD CONSTRAINT plg_conversations_campaign_enrollments_state\n CHECK (state IN ('active', 'replied', 'opted_out', 'completed', 'failed', 'exited', 'no_route', 'stopped'));\n\nCOMMENT ON COLUMN public.plg_conversations_campaign_enrollments.stop_reason IS\n 'Why the journey stopped before its end (029): opted_out, replied, wrong_number, not_interested, no_response, converted, seller_stopped. The free-text note goes to state_reason.';\n\n-- Looking enrollments up by person is what the contact panel and the stop do.\nCREATE INDEX IF NOT EXISTS plg_conversations_campaign_enrollments_person\n ON public.plg_conversations_campaign_enrollments (tenant_id, person_id)\n WHERE person_id IS NOT NULL;\n\n-- \u2500\u2500 the stop \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n--\n-- Who may call: service_role (tenant from the session, else from the\n-- enrollments the person or phone match \u2014 scoped to one tenant, see below),\n-- or a signed-in member of the session's tenant who can work conversations or\n-- deals (conversations.create, sales.edit or crm.pipeline.edit).\nCREATE OR REPLACE FUNCTION public.conversations_stop_journeys(\n p_person uuid,\n p_phone text,\n p_reason text,\n p_note text DEFAULT NULL\n)\nRETURNS integer\nLANGUAGE plpgsql\nSECURITY DEFINER\nSET search_path TO ''\nAS $function$\nDECLARE\n v_service boolean := coalesce(auth.role(), '') = 'service_role';\n v_tenant uuid := app.current_tenant_id();\n v_uid uuid := auth.uid();\n v_reason text := lower(trim(coalesce(p_reason, '')));\n v_digits text := regexp_replace(coalesce(p_phone, ''), '\\D', '', 'g');\n v_name text;\n v_count integer;\nBEGIN\n IF v_reason NOT IN ('opted_out', 'replied', 'wrong_number', 'not_interested', 'no_response', 'converted', 'seller_stopped') THEN\n RAISE EXCEPTION 'conversations_stop_journeys: unknown reason %', p_reason USING ERRCODE = '22023';\n END IF;\n -- The same Brazilian spellings crm_phone_e164 accepts (065), as digits\n -- with the country code; anything else matches no route.\n v_digits := CASE\n WHEN length(v_digits) IN (10, 11) THEN '55' || v_digits\n WHEN length(v_digits) IN (12, 13) AND v_digits LIKE '55%' THEN v_digits\n ELSE NULL END;\n IF p_person IS NULL AND v_digits IS NULL THEN\n RAISE EXCEPTION 'conversations_stop_journeys: send a person or a phone' USING ERRCODE = '22023';\n END IF;\n\n IF v_service THEN\n IF v_tenant IS NULL AND p_person IS NOT NULL THEN\n SELECT p.tenant_id INTO v_tenant FROM public.people p WHERE p.id = p_person;\n END IF;\n IF v_tenant IS NULL THEN\n RAISE EXCEPTION 'conversations_stop_journeys: no tenant (send p_person or a tenant claim)'\n USING ERRCODE = '42501';\n END IF;\n ELSE\n IF v_tenant IS NULL OR v_uid IS NULL\n OR v_tenant NOT IN (SELECT public.user_tenant_ids()) THEN\n RAISE EXCEPTION 'conversations_stop_journeys: not a member of this tenant' USING ERRCODE = '42501';\n END IF;\n IF NOT (app.has_permission_anywhere('conversations.create')\n OR app.has_permission_anywhere('sales.edit')\n OR app.has_permission_anywhere('crm.pipeline.edit')) THEN\n RAISE EXCEPTION 'conversations_stop_journeys: requires conversations.create, sales.edit or crm.pipeline.edit'\n USING ERRCODE = '42501';\n END IF;\n SELECT coalesce(nullif(u.raw_user_meta_data->>'full_name', ''),\n nullif(u.raw_user_meta_data->>'name', ''),\n u.email)\n INTO v_name\n FROM auth.users u WHERE u.id = v_uid;\n END IF;\n\n UPDATE public.plg_conversations_campaign_enrollments e\n SET state = 'stopped',\n stop_reason = v_reason,\n state_reason = coalesce(nullif(trim(coalesce(p_note, '')), ''), e.state_reason),\n stopped_at = now(),\n stopped_by_name = coalesce(v_name, CASE WHEN v_service THEN 'Sistema' END),\n next_run_at = NULL,\n updated_at = now()\n WHERE e.tenant_id = v_tenant\n AND e.state = 'active'\n AND ((p_person IS NOT NULL AND e.person_id = p_person)\n OR (v_digits IS NOT NULL AND EXISTS (\n SELECT 1 FROM jsonb_array_elements(\n CASE WHEN jsonb_typeof(e.routes) = 'array' THEN e.routes ELSE '[]'::jsonb END) r\n WHERE regexp_replace(coalesce(r->>'phone_e164', ''), '\\D', '', 'g') = v_digits)));\n GET DIAGNOSTICS v_count = ROW_COUNT;\n RETURN v_count;\nEND\n$function$;\n\nREVOKE ALL ON FUNCTION public.conversations_stop_journeys(uuid, text, text, text) FROM PUBLIC, anon;\nGRANT EXECUTE ON FUNCTION public.conversations_stop_journeys(uuid, text, text, text) TO authenticated, service_role;\n\nCOMMENT ON FUNCTION public.conversations_stop_journeys(uuid, text, text, text) IS\n 'Stops every ACTIVE campaign enrollment of a person, or whose routes carry a phone, with a stop_reason and an optional note. Returns how many stopped (029).';\n\n-- \u2500\u2500 the monitor counts the new state \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nDROP VIEW IF EXISTS public.v_conversations_campaign_enrollment_summary;\nCREATE VIEW public.v_conversations_campaign_enrollment_summary\nWITH (security_invoker = true) AS\n SELECT e.campaign_id,\n e.tenant_id,\n count(*) AS enrolled,\n count(*) FILTER (WHERE e.state = 'active') AS active,\n count(*) FILTER (WHERE e.state = 'replied') AS replied,\n count(*) FILTER (WHERE e.state = 'opted_out') AS opted_out,\n count(*) FILTER (WHERE e.state = 'completed') AS completed,\n count(*) FILTER (WHERE e.state = 'no_route') AS no_route,\n count(*) FILTER (WHERE e.state IN ('failed', 'exited', 'stopped')) AS stopped\n FROM public.plg_conversations_campaign_enrollments e\n WHERE e.tenant_id IN (SELECT public.user_tenant_ids())\n GROUP BY e.campaign_id, e.tenant_id;\n\nGRANT SELECT ON public.v_conversations_campaign_enrollment_summary TO authenticated;\n";
|
|
31
|
+
export declare const MIGRATION_030_AN_OPT_OUT_IS_NOT_A_CONVERSATION = "-- 030_an_opt_out_is_not_a_conversation.sql\n--\n-- \u00ABResponderam\u00BB on a campaign mixed two opposite outcomes: a lead who wanted\n-- to talk and a lead who answered SAIR. The facts view now says which:\n-- `is_opted_out` (the reply ended the journey as an opt-out) and\n-- `is_conversation` (a reply that is not an opt-out), so the performance\n-- table shows conversations, opt-outs and the conversation rate apart.\n-- Same body as 026 otherwise. Replay-safe: CREATE OR REPLACE inside a\n-- guard (the CRM's deals table may be absent).\nDO $do$\nBEGIN\n IF to_regclass('public.plg_crm_deals') IS NULL THEN\n RETURN;\n END IF;\n EXECUTE $view$\n CREATE OR REPLACE VIEW public.v_conversations_campaign_facts\n WITH (security_invoker = true) AS\n SELECT t.id,\n t.tenant_id,\n t.campaign_id,\n c.name AS campaign_name,\n coalesce(t.provider, c.provider, 'evolution') AS provider,\n t.channel,\n coalesce(t.step_position, 1) AS step_position,\n s.wait_minutes AS step_wait_minutes,\n s.contact_route AS step_route,\n s.template_id,\n tp.name AS template_name,\n t.variant,\n coalesce((SELECT r->>'via' FROM jsonb_array_elements(e.routes) r\n WHERE r->>'phone_e164' = t.phone_e164 LIMIT 1), 'primary') AS via,\n row_number() OVER (PARTITION BY coalesce(t.enrollment_id, t.id) ORDER BY t.queued_at) AS attempt,\n t.state,\n t.queued_at, t.sent_at, t.delivered_at, t.read_at, t.replied_at,\n (t.state IN ('sent','delivered','read','replied')) AS is_sent,\n (t.delivered_at IS NOT NULL OR t.state IN ('delivered','read','replied')) AS is_delivered,\n (t.read_at IS NOT NULL OR t.state IN ('read','replied')) AS is_read,\n (t.replied_at IS NOT NULL OR t.state = 'replied') AS is_replied,\n (t.state = 'failed') AS is_failed,\n e.deal_id,\n (d.status = 'won' AND t.sent_at IS NOT NULL AND coalesce(d.won_at, d.updated_at) >= t.sent_at) AS is_won,\n -- 030, appended (a view keeps its column order).\n ((t.replied_at IS NOT NULL OR t.state = 'replied') AND e.state = 'opted_out') AS is_opted_out,\n ((t.replied_at IS NOT NULL OR t.state = 'replied') AND e.state IS DISTINCT FROM 'opted_out') AS is_conversation\n FROM public.plg_conversations_campaign_targets t\n JOIN public.plg_conversations_campaigns c ON c.id = t.campaign_id\n LEFT JOIN public.plg_conversations_campaign_steps s ON s.campaign_id = t.campaign_id AND s.position = t.step_position\n LEFT JOIN public.plg_conversations_templates tp ON tp.id = s.template_id\n LEFT JOIN public.plg_conversations_campaign_enrollments e ON e.id = t.enrollment_id\n LEFT JOIN public.plg_crm_deals d ON d.id = e.deal_id\n $view$;\n EXECUTE 'GRANT SELECT ON public.v_conversations_campaign_facts TO authenticated, service_role';\nEND\n$do$;\n";
|
|
31
32
|
export declare const MIGRATIONS: Array<{
|
|
32
33
|
id: string;
|
|
33
34
|
sql: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,sBAAsB,2rhCAkgBlC,CAAA;AAED,eAAO,MAAM,gDAAgD,i0LAuG5D,CAAA;AAED,eAAO,MAAM,oDAAoD,m5bAuOhE,CAAA;AAED,eAAO,MAAM,0DAA0D,81rBAwWtE,CAAA;AAED,eAAO,MAAM,gEAAgE,+lJA2E5E,CAAA;AAED,eAAO,MAAM,yDAAyD,w1RAmKrE,CAAA;AAED,eAAO,MAAM,sCAAsC,mtOA6HlD,CAAA;AAED,eAAO,MAAM,6CAA6C,qmIA6DzD,CAAA;AAED,eAAO,MAAM,yCAAyC,ywGA8CrD,CAAA;AAED,eAAO,MAAM,qDAAqD,40FAiDjE,CAAA;AAED,eAAO,MAAM,6CAA6C,6oJA0FzD,CAAA;AAED,eAAO,MAAM,qDAAqD,itGA8DjE,CAAA;AAED,eAAO,MAAM,4CAA4C,6gIA6DxD,CAAA;AAED,eAAO,MAAM,kCAAkC,qlIAiE9C,CAAA;AAED,eAAO,MAAM,6CAA6C,orBAWzD,CAAA;AAED,eAAO,MAAM,4CAA4C,8wEAsDxD,CAAA;AAED,eAAO,MAAM,iDAAiD,yuDA8B7D,CAAA;AAED,eAAO,MAAM,kCAAkC,wwcA+N9C,CAAA;AAED,eAAO,MAAM,gDAAgD,ivCA+B5D,CAAA;AAED,eAAO,MAAM,4DAA4D,wmDAgCxE,CAAA;AAED,eAAO,MAAM,wCAAwC,2oCAuBpD,CAAA;AAED,eAAO,MAAM,6CAA6C,2nBAWzD,CAAA;AAED,eAAO,MAAM,mCAAmC,2zBAe/C,CAAA;AAED,eAAO,MAAM,wCAAwC,2hGAsDpD,CAAA;AAED,eAAO,MAAM,oDAAoD,mgLAqHhE,CAAA;AAED,eAAO,MAAM,0DAA0D,4tCA6BtE,CAAA;AAED,eAAO,MAAM,+DAA+D,k4LAoH3E,CAAA;AAED,eAAO,MAAM,sDAAsD,w+FAkElE,CAAA;AAED,eAAO,MAAM,4DAA4D,+yKAoGxE,CAAA;AAED,eAAO,MAAM,yCAAyC,o/PAsJrD,CAAA;AAED,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,sBAAsB,2rhCAkgBlC,CAAA;AAED,eAAO,MAAM,gDAAgD,i0LAuG5D,CAAA;AAED,eAAO,MAAM,oDAAoD,m5bAuOhE,CAAA;AAED,eAAO,MAAM,0DAA0D,81rBAwWtE,CAAA;AAED,eAAO,MAAM,gEAAgE,+lJA2E5E,CAAA;AAED,eAAO,MAAM,yDAAyD,w1RAmKrE,CAAA;AAED,eAAO,MAAM,sCAAsC,mtOA6HlD,CAAA;AAED,eAAO,MAAM,6CAA6C,qmIA6DzD,CAAA;AAED,eAAO,MAAM,yCAAyC,ywGA8CrD,CAAA;AAED,eAAO,MAAM,qDAAqD,40FAiDjE,CAAA;AAED,eAAO,MAAM,6CAA6C,6oJA0FzD,CAAA;AAED,eAAO,MAAM,qDAAqD,itGA8DjE,CAAA;AAED,eAAO,MAAM,4CAA4C,6gIA6DxD,CAAA;AAED,eAAO,MAAM,kCAAkC,qlIAiE9C,CAAA;AAED,eAAO,MAAM,6CAA6C,orBAWzD,CAAA;AAED,eAAO,MAAM,4CAA4C,8wEAsDxD,CAAA;AAED,eAAO,MAAM,iDAAiD,yuDA8B7D,CAAA;AAED,eAAO,MAAM,kCAAkC,wwcA+N9C,CAAA;AAED,eAAO,MAAM,gDAAgD,ivCA+B5D,CAAA;AAED,eAAO,MAAM,4DAA4D,wmDAgCxE,CAAA;AAED,eAAO,MAAM,wCAAwC,2oCAuBpD,CAAA;AAED,eAAO,MAAM,6CAA6C,2nBAWzD,CAAA;AAED,eAAO,MAAM,mCAAmC,2zBAe/C,CAAA;AAED,eAAO,MAAM,wCAAwC,2hGAsDpD,CAAA;AAED,eAAO,MAAM,oDAAoD,mgLAqHhE,CAAA;AAED,eAAO,MAAM,0DAA0D,4tCA6BtE,CAAA;AAED,eAAO,MAAM,+DAA+D,k4LAoH3E,CAAA;AAED,eAAO,MAAM,sDAAsD,w+FAkElE,CAAA;AAED,eAAO,MAAM,4DAA4D,+yKAoGxE,CAAA;AAED,eAAO,MAAM,yCAAyC,o/PAsJrD,CAAA;AAED,eAAO,MAAM,8CAA8C,4vGAsD1D,CAAA;AAED,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAgCzD,CAAA"}
|
|
@@ -29,8 +29,9 @@ var MIGRATION_026_A_BLOCKED_TOUCH_FALLS_BACK_TO_THE_EVERYDAY_NUMBER = "";
|
|
|
29
29
|
var MIGRATION_027_A_DELIVERED_TOUCH_MOVES_THE_DEAL_FORWARD = "";
|
|
30
30
|
var MIGRATION_028_THE_SELLER_HEARS_THE_LEAD_AWAY_FROM_THE_SCREEN = "";
|
|
31
31
|
var MIGRATION_029_A_SELLER_CAN_STOP_A_JOURNEY = "";
|
|
32
|
+
var MIGRATION_030_AN_OPT_OUT_IS_NOT_A_CONVERSATION = "";
|
|
32
33
|
var MIGRATIONS = [];
|
|
33
34
|
|
|
34
|
-
export { MIGRATIONS, MIGRATION_000_BASELINE, MIGRATION_001_A_CAIXA_SABE_QUEM_FALOU_POR_ULTIMO, MIGRATION_002_A_CASA_ESCOLHE_POR_ONDE_O_WHATSAPP_SAI, MIGRATION_003_A_CAMPANHA_SAI_NO_RITMO_QUE_O_NUMERO_AGUENTA, MIGRATION_004_A_TELA_SABE_SE_PODE_FALAR_ANTES_DE_DEIXAR_ESCREVER, MIGRATION_005_A_CONVERSA_CONTA_AO_FUNIL_QUE_HOUVE_CONTATO, MIGRATION_006_A_CAIXA_AVISA_QUE_CHEGOU, MIGRATION_007_A_CONVERSA_DIZ_DE_QUEM_E_O_LEAD, MIGRATION_008_DAR_POR_VISTA_E_UMA_DECISAO, MIGRATION_009_A_MENSAGEM_INTEIRA_ATRAVESSA_O_REALTIME, MIGRATION_010_A_CHEGADA_E_ANUNCIADA_POR_CONTA, MIGRATION_011_O_ANUNCIO_E_UMA_CAMPAINHA_NAO_UM_RECADO, MIGRATION_012_A_RICH_MESSAGE_KEEPS_ITS_SHAPE, MIGRATION_013_A_MIDIA_FICA_CONOSCO, MIGRATION_014_CLAIMING_TARGETS_IS_SERVER_ONLY, MIGRATION_015_THE_SERVICE_DOOR_FOR_MESSAGING, MIGRATION_016_A_DELIVERY_RECEIPT_FINDS_ITS_TENANT, MIGRATION_017_A_CAMPAIGN_HAS_STEPS, MIGRATION_018_THE_ENGINE_FINDS_RUNNING_CAMPAIGNS, MIGRATION_019_THE_REPLY_LEAVES_FROM_THE_NUMBER_THEY_WROTE_TO, MIGRATION_020_THE_INBOX_READS_THE_NUMBER, MIGRATION_021_A_TOUCH_CAN_REACH_EVERY_CONTACT, MIGRATION_022_ONE_CONTACT_AT_A_TIME, MIGRATION_023_WHAT_EACH_MESSAGE_ACHIEVED, MIGRATION_024_SUPPORT_AND_SALES_KEEP_THEIR_OWN_INBOX, MIGRATION_025_A_NEW_MESSAGE_BRINGS_AN_ARCHIVED_THREAD_BACK, MIGRATION_026_A_BLOCKED_TOUCH_FALLS_BACK_TO_THE_EVERYDAY_NUMBER, MIGRATION_027_A_DELIVERED_TOUCH_MOVES_THE_DEAL_FORWARD, MIGRATION_028_THE_SELLER_HEARS_THE_LEAD_AWAY_FROM_THE_SCREEN, MIGRATION_029_A_SELLER_CAN_STOP_A_JOURNEY };
|
|
35
|
+
export { MIGRATIONS, MIGRATION_000_BASELINE, MIGRATION_001_A_CAIXA_SABE_QUEM_FALOU_POR_ULTIMO, MIGRATION_002_A_CASA_ESCOLHE_POR_ONDE_O_WHATSAPP_SAI, MIGRATION_003_A_CAMPANHA_SAI_NO_RITMO_QUE_O_NUMERO_AGUENTA, MIGRATION_004_A_TELA_SABE_SE_PODE_FALAR_ANTES_DE_DEIXAR_ESCREVER, MIGRATION_005_A_CONVERSA_CONTA_AO_FUNIL_QUE_HOUVE_CONTATO, MIGRATION_006_A_CAIXA_AVISA_QUE_CHEGOU, MIGRATION_007_A_CONVERSA_DIZ_DE_QUEM_E_O_LEAD, MIGRATION_008_DAR_POR_VISTA_E_UMA_DECISAO, MIGRATION_009_A_MENSAGEM_INTEIRA_ATRAVESSA_O_REALTIME, MIGRATION_010_A_CHEGADA_E_ANUNCIADA_POR_CONTA, MIGRATION_011_O_ANUNCIO_E_UMA_CAMPAINHA_NAO_UM_RECADO, MIGRATION_012_A_RICH_MESSAGE_KEEPS_ITS_SHAPE, MIGRATION_013_A_MIDIA_FICA_CONOSCO, MIGRATION_014_CLAIMING_TARGETS_IS_SERVER_ONLY, MIGRATION_015_THE_SERVICE_DOOR_FOR_MESSAGING, MIGRATION_016_A_DELIVERY_RECEIPT_FINDS_ITS_TENANT, MIGRATION_017_A_CAMPAIGN_HAS_STEPS, MIGRATION_018_THE_ENGINE_FINDS_RUNNING_CAMPAIGNS, MIGRATION_019_THE_REPLY_LEAVES_FROM_THE_NUMBER_THEY_WROTE_TO, MIGRATION_020_THE_INBOX_READS_THE_NUMBER, MIGRATION_021_A_TOUCH_CAN_REACH_EVERY_CONTACT, MIGRATION_022_ONE_CONTACT_AT_A_TIME, MIGRATION_023_WHAT_EACH_MESSAGE_ACHIEVED, MIGRATION_024_SUPPORT_AND_SALES_KEEP_THEIR_OWN_INBOX, MIGRATION_025_A_NEW_MESSAGE_BRINGS_AN_ARCHIVED_THREAD_BACK, MIGRATION_026_A_BLOCKED_TOUCH_FALLS_BACK_TO_THE_EVERYDAY_NUMBER, MIGRATION_027_A_DELIVERED_TOUCH_MOVES_THE_DEAL_FORWARD, MIGRATION_028_THE_SELLER_HEARS_THE_LEAD_AWAY_FROM_THE_SCREEN, MIGRATION_029_A_SELLER_CAN_STOP_A_JOURNEY, MIGRATION_030_AN_OPT_OUT_IS_NOT_A_CONVERSATION };
|
|
35
36
|
//# sourceMappingURL=main.browser.js.map
|
|
36
37
|
//# sourceMappingURL=main.browser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../node_modules/.cache/fayz-migration-stubs/main.ts"],"names":[],"mappings":";AAEO,IAAM,sBAAA,GAAyB;AAC/B,IAAM,gDAAA,GAAmD;AACzD,IAAM,oDAAA,GAAuD;AAC7D,IAAM,0DAAA,GAA6D;AACnE,IAAM,gEAAA,GAAmE;AACzE,IAAM,yDAAA,GAA4D;AAClE,IAAM,sCAAA,GAAyC;AAC/C,IAAM,6CAAA,GAAgD;AACtD,IAAM,yCAAA,GAA4C;AAClD,IAAM,qDAAA,GAAwD;AAC9D,IAAM,6CAAA,GAAgD;AACtD,IAAM,qDAAA,GAAwD;AAC9D,IAAM,4CAAA,GAA+C;AACrD,IAAM,kCAAA,GAAqC;AAC3C,IAAM,6CAAA,GAAgD;AACtD,IAAM,4CAAA,GAA+C;AACrD,IAAM,iDAAA,GAAoD;AAC1D,IAAM,kCAAA,GAAqC;AAC3C,IAAM,gDAAA,GAAmD;AACzD,IAAM,4DAAA,GAA+D;AACrE,IAAM,wCAAA,GAA2C;AACjD,IAAM,6CAAA,GAAgD;AACtD,IAAM,mCAAA,GAAsC;AAC5C,IAAM,wCAAA,GAA2C;AACjD,IAAM,oDAAA,GAAuD;AAC7D,IAAM,0DAAA,GAA6D;AACnE,IAAM,+DAAA,GAAkE;AACxE,IAAM,sDAAA,GAAyD;AAC/D,IAAM,4DAAA,GAA+D;AACrE,IAAM,yCAAA,GAA4C;AAClD,IAAM,aAAiD","file":"main.browser.js","sourcesContent":["// GENERATED by scripts/tsup-migrations.mjs — the browser build of a\n// migrations barrel: the same names, no SQL. See that script for why.\nexport const MIGRATION_000_BASELINE = ''\nexport const MIGRATION_001_A_CAIXA_SABE_QUEM_FALOU_POR_ULTIMO = ''\nexport const MIGRATION_002_A_CASA_ESCOLHE_POR_ONDE_O_WHATSAPP_SAI = ''\nexport const MIGRATION_003_A_CAMPANHA_SAI_NO_RITMO_QUE_O_NUMERO_AGUENTA = ''\nexport const MIGRATION_004_A_TELA_SABE_SE_PODE_FALAR_ANTES_DE_DEIXAR_ESCREVER = ''\nexport const MIGRATION_005_A_CONVERSA_CONTA_AO_FUNIL_QUE_HOUVE_CONTATO = ''\nexport const MIGRATION_006_A_CAIXA_AVISA_QUE_CHEGOU = ''\nexport const MIGRATION_007_A_CONVERSA_DIZ_DE_QUEM_E_O_LEAD = ''\nexport const MIGRATION_008_DAR_POR_VISTA_E_UMA_DECISAO = ''\nexport const MIGRATION_009_A_MENSAGEM_INTEIRA_ATRAVESSA_O_REALTIME = ''\nexport const MIGRATION_010_A_CHEGADA_E_ANUNCIADA_POR_CONTA = ''\nexport const MIGRATION_011_O_ANUNCIO_E_UMA_CAMPAINHA_NAO_UM_RECADO = ''\nexport const MIGRATION_012_A_RICH_MESSAGE_KEEPS_ITS_SHAPE = ''\nexport const MIGRATION_013_A_MIDIA_FICA_CONOSCO = ''\nexport const MIGRATION_014_CLAIMING_TARGETS_IS_SERVER_ONLY = ''\nexport const MIGRATION_015_THE_SERVICE_DOOR_FOR_MESSAGING = ''\nexport const MIGRATION_016_A_DELIVERY_RECEIPT_FINDS_ITS_TENANT = ''\nexport const MIGRATION_017_A_CAMPAIGN_HAS_STEPS = ''\nexport const MIGRATION_018_THE_ENGINE_FINDS_RUNNING_CAMPAIGNS = ''\nexport const MIGRATION_019_THE_REPLY_LEAVES_FROM_THE_NUMBER_THEY_WROTE_TO = ''\nexport const MIGRATION_020_THE_INBOX_READS_THE_NUMBER = ''\nexport const MIGRATION_021_A_TOUCH_CAN_REACH_EVERY_CONTACT = ''\nexport const MIGRATION_022_ONE_CONTACT_AT_A_TIME = ''\nexport const MIGRATION_023_WHAT_EACH_MESSAGE_ACHIEVED = ''\nexport const MIGRATION_024_SUPPORT_AND_SALES_KEEP_THEIR_OWN_INBOX = ''\nexport const MIGRATION_025_A_NEW_MESSAGE_BRINGS_AN_ARCHIVED_THREAD_BACK = ''\nexport const MIGRATION_026_A_BLOCKED_TOUCH_FALLS_BACK_TO_THE_EVERYDAY_NUMBER = ''\nexport const MIGRATION_027_A_DELIVERED_TOUCH_MOVES_THE_DEAL_FORWARD = ''\nexport const MIGRATION_028_THE_SELLER_HEARS_THE_LEAD_AWAY_FROM_THE_SCREEN = ''\nexport const MIGRATION_029_A_SELLER_CAN_STOP_A_JOURNEY = ''\nexport const MIGRATIONS: Array<{ id: string; sql: string }> = []\n"]}
|
|
1
|
+
{"version":3,"sources":["../../node_modules/.cache/fayz-migration-stubs/main.ts"],"names":[],"mappings":";AAEO,IAAM,sBAAA,GAAyB;AAC/B,IAAM,gDAAA,GAAmD;AACzD,IAAM,oDAAA,GAAuD;AAC7D,IAAM,0DAAA,GAA6D;AACnE,IAAM,gEAAA,GAAmE;AACzE,IAAM,yDAAA,GAA4D;AAClE,IAAM,sCAAA,GAAyC;AAC/C,IAAM,6CAAA,GAAgD;AACtD,IAAM,yCAAA,GAA4C;AAClD,IAAM,qDAAA,GAAwD;AAC9D,IAAM,6CAAA,GAAgD;AACtD,IAAM,qDAAA,GAAwD;AAC9D,IAAM,4CAAA,GAA+C;AACrD,IAAM,kCAAA,GAAqC;AAC3C,IAAM,6CAAA,GAAgD;AACtD,IAAM,4CAAA,GAA+C;AACrD,IAAM,iDAAA,GAAoD;AAC1D,IAAM,kCAAA,GAAqC;AAC3C,IAAM,gDAAA,GAAmD;AACzD,IAAM,4DAAA,GAA+D;AACrE,IAAM,wCAAA,GAA2C;AACjD,IAAM,6CAAA,GAAgD;AACtD,IAAM,mCAAA,GAAsC;AAC5C,IAAM,wCAAA,GAA2C;AACjD,IAAM,oDAAA,GAAuD;AAC7D,IAAM,0DAAA,GAA6D;AACnE,IAAM,+DAAA,GAAkE;AACxE,IAAM,sDAAA,GAAyD;AAC/D,IAAM,4DAAA,GAA+D;AACrE,IAAM,yCAAA,GAA4C;AAClD,IAAM,8CAAA,GAAiD;AACvD,IAAM,aAAiD","file":"main.browser.js","sourcesContent":["// GENERATED by scripts/tsup-migrations.mjs — the browser build of a\n// migrations barrel: the same names, no SQL. See that script for why.\nexport const MIGRATION_000_BASELINE = ''\nexport const MIGRATION_001_A_CAIXA_SABE_QUEM_FALOU_POR_ULTIMO = ''\nexport const MIGRATION_002_A_CASA_ESCOLHE_POR_ONDE_O_WHATSAPP_SAI = ''\nexport const MIGRATION_003_A_CAMPANHA_SAI_NO_RITMO_QUE_O_NUMERO_AGUENTA = ''\nexport const MIGRATION_004_A_TELA_SABE_SE_PODE_FALAR_ANTES_DE_DEIXAR_ESCREVER = ''\nexport const MIGRATION_005_A_CONVERSA_CONTA_AO_FUNIL_QUE_HOUVE_CONTATO = ''\nexport const MIGRATION_006_A_CAIXA_AVISA_QUE_CHEGOU = ''\nexport const MIGRATION_007_A_CONVERSA_DIZ_DE_QUEM_E_O_LEAD = ''\nexport const MIGRATION_008_DAR_POR_VISTA_E_UMA_DECISAO = ''\nexport const MIGRATION_009_A_MENSAGEM_INTEIRA_ATRAVESSA_O_REALTIME = ''\nexport const MIGRATION_010_A_CHEGADA_E_ANUNCIADA_POR_CONTA = ''\nexport const MIGRATION_011_O_ANUNCIO_E_UMA_CAMPAINHA_NAO_UM_RECADO = ''\nexport const MIGRATION_012_A_RICH_MESSAGE_KEEPS_ITS_SHAPE = ''\nexport const MIGRATION_013_A_MIDIA_FICA_CONOSCO = ''\nexport const MIGRATION_014_CLAIMING_TARGETS_IS_SERVER_ONLY = ''\nexport const MIGRATION_015_THE_SERVICE_DOOR_FOR_MESSAGING = ''\nexport const MIGRATION_016_A_DELIVERY_RECEIPT_FINDS_ITS_TENANT = ''\nexport const MIGRATION_017_A_CAMPAIGN_HAS_STEPS = ''\nexport const MIGRATION_018_THE_ENGINE_FINDS_RUNNING_CAMPAIGNS = ''\nexport const MIGRATION_019_THE_REPLY_LEAVES_FROM_THE_NUMBER_THEY_WROTE_TO = ''\nexport const MIGRATION_020_THE_INBOX_READS_THE_NUMBER = ''\nexport const MIGRATION_021_A_TOUCH_CAN_REACH_EVERY_CONTACT = ''\nexport const MIGRATION_022_ONE_CONTACT_AT_A_TIME = ''\nexport const MIGRATION_023_WHAT_EACH_MESSAGE_ACHIEVED = ''\nexport const MIGRATION_024_SUPPORT_AND_SALES_KEEP_THEIR_OWN_INBOX = ''\nexport const MIGRATION_025_A_NEW_MESSAGE_BRINGS_AN_ARCHIVED_THREAD_BACK = ''\nexport const MIGRATION_026_A_BLOCKED_TOUCH_FALLS_BACK_TO_THE_EVERYDAY_NUMBER = ''\nexport const MIGRATION_027_A_DELIVERED_TOUCH_MOVES_THE_DEAL_FORWARD = ''\nexport const MIGRATION_028_THE_SELLER_HEARS_THE_LEAD_AWAY_FROM_THE_SCREEN = ''\nexport const MIGRATION_029_A_SELLER_CAN_STOP_A_JOURNEY = ''\nexport const MIGRATION_030_AN_OPT_OUT_IS_NOT_A_CONVERSATION = ''\nexport const MIGRATIONS: Array<{ id: string; sql: string }> = []\n"]}
|
package/dist/migrations/main.js
CHANGED
|
@@ -3096,6 +3096,61 @@ WITH (security_invoker = true) AS
|
|
|
3096
3096
|
|
|
3097
3097
|
GRANT SELECT ON public.v_conversations_campaign_enrollment_summary TO authenticated;
|
|
3098
3098
|
`;
|
|
3099
|
+
var MIGRATION_030_AN_OPT_OUT_IS_NOT_A_CONVERSATION = `-- 030_an_opt_out_is_not_a_conversation.sql
|
|
3100
|
+
--
|
|
3101
|
+
-- \xABResponderam\xBB on a campaign mixed two opposite outcomes: a lead who wanted
|
|
3102
|
+
-- to talk and a lead who answered SAIR. The facts view now says which:
|
|
3103
|
+
-- \`is_opted_out\` (the reply ended the journey as an opt-out) and
|
|
3104
|
+
-- \`is_conversation\` (a reply that is not an opt-out), so the performance
|
|
3105
|
+
-- table shows conversations, opt-outs and the conversation rate apart.
|
|
3106
|
+
-- Same body as 026 otherwise. Replay-safe: CREATE OR REPLACE inside a
|
|
3107
|
+
-- guard (the CRM's deals table may be absent).
|
|
3108
|
+
DO $do$
|
|
3109
|
+
BEGIN
|
|
3110
|
+
IF to_regclass('public.plg_crm_deals') IS NULL THEN
|
|
3111
|
+
RETURN;
|
|
3112
|
+
END IF;
|
|
3113
|
+
EXECUTE $view$
|
|
3114
|
+
CREATE OR REPLACE VIEW public.v_conversations_campaign_facts
|
|
3115
|
+
WITH (security_invoker = true) AS
|
|
3116
|
+
SELECT t.id,
|
|
3117
|
+
t.tenant_id,
|
|
3118
|
+
t.campaign_id,
|
|
3119
|
+
c.name AS campaign_name,
|
|
3120
|
+
coalesce(t.provider, c.provider, 'evolution') AS provider,
|
|
3121
|
+
t.channel,
|
|
3122
|
+
coalesce(t.step_position, 1) AS step_position,
|
|
3123
|
+
s.wait_minutes AS step_wait_minutes,
|
|
3124
|
+
s.contact_route AS step_route,
|
|
3125
|
+
s.template_id,
|
|
3126
|
+
tp.name AS template_name,
|
|
3127
|
+
t.variant,
|
|
3128
|
+
coalesce((SELECT r->>'via' FROM jsonb_array_elements(e.routes) r
|
|
3129
|
+
WHERE r->>'phone_e164' = t.phone_e164 LIMIT 1), 'primary') AS via,
|
|
3130
|
+
row_number() OVER (PARTITION BY coalesce(t.enrollment_id, t.id) ORDER BY t.queued_at) AS attempt,
|
|
3131
|
+
t.state,
|
|
3132
|
+
t.queued_at, t.sent_at, t.delivered_at, t.read_at, t.replied_at,
|
|
3133
|
+
(t.state IN ('sent','delivered','read','replied')) AS is_sent,
|
|
3134
|
+
(t.delivered_at IS NOT NULL OR t.state IN ('delivered','read','replied')) AS is_delivered,
|
|
3135
|
+
(t.read_at IS NOT NULL OR t.state IN ('read','replied')) AS is_read,
|
|
3136
|
+
(t.replied_at IS NOT NULL OR t.state = 'replied') AS is_replied,
|
|
3137
|
+
(t.state = 'failed') AS is_failed,
|
|
3138
|
+
e.deal_id,
|
|
3139
|
+
(d.status = 'won' AND t.sent_at IS NOT NULL AND coalesce(d.won_at, d.updated_at) >= t.sent_at) AS is_won,
|
|
3140
|
+
-- 030, appended (a view keeps its column order).
|
|
3141
|
+
((t.replied_at IS NOT NULL OR t.state = 'replied') AND e.state = 'opted_out') AS is_opted_out,
|
|
3142
|
+
((t.replied_at IS NOT NULL OR t.state = 'replied') AND e.state IS DISTINCT FROM 'opted_out') AS is_conversation
|
|
3143
|
+
FROM public.plg_conversations_campaign_targets t
|
|
3144
|
+
JOIN public.plg_conversations_campaigns c ON c.id = t.campaign_id
|
|
3145
|
+
LEFT JOIN public.plg_conversations_campaign_steps s ON s.campaign_id = t.campaign_id AND s.position = t.step_position
|
|
3146
|
+
LEFT JOIN public.plg_conversations_templates tp ON tp.id = s.template_id
|
|
3147
|
+
LEFT JOIN public.plg_conversations_campaign_enrollments e ON e.id = t.enrollment_id
|
|
3148
|
+
LEFT JOIN public.plg_crm_deals d ON d.id = e.deal_id
|
|
3149
|
+
$view$;
|
|
3150
|
+
EXECUTE 'GRANT SELECT ON public.v_conversations_campaign_facts TO authenticated, service_role';
|
|
3151
|
+
END
|
|
3152
|
+
$do$;
|
|
3153
|
+
`;
|
|
3099
3154
|
var MIGRATIONS = [
|
|
3100
3155
|
{ id: "000_baseline", sql: MIGRATION_000_BASELINE },
|
|
3101
3156
|
{ id: "001_a_caixa_sabe_quem_falou_por_ultimo", sql: MIGRATION_001_A_CAIXA_SABE_QUEM_FALOU_POR_ULTIMO },
|
|
@@ -3126,9 +3181,10 @@ var MIGRATIONS = [
|
|
|
3126
3181
|
{ id: "026_a_blocked_touch_falls_back_to_the_everyday_number", sql: MIGRATION_026_A_BLOCKED_TOUCH_FALLS_BACK_TO_THE_EVERYDAY_NUMBER },
|
|
3127
3182
|
{ id: "027_a_delivered_touch_moves_the_deal_forward", sql: MIGRATION_027_A_DELIVERED_TOUCH_MOVES_THE_DEAL_FORWARD },
|
|
3128
3183
|
{ id: "028_the_seller_hears_the_lead_away_from_the_screen", sql: MIGRATION_028_THE_SELLER_HEARS_THE_LEAD_AWAY_FROM_THE_SCREEN },
|
|
3129
|
-
{ id: "029_a_seller_can_stop_a_journey", sql: MIGRATION_029_A_SELLER_CAN_STOP_A_JOURNEY }
|
|
3184
|
+
{ id: "029_a_seller_can_stop_a_journey", sql: MIGRATION_029_A_SELLER_CAN_STOP_A_JOURNEY },
|
|
3185
|
+
{ id: "030_an_opt_out_is_not_a_conversation", sql: MIGRATION_030_AN_OPT_OUT_IS_NOT_A_CONVERSATION }
|
|
3130
3186
|
];
|
|
3131
3187
|
|
|
3132
|
-
export { MIGRATIONS, MIGRATION_000_BASELINE, MIGRATION_001_A_CAIXA_SABE_QUEM_FALOU_POR_ULTIMO, MIGRATION_002_A_CASA_ESCOLHE_POR_ONDE_O_WHATSAPP_SAI, MIGRATION_003_A_CAMPANHA_SAI_NO_RITMO_QUE_O_NUMERO_AGUENTA, MIGRATION_004_A_TELA_SABE_SE_PODE_FALAR_ANTES_DE_DEIXAR_ESCREVER, MIGRATION_005_A_CONVERSA_CONTA_AO_FUNIL_QUE_HOUVE_CONTATO, MIGRATION_006_A_CAIXA_AVISA_QUE_CHEGOU, MIGRATION_007_A_CONVERSA_DIZ_DE_QUEM_E_O_LEAD, MIGRATION_008_DAR_POR_VISTA_E_UMA_DECISAO, MIGRATION_009_A_MENSAGEM_INTEIRA_ATRAVESSA_O_REALTIME, MIGRATION_010_A_CHEGADA_E_ANUNCIADA_POR_CONTA, MIGRATION_011_O_ANUNCIO_E_UMA_CAMPAINHA_NAO_UM_RECADO, MIGRATION_012_A_RICH_MESSAGE_KEEPS_ITS_SHAPE, MIGRATION_013_A_MIDIA_FICA_CONOSCO, MIGRATION_014_CLAIMING_TARGETS_IS_SERVER_ONLY, MIGRATION_015_THE_SERVICE_DOOR_FOR_MESSAGING, MIGRATION_016_A_DELIVERY_RECEIPT_FINDS_ITS_TENANT, MIGRATION_017_A_CAMPAIGN_HAS_STEPS, MIGRATION_018_THE_ENGINE_FINDS_RUNNING_CAMPAIGNS, MIGRATION_019_THE_REPLY_LEAVES_FROM_THE_NUMBER_THEY_WROTE_TO, MIGRATION_020_THE_INBOX_READS_THE_NUMBER, MIGRATION_021_A_TOUCH_CAN_REACH_EVERY_CONTACT, MIGRATION_022_ONE_CONTACT_AT_A_TIME, MIGRATION_023_WHAT_EACH_MESSAGE_ACHIEVED, MIGRATION_024_SUPPORT_AND_SALES_KEEP_THEIR_OWN_INBOX, MIGRATION_025_A_NEW_MESSAGE_BRINGS_AN_ARCHIVED_THREAD_BACK, MIGRATION_026_A_BLOCKED_TOUCH_FALLS_BACK_TO_THE_EVERYDAY_NUMBER, MIGRATION_027_A_DELIVERED_TOUCH_MOVES_THE_DEAL_FORWARD, MIGRATION_028_THE_SELLER_HEARS_THE_LEAD_AWAY_FROM_THE_SCREEN, MIGRATION_029_A_SELLER_CAN_STOP_A_JOURNEY };
|
|
3188
|
+
export { MIGRATIONS, MIGRATION_000_BASELINE, MIGRATION_001_A_CAIXA_SABE_QUEM_FALOU_POR_ULTIMO, MIGRATION_002_A_CASA_ESCOLHE_POR_ONDE_O_WHATSAPP_SAI, MIGRATION_003_A_CAMPANHA_SAI_NO_RITMO_QUE_O_NUMERO_AGUENTA, MIGRATION_004_A_TELA_SABE_SE_PODE_FALAR_ANTES_DE_DEIXAR_ESCREVER, MIGRATION_005_A_CONVERSA_CONTA_AO_FUNIL_QUE_HOUVE_CONTATO, MIGRATION_006_A_CAIXA_AVISA_QUE_CHEGOU, MIGRATION_007_A_CONVERSA_DIZ_DE_QUEM_E_O_LEAD, MIGRATION_008_DAR_POR_VISTA_E_UMA_DECISAO, MIGRATION_009_A_MENSAGEM_INTEIRA_ATRAVESSA_O_REALTIME, MIGRATION_010_A_CHEGADA_E_ANUNCIADA_POR_CONTA, MIGRATION_011_O_ANUNCIO_E_UMA_CAMPAINHA_NAO_UM_RECADO, MIGRATION_012_A_RICH_MESSAGE_KEEPS_ITS_SHAPE, MIGRATION_013_A_MIDIA_FICA_CONOSCO, MIGRATION_014_CLAIMING_TARGETS_IS_SERVER_ONLY, MIGRATION_015_THE_SERVICE_DOOR_FOR_MESSAGING, MIGRATION_016_A_DELIVERY_RECEIPT_FINDS_ITS_TENANT, MIGRATION_017_A_CAMPAIGN_HAS_STEPS, MIGRATION_018_THE_ENGINE_FINDS_RUNNING_CAMPAIGNS, MIGRATION_019_THE_REPLY_LEAVES_FROM_THE_NUMBER_THEY_WROTE_TO, MIGRATION_020_THE_INBOX_READS_THE_NUMBER, MIGRATION_021_A_TOUCH_CAN_REACH_EVERY_CONTACT, MIGRATION_022_ONE_CONTACT_AT_A_TIME, MIGRATION_023_WHAT_EACH_MESSAGE_ACHIEVED, MIGRATION_024_SUPPORT_AND_SALES_KEEP_THEIR_OWN_INBOX, MIGRATION_025_A_NEW_MESSAGE_BRINGS_AN_ARCHIVED_THREAD_BACK, MIGRATION_026_A_BLOCKED_TOUCH_FALLS_BACK_TO_THE_EVERYDAY_NUMBER, MIGRATION_027_A_DELIVERED_TOUCH_MOVES_THE_DEAL_FORWARD, MIGRATION_028_THE_SELLER_HEARS_THE_LEAD_AWAY_FROM_THE_SCREEN, MIGRATION_029_A_SELLER_CAN_STOP_A_JOURNEY, MIGRATION_030_AN_OPT_OUT_IS_NOT_A_CONVERSATION };
|
|
3133
3189
|
//# sourceMappingURL=main.js.map
|
|
3134
3190
|
//# sourceMappingURL=main.js.map
|