plugin-build-guide-block 1.0.9 → 1.0.11
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 +74 -74
- package/dist/client/index.js +1 -1
- package/dist/client/models/index.d.ts +1 -3
- package/dist/externalVersion.js +7 -7
- package/dist/locale/en-US.json +28 -27
- package/dist/locale/vi-VN.json +28 -27
- package/dist/locale/zh-CN.json +28 -27
- package/dist/node_modules/sanitize-html/index.js +2 -2
- package/dist/node_modules/sanitize-html/package.json +1 -1
- package/dist/server/actions/build.js +3 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +7 -1
- package/dist/server/plugin.js +14 -0
- package/package.json +31 -31
- package/src/client/UserGuideBlock.tsx +53 -53
- package/src/client/UserGuideBlockInitializer.tsx +26 -26
- package/src/client/UserGuideBlockProvider.tsx +12 -12
- package/src/client/UserGuideManager.tsx +128 -107
- package/src/client/components/BuildButton.tsx +78 -43
- package/src/client/components/LLMServiceSelect.tsx +44 -44
- package/src/client/components/ModelSelect.tsx +41 -41
- package/src/client/components/StatusTag.tsx +17 -17
- package/src/client/models/UserGuideBlockModel.ts +54 -54
- package/src/client/models/index.ts +1 -3
- package/src/client/plugin.tsx +30 -30
- package/src/client/schemas/spacesSchema.ts +316 -316
- package/src/locale/en-US.json +28 -27
- package/src/locale/vi-VN.json +28 -27
- package/src/locale/zh-CN.json +28 -27
- package/src/server/actions/build.ts +176 -171
- package/src/server/actions/getHtml.ts +26 -26
- package/src/server/collections/ai-build-guide-spaces.ts +50 -50
- package/src/server/index.ts +1 -0
- package/src/server/plugin.ts +76 -60
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import { defineCollection } from '@nocobase/database';
|
|
2
|
-
|
|
3
|
-
export default defineCollection({
|
|
4
|
-
name: 'aiBuildGuideSpaces',
|
|
5
|
-
shared: true,
|
|
6
|
-
dumpRules: 'required',
|
|
7
|
-
migrationRules: ['overwrite', 'schema-only'],
|
|
8
|
-
timestamps: true,
|
|
9
|
-
fields: [
|
|
10
|
-
{
|
|
11
|
-
type: 'uid',
|
|
12
|
-
name: 'id',
|
|
13
|
-
primaryKey: true,
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
type: 'string',
|
|
17
|
-
name: 'title',
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
type: 'string',
|
|
21
|
-
name: 'llmService',
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
type: 'string',
|
|
25
|
-
name: 'model',
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
type: 'text',
|
|
29
|
-
name: 'systemPrompt',
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
type: 'text',
|
|
33
|
-
name: 'generatedHtml',
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
type: 'string',
|
|
37
|
-
name: 'status',
|
|
38
|
-
defaultValue: 'draft',
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
type: 'text',
|
|
42
|
-
name: 'buildLog',
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
type: 'belongsToMany',
|
|
46
|
-
name: 'documents',
|
|
47
|
-
target: 'attachments',
|
|
48
|
-
},
|
|
49
|
-
],
|
|
50
|
-
});
|
|
1
|
+
import { defineCollection } from '@nocobase/database';
|
|
2
|
+
|
|
3
|
+
export default defineCollection({
|
|
4
|
+
name: 'aiBuildGuideSpaces',
|
|
5
|
+
shared: true,
|
|
6
|
+
dumpRules: 'required',
|
|
7
|
+
migrationRules: ['overwrite', 'schema-only'],
|
|
8
|
+
timestamps: true,
|
|
9
|
+
fields: [
|
|
10
|
+
{
|
|
11
|
+
type: 'uid',
|
|
12
|
+
name: 'id',
|
|
13
|
+
primaryKey: true,
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
type: 'string',
|
|
17
|
+
name: 'title',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
type: 'string',
|
|
21
|
+
name: 'llmService',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
type: 'string',
|
|
25
|
+
name: 'model',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
type: 'text',
|
|
29
|
+
name: 'systemPrompt',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
type: 'text',
|
|
33
|
+
name: 'generatedHtml',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
type: 'string',
|
|
37
|
+
name: 'status',
|
|
38
|
+
defaultValue: 'draft',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
type: 'text',
|
|
42
|
+
name: 'buildLog',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
type: 'belongsToMany',
|
|
46
|
+
name: 'documents',
|
|
47
|
+
target: 'attachments',
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
});
|
package/src/server/index.ts
CHANGED
package/src/server/plugin.ts
CHANGED
|
@@ -1,60 +1,76 @@
|
|
|
1
|
-
import { InstallOptions, Plugin } from '@nocobase/server';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { build } from './actions/build';
|
|
4
|
-
import { getHtml } from './actions/getHtml';
|
|
5
|
-
|
|
6
|
-
export class PluginBuildGuideBlockServer extends Plugin {
|
|
7
|
-
afterAdd() {}
|
|
8
|
-
|
|
9
|
-
beforeLoad() {}
|
|
10
|
-
|
|
11
|
-
async load() {
|
|
12
|
-
this.app.resourceManager.registerActionHandlers({
|
|
13
|
-
'aiBuildGuideSpaces:build': build,
|
|
14
|
-
'aiBuildGuideSpaces:getHtml': getHtml,
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
this.app.acl.allow('aiBuildGuideSpaces', 'getHtml', 'loggedIn');
|
|
18
|
-
this.app.acl.registerSnippet({
|
|
19
|
-
name: 'pm.ai-build-guide',
|
|
20
|
-
actions: [
|
|
21
|
-
'aiBuildGuideSpaces:create',
|
|
22
|
-
'aiBuildGuideSpaces:update',
|
|
23
|
-
'aiBuildGuideSpaces:destroy',
|
|
24
|
-
'aiBuildGuideSpaces:list',
|
|
25
|
-
'aiBuildGuideSpaces:get',
|
|
26
|
-
'aiBuildGuideSpaces:build',
|
|
27
|
-
],
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
1
|
+
import { InstallOptions, Plugin } from '@nocobase/server';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { build } from './actions/build';
|
|
4
|
+
import { getHtml } from './actions/getHtml';
|
|
5
|
+
|
|
6
|
+
export class PluginBuildGuideBlockServer extends Plugin {
|
|
7
|
+
afterAdd() {}
|
|
8
|
+
|
|
9
|
+
beforeLoad() {}
|
|
10
|
+
|
|
11
|
+
async load() {
|
|
12
|
+
this.app.resourceManager.registerActionHandlers({
|
|
13
|
+
'aiBuildGuideSpaces:build': build,
|
|
14
|
+
'aiBuildGuideSpaces:getHtml': getHtml,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
this.app.acl.allow('aiBuildGuideSpaces', 'getHtml', 'loggedIn');
|
|
18
|
+
this.app.acl.registerSnippet({
|
|
19
|
+
name: 'pm.ai-build-guide',
|
|
20
|
+
actions: [
|
|
21
|
+
'aiBuildGuideSpaces:create',
|
|
22
|
+
'aiBuildGuideSpaces:update',
|
|
23
|
+
'aiBuildGuideSpaces:destroy',
|
|
24
|
+
'aiBuildGuideSpaces:list',
|
|
25
|
+
'aiBuildGuideSpaces:get',
|
|
26
|
+
'aiBuildGuideSpaces:build',
|
|
27
|
+
],
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Recover stale "building" status after server restart
|
|
31
|
+
this.app.on('afterStart', async () => {
|
|
32
|
+
try {
|
|
33
|
+
const repo = this.db.getRepository('aiBuildGuideSpaces');
|
|
34
|
+
await repo.update({
|
|
35
|
+
filter: { status: 'building' },
|
|
36
|
+
values: {
|
|
37
|
+
status: 'error',
|
|
38
|
+
buildLog: 'Build interrupted by server restart',
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
} catch (err) {
|
|
42
|
+
this.app.logger.warn('[plugin-build-guide-block] Failed to recover stale builds', err);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async install(options?: InstallOptions) {
|
|
48
|
+
const collection = this.db.getCollection('aiBuildGuideSpaces');
|
|
49
|
+
if (collection) {
|
|
50
|
+
await collection.model.sync();
|
|
51
|
+
}
|
|
52
|
+
const repo = this.db.getRepository<any>('collections');
|
|
53
|
+
if (repo) {
|
|
54
|
+
await repo.db2cm('aiBuildGuideSpaces');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async upgrade() {
|
|
59
|
+
const collection = this.db.getCollection('aiBuildGuideSpaces');
|
|
60
|
+
if (collection) {
|
|
61
|
+
await collection.model.sync();
|
|
62
|
+
}
|
|
63
|
+
const repo = this.db.getRepository<any>('collections');
|
|
64
|
+
if (repo) {
|
|
65
|
+
await repo.db2cm('aiBuildGuideSpaces');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async afterEnable() {}
|
|
70
|
+
|
|
71
|
+
async afterDisable() {}
|
|
72
|
+
|
|
73
|
+
async remove() {}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export default PluginBuildGuideBlockServer;
|