@fecommunity/reactpress-toolkit 1.0.0-beta.3 → 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 +9 -27
- package/dist/config/env.js +2 -6
- package/dist/config/global.js +1 -1
- package/dist/config/i18n.d.ts +1 -2
- package/dist/config/i18n.js +1 -5
- package/dist/config/index.d.ts +12 -11
- package/dist/config/index.js +20 -25
- package/dist/index.d.ts +11 -8
- package/dist/index.js +17 -27
- package/package.json +11 -3
package/README.md
CHANGED
|
@@ -42,7 +42,7 @@ pnpm add @fecommunity/reactpress-toolkit
|
|
|
42
42
|
### Using the Default API Instance
|
|
43
43
|
|
|
44
44
|
```typescript
|
|
45
|
-
import api from '@fecommunity/reactpress-toolkit';
|
|
45
|
+
import { api } from '@fecommunity/reactpress-toolkit';
|
|
46
46
|
|
|
47
47
|
// Get all articles
|
|
48
48
|
const articles = await api.article.findAll();
|
|
@@ -74,32 +74,14 @@ const article: types.IArticle = {
|
|
|
74
74
|
const formattedDate = utils.formatDate(new Date());
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
-
## API Modules
|
|
78
|
-
|
|
79
|
-
The toolkit provides clients for all ReactPress backend modules:
|
|
80
|
-
|
|
81
|
-
- `api.article` - Article management
|
|
82
|
-
- `api.auth` - Authentication services
|
|
83
|
-
- `api.category` - Category management
|
|
84
|
-
- `api.comment` - Comment system
|
|
85
|
-
- `api.file` - File management
|
|
86
|
-
- `api.knowledge` - Knowledge base
|
|
87
|
-
- `api.page` - Page management
|
|
88
|
-
- `api.search` - Search functionality
|
|
89
|
-
- `api.setting` - System settings
|
|
90
|
-
- `api.smtp` - SMTP services
|
|
91
|
-
- `api.tag` - Tag management
|
|
92
|
-
- `api.user` - User management
|
|
93
|
-
- `api.view` - View analytics
|
|
94
|
-
|
|
95
77
|
## Configuration
|
|
96
78
|
|
|
97
79
|
You can create a custom API instance with specific configuration:
|
|
98
80
|
|
|
99
81
|
```typescript
|
|
100
|
-
import {
|
|
82
|
+
import { http } from '@fecommunity/reactpress-toolkit';
|
|
101
83
|
|
|
102
|
-
const customApi =
|
|
84
|
+
const customApi = http.createApiInstance({
|
|
103
85
|
baseURL: 'https://api.yourdomain.com',
|
|
104
86
|
timeout: 10000,
|
|
105
87
|
// ... other axios configuration options
|
|
@@ -113,10 +95,10 @@ const articles = await customApi.article.findAll();
|
|
|
113
95
|
|
|
114
96
|
### Automatic Retry Mechanisms
|
|
115
97
|
```typescript
|
|
116
|
-
import {
|
|
98
|
+
import { http } from '@fecommunity/reactpress-toolkit';
|
|
117
99
|
|
|
118
100
|
// Configure retry settings
|
|
119
|
-
const customApi =
|
|
101
|
+
const customApi = http.createApiInstance({
|
|
120
102
|
baseURL: 'https://api.yourdomain.com',
|
|
121
103
|
retry: {
|
|
122
104
|
retries: 3,
|
|
@@ -130,9 +112,9 @@ const customApi = api.createApiInstance({
|
|
|
130
112
|
|
|
131
113
|
### Request/Response Interceptors
|
|
132
114
|
```typescript
|
|
133
|
-
import {
|
|
115
|
+
import { http } from '@fecommunity/reactpress-toolkit';
|
|
134
116
|
|
|
135
|
-
const monitoredApi =
|
|
117
|
+
const monitoredApi = http.createApiInstance({
|
|
136
118
|
baseURL: 'https://api.yourdomain.com',
|
|
137
119
|
interceptors: {
|
|
138
120
|
request: (config) => {
|
|
@@ -151,10 +133,10 @@ const monitoredApi = api.createApiInstance({
|
|
|
151
133
|
|
|
152
134
|
### Authentication Handling
|
|
153
135
|
```typescript
|
|
154
|
-
import { api, utils } from '@fecommunity/reactpress-toolkit';
|
|
136
|
+
import { http, api, utils } from '@fecommunity/reactpress-toolkit';
|
|
155
137
|
|
|
156
138
|
// Automatic token refresh
|
|
157
|
-
const secureApi =
|
|
139
|
+
const secureApi = http.createApiInstance({
|
|
158
140
|
baseURL: 'https://api.yourdomain.com',
|
|
159
141
|
auth: {
|
|
160
142
|
tokenRefresh: async (refreshToken) => {
|
package/dist/config/env.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
9
5
|
}) : (function(o, m, k, k2) {
|
|
10
6
|
if (k2 === undefined) k2 = k;
|
|
11
7
|
o[k2] = m[k];
|
|
@@ -48,7 +44,7 @@ function parseEnv() {
|
|
|
48
44
|
path.resolve(__dirname, '../../../'),
|
|
49
45
|
path.resolve(__dirname, '../'),
|
|
50
46
|
process.cwd(),
|
|
51
|
-
path.resolve(process.cwd(), '../'),
|
|
47
|
+
path.resolve(process.cwd(), '../'),
|
|
52
48
|
];
|
|
53
49
|
let foundEnvFiles = [];
|
|
54
50
|
// Search for .env files in all possible locations
|
package/dist/config/global.js
CHANGED
|
@@ -232,7 +232,7 @@ const urlConfig = [
|
|
|
232
232
|
type: '数据转换工具',
|
|
233
233
|
description: '用于将Excel文件转换为JSON格式的在线工具,便于在Web应用程序中使用。',
|
|
234
234
|
icon: 'https://www.convertio.co/favicon.ico',
|
|
235
|
-
url: 'https://www.convertio.co/zh/excel-json/',
|
|
235
|
+
url: 'https://www.convertio.co/zh/excel-json/',
|
|
236
236
|
},
|
|
237
237
|
{
|
|
238
238
|
key: 'chuangkit',
|
package/dist/config/i18n.d.ts
CHANGED
package/dist/config/i18n.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
9
5
|
}) : (function(o, m, k, k2) {
|
|
10
6
|
if (k2 === undefined) k2 = k;
|
|
11
7
|
o[k2] = m[k];
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 环境变量配置
|
|
3
3
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export
|
|
4
|
+
import { file } from './env';
|
|
5
|
+
import { messages, locales, defaultLocale } from './i18n';
|
|
6
|
+
import { globalSetting } from './global';
|
|
7
|
+
declare const config: {
|
|
8
|
+
locales: string[];
|
|
9
|
+
defaultLocale: string;
|
|
10
|
+
messages: import("./i18n").I18nMessages;
|
|
11
|
+
globalSetting: import("./global").GlobalSetting;
|
|
12
|
+
file: string;
|
|
13
|
+
};
|
|
14
|
+
export { config, file, messages, locales, defaultLocale, globalSetting };
|
|
15
|
+
export default config;
|
package/dist/config/index.js
CHANGED
|
@@ -1,30 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.globalSetting = exports.defaultLocale = exports.locales = exports.messages = exports.file = exports.config = void 0;
|
|
17
4
|
/**
|
|
18
5
|
* 环境变量配置
|
|
19
6
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
7
|
+
const env_1 = require("./env");
|
|
8
|
+
Object.defineProperty(exports, "file", { enumerable: true, get: function () { return env_1.file; } });
|
|
9
|
+
const i18n_1 = require("./i18n");
|
|
10
|
+
Object.defineProperty(exports, "messages", { enumerable: true, get: function () { return i18n_1.messages; } });
|
|
11
|
+
Object.defineProperty(exports, "locales", { enumerable: true, get: function () { return i18n_1.locales; } });
|
|
12
|
+
Object.defineProperty(exports, "defaultLocale", { enumerable: true, get: function () { return i18n_1.defaultLocale; } });
|
|
13
|
+
const global_1 = require("./global");
|
|
14
|
+
Object.defineProperty(exports, "globalSetting", { enumerable: true, get: function () { return global_1.globalSetting; } });
|
|
15
|
+
// Create a unified config object that includes all configuration properties
|
|
16
|
+
const config = {
|
|
17
|
+
...env_1.config,
|
|
18
|
+
locales: i18n_1.locales,
|
|
19
|
+
defaultLocale: i18n_1.defaultLocale,
|
|
20
|
+
messages: i18n_1.messages,
|
|
21
|
+
globalSetting: global_1.globalSetting,
|
|
22
|
+
file: env_1.file
|
|
23
|
+
};
|
|
24
|
+
exports.config = config;
|
|
25
|
+
exports.default = config;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { api, createApiInstance } from './api/instance';
|
|
2
|
+
import * as types from './types';
|
|
3
|
+
import * as utils from './utils';
|
|
4
|
+
import * as config from './config';
|
|
5
|
+
declare const http: {
|
|
6
|
+
createApiInstance: typeof createApiInstance;
|
|
7
|
+
instance: import("axios").AxiosInstance;
|
|
8
|
+
setSecurityData: (data: unknown) => void;
|
|
9
|
+
request: <T = any, _E = any>({ secure, path, type, query, format, body, ...params }: import("./api/HttpClient").FullRequestParams) => Promise<T>;
|
|
10
|
+
};
|
|
11
|
+
export { api, types, utils, config, http };
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
//
|
|
2
|
+
// Automatically generated API toolkit for ReactPress
|
|
3
|
+
// Do not manually modify this file
|
|
4
|
+
// Generated at: 9/25/2025, 9:47:27 PM
|
|
3
5
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
6
|
if (k2 === undefined) k2 = k;
|
|
5
|
-
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
7
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
10
8
|
}) : (function(o, m, k, k2) {
|
|
11
9
|
if (k2 === undefined) k2 = k;
|
|
12
10
|
o[k2] = m[k];
|
|
@@ -23,26 +21,18 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
21
|
__setModuleDefault(result, mod);
|
|
24
22
|
return result;
|
|
25
23
|
};
|
|
26
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
27
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
28
|
-
};
|
|
29
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
exports.
|
|
31
|
-
|
|
32
|
-
var instance_1 = require("./api/instance");
|
|
25
|
+
exports.http = exports.config = exports.utils = exports.types = exports.api = void 0;
|
|
26
|
+
const instance_1 = require("./api/instance");
|
|
33
27
|
Object.defineProperty(exports, "api", { enumerable: true, get: function () { return instance_1.api; } });
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
exports.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
// Export config functionality
|
|
46
|
-
__exportStar(require("./config/env"), exports);
|
|
47
|
-
__exportStar(require("./config/i18n"), exports);
|
|
48
|
-
__exportStar(require("./config/global"), exports);
|
|
28
|
+
const types = __importStar(require("./types"));
|
|
29
|
+
exports.types = types;
|
|
30
|
+
const utils = __importStar(require("./utils"));
|
|
31
|
+
exports.utils = utils;
|
|
32
|
+
const config = __importStar(require("./config"));
|
|
33
|
+
exports.config = config;
|
|
34
|
+
const http = {
|
|
35
|
+
...instance_1.http,
|
|
36
|
+
createApiInstance: instance_1.createApiInstance,
|
|
37
|
+
};
|
|
38
|
+
exports.http = http;
|
package/package.json
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fecommunity/reactpress-toolkit",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.4",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./dist/index.js",
|
|
8
|
+
"./api": "./dist/api/index.js",
|
|
9
|
+
"./api/instance": "./dist/api/instance.js",
|
|
10
|
+
"./types": "./dist/types/index.js",
|
|
11
|
+
"./utils": "./dist/utils/index.js",
|
|
12
|
+
"./config": "./dist/config/index.js"
|
|
13
|
+
},
|
|
6
14
|
"files": [
|
|
7
15
|
"dist"
|
|
8
16
|
],
|
|
@@ -19,10 +27,10 @@
|
|
|
19
27
|
},
|
|
20
28
|
"devDependencies": {
|
|
21
29
|
"@types/fs-extra": "^9.0.13",
|
|
22
|
-
"@types/node": "^
|
|
30
|
+
"@types/node": "^17.0.22"
|
|
23
31
|
},
|
|
24
32
|
"scripts": {
|
|
25
33
|
"generate": "node scripts/generate-swagger.js",
|
|
26
|
-
"build": "tsc && cp -r src/locales dist/"
|
|
34
|
+
"build": "ls -la src/api/ && tsc && cp -r src/locales dist/"
|
|
27
35
|
}
|
|
28
36
|
}
|