@antelopejs/interface-dms 0.14.6 → 0.14.7-next.1002.g39c16f7
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/auth/db/models/sessions.model.d.ts +10 -1
- package/dist/auth/db/models/sessions.model.js +15 -4
- package/dist/auth/db/models/sessions.model.js.map +1 -1
- package/dist/base/chart-schemas.d.ts +252 -0
- package/dist/base/chart-schemas.js +14 -0
- package/dist/base/chart-schemas.js.map +1 -1
- package/dist/base/data-types/default/relations.d.ts +35 -2
- package/dist/base/data-types/default/relations.js +12 -8
- package/dist/base/data-types/default/relations.js.map +1 -1
- package/dist/base/form-relation-options.d.ts +70 -0
- package/dist/base/form-relation-options.js +3 -0
- package/dist/base/form-relation-options.js.map +1 -0
- package/dist/base/form-schema.d.ts +6 -58
- package/dist/base/form-schema.js.map +1 -1
- package/dist/base/period-selector.d.ts +8 -3
- package/dist/base/period-selector.js.map +1 -1
- package/dist/base/query-response.d.ts +48 -0
- package/dist/base/query-response.js +60 -5
- package/dist/base/query-response.js.map +1 -1
- package/dist/base/table-view/column-display.d.ts +9 -2
- package/dist/base/table-view/column-display.js.map +1 -1
- package/dist/base/table-view/internal/factory-private-actions.js +1 -0
- package/dist/base/table-view/internal/factory-private-actions.js.map +1 -1
- package/dist/base/table-view/internal/guards.d.ts +14 -1
- package/dist/base/table-view/internal/guards.js +26 -3
- package/dist/base/table-view/internal/guards.js.map +1 -1
- package/dist/base/table-view/internal/option-contract.d.ts +4 -1
- package/dist/base/types/guards.d.ts +18 -7
- package/dist/base/types/row-action.d.ts +7 -0
- package/dist/component-options/action-target.d.ts +20 -0
- package/dist/component-options/internal/action-target.d.ts +3 -1
- package/dist/component-options/internal/action-target.js +9 -1
- package/dist/component-options/internal/action-target.js.map +1 -1
- package/dist/component-options/row-action.d.ts +6 -0
- package/dist/invite-extensions/internal/payload-slices.js +6 -2
- package/dist/invite-extensions/internal/payload-slices.js.map +1 -1
- package/dist/notifications/index.d.ts +8 -1
- package/dist/notifications/index.js +12 -0
- package/dist/notifications/index.js.map +1 -1
- package/dist/notifications/internal.d.ts +5 -1
- package/dist/notifications/internal.js +4 -0
- package/dist/notifications/internal.js.map +1 -1
- package/dist/notifications/sendable.js +10 -4
- package/dist/notifications/sendable.js.map +1 -1
- package/dist/notifications/types.d.ts +32 -6
- package/dist/page/internal/page-record.d.ts +2 -2
- package/dist/page/internal/page-record.js +9 -8
- package/dist/page/internal/page-record.js.map +1 -1
- package/dist/page/types.d.ts +2 -0
- package/docs/1.core/2.pages-and-modules.md +1 -0
- package/docs/2.auth/3.tokens-and-sessions.md +1 -1
- package/docs/3.base/11.page-layouts.md +2 -0
- package/docs/3.base/12.table-row-actions.md +1 -1
- package/docs/3.base/2.types.md +13 -5
- package/docs/3.base/4.tables.md +1 -1
- package/docs/3.base/5.charts-and-widgets.md +2 -2
- package/docs/3.base/8.data-types.md +3 -0
- package/docs/4.notifications/1.introduction.md +1 -0
- package/docs/4.notifications/2.categories-and-subjects.md +4 -3
- package/docs/4.notifications/3.sending.md +3 -2
- package/docs/4.notifications/4.email.md +79 -0
- package/docs/index.md +1 -1
- package/package.json +3 -3
package/docs/3.base/2.types.md
CHANGED
|
@@ -151,7 +151,7 @@ import type { ActionTarget } from "@antelopejs/interface-dms/base/types/action-t
|
|
|
151
151
|
| `"external"` | `url: string`, `newTab?: boolean`; the same tokens as `page` |
|
|
152
152
|
| `"download"` | `url: string`, `filename?: string` (`DownloadActionTarget`); the same tokens as `page`, the file name taking them as written. Fetched with the user's session and saved under `filename`, else the server's `Content-Disposition` name, else the URL's last segment; a failure is toasted |
|
|
153
153
|
| `"quickAction"` | `id: string` (`category:id`, or the bare id) |
|
|
154
|
-
| `"api"` | `url: string`, `method?: "GET" \| "POST" \| "PUT" \| "DELETE" \| "PATCH"`, `body?`, `copy?`, `successMessage: string`; the same tokens as `page` |
|
|
154
|
+
| `"api"` | `url: string`, `method?: "GET" \| "POST" \| "PUT" \| "DELETE" \| "PATCH"`, `body?`, `copy?`, `redirect?: string`, `successMessage: string`; the same tokens as `page`. `redirect` is a dashboard path (starting with `/`, an absolute URL throws when the target is serialized) opened on success; it takes the tokens of `url` plus `{{response.<field>}}` (dotted paths allowed), and a field the response lacks leaves the user on the page |
|
|
155
155
|
| `"exportJob"` | `url: string`, `method?: "GET" \| "POST"`, `statusUrl?`, `downloadUrl?`, `labels?`; the same tokens as `page`, plus `{{job.id}}` in `statusUrl` and `downloadUrl` |
|
|
156
156
|
|
|
157
157
|
`SidePanelTargetOptions` sets the header the DMS draws above a `sidePanel` target's component: `title` (the action's label by default; `$`: an i18n key), `rowTitle`, the title while a row is open, an i18n key or a literal receiving the row's fields (`"{method} {path}"`), `positionLabel`, an i18n key receiving `{ index }` (from 1) and `{ total }` for the row's position among all the rows the table lists, its count rather than the page loaded (the DMS's "{index} of {total}" by default), and `deepLink`, which keeps the open row in the URL like the action's own `deepLink`. It is on by default for a side panel, `false` opting out (the action's own `deepLink` wins when set), and `notFound` (`SidePanelNotFoundTexts`: `title?`, `description?`), the state the panel draws with a close button when the row a link names answers 404. The panel is non-modal and docked on the right, one at a time with a module's side panels. It is meant for global, page-independent panels (an assistant dock): a detail or record panel opens in a `drawer`.
|
|
@@ -278,16 +278,24 @@ The imported `GuardFn` has this signature:
|
|
|
278
278
|
```typescript
|
|
279
279
|
import type { RequestContext } from "@antelopejs/interface-api";
|
|
280
280
|
|
|
281
|
-
type AfterWrite
|
|
281
|
+
type AfterWrite<TWritten extends unknown[] = []> = (
|
|
282
|
+
...written: TWritten
|
|
283
|
+
) => void | Promise<void>;
|
|
282
284
|
|
|
283
|
-
type GuardFn<
|
|
285
|
+
type GuardFn<
|
|
286
|
+
TArgs,
|
|
287
|
+
TController = unknown,
|
|
288
|
+
TWritten extends unknown[] = [],
|
|
289
|
+
> = (
|
|
284
290
|
this: TController,
|
|
285
291
|
ctx: RequestContext,
|
|
286
292
|
args: TArgs,
|
|
287
|
-
) => void | AfterWrite | Promise<void | AfterWrite
|
|
293
|
+
) => void | AfterWrite<TWritten> | Promise<void | AfterWrite<TWritten>>;
|
|
288
294
|
```
|
|
289
295
|
|
|
290
|
-
A mutating guard may return an `AfterWrite`: the table view runs it once the write succeeded, in the same request. It is where work comparing the row before the write (what the guard saw) with the row after belongs, such as a notification; a failure there is logged and does not fail the request, since the write is done. What a `get` guard returns is ignored.
|
|
296
|
+
A mutating guard may return an `AfterWrite`: the table view runs it once the write succeeded, in the same request. It is where work comparing the row before the write (what the guard saw) with the row after belongs, such as a notification or an audit entry; a failure there is logged and does not fail the request, since the write is done. What a `get` guard returns is ignored.
|
|
297
|
+
|
|
298
|
+
After a `new` or an `edit`, the `AfterWrite` receives `written`: the row as stored once the write is done, read back the way the edit guard's `current` is, so a created row comes with its new `_id`. `TableViewGuards<T>` types it as `T & { _id: string }`, through `AfterWrite<[written]>`; a bare `AfterWrite` takes no argument, and fits every guard. After a `delete`, `archive` or `restore` it receives nothing, since the guard already holds the ids.
|
|
291
299
|
|
|
292
300
|
`ctx` is the `RequestContext` from `@antelopejs/interface-api`. `this` is the data controller instance, typed as such in `TableViewGuards<T>` (`TController` is `T` there), so a guard written as a `function` reaches the properties declared with `@Model` without a cast.
|
|
293
301
|
|
package/docs/3.base/4.tables.md
CHANGED
|
@@ -266,7 +266,7 @@ Typing `TableViewOptions` by `InstanceType<T>` is what makes row-action rules fi
|
|
|
266
266
|
| `tabs` | `TableViewTab[]` | Tabs above the table, each applying a hidden filter on one column (`filter` optional). A tab may link to another page instead (`to`: page controller or path, `countFrom`: data controller or location for its counter); a tab with id `"all"` replaces the implicit one; `permission` (an action of the table) or `permissionId` (an absolute id) gates it; `navBadge` (`true`, or `{ tone }`) publishes its counter as the page's nav badge. Serialized as `TableViewTabSerialized` (`to` resolved per request, `toPage`). |
|
|
267
267
|
| `realtime` | `boolean` | Set to `false` to disable realtime broadcast and presence for this resource. Realtime is on by default. |
|
|
268
268
|
| `realtimeTopic` | `string \| string[]` | Topics the backend publishes on when rows change outside the table's routes: the table reads its rows again on each event. Registered against the page from `onCreated`; also offered by `TableView.fromSource`. |
|
|
269
|
-
| `liveHold` | `boolean \| TableViewLiveHoldOptions` | On a page declared with `live`, keeps the rows while the page is paused, and in Direct while they are on screen or scrolled past (a new row at the top would push them down; `whileOnScreen: false` lets them follow the feed), and shows a "N new · Show" pill over the rows, which moves nothing, counting the rows its tab, search and filters match now beyond those it holds (asked of its count route), not the events; Show reads them once without leaving the pause. `{ whileRowOpen?, whileScrolled?, whileSearching?, whileSorted? }` (all default `false`) also holds the table alone, the page staying live, while a row is open in
|
|
269
|
+
| `liveHold` | `boolean \| TableViewLiveHoldOptions` | On a page declared with `live`, keeps the rows while the page is paused, and in Direct while they are on screen or scrolled past (a new row at the top would push them down; `whileOnScreen: false` lets them follow the feed), and shows a "N new · Show" pill over the rows, which moves nothing, counting the rows its tab, search and filters match now beyond those it holds (asked of its count route), not the events; Show reads them once without leaving the pause. `{ whileRowOpen?, whileScrolled?, whileSearching?, whileSorted? }` (all default `false`) also holds the table alone, the page staying live, while a row is open in a row action's side panel or drawer, its first row is scrolled out of view, the user's search narrows the rows or they are sorted otherwise than by `defaultSort`; the strip then names the reason ("Table on hold · search active"). `missedLabel` words the strip's count, given `{count}` ("12 new requests"); while the page is paused the strip adds the page's `setMissedDetail` breakdown. A `TableView.fromSource` route receives `liveHeldAt` (ISO 8601) on every request made while held. Also offered by `TableView.fromSource`. |
|
|
270
270
|
| `reorder` | `TableViewReorderOptions` | `{ field }`: rows ordered by hand with a drag handle, on the grid and on the `cards` display. `field` must be a `@Sortable()`, writable `NumberType` column, and the edit action on: registration throws otherwise. The rows are listed sorted on it, and a move saves only the rows whose value changed. |
|
|
271
271
|
| `kanban` | `KanbanOptions` | Enable the kanban display. |
|
|
272
272
|
| `grouped` | `GroupedOptions` | `{ groupByField, by?: "value" \| "day" \| "week", collapsible?, count? }`: offer the `grouped` display, the grid's columns under a header row per group. `groupByField` must be a `@Sortable()` column, a `DateType` one to group by day or week. |
|
|
@@ -445,7 +445,7 @@ const selector = PeriodSelector({
|
|
|
445
445
|
| `id` | `string` | Scope identifier other widgets name in `periodScope`, and the prefix of the selector's URL keys. Defaults to `"page"` (`DEFAULT_PERIOD_SCOPE`). |
|
|
446
446
|
| `defaultPreset` | `PeriodPreset` | Preset selected when neither the URL nor the user's last choice names one. |
|
|
447
447
|
| `defaultComparison` | `PeriodComparison` | Comparison selected when neither the URL nor the user's last choice names one. |
|
|
448
|
-
| `presets` | `PeriodPreset[]` | Presets offered. |
|
|
448
|
+
| `presets` | `PeriodPreset[]` | Presets offered. With `"custom"`, the user can type a start and an end date or pick them in the calendar; without it, the popover's date fields and calendar are read-only. |
|
|
449
449
|
| `comparisons` | `PeriodComparison[]` | Comparisons offered. |
|
|
450
450
|
| `presetLabels` | `Partial<Record<PeriodPreset, string>>` | Overrides for preset labels. |
|
|
451
451
|
| `comparisonLabels` | `Partial<Record<PeriodComparison, string>>` | Overrides for comparison labels. |
|
|
@@ -456,7 +456,7 @@ const selector = PeriodSelector({
|
|
|
456
456
|
| `comparisonControl` | `PeriodComparisonControl` | `"menu"`, `"toggle"` (one inline button switching a comparison on and off) or `"hidden"` (nothing drawn, the comparison kept on). Defaults to `"toggle"` when `comparisons` offers a single comparison besides `"none"`, `"menu"` otherwise. The menu's trigger names the compared window (`vs 16 – 17 Oct`, the option's name in its tooltip and its list), so the range label beside it keeps the current window only. |
|
|
457
457
|
| `rememberKey` | `string` | Selectors carrying the same key share the remembered last choice, on any page. |
|
|
458
458
|
| `variant` | `PeriodSelectorVariant` | `"default"` or `"segmented"`. |
|
|
459
|
-
| `maxDays` | `number` | The longest custom range, in days (both ends included), the user can pick in the calendar or the date fields. Presets and a range given by the URL are not limited. |
|
|
459
|
+
| `maxDays` | `number` | The longest custom range, in days (both ends included), the user can pick in the calendar or the date fields (a typed range is cut once focus leaves its field). Presets and a range given by the URL are not limited. |
|
|
460
460
|
|
|
461
461
|
`PeriodPreset` is `"last-hour"`, `"last-24h"`, `"today"`, `"yesterday"`, `"last-7-days"`, `"last-30-days"`, `"last-90-days"`, `"this-month"`, `"last-month"`, `"this-quarter"`, `"last-quarter"`, `"ytd"`, `"last-year"`, `"all"` or `"custom"`. `"all"` is every period: it has no bounds, so the bound widgets are sent no `from` / `to`. `PeriodComparison` is `"none"`, `"previous-period"`, `"previous-year"` or `"custom"`. `PeriodAlign` is `"left" | "center" | "right"`.
|
|
462
462
|
|
|
@@ -324,10 +324,13 @@ declare customerId: string;
|
|
|
324
324
|
| `filterOnly` | `boolean` | Skip the join entirely: the raw scalar id stays in the list output and the funnel filter runs equality on it. A table cell, a card or a kanban card of that column then shows the id: lists draw the joined row only, they never read the ids by `?ids=`. |
|
|
325
325
|
| `addForm` | `{ displayName?: string; description?: string }` | Title and description of the drawer the picker's "add" entry opens ("New customer"). `$`-prefixed: i18n keys. Default to "New entry". |
|
|
326
326
|
| `filterBy` | `{ field, from }` | List only the target rows whose `field` equals the form's current value of the field `from`, e.g. `{ field: "customerId", from: "customerId" }` for a site among its customer's sites. `field` must be filterable on the target (`filterable: true` or `@Filter`); `decorateField` throws otherwise. |
|
|
327
|
+
| `filter` | `TableViewTabFilter` (`{ accessorKey, mode, value? }`) | List only the target rows meeting a fixed condition, written like a tab's filter, e.g. `{ accessorKey: "isArchived", mode: "ne", value: "true" }` for the active rows of an `@ArchiveField` table. `mode` is one the target field's filter takes: `eq` or `ne` for an archive field, a compare mode (`is`, `is_not`, `is_empty`, …) for a filterable column. `accessorKey` must be filterable on the target, as for `filterBy`. |
|
|
327
328
|
| `fallback` | `string` | Text used in place of an empty value. |
|
|
328
329
|
|
|
329
330
|
With `filterBy`, the picker sends the table filter syntax to the `select` endpoint (`filter_<field>=is:<value>`), which honors only the filters the target controller declares. It searches again when `from` changes and clears a pick made for its previous value; the pair a record loaded with is kept, and while `from` is empty every row is offered. It narrows what is offered only: a rule that must hold on save belongs to the module's routes.
|
|
330
331
|
|
|
332
|
+
With `filter`, the picker of a form sends `filter_<accessorKey>=<mode>:<value>` on every search, as a tab does, next to `filterBy`'s condition (both apply when they name the same field). The label read of the ids a record holds (`?ids=`) does not carry it, so a held row outside the condition keeps its label as long as the reader may see that row (an archived row stays hidden from a user without the `viewArchived` permission). A table filter's picker leaves it out and reaches every row.
|
|
333
|
+
|
|
331
334
|
When the target controller exposes a `new` endpoint and has form fields, the picker of an editable form field also carries an inline "add" form built from the target's `new` fields, plus the permission id of the target's `add` action. That form (the target's fields, its validation schema, its own relations' add forms) is the bulk of the component, so a table column's type, its filter and a read-only field leave it out: they read the related rows through the `select` route, and a filter only picks among them.
|
|
332
335
|
|
|
333
336
|
`CascaderRelationType<T>` is the same idea for a self-referencing table: the target's `select` endpoint returns a flat list, and the widget rebuilds the tree client-side. Its cell and its field name the picked row by its path, read by `?ids=` for the picked rows and then each level of their ancestors. Its `keyMapping` is required and adds `parent`, the field pointing at the parent row, which must itself carry `@Select()`, alongside the required `label` and `value`. It adds `maxDepth` and `leafOnly` to the relation options, and supports the same `filterOnly` behaviour. In a table cell it shows the path of the picked node ("Electronics / Audio"); a `multiple` one shows a badge per picked node, named by its own label with its path on hover, and folds those past three into `+N`.
|
|
@@ -21,6 +21,7 @@ The [Read notifications](/docs/auth-and-tenancy/authentication#read-notification
|
|
|
21
21
|
- **Four dispatch targets.** You send to one user, to a list of users, to every user holding at least one of a set of roles, or to every user.
|
|
22
22
|
- **Shared or individual read state.** A multi-recipient send can give each recipient their own read state. It can also group the copies, so that one recipient reading the notification marks it read for all of them.
|
|
23
23
|
- **Preference-aware delivery.** The DMS skips a send without an error for a user who turned the subject off. `togglePermission` marks the subjects that users may not turn off.
|
|
24
|
+
- **E-mail.** A subject can offer e-mail next to the app, and a mail module registers the channel that sends it. See [E-mail](/docs/interfaces/notifications/email).
|
|
24
25
|
|
|
25
26
|
## Dependencies
|
|
26
27
|
|
|
@@ -10,7 +10,7 @@ You declare categories and subjects by calling `NotificationCategory()` and `Not
|
|
|
10
10
|
|
|
11
11
|
Declarations are function calls, not decorators. They run when the module that contains them is imported. Declare them at the top level of a module that is imported during startup, so the taxonomy is complete before the first notification is sent.
|
|
12
12
|
|
|
13
|
-
The [Notification preferences](/docs/auth-and-tenancy/authentication#notification-preferences) walkthrough shows the System category expanded to its subjects, and describes the locked General subject in prose.
|
|
13
|
+
The [Notification preferences](/docs/auth-and-tenancy/authentication#notification-preferences) walkthrough shows the System category expanded to its subjects, and describes the locked General subject in prose. The Email column holds a switch for each subject that offers e-mail once a module registers the e-mail channel, and is marked **Soon** otherwise (see [E-mail](/docs/interfaces/notifications/email)). These switches control notifications, not the transactional authentication emails.
|
|
14
14
|
|
|
15
15
|
## Declaring a category
|
|
16
16
|
|
|
@@ -88,6 +88,7 @@ export const stockSubject = NotificationSubject("stock", {
|
|
|
88
88
|
| `descriptionKey` | `string` (optional) | Translation key for a longer description. |
|
|
89
89
|
| `togglePermission` | [`TogglePermission`](#toggle-permissions) (optional) | Whether users may turn this subject off. The DMS reads it together with the category's value. |
|
|
90
90
|
| `badgeKey` | `string` (optional) | Translation key of a badge that the settings screen shows next to the subject label, for example `Developer mode`. |
|
|
91
|
+
| `email` | `boolean \| { defaultOn?: boolean }` (optional) | Whether the subject also reaches its recipients by e-mail: `true` (off until the user turns it on) or `{ defaultOn: true }` (on until the user turns it off). In-app only when unset. See [E-mail](/docs/interfaces/notifications/email). |
|
|
91
92
|
|
|
92
93
|
A subject carries the whole category object, not only its id, so `subject.category.id` is always available from a subject you hold. A send uses it to build the preference key from the subject you passed to the builder.
|
|
93
94
|
|
|
@@ -123,8 +124,8 @@ Every other combination leaves the subject toggleable. The value on a category a
|
|
|
123
124
|
A locked subject behaves the same way everywhere:
|
|
124
125
|
|
|
125
126
|
- The settings screen shows its switch disabled, with a hint.
|
|
126
|
-
- The preferences route refuses a change that turns it off, with HTTP 403.
|
|
127
|
-
- Every dispatch method delivers it whatever preference the user has stored for it.
|
|
127
|
+
- The preferences route refuses a change that turns it off, with HTTP 403, in the app or by e-mail when it offers e-mail.
|
|
128
|
+
- Every dispatch method delivers it whatever preference the user has stored for it, by e-mail too when it offers e-mail.
|
|
128
129
|
|
|
129
130
|
For a notification a user must always receive, declare `togglePermission: "forbidden"` on the subject **and** `togglePermission: "default"` on its category. `SystemCategory` declares `"default"`, which is what makes `GeneralSubject` mandatory.
|
|
130
131
|
|
|
@@ -164,7 +164,7 @@ Every dispatch method accepts an optional `SendOptions` object.
|
|
|
164
164
|
| `readScope` | `ReadScope` (optional) | Read-state grouping for a multi-recipient send. Defaults to `"individual"`. See [Read scope](/docs/interfaces/notifications/categories-and-subjects#read-scope). |
|
|
165
165
|
| `idempotencyKey` | `string` (optional) | Stable event key, unique across producers. Prefix it with your module ID. Reusing it for a recipient preserves the original notification and its dismissal state. |
|
|
166
166
|
| `dedupe` | `boolean` (optional) | With `false`, the DMS stores every unkeyed send, even one identical to a notification the recipient got less than 10 seconds earlier. Defaults to `true`. See [Repeated sends](#repeated-sends). |
|
|
167
|
-
| `tenantId` | `string` (optional
|
|
167
|
+
| `tenantId` | `string` (optional) | The workspace the notification is about. The [e-mail channel](/docs/interfaces/notifications/email) receives it as `data.tenantId`. With `toRoles`, it also limits the recipients to the members of this tenant holding the roles; every tenant when unset. |
|
|
168
168
|
|
|
169
169
|
Pick `"shared"` for an alert that only needs one person to act on it, and `"individual"` for anything each recipient has to see.
|
|
170
170
|
|
|
@@ -212,6 +212,7 @@ Every dispatch method resolves to one delivery per user, so the DMS applies the
|
|
|
212
212
|
- **Skipping is silent.** A skipped delivery is not an error. The promise resolves normally, and there is no per-recipient result to inspect.
|
|
213
213
|
- **Each recipient gets a row.** Each recipient gets their own stored notification. With `readScope: "shared"`, the DMS ties those copies together for read state, and they stay separate rows.
|
|
214
214
|
- **Stored notifications are pushed live.** The DMS also publishes each new delivery on the recipient's realtime stream, so the dashboard's badge and preview update without a reload.
|
|
215
|
+
- **Stored notifications reach the e-mail channel.** When a module registers the e-mail channel and the subject offers e-mail, each new delivery is also handed to the channel for recipients who have e-mail on. A repeat or a retry that stores nothing new is not mailed. See [E-mail](/docs/interfaces/notifications/email).
|
|
215
216
|
|
|
216
217
|
A send can be skipped for reasons outside your control, so treat notifications as best-effort and do not make a workflow depend on one having been stored. To keep a failed send from breaking the operation that triggered it, wrap the call:
|
|
217
218
|
|
|
@@ -250,7 +251,7 @@ The interface root exports `Notification()` and the data types. The `types` subp
|
|
|
250
251
|
| `NotificationBuilder` | `@antelopejs/interface-dms/notifications/builder` |
|
|
251
252
|
| `SendableNotification` | `@antelopejs/interface-dms/notifications/sendable` |
|
|
252
253
|
|
|
253
|
-
`NotificationData` is the shape the builder assembles. It holds `icon`, `title`, `description` and `subject`, plus the optional `linkTo`, `params` and `tone
|
|
254
|
+
`NotificationData` is the shape the builder assembles. It holds `icon`, `title`, `description` and `subject`, plus the optional `linkTo`, `params` and `tone`, and the `tenantId` a send names. Name it when you carry notification content around before you build it:
|
|
254
255
|
|
|
255
256
|
```typescript
|
|
256
257
|
import { Notification } from "@antelopejs/interface-dms/notifications";
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "E-mail"
|
|
3
|
+
description: "How a module delivers notifications by e-mail, and how a subject offers it."
|
|
4
|
+
mode: reference
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Every notification lands in the recipient's in-app feed. The **e-mail channel** also mails it. The DMS defines the channel and ships no implementation for it. A mail module registers it, and every subject that offers e-mail then reaches the users who turn it on.
|
|
8
|
+
|
|
9
|
+
Two parties take part:
|
|
10
|
+
|
|
11
|
+
- **A subject offers e-mail** with `email` on its declaration. A subject without it stays in-app only.
|
|
12
|
+
- **A module registers the channel** with `NotificationEmailChannel({ deliver })`. Without a registration, nothing is mailed and the settings screen shows the Email column marked **Soon**, as on an installation without a mail module.
|
|
13
|
+
|
|
14
|
+
## Offering e-mail on a subject
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
import {
|
|
18
|
+
NotificationCategory,
|
|
19
|
+
NotificationSubject,
|
|
20
|
+
} from "@antelopejs/interface-dms/notifications";
|
|
21
|
+
|
|
22
|
+
const shopCategory = NotificationCategory("shop", {
|
|
23
|
+
labelKey: "shop.notifications.categories.shop",
|
|
24
|
+
icon: "i-ph-shopping-cart",
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export const orderShippedSubject = NotificationSubject("order-shipped", {
|
|
28
|
+
category: shopCategory,
|
|
29
|
+
labelKey: "shop.notifications.subjects.order_shipped",
|
|
30
|
+
email: true,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export const invoiceSubject = NotificationSubject("invoice", {
|
|
34
|
+
category: shopCategory,
|
|
35
|
+
labelKey: "shop.notifications.subjects.invoice",
|
|
36
|
+
email: { defaultOn: true },
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
| Value of `email` | Meaning |
|
|
41
|
+
| ---------------- | ------- |
|
|
42
|
+
| omitted or `false` | The subject is not offered by e-mail. Its Email cell shows `—`. |
|
|
43
|
+
| `true` or `{ defaultOn: false }` | Offered, off until the user turns it on. |
|
|
44
|
+
| `{ defaultOn: true }` | Offered, on until the user turns it off. |
|
|
45
|
+
|
|
46
|
+
## Registering the channel
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
import { NotificationEmailChannel } from "@antelopejs/interface-dms/notifications";
|
|
50
|
+
|
|
51
|
+
NotificationEmailChannel({
|
|
52
|
+
deliver: (userId, data, notificationId) => {
|
|
53
|
+
// Queue a mail for `userId` about `data` (its title, description,
|
|
54
|
+
// params, link and `tenantId`), keyed by `notificationId`.
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
`deliver(userId, data, notificationId)` receives:
|
|
60
|
+
|
|
61
|
+
| Argument | Description |
|
|
62
|
+
| -------- | ----------- |
|
|
63
|
+
| `userId` | The recipient. |
|
|
64
|
+
| `data` | The `NotificationData` sent, with `tenantId` when the send named a workspace (`SendOptions.tenantId`). |
|
|
65
|
+
| `notificationId` | Id of the in-app notification stored for this recipient. Key the mail on it to send it at most once. |
|
|
66
|
+
|
|
67
|
+
One module registers the channel. A later registration replaces the earlier one. Unloading the module whose registration is live removes the channel; unloading one that was replaced, as a hot reload does, leaves the live one in place.
|
|
68
|
+
|
|
69
|
+
## When the DMS calls the channel
|
|
70
|
+
|
|
71
|
+
For each recipient, after the in-app notification is handled:
|
|
72
|
+
|
|
73
|
+
- **Only a new in-app notification is mailed.** The DMS calls `deliver` once the in-app row is stored and published. A send the recipient turned off in the app, a repeat inside the [10-second window](/docs/interfaces/notifications/sending#repeated-sends) and a retry of a keyed send (`toUsersIdempotently`) store no new row, so they mail nothing. E-mail is a copy of an in-app notification: a user who turns a subject off in the app receives no e-mail for it either, and the settings screen disables its Email switch.
|
|
74
|
+
- **The user preference decides.** The choice is stored under `categoryId:subjectId@email`, next to the in-app key in the same per-user map. A user who never chose gets the subject's `defaultOn`.
|
|
75
|
+
- **A locked subject is mailed whatever is stored.** A [locked subject](/docs/interfaces/notifications/categories-and-subjects#toggle-permissions) that offers e-mail reaches every recipient by e-mail, and the preferences route refuses turning its e-mail off with HTTP 403.
|
|
76
|
+
- **A failing channel never fails the send.** A `deliver` that throws or rejects is logged with `[DMS] Notification e-mail channel failed to deliver`. The in-app notification stays, and the send resolves.
|
|
77
|
+
- **Sends wait for `deliver`.** Queue slow work, such as talking to a mail server, instead of doing it inside `deliver`.
|
|
78
|
+
|
|
79
|
+
Preferences are per user and global: one choice per subject covers every workspace the user belongs to, for e-mail as for the app. `data.tenantId` tells the channel which workspace the notification is about, for example to pick its sender or branding.
|
package/docs/index.md
CHANGED
|
@@ -82,7 +82,7 @@ Each subpath is its own entry point, and importing one does not load the others.
|
|
|
82
82
|
| `/base/table-view` | `TableView`, `@Column`, `TableViewRoutes`, guards, row actions | [Base](/docs/interfaces/base/tables) |
|
|
83
83
|
| `/base/data-types` | `DataType`, the registration decorators, `DefaultDataTypes`, `DefaultDataCompareTypes`, `StatusType` | [Base](/docs/interfaces/base/data-types) |
|
|
84
84
|
| `/base/…` | The per-component subpaths, such as `chart`, `grid`, `stack`, `tab`, `custom`, `layouts` and `helpers/…` | [Base](/docs/interfaces/base/introduction) |
|
|
85
|
-
| `/notifications`, `/notifications/types` | Categories, subjects, the notification builder
|
|
85
|
+
| `/notifications`, `/notifications/types` | Categories, subjects, the notification builder, its dispatch targets and the e-mail channel | [Notifications](/docs/interfaces/notifications/introduction) |
|
|
86
86
|
| `/html-render` | `RegisterHtmlTemplate`, `GenerateHtml` and the template reference types | [HTML Render](/docs/interfaces/html-render/introduction) |
|
|
87
87
|
|
|
88
88
|
Beyond these entry points, built files are importable through the `./*` export (`@antelopejs/interface-dms/base/form-types`). Moving or renaming a public path is a breaking change, like removing an export.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antelopejs/interface-dms",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.7-next.1002.g39c16f7",
|
|
4
4
|
"description": "Public AntelopeJS interfaces of the DMS: pages, components, permissions, tenancy, auth, notifications and HTML rendering.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antelopejs",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@antelopejs/interface-database": ">=0.4.0 <0.5.0",
|
|
52
52
|
"@antelopejs/interface-database-decorators": ">=0.5.2 <0.6.0",
|
|
53
53
|
"@antelopejs/interface-file-storage": ">=0.1.4 <0.2.0",
|
|
54
|
-
"@antelopejs/tooling-configs": ">=0.8.
|
|
54
|
+
"@antelopejs/tooling-configs": ">=0.8.7 <0.9.0",
|
|
55
55
|
"@types/node": "^24.0.0",
|
|
56
56
|
"@types/randomstring": "^1.3.0",
|
|
57
57
|
"knip": "^6.34.0",
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
"provenance": true,
|
|
133
133
|
"registry": "https://registry.npmjs.org/"
|
|
134
134
|
},
|
|
135
|
-
"gitHead": "
|
|
135
|
+
"gitHead": "39c16f7f24a7eb341888c4c57ee1430195734bb3",
|
|
136
136
|
"scripts": {
|
|
137
137
|
"build": "rimraf dist && antelopejs-tsc",
|
|
138
138
|
"typecheck": "antelopejs-tsc --noEmit",
|