@diia-inhouse/cms 1.7.0 → 2.1.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.
package/LICENCE.md CHANGED
@@ -18,40 +18,40 @@ or has expressed by any other means his willingness to license under the EUPL.
18
18
 
19
19
  In this Licence, the following terms have the following meaning:
20
20
 
21
- - ‘The Licence’: this Licence.
21
+ - ‘The Licence’: this Licence.
22
22
 
23
- - ‘The Original Work’: the work or software distributed or communicated by the
24
- Licensor under this Licence, available as Source Code and also as Executable
25
- Code as the case may be.
23
+ - ‘The Original Work’: the work or software distributed or communicated by the
24
+ Licensor under this Licence, available as Source Code and also as Executable
25
+ Code as the case may be.
26
26
 
27
- - ‘Derivative Works’: the works or software that could be created by the
28
- Licensee, based upon the Original Work or modifications thereof. This Licence
29
- does not define the extent of modification or dependence on the Original Work
30
- required in order to classify a work as a Derivative Work; this extent is
31
- determined by copyright law applicable in the country mentioned in Article 15.
27
+ - ‘Derivative Works’: the works or software that could be created by the
28
+ Licensee, based upon the Original Work or modifications thereof. This Licence
29
+ does not define the extent of modification or dependence on the Original Work
30
+ required in order to classify a work as a Derivative Work; this extent is
31
+ determined by copyright law applicable in the country mentioned in Article 15.
32
32
 
33
- - ‘The Work’: the Original Work or its Derivative Works.
33
+ - ‘The Work’: the Original Work or its Derivative Works.
34
34
 
35
- - ‘The Source Code’: the human-readable form of the Work which is the most
36
- convenient for people to study and modify.
35
+ - ‘The Source Code’: the human-readable form of the Work which is the most
36
+ convenient for people to study and modify.
37
37
 
38
- - ‘The Executable Code’: any code which has generally been compiled and which is
39
- meant to be interpreted by a computer as a program.
38
+ - ‘The Executable Code’: any code which has generally been compiled and which is
39
+ meant to be interpreted by a computer as a program.
40
40
 
41
- - ‘The Licensor’: the natural or legal person that distributes or communicates
42
- the Work under the Licence.
41
+ - ‘The Licensor’: the natural or legal person that distributes or communicates
42
+ the Work under the Licence.
43
43
 
44
- - ‘Contributor(s)’: any natural or legal person who modifies the Work under the
45
- Licence, or otherwise contributes to the creation of a Derivative Work.
44
+ - ‘Contributor(s)’: any natural or legal person who modifies the Work under the
45
+ Licence, or otherwise contributes to the creation of a Derivative Work.
46
46
 
47
- - ‘The Licensee’ or ‘You’: any natural or legal person who makes any usage of
48
- the Work under the terms of the Licence.
47
+ - ‘The Licensee’ or ‘You’: any natural or legal person who makes any usage of
48
+ the Work under the terms of the Licence.
49
49
 
50
- - ‘Distribution’ or ‘Communication’: any act of selling, giving, lending,
51
- renting, distributing, communicating, transmitting, or otherwise making
52
- available, online or offline, copies of the Work or providing access to its
53
- essential functionalities at the disposal of any other natural or legal
54
- person.
50
+ - ‘Distribution’ or ‘Communication’: any act of selling, giving, lending,
51
+ renting, distributing, communicating, transmitting, or otherwise making
52
+ available, online or offline, copies of the Work or providing access to its
53
+ essential functionalities at the disposal of any other natural or legal
54
+ person.
55
55
 
56
56
  2. Scope of the rights granted by the Licence
57
57
 
@@ -59,15 +59,15 @@ The Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
59
59
  sublicensable licence to do the following, for the duration of copyright vested
60
60
  in the Original Work:
61
61
 
