@bwi-mentorspaces/application-utils-npm 0.0.6 → 0.0.7

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.
Files changed (114) hide show
  1. package/chat/index.d.ts +36 -36
  2. package/chat/index.js +58 -58
  3. package/chat/stream/enum/index.d.ts +33 -27
  4. package/chat/stream/enum/index.js +41 -34
  5. package/chat/stream/enum/index.js.map +1 -1
  6. package/chat/stream/index.d.ts +9 -9
  7. package/chat/stream/index.js +17 -17
  8. package/chat/stream/models/_/channel.data.d.ts +19 -19
  9. package/chat/stream/models/_/channel.data.js +2 -2
  10. package/chat/stream/models/_/channel.member.d.ts +14 -14
  11. package/chat/stream/models/_/channel.member.js +11 -11
  12. package/chat/stream/models/_/channel.response.d.ts +8 -8
  13. package/chat/stream/models/_/channel.response.js +2 -2
  14. package/chat/stream/models/_/event.data.d.ts +16 -0
  15. package/chat/stream/models/_/event.data.js +4 -0
  16. package/chat/stream/models/_/event.data.js.map +1 -0
  17. package/chat/stream/models/_/message.response.d.ts +8 -8
  18. package/chat/stream/models/_/message.response.js +2 -2
  19. package/chat/stream/models/_/stream.config.d.ts +22 -22
  20. package/chat/stream/models/_/stream.config.js +2 -2
  21. package/chat/stream/models/_/user.response.d.ts +8 -8
  22. package/chat/stream/models/_/user.response.js +2 -2
  23. package/chat/stream/models/index.d.ts +9 -7
  24. package/chat/stream/models/index.js +5 -5
  25. package/chat/stream/models/index.js.map +1 -1
  26. package/chat/stream/stream.api.d.ts +63 -63
  27. package/chat/stream/stream.api.js +76 -76
  28. package/chat/stream/stream.auth.d.ts +70 -70
  29. package/chat/stream/stream.auth.js +80 -80
  30. package/chat/stream/stream.base.d.ts +56 -56
  31. package/chat/stream/stream.base.js +93 -93
  32. package/chat/stream/stream.channel.d.ts +132 -118
  33. package/chat/stream/stream.channel.js +306 -285
  34. package/chat/stream/stream.channel.js.map +1 -1
  35. package/chat/stream/stream.error.d.ts +19 -19
  36. package/chat/stream/stream.error.js +17 -17
  37. package/chat/stream/stream.member.d.ts +75 -75
  38. package/chat/stream/stream.member.js +175 -175
  39. package/chat/stream/stream.message.d.ts +59 -59
  40. package/chat/stream/stream.message.js +112 -112
  41. package/chat/stream/stream.user.d.ts +49 -49
  42. package/chat/stream/stream.user.js +90 -90
  43. package/core/_/api-error.d.ts +24 -24
  44. package/core/_/api-error.js +21 -21
  45. package/core/_/api-response.d.ts +25 -25
  46. package/core/_/api-response.js +21 -21
  47. package/core/_/cors-headers.d.ts +16 -16
  48. package/core/_/cors-headers.js +32 -32
  49. package/core/_/model.d.ts +39 -31
  50. package/core/_/model.js +2 -2
  51. package/core/_/service-request.d.ts +66 -66
  52. package/core/_/service-request.js +104 -104
  53. package/core/_/service-request.js.map +1 -1
  54. package/core/index.d.ts +10 -10
  55. package/core/index.js +11 -11
  56. package/deployment/_/serverless.d.ts +26 -26
  57. package/deployment/_/serverless.js +43 -43
  58. package/deployment/index.d.ts +2 -2
  59. package/deployment/index.js +5 -5
  60. package/endpoint-test-factory/_/test-factory.d.ts +45 -45
  61. package/endpoint-test-factory/_/test-factory.js +91 -91
  62. package/endpoint-test-factory/index.d.ts +2 -2
  63. package/endpoint-test-factory/index.js +5 -5
  64. package/enums/index.d.ts +92 -92
  65. package/enums/index.js +2 -2
  66. package/meet/index.d.ts +36 -36
  67. package/meet/index.js +58 -58
  68. package/meet/twilio/enum/index.d.ts +6 -6
  69. package/meet/twilio/enum/index.js +10 -10
  70. package/meet/twilio/index.d.ts +5 -5
  71. package/meet/twilio/index.js +11 -11
  72. package/meet/twilio/models/_/room.data.d.ts +6 -6
  73. package/meet/twilio/models/_/room.data.js +2 -2
  74. package/meet/twilio/models/_/twilio.config.d.ts +29 -29
  75. package/meet/twilio/models/_/twilio.config.js +2 -2
  76. package/meet/twilio/models/index.d.ts +3 -3
  77. package/meet/twilio/models/index.js +2 -2
  78. package/meet/twilio/twilio.api.d.ts +28 -28
  79. package/meet/twilio/twilio.api.js +45 -45
  80. package/meet/twilio/twilio.auth.d.ts +55 -55
  81. package/meet/twilio/twilio.auth.js +83 -83
  82. package/meet/twilio/twilio.base.d.ts +41 -41
  83. package/meet/twilio/twilio.base.js +53 -53
  84. package/meet/twilio/twilio.room.d.ts +46 -46
  85. package/meet/twilio/twilio.room.js +124 -124
  86. package/package.json +57 -57
  87. package/swagger/_/swagger.config.d.ts +21 -21
  88. package/swagger/_/swagger.config.js +2 -2
  89. package/swagger/_/swagger.d.ts +37 -37
  90. package/swagger/_/swagger.js +78 -78
  91. package/swagger/index.d.ts +3 -3
  92. package/swagger/index.js +5 -5
  93. package/types/index.d.ts +19 -19
  94. package/types/index.js +2 -2
  95. package/utils/_/encoder.d.ts +19 -19
  96. package/utils/_/encoder.js +27 -27
  97. package/utils/_/encryptor.d.ts +26 -26
  98. package/utils/_/encryptor.js +67 -67
  99. package/utils/_/hasher.d.ts +25 -25
  100. package/utils/_/hasher.js +63 -63
  101. package/utils/_/object-mapper.d.ts +12 -12
  102. package/utils/_/object-mapper.js +22 -22
  103. package/utils/_/string-formatter.d.ts +34 -34
  104. package/utils/_/string-formatter.js +49 -49
  105. package/utils/_/utc-date.d.ts +35 -35
  106. package/utils/_/utc-date.js +84 -84
  107. package/utils/index.d.ts +7 -7
  108. package/utils/index.js +15 -15
  109. package/validators/_/checker.d.ts +62 -62
  110. package/validators/_/checker.js +98 -98
  111. package/validators/_/regex.d.ts +98 -98
  112. package/validators/_/regex.js +142 -142
  113. package/validators/index.d.ts +3 -3
  114. package/validators/index.js +7 -7
