Skip to content

Commit 3c50803

Browse files
committed
initial push
0 parents  commit 3c50803

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+2351
-0
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package-lock.json
2+
node_modules
3+
logs
4+
dist
5+
lib
6+
browser

.prettierrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"printWidth": 120,
3+
"trailingComma": "all",
4+
"singleQuote": true
5+
}

.vscode/tasks.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
// See https://go.microsoft.com/fwlink/?LinkId=733558
3+
// for the documentation about the tasks.json format
4+
"version": "2.0.0",
5+
"presentation": {
6+
"echo": false,
7+
"reveal": "always",
8+
"focus": false,
9+
"panel": "dedicated",
10+
"showReuseMessage": true
11+
},
12+
"tasks": [
13+
{
14+
"label": "tsc-watch",
15+
"type": "typescript",
16+
"tsconfig": "tsconfig.json",
17+
"option": "watch",
18+
"problemMatcher": [
19+
"$tsc-watch"
20+
]
21+
}
22+
]
23+
}

gulpfile.js

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
var fs = require('fs');
2+
var gulp = require('gulp');
3+
var shell = require('gulp-shell');
4+
var merge = require('merge-stream');
5+
var browserify = require('browserify');
6+
const tsify = require('tsify');
7+
8+
9+
gulp.task('tsc', shell.task([
10+
'echo "tsc for nodejs"',
11+
'tsc -p tsconfig.json',
12+
'echo "tsc for browser"',
13+
'tsc -p tsconfig-cjs.json'
14+
]));
15+
16+
gulp.task('browserify', function () {
17+
var bfi = browserify({
18+
entries: ['./src/index.ts'],
19+
debug: true,
20+
basedir: '.'
21+
})
22+
.plugin(tsify, { noImplicitAny: false })
23+
.bundle()
24+
25+
.pipe(fs.createWriteStream('./lib/openflow-api.js'));
26+
return bfi;
27+
});
28+
29+
gulp.task("watch", function () {
30+
var web = gulp.watch([].concat("./src/**/*.ts"), gulp.series('tsc', 'browserify'));
31+
return web;
32+
});
33+
34+
35+
gulp.task('default', gulp.series('tsc', 'browserify', 'watch'));

package.json

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "openflow-api",
3+
"version": "1.0.0",
4+
"description": "",
5+
"files": [
6+
"lib/**/*"
7+
],
8+
"main": "./lib/browser/index.js",
9+
"module": "./lib/node/index.js",
10+
"types": "./lib/browser/index.d.ts",
11+
"typings": "./lib/browser/index.d.ts",
12+
"keywords": [],
13+
"author": "OpenRPA / Allan Zimmermann",
14+
"license": "MPL-2.0",
15+
"scripts": {
16+
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
17+
"lint": "tslint -p tsconfig.json",
18+
"build": "tsc -p tsconfig.json & tsc -p tsconfig-cjs.json"
19+
},
20+
"dependencies": {
21+
"envfile": "^6.9.0",
22+
"tsify": "^4.0.2",
23+
"universal-websocket-client": "^1.0.2"
24+
},
25+
"devDependencies": {
26+
"@types/node": "^14.0.19",
27+
"browserify": "^16.5.1",
28+
"gulp": "^4.0.2",
29+
"gulp-shell": "^0.8.0",
30+
"merge-stream": "^2.0.0",
31+
"prettier": "^2.0.5",
32+
"tslint": "^6.1.2",
33+
"tslint-config-prettier": "^1.18.0",
34+
"typescript": "^3.9.6"
35+
}
36+
}

src/Config.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export class Config {
2+
public static amqpReplyExpiration: number = 10000; // 10 seconds
3+
}
4+

