@vigilkids/cms-client 0.3.2 → 0.3.4

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 CHANGED
@@ -5,6 +5,25 @@ 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.4] - 2026-07-19
9
+
10
+ ### Changed
11
+
12
+ - Included the package README and license in the published artifact.
13
+
14
+ ## [0.3.3] - 2026-06-16
15
+
16
+ ### Added
17
+
18
+ - Added localized author profile contract fields for reusable CMS author pages.
19
+ - Added typed site runtime route policy and redirect match rule metadata for CMS delivery consumers.
20
+
21
+ ## [0.3.2] - 2026-06-14
22
+
23
+ ### Added
24
+
25
+ - Added optional author profile content types for reusable author pages across CMS consumers.
26
+
8
27
  ## [0.3.1] - 2026-06-05
9
28
 
10
29
  ### Added
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ArticleListParams, Paginated, ArticleListItem, ArticleDetail, ArticleSearchParams, ArticleSearchResultItem, PaginationParams, Author, CategoryNode, Comment, CreateCommentPayload, SitemapEntry, RedirectRule, SiteConfigQuery, SiteConfig, Series } from './types.mjs';
2
- export { HreflangEntry, ListResponse, LocalizedOgMetaMap, LocalizedSeoMetaMap, LocalizedString, LocalizedTwitterMetaMap, OgMeta, PaginationMeta, RevalidatePayload, SeoMeta, SitemapImageEntry, TwitterMeta, WebhookEventType } from './types.mjs';
2
+ export { AuthorProfile, AuthorProfileCta, AuthorProfileQuestion, AuthorProfileSection, AuthorProfileStat, AuthorSocialLink, HreflangEntry, ListResponse, LocalizedOgMetaMap, LocalizedSeoMetaMap, LocalizedString, LocalizedTwitterMetaMap, OgMeta, PaginationMeta, RedirectMatchType, RevalidatePayload, SeoMeta, SiteDeliveryMode, SiteDomain, SiteDomainType, 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 客户端配置 */
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ArticleListParams, Paginated, ArticleListItem, ArticleDetail, ArticleSearchParams, ArticleSearchResultItem, PaginationParams, Author, CategoryNode, Comment, CreateCommentPayload, SitemapEntry, RedirectRule, SiteConfigQuery, SiteConfig, Series } from './types.js';
2
- export { HreflangEntry, ListResponse, LocalizedOgMetaMap, LocalizedSeoMetaMap, LocalizedString, LocalizedTwitterMetaMap, OgMeta, PaginationMeta, RevalidatePayload, SeoMeta, SitemapImageEntry, TwitterMeta, WebhookEventType } from './types.js';
2
+ export { AuthorProfile, AuthorProfileCta, AuthorProfileQuestion, AuthorProfileSection, AuthorProfileStat, AuthorSocialLink, HreflangEntry, ListResponse, LocalizedOgMetaMap, LocalizedSeoMetaMap, LocalizedString, LocalizedTwitterMetaMap, OgMeta, PaginationMeta, RedirectMatchType, RevalidatePayload, SeoMeta, SiteDeliveryMode, SiteDomain, SiteDomainType, 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 客户端配置 */
package/dist/index.mjs CHANGED
@@ -164,7 +164,7 @@ class CmsClient {
164
164
  async getSiteConfig(options) {
165
165
  return this.request(
166
166
  "GET",
167
- "/site-config",
167
+ "/site",
168
168
  options,
169
169
  void 0,
170
170
  { defaultLocale: false }
package/dist/routes.mjs CHANGED
@@ -11,7 +11,8 @@ function normalizePath(path) {
11
11
  const clean = path.split("?")[0]?.split("#")[0] ?? "";
12
12
  const withSlash = clean.startsWith("/") ? clean : `/${clean}`;
13
13
  const collapsed = withSlash.replace(/\/{2,}/g, "/");
14
- if (collapsed.length > 1) return collapsed.replace(/\/+$/g, "");
14
+ if (collapsed.length > 1)
15
+ return collapsed.replace(/\/+$/g, "");
15
16
  return collapsed;
16
17
  }
17
18
  function encodePathValue(value) {
@@ -21,12 +22,15 @@ function isPlainObject(value) {
21
22
  return typeof value === "object" && value !== null && !Array.isArray(value);
22
23
  }
23
24
  function isStringRecord(value) {
24
- if (!isPlainObject(value)) return false;
25
+ if (!isPlainObject(value))
26
+ return false;
25
27
  return Object.values(value).every((item) => typeof item === "string");
26
28
  }
27
29
  function localePrefix(locale, policy) {
28
- if (!locale) return "";
29
- if (locale === policy.defaultLocale && !policy.includeDefaultLocale) return "";
30
+ if (!locale)
31
+ return "";
32
+ if (locale === policy.defaultLocale && !policy.includeDefaultLocale)
33
+ return "";
30
34
  const prefix = policy.prefixes[locale] ?? locale.toLowerCase();
31
35
  return `/${trimSlashes(prefix)}`;
32
36
  }
@@ -68,7 +72,8 @@ function buildRoutePath(policy, resource, params = {}, options = {}) {
68
72
  return encodePathValue(value);
69
73
  })
70
74
  );
71
- if (!options.includeLocale) return path;
75
+ if (!options.includeLocale)
76
+ return path;
72
77
  return normalizePath(`${localePrefix(String(params.locale ?? ""), resolvedPolicy.locale)}${path}`);
73
78
  }
74
79
  function buildRouteUrl(baseUrl, policy, resource, params = {}, options = {}) {
@@ -77,16 +82,23 @@ function buildRouteUrl(baseUrl, policy, resource, params = {}, options = {}) {
77
82
  return normalizedBaseUrl ? `${normalizedBaseUrl}${path}` : path;
78
83
  }
79
84
  function isRoutePolicy(value) {
80
- if (!isPlainObject(value)) return false;
85
+ if (!isPlainObject(value))
86
+ return false;
81
87
  const { locale, resources, sourceResources } = value;
82
- if (resources !== void 0 && !isStringRecord(resources)) return false;
83
- if (sourceResources !== void 0 && !isStringRecord(sourceResources)) return false;
88
+ if (resources !== void 0 && !isStringRecord(resources))
89
+ return false;
90
+ if (sourceResources !== void 0 && !isStringRecord(sourceResources))
91
+ return false;
84
92
  if (locale !== void 0) {
85
- if (!isPlainObject(locale)) return false;
86
- if (locale.defaultLocale !== void 0 && typeof locale.defaultLocale !== "string") return false;
87
- if (locale.includeDefaultLocale !== void 0 && typeof locale.includeDefaultLocale !== "boolean")
93
+ if (!isPlainObject(locale))
94
+ return false;
95
+ if (locale.defaultLocale !== void 0 && typeof locale.defaultLocale !== "string")
96
+ return false;
97
+ if (locale.includeDefaultLocale !== void 0 && typeof locale.includeDefaultLocale !== "boolean") {
98
+ return false;
99
+ }
100
+ if (locale.prefixes !== void 0 && !isStringRecord(locale.prefixes))
88
101
  return false;
89
- if (locale.prefixes !== void 0 && !isStringRecord(locale.prefixes)) return false;
90
102
  }
91
103
  return true;
92
104
  }
@@ -116,11 +128,13 @@ function extractRouteParams(pattern, path) {
116
128
  }
117
129
  expression += "$";
118
130
  const match = normalizePath(path).match(new RegExp(expression));
119
- if (!match) return null;
131
+ if (!match)
132
+ return null;
120
133
  const params = {};
121
134
  for (let index = 0; index < keys.length; index++) {
122
135
  const raw = match[index + 1];
123
- if (raw) params[keys[index]] = decodeURIComponent(raw);
136
+ if (raw)
137
+ params[keys[index]] = decodeURIComponent(raw);
124
138
  }
125
139
  return params;
126
140
  }
@@ -133,7 +147,8 @@ function extractSourceRouteParams(policy, resource, path) {
133
147
  ].filter((pattern) => Boolean(pattern));
134
148
  for (const pattern of candidates) {
135
149
  const params = extractRouteParams(pattern, path);
136
- if (params) return params;
150
+ if (params)
151
+ return params;
137
152
  }
138
153
  return null;
139
154
  }
package/dist/types.d.mts CHANGED
@@ -1,6 +1,51 @@
1
1
  import { RoutePolicy } from './routes.mjs';
2
2
  export { BuildRoutePathOptions, ResolvedRouteLocalePolicy, ResolvedRoutePolicy, RouteLocalePolicy, RouteParams, RoutePolicyConfig, RouteResourceDefaults, RouteResources } from './routes.mjs';
3
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
+ }
4
49
  /** 作者信息 (Go: delivery.DeliveryAuthorResponse) */