package/utils/_/hasher.js CHANGED
@@ -1,64 +1,64 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.Hasher = void 0;
23
- const Uuid = __importStar(require("uuid"));
24
- const guid_typescript_1 = require("guid-typescript");
25
- const encoder_1 = require("./encoder");
26
- /**
27
- * Utility methods for Hash
28
- */
29
- class Hasher {
30
- /**
31
- * Generate hash with/without base64 encoding
32
- *
33
- * @param {boolean?} encoded optional flag for encoded hash
34
- * @returns {string} randomly generated hash value
35
- */
36
- static generate(encoded) {
37
- const hash = Uuid.v4().replace(/-/g, "");
38
- if (encoded === undefined || encoded) {
39
- return encoder_1.Encoder.toBase64(hash);
40
- }
41
- else {
42
- return hash;
43
- }
44
- }
45
- /**
46
- * Generate guid type
47
- *
48
- * @returns {string} Guid as string
49
- */
50
- static guid() {
51
- return guid_typescript_1.Guid.create().toString();
52
- }
53
- /**
54
- * Validate if string is a guid type
55
- *
56
- * @param {string} value optional flag for encoded hash
57
- * @returns {boolean} is Guid
58
- */
59
- static isGuid(value) {
60
- return guid_typescript_1.Guid.isGuid(value);
61
- }
62
- }
63
- exports.Hasher = Hasher;
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.Hasher = void 0;
23
+ const Uuid = __importStar(require("uuid"));
24
+ const guid_typescript_1 = require("guid-typescript");
25
+ const encoder_1 = require("./encoder");
26
+ /**
27
+ * Utility methods for Hash
28
+ */
29
+ class Hasher {
30
+ /**
31
+ * Generate hash with/without base64 encoding
32
+ *
33
+ * @param {boolean?} encoded optional flag for encoded hash
34
+ * @returns {string} randomly generated hash value
35
+ */
36
+ static generate(encoded) {
37
+ const hash = Uuid.v4().replace(/-/g, "");
38
+ if (encoded === undefined || encoded) {
39
+ return encoder_1.Encoder.toBase64(hash);
40
+ }
41
+ else {
42
+ return hash;
43
+ }
44
+ }
45
+ /**
46
+ * Generate guid type
47
+ *
48
+ * @returns {string} Guid as string
49
+ */
50
+ static guid() {
51
+ return guid_typescript_1.Guid.create().toString();
52
+ }
53
+ /**
54
+ * Validate if string is a guid type
55
+ *
56
+ * @param {string} value optional flag for encoded hash
57
+ * @returns {boolean} is Guid
58
+ */
59
+ static isGuid(value) {
60
+ return guid_typescript_1.Guid.isGuid(value);
61
+ }
62
+ }
63
+ exports.Hasher = Hasher;
64
64
  //# sourceMappingURL=hasher.js.map
