@dench.com/cli 2.9.4-staging.231 → 2.9.5-staging.239

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.
@@ -1845,6 +1845,273 @@ const jobsSearchResponse = z
1845
1845
  */
1846
1846
  const noInput = z.object({});
1847
1847
 
1848
+ // -- crm analytics -----------------------------------------------------------
1849
+ // Mirrors `convex/lib/crm/analyticsConfig.ts` (the validators the mutations
1850
+ // enforce) and the `computePanels` result shape. A panel names a metric, an
1851
+ // optional group-by, an optional date bucketing and optional filters — no
1852
+ // SQL. Synthetic `$createdAt` (row creation time) and `$location` (the
1853
+ // `location` role, resolved through one relation hop) may be used anywhere a
1854
+ // field name is accepted.
1855
+
1856
+ const analyticsPeriod = z
1857
+ .enum([
1858
+ "all",
1859
+ "this_week",
1860
+ "this_month",
1861
+ "last_month",
1862
+ "this_quarter",
1863
+ "last_quarter",
1864
+ "this_year",
1865
+ ])
1866
+ .describe(
1867
+ 'Period preset. Scopes every panel by a date_preset on the object\'s closeDate role (else $createdAt) and fills previousValue from the previous calendar interval. "all" = no scope.',
1868
+ );
1869
+
1870
+ const roleDoc = {
1871
+ amount:
1872
+ 'Numeric field holding the deal value ("Amount") — the "Value field" in the setup sheet.',
1873
+ stage:
1874
+ 'Enum field driving the pipeline ("Stage" / "Status") — the "Progress field".',
1875
+ wonValues: "`stage` options that count as won (closed, successful).",
1876
+ lostValues: "`stage` options that count as lost (closed, gone).",
1877
+ convertedValues:
1878
+ '`stage` options that count as converted (a lead reached "Qualified").',
1879
+ closeDate:
1880
+ "Date field for time bucketing, forecasts and the period pill (falls back to $createdAt).",
1881
+ owner:
1882
+ 'User field naming who owns each record ("Owner"). Rankings on it default to a narrow card and draw member faces.',
1883
+ location:
1884
+ 'Place-name field maps plot. May be a relation path like "Account.HQ Location" (one hop through a relation).',
1885
+ recurrence:
1886
+ "How a won amount recurs: annual treats Amount as ARR, monthly as MRR, one_time disables MRR/ARR panels.",
1887
+ stageProbabilities:
1888
+ "Chance of closing per OPEN stage, 0..1, for the weighted forecast. Unlisted stages are spaced evenly; won = 1, lost = 0.",
1889
+ };
1890
+
1891
+ const recurrence = z.enum(["monthly", "annual", "one_time"]);
1892
+
1893
+ const analyticsFieldRoles = z
1894
+ .object({
1895
+ amount: z.string().optional().describe(roleDoc.amount),
1896
+ stage: z.string().optional().describe(roleDoc.stage),
1897
+ wonValues: z.array(z.string()).optional().describe(roleDoc.wonValues),
1898
+ lostValues: z.array(z.string()).optional().describe(roleDoc.lostValues),
1899
+ convertedValues: z
1900
+ .array(z.string())
1901
+ .optional()
1902
+ .describe(roleDoc.convertedValues),
1903
+ closeDate: z.string().optional().describe(roleDoc.closeDate),
1904
+ owner: z.string().optional().describe(roleDoc.owner),
1905
+ location: z.string().optional().describe(roleDoc.location),
1906
+ recurrence: recurrence.optional().describe(roleDoc.recurrence),
1907
+ stageProbabilities: z
1908
+ .record(z.string(), z.number())
1909
+ .optional()
1910
+ .describe(roleDoc.stageProbabilities),
1911
+ })
1912
+ .describe(
1913
+ "The object's analytics setup, shared by every chart and every view: the semantic field roles derived metrics (win rate, won $, open pipeline, forecast, MRR/ARR), maps and card defaults read.",
1914
+ );
1915
+
1916
+ const analyticsFieldRolesPatch = z
1917
+ .object({
1918
+ amount: z.string().nullable().optional().describe(roleDoc.amount),
1919
+ stage: z.string().nullable().optional().describe(roleDoc.stage),
1920
+ wonValues: z
1921
+ .array(z.string())
1922
+ .nullable()
1923
+ .optional()
1924
+ .describe(roleDoc.wonValues),
1925
+ lostValues: z
1926
+ .array(z.string())
1927
+ .nullable()
1928
+ .optional()
1929
+ .describe(roleDoc.lostValues),
1930
+ convertedValues: z
1931
+ .array(z.string())
1932
+ .nullable()
1933
+ .optional()
1934
+ .describe(roleDoc.convertedValues),
1935
+ closeDate: z.string().nullable().optional().describe(roleDoc.closeDate),
1936
+ owner: z.string().nullable().optional().describe(roleDoc.owner),
1937
+ location: z.string().nullable().optional().describe(roleDoc.location),
1938
+ recurrence: recurrence.nullable().optional().describe(roleDoc.recurrence),
1939
+ stageProbabilities: z
1940
+ .record(z.string(), z.number())
1941
+ .nullable()
1942
+ .optional()
1943
+ .describe(roleDoc.stageProbabilities),
1944
+ })
1945
+ .describe(
1946
+ "Field roles as an edit: the same keys; null clears one. Applied onto the stored mapping with merge: true, otherwise replaces it.",
1947
+ );
1948
+
1949
+ const analyticsPanelType = z.enum([
1950
+ "stat",
1951
+ "bar",
1952
+ "line",
1953
+ "area",
1954
+ "donut",
1955
+ "funnel",
1956
+ "leaderboard",
1957
+ "forecast",
1958
+ "map",
1959
+ ]);
1960
+
1961
+ const analyticsPanel = z
1962
+ .object({
1963
+ id: z
1964
+ .string()
1965
+ .describe("Stable id (template panels use `tpl:<template>:<slug>`)."),
1966
+ title: z.string(),
1967
+ type: analyticsPanelType,
1968
+ metric: z.enum(["count", "sum", "avg", "min", "max"]),
1969
+ metricField: z
1970
+ .string()
1971
+ .optional()
1972
+ .describe("Numeric field for sum/avg/min/max. Ignored for count."),
1973
+ groupBy: z
1974
+ .string()
1975
+ .optional()
1976
+ .describe(
1977
+ "Bucketing field (enum/user/relation/boolean/text, or $location). On a time-series panel it splits the series into one line per value.",
1978
+ ),
1979
+ dateField: z
1980
+ .string()
1981
+ .optional()
1982
+ .describe("Date field for line/area/forecast bucketing (or $createdAt)."),
1983
+ dateBucket: z.enum(["day", "week", "month", "quarter"]).optional(),
1984
+ filters: z
1985
+ .record(z.string(), z.unknown())
1986
+ .optional()
1987
+ .describe("Panel-scoped FilterGroup, same shape as saved-view filters."),
1988
+ size: z
1989
+ .enum(["sm", "md", "lg"])
1990
+ .optional()
1991
+ .describe("Deprecated; ignored for layout. Use `span`."),
1992
+ span: z
1993
+ .union([z.literal(2), z.literal(3), z.literal(4), z.literal(6)])
1994
+ .optional()
1995
+ .describe(
1996
+ "Card width on the 6-track dashboard grid: 2 = a third, 3 = half, 4 = two thirds, 6 = full row. Defaults: funnel 4; map and leaderboard 2; bar/donut grouped by a user field 2, by anything else 4; trends 3.",
1997
+ ),
1998
+ hidden: z
1999
+ .boolean()
2000
+ .optional()
2001
+ .describe(
2002
+ "Hide from the strip above the table; still shown in the full analytics view.",
2003
+ ),
2004
+ sortOrder: z.number(),
2005
+ derived: z
2006
+ .enum([
2007
+ "conversion_rate",
2008
+ "win_rate",
2009
+ "won_amount",
2010
+ "lost_amount",
2011
+ "open_pipeline",
2012
+ "pipeline_forecast",
2013
+ "mrr",
2014
+ "arr",
2015
+ ])
2016
+ .optional()
2017
+ .describe(
2018
+ "Role-driven derived metric; when set the panel computes from fieldRoles instead of metric/groupBy.",
2019
+ ),
2020
+ })
2021
+ .describe("One analytics panel definition.");
2022
+
2023
+ const analyticsPanelPatch = analyticsPanel
2024
+ .omit({ id: true, size: true })
2025
+ .partial()
2026
+ .extend({
2027
+ metricField: z.string().nullable().optional(),
2028
+ groupBy: z.string().nullable().optional(),
2029
+ dateField: z.string().nullable().optional(),
2030
+ dateBucket: z
2031
+ .enum(["day", "week", "month", "quarter"])
2032
+ .nullable()
2033
+ .optional(),
2034
+ filters: z.record(z.string(), z.unknown()).nullable().optional(),
2035
+ span: z
2036
+ .union([z.literal(2), z.literal(3), z.literal(4), z.literal(6)])
2037
+ .nullable()
2038
+ .optional()
2039
+ .describe("Width in tracks; null restores the chart kind's default."),
2040
+ derived: analyticsPanel.shape.derived.unwrap().nullable().optional(),
2041
+ })
2042
+ .describe(
2043
+ "Partial panel edit: only the keys present change; null clears an optional key; hidden: false is stored as absent.",
2044
+ );
2045
+
2046
+ const analyticsPanelContainer = z.object({
2047
+ panels: z.array(analyticsPanel),
2048
+ removedPanelIds: z
2049
+ .array(z.string())
2050
+ .optional()
2051
+ .describe("Template panel ids the user deleted; never resurrected."),
2052
+ });
2053
+
2054
+ const analyticsConfig = analyticsPanelContainer.extend({
2055
+ fieldRoles: analyticsFieldRoles.optional(),
2056
+ stripCollapsed: z.boolean().optional(),
2057
+ });
2058
+
2059
+ const analyticsSeriesPoint = z.object({
2060
+ bucket: z.string(),
2061
+ label: z.string(),
2062
+ value: z.number(),
2063
+ count: z.number(),
2064
+ projected: z.boolean().optional(),
2065
+ });
2066
+
2067
+ const analyticsPanelResult = z.object({
2068
+ id: z.string(),
2069
+ unit: z.enum(["number", "currency", "percent"]),
2070
+ value: z.number().optional(),
2071
+ secondaryValue: z.number().optional(),
2072
+ previousValue: z
2073
+ .number()
2074
+ .optional()
2075
+ .describe(
2076
+ "The same value over the comparison window (period / compareFilters).",
2077
+ ),
2078
+ buckets: z
2079
+ .array(
2080
+ z.object({
2081
+ key: z.string(),
2082
+ label: z.string(),
2083
+ count: z.number(),
2084
+ value: z.number(),
2085
+ color: z.string().optional(),
2086
+ amount: z
2087
+ .number()
2088
+ .optional()
2089
+ .describe(
2090
+ "Funnel only: sum of the amount role over the rows in this stage.",
2091
+ ),
2092
+ }),
2093
+ )
2094
+ .optional(),
2095
+ series: z.array(analyticsSeriesPoint).optional(),
2096
+ seriesGroups: z
2097
+ .array(
2098
+ z.object({
2099
+ key: z.string(),
2100
+ label: z.string(),
2101
+ color: z.string().optional(),
2102
+ series: z.array(analyticsSeriesPoint),
2103
+ }),
2104
+ )
2105
+ .optional(),
2106
+ error: z.string().optional(),
2107
+ });
2108
+
2109
+
2110
+ // ---------------------------------------------------------------------------
2111
+ // Request schemas keyed by operation id
2112
+ // ---------------------------------------------------------------------------
2113
+
2114
+
1848
2115
  export const requestSchemas: Record<string, ZodTypeAny> = {
1849
2116
  // Meta
1850
2117
  "commands.list": noInput,
@@ -3081,6 +3348,147 @@ export const requestSchemas: Record<string, ZodTypeAny> = {
3081
3348
  digestWindowMinutes: z.number().int().optional(),
3082
3349
  maxEmailsPerDay: z.number().int().optional(),
3083
3350
  }),
