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.
Files changed (34) hide show
  1. package/README.md +74 -74
  2. package/dist/client/index.js +1 -1
  3. package/dist/client/models/index.d.ts +1 -3
  4. package/dist/externalVersion.js +7 -7
  5. package/dist/locale/en-US.json +28 -27
  6. package/dist/locale/vi-VN.json +28 -27
  7. package/dist/locale/zh-CN.json +28 -27
  8. package/dist/node_modules/sanitize-html/index.js +2 -2
  9. package/dist/node_modules/sanitize-html/package.json +1 -1
  10. package/dist/server/actions/build.js +3 -0
  11. package/dist/server/index.d.ts +1 -0
  12. package/dist/server/index.js +7 -1
  13. package/dist/server/plugin.js +14 -0
  14. package/package.json +31 -31
  15. package/src/client/UserGuideBlock.tsx +53 -53
  16. package/src/client/UserGuideBlockInitializer.tsx +26 -26
  17. package/src/client/UserGuideBlockProvider.tsx +12 -12
  18. package/src/client/UserGuideManager.tsx +128 -107
  19. package/src/client/components/BuildButton.tsx +78 -43
  20. package/src/client/components/LLMServiceSelect.tsx +44 -44
  21. package/src/client/components/ModelSelect.tsx +41 -41
  22. package/src/client/components/StatusTag.tsx +17 -17
  23. package/src/client/models/UserGuideBlockModel.ts +54 -54
  24. package/src/client/models/index.ts +1 -3
  25. package/src/client/plugin.tsx +30 -30
  26. package/src/client/schemas/spacesSchema.ts +316 -316
  27. package/src/locale/en-US.json +28 -27
  28. package/src/locale/vi-VN.json +28 -27
  29. package/src/locale/zh-CN.json +28 -27
  30. package/src/server/actions/build.ts +176 -171
  31. package/src/server/actions/getHtml.ts +26 -26
  32. package/src/server/collections/ai-build-guide-spaces.ts +50 -50
  33. package/src/server/index.ts +1 -0
  34. 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
+ });
@@ -1 +1,2 @@
1
1
  export { default } from './plugin';
2
+ export const namespace = 'plugin-build-guide-block';
@@ -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
- async install(options?: InstallOptions) {
32
- const collection = this.db.getCollection('aiBuildGuideSpaces');
33
- if (collection) {
34
- await collection.model.sync();
35
- }
36
- const repo = this.db.getRepository<any>('collections');
37
- if (repo) {
38
- await repo.db2cm('aiBuildGuideSpaces');
39
- }
40
- }
41
-
42
- async upgrade() {
43
- const collection = this.db.getCollection('aiBuildGuideSpaces');
44
- if (collection) {
45
- await collection.model.sync();
46
- }
47
- const repo = this.db.getRepository<any>('collections');
48
- if (repo) {
49
- await repo.db2cm('aiBuildGuideSpaces');
50
- }
51
- }
52
-
53
- async afterEnable() {}
54
-
55
- async afterDisable() {}
56
-
57
- async remove() {}
58
- }
59
-
60
- export default PluginBuildGuideBlockServer;
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;