diff --git a/packages/plugin-workflow/package.json b/packages/plugin-workflow/package.json index e44e1e36fa..2eecc598ad 100644 --- a/packages/plugin-workflow/package.json +++ b/packages/plugin-workflow/package.json @@ -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": { diff --git a/packages/plugin-workflow/src/instructions/condition.ts b/packages/plugin-workflow/src/instructions/condition.ts index b38df688c0..8d77a620d3 100644 --- a/packages/plugin-workflow/src/instructions/condition.ts +++ b/packages/plugin-workflow/src/instructions/condition.ts @@ -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"; diff --git a/packages/plugin-workflow/src/models/Execution.ts b/packages/plugin-workflow/src/models/Execution.ts index 26dc50dc1d..7d811cbed6 100644 --- a/packages/plugin-workflow/src/models/Execution.ts +++ b/packages/plugin-workflow/src/models/Execution.ts @@ -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 {} - export interface ExecutionOptions { transaction?: Transaction; } -export default class ExecutionModel - extends Model - implements ExecutionAttributes { - +export default class ExecutionModel extends Model { declare static readonly database: Database; declare id: number; diff --git a/packages/plugin-workflow/src/server.ts b/packages/plugin-workflow/src/server.ts index 6a8c4ce83a..5548a39307 100644 --- a/packages/plugin-workflow/src/server.ts +++ b/packages/plugin-workflow/src/server.ts @@ -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 diff --git a/packages/plugin-workflow/tsconfig.build.json b/packages/plugin-workflow/tsconfig.build.json new file mode 100644 index 0000000000..f79660a89b --- /dev/null +++ b/packages/plugin-workflow/tsconfig.build.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.build.json", + "compilerOptions": { + "outDir": "./lib", + "declaration": true + }, + "include": ["./src/**/*.ts", "./src/**/*.tsx"], + "exclude": ["./src/__tests__/*", "./esm/*", "./lib/*"] + } \ No newline at end of file diff --git a/packages/plugin-workflow/tsconfig.json b/packages/plugin-workflow/tsconfig.json new file mode 100644 index 0000000000..e10a5305ad --- /dev/null +++ b/packages/plugin-workflow/tsconfig.json @@ -0,0 +1,5 @@ +{ + "extends": "../../tsconfig.json", + "include": ["./src/**/*.ts", "./src/**/*.tsx"], + "exclude": ["./esm/*", "./lib/*"] +} \ No newline at end of file