@fecommunity/reactpress-toolkit 1.0.0-beta.2 → 1.0.0-beta.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/README.md +222 -25
- package/dist/api/Article.d.ts +43 -28
- package/dist/api/Article.js +42 -31
- package/dist/api/Auth.d.ts +12 -7
- package/dist/api/Auth.js +12 -10
- package/dist/api/Category.d.ts +19 -12
- package/dist/api/Category.js +18 -15
- package/dist/api/Comment.d.ts +22 -14
- package/dist/api/Comment.js +21 -17
- package/dist/api/File.d.ts +16 -10
- package/dist/api/File.js +15 -13
- package/dist/{HttpClient.d.ts → api/HttpClient.d.ts} +2 -2
- package/dist/{HttpClient.js → api/HttpClient.js} +4 -2
- package/dist/api/Knowledge.d.ts +28 -18
- package/dist/api/Knowledge.js +27 -22
- package/dist/api/Page.d.ts +22 -14
- package/dist/api/Page.js +21 -17
- package/dist/api/Search.d.ts +12 -7
- package/dist/api/Search.js +12 -10
- package/dist/api/Setting.d.ts +10 -6
- package/dist/api/Setting.js +9 -9
- package/dist/api/Smtp.d.ts +13 -8
- package/dist/api/Smtp.js +12 -11
- package/dist/api/Tag.d.ts +22 -14
- package/dist/api/Tag.js +21 -17
- package/dist/api/User.d.ts +17 -10
- package/dist/api/User.js +16 -16
- package/dist/api/View.d.ts +19 -12
- package/dist/api/View.js +18 -15
- package/dist/api/index.d.ts +13 -18
- package/dist/api/index.js +28 -40
- package/dist/api/instance.d.ts +47 -0
- package/dist/api/instance.js +71 -0
- package/dist/config/env.d.ts +1 -0
- package/dist/config/env.js +89 -0
- package/dist/config/global.d.ts +34 -0
- package/dist/config/global.js +382 -0
- package/dist/config/i18n.d.ts +4 -0
- package/dist/config/i18n.js +43 -0
- package/dist/config/index.d.ts +15 -0
- package/dist/config/index.js +25 -0
- package/dist/index.d.ts +11 -5
- package/dist/index.js +18 -25
- package/dist/locales/en.json +97 -0
- package/dist/locales/zh.json +97 -0
- package/dist/types/index.d.ts +245 -1
- package/dist/types/index.js +10 -17
- package/dist/utils/index.d.ts +33 -2
- package/dist/utils/index.js +57 -18
- package/package.json +20 -5
- package/dist/Article.d.ts +0 -121
- package/dist/Article.js +0 -189
- package/dist/Auth.d.ts +0 -30
- package/dist/Auth.js +0 -59
- package/dist/Category.d.ts +0 -49
- package/dist/Category.js +0 -85
- package/dist/Comment.d.ts +0 -58
- package/dist/Comment.js +0 -98
- package/dist/File.d.ts +0 -40
- package/dist/File.js +0 -72
- package/dist/Knowledge.d.ts +0 -76
- package/dist/Knowledge.js +0 -124
- package/dist/Page.d.ts +0 -58
- package/dist/Page.js +0 -98
- package/dist/Search.d.ts +0 -30
- package/dist/Search.js +0 -59
- package/dist/Setting.d.ts +0 -22
- package/dist/Setting.js +0 -46
- package/dist/Smtp.d.ts +0 -31
- package/dist/Smtp.js +0 -59
- package/dist/Tag.d.ts +0 -58
- package/dist/Tag.js +0 -98
- package/dist/User.d.ts +0 -41
- package/dist/User.js +0 -73
- package/dist/View.d.ts +0 -49
- package/dist/View.js +0 -85
- package/dist/api/Admin.d.ts +0 -14
- package/dist/api/Admin.js +0 -32
- package/dist/api/All.d.ts +0 -14
- package/dist/api/All.js +0 -32
- package/dist/api/ApiInstance.d.ts +0 -39
- package/dist/api/ApiInstance.js +0 -46
- package/dist/api/Archives.d.ts +0 -14
- package/dist/api/Archives.js +0 -32
- package/dist/api/ArticleRoute.d.ts +0 -201
- package/dist/api/ArticleRoute.js +0 -12
- package/dist/api/AuthRoute.d.ts +0 -44
- package/dist/api/AuthRoute.js +0 -12
- package/dist/api/Book.d.ts +0 -15
- package/dist/api/Book.js +0 -33
- package/dist/api/CategoryRoute.d.ts +0 -79
- package/dist/api/CategoryRoute.js +0 -12
- package/dist/api/Chapter.d.ts +0 -15
- package/dist/api/Chapter.js +0 -33
- package/dist/api/CommentRoute.d.ts +0 -95
- package/dist/api/CommentRoute.js +0 -12
- package/dist/api/FileRoute.d.ts +0 -63
- package/dist/api/FileRoute.js +0 -12
- package/dist/api/Get.d.ts +0 -14
- package/dist/api/Get.js +0 -32
- package/dist/api/Github.d.ts +0 -14
- package/dist/api/Github.js +0 -32
- package/dist/api/Host.d.ts +0 -14
- package/dist/api/Host.js +0 -32
- package/dist/api/Id.d.ts +0 -284
- package/dist/api/Id.js +0 -422
- package/dist/api/KnowledgeRoute.d.ts +0 -125
- package/dist/api/KnowledgeRoute.js +0 -12
- package/dist/api/Login.d.ts +0 -14
- package/dist/api/Login.js +0 -32
- package/dist/api/PageRoute.d.ts +0 -95
- package/dist/api/PageRoute.js +0 -12
- package/dist/api/Password.d.ts +0 -15
- package/dist/api/Password.js +0 -33
- package/dist/api/Recommend.d.ts +0 -14
- package/dist/api/Recommend.js +0 -32
- package/dist/api/Register.d.ts +0 -15
- package/dist/api/Register.js +0 -33
- package/dist/api/SearchRoute.d.ts +0 -46
- package/dist/api/SearchRoute.js +0 -12
- package/dist/api/SettingRoute.d.ts +0 -31
- package/dist/api/SettingRoute.js +0 -12
- package/dist/api/SmtpRoute.d.ts +0 -47
- package/dist/api/SmtpRoute.js +0 -12
- package/dist/api/TagRoute.d.ts +0 -95
- package/dist/api/TagRoute.js +0 -12
- package/dist/api/Update.d.ts +0 -15
- package/dist/api/Update.js +0 -33
- package/dist/api/Upload.d.ts +0 -15
- package/dist/api/Upload.js +0 -33
- package/dist/api/Url.d.ts +0 -14
- package/dist/api/Url.js +0 -32
- package/dist/api/UserRoute.d.ts +0 -60
- package/dist/api/UserRoute.js +0 -12
- package/dist/api/ViewRoute.d.ts +0 -77
- package/dist/api/ViewRoute.js +0 -12
- package/dist/api/api-instance.d.ts +0 -39
- package/dist/api/api-instance.js +0 -46
- package/dist/api/http-client.d.ts +0 -41
- package/dist/api/http-client.js +0 -94
- package/dist/api/httpClient.d.ts +0 -42
- package/dist/api/httpClient.js +0 -95
- package/dist/data-contracts.d.ts +0 -245
- package/dist/data-contracts.js +0 -12
- package/dist/types/data-contracts.d.ts +0 -177
- package/dist/types/data-contracts.js +0 -12
- package/dist/utils/common.d.ts +0 -21
- package/dist/utils/common.js +0 -52
- package/dist/utils/http.d.ts +0 -3
- package/dist/utils/http.js +0 -45
package/README.md
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
# @fecommunity/reactpress-toolkit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
TypeScript-based API client toolkit for ReactPress, automatically generated from OpenAPI/Swagger specifications.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@fecommunity/reactpress-toolkit)
|
|
6
|
+
[](https://github.com/fecommunity/reactpress/blob/master/toolkit/LICENSE)
|
|
7
|
+
[](http://www.typescriptlang.org/)
|
|
4
8
|
|
|
5
9
|
## Overview
|
|
6
10
|
|
|
7
|
-
The ReactPress Toolkit is
|
|
11
|
+
The ReactPress Toolkit is an API client library that provides strongly-typed interfaces for interacting with the ReactPress backend services. It includes:
|
|
8
12
|
|
|
9
13
|
- **Auto-generated API clients** for all ReactPress modules
|
|
10
14
|
- **TypeScript definitions** for all data contracts
|
|
11
15
|
- **Utility functions** for common operations
|
|
12
16
|
- **HTTP client** with built-in authentication and error handling
|
|
17
|
+
- **Automatic retry mechanisms** for failed requests
|
|
18
|
+
- **Request/response interceptors** for logging
|
|
19
|
+
|
|
20
|
+
The toolkit is automatically generated from the ReactPress backend's OpenAPI specification, ensuring that it's always in sync with the latest API changes. This eliminates manual API client maintenance and reduces the likelihood of API integration errors.
|
|
13
21
|
|
|
14
22
|
## Installation
|
|
15
23
|
|
|
@@ -34,7 +42,7 @@ pnpm add @fecommunity/reactpress-toolkit
|
|
|
34
42
|
### Using the Default API Instance
|
|
35
43
|
|
|
36
44
|
```typescript
|
|
37
|
-
import api from '@fecommunity/reactpress-toolkit';
|
|
45
|
+
import { api } from '@fecommunity/reactpress-toolkit';
|
|
38
46
|
|
|
39
47
|
// Get all articles
|
|
40
48
|
const articles = await api.article.findAll();
|
|
@@ -66,34 +74,16 @@ const article: types.IArticle = {
|
|
|
66
74
|
const formattedDate = utils.formatDate(new Date());
|
|
67
75
|
```
|
|
68
76
|
|
|
69
|
-
## API Modules
|
|
70
|
-
|
|
71
|
-
The toolkit provides clients for all ReactPress backend modules:
|
|
72
|
-
|
|
73
|
-
- `api.article` - Article management
|
|
74
|
-
- `api.auth` - Authentication services
|
|
75
|
-
- `api.category` - Category management
|
|
76
|
-
- `api.comment` - Comment system
|
|
77
|
-
- `api.file` - File management
|
|
78
|
-
- `api.knowledge` - Knowledge base
|
|
79
|
-
- `api.page` - Page management
|
|
80
|
-
- `api.search` - Search functionality
|
|
81
|
-
- `api.setting` - System settings
|
|
82
|
-
- `api.smtp` - SMTP services
|
|
83
|
-
- `api.tag` - Tag management
|
|
84
|
-
- `api.user` - User management
|
|
85
|
-
- `api.view` - View analytics
|
|
86
|
-
|
|
87
77
|
## Configuration
|
|
88
78
|
|
|
89
79
|
You can create a custom API instance with specific configuration:
|
|
90
80
|
|
|
91
81
|
```typescript
|
|
92
|
-
import {
|
|
82
|
+
import { http } from '@fecommunity/reactpress-toolkit';
|
|
93
83
|
|
|
94
|
-
const customApi = createApiInstance({
|
|
84
|
+
const customApi = http.createApiInstance({
|
|
95
85
|
baseURL: 'https://api.yourdomain.com',
|
|
96
|
-
timeout:
|
|
86
|
+
timeout: 10000,
|
|
97
87
|
// ... other axios configuration options
|
|
98
88
|
});
|
|
99
89
|
|
|
@@ -101,6 +91,62 @@ const customApi = createApiInstance({
|
|
|
101
91
|
const articles = await customApi.article.findAll();
|
|
102
92
|
```
|
|
103
93
|
|
|
94
|
+
## Enterprise Features
|
|
95
|
+
|
|
96
|
+
### Automatic Retry Mechanisms
|
|
97
|
+
```typescript
|
|
98
|
+
import { http } from '@fecommunity/reactpress-toolkit';
|
|
99
|
+
|
|
100
|
+
// Configure retry settings
|
|
101
|
+
const customApi = http.createApiInstance({
|
|
102
|
+
baseURL: 'https://api.yourdomain.com',
|
|
103
|
+
retry: {
|
|
104
|
+
retries: 3,
|
|
105
|
+
retryDelay: 1000,
|
|
106
|
+
retryCondition: (error) => {
|
|
107
|
+
return error.response?.status === 503 || error.code === 'ECONNABORTED';
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Request/Response Interceptors
|
|
114
|
+
```typescript
|
|
115
|
+
import { http } from '@fecommunity/reactpress-toolkit';
|
|
116
|
+
|
|
117
|
+
const monitoredApi = http.createApiInstance({
|
|
118
|
+
baseURL: 'https://api.yourdomain.com',
|
|
119
|
+
interceptors: {
|
|
120
|
+
request: (config) => {
|
|
121
|
+
// Add logging, metrics, etc.
|
|
122
|
+
console.log(`Request: ${config.method?.toUpperCase()} ${config.url}`);
|
|
123
|
+
return config;
|
|
124
|
+
},
|
|
125
|
+
response: (response) => {
|
|
126
|
+
// Add logging, metrics, etc.
|
|
127
|
+
console.log(`Response: ${response.status} ${response.config.url}`);
|
|
128
|
+
return response;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Authentication Handling
|
|
135
|
+
```typescript
|
|
136
|
+
import { http, api, utils } from '@fecommunity/reactpress-toolkit';
|
|
137
|
+
|
|
138
|
+
// Automatic token refresh
|
|
139
|
+
const secureApi = http.createApiInstance({
|
|
140
|
+
baseURL: 'https://api.yourdomain.com',
|
|
141
|
+
auth: {
|
|
142
|
+
tokenRefresh: async (refreshToken) => {
|
|
143
|
+
const response = await api.auth.refresh({ refreshToken });
|
|
144
|
+
return response.data.accessToken;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
```
|
|
149
|
+
|
|
104
150
|
## Type Definitions
|
|
105
151
|
|
|
106
152
|
All data models are strongly typed and available through the `types` export:
|
|
@@ -145,6 +191,12 @@ const clonedObject = utils.deepClone(originalObject);
|
|
|
145
191
|
if (utils.ApiError.isInstance(error)) {
|
|
146
192
|
console.log(`API Error: ${error.code} - ${error.message}`);
|
|
147
193
|
}
|
|
194
|
+
|
|
195
|
+
// Data validation
|
|
196
|
+
const isValidEmail = utils.validateEmail('user@example.com');
|
|
197
|
+
|
|
198
|
+
// String manipulation
|
|
199
|
+
const slug = utils.createSlug('My Article Title');
|
|
148
200
|
```
|
|
149
201
|
|
|
150
202
|
## Development
|
|
@@ -171,6 +223,151 @@ npm run build
|
|
|
171
223
|
|
|
172
224
|
This will compile the TypeScript code to JavaScript in the `dist` directory.
|
|
173
225
|
|
|
226
|
+
## Testing
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
# Run unit tests
|
|
230
|
+
npm run test
|
|
231
|
+
|
|
232
|
+
# Run tests with coverage
|
|
233
|
+
npm run test:cov
|
|
234
|
+
|
|
235
|
+
# Run linting
|
|
236
|
+
npm run lint
|
|
237
|
+
|
|
238
|
+
# Run formatting
|
|
239
|
+
npm run format
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
## Integration Examples
|
|
243
|
+
|
|
244
|
+
### React Integration
|
|
245
|
+
```typescript
|
|
246
|
+
import { useState, useEffect } from 'react';
|
|
247
|
+
import { api, types } from '@fecommunity/reactpress-toolkit';
|
|
248
|
+
|
|
249
|
+
const ArticleList = () => {
|
|
250
|
+
const [articles, setArticles] = useState<types.IArticle[]>([]);
|
|
251
|
+
const [loading, setLoading] = useState(true);
|
|
252
|
+
|
|
253
|
+
useEffect(() => {
|
|
254
|
+
const fetchArticles = async () => {
|
|
255
|
+
try {
|
|
256
|
+
const response = await api.article.findAll();
|
|
257
|
+
setArticles(response.data);
|
|
258
|
+
} catch (error) {
|
|
259
|
+
console.error('Failed to fetch articles:', error);
|
|
260
|
+
} finally {
|
|
261
|
+
setLoading(false);
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
fetchArticles();
|
|
266
|
+
}, []);
|
|
267
|
+
|
|
268
|
+
if (loading) return <div>Loading...</div>;
|
|
269
|
+
|
|
270
|
+
return (
|
|
271
|
+
<div>
|
|
272
|
+
{articles.map(article => (
|
|
273
|
+
<div key={article.id}>
|
|
274
|
+
<h2>{article.title}</h2>
|
|
275
|
+
<p>{article.content}</p>
|
|
276
|
+
</div>
|
|
277
|
+
))}
|
|
278
|
+
</div>
|
|
279
|
+
);
|
|
280
|
+
};
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### Node.js Integration
|
|
284
|
+
```typescript
|
|
285
|
+
import { api, types } from '@fecommunity/reactpress-toolkit';
|
|
286
|
+
|
|
287
|
+
async function syncArticles() {
|
|
288
|
+
try {
|
|
289
|
+
// Fetch articles from ReactPress
|
|
290
|
+
const response = await api.article.findAll({
|
|
291
|
+
limit: 100,
|
|
292
|
+
offset: 0
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
// Process articles
|
|
296
|
+
const articles: types.IArticle[] = response.data;
|
|
297
|
+
|
|
298
|
+
// Sync with another system
|
|
299
|
+
for (const article of articles) {
|
|
300
|
+
// Your sync logic here
|
|
301
|
+
console.log(`Synced article: ${article.title}`);
|
|
302
|
+
}
|
|
303
|
+
} catch (error) {
|
|
304
|
+
console.error('Sync failed:', error);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
syncArticles();
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
## Best Practices
|
|
312
|
+
|
|
313
|
+
### Error Handling
|
|
314
|
+
```typescript
|
|
315
|
+
import { api, utils } from '@fecommunity/reactpress-toolkit';
|
|
316
|
+
|
|
317
|
+
try {
|
|
318
|
+
const articles = await api.article.findAll();
|
|
319
|
+
// Process articles
|
|
320
|
+
} catch (error) {
|
|
321
|
+
if (utils.ApiError.isInstance(error)) {
|
|
322
|
+
switch (error.code) {
|
|
323
|
+
case 401:
|
|
324
|
+
// Handle unauthorized access
|
|
325
|
+
redirectToLogin();
|
|
326
|
+
break;
|
|
327
|
+
case 403:
|
|
328
|
+
// Handle forbidden access
|
|
329
|
+
showPermissionError();
|
|
330
|
+
break;
|
|
331
|
+
case 500:
|
|
332
|
+
// Handle server errors
|
|
333
|
+
showServerError();
|
|
334
|
+
break;
|
|
335
|
+
default:
|
|
336
|
+
// Handle other API errors
|
|
337
|
+
showGenericError(error.message);
|
|
338
|
+
}
|
|
339
|
+
} else {
|
|
340
|
+
// Handle network errors
|
|
341
|
+
showNetworkError();
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
### Pagination
|
|
347
|
+
```typescript
|
|
348
|
+
import { api, types } from '@fecommunity/reactpress-toolkit';
|
|
349
|
+
|
|
350
|
+
async function fetchAllArticles(): Promise<types.IArticle[]> {
|
|
351
|
+
const allArticles: types.IArticle[] = [];
|
|
352
|
+
let offset = 0;
|
|
353
|
+
const limit = 50;
|
|
354
|
+
|
|
355
|
+
while (true) {
|
|
356
|
+
const response = await api.article.findAll({ limit, offset });
|
|
357
|
+
allArticles.push(...response.data);
|
|
358
|
+
|
|
359
|
+
if (response.data.length < limit) {
|
|
360
|
+
// No more articles to fetch
|
|
361
|
+
break;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
offset += limit;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
return allArticles;
|
|
368
|
+
}
|
|
369
|
+
```
|
|
370
|
+
|
|
174
371
|
## Contributing
|
|
175
372
|
|
|
176
373
|
1. Fork the repository
|
|
@@ -187,4 +384,4 @@ ISC
|
|
|
187
384
|
|
|
188
385
|
- [ReactPress](https://github.com/fecommunity/reactpress) - The main ReactPress platform
|
|
189
386
|
- [ReactPress Server](https://github.com/fecommunity/reactpress/server) - Backend server
|
|
190
|
-
- [ReactPress Client](https://github.com/fecommunity/reactpress/client) - Frontend client
|
|
387
|
+
- [ReactPress Client](https://github.com/fecommunity/reactpress/client) - Frontend client
|
package/dist/api/Article.d.ts
CHANGED
|
@@ -1,108 +1,123 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IArticleControllerCreateData } from '../types';
|
|
2
2
|
import { HttpClient, RequestParams } from './HttpClient';
|
|
3
|
-
export declare class Article<SecurityDataType = unknown>
|
|
3
|
+
export declare class Article<SecurityDataType = unknown> {
|
|
4
|
+
http: HttpClient<SecurityDataType>;
|
|
5
|
+
constructor(http: HttpClient<SecurityDataType>);
|
|
4
6
|
/**
|
|
5
7
|
* No description
|
|
6
8
|
*
|
|
7
9
|
* @tags Article
|
|
8
|
-
* @name
|
|
10
|
+
* @name ArticleControllerCreate
|
|
9
11
|
* @request POST:/article
|
|
12
|
+
* @response `200` `IArticleControllerCreateData` 创建文章
|
|
10
13
|
*/
|
|
11
|
-
create: (params?: RequestParams) => Promise<
|
|
14
|
+
create: (params?: RequestParams) => Promise<IArticleControllerCreateData>;
|
|
12
15
|
/**
|
|
13
16
|
* No description
|
|
14
17
|
*
|
|
15
18
|
* @tags Article
|
|
16
|
-
* @name
|
|
19
|
+
* @name ArticleControllerFindAll
|
|
17
20
|
* @request GET:/article
|
|
21
|
+
* @response `200` `IArticleControllerFindAllData`
|
|
18
22
|
*/
|
|
19
|
-
findAll: (params?: RequestParams) => Promise<
|
|
23
|
+
findAll: (params?: RequestParams) => Promise<any>;
|
|
20
24
|
/**
|
|
21
25
|
* No description
|
|
22
26
|
*
|
|
23
27
|
* @tags Article
|
|
24
|
-
* @name
|
|
28
|
+
* @name ArticleControllerFindArticlesByCategory
|
|
25
29
|
* @request GET:/article/category/{id}
|
|
30
|
+
* @response `200` `IArticleControllerFindArticlesByCategoryData`
|
|
26
31
|
*/
|
|
27
|
-
findArticlesByCategory: (id: string, params?: RequestParams) => Promise<
|
|
32
|
+
findArticlesByCategory: (id: string, params?: RequestParams) => Promise<any>;
|
|
28
33
|
/**
|
|
29
34
|
* No description
|
|
30
35
|
*
|
|
31
36
|
* @tags Article
|
|
32
|
-
* @name
|
|
37
|
+
* @name ArticleControllerFindArticlesByTag
|
|
33
38
|
* @request GET:/article/tag/{id}
|
|
39
|
+
* @response `200` `IArticleControllerFindArticlesByTagData`
|
|
34
40
|
*/
|
|
35
|
-
findArticlesByTag: (id: string, params?: RequestParams) => Promise<
|
|
41
|
+
findArticlesByTag: (id: string, params?: RequestParams) => Promise<any>;
|
|
36
42
|
/**
|
|
37
43
|
* No description
|
|
38
44
|
*
|
|
39
45
|
* @tags Article
|
|
40
|
-
* @name
|
|
46
|
+
* @name ArticleControllerGetRecommendArticles
|
|
41
47
|
* @request GET:/article/all/recommend
|
|
48
|
+
* @response `200` `IArticleControllerGetRecommendArticlesData`
|
|
42
49
|
*/
|
|
43
|
-
getRecommendArticles: (params?: RequestParams) => Promise<
|
|
50
|
+
getRecommendArticles: (params?: RequestParams) => Promise<any>;
|
|
44
51
|
/**
|
|
45
52
|
* No description
|
|
46
53
|
*
|
|
47
54
|
* @tags Article
|
|
48
|
-
* @name
|
|
55
|
+
* @name ArticleControllerGetArchives
|
|
49
56
|
* @request GET:/article/archives
|
|
57
|
+
* @response `200` `IArticleControllerGetArchivesData`
|
|
50
58
|
*/
|
|
51
|
-
getArchives: (params?: RequestParams) => Promise<
|
|
59
|
+
getArchives: (params?: RequestParams) => Promise<any>;
|
|
52
60
|
/**
|
|
53
61
|
* No description
|
|
54
62
|
*
|
|
55
63
|
* @tags Article
|
|
56
|
-
* @name
|
|
64
|
+
* @name ArticleControllerRecommend
|
|
57
65
|
* @request GET:/article/recommend
|
|
66
|
+
* @response `200` `IArticleControllerRecommendData`
|
|
58
67
|
*/
|
|
59
|
-
recommend: (params?: RequestParams) => Promise<
|
|
68
|
+
recommend: (params?: RequestParams) => Promise<any>;
|
|
60
69
|
/**
|
|
61
70
|
* No description
|
|
62
71
|
*
|
|
63
72
|
* @tags Article
|
|
64
|
-
* @name
|
|
73
|
+
* @name ArticleControllerFindById
|
|
65
74
|
* @request GET:/article/{id}
|
|
75
|
+
* @response `200` `IArticleControllerFindByIdData`
|
|
66
76
|
*/
|
|
67
|
-
findById: (id: string, params?: RequestParams) => Promise<
|
|
77
|
+
findById: (id: string, params?: RequestParams) => Promise<any>;
|
|
68
78
|
/**
|
|
69
79
|
* No description
|
|
70
80
|
*
|
|
71
81
|
* @tags Article
|
|
72
|
-
* @name
|
|
82
|
+
* @name ArticleControllerUpdateById
|
|
73
83
|
* @request PATCH:/article/{id}
|
|
84
|
+
* @response `200` `IArticleControllerUpdateByIdData`
|
|
74
85
|
*/
|
|
75
|
-
updateById: (id: string, params?: RequestParams) => Promise<
|
|
86
|
+
updateById: (id: string, params?: RequestParams) => Promise<any>;
|
|
76
87
|
/**
|
|
77
88
|
* No description
|
|
78
89
|
*
|
|
79
90
|
* @tags Article
|
|
80
|
-
* @name
|
|
91
|
+
* @name ArticleControllerDeleteById
|
|
81
92
|
* @request DELETE:/article/{id}
|
|
93
|
+
* @response `200` `IArticleControllerDeleteByIdData`
|
|
82
94
|
*/
|
|
83
|
-
deleteById: (id: string, params?: RequestParams) => Promise<
|
|
95
|
+
deleteById: (id: string, params?: RequestParams) => Promise<any>;
|
|
84
96
|
/**
|
|
85
97
|
* No description
|
|
86
98
|
*
|
|
87
99
|
* @tags Article
|
|
88
|
-
* @name
|
|
100
|
+
* @name ArticleControllerCheckPassword
|
|
89
101
|
* @request POST:/article/{id}/checkPassword
|
|
102
|
+
* @response `200` `IArticleControllerCheckPasswordData`
|
|
90
103
|
*/
|
|
91
|
-
checkPassword: (id: string, params?: RequestParams) => Promise<
|
|
104
|
+
checkPassword: (id: string, params?: RequestParams) => Promise<any>;
|
|
92
105
|
/**
|
|
93
106
|
* No description
|
|
94
107
|
*
|
|
95
108
|
* @tags Article
|
|
96
|
-
* @name
|
|
109
|
+
* @name ArticleControllerUpdateViewsById
|
|
97
110
|
* @request POST:/article/{id}/views
|
|
111
|
+
* @response `200` `IArticleControllerUpdateViewsByIdData`
|
|
98
112
|
*/
|
|
99
|
-
updateViewsById: (id: string, params?: RequestParams) => Promise<
|
|
113
|
+
updateViewsById: (id: string, params?: RequestParams) => Promise<any>;
|
|
100
114
|
/**
|
|
101
115
|
* No description
|
|
102
116
|
*
|
|
103
117
|
* @tags Article
|
|
104
|
-
* @name
|
|
118
|
+
* @name ArticleControllerUpdateLikesById
|
|
105
119
|
* @request POST:/article/{id}/likes
|
|
120
|
+
* @response `200` `IArticleControllerUpdateLikesByIdData`
|
|
106
121
|
*/
|
|
107
|
-
updateLikesById: (id: string, params?: RequestParams) => Promise<
|
|
122
|
+
updateLikesById: (id: string, params?: RequestParams) => Promise<any>;
|
|
108
123
|
}
|
package/dist/api/Article.js
CHANGED
|
@@ -11,31 +11,30 @@
|
|
|
11
11
|
*/
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.Article = void 0;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
constructor() {
|
|
17
|
-
super(...arguments);
|
|
14
|
+
class Article {
|
|
15
|
+
constructor(http) {
|
|
18
16
|
/**
|
|
19
17
|
* No description
|
|
20
18
|
*
|
|
21
19
|
* @tags Article
|
|
22
|
-
* @name
|
|
20
|
+
* @name ArticleControllerCreate
|
|
23
21
|
* @request POST:/article
|
|
22
|
+
* @response `200` `IArticleControllerCreateData` 创建文章
|
|
24
23
|
*/
|
|
25
|
-
this.create = (params = {}) => this.request({
|
|
24
|
+
this.create = (params = {}) => this.http.request({
|
|
26
25
|
path: `/article`,
|
|
27
26
|
method: 'POST',
|
|
28
|
-
format: 'json',
|
|
29
27
|
...params,
|
|
30
28
|
});
|
|
31
29
|
/**
|
|
32
30
|
* No description
|
|
33
31
|
*
|
|
34
32
|
* @tags Article
|
|
35
|
-
* @name
|
|
33
|
+
* @name ArticleControllerFindAll
|
|
36
34
|
* @request GET:/article
|
|
35
|
+
* @response `200` `IArticleControllerFindAllData`
|
|
37
36
|
*/
|
|
38
|
-
this.findAll = (params = {}) => this.request({
|
|
37
|
+
this.findAll = (params = {}) => this.http.request({
|
|
39
38
|
path: `/article`,
|
|
40
39
|
method: 'GET',
|
|
41
40
|
...params,
|
|
@@ -44,10 +43,11 @@ class Article extends HttpClient_1.HttpClient {
|
|
|
44
43
|
* No description
|
|
45
44
|
*
|
|
46
45
|
* @tags Article
|
|
47
|
-
* @name
|
|
46
|
+
* @name ArticleControllerFindArticlesByCategory
|
|
48
47
|
* @request GET:/article/category/{id}
|
|
48
|
+
* @response `200` `IArticleControllerFindArticlesByCategoryData`
|
|
49
49
|
*/
|
|
50
|
-
this.findArticlesByCategory = (id, params = {}) => this.request({
|
|
50
|
+
this.findArticlesByCategory = (id, params = {}) => this.http.request({
|
|
51
51
|
path: `/article/category/${id}`,
|
|
52
52
|
method: 'GET',
|
|
53
53
|
...params,
|
|
@@ -56,10 +56,11 @@ class Article extends HttpClient_1.HttpClient {
|
|
|
56
56
|
* No description
|
|
57
57
|
*
|
|
58
58
|
* @tags Article
|
|
59
|
-
* @name
|
|
59
|
+
* @name ArticleControllerFindArticlesByTag
|
|
60
60
|
* @request GET:/article/tag/{id}
|
|
61
|
+
* @response `200` `IArticleControllerFindArticlesByTagData`
|
|
61
62
|
*/
|
|
62
|
-
this.findArticlesByTag = (id, params = {}) => this.request({
|
|
63
|
+
this.findArticlesByTag = (id, params = {}) => this.http.request({
|
|
63
64
|
path: `/article/tag/${id}`,
|
|
64
65
|
method: 'GET',
|
|
65
66
|
...params,
|
|
@@ -68,10 +69,11 @@ class Article extends HttpClient_1.HttpClient {
|
|
|
68
69
|
* No description
|
|
69
70
|
*
|
|
70
71
|
* @tags Article
|
|
71
|
-
* @name
|
|
72
|
+
* @name ArticleControllerGetRecommendArticles
|
|
72
73
|
* @request GET:/article/all/recommend
|
|
74
|
+
* @response `200` `IArticleControllerGetRecommendArticlesData`
|
|
73
75
|
*/
|
|
74
|
-
this.getRecommendArticles = (params = {}) => this.request({
|
|
76
|
+
this.getRecommendArticles = (params = {}) => this.http.request({
|
|
75
77
|
path: `/article/all/recommend`,
|
|
76
78
|
method: 'GET',
|
|
77
79
|
...params,
|
|
@@ -80,10 +82,11 @@ class Article extends HttpClient_1.HttpClient {
|
|
|
80
82
|
* No description
|
|
81
83
|
*
|
|
82
84
|
* @tags Article
|
|
83
|
-
* @name
|
|
85
|
+
* @name ArticleControllerGetArchives
|
|
84
86
|
* @request GET:/article/archives
|
|
87
|
+
* @response `200` `IArticleControllerGetArchivesData`
|
|
85
88
|
*/
|
|
86
|
-
this.getArchives = (params = {}) => this.request({
|
|
89
|
+
this.getArchives = (params = {}) => this.http.request({
|
|
87
90
|
path: `/article/archives`,
|
|
88
91
|
method: 'GET',
|
|
89
92
|
...params,
|
|
@@ -92,10 +95,11 @@ class Article extends HttpClient_1.HttpClient {
|
|
|
92
95
|
* No description
|
|
93
96
|
*
|
|
94
97
|
* @tags Article
|
|
95
|
-
* @name
|
|
98
|
+
* @name ArticleControllerRecommend
|
|
96
99
|
* @request GET:/article/recommend
|
|
100
|
+
* @response `200` `IArticleControllerRecommendData`
|
|
97
101
|
*/
|
|
98
|
-
this.recommend = (params = {}) => this.request({
|
|
102
|
+
this.recommend = (params = {}) => this.http.request({
|
|
99
103
|
path: `/article/recommend`,
|
|
100
104
|
method: 'GET',
|
|
101
105
|
...params,
|
|
@@ -104,10 +108,11 @@ class Article extends HttpClient_1.HttpClient {
|
|
|
104
108
|
* No description
|
|
105
109
|
*
|
|
106
110
|
* @tags Article
|
|
107
|
-
* @name
|
|
111
|
+
* @name ArticleControllerFindById
|
|
108
112
|
* @request GET:/article/{id}
|
|
113
|
+
* @response `200` `IArticleControllerFindByIdData`
|
|
109
114
|
*/
|
|
110
|
-
this.findById = (id, params = {}) => this.request({
|
|
115
|
+
this.findById = (id, params = {}) => this.http.request({
|
|
111
116
|
path: `/article/${id}`,
|
|
112
117
|
method: 'GET',
|
|
113
118
|
...params,
|
|
@@ -116,10 +121,11 @@ class Article extends HttpClient_1.HttpClient {
|
|
|
116
121
|
* No description
|
|
117
122
|
*
|
|
118
123
|
* @tags Article
|
|
119
|
-
* @name
|
|
124
|
+
* @name ArticleControllerUpdateById
|
|
120
125
|
* @request PATCH:/article/{id}
|
|
126
|
+
* @response `200` `IArticleControllerUpdateByIdData`
|
|
121
127
|
*/
|
|
122
|
-
this.updateById = (id, params = {}) => this.request({
|
|
128
|
+
this.updateById = (id, params = {}) => this.http.request({
|
|
123
129
|
path: `/article/${id}`,
|
|
124
130
|
method: 'PATCH',
|
|
125
131
|
...params,
|
|
@@ -128,10 +134,11 @@ class Article extends HttpClient_1.HttpClient {
|
|
|
128
134
|
* No description
|
|
129
135
|
*
|
|
130
136
|
* @tags Article
|
|
131
|
-
* @name
|
|
137
|
+
* @name ArticleControllerDeleteById
|
|
132
138
|
* @request DELETE:/article/{id}
|
|
139
|
+
* @response `200` `IArticleControllerDeleteByIdData`
|
|
133
140
|
*/
|
|
134
|
-
this.deleteById = (id, params = {}) => this.request({
|
|
141
|
+
this.deleteById = (id, params = {}) => this.http.request({
|
|
135
142
|
path: `/article/${id}`,
|
|
136
143
|
method: 'DELETE',
|
|
137
144
|
...params,
|
|
@@ -140,10 +147,11 @@ class Article extends HttpClient_1.HttpClient {
|
|
|
140
147
|
* No description
|
|
141
148
|
*
|
|
142
149
|
* @tags Article
|
|
143
|
-
* @name
|
|
150
|
+
* @name ArticleControllerCheckPassword
|
|
144
151
|
* @request POST:/article/{id}/checkPassword
|
|
152
|
+
* @response `200` `IArticleControllerCheckPasswordData`
|
|
145
153
|
*/
|
|
146
|
-
this.checkPassword = (id, params = {}) => this.request({
|
|
154
|
+
this.checkPassword = (id, params = {}) => this.http.request({
|
|
147
155
|
path: `/article/${id}/checkPassword`,
|
|
148
156
|
method: 'POST',
|
|
149
157
|
...params,
|
|
@@ -152,10 +160,11 @@ class Article extends HttpClient_1.HttpClient {
|
|
|
152
160
|
* No description
|
|
153
161
|
*
|
|
154
162
|
* @tags Article
|
|
155
|
-
* @name
|
|
163
|
+
* @name ArticleControllerUpdateViewsById
|
|
156
164
|
* @request POST:/article/{id}/views
|
|
165
|
+
* @response `200` `IArticleControllerUpdateViewsByIdData`
|
|
157
166
|
*/
|
|
158
|
-
this.updateViewsById = (id, params = {}) => this.request({
|
|
167
|
+
this.updateViewsById = (id, params = {}) => this.http.request({
|
|
159
168
|
path: `/article/${id}/views`,
|
|
160
169
|
method: 'POST',
|
|
161
170
|
...params,
|
|
@@ -164,14 +173,16 @@ class Article extends HttpClient_1.HttpClient {
|
|
|
164
173
|
* No description
|
|
165
174
|
*
|
|
166
175
|
* @tags Article
|
|
167
|
-
* @name
|
|
176
|
+
* @name ArticleControllerUpdateLikesById
|
|
168
177
|
* @request POST:/article/{id}/likes
|
|
178
|
+
* @response `200` `IArticleControllerUpdateLikesByIdData`
|
|
169
179
|
*/
|
|
170
|
-
this.updateLikesById = (id, params = {}) => this.request({
|
|
180
|
+
this.updateLikesById = (id, params = {}) => this.http.request({
|
|
171
181
|
path: `/article/${id}/likes`,
|
|
172
182
|
method: 'POST',
|
|
173
183
|
...params,
|
|
174
184
|
});
|
|
185
|
+
this.http = http;
|
|
175
186
|
}
|
|
176
187
|
}
|
|
177
188
|
exports.Article = Article;
|
package/dist/api/Auth.d.ts
CHANGED
|
@@ -1,27 +1,32 @@
|
|
|
1
1
|
import { HttpClient, RequestParams } from './HttpClient';
|
|
2
|
-
export declare class Auth<SecurityDataType = unknown>
|
|
2
|
+
export declare class Auth<SecurityDataType = unknown> {
|
|
3
|
+
http: HttpClient<SecurityDataType>;
|
|
4
|
+
constructor(http: HttpClient<SecurityDataType>);
|
|
3
5
|
/**
|
|
4
6
|
* No description
|
|
5
7
|
*
|
|
6
8
|
* @tags Auth
|
|
7
|
-
* @name
|
|
9
|
+
* @name AuthControllerLogin
|
|
8
10
|
* @request POST:/auth/login
|
|
11
|
+
* @response `200` `IAuthControllerLoginData`
|
|
9
12
|
*/
|
|
10
|
-
login: (params?: RequestParams) => Promise<
|
|
13
|
+
login: (params?: RequestParams) => Promise<any>;
|
|
11
14
|
/**
|
|
12
15
|
* No description
|
|
13
16
|
*
|
|
14
17
|
* @tags Auth
|
|
15
|
-
* @name
|
|
18
|
+
* @name AuthControllerCreateBook
|
|
16
19
|
* @request POST:/auth/admin
|
|
20
|
+
* @response `201` `IAuthControllerCreateBookData`
|
|
17
21
|
*/
|
|
18
|
-
createBook: (params?: RequestParams) => Promise<
|
|
22
|
+
createBook: (params?: RequestParams) => Promise<any>;
|
|
19
23
|
/**
|
|
20
24
|
* No description
|
|
21
25
|
*
|
|
22
26
|
* @tags Auth
|
|
23
|
-
* @name
|
|
27
|
+
* @name AuthControllerLoginWithGithub
|
|
24
28
|
* @request POST:/auth/github
|
|
29
|
+
* @response `201` `IAuthControllerLoginWithGithubData`
|
|
25
30
|
*/
|
|
26
|
-
loginWithGithub: (params?: RequestParams) => Promise<
|
|
31
|
+
loginWithGithub: (params?: RequestParams) => Promise<any>;
|
|
27
32
|
}
|