mirror of
https://gitee.com/nocobase/nocobase.git
synced 2024-12-01 11:47:51 +08:00
Merge pull request #190 from nocobase/plugin-workflow
Refactor(plugin-workflow): upgrade plugin to use abstract plugin class and fix types
This commit is contained in:
commit
be489996c3
@ -4,6 +4,11 @@
|
|||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"private": true,
|
"private": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"scripts": {
|
||||||
|
"build": "rimraf -rf lib esm dist && npm run build:cjs && npm run build:esm",
|
||||||
|
"build:cjs": "tsc --project tsconfig.build.json",
|
||||||
|
"build:esm": "tsc --project tsconfig.build.json --module es2015 --outDir esm"
|
||||||
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
import Sequelize = require('sequelize');
|
import Sequelize from 'sequelize';
|
||||||
import { getValue, Operand } from "../utils/getter";
|
import { getValue, Operand } from "../utils/getter";
|
||||||
import { getCalculator } from "../utils/calculators";
|
import { getCalculator } from "../utils/calculators";
|
||||||
import { JOB_STATUS } from "../constants";
|
import { JOB_STATUS } from "../constants";
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
Model,
|
Model,
|
||||||
BelongsToGetAssociationMixin,
|
BelongsToGetAssociationMixin,
|
||||||
Optional,
|
|
||||||
HasManyGetAssociationsMixin,
|
HasManyGetAssociationsMixin,
|
||||||
Transaction
|
Transaction
|
||||||
} from 'sequelize';
|
} from 'sequelize';
|
||||||
@ -14,23 +13,11 @@ import WorkflowModel from './Workflow';
|
|||||||
import FlowNodeModel from './FlowNode';
|
import FlowNodeModel from './FlowNode';
|
||||||
import JobModel from './Job';
|
import JobModel from './Job';
|
||||||
|
|
||||||
interface ExecutionAttributes {
|
|
||||||
id: number;
|
|
||||||
title: string;
|
|
||||||
context: any;
|
|
||||||
status: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ExecutionCreationAttributes extends Optional<ExecutionAttributes, 'id'> {}
|
|
||||||
|
|
||||||
export interface ExecutionOptions {
|
export interface ExecutionOptions {
|
||||||
transaction?: Transaction;
|
transaction?: Transaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class ExecutionModel
|
export default class ExecutionModel extends Model {
|
||||||
extends Model<ExecutionAttributes, ExecutionCreationAttributes>
|
|
||||||
implements ExecutionAttributes {
|
|
||||||
|
|
||||||
declare static readonly database: Database;
|
declare static readonly database: Database;
|
||||||
|
|
||||||
declare id: number;
|
declare id: number;
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
|
import { Plugin } from '@nocobase/server';
|
||||||
|
|
||||||
import WorkflowModel from './models/Workflow';
|
import WorkflowModel from './models/Workflow';
|
||||||
import ExecutionModel from './models/Execution';
|
import ExecutionModel from './models/Execution';
|
||||||
|
|
||||||
export default {
|
export default class WorkflowPlugin extends Plugin {
|
||||||
name: 'workflow',
|
|
||||||
async load(options = {}) {
|
async load(options = {}) {
|
||||||
const { db } = this.app;
|
const { db } = this.app;
|
||||||
|
|
||||||
@ -23,7 +24,7 @@ export default {
|
|||||||
// * add hooks for create/update[enabled]/delete workflow to add/remove specific hooks
|
// * add hooks for create/update[enabled]/delete workflow to add/remove specific hooks
|
||||||
this.app.on('beforeStart', async () => {
|
this.app.on('beforeStart', async () => {
|
||||||
const { model } = db.getCollection('workflows');
|
const { model } = db.getCollection('workflows');
|
||||||
await model.mount();
|
await (model as typeof WorkflowModel).mount();
|
||||||
})
|
})
|
||||||
|
|
||||||
// [Life Cycle]: initialize all necessary seed data
|
// [Life Cycle]: initialize all necessary seed data
|
||||||
|
9
packages/plugin-workflow/tsconfig.build.json
Normal file
9
packages/plugin-workflow/tsconfig.build.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../tsconfig.build.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "./lib",
|
||||||
|
"declaration": true
|
||||||
|
},
|
||||||
|
"include": ["./src/**/*.ts", "./src/**/*.tsx"],
|
||||||
|
"exclude": ["./src/__tests__/*", "./esm/*", "./lib/*"]
|
||||||
|
}
|
5
packages/plugin-workflow/tsconfig.json
Normal file
5
packages/plugin-workflow/tsconfig.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../tsconfig.json",
|
||||||
|
"include": ["./src/**/*.ts", "./src/**/*.tsx"],
|
||||||
|
"exclude": ["./esm/*", "./lib/*"]
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user