@nocobase/plugin-workflow-manual 0.21.0-alpha.9 → 1.0.0-alpha.10

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 (87) hide show
  1. package/dist/client/WorkflowTodo.d.ts +8 -0
  2. package/dist/client/WorkflowTodoBlockInitializer.d.ts +8 -0
  3. package/dist/client/index.d.ts +8 -0
  4. package/dist/client/index.js +13 -4
  5. package/dist/client/instruction/AssigneesSelect.d.ts +8 -0
  6. package/dist/client/instruction/FormBlockInitializer.d.ts +8 -0
  7. package/dist/client/instruction/FormBlockProvider.d.ts +8 -0
  8. package/dist/client/instruction/ModeConfig.d.ts +8 -0
  9. package/dist/client/instruction/SchemaConfig.d.ts +8 -0
  10. package/dist/client/instruction/createManualFormBlockUISchema.d.ts +8 -0
  11. package/dist/client/instruction/forms/create.d.ts +8 -0
  12. package/dist/client/instruction/forms/custom.d.ts +8 -0
  13. package/dist/client/instruction/forms/update.d.ts +8 -0
  14. package/dist/client/instruction/index.d.ts +8 -0
  15. package/dist/client/instruction/utils.d.ts +8 -0
  16. package/dist/externalVersion.js +18 -9
  17. package/dist/index.d.ts +8 -0
  18. package/dist/index.js +9 -0
  19. package/dist/locale/index.d.ts +8 -0
  20. package/dist/locale/index.js +9 -0
  21. package/dist/server/ManualInstruction.d.ts +8 -0
  22. package/dist/server/ManualInstruction.js +16 -3
  23. package/dist/server/Plugin.d.ts +8 -0
  24. package/dist/server/Plugin.js +9 -0
  25. package/dist/server/actions.d.ts +8 -0
  26. package/dist/server/actions.js +10 -1
  27. package/dist/server/collections/1-users_jobs.d.ts +8 -0
  28. package/dist/server/collections/1-users_jobs.js +9 -0
  29. package/dist/server/collections/2-jobs.d.ts +8 -0
  30. package/dist/server/collections/2-jobs.js +9 -0
  31. package/dist/server/collections/3-users.d.ts +8 -0
  32. package/dist/server/collections/3-users.js +9 -0
  33. package/dist/server/forms/create.d.ts +8 -0
  34. package/dist/server/forms/create.js +9 -0
  35. package/dist/server/forms/index.d.ts +8 -0
  36. package/dist/server/forms/index.js +9 -0
  37. package/dist/server/forms/update.d.ts +8 -0
  38. package/dist/server/forms/update.js +9 -0
  39. package/dist/server/index.d.ts +8 -0
  40. package/dist/server/index.js +9 -0
  41. package/dist/server/migrations/20240325213145-fix-schema.d.ts +9 -0
  42. package/dist/server/migrations/20240325213145-fix-schema.js +10 -0
  43. package/package.json +9 -9
  44. package/src/client/WorkflowTodo.tsx +0 -647
  45. package/src/client/WorkflowTodoBlockInitializer.tsx +0 -32
  46. package/src/client/__e2e__/assignees.test.ts +0 -0
  47. package/src/client/__e2e__/createRecordForm.test.ts +0 -2287
  48. package/src/client/__e2e__/customFormBlocks.test.ts +0 -1933
  49. package/src/client/__e2e__/datablocks.test.ts +0 -1208
  50. package/src/client/__e2e__/updateRecordForm.test.ts +0 -2338
  51. package/src/client/__e2e__/workflowTodo.test.ts +0 -242
  52. package/src/client/index.ts +0 -51
  53. package/src/client/instruction/AssigneesSelect.tsx +0 -39
  54. package/src/client/instruction/FormBlockInitializer.tsx +0 -79
  55. package/src/client/instruction/FormBlockProvider.tsx +0 -97
  56. package/src/client/instruction/ModeConfig.tsx +0 -85
  57. package/src/client/instruction/SchemaConfig.tsx +0 -659
  58. package/src/client/instruction/createManualFormBlockUISchema.ts +0 -5
  59. package/src/client/instruction/forms/create.tsx +0 -123
  60. package/src/client/instruction/forms/custom.tsx +0 -439
  61. package/src/client/instruction/forms/update.tsx +0 -167
  62. package/src/client/instruction/index.tsx +0 -160
  63. package/src/client/instruction/utils.ts +0 -19
  64. package/src/index.ts +0 -2
  65. package/src/locale/en-US.json +0 -30
  66. package/src/locale/index.ts +0 -14
  67. package/src/locale/ko_KR.json +0 -32
  68. package/src/locale/zh-CN.json +0 -32
  69. package/src/server/ManualInstruction.ts +0 -152
  70. package/src/server/Plugin.ts +0 -43
  71. package/src/server/__tests__/collections/categories.ts +0 -15
  72. package/src/server/__tests__/collections/comments.ts +0 -24
  73. package/src/server/__tests__/collections/posts.ts +0 -40
  74. package/src/server/__tests__/collections/replies.ts +0 -9
  75. package/src/server/__tests__/collections/tags.ts +0 -15
  76. package/src/server/__tests__/data-source.test.ts +0 -223
  77. package/src/server/__tests__/form.test.ts +0 -637
  78. package/src/server/__tests__/mode.test.ts +0 -561
  79. package/src/server/actions.ts +0 -100
  80. package/src/server/collections/1-users_jobs.ts +0 -52
  81. package/src/server/collections/2-jobs.ts +0 -19
  82. package/src/server/collections/3-users.ts +0 -17
  83. package/src/server/forms/create.ts +0 -30
  84. package/src/server/forms/index.ts +0 -13
  85. package/src/server/forms/update.ts +0 -30
  86. package/src/server/index.ts +0 -1
  87. package/src/server/migrations/20240325213145-fix-schema.ts +0 -81