5
50
  interface Author {
6
51
  id: number;
@@ -14,6 +59,7 @@ interface Author {
14
59
  twitter_meta?: Partial<TwitterMeta>;
15
60
  available_locales?: string[];
16
61
  localized_slugs?: Record<string, string>;
62
+ profile?: AuthorProfile;
17
63
  }
18
64
 
19
65
  /** 多语言字符串 (Go: domain.LocalizedString = map[string]string) */
@@ -175,11 +221,12 @@ interface CreateCommentPayload {
175
221
  }
176
222
 
177
223
  /** 重定向规则 (Go: delivery.RedirectRuleResponse) */
224
+ type RedirectMatchType = 'exact' | 'prefix' | 'regex';
178
225
  interface RedirectRule {
179
226
  source_path: string;
180
227
  destination_path: string;
181
228
  status_code: number;
182
- match_type: string;
229
+ match_type: RedirectMatchType;
183
230
  priority: number;
184
231
  }
185
232
 
@@ -192,17 +239,28 @@ interface Series {
192
239
  articles: ArticleListItem[];
193
240
  }
194
241
 
242
+ type SiteDeliveryMode = 'isr' | 'static';
243
+ type SiteDomainType = 'alias' | 'preview' | 'primary';
244
+ interface SiteDomain {
245
+ scheme: 'http' | 'https';
246
+ host: string;
247
+ port?: number;
248
+ base_path: string;
249
+ domain_type: SiteDomainType;
250
+ }
195
251
  interface SiteConfig {
252
+ site_code: string;
196
253
  product_code: string;
197
254
  site_name: string;
198
- site_url: string;
255
+ delivery_mode: SiteDeliveryMode;
256
+ canonical_base_url: string;
257
+ domains: SiteDomain[];
199
258
  sitemap_path: string;
200
- domain_aliases: string[];
201
259
  route_policy: RoutePolicy;
202
260
  updated_at: string;
203
261
  }
204
262
  interface SiteConfigQuery {
205
- site_url?: string;
263
+ site_code?: string;
206
264
  host?: string;
207
265
  }
208
266
 
@@ -240,4 +298,4 @@ interface RevalidatePayload {
240
298
  }
241
299
 
242
300
  export { RoutePolicy };
243
- export type { ArticleDetail, ArticleListItem, ArticleListParams, ArticleSearchParams, ArticleSearchResultItem, Author, CategoryNode, Comment, CreateCommentPayload, HreflangEntry, ListResponse, LocalizedOgMetaMap, LocalizedSeoMetaMap, LocalizedString, LocalizedTwitterMetaMap, OgMeta, Paginated, PaginationMeta, PaginationParams, RedirectRule, RevalidatePayload, SeoMeta, Series, SiteConfig, SiteConfigQuery, SitemapEntry, SitemapImageEntry, TwitterMeta, WebhookEventType };
301
+ 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, SiteDeliveryMode, SiteDomain, SiteDomainType, SitemapEntry, SitemapImageEntry, TwitterMeta, WebhookEventType };
package/dist/types.d.ts CHANGED
@@ -1,6 +1,51 @@
1
1
  import { RoutePolicy } from './routes.js';