src/Message/AggregateMessage.ts

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export class AggregateMessage {
2+
public error: string;
3+
public jwt: string;
4+
5+
public aggregates: object[];
6+
public collectionname: string;
7+
public result: any[];
8+
static assign(o: any): AggregateMessage {
9+
if (typeof o === 'string' || o instanceof String) {
10+
return Object.assign(new AggregateMessage(), JSON.parse(o.toString()));
11+
}
12+
return Object.assign(new AggregateMessage(), o);
13+
}
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
export class CreateWorkflowInstanceMessage {
2+
public error: string;
3+
public jwt: any;
4+
5+
public correlationId: string;
6+
public newinstanceid: string;
7+
public state: string;
8+
public queue: string;
9+
public workflowid: string;
10+
public resultqueue: string;
11+
public targetid: string;
12+
public parentid: string;
13+
public initialrun: boolean;
14+
15+
public payload: any;
16+
static assign<T>(o: any): CreateWorkflowInstanceMessage {
17+
if (typeof o === 'string' || o instanceof String) {
18+
return Object.assign(new CreateWorkflowInstanceMessage(), JSON.parse(o.toString()));
19+
}
20+
return Object.assign(new CreateWorkflowInstanceMessage(), o);
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export class DeleteNoderedInstanceMessage {
2+
public error: string;
3+
public jwt: any;
4+
public name: string;
5+
public _id: string;
6+
static assign(o: any): DeleteNoderedInstanceMessage {
7+
if (typeof o === "string" || o instanceof String) {
8+
return Object.assign(new DeleteNoderedInstanceMessage(), JSON.parse(o.toString()));
9+
}
10+
return Object.assign(new DeleteNoderedInstanceMessage(), o);
11+
}
12+
}
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export class DeleteNoderedPodMessage {
2+
public error: string;
3+
public jwt: any;
4+
public name: string;
5+
public _id: string;
6+
static assign(o: any): DeleteNoderedPodMessage {
7+
if (typeof o === "string" || o instanceof String) {
8+
return Object.assign(new DeleteNoderedPodMessage(), JSON.parse(o.toString()));
9+
}
10+
return Object.assign(new DeleteNoderedPodMessage(), o);
11+
}
12+
}

src/Message/DeleteOneMessage.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export class DeleteOneMessage {
2+
public error: string;
3+
public jwt: string;
4+
5+
public _id: string;
6+
public collectionname: string;
7+
static assign(o: any): DeleteOneMessage {
8+
if (typeof o === 'string' || o instanceof String) {
9+
return Object.assign(new DeleteOneMessage(), JSON.parse(o.toString()));
10+
}
11+
return Object.assign(new DeleteOneMessage(), o);
12+
}
13+
}

src/Message/DropCollectionMessage.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export class DropCollectionMessage {
2+
public error: string;
3+
public jwt: string;
4+
public collectionname: string;
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export class EnsureNoderedInstanceMessage {
2+
public error: string;
3+
public jwt: any;
4+
public name: string;
5+
public _id: string;
6+
static assign(o: any): EnsureNoderedInstanceMessage {
7+
if (typeof o === "string" || o instanceof String) {
8+
return Object.assign(new EnsureNoderedInstanceMessage(), JSON.parse(o.toString()));
9+
}
10+
return Object.assign(new EnsureNoderedInstanceMessage(), o);
11+
}
12+
}
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Billing } from "../stripe/Billing";
2+
import { stripe_customer } from "../stripe/stripe_customer";
3+
4+
export class EnsureStripeCustomerMessage implements IReplyMessage {
5+
public error: string;
6+
public jwt: string;
7+
8+
public userid: string;
9+
public billing: Billing;
10+
public customer: stripe_customer;
11+
static assign(o: any): EnsureStripeCustomerMessage {
12+
if (typeof o === "string" || o instanceof String) {
13+
return Object.assign(new EnsureStripeCustomerMessage(), JSON.parse(o.toString()));
14+
}
15+
return Object.assign(new EnsureStripeCustomerMessage(), o);
16+
}
17+
}

src/Message/GetFileMessage.ts

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export class GetFileMessage {
2+
public error: string;
3+
public jwt: string;
4+
5+
public filename: string;
6+
public mimeType: string;
7+
public id: string;
8+
public metadata: any;
9+
public file: string;
10+
static assign(o: any): GetFileMessage {
11+
if (typeof o === 'string' || o instanceof String) {
12+
return Object.assign(new GetFileMessage(), JSON.parse(o.toString()));
13+
}
14+
return Object.assign(new GetFileMessage(), o);
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export class GetNoderedInstanceLogMessage {
2+
public error: string;
3+
public jwt: any;
4+
public name: string;
5+
public instancename: string;
6+
public _id: string;
7+
public result: string;
8+
static assign(o: any): GetNoderedInstanceLogMessage {
9+
if (typeof o === "string" || o instanceof String) {
10+
return Object.assign(new GetNoderedInstanceLogMessage(), JSON.parse(o.toString()));
11+
}
12+
return Object.assign(new GetNoderedInstanceLogMessage(), o);
13+
}
14+
}
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
export class GetNoderedInstanceMessage {
3+
public error: string;
4+
public jwt: any;
5+
public name: string;
6+
public _id: string;
7+
public result: any;
8+
public results: any[];
9+
10+
static assign(o: any): GetNoderedInstanceMessage {
11+
if (typeof o === 'string' || o instanceof String) {
12+
return Object.assign(new GetNoderedInstanceMessage(), JSON.parse(o.toString()));
13+
}
14+
return Object.assign(new GetNoderedInstanceMessage(), o);
15+
}
16+
}

src/Message/IReplyMessage.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
interface IReplyMessage {
2+
error: string;
3+
}

src/Message/InsertOneMessage.ts

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
export class InsertOneMessage {
2+
public error: string;
3+
public jwt: string;
4+
5+
// w: 1 - Requests acknowledgment that the write operation has propagated
6+
// w: 0 - Requests no acknowledgment of the write operation
7+
// w: 2 would require acknowledgment from the primary and one of the secondaries
8+
// w: 3 would require acknowledgment from the primary and both secondaries
9+
public w: number;
10+
// true, requests acknowledgment that the mongod instances have written to the on-disk journal
11+
public j: boolean;
12+
public item: any;
13+
public collectionname: string;
14+
public result: any;
15+
static assign(o: any): InsertOneMessage {
16+
if (typeof o === 'string' || o instanceof String) {
17+
return Object.assign(new InsertOneMessage(), JSON.parse(o.toString()));
18+
}
19+
return Object.assign(new InsertOneMessage(), o);
20+
}
21+
}
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
export class InsertOrUpdateOneMessage {
2+
public error: string;
3+
public jwt: string;
4+
5+
// w: 1 - Requests acknowledgment that the write operation has propagated
6+
// w: 0 - Requests no acknowledgment of the write operation
7+
// w: 2 would require acknowledgment from the primary and one of the secondaries
8+
// w: 3 would require acknowledgment from the primary and both secondaries
9+
public w: number;
10+
// true, requests acknowledgment that the mongod instances have written to the on-disk journal
11+
public j: boolean;
12+
public item: object;
13+
public collectionname: string;
14+
public uniqeness: string;
15+
public result: any;
16+
static assign(o: any): InsertOrUpdateOneMessage {
17+
if (typeof o === 'string' || o instanceof String) {
18+
return Object.assign(new InsertOrUpdateOneMessage(), JSON.parse(o.toString()));
19+
}
20+
return Object.assign(new InsertOrUpdateOneMessage(), o);
21+
}
22+
}

src/Message/ListCollectionsMessage.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export class ListCollectionsMessage {
2+
public error: string;
3+
public jwt: string;
4+
public result: any;
5+
}

src/Message/MapReduceMessage.ts

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
export declare function emit(k: any, v: any): void;
2+
export type mapFunc = () => void;
3+
export type reduceFunc = (key: string, values: any[]) => any;
4+
export type finalizeFunc = (key: string, value: any) => any;
5+
6+
export class MapReduceMessage<T> {
7+
public error: string;
8+
public jwt: string;
9+
10+
public collectionname: string;
11+
public result: T[];
12+
public scope: any;
13+
14+
constructor(
15+
public map: mapFunc,
16+
public reduce: reduceFunc,
17+
public finalize: finalizeFunc,
18+
public query: any,
19+
public out: string | any,
20+
) { }
21+
static assign<T>(o: any): MapReduceMessage<T> {
22+
if (typeof o === 'string' || o instanceof String) {
23+
return Object.assign(new MapReduceMessage(null, null, null, null, null), JSON.parse(o.toString()));
24+
}
25+
return Object.assign(new MapReduceMessage(null, null, null, null, null), o);
26+
}
27+
}

src/Message/QueryMessage.ts

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
export class QueryMessage {
2+
public error: string;
3+
public jwt: string;
4+
5+
public query: any;
6+
public projection: object;
7+
public top: number;
8+
public skip: number;
9+
public orderby: object | string;
10+
public collectionname: string;
11+
public result: any[];
12+
public queryas: string;
13+
static assign(o: any): QueryMessage {
14+
if (typeof o === 'string' || o instanceof String) {
15+
return Object.assign(new QueryMessage(), JSON.parse(o.toString()));
16+
}
17+
return Object.assign(new QueryMessage(), o);
18+
}
19+
}

0 commit comments

Comments
 (0)