@dench.com/cli 2.9.8 → 2.9.9-staging.275
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 +182 -0
- package/crm-comments.ts +253 -4
- package/crm.ts +13 -2
- package/dench.ts +8 -1
- package/leads.ts +3 -3
- package/lib/api-schemas.ts +139 -0
- package/lib/app-sdk-catalog.generated.ts +26 -0
- package/lib/app-sdk-surface.ts +78 -0
- package/lib/command-registry.ts +161 -0
- package/lib/task-repeat-args.ts +219 -0
- package/package.json +1 -1
package/app-sdk.d.ts
CHANGED
|
@@ -565,6 +565,8 @@ export interface ApiRequests {
|
|
|
565
565
|
/** Your open tasks (plus ones completed today). — `dench crm tasks mine` — GET /api/v1/crm/tasks/mine */
|
|
566
566
|
"crm.tasks.mine": {
|
|
567
567
|
limit?: number;
|
|
568
|
+
/** Only tasks at this priority — one of the workspace's Priority options ("high"; case-insensitive). */
|
|
569
|
+
priority?: string;
|
|
568
570
|
};
|
|
569
571
|
/** Tasks linked to a CRM entry. — `dench crm tasks list` — GET /api/v1/crm/objects/{objectName}/entries/{entryId}/tasks */
|
|
570
572
|
"crm.tasks.forEntry": {
|
|
@@ -579,6 +581,8 @@ export interface ApiRequests {
|
|
|
579
581
|
assigneeUserId?: string;
|
|
580
582
|
/** YYYY-MM-DD */
|
|
581
583
|
dueDateKey?: string;
|
|
584
|
+
/** One of the workspace's Priority options (default Low | Medium | High; case-insensitive). */
|
|
585
|
+
priority?: string;
|
|
582
586
|
};
|
|
583
587
|
/** Mark a task done. — `dench crm tasks complete` — POST /api/v1/crm/tasks/{entryId}/complete */
|
|
584
588
|
"crm.tasks.complete": {
|
|
@@ -588,6 +592,113 @@ export interface ApiRequests {
|
|
|
588
592
|
"crm.tasks.reopen": {
|
|
589
593
|
entryId: string;
|
|
590
594
|
};
|
|
595
|
+
/** Set or clear a task's priority. — `dench crm tasks priority` — PUT /api/v1/crm/tasks/{entryId}/priority */
|
|
596
|
+
"crm.tasks.setPriority": {
|
|
597
|
+
entryId: string;
|
|
598
|
+
/** One of the workspace's Priority options ("high"; case-insensitive), or null to clear. */
|
|
599
|
+
priority: string | null;
|
|
600
|
+
};
|
|
601
|
+
/** A task's subtasks. — `dench crm tasks subtasks` — GET /api/v1/crm/tasks/{entryId}/subtasks */
|
|
602
|
+
"crm.tasks.subtasks.list": {
|
|
603
|
+
entryId: string;
|
|
604
|
+
};
|
|
605
|
+
/** Create a subtask under a task (inherits the parent's record relations). — `dench crm tasks create-subtask` — POST /api/v1/crm/tasks/{entryId}/subtasks */
|
|
606
|
+
"crm.tasks.subtasks.create": {
|
|
607
|
+
/** The parent task. */
|
|
608
|
+
entryId: string;
|
|
609
|
+
name: string;
|
|
610
|
+
assigneeUserId?: string;
|
|
611
|
+
/** YYYY-MM-DD */
|
|
612
|
+
dueDateKey?: string;
|
|
613
|
+
priority?: string;
|
|
614
|
+
};
|
|
615
|
+
/** Nest a task under a parent, or promote it (parentEntryId: null). — `dench crm tasks parent` — PUT /api/v1/crm/tasks/{entryId}/parent */
|
|
616
|
+
"crm.tasks.setParent": {
|
|
617
|
+
entryId: string;
|
|
618
|
+
/** The parent task, or null to promote to a top-level task. */
|
|
619
|
+
parentEntryId: string | null;
|
|
620
|
+
};
|
|
621
|
+
/** Delete a task and its subtasks, or keep them as tasks. — `dench crm tasks delete` — DELETE /api/v1/crm/tasks/{entryId} */
|
|
622
|
+
"crm.tasks.delete": {
|
|
623
|
+
entryId: string;
|
|
624
|
+
/** What happens to its subtasks: delete them too (default) or keep them as tasks. */
|
|
625
|
+
subtasks?: "delete" | "keep";
|
|
626
|
+
};
|
|
627
|
+
/** How a task repeats (rule, RRULE, trigger, ends, next due). — `dench crm tasks repeat` — GET /api/v1/crm/tasks/{entryId}/repeat */
|
|
628
|
+
"crm.tasks.repeat.get": {
|
|
629
|
+
entryId: string;
|
|
630
|
+
};
|
|
631
|
+
/** Make a task repeat, or change how it repeats (JSON rule or RRULE). An undated task gets its due date anchored on the first matching day from today. — `dench crm tasks repeat` — PUT /api/v1/crm/tasks/{entryId}/repeat */
|
|
632
|
+
"crm.tasks.repeat.set": {
|
|
633
|
+
entryId: string;
|
|
634
|
+
/** Structured rule; alternative to `rrule`. */
|
|
635
|
+
rule?: {
|
|
636
|
+
freq: "daily";
|
|
637
|
+
interval: number;
|
|
638
|
+
} | {
|
|
639
|
+
freq: "weekly";
|
|
640
|
+
interval: number;
|
|
641
|
+
byWeekday: Array<"mo" | "tu" | "we" | "th" | "fr" | "sa" | "su">;
|
|
642
|
+
} | {
|
|
643
|
+
freq: "monthly";
|
|
644
|
+
interval: number;
|
|
645
|
+
/** 1–31, or -1 for the last day of the month. */
|
|
646
|
+
byMonthDay?: number;
|
|
647
|
+
bySetPos?: {
|
|
648
|
+
/** 1–4, or -1 for the last week. */
|
|
649
|
+
ordinal: number;
|
|
650
|
+
weekday: "mo" | "tu" | "we" | "th" | "fr" | "sa" | "su";
|
|
651
|
+
};
|
|
652
|
+
} | {
|
|
653
|
+
freq: "yearly";
|
|
654
|
+
interval: number;
|
|
655
|
+
month: number;
|
|
656
|
+
day: number;
|
|
657
|
+
};
|
|
658
|
+
/** RFC 5545 subset: FREQ, INTERVAL, BYDAY (ordinal allowed for MONTHLY, e.g. 2TU / -1FR), BYMONTHDAY, BYMONTH, COUNT, UNTIL. Bare FREQ=MONTHLY / YEARLY / WEEKLY take the day from the task's due date. */
|
|
659
|
+
rrule?: string;
|
|
660
|
+
/** When the next occurrence is created: after this one is done (default) or on schedule regardless. */
|
|
661
|
+
trigger?: "after_completion" | "on_schedule";
|
|
662
|
+
ends?: {
|
|
663
|
+
kind: "never";
|
|
664
|
+
} | {
|
|
665
|
+
kind: "count";
|
|
666
|
+
count: number;
|
|
667
|
+
} | {
|
|
668
|
+
kind: "until";
|
|
669
|
+
dateKey: string;
|
|
670
|
+
};
|
|
671
|
+
options?: {
|
|
672
|
+
skipWeekends?: boolean;
|
|
673
|
+
keepAssignee?: boolean;
|
|
674
|
+
copyNotes?: boolean;
|
|
675
|
+
copySubtasks?: boolean;
|
|
676
|
+
};
|
|
677
|
+
};
|
|
678
|
+
/** Stop a task repeating (past occurrences are kept). — `dench crm tasks repeat --off` — DELETE /api/v1/crm/tasks/{entryId}/repeat */
|
|
679
|
+
"crm.tasks.repeat.clear": {
|
|
680
|
+
entryId: string;
|
|
681
|
+
};
|
|
682
|
+
/** Skip the current occurrence: the next one is created now. — `dench crm tasks repeat --skip` — POST /api/v1/crm/tasks/{entryId}/repeat/skip */
|
|
683
|
+
"crm.tasks.repeat.skip": {
|
|
684
|
+
entryId: string;
|
|
685
|
+
};
|
|
686
|
+
/** Pause a repeating task. — `dench crm tasks repeat --pause` — POST /api/v1/crm/tasks/{entryId}/repeat/pause */
|
|
687
|
+
"crm.tasks.repeat.pause": {
|
|
688
|
+
entryId: string;
|
|
689
|
+
};
|
|
690
|
+
/** Resume a paused repeating task. — `dench crm tasks repeat --resume` — POST /api/v1/crm/tasks/{entryId}/repeat/resume */
|
|
691
|
+
"crm.tasks.repeat.resume": {
|
|
692
|
+
entryId: string;
|
|
693
|
+
};
|
|
694
|
+
/** Every repeating-task series in the workspace. — `dench crm tasks series` — GET /api/v1/crm/tasks/series */
|
|
695
|
+
"crm.tasks.series.list": {
|
|
696
|
+
status?: "active" | "paused" | "ended";
|
|
697
|
+
};
|
|
698
|
+
/** Every occurrence (task) of one series. — `dench crm tasks series <seriesId> --occurrences` — GET /api/v1/crm/tasks/series/{seriesId}/occurrences */
|
|
699
|
+
"crm.tasks.series.occurrences": {
|
|
700
|
+
seriesId: string;
|
|
701
|
+
};
|
|
591
702
|
/** Create a CRM entry. — `dench crm entries create` — POST /api/v1/crm/objects/{objectName}/entries */
|
|
592
703
|
"crm.entries.create": {
|
|
593
704
|
objectName: string;
|
|
@@ -3197,6 +3308,19 @@ export interface ApiResponses {
|
|
|
3197
3308
|
"crm.tasks.createForEntry": Record<string, unknown>;
|
|
3198
3309
|
"crm.tasks.complete": Record<string, unknown>;
|
|
3199
3310
|
"crm.tasks.reopen": Record<string, unknown>;
|
|
3311
|
+
"crm.tasks.setPriority": Record<string, unknown>;
|
|
3312
|
+
"crm.tasks.subtasks.list": Record<string, unknown>[];
|
|
3313
|
+
"crm.tasks.subtasks.create": Record<string, unknown>;
|
|
3314
|
+
"crm.tasks.setParent": Record<string, unknown>;
|
|
3315
|
+
"crm.tasks.delete": Record<string, unknown>;
|
|
3316
|
+
"crm.tasks.repeat.get": Record<string, unknown> | null;
|
|
3317
|
+
"crm.tasks.repeat.set": Record<string, unknown> | null;
|
|
3318
|
+
"crm.tasks.repeat.clear": null;
|
|
3319
|
+
"crm.tasks.repeat.skip": Record<string, unknown>;
|
|
3320
|
+
"crm.tasks.repeat.pause": null;
|
|
3321
|
+
"crm.tasks.repeat.resume": null;
|
|
3322
|
+
"crm.tasks.series.list": Record<string, unknown>[];
|
|
3323
|
+
"crm.tasks.series.occurrences": Record<string, unknown>[];
|
|
3200
3324
|
"crm.entries.create": {
|
|
3201
3325
|
entryId: string;
|
|
3202
3326
|
};
|
|
@@ -6001,12 +6125,44 @@ export type DenchApiTree = {
|
|
|
6001
6125
|
complete(args: Req<"crm.tasks.complete">): Promise<Res<"crm.tasks.complete">>;
|
|
6002
6126
|
/** Create a task linked to a CRM entry. (`dench crm tasks create`) */
|
|
6003
6127
|
createForEntry(args: Req<"crm.tasks.createForEntry">): Promise<Res<"crm.tasks.createForEntry">>;
|
|
6128
|
+
/** Delete a task and its subtasks, or keep them as tasks. (`dench crm tasks delete`) */
|
|
6129
|
+
delete(args: Req<"crm.tasks.delete">): Promise<Res<"crm.tasks.delete">>;
|
|
6004
6130
|
/** Tasks linked to a CRM entry. (`dench crm tasks list`) */
|
|
6005
6131
|
forEntry(args: Req<"crm.tasks.forEntry">): Promise<Res<"crm.tasks.forEntry">>;
|
|
6006
6132
|
/** Your open tasks (plus ones completed today). (`dench crm tasks mine`) */
|
|
6007
6133
|
mine(args?: Req<"crm.tasks.mine">): Promise<Res<"crm.tasks.mine">>;
|
|
6008
6134
|
/** Reopen a completed task. (`dench crm tasks reopen`) */
|
|
6009
6135
|
reopen(args: Req<"crm.tasks.reopen">): Promise<Res<"crm.tasks.reopen">>;
|
|
6136
|
+
repeat: {
|
|
6137
|
+
/** Stop a task repeating (past occurrences are kept). (`dench crm tasks repeat --off`) */
|
|
6138
|
+
clear(args: Req<"crm.tasks.repeat.clear">): Promise<Res<"crm.tasks.repeat.clear">>;
|
|
6139
|
+
/** How a task repeats (rule, RRULE, trigger, ends, next due). (`dench crm tasks repeat`) */
|
|
6140
|
+
get(args: Req<"crm.tasks.repeat.get">): Promise<Res<"crm.tasks.repeat.get">>;
|
|
6141
|
+
/** Pause a repeating task. (`dench crm tasks repeat --pause`) */
|
|
6142
|
+
pause(args: Req<"crm.tasks.repeat.pause">): Promise<Res<"crm.tasks.repeat.pause">>;
|
|
6143
|
+
/** Resume a paused repeating task. (`dench crm tasks repeat --resume`) */
|
|
6144
|
+
resume(args: Req<"crm.tasks.repeat.resume">): Promise<Res<"crm.tasks.repeat.resume">>;
|
|
6145
|
+
/** Make a task repeat, or change how it repeats (JSON rule or RRULE). An undated task gets its due date anchored on the first matching day from today. (`dench crm tasks repeat`) */
|
|
6146
|
+
set(args: Req<"crm.tasks.repeat.set">): Promise<Res<"crm.tasks.repeat.set">>;
|
|
6147
|
+
/** Skip the current occurrence: the next one is created now. (`dench crm tasks repeat --skip`) */
|
|
6148
|
+
skip(args: Req<"crm.tasks.repeat.skip">): Promise<Res<"crm.tasks.repeat.skip">>;
|
|
6149
|
+
};
|
|
6150
|
+
series: {
|
|
6151
|
+
/** Every repeating-task series in the workspace. (`dench crm tasks series`) */
|
|
6152
|
+
list(args?: Req<"crm.tasks.series.list">): Promise<Res<"crm.tasks.series.list">>;
|
|
6153
|
+
/** Every occurrence (task) of one series. (`dench crm tasks series <seriesId> --occurrences`) */
|
|
6154
|
+
occurrences(args: Req<"crm.tasks.series.occurrences">): Promise<Res<"crm.tasks.series.occurrences">>;
|
|
6155
|
+
};
|
|
6156
|
+
/** Nest a task under a parent, or promote it (parentEntryId: null). (`dench crm tasks parent`) */
|
|
6157
|
+
setParent(args: Req<"crm.tasks.setParent">): Promise<Res<"crm.tasks.setParent">>;
|
|
6158
|
+
/** Set or clear a task's priority. (`dench crm tasks priority`) */
|
|
6159
|
+
setPriority(args: Req<"crm.tasks.setPriority">): Promise<Res<"crm.tasks.setPriority">>;
|
|
6160
|
+
subtasks: {
|
|
6161
|
+
/** Create a subtask under a task (inherits the parent's record relations). (`dench crm tasks create-subtask`) */
|
|
6162
|
+
create(args: Req<"crm.tasks.subtasks.create">): Promise<Res<"crm.tasks.subtasks.create">>;
|
|
6163
|
+
/** A task's subtasks. (`dench crm tasks subtasks`) */
|
|
6164
|
+
list(args: Req<"crm.tasks.subtasks.list">): Promise<Res<"crm.tasks.subtasks.list">>;
|
|
6165
|
+
};
|
|
6010
6166
|
};
|
|
6011
6167
|
templates: {
|
|
6012
6168
|
/** Install a CRM template. Idempotent: re-installs top up missing pieces and never duplicate objects, automations, or sample rows. (`dench crm templates install`) */
|
|
@@ -6629,6 +6785,32 @@ export interface DenchTasks {
|
|
|
6629
6785
|
complete(entryId: string): Promise<Res<"crm.tasks.complete">>;
|
|
6630
6786
|
/** Reopen a task. Permission: `crm:write`. Wraps `crm.tasks.reopen`. */
|
|
6631
6787
|
reopen(entryId: string): Promise<Res<"crm.tasks.reopen">>;
|
|
6788
|
+
/** Set a task's priority (one of the workspace's options) or clear it with null. Permission: `crm:write`. Wraps `crm.tasks.setPriority`. */
|
|
6789
|
+
setPriority(entryId: string, priority: string | null): Promise<Res<"crm.tasks.setPriority">>;
|
|
6790
|
+
/** A task's subtasks. Permission: `crm:read`. Wraps `crm.tasks.subtasks.list`. */
|
|
6791
|
+
subtasks(entryId: string): Promise<Res<"crm.tasks.subtasks.list">>;
|
|
6792
|
+
/** Create a subtask under a task (one level deep; inherits the parent's record relations). Permission: `crm:write`. Wraps `crm.tasks.subtasks.create`. */
|
|
6793
|
+
createSubtask(entryId: string, subtask: Omit<Req<"crm.tasks.subtasks.create">, "entryId">): Promise<Res<"crm.tasks.subtasks.create">>;
|
|
6794
|
+
/** Nest a task under a parent, or promote it with null. Permission: `crm:write`. Wraps `crm.tasks.setParent`. */
|
|
6795
|
+
setParent(entryId: string, parentEntryId: string | null): Promise<Res<"crm.tasks.setParent">>;
|
|
6796
|
+
/** Delete a task; its subtasks go with it unless subtasks is "keep". Permission: `crm:write`. Wraps `crm.tasks.delete`. */
|
|
6797
|
+
delete(entryId: string, subtasks?: "delete" | "keep"): Promise<Res<"crm.tasks.delete">>;
|
|
6798
|
+
/** How a task repeats (rule, RRULE, trigger, ends, next due), or null. Permission: `crm:read`. Wraps `crm.tasks.repeat.get`. */
|
|
6799
|
+
getRepeat(entryId: string): Promise<Res<"crm.tasks.repeat.get">>;
|
|
6800
|
+
/** Make a task repeat or change how it repeats (JSON rule or RRULE). An undated task gets its due date anchored on the first matching day from today. Permission: `crm:write`. Wraps `crm.tasks.repeat.set`. */
|
|
6801
|
+
setRepeat(entryId: string, repeat: Omit<Req<"crm.tasks.repeat.set">, "entryId">): Promise<Res<"crm.tasks.repeat.set">>;
|
|
6802
|
+
/** Stop a task repeating. Permission: `crm:write`. Wraps `crm.tasks.repeat.clear`. */
|
|
6803
|
+
clearRepeat(entryId: string): Promise<Res<"crm.tasks.repeat.clear">>;
|
|
6804
|
+
/** Skip the current occurrence; the next one is created now. Permission: `crm:write`. Wraps `crm.tasks.repeat.skip`. */
|
|
6805
|
+
skipRepeat(entryId: string): Promise<Res<"crm.tasks.repeat.skip">>;
|
|
6806
|
+
/** Pause a repeating task. Permission: `crm:write`. Wraps `crm.tasks.repeat.pause`. */
|
|
6807
|
+
pauseRepeat(entryId: string): Promise<Res<"crm.tasks.repeat.pause">>;
|
|
6808
|
+
/** Resume a paused repeating task. Permission: `crm:write`. Wraps `crm.tasks.repeat.resume`. */
|
|
6809
|
+
resumeRepeat(entryId: string): Promise<Res<"crm.tasks.repeat.resume">>;
|
|
6810
|
+
/** Every repeating-task series in the workspace. Permission: `crm:read`. Wraps `crm.tasks.series.list`. */
|
|
6811
|
+
series(opts?: Req<"crm.tasks.series.list">): Promise<Res<"crm.tasks.series.list">>;
|
|
6812
|
+
/** Every occurrence of one series. Permission: `crm:read`. Wraps `crm.tasks.series.occurrences`. */
|
|
6813
|
+
seriesOccurrences(seriesId: string): Promise<Res<"crm.tasks.series.occurrences">>;
|
|
6632
6814
|
}
|
|
6633
6815
|
|
|
6634
6816
|
export interface DenchNotifications {
|
package/crm-comments.ts
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
shift,
|
|
20
20
|
} from "./crm";
|
|
21
21
|
import { getFlag, hasFlag } from "./lib/cli-args";
|
|
22
|
+
import { buildRepeatBody, RepeatArgsError } from "./lib/task-repeat-args";
|
|
22
23
|
|
|
23
24
|
const api = {
|
|
24
25
|
comments: {
|
|
@@ -58,9 +59,81 @@ const api = {
|
|
|
58
59
|
reopenTask: makeFunctionReference<"mutation">(
|
|
59
60
|
"functions/crm/tasks:reopenTask",
|
|
60
61
|
),
|
|
62
|
+
setTaskPriority: makeFunctionReference<"mutation">(
|
|
63
|
+
"functions/crm/tasks:setTaskPriority",
|
|
64
|
+
),
|
|
65
|
+
listSubtasks: makeFunctionReference<"query">(
|
|
66
|
+
"functions/crm/tasks:listSubtasks",
|
|
67
|
+
),
|
|
68
|
+
createSubtask: makeFunctionReference<"mutation">(
|
|
69
|
+
"functions/crm/tasks:createSubtask",
|
|
70
|
+
),
|
|
71
|
+
setTaskParent: makeFunctionReference<"mutation">(
|
|
72
|
+
"functions/crm/tasks:setTaskParent",
|
|
73
|
+
),
|
|
74
|
+
deleteTask: makeFunctionReference<"mutation">(
|
|
75
|
+
"functions/crm/tasks:deleteTask",
|
|
76
|
+
),
|
|
77
|
+
},
|
|
78
|
+
repeat: {
|
|
79
|
+
get: makeFunctionReference<"query">(
|
|
80
|
+
"functions/crm/taskRecurrences:getForTask",
|
|
81
|
+
),
|
|
82
|
+
set: makeFunctionReference<"mutation">(
|
|
83
|
+
"functions/crm/taskRecurrences:setForTask",
|
|
84
|
+
),
|
|
85
|
+
clear: makeFunctionReference<"mutation">(
|
|
86
|
+
"functions/crm/taskRecurrences:clearForTask",
|
|
87
|
+
),
|
|
88
|
+
skip: makeFunctionReference<"mutation">(
|
|
89
|
+
"functions/crm/taskRecurrences:skip",
|
|
90
|
+
),
|
|
91
|
+
pause: makeFunctionReference<"mutation">(
|
|
92
|
+
"functions/crm/taskRecurrences:pause",
|
|
93
|
+
),
|
|
94
|
+
resume: makeFunctionReference<"mutation">(
|
|
95
|
+
"functions/crm/taskRecurrences:resume",
|
|
96
|
+
),
|
|
97
|
+
listSeries: makeFunctionReference<"query">(
|
|
98
|
+
"functions/crm/taskRecurrences:listSeries",
|
|
99
|
+
),
|
|
100
|
+
listOccurrences: makeFunctionReference<"query">(
|
|
101
|
+
"functions/crm/taskRecurrences:listOccurrences",
|
|
102
|
+
),
|
|
61
103
|
},
|
|
62
104
|
};
|
|
63
105
|
|
|
106
|
+
/** Shared `--repeat …` flag family (create, create-subtask, repeat). */
|
|
107
|
+
function readRepeatFlags(args: string[], freq?: string) {
|
|
108
|
+
return {
|
|
109
|
+
freq,
|
|
110
|
+
every: getFlag(args, "--every"),
|
|
111
|
+
on: getFlag(args, "--on"),
|
|
112
|
+
day: getFlag(args, "--day"),
|
|
113
|
+
nth: getFlag(args, "--nth"),
|
|
114
|
+
endsAfter: getFlag(args, "--ends-after"),
|
|
115
|
+
until: getFlag(args, "--until"),
|
|
116
|
+
onSchedule: hasFlag(args, "--on-schedule"),
|
|
117
|
+
skipWeekends: hasFlag(args, "--skip-weekends"),
|
|
118
|
+
noCopyNotes: hasFlag(args, "--no-copy-notes"),
|
|
119
|
+
noKeepAssignee: hasFlag(args, "--no-keep-assignee"),
|
|
120
|
+
noCopySubtasks: hasFlag(args, "--no-copy-subtasks"),
|
|
121
|
+
rrule: getFlag(args, "--rrule"),
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function repeatBodyOrThrow(
|
|
126
|
+
input: ReturnType<typeof readRepeatFlags>,
|
|
127
|
+
dueKey?: string | null,
|
|
128
|
+
): Record<string, unknown> {
|
|
129
|
+
try {
|
|
130
|
+
return buildRepeatBody(input, dueKey);
|
|
131
|
+
} catch (error) {
|
|
132
|
+
if (error instanceof RepeatArgsError) throw new CrmCliError(error.message);
|
|
133
|
+
throw error;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
64
137
|
const DENCH_MENTION = "[@Dench](/?member=dench)";
|
|
65
138
|
|
|
66
139
|
function paginationFlags(
|
|
@@ -239,11 +312,13 @@ export async function runTasksCommand(ctx: CrmCliContext): Promise<void> {
|
|
|
239
312
|
switch (verb) {
|
|
240
313
|
case "mine": {
|
|
241
314
|
const rawLimit = getFlag(ctx.args, "--limit");
|
|
315
|
+
const priority = getFlag(ctx.args, "--priority");
|
|
242
316
|
assertNoUnknownFlags(ctx.args, "crm tasks mine");
|
|
243
317
|
out(
|
|
244
318
|
ctx,
|
|
245
319
|
await callQuery(ctx, api.tasks.listMyOpenTasks, {
|
|
246
320
|
...(rawLimit ? { limit: Number.parseInt(rawLimit, 10) } : {}),
|
|
321
|
+
...(priority ? { priority } : {}),
|
|
247
322
|
}),
|
|
248
323
|
);
|
|
249
324
|
return;
|
|
@@ -264,19 +339,193 @@ export async function runTasksCommand(ctx: CrmCliContext): Promise<void> {
|
|
|
264
339
|
const name = getFlag(ctx.args, "--name");
|
|
265
340
|
const assigneeUserId = getFlag(ctx.args, "--assignee");
|
|
266
341
|
const dueDateKey = getFlag(ctx.args, "--due");
|
|
342
|
+
const priority = getFlag(ctx.args, "--priority");
|
|
343
|
+
const repeatFreq = getFlag(ctx.args, "--repeat");
|
|
344
|
+
const repeatFlags = readRepeatFlags(ctx.args, repeatFreq);
|
|
267
345
|
assertNoUnknownFlags(ctx.args, "crm tasks create");
|
|
268
346
|
if (!name?.trim()) throw new CrmCliError("--name is required");
|
|
269
347
|
if (dueDateKey && !/^\d{4}-\d{2}-\d{2}$/.test(dueDateKey)) {
|
|
270
348
|
throw new CrmCliError("--due must be YYYY-MM-DD");
|
|
271
349
|
}
|
|
350
|
+
// `--repeat` without `--due` is fine: the server anchors the due date
|
|
351
|
+
// on the first day the rule matches from today.
|
|
352
|
+
const wantsRepeat = !!(repeatFreq || repeatFlags.rrule);
|
|
353
|
+
const repeatBody = wantsRepeat
|
|
354
|
+
? repeatBodyOrThrow(repeatFlags, dueDateKey)
|
|
355
|
+
: null;
|
|
356
|
+
const created = (await callMutation(ctx, api.tasks.createEntryTask, {
|
|
357
|
+
objectName,
|
|
358
|
+
entryId,
|
|
359
|
+
name: name.trim(),
|
|
360
|
+
...(assigneeUserId ? { assigneeUserId } : {}),
|
|
361
|
+
...(dueDateKey ? { dueDateKey } : {}),
|
|
362
|
+
...(priority ? { priority } : {}),
|
|
363
|
+
})) as { id: string };
|
|
364
|
+
if (repeatBody) {
|
|
365
|
+
const repeat = await callMutation(ctx, api.repeat.set, {
|
|
366
|
+
entryId: created.id,
|
|
367
|
+
...repeatBody,
|
|
368
|
+
});
|
|
369
|
+
out(ctx, { ...created, repeat });
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
out(ctx, created);
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
case "repeat": {
|
|
376
|
+
// dench crm tasks repeat <taskId> → show
|
|
377
|
+
// dench crm tasks repeat <taskId> weekly --on mon → set / replace
|
|
378
|
+
// dench crm tasks repeat <taskId> --rrule "FREQ=…"
|
|
379
|
+
// dench crm tasks repeat <taskId> --off | --skip | --pause | --resume
|
|
380
|
+
const entryId = shift(ctx.args, "task entry id");
|
|
381
|
+
const freq = ctx.args[0]?.startsWith("--") ? undefined : ctx.args.shift();
|
|
382
|
+
const off = hasFlag(ctx.args, "--off");
|
|
383
|
+
const skip = hasFlag(ctx.args, "--skip");
|
|
384
|
+
const pause = hasFlag(ctx.args, "--pause");
|
|
385
|
+
const resume = hasFlag(ctx.args, "--resume");
|
|
386
|
+
const flags = readRepeatFlags(ctx.args, freq);
|
|
387
|
+
assertNoUnknownFlags(ctx.args, "crm tasks repeat");
|
|
388
|
+
if ([off, skip, pause, resume].filter(Boolean).length > 1) {
|
|
389
|
+
throw new CrmCliError(
|
|
390
|
+
"Pass only one of --off, --skip, --pause, --resume.",
|
|
391
|
+
);
|
|
392
|
+
}
|
|
393
|
+
if (off) {
|
|
394
|
+
out(ctx, await callMutation(ctx, api.repeat.clear, { entryId }));
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
if (skip) {
|
|
398
|
+
out(ctx, await callMutation(ctx, api.repeat.skip, { entryId }));
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
if (pause) {
|
|
402
|
+
out(ctx, await callMutation(ctx, api.repeat.pause, { entryId }));
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
if (resume) {
|
|
406
|
+
out(ctx, await callMutation(ctx, api.repeat.resume, { entryId }));
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
const body = repeatBodyOrThrow(flags, null);
|
|
410
|
+
if (Object.keys(body).length === 0) {
|
|
411
|
+
out(ctx, await callQuery(ctx, api.repeat.get, { entryId }));
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
out(ctx, await callMutation(ctx, api.repeat.set, { entryId, ...body }));
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
case "series": {
|
|
418
|
+
// dench crm tasks series [--status active|paused|ended]
|
|
419
|
+
// dench crm tasks series <seriesId> --occurrences
|
|
420
|
+
const maybeId = ctx.args[0]?.startsWith("--")
|
|
421
|
+
? undefined
|
|
422
|
+
: ctx.args.shift();
|
|
423
|
+
const occurrences = hasFlag(ctx.args, "--occurrences");
|
|
424
|
+
const status = getFlag(ctx.args, "--status");
|
|
425
|
+
assertNoUnknownFlags(ctx.args, "crm tasks series");
|
|
426
|
+
if (maybeId && occurrences) {
|
|
427
|
+
out(
|
|
428
|
+
ctx,
|
|
429
|
+
await callQuery(ctx, api.repeat.listOccurrences, {
|
|
430
|
+
seriesId: maybeId,
|
|
431
|
+
}),
|
|
432
|
+
);
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
if (maybeId) {
|
|
436
|
+
throw new CrmCliError(
|
|
437
|
+
"Pass --occurrences with a series id, or no id to list every series.",
|
|
438
|
+
);
|
|
439
|
+
}
|
|
440
|
+
if (status && !["active", "paused", "ended"].includes(status)) {
|
|
441
|
+
throw new CrmCliError("--status must be active, paused or ended.");
|
|
442
|
+
}
|
|
272
443
|
out(
|
|
273
444
|
ctx,
|
|
274
|
-
await
|
|
275
|
-
|
|
276
|
-
|
|
445
|
+
await callQuery(ctx, api.repeat.listSeries, {
|
|
446
|
+
...(status ? { status } : {}),
|
|
447
|
+
}),
|
|
448
|
+
);
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
case "subtasks": {
|
|
452
|
+
const entryId = shift(ctx.args, "task entry id");
|
|
453
|
+
assertNoUnknownFlags(ctx.args, "crm tasks subtasks");
|
|
454
|
+
out(ctx, await callQuery(ctx, api.tasks.listSubtasks, { entryId }));
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
case "create-subtask": {
|
|
458
|
+
const parentEntryId = shift(ctx.args, "parent task entry id");
|
|
459
|
+
const name = getFlag(ctx.args, "--name");
|
|
460
|
+
const assigneeUserId = getFlag(ctx.args, "--assignee");
|
|
461
|
+
const dueDateKey = getFlag(ctx.args, "--due");
|
|
462
|
+
const priority = getFlag(ctx.args, "--priority");
|
|
463
|
+
assertNoUnknownFlags(ctx.args, "crm tasks create-subtask");
|
|
464
|
+
if (!name?.trim()) throw new CrmCliError("--name is required");
|
|
465
|
+
if (dueDateKey && !/^\d{4}-\d{2}-\d{2}$/.test(dueDateKey)) {
|
|
466
|
+
throw new CrmCliError("--due must be YYYY-MM-DD");
|
|
467
|
+
}
|
|
468
|
+
out(
|
|
469
|
+
ctx,
|
|
470
|
+
await callMutation(ctx, api.tasks.createSubtask, {
|
|
471
|
+
parentEntryId,
|
|
277
472
|
name: name.trim(),
|
|
278
473
|
...(assigneeUserId ? { assigneeUserId } : {}),
|
|
279
474
|
...(dueDateKey ? { dueDateKey } : {}),
|
|
475
|
+
...(priority ? { priority } : {}),
|
|
476
|
+
}),
|
|
477
|
+
);
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
case "parent": {
|
|
481
|
+
// `dench crm tasks parent <taskId> <parentId>` / `… --none` to promote.
|
|
482
|
+
const entryId = shift(ctx.args, "task entry id");
|
|
483
|
+
const none = hasFlag(ctx.args, "--none");
|
|
484
|
+
const parentEntryId = none ? null : ctx.args.shift();
|
|
485
|
+
assertNoUnknownFlags(ctx.args, "crm tasks parent");
|
|
486
|
+
if (!none && !parentEntryId?.trim()) {
|
|
487
|
+
throw new CrmCliError(
|
|
488
|
+
"Pass the parent task id, or --none to make it a top-level task.",
|
|
489
|
+
);
|
|
490
|
+
}
|
|
491
|
+
out(
|
|
492
|
+
ctx,
|
|
493
|
+
await callMutation(ctx, api.tasks.setTaskParent, {
|
|
494
|
+
entryId,
|
|
495
|
+
parentEntryId: parentEntryId?.trim() ?? null,
|
|
496
|
+
}),
|
|
497
|
+
);
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
case "delete": {
|
|
501
|
+
const entryId = shift(ctx.args, "task entry id");
|
|
502
|
+
const keep = hasFlag(ctx.args, "--keep-subtasks");
|
|
503
|
+
assertNoUnknownFlags(ctx.args, "crm tasks delete");
|
|
504
|
+
out(
|
|
505
|
+
ctx,
|
|
506
|
+
await callMutation(ctx, api.tasks.deleteTask, {
|
|
507
|
+
entryId,
|
|
508
|
+
subtasks: keep ? "keep" : "delete",
|
|
509
|
+
}),
|
|
510
|
+
);
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
case "priority": {
|
|
514
|
+
// `dench crm tasks priority <taskId> high` / `… --none` to clear.
|
|
515
|
+
const entryId = shift(ctx.args, "task entry id");
|
|
516
|
+
const clear = hasFlag(ctx.args, "--none");
|
|
517
|
+
const value = clear ? null : ctx.args.shift();
|
|
518
|
+
assertNoUnknownFlags(ctx.args, "crm tasks priority");
|
|
519
|
+
if (!clear && !value?.trim()) {
|
|
520
|
+
throw new CrmCliError(
|
|
521
|
+
"Pass a priority (e.g. high) or --none to clear it.",
|
|
522
|
+
);
|
|
523
|
+
}
|
|
524
|
+
out(
|
|
525
|
+
ctx,
|
|
526
|
+
await callMutation(ctx, api.tasks.setTaskPriority, {
|
|
527
|
+
entryId,
|
|
528
|
+
priority: value?.trim() ?? null,
|
|
280
529
|
}),
|
|
281
530
|
);
|
|
282
531
|
return;
|
|
@@ -297,7 +546,7 @@ export async function runTasksCommand(ctx: CrmCliContext): Promise<void> {
|
|
|
297
546
|
}
|
|
298
547
|
default:
|
|
299
548
|
throw new CrmCliError(
|
|
300
|
-
`Unknown tasks verb: ${verb ?? "(none)"}. Use mine | list | create | complete | reopen.`,
|
|
549
|
+
`Unknown tasks verb: ${verb ?? "(none)"}. Use mine | list | create | subtasks | create-subtask | parent | priority | repeat | series | complete | reopen | delete.`,
|
|
301
550
|
);
|
|
302
551
|
}
|
|
303
552
|
}
|
package/crm.ts
CHANGED
|
@@ -4428,11 +4428,22 @@ Comments (the record's Activity feed):
|
|
|
4428
4428
|
dench crm watch status <object> <entryId>
|
|
4429
4429
|
|
|
4430
4430
|
Tasks (shortcuts over the protected 'task' object):
|
|
4431
|
-
dench crm tasks mine [--limit N]
|
|
4431
|
+
dench crm tasks mine [--limit N] [--priority high]
|
|
4432
4432
|
dench crm tasks list <object> <entryId>
|
|
4433
|
-
dench crm tasks create <object> <entryId> --name "…" [--assignee <userId>] [--due YYYY-MM-DD]
|
|
4433
|
+
dench crm tasks create <object> <entryId> --name "…" [--assignee <userId>] [--due YYYY-MM-DD] [--priority low|medium|high]
|
|
4434
|
+
[--repeat daily|weekdays|weekly|monthly|yearly [--every N] [--on mon,wed] [--day 17|last] [--nth 2 --on tue]
|
|
4435
|
+
[--ends-after N | --until YYYY-MM-DD] [--on-schedule] [--skip-weekends] [--no-copy-notes] [--no-keep-assignee] [--no-copy-subtasks]]
|
|
4436
|
+
dench crm tasks priority <taskEntryId> <low|medium|high | --none>
|
|
4437
|
+
dench crm tasks repeat <taskEntryId> [daily|weekdays|weekly|monthly|yearly …flags | --rrule "FREQ=…"] # show when no rule given
|
|
4438
|
+
dench crm tasks repeat <taskEntryId> --off | --skip | --pause | --resume
|
|
4439
|
+
dench crm tasks series [--status active|paused|ended]
|
|
4440
|
+
dench crm tasks series <seriesId> --occurrences
|
|
4441
|
+
dench crm tasks subtasks <taskEntryId>
|
|
4442
|
+
dench crm tasks create-subtask <taskEntryId> --name "…" [--assignee <userId>] [--due YYYY-MM-DD] [--priority …]
|
|
4443
|
+
dench crm tasks parent <taskEntryId> <parentTaskEntryId | --none>
|
|
4434
4444
|
dench crm tasks complete <taskEntryId>
|
|
4435
4445
|
dench crm tasks reopen <taskEntryId>
|
|
4446
|
+
dench crm tasks delete <taskEntryId> [--keep-subtasks]
|
|
4436
4447
|
|
|
4437
4448
|
dench crm entries create <object> --data '{"Field":"Value",...}' (alias: --fields) [--allow-unknown] [--idempotency-key <key>]
|
|
4438
4449
|
--idempotency-key upserts on (object, key): a retried create returns
|
package/dench.ts
CHANGED
|
@@ -2730,13 +2730,20 @@ async function getRuntime() {
|
|
|
2730
2730
|
|
|
2731
2731
|
type Runtime = Awaited<ReturnType<typeof getRuntime>>;
|
|
2732
2732
|
|
|
2733
|
+
/**
|
|
2734
|
+
* Drop the runtime-selection flags before handing argv to a sub-dispatcher
|
|
2735
|
+
* (`dench crm`, `dench members`, …). `--json` is deliberately NOT stripped
|
|
2736
|
+
* here: every sub-dispatcher resolves its own output mode with
|
|
2737
|
+
* `hasFlag(args, "--json")`, so removing it up front made
|
|
2738
|
+
* `dench members list --json` print the human table and `dench crm … --json`
|
|
2739
|
+
* fall back to text on empty results (`(no rows)`), breaking `| jq` pipelines.
|
|
2740
|
+
*/
|
|
2733
2741
|
function stripRuntimeFlags(args: string[]) {
|
|
2734
2742
|
const booleanFlags = new Set([
|
|
2735
2743
|
"--dev",
|
|
2736
2744
|
"--prod",
|
|
2737
2745
|
"--staging",
|
|
2738
2746
|
"--use-dev-env",
|
|
2739
|
-
"--json",
|
|
2740
2747
|
]);
|
|
2741
2748
|
const valueFlags = new Set(["--convex-url", "--host", "--backend"]);
|
|
2742
2749
|
const stripped: string[] = [];
|
package/leads.ts
CHANGED
|
@@ -402,7 +402,7 @@ export function runFindFiltersCommand(opts: {
|
|
|
402
402
|
jsonOutput?: boolean;
|
|
403
403
|
}): void {
|
|
404
404
|
const args = [...opts.args];
|
|
405
|
-
const jsonOutput =
|
|
405
|
+
const jsonOutput = hasFlag(args, "--json") || opts.jsonOutput === true;
|
|
406
406
|
const filterRaw = getFlag(args, "--filter");
|
|
407
407
|
const search = getFlag(args, "--search")?.trim().toLowerCase();
|
|
408
408
|
assertNoUnknownFlags(args, "leads filters");
|
|
@@ -532,7 +532,7 @@ export async function runListsCommand(opts: {
|
|
|
532
532
|
const ctx: FindCliContext = {
|
|
533
533
|
convex: opts.convex,
|
|
534
534
|
args,
|
|
535
|
-
jsonOutput:
|
|
535
|
+
jsonOutput: hasFlag(args, "--json") || opts.jsonOutput === true,
|
|
536
536
|
sessionToken: opts.sessionToken,
|
|
537
537
|
};
|
|
538
538
|
const verb = args[0];
|
|
@@ -996,7 +996,7 @@ export async function runWorkspaceArtifactsCommand(opts: {
|
|
|
996
996
|
const ctx: FindCliContext = {
|
|
997
997
|
convex: opts.convex,
|
|
998
998
|
args,
|
|
999
|
-
jsonOutput:
|
|
999
|
+
jsonOutput: hasFlag(args, "--json") || opts.jsonOutput === true,
|
|
1000
1000
|
sessionToken: opts.sessionToken,
|
|
1001
1001
|
};
|
|
1002
1002
|
if (verb === "list") {
|
package/lib/api-schemas.ts
CHANGED
|
@@ -103,6 +103,38 @@ const memoryVisibility = z
|
|
|
103
103
|
|
|
104
104
|
const riskLevel = z.enum(["low", "medium", "high"]).describe("Risk level.");
|
|
105
105
|
|
|
106
|
+
const repeatWeekday = z.enum(["mo", "tu", "we", "th", "fr", "sa", "su"]);
|
|
107
|
+
/** Structured repeat rule for tasks (mirrors convex/lib/crm/taskRepeatRule). */
|
|
108
|
+
const taskRepeatRuleSchema = z.discriminatedUnion("freq", [
|
|
109
|
+
z.object({ freq: z.literal("daily"), interval: z.number().int().min(1) }),
|
|
110
|
+
z.object({
|
|
111
|
+
freq: z.literal("weekly"),
|
|
112
|
+
interval: z.number().int().min(1),
|
|
113
|
+
byWeekday: z.array(repeatWeekday).min(1),
|
|
114
|
+
}),
|
|
115
|
+
z.object({
|
|
116
|
+
freq: z.literal("monthly"),
|
|
117
|
+
interval: z.number().int().min(1),
|
|
118
|
+
byMonthDay: z
|
|
119
|
+
.number()
|
|
120
|
+
.int()
|
|
121
|
+
.describe("1–31, or -1 for the last day of the month.")
|
|
122
|
+
.optional(),
|
|
123
|
+
bySetPos: z
|
|
124
|
+
.object({
|
|
125
|
+
ordinal: z.number().int().describe("1–4, or -1 for the last week."),
|
|
126
|
+
weekday: repeatWeekday,
|
|
127
|
+
})
|
|
128
|
+
.optional(),
|
|
129
|
+
}),
|
|
130
|
+
z.object({
|
|
131
|
+
freq: z.literal("yearly"),
|
|
132
|
+
interval: z.number().int().min(1),
|
|
133
|
+
month: z.number().int().min(1).max(12),
|
|
134
|
+
day: z.number().int().min(1).max(31),
|
|
135
|
+
}),
|
|
136
|
+
]);
|
|
137
|
+
|
|
106
138
|
const approvalDecision = z
|
|
107
139
|
.enum(["approved", "rejected"])
|
|
108
140
|
.describe("Human decision for an approval request.");
|
|
@@ -2742,6 +2774,12 @@ export const requestSchemas: Record<string, ZodTypeAny> = {
|
|
|
2742
2774
|
// CRM tasks
|
|
2743
2775
|
"crm.tasks.mine": z.object({
|
|
2744
2776
|
limit: z.coerce.number().int().min(1).max(500).optional(),
|
|
2777
|
+
priority: z
|
|
2778
|
+
.string()
|
|
2779
|
+
.optional()
|
|
2780
|
+
.describe(
|
|
2781
|
+
'Only tasks at this priority — one of the workspace\'s Priority options ("high"; case-insensitive).',
|
|
2782
|
+
),
|
|
2745
2783
|
}),
|
|
2746
2784
|
"crm.tasks.forEntry": z.object({
|
|
2747
2785
|
objectName: z.string(),
|
|
@@ -2757,9 +2795,97 @@ export const requestSchemas: Record<string, ZodTypeAny> = {
|
|
|
2757
2795
|
.regex(/^\d{4}-\d{2}-\d{2}$/)
|
|
2758
2796
|
.optional()
|
|
2759
2797
|
.describe("YYYY-MM-DD"),
|
|
2798
|
+
priority: z
|
|
2799
|
+
.string()
|
|
2800
|
+
.optional()
|
|
2801
|
+
.describe(
|
|
2802
|
+
"One of the workspace's Priority options (default Low | Medium | High; case-insensitive).",
|
|
2803
|
+
),
|
|
2760
2804
|
}),
|
|
2761
2805
|
"crm.tasks.complete": z.object({ entryId: z.string() }),
|
|
2762
2806
|
"crm.tasks.reopen": z.object({ entryId: z.string() }),
|
|
2807
|
+
"crm.tasks.setPriority": z.object({
|
|
2808
|
+
entryId: z.string(),
|
|
2809
|
+
priority: z
|
|
2810
|
+
.string()
|
|
2811
|
+
.nullable()
|
|
2812
|
+
.describe(
|
|
2813
|
+
'One of the workspace\'s Priority options ("high"; case-insensitive), or null to clear.',
|
|
2814
|
+
),
|
|
2815
|
+
}),
|
|
2816
|
+
"crm.tasks.subtasks.list": z.object({ entryId: z.string() }),
|
|
2817
|
+
"crm.tasks.subtasks.create": z.object({
|
|
2818
|
+
entryId: z.string().describe("The parent task."),
|
|
2819
|
+
name: z.string().min(1),
|
|
2820
|
+
assigneeUserId: z.string().optional(),
|
|
2821
|
+
dueDateKey: z
|
|
2822
|
+
.string()
|
|
2823
|
+
.regex(/^\d{4}-\d{2}-\d{2}$/)
|
|
2824
|
+
.optional()
|
|
2825
|
+
.describe("YYYY-MM-DD"),
|
|
2826
|
+
priority: z.string().optional(),
|
|
2827
|
+
}),
|
|
2828
|
+
"crm.tasks.setParent": z.object({
|
|
2829
|
+
entryId: z.string(),
|
|
2830
|
+
parentEntryId: z
|
|
2831
|
+
.string()
|
|
2832
|
+
.nullable()
|
|
2833
|
+
.describe("The parent task, or null to promote to a top-level task."),
|
|
2834
|
+
}),
|
|
2835
|
+
"crm.tasks.delete": z.object({
|
|
2836
|
+
entryId: z.string(),
|
|
2837
|
+
subtasks: z
|
|
2838
|
+
.enum(["delete", "keep"])
|
|
2839
|
+
.optional()
|
|
2840
|
+
.describe(
|
|
2841
|
+
"What happens to its subtasks: delete them too (default) or keep them as tasks.",
|
|
2842
|
+
),
|
|
2843
|
+
}),
|
|
2844
|
+
"crm.tasks.repeat.get": z.object({ entryId: z.string() }),
|
|
2845
|
+
"crm.tasks.repeat.set": z.object({
|
|
2846
|
+
entryId: z.string(),
|
|
2847
|
+
rule: taskRepeatRuleSchema
|
|
2848
|
+
.optional()
|
|
2849
|
+
.describe("Structured rule; alternative to `rrule`."),
|
|
2850
|
+
rrule: z
|
|
2851
|
+
.string()
|
|
2852
|
+
.optional()
|
|
2853
|
+
.describe(
|
|
2854
|
+
"RFC 5545 subset: FREQ, INTERVAL, BYDAY (ordinal allowed for MONTHLY, e.g. 2TU / -1FR), BYMONTHDAY, BYMONTH, COUNT, UNTIL. Bare FREQ=MONTHLY / YEARLY / WEEKLY take the day from the task's due date.",
|
|
2855
|
+
),
|
|
2856
|
+
trigger: z
|
|
2857
|
+
.enum(["after_completion", "on_schedule"])
|
|
2858
|
+
.optional()
|
|
2859
|
+
.describe(
|
|
2860
|
+
"When the next occurrence is created: after this one is done (default) or on schedule regardless.",
|
|
2861
|
+
),
|
|
2862
|
+
ends: z
|
|
2863
|
+
.union([
|
|
2864
|
+
z.object({ kind: z.literal("never") }),
|
|
2865
|
+
z.object({ kind: z.literal("count"), count: z.number().int().min(1) }),
|
|
2866
|
+
z.object({
|
|
2867
|
+
kind: z.literal("until"),
|
|
2868
|
+
dateKey: z.string().regex(/^\d{4}-\d{2}-\d{2}$/),
|
|
2869
|
+
}),
|
|
2870
|
+
])
|
|
2871
|
+
.optional(),
|
|
2872
|
+
options: z
|
|
2873
|
+
.object({
|
|
2874
|
+
skipWeekends: z.boolean().optional(),
|
|
2875
|
+
keepAssignee: z.boolean().optional(),
|
|
2876
|
+
copyNotes: z.boolean().optional(),
|
|
2877
|
+
copySubtasks: z.boolean().optional(),
|
|
2878
|
+
})
|
|
2879
|
+
.optional(),
|
|
2880
|
+
}),
|
|
2881
|
+
"crm.tasks.repeat.clear": z.object({ entryId: z.string() }),
|
|
2882
|
+
"crm.tasks.repeat.skip": z.object({ entryId: z.string() }),
|
|
2883
|
+
"crm.tasks.repeat.pause": z.object({ entryId: z.string() }),
|
|
2884
|
+
"crm.tasks.repeat.resume": z.object({ entryId: z.string() }),
|
|
2885
|
+
"crm.tasks.series.list": z.object({
|
|
2886
|
+
status: z.enum(["active", "paused", "ended"]).optional(),
|
|
2887
|
+
}),
|
|
2888
|
+
"crm.tasks.series.occurrences": z.object({ seriesId: z.string() }),
|
|
2763
2889
|
|
|
2764
2890
|
// Meetings — the record itself is a CRM entry on `meeting`; these reach
|
|
2765
2891
|
// the transcript, action-item and attendance side tables.
|
|
@@ -3991,6 +4117,19 @@ export const responseSchemas: Record<string, ZodTypeAny> = {
|
|
|
3991
4117
|
"crm.tasks.createForEntry": z.object({}).passthrough(),
|
|
3992
4118
|
"crm.tasks.complete": z.object({}).passthrough(),
|
|
3993
4119
|
"crm.tasks.reopen": z.object({}).passthrough(),
|
|
4120
|
+
"crm.tasks.setPriority": z.object({}).passthrough(),
|
|
4121
|
+
"crm.tasks.subtasks.list": z.array(z.object({}).passthrough()),
|
|
4122
|
+
"crm.tasks.subtasks.create": z.object({}).passthrough(),
|
|
4123
|
+
"crm.tasks.setParent": z.object({}).passthrough(),
|
|
4124
|
+
"crm.tasks.delete": z.object({}).passthrough(),
|
|
4125
|
+
"crm.tasks.repeat.get": z.object({}).passthrough().nullable(),
|
|
4126
|
+
"crm.tasks.repeat.set": z.object({}).passthrough().nullable(),
|
|
4127
|
+
"crm.tasks.repeat.clear": z.null(),
|
|
4128
|
+
"crm.tasks.repeat.skip": z.object({}).passthrough(),
|
|
4129
|
+
"crm.tasks.repeat.pause": z.null(),
|
|
4130
|
+
"crm.tasks.repeat.resume": z.null(),
|
|
4131
|
+
"crm.tasks.series.list": z.array(z.object({}).passthrough()),
|
|
4132
|
+
"crm.tasks.series.occurrences": z.array(z.object({}).passthrough()),
|
|
3994
4133
|
|
|
3995
4134
|
// Notifications
|
|
3996
4135
|
"notifications.list": z.array(notificationShape),
|
|
@@ -167,6 +167,19 @@ export const APP_SDK_OPERATIONS: readonly AppSdkOperationInfo[] = [
|
|
|
167
167
|
{"id":"crm.tasks.createForEntry","group":"crm","summary":"Create a task linked to a CRM entry.","cli":"dench crm tasks create","method":"POST","path":"/crm/objects/{objectName}/entries/{entryId}/tasks","permission":"crm:write","pathParams":["objectName","entryId"]},
|
|
168
168
|
{"id":"crm.tasks.complete","group":"crm","summary":"Mark a task done.","cli":"dench crm tasks complete","method":"POST","path":"/crm/tasks/{entryId}/complete","permission":"crm:write","pathParams":["entryId"]},
|
|
169
169
|
{"id":"crm.tasks.reopen","group":"crm","summary":"Reopen a completed task.","cli":"dench crm tasks reopen","method":"POST","path":"/crm/tasks/{entryId}/reopen","permission":"crm:write","pathParams":["entryId"]},
|
|
170
|
+
{"id":"crm.tasks.setPriority","group":"crm","summary":"Set or clear a task's priority.","cli":"dench crm tasks priority","method":"PUT","path":"/crm/tasks/{entryId}/priority","permission":"crm:write","pathParams":["entryId"]},
|
|
171
|
+
{"id":"crm.tasks.subtasks.list","group":"crm","summary":"A task's subtasks.","cli":"dench crm tasks subtasks","method":"GET","path":"/crm/tasks/{entryId}/subtasks","permission":"crm:read","pathParams":["entryId"]},
|
|
172
|
+
{"id":"crm.tasks.subtasks.create","group":"crm","summary":"Create a subtask under a task (inherits the parent's record relations).","cli":"dench crm tasks create-subtask","method":"POST","path":"/crm/tasks/{entryId}/subtasks","permission":"crm:write","pathParams":["entryId"]},
|
|
173
|
+
{"id":"crm.tasks.setParent","group":"crm","summary":"Nest a task under a parent, or promote it (parentEntryId: null).","cli":"dench crm tasks parent","method":"PUT","path":"/crm/tasks/{entryId}/parent","permission":"crm:write","pathParams":["entryId"]},
|
|
174
|
+
{"id":"crm.tasks.delete","group":"crm","summary":"Delete a task and its subtasks, or keep them as tasks.","cli":"dench crm tasks delete","method":"DELETE","path":"/crm/tasks/{entryId}","permission":"crm:write","pathParams":["entryId"]},
|
|
175
|
+
{"id":"crm.tasks.repeat.get","group":"crm","summary":"How a task repeats (rule, RRULE, trigger, ends, next due).","cli":"dench crm tasks repeat","method":"GET","path":"/crm/tasks/{entryId}/repeat","permission":"crm:read","pathParams":["entryId"]},
|
|
176
|
+
{"id":"crm.tasks.repeat.set","group":"crm","summary":"Make a task repeat, or change how it repeats (JSON rule or RRULE). An undated task gets its due date anchored on the first matching day from today.","cli":"dench crm tasks repeat","method":"PUT","path":"/crm/tasks/{entryId}/repeat","permission":"crm:write","pathParams":["entryId"]},
|
|
177
|
+
{"id":"crm.tasks.repeat.clear","group":"crm","summary":"Stop a task repeating (past occurrences are kept).","cli":"dench crm tasks repeat --off","method":"DELETE","path":"/crm/tasks/{entryId}/repeat","permission":"crm:write","pathParams":["entryId"]},
|
|
178
|
+
{"id":"crm.tasks.repeat.skip","group":"crm","summary":"Skip the current occurrence: the next one is created now.","cli":"dench crm tasks repeat --skip","method":"POST","path":"/crm/tasks/{entryId}/repeat/skip","permission":"crm:write","pathParams":["entryId"]},
|
|
179
|
+
{"id":"crm.tasks.repeat.pause","group":"crm","summary":"Pause a repeating task.","cli":"dench crm tasks repeat --pause","method":"POST","path":"/crm/tasks/{entryId}/repeat/pause","permission":"crm:write","pathParams":["entryId"]},
|
|
180
|
+
{"id":"crm.tasks.repeat.resume","group":"crm","summary":"Resume a paused repeating task.","cli":"dench crm tasks repeat --resume","method":"POST","path":"/crm/tasks/{entryId}/repeat/resume","permission":"crm:write","pathParams":["entryId"]},
|
|
181
|
+
{"id":"crm.tasks.series.list","group":"crm","summary":"Every repeating-task series in the workspace.","cli":"dench crm tasks series","method":"GET","path":"/crm/tasks/series","permission":"crm:read","pathParams":[]},
|
|
182
|
+
{"id":"crm.tasks.series.occurrences","group":"crm","summary":"Every occurrence (task) of one series.","cli":"dench crm tasks series <seriesId> --occurrences","method":"GET","path":"/crm/tasks/series/{seriesId}/occurrences","permission":"crm:read","pathParams":["seriesId"]},
|
|
170
183
|
{"id":"crm.entries.create","group":"crm","summary":"Create a CRM entry.","cli":"dench crm entries create","method":"POST","path":"/crm/objects/{objectName}/entries","permission":"crm:write","pathParams":["objectName"]},
|
|
171
184
|
{"id":"crm.entries.createMany","group":"crm","summary":"Create many CRM entries.","cli":"dench crm entries create-many","method":"POST","path":"/crm/objects/{objectName}/entries/batch","permission":"crm:write","pathParams":["objectName"]},
|
|
172
185
|
{"id":"crm.entries.update","group":"crm","summary":"Update a CRM entry.","cli":"dench crm entries update","method":"PATCH","path":"/crm/objects/{objectName}/entries/{entryId}","permission":"crm:write","pathParams":["objectName","entryId"]},
|
|
@@ -444,6 +457,19 @@ export const APP_SDK_METHODS: Readonly<Record<string, AppSdkMethodInfo>> = {
|
|
|
444
457
|
"tasks.create": {"kind":"op","permission":"crm:write","op":"crm.tasks.createForEntry","doc":"Create a task on an entry."},
|
|
445
458
|
"tasks.complete": {"kind":"op","permission":"crm:write","op":"crm.tasks.complete","doc":"Mark a task done."},
|
|
446
459
|
"tasks.reopen": {"kind":"op","permission":"crm:write","op":"crm.tasks.reopen","doc":"Reopen a task."},
|
|
460
|
+
"tasks.setPriority": {"kind":"op","permission":"crm:write","op":"crm.tasks.setPriority","doc":"Set a task's priority (one of the workspace's options) or clear it with null."},
|
|
461
|
+
"tasks.subtasks": {"kind":"op","permission":"crm:read","op":"crm.tasks.subtasks.list","doc":"A task's subtasks."},
|
|
462
|
+
"tasks.createSubtask": {"kind":"op","permission":"crm:write","op":"crm.tasks.subtasks.create","doc":"Create a subtask under a task (one level deep; inherits the parent's record relations)."},
|
|
463
|
+
"tasks.setParent": {"kind":"op","permission":"crm:write","op":"crm.tasks.setParent","doc":"Nest a task under a parent, or promote it with null."},
|
|
464
|
+
"tasks.delete": {"kind":"op","permission":"crm:write","op":"crm.tasks.delete","doc":"Delete a task; its subtasks go with it unless subtasks is \"keep\"."},
|
|
465
|
+
"tasks.getRepeat": {"kind":"op","permission":"crm:read","op":"crm.tasks.repeat.get","doc":"How a task repeats (rule, RRULE, trigger, ends, next due), or null."},
|
|
466
|
+
"tasks.setRepeat": {"kind":"op","permission":"crm:write","op":"crm.tasks.repeat.set","doc":"Make a task repeat or change how it repeats (JSON rule or RRULE). An undated task gets its due date anchored on the first matching day from today."},
|
|
467
|
+
"tasks.clearRepeat": {"kind":"op","permission":"crm:write","op":"crm.tasks.repeat.clear","doc":"Stop a task repeating."},
|
|
468
|
+
"tasks.skipRepeat": {"kind":"op","permission":"crm:write","op":"crm.tasks.repeat.skip","doc":"Skip the current occurrence; the next one is created now."},
|
|
469
|
+
"tasks.pauseRepeat": {"kind":"op","permission":"crm:write","op":"crm.tasks.repeat.pause","doc":"Pause a repeating task."},
|
|
470
|
+
"tasks.resumeRepeat": {"kind":"op","permission":"crm:write","op":"crm.tasks.repeat.resume","doc":"Resume a paused repeating task."},
|
|
471
|
+
"tasks.series": {"kind":"op","permission":"crm:read","op":"crm.tasks.series.list","doc":"Every repeating-task series in the workspace."},
|
|
472
|
+
"tasks.seriesOccurrences": {"kind":"op","permission":"crm:read","op":"crm.tasks.series.occurrences","doc":"Every occurrence of one series."},
|
|
447
473
|
"notifications.list": {"kind":"op","permission":"notifications:read","op":"notifications.list","doc":"My notifications (inbox | unread | archived | all | mentions)."},
|
|
448
474
|
"notifications.unreadCount": {"kind":"op","permission":"notifications:read","op":"notifications.unreadCount","doc":"Unread badge count."},
|
|
449
475
|
"notifications.read": {"kind":"op","permission":"notifications:write","op":"notifications.read","doc":"Mark one read (or unread)."},
|
package/lib/app-sdk-surface.ts
CHANGED
|
@@ -386,6 +386,84 @@ export const APP_SDK_SURFACE: AppSdkSurface = {
|
|
|
386
386
|
args: "entryId: string",
|
|
387
387
|
returns: R("crm.tasks.reopen"),
|
|
388
388
|
},
|
|
389
|
+
setPriority: {
|
|
390
|
+
op: "crm.tasks.setPriority",
|
|
391
|
+
doc: "Set a task's priority (one of the workspace's options) or clear it with null.",
|
|
392
|
+
args: "entryId: string, priority: string | null",
|
|
393
|
+
returns: R("crm.tasks.setPriority"),
|
|
394
|
+
},
|
|
395
|
+
subtasks: {
|
|
396
|
+
op: "crm.tasks.subtasks.list",
|
|
397
|
+
doc: "A task's subtasks.",
|
|
398
|
+
args: "entryId: string",
|
|
399
|
+
returns: R("crm.tasks.subtasks.list"),
|
|
400
|
+
},
|
|
401
|
+
createSubtask: {
|
|
402
|
+
op: "crm.tasks.subtasks.create",
|
|
403
|
+
doc: "Create a subtask under a task (one level deep; inherits the parent's record relations).",
|
|
404
|
+
args: `entryId: string, subtask: ${Rest("crm.tasks.subtasks.create", "entryId")}`,
|
|
405
|
+
returns: R("crm.tasks.subtasks.create"),
|
|
406
|
+
},
|
|
407
|
+
setParent: {
|
|
408
|
+
op: "crm.tasks.setParent",
|
|
409
|
+
doc: "Nest a task under a parent, or promote it with null.",
|
|
410
|
+
args: "entryId: string, parentEntryId: string | null",
|
|
411
|
+
returns: R("crm.tasks.setParent"),
|
|
412
|
+
},
|
|
413
|
+
delete: {
|
|
414
|
+
op: "crm.tasks.delete",
|
|
415
|
+
doc: 'Delete a task; its subtasks go with it unless subtasks is "keep".',
|
|
416
|
+
args: 'entryId: string, subtasks?: "delete" | "keep"',
|
|
417
|
+
returns: R("crm.tasks.delete"),
|
|
418
|
+
},
|
|
419
|
+
getRepeat: {
|
|
420
|
+
op: "crm.tasks.repeat.get",
|
|
421
|
+
doc: "How a task repeats (rule, RRULE, trigger, ends, next due), or null.",
|
|
422
|
+
args: "entryId: string",
|
|
423
|
+
returns: R("crm.tasks.repeat.get"),
|
|
424
|
+
},
|
|
425
|
+
setRepeat: {
|
|
426
|
+
op: "crm.tasks.repeat.set",
|
|
427
|
+
doc: "Make a task repeat or change how it repeats (JSON rule or RRULE). An undated task gets its due date anchored on the first matching day from today.",
|
|
428
|
+
args: `entryId: string, repeat: ${Rest("crm.tasks.repeat.set", "entryId")}`,
|
|
429
|
+
returns: R("crm.tasks.repeat.set"),
|
|
430
|
+
},
|
|
431
|
+
clearRepeat: {
|
|
432
|
+
op: "crm.tasks.repeat.clear",
|
|
433
|
+
doc: "Stop a task repeating.",
|
|
434
|
+
args: "entryId: string",
|
|
435
|
+
returns: R("crm.tasks.repeat.clear"),
|
|
436
|
+
},
|
|
437
|
+
skipRepeat: {
|
|
438
|
+
op: "crm.tasks.repeat.skip",
|
|
439
|
+
doc: "Skip the current occurrence; the next one is created now.",
|
|
440
|
+
args: "entryId: string",
|
|
441
|
+
returns: R("crm.tasks.repeat.skip"),
|
|
442
|
+
},
|
|
443
|
+
pauseRepeat: {
|
|
444
|
+
op: "crm.tasks.repeat.pause",
|
|
445
|
+
doc: "Pause a repeating task.",
|
|
446
|
+
args: "entryId: string",
|
|
447
|
+
returns: R("crm.tasks.repeat.pause"),
|
|
448
|
+
},
|
|
449
|
+
resumeRepeat: {
|
|
450
|
+
op: "crm.tasks.repeat.resume",
|
|
451
|
+
doc: "Resume a paused repeating task.",
|
|
452
|
+
args: "entryId: string",
|
|
453
|
+
returns: R("crm.tasks.repeat.resume"),
|
|
454
|
+
},
|
|
455
|
+
series: {
|
|
456
|
+
op: "crm.tasks.series.list",
|
|
457
|
+
doc: "Every repeating-task series in the workspace.",
|
|
458
|
+
args: `opts?: ${A("crm.tasks.series.list")}`,
|
|
459
|
+
returns: R("crm.tasks.series.list"),
|
|
460
|
+
},
|
|
461
|
+
seriesOccurrences: {
|
|
462
|
+
op: "crm.tasks.series.occurrences",
|
|
463
|
+
doc: "Every occurrence of one series.",
|
|
464
|
+
args: "seriesId: string",
|
|
465
|
+
returns: R("crm.tasks.series.occurrences"),
|
|
466
|
+
},
|
|
389
467
|
},
|
|
390
468
|
|
|
391
469
|
notifications: {
|
package/lib/command-registry.ts
CHANGED
|
@@ -1254,6 +1254,167 @@ const rawApiOperations = [
|
|
|
1254
1254
|
responseSchema: anyResponse,
|
|
1255
1255
|
backend: convex("mutation", "functions/crm/tasks:reopenTask"),
|
|
1256
1256
|
}),
|
|
1257
|
+
op({
|
|
1258
|
+
id: "crm.tasks.setPriority",
|
|
1259
|
+
group: "crm",
|
|
1260
|
+
summary: "Set or clear a task's priority.",
|
|
1261
|
+
cli: "dench crm tasks priority",
|
|
1262
|
+
method: "PUT",
|
|
1263
|
+
path: "/crm/tasks/{entryId}/priority",
|
|
1264
|
+
requestSchema: anyObject,
|
|
1265
|
+
responseSchema: anyResponse,
|
|
1266
|
+
backend: convex("mutation", "functions/crm/tasks:setTaskPriority"),
|
|
1267
|
+
}),
|
|
1268
|
+
// Subtasks are ordinary task rows whose `Parent Task` self-relation points
|
|
1269
|
+
// at another task (one level deep). The field is created on first use.
|
|
1270
|
+
op({
|
|
1271
|
+
id: "crm.tasks.subtasks.list",
|
|
1272
|
+
group: "crm",
|
|
1273
|
+
summary: "A task's subtasks.",
|
|
1274
|
+
cli: "dench crm tasks subtasks",
|
|
1275
|
+
method: "GET",
|
|
1276
|
+
path: "/crm/tasks/{entryId}/subtasks",
|
|
1277
|
+
requestSchema: noBody,
|
|
1278
|
+
responseSchema: anyResponse,
|
|
1279
|
+
backend: convex("query", "functions/crm/tasks:listSubtasks"),
|
|
1280
|
+
}),
|
|
1281
|
+
op({
|
|
1282
|
+
id: "crm.tasks.subtasks.create",
|
|
1283
|
+
group: "crm",
|
|
1284
|
+
summary:
|
|
1285
|
+
"Create a subtask under a task (inherits the parent's record relations).",
|
|
1286
|
+
cli: "dench crm tasks create-subtask",
|
|
1287
|
+
method: "POST",
|
|
1288
|
+
path: "/crm/tasks/{entryId}/subtasks",
|
|
1289
|
+
requestSchema: anyObject,
|
|
1290
|
+
responseSchema: anyResponse,
|
|
1291
|
+
backend: {
|
|
1292
|
+
...convex("mutation", "functions/crm/tasks:createSubtask"),
|
|
1293
|
+
transformArgs: (input) => {
|
|
1294
|
+
const { entryId, ...rest } = input;
|
|
1295
|
+
return { ...rest, parentEntryId: entryId };
|
|
1296
|
+
},
|
|
1297
|
+
},
|
|
1298
|
+
}),
|
|
1299
|
+
op({
|
|
1300
|
+
id: "crm.tasks.setParent",
|
|
1301
|
+
group: "crm",
|
|
1302
|
+
summary: "Nest a task under a parent, or promote it (parentEntryId: null).",
|
|
1303
|
+
cli: "dench crm tasks parent",
|
|
1304
|
+
method: "PUT",
|
|
1305
|
+
path: "/crm/tasks/{entryId}/parent",
|
|
1306
|
+
requestSchema: anyObject,
|
|
1307
|
+
responseSchema: anyResponse,
|
|
1308
|
+
backend: convex("mutation", "functions/crm/tasks:setTaskParent"),
|
|
1309
|
+
}),
|
|
1310
|
+
op({
|
|
1311
|
+
id: "crm.tasks.delete",
|
|
1312
|
+
group: "crm",
|
|
1313
|
+
summary: "Delete a task and its subtasks, or keep them as tasks.",
|
|
1314
|
+
cli: "dench crm tasks delete",
|
|
1315
|
+
method: "DELETE",
|
|
1316
|
+
path: "/crm/tasks/{entryId}",
|
|
1317
|
+
requestSchema: anyObject,
|
|
1318
|
+
responseSchema: anyResponse,
|
|
1319
|
+
backend: {
|
|
1320
|
+
...convex("mutation", "functions/crm/tasks:deleteTask"),
|
|
1321
|
+
transformArgs: (input) => ({
|
|
1322
|
+
entryId: input.entryId,
|
|
1323
|
+
subtasks: input.subtasks === "keep" ? "keep" : "delete",
|
|
1324
|
+
}),
|
|
1325
|
+
},
|
|
1326
|
+
}),
|
|
1327
|
+
// Repeating tasks — a property of the task's Due Date. One series per task,
|
|
1328
|
+
// a new task per occurrence (linked through the hidden `_Series` field).
|
|
1329
|
+
op({
|
|
1330
|
+
id: "crm.tasks.repeat.get",
|
|
1331
|
+
group: "crm",
|
|
1332
|
+
summary: "How a task repeats (rule, RRULE, trigger, ends, next due).",
|
|
1333
|
+
cli: "dench crm tasks repeat",
|
|
1334
|
+
method: "GET",
|
|
1335
|
+
path: "/crm/tasks/{entryId}/repeat",
|
|
1336
|
+
requestSchema: noBody,
|
|
1337
|
+
responseSchema: anyResponse,
|
|
1338
|
+
backend: convex("query", "functions/crm/taskRecurrences:getForTask"),
|
|
1339
|
+
}),
|
|
1340
|
+
op({
|
|
1341
|
+
id: "crm.tasks.repeat.set",
|
|
1342
|
+
group: "crm",
|
|
1343
|
+
summary:
|
|
1344
|
+
"Make a task repeat, or change how it repeats (JSON rule or RRULE). An undated task gets its due date anchored on the first matching day from today.",
|
|
1345
|
+
cli: "dench crm tasks repeat",
|
|
1346
|
+
method: "PUT",
|
|
1347
|
+
path: "/crm/tasks/{entryId}/repeat",
|
|
1348
|
+
requestSchema: anyObject,
|
|
1349
|
+
responseSchema: anyResponse,
|
|
1350
|
+
backend: convex("mutation", "functions/crm/taskRecurrences:setForTask"),
|
|
1351
|
+
}),
|
|
1352
|
+
op({
|
|
1353
|
+
id: "crm.tasks.repeat.clear",
|
|
1354
|
+
group: "crm",
|
|
1355
|
+
summary: "Stop a task repeating (past occurrences are kept).",
|
|
1356
|
+
cli: "dench crm tasks repeat --off",
|
|
1357
|
+
method: "DELETE",
|
|
1358
|
+
path: "/crm/tasks/{entryId}/repeat",
|
|
1359
|
+
requestSchema: noBody,
|
|
1360
|
+
responseSchema: anyResponse,
|
|
1361
|
+
backend: convex("mutation", "functions/crm/taskRecurrences:clearForTask"),
|
|
1362
|
+
}),
|
|
1363
|
+
op({
|
|
1364
|
+
id: "crm.tasks.repeat.skip",
|
|
1365
|
+
group: "crm",
|
|
1366
|
+
summary: "Skip the current occurrence: the next one is created now.",
|
|
1367
|
+
cli: "dench crm tasks repeat --skip",
|
|
1368
|
+
method: "POST",
|
|
1369
|
+
path: "/crm/tasks/{entryId}/repeat/skip",
|
|
1370
|
+
requestSchema: noBody,
|
|
1371
|
+
responseSchema: anyResponse,
|
|
1372
|
+
backend: convex("mutation", "functions/crm/taskRecurrences:skip"),
|
|
1373
|
+
}),
|
|
1374
|
+
op({
|
|
1375
|
+
id: "crm.tasks.repeat.pause",
|
|
1376
|
+
group: "crm",
|
|
1377
|
+
summary: "Pause a repeating task.",
|
|
1378
|
+
cli: "dench crm tasks repeat --pause",
|
|
1379
|
+
method: "POST",
|
|
1380
|
+
path: "/crm/tasks/{entryId}/repeat/pause",
|
|
1381
|
+
requestSchema: noBody,
|
|
1382
|
+
responseSchema: anyResponse,
|
|
1383
|
+
backend: convex("mutation", "functions/crm/taskRecurrences:pause"),
|
|
1384
|
+
}),
|
|
1385
|
+
op({
|
|
1386
|
+
id: "crm.tasks.repeat.resume",
|
|
1387
|
+
group: "crm",
|
|
1388
|
+
summary: "Resume a paused repeating task.",
|
|
1389
|
+
cli: "dench crm tasks repeat --resume",
|
|
1390
|
+
method: "POST",
|
|
1391
|
+
path: "/crm/tasks/{entryId}/repeat/resume",
|
|
1392
|
+
requestSchema: noBody,
|
|
1393
|
+
responseSchema: anyResponse,
|
|
1394
|
+
backend: convex("mutation", "functions/crm/taskRecurrences:resume"),
|
|
1395
|
+
}),
|
|
1396
|
+
op({
|
|
1397
|
+
id: "crm.tasks.series.list",
|
|
1398
|
+
group: "crm",
|
|
1399
|
+
summary: "Every repeating-task series in the workspace.",
|
|
1400
|
+
cli: "dench crm tasks series",
|
|
1401
|
+
method: "GET",
|
|
1402
|
+
path: "/crm/tasks/series",
|
|
1403
|
+
requestSchema: noBody,
|
|
1404
|
+
responseSchema: anyResponse,
|
|
1405
|
+
backend: convex("query", "functions/crm/taskRecurrences:listSeries"),
|
|
1406
|
+
}),
|
|
1407
|
+
op({
|
|
1408
|
+
id: "crm.tasks.series.occurrences",
|
|
1409
|
+
group: "crm",
|
|
1410
|
+
summary: "Every occurrence (task) of one series.",
|
|
1411
|
+
cli: "dench crm tasks series <seriesId> --occurrences",
|
|
1412
|
+
method: "GET",
|
|
1413
|
+
path: "/crm/tasks/series/{seriesId}/occurrences",
|
|
1414
|
+
requestSchema: noBody,
|
|
1415
|
+
responseSchema: anyResponse,
|
|
1416
|
+
backend: convex("query", "functions/crm/taskRecurrences:listOccurrences"),
|
|
1417
|
+
}),
|
|
1257
1418
|
|
|
1258
1419
|
op({
|
|
1259
1420
|
id: "crm.entries.create",
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `dench crm tasks repeat <id> weekly --on mon,wed --every 2 --ends-after 10`
|
|
3
|
+
* → the structured repeat spec the API takes. Pure, so the CLI test can pin
|
|
4
|
+
* every shorthand without a Convex client. `--rrule` bypasses all of it.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export type RepeatCliInput = {
|
|
8
|
+
freq?: string;
|
|
9
|
+
every?: string;
|
|
10
|
+
on?: string;
|
|
11
|
+
day?: string;
|
|
12
|
+
nth?: string;
|
|
13
|
+
endsAfter?: string;
|
|
14
|
+
until?: string;
|
|
15
|
+
onSchedule?: boolean;
|
|
16
|
+
skipWeekends?: boolean;
|
|
17
|
+
noCopyNotes?: boolean;
|
|
18
|
+
noKeepAssignee?: boolean;
|
|
19
|
+
noCopySubtasks?: boolean;
|
|
20
|
+
rrule?: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
type Weekday = "mo" | "tu" | "we" | "th" | "fr" | "sa" | "su";
|
|
24
|
+
|
|
25
|
+
const WEEKDAY_ALIASES: Record<string, Weekday> = {
|
|
26
|
+
mo: "mo",
|
|
27
|
+
mon: "mo",
|
|
28
|
+
monday: "mo",
|
|
29
|
+
tu: "tu",
|
|
30
|
+
tue: "tu",
|
|
31
|
+
tues: "tu",
|
|
32
|
+
tuesday: "tu",
|
|
33
|
+
we: "we",
|
|
34
|
+
wed: "we",
|
|
35
|
+
wednesday: "we",
|
|
36
|
+
th: "th",
|
|
37
|
+
thu: "th",
|
|
38
|
+
thur: "th",
|
|
39
|
+
thurs: "th",
|
|
40
|
+
thursday: "th",
|
|
41
|
+
fr: "fr",
|
|
42
|
+
fri: "fr",
|
|
43
|
+
friday: "fr",
|
|
44
|
+
sa: "sa",
|
|
45
|
+
sat: "sa",
|
|
46
|
+
saturday: "sa",
|
|
47
|
+
su: "su",
|
|
48
|
+
sun: "su",
|
|
49
|
+
sunday: "su",
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export class RepeatArgsError extends Error {}
|
|
53
|
+
|
|
54
|
+
function positiveInt(
|
|
55
|
+
raw: string | undefined,
|
|
56
|
+
flag: string,
|
|
57
|
+
): number | undefined {
|
|
58
|
+
if (raw === undefined) return undefined;
|
|
59
|
+
const n = Number(raw);
|
|
60
|
+
if (!Number.isInteger(n) || n < 1) {
|
|
61
|
+
throw new RepeatArgsError(
|
|
62
|
+
`${flag} must be a positive integer (got "${raw}").`,
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
return n;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function parseWeekdays(raw: string): Weekday[] {
|
|
69
|
+
const days = raw
|
|
70
|
+
.split(",")
|
|
71
|
+
.map((token) => token.trim().toLowerCase())
|
|
72
|
+
.filter(Boolean)
|
|
73
|
+
.map((token) => {
|
|
74
|
+
const day = WEEKDAY_ALIASES[token];
|
|
75
|
+
if (!day)
|
|
76
|
+
throw new RepeatArgsError(`Unknown weekday "${token}" in --on.`);
|
|
77
|
+
return day;
|
|
78
|
+
});
|
|
79
|
+
if (days.length === 0)
|
|
80
|
+
throw new RepeatArgsError("--on needs at least one weekday.");
|
|
81
|
+
return Array.from(new Set(days));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Build the `crm.tasks.repeat.set` body (minus `entryId`). `dueKey` fills
|
|
86
|
+
* in weekly / monthly / yearly rules that don't say which day; without it
|
|
87
|
+
* those fall back to a bare RRULE (`FREQ=WEEKLY`) and the server reads the
|
|
88
|
+
* day from the task's due date — or from today, anchoring an undated task.
|
|
89
|
+
*/
|
|
90
|
+
export function buildRepeatBody(
|
|
91
|
+
input: RepeatCliInput,
|
|
92
|
+
dueKey?: string | null,
|
|
93
|
+
): Record<string, unknown> {
|
|
94
|
+
const body: Record<string, unknown> = {};
|
|
95
|
+
|
|
96
|
+
if (input.rrule) {
|
|
97
|
+
body.rrule = input.rrule;
|
|
98
|
+
} else if (input.freq) {
|
|
99
|
+
const interval = positiveInt(input.every, "--every") ?? 1;
|
|
100
|
+
const freq = input.freq.trim().toLowerCase();
|
|
101
|
+
switch (freq) {
|
|
102
|
+
case "daily":
|
|
103
|
+
body.rule = { freq: "daily", interval };
|
|
104
|
+
break;
|
|
105
|
+
case "weekdays":
|
|
106
|
+
body.rule = {
|
|
107
|
+
freq: "weekly",
|
|
108
|
+
interval,
|
|
109
|
+
byWeekday: ["mo", "tu", "we", "th", "fr"],
|
|
110
|
+
};
|
|
111
|
+
break;
|
|
112
|
+
case "weekly": {
|
|
113
|
+
const byWeekday = input.on
|
|
114
|
+
? parseWeekdays(input.on)
|
|
115
|
+
: dueKey
|
|
116
|
+
? [weekdayOfKey(dueKey)]
|
|
117
|
+
: null;
|
|
118
|
+
if (!byWeekday) {
|
|
119
|
+
body.rrule = bareRRule("WEEKLY", interval);
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
body.rule = { freq: "weekly", interval, byWeekday };
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
case "monthly": {
|
|
126
|
+
if (input.nth !== undefined) {
|
|
127
|
+
const ordinal =
|
|
128
|
+
input.nth.trim().toLowerCase() === "last" ? -1 : Number(input.nth);
|
|
129
|
+
if (
|
|
130
|
+
!Number.isInteger(ordinal) ||
|
|
131
|
+
ordinal === 0 ||
|
|
132
|
+
ordinal < -1 ||
|
|
133
|
+
ordinal > 4
|
|
134
|
+
) {
|
|
135
|
+
throw new RepeatArgsError('--nth must be 1–4 or "last".');
|
|
136
|
+
}
|
|
137
|
+
if (!input.on)
|
|
138
|
+
throw new RepeatArgsError("--nth needs --on <weekday>.");
|
|
139
|
+
const [weekday] = parseWeekdays(input.on);
|
|
140
|
+
body.rule = {
|
|
141
|
+
freq: "monthly",
|
|
142
|
+
interval,
|
|
143
|
+
bySetPos: { ordinal, weekday },
|
|
144
|
+
};
|
|
145
|
+
} else {
|
|
146
|
+
const day =
|
|
147
|
+
input.day === undefined
|
|
148
|
+
? dueKey
|
|
149
|
+
? Number(dueKey.slice(8, 10))
|
|
150
|
+
: null
|
|
151
|
+
: input.day.trim().toLowerCase() === "last"
|
|
152
|
+
? -1
|
|
153
|
+
: Number(input.day);
|
|
154
|
+
if (day === null) {
|
|
155
|
+
body.rrule = bareRRule("MONTHLY", interval);
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
if (!Number.isInteger(day) || day === 0 || day < -1 || day > 31) {
|
|
159
|
+
throw new RepeatArgsError('--day must be 1–31 or "last".');
|
|
160
|
+
}
|
|
161
|
+
body.rule = { freq: "monthly", interval, byMonthDay: day };
|
|
162
|
+
}
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
case "yearly": {
|
|
166
|
+
if (!dueKey) {
|
|
167
|
+
body.rrule = bareRRule("YEARLY", interval);
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
body.rule = {
|
|
171
|
+
freq: "yearly",
|
|
172
|
+
interval,
|
|
173
|
+
month: Number(dueKey.slice(5, 7)),
|
|
174
|
+
day: Number(dueKey.slice(8, 10)),
|
|
175
|
+
};
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
default:
|
|
179
|
+
throw new RepeatArgsError(
|
|
180
|
+
`Unknown repeat "${input.freq}". Use daily | weekdays | weekly | monthly | yearly, or --rrule.`,
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const count = positiveInt(input.endsAfter, "--ends-after");
|
|
186
|
+
if (count !== undefined && input.until) {
|
|
187
|
+
throw new RepeatArgsError("Pass --ends-after or --until, not both.");
|
|
188
|
+
}
|
|
189
|
+
if (count !== undefined) body.ends = { kind: "count", count };
|
|
190
|
+
if (input.until) {
|
|
191
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(input.until)) {
|
|
192
|
+
throw new RepeatArgsError("--until must be YYYY-MM-DD.");
|
|
193
|
+
}
|
|
194
|
+
body.ends = { kind: "until", dateKey: input.until };
|
|
195
|
+
}
|
|
196
|
+
if (input.onSchedule) body.trigger = "on_schedule";
|
|
197
|
+
|
|
198
|
+
const options: Record<string, boolean> = {};
|
|
199
|
+
if (input.skipWeekends) options.skipWeekends = true;
|
|
200
|
+
if (input.noCopyNotes) options.copyNotes = false;
|
|
201
|
+
if (input.noKeepAssignee) options.keepAssignee = false;
|
|
202
|
+
if (input.noCopySubtasks) options.copySubtasks = false;
|
|
203
|
+
if (Object.keys(options).length > 0) body.options = options;
|
|
204
|
+
|
|
205
|
+
return body;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** `FREQ=WEEKLY[;INTERVAL=n]` — the server fills the day from the task. */
|
|
209
|
+
function bareRRule(freq: string, interval: number): string {
|
|
210
|
+
return interval === 1 ? `FREQ=${freq}` : `FREQ=${freq};INTERVAL=${interval}`;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function weekdayOfKey(key: string): Weekday {
|
|
214
|
+
const [y, m, d] = key.split("-").map(Number) as [number, number, number];
|
|
215
|
+
const js = new Date(Date.UTC(y, m - 1, d)).getUTCDay();
|
|
216
|
+
return (["su", "mo", "tu", "we", "th", "fr", "sa"] as Weekday[])[
|
|
217
|
+
js
|
|
218
|
+
] as Weekday;
|
|
219
|
+
}
|