62
- - use the Work in any circumstance and for all usage,
63
- - reproduce the Work,
64
- - modify the Work, and make Derivative Works based upon the Work,
65
- - communicate to the public, including the right to make available or display
66
- the Work or copies thereof to the public and perform publicly, as the case may
67
- be, the Work,
68
- - distribute the Work or copies thereof,
69
- - lend and rent the Work or copies thereof,
70
- - sublicense rights in the Work or copies thereof.
62
+ - use the Work in any circumstance and for all usage,
63
+ - reproduce the Work,
64
+ - modify the Work, and make Derivative Works based upon the Work,
65
+ - communicate to the public, including the right to make available or display
66
+ the Work or copies thereof to the public and perform publicly, as the case may
67
+ be, the Work,
68
+ - distribute the Work or copies thereof,
69
+ - lend and rent the Work or copies thereof,
70
+ - sublicense rights in the Work or copies thereof.
71
71
 
72
72
  Those rights can be exercised on any media, supports and formats, whether now
73
73
  known or later invented, as far as the applicable law permits so.
@@ -240,43 +240,43 @@ their choice.
240
240
 
241
241
  Without prejudice to specific agreement between parties,
242
242
 
243
- - any litigation resulting from the interpretation of this License, arising
244
- between the European Union institutions, bodies, offices or agencies, as a
245
- Licensor, and any Licensee, will be subject to the jurisdiction of the Court
246
- of Justice of the European Union, as laid down in article 272 of the Treaty on
247
- the Functioning of the European Union,
243
+ - any litigation resulting from the interpretation of this License, arising
244
+ between the European Union institutions, bodies, offices or agencies, as a
245
+ Licensor, and any Licensee, will be subject to the jurisdiction of the Court
246
+ of Justice of the European Union, as laid down in article 272 of the Treaty on
247
+ the Functioning of the European Union,
248
248
 
249
- - any litigation arising between other parties and resulting from the
250
- interpretation of this License, will be subject to the exclusive jurisdiction
251
- of the competent court where the Licensor resides or conducts its primary
252
- business.
249
+ - any litigation arising between other parties and resulting from the
250
+ interpretation of this License, will be subject to the exclusive jurisdiction
251
+ of the competent court where the Licensor resides or conducts its primary
252
+ business.
253
253
 
254
254
  15. Applicable Law
255
255
 
256
256
  Without prejudice to specific agreement between parties,
257
257
 
258
- - this Licence shall be governed by the law of the European Union Member State
259
- where the Licensor has his seat, resides or has his registered office,
258
+ - this Licence shall be governed by the law of the European Union Member State
259
+ where the Licensor has his seat, resides or has his registered office,
260
260
 
261
- - this licence shall be governed by Belgian law if the Licensor has no seat,
262
- residence or registered office inside a European Union Member State.
261
+ - this licence shall be governed by Belgian law if the Licensor has no seat,
262
+ residence or registered office inside a European Union Member State.
263
263
 
264
264
  Appendix
265
265
 
266
266
  ‘Compatible Licences’ according to Article 5 EUPL are:
267
267
 
268
- - GNU General Public License (GPL) v. 2, v. 3
269
- - GNU Affero General Public License (AGPL) v. 3
270
- - Open Software License (OSL) v. 2.1, v. 3.0
271
- - Eclipse Public License (EPL) v. 1.0
272
- - CeCILL v. 2.0, v. 2.1
273
- - Mozilla Public Licence (MPL) v. 2
274
- - GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3
275
- - Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) for
276
- works other than software
277
- - European Union Public Licence (EUPL) v. 1.1, v. 1.2
278
- - Québec Free and Open-Source Licence — Reciprocity (LiLiQ-R) or Strong
279
- Reciprocity (LiLiQ-R+).
268
+ - GNU General Public License (GPL) v. 2, v. 3
269
+ - GNU Affero General Public License (AGPL) v. 3
270
+ - Open Software License (OSL) v. 2.1, v. 3.0
271
+ - Eclipse Public License (EPL) v. 1.0
272
+ - CeCILL v. 2.0, v. 2.1
273
+ - Mozilla Public Licence (MPL) v. 2
274
+ - GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3
275
+ - Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) for
276
+ works other than software
277
+ - European Union Public Licence (EUPL) v. 1.1, v. 1.2
278
+ - Québec Free and Open-Source Licence — Reciprocity (LiLiQ-R) or Strong
279
+ Reciprocity (LiLiQ-R+).
280
280
 
