@nocobase/plugin-workflow-test 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/index.d.ts +8 -0
- package/dist/client/index.js +9 -0
- package/dist/e2e/e2eCollectionModel.d.ts +8 -0
- package/dist/e2e/e2eCollectionModel.js +9 -0
- package/dist/e2e/e2ePageObjectModel.d.ts +8 -0
- package/dist/e2e/e2ePageObjectModel.js +9 -0
- package/dist/e2e/e2eUtils.d.ts +8 -0
- package/dist/e2e/e2eUtils.js +9 -0
- package/dist/e2e/index.d.ts +8 -0
- package/dist/e2e/index.js +9 -0
- package/dist/externalVersion.js +16 -7
- package/dist/index.d.ts +8 -0
- package/dist/index.js +9 -0
- package/dist/server/collections/categories.d.ts +8 -0
- package/dist/server/collections/categories.js +9 -0
- package/dist/server/collections/comments.d.ts +8 -0
- package/dist/server/collections/comments.js +9 -0
- package/dist/server/collections/posts.d.ts +8 -0
- package/dist/server/collections/posts.js +9 -0
- package/dist/server/collections/replies.d.ts +8 -0
- package/dist/server/collections/replies.js +9 -0
- package/dist/server/collections/tags.d.ts +8 -0
- package/dist/server/collections/tags.js +9 -0
- package/dist/server/functions.d.ts +8 -0
- package/dist/server/functions.js +9 -0
- package/dist/server/index.d.ts +8 -0
- package/dist/server/index.js +9 -0
- package/dist/server/instructions.d.ts +8 -0
- package/dist/server/instructions.js +9 -0
- package/dist/server/triggers.d.ts +8 -0
- package/dist/server/triggers.js +9 -0
- package/package.json +2 -2
- package/src/client/index.ts +0 -3
- package/src/e2e/e2eCollectionModel.ts +0 -4250
- package/src/e2e/e2ePageObjectModel.ts +0 -646
- package/src/e2e/e2eUtils.ts +0 -950
- package/src/e2e/index.ts +0 -4
- package/src/index.ts +0 -2
- package/src/server/collections/categories.ts +0 -15
- package/src/server/collections/comments.ts +0 -24
- package/src/server/collections/posts.ts +0 -40
- package/src/server/collections/replies.ts +0 -9
- package/src/server/collections/tags.ts +0 -15
- package/src/server/functions.ts +0 -3
- package/src/server/index.ts +0 -85
- package/src/server/instructions.ts +0 -67
- package/src/server/triggers.ts +0 -19
package/src/e2e/index.ts
DELETED
package/src/index.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { CollectionOptions } from '@nocobase/database';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
name: 'comments',
|
|
5
|
-
fields: [
|
|
6
|
-
{
|
|
7
|
-
type: 'belongsTo',
|
|
8
|
-
name: 'post',
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
type: 'text',
|
|
12
|
-
name: 'content',
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
type: 'integer',
|
|
16
|
-
name: 'status',
|
|
17
|
-
defaultValue: 0,
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
type: 'hasMany',
|
|
21
|
-
name: 'replies',
|
|
22
|
-
},
|
|
23
|
-
],
|
|
24
|
-
} as CollectionOptions;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { CollectionOptions } from '@nocobase/database';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
name: 'posts',
|
|
5
|
-
createdBy: true,
|
|
6
|
-
updatedBy: true,
|
|
7
|
-
fields: [
|
|
8
|
-
{
|
|
9
|
-
type: 'string',
|
|
10
|
-
name: 'title',
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
type: 'boolean',
|
|
14
|
-
name: 'published',
|
|
15
|
-
defaultValue: false,
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
type: 'integer',
|
|
19
|
-
name: 'read',
|
|
20
|
-
defaultValue: 0,
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
type: 'belongsTo',
|
|
24
|
-
name: 'category',
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
type: 'hasMany',
|
|
28
|
-
name: 'comments',
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
type: 'belongsToMany',
|
|
32
|
-
name: 'tags',
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
type: 'integer',
|
|
36
|
-
name: 'read',
|
|
37
|
-
defaultValue: 0,
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
} as CollectionOptions;
|
package/src/server/functions.ts
DELETED
package/src/server/index.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
|
|
3
|
-
import { ApplicationOptions, Plugin } from '@nocobase/server';
|
|
4
|
-
import { MockServer, createMockServer, mockDatabase } from '@nocobase/test';
|
|
5
|
-
|
|
6
|
-
import functions from './functions';
|
|
7
|
-
import triggers from './triggers';
|
|
8
|
-
import instructions from './instructions';
|
|
9
|
-
import { Resourcer } from '@nocobase/resourcer';
|
|
10
|
-
import { SequelizeDataSource } from '@nocobase/data-source-manager';
|
|
11
|
-
import { uid } from '@nocobase/utils';
|
|
12
|
-
|
|
13
|
-
export interface MockServerOptions extends ApplicationOptions {
|
|
14
|
-
collectionsPath?: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// async function createMockServer(options: MockServerOptions) {
|
|
18
|
-
// const app = mockServer(options);
|
|
19
|
-
// await app.cleanDb();
|
|
20
|
-
// await app.runCommand('start', '--quickstart');
|
|
21
|
-
// return app;
|
|
22
|
-
// }
|
|
23
|
-
|
|
24
|
-
export function sleep(ms: number) {
|
|
25
|
-
return new Promise((resolve) => {
|
|
26
|
-
setTimeout(resolve, ms);
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export async function getApp(options: MockServerOptions = {}): Promise<MockServer> {
|
|
31
|
-
const { plugins = [], collectionsPath, ...others } = options;
|
|
32
|
-
class TestCollectionPlugin extends Plugin {
|
|
33
|
-
async load() {
|
|
34
|
-
if (collectionsPath) {
|
|
35
|
-
await this.db.import({ directory: collectionsPath });
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
const app = await createMockServer({
|
|
40
|
-
...others,
|
|
41
|
-
plugins: [
|
|
42
|
-
[
|
|
43
|
-
'workflow',
|
|
44
|
-
{
|
|
45
|
-
triggers,
|
|
46
|
-
instructions,
|
|
47
|
-
functions,
|
|
48
|
-
},
|
|
49
|
-
],
|
|
50
|
-
'workflow-test',
|
|
51
|
-
TestCollectionPlugin,
|
|
52
|
-
...plugins,
|
|
53
|
-
],
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
await app.dataSourceManager.add(
|
|
57
|
-
new SequelizeDataSource({
|
|
58
|
-
name: 'another',
|
|
59
|
-
collectionManager: {
|
|
60
|
-
database: mockDatabase({
|
|
61
|
-
tablePrefix: `t${uid(5)}`,
|
|
62
|
-
}),
|
|
63
|
-
},
|
|
64
|
-
resourceManager: {},
|
|
65
|
-
}),
|
|
66
|
-
);
|
|
67
|
-
const another = app.dataSourceManager.dataSources.get('another');
|
|
68
|
-
// @ts-ignore
|
|
69
|
-
const anotherDB = another.collectionManager.db;
|
|
70
|
-
|
|
71
|
-
await anotherDB.import({
|
|
72
|
-
directory: path.resolve(__dirname, 'collections'),
|
|
73
|
-
});
|
|
74
|
-
await anotherDB.sync();
|
|
75
|
-
|
|
76
|
-
another.acl.allow('*', '*');
|
|
77
|
-
|
|
78
|
-
return app;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export default class WorkflowTestPlugin extends Plugin {
|
|
82
|
-
async load() {
|
|
83
|
-
await this.importCollections(path.resolve(__dirname, 'collections'));
|
|
84
|
-
}
|
|
85
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { lodash } from '@nocobase/utils';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
echo: {
|
|
5
|
-
run({ config = {} }: any, { result }, processor) {
|
|
6
|
-
return {
|
|
7
|
-
status: 1,
|
|
8
|
-
result: config.path == null ? result : lodash.get(result, config.path),
|
|
9
|
-
};
|
|
10
|
-
},
|
|
11
|
-
},
|
|
12
|
-
|
|
13
|
-
error: {
|
|
14
|
-
run(node, input, processor) {
|
|
15
|
-
throw new Error('definite error');
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
pending: {
|
|
20
|
-
run(node, input, processor) {
|
|
21
|
-
return {
|
|
22
|
-
status: 0,
|
|
23
|
-
};
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
prompt: {
|
|
28
|
-
run(node, input, processor) {
|
|
29
|
-
return {
|
|
30
|
-
status: 0,
|
|
31
|
-
};
|
|
32
|
-
},
|
|
33
|
-
resume(node, job, processor) {
|
|
34
|
-
return job.set({
|
|
35
|
-
status: 1,
|
|
36
|
-
});
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
'prompt->error': {
|
|
41
|
-
run(node, input, processor) {
|
|
42
|
-
return {
|
|
43
|
-
status: 0,
|
|
44
|
-
};
|
|
45
|
-
},
|
|
46
|
-
resume(node, input, processor) {
|
|
47
|
-
throw new Error('input failed');
|
|
48
|
-
return null;
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
customizedSuccess: {
|
|
53
|
-
run(node, input, processor) {
|
|
54
|
-
return {
|
|
55
|
-
status: 100,
|
|
56
|
-
};
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
customizedError: {
|
|
61
|
-
run(node, input, processor) {
|
|
62
|
-
return {
|
|
63
|
-
status: -100,
|
|
64
|
-
};
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
};
|
package/src/server/triggers.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
syncTrigger: class {
|
|
3
|
-
constructor(public readonly workflow) {}
|
|
4
|
-
on() {}
|
|
5
|
-
off() {}
|
|
6
|
-
sync = true;
|
|
7
|
-
validateEvent() {
|
|
8
|
-
return true;
|
|
9
|
-
}
|
|
10
|
-
},
|
|
11
|
-
asyncTrigger: class {
|
|
12
|
-
constructor(public readonly workflow) {}
|
|
13
|
-
on() {}
|
|
14
|
-
off() {}
|
|
15
|
-
validateEvent() {
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
};
|