@dench.com/cli 3.11.16-staging.551 → 3.11.17-staging.559

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 CHANGED
@@ -2345,6 +2345,23 @@ export interface ApiRequests {
2345
2345
  "crm.automations.list": Record<string, unknown>;
2346
2346
  /** Enable or disable a CRM automation. — `dench crm automations enable|disable` — PATCH /api/v1/crm/automations/{automationId} */
2347
2347
  "crm.automations.setEnabled": Record<string, unknown>;
2348
+ /** Start a server-side CSV export of a CRM object into the workspace files (/exports). Returns at once; one export runs per workspace, and a second start returns the running one. — `dench crm exports start` — POST /api/v1/crm/exports */
2349
+ "crm.exports.start": {
2350
+ objectName: string;
2351
+ /** Fields to export, in order. Default: every field except the long-text Notes. */
2352
+ columns?: string[];
2353
+ /** Filter in the crm.query DSL, e.g. {"Status":"Open"} or {"Score":{"$gte":50}}. Field names are case-sensitive. */
2354
+ where?: Record<string, unknown>;
2355
+ /** 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. */
2356
+ assignedTo?: string;
2357
+ /** 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. */
2358
+ assigneeField?: string;
2359
+ };
2360
+ /** Read a CRM CSV export's progress, and its file path and download link once done. — `dench crm exports get` — GET /api/v1/crm/exports/{jobId} */
2361
+ "crm.exports.get": {
2362
+ /** jobId returned by crm.exports.start. */
2363
+ jobId: string;
2364
+ };
2348
2365
  /** List meetings, newest first, with status and participants. — `dench meetings list` — GET /api/v1/meetings */
2349
2366
  "meetings.list": {
2350
2367
  limit?: number;
@@ -6345,6 +6362,50 @@ export interface ApiResponses {
6345
6362
  "crm.templates.removeSampleData": unknown;
6346
6363
  "crm.automations.list": unknown;
6347
6364
  "crm.automations.setEnabled": unknown;
6365
+ "crm.exports.start": {
6366
+ jobId: string;
6367
+ status: "running" | "done" | "failed";
6368
+ objectName: string;
6369
+ rowsDone: number;
6370
+ /** Estimated total, only for an unfiltered, unscoped export. */
6371
+ totalRows?: number;
6372
+ /** The export stopped at its 50,000-row cap and more records may match. */
6373
+ truncated: boolean;
6374
+ /** Workspace path once done. */
6375
+ filePath?: string;
6376
+ /** Signed link once done. */
6377
+ downloadUrl?: string;
6378
+ bytes?: number;
6379
+ error?: string;
6380
+ /** One-line status to show the person. */
6381
+ message: string;
6382
+ /** start returned the workspace's running export instead. */
6383
+ alreadyRunning?: boolean;
6384
+ createdAt: number;
6385
+ finishedAt?: number;
6386
+ };
6387
+ "crm.exports.get": {
6388
+ jobId: string;
6389
+ status: "running" | "done" | "failed";
6390
+ objectName: string;
6391
+ rowsDone: number;
6392
+ /** Estimated total, only for an unfiltered, unscoped export. */
6393
+ totalRows?: number;
6394
+ /** The export stopped at its 50,000-row cap and more records may match. */
6395
+ truncated: boolean;
6396
+ /** Workspace path once done. */
6397
+ filePath?: string;
6398
+ /** Signed link once done. */
6399
+ downloadUrl?: string;
6400
+ bytes?: number;
6401
+ error?: string;
6402
+ /** One-line status to show the person. */
6403
+ message: string;
6404
+ /** start returned the workspace's running export instead. */
6405
+ alreadyRunning?: boolean;
6406
+ createdAt: number;
6407
+ finishedAt?: number;
6408
+ };
6348
6409
  "meetings.list": unknown;
6349
6410
  "meetings.transcript.list": unknown;
6350
6411
  "meetings.transcript.append": unknown;
@@ -9206,6 +9267,12 @@ export type DenchApiTree = {
9206
9267
  /** Update many CRM entries. (`dench crm entries update-many`) */
9207
9268
  updateMany(args: Req<"crm.entries.updateMany">): Promise<Res<"crm.entries.updateMany">>;
9208
9269
  };
9270
+ exports: {
9271
+ /** Read a CRM CSV export's progress, and its file path and download link once done. (`dench crm exports get`) */
9272
+ get(args: Req<"crm.exports.get">): Promise<Res<"crm.exports.get">>;
9273
+ /** Start a server-side CSV export of a CRM object into the workspace files (/exports). Returns at once; one export runs per workspace, and a second start returns the running one. (`dench crm exports start`) */
9274
+ start(args: Req<"crm.exports.start">): Promise<Res<"crm.exports.start">>;
9275
+ };
9209
9276
  fields: {
9210
9277
  /** Create a CRM field or read-only campaign activity boolean column. (`dench crm fields create`) */
9211
9278
  create(args: Req<"crm.fields.create">): Promise<Res<"crm.fields.create">>;
package/crm.ts CHANGED
@@ -1116,6 +1116,10 @@ const api = {
1116
1116
  "functions/crm/automations:setEnabled",
1117
1117
  ),
1118
1118
  },
1119
+ exports: {
1120
+ start: makeFunctionReference<"mutation">("functions/crm/export:start"),
1121
+ get: makeFunctionReference<"query">("functions/crm/export:get"),
1122
+ },
1119
1123
  templates: {
1120
1124
  listAvailable: makeFunctionReference<"query">(
1121
1125
  "functions/crm/templates:listAvailable",
@@ -1223,6 +1227,8 @@ Example: dench crm aggregate deal --field Stage --sum Amount --json`);
1223
1227
  return await runImportCommand(ctx);
1224
1228
  case "export":
1225
1229
  return await runExportCommand(ctx);
1230
+ case "exports":
1231
+ return await runExportsCommand(ctx);
1226
1232
  case "transaction":
1227
1233
  return await runTransactionCommand(ctx);
1228
1234
  case "people":
@@ -1289,6 +1295,7 @@ const CRM_SUBCOMMANDS = [
1289
1295
  "batch",
1290
1296
  "import",
1291
1297
  "export",
1298
+ "exports",
1292
1299
  "transaction",
1293
1300
  "people",
1294
1301
  "companies",
@@ -3984,6 +3991,49 @@ async function runExportCommand(ctx: CrmCliContext): Promise<void> {
3984
3991
  );
3985
3992
  }
3986
3993
 
3994
+ /**
3995
+ * `crm exports start|get`: the server-side export. It builds the CSV in the
3996
+ * workspace files (/exports) as a background job, so it works without a
3997
+ * local filesystem; `crm export` still writes to stdout here.
3998
+ */
3999
+ async function runExportsCommand(ctx: CrmCliContext): Promise<void> {
4000
+ const verb = ctx.args.shift();
4001
+ if (verb === "start") {
4002
+ const objectName = shift(ctx.args, "object name");
4003
+ const columns = getFlag(ctx.args, "--columns")
4004
+ ?.split(",")
4005
+ .map((name) => name.trim())
4006
+ .filter(Boolean);
4007
+ const whereRaw = getFlag(ctx.args, "--where");
4008
+ const where =
4009
+ whereRaw === undefined
4010
+ ? undefined
4011
+ : requireNonEmptyJsonRecord(parseJson(whereRaw), "--where");
4012
+ const scope = resolveAssigneeScopeFlags(ctx.args);
4013
+ assertNoUnknownFlags(ctx.args, "crm exports start");
4014
+ out(
4015
+ ctx,
4016
+ await callMutation(ctx, api.exports.start, {
4017
+ objectName,
4018
+ ...(columns?.length ? { columns } : {}),
4019
+ // $-operators cannot be Convex object keys: send the filter as JSON.
4020
+ ...(where ? { filterJson: JSON.stringify(where) } : {}),
4021
+ ...scope,
4022
+ }),
4023
+ );
4024
+ return;
4025
+ }
4026
+ if (verb === "get") {
4027
+ const jobId = shift(ctx.args, "export job id");
4028
+ assertNoUnknownFlags(ctx.args, "crm exports get");
4029
+ out(ctx, await callQuery(ctx, api.exports.get, { jobId }));
4030
+ return;
4031
+ }
4032
+ throw new CrmCliError(
4033
+ "Usage: dench crm exports start <object> [--columns A,B] [--where '<JSON>'] [--assigned-to me] | dench crm exports get <jobId>",
4034
+ );
4035
+ }
4036
+
3987
4037
  export function parseCsv(
3988
4038
  text: string,
3989
4039
  colMap: Record<string, string>,
@@ -5291,6 +5341,11 @@ Import / export:
5291
5341
  dench crm export <object> --format csv|jsonl [--limit N]
5292
5342
  Pages with a real cursor and verifies no duplicate ids before
5293
5343
  emitting; a summary (exportedCount/uniqueIds) is printed to stderr.
5344
+ dench crm exports start <object> [--columns Name,Email] [--where '<JSON>'] [--assigned-to me|unassigned|<userId|email>] [--assignee-field <Field>]
5345
+ Builds the CSV on the server into the workspace files (/exports) and
5346
+ returns a jobId at once. Up to 50,000 rows; one export per workspace.
5347
+ dench crm exports get <jobId>
5348
+ Progress; once done, the file path and a download link.
5294
5349
  For calls with transcripts / action items / attendees, use
5295
5350
  \`dench meetings import\` instead — same flags, plus the side tables.
5296
5351
 
@@ -348,6 +348,34 @@ const assigneeScopeResponse = z
348
348
  .nullable()
349
349
  .describe("The personal assignee scope that was applied, or null.");
350
350
 
351
+ /** One CRM CSV export's state (crm.exports.start / crm.exports.get). */
352
+ const crmExportStatus = z.object({
353
+ jobId: z.string(),
354
+ status: z.enum(["running", "done", "failed"]),
355
+ objectName: z.string(),
356
+ rowsDone: z.number(),
357
+ totalRows: z
358
+ .number()
359
+ .optional()
360
+ .describe("Estimated total, only for an unfiltered, unscoped export."),
361
+ truncated: z
362
+ .boolean()
363
+ .describe(
364
+ "The export stopped at its 50,000-row cap and more records may match.",
365
+ ),
366
+ filePath: z.string().optional().describe("Workspace path once done."),
367
+ downloadUrl: z.string().optional().describe("Signed link once done."),
368
+ bytes: z.number().optional(),
369
+ error: z.string().optional(),
370
+ message: z.string().describe("One-line status to show the person."),
371
+ alreadyRunning: z
372
+ .boolean()
373
+ .optional()
374
+ .describe("start returned the workspace's running export instead."),
375
+ createdAt: z.number(),
376
+ finishedAt: z.number().optional(),
377
+ });
378
+
351
379
  const cellValue = z
352
380
  .unknown()
353
381
  .describe(
@@ -4824,6 +4852,27 @@ export const requestSchemas: Record<string, ZodTypeAny> = {
4824
4852
  "Number field to sum/avg per bucket (e.g. Amount grouped by Stage). Defaults to the group field itself.",
4825
4853
  ),
4826
4854
  }),
4855
+ "crm.exports.start": z.object({
4856
+ objectName: z.string(),
4857
+ columns: z
4858
+ .array(z.string().min(1))
4859
+ .min(1)
4860
+ .max(100)
4861
+ .optional()
4862
+ .describe(
4863
+ "Fields to export, in order. Default: every field except the long-text Notes.",
4864
+ ),
4865
+ where: z
4866
+ .record(z.string(), z.unknown())
4867
+ .optional()
4868
+ .describe(
4869
+ 'Filter in the crm.query DSL, e.g. {"Status":"Open"} or {"Score":{"$gte":50}}. Field names are case-sensitive.',
4870
+ ),
4871
+ ...assigneeScopeRequest,
4872
+ }),
4873
+ "crm.exports.get": z.object({
4874
+ jobId: z.string().describe("jobId returned by crm.exports.start."),
4875
+ }),
4827
4876
  "crm.enrich.cell": z.object({
4828
4877
  objectName: z.string(),
4829
4878
  entryId: z.string(),
@@ -6347,6 +6396,8 @@ export const responseSchemas: Record<string, ZodTypeAny> = {
6347
6396
  "me.avatar.uploadUrl": z.string().describe("One-time upload URL."),
6348
6397
  "me.avatar.set": z.object({ image: z.string() }),
6349
6398
  "me.avatar.clear": okResponse,
6399
+ "crm.exports.start": crmExportStatus,
6400
+ "crm.exports.get": crmExportStatus,
6350
6401
  "crm.reports.generate": z.object({
6351
6402
  spec: z.object({
6352
6403
  objectName: z.string(),
@@ -6811,6 +6862,13 @@ export const convexExtras: Record<string, ConvexExtras> = {
6811
6862
  "crm.search": {
6812
6863
  withReferencesFunctionName: "functions/crm/query:searchWithReferences",
6813
6864
  },
6865
+ // `$` operators cannot be Convex object keys: the filter travels as JSON.
6866
+ "crm.exports.start": {
6867
+ transformArgs: ({ where, ...input }) => ({
6868
+ ...input,
6869
+ ...(where !== undefined ? { filterJson: JSON.stringify(where) } : {}),
6870
+ }),
6871
+ },
6814
6872
 
6815
6873
  "campaigns.steps.replace": {
6816
6874
  transformArgs: ({ allowSingleBraces: _allowSingleBraces, ...input }) =>
@@ -7124,6 +7182,11 @@ export const requestExamples: Record<string, unknown> = {
7124
7182
  },
7125
7183
  "crm.comments.update": { body: "Kickoff went well — proposal sent." },
7126
7184
  "crm.watch.set": { watching: true },
7185
+ "crm.exports.start": {
7186
+ objectName: "people",
7187
+ columns: ["Name", "Email", "Status"],
7188
+ where: { Status: "Customer" },
7189
+ },
7127
7190
  "crm.tasks.createForEntry": {
7128
7191
  name: "Send proposal",
7129
7192
  assigneeUserId: "user_bob",
@@ -7773,6 +7836,20 @@ export const responseExamples: Record<string, unknown> = {
7773
7836
  updatedAt: 1765612800000,
7774
7837
  },
7775
7838
  "crm.objects.create": { id: "obj_lead01" },
7839
+ "crm.exports.get": {
7840
+ jobId: "k57export0001",
7841
+ status: "done",
7842
+ objectName: "people",
7843
+ rowsDone: 1250,
7844
+ truncated: false,
7845
+ filePath: "/exports/people-2026-10-26-rt0001.csv",
7846
+ downloadUrl: "https://files.example.com/storage/0b1c2d3e",
7847
+ bytes: 184320,
7848
+ message:
7849
+ "Exported 1,250 rows of people to /exports/people-2026-10-26-rt0001.csv.",
7850
+ createdAt: 1793016000000,
7851
+ finishedAt: 1793016042000,
7852
+ },
7776
7853
  "crm.objects.update": { ok: true },
7777
7854
  "crm.objects.rename": { ok: true },
7778
7855
  "crm.objects.delete": { ok: true },
@@ -322,6 +322,8 @@ export const APP_SDK_OPERATIONS: readonly AppSdkOperationInfo[] = [
322
322
  {"id":"crm.templates.removeSampleData","group":"crm","summary":"Delete a CRM template's sample rows (tagged \"Sample\"); schema, views, and automations stay.","cli":"dench crm templates remove-sample-data","method":"POST","path":"/crm/templates/{templateId}/remove-sample-data","permission":"crm:write","pathParams":["templateId"]},
323
323
  {"id":"crm.automations.list","group":"crm","summary":"List deterministic CRM automations (rules that fire inside entry writes, e.g. qualified prospect → opportunity).","cli":"dench crm automations list","method":"GET","path":"/crm/automations","permission":"crm:read","pathParams":[]},
324
324
  {"id":"crm.automations.setEnabled","group":"crm","summary":"Enable or disable a CRM automation.","cli":"dench crm automations enable|disable","method":"PATCH","path":"/crm/automations/{automationId}","permission":"crm:write","pathParams":["automationId"]},
325
+ {"id":"crm.exports.start","group":"crm","summary":"Start a server-side CSV export of a CRM object into the workspace files (/exports). Returns at once; one export runs per workspace, and a second start returns the running one.","cli":"dench crm exports start","method":"POST","path":"/crm/exports","permission":"crm:write","pathParams":[]},
326
+ {"id":"crm.exports.get","group":"crm","summary":"Read a CRM CSV export's progress, and its file path and download link once done.","cli":"dench crm exports get","method":"GET","path":"/crm/exports/{jobId}","permission":"crm:read","pathParams":["jobId"]},
325
327
  {"id":"meetings.list","group":"meetings","summary":"List meetings, newest first, with status and participants.","cli":"dench meetings list","method":"GET","path":"/meetings","permission":"meetings:read","pathParams":[]},
326
328
  {"id":"meetings.transcript.list","group":"meetings","summary":"Read a meeting's transcript, in order, one page at a time.","cli":"dench meetings transcript get","method":"GET","path":"/meetings/{meetingEntryId}/transcript","permission":"meetings:read","pathParams":["meetingEntryId"]},
327
329
  {"id":"meetings.transcript.append","group":"meetings","summary":"Append up to 500 transcript segments to a meeting (speakers with an email link to existing people).","cli":"dench meetings transcript set","method":"POST","path":"/meetings/{meetingEntryId}/transcript","permission":"meetings:write","pathParams":["meetingEntryId"]},
@@ -13,11 +13,12 @@ export type ConvexOperation = {
13
13
  tokenArg?: "sessionToken" | "apiKey";
14
14
  /**
15
15
  * With `tokenArg: "apiKey"`: the Convex function validates a `dch_agent_*`
16
- * session passed as `apiKey` itself (org-scoped, like CRM reads), so an
17
- * agent session goes through as-is instead of being exchanged for the
18
- * workspace gateway key. The narrow key a `connectedAppAccess: "none"`
19
- * session (MCP, Dench Code) exchanges for carries no `files:*` scope.
20
- * Read-only operations only.
16
+ * session passed as `apiKey` itself (org-scoped, like CRM reads and
17
+ * writes), so an agent session goes through as-is instead of being
18
+ * exchanged for the workspace gateway key. The narrow key a
19
+ * `connectedAppAccess: "none"` session (MCP, Dench Code, the direct chat
20
+ * harness) exchanges for carries no `files:*` scope. Workspace file
21
+ * operations only: the CLI already calls these functions with the session.
21
22
  */
22
23
  agentSessionAsApiKey?: true;
23
24
  includeRunId?: boolean;
@@ -3483,6 +3484,30 @@ const rawApiOperations = [
3483
3484
  "Writes a CSV to the caller's local filesystem. Over the API, call POST /crm/query and format CSV client-side.",
3484
3485
  ),
3485
3486
  }),
3487
+ op({
3488
+ id: "crm.exports.start",
3489
+ group: "crm",
3490
+ summary:
3491
+ "Start a server-side CSV export of a CRM object into the workspace files (/exports). Returns at once; one export runs per workspace, and a second start returns the running one.",
3492
+ cli: "dench crm exports start",
3493
+ method: "POST",
3494
+ path: "/crm/exports",
3495
+ requestSchema: anyObject,
3496
+ responseSchema: anyResponse,
3497
+ backend: convex("mutation", "functions/crm/export:start"),
3498
+ }),
3499
+ op({
3500
+ id: "crm.exports.get",
3501
+ group: "crm",
3502
+ summary:
3503
+ "Read a CRM CSV export's progress, and its file path and download link once done.",
3504
+ cli: "dench crm exports get",
3505
+ method: "GET",
3506
+ path: "/crm/exports/{jobId}",
3507
+ requestSchema: noBody,
3508
+ responseSchema: anyResponse,
3509
+ backend: convex("query", "functions/crm/export:get"),
3510
+ }),
3486
3511
 
3487
3512
  // Meetings. A meeting is an ordinary CRM record (`/crm/objects/meeting/…`
3488
3513
  // creates, updates and deletes it); these endpoints reach the side tables
@@ -4965,6 +4990,7 @@ const rawApiOperations = [
4965
4990
  responseSchema: anyResponse,
4966
4991
  backend: convex("action", "functions/files:editFileFromUI", "bearer", {
4967
4992
  tokenArg: "apiKey",
4993
+ agentSessionAsApiKey: true,
4968
4994
  }),
4969
4995
  }),
4970
4996
  op({
@@ -4994,6 +5020,7 @@ const rawApiOperations = [
4994
5020
  responseSchema: anyResponse,
4995
5021
  backend: convex("mutation", "functions/files:deleteFile", "bearer", {
4996
5022
  tokenArg: "apiKey",
5023
+ agentSessionAsApiKey: true,
4997
5024
  }),
4998
5025
  }),
4999
5026
  op({
@@ -5019,6 +5046,7 @@ const rawApiOperations = [
5019
5046
  responseSchema: anyResponse,
5020
5047
  backend: convex("mutation", "functions/files:recordDirCreate", "bearer", {
5021
5048
  tokenArg: "apiKey",
5049
+ agentSessionAsApiKey: true,
5022
5050
  }),
5023
5051
  }),
5024
5052
  op({