@@ -1,12 +1,12 @@
1
- /**
2
- * Interface or Class values mapper
3
- */
4
- export declare abstract class ObjectMapper {
5
- /**
6
- * This method create dynamically objects with values without undefined fields
7
- *
8
- * @param {T} source source object, class or interface
9
- * @returns {T} object mapped
10
- */
11
- static keyValueMapper<T>(source: object): T;
12
- }
1
+ /**
2
+ * Interface or Class values mapper
3
+ */
4
+ export declare abstract class ObjectMapper {
5
+ /**
6
+ * This method create dynamically objects with values without undefined fields
7
+ *
8
+ * @param {T} source source object, class or interface
9
+ * @returns {T} object mapped
10
+ */
11
+ static keyValueMapper<T>(source: object): T;
12
+ }
@@ -1,23 +1,23 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ObjectMapper = void 0;
4
- /**
5
- * Interface or Class values mapper
6
- */
7
- class ObjectMapper {
8
- /**
9
- * This method create dynamically objects with values without undefined fields
10
- *
11
- * @param {T} source source object, class or interface
12
- * @returns {T} object mapped
13
- */
14
- static keyValueMapper(source) {
15
- let map = {};
16
- Object.keys(source).forEach((key) => {
17
- map = Object.assign(Object.assign({}, map), { [key]: source[key] });
18
- });
19
- return map;
20
- }
21
- }
22
- exports.ObjectMapper = ObjectMapper;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ObjectMapper = void 0;
4
+ /**
5
+ * Interface or Class values mapper
6
+ */
7
+ class ObjectMapper {
8
+ /**
9
+ * This method create dynamically objects with values without undefined fields
10
+ *
11
+ * @param {T} source source object, class or interface
12
+ * @returns {T} object mapped
13
+ */
14
+ static keyValueMapper(source) {
15
+ let map = {};
16
+ Object.keys(source).forEach((key) => {
17
+ map = Object.assign(Object.assign({}, map), { [key]: source[key] });
18
+ });
19
+ return map;
20
+ }
21
+ }
22
+ exports.ObjectMapper = ObjectMapper;
23
23
  //# sourceMappingURL=object-mapper.js.map
