@vigilkids/cms-client 0.3.3 → 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,12 @@ 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
+
8
14
  ## [0.3.3] - 2026-06-16
9
15
 
10
16
  ### 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 { AuthorProfile, AuthorProfileCta, AuthorProfileQuestion, AuthorProfileSection, AuthorProfileStat, AuthorSocialLink, HreflangEntry, ListResponse, LocalizedOgMetaMap, LocalizedSeoMetaMap, LocalizedString, LocalizedTwitterMetaMap, OgMeta, PaginationMeta, RedirectMatchType, 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 { AuthorProfile, AuthorProfileCta, AuthorProfileQuestion, AuthorProfileSection, AuthorProfileStat, AuthorSocialLink, HreflangEntry, ListResponse, LocalizedOgMetaMap, LocalizedSeoMetaMap, LocalizedString, LocalizedTwitterMetaMap, OgMeta, PaginationMeta, RedirectMatchType, 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
@@ -239,17 +239,28 @@ interface Series {
239
239
  articles: ArticleListItem[];
240
240
  }
241
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
+ }
242
251
  interface SiteConfig {
252
+ site_code: string;
243
253
  product_code: string;
244
254
  site_name: string;
245
- site_url: string;
255
+ delivery_mode: SiteDeliveryMode;
256
+ canonical_base_url: string;
257
+ domains: SiteDomain[];
246
258
  sitemap_path: string;
247
- domain_aliases: string[];
248
259
  route_policy: RoutePolicy;
249
260
  updated_at: string;
250
261
  }
251
262
  interface SiteConfigQuery {
252
- site_url?: string;
263
+ site_code?: string;
253
264
  host?: string;
254
265
  }
255
266
 
@@ -287,4 +298,4 @@ interface RevalidatePayload {
287
298
  }
288
299
 
289
300
  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 };
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
@@ -239,17 +239,28 @@ interface Series {
239
239
  articles: ArticleListItem[];
240
240
  }
241
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
+ }
242
251
  interface SiteConfig {
252
+ site_code: string;
243
253
  product_code: string;
244
254
  site_name: string;
245
- site_url: string;
255
+ delivery_mode: SiteDeliveryMode;
256
+ canonical_base_url: string;
257
+ domains: SiteDomain[];
246
258
  sitemap_path: string;
247
- domain_aliases: string[];
248
259
  route_policy: RoutePolicy;
249
260
  updated_at: string;
250
261
  }
251
262
  interface SiteConfigQuery {
252
- site_url?: string;
263
+ site_code?: string;
253
264
  host?: string;
254
265
  }
255
266
 
@@ -287,4 +298,4 @@ interface RevalidatePayload {
287
298
  }
288
299
 
289
300
  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 };
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.3",
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,