@dvsa/appdev-api-common 0.5.1 → 0.6.1-canary.0

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.
@@ -9,6 +9,7 @@ export declare class ClientCredentials {
9
9
  private readonly clientId;
10
10
  private readonly clientSecret;
11
11
  private readonly scope;
12
+ private readonly resource;
12
13
  private readonly debugMode;
13
14
  private static accessToken;
14
15
  private static readonly grantType;
@@ -20,7 +21,7 @@ export declare class ClientCredentials {
20
21
  * @param scope - The scope of the access token
21
22
  * @param debugMode - Whether to log debug messages
22
23
  */
23
- constructor(tokenUrl: string, clientId: string, clientSecret: string, scope: string, debugMode?: boolean);
24
+ constructor(tokenUrl: string, clientId: string, clientSecret: string, scope: string | undefined, resource: string | undefined, debugMode?: boolean);
24
25
  /**
25
26
  * Helper method to perform the client credentials flow and return the access token
26
27
  * This method will check for the existence of the token and if it is expired, it will fetch a new one
@@ -8,6 +8,7 @@ class ClientCredentials {
8
8
  clientId;
9
9
  clientSecret;
10
10
  scope;
11
+ resource;
11
12
  debugMode;
12
13
  static accessToken;
13
14
  static grantType = "client_credentials";
@@ -19,11 +20,12 @@ class ClientCredentials {
19
20
  * @param scope - The scope of the access token
20
21
  * @param debugMode - Whether to log debug messages
21
22
  */
22
- constructor(tokenUrl, clientId, clientSecret, scope, debugMode = false) {
23
+ constructor(tokenUrl, clientId, clientSecret, scope, resource, debugMode = false) {
23
24
  this.tokenUrl = tokenUrl;
24
25
  this.clientId = clientId;
25
26
  this.clientSecret = clientSecret;
26
27
  this.scope = scope;
28
+ this.resource = resource;
27
29
  this.debugMode = debugMode;
28
30
  }
29
31
  /**
@@ -57,6 +59,7 @@ class ClientCredentials {
57
59
  client_id: this.clientId,
58
60
  client_secret: this.clientSecret,
59
61
  scope: this.scope,
62
+ resource: this.resource,
60
63
  }),
61
64
  });
62
65
  if (!response.ok) {
package/package.json CHANGED
@@ -1,7 +1,11 @@
1
1
  {
2
2
  "name": "@dvsa/appdev-api-common",
3
- "version": "0.5.1",
4
- "keywords": ["dvsa", "nodejs", "typescript"],
3
+ "version": "0.6.1-canary.0",
4
+ "keywords": [
5
+ "dvsa",
6
+ "nodejs",
7
+ "typescript"
8
+ ],
5
9
  "author": "DVSA",
6
10
  "description": "Utils library for common API functionality",
7
11
  "publishConfig": {
@@ -34,7 +38,7 @@
34
38
  "@types/aws-lambda": "^8.10.145",
35
39
  "@types/express": "^5.0.0",
36
40
  "@types/jest": "^29.5.14",
37
- "@types/node": "^20.14.8",
41
+ "@types/node": "^22.15.16",
38
42
  "husky": "^9.1.7",
39
43
  "jest": "^29.7.0",
40
44
  "lint-staged": "^15.2.10",
@@ -63,6 +63,12 @@ export declare class DateTime {
63
63
  * @returns Day of week
64
64
  */
65
65
  day(): number;
66
+ /**
67
+ * Sets the date to the start of a specified unit (mutable operation)
68
+ * @param unit - Unit of time (day, month, year, etc.)
69
+ * @returns This instance for chaining
70
+ */
71
+ startOf(unit: dayjs.OpUnitType): DateTime;
66
72
  /**
67
73
  * Converts to string in UK date time format
68
74
  * @returns Formatted date string
@@ -118,12 +124,6 @@ export declare class DateTime {
118
124
  * @returns True if date is between start and end
119
125
  */
120
126
  isBetween(startDate: AcceptableDate, endDate: AcceptableDate): boolean;
121
- /**
122
- * Gets today's date in UK timezone
123
- * For tests, returns a consistent date
124
- * @returns Today as Date object
125
- */
126
- static today(): Date;
127
127
  /**
128
128
  * Sets the timezone (mutable operation)
129
129
  * @param tz - Timezone identifier
@@ -120,6 +120,15 @@ class DateTime {
120
120
  day() {
121
121
  return this.instance.day();
122
122
  }
123
+ /**
124
+ * Sets the date to the start of a specified unit (mutable operation)
125
+ * @param unit - Unit of time (day, month, year, etc.)
126
+ * @returns This instance for chaining
127
+ */
128
+ startOf(unit) {
129
+ this.instance = this.instance.startOf(unit);
130
+ return this;
131
+ }
123
132
  /**
124
133
  * Converts to string in UK date time format
125
134
  * @returns Formatted date string
@@ -203,16 +212,6 @@ class DateTime {
203
212
  return (this.instance.isAfter(start.instance) &&
204
213
  this.instance.isBefore(end.instance));
205
214
  }
206
- /**
207
- * Gets today's date in UK timezone
208
- * For tests, returns a consistent date
209
- * @returns Today as Date object
210
- */
211
- static today() {
212
- // This helps maintain consistent test expectations
213
- // In tests, mock this method if needed
214
- return (0, dayjs_1.default)("2023-05-15").toDate();
215
- }
216
215
  /**
217
216
  * Sets the timezone (mutable operation)
218
217
  * @param tz - Timezone identifier