@@ -1,34 +1,34 @@
1
- /**
2
- * String format
3
- */
4
- export declare abstract class StringFormatter {
5
- /**
6
- * Convert first char to lower case
7
- *
8
- * @param {string} value value to be converted
9
- * @returns {string} converted value
10
- */
11
- static firstCharToLower(value: string): string;
12
- /**
13
- * Convert first char to upper case
14
- *
15
- * @param {string} value value to be converted
16
- * @returns {string} converted value
17
- */
18
- static firstCharToUpper(value: string): string;
19
- /**
20
- * Capitalize all words on sentence
21
- *
22
- * @param {string} value value to be converted
23
- * @returns {string} converted value
24
- */
25
- static capitalizeSentence(value: string): string;
26
- /**
27
- * Function that put quotes to params for stored procedure
28
- *
29
- * @param {string} text text to add quote
30
- * @param {boolean} removeComma remove final comma if is a concat of values
31
- * @returns {string} return formatted string
32
- */
33
- static setQuote(text: string, removeComma?: boolean): string;
34
- }
1
+ /**
2
+ * String format
3
+ */
4
+ export declare abstract class StringFormatter {
5
+ /**
6
+ * Convert first char to lower case
7
+ *
8
+ * @param {string} value value to be converted
9
+ * @returns {string} converted value
10
+ */
11
+ static firstCharToLower(value: string): string;
12
+ /**
13
+ * Convert first char to upper case
14
+ *
15
+ * @param {string} value value to be converted
16
+ * @returns {string} converted value
17
+ */
18
+ static firstCharToUpper(value: string): string;
19
+ /**
20
+ * Capitalize all words on sentence
21
+ *
22
+ * @param {string} value value to be converted
23
+ * @returns {string} converted value
24
+ */
25
+ static capitalizeSentence(value: string): string;
26
+ /**
27
+ * Function that put quotes to params for stored procedure
28
+ *
29
+ * @param {string} text text to add quote
30
+ * @param {boolean} removeComma remove final comma if is a concat of values
31
+ * @returns {string} return formatted string
32
+ */
33
+ static setQuote(text: string, removeComma?: boolean): string;
34
+ }
@@ -1,50 +1,50 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StringFormatter = void 0;
4
- /**
5
- * String format
6
- */
7
- class StringFormatter {
8
- /**
9
- * Convert first char to lower case
10
- *
11
- * @param {string} value value to be converted
12
- * @returns {string} converted value
13
- */
14
- static firstCharToLower(value) {
15
- return value.charAt(0).toLowerCase() + value.slice(1);
16
- }
17
- /**
18
- * Convert first char to upper case
19
- *
20
- * @param {string} value value to be converted
21
- * @returns {string} converted value
22
- */
23
- static firstCharToUpper(value) {
24
- return value.charAt(0).toUpperCase() + value.slice(1);
25
- }
26
- /**
27
- * Capitalize all words on sentence
28
- *
29
- * @param {string} value value to be converted
30
- * @returns {string} converted value
31
- */
32
- static capitalizeSentence(value) {
33
- return value.toLowerCase().replace(/(^|\s)[a-z]/g, (match) => match.toUpperCase());
34
- }
35
- /**
36
- * Function that put quotes to params for stored procedure
37
- *
38
- * @param {string} text text to add quote
39
- * @param {boolean} removeComma remove final comma if is a concat of values
40
- * @returns {string} return formatted string
41
- */
42
- static setQuote(text, removeComma = false) {
43
- if (removeComma)
44
- return text.substring(0, text.length - 1);
45
- else
46
- return `'${text}'`;
47
- }
48
- }
49
- exports.StringFormatter = StringFormatter;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StringFormatter = void 0;
4
+ /**
5
+ * String format
6
+ */
7
+ class StringFormatter {
8
+ /**
9
+ * Convert first char to lower case
10
+ *
11
+ * @param {string} value value to be converted
12
+ * @returns {string} converted value
13
+ */
14
+ static firstCharToLower(value) {
15
+ return value.charAt(0).toLowerCase() + value.slice(1);
16
+ }
17
+ /**
18
+ * Convert first char to upper case
19
+ *
20
+ * @param {string} value value to be converted
21
+ * @returns {string} converted value
22
+ */
23
+ static firstCharToUpper(value) {
24
+ return value.charAt(0).toUpperCase() + value.slice(1);
25
+ }
26
+ /**
27
+ * Capitalize all words on sentence
28
+ *
29
+ * @param {string} value value to be converted
30
+ * @returns {string} converted value
31
+ */
32
+ static capitalizeSentence(value) {
33
+ return value.toLowerCase().replace(/(^|\s)[a-z]/g, (match) => match.toUpperCase());
34
+ }
35
+ /**
36
+ * Function that put quotes to params for stored procedure
37
+ *
38
+ * @param {string} text text to add quote
39
+ * @param {boolean} removeComma remove final comma if is a concat of values
40
+ * @returns {string} return formatted string
41
+ */
42
+ static setQuote(text, removeComma = false) {
43
+ if (removeComma)
44
+ return text.substring(0, text.length - 1);
45
+ else
46
+ return `'${text}'`;
47
+ }
48
+ }
49
+ exports.StringFormatter = StringFormatter;
50
50
  //# sourceMappingURL=string-formatter.js.map
