Skip to content

Commit

Permalink
Merge pull request #5 from flow-build/feature/FBS-82
Browse files Browse the repository at this point in the history
Feature/fbs 82
  • Loading branch information
pedropereiraassis authored Oct 19, 2022
2 parents 13243d2 + b8c8de0 commit 95851b4
Show file tree
Hide file tree
Showing 30 changed files with 1,520 additions and 205 deletions.
10 changes: 10 additions & 0 deletions db/migrations/20221014150432_create_blueprints_table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
exports.up = function (knex) {
return knex.schema.createTable("blueprints", (table) => {
table.uuid("id").primary();
table.jsonb("blueprint_spec").notNullable();
});
};

exports.down = function (knex) {
return knex.schema.dropTable("blueprints");
};
12 changes: 12 additions & 0 deletions db/migrations/20221014153521_create_workflows_table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
exports.up = function (knex) {
return knex.schema.createTable("workflows", (table) => {
table.uuid("id").primary();
table.string("server", 255).notNullable();
table.uuid("blueprint_id").notNullable();
table.foreign("blueprint_id").references("blueprints.id");
});
};

exports.down = function (knex) {
return knex.schema.dropTable("workflows");
};
12 changes: 12 additions & 0 deletions db/migrations/20221014154948_create_diagram_to_workflow_table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
exports.up = function (knex) {
return knex.schema.createTable("diagram_to_workflow", (table) => {
table.uuid("diagram_id").notNullable().unique();
table.uuid("workflow_id").notNullable();
table.foreign("diagram_id").references("diagrams.id");
table.foreign("workflow_id").references("workflows.id");
});
};

exports.down = function (knex) {
return knex.schema.dropTable("diagram_to_workflow");
};
10 changes: 10 additions & 0 deletions db/migrations/20221014160432_rename_workflow_id_on_diagrams.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
exports.up = function(knex) {
return knex.schema.alterTable("diagrams", function (table) {
table.renameColumn("workflow_id", "blueprint_id");
table.foreign("blueprint_id").references("blueprints.id");
})
};

exports.down = function(knex) {
return knex.schema.dropTable("diagrams");
};
11 changes: 11 additions & 0 deletions db/seeds/seed-test-blueprint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { blueprint_spec } = require('../../examples/blueprint');

