@antelopejs/interface-dms 0.14.7-next.998.gc2b0d73 → 0.15.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/CHANGELOG.md +49 -0
- package/dist/base/data-types/default/options.d.ts +10 -0
- package/dist/base/data-types/default/strings.d.ts +1 -1
- package/dist/base/data-types/default/strings.js +17 -4
- package/dist/base/data-types/default/strings.js.map +1 -1
- package/dist/base/data-types/field-types.d.ts +7 -0
- package/dist/base/data-types/field-types.js +1 -0
- package/dist/base/data-types/field-types.js.map +1 -1
- package/dist/base/data-types/internal/phone-number.d.ts +7 -0
- package/dist/base/data-types/internal/phone-number.js +12 -0
- package/dist/base/data-types/internal/phone-number.js.map +1 -0
- package/dist/base/form-schema.d.ts +4 -1
- package/dist/base/form-schema.js.map +1 -1
- package/dist/base/table-view/internal/auth.d.ts +9 -2
- package/dist/base/table-view/internal/auth.js +12 -6
- package/dist/base/table-view/internal/auth.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/types/row-action.d.ts +7 -0
- package/dist/component-options/form-field.d.ts +5 -2
- package/dist/component-options/page-layout.d.ts +5 -2
- package/dist/component-options/page-layout.js.map +1 -1
- package/dist/component-options/row-action.d.ts +6 -0
- package/dist/db/internal/invite-token.d.ts +7 -0
- package/dist/db/internal/invite-token.js +14 -0
- package/dist/db/internal/invite-token.js.map +1 -0
- package/dist/db/internal/inviteResolutions.model.js +2 -1
- package/dist/db/internal/inviteResolutions.model.js.map +1 -1
- package/dist/db/models/tenantMembers.model.d.ts +0 -1
- package/dist/db/models/tenantMembers.model.js +0 -6
- package/dist/db/models/tenantMembers.model.js.map +1 -1
- package/dist/db/models/user_invites.model.d.ts +3 -3
- package/dist/db/models/user_invites.model.js +7 -6
- package/dist/db/models/user_invites.model.js.map +1 -1
- package/dist/db/tables/inviteResolutions.table.d.ts +3 -2
- package/dist/db/tables/inviteResolutions.table.js.map +1 -1
- package/dist/db/tables/user_invites.table.d.ts +5 -0
- package/dist/db/tables/user_invites.table.js.map +1 -1
- package/dist/hooks.d.ts +4 -1
- package/dist/hooks.js.map +1 -1
- package/dist/internal/invite-handout.d.ts +24 -0
- package/dist/internal/invite-handout.js +28 -0
- package/dist/internal/invite-handout.js.map +1 -0
- package/dist/internal/invite-replacement.js +0 -1
- package/dist/internal/invite-replacement.js.map +1 -1
- package/dist/invites.d.ts +18 -2
- package/dist/invites.js +75 -29
- package/dist/invites.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 -1
- package/dist/page/internal/page-record.js +51 -7
- package/dist/page/internal/page-record.js.map +1 -1
- package/dist/page/layout-filter.js +2 -6
- package/dist/page/layout-filter.js.map +1 -1
- package/dist/page/types.d.ts +2 -0
- package/dist/utils/internal/type-check.d.ts +7 -0
- package/dist/utils/internal/type-check.js +12 -1
- package/dist/utils/internal/type-check.js.map +1 -1
- package/docs/1.core/2.pages-and-modules.md +1 -0
- package/docs/1.core/5.tenancy.md +0 -1
- package/docs/1.core/6.invites.md +6 -6
- package/docs/1.core/7.hooks.md +1 -2
- package/docs/3.base/1.introduction.md +1 -1
- package/docs/3.base/11.page-layouts.md +2 -2
- package/docs/3.base/12.table-row-actions.md +1 -1
- package/docs/3.base/15.table-sources-and-gates.md +1 -1
- package/docs/3.base/2.types.md +1 -1
- package/docs/3.base/3.forms.md +1 -1
- package/docs/3.base/8.data-types.md +2 -2
- 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 +2 -2
|
@@ -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.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "Public AntelopeJS interfaces of the DMS: pages, components, permissions, tenancy, auth, notifications and HTML rendering.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antelopejs",
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
"provenance": true,
|
|
133
133
|
"registry": "https://registry.npmjs.org/"
|
|
134
134
|
},
|
|
135
|
-
"gitHead": "
|
|
135
|
+
"gitHead": "f74dda76de0e998fe994f0c6c25c287817e00f29",
|
|
136
136
|
"scripts": {
|
|
137
137
|
"build": "rimraf dist && antelopejs-tsc",
|
|
138
138
|
"typecheck": "antelopejs-tsc --noEmit",
|