mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 07:38:13 +00: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",
|
||||
"private": true,
|
||||
"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": {
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -15,7 +15,7 @@
|
||||
// }
|
||||
// }
|
||||
|
||||
import Sequelize = require('sequelize');
|
||||
import Sequelize from 'sequelize';
|
||||
import { getValue, Operand } from "../utils/getter";
|
||||
import { getCalculator } from "../utils/calculators";
|
||||
import { JOB_STATUS } from "../constants";
|
||||
|
@ -1,7 +1,6 @@
|
||||
import {
|
||||
Model,
|
||||
BelongsToGetAssociationMixin,
|
||||
Optional,
|
||||
HasManyGetAssociationsMixin,
|
||||
Transaction
|
||||
} from 'sequelize';
|
||||
@ -14,23 +13,11 @@ import WorkflowModel from './Workflow';
|
||||
import FlowNodeModel from './FlowNode';
|
||||
import JobModel from './Job';
|
||||
|
||||
interface ExecutionAttributes {
|
||||
id: number;
|
||||
title: string;
|
||||
context: any;
|
||||
status: number;
|
||||
}
|
||||
|
||||
interface ExecutionCreationAttributes extends Optional<ExecutionAttributes, 'id'> {}
|
||||
|
||||
export interface ExecutionOptions {
|
||||
transaction?: Transaction;
|
||||
}
|
||||
|
||||
export default class ExecutionModel
|
||||
extends Model<ExecutionAttributes, ExecutionCreationAttributes>
|
||||
implements ExecutionAttributes {
|
||||
|
||||
export default class ExecutionModel extends Model {
|
||||
declare static readonly database: Database;
|
||||
|
||||
declare id: number;
|
||||
|
@ -1,10 +1,11 @@
|
||||
import path from 'path';
|
||||
|
||||
import { Plugin } from '@nocobase/server';
|
||||
|
||||
import WorkflowModel from './models/Workflow';
|
||||
import ExecutionModel from './models/Execution';
|
||||
|
||||
export default {
|
||||
name: 'workflow',
|
||||
export default class WorkflowPlugin extends Plugin {
|
||||
async load(options = {}) {
|
||||
const { db } = this.app;
|
||||
|
||||
@ -23,7 +24,7 @@ export default {
|
||||
// * add hooks for create/update[enabled]/delete workflow to add/remove specific hooks
|
||||
this.app.on('beforeStart', async () => {
|
||||
const { model } = db.getCollection('workflows');
|
||||
await model.mount();
|
||||
await (model as typeof WorkflowModel).mount();
|
||||
})
|
||||
|
||||
// [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