@fecommunity/reactpress-toolkit 1.0.0-beta.2 → 1.0.0-beta.3
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 +221 -6
- 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 +93 -0
- package/dist/config/global.d.ts +34 -0
- package/dist/config/global.js +382 -0
- package/dist/config/i18n.d.ts +5 -0
- package/dist/config/i18n.js +47 -0
- package/dist/config/index.d.ts +14 -0
- package/dist/config/index.js +30 -0
- package/dist/index.d.ts +7 -4
- package/dist/index.js +21 -18
- 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 +12 -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
|
|
|
@@ -89,11 +97,11 @@ The toolkit provides clients for all ReactPress backend modules:
|
|
|
89
97
|
You can create a custom API instance with specific configuration:
|
|
90
98
|
|
|
91
99
|
```typescript
|
|
92
|
-
import {
|
|
100
|
+
import { api } from '@fecommunity/reactpress-toolkit';
|
|
93
101
|
|
|
94
|
-
const customApi = createApiInstance({
|
|
102
|
+
const customApi = api.createApiInstance({
|
|
95
103
|
baseURL: 'https://api.yourdomain.com',
|
|
96
|
-
timeout:
|
|
104
|
+
timeout: 10000,
|
|
97
105
|
// ... other axios configuration options
|
|
98
106
|
});
|
|
99
107
|
|
|
@@ -101,6 +109,62 @@ const customApi = createApiInstance({
|
|
|
101
109
|
const articles = await customApi.article.findAll();
|
|
102
110
|
```
|
|
103
111
|
|
|
112
|
+
## Enterprise Features
|
|
113
|
+
|
|
114
|
+
### Automatic Retry Mechanisms
|
|
115
|
+
```typescript
|
|
116
|
+
import { api } from '@fecommunity/reactpress-toolkit';
|
|
117
|
+
|
|
118
|
+
// Configure retry settings
|
|
119
|
+
const customApi = api.createApiInstance({
|
|
120
|
+
baseURL: 'https://api.yourdomain.com',
|
|
121
|
+
retry: {
|
|
122
|
+
retries: 3,
|
|
123
|
+
retryDelay: 1000,
|
|
124
|
+
retryCondition: (error) => {
|
|
125
|
+
return error.response?.status === 503 || error.code === 'ECONNABORTED';
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Request/Response Interceptors
|
|
132
|
+
```typescript
|
|
133
|
+
import { api } from '@fecommunity/reactpress-toolkit';
|
|
134
|
+
|
|
135
|
+
const monitoredApi = api.createApiInstance({
|
|
136
|
+
baseURL: 'https://api.yourdomain.com',
|
|
137
|
+
interceptors: {
|
|
138
|
+
request: (config) => {
|
|
139
|
+
// Add logging, metrics, etc.
|
|
140
|
+
console.log(`Request: ${config.method?.toUpperCase()} ${config.url}`);
|
|
141
|
+
return config;
|
|
142
|
+
},
|
|
143
|
+
response: (response) => {
|
|
144
|
+
// Add logging, metrics, etc.
|
|
145
|
+
console.log(`Response: ${response.status} ${response.config.url}`);
|
|
146
|
+
return response;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Authentication Handling
|
|
153
|
+
```typescript
|
|
154
|
+
import { api, utils } from '@fecommunity/reactpress-toolkit';
|
|
155
|
+
|
|
156
|
+
// Automatic token refresh
|
|
157
|
+
const secureApi = api.createApiInstance({
|
|
158
|
+
baseURL: 'https://api.yourdomain.com',
|
|
159
|
+
auth: {
|
|
160
|
+
tokenRefresh: async (refreshToken) => {
|
|
161
|
+
const response = await api.auth.refresh({ refreshToken });
|
|
162
|
+
return response.data.accessToken;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
```
|
|
167
|
+
|
|
104
168
|
## Type Definitions
|
|
105
169
|
|
|
106
170
|
All data models are strongly typed and available through the `types` export:
|
|
@@ -145,6 +209,12 @@ const clonedObject = utils.deepClone(originalObject);
|
|
|
145
209
|
if (utils.ApiError.isInstance(error)) {
|
|
146
210
|
console.log(`API Error: ${error.code} - ${error.message}`);
|
|
147
211
|
}
|
|
212
|
+
|
|
213
|
+
// Data validation
|
|
214
|
+
const isValidEmail = utils.validateEmail('user@example.com');
|
|
215
|
+
|
|
216
|
+
// String manipulation
|
|
217
|
+
const slug = utils.createSlug('My Article Title');
|
|
148
218
|
```
|
|
149
219
|
|
|
150
220
|
## Development
|
|
@@ -171,6 +241,151 @@ npm run build
|
|
|
171
241
|
|
|
172
242
|
This will compile the TypeScript code to JavaScript in the `dist` directory.
|
|
173
243
|
|
|
244
|
+
## Testing
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
# Run unit tests
|
|
248
|
+
npm run test
|
|
249
|
+
|
|
250
|
+
# Run tests with coverage
|
|
251
|
+
npm run test:cov
|
|
252
|
+
|
|
253
|
+
# Run linting
|
|
254
|
+
npm run lint
|
|
255
|
+
|
|
256
|
+
# Run formatting
|
|
257
|
+
npm run format
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## Integration Examples
|
|
261
|
+
|
|
262
|
+
### React Integration
|
|
263
|
+
```typescript
|
|
264
|
+
import { useState, useEffect } from 'react';
|
|
265
|
+
import { api, types } from '@fecommunity/reactpress-toolkit';
|
|
266
|
+
|
|
267
|
+
const ArticleList = () => {
|
|
268
|
+
const [articles, setArticles] = useState<types.IArticle[]>([]);
|
|
269
|
+
const [loading, setLoading] = useState(true);
|
|
270
|
+
|
|
271
|
+
useEffect(() => {
|
|
272
|
+
const fetchArticles = async () => {
|
|
273
|
+
try {
|
|
274
|
+
const response = await api.article.findAll();
|
|
275
|
+
setArticles(response.data);
|
|
276
|
+
} catch (error) {
|
|
277
|
+
console.error('Failed to fetch articles:', error);
|
|
278
|
+
} finally {
|
|
279
|
+
setLoading(false);
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
fetchArticles();
|
|
284
|
+
}, []);
|
|
285
|
+
|
|
286
|
+
if (loading) return <div>Loading...</div>;
|
|
287
|
+
|
|
288
|
+
return (
|
|
289
|
+
<div>
|
|
290
|
+
{articles.map(article => (
|
|
291
|
+
<div key={article.id}>
|
|
292
|
+
<h2>{article.title}</h2>
|
|
293
|
+
<p>{article.content}</p>
|
|
294
|
+
</div>
|
|
295
|
+
))}
|
|
296
|
+
</div>
|
|
297
|
+
);
|
|
298
|
+
};
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### Node.js Integration
|
|
302
|
+
```typescript
|
|
303
|
+
import { api, types } from '@fecommunity/reactpress-toolkit';
|
|
304
|
+
|
|
305
|
+
async function syncArticles() {
|
|
306
|
+
try {
|
|
307
|
+
// Fetch articles from ReactPress
|
|
308
|
+
const response = await api.article.findAll({
|
|
309
|
+
limit: 100,
|
|
310
|
+
offset: 0
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
// Process articles
|
|
314
|
+
const articles: types.IArticle[] = response.data;
|
|
315
|
+
|
|
316
|
+
// Sync with another system
|
|
317
|
+
for (const article of articles) {
|
|
318
|
+
// Your sync logic here
|
|
319
|
+
console.log(`Synced article: ${article.title}`);
|
|
320
|
+
}
|
|
321
|
+
} catch (error) {
|
|
322
|
+
console.error('Sync failed:', error);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
syncArticles();
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
## Best Practices
|
|
330
|
+
|
|
331
|
+
### Error Handling
|
|
332
|
+
```typescript
|
|
333
|
+
import { api, utils } from '@fecommunity/reactpress-toolkit';
|
|
334
|
+
|
|
335
|
+
try {
|
|
336
|
+
const articles = await api.article.findAll();
|
|
337
|
+
// Process articles
|
|
338
|
+
} catch (error) {
|
|
339
|
+
if (utils.ApiError.isInstance(error)) {
|
|
340
|
+
switch (error.code) {
|
|
341
|
+
case 401:
|
|
342
|
+
// Handle unauthorized access
|
|
343
|
+
redirectToLogin();
|
|
344
|
+
break;
|
|
345
|
+
case 403:
|
|
346
|
+
// Handle forbidden access
|
|
347
|
+
showPermissionError();
|
|
348
|
+
break;
|
|
349
|
+
case 500:
|
|
350
|
+
// Handle server errors
|
|
351
|
+
showServerError();
|
|
352
|
+
break;
|
|
353
|
+
default:
|
|
354
|
+
// Handle other API errors
|
|
355
|
+
showGenericError(error.message);
|
|
356
|
+
}
|
|
357
|
+
} else {
|
|
358
|
+
// Handle network errors
|
|
359
|
+
showNetworkError();
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
### Pagination
|
|
365
|
+
```typescript
|
|
366
|
+
import { api, types } from '@fecommunity/reactpress-toolkit';
|
|
367
|
+
|
|
368
|
+
async function fetchAllArticles(): Promise<types.IArticle[]> {
|
|
369
|
+
const allArticles: types.IArticle[] = [];
|
|
370
|
+
let offset = 0;
|
|
371
|
+
const limit = 50;
|
|
372
|
+
|
|
373
|
+
while (true) {
|
|
374
|
+
const response = await api.article.findAll({ limit, offset });
|
|
375
|
+
allArticles.push(...response.data);
|
|
376
|
+
|
|
377
|
+
if (response.data.length < limit) {
|
|
378
|
+
// No more articles to fetch
|
|
379
|
+
break;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
offset += limit;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
return allArticles;
|
|
386
|
+
}
|
|
387
|
+
```
|
|
388
|
+
|
|
174
389
|
## Contributing
|
|
175
390
|
|
|
176
391
|
1. Fork the repository
|
|
@@ -187,4 +402,4 @@ ISC
|
|
|
187
402
|
|
|
188
403
|
- [ReactPress](https://github.com/fecommunity/reactpress) - The main ReactPress platform
|
|
189
404
|
- [ReactPress Server](https://github.com/fecommunity/reactpress/server) - Backend server
|
|
190
|
-
- [ReactPress Client](https://github.com/fecommunity/reactpress/client) - Frontend client
|
|
405
|
+
- [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
|
}
|