Skip to content

Commit 9fb5d05

Browse files
authored
add audit (#4923)
* add audit * update audit * update audit
1 parent b974574 commit 9fb5d05

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1564
-175
lines changed

dev.md

Lines changed: 118 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,118 @@
1-
## Premise
2-
3-
Since FastGPT is managed in the same way as monorepo, it is recommended to install ‘make’ first during development.
4-
5-
monorepo Project Name:
6-
7-
- app: main project
8-
-......
9-
10-
## Dev
11-
12-
```sh
13-
# Give automatic script code execution permission (on non-Linux systems, you can manually execute the postinstall.sh file content)
14-
chmod -R +x ./scripts/
15-
# Executing under the code root directory installs all dependencies within the root package, projects, and packages
16-
pnpm i
17-
18-
# Not make cmd
19-
cd projects/app
20-
pnpm dev
21-
22-
# Make cmd
23-
make dev name=app
24-
```
25-
26-
Note: If the Node version is >= 20, you need to pass the `--no-node-snapshot` parameter to Node when running `pnpm i`
27-
28-
```sh
29-
NODE_OPTIONS=--no-node-snapshot pnpm i
30-
```
31-
32-
### Jest
33-
34-
https://fael3z0zfze.feishu.cn/docx/ZOI1dABpxoGhS7xzhkXcKPxZnDL
35-
36-
## I18N
37-
38-
### Install i18n-ally Plugin
39-
40-
1. Open the Extensions Marketplace in VSCode, search for and install the `i18n Ally` plugin.
41-
42-
### Code Optimization Examples
43-
44-
#### Fetch Specific Namespace Translations in `getServerSideProps`
45-
46-
```typescript
47-
// pages/yourPage.tsx
48-
export async function getServerSideProps(context: any) {
49-
return {
50-
props: {
51-
currentTab: context?.query?.currentTab || TabEnum.info,
52-
...(await serverSideTranslations(context.locale, ['publish', 'user']))
53-
}
54-
};
55-
}
56-
```
57-
58-
#### Use useTranslation Hook in Page
59-
60-
```typescript
61-
// pages/yourPage.tsx
62-
import { useTranslation } from 'next-i18next';
63-
64-
const YourComponent = () => {
65-
const { t } = useTranslation();
66-
67-
return (
68-
<Button
69-
variant="outline"
70-
size="sm"
71-
mr={2}
72-
onClick={() => setShowSelected(false)}
73-
>
74-
{t('common:close')}
75-
</Button>
76-
);
77-
};
78-
79-
export default YourComponent;
80-
```
81-
82-
#### Handle Static File Translations
83-
84-
```typescript
85-
// utils/i18n.ts
86-
import { i18nT } from '@fastgpt/web/i18n/utils';
87-
88-
const staticContent = {
89-
id: 'simpleChat',
90-
avatar: 'core/workflow/template/aiChat',
91-
name: i18nT('app:template.simple_robot'),
92-
};
93-
94-
export default staticContent;
95-
```
96-
97-
### Standardize Translation Format
98-
99-
- Use the t(namespace:key) format to ensure consistent naming.
100-
- Translation keys should use lowercase letters and underscores, e.g., common.close.
101-
102-
## Build
103-
104-
```sh
105-
# Docker cmd: Build image, not proxy
106-
docker build -f ./projects/app/Dockerfile -t registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.1 . --build-arg name=app
107-
# Make cmd: Build image, not proxy
108-
make build name=app image=registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.1
109-
110-
# Docker cmd: Build image with proxy
111-
docker build -f ./projects/app/Dockerfile -t registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.1 . --build-arg name=app --build-arg proxy=taobao
112-
# Make cmd: Build image with proxy
113-
make build name=app image=registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.1 proxy=taobao
114-
```
1+
## Premise
2+
3+
Since FastGPT is managed in the same way as monorepo, it is recommended to install ‘make’ first during development.
4+
5+
monorepo Project Name:
6+
7+
- app: main project
8+
-......
9+
10+
## Dev
11+
12+
```sh
13+
# Give automatic script code execution permission (on non-Linux systems, you can manually execute the postinstall.sh file content)
14+
chmod -R +x ./scripts/
15+
# Executing under the code root directory installs all dependencies within the root package, projects, and packages
16+
pnpm i
17+
18+
# Not make cmd
19+
cd projects/app
20+
pnpm dev
21+
22+
# Make cmd
23+
make dev name=app
24+
```
25+
26+
Note: If the Node version is >= 20, you need to pass the `--no-node-snapshot` parameter to Node when running `pnpm i`
27+
28+
```sh
29+
NODE_OPTIONS=--no-node-snapshot pnpm i
30+
```
31+
32+
### Jest
33+
34+
https://fael3z0zfze.feishu.cn/docx/ZOI1dABpxoGhS7xzhkXcKPxZnDL
35+
36+
## I18N
37+
38+
### Install i18n-ally Plugin
39+
40+
1. Open the Extensions Marketplace in VSCode, search for and install the `i18n Ally` plugin.
41+
42+
### Code Optimization Examples
43+
44+
#### Fetch Specific Namespace Translations in `getServerSideProps`
45+
46+
```typescript
47+
// pages/yourPage.tsx
48+
export async function getServerSideProps(context: any) {
49+
return {
50+
props: {
51+
currentTab: context?.query?.currentTab || TabEnum.info,
52+
...(await serverSideTranslations(context.locale, ['publish', 'user']))
53+
}
54+
};
55+
}
56+
```
57+
58+
#### Use useTranslation Hook in Page
59+
60+
```typescript
61+
// pages/yourPage.tsx
62+
import { useTranslation } from 'next-i18next';
63+
64+
const YourComponent = () => {
65+
const { t } = useTranslation();
66+
67+
return (
68+
<Button
69+
variant="outline"
70+
size="sm"
71+
mr={2}
72+
onClick={() => setShowSelected(false)}
73+
>
74+
{t('common:close')}
75+
</Button>
76+
);
77+
};
78+
79+
export default YourComponent;
80+
```
81+
82+
#### Handle Static File Translations
83+
84+
```typescript
85+
// utils/i18n.ts
86+
import { i18nT } from '@fastgpt/web/i18n/utils';
87+
88+
const staticContent = {
89+
id: 'simpleChat',
90+
avatar: 'core/workflow/template/aiChat',
91+
name: i18nT('app:template.simple_robot'),
92+
};
93+
94+
export default staticContent;
95+
```
96+
97+
### Standardize Translation Format
98+
99+
- Use the t(namespace:key) format to ensure consistent naming.
100+
- Translation keys should use lowercase letters and underscores, e.g., common.close.
101+
102+
## audit
103+
104+
Please fill the OperationLogEventEnum and operationLog/audit function is added to the ts, and on the corresponding position to fill i18n, at the same time to add the location of the log using addOpearationLog function add function
105+
106+
## Build
107+
108+
```sh
109+
# Docker cmd: Build image, not proxy
110+
docker build -f ./projects/app/Dockerfile -t registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.1 . --build-arg name=app
111+
# Make cmd: Build image, not proxy
112+
make build name=app image=registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.1
113+
114+
# Docker cmd: Build image with proxy
115+
docker build -f ./projects/app/Dockerfile -t registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.1 . --build-arg name=app --build-arg proxy=taobao
116+
# Make cmd: Build image with proxy
117+
make build name=app image=registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.1 proxy=taobao
118+
```

packages/global/support/operationLog/constants.ts

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export enum OperationLogEventEnum {
2+
//Team
23
LOGIN = 'LOGIN',
34
CREATE_INVITATION_LINK = 'CREATE_INVITATION_LINK',
45
JOIN_TEAM = 'JOIN_TEAM',
@@ -11,5 +12,52 @@ export enum OperationLogEventEnum {
1112
RELOCATE_DEPARTMENT = 'RELOCATE_DEPARTMENT',
1213
CREATE_GROUP = 'CREATE_GROUP',
1314
DELETE_GROUP = 'DELETE_GROUP',
14-
ASSIGN_PERMISSION = 'ASSIGN_PERMISSION'
15+
ASSIGN_PERMISSION = 'ASSIGN_PERMISSION',
16+
//APP
17+
CREATE_APP = 'CREATE_APP',
18+
UPDATE_APP_INFO = 'UPDATE_APP_INFO',
19+
MOVE_APP = 'MOVE_APP',
20+
DELETE_APP = 'DELETE_APP',
21+
UPDATE_APP_COLLABORATOR = 'UPDATE_APP_COLLABORATOR',
22+
DELETE_APP_COLLABORATOR = 'DELETE_APP_COLLABORATOR',
23+
TRANSFER_APP_OWNERSHIP = 'TRANSFER_APP_OWNERSHIP',
24+
CREATE_APP_COPY = 'CREATE_APP_COPY',
25+
CREATE_APP_FOLDER = 'CREATE_APP_FOLDER',
26+
UPDATE_PUBLISH_APP = 'UPDATE_PUBLISH_APP',
27+
CREATE_APP_PUBLISH_CHANNEL = 'CREATE_APP_PUBLISH_CHANNEL',
28+
UPDATE_APP_PUBLISH_CHANNEL = 'UPDATE_APP_PUBLISH_CHANNEL',
29+
DELETE_APP_PUBLISH_CHANNEL = 'DELETE_APP_PUBLISH_CHANNEL',
30+
EXPORT_APP_CHAT_LOG = 'EXPORT_APP_CHAT_LOG',
31+
//Dataset
32+
CREATE_DATASET = 'CREATE_DATASET',
33+
UPDATE_DATASET = 'UPDATE_DATASET',
34+
DELETE_DATASET = 'DELETE_DATASET',
35+
MOVE_DATASET = 'MOVE_DATASET',
36+
UPDATE_DATASET_COLLABORATOR = 'UPDATE_DATASET_COLLABORATOR',
37+
DELETE_DATASET_COLLABORATOR = 'DELETE_DATASET_COLLABORATOR',
38+
TRANSFER_DATASET_OWNERSHIP = 'TRANSFER_DATASET_OWNERSHIP',
39+
EXPORT_DATASET = 'EXPORT_DATASET',
40+
CREATE_DATASET_FOLDER = 'CREATE_DATASET_FOLDER',
41+
//Collection
42+
CREATE_COLLECTION = 'CREATE_COLLECTION',
43+
UPDATE_COLLECTION = 'UPDATE_COLLECTION',
44+
DELETE_COLLECTION = 'DELETE_COLLECTION',
45+
RETRAIN_COLLECTION = 'RETRAIN_COLLECTION',
46+
//Data
47+
CREATE_DATA = 'CREATE_DATA',
48+
UPDATE_DATA = 'UPDATE_DATA',
49+
DELETE_DATA = 'DELETE_DATA',
50+
//SearchTest
51+
SEARCH_TEST = 'SEARCH_TEST',
52+
//Account
53+
CHANGE_PASSWORD = 'CHANGE_PASSWORD',
54+
CHANGE_NOTIFICATION_SETTINGS = 'CHANGE_NOTIFICATION_SETTINGS',
55+
CHANGE_MEMBER_NAME_ACCOUNT = 'CHANGE_MEMBER_NAME_ACCOUNT',
56+
PURCHASE_PLAN = 'PURCHASE_PLAN',
57+
EXPORT_BILL_RECORDS = 'EXPORT_BILL_RECORDS',
58+
CREATE_INVOICE = 'CREATE_INVOICE',
59+
SET_INVOICE_HEADER = 'SET_INVOICE_HEADER',
60+
CREATE_API_KEY = 'CREATE_API_KEY',
61+
UPDATE_API_KEY = 'UPDATE_API_KEY',
62+
DELETE_API_KEY = 'DELETE_API_KEY'
1563
}

0 commit comments

Comments
 (0)