@dvsa/appdev-api-common 0.4.0 → 0.4.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dvsa/appdev-api-common",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "keywords": [
5
5
  "dvsa",
6
6
  "nodejs",
@@ -28,6 +28,7 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "ajv": "^8.17.1",
31
+ "ajv-formats": "^3.0.1",
31
32
  "dayjs": "^1.11.13",
32
33
  "jose": "^5.9.6"
33
34
  },
@@ -36,9 +37,9 @@
36
37
  "@dvsa/biome-config": "0.3.0",
37
38
  "@types/aws-lambda": "^8.10.145",
38
39
  "@types/express": "^5.0.0",
39
- "@types/jest": "^29.5.12",
40
+ "@types/jest": "^29.5.14",
40
41
  "@types/node": "^20.14.8",
41
- "husky": "^9.1.6",
42
+ "husky": "^9.1.7",
42
43
  "jest": "^29.7.0",
43
44
  "lint-staged": "^15.2.10",
44
45
  "rimraf": "^6.0.1",
@@ -14,11 +14,12 @@ export declare class DateTime {
14
14
  day(): number;
15
15
  toString(): string;
16
16
  toISOString(): string;
17
- isAfter(targetDate: AcceptableDate): boolean;
18
17
  diff(targetDate: AcceptableDate, unit: dayjs.QUnitType, precise?: boolean): number;
19
18
  daysDiff(targetDate: AcceptableDate): number;
20
19
  compareDuration(targetDate: AcceptableDate, unit: dayjs.QUnitType): number;
21
20
  isBefore(targetDate: AcceptableDate): boolean;
21
+ isAfter(targetDate: AcceptableDate): boolean;
22
+ isBetween(startDate: AcceptableDate, endDate: AcceptableDate): boolean;
22
23
  static today(): Date;
23
24
  }
24
25
  export {};
@@ -56,10 +56,6 @@ class DateTime {
56
56
  toISOString() {
57
57
  return this.instance.toISOString();
58
58
  }
59
- isAfter(targetDate) {
60
- const date = new DateTime(targetDate);
61
- return this.instance.isAfter(date.instance);
62
- }
63
59
  diff(targetDate, unit, precise) {
64
60
  const date = new DateTime(targetDate);
65
61
  return this.instance.diff(date.instance, unit, precise);
@@ -78,6 +74,16 @@ class DateTime {
78
74
  const date = new DateTime(targetDate);
79
75
  return this.instance.isBefore(date.instance);
80
76
  }
77
+ isAfter(targetDate) {
78
+ const date = new DateTime(targetDate);
79
+ return this.instance.isAfter(date.instance);
80
+ }
81
+ isBetween(startDate, endDate) {
82
+ const start = new DateTime(startDate);
83
+ const end = new DateTime(endDate);
84
+ return (this.instance.isAfter(start.instance) &&
85
+ this.instance.isBefore(end.instance));
86
+ }
81
87
  static today() {
82
88
  return (0, dayjs_1.default)().toDate();
83
89
  }
@@ -5,8 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ValidateRequestBody = ValidateRequestBody;
7
7
  const ajv_1 = __importDefault(require("ajv"));
8
+ const ajv_formats_1 = __importDefault(require("ajv-formats"));
8
9
  const http_status_codes_1 = require("../api/http-status-codes");
9
10
  const ajv = new ajv_1.default({ removeAdditional: true, allErrors: true });
11
+ (0, ajv_formats_1.default)(ajv);
10
12
  ajv.addKeyword("tsEnumNames");
11
13
  /**
12
14
  * Decorator tp validate an express request body against a specified schema