3351
+ "crm.analytics.get": z.object({
3352
+ objectName: z.string(),
3353
+ viewName: z
3354
+ .string()
3355
+ .optional()
3356
+ .describe(
3357
+ "Also return this saved view's own dashboard (viewAnalytics) when it has one.",
3358
+ ),
3359
+ }),
3360
+ "crm.analytics.compute": z.object({
3361
+ objectName: z.string(),
3362
+ viewName: z
3363
+ .string()
3364
+ .optional()
3365
+ .describe(
3366
+ "Compute the saved view's own dashboard instead of the object's (ignored when the view inherits).",
3367
+ ),
3368
+ panelIds: z
3369
+ .array(z.string())
3370
+ .optional()
3371
+ .describe("Only these stored panels."),
3372
+ panels: z
3373
+ .array(analyticsPanel)
3374
+ .optional()
3375
+ .describe(
3376
+ "Ad-hoc panel definitions to compute instead of the stored dashboard (nothing is persisted).",
3377
+ ),
3378
+ period: analyticsPeriod.optional(),
3379
+ extraFilters: z
3380
+ .record(z.string(), z.unknown())
3381
+ .optional()
3382
+ .describe(
3383
+ "FilterGroup applied to every panel (e.g. the view's rules). Forces the bounded scan path.",
3384
+ ),
3385
+ compareFilters: z
3386
+ .record(z.string(), z.unknown())
3387
+ .optional()
3388
+ .describe(
3389
+ "FilterGroup for the comparison window; every panel's value over it comes back as previousValue. Derived automatically from `period`.",
3390
+ ),
3391
+ fieldRolesOverride: analyticsFieldRoles
3392
+ .optional()
3393
+ .describe("Preview an unsaved role mapping."),
3394
+ drillFilters: z
3395
+ .array(
3396
+ z.object({
3397
+ dimension: z
3398
+ .string()
3399
+ .describe(
3400
+ "Dimension the click came from (`field:<name>` or `time:<field>`). Panels bucketing on it keep their full picture.",
3401
+ ),
3402
+ filter: z
3403
+ .record(z.string(), z.unknown())
3404
+ .describe("FilterGroup selecting the clicked bucket."),
3405
+ }),
3406
+ )
3407
+ .optional()
3408
+ .describe(
3409
+ "Click-to-filter chips, same as the strip: each scopes every panel EXCEPT those whose dimensions include `dimension`.",
3410
+ ),
3411
+ }),
3412
+ "crm.analytics.save": z.object({
3413
+ objectName: z.string(),
3414
+ panelId: z.string().describe("Panel id (path); becomes panel.id."),
3415
+ panel: analyticsPanel
3416
+ .omit({ id: true })
3417
+ .extend({ id: z.string().optional() })
3418
+ .describe("The panel definition to upsert."),
3419
+ viewName: z
3420
+ .string()
3421
+ .optional()
3422
+ .describe(
3423
+ "Write the saved view's own dashboard (forks a copy if it was inheriting).",
3424
+ ),
3425
+ }),
3426
+ "crm.analytics.update": z.object({
3427
+ objectName: z.string(),
3428
+ panelId: z.string().describe("Stored panel id (path)."),
3429
+ patch: analyticsPanelPatch,
3430
+ viewName: z
3431
+ .string()
3432
+ .optional()
3433
+ .describe(
3434
+ "Edit the saved view's own dashboard (forks a copy if it was inheriting).",
3435
+ ),
3436
+ }),
3437
+ "crm.analytics.hide": z.object({
3438
+ objectName: z.string(),
3439
+ panelId: z.string(),
3440
+ viewName: z.string().optional(),
3441
+ }),
3442
+ "crm.analytics.show": z.object({
3443
+ objectName: z.string(),
3444
+ panelId: z.string(),
3445
+ viewName: z.string().optional(),
3446
+ }),
3447
+ "crm.analytics.resize": z.object({
3448
+ objectName: z.string(),
3449
+ panelId: z.string(),
3450
+ span: z
3451
+ .union([z.literal(2), z.literal(3), z.literal(4), z.literal(6)])
3452
+ .nullable()
3453
+ .describe(
3454
+ "2 = third, 3 = half, 4 = two thirds, 6 = full row; null = the chart kind's default.",
3455
+ ),
3456
+ viewName: z.string().optional(),
3457
+ }),
3458
+ "crm.analytics.delete": z.object({
3459
+ objectName: z.string(),
3460
+ panelId: z.string(),
3461
+ viewName: z.string().optional(),
3462
+ }),
3463
+ "crm.analytics.reorder": z.object({
3464
+ objectName: z.string(),
3465
+ panelIds: z
3466
+ .array(z.string())
3467
+ .describe("Every stored panel id of the targeted dashboard, in order."),
3468
+ viewName: z.string().optional(),
3469
+ }),
3470
+ "crm.analytics.roles": z.object({
3471
+ objectName: z.string(),
3472
+ fieldRoles: analyticsFieldRolesPatch,
3473
+ merge: z
3474
+ .boolean()
3475
+ .optional()
3476
+ .describe(
3477
+ "true: change only the keys given (null clears one). Default replaces the whole mapping.",
3478
+ ),
3479
+ }),
3480
+ "crm.analytics.collapse": z.object({ objectName: z.string() }),
3481
+ "crm.analytics.expand": z.object({ objectName: z.string() }),
3482
+ "crm.analytics.scope": z.object({
3483
+ objectName: z.string(),
3484
+ viewName: z.string(),
3485
+ mode: z
3486
+ .enum(["own", "shared"])
3487
+ .describe(
3488
+ '"own": the view gets its own dashboard (a copy of the object\'s panels); "shared": it shows the object\'s again.',
3489
+ ),
3490
+ }),
3491
+
3084
3492
  };
