@nocobase/plugin-notification-manager 2.2.0-beta.1 → 2.2.0-beta.10
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/client/{507.6b177256a5fdfe2f.js → 507.fdef14cca9c18c29.js} +1 -1
- package/dist/client/{89.4f9da72110fbe97a.js → 89.4305cb8d81323fe6.js} +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client-v2/49.3feca41b2843a6b2.js +10 -0
- package/dist/client-v2/index.js +1 -1
- package/dist/collections/channel.js +1 -1
- package/dist/externalVersion.js +9 -9
- package/dist/locale/de-DE.json +1 -1
- package/dist/locale/en-US.json +1 -1
- package/dist/locale/es-ES.json +1 -1
- package/dist/locale/fr-FR.json +1 -1
- package/dist/locale/hu-HU.json +1 -1
- package/dist/locale/id-ID.json +1 -1
- package/dist/locale/it-IT.json +1 -1
- package/dist/locale/ja-JP.json +1 -1
- package/dist/locale/ko-KR.json +1 -1
- package/dist/locale/nl-NL.json +1 -1
- package/dist/locale/pt-BR.json +1 -1
- package/dist/locale/ru-RU.json +1 -1
- package/dist/locale/tr-TR.json +1 -1
- package/dist/locale/uk-UA.json +1 -1
- package/dist/locale/vi-VN.json +1 -1
- package/dist/locale/zh-CN.json +1 -1
- package/dist/locale/zh-TW.json +1 -1
- package/dist/node_modules/uuid/package.json +1 -1
- package/dist/server/plugin.js +10 -5
- package/dist/swagger/index.d.ts +542 -0
- package/dist/swagger/index.js +492 -0
- package/package.json +2 -2
- package/dist/client-v2/49.83c515a7f909c364.js +0 -10
|
@@ -0,0 +1,492 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var swagger_exports = {};
|
|
28
|
+
__export(swagger_exports, {
|
|
29
|
+
default: () => swagger_default
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(swagger_exports);
|
|
32
|
+
const jsonObjectSchema = {
|
|
33
|
+
type: "object",
|
|
34
|
+
additionalProperties: true
|
|
35
|
+
};
|
|
36
|
+
const listParameters = [
|
|
37
|
+
{
|
|
38
|
+
name: "filter",
|
|
39
|
+
in: "query",
|
|
40
|
+
required: false,
|
|
41
|
+
description: "Filter object encoded as JSON.",
|
|
42
|
+
schema: jsonObjectSchema
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "sort",
|
|
46
|
+
in: "query",
|
|
47
|
+
required: false,
|
|
48
|
+
description: "Sort fields, for example `-createdAt`.",
|
|
49
|
+
schema: {
|
|
50
|
+
oneOf: [
|
|
51
|
+
{ type: "string" },
|
|
52
|
+
{
|
|
53
|
+
type: "array",
|
|
54
|
+
items: { type: "string" }
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "page",
|
|
61
|
+
in: "query",
|
|
62
|
+
required: false,
|
|
63
|
+
schema: {
|
|
64
|
+
type: "integer"
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "pageSize",
|
|
69
|
+
in: "query",
|
|
70
|
+
required: false,
|
|
71
|
+
schema: {
|
|
72
|
+
type: "integer"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
];
|
|
76
|
+
const filterByTkParameter = {
|
|
77
|
+
name: "filterByTk",
|
|
78
|
+
in: "query",
|
|
79
|
+
required: true,
|
|
80
|
+
description: "Primary key value. For notification channels this is the channel `name`.",
|
|
81
|
+
schema: {
|
|
82
|
+
type: "string"
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
var swagger_default = {
|
|
86
|
+
openapi: "3.0.2",
|
|
87
|
+
info: {
|
|
88
|
+
title: "NocoBase API - Notification manager plugin"
|
|
89
|
+
},
|
|
90
|
+
paths: {
|
|
91
|
+
"/notificationChannels:list": {
|
|
92
|
+
get: {
|
|
93
|
+
tags: ["notificationChannels"],
|
|
94
|
+
summary: "List notification channels",
|
|
95
|
+
description: "List configured notification channels. Channel `name` is the primary key used by send APIs.",
|
|
96
|
+
parameters: listParameters,
|
|
97
|
+
responses: {
|
|
98
|
+
200: {
|
|
99
|
+
description: "OK",
|
|
100
|
+
content: {
|
|
101
|
+
"application/json": {
|
|
102
|
+
schema: {
|
|
103
|
+
$ref: "#/components/schemas/NotificationChannelListResponse"
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
"/notificationChannels:get": {
|
|
112
|
+
get: {
|
|
113
|
+
tags: ["notificationChannels"],
|
|
114
|
+
summary: "Get one notification channel",
|
|
115
|
+
parameters: [filterByTkParameter],
|
|
116
|
+
responses: {
|
|
117
|
+
200: {
|
|
118
|
+
description: "OK",
|
|
119
|
+
content: {
|
|
120
|
+
"application/json": {
|
|
121
|
+
schema: {
|
|
122
|
+
$ref: "#/components/schemas/NotificationChannelResponse"
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
"/notificationChannels:create": {
|
|
131
|
+
post: {
|
|
132
|
+
tags: ["notificationChannels"],
|
|
133
|
+
summary: "Create a notification channel",
|
|
134
|
+
requestBody: {
|
|
135
|
+
required: true,
|
|
136
|
+
content: {
|
|
137
|
+
"application/json": {
|
|
138
|
+
schema: {
|
|
139
|
+
$ref: "#/components/schemas/NotificationChannelInput"
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
responses: {
|
|
145
|
+
200: {
|
|
146
|
+
description: "OK",
|
|
147
|
+
content: {
|
|
148
|
+
"application/json": {
|
|
149
|
+
schema: {
|
|
150
|
+
$ref: "#/components/schemas/NotificationChannelResponse"
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
"/notificationChannels:update": {
|
|
159
|
+
post: {
|
|
160
|
+
tags: ["notificationChannels"],
|
|
161
|
+
summary: "Update a notification channel",
|
|
162
|
+
parameters: [filterByTkParameter],
|
|
163
|
+
requestBody: {
|
|
164
|
+
required: true,
|
|
165
|
+
content: {
|
|
166
|
+
"application/json": {
|
|
167
|
+
schema: {
|
|
168
|
+
$ref: "#/components/schemas/NotificationChannelInput"
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
responses: {
|
|
174
|
+
200: {
|
|
175
|
+
description: "OK",
|
|
176
|
+
content: {
|
|
177
|
+
"application/json": {
|
|
178
|
+
schema: {
|
|
179
|
+
$ref: "#/components/schemas/NotificationChannelResponse"
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
"/notificationChannels:destroy": {
|
|
188
|
+
post: {
|
|
189
|
+
tags: ["notificationChannels"],
|
|
190
|
+
summary: "Delete a notification channel",
|
|
191
|
+
parameters: [filterByTkParameter],
|
|
192
|
+
responses: {
|
|
193
|
+
200: {
|
|
194
|
+
description: "OK"
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
"/notificationSendLogs:list": {
|
|
200
|
+
get: {
|
|
201
|
+
tags: ["notificationSendLogs"],
|
|
202
|
+
summary: "List notification send logs",
|
|
203
|
+
description: "List delivery records written by the notification manager after send attempts.",
|
|
204
|
+
parameters: listParameters,
|
|
205
|
+
responses: {
|
|
206
|
+
200: {
|
|
207
|
+
description: "OK",
|
|
208
|
+
content: {
|
|
209
|
+
"application/json": {
|
|
210
|
+
schema: {
|
|
211
|
+
$ref: "#/components/schemas/NotificationSendLogListResponse"
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
"/notificationSendLogs:get": {
|
|
220
|
+
get: {
|
|
221
|
+
tags: ["notificationSendLogs"],
|
|
222
|
+
summary: "Get one notification send log",
|
|
223
|
+
parameters: [
|
|
224
|
+
{
|
|
225
|
+
...filterByTkParameter,
|
|
226
|
+
description: "Send log UUID."
|
|
227
|
+
}
|
|
228
|
+
],
|
|
229
|
+
responses: {
|
|
230
|
+
200: {
|
|
231
|
+
description: "OK",
|
|
232
|
+
content: {
|
|
233
|
+
"application/json": {
|
|
234
|
+
schema: {
|
|
235
|
+
$ref: "#/components/schemas/NotificationSendLogResponse"
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
"/messages:send": {
|
|
244
|
+
post: {
|
|
245
|
+
tags: ["notifications"],
|
|
246
|
+
summary: "Queue a notification send",
|
|
247
|
+
description: "Send a notification through a configured channel. The manager may enqueue delivery and writes a `notificationSendLogs` record when the send attempt is processed.",
|
|
248
|
+
requestBody: {
|
|
249
|
+
required: true,
|
|
250
|
+
content: {
|
|
251
|
+
"application/json": {
|
|
252
|
+
schema: {
|
|
253
|
+
$ref: "#/components/schemas/NotificationSendRequest"
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
responses: {
|
|
259
|
+
200: {
|
|
260
|
+
description: "OK",
|
|
261
|
+
content: {
|
|
262
|
+
"application/json": {
|
|
263
|
+
schema: {
|
|
264
|
+
$ref: "#/components/schemas/NotificationSendResponse"
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
components: {
|
|
274
|
+
schemas: {
|
|
275
|
+
NotificationChannel: {
|
|
276
|
+
type: "object",
|
|
277
|
+
properties: {
|
|
278
|
+
name: {
|
|
279
|
+
type: "string",
|
|
280
|
+
description: "Channel primary key, usually generated with the `s_` prefix."
|
|
281
|
+
},
|
|
282
|
+
title: {
|
|
283
|
+
type: "string"
|
|
284
|
+
},
|
|
285
|
+
description: {
|
|
286
|
+
type: "string"
|
|
287
|
+
},
|
|
288
|
+
notificationType: {
|
|
289
|
+
type: "string",
|
|
290
|
+
description: "Registered notification channel type, for example `in-app-message` or `email`."
|
|
291
|
+
},
|
|
292
|
+
options: jsonObjectSchema,
|
|
293
|
+
meta: jsonObjectSchema,
|
|
294
|
+
createdAt: {
|
|
295
|
+
type: "string",
|
|
296
|
+
format: "date-time"
|
|
297
|
+
},
|
|
298
|
+
updatedAt: {
|
|
299
|
+
type: "string",
|
|
300
|
+
format: "date-time"
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
additionalProperties: true
|
|
304
|
+
},
|
|
305
|
+
NotificationChannelInput: {
|
|
306
|
+
type: "object",
|
|
307
|
+
required: ["name", "title", "notificationType"],
|
|
308
|
+
properties: {
|
|
309
|
+
name: {
|
|
310
|
+
type: "string"
|
|
311
|
+
},
|
|
312
|
+
title: {
|
|
313
|
+
type: "string"
|
|
314
|
+
},
|
|
315
|
+
description: {
|
|
316
|
+
type: "string"
|
|
317
|
+
},
|
|
318
|
+
notificationType: {
|
|
319
|
+
type: "string"
|
|
320
|
+
},
|
|
321
|
+
options: jsonObjectSchema,
|
|
322
|
+
meta: jsonObjectSchema
|
|
323
|
+
},
|
|
324
|
+
additionalProperties: true
|
|
325
|
+
},
|
|
326
|
+
NotificationChannelResponse: {
|
|
327
|
+
type: "object",
|
|
328
|
+
properties: {
|
|
329
|
+
data: {
|
|
330
|
+
$ref: "#/components/schemas/NotificationChannel"
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
},
|
|
334
|
+
NotificationChannelListResponse: {
|
|
335
|
+
type: "object",
|
|
336
|
+
properties: {
|
|
337
|
+
data: {
|
|
338
|
+
type: "array",
|
|
339
|
+
items: {
|
|
340
|
+
$ref: "#/components/schemas/NotificationChannel"
|
|
341
|
+
}
|
|
342
|
+
},
|
|
343
|
+
meta: jsonObjectSchema
|
|
344
|
+
}
|
|
345
|
+
},
|
|
346
|
+
NotificationSendLog: {
|
|
347
|
+
type: "object",
|
|
348
|
+
properties: {
|
|
349
|
+
id: {
|
|
350
|
+
type: "string",
|
|
351
|
+
format: "uuid"
|
|
352
|
+
},
|
|
353
|
+
channelName: {
|
|
354
|
+
type: "string"
|
|
355
|
+
},
|
|
356
|
+
channelTitle: {
|
|
357
|
+
type: "string"
|
|
358
|
+
},
|
|
359
|
+
triggerFrom: {
|
|
360
|
+
type: "string"
|
|
361
|
+
},
|
|
362
|
+
notificationType: {
|
|
363
|
+
type: "string"
|
|
364
|
+
},
|
|
365
|
+
status: {
|
|
366
|
+
type: "string",
|
|
367
|
+
enum: ["success", "failure"]
|
|
368
|
+
},
|
|
369
|
+
message: jsonObjectSchema,
|
|
370
|
+
reason: {
|
|
371
|
+
type: "string"
|
|
372
|
+
},
|
|
373
|
+
createdAt: {
|
|
374
|
+
type: "string",
|
|
375
|
+
format: "date-time"
|
|
376
|
+
},
|
|
377
|
+
updatedAt: {
|
|
378
|
+
type: "string",
|
|
379
|
+
format: "date-time"
|
|
380
|
+
}
|
|
381
|
+
},
|
|
382
|
+
additionalProperties: true
|
|
383
|
+
},
|
|
384
|
+
NotificationSendLogResponse: {
|
|
385
|
+
type: "object",
|
|
386
|
+
properties: {
|
|
387
|
+
data: {
|
|
388
|
+
$ref: "#/components/schemas/NotificationSendLog"
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
NotificationSendLogListResponse: {
|
|
393
|
+
type: "object",
|
|
394
|
+
properties: {
|
|
395
|
+
data: {
|
|
396
|
+
type: "array",
|
|
397
|
+
items: {
|
|
398
|
+
$ref: "#/components/schemas/NotificationSendLog"
|
|
399
|
+
}
|
|
400
|
+
},
|
|
401
|
+
meta: jsonObjectSchema
|
|
402
|
+
}
|
|
403
|
+
},
|
|
404
|
+
NotificationReceivers: {
|
|
405
|
+
oneOf: [
|
|
406
|
+
{
|
|
407
|
+
type: "object",
|
|
408
|
+
required: ["type", "value"],
|
|
409
|
+
properties: {
|
|
410
|
+
type: {
|
|
411
|
+
type: "string",
|
|
412
|
+
enum: ["userId"]
|
|
413
|
+
},
|
|
414
|
+
value: {
|
|
415
|
+
type: "array",
|
|
416
|
+
items: {
|
|
417
|
+
type: "integer"
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
type: "object",
|
|
424
|
+
required: ["type", "channelType", "value"],
|
|
425
|
+
properties: {
|
|
426
|
+
type: {
|
|
427
|
+
type: "string",
|
|
428
|
+
enum: ["channel-self-defined"]
|
|
429
|
+
},
|
|
430
|
+
channelType: {
|
|
431
|
+
type: "string"
|
|
432
|
+
},
|
|
433
|
+
value: {}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
]
|
|
437
|
+
},
|
|
438
|
+
NotificationSendRequest: {
|
|
439
|
+
type: "object",
|
|
440
|
+
required: ["channelName", "message", "triggerFrom"],
|
|
441
|
+
properties: {
|
|
442
|
+
channelName: {
|
|
443
|
+
type: "string",
|
|
444
|
+
description: "Existing `notificationChannels.name`."
|
|
445
|
+
},
|
|
446
|
+
message: jsonObjectSchema,
|
|
447
|
+
receivers: {
|
|
448
|
+
$ref: "#/components/schemas/NotificationReceivers"
|
|
449
|
+
},
|
|
450
|
+
triggerFrom: {
|
|
451
|
+
type: "string",
|
|
452
|
+
example: "workflow"
|
|
453
|
+
},
|
|
454
|
+
data: jsonObjectSchema
|
|
455
|
+
}
|
|
456
|
+
},
|
|
457
|
+
NotificationSendResult: {
|
|
458
|
+
type: "object",
|
|
459
|
+
properties: {
|
|
460
|
+
status: {
|
|
461
|
+
type: "string",
|
|
462
|
+
enum: ["success", "failure"]
|
|
463
|
+
},
|
|
464
|
+
reason: {
|
|
465
|
+
type: "string"
|
|
466
|
+
},
|
|
467
|
+
triggerFrom: {
|
|
468
|
+
type: "string"
|
|
469
|
+
},
|
|
470
|
+
channelName: {
|
|
471
|
+
type: "string"
|
|
472
|
+
},
|
|
473
|
+
receivers: {
|
|
474
|
+
$ref: "#/components/schemas/NotificationReceivers"
|
|
475
|
+
},
|
|
476
|
+
queued: {
|
|
477
|
+
type: "boolean"
|
|
478
|
+
}
|
|
479
|
+
},
|
|
480
|
+
additionalProperties: true
|
|
481
|
+
},
|
|
482
|
+
NotificationSendResponse: {
|
|
483
|
+
type: "object",
|
|
484
|
+
properties: {
|
|
485
|
+
data: {
|
|
486
|
+
$ref: "#/components/schemas/NotificationSendResult"
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
};
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"description.ru-RU": "Предоставляет единый сервис управления, включающий конфигурирование каналов, логирование и другие функции, поддерживает настройку различных каналов уведомлений, включая внутренние сообщения и электронную почту.",
|
|
7
7
|
"displayName.zh-CN": "通知管理",
|
|
8
8
|
"description.zh-CN": "提供统一的管理服务,涵盖渠道配置、日志记录等功能,支持多种通知渠道的配置,包括站内信和电子邮件等。",
|
|
9
|
-
"version": "2.2.0-beta.
|
|
9
|
+
"version": "2.2.0-beta.10",
|
|
10
10
|
"homepage": "https://docs.nocobase.com/handbook/notification-manager",
|
|
11
11
|
"homepage.ru-RU": "https://docs-ru.nocobase.com/handbook/notification-manager",
|
|
12
12
|
"homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/notification-manager",
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"Notification"
|
|
37
37
|
],
|
|
38
38
|
"license": "Apache-2.0",
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "d572beec24de46df948f28db72b25303a63bf62d"
|
|
40
40
|
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
"use strict";(self.webpackChunk_nocobase_plugin_notification_manager_client_v2=self.webpackChunk_nocobase_plugin_notification_manager_client_v2||[]).push([["49"],{624:function(e,t,n){n.r(t),n.d(t,{default:function(){return j}});var r=n(375),o=n(485),i=n(694),a=n(625),l=n(59),u=n(773),c=n(155),s=n.n(c),f=n(553),m={name:f.L.channels,dataCategory:"system",migrationRules:["overwrite","schema-only"],filterTargetKey:"name",autoGenId:!1,createdAt:!0,createdBy:!0,updatedAt:!0,updatedBy:!0,fields:[{name:"name",type:"uid",prefix:"s_",primaryKey:!0,interface:"input",uiSchema:{type:"string",title:'{{t("Channel name")}}',"x-component":"Input",required:!0,description:"{{t('Randomly generated and can not be modified. Support letters, numbers and underscores, must start with an letter.')}}"}},{name:"title",type:"string",interface:"input",uiSchema:{type:"string","x-component":"Input",title:'{{t("Channel display name")}}',required:!0}},{name:"options",type:"json",interface:"json",uiSchema:{type:"object","x-component":"ConfigForm"}},{name:"meta",type:"json",interface:"json"},{interface:"input",type:"string",name:"notificationType",uiSchema:{type:"string",title:'{{t("Notification type")}}',"x-component":"Select",enum:"{{notificationTypeOptions}}",required:!0}},{name:"description",type:"text",interface:"textarea",uiSchema:{type:"string","x-component":"Input.TextArea",title:'{{t("Description")}}'}}]},p=n(488),d=n(667),y=n(705);function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function h(e,t,n,r,o,i,a){try{var l=e[i](a),u=l.value}catch(e){n(e);return}l.done?t(u):Promise.resolve(u).then(r,o)}function g(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){h(i,r,o,a,l,"next",e)}function l(e){h(i,r,o,a,l,"throw",e)}a(void 0)})}}function v(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function E(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(l)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return b(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return b(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function w(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:u(0)}),l(a,"throw",{value:u(1)}),l(a,"return",{value:u(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function u(l){return function(u){var c=[l,u];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}function O(e){var t,n=(0,p.yr)().t,r=(0,i.useFlowContext)(),m=(0,c.useMemo)(function(){return r.api.resource(f.L.channels)},[r.api]),d=E(l.Form.useForm(),1)[0],y=E((0,c.useState)(!1),2),b=y[0],h=y[1],O=(0,c.useMemo)(function(){return"edit"===e.mode?(0,u.cloneDeep)(e.record||{}):{name:(0,i.randomId)("s_"),notificationType:e.notificationType,options:{}}},[e.mode,e.notificationType,e.record]);(0,c.useEffect)(function(){d.setFieldsValue(O)},[d,O]);var S=e.plugin.channelTypes.get(e.notificationType),j=null==S||null==(t=S.components)?void 0:t.ChannelConfigFormLoader,T=(0,c.useMemo)(function(){return j?(0,c.lazy)(j):null},[j]),A=(0,a.useMemoizedFn)(function(){return g(function(){var t,n,r;return w(this,function(o){switch(o.label){case 0:return[4,d.validateFields()];case 1:t=o.sent(),h(!0),o.label=2;case 2:if(o.trys.push([2,,8,9]),"create"!==e.mode)return[3,4];return[4,m.create({values:t})];case 3:case 5:return o.sent(),e.onSubmitted(),[3,7];case 4:var i,a;if((null==(n=e.record)?void 0:n.name)==null)return[3,6];return i=v({},(0,u.cloneDeep)(e.record),t),a=a={options:v({},e.record.options||{},t.options||{})},Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(a)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(a)).forEach(function(e){Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(a,e))}),r=i,[4,m.update({filterByTk:e.record.name,values:r})];case 6:throw Error("Edit mode requires record.name; got ".concat(JSON.stringify(e.record)));case 7:return[3,9];case 8:return h(!1),[7];case 9:return[2]}})})()});return s().createElement(o.DrawerFormLayout,{title:n("create"===e.mode?"Add new":"Edit"),onSubmit:A,submitting:b,submitText:n("Submit"),cancelText:n("Cancel")},s().createElement(l.Form,{form:d,layout:"vertical",initialValues:O},s().createElement(l.Form.Item,{name:"name",label:n("Channel name"),extra:n("Randomly generated and can not be modified. Support letters, numbers and underscores, must start with an letter."),rules:[{required:!0,message:n("The field value is required")}]},s().createElement(l.Input,{disabled:!0})),s().createElement(l.Form.Item,{name:"title",label:n("Channel display name"),rules:[{required:!0,message:n("The field value is required")}]},s().createElement(l.Input,null)),s().createElement(l.Form.Item,{name:"description",label:n("Description")},s().createElement(l.Input.TextArea,{autoSize:{minRows:2}})),s().createElement(l.Form.Item,{name:"notificationType",hidden:!0},s().createElement(l.Input,null)),T?s().createElement(c.Suspense,{fallback:s().createElement(l.Spin,null)},s().createElement(T,null)):null))}function S(){var e,t,n=(0,p.yr)().t,u=(0,p.kj)(),m=(0,i.useFlowContext)(),y=(0,i.useFlowEngine)(),b=l.theme.useToken().token,h=l.App.useApp(),S=h.modal,j=h.message,T=(0,c.useMemo)(function(){return m.api.resource(f.L.channels)},[m.api]),A=m.app.pm.get(d.A),k=(0,c.useMemo)(function(){var e,t,n,r;return null==(r=y.context.dataSourceManager)||null==(n=r.getDataSource)||null==(t=n.call(r,"main"))||null==(e=t.getCollection)?void 0:e.call(t,f.L.channels)},[y]),C=E((0,c.useState)(1),2),P=C[0],x=C[1],I=E((0,c.useState)(o.DEFAULT_PAGE_SIZE),2),F=I[0],D=I[1],_=E((0,c.useState)([]),2),M=_[0],z=_[1],q=E((0,c.useState)(void 0),2),N=q[0],R=q[1],B=(0,a.useRequest)(function(){return g(function(){return w(this,function(e){switch(e.label){case 0:return[4,T.list(v({page:P,pageSize:F,sort:["createdAt"]},N?{filter:N}:{}))];case 1:var t,n,r,o,i;return[2,{records:o=Array.isArray(r=null==(n=null==(t=e.sent())?void 0:t.data)?void 0:n.data)?r:Array.isArray(null==r?void 0:r.data)?r.data:[],total:(i=(null==n?void 0:n.meta)||(null==r?void 0:r.meta)||{}).count||i.total||o.length}]}})})()},{refreshDeps:[P,F,N]}),L=B.data,G=B.loading,K=B.refresh,U=(0,a.useMemoizedFn)(function(e,t){if(t!==F){D(t),x(1);return}x(e)}),V=(0,c.useMemo)(function(){return A?Array.from(A.channelTypes.getEntities()).map(function(e){return E(e,2)[1]}):[]},[A]),$=(0,a.useMemoizedFn)(function(e){if(!e)return"";var t=V.find(function(t){return t.type===e});return u((null==t?void 0:t.title)||e)}),J=(0,a.useMemoizedFn)(function(e,t,n){m.viewer.drawer({width:"50%",closable:!0,content:function(){return s().createElement(O,{mode:e,notificationType:t,plugin:A,record:n,onSubmitted:function(){return K()}})}})}),Z=(0,a.useMemoizedFn)(function(e){S.confirm({title:n("Delete"),content:n("Are you sure you want to delete it?"),onOk:function(){return g(function(){return w(this,function(t){switch(t.label){case 0:return[4,T.destroy({filterByTk:e})];case 1:return t.sent(),z([]),K(),[2]}})})()}})}),H=(null==(t=m.api)||null==(e=t.auth)?void 0:e.locale)==="zh-CN"?"https://docs-cn.nocobase.com/handbook/notification-manager":"https://docs.nocobase.com/handbook/notification-manager",Q=(0,c.useMemo)(function(){return V.filter(function(e){var t;return(null==(t=e.meta)?void 0:t.creatable)!==!1})},[V]),W=(0,c.useMemo)(function(){return 0===Q.length?{items:[{key:"__empty__",label:s().createElement(l.Empty,{image:l.Empty.PRESENTED_IMAGE_SIMPLE,description:s().createElement(s().Fragment,null,n("No channel enabled yet"),s().createElement("br",null),s().createElement("a",{target:"_blank",href:H,rel:"noreferrer"},n("View documentation")))})}]}:{items:Q.map(function(e){return{key:e.type,label:u(e.title),onClick:function(){return J("create",e.type)}}})}},[Q,u,H,J,n]),X=(0,c.useMemo)(function(){return[{title:n("Channel display name"),dataIndex:"title",ellipsis:!0,render:function(e){return e?u(e):""}},{title:n("Channel name"),dataIndex:"name",ellipsis:!0},{title:n("Description"),dataIndex:"description",ellipsis:!0,render:function(e){return e?u(e):""}},{title:n("Notification type"),dataIndex:"notificationType",render:function(e){return e?s().createElement(l.Tag,null,$(e)):null}},{title:n("Actions"),width:160,render:function(e,t){var r,o;return s().createElement(l.Space,null,(null==(r=t.meta)?void 0:r.editable)===!1?null:s().createElement("a",{onClick:function(){if(t.notificationType){if(!(null==A?void 0:A.channelTypes.get(t.notificationType)))return void j.error(n("Notification type {{type}} is not registered.").replace("{{type}}",t.notificationType));J("edit",t.notificationType,t)}}},n("Edit")),(null==(o=t.meta)?void 0:o.deletable)===!1?null:s().createElement("a",{onClick:function(){return Z(t.name)}},n("Delete")))}}]},[$,u,Z,j,J,A,n]);return s().createElement(l.Card,{variant:"borderless"},s().createElement(l.Flex,{justify:"space-between",style:{marginBottom:b.margin}},s().createElement(o.CollectionFilter,{collection:k,onChange:R,t:u}),s().createElement(l.Space,null,s().createElement(l.Button,{icon:s().createElement(r.ReloadOutlined,null),onClick:function(){return K()}},n("Refresh")),s().createElement(l.Button,{icon:s().createElement(r.DeleteOutlined,null),disabled:!M.length,onClick:function(){return Z(M)}},n("Delete")),s().createElement(l.Dropdown,{menu:W},s().createElement(l.Button,{type:"primary",icon:s().createElement(r.PlusOutlined,null)},n("Add new")," ",s().createElement(r.DownOutlined,null))))),s().createElement(o.Table,{rowKey:"name",loading:G,columns:X,dataSource:(null==L?void 0:L.records)||[],rowSelection:{selectedRowKeys:M,onChange:z},pagination:{current:P,pageSize:F,total:(null==L?void 0:L.total)||0,onChange:U}}))}function j(){var e=(0,i.useFlowContext)(),t=(0,p.kj)(),n=e.app.pm.get(d.A),r=(0,c.useMemo)(function(){var e=(0,y.k)(n,t);return[(0,y.N)(m,e)]},[n,t]);return s().createElement(o.ExtendCollectionsProvider,{collections:r},s().createElement(S,null))}},705:function(e,t,n){function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function i(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function a(e,t){return e?Array.from(e.channelTypes.getEntities()).map(function(e){var n=(function(e){if(Array.isArray(e))return e}(e)||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(e)||function(e){if(e){if("string"==typeof e)return r(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return r(e,2)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[1];return{label:t(n.title),value:n.type}}):[]}function l(e,t){return i(o({},e),{fields:e.fields.map(function(e){return(null==e?void 0:e.name)==="notificationType"&&e.uiSchema?i(o({},e),{uiSchema:i(o({},e.uiSchema),{enum:t})}):e})})}n.d(t,{N:function(){return l},k:function(){return a}})}}]);
|