@mochabug/adaptkit 1.0.0-rc.2 → 1.0.0-rc.20
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/assets/build.js +2 -57
- package/assets/configurator.html +14 -0
- package/assets/configurator.ssg.tsx +2 -16
- package/assets/configurator_none.ts +4 -4
- package/assets/configurator_react.tsx +10 -7
- package/assets/executor.html +14 -0
- package/assets/executor.ssg.tsx +2 -16
- package/assets/executor_action.ts +3 -7
- package/assets/{executor_cron_trigger.ts → executor_action_cron.ts} +3 -7
- package/assets/executor_browser_none.ts +8 -12
- package/assets/executor_browser_none_cron.ts +119 -0
- package/assets/executor_browser_react.tsx +14 -15
- package/assets/executor_browser_react_cron.tsx +55 -0
- package/assets/{executor_external_trigger.ts → executor_external.ts} +7 -11
- package/assets/executor_external_cron.ts +45 -0
- package/assets/gitignore +3 -1
- package/assets/tsconf.json +3 -5
- package/bin/add.d.ts +3 -0
- package/bin/add.d.ts.map +1 -0
- package/bin/genproto/buf/validate/validate_pb.d.ts +8491 -0
- package/bin/genproto/buf/validate/validate_pb.d.ts.map +1 -0
- package/bin/genproto/google/api/annotations_pb.d.ts +14 -0
- package/bin/genproto/google/api/annotations_pb.d.ts.map +1 -0
- package/bin/genproto/google/api/client_pb.d.ts +1432 -0
- package/bin/genproto/google/api/client_pb.d.ts.map +1 -0
- package/bin/genproto/google/api/http_pb.d.ts +843 -0
- package/bin/genproto/google/api/http_pb.d.ts.map +1 -0
- package/bin/genproto/google/api/launch_stage_pb.d.ts +94 -0
- package/bin/genproto/google/api/launch_stage_pb.d.ts.map +1 -0
- package/bin/genproto/mochabugapis/adapt/graph/exchange_pb.d.ts +77 -0
- package/bin/genproto/mochabugapis/adapt/graph/exchange_pb.d.ts.map +1 -0
- package/bin/genproto/mochabugapis/adapt/graph/jtd_schema_pb.d.ts +227 -0
- package/bin/genproto/mochabugapis/adapt/graph/jtd_schema_pb.d.ts.map +1 -0
- package/bin/genproto/mochabugapis/adapt/graph/receiver_pb.d.ts +69 -0
- package/bin/genproto/mochabugapis/adapt/graph/receiver_pb.d.ts.map +1 -0
- package/bin/genproto/mochabugapis/adapt/graph/signal_binding_pb.d.ts +134 -0
- package/bin/genproto/mochabugapis/adapt/graph/signal_binding_pb.d.ts.map +1 -0
- package/bin/genproto/mochabugapis/adapt/graph/signal_descriptor_pb.d.ts +91 -0
- package/bin/genproto/mochabugapis/adapt/graph/signal_descriptor_pb.d.ts.map +1 -0
- package/bin/genproto/mochabugapis/adapt/graph/transceiver_pb.d.ts +77 -0
- package/bin/genproto/mochabugapis/adapt/graph/transceiver_pb.d.ts.map +1 -0
- package/bin/genproto/mochabugapis/adapt/graph/transmitter_pb.d.ts +120 -0
- package/bin/genproto/mochabugapis/adapt/graph/transmitter_pb.d.ts.map +1 -0
- package/bin/genproto/mochabugapis/adapt/graph/vertex_metadata_pb.d.ts +99 -0
- package/bin/genproto/mochabugapis/adapt/graph/vertex_metadata_pb.d.ts.map +1 -0
- package/bin/genproto/mochabugapis/adapt/plugins/v1/file_pb.d.ts +64 -0
- package/bin/genproto/mochabugapis/adapt/plugins/v1/file_pb.d.ts.map +1 -0
- package/bin/genproto/mochabugapis/adapt/plugins/v1/manifest_pb.d.ts +225 -0
- package/bin/genproto/mochabugapis/adapt/plugins/v1/manifest_pb.d.ts.map +1 -0
- package/bin/genproto/mochabugapis/adapt/plugins/v1/oauth2_service_pb.d.ts +721 -0
- package/bin/genproto/mochabugapis/adapt/plugins/v1/oauth2_service_pb.d.ts.map +1 -0
- package/bin/genproto/mochabugapis/adapt/plugins/v1/oneof_service_pb.d.ts +94 -0
- package/bin/genproto/mochabugapis/adapt/plugins/v1/oneof_service_pb.d.ts.map +1 -0
- package/bin/genproto/mochabugapis/adapt/plugins/v1/plugins_pb.d.ts +214 -0
- package/bin/genproto/mochabugapis/adapt/plugins/v1/plugins_pb.d.ts.map +1 -0
- package/bin/genproto/mochabugapis/adapt/plugins/v1/service_binding_pb.d.ts +138 -0
- package/bin/genproto/mochabugapis/adapt/plugins/v1/service_binding_pb.d.ts.map +1 -0
- package/bin/genproto/mochabugapis/adapt/plugins/v1/service_definition_pb.d.ts +118 -0
- package/bin/genproto/mochabugapis/adapt/plugins/v1/service_definition_pb.d.ts.map +1 -0
- package/bin/genproto/mochabugapis/adapt/plugins/v1/tls_service_pb.d.ts +151 -0
- package/bin/genproto/mochabugapis/adapt/plugins/v1/tls_service_pb.d.ts.map +1 -0
- package/bin/genproto/mochabugapis/adapt/plugins/v1/variable_service_pb.d.ts +62 -0
- package/bin/genproto/mochabugapis/adapt/plugins/v1/variable_service_pb.d.ts.map +1 -0
- package/bin/genproto/mochabugapis/adapt/plugins/v1/vertex_pb.d.ts +242 -0
- package/bin/genproto/mochabugapis/adapt/plugins/v1/vertex_pb.d.ts.map +1 -0
- package/bin/index.d.ts +7 -0
- package/bin/index.d.ts.map +1 -0
- package/bin/index.js +737 -796
- package/bin/index.js.map +4 -4
- package/bin/init.d.ts +2 -0
- package/bin/init.d.ts.map +1 -0
- package/bin/oauth2.d.ts +2 -0
- package/bin/oauth2.d.ts.map +1 -0
- package/bin/publish.d.ts +23 -0
- package/bin/publish.d.ts.map +1 -0
- package/bin/utils.d.ts +13 -0
- package/bin/utils.d.ts.map +1 -0
- package/bin/vertices.d.ts +3 -0
- package/bin/vertices.d.ts.map +1 -0
- package/package.json +19 -30
- package/assets/build-client.js +0 -111
- package/assets/global.d.ts +0 -7
- package/assets/inject.js +0 -15
- package/assets/license.md +0 -15
package/assets/build.js
CHANGED
|
@@ -1,57 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import fs from 'node:fs';
|
|
4
|
-
import { defineEnv } from 'unenv';
|
|
5
|
-
|
|
6
|
-
if (!process.env.PLUGINS_CDN) {
|
|
7
|
-
console.error('PLUGINS_CDN is required');
|
|
8
|
-
process.exit(1);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// Load the manifest.json file and read organization, name and version of the plugin
|
|
12
|
-
const manifest = JSON.parse(fs.readFileSync('./manifest.json', 'utf8'));
|
|
13
|
-
if (!manifest.organization || !manifest.name || !manifest.version) {
|
|
14
|
-
throw new Error('Manifest file is missing organization, name or version');
|
|
15
|
-
}
|
|
16
|
-
const CDN_PATH = `${process.env.PLUGINS_CDN}/${manifest.organization}/${manifest.name}/${manifest.version}`;
|
|
17
|
-
|
|
18
|
-
const { env } = defineEnv({ nodeCompat: true, presets: [cloudflare] });
|
|
19
|
-
|
|
20
|
-
const entryPoints = ['./src/executors']
|
|
21
|
-
if (fs.existsSync('./src/configurators.ts')) {
|
|
22
|
-
entryPoints.push('./src/configurators')
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Set up the defines, this will automatically load ssg index.html files if they exists
|
|
26
|
-
const define = {
|
|
27
|
-
PLUGINS_CDN: JSON.stringify(CDN_PATH)
|
|
28
|
-
};
|
|
29
|
-
if (fs.existsSync('./dist/configurator-index-html.json')) {
|
|
30
|
-
const CONFIGURATOR_INDEX_HTML = fs.readFileSync('./dist/configurator-index-html.json', 'utf8');
|
|
31
|
-
define.CONFIGURATOR_INDEX_HTML = CONFIGURATOR_INDEX_HTML;
|
|
32
|
-
}
|
|
33
|
-
if (fs.existsSync('./dist/executor-index-html.json')) {
|
|
34
|
-
const EXECUTOR_INDEX_HTML = fs.readFileSync('./dist/executor-index-html.json', 'utf8');
|
|
35
|
-
define.EXECUTOR_INDEX_HTML = EXECUTOR_INDEX_HTML;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
await build({
|
|
39
|
-
entryPoints,
|
|
40
|
-
outdir: 'dist',
|
|
41
|
-
bundle: true,
|
|
42
|
-
minify: true,
|
|
43
|
-
treeShaking: true,
|
|
44
|
-
sourcemap: false,
|
|
45
|
-
splitting: false,
|
|
46
|
-
format: 'esm',
|
|
47
|
-
platform: 'node',
|
|
48
|
-
target: 'esnext',
|
|
49
|
-
tsconfig: 'tsconfig.json',
|
|
50
|
-
inject: ['./inject.js'],
|
|
51
|
-
mainFields: ["module", "main"],
|
|
52
|
-
conditions: ["workerd"],
|
|
53
|
-
external: env.external,
|
|
54
|
-
alias: env.alias,
|
|
55
|
-
publicPath: CDN_PATH,
|
|
56
|
-
define,
|
|
57
|
-
});
|
|
1
|
+
import { build } from '@mochabug/adapt-plugin-builder';
|
|
2
|
+
build({ cdnBase: process.env.PLUGINS_CDN });
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="utf-8" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>The configurator</title>
|
|
8
|
+
</head>
|
|
9
|
+
|
|
10
|
+
<body>
|
|
11
|
+
<div id="root"><%= define.content %></div>
|
|
12
|
+
</body>
|
|
13
|
+
|
|
14
|
+
</html>
|
|
@@ -12,20 +12,6 @@ import React from 'react';
|
|
|
12
12
|
import { renderToString } from 'react-dom/server';
|
|
13
13
|
import App from './configurator.App';
|
|
14
14
|
|
|
15
|
-
export default function (
|
|
16
|
-
return
|
|
17
|
-
<!DOCTYPE html>
|
|
18
|
-
<html lang="en">
|
|
19
|
-
<head>
|
|
20
|
-
<meta charset="utf-8" />
|
|
21
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
22
|
-
<title>Title</title>
|
|
23
|
-
${css ? `<link rel="stylesheet" href="${css}" />` : ''}
|
|
24
|
-
</head>
|
|
25
|
-
<body>
|
|
26
|
-
<div id="root">${renderToString(<App />)}</div>
|
|
27
|
-
<script type="module" src="${js}"></script>
|
|
28
|
-
</body>
|
|
29
|
-
</html>
|
|
30
|
-
`;
|
|
15
|
+
export default function () {
|
|
16
|
+
return renderToString(<App />);
|
|
31
17
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
ConnectError,
|
|
3
|
+
mapConnectErrorToHttpStatus
|
|
4
4
|
} from '@mochabug/adapt-plugin-toolkit/api';
|
|
5
5
|
import {
|
|
6
6
|
ExternalConfiguratorRouter,
|
|
@@ -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,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
ConnectError,
|
|
3
|
+
mapConnectErrorToHttpStatus
|
|
4
4
|
} from '@mochabug/adapt-plugin-toolkit/api';
|
|
5
5
|
import {
|
|
6
6
|
ExternalConfiguratorRouter,
|
|
@@ -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,
|
|
@@ -29,9 +29,12 @@ export default {
|
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
})
|
|
32
|
-
.add('GET', '{
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
.add('GET', '{/*any}', async (_, api) => {
|
|
33
|
+
const res = await api.readFile(
|
|
34
|
+
'browser/___VERTEX_NAME___/configurator.html'
|
|
35
|
+
);
|
|
36
|
+
return new Response(res.content, {
|
|
37
|
+
headers: { 'Content-Type': 'text/html; charset=utf-8' }
|
|
35
38
|
});
|
|
36
39
|
}),
|
|
37
40
|
internal: new InternalConfiguratorRouter()
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="utf-8" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>The executor</title>
|
|
8
|
+
</head>
|
|
9
|
+
|
|
10
|
+
<body>
|
|
11
|
+
<div id="root"><%= define.content %></div>
|
|
12
|
+
</body>
|
|
13
|
+
|
|
14
|
+
</html>
|
package/assets/executor.ssg.tsx
CHANGED
|
@@ -12,20 +12,6 @@ import React from 'react';
|
|
|
12
12
|
import { renderToString } from 'react-dom/server';
|
|
13
13
|
import App from './executor.App';
|
|
14
14
|
|
|
15
|
-
export default function (
|
|
16
|
-
return
|
|
17
|
-
<!DOCTYPE html>
|
|
18
|
-
<html lang="en">
|
|
19
|
-
<head>
|
|
20
|
-
<meta charset="utf-8" />
|
|
21
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
22
|
-
<title>Title</title>
|
|
23
|
-
${css ? `<link rel="stylesheet" href="${css}" />` : ''}
|
|
24
|
-
</head>
|
|
25
|
-
<body>
|
|
26
|
-
<div id="root">${renderToString(<App />)}</div>
|
|
27
|
-
<script type="module" src="${js}"></script>
|
|
28
|
-
</body>
|
|
29
|
-
</html>
|
|
30
|
-
`;
|
|
15
|
+
export default function () {
|
|
16
|
+
return renderToString(<App />);
|
|
31
17
|
}
|
|
@@ -5,18 +5,14 @@ export default {
|
|
|
5
5
|
.onStart(async (start, api, ctx) => {
|
|
6
6
|
console.log('Start has been called');
|
|
7
7
|
console.log(start);
|
|
8
|
-
ctx.waitUntil(api.
|
|
8
|
+
ctx.waitUntil(api.send('output', {}));
|
|
9
9
|
})
|
|
10
10
|
.onStop(async (stop, _api) => {
|
|
11
11
|
console.log('Stop has been called');
|
|
12
12
|
console.log(stop);
|
|
13
13
|
})
|
|
14
|
-
.
|
|
15
|
-
console.log(`
|
|
16
|
-
console.log(res);
|
|
17
|
-
})
|
|
18
|
-
.onProcedure(async (res, _api, name) => {
|
|
19
|
-
console.log(`Procedure ${name} has been called`);
|
|
14
|
+
.onExchange(async (res, _api, name) => {
|
|
15
|
+
console.log(`Exchange ${name} has been called`);
|
|
20
16
|
console.log(res);
|
|
21
17
|
})
|
|
22
18
|
};
|
|
@@ -10,17 +10,13 @@ export default {
|
|
|
10
10
|
console.log('Stop has been called');
|
|
11
11
|
console.log(stop);
|
|
12
12
|
})
|
|
13
|
-
.
|
|
14
|
-
console.log(`
|
|
15
|
-
console.log(res);
|
|
16
|
-
})
|
|
17
|
-
.onProcedure(async (res, _api, name) => {
|
|
18
|
-
console.log(`Procedure ${name} has been called`);
|
|
13
|
+
.onExchange(async (res, _api, name) => {
|
|
14
|
+
console.log(`Exchange ${name} has been called`);
|
|
19
15
|
console.log(res);
|
|
20
16
|
})
|
|
21
17
|
.onCron(async (cron, api, ctx) => {
|
|
22
18
|
console.log('Received cron event');
|
|
23
|
-
ctx.waitUntil(api.
|
|
19
|
+
ctx.waitUntil(api.send('output', {}));
|
|
24
20
|
console.log(cron);
|
|
25
21
|
})
|
|
26
22
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from
|
|
2
|
+
ConnectError,
|
|
3
|
+
mapConnectErrorToHttpStatus,
|
|
4
|
+
} from "@mochabug/adapt-plugin-toolkit/api";
|
|
5
5
|
import {
|
|
6
6
|
ExternalExecutorRouter,
|
|
7
7
|
InternalExecutorRouter
|
|
@@ -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 () => {
|
|
@@ -42,12 +42,8 @@ export default {
|
|
|
42
42
|
console.log('Stop has been called');
|
|
43
43
|
console.log(stop);
|
|
44
44
|
})
|
|
45
|
-
.
|
|
46
|
-
console.log(`
|
|
47
|
-
console.log(res);
|
|
48
|
-
})
|
|
49
|
-
.onProcedure(async (res, _api, name) => {
|
|
50
|
-
console.log(`Procedure ${name} has been called`);
|
|
45
|
+
.onExchange(async (res, _api, name) => {
|
|
46
|
+
console.log(`Exchange ${name} has been called`);
|
|
51
47
|
console.log(res);
|
|
52
48
|
})
|
|
53
49
|
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConnectError,
|
|
3
|
+
mapConnectErrorToHttpStatus,
|
|
4
|
+
} from "@mochabug/adapt-plugin-toolkit/api";
|
|
5
|
+
import {
|
|
6
|
+
ExternalExecutorRouter,
|
|
7
|
+
CronExecutorRouter
|
|
8
|
+
} from '@mochabug/adapt-plugin-toolkit/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 () => {
|
|
30
|
+
return new Response(helloWorld, {
|
|
31
|
+
headers: {
|
|
32
|
+
'Content-Type': 'text/html'
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}),
|
|
36
|
+
internal: new CronExecutorRouter()
|
|
37
|
+
.onStart(async (start, _api) => {
|
|
38
|
+
console.log('Start has been called');
|
|
39
|
+
console.log(start);
|
|
40
|
+
})
|
|
41
|
+
.onStop(async (stop, _api) => {
|
|
42
|
+
console.log('Stop has been called');
|
|
43
|
+
console.log(stop);
|
|
44
|
+
})
|
|
45
|
+
.onExchange(async (res, _api, name) => {
|
|
46
|
+
console.log(`Exchange ${name} has been called`);
|
|
47
|
+
console.log(res);
|
|
48
|
+
})
|
|
49
|
+
.onCron(async (cron, api, ctx) => {
|
|
50
|
+
console.log('Received cron event');
|
|
51
|
+
ctx.waitUntil(api.send('output', {}));
|
|
52
|
+
console.log(cron);
|
|
53
|
+
})
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const helloWorld = `
|
|
57
|
+
<html>
|
|
58
|
+
<head>
|
|
59
|
+
<style>
|
|
60
|
+
@import url('https://fonts.googleapis.com/css2?family=Orbitron&display=swap');
|
|
61
|
+
@keyframes glow {
|
|
62
|
+
0% { text-shadow: 0 0 5px #0f0, 0 0 10px #0f0, 0 0 15px #0f0, 0 0 20px #0f0; }
|
|
63
|
+
100% { text-shadow: 0 0 10px #0f0, 0 0 20px #0f0, 0 0 30px #0f0, 0 0 40px #0f0; }
|
|
64
|
+
}
|
|
65
|
+
body {
|
|
66
|
+
background-color: #000;
|
|
67
|
+
color: #0f0;
|
|
68
|
+
font-family: 'Orbitron', sans-serif;
|
|
69
|
+
text-align: center;
|
|
70
|
+
overflow: hidden;
|
|
71
|
+
margin: 0;
|
|
72
|
+
padding: 0;
|
|
73
|
+
}
|
|
74
|
+
button {
|
|
75
|
+
position: absolute;
|
|
76
|
+
top: 50%;
|
|
77
|
+
left: 50%;
|
|
78
|
+
transform: translate(-50%, -50%);
|
|
79
|
+
background-color: #0f0;
|
|
80
|
+
border: none;
|
|
81
|
+
color: black;
|
|
82
|
+
padding: 15px 32px;
|
|
83
|
+
text-align: center;
|
|
84
|
+
text-decoration: none;
|
|
85
|
+
display: inline-block;
|
|
86
|
+
font-size: 20px;
|
|
87
|
+
margin: 4px 2px;
|
|
88
|
+
cursor: pointer;
|
|
89
|
+
transition-duration: 0.4s;
|
|
90
|
+
animation: glow 2s infinite alternate;
|
|
91
|
+
font-family: 'Orbitron', sans-serif;
|
|
92
|
+
border-radius: 15px;
|
|
93
|
+
transform: rotate(-10deg) skew(10deg, 10deg);
|
|
94
|
+
}
|
|
95
|
+
</style>
|
|
96
|
+
</head>
|
|
97
|
+
<body>
|
|
98
|
+
<button id="doneButton">Done</button>
|
|
99
|
+
<script>
|
|
100
|
+
document.getElementById('doneButton').addEventListener('click', function() {
|
|
101
|
+
const hash = window.location.hash.substring(1).trim();
|
|
102
|
+
const token = decodeURIComponent(hash);
|
|
103
|
+
fetch('/api/done', {
|
|
104
|
+
method: 'POST',
|
|
105
|
+
headers: {
|
|
106
|
+
'Authorization': 'Bearer ' + token
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
.then(data => {
|
|
110
|
+
this.innerText = 'Done';
|
|
111
|
+
})
|
|
112
|
+
.catch(error => {
|
|
113
|
+
console.error('Error:', error);
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
</script>
|
|
117
|
+
</body>
|
|
118
|
+
</html>
|
|
119
|
+
`;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from
|
|
2
|
+
ConnectError,
|
|
3
|
+
mapConnectErrorToHttpStatus,
|
|
4
|
+
} from "@mochabug/adapt-plugin-toolkit/api";
|
|
5
5
|
import {
|
|
6
6
|
ExternalExecutorRouter,
|
|
7
7
|
InternalExecutorRouter
|
|
@@ -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,12 +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
|
-
|
|
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' }
|
|
32
35
|
});
|
|
33
36
|
}),
|
|
34
37
|
internal: new InternalExecutorRouter()
|
|
@@ -40,12 +43,8 @@ export default {
|
|
|
40
43
|
console.log('Stop has been called');
|
|
41
44
|
console.log(stop);
|
|
42
45
|
})
|
|
43
|
-
.
|
|
44
|
-
console.log(`
|
|
45
|
-
console.log(res);
|
|
46
|
-
})
|
|
47
|
-
.onProcedure(async (res, _api, name) => {
|
|
48
|
-
console.log(`Procedure ${name} has been called`);
|
|
46
|
+
.onExchange(async (res, _api, name) => {
|
|
47
|
+
console.log(`Exchange ${name} has been called`);
|
|
49
48
|
console.log(res);
|
|
50
49
|
})
|
|
51
50
|
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConnectError,
|
|
3
|
+
mapConnectErrorToHttpStatus,
|
|
4
|
+
} from "@mochabug/adapt-plugin-toolkit/api";
|
|
5
|
+
import {
|
|
6
|
+
ExternalExecutorRouter,
|
|
7
|
+
CronExecutorRouter
|
|
8
|
+
} from '@mochabug/adapt-plugin-toolkit/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,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from
|
|
2
|
+
ConnectError,
|
|
3
|
+
mapConnectErrorToHttpStatus,
|
|
4
|
+
} from "@mochabug/adapt-plugin-toolkit/api";
|
|
5
5
|
import {
|
|
6
6
|
ExternalExecutorRouter,
|
|
7
7
|
InternalExecutorRouter
|
|
@@ -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-plugin-toolkit/api";
|
|
5
|
+
import {
|
|
6
|
+
ExternalExecutorRouter,
|
|
7
|
+
InternalExecutorRouter
|
|
8
|
+
} from '@mochabug/adapt-plugin-toolkit/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/gitignore
CHANGED
package/assets/tsconf.json
CHANGED
package/bin/add.d.ts
ADDED
package/bin/add.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
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"}
|