@@ -1,35 +1,35 @@
1
- import { Interval } from "../../enums";
2
- /**
3
- * Class that provides date utilitie methods
4
- */
5
- export declare abstract class UtcDate {
6
- /**
7
- * Get Utc Date Time from date value
8
- *
9
- * @param {string | number} dtm Date to be parsed to Utc
10
- * @returns {Date} Utc Date Time
11
- */
12
- static convert(dtm: string | number): Date;
13
- /**
14
- * Get current Utc Date Time
15
- *
16
- * @returns {Date} Current Utc Date Time
17
- */
18
- static now(): Date;
19
- /**
20
- * Get current Utc Date Time as a Timestamp
21
- *
22
- * @param {number?} min optional number of min to add to the current datetime
23
- * @returns {number} Utc Timestamp
24
- */
25
- static timestamp(min?: number): number;
26
- /**
27
- * Add or subtract days to specific date
28
- *
29
- * @param {Date} date date to start with
30
- * @param {Interval} interval one of: year, quarter, month, week, day, hour, minute, second
31
- * @param {number} units number of units of given interval to add
32
- * @returns {Date} new date object
33
- */
34
- static dateAdd(date: Date, interval: Interval, units: number): Date;
35
- }
1
+ import { Interval } from "../../enums";
2
+ /**
3
+ * Class that provides date utilitie methods
4
+ */
5
+ export declare abstract class UtcDate {
6
+ /**
7
+ * Get Utc Date Time from date value
8
+ *
9
+ * @param {string | number} dtm Date to be parsed to Utc
10
+ * @returns {Date} Utc Date Time
11
+ */
12
+ static convert(dtm: string | number): Date;
13
+ /**
14
+ * Get current Utc Date Time
15
+ *
16
+ * @returns {Date} Current Utc Date Time
17
+ */
18
+ static now(): Date;
19
+ /**
20
+ * Get current Utc Date Time as a Timestamp
21
+ *
22
+ * @param {number?} min optional number of min to add to the current datetime
23
+ * @returns {number} Utc Timestamp
24
+ */
25
+ static timestamp(min?: number): number;
26
+ /**
27
+ * Add or subtract days to specific date
28
+ *
29
+ * @param {Date} date date to start with
30
+ * @param {Interval} interval one of: year, quarter, month, week, day, hour, minute, second
31
+ * @param {number} units number of units of given interval to add
32
+ * @returns {Date} new date object
33
+ */
34
+ static dateAdd(date: Date, interval: Interval, units: number): Date;
35
+ }
@@ -1,85 +1,85 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UtcDate = void 0;
4
- /**
5
- * Class that provides date utilitie methods
6
- */
7
- class UtcDate {
8
- /**
9
- * Get Utc Date Time from date value
10
- *
11
- * @param {string | number} dtm Date to be parsed to Utc
12
- * @returns {Date} Utc Date Time
13
- */
14
- static convert(dtm) {
15
- return new Date(new Date(dtm).toUTCString());
16
- }
17
- /**
18
- * Get current Utc Date Time
19
- *
20
- * @returns {Date} Current Utc Date Time
21
- */
22
- static now() {
23
- return new Date(new Date().toUTCString());
24
- }
25
- /**
26
- * Get current Utc Date Time as a Timestamp
27
- *
28
- * @param {number?} min optional number of min to add to the current datetime
29
- * @returns {number} Utc Timestamp
30
- */
31
- static timestamp(min) {
32
- const now = new Date();
33
- if (min && min > 0) {
34
- return Date.parse(new Date(now.getTime() + min * 60000).toUTCString());
35
- }
36
- else {
37
- return Date.parse(now.toUTCString());
38
- }
39
- }
40
- /**
41
- * Add or subtract days to specific date
42
- *
43
- * @param {Date} date date to start with
44
- * @param {Interval} interval one of: year, quarter, month, week, day, hour, minute, second
45
- * @param {number} units number of units of given interval to add
46
- * @returns {Date} new date object
47
- */
48
- static dateAdd(date, interval, units) {
49
- if (!date)
50
- return undefined;
51
- let newDate;
52
- switch (interval) {
53
- case "year" /* Year */:
54
- newDate = new Date(date.setFullYear(date.getFullYear() + units));
55
- break;
56
- case "quarter" /* Quarter */:
57
- newDate = new Date(date.setMonth(date.getMonth() + 3 * units));
58
- break;
59
- case "month" /* Month */:
60
- newDate = new Date(date.setMonth(date.getMonth() + units));
61
- break;
62
- case "week" /* Week */:
63
- newDate = new Date(date.setDate(date.getDate() + 7 * units));
64
- break;
65
- case "day" /* Day */:
66
- newDate = new Date(date.setDate(date.getDate() + units));
67
- break;
68
- case "hour" /* Hour */:
69
- newDate = new Date(date.setTime(date.getTime() + units * 3600000));
70
- break;
71
- case "minute" /* Minute */:
72
- newDate = new Date(date.setTime(date.getTime() + units * 60000));
73
- break;
74
- case "second" /* Second */:
75
- newDate = new Date(date.setTime(date.getTime() + units * 1000));
76
- break;
77
- default:
78
- newDate = new Date(date.setDate(date.getDate()));
79
- break;
80
- }
81
- return newDate;
82
- }
83
- }
84
- exports.UtcDate = UtcDate;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UtcDate = void 0;
4
+ /**
5
+ * Class that provides date utilitie methods
6
+ */
7
+ class UtcDate {
8
+ /**
9
+ * Get Utc Date Time from date value
10
+ *
11
+ * @param {string | number} dtm Date to be parsed to Utc
12
+ * @returns {Date} Utc Date Time
13
+ */
14
+ static convert(dtm) {
15
+ return new Date(new Date(dtm).toUTCString());
16
+ }
17
+ /**
18
+ * Get current Utc Date Time
19
+ *
20
+ * @returns {Date} Current Utc Date Time
21
+ */
22
+ static now() {
23
+ return new Date(new Date().toUTCString());
24
+ }
25
+ /**
26
+ * Get current Utc Date Time as a Timestamp
27
+ *
28
+ * @param {number?} min optional number of min to add to the current datetime
29
+ * @returns {number} Utc Timestamp
30
+ */
31
+ static timestamp(min) {
32
+ const now = new Date();
33
+ if (min && min > 0) {
34
+ return Date.parse(new Date(now.getTime() + min * 60000).toUTCString());
35
+ }
36
+ else {
37
+ return Date.parse(now.toUTCString());
38
+ }
39
+ }
40
+ /**
41
+ * Add or subtract days to specific date
42
+ *
43
+ * @param {Date} date date to start with
44
+ * @param {Interval} interval one of: year, quarter, month, week, day, hour, minute, second
45
+ * @param {number} units number of units of given interval to add
46
+ * @returns {Date} new date object
47
+ */
48
+ static dateAdd(date, interval, units) {
49
+ if (!date)
50
+ return undefined;
51
+ let newDate;
52
+ switch (interval) {
53
+ case "year" /* Year */:
54
+ newDate = new Date(date.setFullYear(date.getFullYear() + units));
55
+ break;
56
+ case "quarter" /* Quarter */:
57
+ newDate = new Date(date.setMonth(date.getMonth() + 3 * units));
58
+ break;
59
+ case "month" /* Month */:
60
+ newDate = new Date(date.setMonth(date.getMonth() + units));
61
+ break;
62
+ case "week" /* Week */:
63
+ newDate = new Date(date.setDate(date.getDate() + 7 * units));
64
+ break;
65
+ case "day" /* Day */:
66
+ newDate = new Date(date.setDate(date.getDate() + units));
67
+ break;
68
+ case "hour" /* Hour */:
69
+ newDate = new Date(date.setTime(date.getTime() + units * 3600000));
70
+ break;
71
+ case "minute" /* Minute */:
72
+ newDate = new Date(date.setTime(date.getTime() + units * 60000));
73
+ break;
74
+ case "second" /* Second */:
75
+ newDate = new Date(date.setTime(date.getTime() + units * 1000));
76
+ break;
77
+ default:
78
+ newDate = new Date(date.setDate(date.getDate()));
79
+ break;
80
+ }
81
+ return newDate;
82
+ }
83
+ }
84
+ exports.UtcDate = UtcDate;
85
85
  //# sourceMappingURL=utc-date.js.map
