@vigilkids/cms-client 0.3.1 → 0.3.2
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.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.mjs +12 -2
- package/dist/types.d.mts +18 -2
- package/dist/types.d.ts +18 -2
- package/package.json +2 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ArticleListParams, Paginated, ArticleListItem, ArticleDetail, ArticleSearchParams, ArticleSearchResultItem, PaginationParams, Author, CategoryNode, Comment, CreateCommentPayload, SitemapEntry, RedirectRule, Series } 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
2
|
export { HreflangEntry, ListResponse, LocalizedOgMetaMap, LocalizedSeoMetaMap, LocalizedString, LocalizedTwitterMetaMap, OgMeta, PaginationMeta, 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
|
|
|
@@ -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,4 +1,4 @@
|
|
|
1
|
-
import { ArticleListParams, Paginated, ArticleListItem, ArticleDetail, ArticleSearchParams, ArticleSearchResultItem, PaginationParams, Author, CategoryNode, Comment, CreateCommentPayload, SitemapEntry, RedirectRule, Series } 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
2
|
export { HreflangEntry, ListResponse, LocalizedOgMetaMap, LocalizedSeoMetaMap, LocalizedString, LocalizedTwitterMetaMap, OgMeta, PaginationMeta, 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
|
|
|
@@ -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,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { RoutePolicy } from './routes.mjs';
|
|
2
|
+
export { BuildRoutePathOptions, ResolvedRouteLocalePolicy, ResolvedRoutePolicy, RouteLocalePolicy, RouteParams, RoutePolicyConfig, RouteResourceDefaults, RouteResources } from './routes.mjs';
|
|
2
3
|
|
|
3
4
|
/** 作者信息 (Go: delivery.DeliveryAuthorResponse) */
|
|
4
5
|
interface Author {
|
|
@@ -191,6 +192,20 @@ interface Series {
|
|
|
191
192
|
articles: ArticleListItem[];
|
|
192
193
|
}
|
|
193
194
|
|
|
195
|
+
interface SiteConfig {
|
|
196
|
+
product_code: string;
|
|
197
|
+
site_name: string;
|
|
198
|
+
site_url: string;
|
|
199
|
+
sitemap_path: string;
|
|
200
|
+
domain_aliases: string[];
|
|
201
|
+
route_policy: RoutePolicy;
|
|
202
|
+
updated_at: string;
|
|
203
|
+
}
|
|
204
|
+
interface SiteConfigQuery {
|
|
205
|
+
site_url?: string;
|
|
206
|
+
host?: string;
|
|
207
|
+
}
|
|
208
|
+
|
|
194
209
|
/** Hreflang 条目 (Go: delivery.HreflangEntry) */
|
|
195
210
|
interface HreflangEntry {
|
|
196
211
|
lang: string;
|
|
@@ -224,4 +239,5 @@ interface RevalidatePayload {
|
|
|
224
239
|
category_slug?: string;
|
|
225
240
|
}
|
|
226
241
|
|
|
227
|
-
export
|
|
242
|
+
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 };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { RoutePolicy } from './routes.js';
|
|
2
|
+
export { BuildRoutePathOptions, ResolvedRouteLocalePolicy, ResolvedRoutePolicy, RouteLocalePolicy, RouteParams, RoutePolicyConfig, RouteResourceDefaults, RouteResources } from './routes.js';
|
|
2
3
|
|
|
3
4
|
/** 作者信息 (Go: delivery.DeliveryAuthorResponse) */
|
|
4
5
|
interface Author {
|
|
@@ -191,6 +192,20 @@ interface Series {
|
|
|
191
192
|
articles: ArticleListItem[];
|
|
192
193
|
}
|
|
193
194
|
|
|
195
|
+
interface SiteConfig {
|
|
196
|
+
product_code: string;
|
|
197
|
+
site_name: string;
|
|
198
|
+
site_url: string;
|
|
199
|
+
sitemap_path: string;
|
|
200
|
+
domain_aliases: string[];
|
|
201
|
+
route_policy: RoutePolicy;
|
|
202
|
+
updated_at: string;
|
|
203
|
+
}
|
|
204
|
+
interface SiteConfigQuery {
|
|
205
|
+
site_url?: string;
|
|
206
|
+
host?: string;
|
|
207
|
+
}
|
|
208
|
+
|
|
194
209
|
/** Hreflang 条目 (Go: delivery.HreflangEntry) */
|
|
195
210
|
interface HreflangEntry {
|
|
196
211
|
lang: string;
|
|
@@ -224,4 +239,5 @@ interface RevalidatePayload {
|
|
|
224
239
|
category_slug?: string;
|
|
225
240
|
}
|
|
226
241
|
|
|
227
|
-
export
|
|
242
|
+
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vigilkids/cms-client",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
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/"
|