Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
88 changed files
with
11,206 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Logs | ||
logs | ||
*.log | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directory | ||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- | ||
node_modules | ||
|
||
# Autogenerated folder by gulp | ||
out | ||
|
||
# Generated by vscode | ||
.vscode | ||
|
||
|
||
# Debug log from npm | ||
npm-debug.log | ||
|
||
.node-xmlhttprequest-sync* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# README | ||
## This the readme for your application "node-express-typescript" | ||
------------------- | ||
### Visual Studio Code has *awesome* Markdown support! | ||
|
||
* Split the editor (`Cmd+\` on OSX or `Ctrl+\` on Windows and Linux) | ||
* Toggle preview (`Shift+CMD+V` on OSX or `Shift+Ctrl+V` on Windows and Linux) | ||
* Press `Ctrl+Space` (Windows, Linux) or `Cmd+Space` (OSX) to see a list of Markdown snippets | ||
|
||
### For more information | ||
* [Visual Studio Code's Markdown Support](http://code.visualstudio.com/docs/languages/markdown) | ||
* [Markdown Syntax Reference](http://daringfireball.net) | ||
|
||
**Enjoy!** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
var gulp = require('gulp'); | ||
var less = require('gulp-less'); | ||
var path = require('path'); | ||
var mocha = require('gulp-mocha'); | ||
var browserSync = require('browser-sync'); | ||
var nodemon = require('gulp-nodemon'); | ||
var cp = require('child_process'); | ||
var tsb = require('gulp-tsb'); | ||
|
||
|
||
// compile less files from the ./styles folder | ||
// into css files to the ./public/stylesheets folder | ||
gulp.task('less', function() { | ||
return gulp.src('./src/styles/**/*.less') | ||
.pipe(less({ | ||
paths: [path.join(__dirname, 'less', 'includes')] | ||
})) | ||
.pipe(gulp.dest('./out/public/stylesheets')); | ||
}); | ||
|
||
|
||
// run mocha tests in the ./tests folder | ||
gulp.task('test', function() { | ||
return gulp.src('./tests/out/test*.js', { read: false }) | ||
// gulp-mocha needs filepaths so you can't have any plugins before it | ||
.pipe(mocha()); | ||
}); | ||
|
||
// run browser-sync on for client changes | ||
gulp.task('browser-sync', ['nodemon', 'watch'], function() { | ||
browserSync.init(null, { | ||
open: false, | ||
proxy: "http://localhost:3000", | ||
files: ["out/**/*.*", "out/routes/**/*.*", "out/public/**/*.*", "out/views/**/*.*"], | ||
port: 7000, | ||
}); | ||
}); | ||
|
||
// run nodemon on server file changes | ||
gulp.task('nodemon', function(cb) { | ||
var started = false; | ||
|
||
return nodemon({ | ||
script: 'out/www.js', | ||
watch: ['out/**/*.js'] | ||
}).on('start', function() { | ||
if (!started) { | ||
cb(); | ||
started = true; | ||
} | ||
}).on('restart', function onRestart() { | ||
setTimeout(function reload() { | ||
browserSync.reload({ | ||
stream: false | ||
}); | ||
}, 500); // browserSync reload delay | ||
}); | ||
}); | ||
|
||
// TypeScript build for /src folder | ||
var tsConfigSrc = tsb.create('src/tsconfig.json'); | ||
gulp.task('build', function() { | ||
return gulp.src('./src/**/*.ts') | ||
.pipe(tsConfigSrc()) | ||
.pipe(gulp.dest('./out')); | ||
}); | ||
|
||
// watch for any TypeScript or LESS file changes | ||
// if a file change is detected, run the TypeScript or LESS compile gulp tasks | ||
gulp.task('watch', function() { | ||
gulp.watch('src/**/*.ts', ['build']); | ||
// gulp.watch('src/styles/**/*.less', ['less']); | ||
}); | ||
|
||
gulp.task('buildAll', ['build', 'less']); | ||
gulp.task('default', ['browser-sync']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
{ | ||
"name": "node-express-typescript", | ||
"description": "node-express-typescript Sample Application (TypeScript)", | ||
"version": "0.0.0", | ||
"private": true, | ||
"scripts": { | ||
"start": "node ./out/www.js", | ||
"test": "mocha ./tests/out/test.js", | ||
"compile": "node ./node_modules/typescript/bin/tsc -p ./src", | ||
"compiletests": "node ./node_modules/typescript/bin/tsc -p ./tests", | ||
"antlr4ts": "antlr4ts -o ./src/models/dynamic_binding -visitor ./src/models/dynamic_binding/binding_grammar.g4" | ||
}, | ||
"dependencies": { | ||
"antlr4": "^4.7.1", | ||
"antlr4ts": "^0.4.1-alpha.0", | ||
"bignumber.js": "^4.0.1", | ||
"body-parser": "~1.13.2", | ||
"bpmn-moddle": "^0.14.0", | ||
"cookie-parser": "~1.3.5", | ||
"cors": "^2.8.3", | ||
"debug": "~2.2.0", | ||
"ejs": "^2.5.6", | ||
"express": "~4.13.1", | ||
"jade": "~1.11.0", | ||
"mongoose": "^4.13.7", | ||
"morgan": "~1.6.1", | ||
"serve-favicon": "~2.3.0", | ||
"solc": "^0.4.25", | ||
"web3": "^0.19.0", | ||
"web3-eth-abi": "^1.0.0-beta.52" | ||
}, | ||
"devDependencies": { | ||
"@types/antlr4": "^4.7.0", | ||
"@types/body-parser": "^1.16.1", | ||
"@types/cookie-parser": "^1.3.30", | ||
"@types/debug": "^0.0.29", | ||
"@types/express": "^4.0.35", | ||
"@types/gulp": "^4.0.2", | ||
"@types/gulp-less": "^0.0.30", | ||
"@types/gulp-mocha": "^0.0.30", | ||
"@types/gulp-nodemon": "^0.0.30", | ||
"@types/marked": "^0.0.28", | ||
"@types/mocha": "^2.2.40", | ||
"@types/morgan": "^1.7.32", | ||
"@types/node": "^7.0.10", | ||
"@types/power-assert": "^1.4.29", | ||
"@types/serve-favicon": "^2.2.28", | ||
"antlr4ts-cli": "^0.4.0-alpha.4", | ||
"browser-sync": "^2.18.8", | ||
"gulp": "^3.9.1", | ||
"gulp-less": "^3.3.0", | ||
"gulp-mocha": "^4.1.0", | ||
"gulp-nodemon": "^2.2.1", | ||
"gulp-tsb": "^2.0.3", | ||
"marked": "^0.3.6", | ||
"mocha": "^3.2.0", | ||
"nodemon": "^1.11.0", | ||
"typescript": "^2.6.2", | ||
"xml2js": "^0.4.19" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import * as express from 'express'; | ||
import * as logger from 'morgan'; | ||
import * as bodyParser from 'body-parser'; | ||
import * as cors from 'cors'; | ||
import * as mongoose from 'mongoose'; | ||
|
||
import * as path from 'path'; | ||
import models from './models/models.controller'; | ||
|
||
const app: express.Express = express(); | ||
|
||
// uncomment after placing your favicon in /public | ||
//app.use(favicon(__dirname + '/public/favicon.ico')); | ||
app.use(logger('dev')); | ||
app.use(bodyParser.json()); | ||
app.use(cors()); | ||
app.use(bodyParser.urlencoded({ extended: false })); | ||
|
||
app.use('/', models); | ||
|
||
// catch 404 and forward to error handler | ||
app.use((req, res, next) => { | ||
var err = new Error('Not Found'); | ||
err['status'] = 404; | ||
next(err); | ||
}); | ||
|
||
// error handlers | ||
|
||
// development error handler | ||
// will print stacktrace | ||
if (app.get('env') === 'development') { | ||
|
||
app.use((error: any, req, res, next) => { | ||
console.log(error); | ||
res.status(error['status'] || 500); | ||
res.render('error', { | ||
message: error.message, | ||
error | ||
}); | ||
}); | ||
} | ||
|
||
// production error handler | ||
// no stacktraces leaked to user | ||
app.use((error: any, req, res, next) => { | ||
res.status(error['status'] || 500); | ||
res.render('error', { | ||
message: error.message, | ||
error: {} | ||
}); | ||
return null; | ||
}); | ||
|
||
mongoose.Promise = global.Promise; | ||
mongoose.connect('mongodb://localhost:27017/caterpillarRepo', function(error){ | ||
if(error){ | ||
throw error; | ||
}else{ | ||
console.log('Conectado a MongoDB'); | ||
} | ||
}); | ||
|
||
export default app; |
12 changes: 12 additions & 0 deletions
12
v3.0/caterpillar-core/src/models/abstract/AbstractFactory.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
pragma solidity ^0.4.25; | ||
|
||
contract AbstractFactory { | ||
address internal worklist = address(0); | ||
|
||
function setWorklist(address _worklist) public { | ||
worklist = _worklist; | ||
} | ||
|
||
function newInstance(address parent, address globalFactory) public returns(address); | ||
function startInstanceExecution(address processAddress) public; | ||
} |
46 changes: 46 additions & 0 deletions
46
v3.0/caterpillar-core/src/models/abstract/AbstractProcess.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
pragma solidity ^0.4.25; | ||
|
||
import "AbstractRegistry"; | ||
|
||
|
||
contract AbstractProcess { | ||
address internal owner; | ||
address internal parent; | ||
address internal worklist; | ||
uint internal instanceIndex; | ||
address internal processRegistry; | ||
|
||
constructor(address _parent, address _worklist, address _processRegistry) public { | ||
owner = msg.sender; | ||
parent = _parent; | ||
worklist = _worklist; | ||
processRegistry = _processRegistry; | ||
} | ||
|
||
function setInstanceIndex(uint _instanceIndex) public { | ||
require(msg.sender == parent); | ||
instanceIndex = _instanceIndex; | ||
} | ||
|
||
function findParent() public view returns(address) { | ||
return parent; | ||
} | ||
|
||
function handleEvent(bytes32 code, bytes32 eventType, uint _instanceIndex, bool isInstanceCompleted) public; | ||
function killProcess() public; | ||
function startExecution() public; | ||
function broadcastSignal() public; | ||
|
||
function killProcess(uint processElementIndex, uint marking, uint startedActivities) internal returns(uint, uint); | ||
function broadcastSignal(uint tmpMarking, uint tmpStartedActivities, uint sourceChild) internal returns(uint, uint); | ||
|
||
function propagateEvent(bytes32 code, bytes32 eventType, uint tmpMarking, uint tmpStartedActivities, uint sourceChild) internal returns(uint, uint) { | ||
if (eventType == "Error" || eventType == "Terminate") | ||
(tmpMarking, tmpStartedActivities) = killProcess(0, tmpMarking, tmpStartedActivities); | ||
else if (eventType == "Signal") | ||
(tmpMarking, tmpStartedActivities) = broadcastSignal(tmpMarking, tmpStartedActivities, sourceChild); | ||
if (parent != 0) | ||
AbstractProcess(parent).handleEvent(code, eventType, instanceIndex, tmpMarking | tmpStartedActivities == 0); | ||
return (tmpMarking, tmpStartedActivities); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
v3.0/caterpillar-core/src/models/abstract/AbstractRegistry.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
pragma solidity ^0.4.25; | ||
|
||
contract AbstractRegistry { | ||
|
||
function registerFactory(bytes32 bundleId, address factory) public; | ||
|
||
function registerWorklist(bytes32 bundleId, address worklist) public; | ||
|
||
function allInstances() public returns(address[]); | ||
|
||
function newInstanceFor(uint nodeIndex, address parent) public returns(address); | ||
|
||
function newBundleInstanceFor(bytes32 bundleId, address parent) public returns(address); | ||
|
||
function bundleFor(address processInstance) public returns(bytes32); | ||
|
||
function worklistBundleFor(address worklist) public returns(bytes32); | ||
|
||
// Functions for Dynamic Bindings | ||
function bindingPolicyFor(address processInstance) public view returns(bytes32); | ||
|
||
function taskRoleMapFor(address processInstance) public view returns(bytes32); | ||
|
||
function relateProcessToPolicy(bytes32 bundleId, bytes32 _taskRole, bytes32 _policy) external; | ||
|
||
function canPerform(address actor, address processCase, uint taskIndex) external view returns(bool); | ||
} |
44 changes: 44 additions & 0 deletions
44
v3.0/caterpillar-core/src/models/abstract/AbstractWorklist.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
pragma solidity ^0.4.25; | ||
|
||
contract IRFunct { | ||
function findRuntimePolicy(address pCase) public view returns(address); | ||
function canPerform(address actor, address pCase, uint taskIndex) public view returns(bool); | ||
} | ||
|
||
contract AbstractWorklist { | ||
|
||
struct Workitem { | ||
uint elementIndex; | ||
address processInstanceAddr; | ||
} | ||
|
||
Workitem[] internal workitems; | ||
address internal runtimeRegistry; | ||
|
||
function updateRuntimeRegistry(address _runtimeRegistry) public { | ||
runtimeRegistry = _runtimeRegistry; | ||
} | ||
|
||
function workItemsFor(uint elementIndex, address processInstance) external view returns(uint) { | ||
uint reqIndex = 0; | ||
for (uint i = 0; i < workitems.length; i++) { | ||
if (workitems[i].elementIndex == elementIndex && workitems[i].processInstanceAddr == processInstance) | ||
reqIndex |= uint(1) << i; | ||
} | ||
return reqIndex; | ||
} | ||
|
||
function processInstanceFor(uint workitemId) public view returns(address) { | ||
require(workitemId < workitems.length); | ||
return workitems[workitemId].processInstanceAddr; | ||
} | ||
|
||
function elementIndexFor(uint workitemId) public view returns(uint) { | ||
require(workitemId < workitems.length); | ||
return workitems[workitemId].elementIndex; | ||
} | ||
|
||
function canPerform(address actor, address pCase, uint elementIndex) internal view returns(bool) { | ||
return IRFunct(IRFunct(runtimeRegistry).findRuntimePolicy(pCase)).canPerform(actor, pCase, elementIndex); | ||
} | ||
} |
Oops, something went wrong.