mblabs-roccato-backend-commons 1.0.47 → 1.0.49
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/database/migrations/1758382227488-CreateAccountSettingsTable.d.ts +5 -0
- package/dist/database/migrations/1758382227488-CreateAccountSettingsTable.js +81 -0
- package/dist/database/migrations/index.d.ts +2 -0
- package/dist/database/migrations/index.js +2 -0
- package/dist/interfaces/aws.d.ts +11 -0
- package/dist/services/aws/sqs.d.ts +1 -0
- package/dist/services/aws/sqs.js +18 -2
- package/dist/services/date.d.ts +1 -1
- package/dist/services/date.js +4 -3
- package/package.json +1 -1
- package/src/database/migrations/1758382227488-CreateAccountSettingsTable.ts +84 -0
- package/src/database/migrations/index.ts +2 -0
- package/src/interfaces/aws.ts +12 -0
- package/src/services/aws/sqs.ts +26 -5
- package/src/services/date.ts +6 -4
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CreateAccountSettingsTable1758382227488 = void 0;
|
|
7
|
+
const typeorm_1 = require("typeorm");
|
|
8
|
+
const utils_1 = __importDefault(require("../utils"));
|
|
9
|
+
class CreateAccountSettingsTable1758382227488 {
|
|
10
|
+
async up(queryRunner) {
|
|
11
|
+
const hasTable = await utils_1.default.checkHasTable('account_settings', queryRunner);
|
|
12
|
+
if (hasTable)
|
|
13
|
+
return;
|
|
14
|
+
await queryRunner.createTable(new typeorm_1.Table({
|
|
15
|
+
name: 'account_settings',
|
|
16
|
+
columns: [
|
|
17
|
+
{
|
|
18
|
+
name: 'id',
|
|
19
|
+
type: 'uuid',
|
|
20
|
+
isPrimary: true,
|
|
21
|
+
generationStrategy: 'uuid',
|
|
22
|
+
default: 'uuid_generate_v4()',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'accountId',
|
|
26
|
+
type: 'uuid',
|
|
27
|
+
isNullable: true,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'calendar',
|
|
31
|
+
type: 'jsonb',
|
|
32
|
+
isNullable: true,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'favorites',
|
|
36
|
+
type: 'jsonb',
|
|
37
|
+
isNullable: true,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'language',
|
|
41
|
+
type: 'varchar',
|
|
42
|
+
isNullable: true,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: 'theme',
|
|
46
|
+
type: 'varchar',
|
|
47
|
+
isNullable: true,
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
foreignKeys: [
|
|
51
|
+
{
|
|
52
|
+
columnNames: ['accountId'],
|
|
53
|
+
referencedTableName: 'account',
|
|
54
|
+
referencedColumnNames: ['id'],
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
indices: [
|
|
58
|
+
new typeorm_1.TableIndex({
|
|
59
|
+
name: 'IDX_ACCOUNT_SETTINGS',
|
|
60
|
+
columnNames: [
|
|
61
|
+
'id',
|
|
62
|
+
'accountId',
|
|
63
|
+
'calendar',
|
|
64
|
+
'favorites',
|
|
65
|
+
'language',
|
|
66
|
+
'theme',
|
|
67
|
+
],
|
|
68
|
+
}),
|
|
69
|
+
],
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
async down(queryRunner) {
|
|
73
|
+
const hasTable = await utils_1.default.checkHasTable('account_settings', queryRunner);
|
|
74
|
+
if (!hasTable)
|
|
75
|
+
return;
|
|
76
|
+
await utils_1.default.dropTableForeignKeys('account_settings', ['accountId'], queryRunner);
|
|
77
|
+
await utils_1.default.dropIndex('account_settings', 'IDX_ACCOUNT_SETTINGS', queryRunner);
|
|
78
|
+
await queryRunner.dropTable('account_settings');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.CreateAccountSettingsTable1758382227488 = CreateAccountSettingsTable1758382227488;
|
|
@@ -12,6 +12,7 @@ import { CreateAccountAddressTable1750690818577 } from './1750690818577-CreateAc
|
|
|
12
12
|
import { CreateAccountDetailsTable1750691840822 } from './1750691840822-CreateAccountDetailsTable';
|
|
13
13
|
import { CreateProfileModuleTable1751576312683 } from './1751576312683-CreateProfileModuleTable';
|
|
14
14
|
import { CreateAccountDeviceTable1754426499576 } from './1754426499576-CreateAccountDeviceTable';
|
|
15
|
+
import { CreateAccountSettingsTable1758382227488 } from './1758382227488-CreateAccountSettingsTable';
|
|
15
16
|
export declare const Migrations: {
|
|
16
17
|
Init1748448461165: typeof Init1748448461165;
|
|
17
18
|
CreateProfilesTable1748448589743: typeof CreateProfilesTable1748448589743;
|
|
@@ -27,4 +28,5 @@ export declare const Migrations: {
|
|
|
27
28
|
CreateAccountDetailsTable1750691840822: typeof CreateAccountDetailsTable1750691840822;
|
|
28
29
|
CreateProfileModuleTable1751576312683: typeof CreateProfileModuleTable1751576312683;
|
|
29
30
|
CreateAccountDeviceTable1754426499576: typeof CreateAccountDeviceTable1754426499576;
|
|
31
|
+
CreateAccountSettingsTable1758382227488: typeof CreateAccountSettingsTable1758382227488;
|
|
30
32
|
};
|
|
@@ -15,6 +15,7 @@ const _1750690818577_CreateAccountAddressTable_1 = require("./1750690818577-Crea
|
|
|
15
15
|
const _1750691840822_CreateAccountDetailsTable_1 = require("./1750691840822-CreateAccountDetailsTable");
|
|
16
16
|
const _1751576312683_CreateProfileModuleTable_1 = require("./1751576312683-CreateProfileModuleTable");
|
|
17
17
|
const _1754426499576_CreateAccountDeviceTable_1 = require("./1754426499576-CreateAccountDeviceTable");
|
|
18
|
+
const _1758382227488_CreateAccountSettingsTable_1 = require("./1758382227488-CreateAccountSettingsTable");
|
|
18
19
|
exports.Migrations = {
|
|
19
20
|
Init1748448461165: _1748448461165_Init_1.Init1748448461165,
|
|
20
21
|
CreateProfilesTable1748448589743: _1748448589743_CreateProfilesTable_1.CreateProfilesTable1748448589743,
|
|
@@ -30,4 +31,5 @@ exports.Migrations = {
|
|
|
30
31
|
CreateAccountDetailsTable1750691840822: _1750691840822_CreateAccountDetailsTable_1.CreateAccountDetailsTable1750691840822,
|
|
31
32
|
CreateProfileModuleTable1751576312683: _1751576312683_CreateProfileModuleTable_1.CreateProfileModuleTable1751576312683,
|
|
32
33
|
CreateAccountDeviceTable1754426499576: _1754426499576_CreateAccountDeviceTable_1.CreateAccountDeviceTable1754426499576,
|
|
34
|
+
CreateAccountSettingsTable1758382227488: _1758382227488_CreateAccountSettingsTable_1.CreateAccountSettingsTable1758382227488,
|
|
33
35
|
};
|
package/dist/interfaces/aws.d.ts
CHANGED
|
@@ -174,6 +174,7 @@ export declare namespace AmazonSQS {
|
|
|
174
174
|
interface Request {
|
|
175
175
|
data: {
|
|
176
176
|
queue: string;
|
|
177
|
+
limit?: number;
|
|
177
178
|
};
|
|
178
179
|
credentials: Credentials;
|
|
179
180
|
}
|
|
@@ -181,6 +182,15 @@ export declare namespace AmazonSQS {
|
|
|
181
182
|
messages: T[];
|
|
182
183
|
}
|
|
183
184
|
}
|
|
185
|
+
namespace DeleteMessages {
|
|
186
|
+
interface Request {
|
|
187
|
+
data: {
|
|
188
|
+
queue: string;
|
|
189
|
+
messages: string[];
|
|
190
|
+
};
|
|
191
|
+
credentials: Credentials;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
184
194
|
}
|
|
185
195
|
export interface IAmazonCloudwatchService {
|
|
186
196
|
createLogEvent(req: AmazonCloudwatch.CreateLogEvent.Request): Promise<void>;
|
|
@@ -204,5 +214,6 @@ export interface IAmazonSQSService {
|
|
|
204
214
|
publishMessage(req: AmazonSQS.PublishMessage.Request): Promise<void>;
|
|
205
215
|
consumeMessage<T>(req: AmazonSQS.ConsumeMessage.Request): Promise<AmazonSQS.ConsumeMessage.Response<T>>;
|
|
206
216
|
consumeMessages<T>(req: AmazonSQS.ConsumeMessages.Request): Promise<AmazonSQS.ConsumeMessages.Response<T>>;
|
|
217
|
+
deleteMessages(req: AmazonSQS.DeleteMessages.Request): Promise<void>;
|
|
207
218
|
}
|
|
208
219
|
export {};
|
|
@@ -3,6 +3,7 @@ declare class AmazonSQSService implements IAmazonSQSService {
|
|
|
3
3
|
publishMessage({ credentials, data }: AmazonSQS.PublishMessage.Request): Promise<void>;
|
|
4
4
|
consumeMessage<T>({ credentials, data, }: AmazonSQS.ConsumeMessage.Request): Promise<AmazonSQS.ConsumeMessage.Response<T>>;
|
|
5
5
|
consumeMessages<T>({ credentials, data, }: AmazonSQS.ConsumeMessages.Request): Promise<AmazonSQS.ConsumeMessages.Response<T>>;
|
|
6
|
+
deleteMessages({ credentials, data }: AmazonSQS.DeleteMessages.Request): Promise<void>;
|
|
6
7
|
}
|
|
7
8
|
declare const _default: AmazonSQSService;
|
|
8
9
|
export default _default;
|
package/dist/services/aws/sqs.js
CHANGED
|
@@ -55,10 +55,10 @@ class AmazonSQSService {
|
|
|
55
55
|
const { QueueUrl } = await client.getQueueUrl({ QueueName: data.queue });
|
|
56
56
|
const { Messages } = await client.receiveMessage({
|
|
57
57
|
QueueUrl,
|
|
58
|
-
MaxNumberOfMessages: 10,
|
|
58
|
+
MaxNumberOfMessages: typeof data.limit === 'number' ? Math.min(data.limit, 10) : 10,
|
|
59
59
|
});
|
|
60
60
|
if (Messages && Messages.length > 0) {
|
|
61
|
-
await Promise.allSettled(Messages?.map(message => client.send(new client_sqs_1.DeleteMessageCommand({
|
|
61
|
+
await Promise.allSettled(Messages?.map((message) => client.send(new client_sqs_1.DeleteMessageCommand({
|
|
62
62
|
QueueUrl,
|
|
63
63
|
ReceiptHandle: message?.ReceiptHandle,
|
|
64
64
|
}))));
|
|
@@ -70,5 +70,21 @@ class AmazonSQSService {
|
|
|
70
70
|
messages: [],
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
|
+
async deleteMessages({ credentials, data }) {
|
|
74
|
+
const client = new client_sqs_1.SQS({
|
|
75
|
+
credentials: {
|
|
76
|
+
accessKeyId: credentials.accessKey,
|
|
77
|
+
secretAccessKey: credentials.secretKey,
|
|
78
|
+
},
|
|
79
|
+
region: credentials.region,
|
|
80
|
+
});
|
|
81
|
+
const { QueueUrl } = await client.getQueueUrl({ QueueName: data.queue });
|
|
82
|
+
await Promise.allSettled(data.messages.map((message) => {
|
|
83
|
+
client.send(new client_sqs_1.DeleteMessageCommand({
|
|
84
|
+
QueueUrl,
|
|
85
|
+
ReceiptHandle: message,
|
|
86
|
+
}));
|
|
87
|
+
}));
|
|
88
|
+
}
|
|
73
89
|
}
|
|
74
90
|
exports.default = new AmazonSQSService();
|
package/dist/services/date.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ declare class DateService {
|
|
|
24
24
|
getCurrentTimestamp(): number;
|
|
25
25
|
getMillisFromFormattedDate(date: string, format?: string): number;
|
|
26
26
|
getMonthsInRange(startDate: Date, endDate: Date): string[];
|
|
27
|
-
isSameDay(inp: Date, compare?: Date): boolean;
|
|
27
|
+
isSameDay(inp: Date | string, compare?: Date): boolean;
|
|
28
28
|
isToday(date: Date): boolean;
|
|
29
29
|
}
|
|
30
30
|
declare const _default: DateService;
|
package/dist/services/date.js
CHANGED
|
@@ -13,6 +13,7 @@ class DateService {
|
|
|
13
13
|
if (luxon_1.DateTime.fromFormat(inp, format).isValid) {
|
|
14
14
|
return luxon_1.DateTime.fromFormat(inp, format).toJSDate();
|
|
15
15
|
}
|
|
16
|
+
return luxon_1.DateTime.local().toJSDate();
|
|
16
17
|
}
|
|
17
18
|
toFormat(inp, format = constants_1.DATE.SYSTEM.COMMON_DATE) {
|
|
18
19
|
if (inp instanceof Date) {
|
|
@@ -107,9 +108,9 @@ class DateService {
|
|
|
107
108
|
return months;
|
|
108
109
|
}
|
|
109
110
|
isSameDay(inp, compare = this.getCurrentDate()) {
|
|
110
|
-
const
|
|
111
|
-
const
|
|
112
|
-
return
|
|
111
|
+
const startDate = luxon_1.DateTime.fromJSDate(this.toDate(inp)).startOf('day');
|
|
112
|
+
const endDate = luxon_1.DateTime.fromJSDate(this.toDate(compare)).startOf('day');
|
|
113
|
+
return startDate.equals(endDate);
|
|
113
114
|
}
|
|
114
115
|
isToday(date) {
|
|
115
116
|
return this.isSameDay(date);
|
package/package.json
CHANGED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner, Table, TableIndex } from 'typeorm';
|
|
2
|
+
|
|
3
|
+
import DatabaseUtils from '../utils';
|
|
4
|
+
|
|
5
|
+
export class CreateAccountSettingsTable1758382227488 implements MigrationInterface {
|
|
6
|
+
|
|
7
|
+
public async up (queryRunner: QueryRunner): Promise<void> {
|
|
8
|
+
const hasTable = await DatabaseUtils.checkHasTable('account_settings', queryRunner);
|
|
9
|
+
|
|
10
|
+
if (hasTable) return;
|
|
11
|
+
|
|
12
|
+
await queryRunner.createTable(
|
|
13
|
+
new Table({
|
|
14
|
+
name: 'account_settings',
|
|
15
|
+
columns: [
|
|
16
|
+
{
|
|
17
|
+
name: 'id',
|
|
18
|
+
type: 'uuid',
|
|
19
|
+
isPrimary: true,
|
|
20
|
+
generationStrategy: 'uuid',
|
|
21
|
+
default: 'uuid_generate_v4()',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: 'accountId',
|
|
25
|
+
type: 'uuid',
|
|
26
|
+
isNullable: true,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'calendar',
|
|
30
|
+
type: 'jsonb',
|
|
31
|
+
isNullable: true,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: 'favorites',
|
|
35
|
+
type: 'jsonb',
|
|
36
|
+
isNullable: true,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'language',
|
|
40
|
+
type: 'varchar',
|
|
41
|
+
isNullable: true,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'theme',
|
|
45
|
+
type: 'varchar',
|
|
46
|
+
isNullable: true,
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
foreignKeys: [
|
|
50
|
+
{
|
|
51
|
+
columnNames: [ 'accountId' ],
|
|
52
|
+
referencedTableName: 'account',
|
|
53
|
+
referencedColumnNames: [ 'id' ],
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
indices: [
|
|
57
|
+
new TableIndex({
|
|
58
|
+
name: 'IDX_ACCOUNT_SETTINGS',
|
|
59
|
+
columnNames: [
|
|
60
|
+
'id',
|
|
61
|
+
'accountId',
|
|
62
|
+
'calendar',
|
|
63
|
+
'favorites',
|
|
64
|
+
'language',
|
|
65
|
+
'theme',
|
|
66
|
+
],
|
|
67
|
+
}),
|
|
68
|
+
],
|
|
69
|
+
})
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
public async down (queryRunner: QueryRunner): Promise<void> {
|
|
75
|
+
const hasTable = await DatabaseUtils.checkHasTable('account_settings', queryRunner);
|
|
76
|
+
|
|
77
|
+
if (!hasTable) return;
|
|
78
|
+
|
|
79
|
+
await DatabaseUtils.dropTableForeignKeys('account_settings', [ 'accountId' ], queryRunner);
|
|
80
|
+
await DatabaseUtils.dropIndex('account_settings', 'IDX_ACCOUNT_SETTINGS', queryRunner);
|
|
81
|
+
await queryRunner.dropTable('account_settings');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
}
|
|
@@ -12,6 +12,7 @@ import { CreateAccountAddressTable1750690818577 } from './1750690818577-CreateAc
|
|
|
12
12
|
import { CreateAccountDetailsTable1750691840822 } from './1750691840822-CreateAccountDetailsTable';
|
|
13
13
|
import { CreateProfileModuleTable1751576312683 } from './1751576312683-CreateProfileModuleTable';
|
|
14
14
|
import { CreateAccountDeviceTable1754426499576 } from './1754426499576-CreateAccountDeviceTable';
|
|
15
|
+
import { CreateAccountSettingsTable1758382227488 } from './1758382227488-CreateAccountSettingsTable';
|
|
15
16
|
|
|
16
17
|
export const Migrations = {
|
|
17
18
|
Init1748448461165,
|
|
@@ -28,4 +29,5 @@ export const Migrations = {
|
|
|
28
29
|
CreateAccountDetailsTable1750691840822,
|
|
29
30
|
CreateProfileModuleTable1751576312683,
|
|
30
31
|
CreateAccountDeviceTable1754426499576,
|
|
32
|
+
CreateAccountSettingsTable1758382227488,
|
|
31
33
|
};
|
package/src/interfaces/aws.ts
CHANGED
|
@@ -195,6 +195,7 @@ export namespace AmazonSQS {
|
|
|
195
195
|
export interface Request {
|
|
196
196
|
data: {
|
|
197
197
|
queue: string;
|
|
198
|
+
limit?: number;
|
|
198
199
|
};
|
|
199
200
|
credentials: Credentials;
|
|
200
201
|
}
|
|
@@ -203,6 +204,16 @@ export namespace AmazonSQS {
|
|
|
203
204
|
messages: T[];
|
|
204
205
|
}
|
|
205
206
|
}
|
|
207
|
+
|
|
208
|
+
export namespace DeleteMessages {
|
|
209
|
+
export interface Request {
|
|
210
|
+
data: {
|
|
211
|
+
queue: string;
|
|
212
|
+
messages: string[];
|
|
213
|
+
};
|
|
214
|
+
credentials: Credentials;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
206
217
|
}
|
|
207
218
|
|
|
208
219
|
export interface IAmazonCloudwatchService {
|
|
@@ -231,4 +242,5 @@ export interface IAmazonSQSService {
|
|
|
231
242
|
publishMessage(req: AmazonSQS.PublishMessage.Request): Promise<void>;
|
|
232
243
|
consumeMessage<T>(req: AmazonSQS.ConsumeMessage.Request): Promise<AmazonSQS.ConsumeMessage.Response<T>>;
|
|
233
244
|
consumeMessages<T>(req: AmazonSQS.ConsumeMessages.Request): Promise<AmazonSQS.ConsumeMessages.Response<T>>;
|
|
245
|
+
deleteMessages(req: AmazonSQS.DeleteMessages.Request): Promise<void>;
|
|
234
246
|
}
|
package/src/services/aws/sqs.ts
CHANGED
|
@@ -76,12 +76,12 @@ class AmazonSQSService implements IAmazonSQSService {
|
|
|
76
76
|
|
|
77
77
|
const { Messages } = await client.receiveMessage({
|
|
78
78
|
QueueUrl,
|
|
79
|
-
MaxNumberOfMessages: 10,
|
|
79
|
+
MaxNumberOfMessages: typeof data.limit === 'number' ? Math.min(data.limit, 10) : 10,
|
|
80
80
|
});
|
|
81
81
|
|
|
82
82
|
if (Messages && Messages.length > 0) {
|
|
83
83
|
await Promise.allSettled(
|
|
84
|
-
Messages?.map(message =>
|
|
84
|
+
Messages?.map((message) =>
|
|
85
85
|
client.send(
|
|
86
86
|
new DeleteMessageCommand({
|
|
87
87
|
QueueUrl,
|
|
@@ -92,9 +92,7 @@ class AmazonSQSService implements IAmazonSQSService {
|
|
|
92
92
|
);
|
|
93
93
|
|
|
94
94
|
return {
|
|
95
|
-
messages: Messages?.map(
|
|
96
|
-
(message) => parseRecord(message?.Body) as T
|
|
97
|
-
),
|
|
95
|
+
messages: Messages?.map((message) => parseRecord(message?.Body) as T),
|
|
98
96
|
};
|
|
99
97
|
}
|
|
100
98
|
|
|
@@ -102,6 +100,29 @@ class AmazonSQSService implements IAmazonSQSService {
|
|
|
102
100
|
messages: [],
|
|
103
101
|
};
|
|
104
102
|
}
|
|
103
|
+
|
|
104
|
+
async deleteMessages ({ credentials, data }: AmazonSQS.DeleteMessages.Request): Promise<void> {
|
|
105
|
+
const client: SQS = new SQS({
|
|
106
|
+
credentials: {
|
|
107
|
+
accessKeyId: credentials.accessKey,
|
|
108
|
+
secretAccessKey: credentials.secretKey,
|
|
109
|
+
},
|
|
110
|
+
region: credentials.region,
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
const { QueueUrl } = await client.getQueueUrl({ QueueName: data.queue });
|
|
114
|
+
|
|
115
|
+
await Promise.allSettled(
|
|
116
|
+
data.messages.map((message) => {
|
|
117
|
+
client.send(
|
|
118
|
+
new DeleteMessageCommand({
|
|
119
|
+
QueueUrl,
|
|
120
|
+
ReceiptHandle: message,
|
|
121
|
+
})
|
|
122
|
+
);
|
|
123
|
+
})
|
|
124
|
+
);
|
|
125
|
+
}
|
|
105
126
|
}
|
|
106
127
|
|
|
107
128
|
export default new AmazonSQSService();
|
package/src/services/date.ts
CHANGED
|
@@ -15,6 +15,8 @@ class DateService {
|
|
|
15
15
|
if (DateTime.fromFormat(inp, format).isValid) {
|
|
16
16
|
return DateTime.fromFormat(inp, format).toJSDate();
|
|
17
17
|
}
|
|
18
|
+
|
|
19
|
+
return DateTime.local().toJSDate();
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
public toFormat (inp: Date | string, format = DATE.SYSTEM.COMMON_DATE): string {
|
|
@@ -141,11 +143,11 @@ class DateService {
|
|
|
141
143
|
return months;
|
|
142
144
|
}
|
|
143
145
|
|
|
144
|
-
public isSameDay (inp: Date, compare = this.getCurrentDate()): boolean {
|
|
145
|
-
const
|
|
146
|
-
const
|
|
146
|
+
public isSameDay (inp: Date | string, compare = this.getCurrentDate()): boolean {
|
|
147
|
+
const startDate = DateTime.fromJSDate(this.toDate(inp)).startOf('day');
|
|
148
|
+
const endDate = DateTime.fromJSDate(this.toDate(compare)).startOf('day');
|
|
147
149
|
|
|
148
|
-
return
|
|
150
|
+
return startDate.equals(endDate);
|
|
149
151
|
}
|
|
150
152
|
|
|
151
153
|
public isToday (date: Date): boolean {
|