@fayz-ai/plugin-crm 0.14.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +13 -11
- package/dist/index.js.map +1 -1
- package/dist/store.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11840,7 +11840,9 @@ function createSupabaseCrmProvider(options) {
|
|
|
11840
11840
|
function entryStage(stages) {
|
|
11841
11841
|
return stages.find((s) => s.isInitial) ?? stages.filter((s) => !s.isWon && !s.isLost).sort((a, b) => a.order - b.order)[0];
|
|
11842
11842
|
}
|
|
11843
|
+
var storeSeq = 0;
|
|
11843
11844
|
function createCrmStore(provider) {
|
|
11845
|
+
const sid = `s${++storeSeq}:`;
|
|
11844
11846
|
let lastActivitiesQuery = {};
|
|
11845
11847
|
let lastLeadsQuery = {};
|
|
11846
11848
|
let lastCompaniesQuery = {};
|
|
@@ -11873,7 +11875,7 @@ function createCrmStore(provider) {
|
|
|
11873
11875
|
companiesLoading: false,
|
|
11874
11876
|
async fetchCompanies(query) {
|
|
11875
11877
|
lastCompaniesQuery = query;
|
|
11876
|
-
return dedup("crm:companies:" + JSON.stringify(query), async () => {
|
|
11878
|
+
return dedup(sid + "crm:companies:" + JSON.stringify(query), async () => {
|
|
11877
11879
|
set({ companiesLoading: true });
|
|
11878
11880
|
const result = await provider.getCompanies(query);
|
|
11879
11881
|
set({ companies: result.data, companiesTotal: result.total, companiesLoading: false });
|
|
@@ -11930,7 +11932,7 @@ function createCrmStore(provider) {
|
|
|
11930
11932
|
async fetchPipelines() {
|
|
11931
11933
|
set({ pipelinesLoading: true });
|
|
11932
11934
|
try {
|
|
11933
|
-
return await dedup("crm:pipelines:" + (getCrmTenantId() ?? getActiveTenantId() ?? "none"), async () => {
|
|
11935
|
+
return await dedup(sid + "crm:pipelines:" + (getCrmTenantId() ?? getActiveTenantId() ?? "none"), async () => {
|
|
11934
11936
|
const pipelines = await provider.getPipelines();
|
|
11935
11937
|
const current = get().activePipelineId;
|
|
11936
11938
|
const active = current && pipelines.some((p) => p.id === current) ? current : (pipelines.find((p) => p.isDefault) ?? pipelines[0])?.id ?? null;
|
|
@@ -11952,7 +11954,7 @@ function createCrmStore(provider) {
|
|
|
11952
11954
|
set({ stages, activePipelineId: pipelineId, dealsByStage: /* @__PURE__ */ new Map() });
|
|
11953
11955
|
},
|
|
11954
11956
|
async fetchTagDefs() {
|
|
11955
|
-
return dedup("crm:tag-defs", async () => {
|
|
11957
|
+
return dedup(sid + "crm:tag-defs", async () => {
|
|
11956
11958
|
try {
|
|
11957
11959
|
const defs = await provider.getTagDefs();
|
|
11958
11960
|
set({ tagDefs: new Map(defs.map((d) => [d.slug, d])) });
|
|
@@ -11961,7 +11963,7 @@ function createCrmStore(provider) {
|
|
|
11961
11963
|
});
|
|
11962
11964
|
},
|
|
11963
11965
|
async fetchLeadSources() {
|
|
11964
|
-
return dedup("crm:lead-sources", async () => {
|
|
11966
|
+
return dedup(sid + "crm:lead-sources", async () => {
|
|
11965
11967
|
try {
|
|
11966
11968
|
set({ leadSources: await provider.getLeadSources() });
|
|
11967
11969
|
} catch {
|
|
@@ -11969,28 +11971,28 @@ function createCrmStore(provider) {
|
|
|
11969
11971
|
});
|
|
11970
11972
|
},
|
|
11971
11973
|
async fetchSummary() {
|
|
11972
|
-
return dedup("crm:summary", async () => {
|
|
11974
|
+
return dedup(sid + "crm:summary", async () => {
|
|
11973
11975
|
set({ summaryLoading: true });
|
|
11974
11976
|
const summary = await provider.getSummary();
|
|
11975
11977
|
set({ summary, summaryLoading: false });
|
|
11976
11978
|
});
|
|
11977
11979
|
},
|
|
11978
11980
|
async fetchFunnel(pipelineId) {
|
|
11979
|
-
return dedup("crm:funnel:" + pipelineId, async () => {
|
|
11981
|
+
return dedup(sid + "crm:funnel:" + pipelineId, async () => {
|
|
11980
11982
|
const funnel = await provider.getFunnel(pipelineId);
|
|
11981
11983
|
set({ funnel });
|
|
11982
11984
|
});
|
|
11983
11985
|
},
|
|
11984
11986
|
async fetchLeads(query) {
|
|
11985
11987
|
lastLeadsQuery = query;
|
|
11986
|
-
return dedup("crm:leads:" + JSON.stringify(query), async () => {
|
|
11988
|
+
return dedup(sid + "crm:leads:" + JSON.stringify(query), async () => {
|
|
11987
11989
|
set({ leadsLoading: true });
|
|
11988
11990
|
const result = await provider.getLeads(query);
|
|
11989
11991
|
set({ leads: result.data, leadsTotal: result.total, leadsLoading: false });
|
|
11990
11992
|
});
|
|
11991
11993
|
},
|
|
11992
11994
|
async fetchDeals(query) {
|
|
11993
|
-
return dedup("crm:deals:" + JSON.stringify(query), async () => {
|
|
11995
|
+
return dedup(sid + "crm:deals:" + JSON.stringify(query), async () => {
|
|
11994
11996
|
set({ dealsLoading: true });
|
|
11995
11997
|
const result = await provider.getDeals(query);
|
|
11996
11998
|
set({ deals: result.data, dealsTotal: result.total, dealsLoading: false });
|
|
@@ -11998,7 +12000,7 @@ function createCrmStore(provider) {
|
|
|
11998
12000
|
},
|
|
11999
12001
|
async fetchDealsByStage(pipelineId, filter) {
|
|
12000
12002
|
lastBoard = { pipelineId, filter };
|
|
12001
|
-
const key = "crm:dealsByStage:" + pipelineId + ":" + JSON.stringify(filter ?? {});
|
|
12003
|
+
const key = sid + "crm:dealsByStage:" + pipelineId + ":" + JSON.stringify(filter ?? {});
|
|
12002
12004
|
return dedup(key, async () => {
|
|
12003
12005
|
set({ dealsLoading: true });
|
|
12004
12006
|
const { activePipelineId, stages } = get();
|
|
@@ -12014,7 +12016,7 @@ function createCrmStore(provider) {
|
|
|
12014
12016
|
},
|
|
12015
12017
|
async fetchActivities(query) {
|
|
12016
12018
|
lastActivitiesQuery = query;
|
|
12017
|
-
return dedup("crm:activities:" + JSON.stringify(query), async () => {
|
|
12019
|
+
return dedup(sid + "crm:activities:" + JSON.stringify(query), async () => {
|
|
12018
12020
|
set({ activitiesLoading: true });
|
|
12019
12021
|
const result = await provider.getActivities(query);
|
|
12020
12022
|
set({ activities: result.data, activitiesTotal: result.total, activitiesLoading: false });
|
|
@@ -12028,7 +12030,7 @@ function createCrmStore(provider) {
|
|
|
12028
12030
|
}
|
|
12029
12031
|
},
|
|
12030
12032
|
async fetchQuotes(query) {
|
|
12031
|
-
return dedup("crm:quotes:" + JSON.stringify(query), async () => {
|
|
12033
|
+
return dedup(sid + "crm:quotes:" + JSON.stringify(query), async () => {
|
|
12032
12034
|
set({ quotesLoading: true });
|
|
12033
12035
|
const result = await provider.getQuotes(query);
|
|
12034
12036
|
set({ quotes: result.data, quotesTotal: result.total, quotesLoading: false });
|