@dench.com/cli 2.9.4 → 2.9.6-staging.240
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/app-sdk.d.ts +7027 -0
- package/apps.ts +206 -0
- package/crm-analytics.ts +456 -0
- package/crm.ts +62 -0
- package/dench.ts +1 -1
- package/lib/api-schemas.ts +646 -0
- package/lib/app-sdk-catalog.generated.ts +581 -0
- package/lib/app-sdk-surface.ts +1376 -0
- package/lib/apps-validate.ts +469 -0
- package/lib/command-registry.ts +243 -0
- package/notifications.ts +7 -6
- package/package.json +10 -1
package/lib/api-schemas.ts
CHANGED
|
@@ -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,
|
|
@@ -2977,6 +3244,7 @@ export const requestSchemas: Record<string, ZodTypeAny> = {
|
|
|
2977
3244
|
}),
|
|
2978
3245
|
"files.downloadUrl": z.object({ path: z.string() }),
|
|
2979
3246
|
"files.delete": z.object({ path: z.string() }),
|
|
3247
|
+
"files.mkdir": z.object({ path: z.string() }),
|
|
2980
3248
|
"files.move": z.object({
|
|
2981
3249
|
from: z.string().describe("Source workspace path."),
|
|
2982
3250
|
to: z.string().describe("Destination workspace path."),
|
|
@@ -2998,6 +3266,48 @@ export const requestSchemas: Record<string, ZodTypeAny> = {
|
|
|
2998
3266
|
lastModifiedBy: z.string().optional(),
|
|
2999
3267
|
}),
|
|
3000
3268
|
|
|
3269
|
+
// Apps (App Store + app webhooks)
|
|
3270
|
+
"apps.list": noInput,
|
|
3271
|
+
"apps.gallery": noInput,
|
|
3272
|
+
"apps.create": z.object({
|
|
3273
|
+
slug: z.string().describe("Folder slug; becomes /apps/<slug>.dench.app."),
|
|
3274
|
+
name: z.string(),
|
|
3275
|
+
icon: z.string().optional().describe("Lucide icon name."),
|
|
3276
|
+
description: z.string().optional(),
|
|
3277
|
+
}),
|
|
3278
|
+
"apps.install": z.object({ listingId: z.string() }),
|
|
3279
|
+
"apps.publish": z.object({
|
|
3280
|
+
appPath: z.string().describe("Workspace path of the .dench.app folder."),
|
|
3281
|
+
slug: z.string(),
|
|
3282
|
+
name: z.string(),
|
|
3283
|
+
description: z.string().optional(),
|
|
3284
|
+
icon: z.string().optional(),
|
|
3285
|
+
visibility: z.enum(["org", "public", "official", "unlisted"]).optional(),
|
|
3286
|
+
version: z.string().optional(),
|
|
3287
|
+
permissions: z.array(z.string()).optional(),
|
|
3288
|
+
}),
|
|
3289
|
+
"apps.uninstall": z.object({ slug: z.string() }),
|
|
3290
|
+
"apps.setEnabled": z.object({ slug: z.string(), enabled: z.boolean() }),
|
|
3291
|
+
"apps.setPinned": z.object({ slug: z.string(), pinned: z.boolean() }),
|
|
3292
|
+
"apps.webhooks.register": z.object({
|
|
3293
|
+
slug: z.string().describe("Installed app slug."),
|
|
3294
|
+
hookName: z
|
|
3295
|
+
.string()
|
|
3296
|
+
.regex(/^[a-z0-9][a-z0-9_-]{0,63}$/i)
|
|
3297
|
+
.describe("Hook name, e.g. `stripe` or `github-push`."),
|
|
3298
|
+
}),
|
|
3299
|
+
"apps.webhooks.list": z.object({ slug: z.string() }),
|
|
3300
|
+
"apps.webhooks.poll": z.object({
|
|
3301
|
+
slug: z.string(),
|
|
3302
|
+
hookName: z.string(),
|
|
3303
|
+
since: z.coerce
|
|
3304
|
+
.number()
|
|
3305
|
+
.optional()
|
|
3306
|
+
.describe("Only events received after this epoch ms."),
|
|
3307
|
+
limit: z.coerce.number().int().min(1).max(200).optional(),
|
|
3308
|
+
}),
|
|
3309
|
+
"apps.webhooks.delete": z.object({ slug: z.string(), hookName: z.string() }),
|
|
3310
|
+
|
|
3001
3311
|
// Agent config
|
|
3002
3312
|
"agentConfig.identity.show": noInput,
|
|
3003
3313
|
"agentConfig.organisation.show": noInput,
|
|
@@ -3081,6 +3391,147 @@ export const requestSchemas: Record<string, ZodTypeAny> = {
|
|
|
3081
3391
|
digestWindowMinutes: z.number().int().optional(),
|
|
3082
3392
|
maxEmailsPerDay: z.number().int().optional(),
|
|
3083
3393
|
}),
|
|
3394
|
+
"crm.analytics.get": z.object({
|
|
3395
|
+
objectName: z.string(),
|
|
3396
|
+
viewName: z
|
|
3397
|
+
.string()
|
|
3398
|
+
.optional()
|
|
3399
|
+
.describe(
|
|
3400
|
+
"Also return this saved view's own dashboard (viewAnalytics) when it has one.",
|
|
3401
|
+
),
|
|
3402
|
+
}),
|
|
3403
|
+
"crm.analytics.compute": z.object({
|
|
3404
|
+
objectName: z.string(),
|
|
3405
|
+
viewName: z
|
|
3406
|
+
.string()
|
|
3407
|
+
.optional()
|
|
3408
|
+
.describe(
|
|
3409
|
+
"Compute the saved view's own dashboard instead of the object's (ignored when the view inherits).",
|
|
3410
|
+
),
|
|
3411
|
+
panelIds: z
|
|
3412
|
+
.array(z.string())
|
|
3413
|
+
.optional()
|
|
3414
|
+
.describe("Only these stored panels."),
|
|
3415
|
+
panels: z
|
|
3416
|
+
.array(analyticsPanel)
|
|
3417
|
+
.optional()
|
|
3418
|
+
.describe(
|
|
3419
|
+
"Ad-hoc panel definitions to compute instead of the stored dashboard (nothing is persisted).",
|
|
3420
|
+
),
|
|
3421
|
+
period: analyticsPeriod.optional(),
|
|
3422
|
+
extraFilters: z
|
|
3423
|
+
.record(z.string(), z.unknown())
|
|
3424
|
+
.optional()
|
|
3425
|
+
.describe(
|
|
3426
|
+
"FilterGroup applied to every panel (e.g. the view's rules). Forces the bounded scan path.",
|
|
3427
|
+
),
|
|
3428
|
+
compareFilters: z
|
|
3429
|
+
.record(z.string(), z.unknown())
|
|
3430
|
+
.optional()
|
|
3431
|
+
.describe(
|
|
3432
|
+
"FilterGroup for the comparison window; every panel's value over it comes back as previousValue. Derived automatically from `period`.",
|
|
3433
|
+
),
|
|
3434
|
+
fieldRolesOverride: analyticsFieldRoles
|
|
3435
|
+
.optional()
|
|
3436
|
+
.describe("Preview an unsaved role mapping."),
|
|
3437
|
+
drillFilters: z
|
|
3438
|
+
.array(
|
|
3439
|
+
z.object({
|
|
3440
|
+
dimension: z
|
|
3441
|
+
.string()
|
|
3442
|
+
.describe(
|
|
3443
|
+
"Dimension the click came from (`field:<name>` or `time:<field>`). Panels bucketing on it keep their full picture.",
|
|
3444
|
+
),
|
|
3445
|
+
filter: z
|
|
3446
|
+
.record(z.string(), z.unknown())
|
|
3447
|
+
.describe("FilterGroup selecting the clicked bucket."),
|
|
3448
|
+
}),
|
|
3449
|
+
)
|
|
3450
|
+
.optional()
|
|
3451
|
+
.describe(
|
|
3452
|
+
"Click-to-filter chips, same as the strip: each scopes every panel EXCEPT those whose dimensions include `dimension`.",
|
|
3453
|
+
),
|
|
3454
|
+
}),
|
|
3455
|
+
"crm.analytics.save": z.object({
|
|
3456
|
+
objectName: z.string(),
|
|
3457
|
+
panelId: z.string().describe("Panel id (path); becomes panel.id."),
|
|
3458
|
+
panel: analyticsPanel
|
|
3459
|
+
.omit({ id: true })
|
|
3460
|
+
.extend({ id: z.string().optional() })
|
|
3461
|
+
.describe("The panel definition to upsert."),
|
|
3462
|
+
viewName: z
|
|
3463
|
+
.string()
|
|
3464
|
+
.optional()
|
|
3465
|
+
.describe(
|
|
3466
|
+
"Write the saved view's own dashboard (forks a copy if it was inheriting).",
|
|
3467
|
+
),
|
|
3468
|
+
}),
|
|
3469
|
+
"crm.analytics.update": z.object({
|
|
3470
|
+
objectName: z.string(),
|
|
3471
|
+
panelId: z.string().describe("Stored panel id (path)."),
|
|
3472
|
+
patch: analyticsPanelPatch,
|
|
3473
|
+
viewName: z
|
|
3474
|
+
.string()
|
|
3475
|
+
.optional()
|
|
3476
|
+
.describe(
|
|
3477
|
+
"Edit the saved view's own dashboard (forks a copy if it was inheriting).",
|
|
3478
|
+
),
|
|
3479
|
+
}),
|
|
3480
|
+
"crm.analytics.hide": z.object({
|
|
3481
|
+
objectName: z.string(),
|
|
3482
|
+
panelId: z.string(),
|
|
3483
|
+
viewName: z.string().optional(),
|
|
3484
|
+
}),
|
|
3485
|
+
"crm.analytics.show": z.object({
|
|
3486
|
+
objectName: z.string(),
|
|
3487
|
+
panelId: z.string(),
|
|
3488
|
+
viewName: z.string().optional(),
|
|
3489
|
+
}),
|
|
3490
|
+
"crm.analytics.resize": z.object({
|
|
3491
|
+
objectName: z.string(),
|
|
3492
|
+
panelId: z.string(),
|
|
3493
|
+
span: z
|
|
3494
|
+
.union([z.literal(2), z.literal(3), z.literal(4), z.literal(6)])
|
|
3495
|
+
.nullable()
|
|
3496
|
+
.describe(
|
|
3497
|
+
"2 = third, 3 = half, 4 = two thirds, 6 = full row; null = the chart kind's default.",
|
|
3498
|
+
),
|
|
3499
|
+
viewName: z.string().optional(),
|
|
3500
|
+
}),
|
|
3501
|
+
"crm.analytics.delete": z.object({
|
|
3502
|
+
objectName: z.string(),
|
|
3503
|
+
panelId: z.string(),
|
|
3504
|
+
viewName: z.string().optional(),
|
|
3505
|
+
}),
|
|
3506
|
+
"crm.analytics.reorder": z.object({
|
|
3507
|
+
objectName: z.string(),
|
|
3508
|
+
panelIds: z
|
|
3509
|
+
.array(z.string())
|
|
3510
|
+
.describe("Every stored panel id of the targeted dashboard, in order."),
|
|
3511
|
+
viewName: z.string().optional(),
|
|
3512
|
+
}),
|
|
3513
|
+
"crm.analytics.roles": z.object({
|
|
3514
|
+
objectName: z.string(),
|
|
3515
|
+
fieldRoles: analyticsFieldRolesPatch,
|
|
3516
|
+
merge: z
|
|
3517
|
+
.boolean()
|
|
3518
|
+
.optional()
|
|
3519
|
+
.describe(
|
|
3520
|
+
"true: change only the keys given (null clears one). Default replaces the whole mapping.",
|
|
3521
|
+
),
|
|
3522
|
+
}),
|
|
3523
|
+
"crm.analytics.collapse": z.object({ objectName: z.string() }),
|
|
3524
|
+
"crm.analytics.expand": z.object({ objectName: z.string() }),
|
|
3525
|
+
"crm.analytics.scope": z.object({
|
|
3526
|
+
objectName: z.string(),
|
|
3527
|
+
viewName: z.string(),
|
|
3528
|
+
mode: z
|
|
3529
|
+
.enum(["own", "shared"])
|
|
3530
|
+
.describe(
|
|
3531
|
+
'"own": the view gets its own dashboard (a copy of the object\'s panels); "shared": it shows the object\'s again.',
|
|
3532
|
+
),
|
|
3533
|
+
}),
|
|
3534
|
+
|
|
3084
3535
|
};
|
|
3085
3536
|
|
|
3086
3537
|
// ---------------------------------------------------------------------------
|
|
@@ -3994,6 +4445,50 @@ export const responseSchemas: Record<string, ZodTypeAny> = {
|
|
|
3994
4445
|
}),
|
|
3995
4446
|
"agentConfig.daily.today": agentConfigPayload,
|
|
3996
4447
|
"agentConfig.daily.show": agentConfigPayload,
|
|
4448
|
+
"crm.analytics.get": z.object({
|
|
4449
|
+
objectName: z.string(),
|
|
4450
|
+
analytics: analyticsConfig.nullable(),
|
|
4451
|
+
viewAnalytics: analyticsPanelContainer
|
|
4452
|
+
.nullable()
|
|
4453
|
+
.describe("The named view's own dashboard, or null when it inherits."),
|
|
4454
|
+
viewExists: z.boolean(),
|
|
4455
|
+
fields: z.array(
|
|
4456
|
+
z.object({
|
|
4457
|
+
name: z.string(),
|
|
4458
|
+
type: z.string(),
|
|
4459
|
+
enumValues: z.array(z.string()).nullable(),
|
|
4460
|
+
enumColors: z.array(z.string()).nullable(),
|
|
4461
|
+
}),
|
|
4462
|
+
),
|
|
4463
|
+
}),
|
|
4464
|
+
"crm.analytics.compute": z.object({
|
|
4465
|
+
objectName: z.string(),
|
|
4466
|
+
truncated: z
|
|
4467
|
+
.boolean()
|
|
4468
|
+
.describe(
|
|
4469
|
+
"True when the table exceeded the 5,000-row scan and numbers are approximate.",
|
|
4470
|
+
),
|
|
4471
|
+
scannedRows: z.number(),
|
|
4472
|
+
locationRole: z.string().optional(),
|
|
4473
|
+
panels: z.array(analyticsPanelResult),
|
|
4474
|
+
}),
|
|
4475
|
+
"crm.analytics.save": z.object({ ok: z.boolean(), panelId: z.string() }),
|
|
4476
|
+
"crm.analytics.update": z.object({ ok: z.boolean(), panel: analyticsPanel }),
|
|
4477
|
+
"crm.analytics.hide": z.object({ ok: z.boolean(), panel: analyticsPanel }),
|
|
4478
|
+
"crm.analytics.show": z.object({ ok: z.boolean(), panel: analyticsPanel }),
|
|
4479
|
+
"crm.analytics.resize": z.object({ ok: z.boolean(), panel: analyticsPanel }),
|
|
4480
|
+
"crm.analytics.delete": z.object({ ok: z.boolean(), removed: z.boolean() }),
|
|
4481
|
+
"crm.analytics.reorder": okResponse,
|
|
4482
|
+
"crm.analytics.roles": z.object({
|
|
4483
|
+
ok: z.boolean(),
|
|
4484
|
+
fieldRoles: analyticsFieldRoles.describe(
|
|
4485
|
+
"The mapping as stored after the write.",
|
|
4486
|
+
),
|
|
4487
|
+
}),
|
|
4488
|
+
"crm.analytics.collapse": okResponse,
|
|
4489
|
+
"crm.analytics.expand": okResponse,
|
|
4490
|
+
"crm.analytics.scope": z.object({ ok: z.boolean(), changed: z.boolean() }),
|
|
4491
|
+
|
|
3997
4492
|
};
|
|
3998
4493
|
|
|
3999
4494
|
// ---------------------------------------------------------------------------
|
|
@@ -4080,6 +4575,58 @@ export const convexExtras: Record<string, ConvexExtras> = {
|
|
|
4080
4575
|
};
|
|
4081
4576
|
},
|
|
4082
4577
|
},
|
|
4578
|
+
"crm.analytics.collapse": { fixedArgs: { collapsed: true } },
|
|
4579
|
+
"crm.analytics.expand": { fixedArgs: { collapsed: false } },
|
|
4580
|
+
// hide / show / resize are `updateAnalyticsPanel` with a one-key patch.
|
|
4581
|
+
"crm.analytics.hide": { fixedArgs: { patch: { hidden: true } } },
|
|
4582
|
+
"crm.analytics.show": { fixedArgs: { patch: { hidden: false } } },
|
|
4583
|
+
"crm.analytics.resize": {
|
|
4584
|
+
transformArgs: (input) => {
|
|
4585
|
+
const { span, ...rest } = input as { span?: unknown } & Record<
|
|
4586
|
+
string,
|
|
4587
|
+
unknown
|
|
4588
|
+
>;
|
|
4589
|
+
return { ...rest, patch: { span: span ?? null } };
|
|
4590
|
+
},
|
|
4591
|
+
},
|
|
4592
|
+
// PUT /crm/objects/{objectName}/analytics/panels/{panelId} — the path's
|
|
4593
|
+
// panelId is the upsert key: fold it into `panel.id`.
|
|
4594
|
+
"crm.analytics.save": {
|
|
4595
|
+
transformArgs: (input) => {
|
|
4596
|
+
const { panelId, panel, ...rest } = input as {
|
|
4597
|
+
panelId?: unknown;
|
|
4598
|
+
panel?: unknown;
|
|
4599
|
+
} & Record<string, unknown>;
|
|
4600
|
+
const basePanel =
|
|
4601
|
+
panel && typeof panel === "object" && !Array.isArray(panel)
|
|
4602
|
+
? (panel as Record<string, unknown>)
|
|
4603
|
+
: {};
|
|
4604
|
+
return {
|
|
4605
|
+
...rest,
|
|
4606
|
+
panel: { ...basePanel, id: String(panelId ?? basePanel.id ?? "") },
|
|
4607
|
+
};
|
|
4608
|
+
},
|
|
4609
|
+
},
|
|
4610
|
+
"crm.entries.updateMany": {
|
|
4611
|
+
transformArgs: (input) => {
|
|
4612
|
+
const updates = Array.isArray(input.updates) ? input.updates : [];
|
|
4613
|
+
return {
|
|
4614
|
+
ops: updates.map((raw) => {
|
|
4615
|
+
const update = (raw ?? {}) as {
|
|
4616
|
+
entryId?: unknown;
|
|
4617
|
+
id?: unknown;
|
|
4618
|
+
data?: unknown;
|
|
4619
|
+
};
|
|
4620
|
+
return {
|
|
4621
|
+
type: "entries.update",
|
|
4622
|
+
entryId: String(update.entryId ?? update.id ?? ""),
|
|
4623
|
+
data: update.data ?? {},
|
|
4624
|
+
};
|
|
4625
|
+
}),
|
|
4626
|
+
};
|
|
4627
|
+
},
|
|
4628
|
+
},
|
|
4629
|
+
|
|
4083
4630
|
};
|
|
4084
4631
|
|
|
4085
4632
|
// ---------------------------------------------------------------------------
|
|
@@ -4361,6 +4908,45 @@ export const requestExamples: Record<string, unknown> = {
|
|
|
4361
4908
|
],
|
|
4362
4909
|
},
|
|
4363
4910
|
"email.campaign.preview": { sample: 5 },
|
|
4911
|
+
"crm.analytics.compute": {
|
|
4912
|
+
period: "this_month",
|
|
4913
|
+
panels: [
|
|
4914
|
+
{
|
|
4915
|
+
id: "adhoc:leads-by-source",
|
|
4916
|
+
title: "New leads by source",
|
|
4917
|
+
type: "donut",
|
|
4918
|
+
metric: "count",
|
|
4919
|
+
groupBy: "Source",
|
|
4920
|
+
sortOrder: 0,
|
|
4921
|
+
},
|
|
4922
|
+
],
|
|
4923
|
+
},
|
|
4924
|
+
"crm.analytics.save": {
|
|
4925
|
+
panel: {
|
|
4926
|
+
title: "Open pipeline",
|
|
4927
|
+
type: "stat",
|
|
4928
|
+
metric: "sum",
|
|
4929
|
+
derived: "open_pipeline",
|
|
4930
|
+
sortOrder: 10,
|
|
4931
|
+
},
|
|
4932
|
+
},
|
|
4933
|
+
"crm.analytics.reorder": {
|
|
4934
|
+
panelIds: ["tpl:sales:total-leads", "tpl:sales:leads-by-source"],
|
|
4935
|
+
},
|
|
4936
|
+
"crm.analytics.roles": {
|
|
4937
|
+
fieldRoles: {
|
|
4938
|
+
amount: "Amount",
|
|
4939
|
+
stage: "Stage",
|
|
4940
|
+
wonValues: ["Closed Won"],
|
|
4941
|
+
lostValues: ["Closed Lost"],
|
|
4942
|
+
closeDate: "Close Date",
|
|
4943
|
+
owner: "Owner",
|
|
4944
|
+
location: "Account.HQ Location",
|
|
4945
|
+
recurrence: "annual",
|
|
4946
|
+
},
|
|
4947
|
+
},
|
|
4948
|
+
"crm.analytics.scope": { mode: "own" },
|
|
4949
|
+
|
|
4364
4950
|
};
|
|
4365
4951
|
|
|
4366
4952
|
// ---------------------------------------------------------------------------
|
|
@@ -5865,4 +6451,64 @@ export const responseExamples: Record<string, unknown> = {
|
|
|
5865
6451
|
userTimezone: null,
|
|
5866
6452
|
organizationId: "org_abc123",
|
|
5867
6453
|
},
|
|
6454
|
+
"crm.analytics.get": {
|
|
6455
|
+
objectName: "lead",
|
|
6456
|
+
analytics: {
|
|
6457
|
+
panels: [
|
|
6458
|
+
{
|
|
6459
|
+
id: "tpl:sales:total-leads",
|
|
6460
|
+
title: "Total leads",
|
|
6461
|
+
type: "stat",
|
|
6462
|
+
metric: "count",
|
|
6463
|
+
sortOrder: 0,
|
|
6464
|
+
},
|
|
6465
|
+
{
|
|
6466
|
+
id: "tpl:sales:leads-by-source",
|
|
6467
|
+
title: "Leads by source",
|
|
6468
|
+
type: "donut",
|
|
6469
|
+
metric: "count",
|
|
6470
|
+
groupBy: "Source",
|
|
6471
|
+
sortOrder: 1,
|
|
6472
|
+
},
|
|
6473
|
+
],
|
|
6474
|
+
fieldRoles: { stage: "Status", convertedValues: ["Qualified"] },
|
|
6475
|
+
stripCollapsed: false,
|
|
6476
|
+
},
|
|
6477
|
+
viewAnalytics: null,
|
|
6478
|
+
viewExists: false,
|
|
6479
|
+
fields: [
|
|
6480
|
+
{
|
|
6481
|
+
name: "Status",
|
|
6482
|
+
type: "enum",
|
|
6483
|
+
enumValues: ["New", "Qualified"],
|
|
6484
|
+
enumColors: null,
|
|
6485
|
+
},
|
|
6486
|
+
{ name: "$createdAt", type: "date", enumValues: null, enumColors: null },
|
|
6487
|
+
],
|
|
6488
|
+
},
|
|
6489
|
+
"crm.analytics.compute": {
|
|
6490
|
+
objectName: "lead",
|
|
6491
|
+
truncated: false,
|
|
6492
|
+
scannedRows: 42,
|
|
6493
|
+
panels: [
|
|
6494
|
+
{
|
|
6495
|
+
id: "adhoc:leads-by-source",
|
|
6496
|
+
unit: "number",
|
|
6497
|
+
value: 42,
|
|
6498
|
+
previousValue: 31,
|
|
6499
|
+
buckets: [
|
|
6500
|
+
{ key: "Website", label: "Website", count: 25, value: 25 },
|
|
6501
|
+
{ key: "Referral", label: "Referral", count: 17, value: 17 },
|
|
6502
|
+
],
|
|
6503
|
+
},
|
|
6504
|
+
],
|
|
6505
|
+
},
|
|
6506
|
+
"crm.analytics.save": { ok: true, panelId: "adhoc:open-pipeline" },
|
|
6507
|
+
"crm.analytics.delete": { ok: true, removed: true },
|
|
6508
|
+
"crm.analytics.reorder": { ok: true },
|
|
6509
|
+
"crm.analytics.roles": { ok: true },
|
|
6510
|
+
"crm.analytics.collapse": { ok: true },
|
|
6511
|
+
"crm.analytics.expand": { ok: true },
|
|
6512
|
+
"crm.analytics.scope": { ok: true, changed: true },
|
|
6513
|
+
|
|
5868
6514
|
};
|