@nocobase/plugin-workflow-manual 1.0.0-alpha.1 → 1.0.0-alpha.3
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/dist/client/WorkflowTodo.d.ts +8 -0
- package/dist/client/WorkflowTodoBlockInitializer.d.ts +8 -0
- package/dist/client/index.d.ts +8 -0
- package/dist/client/index.js +9 -0
- package/dist/client/instruction/AssigneesSelect.d.ts +8 -0
- package/dist/client/instruction/FormBlockInitializer.d.ts +8 -0
- package/dist/client/instruction/FormBlockProvider.d.ts +8 -0
- package/dist/client/instruction/ModeConfig.d.ts +8 -0
- package/dist/client/instruction/SchemaConfig.d.ts +8 -0
- package/dist/client/instruction/createManualFormBlockUISchema.d.ts +8 -0
- package/dist/client/instruction/forms/create.d.ts +8 -0
- package/dist/client/instruction/forms/custom.d.ts +8 -0
- package/dist/client/instruction/forms/update.d.ts +8 -0
- package/dist/client/instruction/index.d.ts +8 -0
- package/dist/client/instruction/utils.d.ts +8 -0
- package/dist/externalVersion.js +18 -9
- package/dist/index.d.ts +8 -0
- package/dist/index.js +9 -0
- package/dist/locale/index.d.ts +8 -0
- package/dist/locale/index.js +9 -0
- package/dist/server/ManualInstruction.d.ts +8 -0
- package/dist/server/ManualInstruction.js +9 -0
- package/dist/server/Plugin.d.ts +8 -0
- package/dist/server/Plugin.js +9 -0
- package/dist/server/actions.d.ts +8 -0
- package/dist/server/actions.js +9 -0
- package/dist/server/collections/1-users_jobs.d.ts +8 -0
- package/dist/server/collections/1-users_jobs.js +9 -0
- package/dist/server/collections/2-jobs.d.ts +8 -0
- package/dist/server/collections/2-jobs.js +9 -0
- package/dist/server/collections/3-users.d.ts +8 -0
- package/dist/server/collections/3-users.js +9 -0
- package/dist/server/forms/create.d.ts +8 -0
- package/dist/server/forms/create.js +9 -0
- package/dist/server/forms/index.d.ts +8 -0
- package/dist/server/forms/index.js +9 -0
- package/dist/server/forms/update.d.ts +8 -0
- package/dist/server/forms/update.js +9 -0
- package/dist/server/index.d.ts +8 -0
- package/dist/server/index.js +9 -0
- package/dist/server/migrations/20240325213145-fix-schema.d.ts +8 -0
- package/dist/server/migrations/20240325213145-fix-schema.js +9 -0
- package/package.json +2 -2
- package/src/client/WorkflowTodo.tsx +0 -647
- package/src/client/WorkflowTodoBlockInitializer.tsx +0 -32
- package/src/client/__e2e__/assignees.test.ts +0 -0
- package/src/client/__e2e__/createRecordForm.test.ts +0 -2287
- package/src/client/__e2e__/customFormBlocks.test.ts +0 -1933
- package/src/client/__e2e__/datablocks.test.ts +0 -1208
- package/src/client/__e2e__/updateRecordForm.test.ts +0 -2338
- package/src/client/__e2e__/workflowTodo.test.ts +0 -242
- package/src/client/index.ts +0 -51
- package/src/client/instruction/AssigneesSelect.tsx +0 -39
- package/src/client/instruction/FormBlockInitializer.tsx +0 -79
- package/src/client/instruction/FormBlockProvider.tsx +0 -92
- package/src/client/instruction/ModeConfig.tsx +0 -85
- package/src/client/instruction/SchemaConfig.tsx +0 -659
- package/src/client/instruction/createManualFormBlockUISchema.ts +0 -5
- package/src/client/instruction/forms/create.tsx +0 -123
- package/src/client/instruction/forms/custom.tsx +0 -439
- package/src/client/instruction/forms/update.tsx +0 -167
- package/src/client/instruction/index.tsx +0 -160
- package/src/client/instruction/utils.ts +0 -19
- package/src/index.ts +0 -2
- package/src/locale/en-US.json +0 -30
- package/src/locale/index.ts +0 -14
- package/src/locale/ko_KR.json +0 -32
- package/src/locale/zh-CN.json +0 -32
- package/src/server/ManualInstruction.ts +0 -157
- package/src/server/Plugin.ts +0 -43
- package/src/server/__tests__/assignees.test.ts +0 -153
- package/src/server/__tests__/collections/categories.ts +0 -15
- package/src/server/__tests__/collections/comments.ts +0 -24
- package/src/server/__tests__/collections/posts.ts +0 -40
- package/src/server/__tests__/collections/replies.ts +0 -9
- package/src/server/__tests__/collections/tags.ts +0 -15
- package/src/server/__tests__/data-source.test.ts +0 -223
- package/src/server/__tests__/form.test.ts +0 -637
- package/src/server/__tests__/mode.test.ts +0 -561
- package/src/server/actions.ts +0 -103
- package/src/server/collections/1-users_jobs.ts +0 -52
- package/src/server/collections/2-jobs.ts +0 -19
- package/src/server/collections/3-users.ts +0 -17
- package/src/server/forms/create.ts +0 -30
- package/src/server/forms/index.ts +0 -13
- package/src/server/forms/update.ts +0 -30
- package/src/server/index.ts +0 -1
- package/src/server/migrations/20240325213145-fix-schema.ts +0 -82
|
@@ -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
|
-
}
|
package/src/server/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './Plugin';
|
|
@@ -1,82 +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
|
-
appVersion = '<0.21.0-alpha.15';
|
|
48
|
-
async up() {
|
|
49
|
-
const { db } = this.context;
|
|
50
|
-
const NodeRepo = db.getRepository('flow_nodes');
|
|
51
|
-
await db.sequelize.transaction(async (transaction) => {
|
|
52
|
-
const nodes = await NodeRepo.find({
|
|
53
|
-
filter: {
|
|
54
|
-
type: 'manual',
|
|
55
|
-
},
|
|
56
|
-
transaction,
|
|
57
|
-
});
|
|
58
|
-
console.log('%d nodes need to be migrated.', nodes.length);
|
|
59
|
-
|
|
60
|
-
await nodes.reduce(
|
|
61
|
-
(promise, node) =>
|
|
62
|
-
promise.then(() => {
|
|
63
|
-
const { assignees, forms, schema = {}, ...tabs } = node.config;
|
|
64
|
-
return node.update(
|
|
65
|
-
{
|
|
66
|
-
config: {
|
|
67
|
-
assignees,
|
|
68
|
-
forms,
|
|
69
|
-
schema: migrateSchema({ ...tabs, ...schema }),
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
silent: true,
|
|
74
|
-
transaction,
|
|
75
|
-
},
|
|
76
|
-
);
|
|
77
|
-
}),
|
|
78
|
-
Promise.resolve(),
|
|
79
|
-
);
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
}
|