3085
3493
 
3086
3494
  // ---------------------------------------------------------------------------
@@ -3994,6 +4402,50 @@ export const responseSchemas: Record<string, ZodTypeAny> = {
3994
4402
  }),
3995
4403
  "agentConfig.daily.today": agentConfigPayload,
3996
4404
  "agentConfig.daily.show": agentConfigPayload,
4405
+ "crm.analytics.get": z.object({
4406
+ objectName: z.string(),
4407
+ analytics: analyticsConfig.nullable(),
4408
+ viewAnalytics: analyticsPanelContainer
4409
+ .nullable()
4410
+ .describe("The named view's own dashboard, or null when it inherits."),
4411
+ viewExists: z.boolean(),
4412
+ fields: z.array(
4413
+ z.object({
4414
+ name: z.string(),
4415
+ type: z.string(),
4416
+ enumValues: z.array(z.string()).nullable(),
4417
+ enumColors: z.array(z.string()).nullable(),
4418
+ }),
4419
+ ),
4420
+ }),
4421
+ "crm.analytics.compute": z.object({
4422
+ objectName: z.string(),
4423
+ truncated: z
4424
+ .boolean()
4425
+ .describe(
4426
+ "True when the table exceeded the 5,000-row scan and numbers are approximate.",
4427
+ ),
4428
+ scannedRows: z.number(),
4429
+ locationRole: z.string().optional(),
4430
+ panels: z.array(analyticsPanelResult),
4431
+ }),
4432
+ "crm.analytics.save": z.object({ ok: z.boolean(), panelId: z.string() }),
4433
+ "crm.analytics.update": z.object({ ok: z.boolean(), panel: analyticsPanel }),
4434
+ "crm.analytics.hide": z.object({ ok: z.boolean(), panel: analyticsPanel }),
4435
+ "crm.analytics.show": z.object({ ok: z.boolean(), panel: analyticsPanel }),
4436
+ "crm.analytics.resize": z.object({ ok: z.boolean(), panel: analyticsPanel }),
4437
+ "crm.analytics.delete": z.object({ ok: z.boolean(), removed: z.boolean() }),
4438
+ "crm.analytics.reorder": okResponse,
4439
+ "crm.analytics.roles": z.object({
4440
+ ok: z.boolean(),
4441
+ fieldRoles: analyticsFieldRoles.describe(
4442
+ "The mapping as stored after the write.",
4443
+ ),
4444
+ }),
4445
+ "crm.analytics.collapse": okResponse,
4446
+ "crm.analytics.expand": okResponse,
4447
+ "crm.analytics.scope": z.object({ ok: z.boolean(), changed: z.boolean() }),
4448
+
3997
4449
  };