exports.seed = async function(knex) {
await knex('blueprints').del();
await knex('blueprints').insert([
{
id: '42a9a60e-e2e5-4d21-8e2f-67318b100e38',
blueprint_spec: blueprint_spec
}
]);
};
2 changes: 1 addition & 1 deletion db/seeds/seed-test-diagram.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exports.seed = async function(knex) {
id: 'd655538b-95d3-4627-acaf-b391fdc25142',
name: 'Example Diagram',
diagram_xml: diagramSample,
workflow_id: '7be513f4-98dc-43e2-8f3a-66e68a61aca8',
blueprint_id: '42a9a60e-e2e5-4d21-8e2f-67318b100e38',
aligned: true,
user_id: '1'
}
Expand Down
10 changes: 10 additions & 0 deletions db/seeds/seed-test-workflow.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
exports.seed = async function(knex) {
await knex('workflows').del();
await knex('workflows').insert([
{
id: 'ae7e95f6-787a-4c0b-8e1a-4cc122e7d68f',
server: 'http://localhost:3000',
blueprint_id: '42a9a60e-e2e5-4d21-8e2f-67318b100e38'
}
]);
};
9 changes: 9 additions & 0 deletions db/seeds/seed-tests-diagram-to-workflow.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
exports.seed = async function(knex) {
await knex('diagram_to_workflow').del();
await knex('diagram_to_workflow').insert([
{
diagram_id: 'd655538b-95d3-4627-acaf-b391fdc25142',
workflow_id: 'ae7e95f6-787a-4c0b-8e1a-4cc122e7d68f',
}
]);
};
206 changes: 206 additions & 0 deletions examples/blueprint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
module.exports = {
"name": "Medium BP",
"description": "Medium BP for tests",
"blueprint_spec": {
"requirements": ["core"],
"prepare": [],
"nodes": [
{
"id": "START",
"name": "Start node",
"next": "GET-USER",
"type": "Start",
"lane_id": "anyone",
"parameters": {
"input_schema": {},
"timeout": 3600
}
},
{
"id": "GET-USER",
"name": "Get user",
"next": "BAG-USER",
"type": "SystemTask",
"lane_id": "anyone",
"category": "http",
"parameters": {
"input": {},
"request": {
"url": {
"$mustache": "https://api/user"
},
"verb": "GET",
"headers": {
"Authorization": {
"$mustache": "UserLogin apikey=\"{{{actor_data.token}}}\""
}
}
},
"valid_response_codes": [
200,
204
]
}
},
{
"id": "BAG-USER",
"name": "Bag user",
"next": "USER-ACTIVITY",
"type": "SystemTask",
"lane_id": "anyone",
"category": "setToBag",
"parameters": {
"input": {
"user": {
"$ref": "result.data"
}
}
}
},
{
"id": "USER-ACTIVITY",
"name": "Send activity to user",
"next": "BAG-USER-ACTIVITY",
"type": "UserTask",
"lane_id": "anyone",
"parameters": {
"input": {
"user": {
"$ref": "bag.user"
},
"actor_id": {
"$ref": "bag.actor_id"
}
},
"action": "USER_ACTIVITY",
"activity_manager": "commit"
}
},
{
"id": "BAG-USER-ACTIVITY",
"name": "Bag user action",
"next": "GET-STATUS",
"type": "SystemTask",
"lane_id": "anyone",
"category": "setToBag",
"parameters": {
"input": {
"user_action": {
"$ref": "result.activities[0].data.action"
}
}
}
},
{
"id": "GET-STATUS",
"name": "Get status of user",
"next": "CHECK-STATUS",
"type": "SystemTask",
"lane_id": "anyone",
"category": "http",
"parameters": {
"input": {},
"request": {
"url": {
"$mustache": "https://api/user/status"
},
"verb": "GET",
"headers": {
"Authorization": {
"$mustache": "UserLogin apikey=\"{{{actor_data.token}}}\""
}
}
},
"valid_response_codes": [
200,
204
]
}
},
{
"id": "CHECK-STATUS",
"name": "Check user status",
"next": {
"default": "CHECK-USER-ACTIVITY",
"ERROR": "NOTIFY-ERROR"
},
"type": "Flow",
"lane_id": "anyone",
"parameters": {
"input": {
"decision": {
"$ref": "result.data.status"
}
}
}
},
{
"id": "CHECK-USER-ACTIVITY",
"name": "Check user action",
"next": {
"cancel": "END-CANCEL",
"default": "END-ACTIVITY",
"continue": "END-CONTINUE"
},
"type": "Flow",
"lane_id": "anyone",
"parameters": {
"input": {
"decision": {
"$ref": "bag.user_action"
}
}
}
},
{
"id": "END-CANCEL",
"name": "Finish node",
"next": null,
"type": "Finish",
"lane_id": "anyone"
},
{
"id": "END-ACTIVITY",
"name": "Finish node",
"next": null,
"type": "Finish",
"lane_id": "anyone"
},
{
"id": "NOTIFY-ERROR",
"name": "User task node",
"next": "END-ERROR",
"type": "UserTask",
"lane_id": "anyone",
"parameters": {
"input": {},
"action": "NOTIFY_ERROR",
"activity_manager": "notify"
}
},
{
"id": "END-ERROR",
"name": "Finish process after CANCELED",
"next": null,
"type": "Finish",
"lane_id": "anyone"
},
{
"id": "END-CONTINUE",
"name": "Finish process after REDIRECT",
"next": null,
"type": "Finish",
"lane_id": "anyone"
}
],
"lanes": [
{
"id": "anyone",
"name": "anyone",
"rule": ["fn", ["&", "args"], true]
}
],
"environment": {}
}
}

8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
const { DiagramCore } = require('./src/diagramCore');
const { BlueprintCore } = require('./src/blueprintCore');
const { WorkflowCore } = require('./src/workflowCore');
const { DiagramToWorkflowCore } = require('./src/diagramToWorkflowCore');

module.exports = {
DiagramCore
DiagramCore,
BlueprintCore,
WorkflowCore,
DiagramToWorkflowCore
}
Loading

0 comments on commit 95851b4

Please sign in to comment.