@diia-inhouse/cms 2.1.43 → 3.3.1
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/index.d.ts +5 -0
- package/dist/index.js +5 -19
- package/dist/interfaces/cms.d.ts +82 -0
- package/dist/interfaces/cms.js +10 -11
- package/dist/interfaces/config.d.ts +9 -0
- package/dist/interfaces/index.d.ts +11 -0
- package/dist/interfaces/index.js +7 -23
- package/dist/services/cms.d.ts +23 -0
- package/dist/services/cms.js +72 -100
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.js +2 -18
- package/package.json +37 -47
- package/dist/index.js.map +0 -1
- package/dist/interfaces/cms.js.map +0 -1
- package/dist/interfaces/config.js +0 -3
- package/dist/interfaces/config.js.map +0 -1
- package/dist/interfaces/index.js.map +0 -1
- package/dist/services/cms.js.map +0 -1
- package/dist/services/index.js.map +0 -1
- package/dist/types/index.d.ts +0 -2
- package/dist/types/interfaces/cms.d.ts +0 -81
- package/dist/types/interfaces/config.d.ts +0 -6
- package/dist/types/interfaces/index.d.ts +0 -7
- package/dist/types/services/cms.d.ts +0 -17
- package/dist/types/services/index.d.ts +0 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ApplyBasicQueryCasting, CmsBaseAttributes, CmsCollectionType, CmsEntries, CmsEntriesMeta, CmsEntry, CmsFilterQuery, CmsPaginationOptions, CmsQuerySelector, CmsRootFilterQuery, Condition, GetListOptions, ListResponse, Response } from "./interfaces/cms.js";
|
|
2
|
+
import { StrapiConfig } from "./interfaces/config.js";
|
|
3
|
+
import { MetricLabel, MetricLabels } from "./interfaces/index.js";
|
|
4
|
+
import { CmsService } from "./services/cms.js";
|
|
5
|
+
export { ApplyBasicQueryCasting, CmsBaseAttributes, CmsCollectionType, CmsEntries, CmsEntriesMeta, CmsEntry, CmsFilterQuery, CmsPaginationOptions, CmsQuerySelector, CmsRootFilterQuery, CmsService, Condition, GetListOptions, ListResponse, MetricLabel, MetricLabels, Response, StrapiConfig };
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./interfaces"), exports);
|
|
18
|
-
__exportStar(require("./services"), exports);
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import { CmsCollectionType } from "./interfaces/cms.js";
|
|
2
|
+
import { MetricLabels } from "./interfaces/index.js";
|
|
3
|
+
import { CmsService } from "./services/cms.js";
|
|
4
|
+
import "./services/index.js";
|
|
5
|
+
export { CmsCollectionType, CmsService, MetricLabels };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
//#region src/interfaces/cms.d.ts
|
|
2
|
+
declare enum CmsCollectionType {
|
|
3
|
+
ErrorTemplate = "error-template",
|
|
4
|
+
Faq = "faq",
|
|
5
|
+
FaqCategory = "faq-categories",
|
|
6
|
+
MilitaryDonationReports = "military-donation-reports"
|
|
7
|
+
}
|
|
8
|
+
interface CmsBaseAttributes {
|
|
9
|
+
createdAt: string;
|
|
10
|
+
updatedAt: string;
|
|
11
|
+
publishedAt?: string;
|
|
12
|
+
}
|
|
13
|
+
/** Visit strapi docs: https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest/api-parameters.html */
|
|
14
|
+
interface GetListOptions<T> {
|
|
15
|
+
filters?: CmsFilterQuery<T>;
|
|
16
|
+
fields?: string | string[];
|
|
17
|
+
populate?: string | string[] | Record<string, GetListOptions<T>>;
|
|
18
|
+
sort?: string | string[];
|
|
19
|
+
pagination?: CmsPaginationOptions;
|
|
20
|
+
}
|
|
21
|
+
interface CmsQuerySelector<T> {
|
|
22
|
+
$eq?: T;
|
|
23
|
+
$ne?: T;
|
|
24
|
+
$lt?: T;
|
|
25
|
+
$lte?: T;
|
|
26
|
+
$gt?: T;
|
|
27
|
+
$gte?: T;
|
|
28
|
+
$in?: T[];
|
|
29
|
+
$notIn?: T[];
|
|
30
|
+
$contains?: T;
|
|
31
|
+
$notContains?: T;
|
|
32
|
+
$containsi?: T;
|
|
33
|
+
$notContainsi?: T;
|
|
34
|
+
$null?: boolean;
|
|
35
|
+
$notNull?: boolean;
|
|
36
|
+
$between?: T extends number ? [number, number] : never;
|
|
37
|
+
$startsWith?: T extends string ? string : never;
|
|
38
|
+
$endsWith?: T extends string ? string : never;
|
|
39
|
+
}
|
|
40
|
+
interface CmsRootFilterQuery<T> {
|
|
41
|
+
[key: string]: unknown;
|
|
42
|
+
$or?: CmsFilterQuery<T>[];
|
|
43
|
+
$and?: CmsFilterQuery<T>[];
|
|
44
|
+
}
|
|
45
|
+
type ApplyBasicQueryCasting<T> = T | T[] | unknown;
|
|
46
|
+
type Condition<T> = ApplyBasicQueryCasting<T> | CmsQuerySelector<ApplyBasicQueryCasting<T>>;
|
|
47
|
+
type CmsFilterQuery<T> = { [P in keyof T]?: Condition<T[P]> } & CmsRootFilterQuery<T>;
|
|
48
|
+
interface CmsPaginationOptions {
|
|
49
|
+
start?: number;
|
|
50
|
+
limit?: number;
|
|
51
|
+
page?: number;
|
|
52
|
+
pageSize?: number;
|
|
53
|
+
withCount?: boolean;
|
|
54
|
+
}
|
|
55
|
+
interface CmsEntries<T extends CmsBaseAttributes> {
|
|
56
|
+
data: CmsEntry<T>[];
|
|
57
|
+
meta: CmsEntriesMeta;
|
|
58
|
+
}
|
|
59
|
+
interface CmsEntry<T extends CmsBaseAttributes> {
|
|
60
|
+
id: number;
|
|
61
|
+
attributes: T;
|
|
62
|
+
}
|
|
63
|
+
interface ListResponse<T> {
|
|
64
|
+
data: T[];
|
|
65
|
+
meta: CmsEntriesMeta;
|
|
66
|
+
}
|
|
67
|
+
interface Response<T> {
|
|
68
|
+
data: T;
|
|
69
|
+
meta: CmsEntriesMeta;
|
|
70
|
+
}
|
|
71
|
+
interface CmsEntriesMeta {
|
|
72
|
+
pagination?: {
|
|
73
|
+
start?: number;
|
|
74
|
+
limit?: number;
|
|
75
|
+
page?: number;
|
|
76
|
+
pageSize?: number;
|
|
77
|
+
pageCount?: number;
|
|
78
|
+
total: number;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
//#endregion
|
|
82
|
+
export { ApplyBasicQueryCasting, CmsBaseAttributes, CmsCollectionType, CmsEntries, CmsEntriesMeta, CmsEntry, CmsFilterQuery, CmsPaginationOptions, CmsQuerySelector, CmsRootFilterQuery, Condition, GetListOptions, ListResponse, Response };
|
package/dist/interfaces/cms.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
//# sourceMappingURL=cms.js.map
|
|
1
|
+
//#region src/interfaces/cms.ts
|
|
2
|
+
let CmsCollectionType = /* @__PURE__ */ function(CmsCollectionType) {
|
|
3
|
+
CmsCollectionType["ErrorTemplate"] = "error-template";
|
|
4
|
+
CmsCollectionType["Faq"] = "faq";
|
|
5
|
+
CmsCollectionType["FaqCategory"] = "faq-categories";
|
|
6
|
+
CmsCollectionType["MilitaryDonationReports"] = "military-donation-reports";
|
|
7
|
+
return CmsCollectionType;
|
|
8
|
+
}({});
|
|
9
|
+
//#endregion
|
|
10
|
+
export { CmsCollectionType };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ApplyBasicQueryCasting, CmsBaseAttributes, CmsCollectionType, CmsEntries, CmsEntriesMeta, CmsEntry, CmsFilterQuery, CmsPaginationOptions, CmsQuerySelector, CmsRootFilterQuery, Condition, GetListOptions, ListResponse, Response } from "./cms.js";
|
|
2
|
+
import { StrapiConfig } from "./config.js";
|
|
3
|
+
|
|
4
|
+
//#region src/interfaces/index.d.ts
|
|
5
|
+
declare const MetricLabels: {
|
|
6
|
+
readonly strapiGetList: "strapiGetList";
|
|
7
|
+
readonly strapiGetLatestRecord: "strapiGetLatestRecord";
|
|
8
|
+
};
|
|
9
|
+
type MetricLabel = (typeof MetricLabels)[keyof typeof MetricLabels];
|
|
10
|
+
//#endregion
|
|
11
|
+
export { MetricLabel, MetricLabels };
|
package/dist/interfaces/index.js
CHANGED
|
@@ -1,24 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
1
|
+
import "./cms.js";
|
|
2
|
+
//#region src/interfaces/index.ts
|
|
3
|
+
const MetricLabels = {
|
|
4
|
+
strapiGetList: "strapiGetList",
|
|
5
|
+
strapiGetLatestRecord: "strapiGetLatestRecord"
|
|
15
6
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
__exportStar(require("./cms"), exports);
|
|
19
|
-
__exportStar(require("./config"), exports);
|
|
20
|
-
exports.MetricLabels = {
|
|
21
|
-
strapiGetList: 'strapiGetList',
|
|
22
|
-
strapiGetLatestRecord: 'strapiGetLatestRecord',
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=index.js.map
|
|
7
|
+
//#endregion
|
|
8
|
+
export { MetricLabels };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CmsBaseAttributes, CmsCollectionType, GetListOptions, ListResponse, Response } from "../interfaces/cms.js";
|
|
2
|
+
import { StrapiConfig } from "../interfaces/config.js";
|
|
3
|
+
import { MetricLabel } from "../interfaces/index.js";
|
|
4
|
+
import { Logger } from "@diia-inhouse/types";
|
|
5
|
+
import { HttpClientService } from "@diia-inhouse/http";
|
|
6
|
+
|
|
7
|
+
//#region src/services/cms.d.ts
|
|
8
|
+
declare class CmsService {
|
|
9
|
+
private readonly cmsConfig;
|
|
10
|
+
private readonly httpService;
|
|
11
|
+
private readonly logger;
|
|
12
|
+
constructor(cmsConfig: StrapiConfig, httpService: HttpClientService<MetricLabel>, logger: Logger);
|
|
13
|
+
getList<RawT extends CmsBaseAttributes, T>(collectionType: CmsCollectionType, options: GetListOptions<T>, dataMapper: {
|
|
14
|
+
toEntity: (raw: RawT) => T;
|
|
15
|
+
}): Promise<ListResponse<T>>;
|
|
16
|
+
getLatestRecord<RawT extends CmsBaseAttributes, T>(collectionType: CmsCollectionType, options: GetListOptions<T>, dataMapper: {
|
|
17
|
+
toEntity: (raw: RawT) => T;
|
|
18
|
+
}): Promise<Response<T> | null>;
|
|
19
|
+
private getSortOptions;
|
|
20
|
+
private sendRequest;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { CmsService };
|
package/dist/services/cms.js
CHANGED
|
@@ -1,100 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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) {
|
|
81
|
-
const path = `/api/${collectionType}?${qs.stringify(options, { encodeValuesOnly: true })}`;
|
|
82
|
-
this.logger.info(`StrapiService: request data`, { collectionType, path });
|
|
83
|
-
const response = await this.httpService.get(path, {
|
|
84
|
-
baseUrl: `${this.cmsConfig.host}:${this.cmsConfig?.port}`,
|
|
85
|
-
headers: { Authorization: `Bearer ${this.cmsConfig.token}` },
|
|
86
|
-
timeout: 30000,
|
|
87
|
-
httpsAgent: new node_https_1.Agent({ rejectUnauthorized: false }),
|
|
88
|
-
metricLabel,
|
|
89
|
-
});
|
|
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 });
|
|
93
|
-
throw new errors_1.ServiceUnavailableError('StrapiService: failed to retrieve data');
|
|
94
|
-
}
|
|
95
|
-
this.logger.info(`StrapiService: data retrieved`, { collectionType, body: response?.body });
|
|
96
|
-
return response;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
exports.CmsService = CmsService;
|
|
100
|
-
//# sourceMappingURL=cms.js.map
|
|
1
|
+
import { MetricLabels } from "../interfaces/index.js";
|
|
2
|
+
import { Agent } from "node:https";
|
|
3
|
+
import * as qs from "qs";
|
|
4
|
+
import { ServiceUnavailableError } from "@diia-inhouse/errors";
|
|
5
|
+
import { HttpStatusCode } from "@diia-inhouse/types";
|
|
6
|
+
//#region src/services/cms.ts
|
|
7
|
+
var CmsService = class {
|
|
8
|
+
cmsConfig;
|
|
9
|
+
httpService;
|
|
10
|
+
logger;
|
|
11
|
+
constructor(cmsConfig, httpService, logger) {
|
|
12
|
+
this.cmsConfig = cmsConfig;
|
|
13
|
+
this.httpService = httpService;
|
|
14
|
+
this.logger = logger;
|
|
15
|
+
}
|
|
16
|
+
async getList(collectionType, options, dataMapper) {
|
|
17
|
+
const { data, meta } = (await this.sendRequest(collectionType, options, MetricLabels.strapiGetList)).body;
|
|
18
|
+
return {
|
|
19
|
+
meta,
|
|
20
|
+
data: data.map((item) => dataMapper.toEntity(item))
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
async getLatestRecord(collectionType, options, dataMapper) {
|
|
24
|
+
options.sort = this.getSortOptions(options.sort);
|
|
25
|
+
options.pagination = {
|
|
26
|
+
page: 1,
|
|
27
|
+
pageSize: 1
|
|
28
|
+
};
|
|
29
|
+
const { data, meta } = (await this.sendRequest(collectionType, options, MetricLabels.strapiGetLatestRecord)).body;
|
|
30
|
+
if (data.length > 0) return {
|
|
31
|
+
meta,
|
|
32
|
+
data: dataMapper.toEntity(data[0])
|
|
33
|
+
};
|
|
34
|
+
this.logger.info("StrapiService: no record found");
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
getSortOptions(sort) {
|
|
38
|
+
const sortByUpdatedAt = "updatedAt:desc";
|
|
39
|
+
if (Array.isArray(sort)) return [...sort, sortByUpdatedAt];
|
|
40
|
+
if (typeof sort === "string") return [sort, sortByUpdatedAt];
|
|
41
|
+
return sortByUpdatedAt;
|
|
42
|
+
}
|
|
43
|
+
async sendRequest(collectionType, options, metricLabel) {
|
|
44
|
+
const path = `/api/${collectionType}?${qs.stringify(options, { encodeValuesOnly: true })}`;
|
|
45
|
+
this.logger.info(`StrapiService: request data`, {
|
|
46
|
+
collectionType,
|
|
47
|
+
path
|
|
48
|
+
});
|
|
49
|
+
const response = await this.httpService.get(path, {
|
|
50
|
+
baseUrl: `${this.cmsConfig.host}:${this.cmsConfig?.port}`,
|
|
51
|
+
headers: { Authorization: `Bearer ${this.cmsConfig.token}` },
|
|
52
|
+
timeout: 3e4,
|
|
53
|
+
httpsAgent: new Agent({ rejectUnauthorized: false }),
|
|
54
|
+
metricLabel
|
|
55
|
+
});
|
|
56
|
+
if (!response.isOk || response?.statusCode !== HttpStatusCode.OK) {
|
|
57
|
+
const { statusCode, body } = response;
|
|
58
|
+
this.logger.error("StrapiService: failed to retrieve data", {
|
|
59
|
+
statusCode,
|
|
60
|
+
body
|
|
61
|
+
});
|
|
62
|
+
throw new ServiceUnavailableError("StrapiService: failed to retrieve data");
|
|
63
|
+
}
|
|
64
|
+
this.logger.info(`StrapiService: data retrieved`, {
|
|
65
|
+
collectionType,
|
|
66
|
+
body: response?.body
|
|
67
|
+
});
|
|
68
|
+
return response;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
//#endregion
|
|
72
|
+
export { CmsService };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { CmsService } from "./cms.js";
|
package/dist/services/index.js
CHANGED
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./cms"), exports);
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import "./cms.js";
|
|
2
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,24 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diia-inhouse/cms",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.3.1",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"description": "Cms utils",
|
|
5
6
|
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
7
8
|
"repository": "https://github.com/diia-open-source/be-pkg-cms",
|
|
8
9
|
"author": "Diia",
|
|
9
10
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./package.json": "./package.json"
|
|
17
|
+
},
|
|
10
18
|
"files": [
|
|
11
19
|
"dist"
|
|
12
20
|
],
|
|
13
21
|
"engines": {
|
|
14
|
-
"node": ">=
|
|
22
|
+
"node": ">=24"
|
|
15
23
|
},
|
|
16
24
|
"scripts": {
|
|
17
25
|
"prebuild": "rimraf dist",
|
|
18
|
-
"build": "
|
|
26
|
+
"build": "tsdown",
|
|
19
27
|
"semantic-release": "semantic-release",
|
|
20
|
-
"lint": "
|
|
21
|
-
"lint-fix": "
|
|
28
|
+
"lint": "oxlint && oxfmt --check .",
|
|
29
|
+
"lint-fix": "oxlint --fix && oxfmt .",
|
|
22
30
|
"lint:lockfile": "lockfile-lint --path package-lock.json --allowed-hosts registry.npmjs.org --validate-https",
|
|
23
31
|
"prepare": "npm run build",
|
|
24
32
|
"find-circulars": "madge --circular --extensions ts ./",
|
|
@@ -26,34 +34,38 @@
|
|
|
26
34
|
"test:watch": "vitest watch"
|
|
27
35
|
},
|
|
28
36
|
"dependencies": {
|
|
29
|
-
"qs": "6.15.
|
|
37
|
+
"qs": "6.15.2"
|
|
30
38
|
},
|
|
31
39
|
"peerDependencies": {
|
|
32
|
-
"@diia-inhouse/errors": ">=
|
|
33
|
-
"@diia-inhouse/http": ">=
|
|
34
|
-
"@diia-inhouse/types": ">=
|
|
40
|
+
"@diia-inhouse/errors": ">=2.0.0",
|
|
41
|
+
"@diia-inhouse/http": ">=5.0.0",
|
|
42
|
+
"@diia-inhouse/types": ">=13.0.0"
|
|
35
43
|
},
|
|
36
44
|
"devDependencies": {
|
|
37
45
|
"@commitlint/cli": "20.4.2",
|
|
38
|
-
"@diia-inhouse/configs": "
|
|
39
|
-
"@diia-inhouse/diia-logger": "3.
|
|
40
|
-
"@diia-inhouse/errors": "1.
|
|
41
|
-
"@diia-inhouse/
|
|
42
|
-
"@diia-inhouse/
|
|
43
|
-
"@diia-inhouse/test": "
|
|
44
|
-
"@diia-inhouse/types": "
|
|
45
|
-
"@types/node": "25.
|
|
46
|
-
"@types/qs": "6.
|
|
47
|
-
"@vitest/coverage-v8": "4.
|
|
48
|
-
"@vitest/ui": "4.
|
|
49
|
-
"lockfile-lint": "
|
|
46
|
+
"@diia-inhouse/configs": "7.0.0",
|
|
47
|
+
"@diia-inhouse/diia-logger": "4.3.0",
|
|
48
|
+
"@diia-inhouse/errors": "2.1.1",
|
|
49
|
+
"@diia-inhouse/http": "5.1.0",
|
|
50
|
+
"@diia-inhouse/oxc-config": "1.10.0",
|
|
51
|
+
"@diia-inhouse/test": "8.2.1",
|
|
52
|
+
"@diia-inhouse/types": "13.2.0",
|
|
53
|
+
"@types/node": "25.6.2",
|
|
54
|
+
"@types/qs": "6.15.1",
|
|
55
|
+
"@vitest/coverage-v8": "4.1.5",
|
|
56
|
+
"@vitest/ui": "4.1.5",
|
|
57
|
+
"lockfile-lint": "5.0.0",
|
|
50
58
|
"madge": "8.0.0",
|
|
51
59
|
"n": "10.2.0",
|
|
60
|
+
"oxfmt": "0.48.0",
|
|
61
|
+
"oxlint": "1.63.0",
|
|
62
|
+
"oxlint-tsgolint": "0.22.1",
|
|
52
63
|
"rimraf": "6.1.3",
|
|
53
|
-
"semantic-release": "
|
|
64
|
+
"semantic-release": "25.0.3",
|
|
65
|
+
"tsdown": "0.22.0",
|
|
54
66
|
"vite-tsconfig-paths": "6.1.1",
|
|
55
|
-
"vitest": "4.
|
|
56
|
-
"vitest-mock-extended": "
|
|
67
|
+
"vitest": "4.1.5",
|
|
68
|
+
"vitest-mock-extended": "4.0.0"
|
|
57
69
|
},
|
|
58
70
|
"release": {
|
|
59
71
|
"extends": "@diia-inhouse/configs/dist/semantic-release/package",
|
|
@@ -64,28 +76,6 @@
|
|
|
64
76
|
"commitlint": {
|
|
65
77
|
"extends": "@diia-inhouse/configs/dist/commitlint"
|
|
66
78
|
},
|
|
67
|
-
"eslintConfig": {
|
|
68
|
-
"extends": "@diia-inhouse/eslint-config",
|
|
69
|
-
"rules": {
|
|
70
|
-
"@typescript-eslint/no-unnecessary-condition": [
|
|
71
|
-
"off"
|
|
72
|
-
]
|
|
73
|
-
},
|
|
74
|
-
"overrides": [
|
|
75
|
-
{
|
|
76
|
-
"files": [
|
|
77
|
-
"*.ts"
|
|
78
|
-
],
|
|
79
|
-
"parserOptions": {
|
|
80
|
-
"project": [
|
|
81
|
-
"./tsconfig.json",
|
|
82
|
-
"./tests/tsconfig.json"
|
|
83
|
-
]
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
]
|
|
87
|
-
},
|
|
88
|
-
"prettier": "@diia-inhouse/eslint-config/prettier",
|
|
89
79
|
"madge": {
|
|
90
80
|
"tsConfig": "./tsconfig.json"
|
|
91
81
|
}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA4B;AAE5B,6CAA0B"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/interfaces/config.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/services/cms.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cms.js","sourceRoot":"","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ACd,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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAqB"}
|
package/dist/types/index.d.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
export declare enum CmsCollectionType {
|
|
2
|
-
ErrorTemplate = "error-template",
|
|
3
|
-
Faq = "faq",
|
|
4
|
-
FaqCategory = "faq-categories",
|
|
5
|
-
MilitaryDonationReports = "military-donation-reports"
|
|
6
|
-
}
|
|
7
|
-
export interface CmsBaseAttributes {
|
|
8
|
-
createdAt: string;
|
|
9
|
-
updatedAt: string;
|
|
10
|
-
publishedAt?: string;
|
|
11
|
-
}
|
|
12
|
-
/** Visit strapi docs: https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest/api-parameters.html */
|
|
13
|
-
export interface GetListOptions<T> {
|
|
14
|
-
filters?: CmsFilterQuery<T>;
|
|
15
|
-
fields?: string | string[];
|
|
16
|
-
populate?: string | string[] | Record<string, GetListOptions<T>>;
|
|
17
|
-
sort?: string | string[];
|
|
18
|
-
pagination?: CmsPaginationOptions;
|
|
19
|
-
}
|
|
20
|
-
export interface CmsQuerySelector<T> {
|
|
21
|
-
$eq?: T;
|
|
22
|
-
$ne?: T;
|
|
23
|
-
$lt?: T;
|
|
24
|
-
$lte?: T;
|
|
25
|
-
$gt?: T;
|
|
26
|
-
$gte?: T;
|
|
27
|
-
$in?: T[];
|
|
28
|
-
$notIn?: T[];
|
|
29
|
-
$contains?: T;
|
|
30
|
-
$notContains?: T;
|
|
31
|
-
$containsi?: T;
|
|
32
|
-
$notContainsi?: T;
|
|
33
|
-
$null?: boolean;
|
|
34
|
-
$notNull?: boolean;
|
|
35
|
-
$between?: T extends number ? [number, number] : never;
|
|
36
|
-
$startsWith?: T extends string ? string : never;
|
|
37
|
-
$endsWith?: T extends string ? string : never;
|
|
38
|
-
}
|
|
39
|
-
export interface CmsRootFilterQuery<T> {
|
|
40
|
-
[key: string]: unknown;
|
|
41
|
-
$or?: CmsFilterQuery<T>[];
|
|
42
|
-
$and?: CmsFilterQuery<T>[];
|
|
43
|
-
}
|
|
44
|
-
export type ApplyBasicQueryCasting<T> = T | T[] | unknown;
|
|
45
|
-
export type Condition<T> = ApplyBasicQueryCasting<T> | CmsQuerySelector<ApplyBasicQueryCasting<T>>;
|
|
46
|
-
export type CmsFilterQuery<T> = {
|
|
47
|
-
[P in keyof T]?: Condition<T[P]>;
|
|
48
|
-
} & CmsRootFilterQuery<T>;
|
|
49
|
-
export interface CmsPaginationOptions {
|
|
50
|
-
start?: number;
|
|
51
|
-
limit?: number;
|
|
52
|
-
page?: number;
|
|
53
|
-
pageSize?: number;
|
|
54
|
-
withCount?: boolean;
|
|
55
|
-
}
|
|
56
|
-
export interface CmsEntries<T extends CmsBaseAttributes> {
|
|
57
|
-
data: CmsEntry<T>[];
|
|
58
|
-
meta: CmsEntriesMeta;
|
|
59
|
-
}
|
|
60
|
-
export interface CmsEntry<T extends CmsBaseAttributes> {
|
|
61
|
-
id: number;
|
|
62
|
-
attributes: T;
|
|
63
|
-
}
|
|
64
|
-
export interface ListResponse<T> {
|
|
65
|
-
data: T[];
|
|
66
|
-
meta: CmsEntriesMeta;
|
|
67
|
-
}
|
|
68
|
-
export interface Response<T> {
|
|
69
|
-
data: T;
|
|
70
|
-
meta: CmsEntriesMeta;
|
|
71
|
-
}
|
|
72
|
-
export interface CmsEntriesMeta {
|
|
73
|
-
pagination?: {
|
|
74
|
-
start?: number;
|
|
75
|
-
limit?: number;
|
|
76
|
-
page?: number;
|
|
77
|
-
pageSize?: number;
|
|
78
|
-
pageCount?: number;
|
|
79
|
-
total: number;
|
|
80
|
-
};
|
|
81
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export * from './cms';
|
|
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,17 +0,0 @@
|
|
|
1
|
-
import { HttpClientService } from '@diia-inhouse/http';
|
|
2
|
-
import { Logger } from '@diia-inhouse/types';
|
|
3
|
-
import { CmsBaseAttributes, CmsCollectionType, GetListOptions, ListResponse, MetricLabel, Response, StrapiConfig } from '../interfaces';
|
|
4
|
-
export declare class CmsService {
|
|
5
|
-
private readonly cmsConfig;
|
|
6
|
-
private readonly httpService;
|
|
7
|
-
private readonly logger;
|
|
8
|
-
constructor(cmsConfig: StrapiConfig, httpService: HttpClientService<MetricLabel>, logger: Logger);
|
|
9
|
-
getList<RawT extends CmsBaseAttributes, T>(collectionType: CmsCollectionType, options: GetListOptions<T>, dataMapper: {
|
|
10
|
-
toEntity: (raw: RawT) => T;
|
|
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;
|
|
17
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './cms';
|