@mochabug/adaptkit 1.0.0-rc.5 → 1.0.0-rc.51
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/README.md +50 -45
- package/assets/build.js +1 -1
- package/assets/configurator.main.tsx +8 -0
- package/assets/configurator_browser_none.main.ts +30 -0
- package/assets/configurator_browser_none.ssg.ts +64 -0
- package/assets/configurator_none.ts +14 -103
- package/assets/configurator_react.tsx +8 -8
- package/assets/executor.html +1 -1
- package/assets/executor.main.tsx +8 -0
- package/assets/executor_action.ts +4 -8
- package/assets/{executor_cron_trigger.ts → executor_action_cron.ts} +4 -8
- package/assets/executor_browser_none.main.ts +25 -0
- package/assets/executor_browser_none.ssg.ts +42 -0
- package/assets/executor_browser_none.ts +15 -83
- package/assets/executor_browser_none_cron.ts +55 -0
- package/assets/executor_browser_react.tsx +9 -13
- package/assets/executor_browser_react_cron.tsx +55 -0
- package/assets/{executor_external_trigger.ts → executor_external.ts} +8 -12
- package/assets/executor_external_cron.ts +45 -0
- package/assets/tsconf.json +1 -2
- package/bin/add.d.ts.map +1 -1
- package/bin/genproto/buf/validate/validate_pb.d.ts +1245 -547
- package/bin/genproto/buf/validate/validate_pb.d.ts.map +1 -1
- package/bin/genproto/google/api/annotations_pb.d.ts +1 -1
- package/bin/genproto/google/api/client_pb.d.ts +46 -16
- package/bin/genproto/google/api/client_pb.d.ts.map +1 -1
- package/bin/genproto/google/api/http_pb.d.ts +10 -4
- package/bin/genproto/google/api/http_pb.d.ts.map +1 -1
- package/bin/genproto/google/api/launch_stage_pb.d.ts +1 -1
- package/bin/genproto/mochabugapis/adapt/graph/exchange_pb.d.ts +4 -2
- package/bin/genproto/mochabugapis/adapt/graph/exchange_pb.d.ts.map +1 -1
- package/bin/genproto/mochabugapis/adapt/graph/jtd_schema_pb.d.ts +192 -16
- package/bin/genproto/mochabugapis/adapt/graph/jtd_schema_pb.d.ts.map +1 -1
- package/bin/genproto/mochabugapis/adapt/graph/receiver_pb.d.ts +4 -2
- package/bin/genproto/mochabugapis/adapt/graph/receiver_pb.d.ts.map +1 -1
- package/bin/genproto/mochabugapis/adapt/graph/signal_binding_pb.d.ts +309 -53
- package/bin/genproto/mochabugapis/adapt/graph/signal_binding_pb.d.ts.map +1 -1
- package/bin/genproto/mochabugapis/adapt/graph/signal_data_pb.d.ts +198 -0
- package/bin/genproto/mochabugapis/adapt/graph/signal_data_pb.d.ts.map +1 -0
- package/bin/genproto/mochabugapis/adapt/graph/signal_descriptor_pb.d.ts +101 -27
- package/bin/genproto/mochabugapis/adapt/graph/signal_descriptor_pb.d.ts.map +1 -1
- package/bin/genproto/mochabugapis/adapt/graph/signal_format_pb.d.ts +305 -0
- package/bin/genproto/mochabugapis/adapt/graph/signal_format_pb.d.ts.map +1 -0
- package/bin/genproto/mochabugapis/adapt/graph/transceiver_pb.d.ts +16 -2
- package/bin/genproto/mochabugapis/adapt/graph/transceiver_pb.d.ts.map +1 -1
- package/bin/genproto/mochabugapis/adapt/graph/transmitter_pb.d.ts +53 -8
- package/bin/genproto/mochabugapis/adapt/graph/transmitter_pb.d.ts.map +1 -1
- package/bin/genproto/mochabugapis/adapt/graph/user_defined_exchange_options_pb.d.ts +353 -0
- package/bin/genproto/mochabugapis/adapt/graph/user_defined_exchange_options_pb.d.ts.map +1 -0
- package/bin/genproto/mochabugapis/adapt/graph/{vertex_config_pb.d.ts → vertex_metadata_pb.d.ts} +28 -23
- package/bin/genproto/mochabugapis/adapt/graph/vertex_metadata_pb.d.ts.map +1 -0
- package/bin/genproto/mochabugapis/adapt/plugins/v1/compound_services_pb.d.ts +347 -0
- package/bin/genproto/mochabugapis/adapt/plugins/v1/compound_services_pb.d.ts.map +1 -0
- package/bin/genproto/mochabugapis/adapt/plugins/v1/file_pb.d.ts +4 -2
- package/bin/genproto/mochabugapis/adapt/plugins/v1/file_pb.d.ts.map +1 -1
- package/bin/genproto/mochabugapis/adapt/plugins/v1/http_proxy_service_pb.d.ts +1282 -0
- package/bin/genproto/mochabugapis/adapt/plugins/v1/http_proxy_service_pb.d.ts.map +1 -0
- package/bin/genproto/mochabugapis/adapt/plugins/v1/manifest_pb.d.ts +188 -23
- package/bin/genproto/mochabugapis/adapt/plugins/v1/manifest_pb.d.ts.map +1 -1
- package/bin/genproto/mochabugapis/adapt/plugins/v1/oauth2_service_pb.d.ts +129 -39
- package/bin/genproto/mochabugapis/adapt/plugins/v1/oauth2_service_pb.d.ts.map +1 -1
- package/bin/genproto/mochabugapis/adapt/plugins/v1/plugins_pb.d.ts +50 -6
- package/bin/genproto/mochabugapis/adapt/plugins/v1/plugins_pb.d.ts.map +1 -1
- package/bin/genproto/mochabugapis/adapt/plugins/v1/service_definition_pb.d.ts +145 -20
- package/bin/genproto/mochabugapis/adapt/plugins/v1/service_definition_pb.d.ts.map +1 -1
- package/bin/genproto/mochabugapis/adapt/plugins/v1/service_settings_pb.d.ts +539 -0
- package/bin/genproto/mochabugapis/adapt/plugins/v1/service_settings_pb.d.ts.map +1 -0
- package/bin/genproto/mochabugapis/adapt/plugins/v1/variable_service_pb.d.ts +134 -4
- package/bin/genproto/mochabugapis/adapt/plugins/v1/variable_service_pb.d.ts.map +1 -1
- package/bin/genproto/mochabugapis/adapt/plugins/v1/vertex_pb.d.ts +92 -55
- package/bin/genproto/mochabugapis/adapt/plugins/v1/vertex_pb.d.ts.map +1 -1
- package/bin/index.d.ts +5 -0
- package/bin/index.d.ts.map +1 -1
- package/bin/index.js +709 -652
- package/bin/index.js.map +4 -4
- package/bin/init.d.ts.map +1 -1
- package/bin/oauth2.d.ts +1 -1
- package/bin/oauth2.d.ts.map +1 -1
- package/bin/publish.d.ts +4 -0
- package/bin/publish.d.ts.map +1 -1
- package/bin/utils.d.ts +4 -4
- package/bin/utils.d.ts.map +1 -1
- package/bin/vertices.d.ts +2 -2
- package/bin/vertices.d.ts.map +1 -1
- package/package.json +23 -18
- package/assets/license.md +0 -15
- package/bin/genproto/mochabugapis/adapt/graph/vertex_config_pb.d.ts.map +0 -1
- package/bin/genproto/mochabugapis/adapt/plugins/v1/oneof_service_pb.d.ts +0 -92
- package/bin/genproto/mochabugapis/adapt/plugins/v1/oneof_service_pb.d.ts.map +0 -1
- package/bin/genproto/mochabugapis/adapt/plugins/v1/service_binding_pb.d.ts +0 -134
- package/bin/genproto/mochabugapis/adapt/plugins/v1/service_binding_pb.d.ts.map +0 -1
- package/bin/genproto/mochabugapis/adapt/plugins/v1/tls_service_pb.d.ts +0 -159
- package/bin/genproto/mochabugapis/adapt/plugins/v1/tls_service_pb.d.ts.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from
|
|
2
|
+
ConnectError,
|
|
3
|
+
mapConnectErrorToHttpStatus,
|
|
4
|
+
} from "@mochabug/adapt-sdk/api";
|
|
5
5
|
import {
|
|
6
6
|
ExternalExecutorRouter,
|
|
7
7
|
InternalExecutorRouter
|
|
8
|
-
} from '@mochabug/adapt-
|
|
8
|
+
} from '@mochabug/adapt-sdk/router';
|
|
9
9
|
|
|
10
10
|
export default {
|
|
11
11
|
external: new ExternalExecutorRouter()
|
|
@@ -13,8 +13,8 @@ export default {
|
|
|
13
13
|
.useBearerAuthorization(['/api'])
|
|
14
14
|
.useErrorHandling(async (e) => {
|
|
15
15
|
console.error(e);
|
|
16
|
-
if (e instanceof
|
|
17
|
-
return new Response(null, { status:
|
|
16
|
+
if (e instanceof ConnectError) {
|
|
17
|
+
return new Response(null, { status: mapConnectErrorToHttpStatus(e) });
|
|
18
18
|
}
|
|
19
19
|
return new Response(null, {
|
|
20
20
|
status: 500,
|
|
@@ -23,14 +23,15 @@ export default {
|
|
|
23
23
|
})
|
|
24
24
|
.add('POST', '/api/done', async (req, api, _route, ctx) => {
|
|
25
25
|
const sapi = api.getSessionApi(req.headers.get('Authorization')!);
|
|
26
|
-
ctx.waitUntil(sapi.
|
|
26
|
+
ctx.waitUntil(sapi.send('output', {}));
|
|
27
27
|
return new Response();
|
|
28
28
|
})
|
|
29
|
-
.add('GET', '{
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
.add('GET', '{/*any}', async (_, api) => {
|
|
30
|
+
const res = await api.readFile(
|
|
31
|
+
'browser/___VERTEX_NAME___/executor.html'
|
|
32
|
+
);
|
|
33
|
+
return new Response(res.content, {
|
|
34
|
+
headers: { 'Content-Type': 'text/html; charset=utf-8' }
|
|
34
35
|
});
|
|
35
36
|
}),
|
|
36
37
|
internal: new InternalExecutorRouter()
|
|
@@ -42,77 +43,8 @@ export default {
|
|
|
42
43
|
console.log('Stop has been called');
|
|
43
44
|
console.log(stop);
|
|
44
45
|
})
|
|
45
|
-
.
|
|
46
|
-
console.log(`
|
|
47
|
-
console.log(res);
|
|
48
|
-
})
|
|
49
|
-
.onProcedure(async (res, _api, name) => {
|
|
50
|
-
console.log(`Procedure ${name} has been called`);
|
|
46
|
+
.onExchange(async (res, _api, name) => {
|
|
47
|
+
console.log(`Exchange ${name} has been called`);
|
|
51
48
|
console.log(res);
|
|
52
49
|
})
|
|
53
50
|
};
|
|
54
|
-
|
|
55
|
-
const helloWorld = `
|
|
56
|
-
<html>
|
|
57
|
-
<head>
|
|
58
|
-
<style>
|
|
59
|
-
@import url('https://fonts.googleapis.com/css2?family=Orbitron&display=swap');
|
|
60
|
-
@keyframes glow {
|
|
61
|
-
0% { text-shadow: 0 0 5px #0f0, 0 0 10px #0f0, 0 0 15px #0f0, 0 0 20px #0f0; }
|
|
62
|
-
100% { text-shadow: 0 0 10px #0f0, 0 0 20px #0f0, 0 0 30px #0f0, 0 0 40px #0f0; }
|
|
63
|
-
}
|
|
64
|
-
body {
|
|
65
|
-
background-color: #000;
|
|
66
|
-
color: #0f0;
|
|
67
|
-
font-family: 'Orbitron', sans-serif;
|
|
68
|
-
text-align: center;
|
|
69
|
-
overflow: hidden;
|
|
70
|
-
margin: 0;
|
|
71
|
-
padding: 0;
|
|
72
|
-
}
|
|
73
|
-
button {
|
|
74
|
-
position: absolute;
|
|
75
|
-
top: 50%;
|
|
76
|
-
left: 50%;
|
|
77
|
-
transform: translate(-50%, -50%);
|
|
78
|
-
background-color: #0f0;
|
|
79
|
-
border: none;
|
|
80
|
-
color: black;
|
|
81
|
-
padding: 15px 32px;
|
|
82
|
-
text-align: center;
|
|
83
|
-
text-decoration: none;
|
|
84
|
-
display: inline-block;
|
|
85
|
-
font-size: 20px;
|
|
86
|
-
margin: 4px 2px;
|
|
87
|
-
cursor: pointer;
|
|
88
|
-
transition-duration: 0.4s;
|
|
89
|
-
animation: glow 2s infinite alternate;
|
|
90
|
-
font-family: 'Orbitron', sans-serif;
|
|
91
|
-
border-radius: 15px;
|
|
92
|
-
transform: rotate(-10deg) skew(10deg, 10deg);
|
|
93
|
-
}
|
|
94
|
-
</style>
|
|
95
|
-
</head>
|
|
96
|
-
<body>
|
|
97
|
-
<button id="doneButton">Done</button>
|
|
98
|
-
<script>
|
|
99
|
-
document.getElementById('doneButton').addEventListener('click', function() {
|
|
100
|
-
const hash = window.location.hash.substring(1).trim();
|
|
101
|
-
const token = decodeURIComponent(hash);
|
|
102
|
-
fetch('/api/done', {
|
|
103
|
-
method: 'POST',
|
|
104
|
-
headers: {
|
|
105
|
-
'Authorization': 'Bearer ' + token
|
|
106
|
-
}
|
|
107
|
-
})
|
|
108
|
-
.then(data => {
|
|
109
|
-
this.innerText = 'Done';
|
|
110
|
-
})
|
|
111
|
-
.catch(error => {
|
|
112
|
-
console.error('Error:', error);
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
</script>
|
|
116
|
-
</body>
|
|
117
|
-
</html>
|
|
118
|
-
`;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConnectError,
|
|
3
|
+
mapConnectErrorToHttpStatus,
|
|
4
|
+
} from "@mochabug/adapt-sdk/api";
|
|
5
|
+
import {
|
|
6
|
+
ExternalExecutorRouter,
|
|
7
|
+
CronExecutorRouter
|
|
8
|
+
} from '@mochabug/adapt-sdk/router';
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
external: new ExternalExecutorRouter()
|
|
12
|
+
.useRequestLogging()
|
|
13
|
+
.useBearerAuthorization(['/api'])
|
|
14
|
+
.useErrorHandling(async (e) => {
|
|
15
|
+
console.error(e);
|
|
16
|
+
if (e instanceof ConnectError) {
|
|
17
|
+
return new Response(null, { status: mapConnectErrorToHttpStatus(e) });
|
|
18
|
+
}
|
|
19
|
+
return new Response(null, {
|
|
20
|
+
status: 500,
|
|
21
|
+
statusText: 'Internal server error'
|
|
22
|
+
});
|
|
23
|
+
})
|
|
24
|
+
.add('POST', '/api/done', async (req, api, _route, ctx) => {
|
|
25
|
+
const sapi = api.getSessionApi(req.headers.get('Authorization')!);
|
|
26
|
+
ctx.waitUntil(sapi.send('output', {}));
|
|
27
|
+
return new Response();
|
|
28
|
+
})
|
|
29
|
+
.add('GET', '{/*any}', async (_, api) => {
|
|
30
|
+
const res = await api.readFile(
|
|
31
|
+
'browser/___VERTEX_NAME___/executor.html'
|
|
32
|
+
);
|
|
33
|
+
return new Response(res.content, {
|
|
34
|
+
headers: { 'Content-Type': 'text/html; charset=utf-8' }
|
|
35
|
+
});
|
|
36
|
+
}),
|
|
37
|
+
internal: new CronExecutorRouter()
|
|
38
|
+
.onStart(async (start, _api) => {
|
|
39
|
+
console.log('Start has been called');
|
|
40
|
+
console.log(start);
|
|
41
|
+
})
|
|
42
|
+
.onStop(async (stop, _api) => {
|
|
43
|
+
console.log('Stop has been called');
|
|
44
|
+
console.log(stop);
|
|
45
|
+
})
|
|
46
|
+
.onExchange(async (res, _api, name) => {
|
|
47
|
+
console.log(`Exchange ${name} has been called`);
|
|
48
|
+
console.log(res);
|
|
49
|
+
})
|
|
50
|
+
.onCron(async (cron, api, ctx) => {
|
|
51
|
+
console.log('Received cron event');
|
|
52
|
+
ctx.waitUntil(api.send('output', {}));
|
|
53
|
+
console.log(cron);
|
|
54
|
+
})
|
|
55
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from
|
|
2
|
+
ConnectError,
|
|
3
|
+
mapConnectErrorToHttpStatus,
|
|
4
|
+
} from "@mochabug/adapt-sdk/api";
|
|
5
5
|
import {
|
|
6
6
|
ExternalExecutorRouter,
|
|
7
7
|
InternalExecutorRouter
|
|
8
|
-
} from '@mochabug/adapt-
|
|
8
|
+
} from '@mochabug/adapt-sdk/router';
|
|
9
9
|
|
|
10
10
|
export default {
|
|
11
11
|
external: new ExternalExecutorRouter()
|
|
@@ -13,8 +13,8 @@ export default {
|
|
|
13
13
|
.useBearerAuthorization(['/api'])
|
|
14
14
|
.useErrorHandling(async (e) => {
|
|
15
15
|
console.error(e);
|
|
16
|
-
if (e instanceof
|
|
17
|
-
return new Response(null, { status:
|
|
16
|
+
if (e instanceof ConnectError) {
|
|
17
|
+
return new Response(null, { status: mapConnectErrorToHttpStatus(e) });
|
|
18
18
|
}
|
|
19
19
|
return new Response(null, {
|
|
20
20
|
status: 500,
|
|
@@ -23,7 +23,7 @@ export default {
|
|
|
23
23
|
})
|
|
24
24
|
.add('POST', '/api/done', async (req, api, _route, ctx) => {
|
|
25
25
|
const sapi = api.getSessionApi(req.headers.get('Authorization')!);
|
|
26
|
-
ctx.waitUntil(sapi.
|
|
26
|
+
ctx.waitUntil(sapi.send('output', {}));
|
|
27
27
|
return new Response();
|
|
28
28
|
})
|
|
29
29
|
.add('GET', '{/*any}', async (_, api) => {
|
|
@@ -43,12 +43,8 @@ export default {
|
|
|
43
43
|
console.log('Stop has been called');
|
|
44
44
|
console.log(stop);
|
|
45
45
|
})
|
|
46
|
-
.
|
|
47
|
-
console.log(`
|
|
48
|
-
console.log(res);
|
|
49
|
-
})
|
|
50
|
-
.onProcedure(async (res, _api, name) => {
|
|
51
|
-
console.log(`Procedure ${name} has been called`);
|
|
46
|
+
.onExchange(async (res, _api, name) => {
|
|
47
|
+
console.log(`Exchange ${name} has been called`);
|
|
52
48
|
console.log(res);
|
|
53
49
|
})
|
|
54
50
|
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConnectError,
|
|
3
|
+
mapConnectErrorToHttpStatus,
|
|
4
|
+
} from "@mochabug/adapt-sdk/api";
|
|
5
|
+
import {
|
|
6
|
+
ExternalExecutorRouter,
|
|
7
|
+
CronExecutorRouter
|
|
8
|
+
} from '@mochabug/adapt-sdk/router';
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
external: new ExternalExecutorRouter()
|
|
12
|
+
.useRequestLogging()
|
|
13
|
+
.useBearerAuthorization(['/api'])
|
|
14
|
+
.useErrorHandling(async (e) => {
|
|
15
|
+
console.error(e);
|
|
16
|
+
if (e instanceof ConnectError) {
|
|
17
|
+
return new Response(null, { status: mapConnectErrorToHttpStatus(e) });
|
|
18
|
+
}
|
|
19
|
+
return new Response(null, {
|
|
20
|
+
status: 500,
|
|
21
|
+
statusText: 'Internal server error'
|
|
22
|
+
});
|
|
23
|
+
})
|
|
24
|
+
.add('POST', '/api/done', async (req, api, _route, ctx) => {
|
|
25
|
+
const sapi = api.getSessionApi(req.headers.get('Authorization')!);
|
|
26
|
+
ctx.waitUntil(sapi.send('output', {}));
|
|
27
|
+
return new Response();
|
|
28
|
+
})
|
|
29
|
+
.add('GET', '{/*any}', async (_, api) => {
|
|
30
|
+
const res = await api.readFile(
|
|
31
|
+
'browser/___VERTEX_NAME___/executor.html'
|
|
32
|
+
);
|
|
33
|
+
return new Response(res.content, {
|
|
34
|
+
headers: { 'Content-Type': 'text/html; charset=utf-8' }
|
|
35
|
+
});
|
|
36
|
+
}),
|
|
37
|
+
internal: new CronExecutorRouter()
|
|
38
|
+
.onStart(async (start, _api) => {
|
|
39
|
+
console.log('Start has been called');
|
|
40
|
+
console.log(start);
|
|
41
|
+
})
|
|
42
|
+
.onStop(async (stop, _api) => {
|
|
43
|
+
console.log('Stop has been called');
|
|
44
|
+
console.log(stop);
|
|
45
|
+
})
|
|
46
|
+
.onExchange(async (res, _api, name) => {
|
|
47
|
+
console.log(`Exchange ${name} has been called`);
|
|
48
|
+
console.log(res);
|
|
49
|
+
})
|
|
50
|
+
.onCron(async (cron, api, ctx) => {
|
|
51
|
+
console.log('Received cron event');
|
|
52
|
+
ctx.waitUntil(api.send('output', {}));
|
|
53
|
+
console.log(cron);
|
|
54
|
+
})
|
|
55
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from
|
|
2
|
+
ConnectError,
|
|
3
|
+
mapConnectErrorToHttpStatus,
|
|
4
|
+
} from "@mochabug/adapt-sdk/api";
|
|
5
5
|
import {
|
|
6
6
|
ExternalExecutorRouter,
|
|
7
7
|
InternalExecutorRouter
|
|
8
|
-
} from '@mochabug/adapt-
|
|
8
|
+
} from '@mochabug/adapt-sdk/router';
|
|
9
9
|
|
|
10
10
|
export default {
|
|
11
11
|
external: new ExternalExecutorRouter()
|
|
@@ -13,8 +13,8 @@ export default {
|
|
|
13
13
|
.useBearerAuthorization(['/api'])
|
|
14
14
|
.useErrorHandling(async (e) => {
|
|
15
15
|
console.error(e);
|
|
16
|
-
if (e instanceof
|
|
17
|
-
return new Response(null, { status:
|
|
16
|
+
if (e instanceof ConnectError) {
|
|
17
|
+
return new Response(null, { status: mapConnectErrorToHttpStatus(e) });
|
|
18
18
|
}
|
|
19
19
|
return new Response(null, {
|
|
20
20
|
status: 500,
|
|
@@ -33,12 +33,8 @@ export default {
|
|
|
33
33
|
console.log('Stop has been called');
|
|
34
34
|
console.log(stop);
|
|
35
35
|
})
|
|
36
|
-
.
|
|
37
|
-
console.log(`
|
|
38
|
-
console.log(res);
|
|
39
|
-
})
|
|
40
|
-
.onProcedure(async (res, _api, name) => {
|
|
41
|
-
console.log(`Procedure ${name} has been called`);
|
|
36
|
+
.onExchange(async (res, _api, name) => {
|
|
37
|
+
console.log(`Exchange ${name} has been called`);
|
|
42
38
|
console.log(res);
|
|
43
39
|
})
|
|
44
40
|
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConnectError,
|
|
3
|
+
mapConnectErrorToHttpStatus,
|
|
4
|
+
} from "@mochabug/adapt-sdk/api";
|
|
5
|
+
import {
|
|
6
|
+
ExternalExecutorRouter,
|
|
7
|
+
InternalExecutorRouter
|
|
8
|
+
} from '@mochabug/adapt-sdk/router';
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
external: new ExternalExecutorRouter()
|
|
12
|
+
.useRequestLogging()
|
|
13
|
+
.useBearerAuthorization(['/api'])
|
|
14
|
+
.useErrorHandling(async (e) => {
|
|
15
|
+
console.error(e);
|
|
16
|
+
if (e instanceof ConnectError) {
|
|
17
|
+
return new Response(null, { status: mapConnectErrorToHttpStatus(e) });
|
|
18
|
+
}
|
|
19
|
+
return new Response(null, {
|
|
20
|
+
status: 500,
|
|
21
|
+
statusText: 'Internal server error'
|
|
22
|
+
});
|
|
23
|
+
})
|
|
24
|
+
.add('*', '(.*)', async (_req, _api, _route, _ctx) => {
|
|
25
|
+
return new Response();
|
|
26
|
+
}),
|
|
27
|
+
internal: new InternalExecutorRouter()
|
|
28
|
+
.onStart(async (start, _api) => {
|
|
29
|
+
console.log('Start has been called');
|
|
30
|
+
console.log(start);
|
|
31
|
+
})
|
|
32
|
+
.onStop(async (stop, _api) => {
|
|
33
|
+
console.log('Stop has been called');
|
|
34
|
+
console.log(stop);
|
|
35
|
+
})
|
|
36
|
+
.onExchange(async (res, _api, name) => {
|
|
37
|
+
console.log(`Exchange ${name} has been called`);
|
|
38
|
+
console.log(res);
|
|
39
|
+
})
|
|
40
|
+
.onCron(async (cron, api, ctx) => {
|
|
41
|
+
console.log('Received cron event');
|
|
42
|
+
ctx.waitUntil(api.send('output', {}));
|
|
43
|
+
console.log(cron);
|
|
44
|
+
})
|
|
45
|
+
};
|
package/assets/tsconf.json
CHANGED
package/bin/add.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../src/add.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,QAAQ,EAAE,MAAM,sDAAsD,CAAC;
|
|
1
|
+
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../src/add.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,QAAQ,EAAE,MAAM,sDAAsD,CAAC;AAIhF,wBAAsB,GAAG,CAAC,QAAQ,EAAE,QAAQ,iBA2E3C"}
|