2
2
  export { BuildRoutePathOptions, ResolvedRouteLocalePolicy, ResolvedRoutePolicy, RouteLocalePolicy, RouteParams, RoutePolicyConfig, RouteResourceDefaults, RouteResources } from './routes.js';
3
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
+ }
4
49
  /** 作者信息 (Go: delivery.DeliveryAuthorResponse) */
5
50
  interface Author {
6
51
  id: number;
@@ -14,6 +59,7 @@ interface Author {
14
59
  twitter_meta?: Partial<TwitterMeta>;
15
60
  available_locales?: string[];
16
61
  localized_slugs?: Record<string, string>;
62
+ profile?: AuthorProfile;
17
63
  }
18
64
 
19
65
  /** 多语言字符串 (Go: domain.LocalizedString = map[string]string) */
@@ -175,11 +221,12 @@ interface CreateCommentPayload {
175
221
  }
176
222
 
177
223
  /** 重定向规则 (Go: delivery.RedirectRuleResponse) */
224
+ type RedirectMatchType = 'exact' | 'prefix' | 'regex';
178
225
  interface RedirectRule {
179
226
  source_path: string;
180
227
  destination_path: string;
181
228
  status_code: number;
182
- match_type: string;
229
+ match_type: RedirectMatchType;
183
230
  priority: number;
184
231
  }
185
232
 
@@ -192,17 +239,28 @@ interface Series {
192
239
  articles: ArticleListItem[];
193
240
  }
194
241
 
242
+ type SiteDeliveryMode = 'isr' | 'static';
243
+ type SiteDomainType = 'alias' | 'preview' | 'primary';
244
+ interface SiteDomain {
245
+ scheme: 'http' | 'https';
246
+ host: string;
247
+ port?: number;
248
+ base_path: string;
249
+ domain_type: SiteDomainType;
250
+ }
195
251
  interface SiteConfig {
252
+ site_code: string;
196
253
  product_code: string;
197
254
  site_name: string;
198
- site_url: string;
255
+ delivery_mode: SiteDeliveryMode;
256
+ canonical_base_url: string;
257
+ domains: SiteDomain[];
199
258
  sitemap_path: string;
200
- domain_aliases: string[];
201
259
  route_policy: RoutePolicy;
202
260
  updated_at: string;
203
261
  }
204
262
  interface SiteConfigQuery {
205
- site_url?: string;
263
+ site_code?: string;
206
264
  host?: string;
207
265
  }
208
266
 
@@ -240,4 +298,4 @@ interface RevalidatePayload {
240
298
  }
241
299
 
242
300
  export { RoutePolicy };
243
- export type { ArticleDetail, ArticleListItem, ArticleListParams, ArticleSearchParams, ArticleSearchResultItem, Author, CategoryNode, Comment, CreateCommentPayload, HreflangEntry, ListResponse, LocalizedOgMetaMap, LocalizedSeoMetaMap, LocalizedString, LocalizedTwitterMetaMap, OgMeta, Paginated, PaginationMeta, PaginationParams, RedirectRule, RevalidatePayload, SeoMeta, Series, SiteConfig, SiteConfigQuery, SitemapEntry, SitemapImageEntry, TwitterMeta, WebhookEventType };
301
+ 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, SiteDeliveryMode, SiteDomain, SiteDomainType, SitemapEntry, SitemapImageEntry, TwitterMeta, WebhookEventType };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vigilkids/cms-client",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "Framework-agnostic TypeScript client for OnEx CMS Public API",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",
@@ -41,6 +41,8 @@
41
41
  },
42
42
  "files": [
43
43
  "dist",
44
+ "README.md",
45
+ "LICENSE",
44
46
  "CHANGELOG.md"
45
47
  ],
46
48
  "sideEffects": false,