3998
4450
 
3999
4451
  // ---------------------------------------------------------------------------
@@ -4080,6 +4532,58 @@ export const convexExtras: Record<string, ConvexExtras> = {
4080
4532
  };
4081
4533
  },
4082
4534
  },
4535
+ "crm.analytics.collapse": { fixedArgs: { collapsed: true } },
4536
+ "crm.analytics.expand": { fixedArgs: { collapsed: false } },
4537
+ // hide / show / resize are `updateAnalyticsPanel` with a one-key patch.
4538
+ "crm.analytics.hide": { fixedArgs: { patch: { hidden: true } } },
4539
+ "crm.analytics.show": { fixedArgs: { patch: { hidden: false } } },
4540
+ "crm.analytics.resize": {
4541
+ transformArgs: (input) => {
4542
+ const { span, ...rest } = input as { span?: unknown } & Record<
4543
+ string,
4544
+ unknown
4545
+ >;
4546
+ return { ...rest, patch: { span: span ?? null } };
4547
+ },
4548
+ },
4549
+ // PUT /crm/objects/{objectName}/analytics/panels/{panelId} — the path's
4550
+ // panelId is the upsert key: fold it into `panel.id`.
4551
+ "crm.analytics.save": {
4552
+ transformArgs: (input) => {
4553
+ const { panelId, panel, ...rest } = input as {
4554
+ panelId?: unknown;
4555
+ panel?: unknown;
4556
+ } & Record<string, unknown>;
4557
+ const basePanel =
4558
+ panel && typeof panel === "object" && !Array.isArray(panel)
4559
+ ? (panel as Record<string, unknown>)
4560
+ : {};
4561
+ return {
4562
+ ...rest,
4563
+ panel: { ...basePanel, id: String(panelId ?? basePanel.id ?? "") },
4564
+ };
4565
+ },
4566
+ },
4567
+ "crm.entries.updateMany": {
4568
+ transformArgs: (input) => {
4569
+ const updates = Array.isArray(input.updates) ? input.updates : [];
4570
+ return {
4571
+ ops: updates.map((raw) => {
4572
+ const update = (raw ?? {}) as {
4573
+ entryId?: unknown;
4574
+ id?: unknown;
4575
+ data?: unknown;
4576
+ };
4577
+ return {
4578
+ type: "entries.update",
4579
+ entryId: String(update.entryId ?? update.id ?? ""),
4580
+ data: update.data ?? {},
4581
+ };
4582
+ }),
4583
+ };
4584
+ },
4585
+ },
4586
+
4083
4587
  };