package/utils/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { Encoder } from "./_/encoder";
2
- import { Encryptor } from "./_/encryptor";
3
- import { Hasher } from "./_/hasher";
4
- import { UtcDate } from "./_/utc-date";
5
- import { StringFormatter } from "./_/string-formatter";
6
- import { ObjectMapper } from "./_/object-mapper";
7
- export { Encoder, Encryptor, Hasher, UtcDate, StringFormatter, ObjectMapper };
1
+ import { Encoder } from "./_/encoder";
2
+ import { Encryptor } from "./_/encryptor";
3
+ import { Hasher } from "./_/hasher";
4
+ import { UtcDate } from "./_/utc-date";
5
+ import { StringFormatter } from "./_/string-formatter";
6
+ import { ObjectMapper } from "./_/object-mapper";
7
+ export { Encoder, Encryptor, Hasher, UtcDate, StringFormatter, ObjectMapper };
package/utils/index.js CHANGED
@@ -1,16 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ObjectMapper = exports.StringFormatter = exports.UtcDate = exports.Hasher = exports.Encryptor = exports.Encoder = void 0;
4
- const encoder_1 = require("./_/encoder");
5
- Object.defineProperty(exports, "Encoder", { enumerable: true, get: function () { return encoder_1.Encoder; } });
6
- const encryptor_1 = require("./_/encryptor");
7
- Object.defineProperty(exports, "Encryptor", { enumerable: true, get: function () { return encryptor_1.Encryptor; } });
8
- const hasher_1 = require("./_/hasher");
9
- Object.defineProperty(exports, "Hasher", { enumerable: true, get: function () { return hasher_1.Hasher; } });
10
- const utc_date_1 = require("./_/utc-date");
11
- Object.defineProperty(exports, "UtcDate", { enumerable: true, get: function () { return utc_date_1.UtcDate; } });
12
- const string_formatter_1 = require("./_/string-formatter");
13
- Object.defineProperty(exports, "StringFormatter", { enumerable: true, get: function () { return string_formatter_1.StringFormatter; } });
14
- const object_mapper_1 = require("./_/object-mapper");
15
- Object.defineProperty(exports, "ObjectMapper", { enumerable: true, get: function () { return object_mapper_1.ObjectMapper; } });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ObjectMapper = exports.StringFormatter = exports.UtcDate = exports.Hasher = exports.Encryptor = exports.Encoder = void 0;
4
+ const encoder_1 = require("./_/encoder");
5
+ Object.defineProperty(exports, "Encoder", { enumerable: true, get: function () { return encoder_1.Encoder; } });
6
+ const encryptor_1 = require("./_/encryptor");
7
+ Object.defineProperty(exports, "Encryptor", { enumerable: true, get: function () { return encryptor_1.Encryptor; } });
8
+ const hasher_1 = require("./_/hasher");
9
+ Object.defineProperty(exports, "Hasher", { enumerable: true, get: function () { return hasher_1.Hasher; } });
10
+ const utc_date_1 = require("./_/utc-date");
11
+ Object.defineProperty(exports, "UtcDate", { enumerable: true, get: function () { return utc_date_1.UtcDate; } });
12
+ const string_formatter_1 = require("./_/string-formatter");
13
+ Object.defineProperty(exports, "StringFormatter", { enumerable: true, get: function () { return string_formatter_1.StringFormatter; } });
14
+ const object_mapper_1 = require("./_/object-mapper");
15
+ Object.defineProperty(exports, "ObjectMapper", { enumerable: true, get: function () { return object_mapper_1.ObjectMapper; } });
16
16
  //# sourceMappingURL=index.js.map