-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Expand file tree
/
Copy pathactivities-response.dto.ts
More file actions
490 lines (399 loc) · 15.1 KB
/
activities-response.dto.ts
File metadata and controls
490 lines (399 loc) · 15.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { StepFilterDto } from '@novu/application-generic';
import {
DaysEnum,
DigestTypeEnum,
DigestUnitEnum,
ExecutionDetailsSourceEnum,
ExecutionDetailsStatusEnum,
MessageTemplateDto,
MonthlyTypeEnum,
OrdinalEnum,
OrdinalValueEnum,
ProvidersIdEnum,
ProvidersIdEnumConst,
ResourceOriginEnum,
SeverityLevelEnum,
StepTypeEnum,
TriggerTypeEnum,
} from '@novu/shared';
import { IsArray, IsEnum, IsNumber, IsOptional, IsString } from 'class-validator';
export class DigestTimedConfigDto {
@ApiPropertyOptional({ description: 'Time at which the digest is triggered' })
@IsOptional()
@IsString()
atTime?: string;
@ApiPropertyOptional({
description: 'Days of the week for the digest',
type: 'array',
items: {
type: 'string',
enum: Object.values(DaysEnum),
},
enumName: 'DaysEnum',
})
@IsOptional()
@IsArray()
@IsEnum(DaysEnum, { each: true })
weekDays?: DaysEnum[];
@ApiPropertyOptional({ description: 'Specific days of the month for the digest', type: [Number] })
@IsOptional()
@IsArray()
@IsNumber({}, { each: true })
monthDays?: number[];
@ApiPropertyOptional({
description: 'Ordinal position for the digest',
enum: [...Object.values(OrdinalEnum)],
enumName: 'OrdinalEnum',
})
@IsOptional()
@IsEnum(OrdinalEnum)
ordinal?: OrdinalEnum;
@ApiPropertyOptional({
description: 'Value of the ordinal',
enum: [...Object.values(OrdinalValueEnum)],
enumName: 'OrdinalValueEnum',
})
@IsOptional()
@IsEnum(OrdinalValueEnum)
ordinalValue?: OrdinalValueEnum;
@ApiPropertyOptional({
description: 'Type of monthly schedule',
enum: [...Object.values(MonthlyTypeEnum)],
enumName: 'MonthlyTypeEnum',
})
@IsOptional()
@IsEnum(MonthlyTypeEnum)
monthlyType?: MonthlyTypeEnum;
@ApiPropertyOptional({ description: 'Cron expression for scheduling' })
@IsOptional()
@IsString()
cronExpression?: string;
@ApiPropertyOptional({ description: 'Until date for scheduling' })
@IsOptional()
@IsString()
untilDate?: string;
}
export class DigestMetadataDto {
@ApiPropertyOptional({ description: 'Optional key for the digest' })
digestKey?: string;
@ApiPropertyOptional({ description: 'Amount for the digest', type: Number })
amount?: number;
@ApiPropertyOptional({ description: 'Unit of the digest', enum: DigestUnitEnum })
unit?: DigestUnitEnum;
@ApiProperty({
enum: [...Object.values(DigestTypeEnum)],
enumName: 'DigestTypeEnum',
description: 'The Digest Type',
type: String,
})
type: DigestTypeEnum;
@ApiPropertyOptional({
type: 'array',
items: {
type: 'object',
additionalProperties: true,
},
description: 'Optional array of events associated with the digest, represented as key-value pairs',
})
events?: Record<string, unknown>[];
// Properties for Regular Digest
@ApiPropertyOptional({
description: 'Regular digest: Indicates if backoff is enabled for the regular digest',
type: Boolean,
})
backoff?: boolean;
@ApiPropertyOptional({ description: 'Regular digest: Amount for backoff', type: Number })
backoffAmount?: number;
@ApiPropertyOptional({
description: 'Regular digest: Unit for backoff',
enum: [...Object.values(DigestUnitEnum)],
enumName: 'DigestUnitEnum',
})
backoffUnit?: DigestUnitEnum;
@ApiPropertyOptional({ description: 'Regular digest: Indicates if the digest should update', type: Boolean })
updateMode?: boolean;
// Properties for Timed Digest
@ApiPropertyOptional({ description: 'Configuration for timed digest', type: () => DigestTimedConfigDto })
timed?: DigestTimedConfigDto;
}
export class ActivityNotificationStepResponseDto {
@ApiProperty({ description: 'Unique identifier of the step', type: String })
_id: string;
@ApiProperty({ description: 'Whether the step is active or not', type: Boolean })
active: boolean;
@ApiPropertyOptional({ description: 'Reply callback settings', type: Object })
replyCallback?: {
active: boolean;
url: string;
};
@ApiPropertyOptional({ description: 'Control variables', type: Object })
controlVariables?: Record<string, unknown>;
@ApiPropertyOptional({ description: 'Metadata for the workflow step', type: Object })
metadata?: any; // Adjust the type based on your actual metadata structure
@ApiPropertyOptional({ description: 'Step issues', type: Object })
issues?: any; // Adjust the type based on your actual issues structure
@ApiProperty({ description: 'Filter criteria for the step', isArray: true, type: StepFilterDto })
filters: StepFilterDto[];
@ApiPropertyOptional({ description: 'Optional template for the step', type: MessageTemplateDto })
template?: MessageTemplateDto;
@ApiPropertyOptional({ description: 'Variants of the step', type: [ActivityNotificationStepResponseDto] })
variants?: ActivityNotificationStepResponseDto[]; // Assuming variants are the same type
@ApiProperty({ description: 'The identifier for the template associated with this step', type: String })
_templateId: string;
@ApiPropertyOptional({ description: 'The name of the step', type: String })
name?: string;
@ApiPropertyOptional({ description: 'The unique identifier for the parent step', type: String })
_parentId?: string | null;
}
// Activity Notification Execution Detail Response DTO
export class ActivityNotificationExecutionDetailResponseDto {
@ApiProperty({ description: 'Unique identifier of the execution detail', type: String })
_id: string;
@ApiPropertyOptional({ description: 'Creation time of the execution detail', type: String })
createdAt?: string;
@ApiProperty({
enum: [...Object.values(ExecutionDetailsStatusEnum)],
enumName: 'ExecutionDetailsStatusEnum',
description: 'Status of the execution detail',
type: String,
})
status: ExecutionDetailsStatusEnum;
@ApiProperty({ description: 'Detailed information about the execution', type: String })
detail: string;
@ApiProperty({ description: 'Whether the execution is a retry or not', type: Boolean })
isRetry: boolean;
@ApiProperty({ description: 'Whether the execution is a test or not', type: Boolean })
isTest: boolean;
@ApiPropertyOptional({
enum: [...new Set([...Object.values(ProvidersIdEnumConst).flatMap((enumObj) => Object.values(enumObj))])],
enumName: 'ProvidersIdEnum',
description: 'Provider ID of the execution',
type: String,
})
@IsString()
@IsOptional()
@IsEnum(ProvidersIdEnumConst)
providerId?: ProvidersIdEnum;
@ApiPropertyOptional({ description: 'Raw data of the execution', type: String })
raw?: string | null;
@ApiProperty({
enum: [...Object.values(ExecutionDetailsSourceEnum)],
enumName: 'ExecutionDetailsSourceEnum',
description: 'Source of the execution detail',
type: String,
})
@IsString()
@IsEnum(ExecutionDetailsSourceEnum)
source: ExecutionDetailsSourceEnum;
}
// Activity Notification Job Response DTO
export class ActivityNotificationJobResponseDto {
@ApiProperty({ description: 'Unique identifier of the job', type: String })
_id: string;
@ApiProperty({ description: 'Type of the job', type: String })
type: StepTypeEnum;
@ApiPropertyOptional({
description: 'Optional digest for the job, including metadata and events',
type: DigestMetadataDto,
})
digest?: DigestMetadataDto;
@ApiProperty({
description: 'Execution details of the job',
type: [ActivityNotificationExecutionDetailResponseDto],
})
executionDetails: ActivityNotificationExecutionDetailResponseDto[];
@ApiProperty({
description: 'Step details of the job',
type: ActivityNotificationStepResponseDto,
})
step: ActivityNotificationStepResponseDto;
@ApiPropertyOptional({
description: 'Optional context object for additional error details.',
type: Object,
additionalProperties: true,
example: {
workflowId: 'some_wf_id',
stepId: 'some_wf_id',
},
})
overrides?: Record<string, unknown>;
@ApiPropertyOptional({ description: 'Optional payload for the job', type: Object })
payload?: Record<string, unknown>;
@ApiProperty({
enum: [...new Set([...Object.values(ProvidersIdEnumConst).flatMap((enumObj) => Object.values(enumObj))])],
enumName: 'ProvidersIdEnum',
description: 'Provider ID of the job',
type: String, // Explicit type reference for enum
})
providerId: ProvidersIdEnum;
@ApiProperty({ description: 'Status of the job', type: String })
status: string;
@ApiPropertyOptional({ description: 'Updated time of the notification', type: String })
updatedAt?: string;
@ApiPropertyOptional({
description: 'The number of times the digest/delay job has been extended to align with the subscribers schedule',
type: Number,
})
scheduleExtensionsCount?: number;
}
// Activity Notification Subscriber Response DTO
export class ActivityNotificationSubscriberResponseDto {
@ApiPropertyOptional({ description: 'First name of the subscriber', type: String })
firstName?: string;
@ApiProperty({ description: 'External unique identifier of the subscriber', type: String })
subscriberId: string;
@ApiProperty({ description: 'Internal to Novu unique identifier of the subscriber', type: String })
_id: string;
@ApiPropertyOptional({ description: 'Last name of the subscriber', type: String })
lastName?: string;
@ApiPropertyOptional({ description: 'Email address of the subscriber', type: String })
email?: string;
@ApiPropertyOptional({ description: 'Phone number of the subscriber', type: String })
phone?: string;
}
// Notification Trigger Variable DTO
export class NotificationTriggerVariable {
@ApiProperty({ description: 'Name of the variable', type: String })
name: string;
}
export class NotificationTriggerDto {
@ApiProperty({
enum: TriggerTypeEnum,
description: 'Type of the trigger',
type: String, // Explicit type reference for enum
})
type: TriggerTypeEnum;
@ApiProperty({ description: 'Identifier of the trigger', type: String })
identifier: string;
@ApiProperty({
description: 'Variables of the trigger',
type: [NotificationTriggerVariable],
})
variables: NotificationTriggerVariable[];
@ApiPropertyOptional({
description: 'Subscriber variables of the trigger',
type: [NotificationTriggerVariable],
})
subscriberVariables?: NotificationTriggerVariable[];
}
// Activity Notification Template Response DTO
export class ActivityNotificationTemplateResponseDto {
@ApiPropertyOptional({ description: 'Unique identifier of the template', type: String })
_id?: string;
@ApiProperty({ description: 'Name of the template', type: String })
name: string;
@ApiProperty({
enum: [...Object.values(ResourceOriginEnum)],
enumName: 'ResourceOriginEnum',
description: 'Origin of the workflow',
type: String,
})
@IsString()
@IsEnum(ResourceOriginEnum)
origin?: ResourceOriginEnum;
@ApiProperty({
description: 'Triggers of the template',
type: [NotificationTriggerDto],
})
triggers: NotificationTriggerDto[];
}
export class ActivityTopicDto {
@ApiProperty({ description: 'Internal Topic ID of the notification', type: String })
_topicId: string;
@ApiProperty({ description: 'Topic Key of the notification', type: String })
topicKey: string;
}
// Activity Notification Response DTO
export class ActivityNotificationResponseDto {
@ApiPropertyOptional({ description: 'Unique identifier of the notification', type: String })
_id?: string;
@ApiProperty({ description: 'Environment ID of the notification', type: String })
_environmentId: string;
@ApiProperty({ description: 'Organization ID of the notification', type: String })
_organizationId: string;
@ApiProperty({ description: 'Subscriber ID of the notification', type: String })
_subscriberId: string; // Added to align with NotificationEntity
@ApiProperty({ description: 'Transaction ID of the notification', type: String })
transactionId: string;
@ApiPropertyOptional({ description: 'Template ID of the notification', type: String })
_templateId?: string; // Added to align with NotificationEntity
@ApiPropertyOptional({ description: 'Digested Notification ID', type: String })
_digestedNotificationId?: string; // Added to align with NotificationEntity
@ApiPropertyOptional({ description: 'Creation time of the notification', type: String })
createdAt?: string;
@ApiPropertyOptional({ description: 'Last updated time of the notification', type: String })
updatedAt?: string; // Added to align with NotificationEntity
@ApiPropertyOptional({
description: 'Channels of the notification',
enum: [...Object.values(StepTypeEnum)],
enumName: 'StepTypeEnum',
isArray: true,
type: String,
})
channels?: StepTypeEnum[];
@ApiPropertyOptional({
description: 'Subscriber of the notification',
type: ActivityNotificationSubscriberResponseDto,
})
subscriber?: ActivityNotificationSubscriberResponseDto;
@ApiPropertyOptional({
description: 'Template of the notification',
type: ActivityNotificationTemplateResponseDto,
})
template?: ActivityNotificationTemplateResponseDto;
@ApiPropertyOptional({
description: 'Jobs of the notification',
type: [ActivityNotificationJobResponseDto],
})
jobs?: ActivityNotificationJobResponseDto[];
@ApiPropertyOptional({
description: 'Payload of the notification',
type: Object,
additionalProperties: true,
})
payload?: Record<string, unknown>; // Added to align with NotificationEntity
@ApiPropertyOptional({
description: 'Tags associated with the notification',
type: [String],
})
tags?: string[]; // Added to align with NotificationEntity
@ApiPropertyOptional({
description: 'Controls associated with the notification',
type: Object,
additionalProperties: true,
})
controls?: Record<string, unknown>; // Added to align with NotificationEntity
@ApiPropertyOptional({
description: 'To field for subscriber definition',
type: Object,
additionalProperties: true,
})
to?: Record<string, unknown>; // Added to align with NotificationEntity
@ApiPropertyOptional({ description: 'Topics of the notification', type: [ActivityTopicDto] })
topics?: ActivityTopicDto[];
@ApiPropertyOptional({
description: 'Severity of the notification',
enum: [...Object.values(SeverityLevelEnum)],
enumName: 'SeverityLevelEnum',
})
severity: SeverityLevelEnum;
@ApiPropertyOptional({ description: 'Criticality of the notification', type: Boolean })
critical?: boolean;
@ApiPropertyOptional({ description: 'Context (single or multi) in which the notification was sent', type: [String] })
contextKeys?: string[];
}
// Activities Response DTO
export class ActivitiesResponseDto {
@ApiProperty({ description: 'Indicates if there are more activities in the result set', type: Boolean })
hasMore: boolean;
@ApiProperty({
description: 'Array of activity notifications',
type: [ActivityNotificationResponseDto],
})
data: ActivityNotificationResponseDto[];
@ApiProperty({ description: 'Page size of the activities', type: Number })
pageSize: number;
@ApiProperty({ description: 'Current page of the activities', type: Number })
page: number;
}