4084
4588
 
4085
4589
  // ---------------------------------------------------------------------------
@@ -4361,6 +4865,45 @@ export const requestExamples: Record<string, unknown> = {
4361
4865
  ],
4362
4866
  },
4363
4867
  "email.campaign.preview": { sample: 5 },
4868
+ "crm.analytics.compute": {
4869
+ period: "this_month",
4870
+ panels: [
4871
+ {
4872
+ id: "adhoc:leads-by-source",
4873
+ title: "New leads by source",
4874
+ type: "donut",
4875
+ metric: "count",
4876
+ groupBy: "Source",
4877
+ sortOrder: 0,
4878
+ },
4879
+ ],
4880
+ },
4881
+ "crm.analytics.save": {
4882
+ panel: {
4883
+ title: "Open pipeline",
4884
+ type: "stat",
4885
+ metric: "sum",
4886
+ derived: "open_pipeline",
4887
+ sortOrder: 10,
4888
+ },
4889
+ },
4890
+ "crm.analytics.reorder": {
4891
+ panelIds: ["tpl:sales:total-leads", "tpl:sales:leads-by-source"],
4892
+ },
4893
+ "crm.analytics.roles": {
4894
+ fieldRoles: {
4895
+ amount: "Amount",
4896
+ stage: "Stage",
4897
+ wonValues: ["Closed Won"],
4898
+ lostValues: ["Closed Lost"],
4899
+ closeDate: "Close Date",
4900
+ owner: "Owner",
4901
+ location: "Account.HQ Location",
4902
+ recurrence: "annual",
4903
+ },
4904
+ },
4905
+ "crm.analytics.scope": { mode: "own" },
4906
+
4364
4907
  };
