@oneuptime/common 8.0.5312 → 8.0.5329
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/Models/DatabaseModels/GlobalConfig.ts +90 -0
- package/Models/DatabaseModels/Index.ts +4 -0
- package/Models/DatabaseModels/Project.ts +27 -0
- package/Models/DatabaseModels/UserNotificationRule.ts +48 -0
- package/Models/DatabaseModels/UserNotificationSetting.ts +16 -0
- package/Models/DatabaseModels/UserOnCallLogTimeline.ts +48 -0
- package/Models/DatabaseModels/UserWhatsApp.ts +288 -0
- package/Models/DatabaseModels/WhatsAppLog.ts +884 -0
- package/Server/API/NotificationAPI.ts +4 -4
- package/Server/API/ProjectSSO.ts +41 -33
- package/Server/API/ShortLinkAPI.ts +33 -25
- package/Server/API/UserCallAPI.ts +82 -73
- package/Server/API/UserEmailAPI.ts +82 -73
- package/Server/API/UserOnCallLogTimelineAPI.ts +227 -214
- package/Server/API/UserPushAPI.ts +177 -169
- package/Server/API/UserSmsAPI.ts +82 -73
- package/Server/API/UserWhatsAppAPI.ts +136 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1759838763506-MigrationName.ts +103 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1759839342566-MigrationName.ts +71 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +4 -0
- package/Server/Services/Index.ts +4 -0
- package/Server/Services/MonitorService.ts +32 -4
- package/Server/Services/OnCallDutyPolicyEscalationRuleScheduleService.ts +36 -4
- package/Server/Services/OnCallDutyPolicyEscalationRuleTeamService.ts +34 -4
- package/Server/Services/OnCallDutyPolicyEscalationRuleUserService.ts +34 -4
- package/Server/Services/OnCallDutyPolicyScheduleService.ts +47 -6
- package/Server/Services/ProbeService.ts +17 -2
- package/Server/Services/UserNotificationRuleService.ts +258 -7
- package/Server/Services/UserNotificationSettingService.ts +60 -0
- package/Server/Services/UserWhatsAppService.ts +203 -0
- package/Server/Services/WhatsAppLogService.ts +15 -0
- package/Server/Services/WhatsAppService.ts +141 -0
- package/Server/Types/Workflow/Components/BaseModel/OnTriggerBaseModel.ts +17 -5
- package/Server/Types/Workflow/Components/Webhook.ts +2 -2
- package/Server/Utils/StartServer.ts +57 -31
- package/Server/Utils/WhatsAppTemplateUtil.ts +247 -0
- package/Types/Icon/IconProp.ts +1 -0
- package/Types/WhatsApp/WhatsAppMessage.ts +12 -0
- package/Types/WhatsApp/WhatsAppTemplates.ts +197 -0
- package/Types/WhatsAppStatus.ts +8 -0
- package/UI/Components/Icon/Icon.tsx +12 -0
- package/build/dist/Models/DatabaseModels/GlobalConfig.js +98 -0
- package/build/dist/Models/DatabaseModels/GlobalConfig.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Index.js +4 -0
- package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Project.js +29 -0
- package/build/dist/Models/DatabaseModels/Project.js.map +1 -1
- package/build/dist/Models/DatabaseModels/UserNotificationRule.js +48 -0
- package/build/dist/Models/DatabaseModels/UserNotificationRule.js.map +1 -1
- package/build/dist/Models/DatabaseModels/UserNotificationSetting.js +18 -0
- package/build/dist/Models/DatabaseModels/UserNotificationSetting.js.map +1 -1
- package/build/dist/Models/DatabaseModels/UserOnCallLogTimeline.js +48 -0
- package/build/dist/Models/DatabaseModels/UserOnCallLogTimeline.js.map +1 -1
- package/build/dist/Models/DatabaseModels/UserWhatsApp.js +308 -0
- package/build/dist/Models/DatabaseModels/UserWhatsApp.js.map +1 -0
- package/build/dist/Models/DatabaseModels/WhatsAppLog.js +911 -0
- package/build/dist/Models/DatabaseModels/WhatsAppLog.js.map +1 -0
- package/build/dist/Server/API/NotificationAPI.js +2 -2
- package/build/dist/Server/API/NotificationAPI.js.map +1 -1
- package/build/dist/Server/API/ProjectSSO.js +26 -21
- package/build/dist/Server/API/ProjectSSO.js.map +1 -1
- package/build/dist/Server/API/ShortLinkAPI.js +17 -12
- package/build/dist/Server/API/ShortLinkAPI.js.map +1 -1
- package/build/dist/Server/API/UserCallAPI.js +54 -44
- package/build/dist/Server/API/UserCallAPI.js.map +1 -1
- package/build/dist/Server/API/UserEmailAPI.js +54 -44
- package/build/dist/Server/API/UserEmailAPI.js.map +1 -1
- package/build/dist/Server/API/UserOnCallLogTimelineAPI.js +142 -127
- package/build/dist/Server/API/UserOnCallLogTimelineAPI.js.map +1 -1
- package/build/dist/Server/API/UserPushAPI.js +111 -96
- package/build/dist/Server/API/UserPushAPI.js.map +1 -1
- package/build/dist/Server/API/UserSmsAPI.js +54 -44
- package/build/dist/Server/API/UserSmsAPI.js.map +1 -1
- package/build/dist/Server/API/UserWhatsAppAPI.js +76 -0
- package/build/dist/Server/API/UserWhatsAppAPI.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1759838763506-MigrationName.js +41 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1759838763506-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1759839342566-MigrationName.js +30 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1759839342566-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +4 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Services/Index.js +4 -0
- package/build/dist/Server/Services/Index.js.map +1 -1
- package/build/dist/Server/Services/MonitorService.js +23 -2
- package/build/dist/Server/Services/MonitorService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleScheduleService.js +29 -6
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleScheduleService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleTeamService.js +27 -6
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleTeamService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleUserService.js +26 -5
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleUserService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyScheduleService.js +34 -3
- package/build/dist/Server/Services/OnCallDutyPolicyScheduleService.js.map +1 -1
- package/build/dist/Server/Services/ProbeService.js +12 -1
- package/build/dist/Server/Services/ProbeService.js.map +1 -1
- package/build/dist/Server/Services/UserNotificationRuleService.js +196 -19
- package/build/dist/Server/Services/UserNotificationRuleService.js.map +1 -1
- package/build/dist/Server/Services/UserNotificationSettingService.js +45 -0
- package/build/dist/Server/Services/UserNotificationSettingService.js.map +1 -1
- package/build/dist/Server/Services/UserWhatsAppService.js +179 -0
- package/build/dist/Server/Services/UserWhatsAppService.js.map +1 -0
- package/build/dist/Server/Services/WhatsAppLogService.js +13 -0
- package/build/dist/Server/Services/WhatsAppLogService.js.map +1 -0
- package/build/dist/Server/Services/WhatsAppService.js +103 -0
- package/build/dist/Server/Services/WhatsAppService.js.map +1 -0
- package/build/dist/Server/Types/Workflow/Components/BaseModel/OnTriggerBaseModel.js +14 -4
- package/build/dist/Server/Types/Workflow/Components/BaseModel/OnTriggerBaseModel.js.map +1 -1
- package/build/dist/Server/Types/Workflow/Components/Webhook.js +2 -2
- package/build/dist/Server/Types/Workflow/Components/Webhook.js.map +1 -1
- package/build/dist/Server/Utils/StartServer.js +41 -19
- package/build/dist/Server/Utils/StartServer.js.map +1 -1
- package/build/dist/Server/Utils/WhatsAppTemplateUtil.js +124 -0
- package/build/dist/Server/Utils/WhatsAppTemplateUtil.js.map +1 -0
- package/build/dist/Types/Icon/IconProp.js +1 -0
- package/build/dist/Types/Icon/IconProp.js.map +1 -1
- package/build/dist/Types/WhatsApp/WhatsAppMessage.js +2 -0
- package/build/dist/Types/WhatsApp/WhatsAppMessage.js.map +1 -0
- package/build/dist/Types/WhatsApp/WhatsAppTemplates.js +118 -0
- package/build/dist/Types/WhatsApp/WhatsAppTemplates.js.map +1 -0
- package/build/dist/Types/WhatsAppStatus.js +9 -0
- package/build/dist/Types/WhatsAppStatus.js.map +1 -0
- package/build/dist/UI/Components/Icon/Icon.js +6 -0
- package/build/dist/UI/Components/Icon/Icon.js.map +1 -1
- package/package.json +1 -1
|
@@ -262,6 +262,96 @@ export default class GlobalConfig extends GlobalConfigModel {
|
|
|
262
262
|
})
|
|
263
263
|
public twilioSecondaryPhoneNumbers?: string = undefined; // phone numbers separated by comma
|
|
264
264
|
|
|
265
|
+
@ColumnAccessControl({
|
|
266
|
+
create: [],
|
|
267
|
+
read: [],
|
|
268
|
+
update: [],
|
|
269
|
+
})
|
|
270
|
+
@TableColumn({
|
|
271
|
+
type: TableColumnType.VeryLongText,
|
|
272
|
+
title: "Meta WhatsApp Access Token",
|
|
273
|
+
description:
|
|
274
|
+
"Access token generated from Meta for sending WhatsApp messages.",
|
|
275
|
+
})
|
|
276
|
+
@Column({
|
|
277
|
+
type: ColumnType.VeryLongText,
|
|
278
|
+
nullable: true,
|
|
279
|
+
unique: true,
|
|
280
|
+
})
|
|
281
|
+
public metaWhatsAppAccessToken?: string = undefined;
|
|
282
|
+
|
|
283
|
+
@ColumnAccessControl({
|
|
284
|
+
create: [],
|
|
285
|
+
read: [],
|
|
286
|
+
update: [],
|
|
287
|
+
})
|
|
288
|
+
@TableColumn({
|
|
289
|
+
type: TableColumnType.ShortText,
|
|
290
|
+
title: "Meta WhatsApp Phone Number ID",
|
|
291
|
+
description: "The WhatsApp Business phone number ID from Meta.",
|
|
292
|
+
})
|
|
293
|
+
@Column({
|
|
294
|
+
type: ColumnType.ShortText,
|
|
295
|
+
length: ColumnLength.ShortText,
|
|
296
|
+
nullable: true,
|
|
297
|
+
unique: true,
|
|
298
|
+
})
|
|
299
|
+
public metaWhatsAppPhoneNumberId?: string = undefined;
|
|
300
|
+
|
|
301
|
+
@ColumnAccessControl({
|
|
302
|
+
create: [],
|
|
303
|
+
read: [],
|
|
304
|
+
update: [],
|
|
305
|
+
})
|
|
306
|
+
@TableColumn({
|
|
307
|
+
type: TableColumnType.ShortText,
|
|
308
|
+
title: "Meta WhatsApp Business Account ID",
|
|
309
|
+
description: "Business account ID associated with your WhatsApp setup.",
|
|
310
|
+
})
|
|
311
|
+
@Column({
|
|
312
|
+
type: ColumnType.ShortText,
|
|
313
|
+
length: ColumnLength.ShortText,
|
|
314
|
+
nullable: true,
|
|
315
|
+
unique: true,
|
|
316
|
+
})
|
|
317
|
+
public metaWhatsAppBusinessAccountId?: string = undefined;
|
|
318
|
+
|
|
319
|
+
@ColumnAccessControl({
|
|
320
|
+
create: [],
|
|
321
|
+
read: [],
|
|
322
|
+
update: [],
|
|
323
|
+
})
|
|
324
|
+
@TableColumn({
|
|
325
|
+
type: TableColumnType.ShortText,
|
|
326
|
+
title: "Meta WhatsApp App ID",
|
|
327
|
+
description:
|
|
328
|
+
"Facebook App ID used for the WhatsApp Business Platform integration.",
|
|
329
|
+
})
|
|
330
|
+
@Column({
|
|
331
|
+
type: ColumnType.ShortText,
|
|
332
|
+
length: ColumnLength.ShortText,
|
|
333
|
+
nullable: true,
|
|
334
|
+
unique: true,
|
|
335
|
+
})
|
|
336
|
+
public metaWhatsAppAppId?: string = undefined;
|
|
337
|
+
|
|
338
|
+
@ColumnAccessControl({
|
|
339
|
+
create: [],
|
|
340
|
+
read: [],
|
|
341
|
+
update: [],
|
|
342
|
+
})
|
|
343
|
+
@TableColumn({
|
|
344
|
+
type: TableColumnType.VeryLongText,
|
|
345
|
+
title: "Meta WhatsApp App Secret",
|
|
346
|
+
description: "Facebook App Secret for the WhatsApp Business Platform.",
|
|
347
|
+
})
|
|
348
|
+
@Column({
|
|
349
|
+
type: ColumnType.VeryLongText,
|
|
350
|
+
nullable: true,
|
|
351
|
+
unique: true,
|
|
352
|
+
})
|
|
353
|
+
public metaWhatsAppAppSecret?: string = undefined;
|
|
354
|
+
|
|
265
355
|
@ColumnAccessControl({
|
|
266
356
|
create: [],
|
|
267
357
|
read: [],
|
|
@@ -100,6 +100,7 @@ import ServiceCopilotCodeRepository from "./ServiceCopilotCodeRepository";
|
|
|
100
100
|
import ShortLink from "./ShortLink";
|
|
101
101
|
// SMS
|
|
102
102
|
import SmsLog from "./SmsLog";
|
|
103
|
+
import WhatsAppLog from "./WhatsAppLog";
|
|
103
104
|
import PushNotificationLog from "./PushNotificationLog";
|
|
104
105
|
import WorkspaceNotificationLog from "./WorkspaceNotificationLog";
|
|
105
106
|
// Status Page
|
|
@@ -131,6 +132,7 @@ import UserCall from "./UserCall";
|
|
|
131
132
|
// Notification Methods
|
|
132
133
|
import UserEmail from "./UserEmail";
|
|
133
134
|
import UserPush from "./UserPush";
|
|
135
|
+
import UserWhatsApp from "./UserWhatsApp";
|
|
134
136
|
// User Notification Rules
|
|
135
137
|
import UserNotificationRule from "./UserNotificationRule";
|
|
136
138
|
import UserNotificationSetting from "./UserNotificationSetting";
|
|
@@ -297,6 +299,7 @@ const AllModelTypes: Array<{
|
|
|
297
299
|
StatusPageOwnerUser,
|
|
298
300
|
|
|
299
301
|
SmsLog,
|
|
302
|
+
WhatsAppLog,
|
|
300
303
|
PushNotificationLog,
|
|
301
304
|
WorkspaceNotificationLog,
|
|
302
305
|
CallLog,
|
|
@@ -306,6 +309,7 @@ const AllModelTypes: Array<{
|
|
|
306
309
|
UserSms,
|
|
307
310
|
UserCall,
|
|
308
311
|
UserPush,
|
|
312
|
+
UserWhatsApp,
|
|
309
313
|
|
|
310
314
|
UserNotificationRule,
|
|
311
315
|
UserOnCallLog,
|
|
@@ -798,6 +798,33 @@ export default class Project extends TenantModel {
|
|
|
798
798
|
})
|
|
799
799
|
public enableSmsNotifications?: boolean = undefined;
|
|
800
800
|
|
|
801
|
+
@ColumnAccessControl({
|
|
802
|
+
create: [],
|
|
803
|
+
read: [
|
|
804
|
+
Permission.ProjectOwner,
|
|
805
|
+
Permission.ProjectAdmin,
|
|
806
|
+
Permission.ProjectMember,
|
|
807
|
+
Permission.ReadProject,
|
|
808
|
+
Permission.UnAuthorizedSsoUser,
|
|
809
|
+
Permission.ProjectUser,
|
|
810
|
+
],
|
|
811
|
+
update: [Permission.ProjectOwner, Permission.ManageProjectBilling],
|
|
812
|
+
})
|
|
813
|
+
@TableColumn({
|
|
814
|
+
required: true,
|
|
815
|
+
isDefaultValueColumn: true,
|
|
816
|
+
type: TableColumnType.Boolean,
|
|
817
|
+
title: "Enable WhatsApp Notifications",
|
|
818
|
+
description: "Enable WhatsApp notifications for this project.",
|
|
819
|
+
defaultValue: false,
|
|
820
|
+
})
|
|
821
|
+
@Column({
|
|
822
|
+
nullable: false,
|
|
823
|
+
default: false,
|
|
824
|
+
type: ColumnType.Boolean,
|
|
825
|
+
})
|
|
826
|
+
public enableWhatsAppNotifications?: boolean = undefined;
|
|
827
|
+
|
|
801
828
|
@ColumnAccessControl({
|
|
802
829
|
create: [],
|
|
803
830
|
read: [
|
|
@@ -6,6 +6,7 @@ import UserCall from "./UserCall";
|
|
|
6
6
|
import UserEmail from "./UserEmail";
|
|
7
7
|
import UserPush from "./UserPush";
|
|
8
8
|
import UserSMS from "./UserSMS";
|
|
9
|
+
import UserWhatsApp from "./UserWhatsApp";
|
|
9
10
|
import BaseModel from "./DatabaseBaseModel/DatabaseBaseModel";
|
|
10
11
|
import Route from "../../Types/API/Route";
|
|
11
12
|
import ColumnAccessControl from "../../Types/Database/AccessControl/ColumnAccessControl";
|
|
@@ -383,6 +384,53 @@ class UserNotificationRule extends BaseModel {
|
|
|
383
384
|
})
|
|
384
385
|
public userSmsId?: ObjectID = undefined;
|
|
385
386
|
|
|
387
|
+
@ColumnAccessControl({
|
|
388
|
+
create: [Permission.CurrentUser],
|
|
389
|
+
read: [Permission.CurrentUser],
|
|
390
|
+
update: [],
|
|
391
|
+
})
|
|
392
|
+
@TableColumn({
|
|
393
|
+
manyToOneRelationColumn: "userWhatsAppId",
|
|
394
|
+
type: TableColumnType.Entity,
|
|
395
|
+
modelType: UserWhatsApp,
|
|
396
|
+
title: "User WhatsApp",
|
|
397
|
+
description:
|
|
398
|
+
"Relation to User WhatsApp Resource in which this object belongs",
|
|
399
|
+
})
|
|
400
|
+
@ManyToOne(
|
|
401
|
+
() => {
|
|
402
|
+
return UserWhatsApp;
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
eager: false,
|
|
406
|
+
nullable: true,
|
|
407
|
+
onDelete: "CASCADE",
|
|
408
|
+
orphanedRowAction: "nullify",
|
|
409
|
+
},
|
|
410
|
+
)
|
|
411
|
+
@JoinColumn({ name: "userWhatsAppId" })
|
|
412
|
+
public userWhatsApp?: UserWhatsApp = undefined;
|
|
413
|
+
|
|
414
|
+
@ColumnAccessControl({
|
|
415
|
+
create: [Permission.CurrentUser],
|
|
416
|
+
read: [Permission.CurrentUser],
|
|
417
|
+
update: [],
|
|
418
|
+
})
|
|
419
|
+
@Index()
|
|
420
|
+
@TableColumn({
|
|
421
|
+
type: TableColumnType.ObjectID,
|
|
422
|
+
required: false,
|
|
423
|
+
canReadOnRelationQuery: true,
|
|
424
|
+
title: "User WhatsApp ID",
|
|
425
|
+
description: "ID of User WhatsApp in which this object belongs",
|
|
426
|
+
})
|
|
427
|
+
@Column({
|
|
428
|
+
type: ColumnType.ObjectID,
|
|
429
|
+
nullable: true,
|
|
430
|
+
transformer: ObjectID.getDatabaseTransformer(),
|
|
431
|
+
})
|
|
432
|
+
public userWhatsAppId?: ObjectID = undefined;
|
|
433
|
+
|
|
386
434
|
@ColumnAccessControl({
|
|
387
435
|
create: [Permission.CurrentUser],
|
|
388
436
|
read: [Permission.CurrentUser],
|
|
@@ -273,6 +273,22 @@ class UserNotificationSetting extends BaseModel {
|
|
|
273
273
|
})
|
|
274
274
|
public alertBySMS?: boolean = undefined;
|
|
275
275
|
|
|
276
|
+
@ColumnAccessControl({
|
|
277
|
+
create: [Permission.CurrentUser],
|
|
278
|
+
read: [Permission.CurrentUser],
|
|
279
|
+
update: [Permission.CurrentUser],
|
|
280
|
+
})
|
|
281
|
+
@TableColumn({
|
|
282
|
+
isDefaultValueColumn: true,
|
|
283
|
+
type: TableColumnType.Boolean,
|
|
284
|
+
defaultValue: false,
|
|
285
|
+
})
|
|
286
|
+
@Column({
|
|
287
|
+
type: ColumnType.Boolean,
|
|
288
|
+
default: false,
|
|
289
|
+
})
|
|
290
|
+
public alertByWhatsApp?: boolean = undefined;
|
|
291
|
+
|
|
276
292
|
@ColumnAccessControl({
|
|
277
293
|
create: [Permission.CurrentUser],
|
|
278
294
|
read: [Permission.CurrentUser],
|
|
@@ -13,6 +13,7 @@ import UserNotificationRule from "./UserNotificationRule";
|
|
|
13
13
|
import UserPush from "./UserPush";
|
|
14
14
|
import UserOnCallLog from "./UserOnCallLog";
|
|
15
15
|
import UserSMS from "./UserSMS";
|
|
16
|
+
import UserWhatsApp from "./UserWhatsApp";
|
|
16
17
|
import BaseModel from "./DatabaseBaseModel/DatabaseBaseModel";
|
|
17
18
|
import Route from "../../Types/API/Route";
|
|
18
19
|
import { PlanType } from "../../Types/Billing/SubscriptionPlan";
|
|
@@ -834,6 +835,53 @@ export default class UserOnCallLogTimeline extends BaseModel {
|
|
|
834
835
|
})
|
|
835
836
|
public userSmsId?: ObjectID = undefined;
|
|
836
837
|
|
|
838
|
+
@ColumnAccessControl({
|
|
839
|
+
create: [],
|
|
840
|
+
read: [Permission.CurrentUser],
|
|
841
|
+
update: [],
|
|
842
|
+
})
|
|
843
|
+
@TableColumn({
|
|
844
|
+
manyToOneRelationColumn: "userWhatsAppId",
|
|
845
|
+
type: TableColumnType.Entity,
|
|
846
|
+
modelType: UserWhatsApp,
|
|
847
|
+
title: "User WhatsApp",
|
|
848
|
+
description:
|
|
849
|
+
"Relation to User WhatsApp Resource in which this object belongs",
|
|
850
|
+
})
|
|
851
|
+
@ManyToOne(
|
|
852
|
+
() => {
|
|
853
|
+
return UserWhatsApp;
|
|
854
|
+
},
|
|
855
|
+
{
|
|
856
|
+
eager: false,
|
|
857
|
+
nullable: true,
|
|
858
|
+
onDelete: "CASCADE",
|
|
859
|
+
orphanedRowAction: "nullify",
|
|
860
|
+
},
|
|
861
|
+
)
|
|
862
|
+
@JoinColumn({ name: "userWhatsAppId" })
|
|
863
|
+
public userWhatsApp?: UserWhatsApp = undefined;
|
|
864
|
+
|
|
865
|
+
@ColumnAccessControl({
|
|
866
|
+
create: [],
|
|
867
|
+
read: [Permission.CurrentUser],
|
|
868
|
+
update: [],
|
|
869
|
+
})
|
|
870
|
+
@Index()
|
|
871
|
+
@TableColumn({
|
|
872
|
+
type: TableColumnType.ObjectID,
|
|
873
|
+
required: false,
|
|
874
|
+
canReadOnRelationQuery: true,
|
|
875
|
+
title: "User WhatsApp ID",
|
|
876
|
+
description: "ID of User WhatsApp in which this object belongs",
|
|
877
|
+
})
|
|
878
|
+
@Column({
|
|
879
|
+
type: ColumnType.ObjectID,
|
|
880
|
+
nullable: true,
|
|
881
|
+
transformer: ObjectID.getDatabaseTransformer(),
|
|
882
|
+
})
|
|
883
|
+
public userWhatsAppId?: ObjectID = undefined;
|
|
884
|
+
|
|
837
885
|
@ColumnAccessControl({
|
|
838
886
|
create: [],
|
|
839
887
|
read: [Permission.CurrentUser],
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import Project from "./Project";
|
|
2
|
+
import User from "./User";
|
|
3
|
+
import BaseModel from "./DatabaseBaseModel/DatabaseBaseModel";
|
|
4
|
+
import Route from "../../Types/API/Route";
|
|
5
|
+
import AllowAccessIfSubscriptionIsUnpaid from "../../Types/Database/AccessControl/AllowAccessIfSubscriptionIsUnpaid";
|
|
6
|
+
import ColumnAccessControl from "../../Types/Database/AccessControl/ColumnAccessControl";
|
|
7
|
+
import TableAccessControl from "../../Types/Database/AccessControl/TableAccessControl";
|
|
8
|
+
import ColumnLength from "../../Types/Database/ColumnLength";
|
|
9
|
+
import ColumnType from "../../Types/Database/ColumnType";
|
|
10
|
+
import CrudApiEndpoint from "../../Types/Database/CrudApiEndpoint";
|
|
11
|
+
import CurrentUserCanAccessRecordBy from "../../Types/Database/CurrentUserCanAccessRecordBy";
|
|
12
|
+
import TableColumn from "../../Types/Database/TableColumn";
|
|
13
|
+
import TableColumnType from "../../Types/Database/TableColumnType";
|
|
14
|
+
import TableMetadata from "../../Types/Database/TableMetadata";
|
|
15
|
+
import TenantColumn from "../../Types/Database/TenantColumn";
|
|
16
|
+
import IconProp from "../../Types/Icon/IconProp";
|
|
17
|
+
import ObjectID from "../../Types/ObjectID";
|
|
18
|
+
import Permission from "../../Types/Permission";
|
|
19
|
+
import Phone from "../../Types/Phone";
|
|
20
|
+
import Text from "../../Types/Text";
|
|
21
|
+
import { Column, Entity, Index, JoinColumn, ManyToOne } from "typeorm";
|
|
22
|
+
|
|
23
|
+
@TenantColumn("projectId")
|
|
24
|
+
@AllowAccessIfSubscriptionIsUnpaid()
|
|
25
|
+
@TableAccessControl({
|
|
26
|
+
create: [Permission.CurrentUser],
|
|
27
|
+
read: [Permission.CurrentUser],
|
|
28
|
+
delete: [Permission.CurrentUser],
|
|
29
|
+
update: [Permission.CurrentUser],
|
|
30
|
+
})
|
|
31
|
+
@CrudApiEndpoint(new Route("/user-whatsapp"))
|
|
32
|
+
@Entity({
|
|
33
|
+
name: "UserWhatsApp",
|
|
34
|
+
})
|
|
35
|
+
@TableMetadata({
|
|
36
|
+
tableName: "UserWhatsApp",
|
|
37
|
+
singularName: "WhatsApp Number",
|
|
38
|
+
pluralName: "WhatsApp Numbers",
|
|
39
|
+
icon: IconProp.WhatsApp,
|
|
40
|
+
tableDescription: "WhatsApp numbers used for WhatsApp notifications.",
|
|
41
|
+
})
|
|
42
|
+
@CurrentUserCanAccessRecordBy("userId")
|
|
43
|
+
class UserWhatsApp extends BaseModel {
|
|
44
|
+
@ColumnAccessControl({
|
|
45
|
+
create: [Permission.CurrentUser],
|
|
46
|
+
read: [Permission.CurrentUser],
|
|
47
|
+
update: [],
|
|
48
|
+
})
|
|
49
|
+
@TableColumn({
|
|
50
|
+
manyToOneRelationColumn: "projectId",
|
|
51
|
+
type: TableColumnType.Entity,
|
|
52
|
+
modelType: Project,
|
|
53
|
+
title: "Project",
|
|
54
|
+
description: "Relation to Project Resource in which this object belongs",
|
|
55
|
+
})
|
|
56
|
+
@ManyToOne(
|
|
57
|
+
() => {
|
|
58
|
+
return Project;
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
eager: false,
|
|
62
|
+
nullable: true,
|
|
63
|
+
onDelete: "CASCADE",
|
|
64
|
+
orphanedRowAction: "nullify",
|
|
65
|
+
},
|
|
66
|
+
)
|
|
67
|
+
@JoinColumn({ name: "projectId" })
|
|
68
|
+
public project?: Project = undefined;
|
|
69
|
+
|
|
70
|
+
@ColumnAccessControl({
|
|
71
|
+
create: [Permission.CurrentUser],
|
|
72
|
+
read: [Permission.CurrentUser],
|
|
73
|
+
update: [],
|
|
74
|
+
})
|
|
75
|
+
@Index()
|
|
76
|
+
@TableColumn({
|
|
77
|
+
type: TableColumnType.ObjectID,
|
|
78
|
+
required: true,
|
|
79
|
+
canReadOnRelationQuery: true,
|
|
80
|
+
title: "Project ID",
|
|
81
|
+
description: "ID of your OneUptime Project in which this object belongs",
|
|
82
|
+
})
|
|
83
|
+
@Column({
|
|
84
|
+
type: ColumnType.ObjectID,
|
|
85
|
+
nullable: false,
|
|
86
|
+
transformer: ObjectID.getDatabaseTransformer(),
|
|
87
|
+
})
|
|
88
|
+
public projectId?: ObjectID = undefined;
|
|
89
|
+
|
|
90
|
+
@ColumnAccessControl({
|
|
91
|
+
create: [Permission.CurrentUser],
|
|
92
|
+
read: [Permission.CurrentUser],
|
|
93
|
+
update: [],
|
|
94
|
+
})
|
|
95
|
+
@TableColumn({
|
|
96
|
+
title: "WhatsApp Number",
|
|
97
|
+
required: true,
|
|
98
|
+
unique: false,
|
|
99
|
+
type: TableColumnType.Phone,
|
|
100
|
+
canReadOnRelationQuery: true,
|
|
101
|
+
})
|
|
102
|
+
@Column({
|
|
103
|
+
type: ColumnType.Phone,
|
|
104
|
+
length: ColumnLength.Phone,
|
|
105
|
+
unique: false,
|
|
106
|
+
nullable: false,
|
|
107
|
+
transformer: Phone.getDatabaseTransformer(),
|
|
108
|
+
})
|
|
109
|
+
public phone?: Phone = undefined;
|
|
110
|
+
|
|
111
|
+
@ColumnAccessControl({
|
|
112
|
+
create: [Permission.CurrentUser],
|
|
113
|
+
read: [Permission.CurrentUser],
|
|
114
|
+
update: [],
|
|
115
|
+
})
|
|
116
|
+
@TableColumn({
|
|
117
|
+
manyToOneRelationColumn: "user",
|
|
118
|
+
type: TableColumnType.Entity,
|
|
119
|
+
modelType: User,
|
|
120
|
+
title: "User",
|
|
121
|
+
description: "Relation to User who this WhatsApp number belongs to",
|
|
122
|
+
})
|
|
123
|
+
@ManyToOne(
|
|
124
|
+
() => {
|
|
125
|
+
return User;
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
eager: false,
|
|
129
|
+
nullable: true,
|
|
130
|
+
onDelete: "CASCADE",
|
|
131
|
+
orphanedRowAction: "nullify",
|
|
132
|
+
},
|
|
133
|
+
)
|
|
134
|
+
@JoinColumn({ name: "userId" })
|
|
135
|
+
public user?: User = undefined;
|
|
136
|
+
|
|
137
|
+
@ColumnAccessControl({
|
|
138
|
+
create: [Permission.CurrentUser],
|
|
139
|
+
read: [Permission.CurrentUser],
|
|
140
|
+
update: [],
|
|
141
|
+
})
|
|
142
|
+
@TableColumn({
|
|
143
|
+
type: TableColumnType.ObjectID,
|
|
144
|
+
title: "User ID",
|
|
145
|
+
description: "User ID who this WhatsApp number belongs to",
|
|
146
|
+
})
|
|
147
|
+
@Column({
|
|
148
|
+
type: ColumnType.ObjectID,
|
|
149
|
+
nullable: true,
|
|
150
|
+
transformer: ObjectID.getDatabaseTransformer(),
|
|
151
|
+
})
|
|
152
|
+
@Index()
|
|
153
|
+
public userId?: ObjectID = undefined;
|
|
154
|
+
|
|
155
|
+
@ColumnAccessControl({
|
|
156
|
+
create: [Permission.CurrentUser],
|
|
157
|
+
read: [Permission.CurrentUser],
|
|
158
|
+
update: [],
|
|
159
|
+
})
|
|
160
|
+
@TableColumn({
|
|
161
|
+
manyToOneRelationColumn: "createdByUserId",
|
|
162
|
+
type: TableColumnType.Entity,
|
|
163
|
+
modelType: User,
|
|
164
|
+
title: "Created by User",
|
|
165
|
+
description:
|
|
166
|
+
"Relation to User who created this object (if this object was created by a User)",
|
|
167
|
+
})
|
|
168
|
+
@ManyToOne(
|
|
169
|
+
() => {
|
|
170
|
+
return User;
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
eager: false,
|
|
174
|
+
nullable: true,
|
|
175
|
+
onDelete: "SET NULL",
|
|
176
|
+
orphanedRowAction: "nullify",
|
|
177
|
+
},
|
|
178
|
+
)
|
|
179
|
+
@JoinColumn({ name: "createdByUserId" })
|
|
180
|
+
public createdByUser?: User = undefined;
|
|
181
|
+
|
|
182
|
+
@ColumnAccessControl({
|
|
183
|
+
create: [Permission.CurrentUser],
|
|
184
|
+
read: [Permission.CurrentUser],
|
|
185
|
+
update: [],
|
|
186
|
+
})
|
|
187
|
+
@TableColumn({
|
|
188
|
+
type: TableColumnType.ObjectID,
|
|
189
|
+
title: "Created by User ID",
|
|
190
|
+
description:
|
|
191
|
+
"User ID who created this object (if this object was created by a User)",
|
|
192
|
+
})
|
|
193
|
+
@Column({
|
|
194
|
+
type: ColumnType.ObjectID,
|
|
195
|
+
nullable: true,
|
|
196
|
+
transformer: ObjectID.getDatabaseTransformer(),
|
|
197
|
+
})
|
|
198
|
+
public createdByUserId?: ObjectID = undefined;
|
|
199
|
+
|
|
200
|
+
@ColumnAccessControl({
|
|
201
|
+
create: [],
|
|
202
|
+
read: [],
|
|
203
|
+
update: [],
|
|
204
|
+
})
|
|
205
|
+
@TableColumn({
|
|
206
|
+
manyToOneRelationColumn: "deletedByUserId",
|
|
207
|
+
type: TableColumnType.Entity,
|
|
208
|
+
title: "Deleted by User",
|
|
209
|
+
modelType: User,
|
|
210
|
+
description:
|
|
211
|
+
"Relation to User who deleted this object (if this object was deleted by a User)",
|
|
212
|
+
})
|
|
213
|
+
@ManyToOne(
|
|
214
|
+
() => {
|
|
215
|
+
return User;
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
cascade: false,
|
|
219
|
+
eager: false,
|
|
220
|
+
nullable: true,
|
|
221
|
+
onDelete: "SET NULL",
|
|
222
|
+
orphanedRowAction: "nullify",
|
|
223
|
+
},
|
|
224
|
+
)
|
|
225
|
+
@JoinColumn({ name: "deletedByUserId" })
|
|
226
|
+
public deletedByUser?: User = undefined;
|
|
227
|
+
|
|
228
|
+
@ColumnAccessControl({
|
|
229
|
+
create: [],
|
|
230
|
+
read: [],
|
|
231
|
+
update: [],
|
|
232
|
+
})
|
|
233
|
+
@TableColumn({
|
|
234
|
+
type: TableColumnType.ObjectID,
|
|
235
|
+
title: "Deleted by User ID",
|
|
236
|
+
description:
|
|
237
|
+
"User ID who deleted this object (if this object was deleted by a User)",
|
|
238
|
+
})
|
|
239
|
+
@Column({
|
|
240
|
+
type: ColumnType.ObjectID,
|
|
241
|
+
nullable: true,
|
|
242
|
+
transformer: ObjectID.getDatabaseTransformer(),
|
|
243
|
+
})
|
|
244
|
+
public deletedByUserId?: ObjectID = undefined;
|
|
245
|
+
|
|
246
|
+
@ColumnAccessControl({
|
|
247
|
+
create: [],
|
|
248
|
+
read: [Permission.CurrentUser],
|
|
249
|
+
update: [],
|
|
250
|
+
})
|
|
251
|
+
@TableColumn({
|
|
252
|
+
title: "Is Verified",
|
|
253
|
+
description: "Is this WhatsApp number verified?",
|
|
254
|
+
isDefaultValueColumn: true,
|
|
255
|
+
type: TableColumnType.Boolean,
|
|
256
|
+
defaultValue: false,
|
|
257
|
+
})
|
|
258
|
+
@Column({
|
|
259
|
+
type: ColumnType.Boolean,
|
|
260
|
+
default: false,
|
|
261
|
+
})
|
|
262
|
+
public isVerified?: boolean = undefined;
|
|
263
|
+
|
|
264
|
+
@ColumnAccessControl({
|
|
265
|
+
create: [],
|
|
266
|
+
read: [],
|
|
267
|
+
update: [],
|
|
268
|
+
})
|
|
269
|
+
@TableColumn({
|
|
270
|
+
title: "Verification Code",
|
|
271
|
+
description: "Temporary Verification Code",
|
|
272
|
+
isDefaultValueColumn: true,
|
|
273
|
+
computed: true,
|
|
274
|
+
required: true,
|
|
275
|
+
type: TableColumnType.ShortText,
|
|
276
|
+
forceGetDefaultValueOnCreate: () => {
|
|
277
|
+
return Text.generateRandomNumber(6);
|
|
278
|
+
},
|
|
279
|
+
})
|
|
280
|
+
@Column({
|
|
281
|
+
type: ColumnType.ShortText,
|
|
282
|
+
nullable: false,
|
|
283
|
+
length: ColumnLength.ShortText,
|
|
284
|
+
})
|
|
285
|
+
public verificationCode?: string = undefined;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export default UserWhatsApp;
|