@aloma.io/integration-sdk 3.0.1-1 → 3.0.1-10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/builder/index.d.mts +1 -1
- package/build/builder/index.mjs +15 -11
- package/build/builder/runtime-context.d.mts +1 -1
- package/build/builder/runtime-context.mjs +10 -7
- package/build/builder/transform/index.mjs +18 -18
- package/build/cli.d.mts +1 -0
- package/build/cli.mjs +81 -2
- package/build/controller/index.mjs +5 -5
- package/build/index.d.mts +2 -2
- package/build/index.mjs +2 -2
- package/build/internal/dispatcher/index.cjs +41 -30
- package/build/internal/index.cjs +86 -71
- package/build/internal/util/jwe/cli.cjs +3 -3
- package/build/internal/util/jwe/index.cjs +10 -10
- package/build/internal/websocket/config.cjs +7 -7
- package/build/internal/websocket/connection/constants.cjs +3 -3
- package/build/internal/websocket/connection/index.cjs +9 -9
- package/build/internal/websocket/connection/registration.cjs +7 -7
- package/build/internal/websocket/index.cjs +3 -3
- package/build/internal/websocket/transport/durable.cjs +6 -6
- package/build/internal/websocket/transport/index.cjs +18 -18
- package/build/internal/websocket/transport/packet.cjs +2 -2
- package/build/internal/websocket/transport/processor.cjs +5 -5
- package/package.json +3 -2
- package/src/builder/index.mts +26 -19
- package/src/builder/runtime-context.mts +31 -21
- package/src/builder/transform/index.mts +24 -19
- package/src/cli.mts +107 -0
- package/src/controller/index.mts +13 -7
- package/src/index.mts +2 -2
- package/src/internal/dispatcher/index.cjs +61 -44
- package/src/internal/index.cjs +125 -84
- package/src/internal/util/jwe/cli.cjs +3 -3
- package/src/internal/util/jwe/index.cjs +21 -17
- package/src/internal/websocket/config.cjs +12 -8
- package/src/internal/websocket/connection/constants.cjs +3 -3
- package/src/internal/websocket/connection/index.cjs +11 -11
- package/src/internal/websocket/connection/registration.cjs +9 -9
- package/src/internal/websocket/index.cjs +6 -6
- package/src/internal/websocket/transport/durable.cjs +9 -9
- package/src/internal/websocket/transport/index.cjs +30 -26
- package/src/internal/websocket/transport/packet.cjs +4 -4
- package/src/internal/websocket/transport/processor.cjs +12 -9
- package/template/connector/Containerfile +18 -0
- package/template/connector/entrypoint.sh +5 -0
- package/template/connector/package.json +25 -0
- package/template/connector/src/controller/index.mts +12 -0
- package/template/connector/src/index.mts +6 -0
- package/template/connector/tsconfig.json +27 -0
- package/src/cli.js +0 -1
@@ -1,11 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const fetch = require(
|
4
|
-
const C = require(
|
5
|
-
const cuid = require(
|
6
|
-
const { DurableWebsocket } = require(
|
7
|
-
const WebSocket = require(
|
8
|
-
const { Packet, Callback } = require(
|
3
|
+
const fetch = require("node-fetch");
|
4
|
+
const C = require("../connection/constants.cjs");
|
5
|
+
const cuid = require("@paralleldrive/cuid2").init({ length: 32 });
|
6
|
+
const { DurableWebsocket } = require("./durable.cjs");
|
7
|
+
const WebSocket = require("ws");
|
8
|
+
const { Packet, Callback } = require("./packet.cjs");
|
9
9
|
const cleanInterval = 45 * 1000;
|
10
10
|
const pingInterval = 30 * 1000;
|
11
11
|
class Transport {
|
@@ -38,7 +38,7 @@ class Transport {
|
|
38
38
|
local.ws.send(JSON.stringify({ p: packets }));
|
39
39
|
}
|
40
40
|
catch (e) {
|
41
|
-
console.log(
|
41
|
+
console.log("could not send packets ", e);
|
42
42
|
packets.forEach((packet) => local.packets.unshift(packet));
|
43
43
|
}
|
44
44
|
}
|
@@ -48,20 +48,20 @@ class Transport {
|
|
48
48
|
return;
|
49
49
|
local.close();
|
50
50
|
this.running = true;
|
51
|
-
const ws = (local.ws = new WebSocket(config.wsUrl(), [
|
52
|
-
ws.on(
|
53
|
-
console.log(
|
51
|
+
const ws = (local.ws = new WebSocket(config.wsUrl(), ["connector"], C.augmentRequest({ headers: {} }, config)));
|
52
|
+
ws.on("open", () => {
|
53
|
+
console.log("websocket connected");
|
54
54
|
local.connected = true;
|
55
55
|
local.pinger = setInterval(() => ws.ping(() => null), pingInterval);
|
56
56
|
local.onConnect(local);
|
57
57
|
});
|
58
|
-
ws.on(
|
58
|
+
ws.on("message", (message) => {
|
59
59
|
setTimeout(() => local.onMessages(JSON.parse(message)), 0);
|
60
60
|
});
|
61
|
-
ws.on(
|
62
|
-
console.log(
|
61
|
+
ws.on("error", (message) => {
|
62
|
+
console.log("error:", message);
|
63
63
|
});
|
64
|
-
ws.on(
|
64
|
+
ws.on("close", (message) => {
|
65
65
|
local.connected = false;
|
66
66
|
clearInterval(local.pinger);
|
67
67
|
if (local.running)
|
@@ -92,7 +92,7 @@ class Transport {
|
|
92
92
|
this.callbacks[packet.cb()].cb(packet.args());
|
93
93
|
}
|
94
94
|
catch (e) {
|
95
|
-
console.log(
|
95
|
+
console.log("error processing packet", e, packet);
|
96
96
|
}
|
97
97
|
finally {
|
98
98
|
delete this.callbacks[packet.cb()];
|
@@ -117,12 +117,12 @@ class Transport {
|
|
117
117
|
if (!cb)
|
118
118
|
return;
|
119
119
|
if (cb.created < then) {
|
120
|
-
console.log(
|
120
|
+
console.log("callback timeout", key);
|
121
121
|
try {
|
122
|
-
cb.cb({ error:
|
122
|
+
cb.cb({ error: "timeout" });
|
123
123
|
}
|
124
124
|
catch (e) {
|
125
|
-
console.log(
|
125
|
+
console.log("error while callback", key, cb, e);
|
126
126
|
}
|
127
127
|
delete local.callbacks[key];
|
128
128
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const fetch = require(
|
4
|
-
const cuid = require(
|
3
|
+
const fetch = require("node-fetch");
|
4
|
+
const cuid = require("@paralleldrive/cuid2").init({ length: 32 });
|
5
5
|
class Packet {
|
6
6
|
constructor(data = {}) {
|
7
7
|
this.data = data;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const { Packet, Callback } = require(
|
3
|
+
const { Packet, Callback } = require("./packet.cjs");
|
4
4
|
class Processor {
|
5
5
|
constructor({ transport, processPacket }) {
|
6
6
|
var local = this;
|
@@ -33,24 +33,24 @@ class Processor {
|
|
33
33
|
callbacks[packet.cb()](packet.args());
|
34
34
|
}
|
35
35
|
catch (e) {
|
36
|
-
console.log(
|
36
|
+
console.log("error in callback", callbacks[packet.cb()], packet);
|
37
37
|
}
|
38
38
|
delete local.transport.callbacks[packet.cb()];
|
39
39
|
}
|
40
40
|
else if (packet.event()) {
|
41
|
-
console.log(
|
41
|
+
console.log("handle event packet", packet);
|
42
42
|
}
|
43
43
|
else {
|
44
44
|
try {
|
45
45
|
const result = await local._processPacket(packet);
|
46
46
|
const reply = local.transport.newPacket({});
|
47
|
-
reply.method(
|
47
|
+
reply.method("connector.reply");
|
48
48
|
reply.cb(original.cb());
|
49
49
|
reply.args({ ...result });
|
50
50
|
local.transport.send(reply);
|
51
51
|
}
|
52
52
|
catch (e) {
|
53
|
-
console.log(
|
53
|
+
console.log("error processing packet", e, packet);
|
54
54
|
}
|
55
55
|
}
|
56
56
|
}
|
package/package.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "@aloma.io/integration-sdk",
|
3
|
-
"version": "3.0.1-
|
3
|
+
"version": "3.0.1-10",
|
4
4
|
"description": "",
|
5
5
|
"author": "aloma.io",
|
6
6
|
"license": "Apache-2.0",
|
7
7
|
"type": "module",
|
8
8
|
"bin": {
|
9
|
-
"
|
9
|
+
"aloma": "./build/cli.mjs"
|
10
10
|
},
|
11
11
|
"scripts": {
|
12
12
|
"dev": "./node_modules/typescript/bin/tsc --watch",
|
@@ -27,6 +27,7 @@
|
|
27
27
|
"dependencies": {
|
28
28
|
"@paralleldrive/cuid2": "^2",
|
29
29
|
"@ts-ast-parser/core": "^0",
|
30
|
+
"commander": "^11",
|
30
31
|
"dotenv": "*",
|
31
32
|
"express": "^4",
|
32
33
|
"jose": "^4",
|
package/src/builder/index.mts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
import fs from
|
2
|
-
import parseTypes from
|
3
|
-
import RuntimeContext from
|
4
|
-
import {fileURLToPath} from
|
5
|
-
import path from
|
1
|
+
import fs from "node:fs";
|
2
|
+
import parseTypes from "./transform/index.mjs";
|
3
|
+
import RuntimeContext from "./runtime-context.mjs";
|
4
|
+
import { fileURLToPath } from "node:url";
|
5
|
+
import path from "node:path";
|
6
6
|
|
7
7
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
8
8
|
|
@@ -13,17 +13,19 @@ const notEmpty = (what, name) => {
|
|
13
13
|
};
|
14
14
|
|
15
15
|
export class Builder {
|
16
|
-
private data: any = {
|
16
|
+
private data: any = {
|
17
|
+
controller: "./build/controller/.controller-for-types.mts",
|
18
|
+
};
|
17
19
|
|
18
20
|
config(arg: any): Builder {
|
19
21
|
this.data.config = arg;
|
20
|
-
|
22
|
+
|
21
23
|
return this;
|
22
24
|
}
|
23
25
|
|
24
26
|
options(arg: any): Builder {
|
25
27
|
this.data.options = arg;
|
26
|
-
|
28
|
+
|
27
29
|
return this;
|
28
30
|
}
|
29
31
|
|
@@ -37,28 +39,33 @@ export class Builder {
|
|
37
39
|
await this.discoverTypes();
|
38
40
|
|
39
41
|
// @ts-ignore
|
40
|
-
const Controller = (
|
42
|
+
const Controller = (
|
43
|
+
await import(__dirname + "/../../../../../build/controller/index.mjs")
|
44
|
+
).default;
|
41
45
|
|
42
46
|
return new RuntimeContext(new Controller(), this.data);
|
43
47
|
}
|
44
48
|
|
45
|
-
private async parsePackageJson()
|
46
|
-
{
|
49
|
+
private async parsePackageJson() {
|
47
50
|
const data = this.data;
|
48
|
-
|
49
|
-
const packageJson = JSON.parse(
|
50
|
-
|
51
|
-
|
52
|
-
|
51
|
+
|
52
|
+
const packageJson = JSON.parse(
|
53
|
+
fs.readFileSync(__dirname + "/../../../../../package.json", {
|
54
|
+
encoding: "utf-8",
|
55
|
+
})
|
56
|
+
);
|
57
|
+
|
58
|
+
notEmpty((data.id = packageJson.connectorId), "id");
|
59
|
+
notEmpty((data.version = packageJson.version), "version");
|
53
60
|
}
|
54
61
|
|
55
62
|
private async discoverTypes() {
|
56
|
-
notEmpty(this.data.controller,
|
63
|
+
notEmpty(this.data.controller, "controller");
|
57
64
|
|
58
65
|
const content = fs.readFileSync(this.data.controller);
|
59
|
-
const {text, methods} = parseTypes(this.data.controller);
|
66
|
+
const { text, methods } = parseTypes(this.data.controller);
|
60
67
|
|
61
|
-
this.data.types
|
68
|
+
this.data.types = text;
|
62
69
|
this.data.methods = methods;
|
63
70
|
}
|
64
71
|
}
|
@@ -1,15 +1,16 @@
|
|
1
|
-
import {AbstractController} from
|
2
|
-
import {Connector} from
|
1
|
+
import { AbstractController } from "../controller/index.mjs";
|
2
|
+
import { Connector } from "../internal/index.cjs";
|
3
3
|
|
4
4
|
export default class RuntimeContext {
|
5
5
|
constructor(private controller: AbstractController, private data: any) {}
|
6
6
|
|
7
7
|
async start(): Promise<void> {
|
8
8
|
const controller = this.controller;
|
9
|
-
|
10
|
-
if (!(controller instanceof AbstractController))
|
11
|
-
|
12
|
-
|
9
|
+
|
10
|
+
if (!(controller instanceof AbstractController))
|
11
|
+
throw new Error("the controller needs to extend AbstractController");
|
12
|
+
const data: any = this.data;
|
13
|
+
|
13
14
|
const connector = new Connector({
|
14
15
|
id: data.id,
|
15
16
|
version: data.version,
|
@@ -19,7 +20,12 @@ export default class RuntimeContext {
|
|
19
20
|
const configuration = connector.configure().config(data.config || {});
|
20
21
|
|
21
22
|
const resolvers: any = {};
|
22
|
-
const methods: string[] = [
|
23
|
+
const methods: string[] = [
|
24
|
+
...data.methods,
|
25
|
+
"__endpoint",
|
26
|
+
"__configQuery",
|
27
|
+
"__default",
|
28
|
+
];
|
23
29
|
|
24
30
|
methods.forEach((method) => {
|
25
31
|
resolvers[method] = async (args) => {
|
@@ -28,29 +34,33 @@ export default class RuntimeContext {
|
|
28
34
|
return controller[method](args);
|
29
35
|
};
|
30
36
|
});
|
31
|
-
|
32
|
-
configuration
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
if (data.options?.endpoint?.enabled)
|
37
|
-
{
|
37
|
+
|
38
|
+
configuration.types(data.types).resolvers(resolvers);
|
39
|
+
|
40
|
+
if (data.options?.endpoint?.enabled) {
|
38
41
|
configuration.endpoint((arg) => controller.__endpoint(arg));
|
39
42
|
}
|
40
|
-
|
41
|
-
if (data.auth?.oauth)
|
42
|
-
{
|
43
|
+
|
44
|
+
if (data.auth?.oauth) {
|
43
45
|
configuration.oauth(data.auth?.oauth);
|
44
46
|
}
|
45
|
-
|
46
|
-
|
47
|
+
|
48
|
+
configuration.main(
|
49
|
+
async ({ newTask, updateTask, config, oauth, getClient }) => {
|
47
50
|
try {
|
48
51
|
await controller._doStop();
|
49
|
-
await controller._doStart(
|
52
|
+
await controller._doStart(
|
53
|
+
config,
|
54
|
+
oauth,
|
55
|
+
newTask,
|
56
|
+
updateTask,
|
57
|
+
getClient
|
58
|
+
);
|
50
59
|
} catch (e) {
|
51
60
|
console.log(e);
|
52
61
|
}
|
53
|
-
}
|
62
|
+
}
|
63
|
+
);
|
54
64
|
|
55
65
|
connector.run();
|
56
66
|
}
|
@@ -1,11 +1,11 @@
|
|
1
|
-
import {parseFromFiles} from
|
1
|
+
import { parseFromFiles } from "@ts-ast-parser/core";
|
2
2
|
|
3
3
|
const transform = (meta: any) => {
|
4
|
-
if (!meta?.length) throw new Error(
|
4
|
+
if (!meta?.length) throw new Error("metadata is empty");
|
5
5
|
meta = meta[0];
|
6
6
|
|
7
7
|
if (meta.getDeclarations()?.length !== 1) {
|
8
|
-
throw new Error(
|
8
|
+
throw new Error("connector file needs to export default class");
|
9
9
|
}
|
10
10
|
|
11
11
|
const methods = {};
|
@@ -15,9 +15,9 @@ const transform = (meta: any) => {
|
|
15
15
|
return !(
|
16
16
|
member.isStatic() ||
|
17
17
|
member.isInherited() ||
|
18
|
-
member.getKind() !==
|
19
|
-
member.getModifier() !==
|
20
|
-
member.getName().startsWith(
|
18
|
+
member.getKind() !== "Method" ||
|
19
|
+
member.getModifier() !== "public" ||
|
20
|
+
member.getName().startsWith("_")
|
21
21
|
);
|
22
22
|
});
|
23
23
|
|
@@ -29,15 +29,19 @@ const transform = (meta: any) => {
|
|
29
29
|
.getSignatures()
|
30
30
|
.map((sig: any) => {
|
31
31
|
const docs = sig.getJSDoc().serialize() || [];
|
32
|
-
const desc = docs.find(
|
32
|
+
const desc = docs.find(
|
33
|
+
(what: any) => what.kind === "description"
|
34
|
+
)?.value;
|
33
35
|
|
34
36
|
const paramDocs =
|
35
37
|
docs
|
36
|
-
.filter((what: any) => what.kind ===
|
38
|
+
.filter((what: any) => what.kind === "param")
|
37
39
|
.map((what: any) => {
|
38
|
-
return ` * @param {${what.value.type}} ${what.value.name} - ${
|
40
|
+
return ` * @param {${what.value.type}} ${what.value.name} - ${
|
41
|
+
what.value.description || ""
|
42
|
+
}`;
|
39
43
|
})
|
40
|
-
.join(
|
44
|
+
.join("\n") || " *";
|
41
45
|
|
42
46
|
const params = sig
|
43
47
|
.getParameters()
|
@@ -49,37 +53,38 @@ const transform = (meta: any) => {
|
|
49
53
|
const tmp = param
|
50
54
|
.getNamedElements()
|
51
55
|
.map((p) => {
|
52
|
-
const defaultVal =
|
56
|
+
const defaultVal =
|
57
|
+
p.default != null ? " = " + p.default : "";
|
53
58
|
|
54
59
|
return `${p.name}${defaultVal}`;
|
55
60
|
})
|
56
|
-
.join(
|
61
|
+
.join("; ");
|
57
62
|
return `{${tmp}}: ${param.getType().text}`;
|
58
63
|
case false:
|
59
64
|
return `${param.getName()}: ${param.getType().text}`;
|
60
65
|
}
|
61
66
|
})
|
62
|
-
.join(
|
67
|
+
.join(", ");
|
63
68
|
|
64
69
|
const retVal = sig
|
65
70
|
.getReturnType()
|
66
|
-
.type.text.replace(/^Promise</,
|
67
|
-
.replace(/>$/,
|
71
|
+
.type.text.replace(/^Promise</, "")
|
72
|
+
.replace(/>$/, "");
|
68
73
|
|
69
74
|
return `
|
70
75
|
/**
|
71
|
-
* ${desc ||
|
76
|
+
* ${desc || ""}
|
72
77
|
*
|
73
78
|
${paramDocs}
|
74
79
|
**/
|
75
80
|
declare function ${member.getName()}(${params}): ${retVal};
|
76
81
|
`;
|
77
82
|
})
|
78
|
-
.join(
|
83
|
+
.join("\n");
|
79
84
|
})
|
80
|
-
.join(
|
85
|
+
.join("");
|
81
86
|
|
82
|
-
return {text, methods: Object.keys(methods)};
|
87
|
+
return { text, methods: Object.keys(methods) };
|
83
88
|
};
|
84
89
|
|
85
90
|
export default (path: string) => {
|
package/src/cli.mts
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
|
3
|
+
import { Command } from "commander";
|
4
|
+
import fs from "node:fs";
|
5
|
+
import { fileURLToPath } from "node:url";
|
6
|
+
import path from "node:path";
|
7
|
+
import JWE from './internal/util/jwe/index.cjs'
|
8
|
+
import util from 'node:util';
|
9
|
+
import ChildProcess from 'node:child_process';
|
10
|
+
|
11
|
+
const exec = util.promisify(ChildProcess.exec);
|
12
|
+
|
13
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
14
|
+
|
15
|
+
const files = [
|
16
|
+
{ name: "index.mts", dir: "src/controller" },
|
17
|
+
{ name: "index.mts", dir: "src" },
|
18
|
+
{ name: "package.json", dir: "" },
|
19
|
+
{ name: "Containerfile", dir: "" },
|
20
|
+
{ name: "entrypoint.sh", dir: "" },
|
21
|
+
{ name: "tsconfig.json", dir: "" },
|
22
|
+
];
|
23
|
+
|
24
|
+
const extract = ({ target, name, connectorId }) => {
|
25
|
+
const source = `${__dirname}/../template/connector/`;
|
26
|
+
|
27
|
+
if (!fs.existsSync(source)) {
|
28
|
+
throw new Error(`source ${source} does not exist`);
|
29
|
+
}
|
30
|
+
|
31
|
+
files.forEach(({ name, dir }) => {
|
32
|
+
if (dir) {
|
33
|
+
fs.mkdirSync(`${target}/${dir}`, {recursive: true});
|
34
|
+
}
|
35
|
+
|
36
|
+
const content = fs.readFileSync(`${source}/${dir}/${name}`, {
|
37
|
+
encoding: "utf-8",
|
38
|
+
});
|
39
|
+
fs.writeFileSync(`${target}/${dir}/${name}`, content);
|
40
|
+
});
|
41
|
+
|
42
|
+
const content = JSON.parse(
|
43
|
+
fs.readFileSync(`${target}/package.json`, { encoding: "utf-8" })
|
44
|
+
);
|
45
|
+
|
46
|
+
content.name = name;
|
47
|
+
content.connectorId = connectorId;
|
48
|
+
|
49
|
+
fs.writeFileSync(`${target}/package.json`, JSON.stringify(content, null, 2));
|
50
|
+
fs.writeFileSync(`${target}/.gitignore`, `.DS_Store
|
51
|
+
node_modules
|
52
|
+
build
|
53
|
+
.env`);
|
54
|
+
};
|
55
|
+
|
56
|
+
const generateKeys = async ({target}) =>
|
57
|
+
{
|
58
|
+
const jwe = new JWE({});
|
59
|
+
await jwe.newPair();
|
60
|
+
|
61
|
+
const priv = await jwe.exportPrivateAsBase64();
|
62
|
+
const pub = await jwe.exportPublicAsBase64();
|
63
|
+
|
64
|
+
const content = `REGISTRATION_TOKEN=
|
65
|
+
PRIVATE_KEY=${priv}
|
66
|
+
PUBLIC_KEY=${pub}
|
67
|
+
`;
|
68
|
+
|
69
|
+
fs.writeFileSync(`${target}/.env`, content);
|
70
|
+
};
|
71
|
+
|
72
|
+
const program = new Command();
|
73
|
+
|
74
|
+
program
|
75
|
+
.name("npx @aloma.io/integration-sdk")
|
76
|
+
.description("aloma.io integration sdk")
|
77
|
+
.version("0.8.0")
|
78
|
+
.showHelpAfterError();
|
79
|
+
|
80
|
+
program
|
81
|
+
.command("create")
|
82
|
+
.description("Create a new connector project")
|
83
|
+
.argument("<name>", "name of the project")
|
84
|
+
.requiredOption("--connector-id <id>", "id of the connector")
|
85
|
+
.action(async (name, options) => {
|
86
|
+
name = name.replace(/[\/\.]/gi, "");
|
87
|
+
if (!name) throw new Error("name is empty");
|
88
|
+
|
89
|
+
const target = `${process.cwd()}/${name}`;
|
90
|
+
|
91
|
+
fs.mkdirSync(target);
|
92
|
+
|
93
|
+
extract({ ...options, target, name });
|
94
|
+
await generateKeys({target});
|
95
|
+
});
|
96
|
+
|
97
|
+
program
|
98
|
+
.command("build")
|
99
|
+
.description("Build the current connector project")
|
100
|
+
.action(async (str, options) => {
|
101
|
+
console.log('building');
|
102
|
+
const {stdout, stderr} = await exec(`rm -rf build; mkdir -p build/controller; cp ./src/controller/index.mts ./build/controller/.controller-for-types.mts; ./node_modules/typescript/bin/tsc`);
|
103
|
+
|
104
|
+
console.log(stdout, stderr);
|
105
|
+
});
|
106
|
+
|
107
|
+
program.parse();
|
package/src/controller/index.mts
CHANGED
@@ -11,23 +11,23 @@ export abstract class AbstractController {
|
|
11
11
|
}
|
12
12
|
|
13
13
|
protected fallback(arg: any): Promise<any> {
|
14
|
-
throw new Error(
|
14
|
+
throw new Error("method not found");
|
15
15
|
}
|
16
16
|
|
17
17
|
protected endpoint(arg: any): Promise<any> {
|
18
|
-
throw new Error(
|
18
|
+
throw new Error("method not found");
|
19
19
|
}
|
20
20
|
|
21
21
|
protected async newTask(name: string, data: any): Promise<string> {
|
22
|
-
throw new Error(
|
22
|
+
throw new Error("not implemented");
|
23
23
|
}
|
24
24
|
|
25
|
-
protected getClient({baseUrl}: {baseUrl: string}): Promise<any> {
|
26
|
-
throw new Error(
|
25
|
+
protected getClient({ baseUrl }: { baseUrl: string }): Promise<any> {
|
26
|
+
throw new Error("not implemented");
|
27
27
|
}
|
28
28
|
|
29
29
|
protected async updateTask(name: string, data: any): Promise<string> {
|
30
|
-
throw new Error(
|
30
|
+
throw new Error("not implemented");
|
31
31
|
}
|
32
32
|
|
33
33
|
async __endpoint(arg: any): Promise<any | null> {
|
@@ -42,7 +42,13 @@ export abstract class AbstractController {
|
|
42
42
|
return this.fallback(arg);
|
43
43
|
}
|
44
44
|
|
45
|
-
async _doStart(
|
45
|
+
async _doStart(
|
46
|
+
config: any,
|
47
|
+
client: any,
|
48
|
+
newTask: any,
|
49
|
+
updateTask: any,
|
50
|
+
getClient: any
|
51
|
+
): Promise<void> {
|
46
52
|
this.config = config;
|
47
53
|
this.client = client;
|
48
54
|
this.newTask = newTask;
|
package/src/index.mts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export * from
|
2
|
-
export * from
|
1
|
+
export * from "./builder/index.mjs";
|
2
|
+
export * from "./controller/index.mjs";
|