@dench.com/cli 3.0.1-staging.284 → 3.0.3-staging.286
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 +69 -6
- package/crm-analytics.ts +16 -0
- package/crm.ts +65 -2
- package/lib/api-schemas.ts +56 -1
- package/package.json +1 -1
package/app-sdk.d.ts
CHANGED
|
@@ -273,6 +273,10 @@ export interface ApiRequests {
|
|
|
273
273
|
viewName: string;
|
|
274
274
|
page?: number;
|
|
275
275
|
pageSize?: number;
|
|
276
|
+
/** Personal scope: "me" (the signed-in member / the human behind an agent session), "unassigned", or a member userId or email. Adds one has_any / is_empty rule on the object's assignee user field; rows, totalCount, sums and analytics all follow it. Never saved onto the view. */
|
|
277
|
+
assignedTo?: string;
|
|
278
|
+
/** Which `user` field "assigned" means. Default: the analytics owner role, else the task `Assignee`, else a user field named like owner/assignee, else the first user field. */
|
|
279
|
+
assigneeField?: string;
|
|
276
280
|
};
|
|
277
281
|
/** Create a saved view (named filters/sort/columns combo) on a CRM object. — `dench crm views create` — POST /api/v1/crm/objects/{objectName}/views */
|
|
278
282
|
"crm.views.create": {
|
|
@@ -493,6 +497,10 @@ export interface ApiRequests {
|
|
|
493
497
|
"crm.entries.list": {
|
|
494
498
|
objectName: string;
|
|
495
499
|
limit?: number;
|
|
500
|
+
/** Personal scope: "me" (the signed-in member / the human behind an agent session), "unassigned", or a member userId or email. Adds one has_any / is_empty rule on the object's assignee user field; rows, totalCount, sums and analytics all follow it. Never saved onto the view. */
|
|
501
|
+
assignedTo?: string;
|
|
502
|
+
/** Which `user` field "assigned" means. Default: the analytics owner role, else the task `Assignee`, else a user field named like owner/assignee, else the first user field. */
|
|
503
|
+
assigneeField?: string;
|
|
496
504
|
};
|
|
497
505
|
/** Get a CRM entry. — `dench crm entries get` — GET /api/v1/crm/objects/{objectName}/entries/{entryId} */
|
|
498
506
|
"crm.entries.get": {
|
|
@@ -783,6 +791,10 @@ export interface ApiRequests {
|
|
|
783
791
|
};
|
|
784
792
|
/** JSON string of the DSL when filters use operators like $gt/$in/$contains/$and/$or. Date fields and the system timestamps created_at/updated_at also accept $datePreset ("today", "yesterday", "this_week", "last_week", "this_month", "last_month", "this_quarter", "last_quarter", "this_year", "last_year"), and $inLast/$inNext rolling windows (a day count like 7, or {"amount":2,"unit":"weeks"} with unit days|weeks|months|quarters|years). Example: {"filter":{"updated_at":{"$datePreset":"this_month"}}}. */
|
|
785
793
|
dslJson?: string;
|
|
794
|
+
/** Personal scope: "me" (the signed-in member / the human behind an agent session), "unassigned", or a member userId or email. Adds one has_any / is_empty rule on the object's assignee user field; rows, totalCount, sums and analytics all follow it. Never saved onto the view. */
|
|
795
|
+
assignedTo?: string;
|
|
796
|
+
/** Which `user` field "assigned" means. Default: the analytics owner role, else the task `Assignee`, else a user field named like owner/assignee, else the first user field. */
|
|
797
|
+
assigneeField?: string;
|
|
786
798
|
};
|
|
787
799
|
/** Run CRM SQL-compatible query. — `dench crm sql` — POST /api/v1/crm/sql */
|
|
788
800
|
"crm.sql": {
|
|
@@ -1063,9 +1075,13 @@ export interface ApiRequests {
|
|
|
1063
1075
|
/** Chance of closing per OPEN stage, 0..1, for the weighted forecast. Unlisted stages are spaced evenly; won = 1, lost = 0. */
|
|
1064
1076
|
stageProbabilities?: Record<string, number>;
|
|
1065
1077
|
};
|
|
1078
|
+
/** Personal scope: "me" (the signed-in member / the human behind an agent session), "unassigned", or a member userId or email. Adds one has_any / is_empty rule on the object's assignee user field; rows, totalCount, sums and analytics all follow it. Never saved onto the view. */
|
|
1079
|
+
assignedTo?: string;
|
|
1080
|
+
/** Which `user` field "assigned" means. Default: the analytics owner role, else the task `Assignee`, else a user field named like owner/assignee, else the first user field. */
|
|
1081
|
+
assigneeField?: string;
|
|
1066
1082
|
/** Click-to-filter chips, same as the strip: each scopes every panel EXCEPT those whose dimensions include `dimension`. */
|
|
1067
1083
|
drillFilters?: {
|
|
1068
|
-
/**
|
|
1084
|
+
/** The bare field the click came from — a panel's groupBy or dateField, or `$location` for a map. Panels drawn along it keep their full picture; every other panel is scoped. */
|
|
1069
1085
|
dimension: string;
|
|
1070
1086
|
/** FilterGroup selecting the clicked bucket. */
|
|
1071
1087
|
filter: Record<string, unknown>;
|
|
@@ -1966,9 +1982,20 @@ export interface ApiRequests {
|
|
|
1966
1982
|
slug?: string;
|
|
1967
1983
|
};
|
|
1968
1984
|
/** Read a workspace file's text. — `dench files cat` — GET /api/v1/files/content */
|
|
1969
|
-
"files.content":
|
|
1985
|
+
"files.content": {
|
|
1986
|
+
/** Workspace file path, e.g. /reports/q2.md. A leading /workspace/ mount prefix is stripped. */
|
|
1987
|
+
path: string;
|
|
1988
|
+
slug?: string;
|
|
1989
|
+
};
|
|
1970
1990
|
/** Write a workspace file's text. — `dench files write` — PUT /api/v1/files/content */
|
|
1971
|
-
"files.write":
|
|
1991
|
+
"files.write": {
|
|
1992
|
+
/** Workspace file path, e.g. /reports/q2.md. A leading /workspace/ mount prefix is stripped. */
|
|
1993
|
+
path: string;
|
|
1994
|
+
/** Full replacement text (UTF-8, <= 400 KB). */
|
|
1995
|
+
content: string;
|
|
1996
|
+
/** contentHash from the last read; the write is rejected with version_mismatch if the file changed since. */
|
|
1997
|
+
expectedPreviousHash?: string;
|
|
1998
|
+
};
|
|
1972
1999
|
/** Get a signed file download URL. — `dench files download` — GET /api/v1/files/download-url */
|
|
1973
2000
|
"files.downloadUrl": {
|
|
1974
2001
|
path: string;
|
|
@@ -3001,7 +3028,27 @@ export interface ApiResponses {
|
|
|
3001
3028
|
views: Record<string, unknown>[];
|
|
3002
3029
|
};
|
|
3003
3030
|
"crm.views.get": Record<string, unknown>;
|
|
3004
|
-
"crm.views.entries":
|
|
3031
|
+
"crm.views.entries": {
|
|
3032
|
+
/** Materialized rows: id, entry_id, created_at, updated_at plus one key per field. */
|
|
3033
|
+
entries: Record<string, unknown>[];
|
|
3034
|
+
totalCount: number;
|
|
3035
|
+
page: number;
|
|
3036
|
+
pageSize: number;
|
|
3037
|
+
/** True when the read hit a server budget and rows may be missing. */
|
|
3038
|
+
truncated: boolean;
|
|
3039
|
+
/** The personal assignee scope that was applied, or null. */
|
|
3040
|
+
assigneeScope: {
|
|
3041
|
+
/** The user field the scope keyed on. */
|
|
3042
|
+
field: string;
|
|
3043
|
+
target: {
|
|
3044
|
+
kind: "user";
|
|
3045
|
+
userId: string;
|
|
3046
|
+
} | {
|
|
3047
|
+
kind: "unassigned";
|
|
3048
|
+
};
|
|
3049
|
+
} | null;
|
|
3050
|
+
[key: string]: unknown;
|
|
3051
|
+
};
|
|
3005
3052
|
"crm.views.create": {
|
|
3006
3053
|
ok: boolean;
|
|
3007
3054
|
objectName: string;
|
|
@@ -4915,8 +4962,24 @@ export interface ApiResponses {
|
|
|
4915
4962
|
virtual?: boolean;
|
|
4916
4963
|
[key: string]: unknown;
|
|
4917
4964
|
}[];
|
|
4918
|
-
"files.content":
|
|
4919
|
-
|
|
4965
|
+
"files.content": {
|
|
4966
|
+
path: string;
|
|
4967
|
+
isDir: boolean;
|
|
4968
|
+
virtual: boolean;
|
|
4969
|
+
size: number | null;
|
|
4970
|
+
mtime?: number | null;
|
|
4971
|
+
/** Inline text, or null for binary / uncached files. */
|
|
4972
|
+
content: string | null;
|
|
4973
|
+
encoding: string | null;
|
|
4974
|
+
contentHash?: string | null;
|
|
4975
|
+
downloadable: boolean;
|
|
4976
|
+
[key: string]: unknown;
|
|
4977
|
+
} | null;
|
|
4978
|
+
"files.write": {
|
|
4979
|
+
/** Normalized workspace path that was written. */
|
|
4980
|
+
path: string;
|
|
4981
|
+
contentHash: string;
|
|
4982
|
+
};
|
|
4920
4983
|
"files.downloadUrl": string | null;
|
|
4921
4984
|
"files.delete": {
|
|
4922
4985
|
path: string;
|
package/crm-analytics.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* get [--view V] read config (+ the view's own dashboard)
|
|
10
10
|
* compute [--view V] [--period P] [--panel ID ...] [--panels JSON] [--filters JSON]
|
|
11
|
+
* [--assigned-to me|unassigned|<user>] [--assignee-field F] personal scope
|
|
11
12
|
* save <panelId> --panel JSON [--view V] create / replace one panel
|
|
12
13
|
* update <panelId> --patch JSON [--view V] edit part of one panel (null clears)
|
|
13
14
|
* hide <panelId> [--view V] keep it off the strip (full view only)
|
|
@@ -32,6 +33,7 @@ import {
|
|
|
32
33
|
callMutation,
|
|
33
34
|
callQuery,
|
|
34
35
|
out,
|
|
36
|
+
resolveAssigneeScopeFlags,
|
|
35
37
|
shift,
|
|
36
38
|
} from "./crm";
|
|
37
39
|
import { getFlag, hasFlag, parseJson } from "./lib/cli-args";
|
|
@@ -217,6 +219,9 @@ export function analyticsDeepLink(args: {
|
|
|
217
219
|
objectName: string;
|
|
218
220
|
viewName?: string;
|
|
219
221
|
period?: string;
|
|
222
|
+
/** Personal assignee scope the numbers were computed under (`?assignee=`). */
|
|
223
|
+
assignedTo?: string;
|
|
224
|
+
assigneeField?: string;
|
|
220
225
|
host?: string;
|
|
221
226
|
workspaceSlug?: string;
|
|
222
227
|
}): { href: string; url?: string } {
|
|
@@ -226,6 +231,10 @@ export function analyticsDeepLink(args: {
|
|
|
226
231
|
params.set("analytics", "1");
|
|
227
232
|
if (args.period && args.period !== "all")
|
|
228
233
|
params.set("analyticsPeriod", args.period);
|
|
234
|
+
if (args.assignedTo) {
|
|
235
|
+
params.set("assignee", args.assignedTo);
|
|
236
|
+
if (args.assigneeField) params.set("assigneeField", args.assigneeField);
|
|
237
|
+
}
|
|
229
238
|
const href = `/?${params.toString()}`;
|
|
230
239
|
const slug = args.workspaceSlug?.trim();
|
|
231
240
|
const host = args.host?.trim();
|
|
@@ -260,6 +269,7 @@ export async function runAnalyticsCommand(ctx: CrmCliContext): Promise<void> {
|
|
|
260
269
|
const extraFilters = parseObjectFlag(ctx.args, "--filters");
|
|
261
270
|
const compareFilters = parseObjectFlag(ctx.args, "--compare-filters");
|
|
262
271
|
const rolesOverride = parseObjectFlag(ctx.args, "--roles");
|
|
272
|
+
const assigneeScopeArgs = resolveAssigneeScopeFlags(ctx.args);
|
|
263
273
|
assertNoUnknownFlags(ctx.args, "crm analytics compute");
|
|
264
274
|
if (panelIds.length > 0 && adhoc) {
|
|
265
275
|
throw new CrmCliError(
|
|
@@ -279,17 +289,23 @@ export async function runAnalyticsCommand(ctx: CrmCliContext): Promise<void> {
|
|
|
279
289
|
...(extraFilters ? { extraFilters } : {}),
|
|
280
290
|
...(compareFilters ? { compareFilters } : {}),
|
|
281
291
|
...(rolesOverride ? { fieldRolesOverride: rolesOverride } : {}),
|
|
292
|
+
...assigneeScopeArgs,
|
|
282
293
|
})) as Record<string, unknown>;
|
|
283
294
|
const link = analyticsDeepLink({
|
|
284
295
|
objectName,
|
|
285
296
|
viewName: "viewName" in view ? view.viewName : undefined,
|
|
286
297
|
period,
|
|
298
|
+
assignedTo: assigneeScopeArgs.assignedTo,
|
|
299
|
+
assigneeField: assigneeScopeArgs.assigneeField,
|
|
287
300
|
host: ctx.host,
|
|
288
301
|
workspaceSlug: ctx.workspaceSlug,
|
|
289
302
|
});
|
|
290
303
|
out(ctx, {
|
|
291
304
|
...result,
|
|
292
305
|
...(period ? { period } : {}),
|
|
306
|
+
...(assigneeScopeArgs.assignedTo
|
|
307
|
+
? { assignedTo: assigneeScopeArgs.assignedTo }
|
|
308
|
+
: {}),
|
|
293
309
|
link: link.url ?? link.href,
|
|
294
310
|
});
|
|
295
311
|
return;
|
package/crm.ts
CHANGED
|
@@ -291,6 +291,51 @@ function resolveLimitFlag(
|
|
|
291
291
|
return parsed;
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
+
/**
|
|
295
|
+
* The personal assignee scope flags shared by every read that supports it
|
|
296
|
+
* (`views entries`, `entries list`, `query`, `analytics compute`):
|
|
297
|
+
*
|
|
298
|
+
* --assigned-to me|unassigned|<userId|email> (alias: --mine)
|
|
299
|
+
* --assignee-field <Field> which `user` field counts
|
|
300
|
+
*
|
|
301
|
+
* Forwarded verbatim as `assignedTo` / `assigneeField`; the server resolves
|
|
302
|
+
* "me", validates the member and picks the field (owner role → Assignee →
|
|
303
|
+
* name → first user field). Drains the flags so `assertNoUnknownFlags`
|
|
304
|
+
* stays honest.
|
|
305
|
+
*/
|
|
306
|
+
export function resolveAssigneeScopeFlags(args: string[]): {
|
|
307
|
+
assignedTo?: string;
|
|
308
|
+
assigneeField?: string;
|
|
309
|
+
} {
|
|
310
|
+
const assignedToRaw = getFlagWithAliases(args, "--assigned-to", [
|
|
311
|
+
"--assignedTo",
|
|
312
|
+
]);
|
|
313
|
+
const mine = hasFlag(args, "--mine");
|
|
314
|
+
const assigneeField = getFlagWithAliases(args, "--assignee-field", [
|
|
315
|
+
"--assigneeField",
|
|
316
|
+
]);
|
|
317
|
+
if (mine && assignedToRaw !== undefined) {
|
|
318
|
+
throw new CrmCliError(
|
|
319
|
+
"--mine and --assigned-to are the same switch; pass one of them.",
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
const assignedTo = mine ? "me" : assignedToRaw?.trim();
|
|
323
|
+
if (assignedTo !== undefined && assignedTo === "") {
|
|
324
|
+
throw new CrmCliError(
|
|
325
|
+
"--assigned-to needs a value: me, unassigned, or a member userId / email.",
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
if (assigneeField !== undefined && assignedTo === undefined) {
|
|
329
|
+
throw new CrmCliError(
|
|
330
|
+
"--assignee-field only makes sense with --assigned-to (or --mine).",
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
return {
|
|
334
|
+
...(assignedTo !== undefined ? { assignedTo } : {}),
|
|
335
|
+
...(assigneeField?.trim() ? { assigneeField: assigneeField.trim() } : {}),
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
|
|
294
339
|
/**
|
|
295
340
|
* Reject curl-style `--data @rows.json`. The CLI never reads files off
|
|
296
341
|
* an `@` prefix — the literal string "@rows.json" would be parsed as
|
|
@@ -1757,6 +1802,7 @@ async function runViewsCommand(ctx: CrmCliContext): Promise<void> {
|
|
|
1757
1802
|
10,
|
|
1758
1803
|
);
|
|
1759
1804
|
const withMeta = hasFlag(ctx.args, "--with-meta");
|
|
1805
|
+
const assigneeScopeArgs = resolveAssigneeScopeFlags(ctx.args);
|
|
1760
1806
|
assertNoUnknownFlags(ctx.args, "crm views entries");
|
|
1761
1807
|
if (!Number.isFinite(page) || page < 1) {
|
|
1762
1808
|
throw new CrmCliError(`--page must be a positive integer, got ${page}`);
|
|
@@ -1789,6 +1835,7 @@ async function runViewsCommand(ctx: CrmCliContext): Promise<void> {
|
|
|
1789
1835
|
sort: Array.isArray(view.sort) ? view.sort : undefined,
|
|
1790
1836
|
pinnedEntryIds,
|
|
1791
1837
|
includeReverseRelations: false,
|
|
1838
|
+
...assigneeScopeArgs,
|
|
1792
1839
|
}),
|
|
1793
1840
|
)) as {
|
|
1794
1841
|
entries?: unknown[];
|
|
@@ -1796,6 +1843,7 @@ async function runViewsCommand(ctx: CrmCliContext): Promise<void> {
|
|
|
1796
1843
|
page?: number;
|
|
1797
1844
|
pageSize?: number;
|
|
1798
1845
|
truncated?: boolean;
|
|
1846
|
+
assigneeScope?: unknown;
|
|
1799
1847
|
} | null;
|
|
1800
1848
|
|
|
1801
1849
|
if (!materialized) {
|
|
@@ -1831,6 +1879,7 @@ async function runViewsCommand(ctx: CrmCliContext): Promise<void> {
|
|
|
1831
1879
|
page: materialized.page ?? page,
|
|
1832
1880
|
pageSize: materialized.pageSize ?? pageSize,
|
|
1833
1881
|
truncated: materialized.truncated ?? false,
|
|
1882
|
+
assigneeScope: materialized.assigneeScope ?? null,
|
|
1834
1883
|
entries,
|
|
1835
1884
|
});
|
|
1836
1885
|
return;
|
|
@@ -2284,10 +2333,12 @@ async function runEntriesCommand(ctx: CrmCliContext): Promise<void> {
|
|
|
2284
2333
|
command: "crm entries list",
|
|
2285
2334
|
});
|
|
2286
2335
|
const withMeta = hasFlag(ctx.args, "--with-meta");
|
|
2336
|
+
const assigneeScopeArgs = resolveAssigneeScopeFlags(ctx.args);
|
|
2287
2337
|
assertNoUnknownFlags(ctx.args, "crm entries list");
|
|
2288
2338
|
const entries = await callQuery(ctx, api.entries.list, {
|
|
2289
2339
|
objectName,
|
|
2290
2340
|
limit: limit.effective,
|
|
2341
|
+
...assigneeScopeArgs,
|
|
2291
2342
|
});
|
|
2292
2343
|
if (!withMeta) {
|
|
2293
2344
|
// Bare-array output: the clamp warning already went to stderr
|
|
@@ -2813,6 +2864,7 @@ async function runQueryCommand(ctx: CrmCliContext): Promise<void> {
|
|
|
2813
2864
|
cap: 1000,
|
|
2814
2865
|
command: "crm query",
|
|
2815
2866
|
});
|
|
2867
|
+
const assigneeScopeArgs = resolveAssigneeScopeFlags(ctx.args);
|
|
2816
2868
|
assertNoUnknownFlags(ctx.args, "crm query");
|
|
2817
2869
|
// Convex's wire serializer rejects $-prefixed object keys, so we
|
|
2818
2870
|
// route the DSL through the dslJson string field whenever the filter
|
|
@@ -2825,8 +2877,8 @@ async function runQueryCommand(ctx: CrmCliContext): Promise<void> {
|
|
|
2825
2877
|
ctx,
|
|
2826
2878
|
api.query.queryEntries,
|
|
2827
2879
|
hasDollarKey
|
|
2828
|
-
? { objectName, dslJson: JSON.stringify(dsl) }
|
|
2829
|
-
: { objectName, dsl },
|
|
2880
|
+
? { objectName, dslJson: JSON.stringify(dsl), ...assigneeScopeArgs }
|
|
2881
|
+
: { objectName, dsl, ...assigneeScopeArgs },
|
|
2830
2882
|
),
|
|
2831
2883
|
);
|
|
2832
2884
|
}
|
|
@@ -4354,6 +4406,12 @@ Views (saved CRM subsets):
|
|
|
4354
4406
|
dench crm views list <object> [--json]
|
|
4355
4407
|
dench crm views get <object> <view-name> [--json]
|
|
4356
4408
|
dench crm views entries <object> <view-name> [--limit N] [--page N] [--with-meta] [--json]
|
|
4409
|
+
[--assigned-to me|unassigned|<userId|email>] [--assignee-field <Field>]
|
|
4410
|
+
--assigned-to (alias --mine) is the PERSONAL scope the toolbar's
|
|
4411
|
+
avatar pill applies: rows whose people field includes that member
|
|
4412
|
+
(or is empty for "unassigned"). It never touches the saved view.
|
|
4413
|
+
The field defaults to the analytics owner role → Assignee → a
|
|
4414
|
+
field named like owner/assignee → the first user field.
|
|
4357
4415
|
dench crm views create <object> <view-name> [--where '{"Status":"Hot"}']
|
|
4358
4416
|
[--filters '<FilterGroup JSON>'] [--sort '-Score' | --sort '[{"field":"Score","direction":"desc"}]']
|
|
4359
4417
|
[--columns Name,Email] [--type table|kanban|calendar|timeline|gallery|list]
|
|
@@ -4470,6 +4528,7 @@ Fields (columns):
|
|
|
4470
4528
|
|
|
4471
4529
|
Entries (rows):
|
|
4472
4530
|
dench crm entries list <object> [--limit N] [--with-meta] [--json]
|
|
4531
|
+
[--assigned-to me|unassigned|<userId|email> | --mine] [--assignee-field <Field>]
|
|
4473
4532
|
dench crm entries get <object> <entryId>
|
|
4474
4533
|
dench crm history <object> <entryId> [--include-system] [--limit N] [--cursor CURSOR] [--json]
|
|
4475
4534
|
|
|
@@ -4548,6 +4607,9 @@ Cells (single-field updates):
|
|
|
4548
4607
|
|
|
4549
4608
|
Query DSL:
|
|
4550
4609
|
dench crm query <object> --where '{"Status":"New"}' --select Name,Email --sort -Score --limit 100
|
|
4610
|
+
[--assigned-to me|unassigned|<userId|email> | --mine] [--assignee-field <Field>]
|
|
4611
|
+
--mine AND-s "assigned to me" onto --where without you having to
|
|
4612
|
+
know your own userId or the object's people field.
|
|
4551
4613
|
Operators: $eq $ne $in $nin $gt $gte $lt $lte $exists
|
|
4552
4614
|
$startsWith $endsWith $contains, plus logical $and / $or.
|
|
4553
4615
|
Date operators (work on date fields and the system timestamps
|
|
@@ -4639,6 +4701,7 @@ Analytics (the dashboard strip above every object table — same math the UI dra
|
|
|
4639
4701
|
that saved view's own dashboard (viewAnalytics; null when it inherits).
|
|
4640
4702
|
dench crm analytics compute <object> [--view <view-name>] [--period this_week|this_month|last_month|this_quarter|last_quarter|this_year]
|
|
4641
4703
|
[--panel <id> ...] [--panels '<JSON array of panel defs>'] [--filters '<FilterGroup JSON>'] [--json]
|
|
4704
|
+
[--assigned-to me|unassigned|<userId|email> | --mine] [--assignee-field <Field>]
|
|
4642
4705
|
Chart-ready buckets / series / values for the stored dashboard, a
|
|
4643
4706
|
subset of its panels (--panel), or ad-hoc definitions (--panels; nothing
|
|
4644
4707
|
is persisted). --period scopes every panel AND fills previousValue from
|
package/lib/api-schemas.ts
CHANGED
|
@@ -197,6 +197,36 @@ const dataMap = z
|
|
|
197
197
|
"Field-name -> value map. For `user` fields use one member userId or a userId array; preserve every assignee.",
|
|
198
198
|
);
|
|
199
199
|
|
|
200
|
+
/**
|
|
201
|
+
* The personal assignee scope — the same two arguments on every read that
|
|
202
|
+
* supports it. Never part of the saved view; the caller's preference.
|
|
203
|
+
*/
|
|
204
|
+
const assigneeScopeRequest = {
|
|
205
|
+
assignedTo: z
|
|
206
|
+
.string()
|
|
207
|
+
.optional()
|
|
208
|
+
.describe(
|
|
209
|
+
'Personal scope: "me" (the signed-in member / the human behind an agent session), "unassigned", or a member userId or email. Adds one has_any / is_empty rule on the object\'s assignee user field; rows, totalCount, sums and analytics all follow it. Never saved onto the view.',
|
|
210
|
+
),
|
|
211
|
+
assigneeField: z
|
|
212
|
+
.string()
|
|
213
|
+
.optional()
|
|
214
|
+
.describe(
|
|
215
|
+
'Which `user` field "assigned" means. Default: the analytics owner role, else the task `Assignee`, else a user field named like owner/assignee, else the first user field.',
|
|
216
|
+
),
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
const assigneeScopeResponse = z
|
|
220
|
+
.object({
|
|
221
|
+
field: z.string().describe("The user field the scope keyed on."),
|
|
222
|
+
target: z.union([
|
|
223
|
+
z.object({ kind: z.literal("user"), userId: z.string() }),
|
|
224
|
+
z.object({ kind: z.literal("unassigned") }),
|
|
225
|
+
]),
|
|
226
|
+
})
|
|
227
|
+
.nullable()
|
|
228
|
+
.describe("The personal assignee scope that was applied, or null.");
|
|
229
|
+
|
|
200
230
|
const cellValue = z
|
|
201
231
|
.unknown()
|
|
202
232
|
.describe(
|
|
@@ -2520,6 +2550,7 @@ export const requestSchemas: Record<string, ZodTypeAny> = {
|
|
|
2520
2550
|
viewName: z.string(),
|
|
2521
2551
|
page: z.number().int().min(1).optional(),
|
|
2522
2552
|
pageSize: z.number().int().min(1).optional(),
|
|
2553
|
+
...assigneeScopeRequest,
|
|
2523
2554
|
}),
|
|
2524
2555
|
"crm.views.create": z.object({
|
|
2525
2556
|
objectName: z.string(),
|
|
@@ -2667,6 +2698,7 @@ export const requestSchemas: Record<string, ZodTypeAny> = {
|
|
|
2667
2698
|
"crm.entries.list": z.object({
|
|
2668
2699
|
objectName: z.string(),
|
|
2669
2700
|
limit: z.coerce.number().int().min(1).max(1000).optional(),
|
|
2701
|
+
...assigneeScopeRequest,
|
|
2670
2702
|
}),
|
|
2671
2703
|
"crm.entries.get": z.object({
|
|
2672
2704
|
objectName: z.string(),
|
|
@@ -3064,6 +3096,7 @@ export const requestSchemas: Record<string, ZodTypeAny> = {
|
|
|
3064
3096
|
"with unit days|weeks|months|quarters|years). " +
|
|
3065
3097
|
'Example: {"filter":{"updated_at":{"$datePreset":"this_month"}}}.',
|
|
3066
3098
|
),
|
|
3099
|
+
...assigneeScopeRequest,
|
|
3067
3100
|
}),
|
|
3068
3101
|
"crm.sql": z.object({
|
|
3069
3102
|
objectName: z.string(),
|
|
@@ -3628,13 +3661,14 @@ export const requestSchemas: Record<string, ZodTypeAny> = {
|
|
|
3628
3661
|
fieldRolesOverride: analyticsFieldRoles
|
|
3629
3662
|
.optional()
|
|
3630
3663
|
.describe("Preview an unsaved role mapping."),
|
|
3664
|
+
...assigneeScopeRequest,
|
|
3631
3665
|
drillFilters: z
|
|
3632
3666
|
.array(
|
|
3633
3667
|
z.object({
|
|
3634
3668
|
dimension: z
|
|
3635
3669
|
.string()
|
|
3636
3670
|
.describe(
|
|
3637
|
-
"
|
|
3671
|
+
"The bare field the click came from — a panel's groupBy or dateField, or `$location` for a map. Panels drawn along it keep their full picture; every other panel is scoped.",
|
|
3638
3672
|
),
|
|
3639
3673
|
filter: z
|
|
3640
3674
|
.record(z.string(), z.unknown())
|
|
@@ -4083,6 +4117,27 @@ export const responseSchemas: Record<string, ZodTypeAny> = {
|
|
|
4083
4117
|
|
|
4084
4118
|
// CRM entries + cells
|
|
4085
4119
|
"crm.entries.list": z.array(crmEntryShape),
|
|
4120
|
+
"crm.views.entries": z
|
|
4121
|
+
.object({
|
|
4122
|
+
entries: z
|
|
4123
|
+
.array(z.record(z.string(), z.unknown()))
|
|
4124
|
+
.describe(
|
|
4125
|
+
"Materialized rows: id, entry_id, created_at, updated_at plus one key per field.",
|
|
4126
|
+
),
|
|
4127
|
+
totalCount: z.number(),
|
|
4128
|
+
page: z.number(),
|
|
4129
|
+
pageSize: z.number(),
|
|
4130
|
+
truncated: z
|
|
4131
|
+
.boolean()
|
|
4132
|
+
.describe(
|
|
4133
|
+
"True when the read hit a server budget and rows may be missing.",
|
|
4134
|
+
),
|
|
4135
|
+
assigneeScope: assigneeScopeResponse,
|
|
4136
|
+
})
|
|
4137
|
+
.passthrough()
|
|
4138
|
+
.describe(
|
|
4139
|
+
"The same payload the workspace table renders from (fields, statuses, savedViews, …).",
|
|
4140
|
+
),
|
|
4086
4141
|
"crm.entries.get": crmEntryShape.nullable(),
|
|
4087
4142
|
"crm.entries.create": entryWriteResponse,
|
|
4088
4143
|
"crm.entries.createMany": z.object({
|