icms-api 0.1.2 → 0.1.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.
@@ -0,0 +1,3 @@
1
+ export * from './types/site';
2
+ export * from './types/cms';
3
+ export * from './client';
@@ -0,0 +1,78 @@
1
+ /**
2
+ * 客户端 HTTP 辅助函数
3
+ * 从 @rock.chen/icms-http-client/web-client 内联,
4
+ * 避免引入 pino/pino-pretty/sonic-boom 等 Node.js 服务端模块
5
+ */
6
+ /** Cookie 读写接口 */
7
+ export interface ICookies {
8
+ get(key: string): string | undefined;
9
+ set?(key: string, value: string): void;
10
+ delete?(key: string): void;
11
+ }
12
+ /** API 返回模型 */
13
+ export interface ResultModel<T = unknown> {
14
+ code: number;
15
+ success: boolean;
16
+ msg: string;
17
+ data?: T;
18
+ headers?: Record<string, string>;
19
+ }
20
+ /** GET 请求参数 */
21
+ export interface ClientGetParams {
22
+ data?: Record<string, string>;
23
+ headers?: Record<string, string>;
24
+ useCache?: boolean;
25
+ showError?: (msg: string) => void;
26
+ }
27
+ /** POST 请求参数 */
28
+ export interface ClientPostParams {
29
+ data?: Record<string, unknown> | FormData;
30
+ headers?: Record<string, string>;
31
+ showError?: (msg: string) => void;
32
+ showSuccess?: (msg: string) => void;
33
+ }
34
+ /** Cookie 名称常量 */
35
+ export declare const COOKIE_NAMES: {
36
+ readonly IBOOT_DEVICE_ID: "dvid";
37
+ readonly IBOOT_LANG: "lang";
38
+ readonly IBOOT_WEBSITE_ID: "wid";
39
+ readonly IBOOT_WEBSITE_NO: "wno";
40
+ readonly IBOOT_TOKEN: "token";
41
+ readonly IBOOT_USER: "user";
42
+ };
43
+ /** Content-Type 常量 */
44
+ export declare const CONTENT_TYPE_KEY = "Content-Type";
45
+ export declare const CONTENT_TYPE_MAP: {
46
+ readonly applicationJson: "application/json";
47
+ readonly multipartFormData: "multipart/form-data";
48
+ readonly applicationXwwwFormUrlencoded: "application/x-www-form-urlencoded";
49
+ };
50
+ /** 用户信息 */
51
+ export interface User {
52
+ id: string;
53
+ name: string;
54
+ userType: number;
55
+ username?: string;
56
+ nickname?: string;
57
+ sex?: number;
58
+ headImg?: string;
59
+ lastLoginTime?: string;
60
+ tokenExpired?: string;
61
+ deviceId?: string;
62
+ status?: number;
63
+ accountType?: number;
64
+ enabled?: boolean;
65
+ userFrom?: number;
66
+ needToReview?: boolean;
67
+ socketOnline?: boolean;
68
+ createTime?: string;
69
+ mustChangePwd?: boolean;
70
+ }
71
+ /** 从 cookie 中读取已登录用户信息 */
72
+ export declare const getLoginUser: (cookies: ICookies) => User | undefined;
73
+ /** GET 请求快捷方法(自动解包 data) */
74
+ export declare const iGet: <T>(url: string, opts?: ClientGetParams) => Promise<T | undefined>;
75
+ /** POST 请求快捷方法(自动解包 data) */
76
+ export declare const iPost: <T>(url: string, opts?: ClientPostParams) => Promise<T | undefined>;
77
+ /** POST 请求,返回 boolean */
78
+ export declare const iPostSuccess: (url: string, opts?: ClientPostParams) => Promise<boolean>;
@@ -1,13 +1,109 @@
1
- import { ICookies } from '@rock.chen/icms-http-client';
2
- import { Member } from './types/site';
1
+ import { Member, FriendLink, LinkGroup, I18NWebsite, Webchannel, WebsiteInfo } from './types/site';
2
+ import { ProductContent } from './types/cms-product';
3
+ import { PageInfo, PageParams } from './types/cms-base';
4
+ import { NewsContent } from './types/cms-news';
5
+ import { PhotoContent } from './types/cms-photo';
6
+ import { VideoContent } from './types/cms-video';
7
+ import { ActivityContent } from './types/cms-activity';
8
+ import { Reviews, SubscribeUser, ContactUs } from './types/cms-message';
9
+ import { SpecDescription } from './types/cms-mall';
10
+ import { ICookies } from './client-helper';
3
11
  export declare class ICMSClient {
4
12
  private cookies;
5
13
  constructor();
6
- submitComment(): Promise<void>;
7
14
  setICookies(c: ICookies): ICMSClient;
8
15
  login({ username, password }: Readonly<{
9
16
  username: string;
10
17
  password: string;
11
18
  }>): Promise<Member | undefined>;
12
19
  logout(): Promise<void>;
20
+ loadI18nList(): Promise<Array<I18NWebsite>>;
21
+ loadWebsite(params?: Readonly<{
22
+ showNav?: boolean;
23
+ showFriendLink?: boolean;
24
+ showI18NList?: boolean;
25
+ }>): Promise<WebsiteInfo | undefined>;
26
+ loadChannels(params?: Readonly<{
27
+ channelNo?: string;
28
+ showChildren?: boolean;
29
+ }>): Promise<Array<Webchannel>>;
30
+ loadChannelById(params: Readonly<{
31
+ channelId: string;
32
+ showChildren?: boolean;
33
+ }>): Promise<Webchannel | undefined>;
34
+ loadChannelByNo(params: Readonly<{
35
+ channelNo: string;
36
+ showChildren?: boolean;
37
+ }>): Promise<Webchannel | undefined>;
38
+ loadChannelByUri(params: Readonly<{
39
+ uri: string;
40
+ showChildren?: boolean;
41
+ }>): Promise<Webchannel | undefined>;
42
+ loadProductDetail(proId: string): Promise<ProductContent | undefined>;
43
+ loadProductPageInfo(params: Readonly<{
44
+ channelId?: string;
45
+ keyword?: string;
46
+ } & PageParams>): Promise<PageInfo<ProductContent> | undefined>;
47
+ loadProductPageInfoByGroup(params: Readonly<{
48
+ groupId: string;
49
+ } & PageParams>): Promise<PageInfo<ProductContent> | undefined>;
50
+ loadProductListByGroupId(params: Readonly<{
51
+ groupId: string;
52
+ }>): Promise<Array<ProductContent>>;
53
+ loadNewsDetail(newId: string): Promise<NewsContent | undefined>;
54
+ loadNewsPageInfo(params: Readonly<{
55
+ channelNo?: string;
56
+ keyword?: string;
57
+ } & PageParams>): Promise<PageInfo<NewsContent> | undefined>;
58
+ loadNewsPageInfoByGroupId(params: Readonly<{
59
+ groupId: string;
60
+ } & PageParams>): Promise<PageInfo<NewsContent> | undefined>;
61
+ loadNewsListByGroupId(params: Readonly<{
62
+ groupId: string;
63
+ }>): Promise<Array<NewsContent>>;
64
+ loadPhotoDetail(photoId: string): Promise<PhotoContent | undefined>;
65
+ loadPhotoPageInfo(params: Readonly<{
66
+ channelNo?: string;
67
+ keyword?: string;
68
+ } & PageParams>): Promise<PageInfo<PhotoContent> | undefined>;
69
+ loadPhotoPageInfoByGroup(params: Readonly<{
70
+ groupId: string;
71
+ } & PageParams>): Promise<PageInfo<PhotoContent> | undefined>;
72
+ loadPhotoListByGroupId(params: Readonly<{
73
+ groupId: string;
74
+ }>): Promise<Array<PhotoContent>>;
75
+ loadVideoDetail(videoId: string): Promise<VideoContent | undefined>;
76
+ loadVideoPageInfo(params: Readonly<{
77
+ channelNo?: string;
78
+ keyword?: string;
79
+ } & PageParams>): Promise<PageInfo<VideoContent> | undefined>;
80
+ loadVideoPageInfoByGroup(params: Readonly<{
81
+ groupId: string;
82
+ } & PageParams>): Promise<PageInfo<VideoContent> | undefined>;
83
+ loadVideoListByGroupId(params: Readonly<{
84
+ groupId: string;
85
+ }>): Promise<Array<VideoContent>>;
86
+ loadActivityDetail(activityId: string): Promise<ActivityContent | undefined>;
87
+ loadActivityPageInfo(params: Readonly<{
88
+ channelNo?: string;
89
+ keyword?: string;
90
+ } & PageParams>): Promise<PageInfo<ActivityContent> | undefined>;
91
+ loadActivityPageInfoByGroup(params: Readonly<{
92
+ groupId: string;
93
+ } & PageParams>): Promise<PageInfo<ActivityContent> | undefined>;
94
+ loadActivityListByGroupId(params: Readonly<{
95
+ groupId: string;
96
+ }>): Promise<Array<ActivityContent>>;
97
+ loadReviewList(params: Readonly<{
98
+ entityNo?: string;
99
+ rowCount?: string;
100
+ }>): Promise<Array<Reviews>>;
101
+ submitComment(data: Readonly<Partial<Reviews>>): Promise<boolean>;
102
+ subscribe(data: Readonly<Pick<SubscribeUser, 'email'> & Partial<Pick<SubscribeUser, 'nickname'>>>): Promise<boolean>;
103
+ submitContactUs(data: Readonly<Partial<ContactUs>>): Promise<boolean>;
104
+ loadLinkGroups(): Promise<Array<LinkGroup>>;
105
+ loadFriendLinks(count?: number): Promise<Array<FriendLink>>;
106
+ submitLink(data: Readonly<Pick<FriendLink, 'name' | 'url'> & Partial<Pick<FriendLink, 'description'>>>): Promise<boolean>;
107
+ getSpecDescription(code: string): Promise<SpecDescription | undefined>;
13
108
  }
