@fayz-ai/plugin-crm 0.37.0 → 0.38.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.
@@ -1 +1 @@
1
- {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../src/locales/en.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA0iCrC,CAAA"}
1
+ {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../src/locales/en.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA+iCrC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"pt-BR.d.ts","sourceRoot":"","sources":["../../src/locales/pt-BR.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA0iCvC,CAAA"}
1
+ {"version":3,"file":"pt-BR.d.ts","sourceRoot":"","sources":["../../src/locales/pt-BR.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA+iCvC,CAAA"}
@@ -64,6 +64,7 @@ export declare const MIGRATION_063_THE_ROTA_ENGINE_IS_SERVER_ONLY = "-- 063_the_
64
64
  export declare const MIGRATION_064_SEGMENTS_REACH_THE_DEAL = "-- 064_segments_reach_the_deal.sql\n--\n-- Segments could only ask about the PERSON (people / v_crm_people_engagement).\n-- The question sales asks is about the DEAL: \"open deals in Novo (feira) or\n-- Contato feito, in the ChefControl unit, tagged ICP \u00B7 Dentro\". The stage, the\n-- unit, the owner and the deal's own tags are facts of the deal, and a person\n-- can have several deals, so they cannot become person columns.\n--\n-- Three changes, all on the existing engine (crm_resolve_segment):\n--\n-- 1. `v_crm_deal_audience`: one row per deal with the columns a rule can name.\n-- It has `person_id`, so a deal segment still resolves to people for every\n-- existing caller (counts, campaigns by person), and a new resolver returns\n-- the deals themselves for campaigns that rotate through a deal's contacts.\n--\n-- 2. Match groups, as in V1 (Silvio's builder): `where` = every clause must\n-- match (AND, the only group so far), `any` = at least one must match (OR),\n-- `none` = none may match (exclusion). Missing groups mean \"no condition\",\n-- so every saved segment keeps its meaning.\n--\n-- 3. The clause builder moves to its own function so both resolvers build the\n-- same SQL. It keeps the closed operator set: an unknown operator raises,\n-- because ignoring it would widen the audience without telling anyone.\n\n-- \u2500\u2500 1. the deal as a segment source \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\nCREATE OR REPLACE VIEW public.v_crm_deal_audience\nWITH (security_invoker = true) AS\nSELECT\n d.id,\n d.tenant_id,\n d.unit_id,\n d.contact_id AS person_id,\n d.company_id,\n gm.group_id,\n d.pipeline_id,\n d.stage_id,\n st.name AS stage_name,\n d.status AS deal_status,\n coalesce(d.tags, '{}'::text[]) AS tags,\n d.assigned_to_id AS owner_id,\n d.value,\n d.created_at,\n d.updated_at\nFROM public.plg_crm_deals d\nLEFT JOIN public.plg_crm_pipeline_stages st ON st.id = d.stage_id\nLEFT JOIN LATERAL (\n SELECT m.group_id FROM public.plg_crm_company_group_members m\n WHERE m.company_id = d.company_id\n ORDER BY m.created_at\n LIMIT 1\n) gm ON true;\n\nGRANT SELECT ON public.v_crm_deal_audience TO authenticated, service_role;\n\n-- \u2500\u2500 2. one clause, one place \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\nCREATE OR REPLACE FUNCTION public.crm_segment_clause(p_view text, p_clause jsonb)\nRETURNS text\nLANGUAGE plpgsql\nSTABLE\nSET search_path TO ''\nAS $function$\nDECLARE\n v_col text := p_clause ->> 'column';\n v_op text := coalesce(p_clause ->> 'op', '=');\n v_sql text;\nBEGIN\n IF NOT EXISTS (SELECT 1 FROM information_schema.columns\n WHERE table_schema = 'public' AND table_name = p_view AND column_name = v_col) THEN\n RAISE EXCEPTION 'crm_segment_clause: public.% n\u00E3o tem a coluna %', p_view, v_col USING ERRCODE = '42703';\n END IF;\n\n v_sql := CASE\n WHEN v_op IN ('=', '<>', '>', '<', '>=', '<=') THEN\n format('%I %s %L', v_col,\n CASE v_op WHEN '<>' THEN '<>' WHEN '>' THEN '>' WHEN '<' THEN '<'\n WHEN '>=' THEN '>=' WHEN '<=' THEN '<=' ELSE '=' END,\n p_clause ->> 'value')\n WHEN v_op = 'ilike' THEN\n format('%I ILIKE %L', v_col, '%' || coalesce(p_clause ->> 'value', '') || '%')\n WHEN v_op IN ('in', 'not_in') THEN (\n SELECT format('%I %s (%s)', v_col,\n CASE WHEN v_op = 'not_in' THEN 'NOT IN' ELSE 'IN' END,\n coalesce(string_agg(quote_literal(e), ','), 'NULL'))\n FROM jsonb_array_elements_text(coalesce(p_clause -> 'value', '[]'::jsonb)) AS e)\n WHEN v_op = 'is_null' THEN format('%I IS NULL', v_col)\n WHEN v_op = 'not_null' THEN format('%I IS NOT NULL', v_col)\n WHEN v_op = 'has_tag' THEN\n format('%L = ANY(%I)', p_clause ->> 'value', v_col)\n -- Any of the listed tags (V1's \"\u00E9 um de\" over tags).\n WHEN v_op = 'has_any_tag' THEN (\n SELECT format('%I && ARRAY[%s]::text[]', v_col, coalesce(string_agg(quote_literal(e), ','), 'NULL'))\n FROM jsonb_array_elements_text(coalesce(p_clause -> 'value', '[]'::jsonb)) AS e)\n WHEN v_op IN ('within_days', 'older_than_days') THEN\n format('%I %s now() - make_interval(days => %s)', v_col,\n CASE WHEN v_op = 'within_days' THEN '>=' ELSE '<' END,\n (coalesce(p_clause ->> 'value', '0'))::integer)\n WHEN v_op = 'birthday_within_days' THEN\n format('%I IS NOT NULL AND ((EXTRACT(doy FROM %I::date)::int - EXTRACT(doy FROM now())::int + 366) %% 366) <= %s',\n v_col, v_col, (coalesce(p_clause ->> 'value', '0'))::integer)\n ELSE NULL\n END;\n\n IF v_sql IS NULL THEN\n RAISE EXCEPTION 'crm_segment_clause: operador % n\u00E3o \u00E9 reconhecido', v_op USING ERRCODE = '22023';\n END IF;\n RETURN '(' || v_sql || ')';\nEND $function$;\n\nREVOKE ALL ON FUNCTION public.crm_segment_clause(text, jsonb) FROM PUBLIC, anon, authenticated;\nGRANT EXECUTE ON FUNCTION public.crm_segment_clause(text, jsonb) TO service_role;\n\n-- The WHERE of a rule over a view: tenant, unit, then all / any / none.\nCREATE OR REPLACE FUNCTION public.crm_segment_where_for(p_view text, p_rules jsonb, p_unit uuid, p_tenant uuid)\nRETURNS text\nLANGUAGE plpgsql\nSTABLE\nSET search_path TO ''\nAS $function$\nDECLARE\n v_kind char;\n v_where text;\n v_part text;\nBEGIN\n IF p_view !~ '^[a-z_][a-z0-9_]*$' THEN\n RAISE EXCEPTION 'crm_segment_where: % n\u00E3o \u00E9 um nome de rela\u00E7\u00E3o simples', p_view USING ERRCODE = '22023';\n END IF;\n SELECT cl.relkind INTO v_kind FROM pg_catalog.pg_class cl\n JOIN pg_catalog.pg_namespace n ON n.oid = cl.relnamespace\n WHERE n.nspname = 'public' AND cl.relname = p_view;\n IF v_kind IS NULL THEN\n RAISE EXCEPTION 'crm_segment_where: public.% n\u00E3o existe', p_view USING ERRCODE = '42P01';\n END IF;\n\n v_where := format('tenant_id = %L', p_tenant);\n IF p_unit IS NOT NULL AND EXISTS (\n SELECT 1 FROM information_schema.columns\n WHERE table_schema = 'public' AND table_name = p_view AND column_name = 'unit_id'\n ) THEN\n v_where := v_where || format(' AND unit_id = %L', p_unit);\n END IF;\n\n SELECT string_agg(public.crm_segment_clause(p_view, c), ' AND ')\n INTO v_part FROM jsonb_array_elements(coalesce(p_rules -> 'where', '[]'::jsonb)) c;\n IF v_part IS NOT NULL THEN v_where := v_where || ' AND ' || v_part; END IF;\n\n SELECT string_agg(public.crm_segment_clause(p_view, c), ' OR ')\n INTO v_part FROM jsonb_array_elements(coalesce(p_rules -> 'any', '[]'::jsonb)) c;\n IF v_part IS NOT NULL THEN v_where := v_where || ' AND (' || v_part || ')'; END IF;\n\n SELECT string_agg(public.crm_segment_clause(p_view, c), ' OR ')\n INTO v_part FROM jsonb_array_elements(coalesce(p_rules -> 'none', '[]'::jsonb)) c;\n IF v_part IS NOT NULL THEN v_where := v_where || ' AND NOT coalesce(' || v_part || ', false)'; END IF;\n\n RETURN v_where;\nEND $function$;\n\nREVOKE ALL ON FUNCTION public.crm_segment_where_for(text, jsonb, uuid, uuid) FROM PUBLIC, anon, authenticated;\nGRANT EXECUTE ON FUNCTION public.crm_segment_where_for(text, jsonb, uuid, uuid) TO service_role;\n\n-- The WHERE of a saved segment.\nCREATE OR REPLACE FUNCTION public.crm_segment_where(p_segment_id uuid, p_tenant uuid)\nRETURNS text\nLANGUAGE plpgsql\nSTABLE\nSET search_path TO ''\nAS $function$\nDECLARE\n v_seg record;\nBEGIN\n SELECT * INTO v_seg FROM public.plg_crm_segments s WHERE s.id = p_segment_id AND s.tenant_id = p_tenant;\n IF v_seg.id IS NULL THEN\n RAISE EXCEPTION 'crm_segment_where: segmento n\u00E3o encontrado' USING ERRCODE = 'P0002';\n END IF;\n RETURN public.crm_segment_where_for(v_seg.source_view, v_seg.rules, v_seg.unit_id, p_tenant);\nEND $function$;\n\nREVOKE ALL ON FUNCTION public.crm_segment_where(uuid, uuid) FROM PUBLIC, anon, authenticated;\nGRANT EXECUTE ON FUNCTION public.crm_segment_where(uuid, uuid) TO service_role;\n\n-- How many a DRAFT rule reaches, before anyone saves it: the editor counts as\n-- the rule is written. People for a people view; deals AND their people for\n-- the deal audience.\nCREATE OR REPLACE FUNCTION public.crm_segment_preview(p_source_view text, p_rules jsonb, p_unit uuid DEFAULT NULL)\nRETURNS TABLE(rows_count bigint, people_count bigint)\nLANGUAGE plpgsql\nSTABLE SECURITY DEFINER\nSET search_path TO ''\nAS $function$\nDECLARE\n v_tenant uuid := app.current_tenant_id();\n v_where text;\n v_person text;\nBEGIN\n IF v_tenant IS NULL THEN\n RAISE EXCEPTION 'crm_segment_preview: sem tenant na sess\u00E3o' USING ERRCODE = '42501';\n END IF;\n IF NOT app.has_permission('sales.read', NULL::uuid) THEN\n RAISE EXCEPTION 'crm_segment_preview: exige sales.read' USING ERRCODE = '42501';\n END IF;\n IF p_source_view NOT IN ('people', 'v_crm_people_engagement', 'v_crm_deal_audience') THEN\n RAISE EXCEPTION 'crm_segment_preview: leitura % n\u00E3o \u00E9 um p\u00FAblico', p_source_view USING ERRCODE = '22023';\n END IF;\n v_where := public.crm_segment_where_for(p_source_view, p_rules, p_unit, v_tenant);\n v_person := CASE WHEN p_source_view = 'v_crm_deal_audience' THEN 'person_id' ELSE 'id' END;\n RETURN QUERY EXECUTE format('SELECT count(*)::bigint, count(DISTINCT %I)::bigint FROM public.%I WHERE %s',\n v_person, p_source_view, v_where);\nEND $function$;\n\nREVOKE ALL ON FUNCTION public.crm_segment_preview(text, jsonb, uuid) FROM PUBLIC, anon;\nGRANT EXECUTE ON FUNCTION public.crm_segment_preview(text, jsonb, uuid) TO authenticated, service_role;\n\n-- \u2500\u2500 3. the resolvers \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-- People, as before. A source with `person_id` (the deal audience) answers its\n-- people, once each.\nCREATE OR REPLACE FUNCTION public.crm_resolve_segment(p_segment_id uuid)\nRETURNS TABLE(person_id uuid)\nLANGUAGE plpgsql\nSTABLE SECURITY DEFINER\nSET search_path TO ''\nAS $function$\nDECLARE\n v_tenant uuid := app.current_tenant_id();\n v_seg record;\n v_col text;\nBEGIN\n IF v_tenant IS NULL THEN\n RAISE EXCEPTION 'crm_resolve_segment: sem tenant na sess\u00E3o' USING ERRCODE = '42501';\n END IF;\n IF NOT app.has_permission('sales.read', NULL::uuid) THEN\n RAISE EXCEPTION 'crm_resolve_segment: exige sales.read' USING ERRCODE = '42501';\n END IF;\n\n SELECT * INTO v_seg FROM public.plg_crm_segments s\n WHERE s.id = p_segment_id AND s.tenant_id = v_tenant;\n IF v_seg.id IS NULL THEN\n RAISE EXCEPTION 'crm_resolve_segment: segmento n\u00E3o encontrado' USING ERRCODE = 'P0002';\n END IF;\n\n -- A hand-picked list is the answer itself.\n IF v_seg.kind = 'list' THEN\n RETURN QUERY\n SELECT m.person_id FROM public.plg_crm_segment_members m\n WHERE m.segment_id = v_seg.id AND m.tenant_id = v_tenant;\n RETURN;\n END IF;\n\n v_col := CASE WHEN EXISTS (\n SELECT 1 FROM information_schema.columns\n WHERE table_schema = 'public' AND table_name = v_seg.source_view AND column_name = 'person_id'\n ) THEN 'person_id' ELSE 'id' END;\n\n RETURN QUERY EXECUTE format(\n 'SELECT DISTINCT s.%I FROM public.%I s WHERE %s AND s.%I IS NOT NULL',\n v_col, v_seg.source_view, public.crm_segment_where(v_seg.id, v_tenant), v_col);\nEND $function$;\n\n-- Deals: only for a segment over the deal audience.\nCREATE OR REPLACE FUNCTION public.crm_resolve_segment_deals(p_segment_id uuid)\nRETURNS TABLE(deal_id uuid)\nLANGUAGE plpgsql\nSTABLE SECURITY DEFINER\nSET search_path TO ''\nAS $function$\nDECLARE\n v_tenant uuid := app.current_tenant_id();\n v_view text;\nBEGIN\n IF v_tenant IS NULL THEN\n RAISE EXCEPTION 'crm_resolve_segment_deals: sem tenant na sess\u00E3o' USING ERRCODE = '42501';\n END IF;\n IF NOT app.has_permission('sales.read', NULL::uuid) THEN\n RAISE EXCEPTION 'crm_resolve_segment_deals: exige sales.read' USING ERRCODE = '42501';\n END IF;\n SELECT s.source_view INTO v_view FROM public.plg_crm_segments s\n WHERE s.id = p_segment_id AND s.tenant_id = v_tenant AND s.kind = 'rule';\n IF v_view IS DISTINCT FROM 'v_crm_deal_audience' THEN\n RAISE EXCEPTION 'crm_resolve_segment_deals: o segmento n\u00E3o \u00E9 sobre neg\u00F3cios' USING ERRCODE = '22023';\n END IF;\n RETURN QUERY EXECUTE format('SELECT s.id FROM public.v_crm_deal_audience s WHERE %s',\n public.crm_segment_where(p_segment_id, v_tenant));\nEND $function$;\n\nREVOKE ALL ON FUNCTION public.crm_resolve_segment_deals(uuid) FROM PUBLIC, anon;\nGRANT EXECUTE ON FUNCTION public.crm_resolve_segment_deals(uuid) TO authenticated, service_role;\n";
65
65
  export declare const MIGRATION_065_A_DEAL_HAS_CONTACT_ROUTES = "-- 065_a_deal_has_contact_routes.sql\n--\n-- The sellers talked to ONE contact per deal \u2014 the central one, picked with no\n-- clear rule. When that contact does not answer, the next attempt should not\n-- be the same number again: it should be the person's other phone, then\n-- another person of the same company, then someone in the company's group.\n--\n-- This is that order, once, in the database: every way to reach a deal, best\n-- first, one row per (person, phone), with the person's e-mail on each row.\n-- Campaign journeys (conversations 017) walk it step by step.\n--\n-- SECURITY INVOKER: it reads people, phones and companies under the caller's\n-- RLS, so it can never return a contact the caller could not see.\n\nCREATE OR REPLACE FUNCTION public.crm_phone_e164(p_raw text)\nRETURNS text\nLANGUAGE sql\nIMMUTABLE\nSET search_path TO ''\nAS $function$\n -- Brazilian numbers as people type them: with or without +55, with or\n -- without punctuation. Anything that is not 10\u201313 digits is not a phone.\n SELECT CASE\n WHEN d IS NULL OR d = '' THEN NULL\n WHEN length(d) IN (10, 11) THEN '+55' || d\n WHEN length(d) IN (12, 13) AND d LIKE '55%' THEN '+' || d\n ELSE NULL\n END\n FROM (SELECT regexp_replace(coalesce(p_raw, ''), '\\D', '', 'g') AS d) x\n$function$;\n\nCREATE OR REPLACE FUNCTION public.crm_deal_contact_routes(p_deal uuid)\nRETURNS TABLE(route integer, person_id uuid, name text, phone_e164 text, email text, via text)\nLANGUAGE sql\nSTABLE\nSET search_path TO ''\nAS $function$\n WITH deal AS (\n SELECT d.id, d.tenant_id, d.contact_id, d.company_id\n FROM public.plg_crm_deals d WHERE d.id = p_deal\n ),\n grp AS (\n SELECT m2.company_id\n FROM deal\n JOIN public.plg_crm_company_group_members m1 ON m1.company_id = deal.company_id\n JOIN public.plg_crm_company_group_members m2 ON m2.group_id = m1.group_id\n WHERE m2.company_id <> deal.company_id\n ),\n -- Who, in order: the deal's contact, the company's people (primary first),\n -- the group's people.\n who AS (\n SELECT deal.contact_id AS person_id, 0 AS rank, 'primary'::text AS via FROM deal WHERE deal.contact_id IS NOT NULL\n UNION ALL\n SELECT cp.person_id, 10 + CASE WHEN cp.is_primary THEN 0 ELSE 1 END, 'company'\n FROM deal JOIN public.plg_crm_company_people cp ON cp.company_id = deal.company_id\n WHERE cp.person_id IS DISTINCT FROM deal.contact_id\n UNION ALL\n SELECT cp.person_id, 20 + CASE WHEN cp.is_primary THEN 0 ELSE 1 END, 'group'\n FROM grp JOIN public.plg_crm_company_people cp ON cp.company_id = grp.company_id\n ),\n person AS (\n SELECT DISTINCT ON (w.person_id) w.person_id, w.rank, w.via, p.name, p.email, p.phone\n FROM who w JOIN public.people p ON p.id = w.person_id\n WHERE p.merged_into_id IS NULL AND coalesce(p.is_active, true)\n ORDER BY w.person_id, w.rank\n ),\n -- Every phone of every person: the record's own first, then the list\n -- (primary first). A second phone of the deal's contact is `other_phone`.\n phones AS (\n SELECT pe.person_id, pe.rank, pe.via, pe.name, pe.email, public.crm_phone_e164(pe.phone) AS phone_e164, 0 AS ord\n FROM person pe\n UNION ALL\n SELECT pe.person_id, pe.rank, pe.via, pe.name, pe.email, public.crm_phone_e164(ph.phone),\n CASE WHEN ph.is_primary THEN 1 ELSE 2 END\n FROM person pe JOIN public.plg_crm_person_phones ph ON ph.person_id = pe.person_id\n ),\n dedup AS (\n SELECT DISTINCT ON (coalesce(ph.phone_e164, 'person:' || ph.person_id::text))\n ph.person_id, ph.rank, ph.via, ph.name, ph.email, ph.phone_e164, ph.ord\n FROM phones ph\n WHERE ph.phone_e164 IS NOT NULL OR ph.email IS NOT NULL\n ORDER BY coalesce(ph.phone_e164, 'person:' || ph.person_id::text), ph.rank, ph.ord\n ),\n numbered AS (\n SELECT d.*, row_number() OVER (PARTITION BY d.person_id ORDER BY d.ord) AS nth\n FROM dedup d\n )\n SELECT row_number() OVER (ORDER BY n.rank, n.person_id, n.nth)::integer,\n n.person_id, n.name, n.phone_e164, n.email,\n CASE WHEN n.via = 'primary' AND n.nth > 1 THEN 'other_phone' ELSE n.via END\n FROM numbered n\n -- A person with a phone does not also get a phone-less row.\n WHERE n.phone_e164 IS NOT NULL\n OR NOT EXISTS (SELECT 1 FROM numbered o WHERE o.person_id = n.person_id AND o.phone_e164 IS NOT NULL)\n ORDER BY n.rank, n.person_id, n.nth\n$function$;\n\nREVOKE ALL ON FUNCTION public.crm_deal_contact_routes(uuid) FROM PUBLIC, anon;\nGRANT EXECUTE ON FUNCTION public.crm_deal_contact_routes(uuid) TO authenticated, service_role;\nGRANT EXECUTE ON FUNCTION public.crm_phone_e164(text) TO authenticated, service_role;\n";
66
66
  export declare const MIGRATION_066_A_DRAFT_SEGMENT_SHOWS_WHO_IT_REACHES = "-- 066_a_draft_segment_shows_who_it_reaches.sql\n--\n-- The editor counted the draft (064) but did not say WHO: \"129 neg\u00F3cios\" with\n-- no way to see them means the person checks the segment somewhere else, or\n-- trusts it blind. This returns the rows a draft rule reaches (ids only; the\n-- screen reads names under its own RLS), capped, in the same rule engine.\n\nCREATE OR REPLACE FUNCTION public.crm_segment_preview_rows(\n p_source_view text, p_rules jsonb, p_unit uuid DEFAULT NULL, p_limit integer DEFAULT 500\n)\nRETURNS TABLE(id uuid, person_id uuid)\nLANGUAGE plpgsql\nSTABLE SECURITY DEFINER\nSET search_path TO ''\nAS $function$\nDECLARE\n v_tenant uuid := app.current_tenant_id();\n v_person text;\nBEGIN\n IF v_tenant IS NULL THEN\n RAISE EXCEPTION 'crm_segment_preview_rows: sem tenant na sess\u00E3o' USING ERRCODE = '42501';\n END IF;\n IF NOT app.has_permission('sales.read', NULL::uuid) THEN\n RAISE EXCEPTION 'crm_segment_preview_rows: exige sales.read' USING ERRCODE = '42501';\n END IF;\n IF p_source_view NOT IN ('people', 'v_crm_people_engagement', 'v_crm_deal_audience') THEN\n RAISE EXCEPTION 'crm_segment_preview_rows: leitura % n\u00E3o \u00E9 um p\u00FAblico', p_source_view USING ERRCODE = '22023';\n END IF;\n v_person := CASE WHEN p_source_view = 'v_crm_deal_audience' THEN 'person_id' ELSE 'id' END;\n RETURN QUERY EXECUTE format('SELECT s.id, s.%I FROM public.%I s WHERE %s LIMIT %s',\n v_person, p_source_view, public.crm_segment_where_for(p_source_view, p_rules, p_unit, v_tenant),\n greatest(1, least(coalesce(p_limit, 500), 2000)));\nEND $function$;\n\nREVOKE ALL ON FUNCTION public.crm_segment_preview_rows(text, jsonb, uuid, integer) FROM PUBLIC, anon;\nGRANT EXECUTE ON FUNCTION public.crm_segment_preview_rows(text, jsonb, uuid, integer) TO authenticated, service_role;\n";
67
+ export declare const MIGRATION_067_PARKED_STAGES_AND_HONEST_NUMBERS = "-- 067_parked_stages_and_honest_numbers.sql\n--\n-- Three corrections to how the CRM counts, and two panels that were \"em breve\".\n--\n-- 1. PARKED STAGES. \"Contato futuro\" and \"Lista de espera\" are not steps of\n-- the funnel: a deal there is waiting, not progressing. They inflated the\n-- conversion view (a stage after Ganho with 8 deals) and every pipeline\n-- total. A stage can now say it is parked; funnel, pipeline and rates skip\n-- it. Backfilled by code for the two stages every funnel here uses.\n--\n-- 2. CONVERSION = A WON DEAL. The KPI read \"lead para neg\u00F3cio\" (deals \u00F7 leads),\n-- which is meaningless where every lead gets a deal on arrival \u2014 it showed\n-- 101%. Conversion is now won \u00F7 deals that entered the flow (not parked, not\n-- archived); win rate is won \u00F7 closed (won + lost); the sales cycle is the\n-- average days from a deal's creation to its win.\n--\n-- 3. The two panels: `crm_operational_panel` (the seller's day: overdue and\n-- today's tasks, deals with no contact yet, stalled deals, conversations\n-- waiting on us) and `crm_maturity_panel` (is the CRM being used: deals with\n-- no owner / company / contact, contacts with no phone, activity logged per\n-- seller, messages that go through the platform).\n\nALTER TABLE public.plg_crm_pipeline_stages\n ADD COLUMN IF NOT EXISTS is_parked boolean NOT NULL DEFAULT false;\n\nCOMMENT ON COLUMN public.plg_crm_pipeline_stages.is_parked IS\n 'A waiting stage (Contato futuro, Lista de espera): outside the funnel, the conversion rate and the pipeline totals (067).';\n\nUPDATE public.plg_crm_pipeline_stages\n SET is_parked = true\n WHERE code IN ('contato-futuro', 'lista-de-espera') AND NOT is_parked;\n\n-- \u2500\u2500 the summary, with the numbers that mean something \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-- A NEW function and not a new `crm_summary`: changing its return type made\n-- the replay of 032 (which creates the old shape) fail. `crm_summary` stays\n-- exactly as 032 left it \u2014 restored here, because an earlier draft of this\n-- migration was applied with the wider shape \u2014 and `crm_flow_summary` carries\n-- the same columns plus the flow-aware ones.\nDROP FUNCTION IF EXISTS public.crm_summary();\ncreate or replace function public.crm_summary()\nreturns table (\n total_leads bigint,\n new_leads_this_month bigint,\n total_deals bigint,\n open_deals_value numeric,\n won_deals_this_month bigint,\n won_deals_value_this_month numeric,\n won_deals bigint,\n won_deals_value numeric,\n pending_activities bigint,\n overdue_activities bigint\n)\nlanguage plpgsql\nstable\nsecurity definer\nset search_path = public, app, pg_catalog\nas $$\ndeclare\n v_tenant uuid := app.current_tenant_id();\n v_foco uuid := nullif(app.current_unit_id(), '00000000-0000-0000-0000-000000000000'::uuid);\n v_negado boolean := app.current_unit_id() = '00000000-0000-0000-0000-000000000000'::uuid;\n v_unidades uuid[];\n v_sem_unidade boolean;\n v_dono boolean;\n v_uid uuid := auth.uid();\n v_mes date := date_trunc('month', now())::date;\n v_hoje date := now()::date;\nbegin\n -- Sem tenant, ou com unidade pedida que o usu\u00E1rio n\u00E3o tem: a pol\u00EDtica\n -- devolveria vazio, e aqui tamb\u00E9m. Nunca cair para \"a rede inteira\".\n if v_tenant is null or v_negado then\n return query select 0::bigint, 0::bigint, 0::bigint, 0::numeric,\n 0::bigint, 0::numeric, 0::bigint, 0::numeric,\n 0::bigint, 0::bigint;\n return;\n end if;\n\n select coalesce(array_agg(a.unit_id), '{}'::uuid[])\n into v_unidades\n from app.user_unit_access a\n where a.tenant_id = v_tenant\n and a.user_id = v_uid\n and (v_foco is null or a.unit_id = v_foco)\n and app.has_permission('crm.pipeline.read', a.unit_id);\n\n -- Linha sem unidade \u00E9 da rede: a pol\u00EDtica a mostra a quem tem a permiss\u00E3o no\n -- n\u00EDvel do tenant. Com uma unidade em foco ela continua aparecendo \u2014 \u00E9 o que\n -- a pol\u00EDtica diz, e \u00E9 por isso que os R$ 520.072,00 dos 1.599 neg\u00F3cios sem\n -- unidade aparecem em toda unidade. Assim \u00E9 no V1 tamb\u00E9m: l\u00E1 s\u00E3o 1.600\n -- oportunidades sem `unit_id`.\n v_sem_unidade := app.has_permission('crm.pipeline.read', null::uuid);\n v_dono := app.owner_scoped('crm.deal');\n\n return query\n with negocios as (\n select d.status, d.value, d.won_at, d.updated_at\n from public.plg_crm_deals d\n where d.tenant_id = v_tenant\n and ( (d.unit_id is null and v_sem_unidade)\n or (d.unit_id = any (v_unidades)))\n and (not v_dono or d.owner_id is null or d.owner_id = v_uid)\n ),\n pessoas as (\n select count(*) filter (where p.kind = 'lead') as leads,\n count(*) filter (where p.kind = 'lead' and p.created_at >= v_mes) as leads_mes\n from public.people p\n where p.tenant_id = v_tenant\n and (p.unit_id is null or p.unit_id = any (v_unidades))\n ),\n tarefas as (\n select count(*) filter (where a.completed_at is null) as pendentes,\n count(*) filter (where a.completed_at is null and a.due_date < v_hoje) as atrasadas\n from public.plg_crm_activities a\n where a.tenant_id = v_tenant\n )\n select pessoas.leads,\n pessoas.leads_mes,\n (select count(*) from negocios),\n (select coalesce(sum(value), 0) from negocios where status = 'open'),\n (select count(*) from negocios where status = 'won' and coalesce(won_at, updated_at) >= v_mes),\n (select coalesce(sum(value), 0) from negocios where status = 'won' and coalesce(won_at, updated_at) >= v_mes),\n (select count(*) from negocios where status = 'won'),\n (select coalesce(sum(value), 0) from negocios where status = 'won'),\n tarefas.pendentes,\n tarefas.atrasadas\n from pessoas, tarefas;\nend $$;\n\nrevoke all on function public.crm_summary() from public;\ngrant execute on function public.crm_summary() to authenticated, service_role;\n\nDROP FUNCTION IF EXISTS public.crm_flow_summary();\nCREATE FUNCTION public.crm_flow_summary()\n RETURNS TABLE(\n total_leads bigint, new_leads_this_month bigint, total_deals bigint, open_deals_value numeric,\n won_deals_this_month bigint, won_deals_value_this_month numeric, won_deals bigint, won_deals_value numeric,\n pending_activities bigint, overdue_activities bigint,\n entered_deals bigint, open_deals bigint, parked_deals bigint, lost_deals bigint, avg_cycle_days numeric\n )\n LANGUAGE plpgsql\n STABLE SECURITY DEFINER\n SET search_path TO 'public', 'app', 'pg_catalog'\nAS $function$\ndeclare\n v_tenant uuid := app.current_tenant_id();\n v_foco uuid := nullif(app.current_unit_id(), '00000000-0000-0000-0000-000000000000'::uuid);\n v_negado boolean := app.current_unit_id() = '00000000-0000-0000-0000-000000000000'::uuid;\n v_unidades uuid[];\n v_sem_unidade boolean;\n v_dono boolean;\n v_uid uuid := auth.uid();\n v_mes date := date_trunc('month', now())::date;\n v_hoje date := now()::date;\nbegin\n if v_tenant is null or v_negado then\n return query select 0::bigint, 0::bigint, 0::bigint, 0::numeric, 0::bigint, 0::numeric, 0::bigint, 0::numeric,\n 0::bigint, 0::bigint, 0::bigint, 0::bigint, 0::bigint, 0::bigint, null::numeric;\n return;\n end if;\n\n select coalesce(array_agg(a.unit_id), '{}'::uuid[])\n into v_unidades\n from app.user_unit_access a\n where a.tenant_id = v_tenant\n and a.user_id = v_uid\n and (v_foco is null or a.unit_id = v_foco)\n and app.has_permission('crm.pipeline.read', a.unit_id);\n v_sem_unidade := app.has_permission('crm.pipeline.read', null::uuid);\n v_dono := app.owner_scoped('crm.deal');\n\n return query\n with negocios as (\n select d.status, d.value, d.won_at, d.updated_at, d.created_at,\n coalesce(st.is_parked, false) as parked\n from public.plg_crm_deals d\n left join public.plg_crm_pipeline_stages st on st.id = d.stage_id\n where d.tenant_id = v_tenant\n and ( (d.unit_id is null and v_sem_unidade)\n or (d.unit_id = any (v_unidades)))\n and (not v_dono or d.owner_id is null or d.owner_id = v_uid)\n ),\n pessoas as (\n select count(*) filter (where p.kind = 'lead') as leads,\n count(*) filter (where p.kind = 'lead' and p.created_at >= v_mes) as leads_mes\n from public.people p\n where p.tenant_id = v_tenant\n and (p.unit_id is null or p.unit_id = any (v_unidades))\n ),\n tarefas as (\n select count(*) filter (where a.completed_at is null) as pendentes,\n count(*) filter (where a.completed_at is null and a.due_date < v_hoje) as atrasadas\n from public.plg_crm_activities a\n where a.tenant_id = v_tenant\n )\n select pessoas.leads,\n pessoas.leads_mes,\n (select count(*) from negocios where status <> 'archived'),\n (select coalesce(sum(value), 0) from negocios where status = 'open' and not parked),\n (select count(*) from negocios where status = 'won' and coalesce(won_at, updated_at) >= v_mes),\n (select coalesce(sum(value), 0) from negocios where status = 'won' and coalesce(won_at, updated_at) >= v_mes),\n (select count(*) from negocios where status = 'won'),\n (select coalesce(sum(value), 0) from negocios where status = 'won'),\n tarefas.pendentes,\n tarefas.atrasadas,\n (select count(*) from negocios where status <> 'archived' and not (status = 'open' and parked)),\n (select count(*) from negocios where status = 'open' and not parked),\n (select count(*) from negocios where status = 'open' and parked),\n (select count(*) from negocios where status = 'lost'),\n (select round(avg(extract(epoch from (coalesce(won_at, updated_at) - created_at)) / 86400)::numeric, 1)\n from negocios where status = 'won')\n from pessoas, tarefas;\nend $function$;\n\nREVOKE ALL ON FUNCTION public.crm_flow_summary() FROM PUBLIC, anon;\nGRANT EXECUTE ON FUNCTION public.crm_flow_summary() TO authenticated, service_role;\n\n-- \u2500\u2500 the seller's day \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\nCREATE OR REPLACE FUNCTION public.crm_operational_panel(p_stalled_days integer DEFAULT 14)\nRETURNS jsonb\nLANGUAGE plpgsql\nSTABLE SECURITY DEFINER\nSET search_path TO 'public', 'app', 'pg_catalog'\nAS $function$\ndeclare\n v_tenant uuid := app.current_tenant_id();\n v_foco uuid := nullif(app.current_unit_id(), '00000000-0000-0000-0000-000000000000'::uuid);\n v_out jsonb;\nbegin\n if v_tenant is null then raise exception 'crm_operational_panel: sem tenant na sess\u00E3o' using errcode = '42501'; end if;\n if not app.has_permission('sales.read', null::uuid) then raise exception 'crm_operational_panel: exige sales.read' using errcode = '42501'; end if;\n\n with deals as (\n select d.id, d.assigned_to_id as owner, d.created_at, d.updated_at, d.stage_id, st.name as stage, st.\"order\" as stage_order\n from public.plg_crm_deals d\n join public.plg_crm_pipeline_stages st on st.id = d.stage_id\n where d.tenant_id = v_tenant and d.status = 'open' and not st.is_parked and not st.is_won and not st.is_lost\n and (v_foco is null or d.unit_id is null or d.unit_id = v_foco)\n ),\n contacted as (\n select distinct a.deal_id from public.plg_crm_activities a\n where a.tenant_id = v_tenant and a.deal_id is not null\n and a.activity_type in ('whatsapp', 'call', 'email', 'meeting', 'visit', 'note')\n ),\n per_deal as (\n select d.*,\n (d.updated_at < now() - make_interval(days => p_stalled_days)) as stalled,\n (c.deal_id is null) as uncontacted\n from deals d left join contacted c on c.deal_id = d.id\n ),\n tasks as (\n select a.assigned_to_id as owner,\n count(*) filter (where a.due_date < current_date) as overdue,\n count(*) filter (where a.due_date = current_date) as today\n from public.plg_crm_activities a\n where a.tenant_id = v_tenant and a.completed_at is null and a.activity_type = 'task'\n group by 1\n ),\n waiting as (\n select c.lead_owner_id as owner, count(*) as n\n from public.v_conversations c\n where c.tenant_id = v_tenant and c.status = 'open' and c.last_message_direction = 'inbound'\n and not (c.acknowledged_at is not null and c.acknowledged_at >= c.last_message_at)\n group by 1\n ),\n owners as (\n select owner::text as owner from per_deal union select owner::text from tasks union select owner::text from waiting\n ),\n team as (\n select m.user_id::text as user_id, p.name\n from public.v_authz_memberships m join public.people p on p.id = m.person_id\n where m.tenant_id = v_tenant\n )\n select jsonb_build_object(\n 'totals', jsonb_build_object(\n 'open_deals', (select count(*) from per_deal),\n 'stalled', (select count(*) from per_deal where stalled),\n 'uncontacted', (select count(*) from per_deal where uncontacted),\n 'overdue_tasks', (select coalesce(sum(overdue), 0) from tasks),\n 'today_tasks', (select coalesce(sum(today), 0) from tasks),\n 'waiting_conversations', (select coalesce(sum(n), 0) from waiting)\n ),\n 'by_owner', coalesce((\n select jsonb_agg(jsonb_build_object(\n 'owner_id', o.owner,\n 'name', coalesce((select t.name from team t where t.user_id = o.owner limit 1), case when o.owner is null then 'Sem dono' else 'Sem nome' end),\n 'open_deals', (select count(*) from per_deal d where d.owner::text is not distinct from o.owner),\n 'stalled', (select count(*) from per_deal d where d.owner::text is not distinct from o.owner and d.stalled),\n 'uncontacted', (select count(*) from per_deal d where d.owner::text is not distinct from o.owner and d.uncontacted),\n 'overdue_tasks', coalesce((select t.overdue from tasks t where t.owner::text is not distinct from o.owner), 0),\n 'today_tasks', coalesce((select t.today from tasks t where t.owner::text is not distinct from o.owner), 0),\n 'waiting_conversations', coalesce((select w.n from waiting w where w.owner::text is not distinct from o.owner), 0)\n ) order by o.owner nulls last)\n from owners o), '[]'::jsonb),\n 'by_stage', coalesce((\n select jsonb_agg(jsonb_build_object('stage', s.stage, 'open', s.open, 'stalled', s.stalled, 'avg_days', s.avg_days) order by s.stage_order)\n from (select stage, stage_order, count(*) as open, count(*) filter (where stalled) as stalled,\n round(avg(extract(epoch from (now() - updated_at)) / 86400)::numeric, 1) as avg_days\n from per_deal group by stage, stage_order) s), '[]'::jsonb)\n ) into v_out;\n return v_out;\nend $function$;\n\nREVOKE ALL ON FUNCTION public.crm_operational_panel(integer) FROM PUBLIC, anon;\nGRANT EXECUTE ON FUNCTION public.crm_operational_panel(integer) TO authenticated, service_role;\n\n-- \u2500\u2500 is the CRM being used \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\nCREATE OR REPLACE FUNCTION public.crm_maturity_panel()\nRETURNS jsonb\nLANGUAGE plpgsql\nSTABLE SECURITY DEFINER\nSET search_path TO 'public', 'app', 'pg_catalog'\nAS $function$\ndeclare\n v_tenant uuid := app.current_tenant_id();\n v_foco uuid := nullif(app.current_unit_id(), '00000000-0000-0000-0000-000000000000'::uuid);\n v_out jsonb;\nbegin\n if v_tenant is null then raise exception 'crm_maturity_panel: sem tenant na sess\u00E3o' using errcode = '42501'; end if;\n if not app.has_permission('sales.read', null::uuid) then raise exception 'crm_maturity_panel: exige sales.read' using errcode = '42501'; end if;\n\n with deals as (\n select d.* from public.plg_crm_deals d\n where d.tenant_id = v_tenant and d.status in ('open', 'won', 'lost')\n and (v_foco is null or d.unit_id is null or d.unit_id = v_foco)\n ),\n team as (\n select m.user_id, p.name from public.v_authz_memberships m join public.people p on p.id = m.person_id\n where m.tenant_id = v_tenant and m.active\n ),\n acts as (\n select a.created_by, a.activity_type, a.created_at from public.plg_crm_activities a\n where a.tenant_id = v_tenant and a.created_at > now() - interval '30 days'\n and a.activity_type not in ('stage_changed', 'deal_created', 'lead_created', 'deal_archived', 'lead_archived', 'quote_created')\n ),\n msgs as (\n select m.direction, m.sender_kind, m.sender_label, m.author from public.plg_conversation_messages m\n where m.tenant_id = v_tenant and m.channel = 'whatsapp' and m.at > now() - interval '30 days'\n )\n select jsonb_build_object(\n 'deals', (select count(*) from deals),\n 'hygiene', jsonb_build_object(\n 'no_owner', (select count(*) from deals where assigned_to_id is null),\n 'no_company', (select count(*) from deals where company_id is null),\n 'no_contact', (select count(*) from deals where contact_id is null),\n 'no_phone', (select count(*) from deals d left join public.people p on p.id = d.contact_id\n where coalesce(p.phone, '') = ''\n and not exists (select 1 from public.plg_crm_person_phones ph where ph.person_id = d.contact_id)),\n 'stale_30d', (select count(*) from deals where status = 'open' and updated_at < now() - interval '30 days')\n ),\n 'activity_by_seller', coalesce((\n select jsonb_agg(jsonb_build_object(\n 'user_id', t.user_id, 'name', t.name,\n 'last_7d', (select count(*) from acts a where a.created_by = t.user_id and a.created_at > now() - interval '7 days'),\n 'last_30d', (select count(*) from acts a where a.created_by = t.user_id),\n 'whatsapp_30d', (select count(*) from acts a where a.created_by = t.user_id and a.activity_type = 'whatsapp')\n ) order by (select count(*) from acts a where a.created_by = t.user_id) desc, t.name) from team t), '[]'::jsonb),\n 'inbox', jsonb_build_object(\n 'inbound_30d', (select count(*) from msgs where direction = 'inbound'),\n 'outbound_platform_30d', (select count(*) from msgs where direction = 'outbound' and coalesce(sender_label, '') <> 'Pelo celular'),\n 'outbound_phone_30d', (select count(*) from msgs where direction = 'outbound' and sender_label = 'Pelo celular'),\n 'outbound_campaign_30d', (select count(*) from msgs where direction = 'outbound' and sender_kind = 'automation')\n )\n ) into v_out;\n return v_out;\nend $function$;\n\nREVOKE ALL ON FUNCTION public.crm_maturity_panel() FROM PUBLIC, anon;\nGRANT EXECUTE ON FUNCTION public.crm_maturity_panel() TO authenticated, service_role;\n";
67
68
  export declare const MIGRATIONS: Array<{
68
69
  id: string;
69
70
  sql: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"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"}
@@ -65,8 +65,9 @@ var MIGRATION_063_THE_ROTA_ENGINE_IS_SERVER_ONLY = "";
65
65
  var MIGRATION_064_SEGMENTS_REACH_THE_DEAL = "";
66
66
  var MIGRATION_065_A_DEAL_HAS_CONTACT_ROUTES = "";
67
67
  var MIGRATION_066_A_DRAFT_SEGMENT_SHOWS_WHO_IT_REACHES = "";
68
+ var MIGRATION_067_PARKED_STAGES_AND_HONEST_NUMBERS = "";
68
69
  var MIGRATIONS = [];
69
70
 
70
- export { MIGRATIONS, MIGRATION_000_BASELINE, MIGRATION_001_DE_ONDE_VEIO_E_QUEM_INDICOU, MIGRATION_002_A_PERGUNTA_QUE_O_CLIENTE_RESPONDE, MIGRATION_003_O_CLIENTE_RESPONDE_NO_PROPRIO_TELEFONE, MIGRATION_004_UM_RECORTE_DE_GENTE_QUE_TEM_NOME, MIGRATION_005_A_ETAPA_GANHA_UM_CODIGO_E_UM_COMECO, MIGRATION_006_A_ESCADA_DO_RELACIONAMENTO, MIGRATION_008_A_REGUA_DA_REDE_E_PUBLICA, MIGRATION_009_THE_LEAD_OFFER_CASCADES, MIGRATION_010_THE_BOARD_HEARS_THE_DEAL, MIGRATION_011_A_FUNNEL_IS_BORN_USABLE, MIGRATION_012_THE_CRM_SAYS_WHAT_HAPPENED, MIGRATION_013_THE_COMPANY_HOLDS_ITS_PEOPLE, MIGRATION_014_THE_SECOND_FORM_IS_THE_SAME_PERSON, MIGRATION_015_THE_FAMILY_OWNS_MORE_THAN_ONE_HOUSE, MIGRATION_016_THE_STRANGER_ONLY_EDITS_WHAT_IT_MADE, MIGRATION_017_TWO_FORMS_ONE_PERSON_AND_THE_INTEREST_ADDS_UP, MIGRATION_018_THE_ROTA_SKIPS_WHO_LEFT_AND_THE_SCREEN_SHOWS_WHO_WAITS, MIGRATION_019_QUEM_AINDA_COMPRA_E_QUEM_SUMIU, MIGRATION_020_O_STATUS_E_CONSEQUENCIA_DO_QUE_FOI_FEITO, MIGRATION_021_O_AGENTE_MEXE_NO_CARD, MIGRATION_022_A_LISTA_DO_FUNIL_PERGUNTA_POR_CIDADE, MIGRATION_023_O_CONTATO_DIZ_DE_QUE_EMPRESA_ELE_E, MIGRATION_024_O_NEGOCIO_DIZ_DE_QUE_CASA_ELE_E, MIGRATION_025_O_CARD_DIZ_QUEM_E_O_VENDEDOR, MIGRATION_026_A_LEITURA_DO_FUNIL_SAI_DO_LACO, MIGRATION_027_A_NOTA_DO_NEGOCIO_CHEGA_NA_BUSCA, MIGRATION_028_O_LEAD_DIZ_QUANTO_VALE_E_POR_QUE, MIGRATION_029_A_PORTA_DE_SERVICO_FECHA_ATRAS_DE_QUEM_ENTROU_DEPOIS, MIGRATION_030_A_LISTA_DE_ORCAMENTOS_NAO_VARRE_O_HISTORICO, MIGRATION_031_O_NOME_DO_CONTATO_ENTRA_NO_CARD, MIGRATION_032_O_PAINEL_DE_VENDAS_CONTA_NO_BANCO, MIGRATION_033_O_ENGAJAMENTO_NAO_SOMA_OS_PEDIDOS_DA_PLATAFORMA, MIGRATION_034_O_GRAFICO_DO_FUNIL_CONTA_A_ETAPA_INTEIRA, MIGRATION_035_QUEM_ESTA_NO_FUNIL_E_UM_LEAD, MIGRATION_036_O_FUNIL_DO_V1_ENTRA_NO_LUGAR_DO_FUNIL_DE_FABRICA, MIGRATION_037_O_NEGOCIO_E_O_ORCAMENTO_ATRAVESSAM_O_HISTORICO_FICA, MIGRATION_038_CANAL_ORIGEM_E_CAMPANHA_SAO_TRES_PERGUNTAS, MIGRATION_039_A_BANDEIRA_AGRUPA_O_QUE_A_RAIZ_DO_CNPJ_NAO_VE, MIGRATION_040_O_CARD_DO_FUNIL_NAO_LE_A_AGENDA_INTEIRA, MIGRATION_041_O_NOME_NO_CARD_E_DO_NEGOCIO_NAO_DA_AGENDA, MIGRATION_042_A_ATIVIDADE_DIZ_QUEM_A_FEZ, MIGRATION_043_A_CADENCIA_PARA_DE_ESPERAR_UM_FATO_QUE_NUNCA_CHEGA, MIGRATION_044_O_STATUS_NAO_E_UM_ACONTECIMENTO, MIGRATION_045_CONTATO_FEITO_E_CONTATO_QUE_ALGUEM_FEZ, MIGRATION_046_A_PASTILHA_DO_CARD_SO_FALA_QUANDO_TEM_O_QUE_DIZER, MIGRATION_047_O_DONO_DO_LEAD_TEM_UM_LUGAR_SO, MIGRATION_048_A_EMPRESA_TAMBEM_TEM_UM_ARROBA, MIGRATION_049_O_ARROBA_CHEGA_ATE_A_LISTA, MIGRATION_050_A_REUNIAO_E_UMA_ESPECIE_DECLARADA, MIGRATION_051_O_CRACHA_E_O_TELEFONE_RECUSADO_APARECEM, MIGRATION_052_O_NEGOCIO_DIZ_DE_QUE_CASA_ELE_E, MIGRATION_053_A_ATIVIDADE_DIZ_DE_QUEM_ELA_E, MIGRATION_054_A_LISTA_DE_LEADS_PERGUNTA_POR_CIDADE, MIGRATION_055_A_CESTA_DO_INTERESSE_TEM_ONDE_MORAR, MIGRATION_056_O_INTERESSE_ENTRA_PELO_AGENDAMENTO, MIGRATION_057_O_NEGOCIO_E_DO_GRUPO_NAO_DO_CNPJ, MIGRATION_058_O_CARD_DIZ_O_NOME_DO_GRUPO, MIGRATION_059_A_EMPRESA_MOSTRA_O_INSTAGRAM_QUE_ELA_GUARDA, MIGRATION_060_O_FUNIL_SABE_DE_QUEM_ELE_E, MIGRATION_061_A_CONVERSAO_RESPEITA_O_FILTRO_DO_QUADRO, MIGRATION_062_THE_WHOLE_CRM_SAYS_WHICH_UNIT_IT_IS, MIGRATION_063_THE_ROTA_ENGINE_IS_SERVER_ONLY, MIGRATION_064_SEGMENTS_REACH_THE_DEAL, MIGRATION_065_A_DEAL_HAS_CONTACT_ROUTES, MIGRATION_066_A_DRAFT_SEGMENT_SHOWS_WHO_IT_REACHES };
71
+ export { MIGRATIONS, MIGRATION_000_BASELINE, MIGRATION_001_DE_ONDE_VEIO_E_QUEM_INDICOU, MIGRATION_002_A_PERGUNTA_QUE_O_CLIENTE_RESPONDE, MIGRATION_003_O_CLIENTE_RESPONDE_NO_PROPRIO_TELEFONE, MIGRATION_004_UM_RECORTE_DE_GENTE_QUE_TEM_NOME, MIGRATION_005_A_ETAPA_GANHA_UM_CODIGO_E_UM_COMECO, MIGRATION_006_A_ESCADA_DO_RELACIONAMENTO, MIGRATION_008_A_REGUA_DA_REDE_E_PUBLICA, MIGRATION_009_THE_LEAD_OFFER_CASCADES, MIGRATION_010_THE_BOARD_HEARS_THE_DEAL, MIGRATION_011_A_FUNNEL_IS_BORN_USABLE, MIGRATION_012_THE_CRM_SAYS_WHAT_HAPPENED, MIGRATION_013_THE_COMPANY_HOLDS_ITS_PEOPLE, MIGRATION_014_THE_SECOND_FORM_IS_THE_SAME_PERSON, MIGRATION_015_THE_FAMILY_OWNS_MORE_THAN_ONE_HOUSE, MIGRATION_016_THE_STRANGER_ONLY_EDITS_WHAT_IT_MADE, MIGRATION_017_TWO_FORMS_ONE_PERSON_AND_THE_INTEREST_ADDS_UP, MIGRATION_018_THE_ROTA_SKIPS_WHO_LEFT_AND_THE_SCREEN_SHOWS_WHO_WAITS, MIGRATION_019_QUEM_AINDA_COMPRA_E_QUEM_SUMIU, MIGRATION_020_O_STATUS_E_CONSEQUENCIA_DO_QUE_FOI_FEITO, MIGRATION_021_O_AGENTE_MEXE_NO_CARD, MIGRATION_022_A_LISTA_DO_FUNIL_PERGUNTA_POR_CIDADE, MIGRATION_023_O_CONTATO_DIZ_DE_QUE_EMPRESA_ELE_E, MIGRATION_024_O_NEGOCIO_DIZ_DE_QUE_CASA_ELE_E, MIGRATION_025_O_CARD_DIZ_QUEM_E_O_VENDEDOR, MIGRATION_026_A_LEITURA_DO_FUNIL_SAI_DO_LACO, MIGRATION_027_A_NOTA_DO_NEGOCIO_CHEGA_NA_BUSCA, MIGRATION_028_O_LEAD_DIZ_QUANTO_VALE_E_POR_QUE, MIGRATION_029_A_PORTA_DE_SERVICO_FECHA_ATRAS_DE_QUEM_ENTROU_DEPOIS, MIGRATION_030_A_LISTA_DE_ORCAMENTOS_NAO_VARRE_O_HISTORICO, MIGRATION_031_O_NOME_DO_CONTATO_ENTRA_NO_CARD, MIGRATION_032_O_PAINEL_DE_VENDAS_CONTA_NO_BANCO, MIGRATION_033_O_ENGAJAMENTO_NAO_SOMA_OS_PEDIDOS_DA_PLATAFORMA, MIGRATION_034_O_GRAFICO_DO_FUNIL_CONTA_A_ETAPA_INTEIRA, MIGRATION_035_QUEM_ESTA_NO_FUNIL_E_UM_LEAD, MIGRATION_036_O_FUNIL_DO_V1_ENTRA_NO_LUGAR_DO_FUNIL_DE_FABRICA, MIGRATION_037_O_NEGOCIO_E_O_ORCAMENTO_ATRAVESSAM_O_HISTORICO_FICA, MIGRATION_038_CANAL_ORIGEM_E_CAMPANHA_SAO_TRES_PERGUNTAS, MIGRATION_039_A_BANDEIRA_AGRUPA_O_QUE_A_RAIZ_DO_CNPJ_NAO_VE, MIGRATION_040_O_CARD_DO_FUNIL_NAO_LE_A_AGENDA_INTEIRA, MIGRATION_041_O_NOME_NO_CARD_E_DO_NEGOCIO_NAO_DA_AGENDA, MIGRATION_042_A_ATIVIDADE_DIZ_QUEM_A_FEZ, MIGRATION_043_A_CADENCIA_PARA_DE_ESPERAR_UM_FATO_QUE_NUNCA_CHEGA, MIGRATION_044_O_STATUS_NAO_E_UM_ACONTECIMENTO, MIGRATION_045_CONTATO_FEITO_E_CONTATO_QUE_ALGUEM_FEZ, MIGRATION_046_A_PASTILHA_DO_CARD_SO_FALA_QUANDO_TEM_O_QUE_DIZER, MIGRATION_047_O_DONO_DO_LEAD_TEM_UM_LUGAR_SO, MIGRATION_048_A_EMPRESA_TAMBEM_TEM_UM_ARROBA, MIGRATION_049_O_ARROBA_CHEGA_ATE_A_LISTA, MIGRATION_050_A_REUNIAO_E_UMA_ESPECIE_DECLARADA, MIGRATION_051_O_CRACHA_E_O_TELEFONE_RECUSADO_APARECEM, MIGRATION_052_O_NEGOCIO_DIZ_DE_QUE_CASA_ELE_E, MIGRATION_053_A_ATIVIDADE_DIZ_DE_QUEM_ELA_E, MIGRATION_054_A_LISTA_DE_LEADS_PERGUNTA_POR_CIDADE, MIGRATION_055_A_CESTA_DO_INTERESSE_TEM_ONDE_MORAR, MIGRATION_056_O_INTERESSE_ENTRA_PELO_AGENDAMENTO, MIGRATION_057_O_NEGOCIO_E_DO_GRUPO_NAO_DO_CNPJ, MIGRATION_058_O_CARD_DIZ_O_NOME_DO_GRUPO, MIGRATION_059_A_EMPRESA_MOSTRA_O_INSTAGRAM_QUE_ELA_GUARDA, MIGRATION_060_O_FUNIL_SABE_DE_QUEM_ELE_E, MIGRATION_061_A_CONVERSAO_RESPEITA_O_FILTRO_DO_QUADRO, MIGRATION_062_THE_WHOLE_CRM_SAYS_WHICH_UNIT_IT_IS, MIGRATION_063_THE_ROTA_ENGINE_IS_SERVER_ONLY, MIGRATION_064_SEGMENTS_REACH_THE_DEAL, MIGRATION_065_A_DEAL_HAS_CONTACT_ROUTES, MIGRATION_066_A_DRAFT_SEGMENT_SHOWS_WHO_IT_REACHES, MIGRATION_067_PARKED_STAGES_AND_HONEST_NUMBERS };
71
72
  //# sourceMappingURL=main.browser.js.map
72
73
  //# 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,yCAAA,GAA4C;AAClD,IAAM,+CAAA,GAAkD;AACxD,IAAM,oDAAA,GAAuD;AAC7D,IAAM,8CAAA,GAAiD;AACvD,IAAM,iDAAA,GAAoD;AAC1D,IAAM,wCAAA,GAA2C;AACjD,IAAM,uCAAA,GAA0C;AAChD,IAAM,qCAAA,GAAwC;AAC9C,IAAM,sCAAA,GAAyC;AAC/C,IAAM,qCAAA,GAAwC;AAC9C,IAAM,wCAAA,GAA2C;AACjD,IAAM,0CAAA,GAA6C;AACnD,IAAM,gDAAA,GAAmD;AACzD,IAAM,iDAAA,GAAoD;AAC1D,IAAM,kDAAA,GAAqD;AAC3D,IAAM,2DAAA,GAA8D;AACpE,IAAM,oEAAA,GAAuE;AAC7E,IAAM,4CAAA,GAA+C;AACrD,IAAM,sDAAA,GAAyD;AAC/D,IAAM,mCAAA,GAAsC;AAC5C,IAAM,kDAAA,GAAqD;AAC3D,IAAM,gDAAA,GAAmD;AACzD,IAAM,6CAAA,GAAgD;AACtD,IAAM,0CAAA,GAA6C;AACnD,IAAM,4CAAA,GAA+C;AACrD,IAAM,8CAAA,GAAiD;AACvD,IAAM,8CAAA,GAAiD;AACvD,IAAM,kEAAA,GAAqE;AAC3E,IAAM,yDAAA,GAA4D;AAClE,IAAM,6CAAA,GAAgD;AACtD,IAAM,+CAAA,GAAkD;AACxD,IAAM,6DAAA,GAAgE;AACtE,IAAM,sDAAA,GAAyD;AAC/D,IAAM,0CAAA,GAA6C;AACnD,IAAM,8DAAA,GAAiE;AACvE,IAAM,iEAAA,GAAoE;AAC1E,IAAM,wDAAA,GAA2D;AACjE,IAAM,2DAAA,GAA8D;AACpE,IAAM,qDAAA,GAAwD;AAC9D,IAAM,uDAAA,GAA0D;AAChE,IAAM,wCAAA,GAA2C;AACjD,IAAM,gEAAA,GAAmE;AACzE,IAAM,6CAAA,GAAgD;AACtD,IAAM,oDAAA,GAAuD;AAC7D,IAAM,+DAAA,GAAkE;AACxE,IAAM,4CAAA,GAA+C;AACrD,IAAM,4CAAA,GAA+C;AACrD,IAAM,wCAAA,GAA2C;AACjD,IAAM,+CAAA,GAAkD;AACxD,IAAM,qDAAA,GAAwD;AAC9D,IAAM,6CAAA,GAAgD;AACtD,IAAM,2CAAA,GAA8C;AACpD,IAAM,kDAAA,GAAqD;AAC3D,IAAM,iDAAA,GAAoD;AAC1D,IAAM,gDAAA,GAAmD;AACzD,IAAM,8CAAA,GAAiD;AACvD,IAAM,wCAAA,GAA2C;AACjD,IAAM,yDAAA,GAA4D;AAClE,IAAM,wCAAA,GAA2C;AACjD,IAAM,qDAAA,GAAwD;AAC9D,IAAM,iDAAA,GAAoD;AAC1D,IAAM,4CAAA,GAA+C;AACrD,IAAM,qCAAA,GAAwC;AAC9C,IAAM,uCAAA,GAA0C;AAChD,IAAM,kDAAA,GAAqD;AAC3D,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_DE_ONDE_VEIO_E_QUEM_INDICOU = ''\nexport const MIGRATION_002_A_PERGUNTA_QUE_O_CLIENTE_RESPONDE = ''\nexport const MIGRATION_003_O_CLIENTE_RESPONDE_NO_PROPRIO_TELEFONE = ''\nexport const MIGRATION_004_UM_RECORTE_DE_GENTE_QUE_TEM_NOME = ''\nexport const MIGRATION_005_A_ETAPA_GANHA_UM_CODIGO_E_UM_COMECO = ''\nexport const MIGRATION_006_A_ESCADA_DO_RELACIONAMENTO = ''\nexport const MIGRATION_008_A_REGUA_DA_REDE_E_PUBLICA = ''\nexport const MIGRATION_009_THE_LEAD_OFFER_CASCADES = ''\nexport const MIGRATION_010_THE_BOARD_HEARS_THE_DEAL = ''\nexport const MIGRATION_011_A_FUNNEL_IS_BORN_USABLE = ''\nexport const MIGRATION_012_THE_CRM_SAYS_WHAT_HAPPENED = ''\nexport const MIGRATION_013_THE_COMPANY_HOLDS_ITS_PEOPLE = ''\nexport const MIGRATION_014_THE_SECOND_FORM_IS_THE_SAME_PERSON = ''\nexport const MIGRATION_015_THE_FAMILY_OWNS_MORE_THAN_ONE_HOUSE = ''\nexport const MIGRATION_016_THE_STRANGER_ONLY_EDITS_WHAT_IT_MADE = ''\nexport const MIGRATION_017_TWO_FORMS_ONE_PERSON_AND_THE_INTEREST_ADDS_UP = ''\nexport const MIGRATION_018_THE_ROTA_SKIPS_WHO_LEFT_AND_THE_SCREEN_SHOWS_WHO_WAITS = ''\nexport const MIGRATION_019_QUEM_AINDA_COMPRA_E_QUEM_SUMIU = ''\nexport const MIGRATION_020_O_STATUS_E_CONSEQUENCIA_DO_QUE_FOI_FEITO = ''\nexport const MIGRATION_021_O_AGENTE_MEXE_NO_CARD = ''\nexport const MIGRATION_022_A_LISTA_DO_FUNIL_PERGUNTA_POR_CIDADE = ''\nexport const MIGRATION_023_O_CONTATO_DIZ_DE_QUE_EMPRESA_ELE_E = ''\nexport const MIGRATION_024_O_NEGOCIO_DIZ_DE_QUE_CASA_ELE_E = ''\nexport const MIGRATION_025_O_CARD_DIZ_QUEM_E_O_VENDEDOR = ''\nexport const MIGRATION_026_A_LEITURA_DO_FUNIL_SAI_DO_LACO = ''\nexport const MIGRATION_027_A_NOTA_DO_NEGOCIO_CHEGA_NA_BUSCA = ''\nexport const MIGRATION_028_O_LEAD_DIZ_QUANTO_VALE_E_POR_QUE = ''\nexport const MIGRATION_029_A_PORTA_DE_SERVICO_FECHA_ATRAS_DE_QUEM_ENTROU_DEPOIS = ''\nexport const MIGRATION_030_A_LISTA_DE_ORCAMENTOS_NAO_VARRE_O_HISTORICO = ''\nexport const MIGRATION_031_O_NOME_DO_CONTATO_ENTRA_NO_CARD = ''\nexport const MIGRATION_032_O_PAINEL_DE_VENDAS_CONTA_NO_BANCO = ''\nexport const MIGRATION_033_O_ENGAJAMENTO_NAO_SOMA_OS_PEDIDOS_DA_PLATAFORMA = ''\nexport const MIGRATION_034_O_GRAFICO_DO_FUNIL_CONTA_A_ETAPA_INTEIRA = ''\nexport const MIGRATION_035_QUEM_ESTA_NO_FUNIL_E_UM_LEAD = ''\nexport const MIGRATION_036_O_FUNIL_DO_V1_ENTRA_NO_LUGAR_DO_FUNIL_DE_FABRICA = ''\nexport const MIGRATION_037_O_NEGOCIO_E_O_ORCAMENTO_ATRAVESSAM_O_HISTORICO_FICA = ''\nexport const MIGRATION_038_CANAL_ORIGEM_E_CAMPANHA_SAO_TRES_PERGUNTAS = ''\nexport const MIGRATION_039_A_BANDEIRA_AGRUPA_O_QUE_A_RAIZ_DO_CNPJ_NAO_VE = ''\nexport const MIGRATION_040_O_CARD_DO_FUNIL_NAO_LE_A_AGENDA_INTEIRA = ''\nexport const MIGRATION_041_O_NOME_NO_CARD_E_DO_NEGOCIO_NAO_DA_AGENDA = ''\nexport const MIGRATION_042_A_ATIVIDADE_DIZ_QUEM_A_FEZ = ''\nexport const MIGRATION_043_A_CADENCIA_PARA_DE_ESPERAR_UM_FATO_QUE_NUNCA_CHEGA = ''\nexport const MIGRATION_044_O_STATUS_NAO_E_UM_ACONTECIMENTO = ''\nexport const MIGRATION_045_CONTATO_FEITO_E_CONTATO_QUE_ALGUEM_FEZ = ''\nexport const MIGRATION_046_A_PASTILHA_DO_CARD_SO_FALA_QUANDO_TEM_O_QUE_DIZER = ''\nexport const MIGRATION_047_O_DONO_DO_LEAD_TEM_UM_LUGAR_SO = ''\nexport const MIGRATION_048_A_EMPRESA_TAMBEM_TEM_UM_ARROBA = ''\nexport const MIGRATION_049_O_ARROBA_CHEGA_ATE_A_LISTA = ''\nexport const MIGRATION_050_A_REUNIAO_E_UMA_ESPECIE_DECLARADA = ''\nexport const MIGRATION_051_O_CRACHA_E_O_TELEFONE_RECUSADO_APARECEM = ''\nexport const MIGRATION_052_O_NEGOCIO_DIZ_DE_QUE_CASA_ELE_E = ''\nexport const MIGRATION_053_A_ATIVIDADE_DIZ_DE_QUEM_ELA_E = ''\nexport const MIGRATION_054_A_LISTA_DE_LEADS_PERGUNTA_POR_CIDADE = ''\nexport const MIGRATION_055_A_CESTA_DO_INTERESSE_TEM_ONDE_MORAR = ''\nexport const MIGRATION_056_O_INTERESSE_ENTRA_PELO_AGENDAMENTO = ''\nexport const MIGRATION_057_O_NEGOCIO_E_DO_GRUPO_NAO_DO_CNPJ = ''\nexport const MIGRATION_058_O_CARD_DIZ_O_NOME_DO_GRUPO = ''\nexport const MIGRATION_059_A_EMPRESA_MOSTRA_O_INSTAGRAM_QUE_ELA_GUARDA = ''\nexport const MIGRATION_060_O_FUNIL_SABE_DE_QUEM_ELE_E = ''\nexport const MIGRATION_061_A_CONVERSAO_RESPEITA_O_FILTRO_DO_QUADRO = ''\nexport const MIGRATION_062_THE_WHOLE_CRM_SAYS_WHICH_UNIT_IT_IS = ''\nexport const MIGRATION_063_THE_ROTA_ENGINE_IS_SERVER_ONLY = ''\nexport const MIGRATION_064_SEGMENTS_REACH_THE_DEAL = ''\nexport const MIGRATION_065_A_DEAL_HAS_CONTACT_ROUTES = ''\nexport const MIGRATION_066_A_DRAFT_SEGMENT_SHOWS_WHO_IT_REACHES = ''\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,yCAAA,GAA4C;AAClD,IAAM,+CAAA,GAAkD;AACxD,IAAM,oDAAA,GAAuD;AAC7D,IAAM,8CAAA,GAAiD;AACvD,IAAM,iDAAA,GAAoD;AAC1D,IAAM,wCAAA,GAA2C;AACjD,IAAM,uCAAA,GAA0C;AAChD,IAAM,qCAAA,GAAwC;AAC9C,IAAM,sCAAA,GAAyC;AAC/C,IAAM,qCAAA,GAAwC;AAC9C,IAAM,wCAAA,GAA2C;AACjD,IAAM,0CAAA,GAA6C;AACnD,IAAM,gDAAA,GAAmD;AACzD,IAAM,iDAAA,GAAoD;AAC1D,IAAM,kDAAA,GAAqD;AAC3D,IAAM,2DAAA,GAA8D;AACpE,IAAM,oEAAA,GAAuE;AAC7E,IAAM,4CAAA,GAA+C;AACrD,IAAM,sDAAA,GAAyD;AAC/D,IAAM,mCAAA,GAAsC;AAC5C,IAAM,kDAAA,GAAqD;AAC3D,IAAM,gDAAA,GAAmD;AACzD,IAAM,6CAAA,GAAgD;AACtD,IAAM,0CAAA,GAA6C;AACnD,IAAM,4CAAA,GAA+C;AACrD,IAAM,8CAAA,GAAiD;AACvD,IAAM,8CAAA,GAAiD;AACvD,IAAM,kEAAA,GAAqE;AAC3E,IAAM,yDAAA,GAA4D;AAClE,IAAM,6CAAA,GAAgD;AACtD,IAAM,+CAAA,GAAkD;AACxD,IAAM,6DAAA,GAAgE;AACtE,IAAM,sDAAA,GAAyD;AAC/D,IAAM,0CAAA,GAA6C;AACnD,IAAM,8DAAA,GAAiE;AACvE,IAAM,iEAAA,GAAoE;AAC1E,IAAM,wDAAA,GAA2D;AACjE,IAAM,2DAAA,GAA8D;AACpE,IAAM,qDAAA,GAAwD;AAC9D,IAAM,uDAAA,GAA0D;AAChE,IAAM,wCAAA,GAA2C;AACjD,IAAM,gEAAA,GAAmE;AACzE,IAAM,6CAAA,GAAgD;AACtD,IAAM,oDAAA,GAAuD;AAC7D,IAAM,+DAAA,GAAkE;AACxE,IAAM,4CAAA,GAA+C;AACrD,IAAM,4CAAA,GAA+C;AACrD,IAAM,wCAAA,GAA2C;AACjD,IAAM,+CAAA,GAAkD;AACxD,IAAM,qDAAA,GAAwD;AAC9D,IAAM,6CAAA,GAAgD;AACtD,IAAM,2CAAA,GAA8C;AACpD,IAAM,kDAAA,GAAqD;AAC3D,IAAM,iDAAA,GAAoD;AAC1D,IAAM,gDAAA,GAAmD;AACzD,IAAM,8CAAA,GAAiD;AACvD,IAAM,wCAAA,GAA2C;AACjD,IAAM,yDAAA,GAA4D;AAClE,IAAM,wCAAA,GAA2C;AACjD,IAAM,qDAAA,GAAwD;AAC9D,IAAM,iDAAA,GAAoD;AAC1D,IAAM,4CAAA,GAA+C;AACrD,IAAM,qCAAA,GAAwC;AAC9C,IAAM,uCAAA,GAA0C;AAChD,IAAM,kDAAA,GAAqD;AAC3D,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_DE_ONDE_VEIO_E_QUEM_INDICOU = ''\nexport const MIGRATION_002_A_PERGUNTA_QUE_O_CLIENTE_RESPONDE = ''\nexport const MIGRATION_003_O_CLIENTE_RESPONDE_NO_PROPRIO_TELEFONE = ''\nexport const MIGRATION_004_UM_RECORTE_DE_GENTE_QUE_TEM_NOME = ''\nexport const MIGRATION_005_A_ETAPA_GANHA_UM_CODIGO_E_UM_COMECO = ''\nexport const MIGRATION_006_A_ESCADA_DO_RELACIONAMENTO = ''\nexport const MIGRATION_008_A_REGUA_DA_REDE_E_PUBLICA = ''\nexport const MIGRATION_009_THE_LEAD_OFFER_CASCADES = ''\nexport const MIGRATION_010_THE_BOARD_HEARS_THE_DEAL = ''\nexport const MIGRATION_011_A_FUNNEL_IS_BORN_USABLE = ''\nexport const MIGRATION_012_THE_CRM_SAYS_WHAT_HAPPENED = ''\nexport const MIGRATION_013_THE_COMPANY_HOLDS_ITS_PEOPLE = ''\nexport const MIGRATION_014_THE_SECOND_FORM_IS_THE_SAME_PERSON = ''\nexport const MIGRATION_015_THE_FAMILY_OWNS_MORE_THAN_ONE_HOUSE = ''\nexport const MIGRATION_016_THE_STRANGER_ONLY_EDITS_WHAT_IT_MADE = ''\nexport const MIGRATION_017_TWO_FORMS_ONE_PERSON_AND_THE_INTEREST_ADDS_UP = ''\nexport const MIGRATION_018_THE_ROTA_SKIPS_WHO_LEFT_AND_THE_SCREEN_SHOWS_WHO_WAITS = ''\nexport const MIGRATION_019_QUEM_AINDA_COMPRA_E_QUEM_SUMIU = ''\nexport const MIGRATION_020_O_STATUS_E_CONSEQUENCIA_DO_QUE_FOI_FEITO = ''\nexport const MIGRATION_021_O_AGENTE_MEXE_NO_CARD = ''\nexport const MIGRATION_022_A_LISTA_DO_FUNIL_PERGUNTA_POR_CIDADE = ''\nexport const MIGRATION_023_O_CONTATO_DIZ_DE_QUE_EMPRESA_ELE_E = ''\nexport const MIGRATION_024_O_NEGOCIO_DIZ_DE_QUE_CASA_ELE_E = ''\nexport const MIGRATION_025_O_CARD_DIZ_QUEM_E_O_VENDEDOR = ''\nexport const MIGRATION_026_A_LEITURA_DO_FUNIL_SAI_DO_LACO = ''\nexport const MIGRATION_027_A_NOTA_DO_NEGOCIO_CHEGA_NA_BUSCA = ''\nexport const MIGRATION_028_O_LEAD_DIZ_QUANTO_VALE_E_POR_QUE = ''\nexport const MIGRATION_029_A_PORTA_DE_SERVICO_FECHA_ATRAS_DE_QUEM_ENTROU_DEPOIS = ''\nexport const MIGRATION_030_A_LISTA_DE_ORCAMENTOS_NAO_VARRE_O_HISTORICO = ''\nexport const MIGRATION_031_O_NOME_DO_CONTATO_ENTRA_NO_CARD = ''\nexport const MIGRATION_032_O_PAINEL_DE_VENDAS_CONTA_NO_BANCO = ''\nexport const MIGRATION_033_O_ENGAJAMENTO_NAO_SOMA_OS_PEDIDOS_DA_PLATAFORMA = ''\nexport const MIGRATION_034_O_GRAFICO_DO_FUNIL_CONTA_A_ETAPA_INTEIRA = ''\nexport const MIGRATION_035_QUEM_ESTA_NO_FUNIL_E_UM_LEAD = ''\nexport const MIGRATION_036_O_FUNIL_DO_V1_ENTRA_NO_LUGAR_DO_FUNIL_DE_FABRICA = ''\nexport const MIGRATION_037_O_NEGOCIO_E_O_ORCAMENTO_ATRAVESSAM_O_HISTORICO_FICA = ''\nexport const MIGRATION_038_CANAL_ORIGEM_E_CAMPANHA_SAO_TRES_PERGUNTAS = ''\nexport const MIGRATION_039_A_BANDEIRA_AGRUPA_O_QUE_A_RAIZ_DO_CNPJ_NAO_VE = ''\nexport const MIGRATION_040_O_CARD_DO_FUNIL_NAO_LE_A_AGENDA_INTEIRA = ''\nexport const MIGRATION_041_O_NOME_NO_CARD_E_DO_NEGOCIO_NAO_DA_AGENDA = ''\nexport const MIGRATION_042_A_ATIVIDADE_DIZ_QUEM_A_FEZ = ''\nexport const MIGRATION_043_A_CADENCIA_PARA_DE_ESPERAR_UM_FATO_QUE_NUNCA_CHEGA = ''\nexport const MIGRATION_044_O_STATUS_NAO_E_UM_ACONTECIMENTO = ''\nexport const MIGRATION_045_CONTATO_FEITO_E_CONTATO_QUE_ALGUEM_FEZ = ''\nexport const MIGRATION_046_A_PASTILHA_DO_CARD_SO_FALA_QUANDO_TEM_O_QUE_DIZER = ''\nexport const MIGRATION_047_O_DONO_DO_LEAD_TEM_UM_LUGAR_SO = ''\nexport const MIGRATION_048_A_EMPRESA_TAMBEM_TEM_UM_ARROBA = ''\nexport const MIGRATION_049_O_ARROBA_CHEGA_ATE_A_LISTA = ''\nexport const MIGRATION_050_A_REUNIAO_E_UMA_ESPECIE_DECLARADA = ''\nexport const MIGRATION_051_O_CRACHA_E_O_TELEFONE_RECUSADO_APARECEM = ''\nexport const MIGRATION_052_O_NEGOCIO_DIZ_DE_QUE_CASA_ELE_E = ''\nexport const MIGRATION_053_A_ATIVIDADE_DIZ_DE_QUEM_ELA_E = ''\nexport const MIGRATION_054_A_LISTA_DE_LEADS_PERGUNTA_POR_CIDADE = ''\nexport const MIGRATION_055_A_CESTA_DO_INTERESSE_TEM_ONDE_MORAR = ''\nexport const MIGRATION_056_O_INTERESSE_ENTRA_PELO_AGENDAMENTO = ''\nexport const MIGRATION_057_O_NEGOCIO_E_DO_GRUPO_NAO_DO_CNPJ = ''\nexport const MIGRATION_058_O_CARD_DIZ_O_NOME_DO_GRUPO = ''\nexport const MIGRATION_059_A_EMPRESA_MOSTRA_O_INSTAGRAM_QUE_ELA_GUARDA = ''\nexport const MIGRATION_060_O_FUNIL_SABE_DE_QUEM_ELE_E = ''\nexport const MIGRATION_061_A_CONVERSAO_RESPEITA_O_FILTRO_DO_QUADRO = ''\nexport const MIGRATION_062_THE_WHOLE_CRM_SAYS_WHICH_UNIT_IT_IS = ''\nexport const MIGRATION_063_THE_ROTA_ENGINE_IS_SERVER_ONLY = ''\nexport const MIGRATION_064_SEGMENTS_REACH_THE_DEAL = ''\nexport const MIGRATION_065_A_DEAL_HAS_CONTACT_ROUTES = ''\nexport const MIGRATION_066_A_DRAFT_SEGMENT_SHOWS_WHO_IT_REACHES = ''\nexport const MIGRATION_067_PARKED_STAGES_AND_HONEST_NUMBERS = ''\nexport const MIGRATIONS: Array<{ id: string; sql: string }> = []\n"]}
@@ -14489,6 +14489,376 @@ END $function$;
14489
14489
  REVOKE ALL ON FUNCTION public.crm_segment_preview_rows(text, jsonb, uuid, integer) FROM PUBLIC, anon;
14490
14490
  GRANT EXECUTE ON FUNCTION public.crm_segment_preview_rows(text, jsonb, uuid, integer) TO authenticated, service_role;
14491
14491
  `;
14492
+ var MIGRATION_067_PARKED_STAGES_AND_HONEST_NUMBERS = `-- 067_parked_stages_and_honest_numbers.sql
14493
+ --
14494
+ -- Three corrections to how the CRM counts, and two panels that were "em breve".
14495
+ --
14496
+ -- 1. PARKED STAGES. "Contato futuro" and "Lista de espera" are not steps of
14497
+ -- the funnel: a deal there is waiting, not progressing. They inflated the
14498
+ -- conversion view (a stage after Ganho with 8 deals) and every pipeline
14499
+ -- total. A stage can now say it is parked; funnel, pipeline and rates skip
14500
+ -- it. Backfilled by code for the two stages every funnel here uses.
14501
+ --
14502
+ -- 2. CONVERSION = A WON DEAL. The KPI read "lead para neg\xF3cio" (deals \xF7 leads),
14503
+ -- which is meaningless where every lead gets a deal on arrival \u2014 it showed
14504
+ -- 101%. Conversion is now won \xF7 deals that entered the flow (not parked, not
14505
+ -- archived); win rate is won \xF7 closed (won + lost); the sales cycle is the
14506
+ -- average days from a deal's creation to its win.
14507
+ --
14508
+ -- 3. The two panels: \`crm_operational_panel\` (the seller's day: overdue and
14509
+ -- today's tasks, deals with no contact yet, stalled deals, conversations
14510
+ -- waiting on us) and \`crm_maturity_panel\` (is the CRM being used: deals with
14511
+ -- no owner / company / contact, contacts with no phone, activity logged per
14512
+ -- seller, messages that go through the platform).
14513
+
14514
+ ALTER TABLE public.plg_crm_pipeline_stages
14515
+ ADD COLUMN IF NOT EXISTS is_parked boolean NOT NULL DEFAULT false;
14516
+
14517
+ COMMENT ON COLUMN public.plg_crm_pipeline_stages.is_parked IS
14518
+ 'A waiting stage (Contato futuro, Lista de espera): outside the funnel, the conversion rate and the pipeline totals (067).';
14519
+
14520
+ UPDATE public.plg_crm_pipeline_stages
14521
+ SET is_parked = true
14522
+ WHERE code IN ('contato-futuro', 'lista-de-espera') AND NOT is_parked;
14523
+
14524
+ -- \u2500\u2500 the summary, with the numbers that mean something \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
14525
+ --
14526
+ -- A NEW function and not a new \`crm_summary\`: changing its return type made
14527
+ -- the replay of 032 (which creates the old shape) fail. \`crm_summary\` stays
14528
+ -- exactly as 032 left it \u2014 restored here, because an earlier draft of this
14529
+ -- migration was applied with the wider shape \u2014 and \`crm_flow_summary\` carries
14530
+ -- the same columns plus the flow-aware ones.
14531
+ DROP FUNCTION IF EXISTS public.crm_summary();
14532
+ create or replace function public.crm_summary()
14533
+ returns table (
14534
+ total_leads bigint,
14535
+ new_leads_this_month bigint,
14536
+ total_deals bigint,
14537
+ open_deals_value numeric,
14538
+ won_deals_this_month bigint,
14539
+ won_deals_value_this_month numeric,
14540
+ won_deals bigint,
14541
+ won_deals_value numeric,
14542
+ pending_activities bigint,
14543
+ overdue_activities bigint
14544
+ )
14545
+ language plpgsql
14546
+ stable
14547
+ security definer
14548
+ set search_path = public, app, pg_catalog
14549
+ as $$
14550
+ declare
14551
+ v_tenant uuid := app.current_tenant_id();
14552
+ v_foco uuid := nullif(app.current_unit_id(), '00000000-0000-0000-0000-000000000000'::uuid);
14553
+ v_negado boolean := app.current_unit_id() = '00000000-0000-0000-0000-000000000000'::uuid;
14554
+ v_unidades uuid[];
14555
+ v_sem_unidade boolean;
14556
+ v_dono boolean;
14557
+ v_uid uuid := auth.uid();
14558
+ v_mes date := date_trunc('month', now())::date;
14559
+ v_hoje date := now()::date;
14560
+ begin
14561
+ -- Sem tenant, ou com unidade pedida que o usu\xE1rio n\xE3o tem: a pol\xEDtica
14562
+ -- devolveria vazio, e aqui tamb\xE9m. Nunca cair para "a rede inteira".
14563
+ if v_tenant is null or v_negado then
14564
+ return query select 0::bigint, 0::bigint, 0::bigint, 0::numeric,
14565
+ 0::bigint, 0::numeric, 0::bigint, 0::numeric,
14566
+ 0::bigint, 0::bigint;
14567
+ return;
14568
+ end if;
14569
+
14570
+ select coalesce(array_agg(a.unit_id), '{}'::uuid[])
14571
+ into v_unidades
14572
+ from app.user_unit_access a
14573
+ where a.tenant_id = v_tenant
14574
+ and a.user_id = v_uid
14575
+ and (v_foco is null or a.unit_id = v_foco)
14576
+ and app.has_permission('crm.pipeline.read', a.unit_id);
14577
+
14578
+ -- Linha sem unidade \xE9 da rede: a pol\xEDtica a mostra a quem tem a permiss\xE3o no
14579
+ -- n\xEDvel do tenant. Com uma unidade em foco ela continua aparecendo \u2014 \xE9 o que
14580
+ -- a pol\xEDtica diz, e \xE9 por isso que os R$ 520.072,00 dos 1.599 neg\xF3cios sem
14581
+ -- unidade aparecem em toda unidade. Assim \xE9 no V1 tamb\xE9m: l\xE1 s\xE3o 1.600
14582
+ -- oportunidades sem \`unit_id\`.
14583
+ v_sem_unidade := app.has_permission('crm.pipeline.read', null::uuid);
14584
+ v_dono := app.owner_scoped('crm.deal');
14585
+
14586
+ return query
14587
+ with negocios as (
14588
+ select d.status, d.value, d.won_at, d.updated_at
14589
+ from public.plg_crm_deals d
14590
+ where d.tenant_id = v_tenant
14591
+ and ( (d.unit_id is null and v_sem_unidade)
14592
+ or (d.unit_id = any (v_unidades)))
14593
+ and (not v_dono or d.owner_id is null or d.owner_id = v_uid)
14594
+ ),
14595
+ pessoas as (
14596
+ select count(*) filter (where p.kind = 'lead') as leads,
14597
+ count(*) filter (where p.kind = 'lead' and p.created_at >= v_mes) as leads_mes
14598
+ from public.people p
14599
+ where p.tenant_id = v_tenant
14600
+ and (p.unit_id is null or p.unit_id = any (v_unidades))
14601
+ ),
14602
+ tarefas as (
14603
+ select count(*) filter (where a.completed_at is null) as pendentes,
14604
+ count(*) filter (where a.completed_at is null and a.due_date < v_hoje) as atrasadas
14605
+ from public.plg_crm_activities a
14606
+ where a.tenant_id = v_tenant
14607
+ )
14608
+ select pessoas.leads,
14609
+ pessoas.leads_mes,
14610
+ (select count(*) from negocios),
14611
+ (select coalesce(sum(value), 0) from negocios where status = 'open'),
14612
+ (select count(*) from negocios where status = 'won' and coalesce(won_at, updated_at) >= v_mes),
14613
+ (select coalesce(sum(value), 0) from negocios where status = 'won' and coalesce(won_at, updated_at) >= v_mes),
14614
+ (select count(*) from negocios where status = 'won'),
14615
+ (select coalesce(sum(value), 0) from negocios where status = 'won'),
14616
+ tarefas.pendentes,
14617
+ tarefas.atrasadas
14618
+ from pessoas, tarefas;
14619
+ end $$;
14620
+
14621
+ revoke all on function public.crm_summary() from public;
14622
+ grant execute on function public.crm_summary() to authenticated, service_role;
14623
+
14624
+ DROP FUNCTION IF EXISTS public.crm_flow_summary();
14625
+ CREATE FUNCTION public.crm_flow_summary()
14626
+ RETURNS TABLE(
14627
+ total_leads bigint, new_leads_this_month bigint, total_deals bigint, open_deals_value numeric,
14628
+ won_deals_this_month bigint, won_deals_value_this_month numeric, won_deals bigint, won_deals_value numeric,
14629
+ pending_activities bigint, overdue_activities bigint,
14630
+ entered_deals bigint, open_deals bigint, parked_deals bigint, lost_deals bigint, avg_cycle_days numeric
14631
+ )
14632
+ LANGUAGE plpgsql
14633
+ STABLE SECURITY DEFINER
14634
+ SET search_path TO 'public', 'app', 'pg_catalog'
14635
+ AS $function$
14636
+ declare
14637
+ v_tenant uuid := app.current_tenant_id();
14638
+ v_foco uuid := nullif(app.current_unit_id(), '00000000-0000-0000-0000-000000000000'::uuid);
14639
+ v_negado boolean := app.current_unit_id() = '00000000-0000-0000-0000-000000000000'::uuid;
14640
+ v_unidades uuid[];
14641
+ v_sem_unidade boolean;
14642
+ v_dono boolean;
14643
+ v_uid uuid := auth.uid();
14644
+ v_mes date := date_trunc('month', now())::date;
14645
+ v_hoje date := now()::date;
14646
+ begin
14647
+ if v_tenant is null or v_negado then
14648
+ return query select 0::bigint, 0::bigint, 0::bigint, 0::numeric, 0::bigint, 0::numeric, 0::bigint, 0::numeric,
14649
+ 0::bigint, 0::bigint, 0::bigint, 0::bigint, 0::bigint, 0::bigint, null::numeric;
14650
+ return;
14651
+ end if;
14652
+
14653
+ select coalesce(array_agg(a.unit_id), '{}'::uuid[])
14654
+ into v_unidades
14655
+ from app.user_unit_access a
14656
+ where a.tenant_id = v_tenant
14657
+ and a.user_id = v_uid
14658
+ and (v_foco is null or a.unit_id = v_foco)
14659
+ and app.has_permission('crm.pipeline.read', a.unit_id);
14660
+ v_sem_unidade := app.has_permission('crm.pipeline.read', null::uuid);
14661
+ v_dono := app.owner_scoped('crm.deal');
14662
+
14663
+ return query
14664
+ with negocios as (
14665
+ select d.status, d.value, d.won_at, d.updated_at, d.created_at,
14666
+ coalesce(st.is_parked, false) as parked
14667
+ from public.plg_crm_deals d
14668
+ left join public.plg_crm_pipeline_stages st on st.id = d.stage_id
14669
+ where d.tenant_id = v_tenant
14670
+ and ( (d.unit_id is null and v_sem_unidade)
14671
+ or (d.unit_id = any (v_unidades)))
14672
+ and (not v_dono or d.owner_id is null or d.owner_id = v_uid)
14673
+ ),
14674
+ pessoas as (
14675
+ select count(*) filter (where p.kind = 'lead') as leads,
14676
+ count(*) filter (where p.kind = 'lead' and p.created_at >= v_mes) as leads_mes
14677
+ from public.people p
14678
+ where p.tenant_id = v_tenant
14679
+ and (p.unit_id is null or p.unit_id = any (v_unidades))
14680
+ ),
14681
+ tarefas as (
14682
+ select count(*) filter (where a.completed_at is null) as pendentes,
14683
+ count(*) filter (where a.completed_at is null and a.due_date < v_hoje) as atrasadas
14684
+ from public.plg_crm_activities a
14685
+ where a.tenant_id = v_tenant
14686
+ )
14687
+ select pessoas.leads,
14688
+ pessoas.leads_mes,
14689
+ (select count(*) from negocios where status <> 'archived'),
14690
+ (select coalesce(sum(value), 0) from negocios where status = 'open' and not parked),
14691
+ (select count(*) from negocios where status = 'won' and coalesce(won_at, updated_at) >= v_mes),
14692
+ (select coalesce(sum(value), 0) from negocios where status = 'won' and coalesce(won_at, updated_at) >= v_mes),
14693
+ (select count(*) from negocios where status = 'won'),
14694
+ (select coalesce(sum(value), 0) from negocios where status = 'won'),
14695
+ tarefas.pendentes,
14696
+ tarefas.atrasadas,
14697
+ (select count(*) from negocios where status <> 'archived' and not (status = 'open' and parked)),
14698
+ (select count(*) from negocios where status = 'open' and not parked),
14699
+ (select count(*) from negocios where status = 'open' and parked),
14700
+ (select count(*) from negocios where status = 'lost'),
14701
+ (select round(avg(extract(epoch from (coalesce(won_at, updated_at) - created_at)) / 86400)::numeric, 1)
14702
+ from negocios where status = 'won')
14703
+ from pessoas, tarefas;
14704
+ end $function$;
14705
+
14706
+ REVOKE ALL ON FUNCTION public.crm_flow_summary() FROM PUBLIC, anon;
14707
+ GRANT EXECUTE ON FUNCTION public.crm_flow_summary() TO authenticated, service_role;
14708
+
14709
+ -- \u2500\u2500 the seller's day \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
14710
+ CREATE OR REPLACE FUNCTION public.crm_operational_panel(p_stalled_days integer DEFAULT 14)
14711
+ RETURNS jsonb
14712
+ LANGUAGE plpgsql
14713
+ STABLE SECURITY DEFINER
14714
+ SET search_path TO 'public', 'app', 'pg_catalog'
14715
+ AS $function$
14716
+ declare
14717
+ v_tenant uuid := app.current_tenant_id();
14718
+ v_foco uuid := nullif(app.current_unit_id(), '00000000-0000-0000-0000-000000000000'::uuid);
14719
+ v_out jsonb;
14720
+ begin
14721
+ if v_tenant is null then raise exception 'crm_operational_panel: sem tenant na sess\xE3o' using errcode = '42501'; end if;
14722
+ if not app.has_permission('sales.read', null::uuid) then raise exception 'crm_operational_panel: exige sales.read' using errcode = '42501'; end if;
14723
+
14724
+ with deals as (
14725
+ select d.id, d.assigned_to_id as owner, d.created_at, d.updated_at, d.stage_id, st.name as stage, st."order" as stage_order
14726
+ from public.plg_crm_deals d
14727
+ join public.plg_crm_pipeline_stages st on st.id = d.stage_id
14728
+ where d.tenant_id = v_tenant and d.status = 'open' and not st.is_parked and not st.is_won and not st.is_lost
14729
+ and (v_foco is null or d.unit_id is null or d.unit_id = v_foco)
14730
+ ),
14731
+ contacted as (
14732
+ select distinct a.deal_id from public.plg_crm_activities a
14733
+ where a.tenant_id = v_tenant and a.deal_id is not null
14734
+ and a.activity_type in ('whatsapp', 'call', 'email', 'meeting', 'visit', 'note')
14735
+ ),
14736
+ per_deal as (
14737
+ select d.*,
14738
+ (d.updated_at < now() - make_interval(days => p_stalled_days)) as stalled,
14739
+ (c.deal_id is null) as uncontacted
14740
+ from deals d left join contacted c on c.deal_id = d.id
14741
+ ),
14742
+ tasks as (
14743
+ select a.assigned_to_id as owner,
14744
+ count(*) filter (where a.due_date < current_date) as overdue,
14745
+ count(*) filter (where a.due_date = current_date) as today
14746
+ from public.plg_crm_activities a
14747
+ where a.tenant_id = v_tenant and a.completed_at is null and a.activity_type = 'task'
14748
+ group by 1
14749
+ ),
14750
+ waiting as (
14751
+ select c.lead_owner_id as owner, count(*) as n
14752
+ from public.v_conversations c
14753
+ where c.tenant_id = v_tenant and c.status = 'open' and c.last_message_direction = 'inbound'
14754
+ and not (c.acknowledged_at is not null and c.acknowledged_at >= c.last_message_at)
14755
+ group by 1
14756
+ ),
14757
+ owners as (
14758
+ select owner::text as owner from per_deal union select owner::text from tasks union select owner::text from waiting
14759
+ ),
14760
+ team as (
14761
+ select m.user_id::text as user_id, p.name
14762
+ from public.v_authz_memberships m join public.people p on p.id = m.person_id
14763
+ where m.tenant_id = v_tenant
14764
+ )
14765
+ select jsonb_build_object(
14766
+ 'totals', jsonb_build_object(
14767
+ 'open_deals', (select count(*) from per_deal),
14768
+ 'stalled', (select count(*) from per_deal where stalled),
14769
+ 'uncontacted', (select count(*) from per_deal where uncontacted),
14770
+ 'overdue_tasks', (select coalesce(sum(overdue), 0) from tasks),
14771
+ 'today_tasks', (select coalesce(sum(today), 0) from tasks),
14772
+ 'waiting_conversations', (select coalesce(sum(n), 0) from waiting)
14773
+ ),
14774
+ 'by_owner', coalesce((
14775
+ select jsonb_agg(jsonb_build_object(
14776
+ 'owner_id', o.owner,
14777
+ 'name', coalesce((select t.name from team t where t.user_id = o.owner limit 1), case when o.owner is null then 'Sem dono' else 'Sem nome' end),
14778
+ 'open_deals', (select count(*) from per_deal d where d.owner::text is not distinct from o.owner),
14779
+ 'stalled', (select count(*) from per_deal d where d.owner::text is not distinct from o.owner and d.stalled),
14780
+ 'uncontacted', (select count(*) from per_deal d where d.owner::text is not distinct from o.owner and d.uncontacted),
14781
+ 'overdue_tasks', coalesce((select t.overdue from tasks t where t.owner::text is not distinct from o.owner), 0),
14782
+ 'today_tasks', coalesce((select t.today from tasks t where t.owner::text is not distinct from o.owner), 0),
14783
+ 'waiting_conversations', coalesce((select w.n from waiting w where w.owner::text is not distinct from o.owner), 0)
14784
+ ) order by o.owner nulls last)
14785
+ from owners o), '[]'::jsonb),
14786
+ 'by_stage', coalesce((
14787
+ select jsonb_agg(jsonb_build_object('stage', s.stage, 'open', s.open, 'stalled', s.stalled, 'avg_days', s.avg_days) order by s.stage_order)
14788
+ from (select stage, stage_order, count(*) as open, count(*) filter (where stalled) as stalled,
14789
+ round(avg(extract(epoch from (now() - updated_at)) / 86400)::numeric, 1) as avg_days
14790
+ from per_deal group by stage, stage_order) s), '[]'::jsonb)
14791
+ ) into v_out;
14792
+ return v_out;
14793
+ end $function$;
14794
+
14795
+ REVOKE ALL ON FUNCTION public.crm_operational_panel(integer) FROM PUBLIC, anon;
14796
+ GRANT EXECUTE ON FUNCTION public.crm_operational_panel(integer) TO authenticated, service_role;
14797
+
14798
+ -- \u2500\u2500 is the CRM being used \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
14799
+ CREATE OR REPLACE FUNCTION public.crm_maturity_panel()
14800
+ RETURNS jsonb
14801
+ LANGUAGE plpgsql
14802
+ STABLE SECURITY DEFINER
14803
+ SET search_path TO 'public', 'app', 'pg_catalog'
14804
+ AS $function$
14805
+ declare
14806
+ v_tenant uuid := app.current_tenant_id();
14807
+ v_foco uuid := nullif(app.current_unit_id(), '00000000-0000-0000-0000-000000000000'::uuid);
14808
+ v_out jsonb;
14809
+ begin
14810
+ if v_tenant is null then raise exception 'crm_maturity_panel: sem tenant na sess\xE3o' using errcode = '42501'; end if;
14811
+ if not app.has_permission('sales.read', null::uuid) then raise exception 'crm_maturity_panel: exige sales.read' using errcode = '42501'; end if;
14812
+
14813
+ with deals as (
14814
+ select d.* from public.plg_crm_deals d
14815
+ where d.tenant_id = v_tenant and d.status in ('open', 'won', 'lost')
14816
+ and (v_foco is null or d.unit_id is null or d.unit_id = v_foco)
14817
+ ),
14818
+ team as (
14819
+ select m.user_id, p.name from public.v_authz_memberships m join public.people p on p.id = m.person_id
14820
+ where m.tenant_id = v_tenant and m.active
14821
+ ),
14822
+ acts as (
14823
+ select a.created_by, a.activity_type, a.created_at from public.plg_crm_activities a
14824
+ where a.tenant_id = v_tenant and a.created_at > now() - interval '30 days'
14825
+ and a.activity_type not in ('stage_changed', 'deal_created', 'lead_created', 'deal_archived', 'lead_archived', 'quote_created')
14826
+ ),
14827
+ msgs as (
14828
+ select m.direction, m.sender_kind, m.sender_label, m.author from public.plg_conversation_messages m
14829
+ where m.tenant_id = v_tenant and m.channel = 'whatsapp' and m.at > now() - interval '30 days'
14830
+ )
14831
+ select jsonb_build_object(
14832
+ 'deals', (select count(*) from deals),
14833
+ 'hygiene', jsonb_build_object(
14834
+ 'no_owner', (select count(*) from deals where assigned_to_id is null),
14835
+ 'no_company', (select count(*) from deals where company_id is null),
14836
+ 'no_contact', (select count(*) from deals where contact_id is null),
14837
+ 'no_phone', (select count(*) from deals d left join public.people p on p.id = d.contact_id
14838
+ where coalesce(p.phone, '') = ''
14839
+ and not exists (select 1 from public.plg_crm_person_phones ph where ph.person_id = d.contact_id)),
14840
+ 'stale_30d', (select count(*) from deals where status = 'open' and updated_at < now() - interval '30 days')
14841
+ ),
14842
+ 'activity_by_seller', coalesce((
14843
+ select jsonb_agg(jsonb_build_object(
14844
+ 'user_id', t.user_id, 'name', t.name,
14845
+ 'last_7d', (select count(*) from acts a where a.created_by = t.user_id and a.created_at > now() - interval '7 days'),
14846
+ 'last_30d', (select count(*) from acts a where a.created_by = t.user_id),
14847
+ 'whatsapp_30d', (select count(*) from acts a where a.created_by = t.user_id and a.activity_type = 'whatsapp')
14848
+ ) order by (select count(*) from acts a where a.created_by = t.user_id) desc, t.name) from team t), '[]'::jsonb),
14849
+ 'inbox', jsonb_build_object(
14850
+ 'inbound_30d', (select count(*) from msgs where direction = 'inbound'),
14851
+ 'outbound_platform_30d', (select count(*) from msgs where direction = 'outbound' and coalesce(sender_label, '') <> 'Pelo celular'),
14852
+ 'outbound_phone_30d', (select count(*) from msgs where direction = 'outbound' and sender_label = 'Pelo celular'),
14853
+ 'outbound_campaign_30d', (select count(*) from msgs where direction = 'outbound' and sender_kind = 'automation')
14854
+ )
14855
+ ) into v_out;
14856
+ return v_out;
14857
+ end $function$;
14858
+
14859
+ REVOKE ALL ON FUNCTION public.crm_maturity_panel() FROM PUBLIC, anon;
14860
+ GRANT EXECUTE ON FUNCTION public.crm_maturity_panel() TO authenticated, service_role;
14861
+ `;
14492
14862
  var MIGRATIONS = [
14493
14863
  { id: "000_baseline", sql: MIGRATION_000_BASELINE },
14494
14864
  { id: "001_de_onde_veio_e_quem_indicou", sql: MIGRATION_001_DE_ONDE_VEIO_E_QUEM_INDICOU },
@@ -14555,9 +14925,10 @@ var MIGRATIONS = [
14555
14925
  { id: "063_the_rota_engine_is_server_only", sql: MIGRATION_063_THE_ROTA_ENGINE_IS_SERVER_ONLY },
14556
14926
  { id: "064_segments_reach_the_deal", sql: MIGRATION_064_SEGMENTS_REACH_THE_DEAL },
14557
14927
  { id: "065_a_deal_has_contact_routes", sql: MIGRATION_065_A_DEAL_HAS_CONTACT_ROUTES },
14558
- { id: "066_a_draft_segment_shows_who_it_reaches", sql: MIGRATION_066_A_DRAFT_SEGMENT_SHOWS_WHO_IT_REACHES }
14928
+ { id: "066_a_draft_segment_shows_who_it_reaches", sql: MIGRATION_066_A_DRAFT_SEGMENT_SHOWS_WHO_IT_REACHES },
14929
+ { id: "067_parked_stages_and_honest_numbers", sql: MIGRATION_067_PARKED_STAGES_AND_HONEST_NUMBERS }
14559
14930
  ];
14560
14931
 
14561
- export { MIGRATIONS, MIGRATION_000_BASELINE, MIGRATION_001_DE_ONDE_VEIO_E_QUEM_INDICOU, MIGRATION_002_A_PERGUNTA_QUE_O_CLIENTE_RESPONDE, MIGRATION_003_O_CLIENTE_RESPONDE_NO_PROPRIO_TELEFONE, MIGRATION_004_UM_RECORTE_DE_GENTE_QUE_TEM_NOME, MIGRATION_005_A_ETAPA_GANHA_UM_CODIGO_E_UM_COMECO, MIGRATION_006_A_ESCADA_DO_RELACIONAMENTO, MIGRATION_008_A_REGUA_DA_REDE_E_PUBLICA, MIGRATION_009_THE_LEAD_OFFER_CASCADES, MIGRATION_010_THE_BOARD_HEARS_THE_DEAL, MIGRATION_011_A_FUNNEL_IS_BORN_USABLE, MIGRATION_012_THE_CRM_SAYS_WHAT_HAPPENED, MIGRATION_013_THE_COMPANY_HOLDS_ITS_PEOPLE, MIGRATION_014_THE_SECOND_FORM_IS_THE_SAME_PERSON, MIGRATION_015_THE_FAMILY_OWNS_MORE_THAN_ONE_HOUSE, MIGRATION_016_THE_STRANGER_ONLY_EDITS_WHAT_IT_MADE, MIGRATION_017_TWO_FORMS_ONE_PERSON_AND_THE_INTEREST_ADDS_UP, MIGRATION_018_THE_ROTA_SKIPS_WHO_LEFT_AND_THE_SCREEN_SHOWS_WHO_WAITS, MIGRATION_019_QUEM_AINDA_COMPRA_E_QUEM_SUMIU, MIGRATION_020_O_STATUS_E_CONSEQUENCIA_DO_QUE_FOI_FEITO, MIGRATION_021_O_AGENTE_MEXE_NO_CARD, MIGRATION_022_A_LISTA_DO_FUNIL_PERGUNTA_POR_CIDADE, MIGRATION_023_O_CONTATO_DIZ_DE_QUE_EMPRESA_ELE_E, MIGRATION_024_O_NEGOCIO_DIZ_DE_QUE_CASA_ELE_E, MIGRATION_025_O_CARD_DIZ_QUEM_E_O_VENDEDOR, MIGRATION_026_A_LEITURA_DO_FUNIL_SAI_DO_LACO, MIGRATION_027_A_NOTA_DO_NEGOCIO_CHEGA_NA_BUSCA, MIGRATION_028_O_LEAD_DIZ_QUANTO_VALE_E_POR_QUE, MIGRATION_029_A_PORTA_DE_SERVICO_FECHA_ATRAS_DE_QUEM_ENTROU_DEPOIS, MIGRATION_030_A_LISTA_DE_ORCAMENTOS_NAO_VARRE_O_HISTORICO, MIGRATION_031_O_NOME_DO_CONTATO_ENTRA_NO_CARD, MIGRATION_032_O_PAINEL_DE_VENDAS_CONTA_NO_BANCO, MIGRATION_033_O_ENGAJAMENTO_NAO_SOMA_OS_PEDIDOS_DA_PLATAFORMA, MIGRATION_034_O_GRAFICO_DO_FUNIL_CONTA_A_ETAPA_INTEIRA, MIGRATION_035_QUEM_ESTA_NO_FUNIL_E_UM_LEAD, MIGRATION_036_O_FUNIL_DO_V1_ENTRA_NO_LUGAR_DO_FUNIL_DE_FABRICA, MIGRATION_037_O_NEGOCIO_E_O_ORCAMENTO_ATRAVESSAM_O_HISTORICO_FICA, MIGRATION_038_CANAL_ORIGEM_E_CAMPANHA_SAO_TRES_PERGUNTAS, MIGRATION_039_A_BANDEIRA_AGRUPA_O_QUE_A_RAIZ_DO_CNPJ_NAO_VE, MIGRATION_040_O_CARD_DO_FUNIL_NAO_LE_A_AGENDA_INTEIRA, MIGRATION_041_O_NOME_NO_CARD_E_DO_NEGOCIO_NAO_DA_AGENDA, MIGRATION_042_A_ATIVIDADE_DIZ_QUEM_A_FEZ, MIGRATION_043_A_CADENCIA_PARA_DE_ESPERAR_UM_FATO_QUE_NUNCA_CHEGA, MIGRATION_044_O_STATUS_NAO_E_UM_ACONTECIMENTO, MIGRATION_045_CONTATO_FEITO_E_CONTATO_QUE_ALGUEM_FEZ, MIGRATION_046_A_PASTILHA_DO_CARD_SO_FALA_QUANDO_TEM_O_QUE_DIZER, MIGRATION_047_O_DONO_DO_LEAD_TEM_UM_LUGAR_SO, MIGRATION_048_A_EMPRESA_TAMBEM_TEM_UM_ARROBA, MIGRATION_049_O_ARROBA_CHEGA_ATE_A_LISTA, MIGRATION_050_A_REUNIAO_E_UMA_ESPECIE_DECLARADA, MIGRATION_051_O_CRACHA_E_O_TELEFONE_RECUSADO_APARECEM, MIGRATION_052_O_NEGOCIO_DIZ_DE_QUE_CASA_ELE_E, MIGRATION_053_A_ATIVIDADE_DIZ_DE_QUEM_ELA_E, MIGRATION_054_A_LISTA_DE_LEADS_PERGUNTA_POR_CIDADE, MIGRATION_055_A_CESTA_DO_INTERESSE_TEM_ONDE_MORAR, MIGRATION_056_O_INTERESSE_ENTRA_PELO_AGENDAMENTO, MIGRATION_057_O_NEGOCIO_E_DO_GRUPO_NAO_DO_CNPJ, MIGRATION_058_O_CARD_DIZ_O_NOME_DO_GRUPO, MIGRATION_059_A_EMPRESA_MOSTRA_O_INSTAGRAM_QUE_ELA_GUARDA, MIGRATION_060_O_FUNIL_SABE_DE_QUEM_ELE_E, MIGRATION_061_A_CONVERSAO_RESPEITA_O_FILTRO_DO_QUADRO, MIGRATION_062_THE_WHOLE_CRM_SAYS_WHICH_UNIT_IT_IS, MIGRATION_063_THE_ROTA_ENGINE_IS_SERVER_ONLY, MIGRATION_064_SEGMENTS_REACH_THE_DEAL, MIGRATION_065_A_DEAL_HAS_CONTACT_ROUTES, MIGRATION_066_A_DRAFT_SEGMENT_SHOWS_WHO_IT_REACHES };
14932
+ export { MIGRATIONS, MIGRATION_000_BASELINE, MIGRATION_001_DE_ONDE_VEIO_E_QUEM_INDICOU, MIGRATION_002_A_PERGUNTA_QUE_O_CLIENTE_RESPONDE, MIGRATION_003_O_CLIENTE_RESPONDE_NO_PROPRIO_TELEFONE, MIGRATION_004_UM_RECORTE_DE_GENTE_QUE_TEM_NOME, MIGRATION_005_A_ETAPA_GANHA_UM_CODIGO_E_UM_COMECO, MIGRATION_006_A_ESCADA_DO_RELACIONAMENTO, MIGRATION_008_A_REGUA_DA_REDE_E_PUBLICA, MIGRATION_009_THE_LEAD_OFFER_CASCADES, MIGRATION_010_THE_BOARD_HEARS_THE_DEAL, MIGRATION_011_A_FUNNEL_IS_BORN_USABLE, MIGRATION_012_THE_CRM_SAYS_WHAT_HAPPENED, MIGRATION_013_THE_COMPANY_HOLDS_ITS_PEOPLE, MIGRATION_014_THE_SECOND_FORM_IS_THE_SAME_PERSON, MIGRATION_015_THE_FAMILY_OWNS_MORE_THAN_ONE_HOUSE, MIGRATION_016_THE_STRANGER_ONLY_EDITS_WHAT_IT_MADE, MIGRATION_017_TWO_FORMS_ONE_PERSON_AND_THE_INTEREST_ADDS_UP, MIGRATION_018_THE_ROTA_SKIPS_WHO_LEFT_AND_THE_SCREEN_SHOWS_WHO_WAITS, MIGRATION_019_QUEM_AINDA_COMPRA_E_QUEM_SUMIU, MIGRATION_020_O_STATUS_E_CONSEQUENCIA_DO_QUE_FOI_FEITO, MIGRATION_021_O_AGENTE_MEXE_NO_CARD, MIGRATION_022_A_LISTA_DO_FUNIL_PERGUNTA_POR_CIDADE, MIGRATION_023_O_CONTATO_DIZ_DE_QUE_EMPRESA_ELE_E, MIGRATION_024_O_NEGOCIO_DIZ_DE_QUE_CASA_ELE_E, MIGRATION_025_O_CARD_DIZ_QUEM_E_O_VENDEDOR, MIGRATION_026_A_LEITURA_DO_FUNIL_SAI_DO_LACO, MIGRATION_027_A_NOTA_DO_NEGOCIO_CHEGA_NA_BUSCA, MIGRATION_028_O_LEAD_DIZ_QUANTO_VALE_E_POR_QUE, MIGRATION_029_A_PORTA_DE_SERVICO_FECHA_ATRAS_DE_QUEM_ENTROU_DEPOIS, MIGRATION_030_A_LISTA_DE_ORCAMENTOS_NAO_VARRE_O_HISTORICO, MIGRATION_031_O_NOME_DO_CONTATO_ENTRA_NO_CARD, MIGRATION_032_O_PAINEL_DE_VENDAS_CONTA_NO_BANCO, MIGRATION_033_O_ENGAJAMENTO_NAO_SOMA_OS_PEDIDOS_DA_PLATAFORMA, MIGRATION_034_O_GRAFICO_DO_FUNIL_CONTA_A_ETAPA_INTEIRA, MIGRATION_035_QUEM_ESTA_NO_FUNIL_E_UM_LEAD, MIGRATION_036_O_FUNIL_DO_V1_ENTRA_NO_LUGAR_DO_FUNIL_DE_FABRICA, MIGRATION_037_O_NEGOCIO_E_O_ORCAMENTO_ATRAVESSAM_O_HISTORICO_FICA, MIGRATION_038_CANAL_ORIGEM_E_CAMPANHA_SAO_TRES_PERGUNTAS, MIGRATION_039_A_BANDEIRA_AGRUPA_O_QUE_A_RAIZ_DO_CNPJ_NAO_VE, MIGRATION_040_O_CARD_DO_FUNIL_NAO_LE_A_AGENDA_INTEIRA, MIGRATION_041_O_NOME_NO_CARD_E_DO_NEGOCIO_NAO_DA_AGENDA, MIGRATION_042_A_ATIVIDADE_DIZ_QUEM_A_FEZ, MIGRATION_043_A_CADENCIA_PARA_DE_ESPERAR_UM_FATO_QUE_NUNCA_CHEGA, MIGRATION_044_O_STATUS_NAO_E_UM_ACONTECIMENTO, MIGRATION_045_CONTATO_FEITO_E_CONTATO_QUE_ALGUEM_FEZ, MIGRATION_046_A_PASTILHA_DO_CARD_SO_FALA_QUANDO_TEM_O_QUE_DIZER, MIGRATION_047_O_DONO_DO_LEAD_TEM_UM_LUGAR_SO, MIGRATION_048_A_EMPRESA_TAMBEM_TEM_UM_ARROBA, MIGRATION_049_O_ARROBA_CHEGA_ATE_A_LISTA, MIGRATION_050_A_REUNIAO_E_UMA_ESPECIE_DECLARADA, MIGRATION_051_O_CRACHA_E_O_TELEFONE_RECUSADO_APARECEM, MIGRATION_052_O_NEGOCIO_DIZ_DE_QUE_CASA_ELE_E, MIGRATION_053_A_ATIVIDADE_DIZ_DE_QUEM_ELA_E, MIGRATION_054_A_LISTA_DE_LEADS_PERGUNTA_POR_CIDADE, MIGRATION_055_A_CESTA_DO_INTERESSE_TEM_ONDE_MORAR, MIGRATION_056_O_INTERESSE_ENTRA_PELO_AGENDAMENTO, MIGRATION_057_O_NEGOCIO_E_DO_GRUPO_NAO_DO_CNPJ, MIGRATION_058_O_CARD_DIZ_O_NOME_DO_GRUPO, MIGRATION_059_A_EMPRESA_MOSTRA_O_INSTAGRAM_QUE_ELA_GUARDA, MIGRATION_060_O_FUNIL_SABE_DE_QUEM_ELE_E, MIGRATION_061_A_CONVERSAO_RESPEITA_O_FILTRO_DO_QUADRO, MIGRATION_062_THE_WHOLE_CRM_SAYS_WHICH_UNIT_IT_IS, MIGRATION_063_THE_ROTA_ENGINE_IS_SERVER_ONLY, MIGRATION_064_SEGMENTS_REACH_THE_DEAL, MIGRATION_065_A_DEAL_HAS_CONTACT_ROUTES, MIGRATION_066_A_DRAFT_SEGMENT_SHOWS_WHO_IT_REACHES, MIGRATION_067_PARKED_STAGES_AND_HONEST_NUMBERS };
14562
14933
  //# sourceMappingURL=main.js.map
14563
14934
  //# sourceMappingURL=main.js.map