281
281
  The European Commission may update this Appendix to later versions of the above
282
282
  licences without producing a new version of the EUPL, as long as they provide
@@ -6,5 +6,6 @@ var CmsCollectionType;
6
6
  CmsCollectionType["ErrorTemplate"] = "error-template";
7
7
  CmsCollectionType["Faq"] = "faq";
8
8
  CmsCollectionType["FaqCategory"] = "faq-categories";
9
+ CmsCollectionType["MilitaryDonationReports"] = "military-donation-reports";
9
10
  })(CmsCollectionType || (exports.CmsCollectionType = CmsCollectionType = {}));
10
11
  //# sourceMappingURL=cms.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cms.js","sourceRoot":"","sources":["../../src/interfaces/cms.ts"],"names":[],"mappings":";;;AAAA,IAAY,iBAIX;AAJD,WAAY,iBAAiB;IACzB,qDAAgC,CAAA;IAChC,gCAAW,CAAA;IACX,mDAA8B,CAAA;AAClC,CAAC,EAJW,iBAAiB,iCAAjB,iBAAiB,QAI5B"}
1
+ {"version":3,"file":"cms.js","sourceRoot":"","sources":["../../src/interfaces/cms.ts"],"names":[],"mappings":";;;AAAA,IAAY,iBAKX;AALD,WAAY,iBAAiB;IACzB,qDAAgC,CAAA;IAChC,gCAAW,CAAA;IACX,mDAA8B,CAAA;IAC9B,0EAAqD,CAAA;AACzD,CAAC,EALW,iBAAiB,iCAAjB,iBAAiB,QAK5B"}
@@ -14,6 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.MetricLabels = void 0;
17
18
  __exportStar(require("./cms"), exports);
18
19
  __exportStar(require("./config"), exports);
20
+ exports.MetricLabels = {
21
+ strapiGetList: 'strapiGetList',
22
+ strapiGetLatestRecord: 'strapiGetLatestRecord',
23
+ };
19
24
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAqB;AAErB,2CAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,wCAAqB;AAErB,2CAAwB;AAEX,QAAA,YAAY,GAAG;IACxB,aAAa,EAAE,eAAe;IAC9B,qBAAqB,EAAE,uBAAuB;CACxC,CAAA"}
@@ -15,18 +15,30 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.CmsService = void 0;
37
+ const node_https_1 = require("node:https");
27
38
  const qs = __importStar(require("qs"));
28
39
  const errors_1 = require("@diia-inhouse/errors");
29
40
  const types_1 = require("@diia-inhouse/types");