@@ -1,19 +0,0 @@
1
- import { extendCollection } from '@nocobase/database';
2
-
3
- export default extendCollection({
4
- name: 'jobs',
5
- fields: [
6
- {
7
- type: 'belongsToMany',
8
- name: 'users',
9
- through: 'users_jobs',
10
- },
11
- {
12
- type: 'hasMany',
13
- name: 'usersJobs',
14
- target: 'users_jobs',
15
- foreignKey: 'jobId',
16
- onDelete: 'CASCADE',
17
- },
18
- ],
19
- });
@@ -1,17 +0,0 @@
1
- import { extendCollection } from '@nocobase/database';
2
-
3
- export default extendCollection({
4
- name: 'users',
5
- fields: [
6
- {
7
- type: 'belongsToMany',
8
- name: 'jobs',
9
- through: 'users_jobs',
10
- },
11
- {
12
- type: 'hasMany',
13
- name: 'usersJobs',
14
- target: 'users_jobs',
15
- },
16
- ],
17
- });
@@ -1,30 +0,0 @@
1
- import { Processor } from '@nocobase/plugin-workflow';
2
- import ManualInstruction from '../ManualInstruction';
3
-
4
- export default async function (
5
- this: ManualInstruction,
6
- instance,
7
- { dataSource = 'main', collection },
8
- processor: Processor,
9
- ) {
10
- const repo = this.workflow.app.dataSourceManager.dataSources
11
- .get(dataSource)
12
- .collectionManager.getRepository(collection);
13
- if (!repo) {
14
- throw new Error(`collection ${collection} for create data on manual node not found`);
15
- }
16
-
17
- const { _, ...form } = instance.result;
18
- const [values] = Object.values(form);
19
- await repo.create({
20
- values: {
21
- ...((values as { [key: string]: any }) ?? {}),
22
- createdBy: instance.userId,
23
- updatedBy: instance.userId,
24
- },
25
- context: {
26
- executionId: processor.execution.id,
27
- },
28
- transaction: processor.transaction,
29
- });
30
- }
@@ -1,13 +0,0 @@
1
- import { Processor } from '@nocobase/plugin-workflow';
2
-
3
- import ManualInstruction from '../ManualInstruction';
4
-
5
- import create from './create';
6
- import update from './update';
7
-
8
- export type FormHandler = (this: ManualInstruction, instance, formConfig, processor: Processor) => Promise<void>;
9
-
10
- export default function ({ formTypes }) {
11
- formTypes.register('create', create);
12
- formTypes.register('update', update);
13
- }
@@ -1,30 +0,0 @@
1
- import { Processor } from '@nocobase/plugin-workflow';
2
- import ManualInstruction from '../ManualInstruction';
3
-
4
- export default async function (
5
- this: ManualInstruction,
6
- instance,
7
- { dataSource = 'main', collection, filter = {} },
8
- processor: Processor,
9
- ) {
10
- const repo = this.workflow.app.dataSourceManager.dataSources
11
- .get(dataSource)
12
- .collectionManager.getRepository(collection);
13
- if (!repo) {
14
- throw new Error(`collection ${collection} for update data on manual node not found`);
15
- }
16
-
17
- const { _, ...form } = instance.result;
18
- const [values] = Object.values(form);
19
- await repo.update({
20
- filter: processor.getParsedValue(filter, instance.nodeId),
21
- values: {
22
- ...((values as { [key: string]: any }) ?? {}),
23
- updatedBy: instance.userId,
24
- },
25
- context: {
26
- executionId: processor.execution.id,
27
- },
28
- transaction: processor.transaction,
29
- });
30
- }
@@ -1 +0,0 @@
1
- export { default } from './Plugin';
@@ -1,81 +0,0 @@
1
- import { Migration } from '@nocobase/server';
2
-
3
- function findSchema(root, filter, onlyLeaf = false) {
4
- const result = [];
5
-
6
- if (!root) {
7
- return result;
8
- }
9
-
10
- if (filter(root) && (!onlyLeaf || !root.properties)) {
11
- result.push(root);
12
- return result;
13
- }
14
-
15
- if (root.properties) {
16
- Object.keys(root.properties).forEach((key) => {
17
- result.push(...findSchema(root.properties[key], filter));
18
- });
19
- }
20
- return result;
21
- }
22
-
23
- function changeToDataPath(item) {
24
- if (item && item['x-decorator-props']?.dataSource) {
25
- item['x-decorator-props'].dataPath = item['x-decorator-props'].dataSource.replace(/^{{|}}$/g, '');
26
- delete item['x-decorator-props'].dataSource;
27
- }
28
- }
29
-
30
- function migrateSchema(schema) {
31
- const root = { properties: schema };
32
-
33
- const detailNodes = findSchema(root, (item) => {
34
- return (
35
- item['x-decorator'] === 'DetailsBlockProvider' &&
36
- item['x-component'] === 'CardItem' &&
37
- item['x-designer'] === 'SimpleDesigner'
38
- );
39
- });
40
-
41
- detailNodes.forEach(changeToDataPath);
42
-
43
- return schema;
44
- }
45
-
46
- export default class extends Migration {
47
- async up() {
48
- const { db } = this.context;
49
- const NodeRepo = db.getRepository('flow_nodes');
50
- await db.sequelize.transaction(async (transaction) => {
51
- const nodes = await NodeRepo.find({
52
- filter: {
53
- type: 'manual',
54
- },
55
- transaction,
56
- });
57
- console.log('%d nodes need to be migrated.', nodes.length);
58
-
59
- await nodes.reduce(
60
- (promise, node) =>
61
- promise.then(() => {
62
- const { assignees, forms, schema = {}, ...tabs } = node.config;
63
- return node.update(
64
- {
65
- config: {
66
- assignees,
67
- forms,
68
- schema: migrateSchema({ ...tabs, ...schema }),
69
- },
70
- },
71
- {
72
- silent: true,
73
- transaction,
74
- },
75
- );
76
- }),
77
- Promise.resolve(),
78
- );
79
- });
80
- }
81
- }