@vigilkids/cms-client 0.3.1 → 0.3.3
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/CHANGELOG.md +13 -0
- package/dist/index.d.mts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.mjs +12 -2
- package/dist/types.d.mts +66 -3
- package/dist/types.d.ts +66 -3
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.3.3] - 2026-06-16
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Added localized author profile contract fields for reusable CMS author pages.
|
|
13
|
+
- Added typed site runtime route policy and redirect match rule metadata for CMS delivery consumers.
|
|
14
|
+
|
|
15
|
+
## [0.3.2] - 2026-06-14
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- Added optional author profile content types for reusable author pages across CMS consumers.
|
|
20
|
+
|
|
8
21
|
## [0.3.1] - 2026-06-05
|
|
9
22
|
|
|
10
23
|
### Added
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ArticleListParams, Paginated, ArticleListItem, ArticleDetail, ArticleSearchParams, ArticleSearchResultItem, PaginationParams, Author, CategoryNode, Comment, CreateCommentPayload, SitemapEntry, RedirectRule, Series } from './types.mjs';
|
|
2
|
-
export { HreflangEntry, ListResponse, LocalizedOgMetaMap, LocalizedSeoMetaMap, LocalizedString, LocalizedTwitterMetaMap, OgMeta, PaginationMeta, RevalidatePayload, SeoMeta, SitemapImageEntry, TwitterMeta, WebhookEventType } from './types.mjs';
|
|
1
|
+
import { ArticleListParams, Paginated, ArticleListItem, ArticleDetail, ArticleSearchParams, ArticleSearchResultItem, PaginationParams, Author, CategoryNode, Comment, CreateCommentPayload, SitemapEntry, RedirectRule, SiteConfigQuery, SiteConfig, Series } from './types.mjs';
|
|
2
|
+
export { AuthorProfile, AuthorProfileCta, AuthorProfileQuestion, AuthorProfileSection, AuthorProfileStat, AuthorSocialLink, HreflangEntry, ListResponse, LocalizedOgMetaMap, LocalizedSeoMetaMap, LocalizedString, LocalizedTwitterMetaMap, OgMeta, PaginationMeta, RedirectMatchType, RevalidatePayload, SeoMeta, SitemapImageEntry, TwitterMeta, WebhookEventType } from './types.mjs';
|
|
3
3
|
export { BuildRoutePathOptions, BuildRouteUrlOptions, DEFAULT_ROUTE_RESOURCES, ResolvedRouteLocalePolicy, ResolvedRoutePolicy, RouteLocalePolicy, RouteParams, RoutePolicy, RoutePolicyConfig, RouteResourceDefaults, RouteResources, buildRoutePath, buildRouteUrl, extractRouteParams, extractSourceRouteParams, formatRoutePolicy, hasCustomArticleRoute, isRoutePolicy, mergeRouteParams, resolveRoutePolicy } from './routes.mjs';
|
|
4
4
|
|
|
5
5
|
/** CMS 客户端配置 */
|
|
@@ -66,6 +66,8 @@ declare class CmsClient {
|
|
|
66
66
|
getSitemap(locale?: string): Promise<SitemapEntry[]>;
|
|
67
67
|
/** 获取重定向规则 */
|
|
68
68
|
getRedirects(): Promise<RedirectRule[]>;
|
|
69
|
+
/** 获取站点运行时配置 */
|
|
70
|
+
getSiteConfig(options?: SiteConfigQuery): Promise<SiteConfig>;
|
|
69
71
|
/** 获取文章系列 */
|
|
70
72
|
getSeries(slug: string, locale?: string): Promise<Series>;
|
|
71
73
|
private request;
|
|
@@ -87,5 +89,5 @@ declare class CmsApiError extends Error {
|
|
|
87
89
|
get isUnauthorized(): boolean;
|
|
88
90
|
}
|
|
89
91
|
|
|
90
|
-
export { ArticleDetail, ArticleListItem, ArticleListParams, ArticleSearchParams, ArticleSearchResultItem, Author, CategoryNode, CmsApiError, CmsClient, Comment, CreateCommentPayload, Paginated, PaginationParams, RedirectRule, Series, SitemapEntry, createCmsClient };
|
|
92
|
+
export { ArticleDetail, ArticleListItem, ArticleListParams, ArticleSearchParams, ArticleSearchResultItem, Author, CategoryNode, CmsApiError, CmsClient, Comment, CreateCommentPayload, Paginated, PaginationParams, RedirectRule, Series, SiteConfig, SiteConfigQuery, SitemapEntry, createCmsClient };
|
|
91
93
|
export type { CmsClientConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ArticleListParams, Paginated, ArticleListItem, ArticleDetail, ArticleSearchParams, ArticleSearchResultItem, PaginationParams, Author, CategoryNode, Comment, CreateCommentPayload, SitemapEntry, RedirectRule, Series } from './types.js';
|
|
2
|
-
export { HreflangEntry, ListResponse, LocalizedOgMetaMap, LocalizedSeoMetaMap, LocalizedString, LocalizedTwitterMetaMap, OgMeta, PaginationMeta, RevalidatePayload, SeoMeta, SitemapImageEntry, TwitterMeta, WebhookEventType } from './types.js';
|
|
1
|
+
import { ArticleListParams, Paginated, ArticleListItem, ArticleDetail, ArticleSearchParams, ArticleSearchResultItem, PaginationParams, Author, CategoryNode, Comment, CreateCommentPayload, SitemapEntry, RedirectRule, SiteConfigQuery, SiteConfig, Series } from './types.js';
|
|
2
|
+
export { AuthorProfile, AuthorProfileCta, AuthorProfileQuestion, AuthorProfileSection, AuthorProfileStat, AuthorSocialLink, HreflangEntry, ListResponse, LocalizedOgMetaMap, LocalizedSeoMetaMap, LocalizedString, LocalizedTwitterMetaMap, OgMeta, PaginationMeta, RedirectMatchType, RevalidatePayload, SeoMeta, SitemapImageEntry, TwitterMeta, WebhookEventType } from './types.js';
|
|
3
3
|
export { BuildRoutePathOptions, BuildRouteUrlOptions, DEFAULT_ROUTE_RESOURCES, ResolvedRouteLocalePolicy, ResolvedRoutePolicy, RouteLocalePolicy, RouteParams, RoutePolicy, RoutePolicyConfig, RouteResourceDefaults, RouteResources, buildRoutePath, buildRouteUrl, extractRouteParams, extractSourceRouteParams, formatRoutePolicy, hasCustomArticleRoute, isRoutePolicy, mergeRouteParams, resolveRoutePolicy } from './routes.js';
|
|
4
4
|
|
|
5
5
|
/** CMS 客户端配置 */
|
|
@@ -66,6 +66,8 @@ declare class CmsClient {
|
|
|
66
66
|
getSitemap(locale?: string): Promise<SitemapEntry[]>;
|
|
67
67
|
/** 获取重定向规则 */
|
|
68
68
|
getRedirects(): Promise<RedirectRule[]>;
|
|
69
|
+
/** 获取站点运行时配置 */
|
|
70
|
+
getSiteConfig(options?: SiteConfigQuery): Promise<SiteConfig>;
|
|
69
71
|
/** 获取文章系列 */
|
|
70
72
|
getSeries(slug: string, locale?: string): Promise<Series>;
|
|
71
73
|
private request;
|
|
@@ -87,5 +89,5 @@ declare class CmsApiError extends Error {
|
|
|
87
89
|
get isUnauthorized(): boolean;
|
|
88
90
|
}
|
|
89
91
|
|
|
90
|
-
export { ArticleDetail, ArticleListItem, ArticleListParams, ArticleSearchParams, ArticleSearchResultItem, Author, CategoryNode, CmsApiError, CmsClient, Comment, CreateCommentPayload, Paginated, PaginationParams, RedirectRule, Series, SitemapEntry, createCmsClient };
|
|
92
|
+
export { ArticleDetail, ArticleListItem, ArticleListParams, ArticleSearchParams, ArticleSearchResultItem, Author, CategoryNode, CmsApiError, CmsClient, Comment, CreateCommentPayload, Paginated, PaginationParams, RedirectRule, Series, SiteConfig, SiteConfigQuery, SitemapEntry, createCmsClient };
|
|
91
93
|
export type { CmsClientConfig };
|
package/dist/index.mjs
CHANGED
|
@@ -160,13 +160,23 @@ class CmsClient {
|
|
|
160
160
|
);
|
|
161
161
|
return normalizeListResponse(result, "/redirects");
|
|
162
162
|
}
|
|
163
|
+
/** 获取站点运行时配置 */
|
|
164
|
+
async getSiteConfig(options) {
|
|
165
|
+
return this.request(
|
|
166
|
+
"GET",
|
|
167
|
+
"/site-config",
|
|
168
|
+
options,
|
|
169
|
+
void 0,
|
|
170
|
+
{ defaultLocale: false }
|
|
171
|
+
);
|
|
172
|
+
}
|
|
163
173
|
/** 获取文章系列 */
|
|
164
174
|
async getSeries(slug, locale) {
|
|
165
175
|
return this.request("GET", `/series/${encodeURIComponent(slug)}`, { locale });
|
|
166
176
|
}
|
|
167
177
|
// ─── 内部请求方法 ──────────────────────────────────
|
|
168
|
-
async request(method, path, query, body) {
|
|
169
|
-
if (method === "GET" && this.config.defaultLocale) {
|
|
178
|
+
async request(method, path, query, body, options) {
|
|
179
|
+
if (method === "GET" && options?.defaultLocale !== false && this.config.defaultLocale) {
|
|
170
180
|
const q = query ?? {};
|
|
171
181
|
if (q.locale === void 0 || q.locale === null) {
|
|
172
182
|
q.locale = this.config.defaultLocale;
|
package/dist/types.d.mts
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
|
-
|
|
1
|
+
import { RoutePolicy } from './routes.mjs';
|
|
2
|
+
export { BuildRoutePathOptions, ResolvedRouteLocalePolicy, ResolvedRoutePolicy, RouteLocalePolicy, RouteParams, RoutePolicyConfig, RouteResourceDefaults, RouteResources } from './routes.mjs';
|
|
2
3
|
|
|
4
|
+
/** 作者社交链接 */
|
|
5
|
+
interface AuthorSocialLink {
|
|
6
|
+
kind?: string;
|
|
7
|
+
label: string;
|
|
8
|
+
href: string;
|
|
9
|
+
handle?: string;
|
|
10
|
+
}
|
|
11
|
+
/** 作者资料统计项 */
|
|
12
|
+
interface AuthorProfileStat {
|
|
13
|
+
label: string;
|
|
14
|
+
value: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
}
|
|
17
|
+
/** 作者资料问答项 */
|
|
18
|
+
interface AuthorProfileQuestion {
|
|
19
|
+
label?: string;
|
|
20
|
+
text: string;
|
|
21
|
+
}
|
|
22
|
+
/** 作者资料内容分区 */
|
|
23
|
+
interface AuthorProfileSection {
|
|
24
|
+
key: string;
|
|
25
|
+
eyebrow: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
paragraphs?: string[];
|
|
28
|
+
questions?: AuthorProfileQuestion[];
|
|
29
|
+
}
|
|
30
|
+
/** 作者资料行动入口 */
|
|
31
|
+
interface AuthorProfileCta {
|
|
32
|
+
label: string;
|
|
33
|
+
href: string;
|
|
34
|
+
title?: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
}
|
|
37
|
+
/** 作者资料内容 */
|
|
38
|
+
interface AuthorProfile {
|
|
39
|
+
eyebrow?: string;
|
|
40
|
+
role?: string;
|
|
41
|
+
role_line?: string;
|
|
42
|
+
lede?: string;
|
|
43
|
+
socials?: AuthorSocialLink[];
|
|
44
|
+
stats?: AuthorProfileStat[];
|
|
45
|
+
sections?: AuthorProfileSection[];
|
|
46
|
+
tags?: string[];
|
|
47
|
+
cta?: AuthorProfileCta;
|
|
48
|
+
}
|
|
3
49
|
/** 作者信息 (Go: delivery.DeliveryAuthorResponse) */
|
|
4
50
|
interface Author {
|
|
5
51
|
id: number;
|
|
@@ -13,6 +59,7 @@ interface Author {
|
|
|
13
59
|
twitter_meta?: Partial<TwitterMeta>;
|
|
14
60
|
available_locales?: string[];
|
|
15
61
|
localized_slugs?: Record<string, string>;
|
|
62
|
+
profile?: AuthorProfile;
|
|
16
63
|
}
|
|
17
64
|
|
|
18
65
|
/** 多语言字符串 (Go: domain.LocalizedString = map[string]string) */
|
|
@@ -174,11 +221,12 @@ interface CreateCommentPayload {
|
|
|
174
221
|
}
|
|
175
222
|
|
|
176
223
|
/** 重定向规则 (Go: delivery.RedirectRuleResponse) */
|
|
224
|
+
type RedirectMatchType = 'exact' | 'prefix' | 'regex';
|
|
177
225
|
interface RedirectRule {
|
|
178
226
|
source_path: string;
|
|
179
227
|
destination_path: string;
|
|
180
228
|
status_code: number;
|
|
181
|
-
match_type:
|
|
229
|
+
match_type: RedirectMatchType;
|
|
182
230
|
priority: number;
|
|
183
231
|
}
|
|
184
232
|
|
|
@@ -191,6 +239,20 @@ interface Series {
|
|
|
191
239
|
articles: ArticleListItem[];
|
|
192
240
|
}
|
|
193
241
|
|
|
242
|
+
interface SiteConfig {
|
|
243
|
+
product_code: string;
|
|
244
|
+
site_name: string;
|
|
245
|
+
site_url: string;
|
|
246
|
+
sitemap_path: string;
|
|
247
|
+
domain_aliases: string[];
|
|
248
|
+
route_policy: RoutePolicy;
|
|
249
|
+
updated_at: string;
|
|
250
|
+
}
|
|
251
|
+
interface SiteConfigQuery {
|
|
252
|
+
site_url?: string;
|
|
253
|
+
host?: string;
|
|
254
|
+
}
|
|
255
|
+
|
|
194
256
|
/** Hreflang 条目 (Go: delivery.HreflangEntry) */
|
|
195
257
|
interface HreflangEntry {
|
|
196
258
|
lang: string;
|
|
@@ -224,4 +286,5 @@ interface RevalidatePayload {
|
|
|
224
286
|
category_slug?: string;
|
|
225
287
|
}
|
|
226
288
|
|
|
227
|
-
export
|
|
289
|
+
export { RoutePolicy };
|
|
290
|
+
export type { ArticleDetail, ArticleListItem, ArticleListParams, ArticleSearchParams, ArticleSearchResultItem, Author, AuthorProfile, AuthorProfileCta, AuthorProfileQuestion, AuthorProfileSection, AuthorProfileStat, AuthorSocialLink, CategoryNode, Comment, CreateCommentPayload, HreflangEntry, ListResponse, LocalizedOgMetaMap, LocalizedSeoMetaMap, LocalizedString, LocalizedTwitterMetaMap, OgMeta, Paginated, PaginationMeta, PaginationParams, RedirectMatchType, RedirectRule, RevalidatePayload, SeoMeta, Series, SiteConfig, SiteConfigQuery, SitemapEntry, SitemapImageEntry, TwitterMeta, WebhookEventType };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
|
-
|
|
1
|
+
import { RoutePolicy } from './routes.js';
|
|
2
|
+
export { BuildRoutePathOptions, ResolvedRouteLocalePolicy, ResolvedRoutePolicy, RouteLocalePolicy, RouteParams, RoutePolicyConfig, RouteResourceDefaults, RouteResources } from './routes.js';
|
|
2
3
|
|
|
4
|
+
/** 作者社交链接 */
|
|
5
|
+
interface AuthorSocialLink {
|
|
6
|
+
kind?: string;
|
|
7
|
+
label: string;
|
|
8
|
+
href: string;
|
|
9
|
+
handle?: string;
|
|
10
|
+
}
|
|
11
|
+
/** 作者资料统计项 */
|
|
12
|
+
interface AuthorProfileStat {
|
|
13
|
+
label: string;
|
|
14
|
+
value: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
}
|
|
17
|
+
/** 作者资料问答项 */
|
|
18
|
+
interface AuthorProfileQuestion {
|
|
19
|
+
label?: string;
|
|
20
|
+
text: string;
|
|
21
|
+
}
|
|
22
|
+
/** 作者资料内容分区 */
|
|
23
|
+
interface AuthorProfileSection {
|
|
24
|
+
key: string;
|
|
25
|
+
eyebrow: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
paragraphs?: string[];
|
|
28
|
+
questions?: AuthorProfileQuestion[];
|
|
29
|
+
}
|
|
30
|
+
/** 作者资料行动入口 */
|
|
31
|
+
interface AuthorProfileCta {
|
|
32
|
+
label: string;
|
|
33
|
+
href: string;
|
|
34
|
+
title?: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
}
|
|
37
|
+
/** 作者资料内容 */
|
|
38
|
+
interface AuthorProfile {
|
|
39
|
+
eyebrow?: string;
|
|
40
|
+
role?: string;
|
|
41
|
+
role_line?: string;
|
|
42
|
+
lede?: string;
|
|
43
|
+
socials?: AuthorSocialLink[];
|
|
44
|
+
stats?: AuthorProfileStat[];
|
|
45
|
+
sections?: AuthorProfileSection[];
|
|
46
|
+
tags?: string[];
|
|
47
|
+
cta?: AuthorProfileCta;
|
|
48
|
+
}
|
|
3
49
|
/** 作者信息 (Go: delivery.DeliveryAuthorResponse) */
|
|
4
50
|
interface Author {
|
|
5
51
|
id: number;
|
|
@@ -13,6 +59,7 @@ interface Author {
|
|
|
13
59
|
twitter_meta?: Partial<TwitterMeta>;
|
|
14
60
|
available_locales?: string[];
|
|
15
61
|
localized_slugs?: Record<string, string>;
|
|
62
|
+
profile?: AuthorProfile;
|
|
16
63
|
}
|
|
17
64
|
|
|
18
65
|
/** 多语言字符串 (Go: domain.LocalizedString = map[string]string) */
|
|
@@ -174,11 +221,12 @@ interface CreateCommentPayload {
|
|
|
174
221
|
}
|
|
175
222
|
|
|
176
223
|
/** 重定向规则 (Go: delivery.RedirectRuleResponse) */
|
|
224
|
+
type RedirectMatchType = 'exact' | 'prefix' | 'regex';
|
|
177
225
|
interface RedirectRule {
|
|
178
226
|
source_path: string;
|
|
179
227
|
destination_path: string;
|
|
180
228
|
status_code: number;
|
|
181
|
-
match_type:
|
|
229
|
+
match_type: RedirectMatchType;
|
|
182
230
|
priority: number;
|
|
183
231
|
}
|
|
184
232
|
|
|
@@ -191,6 +239,20 @@ interface Series {
|
|
|
191
239
|
articles: ArticleListItem[];
|
|
192
240
|
}
|
|
193
241
|
|
|
242
|
+
interface SiteConfig {
|
|
243
|
+
product_code: string;
|
|
244
|
+
site_name: string;
|
|
245
|
+
site_url: string;
|
|
246
|
+
sitemap_path: string;
|
|
247
|
+
domain_aliases: string[];
|
|
248
|
+
route_policy: RoutePolicy;
|
|
249
|
+
updated_at: string;
|
|
250
|
+
}
|
|
251
|
+
interface SiteConfigQuery {
|
|
252
|
+
site_url?: string;
|
|
253
|
+
host?: string;
|
|
254
|
+
}
|
|
255
|
+
|
|
194
256
|
/** Hreflang 条目 (Go: delivery.HreflangEntry) */
|
|
195
257
|
interface HreflangEntry {
|
|
196
258
|
lang: string;
|
|
@@ -224,4 +286,5 @@ interface RevalidatePayload {
|
|
|
224
286
|
category_slug?: string;
|
|
225
287
|
}
|
|
226
288
|
|
|
227
|
-
export
|
|
289
|
+
export { RoutePolicy };
|
|
290
|
+
export type { ArticleDetail, ArticleListItem, ArticleListParams, ArticleSearchParams, ArticleSearchResultItem, Author, AuthorProfile, AuthorProfileCta, AuthorProfileQuestion, AuthorProfileSection, AuthorProfileStat, AuthorSocialLink, CategoryNode, Comment, CreateCommentPayload, HreflangEntry, ListResponse, LocalizedOgMetaMap, LocalizedSeoMetaMap, LocalizedString, LocalizedTwitterMetaMap, OgMeta, Paginated, PaginationMeta, PaginationParams, RedirectMatchType, RedirectRule, RevalidatePayload, SeoMeta, Series, SiteConfig, SiteConfigQuery, SitemapEntry, SitemapImageEntry, TwitterMeta, WebhookEventType };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vigilkids/cms-client",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Framework-agnostic TypeScript client for OnEx CMS Public API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.mjs",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"sideEffects": false,
|
|
47
47
|
"scripts": {
|
|
48
48
|
"build": "unbuild",
|
|
49
|
+
"prepack": "pnpm build",
|
|
49
50
|
"lint": "eslint .",
|
|
50
51
|
"lint:fix": "eslint . --fix",
|
|
51
52
|
"format": "prettier --write src/"
|