41
+ const interfaces_1 = require("../interfaces");
30
42
  class CmsService {
31
43
  cmsConfig;
32
44
  httpService;
@@ -37,27 +49,51 @@ class CmsService {
37
49
  this.logger = logger;
38
50
  }
39
51
  async getList(collectionType, options, dataMapper) {
52
+ const response = await this.sendRequest(collectionType, options, interfaces_1.MetricLabels.strapiGetList);
53
+ const { data, meta } = response.body;
54
+ return {
55
+ meta,
56
+ data: data.map((item) => dataMapper.toEntity(item)),
57
+ };
58
+ }
59
+ async getLatestRecord(collectionType, options, dataMapper) {
60
+ options.sort = this.getSortOptions(options.sort);
61
+ options.pagination = { page: 1, pageSize: 1 };
62
+ const response = await this.sendRequest(collectionType, options, interfaces_1.MetricLabels.strapiGetLatestRecord);
63
+ const { data, meta } = response.body;
64
+ if (data.length > 0) {
65
+ return { meta, data: dataMapper.toEntity(data[0]) };
66
+ }
67
+ this.logger.info('StrapiService: no record found');
68
+ return null;
69
+ }
70
+ getSortOptions(sort) {
71
+ const sortByUpdatedAt = 'updatedAt:desc';
72
+ if (Array.isArray(sort)) {
73
+ return [...sort, sortByUpdatedAt];
74
+ }
75
+ if (typeof sort === 'string') {
76
+ return [sort, sortByUpdatedAt];
77
+ }
78
+ return sortByUpdatedAt;
79
+ }
80
+ async sendRequest(collectionType, options, metricLabel) {
40
81
  const path = `/api/${collectionType}?${qs.stringify(options, { encodeValuesOnly: true })}`;
41
82
  this.logger.info(`StrapiService: request data`, { collectionType, path });
42
- const [err, response = {}] = await this.httpService.get({
43
- path,
44
- host: this.cmsConfig.host,
45
- port: this.cmsConfig.port,
83
+ const response = await this.httpService.get(path, {
84
+ baseUrl: `${this.cmsConfig.host}:${this.cmsConfig?.port}`,
46
85
  headers: { Authorization: `Bearer ${this.cmsConfig.token}` },
47
- rejectUnauthorized: false,
48
86
  timeout: 30000,
87
+ httpsAgent: new node_https_1.Agent({ rejectUnauthorized: false }),
88
+ metricLabel,
49
89
  });
50
- if (err || response?.statusCode !== types_1.HttpStatusCode.OK) {
51
- const { statusCode, data } = err ?? response;
52
- this.logger.error('StrapiService: failed to retrieve data', { statusCode, data });
90
+ if (!response.isOk || response?.statusCode !== types_1.HttpStatusCode.OK) {
91
+ const { statusCode, body } = response;
92
+ this.logger.error('StrapiService: failed to retrieve data', { statusCode, body });
53
93
  throw new errors_1.ServiceUnavailableError('StrapiService: failed to retrieve data');
54
94
  }
55
- const { data, meta } = response.data;
56
- this.logger.info(`StrapiService: data retrieved`, { collectionType, meta });
57
- return {
58
- data: data.map((item) => dataMapper.toEntity(item.attributes)),
59
- meta,
60
- };
95
+ this.logger.info(`StrapiService: data retrieved`, { collectionType, body: response?.body });
96
+ return response;
61
97
  }
62
98
  }
63
99
  exports.CmsService = CmsService;
@@ -1 +1 @@
1
- {"version":3,"file":"cms.js","sourceRoot":"","sources":["../../src/services/cms.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAwB;AAExB,iDAA8D;AAE9D,+CAA4D;AAK5D,MAAa,UAAU;IAEE;IACA;IACA;IAHrB,YACqB,SAAuB,EACvB,WAAwB,EACxB,MAAc;QAFd,cAAS,GAAT,SAAS,CAAc;QACvB,gBAAW,GAAX,WAAW,CAAa;QACxB,WAAM,GAAN,MAAM,CAAQ;IAChC,CAAC;IAEJ,KAAK,CAAC,OAAO,CACT,cAAiC,EACjC,OAA0B,EAC1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AO,EAAE,KAAK;YACd,UAAU,EAAE,IAAI,kBAAK,CAAC,EAAE,kBAAkB,EAAE,KAAK,EAAE,CAAC;YACpD,WAAW;SACd,CAAC,CAAA;QAEF,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,QAAQ,EAAE,UAAU,KAAK,sBAAc,CAAC,EAAE,EAAE,CAAC;YAC/D,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAA;YAErC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,wCAAwC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAA;YAEjF,MAAM,IAAI,gCAAuB,CAAC,wCAAwC,CAAC,CAAA;QAC/E,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,+BAA+B,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;QAE3F,OAAO,QAAQ,CAAA;IACnB,CAAC;CACJ;AAtFD,gCAsFC"}
@@ -1,7 +1,8 @@
1
1
  export declare enum CmsCollectionType {
2
2
  ErrorTemplate = "error-template",
3
3
  Faq = "faq",
4
- FaqCategory = "faq-categories"
4
+ FaqCategory = "faq-categories",
5
+ MilitaryDonationReports = "military-donation-reports"
5
6
  }
6
7
  export interface CmsBaseAttributes {
7
8
  createdAt: string;
@@ -36,9 +37,9 @@ export interface CmsQuerySelector<T> {
36
37
  $endsWith?: T extends string ? string : never;
37
38
  }
38
39
  export interface CmsRootFilterQuery<T> {
40
+ [key: string]: unknown;
39
41
  $or?: CmsFilterQuery<T>[];
40
42
  $and?: CmsFilterQuery<T>[];
41
- [key: string]: unknown;
42
43
  }
43
44
  export type ApplyBasicQueryCasting<T> = T | T[] | unknown;
44
45
  export type Condition<T> = ApplyBasicQueryCasting<T> | CmsQuerySelector<ApplyBasicQueryCasting<T>>;
@@ -64,6 +65,10 @@ export interface ListResponse<T> {
64
65
  data: T[];
65
66
  meta: CmsEntriesMeta;
66
67
  }
68
+ export interface Response<T> {
69
+ data: T;
70
+ meta: CmsEntriesMeta;
71
+ }
67
72
  export interface CmsEntriesMeta {
68
73
  pagination?: {
69
74
  start?: number;
@@ -1,6 +1,6 @@
1
1
  export interface StrapiConfig {
2
2
  isEnabled: boolean;
3
3
  host: string;
4
- port: number;
4
+ port?: number;
5
5
  token: string;
6
6
  }
@@ -1,2 +1,7 @@
1
1
  export * from './cms';
2
2
  export * from './config';
3
+ export declare const MetricLabels: {
4
+ readonly strapiGetList: "strapiGetList";
5
+ readonly strapiGetLatestRecord: "strapiGetLatestRecord";
6
+ };
7
+ export type MetricLabel = (typeof MetricLabels)[keyof typeof MetricLabels];
@@ -1,13 +1,17 @@
1
- import { HttpService } from '@diia-inhouse/http';
1
+ import { HttpClientService } from '@diia-inhouse/http';
2
2
  import { Logger } from '@diia-inhouse/types';
3
- import { StrapiConfig } from '../interfaces';
4
- import { CmsBaseAttributes, CmsCollectionType, GetListOptions, ListResponse } from '../interfaces/cms';
3
+ import { CmsBaseAttributes, CmsCollectionType, GetListOptions, ListResponse, MetricLabel, Response, StrapiConfig } from '../interfaces';
5
4
  export declare class CmsService {
6
5
  private readonly cmsConfig;
7
6
  private readonly httpService;
8
7
  private readonly logger;
9
- constructor(cmsConfig: StrapiConfig, httpService: HttpService, logger: Logger);
8
+ constructor(cmsConfig: StrapiConfig, httpService: HttpClientService<MetricLabel>, logger: Logger);
10
9
  getList<RawT extends CmsBaseAttributes, T>(collectionType: CmsCollectionType, options: GetListOptions<T>, dataMapper: {
11
10
  toEntity: (raw: RawT) => T;
12
11
  }): Promise<ListResponse<T>>;
12
+ getLatestRecord<RawT extends CmsBaseAttributes, T>(collectionType: CmsCollectionType, options: GetListOptions<T>, dataMapper: {
13
+ toEntity: (raw: RawT) => T;
14
+ }): Promise<Response<T> | null>;
15
+ private getSortOptions;
16
+ private sendRequest;
13
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diia-inhouse/cms",
3
- "version": "1.7.0",
3
+ "version": "2.1.0",
4
4
  "description": "Cms utils",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -11,45 +11,49 @@
11
11
  "dist"
12
12
  ],
13
13
  "engines": {
14
- "node": ">=18"
14
+ "node": ">=22"
15
15
  },
16
16
  "scripts": {
17
17
  "prebuild": "rimraf dist",
18
18
  "build": "tsc",
19
19
  "semantic-release": "semantic-release",
20
- "start": "npm run build && node dist/index.js",
21
- "lint": "eslint --ext .ts . && prettier --check .",
22
- "lint-fix": "eslint '*/**/*.{js,ts}' --fix && prettier --write .",
20
+ "lint": "eslint . && prettier --check .",
21
+ "lint-fix": "eslint --fix . && prettier --write .",
23
22
  "lint:lockfile": "lockfile-lint --path package-lock.json --allowed-hosts registry.npmjs.org --validate-https",
24
23
  "prepare": "npm run build",
25
24
  "find-circulars": "madge --circular --extensions ts ./",
26
- "test": "jest",
27
- "test:unit": "npm run test --selectProjects unit --",
28
- "test:coverage": "npm run test --selectProjects unit --coverage --"
25
+ "test": "vitest run",
26
+ "test:watch": "vitest watch"
29
27
  },
30
28
  "dependencies": {
31
- "qs": "6.11.1"
29
+ "qs": "6.15.0"
32
30
  },
33
31
  "peerDependencies": {
34
32
  "@diia-inhouse/errors": ">=1.0.0",
35
- "@diia-inhouse/http": ">=1.0.0",
33
+ "@diia-inhouse/http": ">=2.4.3",
36
34
  "@diia-inhouse/types": ">=1.0.0"
37
35
  },
38
36
  "devDependencies": {
39
- "@commitlint/cli": "17.4.4",
40
- "@diia-inhouse/configs": "1.31.1",
41
- "@diia-inhouse/diia-logger": "2.15.0",
42
- "@diia-inhouse/errors": "1.9.0",
43
- "@diia-inhouse/eslint-config": "5.1.0",
44
- "@diia-inhouse/http": "1.9.0",
45
- "@diia-inhouse/test": "6.3.0",
46
- "@diia-inhouse/types": "6.24.0",
47
- "@types/node": "20.3.1",
48
- "@types/qs": "6.9.7",
49
- "lockfile-lint": "4.12.1",
50
- "madge": "6.1.0",
51
- "rimraf": "5.0.5",
52
- "semantic-release": "21.1.2"
37
+ "@commitlint/cli": "20.4.2",
38
+ "@diia-inhouse/configs": "6.1.1",
39
+ "@diia-inhouse/diia-logger": "3.16.0",
40
+ "@diia-inhouse/errors": "1.17.0",
41
+ "@diia-inhouse/eslint-config": "8.2.4",
42
+ "@diia-inhouse/http": "4.0.0",
43
+ "@diia-inhouse/test": "7.2.0",
44
+ "@diia-inhouse/types": "11.3.0",
45
+ "@types/node": "25.3.3",
46
+ "@types/qs": "6.14.0",
47
+ "@vitest/coverage-v8": "4.0.18",
48
+ "@vitest/ui": "4.0.18",
49
+ "lockfile-lint": "4.14.1",
50
+ "madge": "8.0.0",
51
+ "n": "10.2.0",
52
+ "rimraf": "6.1.3",
53
+ "semantic-release": "24.2.5",
54
+ "vite-tsconfig-paths": "6.1.1",
55
+ "vitest": "4.0.18",
56
+ "vitest-mock-extended": "3.1.0"
53
57
  },
54
58
  "release": {
55
59
  "extends": "@diia-inhouse/configs/dist/semantic-release/package",
@@ -84,8 +88,5 @@
84
88
  "prettier": "@diia-inhouse/eslint-config/prettier",
85
89
  "madge": {
86
90
  "tsConfig": "./tsconfig.json"
87
- },
88
- "jest": {
89
- "preset": "@diia-inhouse/configs/dist/jest"
90
91
  }
91
92
  }