Skip to content

Commit cf95d89

Browse files
committed
translations progress
1 parent f8ca443 commit cf95d89

File tree

20 files changed

+479
-108
lines changed

20 files changed

+479
-108
lines changed

Changelog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [v1.5.8] - next
99

10+
# Added
11+
12+
- Command to generate typescript models `npx -y adminforth generate-models --env-file=.env`
13+
14+
# Improved
15+
16+
- Added separate BeforeCreateSave function in types without oldRecord and make oldRecord Mandatory in existing BeforeSaveFunction
17+
1018
## [v1.5.7] - 2024-12-09
1119

1220
### Fixed

README.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,7 @@ npm start
7171
Add some columns to a database. Open .prisma file, modify it, and run:
7272

7373
```
74-
npm run migrate -- --name desctiption_of_changes
75-
```
76-
77-
Add some columns to a database. Open .prisma file, modify it, and run:
78-
79-
```
80-
npm run migrate -- --name desctiption_of_changes
74+
npm run namemigration -- --name desctiption_of_changes
8175
```
8276

8377

adminforth/adapters/completion-adapter-open-ai-chat-gpt/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ export default class CompletionAdapterOpenAIChatGPT
1313
}
1414
}
1515

16-
complete = async (content: string, stop = ["."], maxTokens = 50) => {
16+
complete = async (content: string, stop = ["."], maxTokens = 50): Promise<{
17+
content?: string;
18+
finishReason?: string;
19+
error?: string;
20+
}> => {
1721
const resp = await fetch("https://api.openai.com/v1/chat/completions", {
1822
method: "POST",
1923
headers: {
@@ -35,8 +39,7 @@ export default class CompletionAdapterOpenAIChatGPT
3539
});
3640
const data = await resp.json();
3741
if (data.error) {
38-
console.error('ChatGPT was not able to generate a response', data.error);
39-
return null;
42+
return { error: data.error.message };
4043
}
4144
return {
4245
content: data.choices[0].message.content,

adminforth/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
IAdminForthDataSourceConnectorBase,
2222
IWebSocketBroker,
2323
HttpExtra,
24+
BeforeCreateSaveFunction,
2425
} from './types/Back.js';
2526

2627
import {
@@ -115,6 +116,11 @@ class AdminForth implements IAdminForth {
115116
console.log(`🚀 AdminForth v${ADMINFORTH_VERSION} starting up`)
116117
}
117118

119+
async tr(this, msg: string, category: string = 'default', lang: string = 'en'): Promise<string> {
120+
// stub function to make a translation
121+
return msg;
122+
}
123+
118124
activatePlugins() {
119125
process.env.HEAVY_DEBUG && console.log('🔌🔌🔌 Activating plugins');
120126
const allPluginInstances = [];
@@ -295,7 +301,7 @@ class AdminForth implements IAdminForth {
295301
): Promise<{ error?: string, createdRecord?: any }> {
296302

297303
// execute hook if needed
298-
for (const hook of listify(resource.hooks?.create?.beforeSave as BeforeSaveFunction[])) {
304+
for (const hook of listify(resource.hooks?.create?.beforeSave as BeforeCreateSaveFunction[])) {
299305
console.log('🪲 Hook beforeSave', hook);
300306
const resp = await hook({
301307
recordId: undefined,

adminforth/package-lock.json

Lines changed: 30 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

adminforth/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "adminforth",
3-
"version": "1.5.8-next.0",
3+
"version": "1.5.8-next.5",
44
"description": "OpenSource Vue3 powered forth-generation admin panel",
55
"main": "dist/index.js",
66
"module": "dist/index.js",
@@ -14,7 +14,7 @@
1414
},
1515
"scripts": {
1616
"test": "echo \"Error: no test specified\" && exit 1",
17-
"build": "rm -rf dist && tsc && npm run prepareDist",
17+
"build": "rm -rf dist && tsc && npm run prepareDist && npm link",
1818
"--comment-prepareDist": "-rl allows supply the spa without symlinks which allows to not include source code in the package",
1919
"prepareDist": "cp -rL spa dist/",
2020
"put-git-tag": "git tag v$(node -p \"require('./package.json').version\") && git push --tags",
@@ -26,7 +26,6 @@
2626
"postinstall": "if test -d ./dist/spa/; then cd ./dist/spa/ && npm ci && echo 'installed spa dependencies'; fi",
2727
"ci-plugins": "for d in plugins/*; do cd $d && npm ci && cd ../..; done",
2828
"ci-adapters": "for d in adapters/*; do cd $d && npm ci && cd ../..; done"
29-
3029
},
3130
"exports": {
3231
".": {
@@ -41,6 +40,7 @@
4140
"@clickhouse/client": "^1.4.0",
4241
"@faker-js/faker": "^9.0.3",
4342
"@types/express": "^5.0.0",
43+
"adminforth": "^1.5.8-next.0",
4444
"better-sqlite3": "^11.5.0",
4545
"dayjs": "^1.11.11",
4646
"dotenv": "^16.4.5",

adminforth/plugins/audit-log/index.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,20 @@ export default class AuditLogPlugin extends AdminForthPlugin {
146146
direction: AdminForthSortDirections.desc
147147
}
148148
return;
149-
}
149+
};
150150

151-
['edit', 'create', 'delete'].forEach((hook) => {
151+
['edit', 'delete'].forEach((hook) => {
152152
resource.hooks[hook].afterSave.push(async ({resource, record, adminUser, oldRecord, extra}) => {
153153
return await this.createLogRecord(resource, hook as AllowedActionsEnum, record, adminUser, oldRecord, extra)
154154
})
155-
})
155+
});
156+
157+
['create'].forEach((hook) => {
158+
resource.hooks[hook].afterSave.push(async ({resource, record, adminUser, extra}) => {
159+
return await this.createLogRecord(resource, hook as AllowedActionsEnum, record, adminUser, undefined, extra)
160+
})
161+
});
162+
156163
})
157164
}
158165
}

0 commit comments

Comments
 (0)