4365
4908
 
4366
4909
  // ---------------------------------------------------------------------------
@@ -5865,4 +6408,64 @@ export const responseExamples: Record<string, unknown> = {
5865
6408
  userTimezone: null,
5866
6409
  organizationId: "org_abc123",
5867
6410
  },
6411
+ "crm.analytics.get": {
6412
+ objectName: "lead",
6413
+ analytics: {
6414
+ panels: [
6415
+ {
6416
+ id: "tpl:sales:total-leads",
6417
+ title: "Total leads",
6418
+ type: "stat",
6419
+ metric: "count",
6420
+ sortOrder: 0,
6421
+ },
6422
+ {
6423
+ id: "tpl:sales:leads-by-source",
6424
+ title: "Leads by source",
6425
+ type: "donut",
6426
+ metric: "count",
6427
+ groupBy: "Source",
6428
+ sortOrder: 1,
6429
+ },
6430
+ ],
6431
+ fieldRoles: { stage: "Status", convertedValues: ["Qualified"] },
6432
+ stripCollapsed: false,
6433
+ },
6434
+ viewAnalytics: null,
6435
+ viewExists: false,
6436
+ fields: [
6437
+ {
6438
+ name: "Status",
6439
+ type: "enum",
6440
+ enumValues: ["New", "Qualified"],
6441
+ enumColors: null,
6442
+ },
6443
+ { name: "$createdAt", type: "date", enumValues: null, enumColors: null },
6444
+ ],
6445
+ },
6446
+ "crm.analytics.compute": {
6447
+ objectName: "lead",
6448
+ truncated: false,
6449
+ scannedRows: 42,
6450
+ panels: [
6451
+ {
6452
+ id: "adhoc:leads-by-source",
6453
+ unit: "number",
6454
+ value: 42,
6455
+ previousValue: 31,
6456
+ buckets: [
6457
+ { key: "Website", label: "Website", count: 25, value: 25 },
6458
+ { key: "Referral", label: "Referral", count: 17, value: 17 },
6459
+ ],
6460
+ },
6461
+ ],
6462
+ },
6463
+ "crm.analytics.save": { ok: true, panelId: "adhoc:open-pipeline" },
6464
+ "crm.analytics.delete": { ok: true, removed: true },
6465
+ "crm.analytics.reorder": { ok: true },
6466
+ "crm.analytics.roles": { ok: true },
6467
+ "crm.analytics.collapse": { ok: true },
6468
+ "crm.analytics.expand": { ok: true },
6469
+ "crm.analytics.scope": { ok: true, changed: true },
6470
+
5868
6471
  };