@vigilkids/cms-client 0.0.1 → 0.1.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.mjs +6 -5
- package/dist/types.d.mts +15 -15
- package/dist/types.d.ts +15 -15
- package/dist/webhook.mjs +4 -2
- package/package.json +9 -2
package/dist/index.mjs
CHANGED
|
@@ -32,7 +32,11 @@ class CmsClient {
|
|
|
32
32
|
// ─── 文章 ───────────────────────────────────────────
|
|
33
33
|
/** 获取文章分页列表 */
|
|
34
34
|
async getArticles(params) {
|
|
35
|
-
return this.request(
|
|
35
|
+
return this.request(
|
|
36
|
+
"GET",
|
|
37
|
+
"/articles",
|
|
38
|
+
params
|
|
39
|
+
);
|
|
36
40
|
}
|
|
37
41
|
/** 获取文章详情 */
|
|
38
42
|
async getArticle(slug, locale) {
|
|
@@ -71,10 +75,7 @@ class CmsClient {
|
|
|
71
75
|
// ─── 评论 ───────────────────────────────────────────
|
|
72
76
|
/** 获取文章评论树 */
|
|
73
77
|
async getComments(articleSlug) {
|
|
74
|
-
return this.request(
|
|
75
|
-
"GET",
|
|
76
|
-
`/articles/${encodeURIComponent(articleSlug)}/comments`
|
|
77
|
-
);
|
|
78
|
+
return this.request("GET", `/articles/${encodeURIComponent(articleSlug)}/comments`);
|
|
78
79
|
}
|
|
79
80
|
/** 发表评论 */
|
|
80
81
|
async createComment(articleSlug, payload) {
|
package/dist/types.d.mts
CHANGED
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
/** 多语言字符串 (Go: domain.LocalizedString = map[string]string) */
|
|
2
|
-
type LocalizedString = Record<string, string>;
|
|
3
|
-
/** 分页元信息 (Go: response.PaginationMeta) */
|
|
4
|
-
interface PaginationMeta {
|
|
5
|
-
page: number;
|
|
6
|
-
page_size: number;
|
|
7
|
-
total: number;
|
|
8
|
-
total_pages: number;
|
|
9
|
-
}
|
|
10
|
-
/** 分页响应 (Go: response.Paginated[T]) */
|
|
11
|
-
interface Paginated<T> {
|
|
12
|
-
data: T[];
|
|
13
|
-
pagination: PaginationMeta;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
1
|
/** 作者信息 (Go: delivery.DeliveryAuthorResponse) */
|
|
17
2
|
interface Author {
|
|
18
3
|
display_name: string;
|
|
@@ -95,6 +80,21 @@ interface TwitterMeta {
|
|
|
95
80
|
image: string | null;
|
|
96
81
|
}
|
|
97
82
|
|
|
83
|
+
/** 多语言字符串 (Go: domain.LocalizedString = map[string]string) */
|
|
84
|
+
type LocalizedString = Record<string, string>;
|
|
85
|
+
/** 分页元信息 (Go: response.PaginationMeta) */
|
|
86
|
+
interface PaginationMeta {
|
|
87
|
+
page: number;
|
|
88
|
+
page_size: number;
|
|
89
|
+
total: number;
|
|
90
|
+
total_pages: number;
|
|
91
|
+
}
|
|
92
|
+
/** 分页响应 (Go: response.Paginated[T]) */
|
|
93
|
+
interface Paginated<T> {
|
|
94
|
+
data: T[];
|
|
95
|
+
pagination: PaginationMeta;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
98
|
/** 分类树节点 (Go: delivery.CategoryNodeResponse) */
|
|
99
99
|
interface CategoryNode {
|
|
100
100
|
id: number;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
/** 多语言字符串 (Go: domain.LocalizedString = map[string]string) */
|
|
2
|
-
type LocalizedString = Record<string, string>;
|
|
3
|
-
/** 分页元信息 (Go: response.PaginationMeta) */
|
|
4
|
-
interface PaginationMeta {
|
|
5
|
-
page: number;
|
|
6
|
-
page_size: number;
|
|
7
|
-
total: number;
|
|
8
|
-
total_pages: number;
|
|
9
|
-
}
|
|
10
|
-
/** 分页响应 (Go: response.Paginated[T]) */
|
|
11
|
-
interface Paginated<T> {
|
|
12
|
-
data: T[];
|
|
13
|
-
pagination: PaginationMeta;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
1
|
/** 作者信息 (Go: delivery.DeliveryAuthorResponse) */
|
|
17
2
|
interface Author {
|
|
18
3
|
display_name: string;
|
|
@@ -95,6 +80,21 @@ interface TwitterMeta {
|
|
|
95
80
|
image: string | null;
|
|
96
81
|
}
|
|
97
82
|
|
|
83
|
+
/** 多语言字符串 (Go: domain.LocalizedString = map[string]string) */
|
|
84
|
+
type LocalizedString = Record<string, string>;
|
|
85
|
+
/** 分页元信息 (Go: response.PaginationMeta) */
|
|
86
|
+
interface PaginationMeta {
|
|
87
|
+
page: number;
|
|
88
|
+
page_size: number;
|
|
89
|
+
total: number;
|
|
90
|
+
total_pages: number;
|
|
91
|
+
}
|
|
92
|
+
/** 分页响应 (Go: response.Paginated[T]) */
|
|
93
|
+
interface Paginated<T> {
|
|
94
|
+
data: T[];
|
|
95
|
+
pagination: PaginationMeta;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
98
|
/** 分类树节点 (Go: delivery.CategoryNodeResponse) */
|
|
99
99
|
interface CategoryNode {
|
|
100
100
|
id: number;
|
package/dist/webhook.mjs
CHANGED
|
@@ -2,11 +2,13 @@ import { createHmac, timingSafeEqual } from 'node:crypto';
|
|
|
2
2
|
|
|
3
3
|
function verifyWebhookSignature(options) {
|
|
4
4
|
const { rawBody, signature, secret } = options;
|
|
5
|
-
if (!signature || !rawBody || !secret)
|
|
5
|
+
if (!signature || !rawBody || !secret)
|
|
6
|
+
return false;
|
|
6
7
|
const expected = `sha256=${createHmac("sha256", secret).update(rawBody).digest("hex")}`;
|
|
7
8
|
const sigBuffer = Buffer.from(signature);
|
|
8
9
|
const expectedBuffer = Buffer.from(expected);
|
|
9
|
-
if (sigBuffer.length !== expectedBuffer.length)
|
|
10
|
+
if (sigBuffer.length !== expectedBuffer.length)
|
|
11
|
+
return false;
|
|
10
12
|
return timingSafeEqual(sigBuffer, expectedBuffer);
|
|
11
13
|
}
|
|
12
14
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vigilkids/cms-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Framework-agnostic TypeScript client for OnEx CMS Public API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.mjs",
|
|
@@ -24,7 +24,10 @@
|
|
|
24
24
|
],
|
|
25
25
|
"sideEffects": false,
|
|
26
26
|
"scripts": {
|
|
27
|
-
"build": "unbuild"
|
|
27
|
+
"build": "unbuild",
|
|
28
|
+
"lint": "eslint .",
|
|
29
|
+
"lint:fix": "eslint . --fix",
|
|
30
|
+
"format": "prettier --write src/"
|
|
28
31
|
},
|
|
29
32
|
"publishConfig": {
|
|
30
33
|
"access": "public"
|
|
@@ -35,7 +38,11 @@
|
|
|
35
38
|
"directory": "packages/cms-client"
|
|
36
39
|
},
|
|
37
40
|
"devDependencies": {
|
|
41
|
+
"@antfu/eslint-config": "^4.13.2",
|
|
38
42
|
"@types/node": "^22.0.0",
|
|
43
|
+
"eslint": "^9.22.0",
|
|
44
|
+
"eslint-config-prettier": "^10.1.1",
|
|
45
|
+
"prettier": "^3.5.3",
|
|
39
46
|
"unbuild": "^3.5.0"
|
|
40
47
|
}
|
|
41
48
|
}
|