@webx-ui/module-notifications 0.0.0-stage → 0.2.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.
@@ -0,0 +1,200 @@
1
+ import { ScreenModel } from '@webx-ui/schema';
2
+ /** What happened to one recipient of one channel (§9). */
3
+ export type DeliveryStatus = 'queued' | 'sent' | 'failed' | 'skipped';
4
+ /** A setting of a provider: a bot's token, an SMTP host (`Sending\Field` on the server). */
5
+ export interface ProviderField {
6
+ name: string;
7
+ label: string;
8
+ /** Lives encrypted in `credentials` and is answered only with "it is set". */
9
+ secret: boolean;
10
+ kind: 'text' | 'number' | 'choice' | 'email';
11
+ choices: string[];
12
+ default: unknown;
13
+ }
14
+ /** A kind of channel (§4): Telegram, e-mail, or one a site registered. */
15
+ export interface NotificationProvider {
16
+ key: string;
17
+ label: string;
18
+ icon: string;
19
+ fields: ProviderField[];
20
+ /** Whether a message has a subject — e-mail does, Telegram does not. */
21
+ subject: boolean;
22
+ /** The kind of address an event's addressee must be to receive through it: `email`, `telegram`. */
23
+ address: string;
24
+ /** The longest message, in characters; null for none. */
25
+ limit: number | null;
26
+ /** Whether it can find its recipients itself — Telegram's "Find chats". */
27
+ find_recipients: boolean;
28
+ }
29
+ /** A variable an event fills a template with (`Variable::toArray()`). */
30
+ export interface EventVariable {
31
+ /** `form`, `field.*` for a family of names, `items` for a list. */
32
+ name: string;
33
+ label: string;
34
+ example: unknown;
35
+ /** `email` or `telegram` when the value is an address a channel may send to. */
36
+ address: string | null;
37
+ /** A list: the fields of each element. */
38
+ fields: {
39
+ name: string;
40
+ label: string;
41
+ }[];
42
+ }
43
+ /** An event a consumer declared (§5). */
44
+ export interface NotificationEvent {
45
+ key: string;
46
+ label: string;
47
+ module: string;
48
+ variables: EventVariable[];
49
+ /** What a new channel starts with, by provider; `*` for any. */
50
+ sample: Record<string, {
51
+ subject?: string | null;
52
+ template: string;
53
+ }>;
54
+ }
55
+ /** `GET meta`: what the site has. */
56
+ export interface NotificationsMeta {
57
+ providers: NotificationProvider[];
58
+ events: NotificationEvent[];
59
+ environment: string;
60
+ /** How sending goes: `queue`, `after_response`. */
61
+ mode: string;
62
+ }
63
+ /** One channel as a row of the list and the head of its form (`ChannelForm::row()`). */
64
+ export interface ChannelRow {
65
+ id: number;
66
+ name: string;
67
+ provider: string;
68
+ provider_label: string;
69
+ /** False when the provider's package is gone: the channel sends nothing. */
70
+ provider_declared: boolean;
71
+ icon: string | null;
72
+ event: string | null;
73
+ event_label: string | null;
74
+ /** False when the event is no longer declared: the channel works as one for any event. */
75
+ event_declared: boolean;
76
+ /** How many recipients. */
77
+ recipients: number;
78
+ enabled: boolean;
79
+ /** Which secrets are set — never their values. */
80
+ credentials_set: Record<string, true>;
81
+ /** False when the secrets cannot be decrypted: the key of the site changed. */
82
+ credentials_readable: boolean;
83
+ /** The bot a check found, `@name`, kept for an hour. */
84
+ bot: string | null;
85
+ copied_from: number | null;
86
+ last_delivery: {
87
+ status: DeliveryStatus;
88
+ at: string | null;
89
+ error: string | null;
90
+ } | null;
91
+ updated_at: string | null;
92
+ deleted_at: string | null;
93
+ }
94
+ /** A channel as its form opens it. Secret fields are always empty in `values`. */
95
+ export interface ChannelDetail {
96
+ channel: ChannelRow;
97
+ values: ScreenModel;
98
+ /** What to look at although the channel was saved: names no event has. */
99
+ warnings: string[];
100
+ }
101
+ export interface ChannelsList {
102
+ data: ChannelRow[];
103
+ environment: string;
104
+ }
105
+ /** A recipient of a Telegram channel. */
106
+ export interface ChatRecipient {
107
+ chat_id?: string;
108
+ label?: string;
109
+ /** An addressee of the event instead of a fixed chat. */
110
+ variable?: string;
111
+ }
112
+ /** A recipient of an e-mail channel. */
113
+ export interface EmailRecipient {
114
+ admin_id?: number;
115
+ email?: string;
116
+ variable?: string;
117
+ }
118
+ /** A chat "Find chats" found among the bot's updates (§6.3). */
119
+ export interface FoundChat {
120
+ id: string;
121
+ /** `private`, `group`, `supergroup`, `channel`. */
122
+ type: string;
123
+ title: string;
124
+ username: string | null;
125
+ }
126
+ export interface Administrator {
127
+ id: number;
128
+ name: string;
129
+ email: string;
130
+ }
131
+ /** One line of the delivery log (`DeliveryController::row()`). */
132
+ export interface DeliveryRow {
133
+ id: number;
134
+ channel_id: number | null;
135
+ channel_name: string;
136
+ provider: string;
137
+ event: string;
138
+ event_label: string | null;
139
+ subject_type: string | null;
140
+ subject_id: number | null;
141
+ subject_url: string | null;
142
+ locale: string | null;
143
+ recipient: string;
144
+ recipient_label: string | null;
145
+ status: DeliveryStatus;
146
+ reason: string | null;
147
+ error: string | null;
148
+ attempts: number;
149
+ is_test: boolean;
150
+ truncated: boolean;
151
+ unknown_variables: string[];
152
+ variables: Record<string, unknown>;
153
+ retryable: boolean;
154
+ created_at: string | null;
155
+ sent_at: string | null;
156
+ }
157
+ /** A page of the log, as Laravel's paginator answers it. */
158
+ export interface DeliveriesPage {
159
+ data: DeliveryRow[];
160
+ current_page: number;
161
+ last_page: number;
162
+ per_page: number;
163
+ total: number;
164
+ from: number | null;
165
+ to: number | null;
166
+ environment: string;
167
+ }
168
+ export interface DeliveriesQuery {
169
+ page?: number;
170
+ per_page?: number;
171
+ channel?: number | null;
172
+ status?: DeliveryStatus | null;
173
+ event?: string | null;
174
+ /** False hides the tests. */
175
+ tests?: boolean;
176
+ }
177
+ /** What a test did for one recipient. */
178
+ export interface TestResult {
179
+ recipient: string;
180
+ label?: string | null;
181
+ status: DeliveryStatus;
182
+ error?: string | null;
183
+ reason?: string | null;
184
+ truncated?: boolean;
185
+ unknown_variables?: string[];
186
+ }
187
+ /** What the server's check of the settings said. */
188
+ export interface CheckAnswer {
189
+ ok: boolean;
190
+ message: string;
191
+ details?: Record<string, unknown>;
192
+ }
193
+ /** The message rendered on the event's examples, by the server (`POST preview`). */
194
+ export interface ServerPreview {
195
+ subject: string | null;
196
+ body: string;
197
+ plain: string;
198
+ truncated: boolean;
199
+ unknown_variables: string[];
200
+ }
@@ -0,0 +1,8 @@
1
+ import { MustacheVariable } from '@webx-ui/core';
2
+ import { NotificationEvent } from './types';
3
+ /** The variables of an event as the editor's suggestions take them. */
4
+ export declare function variablesOf(event: NotificationEvent | null | undefined): MustacheVariable[];
5
+ /** What a click on a variable puts into the template. */
6
+ export declare function snippetOf(variable: MustacheVariable, kind?: 'value' | 'has' | 'empty'): string;
7
+ /** The addressees of an event a provider can send to: the visitor's e-mail, a chat id. */
8
+ export declare function addresseesOf(event: NotificationEvent | null | undefined, address: string): import('./types').EventVariable[];
package/package.json CHANGED
@@ -1,6 +1,68 @@
1
1
  {
2
2
  "name": "@webx-ui/module-notifications",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.2.0",
4
+ "description": "Notification channels for the WebX UI admin panel: Telegram and e-mail, Mustache templates in every language of the site with highlighting, suggestions and a live preview, and the log of every delivery.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "sideEffects": [
8
+ "*.css"
9
+ ],
10
+ "keywords": [
11
+ "webx-ui",
12
+ "vue",
13
+ "admin",
14
+ "cms",
15
+ "notifications",
16
+ "telegram"
17
+ ],
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/webx-ui/webx-ui.git",
21
+ "directory": "packages/module-notifications"
22
+ },
23
+ "homepage": "https://webx-ui.github.io/webx-ui/guide/notifications.html",
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
27
+ "files": [
28
+ "dist"
29
+ ],
30
+ "main": "./dist/index.js",
31
+ "module": "./dist/index.js",
32
+ "types": "./dist/index.d.ts",
33
+ "exports": {
34
+ ".": {
35
+ "types": "./dist/index.d.ts",
36
+ "import": "./dist/index.js"
37
+ },
38
+ "./style.css": "./dist/style.css",
39
+ "./dist/style.css": "./dist/style.css",
40
+ "./package.json": "./package.json"
41
+ },
42
+ "peerDependencies": {
43
+ "vue": "^3.5.0",
44
+ "vue-router": "^4.5.0"
45
+ },
46
+ "dependencies": {
47
+ "@webx-ui/core": "^0.43.0",
48
+ "@webx-ui/module-admin": "^0.30.0",
49
+ "@webx-ui/schema": "^0.9.3",
50
+ "mustache": "^4.2.0"
51
+ },
52
+ "devDependencies": {
53
+ "@types/mustache": "^4.2.6",
54
+ "@types/node": "^24.10.1",
55
+ "@vitejs/plugin-vue": "^6.0.1",
56
+ "typescript": "^5.9.3",
57
+ "vite": "^7.1.14",
58
+ "vite-plugin-dts": "^4.5.4",
59
+ "vue": "^3.5.24",
60
+ "vue-router": "^4.5.1",
61
+ "vue-tsc": "^3.1.3"
62
+ },
63
+ "scripts": {
64
+ "build": "vite build",
65
+ "dev": "vite build --watch",
66
+ "typecheck": "vue-tsc -p tsconfig.json --noEmit"
67
+ }
6
68
  }