@fayz-ai/plugin-crm 0.17.1 → 0.18.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":"mock.d.ts","sourceRoot":"","sources":["../../src/data/mock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AA2K9C,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE;IAC9C,UAAU,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IACxE,aAAa,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACvE,GAAG,eAAe,CA0pClB"}
1
+ {"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../src/data/mock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AA2K9C,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE;IAC9C,UAAU,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IACxE,aAAa,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACvE,GAAG,eAAe,CAiqClB"}
@@ -1 +1 @@
1
- {"version":3,"file":"supabase.d.ts","sourceRoot":"","sources":["../../src/data/supabase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAwQ9C,wBAAgB,yBAAyB,CAAC,OAAO,CAAC,EAAE;IAClD,gBAAgB,CAAC,EAAE;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAA;IACtF,kFAAkF;IAClF,aAAa,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACvE,GAAG,eAAe,CA2qElB"}
1
+ {"version":3,"file":"supabase.d.ts","sourceRoot":"","sources":["../../src/data/supabase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AA+Q9C,wBAAgB,yBAAyB,CAAC,OAAO,CAAC,EAAE;IAClD,gBAAgB,CAAC,EAAE;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAA;IACtF,kFAAkF;IAClF,aAAa,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACvE,GAAG,eAAe,CAusElB"}
package/dist/index.js CHANGED
@@ -254,7 +254,7 @@ function GroupRow({ g, onOpen, open, members, roll, onEdit, onAdd, onRemove, onD
254
254
  /* @__PURE__ */ jsx("span", { className: "font-medium", children: m.companyName }),
255
255
  m.companyLegalName && m.companyLegalName !== m.companyName && /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: m.companyLegalName }),
256
256
  m.companyDocument && /* @__PURE__ */ jsx("span", { className: "tabular-nums text-muted-foreground", children: m.companyDocument }),
257
- m.source && /* @__PURE__ */ jsx("span", { className: "text-[10px] text-muted-foreground/70", children: m.source === "cnpj_root" ? "pela raiz do CNPJ" : "declarado" }),
257
+ m.source && /* @__PURE__ */ jsx("span", { className: "text-[10px] text-muted-foreground/70", children: m.source === "document_root" ? "pela raiz do CNPJ" : "declarado" }),
258
258
  editing && /* @__PURE__ */ jsx(
259
259
  "button",
260
260
  {
@@ -1180,6 +1180,11 @@ function PipelineView({ onDealClick, onAddLead, onOpenSettings }) {
1180
1180
  const [customTo, setCustomTo] = useState(() => localDate());
1181
1181
  const [selectedTags, setSelectedTags] = useState([]);
1182
1182
  const [search, setSearch] = useState("");
1183
+ const [searchNoBanco, setSearchNoBanco] = useState("");
1184
+ useEffect(() => {
1185
+ const t3 = setTimeout(() => setSearchNoBanco(search.trim()), 300);
1186
+ return () => clearTimeout(t3);
1187
+ }, [search]);
1183
1188
  const [dragOverStageId, setDragOverStageId] = useState(null);
1184
1189
  const [savingDealIds, setSavingDealIds] = useState(/* @__PURE__ */ new Set());
1185
1190
  const [optimisticBoard, setOptimisticBoard] = useState(null);
@@ -1189,8 +1194,13 @@ function PipelineView({ onDealClick, onAddLead, onOpenSettings }) {
1189
1194
  savingRef.current = savingDealIds;
1190
1195
  const boardFilter = useMemo(() => ({
1191
1196
  ...selectedTags.length ? { tags: selectedTags } : {},
1197
+ ...searchNoBanco ? {
1198
+ search: searchNoBanco,
1199
+ // O de-para nome→slug vive aqui porque é aqui que o cadastro está.
1200
+ searchTags: [...tagDefs?.values() ?? []].filter((d) => d.name.toLowerCase().includes(searchNoBanco.toLowerCase())).map((d) => d.slug)
1201
+ } : {},
1192
1202
  ...periodToRange(period, customFrom, customTo)
1193
- }), [selectedTags, period, customFrom, customTo]);
1203
+ }), [selectedTags, searchNoBanco, tagDefs, period, customFrom, customTo]);
1194
1204
  const filterKey = JSON.stringify(boardFilter);
1195
1205
  const availableTags = useMemo(() => [...tagDefs.keys()], [tagDefs]);
1196
1206
  const tenantId = useActiveTenantId();
@@ -9104,6 +9114,13 @@ function createMockCrmProvider(options) {
9104
9114
  const stages = knownStages ?? store.stages.filter((s) => s.pipelineId === pipelineId).sort((a, b) => a.order - b.order);
9105
9115
  const matches2 = (d) => {
9106
9116
  if (filter?.tags?.length && !filter.tags.some((t2) => (d.tags ?? []).includes(t2))) return false;
9117
+ if (filter?.search) {
9118
+ const t2 = filter.search.toLowerCase();
9119
+ const campos = [d.title, d.contactName, d.notes, d.lostReason, d.stageName, d.contactStatusName];
9120
+ const porTexto = campos.some((c) => (c ?? "").toLowerCase().includes(t2));
9121
+ const porTag = filter.searchTags?.some((slug) => (d.tags ?? []).includes(slug)) ?? false;
9122
+ if (!porTexto && !porTag) return false;
9123
+ }
9107
9124
  if (filter?.createdFrom && d.createdAt < filter.createdFrom) return false;
9108
9125
  if (filter?.createdTo && d.createdAt > filter.createdTo) return false;
9109
9126
  return true;
@@ -10239,6 +10256,7 @@ function snakeToCamel(obj) {
10239
10256
  return result;
10240
10257
  }
10241
10258
  var DEALS_POR_ETAPA = 100;
10259
+ var BUSCA_NO_QUADRO = ["title", "contact_name", "notes", "lost_reason", "stage_name", "contact_status_name"];
10242
10260
  async function callBacklog(limit, dryRun) {
10243
10261
  const supabase = getSupabaseClientOptional();
10244
10262
  if (!supabase) throw new Error("Supabase not initialized");
@@ -10531,6 +10549,14 @@ function createSupabaseCrmProvider(options) {
10531
10549
  const montar = async (stageId) => {
10532
10550
  let qb = pub.from("v_deals").select("*", { count: "exact" }).eq("pipeline_id", pipelineId).eq("stage_id", stageId).not("status", "in", "(lost,archived)");
10533
10551
  if (filter?.tags?.length) qb = qb.overlaps("tags", filter.tags);
10552
+ if (filter?.search) {
10553
+ const t2 = filter.search.replace(/[(),]/g, " ").trim();
10554
+ if (t2) {
10555
+ const ramos = BUSCA_NO_QUADRO.map((c) => `${c}.ilike.*${t2}*`);
10556
+ if (filter.searchTags?.length) ramos.push(`tags.ov.{${filter.searchTags.join(",")}}`);
10557
+ qb = qb.or(ramos.join(","));
10558
+ }
10559
+ }
10534
10560
  if (filter?.createdFrom) qb = qb.gte("created_at", filter.createdFrom);
10535
10561
  if (filter?.createdTo) qb = qb.lte("created_at", filter.createdTo);
10536
10562
  const teto = limits?.[stageId] ?? DEALS_POR_ETAPA;
@@ -11988,10 +12014,17 @@ function createSupabaseCrmProvider(options) {
11988
12014
  tenant_id: tenantId,
11989
12015
  group_id: group.id,
11990
12016
  company_id: cid,
11991
- // `cnpj_root` e não `manual`: quem aceitou a proposta confirmou o que
11992
- // a raiz do CNPJ dizia. Guardar a PROCEDÊNCIA é o que deixa alguém,
11993
- // meses depois, saber se aquilo foi conferido ou deduzido.
11994
- source: documentRoot2 ? "cnpj_root" : "manual"
12017
+ // `document_root` e não `manual`: quem aceitou a proposta confirmou o
12018
+ // que a raiz do documento dizia. Guardar a PROCEDÊNCIA é o que deixa
12019
+ // alguém, meses depois, saber se aquilo foi conferido ou deduzido.
12020
+ //
12021
+ // O nome é o do CHECK da coluna (`manual, document_root,
12022
+ // shared_phone, email_domain, import`), não um sinónimo. Estava
12023
+ // `cnpj_root`, que a restrição recusa — e confirmar uma sugestão por
12024
+ // raiz de documento nunca chegou a funcionar: dava
12025
+ // `plg_crm_company_group_members_source_check` na cara de quem
12026
+ // clicava. O banco é quem define este vocabulário.
12027
+ source: documentRoot2 ? "document_root" : "manual"
11995
12028
  }))
11996
12029
  );
11997
12030
  if (e2) throw new Error(e2.message);