@endora-commerce/contracts 0.108.0 → 0.110.0
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/dist/actor.d.ts +16 -0
- package/dist/actor.d.ts.map +1 -1
- package/dist/addresses.d.ts +35 -0
- package/dist/addresses.d.ts.map +1 -1
- package/dist/addresses.js +8 -1
- package/dist/addresses.js.map +1 -1
- package/dist/admin-actions.d.ts +12 -3
- package/dist/admin-actions.d.ts.map +1 -1
- package/dist/admin-actions.js +34 -3
- package/dist/admin-actions.js.map +1 -1
- package/dist/admin-contributions.d.ts +94 -10
- package/dist/admin-contributions.d.ts.map +1 -1
- package/dist/admin-contributions.js +65 -0
- package/dist/admin-contributions.js.map +1 -1
- package/dist/admin-notifications.d.ts +17 -1
- package/dist/admin-notifications.d.ts.map +1 -1
- package/dist/admin-preferences.d.ts +108 -0
- package/dist/admin-preferences.d.ts.map +1 -0
- package/dist/admin-preferences.js +133 -0
- package/dist/admin-preferences.js.map +1 -0
- package/dist/admin-roles.d.ts +8 -2
- package/dist/admin-roles.d.ts.map +1 -1
- package/dist/admin-roles.js.map +1 -1
- package/dist/admin-users.d.ts +9 -0
- package/dist/admin-users.d.ts.map +1 -1
- package/dist/admin.d.ts +92 -5
- package/dist/admin.d.ts.map +1 -1
- package/dist/admin.js +86 -3
- package/dist/admin.js.map +1 -1
- package/dist/assets-library.d.ts +123 -3
- package/dist/assets-library.d.ts.map +1 -1
- package/dist/assets-library.js +11 -3
- package/dist/assets-library.js.map +1 -1
- package/dist/audit-logs.d.ts +12 -0
- package/dist/audit-logs.d.ts.map +1 -1
- package/dist/audit-logs.js +12 -0
- package/dist/audit-logs.js.map +1 -1
- package/dist/blog.d.ts +431 -14
- package/dist/blog.d.ts.map +1 -1
- package/dist/blog.js +251 -7
- package/dist/blog.js.map +1 -1
- package/dist/carts.d.ts +507 -92
- package/dist/carts.d.ts.map +1 -1
- package/dist/carts.js +197 -21
- package/dist/carts.js.map +1 -1
- package/dist/catalog.d.ts +515 -144
- package/dist/catalog.d.ts.map +1 -1
- package/dist/catalog.js +356 -68
- package/dist/catalog.js.map +1 -1
- package/dist/cms-brand.d.ts +2233 -0
- package/dist/cms-brand.d.ts.map +1 -0
- package/dist/cms-brand.js +311 -0
- package/dist/cms-brand.js.map +1 -0
- package/dist/cms-contact-form.d.ts +55 -0
- package/dist/cms-contact-form.d.ts.map +1 -0
- package/dist/cms-contact-form.js +100 -0
- package/dist/cms-contact-form.js.map +1 -0
- package/dist/cms.d.ts +576 -17
- package/dist/cms.d.ts.map +1 -1
- package/dist/cms.js +251 -0
- package/dist/cms.js.map +1 -1
- package/dist/common.d.ts +23 -6
- package/dist/common.d.ts.map +1 -1
- package/dist/common.js +25 -2
- package/dist/common.js.map +1 -1
- package/dist/comparisons.d.ts +28 -21
- package/dist/comparisons.d.ts.map +1 -1
- package/dist/comparisons.js +2 -1
- package/dist/comparisons.js.map +1 -1
- package/dist/credit-limits.d.ts +1 -0
- package/dist/credit-limits.d.ts.map +1 -1
- package/dist/credit-limits.js +14 -0
- package/dist/credit-limits.js.map +1 -1
- package/dist/crm-rich-text.d.ts +10 -61
- package/dist/crm-rich-text.d.ts.map +1 -1
- package/dist/crm-rich-text.js +10 -300
- package/dist/crm-rich-text.js.map +1 -1
- package/dist/crm.d.ts +173 -115
- package/dist/crm.d.ts.map +1 -1
- package/dist/crm.js +35 -88
- package/dist/crm.js.map +1 -1
- package/dist/custom-fields.d.ts +54 -22
- package/dist/custom-fields.d.ts.map +1 -1
- package/dist/custom-fields.js +21 -1
- package/dist/custom-fields.js.map +1 -1
- package/dist/customer-accounts.d.ts +216 -22
- package/dist/customer-accounts.d.ts.map +1 -1
- package/dist/customer-accounts.js +70 -0
- package/dist/customer-accounts.js.map +1 -1
- package/dist/customers.d.ts +40 -73
- package/dist/customers.d.ts.map +1 -1
- package/dist/customers.js +45 -10
- package/dist/customers.js.map +1 -1
- package/dist/document-templates.d.ts +35 -23
- package/dist/document-templates.d.ts.map +1 -1
- package/dist/document-values.d.ts +8 -0
- package/dist/document-values.d.ts.map +1 -1
- package/dist/document-values.js +24 -6
- package/dist/document-values.js.map +1 -1
- package/dist/email.d.ts +5 -0
- package/dist/email.d.ts.map +1 -1
- package/dist/errors.d.ts +224 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +269 -1
- package/dist/errors.js.map +1 -1
- package/dist/forms-logic.d.ts +79 -0
- package/dist/forms-logic.d.ts.map +1 -0
- package/dist/forms-logic.fixtures.d.ts +52 -0
- package/dist/forms-logic.fixtures.d.ts.map +1 -0
- package/dist/forms-logic.fixtures.js +610 -0
- package/dist/forms-logic.fixtures.js.map +1 -0
- package/dist/forms-logic.js +699 -0
- package/dist/forms-logic.js.map +1 -0
- package/dist/forms.d.ts +9833 -0
- package/dist/forms.d.ts.map +1 -0
- package/dist/forms.js +827 -0
- package/dist/forms.js.map +1 -0
- package/dist/import-export.d.ts +180 -0
- package/dist/import-export.d.ts.map +1 -1
- package/dist/import-export.js +60 -0
- package/dist/import-export.js.map +1 -1
- package/dist/index.d.ts +22 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +45 -1
- package/dist/index.js.map +1 -1
- package/dist/inventory.d.ts +6 -6
- package/dist/invoice-ledger.d.ts +7 -7
- package/dist/invoices.d.ts +6 -2
- package/dist/invoices.d.ts.map +1 -1
- package/dist/invoices.js +7 -0
- package/dist/invoices.js.map +1 -1
- package/dist/megamenu.d.ts +674 -0
- package/dist/megamenu.d.ts.map +1 -1
- package/dist/megamenu.js +96 -3
- package/dist/megamenu.js.map +1 -1
- package/dist/mfa.d.ts +125 -4
- package/dist/mfa.d.ts.map +1 -1
- package/dist/mfa.js +54 -2
- package/dist/mfa.js.map +1 -1
- package/dist/modules.d.ts +44 -5
- package/dist/modules.d.ts.map +1 -1
- package/dist/modules.js +73 -0
- package/dist/modules.js.map +1 -1
- package/dist/money-decimal.d.ts +54 -0
- package/dist/money-decimal.d.ts.map +1 -1
- package/dist/money-decimal.js +95 -0
- package/dist/money-decimal.js.map +1 -1
- package/dist/newsletter.d.ts +7 -7
- package/dist/orders.d.ts +128 -10
- package/dist/orders.d.ts.map +1 -1
- package/dist/orders.js +74 -4
- package/dist/orders.js.map +1 -1
- package/dist/organization-registry-lookup.d.ts +362 -0
- package/dist/organization-registry-lookup.d.ts.map +1 -0
- package/dist/organization-registry-lookup.js +196 -0
- package/dist/organization-registry-lookup.js.map +1 -0
- package/dist/organization-roles.d.ts +340 -0
- package/dist/organization-roles.d.ts.map +1 -0
- package/dist/organization-roles.js +211 -0
- package/dist/organization-roles.js.map +1 -0
- package/dist/organizations.d.ts +123 -89
- package/dist/organizations.d.ts.map +1 -1
- package/dist/organizations.js +68 -24
- package/dist/organizations.js.map +1 -1
- package/dist/page-builder-props.d.ts +1401 -0
- package/dist/page-builder-props.d.ts.map +1 -0
- package/dist/page-builder-props.js +266 -0
- package/dist/page-builder-props.js.map +1 -0
- package/dist/page-builder-values.d.ts +95 -0
- package/dist/page-builder-values.d.ts.map +1 -0
- package/dist/page-builder-values.js +164 -0
- package/dist/page-builder-values.js.map +1 -0
- package/dist/pim-connector.d.ts +6 -2
- package/dist/pim-connector.d.ts.map +1 -1
- package/dist/pim-connector.js +6 -2
- package/dist/pim-connector.js.map +1 -1
- package/dist/pim-field-path.d.ts +5 -1
- package/dist/pim-field-path.d.ts.map +1 -1
- package/dist/pim-field-path.js +37 -81
- package/dist/pim-field-path.js.map +1 -1
- package/dist/pim-locale-mapping.d.ts +131 -0
- package/dist/pim-locale-mapping.d.ts.map +1 -0
- package/dist/pim-locale-mapping.js +193 -0
- package/dist/pim-locale-mapping.js.map +1 -0
- package/dist/platform-language.d.ts +9 -0
- package/dist/platform-language.d.ts.map +1 -1
- package/dist/platform-language.js +14 -0
- package/dist/platform-language.js.map +1 -1
- package/dist/price-books.d.ts +47 -43
- package/dist/price-books.d.ts.map +1 -1
- package/dist/price-books.js +6 -2
- package/dist/price-books.js.map +1 -1
- package/dist/price-lists.d.ts +48 -14
- package/dist/price-lists.d.ts.map +1 -1
- package/dist/price-lists.js +24 -1
- package/dist/price-lists.js.map +1 -1
- package/dist/product-feeds.d.ts +144 -84
- package/dist/product-feeds.d.ts.map +1 -1
- package/dist/product-feeds.js +23 -0
- package/dist/product-feeds.js.map +1 -1
- package/dist/product-scope-model.d.ts +161 -0
- package/dist/product-scope-model.d.ts.map +1 -0
- package/dist/product-scope-model.js +161 -0
- package/dist/product-scope-model.js.map +1 -0
- package/dist/product-scope-overrides.d.ts +0 -103
- package/dist/product-scope-overrides.d.ts.map +1 -1
- package/dist/product-scope-overrides.js +0 -54
- package/dist/product-scope-overrides.js.map +1 -1
- package/dist/product-scoped-values.d.ts +2610 -0
- package/dist/product-scoped-values.d.ts.map +1 -0
- package/dist/product-scoped-values.js +425 -0
- package/dist/product-scoped-values.js.map +1 -0
- package/dist/product-scopes.d.ts +746 -0
- package/dist/product-scopes.d.ts.map +1 -0
- package/dist/product-scopes.js +436 -0
- package/dist/product-scopes.js.map +1 -0
- package/dist/product-summary-text.d.ts +23 -0
- package/dist/product-summary-text.d.ts.map +1 -0
- package/dist/product-summary-text.js +64 -0
- package/dist/product-summary-text.js.map +1 -0
- package/dist/product-tax-rates.d.ts +38 -0
- package/dist/product-tax-rates.d.ts.map +1 -0
- package/dist/product-tax-rates.js +45 -0
- package/dist/product-tax-rates.js.map +1 -0
- package/dist/product-url-keys.d.ts +210 -0
- package/dist/product-url-keys.d.ts.map +1 -0
- package/dist/product-url-keys.js +200 -0
- package/dist/product-url-keys.js.map +1 -0
- package/dist/product-value-resolver.d.ts +37 -60
- package/dist/product-value-resolver.d.ts.map +1 -1
- package/dist/product-value-resolver.js +36 -96
- package/dist/product-value-resolver.js.map +1 -1
- package/dist/projects.d.ts +2370 -0
- package/dist/projects.d.ts.map +1 -0
- package/dist/projects.js +843 -0
- package/dist/projects.js.map +1 -0
- package/dist/promotions.d.ts +10 -10
- package/dist/prompt-actions.d.ts +19 -1
- package/dist/prompt-actions.d.ts.map +1 -1
- package/dist/prompt-actions.js +31 -2
- package/dist/prompt-actions.js.map +1 -1
- package/dist/pwa.d.ts +2 -2
- package/dist/quick-order.d.ts +150 -7
- package/dist/quick-order.d.ts.map +1 -1
- package/dist/quick-order.js +76 -2
- package/dist/quick-order.js.map +1 -1
- package/dist/quote-requests.d.ts +99 -13
- package/dist/quote-requests.d.ts.map +1 -1
- package/dist/quote-requests.js +66 -1
- package/dist/quote-requests.js.map +1 -1
- package/dist/record-references.d.ts +252 -0
- package/dist/record-references.d.ts.map +1 -0
- package/dist/record-references.js +178 -0
- package/dist/record-references.js.map +1 -0
- package/dist/record-rich-text.d.ts +66 -0
- package/dist/record-rich-text.d.ts.map +1 -0
- package/dist/record-rich-text.js +304 -0
- package/dist/record-rich-text.js.map +1 -0
- package/dist/returns.d.ts +234 -52
- package/dist/returns.d.ts.map +1 -1
- package/dist/returns.js +139 -26
- package/dist/returns.js.map +1 -1
- package/dist/sales-channels.d.ts +51 -7
- package/dist/sales-channels.d.ts.map +1 -1
- package/dist/sales-channels.js +38 -4
- package/dist/sales-channels.js.map +1 -1
- package/dist/saved-list-views.d.ts +56 -0
- package/dist/saved-list-views.d.ts.map +1 -1
- package/dist/saved-list-views.js +27 -1
- package/dist/saved-list-views.js.map +1 -1
- package/dist/scoped-write-encoding.d.ts +100 -0
- package/dist/scoped-write-encoding.d.ts.map +1 -0
- package/dist/scoped-write-encoding.js +135 -0
- package/dist/scoped-write-encoding.js.map +1 -0
- package/dist/search.d.ts +25 -15
- package/dist/search.d.ts.map +1 -1
- package/dist/seo.d.ts +127 -15
- package/dist/seo.d.ts.map +1 -1
- package/dist/seo.js +38 -4
- package/dist/seo.js.map +1 -1
- package/dist/settings.d.ts +161 -3
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +73 -3
- package/dist/settings.js.map +1 -1
- package/dist/shopping-lists.d.ts +24 -3
- package/dist/shopping-lists.d.ts.map +1 -1
- package/dist/shopping-lists.js +20 -0
- package/dist/shopping-lists.js.map +1 -1
- package/dist/storefront-cache-tags.d.ts +41 -0
- package/dist/storefront-cache-tags.d.ts.map +1 -1
- package/dist/storefront-cache-tags.js +36 -0
- package/dist/storefront-cache-tags.js.map +1 -1
- package/dist/storefront-language-path.d.ts +77 -0
- package/dist/storefront-language-path.d.ts.map +1 -0
- package/dist/storefront-language-path.js +123 -0
- package/dist/storefront-language-path.js.map +1 -0
- package/dist/storefront-value-overrides.d.ts +18 -56
- package/dist/storefront-value-overrides.d.ts.map +1 -1
- package/dist/storefront-value-overrides.js +11 -86
- package/dist/storefront-value-overrides.js.map +1 -1
- package/dist/tasks.d.ts +2842 -0
- package/dist/tasks.d.ts.map +1 -0
- package/dist/tasks.js +901 -0
- package/dist/tasks.js.map +1 -0
- package/dist/transactional-emails.d.ts +14 -11
- package/dist/transactional-emails.d.ts.map +1 -1
- package/dist/transactional-emails.js +13 -0
- package/dist/transactional-emails.js.map +1 -1
- package/package.json +3 -3
package/dist/tasks.js
ADDED
|
@@ -0,0 +1,901 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { calendarDateSchema, isoDateTimeSchema } from './common.js';
|
|
3
|
+
import { customFieldFiltersQueryParamSchema, customFieldValuesSchema } from './custom-fields.js';
|
|
4
|
+
import { dataEnvelope } from './envelopes.js';
|
|
5
|
+
import { RecordReferenceSchema } from './record-references.js';
|
|
6
|
+
/**
|
|
7
|
+
* Tasks — `specs/163-projects-and-tasks/`, grown into a work-management module
|
|
8
|
+
* by `specs/165-task-management/`.
|
|
9
|
+
*
|
|
10
|
+
* Every request, response, port, registry and event shape of the `tasks`
|
|
11
|
+
* module, written before the first route (Constitution II) and for **every**
|
|
12
|
+
* story of feature 165 — later phases add no contract here. The normative prose
|
|
13
|
+
* is `specs/165-task-management/contracts/admin-api.md` §1–§5 and
|
|
14
|
+
* `contracts/ports-and-events.md`; the schema is `data-model.md`.
|
|
15
|
+
*
|
|
16
|
+
* What 165 changed, all of it breaking for a consumer of the published shapes:
|
|
17
|
+
*
|
|
18
|
+
* - **A status is a code** of the operator's workflow, grouped into the three
|
|
19
|
+
* {@link TASK_STATUS_CATEGORIES}; *closed* means category `done` or
|
|
20
|
+
* `cancelled` (research R-1, FR-017). The four codes 163 fixed are the seed.
|
|
21
|
+
* - **A Task has a list of assignees**, not one (R-2): `assigneeIds` on every
|
|
22
|
+
* write and on {@link TaskRecord}, `assignees` on every read.
|
|
23
|
+
* - **`tasks.task.assigned.v1` is gone**, replaced by
|
|
24
|
+
* `tasks.task.assignees_changed.v1`; `status_changed` carries codes and the
|
|
25
|
+
* target's category (`data-model.md` §8).
|
|
26
|
+
*
|
|
27
|
+
* A Task may belong to an **opaque context** — `contextType` / `contextId` /
|
|
28
|
+
* `contextGroupId` — through which another module owns it (a Project and one
|
|
29
|
+
* of its Stages, today). `tasks` names no such module: the context's owner
|
|
30
|
+
* registers a {@link TaskContextDescriptor} that answers who may see its
|
|
31
|
+
* contexts and how to label them (163 research R-1, R-9).
|
|
32
|
+
*
|
|
33
|
+
* Base path of the HTTP API: `/api/v1/admin/tasks`. There is no storefront or
|
|
34
|
+
* customer route (FR-044).
|
|
35
|
+
*/
|
|
36
|
+
// ---------------------------------------------------------------------------
|
|
37
|
+
// Vocabulary and limits
|
|
38
|
+
// ---------------------------------------------------------------------------
|
|
39
|
+
/**
|
|
40
|
+
* A code of the operator's workflow, or of the priority list: snake_case,
|
|
41
|
+
* starting with a letter, at most 64 characters. Held **by value** on a Task,
|
|
42
|
+
* never by foreign key (research R-1, R-9).
|
|
43
|
+
*/
|
|
44
|
+
const snakeCodeSchema = z
|
|
45
|
+
.string()
|
|
46
|
+
.min(1)
|
|
47
|
+
.max(64)
|
|
48
|
+
.regex(/^[a-z][a-z0-9_]*$/, 'A code is snake_case and starts with a letter');
|
|
49
|
+
/** A Task's status — a code of the configured workflow (R-1). */
|
|
50
|
+
export const taskStatusCodeSchema = snakeCodeSchema;
|
|
51
|
+
/**
|
|
52
|
+
* The four statuses the upgrade seeds, in workflow order (FR-014): every 163
|
|
53
|
+
* Task already holds one of them, so no row changes. Kept for the seed and the
|
|
54
|
+
* tests; the live workflow is the operator's.
|
|
55
|
+
*/
|
|
56
|
+
export const TASK_DEFAULT_STATUS_CODES = ['todo', 'in_progress', 'done', 'cancelled'];
|
|
57
|
+
/** What a status means for the Task: still worked, finished, or abandoned. */
|
|
58
|
+
export const TASK_STATUS_CATEGORIES = ['open', 'done', 'cancelled'];
|
|
59
|
+
export const taskStatusCategorySchema = z.enum(TASK_STATUS_CATEGORIES);
|
|
60
|
+
/**
|
|
61
|
+
* The categories a Task is **closed** in (FR-017) — *My Tasks*, overdue, the
|
|
62
|
+
* digest, sub-task progress and the Projects completion gate all read this.
|
|
63
|
+
*/
|
|
64
|
+
export const TASK_CLOSED_STATUS_CATEGORIES = ['done', 'cancelled'];
|
|
65
|
+
export function isClosedTaskStatusCategory(category) {
|
|
66
|
+
return TASK_CLOSED_STATUS_CATEGORIES.includes(category);
|
|
67
|
+
}
|
|
68
|
+
/** A priority — a code of the configured list (R-9). */
|
|
69
|
+
export const taskPriorityCodeSchema = snakeCodeSchema;
|
|
70
|
+
/** The priorities the upgrade seeds, most urgent first (FR-024). */
|
|
71
|
+
export const TASK_DEFAULT_PRIORITY_CODES = ['urgent', 'high', 'normal', 'low'];
|
|
72
|
+
/** `#rrggbb` — a status, priority or tag colour. */
|
|
73
|
+
export const taskColorSchema = z.string().regex(/^#[0-9a-fA-F]{6}$/, 'Colour must be a #rrggbb hex value');
|
|
74
|
+
export const TASK_TITLE_MAX = 200;
|
|
75
|
+
export const TASK_DESCRIPTION_MAX = 20_000;
|
|
76
|
+
export const TASK_CONTEXT_NOTE_MAX = 200;
|
|
77
|
+
/** The most Tasks one `taskWritePort.createMany` call creates (163 research R-22). */
|
|
78
|
+
export const TASK_WRITE_PORT_BATCH_MAX = 100;
|
|
79
|
+
export const TASK_LIST_LIMIT_MAX = 100;
|
|
80
|
+
/** The most Tasks `GET /tasks/mine` answers. */
|
|
81
|
+
export const TASK_MINE_MAX = 500;
|
|
82
|
+
/** Assignees of one Task (R-2). */
|
|
83
|
+
export const TASK_ASSIGNEES_MAX = 20;
|
|
84
|
+
/** Tags of one Task (FR-010). */
|
|
85
|
+
export const TASK_TAGS_MAX = 50;
|
|
86
|
+
/** Record links one create body may carry. */
|
|
87
|
+
export const TASK_LINKS_MAX = 20;
|
|
88
|
+
/** Levels of sub-tasks, the top-level Task counted (FR-027, R-15). */
|
|
89
|
+
export const TASK_HIERARCHY_DEPTH_MAX = 5;
|
|
90
|
+
/**
|
|
91
|
+
* The most Tasks one status or priority removal moves to its replacement inside
|
|
92
|
+
* one Command; above it the removal answers 409 `TASK_STATUS_IN_USE_TOO_MANY`
|
|
93
|
+
* (R-1).
|
|
94
|
+
*/
|
|
95
|
+
export const TASK_STATUS_REASSIGN_MAX = 5_000;
|
|
96
|
+
/** One attachment's size; the asset library's own policy also applies (R-7). */
|
|
97
|
+
export const TASK_ATTACHMENT_MAX_BYTES = 25 * 1024 * 1024;
|
|
98
|
+
/**
|
|
99
|
+
* How late a reminder may still be delivered after its moment — after downtime
|
|
100
|
+
* or while Tasks was off. An older one is recorded as expired and not sent
|
|
101
|
+
* (R-17).
|
|
102
|
+
*/
|
|
103
|
+
export const TASK_REMINDER_GRACE_MS = 24 * 60 * 60 * 1000;
|
|
104
|
+
/** Reminders of one Task. */
|
|
105
|
+
export const TASK_REMINDERS_MAX = 10;
|
|
106
|
+
/** Recipients of one reminder: the caller and up to {@link TASK_ASSIGNEES_MAX} assignees. */
|
|
107
|
+
export const TASK_REMINDER_RECIPIENTS_MAX = TASK_ASSIGNEES_MAX + 1;
|
|
108
|
+
/** How far before the due moment a relative reminder may fire: 30 days. */
|
|
109
|
+
export const TASK_REMINDER_OFFSET_MAX_MINUTES = 30 * 24 * 60;
|
|
110
|
+
/** A context owner's own key for a Task it creates (R-19). */
|
|
111
|
+
export const TASK_SOURCE_KEY_MAX = 100;
|
|
112
|
+
export const TASK_COMMENT_MAX = 20_000;
|
|
113
|
+
export const TASK_TAG_NAME_MAX = 64;
|
|
114
|
+
export const TASK_STATUS_NAME_MAX = 120;
|
|
115
|
+
export const TASK_BOARD_PER_COLUMN_DEFAULT = 25;
|
|
116
|
+
export const TASK_BOARD_PER_COLUMN_MAX = 50;
|
|
117
|
+
/**
|
|
118
|
+
* A context type — the contributor's own stable code (`project`). snake_case,
|
|
119
|
+
* so it reads the same in a query string, a column and a log line.
|
|
120
|
+
*/
|
|
121
|
+
export const taskContextTypeSchema = z
|
|
122
|
+
.string()
|
|
123
|
+
.min(1)
|
|
124
|
+
.max(64)
|
|
125
|
+
.regex(/^[a-z][a-z0-9_]*$/, 'A context type is a snake_case code');
|
|
126
|
+
const uuid = z.string().uuid();
|
|
127
|
+
const titleSchema = z.string().trim().min(1).max(TASK_TITLE_MAX);
|
|
128
|
+
const descriptionSchema = z.string().max(TASK_DESCRIPTION_MAX);
|
|
129
|
+
const isoTimestampSchema = z.string();
|
|
130
|
+
const unique = (xs) => new Set(xs).size === xs.length;
|
|
131
|
+
/** A list of distinct uuids, at most `max`. */
|
|
132
|
+
function uuidSet(max, what) {
|
|
133
|
+
return z
|
|
134
|
+
.array(uuid)
|
|
135
|
+
.max(max)
|
|
136
|
+
.refine(unique, { message: `${what} may be named once each` });
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* A query-string field that may repeat. One occurrence arrives as a string and
|
|
140
|
+
* several as an array; both normalise to an array.
|
|
141
|
+
*/
|
|
142
|
+
function repeatable(item) {
|
|
143
|
+
return z.preprocess((value) => (value === undefined || Array.isArray(value) ? value : [value]), z.array(item).max(50).optional());
|
|
144
|
+
}
|
|
145
|
+
/** A query-string boolean: `true` / `false` as text, or a real boolean. */
|
|
146
|
+
const queryBooleanSchema = z.preprocess((value) => (value === 'true' ? true : value === 'false' ? false : value), z.boolean());
|
|
147
|
+
/** A name per Admin UI language — both are required (FR-012, FR-024). */
|
|
148
|
+
export const TaskLocalizedNameSchema = z
|
|
149
|
+
.object({
|
|
150
|
+
en: z.string().trim().min(1).max(TASK_STATUS_NAME_MAX),
|
|
151
|
+
pl: z.string().trim().min(1).max(TASK_STATUS_NAME_MAX),
|
|
152
|
+
})
|
|
153
|
+
.strict();
|
|
154
|
+
// ---------------------------------------------------------------------------
|
|
155
|
+
// The Task context (163 `data-model.md` §1 — all or nothing)
|
|
156
|
+
// ---------------------------------------------------------------------------
|
|
157
|
+
/**
|
|
158
|
+
* Where a Task belongs, when it belongs anywhere. **All or nothing**: a type
|
|
159
|
+
* without an id, or an id without a type, is no context — the table's check
|
|
160
|
+
* `(context_type is null) = (context_id is null)` says the same — and a group
|
|
161
|
+
* (a Stage) exists only inside a context. A Task with no context is written as
|
|
162
|
+
* `context: null` or by leaving `context` out.
|
|
163
|
+
*/
|
|
164
|
+
export const TaskContextSchema = z
|
|
165
|
+
.object({
|
|
166
|
+
contextType: taskContextTypeSchema,
|
|
167
|
+
contextId: uuid,
|
|
168
|
+
contextGroupId: uuid.nullable().optional(),
|
|
169
|
+
})
|
|
170
|
+
.strict();
|
|
171
|
+
/**
|
|
172
|
+
* A context as the reader is shown it: what the owner's descriptor says about it.
|
|
173
|
+
*
|
|
174
|
+
* `available: false` when the owner's `describe()` did not describe the id —
|
|
175
|
+
* a record that went away between the visibility check and the description.
|
|
176
|
+
* The context then fails closed: `label` is the sentence "unavailable record"
|
|
177
|
+
* in the reader's language, `href` and `groupLabel` are `null`. A label is
|
|
178
|
+
* never empty.
|
|
179
|
+
*/
|
|
180
|
+
export const TaskContextSummarySchema = z.object({
|
|
181
|
+
type: z.string(),
|
|
182
|
+
available: z.boolean(),
|
|
183
|
+
label: z.string().min(1),
|
|
184
|
+
href: z.string().nullable(),
|
|
185
|
+
groupLabel: z.string().nullable(),
|
|
186
|
+
});
|
|
187
|
+
export const TaskContextDetailSchema = TaskContextSummarySchema.extend({
|
|
188
|
+
id: uuid,
|
|
189
|
+
groupId: uuid.nullable(),
|
|
190
|
+
/**
|
|
191
|
+
* The context owner's `canChangeTasks` for this reader: whether they may
|
|
192
|
+
* delete this Task or move it out of its record. `false` for an unavailable
|
|
193
|
+
* context. A screen offers neither when it is `false` (163 T147).
|
|
194
|
+
*/
|
|
195
|
+
canChangeTasks: z.boolean(),
|
|
196
|
+
});
|
|
197
|
+
// ---------------------------------------------------------------------------
|
|
198
|
+
// Record links (R-16)
|
|
199
|
+
// ---------------------------------------------------------------------------
|
|
200
|
+
/** The records a Task may be linked to besides its context (FR-031). */
|
|
201
|
+
export const TASK_LINK_KINDS = ['opportunity', 'order', 'quote_request'];
|
|
202
|
+
export const taskLinkKindSchema = z.enum(TASK_LINK_KINDS);
|
|
203
|
+
export const TaskLinkTargetSchema = z.object({ kind: taskLinkKindSchema, id: uuid }).strict();
|
|
204
|
+
// ---------------------------------------------------------------------------
|
|
205
|
+
// §1 Requests
|
|
206
|
+
// ---------------------------------------------------------------------------
|
|
207
|
+
/** `assignee`: an admin user's id, `me` (the caller) or `none` (unassigned). Any-of. */
|
|
208
|
+
const assigneeFilterSchema = z.union([z.literal('me'), z.literal('none'), uuid]);
|
|
209
|
+
/** `creator`: an admin user's id or `me`. */
|
|
210
|
+
const creatorFilterSchema = z.union([z.literal('me'), uuid]);
|
|
211
|
+
/** `priority`: a code, or `none` for a Task without one. */
|
|
212
|
+
const priorityFilterSchema = z.union([z.literal('none'), taskPriorityCodeSchema]);
|
|
213
|
+
/** The orders `GET /tasks` sorts by (FR-020, R-12). */
|
|
214
|
+
export const TASK_LIST_SORTS = ['created', 'number', 'title', 'due', 'priority', 'status', 'updated'];
|
|
215
|
+
export const taskListSortSchema = z.enum(TASK_LIST_SORTS);
|
|
216
|
+
export const taskSortDirectionSchema = z.enum(['asc', 'desc']);
|
|
217
|
+
/**
|
|
218
|
+
* The filters the list, *My Tasks* and the board share (FR-020, US3 scenario
|
|
219
|
+
* 4). Unknown status, priority and tag ids **match nothing**; they never answer
|
|
220
|
+
* 422 (R-13) — only a malformed one does.
|
|
221
|
+
*/
|
|
222
|
+
const taskFilterShape = {
|
|
223
|
+
status: repeatable(taskStatusCodeSchema),
|
|
224
|
+
statusCategory: repeatable(taskStatusCategorySchema),
|
|
225
|
+
assignee: repeatable(assigneeFilterSchema),
|
|
226
|
+
creator: creatorFilterSchema.optional(),
|
|
227
|
+
priority: repeatable(priorityFilterSchema),
|
|
228
|
+
/** Every tag must be carried (AND). */
|
|
229
|
+
tagId: repeatable(uuid),
|
|
230
|
+
dueFrom: calendarDateSchema.optional(),
|
|
231
|
+
dueTo: calendarDateSchema.optional(),
|
|
232
|
+
/** `true`: open Tasks past their due moment (FR-002). */
|
|
233
|
+
overdue: queryBooleanSchema.optional(),
|
|
234
|
+
/** Both or neither. */
|
|
235
|
+
linkedKind: taskLinkKindSchema.optional(),
|
|
236
|
+
linkedId: uuid.optional(),
|
|
237
|
+
contextType: taskContextTypeSchema.optional(),
|
|
238
|
+
contextId: uuid.optional(),
|
|
239
|
+
parentId: uuid.optional(),
|
|
240
|
+
isSubtask: queryBooleanSchema.optional(),
|
|
241
|
+
hasSubtasks: queryBooleanSchema.optional(),
|
|
242
|
+
/** Only ever the caller's own drafts (R-3). */
|
|
243
|
+
draft: queryBooleanSchema.optional(),
|
|
244
|
+
private: queryBooleanSchema.optional(),
|
|
245
|
+
customFieldFilters: customFieldFiltersQueryParamSchema,
|
|
246
|
+
/** Number or title. */
|
|
247
|
+
q: z.string().trim().max(200).optional(),
|
|
248
|
+
};
|
|
249
|
+
function linkedBothOrNeither(query) {
|
|
250
|
+
return (query.linkedKind === undefined) === (query.linkedId === undefined);
|
|
251
|
+
}
|
|
252
|
+
const LINKED_MESSAGE = { message: 'linkedKind and linkedId go together', path: ['linkedKind'] };
|
|
253
|
+
/** `GET /tasks` — keyset paging on any sort (R-12). Hidden Tasks are pre-filtered (R-3). */
|
|
254
|
+
export const TaskListQuerySchema = z
|
|
255
|
+
.object({
|
|
256
|
+
...taskFilterShape,
|
|
257
|
+
sort: taskListSortSchema.optional(),
|
|
258
|
+
dir: taskSortDirectionSchema.optional(),
|
|
259
|
+
cursor: z.string().max(1000).optional(),
|
|
260
|
+
limit: z.coerce.number().int().positive().max(TASK_LIST_LIMIT_MAX).default(50),
|
|
261
|
+
/**
|
|
262
|
+
* `true`: each row carries the board's card fields (`cardFields`), as a
|
|
263
|
+
* board card does — what a lane's further cards are read with (R-11).
|
|
264
|
+
*/
|
|
265
|
+
cardValues: queryBooleanSchema.optional(),
|
|
266
|
+
})
|
|
267
|
+
.refine(linkedBothOrNeither, LINKED_MESSAGE);
|
|
268
|
+
/**
|
|
269
|
+
* `GET /tasks/mine` — the list's filters, with `assignee=me`,
|
|
270
|
+
* `statusCategory=open` and no draft implied (so those three are not taken).
|
|
271
|
+
*/
|
|
272
|
+
export const MyTasksQuerySchema = z
|
|
273
|
+
.object({
|
|
274
|
+
...taskFilterShape,
|
|
275
|
+
assignee: z.undefined().optional(),
|
|
276
|
+
statusCategory: z.undefined().optional(),
|
|
277
|
+
draft: z.undefined().optional(),
|
|
278
|
+
sort: taskListSortSchema.optional(),
|
|
279
|
+
dir: taskSortDirectionSchema.optional(),
|
|
280
|
+
})
|
|
281
|
+
.strict()
|
|
282
|
+
.refine(linkedBothOrNeither, LINKED_MESSAGE);
|
|
283
|
+
/**
|
|
284
|
+
* `GET /tasks/board` — the list's filters without cursor and sort: a column is
|
|
285
|
+
* ordered by the board, and further cards come from `GET /tasks?status=` (R-11).
|
|
286
|
+
*/
|
|
287
|
+
export const TaskBoardQuerySchema = z
|
|
288
|
+
.object({
|
|
289
|
+
...taskFilterShape,
|
|
290
|
+
perColumn: z.coerce
|
|
291
|
+
.number()
|
|
292
|
+
.int()
|
|
293
|
+
.min(1)
|
|
294
|
+
.max(TASK_BOARD_PER_COLUMN_MAX)
|
|
295
|
+
.default(TASK_BOARD_PER_COLUMN_DEFAULT),
|
|
296
|
+
})
|
|
297
|
+
.strict()
|
|
298
|
+
.refine(linkedBothOrNeither, LINKED_MESSAGE);
|
|
299
|
+
/** The fields `POST /tasks` and `PATCH /tasks/:id` share. */
|
|
300
|
+
const taskFieldShape = {
|
|
301
|
+
title: titleSchema,
|
|
302
|
+
/** Rich text: the `record-rich-text` Markdown subset plus reference tokens (R-4). */
|
|
303
|
+
description: descriptionSchema,
|
|
304
|
+
assigneeIds: uuidSet(TASK_ASSIGNEES_MAX, 'An assignee'),
|
|
305
|
+
/** A date without a time. Exclusive with {@link dueAt}. */
|
|
306
|
+
dueOn: calendarDateSchema.nullable(),
|
|
307
|
+
/** A moment; `dueOn` is derived from it in `tasks.time_zone` (R-17). */
|
|
308
|
+
dueAt: isoDateTimeSchema.nullable(),
|
|
309
|
+
startOn: calendarDateSchema.nullable(),
|
|
310
|
+
priorityCode: taskPriorityCodeSchema.nullable(),
|
|
311
|
+
/** The whole set, replaced. */
|
|
312
|
+
tagIds: uuidSet(TASK_TAGS_MAX, 'A tag'),
|
|
313
|
+
/** Validated against the `task` host's definitions (R-8). */
|
|
314
|
+
customFieldValues: customFieldValuesSchema,
|
|
315
|
+
context: TaskContextSchema.nullable(),
|
|
316
|
+
parentTaskId: uuid.nullable(),
|
|
317
|
+
/** Visible to the Creator and to holders of `tasks:see_private` only; never in a context (FR-038). */
|
|
318
|
+
private: z.boolean(),
|
|
319
|
+
};
|
|
320
|
+
function notBothDue(body) {
|
|
321
|
+
return !(body.dueOn != null && body.dueAt != null);
|
|
322
|
+
}
|
|
323
|
+
const BOTH_DUE_MESSAGE = { message: 'A due date and a due moment are exclusive', path: ['dueAt'] };
|
|
324
|
+
/**
|
|
325
|
+
* `POST /tasks`. A `context` is accepted only for a type registered by a
|
|
326
|
+
* present module whose descriptor lists the id as visible to the caller — else
|
|
327
|
+
* 422 `TASK_CONTEXT_INVALID`. Each assignee must be an active administrator
|
|
328
|
+
* holding `tasks:read` — else 422 `TASK_ASSIGNEE_INVALID`. A new Task starts in
|
|
329
|
+
* the workflow's initial status (FR-015).
|
|
330
|
+
*/
|
|
331
|
+
export const CreateTaskBodySchema = z
|
|
332
|
+
.object({
|
|
333
|
+
...taskFieldShape,
|
|
334
|
+
description: descriptionSchema.optional(),
|
|
335
|
+
assigneeIds: taskFieldShape.assigneeIds.optional(),
|
|
336
|
+
dueOn: taskFieldShape.dueOn.optional(),
|
|
337
|
+
dueAt: taskFieldShape.dueAt.optional(),
|
|
338
|
+
startOn: taskFieldShape.startOn.optional(),
|
|
339
|
+
priorityCode: taskFieldShape.priorityCode.optional(),
|
|
340
|
+
tagIds: taskFieldShape.tagIds.optional(),
|
|
341
|
+
customFieldValues: taskFieldShape.customFieldValues.optional(),
|
|
342
|
+
context: taskFieldShape.context.optional(),
|
|
343
|
+
parentTaskId: taskFieldShape.parentTaskId.optional(),
|
|
344
|
+
private: taskFieldShape.private.optional(),
|
|
345
|
+
links: z.array(TaskLinkTargetSchema).max(TASK_LINKS_MAX).optional(),
|
|
346
|
+
/** Visible to the Creator only until published; one-way (FR-037). */
|
|
347
|
+
draft: z.boolean().optional(),
|
|
348
|
+
})
|
|
349
|
+
.strict()
|
|
350
|
+
.refine(notBothDue, BOTH_DUE_MESSAGE)
|
|
351
|
+
.refine((body) => !(body.private === true && body.context != null), {
|
|
352
|
+
message: 'A private Task has no context',
|
|
353
|
+
path: ['private'],
|
|
354
|
+
});
|
|
355
|
+
/**
|
|
356
|
+
* `PATCH /tasks/:id` — any of the fields, at least one. `assigneeIds` replaces
|
|
357
|
+
* the set; `addAssigneeIds` / `removeAssigneeIds` change it, and the two forms
|
|
358
|
+
* are exclusive. **`status` is not accepted**: a status change goes through
|
|
359
|
+
* `POST /tasks/:id/status`, which checks the workflow (R-1). Publishing goes
|
|
360
|
+
* through `POST /tasks/:id/publish`, so `draft` is not accepted either.
|
|
361
|
+
*/
|
|
362
|
+
export const UpdateTaskBodySchema = z
|
|
363
|
+
.object({
|
|
364
|
+
...taskFieldShape,
|
|
365
|
+
addAssigneeIds: uuidSet(TASK_ASSIGNEES_MAX, 'An assignee'),
|
|
366
|
+
removeAssigneeIds: uuidSet(TASK_ASSIGNEES_MAX, 'An assignee'),
|
|
367
|
+
})
|
|
368
|
+
.partial()
|
|
369
|
+
.strict()
|
|
370
|
+
.refine((body) => Object.keys(body).length > 0, { message: 'Nothing to change' })
|
|
371
|
+
.refine(notBothDue, BOTH_DUE_MESSAGE)
|
|
372
|
+
.refine((body) => body.assigneeIds === undefined || (body.addAssigneeIds === undefined && body.removeAssigneeIds === undefined), { message: 'Replace the assignees or change them, not both', path: ['assigneeIds'] });
|
|
373
|
+
/**
|
|
374
|
+
* `POST /tasks/:id/status` — `from` is the status the caller saw; a Task that
|
|
375
|
+
* moved meanwhile answers 409 `TASK_TRANSITION_CONFLICT` (R-1).
|
|
376
|
+
*/
|
|
377
|
+
export const TaskStatusChangeBodySchema = z
|
|
378
|
+
.object({ to: taskStatusCodeSchema, from: taskStatusCodeSchema })
|
|
379
|
+
.strict();
|
|
380
|
+
// ---------------------------------------------------------------------------
|
|
381
|
+
// §2 Collaboration requests
|
|
382
|
+
// ---------------------------------------------------------------------------
|
|
383
|
+
const commentBodySchema = z.string().trim().min(1).max(TASK_COMMENT_MAX);
|
|
384
|
+
/** `POST /tasks/:id/comments` — rich text with references, as the description (R-6). */
|
|
385
|
+
export const CreateTaskCommentBodySchema = z.object({ body: commentBodySchema }).strict();
|
|
386
|
+
/** `PATCH /tasks/:id/comments/:commentId` — the author only. */
|
|
387
|
+
export const UpdateTaskCommentBodySchema = z.object({ body: commentBodySchema }).strict();
|
|
388
|
+
/** `POST /tasks/:id/attachments` with an asset already in the library (the upload is multipart). */
|
|
389
|
+
export const CreateTaskAttachmentBodySchema = z.object({ assetId: uuid }).strict();
|
|
390
|
+
/** `POST /tasks/:id/links`. 422 `TASK_LINK_INVALID` when the record cannot be linked (R-16). */
|
|
391
|
+
export const CreateTaskLinkBodySchema = TaskLinkTargetSchema;
|
|
392
|
+
/**
|
|
393
|
+
* `POST /tasks/:id/reminders` — at a moment (`remindAt`) **or** some minutes
|
|
394
|
+
* before the due moment (`offsetMinutes`), never both, for 1–21 distinct
|
|
395
|
+
* recipients drawn from the caller and the assignees (R-17). A relative
|
|
396
|
+
* reminder on a Task without a due moment answers 422 `TASK_REMINDER_INVALID`.
|
|
397
|
+
*/
|
|
398
|
+
export const CreateTaskReminderBodySchema = z
|
|
399
|
+
.object({
|
|
400
|
+
remindAt: isoDateTimeSchema.optional(),
|
|
401
|
+
offsetMinutes: z.number().int().min(0).max(TASK_REMINDER_OFFSET_MAX_MINUTES).optional(),
|
|
402
|
+
recipientIds: z
|
|
403
|
+
.array(uuid)
|
|
404
|
+
.min(1)
|
|
405
|
+
.max(TASK_REMINDER_RECIPIENTS_MAX)
|
|
406
|
+
.refine(unique, { message: 'A recipient may be named once' }),
|
|
407
|
+
})
|
|
408
|
+
.strict()
|
|
409
|
+
.refine((body) => (body.remindAt === undefined) !== (body.offsetMinutes === undefined), {
|
|
410
|
+
message: 'A reminder is at a moment or relative to the due moment',
|
|
411
|
+
path: ['remindAt'],
|
|
412
|
+
});
|
|
413
|
+
// ---------------------------------------------------------------------------
|
|
414
|
+
// §3 Lookups
|
|
415
|
+
// ---------------------------------------------------------------------------
|
|
416
|
+
const lookupSearchSchema = z.string().trim().max(200).optional();
|
|
417
|
+
/**
|
|
418
|
+
* `GET /tasks/lookups/assignees?q=&taskId=&contextType=&contextId=` — active
|
|
419
|
+
* administrators holding `tasks:read` who may see the Task; only the Creator
|
|
420
|
+
* for a private one. A context (both of its parts, or neither) narrows the
|
|
421
|
+
* answer to who may see that record — the create form's `?context=`, before
|
|
422
|
+
* there is a Task (issue #506); the caller must see the record themselves.
|
|
423
|
+
*/
|
|
424
|
+
export const TaskAssigneeLookupQuerySchema = z
|
|
425
|
+
.object({
|
|
426
|
+
q: lookupSearchSchema,
|
|
427
|
+
taskId: uuid.optional(),
|
|
428
|
+
contextType: taskContextTypeSchema.optional(),
|
|
429
|
+
contextId: uuid.optional(),
|
|
430
|
+
})
|
|
431
|
+
.refine((query) => (query.contextType === undefined) === (query.contextId === undefined), {
|
|
432
|
+
message: 'A context is its type and its id together.',
|
|
433
|
+
path: ['contextId'],
|
|
434
|
+
});
|
|
435
|
+
/** `GET /tasks/lookups/mentionable?taskId=&q=` — at most 20 (R-5). */
|
|
436
|
+
export const TaskMentionableLookupQuerySchema = z.object({
|
|
437
|
+
taskId: uuid.optional(),
|
|
438
|
+
q: lookupSearchSchema,
|
|
439
|
+
});
|
|
440
|
+
/** `GET /tasks/lookups/documents?q=` — answers `RecordDocumentLookupResponse`. */
|
|
441
|
+
export const TaskDocumentLookupQuerySchema = z.object({ q: lookupSearchSchema });
|
|
442
|
+
/** `GET /tasks/lookups/records?kind=&q=` — link targets (R-16). */
|
|
443
|
+
export const TaskRecordLookupQuerySchema = z.object({ kind: taskLinkKindSchema, q: lookupSearchSchema });
|
|
444
|
+
/** `GET /tasks/lookups/contexts?q=` — the Project/Stage picker through each present descriptor. */
|
|
445
|
+
export const TaskContextLookupQuerySchema = z.object({ q: lookupSearchSchema });
|
|
446
|
+
// ---------------------------------------------------------------------------
|
|
447
|
+
// §4 Configuration requests
|
|
448
|
+
// ---------------------------------------------------------------------------
|
|
449
|
+
const weightSchema = z.number().int().min(0).max(100_000);
|
|
450
|
+
/** `POST /tasks/statuses`. `code` is immutable once created. */
|
|
451
|
+
export const CreateTaskStatusBodySchema = z
|
|
452
|
+
.object({
|
|
453
|
+
code: taskStatusCodeSchema,
|
|
454
|
+
name: TaskLocalizedNameSchema,
|
|
455
|
+
category: taskStatusCategorySchema,
|
|
456
|
+
color: taskColorSchema,
|
|
457
|
+
weight: weightSchema,
|
|
458
|
+
isInitial: z.boolean().optional(),
|
|
459
|
+
})
|
|
460
|
+
.strict();
|
|
461
|
+
/** `PATCH /tasks/statuses/:code` — every field but the code, at least one. */
|
|
462
|
+
export const UpdateTaskStatusBodySchema = z
|
|
463
|
+
.object({
|
|
464
|
+
name: TaskLocalizedNameSchema,
|
|
465
|
+
category: taskStatusCategorySchema,
|
|
466
|
+
color: taskColorSchema,
|
|
467
|
+
weight: weightSchema,
|
|
468
|
+
isInitial: z.boolean(),
|
|
469
|
+
})
|
|
470
|
+
.partial()
|
|
471
|
+
.strict()
|
|
472
|
+
.refine((body) => Object.keys(body).length > 0, { message: 'Nothing to change' });
|
|
473
|
+
/**
|
|
474
|
+
* `DELETE /tasks/statuses/:code?replacement=` — required when the status is in
|
|
475
|
+
* use; it must be reachable. Above {@link TASK_STATUS_REASSIGN_MAX} Tasks the
|
|
476
|
+
* removal answers 409 `TASK_STATUS_IN_USE_TOO_MANY` (FR-016, R-1).
|
|
477
|
+
*/
|
|
478
|
+
export const DeleteTaskStatusQuerySchema = z.object({ replacement: taskStatusCodeSchema.optional() });
|
|
479
|
+
export const TaskTransitionEdgeSchema = z
|
|
480
|
+
.object({ from: taskStatusCodeSchema, to: taskStatusCodeSchema })
|
|
481
|
+
.strict()
|
|
482
|
+
.refine((edge) => edge.from !== edge.to, { message: 'A transition connects two different statuses' });
|
|
483
|
+
/**
|
|
484
|
+
* `PUT /tasks/transitions` — a delta. The answer is the whole workflow; an
|
|
485
|
+
* invalid result answers 422 `TASK_WORKFLOW_INVALID {rule}` and changes nothing.
|
|
486
|
+
*/
|
|
487
|
+
export const SetTaskTransitionsBodySchema = z
|
|
488
|
+
.object({
|
|
489
|
+
add: z.array(TaskTransitionEdgeSchema).max(500).optional(),
|
|
490
|
+
remove: z.array(TaskTransitionEdgeSchema).max(500).optional(),
|
|
491
|
+
})
|
|
492
|
+
.strict()
|
|
493
|
+
.refine((body) => (body.add?.length ?? 0) + (body.remove?.length ?? 0) > 0, {
|
|
494
|
+
message: 'Add or remove at least one transition',
|
|
495
|
+
});
|
|
496
|
+
/** `POST /tasks/priorities`. Lower weight is more urgent (R-9). */
|
|
497
|
+
export const CreateTaskPriorityBodySchema = z
|
|
498
|
+
.object({
|
|
499
|
+
code: taskPriorityCodeSchema.refine((code) => code !== 'none', {
|
|
500
|
+
message: '`none` is the filter token for a Task without a priority',
|
|
501
|
+
}),
|
|
502
|
+
name: TaskLocalizedNameSchema,
|
|
503
|
+
color: taskColorSchema,
|
|
504
|
+
weight: weightSchema,
|
|
505
|
+
})
|
|
506
|
+
.strict();
|
|
507
|
+
export const UpdateTaskPriorityBodySchema = z
|
|
508
|
+
.object({ name: TaskLocalizedNameSchema, color: taskColorSchema, weight: weightSchema })
|
|
509
|
+
.partial()
|
|
510
|
+
.strict()
|
|
511
|
+
.refine((body) => Object.keys(body).length > 0, { message: 'Nothing to change' });
|
|
512
|
+
/** `DELETE /tasks/priorities/:code?replacement=` — a code, or `none` to clear it (FR-024). */
|
|
513
|
+
export const DeleteTaskPriorityQuerySchema = z.object({ replacement: priorityFilterSchema.optional() });
|
|
514
|
+
/** The colour a tag gets when none is chosen. */
|
|
515
|
+
export const TASK_TAG_DEFAULT_COLOR = '#64748b';
|
|
516
|
+
const tagNameSchema = z.string().trim().min(1).max(TASK_TAG_NAME_MAX);
|
|
517
|
+
/** `POST /tasks/tags`. A taken name, case-insensitively, answers 409 `TASK_TAG_NAME_TAKEN`. */
|
|
518
|
+
export const CreateTaskTagBodySchema = z
|
|
519
|
+
.object({ name: tagNameSchema, color: taskColorSchema.optional() })
|
|
520
|
+
.strict();
|
|
521
|
+
export const UpdateTaskTagBodySchema = z
|
|
522
|
+
.object({ name: tagNameSchema, color: taskColorSchema })
|
|
523
|
+
.partial()
|
|
524
|
+
.strict()
|
|
525
|
+
.refine((body) => Object.keys(body).length > 0, { message: 'Nothing to change' });
|
|
526
|
+
/** How many fields a board card shows at most, the title besides (R-11). */
|
|
527
|
+
export const TASK_BOARD_CARD_MAX_FIELDS = 6;
|
|
528
|
+
/** The fields every Task has that a board card can show, in the order they are offered. */
|
|
529
|
+
export const TASK_BOARD_BUILTIN_FIELD_KEYS = [
|
|
530
|
+
'number',
|
|
531
|
+
'assignees',
|
|
532
|
+
'due',
|
|
533
|
+
'priority',
|
|
534
|
+
'tags',
|
|
535
|
+
'startOn',
|
|
536
|
+
'context',
|
|
537
|
+
'subtasks',
|
|
538
|
+
'createdAt',
|
|
539
|
+
'updatedAt',
|
|
540
|
+
];
|
|
541
|
+
/** `builtin:<key>` or `custom:<definition key>` — CRM's grammar. */
|
|
542
|
+
export const taskBoardFieldRefSchema = z
|
|
543
|
+
.string()
|
|
544
|
+
.regex(/^(builtin:[A-Za-z]{1,40}|custom:[a-z][a-z0-9_]{0,63})$/, 'Not a board field reference');
|
|
545
|
+
/** The `tasks.board_card_fields` default (`data-model.md` §4). */
|
|
546
|
+
export const TASK_BOARD_DEFAULT_CARD_FIELDS = [
|
|
547
|
+
'builtin:number',
|
|
548
|
+
'builtin:assignees',
|
|
549
|
+
'builtin:due',
|
|
550
|
+
'builtin:priority',
|
|
551
|
+
'builtin:tags',
|
|
552
|
+
];
|
|
553
|
+
/** `PUT /tasks/board/card-fields`. Validated against the catalogue and the `task` definitions. */
|
|
554
|
+
export const SetTaskBoardCardFieldsBodySchema = z
|
|
555
|
+
.object({
|
|
556
|
+
fields: z
|
|
557
|
+
.array(taskBoardFieldRefSchema)
|
|
558
|
+
.max(TASK_BOARD_CARD_MAX_FIELDS)
|
|
559
|
+
.refine(unique, { message: 'A field can be shown once' }),
|
|
560
|
+
})
|
|
561
|
+
.strict();
|
|
562
|
+
/** `PUT /tasks/settings/time-zone` — an IANA name, validated by the server (R-17). */
|
|
563
|
+
export const SetTaskTimeZoneBodySchema = z.object({ timeZone: z.string().trim().min(1).max(64) }).strict();
|
|
564
|
+
// ---------------------------------------------------------------------------
|
|
565
|
+
// §5 Per-admin requests
|
|
566
|
+
// ---------------------------------------------------------------------------
|
|
567
|
+
/** `PUT /tasks/me/digest` — on, at a local hour of `tasks.time_zone` (R-18). Off is `DELETE`. */
|
|
568
|
+
export const SetTaskDigestBodySchema = z.object({ hour: z.number().int().min(0).max(23) }).strict();
|
|
569
|
+
// Saved views (`/tasks/list-views`) use `createTaskSavedViewRequestSchema` of `saved-list-views.ts`.
|
|
570
|
+
// ---------------------------------------------------------------------------
|
|
571
|
+
// Responses
|
|
572
|
+
// ---------------------------------------------------------------------------
|
|
573
|
+
export const TaskAssigneeSchema = z.object({
|
|
574
|
+
id: uuid,
|
|
575
|
+
name: z.string(),
|
|
576
|
+
/** `false` once the administrator was deactivated; the Task keeps them. */
|
|
577
|
+
active: z.boolean(),
|
|
578
|
+
});
|
|
579
|
+
/** A status as a reader is shown it: its name in the reader's language. */
|
|
580
|
+
export const TaskStatusRefSchema = z.object({
|
|
581
|
+
code: z.string(),
|
|
582
|
+
name: z.string(),
|
|
583
|
+
color: z.string(),
|
|
584
|
+
category: taskStatusCategorySchema,
|
|
585
|
+
});
|
|
586
|
+
export const TaskPriorityRefSchema = z.object({
|
|
587
|
+
code: z.string(),
|
|
588
|
+
name: z.string(),
|
|
589
|
+
color: z.string(),
|
|
590
|
+
});
|
|
591
|
+
export const TaskTagRefSchema = z.object({ id: uuid, name: z.string(), color: z.string() });
|
|
592
|
+
/** A parent the reader may not see is `available: false` with its number withheld. */
|
|
593
|
+
export const TaskParentRefSchema = z.object({
|
|
594
|
+
id: uuid,
|
|
595
|
+
number: z.string().nullable(),
|
|
596
|
+
available: z.boolean(),
|
|
597
|
+
});
|
|
598
|
+
/** One field of a board card, as configured (`tasks.board_card_fields`). */
|
|
599
|
+
export const TaskCardFieldValueSchema = z.object({
|
|
600
|
+
ref: z.string(),
|
|
601
|
+
value: z.unknown(),
|
|
602
|
+
});
|
|
603
|
+
export const TaskSummarySchema = z.object({
|
|
604
|
+
id: uuid,
|
|
605
|
+
number: z.string(),
|
|
606
|
+
title: z.string(),
|
|
607
|
+
status: TaskStatusRefSchema,
|
|
608
|
+
/** Category `done` or `cancelled` (FR-017). */
|
|
609
|
+
closed: z.boolean(),
|
|
610
|
+
assignees: z.array(TaskAssigneeSchema),
|
|
611
|
+
dueOn: z.string().nullable(),
|
|
612
|
+
dueAt: isoTimestampSchema.nullable(),
|
|
613
|
+
/** Open and past the due moment, in `tasks.time_zone` for a date only (FR-002). */
|
|
614
|
+
overdue: z.boolean(),
|
|
615
|
+
priority: TaskPriorityRefSchema.nullable(),
|
|
616
|
+
tags: z.array(TaskTagRefSchema),
|
|
617
|
+
context: TaskContextSummarySchema.nullable(),
|
|
618
|
+
parent: TaskParentRefSchema.nullable(),
|
|
619
|
+
/** Among the sub-tasks the reader may see (FR-028). */
|
|
620
|
+
subtasks: z.object({ closed: z.number().int().nonnegative(), total: z.number().int().nonnegative() }),
|
|
621
|
+
draft: z.boolean(),
|
|
622
|
+
private: z.boolean(),
|
|
623
|
+
/** On the board only: the configured card fields, in order. */
|
|
624
|
+
cardFields: z.array(TaskCardFieldValueSchema).optional(),
|
|
625
|
+
createdAt: isoTimestampSchema,
|
|
626
|
+
updatedAt: isoTimestampSchema,
|
|
627
|
+
});
|
|
628
|
+
/** A record link as the reader is shown it — resolved per reader, like a reference (R-16). */
|
|
629
|
+
export const TaskLinkSchema = z.object({
|
|
630
|
+
/** The link's own id — what `DELETE /tasks/:id/links/:linkId` takes. */
|
|
631
|
+
id: uuid,
|
|
632
|
+
kind: taskLinkKindSchema,
|
|
633
|
+
recordId: uuid,
|
|
634
|
+
available: z.boolean(),
|
|
635
|
+
label: z.string().nullable(),
|
|
636
|
+
url: z.string().nullable(),
|
|
637
|
+
});
|
|
638
|
+
export const TaskPersonSchema = z.object({ id: uuid, name: z.string() });
|
|
639
|
+
export const TaskReminderSchema = z.object({
|
|
640
|
+
id: uuid,
|
|
641
|
+
mode: z.enum(['absolute', 'relative']),
|
|
642
|
+
remindAt: isoTimestampSchema,
|
|
643
|
+
offsetMinutes: z.number().int().nullable(),
|
|
644
|
+
recipients: z.array(TaskAssigneeSchema),
|
|
645
|
+
createdBy: TaskPersonSchema.nullable(),
|
|
646
|
+
/** Whether the moment has passed and it was handled for every recipient. */
|
|
647
|
+
done: z.boolean(),
|
|
648
|
+
createdAt: isoTimestampSchema,
|
|
649
|
+
});
|
|
650
|
+
export const TaskDetailSchema = TaskSummarySchema.extend({
|
|
651
|
+
/** Rich text with reference tokens (R-4). */
|
|
652
|
+
description: z.string(),
|
|
653
|
+
/** What the description's reference tokens name for this reader (`record-references.ts`). */
|
|
654
|
+
references: z.array(RecordReferenceSchema),
|
|
655
|
+
context: TaskContextDetailSchema.nullable(),
|
|
656
|
+
/**
|
|
657
|
+
* Written by the context's owner when it created the Task, in the reader's
|
|
658
|
+
* language — e.g. "Responsible role: Installer" (`TaskContextDescriptor.renderNote`).
|
|
659
|
+
*/
|
|
660
|
+
contextNote: z.string().nullable(),
|
|
661
|
+
startOn: z.string().nullable(),
|
|
662
|
+
customFieldValues: z.record(z.string(), z.unknown()),
|
|
663
|
+
links: z.array(TaskLinkSchema),
|
|
664
|
+
relatedTasks: z.array(TaskSummarySchema),
|
|
665
|
+
/** The visible sub-tasks themselves; `subtasks` keeps the counts. */
|
|
666
|
+
subtaskItems: z.array(TaskSummarySchema),
|
|
667
|
+
attachmentsCount: z.number().int().nonnegative(),
|
|
668
|
+
commentsCount: z.number().int().nonnegative(),
|
|
669
|
+
/** Only the caller's own reminders and those that name the caller. */
|
|
670
|
+
reminders: z.array(TaskReminderSchema),
|
|
671
|
+
createdBy: TaskPersonSchema.nullable(),
|
|
672
|
+
publishedAt: isoTimestampSchema.nullable(),
|
|
673
|
+
completedAt: isoTimestampSchema.nullable(),
|
|
674
|
+
permissions: z.object({
|
|
675
|
+
/** `false` for a context that refuses changes and for someone else's private Task. */
|
|
676
|
+
canChange: z.boolean(),
|
|
677
|
+
canDelete: z.boolean(),
|
|
678
|
+
/** The Creator of a draft. */
|
|
679
|
+
canPublish: z.boolean(),
|
|
680
|
+
}),
|
|
681
|
+
});
|
|
682
|
+
/** `GET /tasks` — one page; `nextCursor` is `null` on the last. */
|
|
683
|
+
export const TaskListResponseSchema = z.object({
|
|
684
|
+
items: z.array(TaskSummarySchema),
|
|
685
|
+
nextCursor: z.string().nullable(),
|
|
686
|
+
prevCursor: z.string().nullable().optional(),
|
|
687
|
+
});
|
|
688
|
+
export const TaskBoardColumnSchema = z.object({
|
|
689
|
+
status: TaskStatusRefSchema,
|
|
690
|
+
/** Every visible Task in the column under the filters, not only those sent. */
|
|
691
|
+
count: z.number().int().nonnegative(),
|
|
692
|
+
items: z.array(TaskSummarySchema),
|
|
693
|
+
hasMore: z.boolean(),
|
|
694
|
+
});
|
|
695
|
+
/** `GET /tasks/board` — one column per status, in workflow order (FR-019). */
|
|
696
|
+
export const TaskBoardSchema = z.object({ columns: z.array(TaskBoardColumnSchema) });
|
|
697
|
+
/** `POST /tasks/:id/status`. `openSubtasks` > 0 drives the warning on closing a parent (FR-028). */
|
|
698
|
+
export const TaskStatusChangeResultSchema = z.object({
|
|
699
|
+
task: TaskDetailSchema,
|
|
700
|
+
openSubtasks: z.number().int().nonnegative(),
|
|
701
|
+
});
|
|
702
|
+
/** What deleting a Task did beyond the Task: its sub-tasks became top-level (FR-029). */
|
|
703
|
+
export const TaskDeleteResultSchema = z.object({ subtasksDetached: z.number().int().nonnegative() });
|
|
704
|
+
export const TaskAssigneeOptionSchema = z.object({
|
|
705
|
+
id: uuid,
|
|
706
|
+
name: z.string(),
|
|
707
|
+
email: z.string(),
|
|
708
|
+
});
|
|
709
|
+
export const TaskCommentSchema = z.object({
|
|
710
|
+
id: uuid,
|
|
711
|
+
author: TaskPersonSchema.nullable(),
|
|
712
|
+
/** Empty once deleted; the thread shows that it was (R-6). */
|
|
713
|
+
body: z.string(),
|
|
714
|
+
references: z.array(RecordReferenceSchema),
|
|
715
|
+
editedAt: isoTimestampSchema.nullable(),
|
|
716
|
+
deletedAt: isoTimestampSchema.nullable(),
|
|
717
|
+
createdAt: isoTimestampSchema,
|
|
718
|
+
});
|
|
719
|
+
export const TaskAttachmentSchema = z.object({
|
|
720
|
+
id: uuid,
|
|
721
|
+
assetId: uuid,
|
|
722
|
+
fileName: z.string(),
|
|
723
|
+
mimeType: z.string(),
|
|
724
|
+
sizeBytes: z.number().int().nonnegative(),
|
|
725
|
+
url: z.string().nullable(),
|
|
726
|
+
uploadedBy: TaskPersonSchema.nullable(),
|
|
727
|
+
createdAt: isoTimestampSchema,
|
|
728
|
+
});
|
|
729
|
+
/** A link target or a context the picker offers. */
|
|
730
|
+
export const TaskLookupOptionSchema = z.object({
|
|
731
|
+
id: uuid,
|
|
732
|
+
label: z.string(),
|
|
733
|
+
sublabel: z.string().optional(),
|
|
734
|
+
});
|
|
735
|
+
/** `GET /tasks/lookups/contexts` — a context with its groups (a Project with its Stages). */
|
|
736
|
+
export const TaskContextOptionSchema = z.object({
|
|
737
|
+
contextType: z.string(),
|
|
738
|
+
id: uuid,
|
|
739
|
+
label: z.string(),
|
|
740
|
+
groups: z.array(z.object({ id: uuid, label: z.string() })),
|
|
741
|
+
});
|
|
742
|
+
/** A status as the workflow page shows it: every language, and how many visible Tasks hold it. */
|
|
743
|
+
export const TaskStatusConfigSchema = z.object({
|
|
744
|
+
code: z.string(),
|
|
745
|
+
name: z.record(z.string(), z.string()),
|
|
746
|
+
defaultName: z.string(),
|
|
747
|
+
category: taskStatusCategorySchema,
|
|
748
|
+
isInitial: z.boolean(),
|
|
749
|
+
weight: z.number().int(),
|
|
750
|
+
color: z.string(),
|
|
751
|
+
inUseCount: z.number().int().nonnegative(),
|
|
752
|
+
});
|
|
753
|
+
/** `GET /tasks/workflow`, and the answer of every workflow write. */
|
|
754
|
+
export const TaskWorkflowSchema = z.object({
|
|
755
|
+
statuses: z.array(TaskStatusConfigSchema),
|
|
756
|
+
transitions: z.array(z.object({ from: z.string(), to: z.string() })),
|
|
757
|
+
});
|
|
758
|
+
export const TaskPriorityConfigSchema = z.object({
|
|
759
|
+
code: z.string(),
|
|
760
|
+
name: z.record(z.string(), z.string()),
|
|
761
|
+
defaultName: z.string(),
|
|
762
|
+
color: z.string(),
|
|
763
|
+
weight: z.number().int(),
|
|
764
|
+
inUseCount: z.number().int().nonnegative(),
|
|
765
|
+
});
|
|
766
|
+
export const TaskTagSchema = z.object({
|
|
767
|
+
id: uuid,
|
|
768
|
+
name: z.string(),
|
|
769
|
+
color: z.string(),
|
|
770
|
+
usageCount: z.number().int().nonnegative(),
|
|
771
|
+
});
|
|
772
|
+
export const TaskBoardCardFieldSchema = z.object({
|
|
773
|
+
ref: taskBoardFieldRefSchema,
|
|
774
|
+
source: z.enum(['builtin', 'custom']),
|
|
775
|
+
key: z.string(),
|
|
776
|
+
/** A custom field's labels per language; empty for a built-in field, which the Admin UI names. */
|
|
777
|
+
label: z.record(z.string(), z.string()),
|
|
778
|
+
labelDefault: z.string().nullable(),
|
|
779
|
+
});
|
|
780
|
+
export const TaskBoardCardConfigSchema = z.object({
|
|
781
|
+
/** The stored choice, resolved, in order. */
|
|
782
|
+
fields: z.array(TaskBoardCardFieldSchema),
|
|
783
|
+
/** Everything that can be chosen. */
|
|
784
|
+
available: z.array(TaskBoardCardFieldSchema),
|
|
785
|
+
maxFields: z.number().int().positive(),
|
|
786
|
+
});
|
|
787
|
+
export const TaskTimeZoneSchema = z.object({ timeZone: z.string() });
|
|
788
|
+
/** `GET /tasks/me/digest` — `null` while the digest is off (the default, Q3 = A). */
|
|
789
|
+
export const TaskDigestSubscriptionSchema = z.object({ hour: z.number().int().min(0).max(23) }).nullable();
|
|
790
|
+
export const TaskDetailResponseSchema = dataEnvelope(TaskDetailSchema);
|
|
791
|
+
/** `GET /tasks/mine` — the caller's open Tasks, by due date, undated last; at most {@link TASK_MINE_MAX}. */
|
|
792
|
+
export const MyTasksResponseSchema = dataEnvelope(z.array(TaskSummarySchema));
|
|
793
|
+
export const TaskBoardResponseSchema = dataEnvelope(TaskBoardSchema);
|
|
794
|
+
export const TaskStatusChangeResponseSchema = dataEnvelope(TaskStatusChangeResultSchema);
|
|
795
|
+
export const TaskAssigneeLookupResponseSchema = dataEnvelope(z.array(TaskAssigneeOptionSchema));
|
|
796
|
+
export const TaskMentionableLookupResponseSchema = dataEnvelope(z.array(TaskAssigneeOptionSchema));
|
|
797
|
+
export const TaskRecordLookupResponseSchema = dataEnvelope(z.array(TaskLookupOptionSchema));
|
|
798
|
+
export const TaskContextLookupResponseSchema = dataEnvelope(z.array(TaskContextOptionSchema));
|
|
799
|
+
export const TaskCommentResponseSchema = dataEnvelope(TaskCommentSchema);
|
|
800
|
+
export const TaskCommentListResponseSchema = dataEnvelope(z.array(TaskCommentSchema));
|
|
801
|
+
export const TaskAttachmentResponseSchema = dataEnvelope(TaskAttachmentSchema);
|
|
802
|
+
export const TaskAttachmentListResponseSchema = dataEnvelope(z.array(TaskAttachmentSchema));
|
|
803
|
+
export const TaskLinkResponseSchema = dataEnvelope(TaskLinkSchema);
|
|
804
|
+
export const TaskReminderResponseSchema = dataEnvelope(TaskReminderSchema);
|
|
805
|
+
export const TaskReminderListResponseSchema = dataEnvelope(z.array(TaskReminderSchema));
|
|
806
|
+
export const TaskWorkflowResponseSchema = dataEnvelope(TaskWorkflowSchema);
|
|
807
|
+
export const TaskPriorityListResponseSchema = dataEnvelope(z.array(TaskPriorityConfigSchema));
|
|
808
|
+
export const TaskPriorityResponseSchema = dataEnvelope(TaskPriorityConfigSchema);
|
|
809
|
+
export const TaskTagListResponseSchema = dataEnvelope(z.array(TaskTagSchema));
|
|
810
|
+
export const TaskTagResponseSchema = dataEnvelope(TaskTagSchema);
|
|
811
|
+
export const TaskBoardCardConfigResponseSchema = dataEnvelope(TaskBoardCardConfigSchema);
|
|
812
|
+
export const TaskTimeZoneResponseSchema = dataEnvelope(TaskTimeZoneSchema);
|
|
813
|
+
export const TaskDigestSubscriptionResponseSchema = dataEnvelope(TaskDigestSubscriptionSchema);
|
|
814
|
+
export const TaskDeleteResponseSchema = dataEnvelope(TaskDeleteResultSchema);
|
|
815
|
+
// `GET /tasks/:id/history` answers `RecordHistoryPageSchema` of `record-references.ts`;
|
|
816
|
+
// `GET /tasks/lookups/documents` answers `RecordDocumentLookupResponseSchema`.
|
|
817
|
+
// ---------------------------------------------------------------------------
|
|
818
|
+
// Error codes (`contracts/admin-api.md`, research R-20)
|
|
819
|
+
// ---------------------------------------------------------------------------
|
|
820
|
+
/**
|
|
821
|
+
* The codes the Tasks API raises. Each joins the platform's `ERROR_CODES`, the
|
|
822
|
+
* `tasks` manifest's `errorCodes` and the module's `errors.<CODE>` sentences in
|
|
823
|
+
* the change that adds its first raise site — `check:error-translations` refuses
|
|
824
|
+
* a code enumerated before a manifest declares it.
|
|
825
|
+
*/
|
|
826
|
+
export const TASKS_ERROR_CODES = [
|
|
827
|
+
/** No such Task, or one the caller may not see (context, draft, private) — indistinguishable. */
|
|
828
|
+
'TASK_NOT_FOUND',
|
|
829
|
+
/** The context's type is not registered by a present module, or the caller may not see the id. */
|
|
830
|
+
'TASK_CONTEXT_INVALID',
|
|
831
|
+
/** An assignee is not an active administrator holding `tasks:read` who may see the Task. */
|
|
832
|
+
'TASK_ASSIGNEE_INVALID',
|
|
833
|
+
/** A status code that is not in the workflow (422). */
|
|
834
|
+
'TASK_STATUS_UNKNOWN',
|
|
835
|
+
/** A move the workflow does not permit; carries `allowedTargets` (409). */
|
|
836
|
+
'TASK_TRANSITION_FORBIDDEN',
|
|
837
|
+
/** The Task left the status the caller saw (409). */
|
|
838
|
+
'TASK_TRANSITION_CONFLICT',
|
|
839
|
+
/** A workflow change that breaks a FR-013 rule; carries `rule` (422). */
|
|
840
|
+
'TASK_WORKFLOW_INVALID',
|
|
841
|
+
/** A status or priority removal that would move more than {@link TASK_STATUS_REASSIGN_MAX} Tasks (409). */
|
|
842
|
+
'TASK_STATUS_IN_USE_TOO_MANY',
|
|
843
|
+
/** A priority code that is not configured (422). */
|
|
844
|
+
'TASK_PRIORITY_UNKNOWN',
|
|
845
|
+
/** A tag name taken, case-insensitively (409). */
|
|
846
|
+
'TASK_TAG_NAME_TAKEN',
|
|
847
|
+
/** A tag id that does not exist (422). */
|
|
848
|
+
'TASK_TAG_UNKNOWN',
|
|
849
|
+
/** A private Task assigned to someone other than its Creator (422). */
|
|
850
|
+
'TASK_PRIVATE_ASSIGNEE',
|
|
851
|
+
/** A change to someone else's private Task by a holder of `tasks:see_private` (403). */
|
|
852
|
+
'TASK_PRIVATE_READ_ONLY',
|
|
853
|
+
/**
|
|
854
|
+
* Publishing a Task that is not a draft any more (409) — publishing is
|
|
855
|
+
* one-way. Somebody else's draft is not refused with a code of its own: it
|
|
856
|
+
* does not exist for them (404 `TASK_NOT_FOUND`, FR-037, SC-005), so the
|
|
857
|
+
* `TASK_DRAFT_ONLY_CREATOR` the plan named could never be raised (T078).
|
|
858
|
+
*/
|
|
859
|
+
'TASK_ALREADY_PUBLISHED',
|
|
860
|
+
/** A parent that would close a cycle (422). */
|
|
861
|
+
'TASK_PARENT_CYCLE',
|
|
862
|
+
/** A parent that would nest deeper than {@link TASK_HIERARCHY_DEPTH_MAX} (422). */
|
|
863
|
+
'TASK_HIERARCHY_TOO_DEEP',
|
|
864
|
+
/** A record that cannot be linked: owner absent, no read permission, or not found (422). */
|
|
865
|
+
'TASK_LINK_INVALID',
|
|
866
|
+
/** An attachment refused: too large or active content (415). */
|
|
867
|
+
'TASK_ATTACHMENT_REFUSED',
|
|
868
|
+
/** A reminder that cannot be set: no due moment, bad recipients, too many (422). */
|
|
869
|
+
'TASK_REMINDER_INVALID',
|
|
870
|
+
/** A saved view name the owner already uses (409). */
|
|
871
|
+
'TASK_VIEW_NAME_TAKEN',
|
|
872
|
+
];
|
|
873
|
+
/** The event names `tasks` emits, once per Command, on commit. Nothing subscribes today. */
|
|
874
|
+
export const TASKS_EVENTS = {
|
|
875
|
+
CREATED: 'tasks.task.created.v1',
|
|
876
|
+
STATUS_CHANGED: 'tasks.task.status_changed.v1',
|
|
877
|
+
ASSIGNEES_CHANGED: 'tasks.task.assignees_changed.v1',
|
|
878
|
+
DELETED: 'tasks.task.deleted.v1',
|
|
879
|
+
};
|
|
880
|
+
/**
|
|
881
|
+
* One Task another module asks `tasks` to create in its context. Validated by
|
|
882
|
+
* the port with this schema before the first Command runs.
|
|
883
|
+
*/
|
|
884
|
+
export const NewContextTaskSchema = z
|
|
885
|
+
.object({
|
|
886
|
+
title: titleSchema,
|
|
887
|
+
description: descriptionSchema.optional(),
|
|
888
|
+
assigneeIds: uuidSet(TASK_ASSIGNEES_MAX, 'An assignee').optional(),
|
|
889
|
+
dueOn: calendarDateSchema.nullable().optional(),
|
|
890
|
+
/** Overrides the call's `context.contextGroupId` for this Task. */
|
|
891
|
+
contextGroupId: uuid.nullable().optional(),
|
|
892
|
+
contextNote: z.string().max(TASK_CONTEXT_NOTE_MAX).nullable().optional(),
|
|
893
|
+
/**
|
|
894
|
+
* The owner's own key for this Task (a Stage Task definition's id). A key
|
|
895
|
+
* that already exists in the context is not created again: its id is
|
|
896
|
+
* returned in its place, which makes a retry safe (R-19, issue #450).
|
|
897
|
+
*/
|
|
898
|
+
sourceKey: z.string().min(1).max(TASK_SOURCE_KEY_MAX).optional(),
|
|
899
|
+
})
|
|
900
|
+
.strict();
|
|
901
|
+
//# sourceMappingURL=tasks.js.map
|