@hosterai/types 0.0.8 → 0.0.9
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/dtos/notification/notification-info.dto.d.ts +5 -0
- package/dist/dtos/notification/notification-info.dto.js +7 -0
- package/dist/dtos/notification/notification-request.dto.d.ts +6 -6
- package/dist/dtos/notification/receiver/receiver-email.dto.d.ts +20 -0
- package/dist/dtos/notification/receiver/receiver-email.dto.js +39 -0
- package/dist/dtos/notification/receiver/receiver-push.dto.d.ts +15 -0
- package/dist/dtos/notification/receiver/receiver-push.dto.js +31 -0
- package/dist/dtos/notification/receiver/receiver-sms.dto.d.ts +11 -0
- package/dist/dtos/notification/receiver/receiver-sms.dto.js +26 -0
- package/dist/dtos/notification/sender/sender-email.dto.d.ts +25 -0
- package/dist/dtos/notification/sender/sender-email.dto.js +46 -0
- package/dist/dtos/notification/sender/sender-push.dto.d.ts +31 -0
- package/dist/dtos/notification/sender/sender-push.dto.js +50 -0
- package/dist/dtos/notification/sender/sender-sms.dto.d.ts +15 -0
- package/dist/dtos/notification/sender/sender-sms.dto.js +30 -0
- package/dist/index.d.ts +7 -8
- package/dist/index.js +7 -8
- package/dist/validators/notification-request-validator.d.ts +4 -12
- package/dist/validators/notification-request-validator.js +4 -74
- package/package.json +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotificationInfoDto = void 0;
|
|
4
|
+
const info_dto_1 = require("../info.dto");
|
|
5
|
+
class NotificationInfoDto extends info_dto_1.InfoDto {
|
|
6
|
+
}
|
|
7
|
+
exports.NotificationInfoDto = NotificationInfoDto;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { EmailReceiverDto } from '
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { EmailReceiverDto } from './receiver/receiver-email.dto';
|
|
2
|
+
import { PushReceiverDto } from './receiver/receiver-push.dto';
|
|
3
|
+
import { SmsReceiverDto } from './receiver/receiver-sms.dto';
|
|
4
|
+
import { EmailSenderDto } from './sender/sender-email.dto';
|
|
5
|
+
import { PushSenderDto } from './sender/sender-push.dto';
|
|
6
|
+
import { SmsSenderDto } from './sender/sender-sms.dto';
|
|
7
7
|
export declare class NotificationRequestDto {
|
|
8
8
|
/**
|
|
9
9
|
* Unique identifier of the hoster message
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DTO for email recipients
|
|
3
|
+
* Used to define the recipients of an email
|
|
4
|
+
*/
|
|
5
|
+
export declare class EmailReceiverDto {
|
|
6
|
+
/**
|
|
7
|
+
* The main email address
|
|
8
|
+
*/
|
|
9
|
+
to: string;
|
|
10
|
+
/**
|
|
11
|
+
* List of email addresses for carbon copy (optional)
|
|
12
|
+
* Must be valid and unique email addresses
|
|
13
|
+
*/
|
|
14
|
+
cc?: string[];
|
|
15
|
+
/**
|
|
16
|
+
* List of email addresses for blind carbon copy (optional)
|
|
17
|
+
* Must be valid and unique email addresses
|
|
18
|
+
*/
|
|
19
|
+
bcc?: string[];
|
|
20
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.EmailReceiverDto = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
/**
|
|
15
|
+
* DTO for email recipients
|
|
16
|
+
* Used to define the recipients of an email
|
|
17
|
+
*/
|
|
18
|
+
class EmailReceiverDto {
|
|
19
|
+
}
|
|
20
|
+
exports.EmailReceiverDto = EmailReceiverDto;
|
|
21
|
+
__decorate([
|
|
22
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
23
|
+
(0, class_validator_1.IsEmail)(),
|
|
24
|
+
__metadata("design:type", String)
|
|
25
|
+
], EmailReceiverDto.prototype, "to", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, class_validator_1.IsOptional)(),
|
|
28
|
+
(0, class_validator_1.IsArray)(),
|
|
29
|
+
(0, class_validator_1.IsEmail)({}, { each: true }),
|
|
30
|
+
(0, class_validator_1.ArrayUnique)(),
|
|
31
|
+
__metadata("design:type", Array)
|
|
32
|
+
], EmailReceiverDto.prototype, "cc", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, class_validator_1.IsOptional)(),
|
|
35
|
+
(0, class_validator_1.IsArray)(),
|
|
36
|
+
(0, class_validator_1.IsEmail)({}, { each: true }),
|
|
37
|
+
(0, class_validator_1.ArrayUnique)(),
|
|
38
|
+
__metadata("design:type", Array)
|
|
39
|
+
], EmailReceiverDto.prototype, "bcc", void 0);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DTO for push notification recipients
|
|
3
|
+
* Used to define the recipients of a push notification
|
|
4
|
+
*/
|
|
5
|
+
export declare class PushReceiverDto {
|
|
6
|
+
/**
|
|
7
|
+
* The user ID that will receive the push notification
|
|
8
|
+
*/
|
|
9
|
+
userId: string;
|
|
10
|
+
/**
|
|
11
|
+
* List of user device tokens
|
|
12
|
+
* Must contain at least one token
|
|
13
|
+
*/
|
|
14
|
+
deviceTokens: string[];
|
|
15
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.PushReceiverDto = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
/**
|
|
15
|
+
* DTO for push notification recipients
|
|
16
|
+
* Used to define the recipients of a push notification
|
|
17
|
+
*/
|
|
18
|
+
class PushReceiverDto {
|
|
19
|
+
}
|
|
20
|
+
exports.PushReceiverDto = PushReceiverDto;
|
|
21
|
+
__decorate([
|
|
22
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
23
|
+
(0, class_validator_1.IsString)(),
|
|
24
|
+
__metadata("design:type", String)
|
|
25
|
+
], PushReceiverDto.prototype, "userId", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, class_validator_1.IsArray)(),
|
|
28
|
+
(0, class_validator_1.ArrayNotEmpty)(),
|
|
29
|
+
(0, class_validator_1.ArrayMinSize)(1),
|
|
30
|
+
__metadata("design:type", Array)
|
|
31
|
+
], PushReceiverDto.prototype, "deviceTokens", void 0);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SmsReceiverDto = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
/**
|
|
15
|
+
* DTO for SMS recipients
|
|
16
|
+
* Used to define the recipients of an SMS message
|
|
17
|
+
*/
|
|
18
|
+
class SmsReceiverDto {
|
|
19
|
+
}
|
|
20
|
+
exports.SmsReceiverDto = SmsReceiverDto;
|
|
21
|
+
__decorate([
|
|
22
|
+
(0, class_validator_1.IsArray)(),
|
|
23
|
+
(0, class_validator_1.ArrayUnique)(),
|
|
24
|
+
(0, class_validator_1.IsPhoneNumber)(undefined, { each: true }),
|
|
25
|
+
__metadata("design:type", Array)
|
|
26
|
+
], SmsReceiverDto.prototype, "receiverPhones", void 0);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AttachmentDto } from '../../attachment.dto';
|
|
2
|
+
/**
|
|
3
|
+
* DTO for email sender
|
|
4
|
+
* Used to define the details for sending an email
|
|
5
|
+
*/
|
|
6
|
+
export declare class EmailSenderDto {
|
|
7
|
+
/**
|
|
8
|
+
* The full name of the sender
|
|
9
|
+
*/
|
|
10
|
+
fullName: string;
|
|
11
|
+
/**
|
|
12
|
+
* The email subject
|
|
13
|
+
* Length restriction from 1 to 500 characters
|
|
14
|
+
*/
|
|
15
|
+
subject: string;
|
|
16
|
+
/**
|
|
17
|
+
* The message content
|
|
18
|
+
* Length restriction from 1 to 50000 characters
|
|
19
|
+
*/
|
|
20
|
+
message: string;
|
|
21
|
+
/**
|
|
22
|
+
* File attachments (optional)
|
|
23
|
+
*/
|
|
24
|
+
attachments?: AttachmentDto[];
|
|
25
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.EmailSenderDto = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
const class_transformer_1 = require("class-transformer");
|
|
15
|
+
const attachment_dto_1 = require("../../attachment.dto");
|
|
16
|
+
/**
|
|
17
|
+
* DTO for email sender
|
|
18
|
+
* Used to define the details for sending an email
|
|
19
|
+
*/
|
|
20
|
+
class EmailSenderDto {
|
|
21
|
+
}
|
|
22
|
+
exports.EmailSenderDto = EmailSenderDto;
|
|
23
|
+
__decorate([
|
|
24
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
25
|
+
(0, class_validator_1.IsString)(),
|
|
26
|
+
__metadata("design:type", String)
|
|
27
|
+
], EmailSenderDto.prototype, "fullName", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
30
|
+
(0, class_validator_1.IsString)(),
|
|
31
|
+
(0, class_validator_1.Length)(1, 500),
|
|
32
|
+
__metadata("design:type", String)
|
|
33
|
+
], EmailSenderDto.prototype, "subject", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
36
|
+
(0, class_validator_1.IsString)(),
|
|
37
|
+
(0, class_validator_1.Length)(1, 50000),
|
|
38
|
+
__metadata("design:type", String)
|
|
39
|
+
], EmailSenderDto.prototype, "message", void 0);
|
|
40
|
+
__decorate([
|
|
41
|
+
(0, class_validator_1.IsOptional)(),
|
|
42
|
+
(0, class_validator_1.IsArray)(),
|
|
43
|
+
(0, class_validator_1.ValidateNested)({ each: true }),
|
|
44
|
+
(0, class_transformer_1.Type)(() => attachment_dto_1.AttachmentDto),
|
|
45
|
+
__metadata("design:type", Array)
|
|
46
|
+
], EmailSenderDto.prototype, "attachments", void 0);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DTO for push notification sender
|
|
3
|
+
* Used to define the details for sending a push notification
|
|
4
|
+
*/
|
|
5
|
+
export declare class PushSenderDto {
|
|
6
|
+
/**
|
|
7
|
+
* Unique identifier of the message
|
|
8
|
+
* Length restriction from 1 to 255 characters
|
|
9
|
+
*/
|
|
10
|
+
messageId: string;
|
|
11
|
+
/**
|
|
12
|
+
* The user ID that will receive the push notification
|
|
13
|
+
* Length restriction from 1 to 255 characters
|
|
14
|
+
*/
|
|
15
|
+
userId: string;
|
|
16
|
+
/**
|
|
17
|
+
* The title of the push notification
|
|
18
|
+
* Length restriction from 1 to 255 characters
|
|
19
|
+
*/
|
|
20
|
+
title: string;
|
|
21
|
+
/**
|
|
22
|
+
* The content of the push notification
|
|
23
|
+
* Length restriction from 1 to 1000 characters
|
|
24
|
+
*/
|
|
25
|
+
message: string;
|
|
26
|
+
/**
|
|
27
|
+
* The subtitle of the push notification (optional)
|
|
28
|
+
* Length restriction from 1 to 255 characters
|
|
29
|
+
*/
|
|
30
|
+
subtitle?: string;
|
|
31
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.PushSenderDto = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
/**
|
|
15
|
+
* DTO for push notification sender
|
|
16
|
+
* Used to define the details for sending a push notification
|
|
17
|
+
*/
|
|
18
|
+
class PushSenderDto {
|
|
19
|
+
}
|
|
20
|
+
exports.PushSenderDto = PushSenderDto;
|
|
21
|
+
__decorate([
|
|
22
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
23
|
+
(0, class_validator_1.IsString)(),
|
|
24
|
+
(0, class_validator_1.Length)(1, 255),
|
|
25
|
+
__metadata("design:type", String)
|
|
26
|
+
], PushSenderDto.prototype, "messageId", void 0);
|
|
27
|
+
__decorate([
|
|
28
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
29
|
+
(0, class_validator_1.IsString)(),
|
|
30
|
+
(0, class_validator_1.Length)(1, 255),
|
|
31
|
+
__metadata("design:type", String)
|
|
32
|
+
], PushSenderDto.prototype, "userId", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
35
|
+
(0, class_validator_1.IsString)(),
|
|
36
|
+
(0, class_validator_1.Length)(1, 255),
|
|
37
|
+
__metadata("design:type", String)
|
|
38
|
+
], PushSenderDto.prototype, "title", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
41
|
+
(0, class_validator_1.IsString)(),
|
|
42
|
+
(0, class_validator_1.Length)(1, 1000),
|
|
43
|
+
__metadata("design:type", String)
|
|
44
|
+
], PushSenderDto.prototype, "message", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, class_validator_1.IsOptional)(),
|
|
47
|
+
(0, class_validator_1.IsString)(),
|
|
48
|
+
(0, class_validator_1.Length)(1, 255),
|
|
49
|
+
__metadata("design:type", String)
|
|
50
|
+
], PushSenderDto.prototype, "subtitle", void 0);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DTO for SMS sender
|
|
3
|
+
* Used to define the details for sending an SMS message
|
|
4
|
+
*/
|
|
5
|
+
export declare class SmsSenderDto {
|
|
6
|
+
/**
|
|
7
|
+
* Sender's phone number
|
|
8
|
+
* Must be a valid phone number
|
|
9
|
+
*/
|
|
10
|
+
senderPhone: string;
|
|
11
|
+
/**
|
|
12
|
+
* The content of the SMS message
|
|
13
|
+
*/
|
|
14
|
+
message: string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SmsSenderDto = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
/**
|
|
15
|
+
* DTO for SMS sender
|
|
16
|
+
* Used to define the details for sending an SMS message
|
|
17
|
+
*/
|
|
18
|
+
class SmsSenderDto {
|
|
19
|
+
}
|
|
20
|
+
exports.SmsSenderDto = SmsSenderDto;
|
|
21
|
+
__decorate([
|
|
22
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
23
|
+
(0, class_validator_1.IsPhoneNumber)(),
|
|
24
|
+
__metadata("design:type", String)
|
|
25
|
+
], SmsSenderDto.prototype, "senderPhone", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
28
|
+
(0, class_validator_1.IsString)(),
|
|
29
|
+
__metadata("design:type", String)
|
|
30
|
+
], SmsSenderDto.prototype, "message", void 0);
|
package/dist/index.d.ts
CHANGED
|
@@ -9,17 +9,16 @@ export * from './dtos/success-response.dto';
|
|
|
9
9
|
export * from './dtos/task-response.dto';
|
|
10
10
|
export * from './dtos/action.dto';
|
|
11
11
|
export * from './dtos/field.dto';
|
|
12
|
-
export * from './dtos/notification/info
|
|
13
|
-
export * from './dtos/info.dto';
|
|
12
|
+
export * from './dtos/notification/notification-info.dto';
|
|
14
13
|
export * from './dtos/multilang-text.dto';
|
|
15
14
|
export * from './dtos/response-data.dto';
|
|
16
15
|
export * from './dtos/unit.dto';
|
|
17
|
-
export * from './dtos/receiver/receiver-email.dto';
|
|
18
|
-
export * from './dtos/receiver/receiver-push.dto';
|
|
19
|
-
export * from './dtos/receiver/receiver-sms.dto';
|
|
20
|
-
export * from './dtos/sender/sender-email.dto';
|
|
21
|
-
export * from './dtos/sender/sender-push.dto';
|
|
22
|
-
export * from './dtos/sender/sender-sms.dto';
|
|
16
|
+
export * from './dtos/notification/receiver/receiver-email.dto';
|
|
17
|
+
export * from './dtos/notification/receiver/receiver-push.dto';
|
|
18
|
+
export * from './dtos/notification/receiver/receiver-sms.dto';
|
|
19
|
+
export * from './dtos/notification/sender/sender-email.dto';
|
|
20
|
+
export * from './dtos/notification/sender/sender-push.dto';
|
|
21
|
+
export * from './dtos/notification/sender/sender-sms.dto';
|
|
23
22
|
export * from './enums/country.enum';
|
|
24
23
|
export * from './enums/language.enum';
|
|
25
24
|
export * from './enums/message-type.enum';
|
package/dist/index.js
CHANGED
|
@@ -26,19 +26,18 @@ __exportStar(require("./dtos/success-response.dto"), exports);
|
|
|
26
26
|
__exportStar(require("./dtos/task-response.dto"), exports);
|
|
27
27
|
__exportStar(require("./dtos/action.dto"), exports);
|
|
28
28
|
__exportStar(require("./dtos/field.dto"), exports);
|
|
29
|
-
__exportStar(require("./dtos/notification/info
|
|
30
|
-
__exportStar(require("./dtos/info.dto"), exports);
|
|
29
|
+
__exportStar(require("./dtos/notification/notification-info.dto"), exports);
|
|
31
30
|
__exportStar(require("./dtos/multilang-text.dto"), exports);
|
|
32
31
|
__exportStar(require("./dtos/response-data.dto"), exports);
|
|
33
32
|
__exportStar(require("./dtos/unit.dto"), exports);
|
|
34
33
|
// Export receiver DTOs
|
|
35
|
-
__exportStar(require("./dtos/receiver/receiver-email.dto"), exports);
|
|
36
|
-
__exportStar(require("./dtos/receiver/receiver-push.dto"), exports);
|
|
37
|
-
__exportStar(require("./dtos/receiver/receiver-sms.dto"), exports);
|
|
34
|
+
__exportStar(require("./dtos/notification/receiver/receiver-email.dto"), exports);
|
|
35
|
+
__exportStar(require("./dtos/notification/receiver/receiver-push.dto"), exports);
|
|
36
|
+
__exportStar(require("./dtos/notification/receiver/receiver-sms.dto"), exports);
|
|
38
37
|
// Export sender DTOs
|
|
39
|
-
__exportStar(require("./dtos/sender/sender-email.dto"), exports);
|
|
40
|
-
__exportStar(require("./dtos/sender/sender-push.dto"), exports);
|
|
41
|
-
__exportStar(require("./dtos/sender/sender-sms.dto"), exports);
|
|
38
|
+
__exportStar(require("./dtos/notification/sender/sender-email.dto"), exports);
|
|
39
|
+
__exportStar(require("./dtos/notification/sender/sender-push.dto"), exports);
|
|
40
|
+
__exportStar(require("./dtos/notification/sender/sender-sms.dto"), exports);
|
|
42
41
|
// Export all ENUMs
|
|
43
42
|
__exportStar(require("./enums/country.enum"), exports);
|
|
44
43
|
__exportStar(require("./enums/language.enum"), exports);
|
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
import { ValidationError } from 'class-validator';
|
|
2
2
|
/**
|
|
3
|
-
* Validates a NotificationRequestDto object
|
|
4
|
-
* This function can be used for DTOs imported from remote packages where decorators don't work.
|
|
3
|
+
* Validates a NotificationRequestDto object using class-validator decorators.
|
|
5
4
|
*
|
|
6
|
-
* @param data The object to validate as a NotificationRequestDto
|
|
7
|
-
* @returns An array of validation errors, empty if validation succeeds
|
|
5
|
+
* @param data The object to validate as a NotificationRequestDto.
|
|
6
|
+
* @returns An array of validation errors, empty if validation succeeds.
|
|
8
7
|
*/
|
|
9
|
-
export declare function validateNotificationRequestDto(data:
|
|
10
|
-
/**
|
|
11
|
-
* A convenience wrapper that throws an error if validation fails
|
|
12
|
-
*
|
|
13
|
-
* @param data The object to validate as a NotificationRequestDto
|
|
14
|
-
* @throws Error if validation fails, with error message containing all validation errors
|
|
15
|
-
*/
|
|
16
|
-
export declare function validateNotificationRequestDtoOrThrow(data: any): void;
|
|
8
|
+
export declare function validateNotificationRequestDto(data: object): ValidationError[];
|
|
@@ -1,87 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.validateNotificationRequestDto = validateNotificationRequestDto;
|
|
4
|
-
exports.validateNotificationRequestDtoOrThrow = validateNotificationRequestDtoOrThrow;
|
|
5
4
|
const class_validator_1 = require("class-validator");
|
|
6
5
|
const class_transformer_1 = require("class-transformer");
|
|
7
6
|
const notification_request_dto_1 = require("../dtos/notification/notification-request.dto");
|
|
8
7
|
/**
|
|
9
|
-
* Validates a NotificationRequestDto object
|
|
10
|
-
* This function can be used for DTOs imported from remote packages where decorators don't work.
|
|
8
|
+
* Validates a NotificationRequestDto object using class-validator decorators.
|
|
11
9
|
*
|
|
12
|
-
* @param data The object to validate as a NotificationRequestDto
|
|
13
|
-
* @returns An array of validation errors, empty if validation succeeds
|
|
10
|
+
* @param data The object to validate as a NotificationRequestDto.
|
|
11
|
+
* @returns An array of validation errors, empty if validation succeeds.
|
|
14
12
|
*/
|
|
15
13
|
function validateNotificationRequestDto(data) {
|
|
16
|
-
// First, transform plain object to instance if needed
|
|
17
14
|
const dto = (0, class_transformer_1.plainToInstance)(notification_request_dto_1.NotificationRequestDto, data);
|
|
18
|
-
const errors =
|
|
19
|
-
// Ensure notificationId exists and is a string
|
|
20
|
-
if (!dto.notificationId) {
|
|
21
|
-
const error = new class_validator_1.ValidationError();
|
|
22
|
-
error.property = 'notificationId';
|
|
23
|
-
error.constraints = { isNotEmpty: 'notificationId should not be empty' };
|
|
24
|
-
errors.push(error);
|
|
25
|
-
}
|
|
26
|
-
else if (typeof dto.notificationId !== 'string') {
|
|
27
|
-
const error = new class_validator_1.ValidationError();
|
|
28
|
-
error.property = 'notificationId';
|
|
29
|
-
error.constraints = { isString: 'notificationId must be a string' };
|
|
30
|
-
errors.push(error);
|
|
31
|
-
}
|
|
32
|
-
// Ensure sender exists and is an object
|
|
33
|
-
if (dto.sender === null) {
|
|
34
|
-
const error = new class_validator_1.ValidationError();
|
|
35
|
-
error.property = 'sender';
|
|
36
|
-
error.constraints = { isObject: 'sender must be an object' };
|
|
37
|
-
errors.push(error);
|
|
38
|
-
}
|
|
39
|
-
else if (!dto.sender) {
|
|
40
|
-
const error = new class_validator_1.ValidationError();
|
|
41
|
-
error.property = 'sender';
|
|
42
|
-
error.constraints = { isNotEmpty: 'sender should not be empty' };
|
|
43
|
-
errors.push(error);
|
|
44
|
-
}
|
|
45
|
-
else if (typeof dto.sender !== 'object') {
|
|
46
|
-
const error = new class_validator_1.ValidationError();
|
|
47
|
-
error.property = 'sender';
|
|
48
|
-
error.constraints = { isObject: 'sender must be an object' };
|
|
49
|
-
errors.push(error);
|
|
50
|
-
}
|
|
51
|
-
// Ensure receiver exists and is an object
|
|
52
|
-
if (dto.receiver === null) {
|
|
53
|
-
const error = new class_validator_1.ValidationError();
|
|
54
|
-
error.property = 'receiver';
|
|
55
|
-
error.constraints = { isObject: 'receiver must be an object' };
|
|
56
|
-
errors.push(error);
|
|
57
|
-
}
|
|
58
|
-
else if (!dto.receiver) {
|
|
59
|
-
const error = new class_validator_1.ValidationError();
|
|
60
|
-
error.property = 'receiver';
|
|
61
|
-
error.constraints = { isNotEmpty: 'receiver should not be empty' };
|
|
62
|
-
errors.push(error);
|
|
63
|
-
}
|
|
64
|
-
else if (typeof dto.receiver !== 'object') {
|
|
65
|
-
const error = new class_validator_1.ValidationError();
|
|
66
|
-
error.property = 'receiver';
|
|
67
|
-
error.constraints = { isObject: 'receiver must be an object' };
|
|
68
|
-
errors.push(error);
|
|
69
|
-
}
|
|
15
|
+
const errors = (0, class_validator_1.validateSync)(dto);
|
|
70
16
|
return errors;
|
|
71
17
|
}
|
|
72
|
-
/**
|
|
73
|
-
* A convenience wrapper that throws an error if validation fails
|
|
74
|
-
*
|
|
75
|
-
* @param data The object to validate as a NotificationRequestDto
|
|
76
|
-
* @throws Error if validation fails, with error message containing all validation errors
|
|
77
|
-
*/
|
|
78
|
-
function validateNotificationRequestDtoOrThrow(data) {
|
|
79
|
-
const errors = validateNotificationRequestDto(data);
|
|
80
|
-
if (errors.length > 0) {
|
|
81
|
-
const errorMessages = errors.map(error => {
|
|
82
|
-
const constraintValues = error.constraints ? Object.values(error.constraints) : [];
|
|
83
|
-
return `${error.property}: ${constraintValues.join(', ')}`;
|
|
84
|
-
}).join('; ');
|
|
85
|
-
throw new Error(`Validation failed: ${errorMessages}`);
|
|
86
|
-
}
|
|
87
|
-
}
|