109
+ export declare const icmsClient: ICMSClient;
@@ -2,4 +2,3 @@ export * from './types/site';
2
2
  export * from './types/cms';
3
3
  export * from './server';
4
4
  export * from './router';
5
- export * from './client';
@@ -1,9 +1,13 @@
1
1
  import { ICookies } from '@rock.chen/icms-http-client';
2
- import { I18NWebsite, Webchannel, WebsiteInfo } from './types/site';
2
+ import { I18NWebsite, Webchannel, WebsiteInfo, FriendLink, LinkGroup } from './types/site';
3
3
  import { ProductContent } from './types/cms-product';
4
4
  import { PageInfo, PageParams } from './types/cms-base';
5
5
  import { NewsContent } from './types/cms-news';
6
- import { Reviews } from './types/cms-message';
6
+ import { PhotoContent } from './types/cms-photo';
7
+ import { VideoContent } from './types/cms-video';
8
+ import { ActivityContent } from './types/cms-activity';
9
+ import { Reviews, SubscribeUser, ContactUs } from './types/cms-message';
10
+ import { SpecDescription } from './types/cms-mall';
7
11
  export declare const helloURL: string;
8
12
  export declare class ICMSServer {
9
13
  private readonly http;
@@ -122,8 +126,138 @@ export declare class ICMSServer {
122
126
  loadNewsListByGroupId(params: Readonly<{
123
127
  groupId: string;
124
128
  }>): Promise<Array<NewsContent>>;
129
+ /**
130
+ * 获取相册详情
131
+ * @param photoId
132
+ * @returns
133
+ */
134
+ loadPhotoDetail(photoId: string): Promise<PhotoContent | undefined>;
135
+ /**
136
+ * 分页获取相册列表
137
+ * @param params {channelNo?:指定栏目下的内容, keyword?:关键字查询, pageNo:页码, pageSize:每页记录数, sortBy?:指定排序字段, sort?:排序方向'ASC' | 'DESC'}
138
+ * @returns
139
+ */
140
+ loadPhotoPageInfo(params: Readonly<{
141
+ channelNo?: string;
142
+ keyword?: string;
143
+ } & PageParams>): Promise<PageInfo<PhotoContent>>;
144
+ /**
145
+ * 按分组分页获取相册列表
146
+ * @param params {groupId:分组ID, pageNo:页码, pageSize:每页记录数, sortBy?:指定排序字段, sort?:排序方向'ASC' | 'DESC'}
147
+ * @returns
148
+ */
149
+ loadPhotoPageInfoByGroup(params: Readonly<{
150
+ groupId: string;
151
+ } & PageParams>): Promise<PageInfo<PhotoContent>>;
152
+ /**
153
+ * 按分组获取相册列表
154
+ * @param params
155
+ * @returns
156
+ */
157
+ loadPhotoListByGroupId(params: Readonly<{
158
+ groupId: string;
159
+ }>): Promise<Array<PhotoContent>>;
160
+ /**
161
+ * 获取视频详情
162
+ * @param videoId
163
+ * @returns
164
+ */
165
+ loadVideoDetail(videoId: string): Promise<VideoContent | undefined>;
166
+ /**
167
+ * 分页获取视频列表
168
+ * @param params {channelNo?:指定栏目下的内容, keyword?:关键字查询, pageNo:页码, pageSize:每页记录数, sortBy?:指定排序字段, sort?:排序方向'ASC' | 'DESC'}
169
+ * @returns
170
+ */
171
+ loadVideoPageInfo(params: Readonly<{
172
+ channelNo?: string;
173
+ keyword?: string;
174
+ } & PageParams>): Promise<PageInfo<VideoContent>>;
175
+ /**
176
+ * 按分组分页获取视频列表
177
+ * @param params {groupId:分组ID, pageNo:页码, pageSize:每页记录数, sortBy?:指定排序字段, sort?:排序方向'ASC' | 'DESC'}
178
+ * @returns
179
+ */
180
+ loadVideoPageInfoByGroup(params: Readonly<{
181
+ groupId: string;
182
+ } & PageParams>): Promise<PageInfo<VideoContent>>;
183
+ /**
184
+ * 按分组获取视频列表
185
+ * @param params
186
+ * @returns
187
+ */
188
+ loadVideoListByGroupId(params: Readonly<{
189
+ groupId: string;
190
+ }>): Promise<Array<VideoContent>>;
191
+ /**
192
+ * 获取活动详情
193
+ * @param activityId
194
+ * @returns
195
+ */
196
+ loadActivityDetail(activityId: string): Promise<ActivityContent | undefined>;
197
+ /**
198
+ * 分页获取活动列表
199
+ * @param params {channelNo?:指定栏目下的内容, keyword?:关键字查询, pageNo:页码, pageSize:每页记录数, sortBy?:指定排序字段, sort?:排序方向'ASC' | 'DESC'}
200
+ * @returns
201
+ */
202
+ loadActivityPageInfo(params: Readonly<{
203
+ channelNo?: string;
204
+ keyword?: string;
205
+ } & PageParams>): Promise<PageInfo<ActivityContent>>;
206
+ /**
207
+ * 按分组分页获取活动列表
208
+ * @param params {groupId:分组ID, pageNo:页码, pageSize:每页记录数, sortBy?:指定排序字段, sort?:排序方向'ASC' | 'DESC'}
209
+ * @returns
210
+ */
211
+ loadActivityPageInfoByGroup(params: Readonly<{
212
+ groupId: string;
213
+ } & PageParams>): Promise<PageInfo<ActivityContent>>;
214
+ /**
215
+ * 按分组获取活动列表
216
+ * @param params
217
+ * @returns
218
+ */
219
+ loadActivityListByGroupId(params: Readonly<{
220
+ groupId: string;
221
+ }>): Promise<Array<ActivityContent>>;
222
+ /**
223
+ * 获取评论列表
224
+ */
125
225
  loadReviewList(params: Readonly<{
126
226
  entityNo?: string;
127
227
  rowCount?: string;
128
228
  }>): Promise<Array<Reviews>>;
229
+ /**
230
+ * 发表评论
231
+ * @param data 评论数据
232
+ */
233
+ submitComment(data: Readonly<Partial<Reviews>>): Promise<boolean>;
234
+ /**
235
+ * 订阅
236
+ * @param data 订阅数据 {email, nickname?}
237
+ */
238
+ subscribe(data: Readonly<Pick<SubscribeUser, 'email'> & Partial<Pick<SubscribeUser, 'nickname'>>>): Promise<boolean>;
239
+ /**
240
+ * 联系我们留言
241
+ * @param data 留言数据
242
+ */
243
+ submitContactUs(data: Readonly<Partial<ContactUs>>): Promise<boolean>;
244
+ /**
245
+ * 获取链接分组列表(含友链)
246
+ */
247
+ loadLinkGroups(): Promise<Array<LinkGroup>>;
248
+ /**
249
+ * 获取友情链接列表
250
+ * @param count 获取数量,不传则全部
251
+ */
252
+ loadFriendLinks(count?: number): Promise<Array<FriendLink>>;
253
+ /**
254
+ * 申请添加友链
255
+ * @param data 友链数据 {name, url, description?}
256
+ */
257
+ submitLink(data: Readonly<Pick<FriendLink, 'name' | 'url'> & Partial<Pick<FriendLink, 'description'>>>): Promise<boolean>;
258
+ /**
259
+ * 获取商品规格描述
260
+ * @param code 规格编码
261
+ */
262
+ getSpecDescription(code: string): Promise<SpecDescription | undefined>;
129
263
  }
@@ -0,0 +1,22 @@
1
+ import { AbsContent } from './cms-base';
2
+ /**
3
+ * 活动内容
4
+ */
5
+ export interface ActivityContent extends AbsContent {
6
+ /** 活动开始时间 */
7
+ startTime?: string;
8
+ /** 活动结束时间 */
9
+ endTime?: string;
10
+ /** 活动地点 */
11
+ location?: string;
12
+ details?: {
13
+ /**
14
+ * 活动简介
15
+ */
16
+ introduction?: string;
17
+ /**
18
+ * 活动详情
19
+ */
20
+ description?: string;
21
+ };
22
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * 商城规格描述
3
+ */
4
+ export interface SpecDescription {
5
+ id: string;
6
+ /** 规格编码 */
7
+ code: string;
8
+ /** 规格描述内容 */
9
+ description?: string;
10
+ /** 规格图片列表 */
11
+ images?: Array<string>;
12
+ /** JSON格式的额外属性 */
13
+ props?: Record<string, string>;
14
+ }
@@ -51,3 +51,35 @@ export interface Reviews extends WebsiteOwner {
51
51
  */
52
52
  createdAt?: string;
53
53
  }
54
+ /**
55
+ * 订阅用户
56
+ */
57
+ export interface SubscribeUser extends WebsiteOwner {
58
+ /** 用户昵称 */
59
+ nickname?: string;
60
+ /** 邮箱 */
61
+ email: string;
62
+ /** 是否已取消订阅 */
63
+ cancelSubscribe: boolean;
64
+ /** 订阅时间 */
65
+ subscribeTime: string;
66
+ }
67
+ /**
68
+ * 联系我们留言
69
+ */
70
+ export interface ContactUs extends WebsiteOwner {
71
+ /** 留言用户姓名 */
72
+ name: string;
73
+ /** 电话 */
74
+ phone?: string;
75
+ /** 邮箱 */
76
+ email?: string;
77
+ /** 主题 */
78
+ subject?: string;
79
+ /** 留言内容 */
80
+ message?: string;
81
+ /** 转发邮箱 */
82
+ forwardEmail?: string;
83
+ /** 创建时间 */
84
+ createTime: string;
85
+ }
@@ -0,0 +1,16 @@
1
+ import { AbsContent } from './cms-base';
2
+ /**
3
+ * 相册内容
4
+ */
5
+ export interface PhotoContent extends AbsContent {
6
+ details?: {
7
+ /**
8
+ * 相册简介
9
+ */
10
+ introduction?: string;
11
+ /**
12
+ * 相册详情
13
+ */
14
+ description?: string;
15
+ };
16
+ }
@@ -0,0 +1,18 @@
1
+ import { AbsContent } from './cms-base';
2
+ /**
3
+ * 视频内容
4
+ */
5
+ export interface VideoContent extends AbsContent {
6
+ /** 视频链接 */
7
+ videoUrl?: string;
8
+ details?: {
9
+ /**
10
+ * 视频简介
11
+ */
12
+ introduction?: string;
13
+ /**
14
+ * 视频详情
15
+ */
16
+ description?: string;
17
+ };
18
+ }
@@ -1,3 +1,8 @@
1
1
  export type { AttachmentType, AttachmentVO, PageInfo, PageParams, OwnerUser, MemberSrvProp } from './cms-base';
2
2
  export * from './cms-product';
3
3
  export * from './cms-news';
4
+ export * from './cms-photo';
5
+ export * from './cms-video';
6
+ export * from './cms-activity';
7
+ export * from './cms-message';
8
+ export * from './cms-mall';
@@ -235,6 +235,16 @@ export interface FriendLink {
235
235
  */
236
236
  visible: boolean;
237
237
  }
238
+ /**
239
+ * 链接分组
240
+ */
241
+ export interface LinkGroup {
242
+ id: string;
243
+ /** 分组名称 */
244
+ name: string;
245
+ /** 分组下的链接列表 */
246
+ friendLinkList?: Array<FriendLink>;
247
+ }
238
248
  export type WebsiteNavVO = Pick<Webchannel, 'id' | 'name' | 'channelNo' | 'channelType' | 'uri' | 'image' | 'jumpUrl' | 'jumpText' | 'subTitle' | 'level' | 'sortBy' | 'children'>;
239
249
  /**
240
250
  * 栏目类型
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "icms-api",
3
3
  "private": false,
4
- "version": "0.1.2",
4
+ "version": "0.1.4",
5
5
  "description": "对iCMS内容管理系统API的封装,使用该API能快速使用iCMS搭建您的WebApp!",
6
6
  "type": "module",
7
7
  "main": "./dist/icms-api.cjs.js",
@@ -13,6 +13,12 @@
13
13
  "import": "./dist/icms-api.es.js",
14
14
  "require": "./dist/icms-api.cjs.js",
15
15
  "default": "./dist/icms-api.es.js"
16
+ },
17
+ "./client": {
18
+ "types": "./dist/types/client-entry.d.ts",
19
+ "import": "./dist/icms-api.client.es.js",
20
+ "require": "./dist/icms-api.client.cjs.js",
21
+ "default": "./dist/icms-api.client.es.js"
16
22
  }
17
23
  },
18
24
  "types": "./dist/types/index.d.ts",
@@ -21,7 +27,7 @@
21
27
  ],
22
28
  "scripts": {
23
29
  "dev": "vite",
24
- "build": "tsc && vite build",
30
+ "build": "tsc && vite build && vite build --config vite.client.config.ts",
25
31
  "build:types": "tsc --emitDeclarationOnly --outDir dist/types",
26
32
  "test": "vitest run",
27
33
  "preview": "vite preview",