@mochabug/adaptkit 0.1.0-alpha.9 → 0.2.0-alpha.2
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 +13 -5
- package/bin/index.js +388 -325
- package/bin/index.js.map +1 -1
- package/package.json +24 -21
- package/bin/gen/google/protobuf/descriptor.d.ts +0 -1799
- package/bin/gen/google/protobuf/descriptor.d.ts.map +0 -1
- package/bin/gen/mochabug/adapt/plugins/v1/plugins.client.d.ts +0 -46
- package/bin/gen/mochabug/adapt/plugins/v1/plugins.client.d.ts.map +0 -1
- package/bin/gen/mochabug/adapt/plugins/v1/plugins.d.ts +0 -797
- package/bin/gen/mochabug/adapt/plugins/v1/plugins.d.ts.map +0 -1
package/bin/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { ChannelCredentials } from '@grpc/grpc-js';
|
|
3
|
+
import { ServiceType, stackIntercept } from '@protobuf-ts/runtime-rpc';
|
|
4
|
+
import { MessageType, reflectionMergePartial, UnknownFieldHandler, WireType, MESSAGE_TYPE } from '@protobuf-ts/runtime';
|
|
3
5
|
import { GrpcTransport } from '@protobuf-ts/grpc-transport';
|
|
4
6
|
import chalk from 'chalk';
|
|
5
7
|
import { execSync } from 'child_process';
|
|
6
8
|
import { program } from 'commander';
|
|
9
|
+
import fg from 'fast-glob';
|
|
7
10
|
import figlet from 'figlet';
|
|
8
11
|
import fs from 'fs';
|
|
9
|
-
import { glob } from 'glob';
|
|
10
12
|
import inquirer from 'inquirer';
|
|
11
13
|
import { mkdirp } from 'mkdirp';
|
|
12
14
|
import path from 'path';
|
|
13
15
|
import sharp from 'sharp';
|
|
14
|
-
import { ServiceType, stackIntercept } from '@protobuf-ts/runtime-rpc';
|
|
15
|
-
import { MessageType, reflectionMergePartial, UnknownFieldHandler, WireType, MESSAGE_TYPE } from '@protobuf-ts/runtime';
|
|
16
16
|
|
|
17
17
|
/******************************************************************************
|
|
18
18
|
Copyright (c) Microsoft Corporation.
|
|
@@ -41,28 +41,8 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
var configTemplate = "import { ConfiguratorApi } from \"@mochabug/adapt-plugin-toolkit/api\";\nimport { Router } from \"@mochabug/adapt-plugin-toolkit/router\";\n\n/**\n * Represents a configurator of a vertex.\n * All requests coming from an external source (i.e. browsers) are\n * getting routed onto this endpoint. See the configurator API specification\n * for details and best practices regarding authorization and security.\n * See the configurator API specifications for details on how to interact with the runtime.\n *\n * @property {Function} fetch - A function that takes a Request, ConfiguratorEnvironment, and ExecutionContext\n * and returns a Promise resolving to a Response.\n */\nconst external = {\n async fetch(\n req: Request,\n env: ConfiguratorEnvironment,\n ctx: ExecutionContext\n ): Promise<Response> {\n const api = new ConfiguratorApi(env, req.headers.get(\"Authorization\"));\n\n const router = new Router();\n router.add('GET', '(.*)', async (params, searchParams) => {\n const authorized = await api.authorize(req);\n return authorized ? new Response(\"Hello Authorized!\") : new Response(\"Hello Unauthorized!\");\n });\n\n return router.route(req)\n },\n};\n\n/**\n * The internal endpoint of a configurator fires events from the platform\n * during configuration.\n */\nconst internal = {\n async fetch(\n req: Request,\n env: ConfiguratorEnvironment,\n ctx: ExecutionContext\n ): Promise<Response> {\n return new Response();\n },\n};\n\nexport { external, internal };\n";
|
|
47
|
-
|
|
48
|
-
var cronTriggerTemplate = "import { ExecutorApi } from '@mochabug/adapt-plugin-toolkit/api';\nimport { Router } from '@mochabug/adapt-plugin-toolkit/router';\n\n/**\n * Represents a executor of a vertex.\n * The internal entrypoint is called by the runtime and is never exposed to the outside world.\n * See the executor API specifications for details on how to interact with the runtime.\n *\n * POST: /start\n * - When the vertex starts executing this endpoint is called with the \"application/json\" Content-Type.\n * - Refer to the executor API documentation or the plugin-toolkit on the content of the body.\n * - Contains the instance's Bearer token in the Authorization Header\n * POST: /cron\n * - When execution is trigger by a cron trigger this endpoint is called with the \"application/json\" Content-Type.\n * - Refer to the executor API documentation or the plugin-toolkit on the content of the body.\n * - Contains the instance's Bearer token in the Authorization Header\n * POST: /streams/<name>\n * - If a stream has been started by the vertex, stream writes to this endpoint as \"application/json\" Content-Type.\n * - Refer to the executor API documentation or the plugin-toolkit on the content of the body.\n * - Contains the instance's Bearer token in the Authorization Header\n * POST: /procedures/<name>\n * - If a procedure has been executed by the vertex, procedure writes to this endpoint as \"application/json\"\n * - Refer to the executor API documentation or the plugin-toolkit on the content of the body.\n * - Contains the instance's Bearer token in the Authorization Header\n * @property {Function} fetch - A function that takes a Request, ExecutorEnvironment, and ExecutionContext\n * and returns a Promise resolving to a Response.\n */\nconst internal = {\n async fetch(\n req: Request,\n env: ExecutorEnvironment,\n ctx: ExecutionContext\n ): Promise<Response> {\n const api = new ExecutorApi(env, req.headers.get(\"Authorization\"));\n if (!await api.authorize(req)) {\n return new Response(\"Should never happen\", { status: 401 });\n\n }\n\n const router = new Router();\n router.add('POST', '/start', async (params, searchParams) => {\n return new Response();\n });\n\n router.add('POST', '/cron', async (params, searchParams) => {\n return new Response();\n });\n\n router.add('POST', '/streams/:name', async (params, searchParams) => {\n return new Response();\n });\n\n router.add('POST', '/procedures/:name', async (params, searchParams) => {\n return new Response();\n });\n\n return router.route(req)\n },\n};\n\nexport { internal };";
|
|
49
|
-
|
|
50
|
-
var externalTriggerTemplate = "import { ExecutorApi } from \"@mochabug/adapt-plugin-toolkit/api\";\nimport { Router } from \"@mochabug/adapt-plugin-toolkit/router\";\n\n/**\n * Represents an external executor for a vertex.\n * All requests coming from an external source (i.e. the external trigger) are\n * getting routed onto this endpoint. See the executor API specification\n * for details and best practices regarding authorization and security.\n * See the executor API specifications for details on how to interact with the runtime.\n *\n * @property {Function} fetch - A function that takes a Request, ExecutorEnvironment, and ExecutionContext\n * and returns a Promise resolving to a Response.\n */\nconst external = {\n async fetch(\n req: Request,\n env: ExecutorEnvironment,\n ctx: ExecutionContext\n ): Promise<Response> {\n const api = new ExecutorApi(env, req.headers.get(\"Authorization\"));\n\n // Do your thing here\n\n // Mark the execution as complete. This will trigger downstream tasks\n ctx.waitUntil(api.complete(\"output\", []));\n\n return new Response(\"Hello World!\");\n },\n};\n\n/**\n * Represents a executor of a vertex.\n * The internal entrypoint is called by the runtime and is never exposed to the outside world.\n * See the executor API specifications for details on how to interact with the runtime.\n *\n * POST: /start\n * - When the vertex starts executing this endpoint is called with the \"application/json\" Content-Type.\n * - Refer to the executor API documentation or the plugin-toolkit on the content of the body.\n * - Contains the instance's Bearer token in the Authorization Header\n * POST: /streams/<name>\n * - If a stream has been started by the vertex, stream writes to this endpoint as \"application/json\" Content-Type.\n * - Refer to the executor API documentation or the plugin-toolkit on the content of the body.\n * - Contains the instance's Bearer token in the Authorization Header\n * POST: /procedures/<name>\n * - If a procedure has been executed by the vertex, procedure writes to this endpoint as \"application/json\"\n * - Refer to the executor API documentation or the plugin-toolkit on the content of the body.\n * - Contains the instance's Bearer token in the Authorization Header\n * @property {Function} fetch - A function that takes a Request, ExecutorEnvironment, and ExecutionContext\n * and returns a Promise resolving to a Response.\n */\nconst internal = {\n async fetch(\n req: Request,\n env: ExecutorEnvironment,\n ctx: ExecutionContext\n ): Promise<Response> {\n const api = new ExecutorApi(env, req.headers.get(\"Authorization\"));\n const router = new Router();\n\n router.add('POST', '/start', async (params, searchParams) => {\n api.authorize(req)\n return new Response();\n });\n\n router.add('POST', '/streams/:name', async (params, searchParams) => {\n return new Response();\n });\n\n router.add('POST', '/procedures/:name', async (params, searchParams) => {\n return new Response();\n });\n\n return router.route(req)\n },\n};\n\nexport { external, internal };";
|
|
51
|
-
|
|
52
|
-
var gitignoreTemplate = "# Logs\nlogs\n*.log\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\nlerna-debug.log*\n.pnpm-debug.log*\n\n# Diagnostic reports (https://nodejs.org/api/report.html)\nreport.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json\n\n# Runtime data\npids\n*.pid\n*.seed\n*.pid.lock\n\n# Directory for instrumented libs generated by jscoverage/JSCover\nlib-cov\n\n# Coverage directory used by tools like istanbul\ncoverage\n*.lcov\n\n# nyc test coverage\n.nyc_output\n\n# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)\n.grunt\n\n# Bower dependency directory (https://bower.io/)\nbower_components\n\n# node-waf configuration\n.lock-wscript\n\n# Compiled binary addons (https://nodejs.org/api/addons.html)\nbuild/Release\n\n# Dependency directories\nnode_modules/\njspm_packages/\n\n# Snowpack dependency directory (https://snowpack.dev/)\nweb_modules/\n\n# TypeScript cache\n*.tsbuildinfo\n\n# Optional npm cache directory\n.npm\n\n# Optional eslint cache\n.eslintcache\n\n# Optional stylelint cache\n.stylelintcache\n\n# Microbundle cache\n.rpt2_cache/\n.rts2_cache_cjs/\n.rts2_cache_es/\n.rts2_cache_umd/\n\n# Optional REPL history\n.node_repl_history\n\n# Output of 'npm pack'\n*.tgz\n\n# Yarn Integrity file\n.yarn-integrity\n\n# dotenv environment variable files\n.env\n.env.development.local\n.env.test.local\n.env.production.local\n.env.local\n\n# parcel-bundler cache (https://parceljs.org/)\n.cache\n.parcel-cache\n\n# Next.js build output\n.next\nout\n\n# Nuxt.js build / generate output\n.nuxt\ndist\nbuild\n\n# Gatsby files\n.cache/\n# Comment in the public line in if your project uses Gatsby and not Next.js\n# https://nextjs.org/blog/next-9-1#public-directory-support\n# public\n\n# vuepress build output\n.vuepress/dist\n\n# vuepress v2.x temp and cache directory\n.temp\n.cache\n\n# Stores VSCode versions used for testing VSCode extensions\n.vscode-test\n\n# yarn v2\n.yarn/cache\n.yarn/unplugged\n.yarn/build-state.yml\n.yarn/install-state.gz\n.pnp.*";
|
|
53
|
-
|
|
54
|
-
var jestTemplate = "import type { Config } from \"@jest/types\"\n\nconst config: Config.InitialOptions = {\n preset: \"ts-jest\",\n testEnvironment: \"node\",\n verbose: true,\n automock: true,\n}\nexport default config";
|
|
55
|
-
|
|
56
|
-
var licenseTemplate = "## ISC License\n\nCopyright (c) [year] [fullname]\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted, provided that the above\ncopyright notice and this permission notice appear in all copies.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.";
|
|
57
|
-
|
|
58
|
-
var readmeTemplate = "# 🐞 Mochabug Adapt's Magnificent Plugin 🐞\n\n[](PLUGIN_REPOSITORY_URL)\n[](https://opensource.org/licenses/ISC)\n\n## 📝 Description\n\nWelcome to the Magnificent Plugin for Mochabug Adapt! Developed by a talented third-party developer, this plugin promises to bring extra flavor to your Mochabug Adapt cloud platform experience. PLUGIN_DESCRIPTION\n\nThis plugin consists of one or more vertices. Each vertex is made up of an Executor and may optionally include a Configurator to help you tailor its behavior.\n\n## 📚 Table of Contents\n\n- [🐞 Mochabug Adapt's Magnificent Plugin 🐞](#-mochabug-adapts-magnificent-plugin-)\n - [📝 Description](#-description)\n - [📚 Table of Contents](#-table-of-contents)\n - [🚀 Getting Started](#-getting-started)\n - [🎯 Usage](#-usage)\n - [⚙️ Configuration](#️-configuration)\n - [📖 Documentation](#-documentation)\n - [🤝 Contributing](#-contributing)\n - [📜 License](#-license)\n - [👤 Author](#-author)\n\n## 🚀 Getting Started\n\nTo begin using Mochabug Adapt's Magnificent Plugin, simply start incorporating its vertices into your workflows within the Mochabug Adapt platform. No installation is required.\n\n## 🎯 Usage\n\nYou can start using the vertices by incorporating them into your workflows on the Mochabug Adapt platform. Each vertex will delight you with a specific task, and the usage will vary depending on your requirements. Consult the plugin documentation for a comprehensive guide on each vertex's usage.\n\n## ⚙️ Configuration\n\nEach vertex in the plugin may have a Configurator, which allows you to tailor the vertex's behavior to your liking. Configuration options may include settings for the Executor, input/output data formats, and other essential options.\n\n## 📖 Documentation\n\nFor more insights into the plugin, its vertices, and their features, visit the [homepage](PLUGIN_HOMEPAGE) and the [repository](PLUGIN_REPOSITORY_URL).\n\n## 🤝 Contributing\n\nReady to make the Magnificent Plugin for Mochabug Adapt even more magical? Contributions are welcome! Check the [repository](PLUGIN_REPOSITORY_URL) for open issues and guidelines on how to contribute.\n\n## 📜 License\n\nThis plugin is licensed under the [ISC License](https://opensource.org/licenses/ISC).\n\n## 👤 Author\n\nPLUGIN_AUTHOR\n";
|
|
59
|
-
|
|
60
|
-
var rollupTemplate = "import typescript from '@rollup/plugin-typescript';\nimport { nodeResolve } from '@rollup/plugin-node-resolve';\nimport terser from '@rollup/plugin-terser';\nimport commonjs from '@rollup/plugin-commonjs';\n\nexport default [\n {\n input: 'src/executors.ts',\n output: {\n file: 'dist/executors.js',\n format: 'esm'\n },\n plugins: [typescript(), nodeResolve(), commonjs(), terser()]\n },\n {\n input: 'src/configurators.ts',\n output: {\n file: 'dist/configurators.js',\n format: 'esm'\n },\n plugins: [typescript(), nodeResolve(), commonjs(), terser()]\n }\n];";
|
|
61
|
-
|
|
62
|
-
var tsconfig = "{\n \"exclude\": [\n \"**/*.test.*\",\n \"**/__mocks__/*\",\n \"**/__tests__/*\"\n ],\n \"compilerOptions\": {\n \"rootDir\": \"src\",\n \"target\": \"es2021\",\n \"lib\": [\n \"es2021\"\n ],\n \"jsx\": \"react\",\n \"module\": \"es2022\",\n \"moduleResolution\": \"node\",\n \"types\": [\n \"@mochabug/adapt-plugin-typings\",\n \"jest\"\n ],\n \"resolveJsonModule\": true,\n \"allowJs\": true,\n \"checkJs\": false,\n \"noEmit\": true,\n \"isolatedModules\": true,\n \"allowSyntheticDefaultImports\": true,\n \"forceConsistentCasingInFileNames\": true,\n \"strict\": true,\n \"skipLibCheck\": true\n }\n}";
|
|
63
|
-
|
|
64
|
-
// @generated by protobuf-ts 2.9.0
|
|
65
|
-
// @generated from protobuf file "mochabug/adapt/plugins/v1/plugins.proto" (package "mochabug.adapt.plugins.v1", syntax proto3)
|
|
44
|
+
// @generated by protobuf-ts 2.9.1
|
|
45
|
+
// @generated from protobuf file "mochabugapis/adapt/plugins/v1/plugins.proto" (package "mochabugapis.adapt.plugins.v1", syntax proto3)
|
|
66
46
|
// tslint:disable
|
|
67
47
|
//
|
|
68
48
|
// Copyright 2023, mochabug AB
|
|
@@ -82,7 +62,7 @@ var tsconfig = "{\n \"exclude\": [\n \"**/*.test.*\",\n \"**/__
|
|
|
82
62
|
/**
|
|
83
63
|
* GrantType represents the supported OAuth2 grant types.
|
|
84
64
|
*
|
|
85
|
-
* @generated from protobuf enum
|
|
65
|
+
* @generated from protobuf enum mochabugapis.adapt.plugins.v1.OAuth2Service.GrantType
|
|
86
66
|
*/
|
|
87
67
|
var OAuth2Service_GrantType;
|
|
88
68
|
(function (OAuth2Service_GrantType) {
|
|
@@ -107,10 +87,42 @@ var OAuth2Service_GrantType;
|
|
|
107
87
|
*/
|
|
108
88
|
OAuth2Service_GrantType[OAuth2Service_GrantType["CLIENT_CREDENTIALS"] = 2] = "CLIENT_CREDENTIALS";
|
|
109
89
|
})(OAuth2Service_GrantType || (OAuth2Service_GrantType = {}));
|
|
90
|
+
/**
|
|
91
|
+
* The type of variable
|
|
92
|
+
*
|
|
93
|
+
* @generated from protobuf enum mochabugapis.adapt.plugins.v1.EnvironmentalVariable.Type
|
|
94
|
+
*/
|
|
95
|
+
var EnvironmentalVariable_Type;
|
|
96
|
+
(function (EnvironmentalVariable_Type) {
|
|
97
|
+
/**
|
|
98
|
+
* The type is not specified. Invalid value
|
|
99
|
+
*
|
|
100
|
+
* @generated from protobuf enum value: TYPE_UNSPECIFIED = 0;
|
|
101
|
+
*/
|
|
102
|
+
EnvironmentalVariable_Type[EnvironmentalVariable_Type["UNSPECIFIED"] = 0] = "UNSPECIFIED";
|
|
103
|
+
/**
|
|
104
|
+
* The variable will hold a secret
|
|
105
|
+
*
|
|
106
|
+
* @generated from protobuf enum value: TYPE_SECRET = 1;
|
|
107
|
+
*/
|
|
108
|
+
EnvironmentalVariable_Type[EnvironmentalVariable_Type["SECRET"] = 1] = "SECRET";
|
|
109
|
+
/**
|
|
110
|
+
* The variable will hold a string
|
|
111
|
+
*
|
|
112
|
+
* @generated from protobuf enum value: TYPE_STRING = 2;
|
|
113
|
+
*/
|
|
114
|
+
EnvironmentalVariable_Type[EnvironmentalVariable_Type["STRING"] = 2] = "STRING";
|
|
115
|
+
/**
|
|
116
|
+
* The variable is a boolean value
|
|
117
|
+
*
|
|
118
|
+
* @generated from protobuf enum value: TYPE_SWITCH = 3;
|
|
119
|
+
*/
|
|
120
|
+
EnvironmentalVariable_Type[EnvironmentalVariable_Type["SWITCH"] = 3] = "SWITCH";
|
|
121
|
+
})(EnvironmentalVariable_Type || (EnvironmentalVariable_Type = {}));
|
|
110
122
|
/**
|
|
111
123
|
* VertexType represents the type of a vertex.
|
|
112
124
|
*
|
|
113
|
-
* @generated from protobuf enum
|
|
125
|
+
* @generated from protobuf enum mochabugapis.adapt.plugins.v1.Vertex.VertexType
|
|
114
126
|
*/
|
|
115
127
|
var Vertex_VertexType;
|
|
116
128
|
(function (Vertex_VertexType) {
|
|
@@ -156,7 +168,7 @@ var Vertex_VertexType;
|
|
|
156
168
|
// @generated message type with reflection information, may provide speed optimized methods
|
|
157
169
|
class UploadPluginRequest$Type extends MessageType {
|
|
158
170
|
constructor() {
|
|
159
|
-
super("
|
|
171
|
+
super("mochabugapis.adapt.plugins.v1.UploadPluginRequest", [
|
|
160
172
|
{ no: 1, name: "manifest", kind: "message", oneof: "data", T: () => Manifest },
|
|
161
173
|
{ no: 2, name: "file", kind: "message", oneof: "data", T: () => File }
|
|
162
174
|
]);
|
|
@@ -169,17 +181,17 @@ class UploadPluginRequest$Type extends MessageType {
|
|
|
169
181
|
return message;
|
|
170
182
|
}
|
|
171
183
|
internalBinaryRead(reader, length, options, target) {
|
|
172
|
-
let message = target
|
|
184
|
+
let message = target ?? this.create(), end = reader.pos + length;
|
|
173
185
|
while (reader.pos < end) {
|
|
174
186
|
let [fieldNo, wireType] = reader.tag();
|
|
175
187
|
switch (fieldNo) {
|
|
176
|
-
case /*
|
|
188
|
+
case /* mochabugapis.adapt.plugins.v1.Manifest manifest */ 1:
|
|
177
189
|
message.data = {
|
|
178
190
|
oneofKind: "manifest",
|
|
179
191
|
manifest: Manifest.internalBinaryRead(reader, reader.uint32(), options, message.data.manifest)
|
|
180
192
|
};
|
|
181
193
|
break;
|
|
182
|
-
case /*
|
|
194
|
+
case /* mochabugapis.adapt.plugins.v1.File file */ 2:
|
|
183
195
|
message.data = {
|
|
184
196
|
oneofKind: "file",
|
|
185
197
|
file: File.internalBinaryRead(reader, reader.uint32(), options, message.data.file)
|
|
@@ -197,10 +209,10 @@ class UploadPluginRequest$Type extends MessageType {
|
|
|
197
209
|
return message;
|
|
198
210
|
}
|
|
199
211
|
internalBinaryWrite(message, writer, options) {
|
|
200
|
-
/*
|
|
212
|
+
/* mochabugapis.adapt.plugins.v1.Manifest manifest = 1; */
|
|
201
213
|
if (message.data.oneofKind === "manifest")
|
|
202
214
|
Manifest.internalBinaryWrite(message.data.manifest, writer.tag(1, WireType.LengthDelimited).fork(), options).join();
|
|
203
|
-
/*
|
|
215
|
+
/* mochabugapis.adapt.plugins.v1.File file = 2; */
|
|
204
216
|
if (message.data.oneofKind === "file")
|
|
205
217
|
File.internalBinaryWrite(message.data.file, writer.tag(2, WireType.LengthDelimited).fork(), options).join();
|
|
206
218
|
let u = options.writeUnknownFields;
|
|
@@ -210,13 +222,13 @@ class UploadPluginRequest$Type extends MessageType {
|
|
|
210
222
|
}
|
|
211
223
|
}
|
|
212
224
|
/**
|
|
213
|
-
* @generated MessageType for protobuf message
|
|
225
|
+
* @generated MessageType for protobuf message mochabugapis.adapt.plugins.v1.UploadPluginRequest
|
|
214
226
|
*/
|
|
215
227
|
const UploadPluginRequest = new UploadPluginRequest$Type();
|
|
216
228
|
// @generated message type with reflection information, may provide speed optimized methods
|
|
217
229
|
class UploadPluginResponse$Type extends MessageType {
|
|
218
230
|
constructor() {
|
|
219
|
-
super("
|
|
231
|
+
super("mochabugapis.adapt.plugins.v1.UploadPluginResponse", []);
|
|
220
232
|
}
|
|
221
233
|
create(value) {
|
|
222
234
|
const message = {};
|
|
@@ -226,7 +238,7 @@ class UploadPluginResponse$Type extends MessageType {
|
|
|
226
238
|
return message;
|
|
227
239
|
}
|
|
228
240
|
internalBinaryRead(reader, length, options, target) {
|
|
229
|
-
return target
|
|
241
|
+
return target ?? this.create();
|
|
230
242
|
}
|
|
231
243
|
internalBinaryWrite(message, writer, options) {
|
|
232
244
|
let u = options.writeUnknownFields;
|
|
@@ -236,13 +248,13 @@ class UploadPluginResponse$Type extends MessageType {
|
|
|
236
248
|
}
|
|
237
249
|
}
|
|
238
250
|
/**
|
|
239
|
-
* @generated MessageType for protobuf message
|
|
251
|
+
* @generated MessageType for protobuf message mochabugapis.adapt.plugins.v1.UploadPluginResponse
|
|
240
252
|
*/
|
|
241
253
|
const UploadPluginResponse = new UploadPluginResponse$Type();
|
|
242
254
|
// @generated message type with reflection information, may provide speed optimized methods
|
|
243
255
|
class File$Type extends MessageType {
|
|
244
256
|
constructor() {
|
|
245
|
-
super("
|
|
257
|
+
super("mochabugapis.adapt.plugins.v1.File", [
|
|
246
258
|
{ no: 1, name: "path", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
|
247
259
|
{ no: 2, name: "data", kind: "scalar", T: 12 /*ScalarType.BYTES*/ }
|
|
248
260
|
]);
|
|
@@ -255,7 +267,7 @@ class File$Type extends MessageType {
|
|
|
255
267
|
return message;
|
|
256
268
|
}
|
|
257
269
|
internalBinaryRead(reader, length, options, target) {
|
|
258
|
-
let message = target
|
|
270
|
+
let message = target ?? this.create(), end = reader.pos + length;
|
|
259
271
|
while (reader.pos < end) {
|
|
260
272
|
let [fieldNo, wireType] = reader.tag();
|
|
261
273
|
switch (fieldNo) {
|
|
@@ -290,13 +302,13 @@ class File$Type extends MessageType {
|
|
|
290
302
|
}
|
|
291
303
|
}
|
|
292
304
|
/**
|
|
293
|
-
* @generated MessageType for protobuf message
|
|
305
|
+
* @generated MessageType for protobuf message mochabugapis.adapt.plugins.v1.File
|
|
294
306
|
*/
|
|
295
307
|
const File = new File$Type();
|
|
296
308
|
// @generated message type with reflection information, may provide speed optimized methods
|
|
297
309
|
class Manifest$Type extends MessageType {
|
|
298
310
|
constructor() {
|
|
299
|
-
super("
|
|
311
|
+
super("mochabugapis.adapt.plugins.v1.Manifest", [
|
|
300
312
|
{ no: 1, name: "name", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
|
301
313
|
{ no: 2, name: "version", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
|
302
314
|
{ no: 3, name: "label", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
|
@@ -309,24 +321,21 @@ class Manifest$Type extends MessageType {
|
|
|
309
321
|
{ no: 10, name: "executor_esm", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
|
310
322
|
{ no: 11, name: "configurator_esm", kind: "scalar", opt: true, T: 9 /*ScalarType.STRING*/ },
|
|
311
323
|
{ no: 12, name: "assets_dir", kind: "scalar", opt: true, T: 9 /*ScalarType.STRING*/ },
|
|
312
|
-
{ no: 13, name: "
|
|
313
|
-
{ no: 14, name: "
|
|
314
|
-
{ no: 15, name: "
|
|
315
|
-
{ no: 16, name: "
|
|
316
|
-
{ no: 17, name: "plugin_mtls", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => MTLSService },
|
|
317
|
-
{ no: 18, name: "plugin_secrets", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => Secret },
|
|
318
|
-
{ no: 19, name: "oauth2", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => OAuth2Service }
|
|
324
|
+
{ no: 13, name: "vertices", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => Vertex },
|
|
325
|
+
{ no: 14, name: "oauth2", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => OAuth2Service },
|
|
326
|
+
{ no: 15, name: "variables", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => EnvironmentalVariable },
|
|
327
|
+
{ no: 16, name: "mtls", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => MTLSService }
|
|
319
328
|
]);
|
|
320
329
|
}
|
|
321
330
|
create(value) {
|
|
322
|
-
const message = { name: "", version: "", label: "", description: "", executorEsm: "", vertices: [],
|
|
331
|
+
const message = { name: "", version: "", label: "", description: "", executorEsm: "", vertices: [], oauth2: [], variables: [], mtls: [] };
|
|
323
332
|
globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
|
|
324
333
|
if (value !== undefined)
|
|
325
334
|
reflectionMergePartial(this, message, value);
|
|
326
335
|
return message;
|
|
327
336
|
}
|
|
328
337
|
internalBinaryRead(reader, length, options, target) {
|
|
329
|
-
let message = target
|
|
338
|
+
let message = target ?? this.create(), end = reader.pos + length;
|
|
330
339
|
while (reader.pos < end) {
|
|
331
340
|
let [fieldNo, wireType] = reader.tag();
|
|
332
341
|
switch (fieldNo) {
|
|
@@ -366,26 +375,17 @@ class Manifest$Type extends MessageType {
|
|
|
366
375
|
case /* optional string assets_dir */ 12:
|
|
367
376
|
message.assetsDir = reader.string();
|
|
368
377
|
break;
|
|
369
|
-
case /*
|
|
370
|
-
message.defaultConfig = reader.string();
|
|
371
|
-
break;
|
|
372
|
-
case /* repeated mochabug.adapt.plugins.v1.Vertex vertices */ 14:
|
|
378
|
+
case /* repeated mochabugapis.adapt.plugins.v1.Vertex vertices */ 13:
|
|
373
379
|
message.vertices.push(Vertex.internalBinaryRead(reader, reader.uint32(), options));
|
|
374
380
|
break;
|
|
375
|
-
case /* repeated
|
|
376
|
-
message.
|
|
377
|
-
break;
|
|
378
|
-
case /* repeated mochabug.adapt.plugins.v1.MTLSService user_mtls */ 16:
|
|
379
|
-
message.userMtls.push(MTLSService.internalBinaryRead(reader, reader.uint32(), options));
|
|
380
|
-
break;
|
|
381
|
-
case /* repeated mochabug.adapt.plugins.v1.MTLSService plugin_mtls */ 17:
|
|
382
|
-
message.pluginMtls.push(MTLSService.internalBinaryRead(reader, reader.uint32(), options));
|
|
381
|
+
case /* repeated mochabugapis.adapt.plugins.v1.OAuth2Service oauth2 */ 14:
|
|
382
|
+
message.oauth2.push(OAuth2Service.internalBinaryRead(reader, reader.uint32(), options));
|
|
383
383
|
break;
|
|
384
|
-
case /* repeated
|
|
385
|
-
message.
|
|
384
|
+
case /* repeated mochabugapis.adapt.plugins.v1.EnvironmentalVariable variables */ 15:
|
|
385
|
+
message.variables.push(EnvironmentalVariable.internalBinaryRead(reader, reader.uint32(), options));
|
|
386
386
|
break;
|
|
387
|
-
case /* repeated
|
|
388
|
-
message.
|
|
387
|
+
case /* repeated mochabugapis.adapt.plugins.v1.MTLSService mtls */ 16:
|
|
388
|
+
message.mtls.push(MTLSService.internalBinaryRead(reader, reader.uint32(), options));
|
|
389
389
|
break;
|
|
390
390
|
default:
|
|
391
391
|
let u = options.readUnknownField;
|
|
@@ -435,27 +435,18 @@ class Manifest$Type extends MessageType {
|
|
|
435
435
|
/* optional string assets_dir = 12; */
|
|
436
436
|
if (message.assetsDir !== undefined)
|
|
437
437
|
writer.tag(12, WireType.LengthDelimited).string(message.assetsDir);
|
|
438
|
-
/*
|
|
439
|
-
if (message.defaultConfig !== undefined)
|
|
440
|
-
writer.tag(13, WireType.LengthDelimited).string(message.defaultConfig);
|
|
441
|
-
/* repeated mochabug.adapt.plugins.v1.Vertex vertices = 14; */
|
|
438
|
+
/* repeated mochabugapis.adapt.plugins.v1.Vertex vertices = 13; */
|
|
442
439
|
for (let i = 0; i < message.vertices.length; i++)
|
|
443
|
-
Vertex.internalBinaryWrite(message.vertices[i], writer.tag(
|
|
444
|
-
/* repeated
|
|
445
|
-
for (let i = 0; i < message.userSecrets.length; i++)
|
|
446
|
-
Secret.internalBinaryWrite(message.userSecrets[i], writer.tag(15, WireType.LengthDelimited).fork(), options).join();
|
|
447
|
-
/* repeated mochabug.adapt.plugins.v1.MTLSService user_mtls = 16; */
|
|
448
|
-
for (let i = 0; i < message.userMtls.length; i++)
|
|
449
|
-
MTLSService.internalBinaryWrite(message.userMtls[i], writer.tag(16, WireType.LengthDelimited).fork(), options).join();
|
|
450
|
-
/* repeated mochabug.adapt.plugins.v1.MTLSService plugin_mtls = 17; */
|
|
451
|
-
for (let i = 0; i < message.pluginMtls.length; i++)
|
|
452
|
-
MTLSService.internalBinaryWrite(message.pluginMtls[i], writer.tag(17, WireType.LengthDelimited).fork(), options).join();
|
|
453
|
-
/* repeated mochabug.adapt.plugins.v1.Secret plugin_secrets = 18; */
|
|
454
|
-
for (let i = 0; i < message.pluginSecrets.length; i++)
|
|
455
|
-
Secret.internalBinaryWrite(message.pluginSecrets[i], writer.tag(18, WireType.LengthDelimited).fork(), options).join();
|
|
456
|
-
/* repeated mochabug.adapt.plugins.v1.OAuth2Service oauth2 = 19; */
|
|
440
|
+
Vertex.internalBinaryWrite(message.vertices[i], writer.tag(13, WireType.LengthDelimited).fork(), options).join();
|
|
441
|
+
/* repeated mochabugapis.adapt.plugins.v1.OAuth2Service oauth2 = 14; */
|
|
457
442
|
for (let i = 0; i < message.oauth2.length; i++)
|
|
458
|
-
OAuth2Service.internalBinaryWrite(message.oauth2[i], writer.tag(
|
|
443
|
+
OAuth2Service.internalBinaryWrite(message.oauth2[i], writer.tag(14, WireType.LengthDelimited).fork(), options).join();
|
|
444
|
+
/* repeated mochabugapis.adapt.plugins.v1.EnvironmentalVariable variables = 15; */
|
|
445
|
+
for (let i = 0; i < message.variables.length; i++)
|
|
446
|
+
EnvironmentalVariable.internalBinaryWrite(message.variables[i], writer.tag(15, WireType.LengthDelimited).fork(), options).join();
|
|
447
|
+
/* repeated mochabugapis.adapt.plugins.v1.MTLSService mtls = 16; */
|
|
448
|
+
for (let i = 0; i < message.mtls.length; i++)
|
|
449
|
+
MTLSService.internalBinaryWrite(message.mtls[i], writer.tag(16, WireType.LengthDelimited).fork(), options).join();
|
|
459
450
|
let u = options.writeUnknownFields;
|
|
460
451
|
if (u !== false)
|
|
461
452
|
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
@@ -463,47 +454,47 @@ class Manifest$Type extends MessageType {
|
|
|
463
454
|
}
|
|
464
455
|
}
|
|
465
456
|
/**
|
|
466
|
-
* @generated MessageType for protobuf message
|
|
457
|
+
* @generated MessageType for protobuf message mochabugapis.adapt.plugins.v1.Manifest
|
|
467
458
|
*/
|
|
468
459
|
const Manifest = new Manifest$Type();
|
|
469
460
|
// @generated message type with reflection information, may provide speed optimized methods
|
|
470
461
|
class MTLSService$Type extends MessageType {
|
|
471
462
|
constructor() {
|
|
472
|
-
super("
|
|
463
|
+
super("mochabugapis.adapt.plugins.v1.MTLSService", [
|
|
473
464
|
{ no: 1, name: "name", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
|
474
|
-
{ no: 2, name: "
|
|
475
|
-
{ no: 3, name: "
|
|
476
|
-
{ no: 4, name: "
|
|
477
|
-
{ no: 5, name: "
|
|
465
|
+
{ no: 2, name: "trusted_ca", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
|
466
|
+
{ no: 3, name: "label", kind: "scalar", opt: true, T: 9 /*ScalarType.STRING*/ },
|
|
467
|
+
{ no: 4, name: "description", kind: "scalar", opt: true, T: 9 /*ScalarType.STRING*/ },
|
|
468
|
+
{ no: 5, name: "optional", kind: "scalar", opt: true, T: 8 /*ScalarType.BOOL*/ }
|
|
478
469
|
]);
|
|
479
470
|
}
|
|
480
471
|
create(value) {
|
|
481
|
-
const message = { name: "",
|
|
472
|
+
const message = { name: "", trustedCa: "" };
|
|
482
473
|
globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
|
|
483
474
|
if (value !== undefined)
|
|
484
475
|
reflectionMergePartial(this, message, value);
|
|
485
476
|
return message;
|
|
486
477
|
}
|
|
487
478
|
internalBinaryRead(reader, length, options, target) {
|
|
488
|
-
let message = target
|
|
479
|
+
let message = target ?? this.create(), end = reader.pos + length;
|
|
489
480
|
while (reader.pos < end) {
|
|
490
481
|
let [fieldNo, wireType] = reader.tag();
|
|
491
482
|
switch (fieldNo) {
|
|
492
483
|
case /* string name */ 1:
|
|
493
484
|
message.name = reader.string();
|
|
494
485
|
break;
|
|
495
|
-
case /*
|
|
496
|
-
message.optional = reader.bool();
|
|
497
|
-
break;
|
|
498
|
-
case /* string trusted_ca */ 3:
|
|
486
|
+
case /* string trusted_ca */ 2:
|
|
499
487
|
message.trustedCa = reader.string();
|
|
500
488
|
break;
|
|
501
|
-
case /* optional string label */
|
|
489
|
+
case /* optional string label */ 3:
|
|
502
490
|
message.label = reader.string();
|
|
503
491
|
break;
|
|
504
|
-
case /* optional string description */
|
|
492
|
+
case /* optional string description */ 4:
|
|
505
493
|
message.description = reader.string();
|
|
506
494
|
break;
|
|
495
|
+
case /* optional bool optional */ 5:
|
|
496
|
+
message.optional = reader.bool();
|
|
497
|
+
break;
|
|
507
498
|
default:
|
|
508
499
|
let u = options.readUnknownField;
|
|
509
500
|
if (u === "throw")
|
|
@@ -519,18 +510,18 @@ class MTLSService$Type extends MessageType {
|
|
|
519
510
|
/* string name = 1; */
|
|
520
511
|
if (message.name !== "")
|
|
521
512
|
writer.tag(1, WireType.LengthDelimited).string(message.name);
|
|
522
|
-
/*
|
|
523
|
-
if (message.optional !== false)
|
|
524
|
-
writer.tag(2, WireType.Varint).bool(message.optional);
|
|
525
|
-
/* string trusted_ca = 3; */
|
|
513
|
+
/* string trusted_ca = 2; */
|
|
526
514
|
if (message.trustedCa !== "")
|
|
527
|
-
writer.tag(
|
|
528
|
-
/* optional string label =
|
|
515
|
+
writer.tag(2, WireType.LengthDelimited).string(message.trustedCa);
|
|
516
|
+
/* optional string label = 3; */
|
|
529
517
|
if (message.label !== undefined)
|
|
530
|
-
writer.tag(
|
|
531
|
-
/* optional string description =
|
|
518
|
+
writer.tag(3, WireType.LengthDelimited).string(message.label);
|
|
519
|
+
/* optional string description = 4; */
|
|
532
520
|
if (message.description !== undefined)
|
|
533
|
-
writer.tag(
|
|
521
|
+
writer.tag(4, WireType.LengthDelimited).string(message.description);
|
|
522
|
+
/* optional bool optional = 5; */
|
|
523
|
+
if (message.optional !== undefined)
|
|
524
|
+
writer.tag(5, WireType.Varint).bool(message.optional);
|
|
534
525
|
let u = options.writeUnknownFields;
|
|
535
526
|
if (u !== false)
|
|
536
527
|
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
@@ -538,45 +529,41 @@ class MTLSService$Type extends MessageType {
|
|
|
538
529
|
}
|
|
539
530
|
}
|
|
540
531
|
/**
|
|
541
|
-
* @generated MessageType for protobuf message
|
|
532
|
+
* @generated MessageType for protobuf message mochabugapis.adapt.plugins.v1.MTLSService
|
|
542
533
|
*/
|
|
543
534
|
const MTLSService = new MTLSService$Type();
|
|
544
535
|
// @generated message type with reflection information, may provide speed optimized methods
|
|
545
536
|
class OAuth2Service$Type extends MessageType {
|
|
546
537
|
constructor() {
|
|
547
|
-
super("
|
|
538
|
+
super("mochabugapis.adapt.plugins.v1.OAuth2Service", [
|
|
548
539
|
{ no: 1, name: "name", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
|
549
|
-
{ no: 2, name: "
|
|
550
|
-
{ no: 3, name: "
|
|
551
|
-
{ no: 4, name: "
|
|
552
|
-
{ no: 5, name: "description", kind: "scalar", opt: true, T: 9 /*ScalarType.STRING*/ }
|
|
540
|
+
{ no: 2, name: "grant_type", kind: "enum", T: () => ["mochabugapis.adapt.plugins.v1.OAuth2Service.GrantType", OAuth2Service_GrantType, "GRANT_TYPE_"] },
|
|
541
|
+
{ no: 3, name: "label", kind: "scalar", opt: true, T: 9 /*ScalarType.STRING*/ },
|
|
542
|
+
{ no: 4, name: "description", kind: "scalar", opt: true, T: 9 /*ScalarType.STRING*/ }
|
|
553
543
|
]);
|
|
554
544
|
}
|
|
555
545
|
create(value) {
|
|
556
|
-
const message = { name: "",
|
|
546
|
+
const message = { name: "", grantType: 0 };
|
|
557
547
|
globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
|
|
558
548
|
if (value !== undefined)
|
|
559
549
|
reflectionMergePartial(this, message, value);
|
|
560
550
|
return message;
|
|
561
551
|
}
|
|
562
552
|
internalBinaryRead(reader, length, options, target) {
|
|
563
|
-
let message = target
|
|
553
|
+
let message = target ?? this.create(), end = reader.pos + length;
|
|
564
554
|
while (reader.pos < end) {
|
|
565
555
|
let [fieldNo, wireType] = reader.tag();
|
|
566
556
|
switch (fieldNo) {
|
|
567
557
|
case /* string name */ 1:
|
|
568
558
|
message.name = reader.string();
|
|
569
559
|
break;
|
|
570
|
-
case /*
|
|
571
|
-
message.optional = reader.bool();
|
|
572
|
-
break;
|
|
573
|
-
case /* mochabug.adapt.plugins.v1.OAuth2Service.GrantType grant_type */ 3:
|
|
560
|
+
case /* mochabugapis.adapt.plugins.v1.OAuth2Service.GrantType grant_type */ 2:
|
|
574
561
|
message.grantType = reader.int32();
|
|
575
562
|
break;
|
|
576
|
-
case /* optional string label */
|
|
563
|
+
case /* optional string label */ 3:
|
|
577
564
|
message.label = reader.string();
|
|
578
565
|
break;
|
|
579
|
-
case /* optional string description */
|
|
566
|
+
case /* optional string description */ 4:
|
|
580
567
|
message.description = reader.string();
|
|
581
568
|
break;
|
|
582
569
|
default:
|
|
@@ -594,18 +581,15 @@ class OAuth2Service$Type extends MessageType {
|
|
|
594
581
|
/* string name = 1; */
|
|
595
582
|
if (message.name !== "")
|
|
596
583
|
writer.tag(1, WireType.LengthDelimited).string(message.name);
|
|
597
|
-
/*
|
|
598
|
-
if (message.optional !== false)
|
|
599
|
-
writer.tag(2, WireType.Varint).bool(message.optional);
|
|
600
|
-
/* mochabug.adapt.plugins.v1.OAuth2Service.GrantType grant_type = 3; */
|
|
584
|
+
/* mochabugapis.adapt.plugins.v1.OAuth2Service.GrantType grant_type = 2; */
|
|
601
585
|
if (message.grantType !== 0)
|
|
602
|
-
writer.tag(
|
|
603
|
-
/* optional string label =
|
|
586
|
+
writer.tag(2, WireType.Varint).int32(message.grantType);
|
|
587
|
+
/* optional string label = 3; */
|
|
604
588
|
if (message.label !== undefined)
|
|
605
|
-
writer.tag(
|
|
606
|
-
/* optional string description =
|
|
589
|
+
writer.tag(3, WireType.LengthDelimited).string(message.label);
|
|
590
|
+
/* optional string description = 4; */
|
|
607
591
|
if (message.description !== undefined)
|
|
608
|
-
writer.tag(
|
|
592
|
+
writer.tag(4, WireType.LengthDelimited).string(message.description);
|
|
609
593
|
let u = options.writeUnknownFields;
|
|
610
594
|
if (u !== false)
|
|
611
595
|
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
@@ -613,43 +597,110 @@ class OAuth2Service$Type extends MessageType {
|
|
|
613
597
|
}
|
|
614
598
|
}
|
|
615
599
|
/**
|
|
616
|
-
* @generated MessageType for protobuf message
|
|
600
|
+
* @generated MessageType for protobuf message mochabugapis.adapt.plugins.v1.OAuth2Service
|
|
617
601
|
*/
|
|
618
602
|
const OAuth2Service = new OAuth2Service$Type();
|
|
619
603
|
// @generated message type with reflection information, may provide speed optimized methods
|
|
620
|
-
class
|
|
604
|
+
class EnvironmentalVariable$Type extends MessageType {
|
|
621
605
|
constructor() {
|
|
622
|
-
super("
|
|
606
|
+
super("mochabugapis.adapt.plugins.v1.EnvironmentalVariable", [
|
|
623
607
|
{ no: 1, name: "name", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
|
624
|
-
{ no: 2, name: "
|
|
625
|
-
{ no: 3, name: "
|
|
626
|
-
{ no: 4, name: "
|
|
608
|
+
{ no: 2, name: "label", kind: "scalar", opt: true, T: 9 /*ScalarType.STRING*/ },
|
|
609
|
+
{ no: 3, name: "description", kind: "scalar", opt: true, T: 9 /*ScalarType.STRING*/ },
|
|
610
|
+
{ no: 4, name: "type", kind: "enum", T: () => ["mochabugapis.adapt.plugins.v1.EnvironmentalVariable.Type", EnvironmentalVariable_Type, "TYPE_"] },
|
|
611
|
+
{ no: 5, name: "optional", kind: "scalar", opt: true, T: 8 /*ScalarType.BOOL*/ }
|
|
627
612
|
]);
|
|
628
613
|
}
|
|
629
614
|
create(value) {
|
|
630
|
-
const message = { name: "",
|
|
615
|
+
const message = { name: "", type: 0 };
|
|
631
616
|
globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
|
|
632
617
|
if (value !== undefined)
|
|
633
618
|
reflectionMergePartial(this, message, value);
|
|
634
619
|
return message;
|
|
635
620
|
}
|
|
636
621
|
internalBinaryRead(reader, length, options, target) {
|
|
637
|
-
let message = target
|
|
622
|
+
let message = target ?? this.create(), end = reader.pos + length;
|
|
638
623
|
while (reader.pos < end) {
|
|
639
624
|
let [fieldNo, wireType] = reader.tag();
|
|
640
625
|
switch (fieldNo) {
|
|
641
626
|
case /* string name */ 1:
|
|
642
627
|
message.name = reader.string();
|
|
643
628
|
break;
|
|
644
|
-
case /*
|
|
645
|
-
message.optional = reader.bool();
|
|
646
|
-
break;
|
|
647
|
-
case /* optional string label */ 3:
|
|
629
|
+
case /* optional string label */ 2:
|
|
648
630
|
message.label = reader.string();
|
|
649
631
|
break;
|
|
650
|
-
case /* optional string description */
|
|
632
|
+
case /* optional string description */ 3:
|
|
651
633
|
message.description = reader.string();
|
|
652
634
|
break;
|
|
635
|
+
case /* mochabugapis.adapt.plugins.v1.EnvironmentalVariable.Type type */ 4:
|
|
636
|
+
message.type = reader.int32();
|
|
637
|
+
break;
|
|
638
|
+
case /* optional bool optional */ 5:
|
|
639
|
+
message.optional = reader.bool();
|
|
640
|
+
break;
|
|
641
|
+
default:
|
|
642
|
+
let u = options.readUnknownField;
|
|
643
|
+
if (u === "throw")
|
|
644
|
+
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
|
645
|
+
let d = reader.skip(wireType);
|
|
646
|
+
if (u !== false)
|
|
647
|
+
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
return message;
|
|
651
|
+
}
|
|
652
|
+
internalBinaryWrite(message, writer, options) {
|
|
653
|
+
/* string name = 1; */
|
|
654
|
+
if (message.name !== "")
|
|
655
|
+
writer.tag(1, WireType.LengthDelimited).string(message.name);
|
|
656
|
+
/* optional string label = 2; */
|
|
657
|
+
if (message.label !== undefined)
|
|
658
|
+
writer.tag(2, WireType.LengthDelimited).string(message.label);
|
|
659
|
+
/* optional string description = 3; */
|
|
660
|
+
if (message.description !== undefined)
|
|
661
|
+
writer.tag(3, WireType.LengthDelimited).string(message.description);
|
|
662
|
+
/* mochabugapis.adapt.plugins.v1.EnvironmentalVariable.Type type = 4; */
|
|
663
|
+
if (message.type !== 0)
|
|
664
|
+
writer.tag(4, WireType.Varint).int32(message.type);
|
|
665
|
+
/* optional bool optional = 5; */
|
|
666
|
+
if (message.optional !== undefined)
|
|
667
|
+
writer.tag(5, WireType.Varint).bool(message.optional);
|
|
668
|
+
let u = options.writeUnknownFields;
|
|
669
|
+
if (u !== false)
|
|
670
|
+
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
671
|
+
return writer;
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* @generated MessageType for protobuf message mochabugapis.adapt.plugins.v1.EnvironmentalVariable
|
|
676
|
+
*/
|
|
677
|
+
const EnvironmentalVariable = new EnvironmentalVariable$Type();
|
|
678
|
+
// @generated message type with reflection information, may provide speed optimized methods
|
|
679
|
+
class ServiceBinding$Type extends MessageType {
|
|
680
|
+
constructor() {
|
|
681
|
+
super("mochabugapis.adapt.plugins.v1.ServiceBinding", [
|
|
682
|
+
{ no: 1, name: "name", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
|
683
|
+
{ no: 2, name: "optional", kind: "scalar", T: 8 /*ScalarType.BOOL*/ }
|
|
684
|
+
]);
|
|
685
|
+
}
|
|
686
|
+
create(value) {
|
|
687
|
+
const message = { name: "", optional: false };
|
|
688
|
+
globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
|
|
689
|
+
if (value !== undefined)
|
|
690
|
+
reflectionMergePartial(this, message, value);
|
|
691
|
+
return message;
|
|
692
|
+
}
|
|
693
|
+
internalBinaryRead(reader, length, options, target) {
|
|
694
|
+
let message = target ?? this.create(), end = reader.pos + length;
|
|
695
|
+
while (reader.pos < end) {
|
|
696
|
+
let [fieldNo, wireType] = reader.tag();
|
|
697
|
+
switch (fieldNo) {
|
|
698
|
+
case /* string name */ 1:
|
|
699
|
+
message.name = reader.string();
|
|
700
|
+
break;
|
|
701
|
+
case /* bool optional */ 2:
|
|
702
|
+
message.optional = reader.bool();
|
|
703
|
+
break;
|
|
653
704
|
default:
|
|
654
705
|
let u = options.readUnknownField;
|
|
655
706
|
if (u === "throw")
|
|
@@ -668,12 +719,6 @@ class Secret$Type extends MessageType {
|
|
|
668
719
|
/* bool optional = 2; */
|
|
669
720
|
if (message.optional !== false)
|
|
670
721
|
writer.tag(2, WireType.Varint).bool(message.optional);
|
|
671
|
-
/* optional string label = 3; */
|
|
672
|
-
if (message.label !== undefined)
|
|
673
|
-
writer.tag(3, WireType.LengthDelimited).string(message.label);
|
|
674
|
-
/* optional string description = 4; */
|
|
675
|
-
if (message.description !== undefined)
|
|
676
|
-
writer.tag(4, WireType.LengthDelimited).string(message.description);
|
|
677
722
|
let u = options.writeUnknownFields;
|
|
678
723
|
if (u !== false)
|
|
679
724
|
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
@@ -681,33 +726,34 @@ class Secret$Type extends MessageType {
|
|
|
681
726
|
}
|
|
682
727
|
}
|
|
683
728
|
/**
|
|
684
|
-
* @generated MessageType for protobuf message
|
|
729
|
+
* @generated MessageType for protobuf message mochabugapis.adapt.plugins.v1.ServiceBinding
|
|
685
730
|
*/
|
|
686
|
-
const
|
|
731
|
+
const ServiceBinding = new ServiceBinding$Type();
|
|
687
732
|
// @generated message type with reflection information, may provide speed optimized methods
|
|
688
733
|
class Vertex$Type extends MessageType {
|
|
689
734
|
constructor() {
|
|
690
|
-
super("
|
|
735
|
+
super("mochabugapis.adapt.plugins.v1.Vertex", [
|
|
691
736
|
{ no: 1, name: "name", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
|
692
737
|
{ no: 2, name: "label", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
|
693
738
|
{ no: 3, name: "description", kind: "scalar", opt: true, T: 9 /*ScalarType.STRING*/ },
|
|
694
739
|
{ no: 4, name: "logo", kind: "scalar", opt: true, T: 9 /*ScalarType.STRING*/ },
|
|
695
|
-
{ no: 5, name: "type", kind: "enum", T: () => ["
|
|
740
|
+
{ no: 5, name: "type", kind: "enum", T: () => ["mochabugapis.adapt.plugins.v1.Vertex.VertexType", Vertex_VertexType, "VERTEX_TYPE_"] },
|
|
696
741
|
{ no: 6, name: "default_config", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
|
697
742
|
{ no: 7, name: "has_configurator", kind: "scalar", T: 8 /*ScalarType.BOOL*/ },
|
|
698
|
-
{ no: 8, name: "
|
|
699
|
-
{ no: 9, name: "
|
|
743
|
+
{ no: 8, name: "variables", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => EnvironmentalVariable },
|
|
744
|
+
{ no: 9, name: "mtls", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => MTLSService },
|
|
745
|
+
{ no: 10, name: "oauth2", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => ServiceBinding }
|
|
700
746
|
]);
|
|
701
747
|
}
|
|
702
748
|
create(value) {
|
|
703
|
-
const message = { name: "", label: "", type: 0, defaultConfig: "", hasConfigurator: false };
|
|
749
|
+
const message = { name: "", label: "", type: 0, defaultConfig: "", hasConfigurator: false, variables: [], mtls: [], oauth2: [] };
|
|
704
750
|
globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
|
|
705
751
|
if (value !== undefined)
|
|
706
752
|
reflectionMergePartial(this, message, value);
|
|
707
753
|
return message;
|
|
708
754
|
}
|
|
709
755
|
internalBinaryRead(reader, length, options, target) {
|
|
710
|
-
let message = target
|
|
756
|
+
let message = target ?? this.create(), end = reader.pos + length;
|
|
711
757
|
while (reader.pos < end) {
|
|
712
758
|
let [fieldNo, wireType] = reader.tag();
|
|
713
759
|
switch (fieldNo) {
|
|
@@ -723,7 +769,7 @@ class Vertex$Type extends MessageType {
|
|
|
723
769
|
case /* optional string logo */ 4:
|
|
724
770
|
message.logo = reader.string();
|
|
725
771
|
break;
|
|
726
|
-
case /*
|
|
772
|
+
case /* mochabugapis.adapt.plugins.v1.Vertex.VertexType type */ 5:
|
|
727
773
|
message.type = reader.int32();
|
|
728
774
|
break;
|
|
729
775
|
case /* string default_config */ 6:
|
|
@@ -732,11 +778,14 @@ class Vertex$Type extends MessageType {
|
|
|
732
778
|
case /* bool has_configurator */ 7:
|
|
733
779
|
message.hasConfigurator = reader.bool();
|
|
734
780
|
break;
|
|
735
|
-
case /*
|
|
736
|
-
message.
|
|
781
|
+
case /* repeated mochabugapis.adapt.plugins.v1.EnvironmentalVariable variables */ 8:
|
|
782
|
+
message.variables.push(EnvironmentalVariable.internalBinaryRead(reader, reader.uint32(), options));
|
|
783
|
+
break;
|
|
784
|
+
case /* repeated mochabugapis.adapt.plugins.v1.MTLSService mtls */ 9:
|
|
785
|
+
message.mtls.push(MTLSService.internalBinaryRead(reader, reader.uint32(), options));
|
|
737
786
|
break;
|
|
738
|
-
case /*
|
|
739
|
-
message.
|
|
787
|
+
case /* repeated mochabugapis.adapt.plugins.v1.ServiceBinding oauth2 */ 10:
|
|
788
|
+
message.oauth2.push(ServiceBinding.internalBinaryRead(reader, reader.uint32(), options));
|
|
740
789
|
break;
|
|
741
790
|
default:
|
|
742
791
|
let u = options.readUnknownField;
|
|
@@ -762,7 +811,7 @@ class Vertex$Type extends MessageType {
|
|
|
762
811
|
/* optional string logo = 4; */
|
|
763
812
|
if (message.logo !== undefined)
|
|
764
813
|
writer.tag(4, WireType.LengthDelimited).string(message.logo);
|
|
765
|
-
/*
|
|
814
|
+
/* mochabugapis.adapt.plugins.v1.Vertex.VertexType type = 5; */
|
|
766
815
|
if (message.type !== 0)
|
|
767
816
|
writer.tag(5, WireType.Varint).int32(message.type);
|
|
768
817
|
/* string default_config = 6; */
|
|
@@ -771,12 +820,15 @@ class Vertex$Type extends MessageType {
|
|
|
771
820
|
/* bool has_configurator = 7; */
|
|
772
821
|
if (message.hasConfigurator !== false)
|
|
773
822
|
writer.tag(7, WireType.Varint).bool(message.hasConfigurator);
|
|
774
|
-
/*
|
|
775
|
-
|
|
776
|
-
writer.tag(8, WireType.
|
|
777
|
-
/*
|
|
778
|
-
|
|
779
|
-
writer.tag(9, WireType.
|
|
823
|
+
/* repeated mochabugapis.adapt.plugins.v1.EnvironmentalVariable variables = 8; */
|
|
824
|
+
for (let i = 0; i < message.variables.length; i++)
|
|
825
|
+
EnvironmentalVariable.internalBinaryWrite(message.variables[i], writer.tag(8, WireType.LengthDelimited).fork(), options).join();
|
|
826
|
+
/* repeated mochabugapis.adapt.plugins.v1.MTLSService mtls = 9; */
|
|
827
|
+
for (let i = 0; i < message.mtls.length; i++)
|
|
828
|
+
MTLSService.internalBinaryWrite(message.mtls[i], writer.tag(9, WireType.LengthDelimited).fork(), options).join();
|
|
829
|
+
/* repeated mochabugapis.adapt.plugins.v1.ServiceBinding oauth2 = 10; */
|
|
830
|
+
for (let i = 0; i < message.oauth2.length; i++)
|
|
831
|
+
ServiceBinding.internalBinaryWrite(message.oauth2[i], writer.tag(10, WireType.LengthDelimited).fork(), options).join();
|
|
780
832
|
let u = options.writeUnknownFields;
|
|
781
833
|
if (u !== false)
|
|
782
834
|
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
@@ -784,27 +836,28 @@ class Vertex$Type extends MessageType {
|
|
|
784
836
|
}
|
|
785
837
|
}
|
|
786
838
|
/**
|
|
787
|
-
* @generated MessageType for protobuf message
|
|
839
|
+
* @generated MessageType for protobuf message mochabugapis.adapt.plugins.v1.Vertex
|
|
788
840
|
*/
|
|
789
841
|
const Vertex = new Vertex$Type();
|
|
790
842
|
/**
|
|
791
|
-
* @generated ServiceType for protobuf service
|
|
843
|
+
* @generated ServiceType for protobuf service mochabugapis.adapt.plugins.v1.PluginService
|
|
792
844
|
*/
|
|
793
|
-
const PluginService = new ServiceType("
|
|
845
|
+
const PluginService = new ServiceType("mochabugapis.adapt.plugins.v1.PluginService", [
|
|
794
846
|
{ name: "UploadPlugin", clientStreaming: true, options: { "google.api.http": { post: "/v1/plugins/upload", body: "*" } }, I: UploadPluginRequest, O: UploadPluginResponse }
|
|
795
847
|
], { "google.api.default_host": "adapt.mochabugapis.com", "google.api.oauth_scopes": "https://www.mochabugapis.com/auth/adapt.plugins" });
|
|
796
848
|
|
|
797
849
|
/**
|
|
798
850
|
* PluginService provides a service for uploading a plugin.
|
|
799
851
|
*
|
|
800
|
-
* @generated from protobuf service
|
|
852
|
+
* @generated from protobuf service mochabugapis.adapt.plugins.v1.PluginService
|
|
801
853
|
*/
|
|
802
854
|
class PluginServiceClient {
|
|
855
|
+
_transport;
|
|
856
|
+
typeName = PluginService.typeName;
|
|
857
|
+
methods = PluginService.methods;
|
|
858
|
+
options = PluginService.options;
|
|
803
859
|
constructor(_transport) {
|
|
804
860
|
this._transport = _transport;
|
|
805
|
-
this.typeName = PluginService.typeName;
|
|
806
|
-
this.methods = PluginService.methods;
|
|
807
|
-
this.options = PluginService.options;
|
|
808
861
|
}
|
|
809
862
|
/**
|
|
810
863
|
* UploadPlugin is a streaming RPC method that allows uploading a plugin in
|
|
@@ -812,7 +865,7 @@ class PluginServiceClient {
|
|
|
812
865
|
* server will respond with a single UploadPluginResponse after processing all
|
|
813
866
|
* requests.
|
|
814
867
|
*
|
|
815
|
-
* @generated from protobuf rpc: UploadPlugin(stream
|
|
868
|
+
* @generated from protobuf rpc: UploadPlugin(stream mochabugapis.adapt.plugins.v1.UploadPluginRequest) returns (mochabugapis.adapt.plugins.v1.UploadPluginResponse);
|
|
816
869
|
*/
|
|
817
870
|
uploadPlugin(options) {
|
|
818
871
|
const method = this.methods[0], opt = this._transport.mergeOptions(options);
|
|
@@ -820,6 +873,30 @@ class PluginServiceClient {
|
|
|
820
873
|
}
|
|
821
874
|
}
|
|
822
875
|
|
|
876
|
+
var externalConfigTemplate = "import { VertexConfig } from '@mochabug/adapt-plugin-toolkit/api';\nimport { ExternalConfiguratorRouter } from '@mochabug/adapt-plugin-toolkit/router';\n\nexport const router = new ExternalConfiguratorRouter()\n .useRequestLogging()\n .useBearerAuthorization(['/api'])\n .add('GET', '/api/config', async (_req, api) => {\n const res = await api.getVertexConfig<VertexConfig>();\n if (!res.ok) {\n console.error(res);\n return new Response(res.errorMessage, { status: res.errorStatus });\n }\n return new Response(JSON.stringify(res.data!), {\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n })\n .add('GET', '(/?)', async () => {\n return new Response(getHelloWorldPage(), {\n headers: {\n 'Content-Type': 'text/html',\n },\n });\n });\n\nfunction getHelloWorldPage(): string {\n return `\n <html>\n <head>\n <style>\n @import url('https://fonts.googleapis.com/css2?family=Orbitron&display=swap');\n @keyframes glow {\n 0% { text-shadow: 0 0 5px #0f0, 0 0 10px #0f0, 0 0 15px #0f0, 0 0 20px #0f0; }\n 100% { text-shadow: 0 0 10px #0f0, 0 0 20px #0f0, 0 0 30px #0f0, 0 0 40px #0f0; }\n }\n body {\n background-color: #000;\n color: #0f0;\n font-family: 'Orbitron', sans-serif;\n text-align: center;\n overflow: hidden;\n margin: 0;\n padding: 0;\n }\n h1 {\n position: absolute;\n top: 30%;\n left: 50%;\n transform: translate(-50%, -50%);\n font-size: 3em;\n text-transform: uppercase;\n letter-spacing: 4px;\n animation: glow 2s infinite alternate;\n }\n #jsonOutput {\n position: absolute;\n top: 70%;\n left: 50%;\n transform: translate(-50%, -50%);\n font-size: 1.5em;\n text-transform: uppercase;\n letter-spacing: 2px;\n animation: glow 2s infinite alternate;\n }\n button {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n background-color: #0f0;\n border: none;\n color: black;\n padding: 15px 32px;\n text-align: center;\n text-decoration: none;\n display: inline-block;\n font-size: 20px; /* Increase the font size */\n margin: 4px 2px;\n cursor: pointer;\n transition-duration: 0.4s;\n animation: glow 2s infinite alternate;\n font-family: 'Orbitron', sans-serif;\n border-radius: 15px;\n transform: rotate(-10deg) skew(10deg, 10deg);\n }\n </style>\n </head>\n <body>\n <h1>Hello, World!</h1>\n <button id=\"assimilateButton\">Assimilate</button>\n <pre id=\"jsonOutput\"></pre>\n <script>\n document.getElementById('assimilateButton').addEventListener('click', function() {\n const hash = window.location.hash.substr(1).trim();\n const token = decodeURIComponent(hash); \n fetch('/api/config', {\n method: 'GET',\n headers: {\n 'Authorization': 'Bearer ' + token\n }\n })\n .then(response => response.json())\n .then(data => {\n document.getElementById('jsonOutput').innerText = JSON.stringify(data, null, 2);\n this.style.display = 'none'; /* Hide button after being clicked */\n })\n .catch(error => {\n console.error('Error:', error);\n document.getElementById('jsonOutput').innerText = 'Error occurred while assimilating data';\n });\n });\n </script>\n </body>\n </html>\n `;\n}\n";
|
|
877
|
+
|
|
878
|
+
var internalConfigTemplate = "import { InternalConfiguratorRouter } from '@mochabug/adapt-plugin-toolkit/router';\n/**\n * A `InternalConfiguratorRouter` instance configured to handle internal platform calls for the vertex during configuration.\n *\n * There are no events to handle at the moment\n */\nexport const router = new InternalConfiguratorRouter();\n";
|
|
879
|
+
|
|
880
|
+
var browserExecTempalte = "import { ExternalExecutorRouter } from '@mochabug/adapt-plugin-toolkit/router';\n\nexport const router = new ExternalExecutorRouter()\n .useRequestLogging()\n .useBearerAuthorization(['/api'])\n .add('POST', '/api/done', async (req, api, _route, ctx) => {\n const sapi = api.getSessionApi(req.headers.get('Authorization')!);\n ctx.waitUntil(sapi.complete('output', {}));\n return new Response();\n })\n .add('GET', '(/?)', async () => {\n return new Response(getSamplePage(), {\n headers: {\n 'Content-Type': 'text/html',\n },\n });\n });\n\nfunction getSamplePage(): string {\n return `\n <html>\n <head>\n <style>\n @import url('https://fonts.googleapis.com/css2?family=Orbitron&display=swap');\n @keyframes glow {\n 0% { text-shadow: 0 0 5px #0f0, 0 0 10px #0f0, 0 0 15px #0f0, 0 0 20px #0f0; }\n 100% { text-shadow: 0 0 10px #0f0, 0 0 20px #0f0, 0 0 30px #0f0, 0 0 40px #0f0; }\n }\n body {\n background-color: #000;\n color: #0f0;\n font-family: 'Orbitron', sans-serif;\n text-align: center;\n overflow: hidden;\n margin: 0;\n padding: 0;\n }\n button {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n background-color: #0f0;\n border: none;\n color: black;\n padding: 15px 32px;\n text-align: center;\n text-decoration: none;\n display: inline-block;\n font-size: 20px;\n margin: 4px 2px;\n cursor: pointer;\n transition-duration: 0.4s;\n animation: glow 2s infinite alternate;\n font-family: 'Orbitron', sans-serif;\n border-radius: 15px;\n transform: rotate(-10deg) skew(10deg, 10deg);\n }\n </style>\n </head>\n <body>\n <button id=\"doneButton\">Done</button>\n <script>\n document.getElementById('doneButton').addEventListener('click', function() {\n const hash = window.location.hash.substr(1).trim();\n const token = decodeURIComponent(hash); \n fetch('/api/done', {\n method: 'POST',\n headers: {\n 'Authorization': 'Bearer ' + token\n }\n })\n .then(data => {\n this.innerText = 'Done';\n })\n .catch(error => {\n console.error('Error:', error);\n });\n });\n </script>\n </body>\n </html>\n `;\n}\n";
|
|
881
|
+
|
|
882
|
+
var cronExecTemplate = "import { CronExecutorRouter } from '@mochabug/adapt-plugin-toolkit/router';\n\nexport const router = new CronExecutorRouter()\n .onStart(async (req, _api) => {\n const start = await req.json<StartExecutionRequest>();\n console.log('Start has been called');\n console.log(start);\n })\n .onStop(async (_req, _api) => {\n console.log('Stop has been called');\n })\n .onCron(async (_req, _api) => {\n console.log('Received cron event');\n })\n .onStream(async (req, _api, name) => {\n console.log(`Stream ${name} has been called`);\n const res = await req.json<StreamResult>();\n console.log(res);\n })\n .onProcedure(async (req, _api, name) => {\n console.log(`Procedure ${name} has been called`);\n const res = await req.json<ProcedureResult>();\n console.log(res);\n });\n";
|
|
883
|
+
|
|
884
|
+
var triggerExecTemplate = "import { ExternalExecutorRouter } from '@mochabug/adapt-plugin-toolkit/router';\n\nexport const router = new ExternalExecutorRouter().add(\n '*',\n '(.*)',\n async (_req, _api, _route, _ctx) => {\n return new Response();\n },\n);\n";
|
|
885
|
+
|
|
886
|
+
var internalExecTemplate = "import { InternalExecutorRouter } from '@mochabug/adapt-plugin-toolkit/router';\n\nexport const router = new InternalExecutorRouter()\n .onStart(async (req, _api) => {\n const start = await req.json<StartExecutionRequest>();\n console.log('Start has been called');\n console.log(start);\n })\n .onStop(async (_req, _api) => {\n console.log('Stop has been called');\n })\n .onStream(async (req, _api, name) => {\n console.log(`Stream ${name} has been called`);\n const res = await req.json<StreamResult>();\n console.log(res);\n })\n .onProcedure(async (req, _api, name) => {\n console.log(`Procedure ${name} has been called`);\n const res = await req.json<ProcedureResult>();\n console.log(res);\n });\n";
|
|
887
|
+
|
|
888
|
+
var gitignoreTemplate = "# Logs\nlogs\n*.log\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\nlerna-debug.log*\n.pnpm-debug.log*\n\n# Diagnostic reports (https://nodejs.org/api/report.html)\nreport.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json\n\n# Runtime data\npids\n*.pid\n*.seed\n*.pid.lock\n\n# Directory for instrumented libs generated by jscoverage/JSCover\nlib-cov\n\n# Coverage directory used by tools like istanbul\ncoverage\n*.lcov\n\n# nyc test coverage\n.nyc_output\n\n# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)\n.grunt\n\n# Bower dependency directory (https://bower.io/)\nbower_components\n\n# node-waf configuration\n.lock-wscript\n\n# Compiled binary addons (https://nodejs.org/api/addons.html)\nbuild/Release\n\n# Dependency directories\nnode_modules/\njspm_packages/\n\n# Snowpack dependency directory (https://snowpack.dev/)\nweb_modules/\n\n# TypeScript cache\n*.tsbuildinfo\n\n# Optional npm cache directory\n.npm\n\n# Optional eslint cache\n.eslintcache\n\n# Optional stylelint cache\n.stylelintcache\n\n# Microbundle cache\n.rpt2_cache/\n.rts2_cache_cjs/\n.rts2_cache_es/\n.rts2_cache_umd/\n\n# Optional REPL history\n.node_repl_history\n\n# Output of 'npm pack'\n*.tgz\n\n# Yarn Integrity file\n.yarn-integrity\n\n# dotenv environment variable files\n.env\n.env.development.local\n.env.test.local\n.env.production.local\n.env.local\n\n# parcel-bundler cache (https://parceljs.org/)\n.cache\n.parcel-cache\n\n# Next.js build output\n.next\nout\n\n# Nuxt.js build / generate output\n.nuxt\ndist\nbuild\n\n# Gatsby files\n.cache/\n# Comment in the public line in if your project uses Gatsby and not Next.js\n# https://nextjs.org/blog/next-9-1#public-directory-support\n# public\n\n# vuepress build output\n.vuepress/dist\n\n# vuepress v2.x temp and cache directory\n.temp\n.cache\n\n# Stores VSCode versions used for testing VSCode extensions\n.vscode-test\n\n# yarn v2\n.yarn/cache\n.yarn/unplugged\n.yarn/build-state.yml\n.yarn/install-state.gz\n.pnp.*";
|
|
889
|
+
|
|
890
|
+
var jestTemplate = "import type { Config } from \"@jest/types\"\n\nconst config: Config.InitialOptions = {\n preset: \"ts-jest\",\n testEnvironment: \"node\",\n verbose: true,\n automock: true,\n}\nexport default config";
|
|
891
|
+
|
|
892
|
+
var licenseTemplate = "## ISC License\n\nCopyright (c) [year] [fullname]\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted, provided that the above\ncopyright notice and this permission notice appear in all copies.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.";
|
|
893
|
+
|
|
894
|
+
var readmeTemplate = "# 🐞 Mochabug Adapt's Magnificent Plugin 🐞\n\n[](PLUGIN_REPOSITORY_URL)\n[](https://opensource.org/licenses/ISC)\n\n## 📝 Description\n\nWelcome to the Magnificent Plugin for Mochabug Adapt! Developed by a talented third-party developer, this plugin promises to bring extra flavor to your Mochabug Adapt cloud platform experience. PLUGIN_DESCRIPTION\n\nThis plugin consists of one or more vertices. Each vertex is made up of an Executor and may optionally include a Configurator to help you tailor its behavior.\n\n## 📚 Table of Contents\n\n- [🐞 Mochabug Adapt's Magnificent Plugin 🐞](#-mochabug-adapts-magnificent-plugin-)\n - [📝 Description](#-description)\n - [📚 Table of Contents](#-table-of-contents)\n - [🚀 Getting Started](#-getting-started)\n - [🎯 Usage](#-usage)\n - [⚙️ Configuration](#️-configuration)\n - [📖 Documentation](#-documentation)\n - [🤝 Contributing](#-contributing)\n - [📜 License](#-license)\n - [👤 Author](#-author)\n\n## 🚀 Getting Started\n\nTo begin using Mochabug Adapt's Magnificent Plugin, simply start incorporating its vertices into your workflows within the Mochabug Adapt platform. No installation is required.\n\n## 🎯 Usage\n\nYou can start using the vertices by incorporating them into your workflows on the Mochabug Adapt platform. Each vertex will delight you with a specific task, and the usage will vary depending on your requirements. Consult the plugin documentation for a comprehensive guide on each vertex's usage.\n\n## ⚙️ Configuration\n\nEach vertex in the plugin may have a Configurator, which allows you to tailor the vertex's behavior to your liking. Configuration options may include settings for the Executor, input/output data formats, and other essential options.\n\n## 📖 Documentation\n\nFor more insights into the plugin, its vertices, and their features, visit the [homepage](PLUGIN_HOMEPAGE) and the [repository](PLUGIN_REPOSITORY_URL).\n\n## 🤝 Contributing\n\nReady to make the Magnificent Plugin for Mochabug Adapt even more magical? Contributions are welcome! Check the [repository](PLUGIN_REPOSITORY_URL) for open issues and guidelines on how to contribute.\n\n## 📜 License\n\nThis plugin is licensed under the [ISC License](https://opensource.org/licenses/ISC).\n\n## 👤 Author\n\nPLUGIN_AUTHOR\n";
|
|
895
|
+
|
|
896
|
+
var rollupTemplate = "import fs from 'fs';\nimport typescript from '@rollup/plugin-typescript';\nimport { nodeResolve } from '@rollup/plugin-node-resolve';\nimport terser from '@rollup/plugin-terser';\nimport commonjs from '@rollup/plugin-commonjs';\n\nconst config = [\n {\n input: 'src/executors.ts',\n output: {\n file: 'dist/executors.js',\n format: 'esm'\n },\n plugins: [typescript(), nodeResolve(), commonjs(), terser()]\n }\n];\n\n// Check if 'src/configurators.ts' exists\nif (fs.existsSync('src/configurators.ts')) {\n config.push({\n input: 'src/configurators.ts',\n output: {\n file: 'dist/configurators.js',\n format: 'esm'\n },\n plugins: [typescript(), nodeResolve(), commonjs(), terser()]\n });\n}\n\nexport default config;\n";
|
|
897
|
+
|
|
898
|
+
var tsconfig = "{\n \"exclude\": [\n \"**/*.test.*\",\n \"**/__mocks__/*\",\n \"**/__tests__/*\"\n ],\n \"compilerOptions\": {\n \"rootDir\": \"src\",\n \"jsx\": \"react\",\n \"target\": \"esnext\",\n \"module\": \"esnext\",\n \"lib\": [\n \"esnext\"\n ],\n \"moduleResolution\": \"node\",\n \"types\": [\n \"@mochabug/adapt-plugin-typings\",\n \"jest\"\n ],\n \"resolveJsonModule\": true,\n \"allowJs\": true,\n \"checkJs\": false,\n \"noEmit\": true,\n \"isolatedModules\": true,\n \"allowSyntheticDefaultImports\": true,\n \"forceConsistentCasingInFileNames\": true,\n \"strict\": true,\n \"skipLibCheck\": true,\n \"noUnusedLocals\": true,\n \"noUnusedParameters\": true,\n \"noFallthroughCasesInSwitch\": true,\n \"noImplicitReturns\": true,\n \"useUnknownInCatchVariables\": true,\n \"noUncheckedIndexedAccess\": true,\n \"noPropertyAccessFromIndexSignature\": true\n }\n}";
|
|
899
|
+
|
|
823
900
|
// Copyright 2023, mochabug AB
|
|
824
901
|
//
|
|
825
902
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -850,49 +927,34 @@ function resize(filepath, height, width) {
|
|
|
850
927
|
const extname = path.extname(filepath);
|
|
851
928
|
switch (extname) {
|
|
852
929
|
case '.avif':
|
|
853
|
-
return yield sharp(filepath)
|
|
854
|
-
.resize(height, width)
|
|
855
|
-
.avif()
|
|
856
|
-
.toBuffer();
|
|
930
|
+
return yield sharp(filepath).resize(height, width).avif().toBuffer();
|
|
857
931
|
case '.gif':
|
|
858
|
-
return yield sharp(filepath)
|
|
859
|
-
.resize(height, width)
|
|
860
|
-
.gif()
|
|
861
|
-
.toBuffer();
|
|
932
|
+
return yield sharp(filepath).resize(height, width).gif().toBuffer();
|
|
862
933
|
case '.jpg':
|
|
863
934
|
case '.jpeg':
|
|
864
935
|
case '.jfif':
|
|
865
936
|
case '.pjpeg':
|
|
866
937
|
case '.pjp':
|
|
867
|
-
return yield sharp(filepath)
|
|
868
|
-
.resize(height, width)
|
|
869
|
-
.jpeg()
|
|
870
|
-
.toBuffer();
|
|
938
|
+
return yield sharp(filepath).resize(height, width).jpeg().toBuffer();
|
|
871
939
|
case '.png':
|
|
872
|
-
return yield sharp(filepath)
|
|
873
|
-
.resize(height, width)
|
|
874
|
-
.png()
|
|
875
|
-
.toBuffer();
|
|
940
|
+
return yield sharp(filepath).resize(height, width).png().toBuffer();
|
|
876
941
|
case '.svg':
|
|
877
942
|
return fs.readFileSync(filepath);
|
|
878
943
|
case '.webp':
|
|
879
|
-
return yield sharp(filepath)
|
|
880
|
-
.resize(height, width)
|
|
881
|
-
.webp()
|
|
882
|
-
.toBuffer();
|
|
944
|
+
return yield sharp(filepath).resize(height, width).webp().toBuffer();
|
|
883
945
|
}
|
|
884
|
-
throw new Error(
|
|
946
|
+
throw new Error('Invalid logotype');
|
|
885
947
|
});
|
|
886
948
|
}
|
|
887
949
|
function convertVertexType(type) {
|
|
888
950
|
switch (type) {
|
|
889
|
-
case
|
|
951
|
+
case 'action':
|
|
890
952
|
return Vertex_VertexType.ACTION;
|
|
891
|
-
case
|
|
953
|
+
case 'cron-trigger':
|
|
892
954
|
return Vertex_VertexType.CRON_TRIGGER;
|
|
893
|
-
case
|
|
955
|
+
case 'external-trigger':
|
|
894
956
|
return Vertex_VertexType.EXTERNAL_TRIGGER;
|
|
895
|
-
case
|
|
957
|
+
case 'browser':
|
|
896
958
|
return Vertex_VertexType.BROWSER;
|
|
897
959
|
default:
|
|
898
960
|
throw new Error('The node type is invalid');
|
|
@@ -905,48 +967,55 @@ function addVertex(cwd, name, type, hasConfigurator) {
|
|
|
905
967
|
throw new Error(`The folder for the new vertex: ${newFolder} already exists`);
|
|
906
968
|
}
|
|
907
969
|
mkdirp.sync(newFolder);
|
|
908
|
-
const
|
|
909
|
-
const
|
|
910
|
-
const
|
|
911
|
-
const configFile = path.join(cwd, relPathConfig);
|
|
970
|
+
const folder = path.join(cwd, 'src', name);
|
|
971
|
+
const execInternalFile = path.join(folder, 'executor.internal.ts');
|
|
972
|
+
const execExternalFile = path.join(folder, 'executor.external.ts');
|
|
912
973
|
const vertex = {
|
|
913
974
|
name,
|
|
914
975
|
label: capitilize(name),
|
|
915
976
|
description: `The better description of what ${name} is doing, the better it is for both AI and humans`,
|
|
916
977
|
type: convertVertexType(type),
|
|
917
978
|
defaultConfig: path.join('src', name, 'config.json'),
|
|
918
|
-
hasConfigurator
|
|
979
|
+
hasConfigurator,
|
|
980
|
+
mtls: [],
|
|
981
|
+
oauth2: [],
|
|
982
|
+
variables: [],
|
|
919
983
|
};
|
|
920
|
-
// 5 seconds is a nice default
|
|
921
|
-
if (vertex.type === Vertex_VertexType.CRON_TRIGGER) {
|
|
922
|
-
vertex.cronInterval = 5000;
|
|
923
|
-
}
|
|
924
984
|
// Write the new task
|
|
925
|
-
let importFile = `./${name}/executor`;
|
|
926
|
-
let exportFile = path.join(cwd, 'src', 'executors.ts');
|
|
927
985
|
let importString;
|
|
928
986
|
let exportString;
|
|
929
987
|
switch (vertex.type) {
|
|
930
988
|
case Vertex_VertexType.ACTION:
|
|
931
|
-
|
|
932
|
-
|
|
989
|
+
// An action only has a internal executor
|
|
990
|
+
writeFile(execInternalFile, internalExecTemplate);
|
|
991
|
+
importString = `import { router as ${name}InternalExecutor} from "${`./${name}/executor.internal`}";`;
|
|
933
992
|
exportString = `export { ${name}InternalExecutor }`;
|
|
934
993
|
break;
|
|
935
994
|
case Vertex_VertexType.BROWSER:
|
|
995
|
+
// The browser has both an internal and external executor
|
|
996
|
+
writeFile(execInternalFile, internalExecTemplate);
|
|
997
|
+
writeFile(execExternalFile, browserExecTempalte);
|
|
998
|
+
importString = `import { router as ${name}InternalExecutor} from "${`./${name}/executor.internal`}";\nimport { router as ${name}ExternalExecutor} from "${`./${name}/executor.external`}";`;
|
|
999
|
+
exportString = `export { ${name}InternalExecutor, ${name}ExternalExecutor }`;
|
|
1000
|
+
break;
|
|
936
1001
|
case Vertex_VertexType.EXTERNAL_TRIGGER:
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
1002
|
+
// The external trigger has both an internal and external executor
|
|
1003
|
+
writeFile(execInternalFile, internalExecTemplate);
|
|
1004
|
+
writeFile(execExternalFile, triggerExecTemplate);
|
|
1005
|
+
importString = `import { router as ${name}InternalExecutor} from "${`./${name}/executor.internal`}";\nimport { router as ${name}ExternalExecutor} from "${`./${name}/executor.external`}";`;
|
|
1006
|
+
exportString = `export { ${name}InternalExecutor, ${name}ExternalExecutor }`;
|
|
940
1007
|
break;
|
|
941
1008
|
case Vertex_VertexType.CRON_TRIGGER:
|
|
942
|
-
|
|
943
|
-
|
|
1009
|
+
// The cron trigger does not expose an external endpoint
|
|
1010
|
+
writeFile(execInternalFile, cronExecTemplate);
|
|
1011
|
+
importString = `import { router as ${name}InternalExecutor} from "${`./${name}/executor.internal`}";`;
|
|
944
1012
|
exportString = `export { ${name}InternalExecutor }`;
|
|
945
1013
|
break;
|
|
946
1014
|
default:
|
|
947
1015
|
throw new Error('The vertex type is invalid');
|
|
948
1016
|
}
|
|
949
1017
|
// Append or create src/executors.ts
|
|
1018
|
+
let exportFile = path.join(cwd, 'src', 'executors.ts');
|
|
950
1019
|
if (fs.existsSync(exportFile)) {
|
|
951
1020
|
let exports = fs.readFileSync(exportFile).toString();
|
|
952
1021
|
exports = `${importString}\n` + exports + `\n${exportString}`;
|
|
@@ -956,43 +1025,54 @@ function addVertex(cwd, name, type, hasConfigurator) {
|
|
|
956
1025
|
const exports = `${importString}\n\n${exportString}`;
|
|
957
1026
|
fs.writeFileSync(exportFile, exports);
|
|
958
1027
|
}
|
|
959
|
-
const
|
|
1028
|
+
const vertexConfig = {
|
|
960
1029
|
complete: true,
|
|
961
|
-
receivers: [
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
1030
|
+
receivers: [
|
|
1031
|
+
{
|
|
1032
|
+
name: 'input',
|
|
1033
|
+
description: 'Default input receiver',
|
|
1034
|
+
bindings: [],
|
|
1035
|
+
},
|
|
1036
|
+
],
|
|
1037
|
+
transmitters: [
|
|
1038
|
+
{
|
|
1039
|
+
name: 'output',
|
|
1040
|
+
description: 'Default output transmitter',
|
|
969
1041
|
signals: [],
|
|
970
|
-
failure: false
|
|
971
|
-
}
|
|
1042
|
+
failure: false,
|
|
1043
|
+
},
|
|
1044
|
+
],
|
|
972
1045
|
procedures: [],
|
|
973
1046
|
streams: [],
|
|
974
|
-
|
|
1047
|
+
bindings: [],
|
|
975
1048
|
};
|
|
1049
|
+
if (vertex.type === Vertex_VertexType.CRON_TRIGGER) {
|
|
1050
|
+
vertexConfig.cronInterval = 5000;
|
|
1051
|
+
}
|
|
976
1052
|
if (hasConfigurator) {
|
|
977
|
-
|
|
978
|
-
|
|
1053
|
+
const configInternalFile = path.join(folder, 'configurator.internal.ts');
|
|
1054
|
+
const configExternalFile = path.join(folder, 'configurator.external.ts');
|
|
1055
|
+
writeFile(configInternalFile, internalConfigTemplate);
|
|
1056
|
+
writeFile(configExternalFile, externalConfigTemplate);
|
|
1057
|
+
// If we have a config, make sure we don't say that the config is complete by default
|
|
1058
|
+
vertexConfig.complete = false;
|
|
979
1059
|
const internalName = `${name}InternalConfigurator`;
|
|
980
1060
|
const externalName = `${name}ExternalConfigurator`;
|
|
981
|
-
|
|
1061
|
+
importString = `import { router as ${internalName}} from "${`./${name}/configurator.internal`}";\nimport { router as ${externalName}} from "${`./${name}/configurator.external`}";`;
|
|
1062
|
+
exportString = `export { ${internalName}, ${externalName} }`;
|
|
982
1063
|
exportFile = path.join(cwd, 'src', 'configurators.ts');
|
|
983
1064
|
if (fs.existsSync(exportFile)) {
|
|
984
1065
|
let exports = fs.readFileSync(exportFile).toString();
|
|
985
|
-
exports =
|
|
986
|
-
`\nexport { ${externalName}, ${internalName} }`;
|
|
1066
|
+
exports = `${importString}\n` + exports + `\n${exportString}`;
|
|
987
1067
|
fs.writeFileSync(exportFile, exports);
|
|
988
1068
|
}
|
|
989
1069
|
else {
|
|
990
|
-
const exports =
|
|
1070
|
+
const exports = `${importString}\n\n${exportString}`;
|
|
991
1071
|
fs.writeFileSync(exportFile, exports);
|
|
992
1072
|
}
|
|
993
1073
|
}
|
|
994
1074
|
// Write the config json file
|
|
995
|
-
fs.writeFileSync(path.join(cwd, 'src', name, 'config.json'), JSON.stringify(
|
|
1075
|
+
fs.writeFileSync(path.join(cwd, 'src', name, 'config.json'), JSON.stringify(vertexConfig, null, 2));
|
|
996
1076
|
return vertex;
|
|
997
1077
|
}
|
|
998
1078
|
function init(dir) {
|
|
@@ -1007,13 +1087,13 @@ function init(dir) {
|
|
|
1007
1087
|
},
|
|
1008
1088
|
validate: (val) => {
|
|
1009
1089
|
return /[a-zA-Z][0-9a-zA-Z_]*/.test(val);
|
|
1010
|
-
}
|
|
1090
|
+
},
|
|
1011
1091
|
},
|
|
1012
1092
|
{
|
|
1013
1093
|
type: 'list',
|
|
1014
1094
|
name: 'vertexType',
|
|
1015
1095
|
message: 'Choose vertex type',
|
|
1016
|
-
choices: ['action', 'browser', 'cron-trigger', 'external-trigger']
|
|
1096
|
+
choices: ['action', 'browser', 'cron-trigger', 'external-trigger'],
|
|
1017
1097
|
},
|
|
1018
1098
|
{
|
|
1019
1099
|
type: 'input',
|
|
@@ -1024,13 +1104,13 @@ function init(dir) {
|
|
|
1024
1104
|
},
|
|
1025
1105
|
validate: (val) => {
|
|
1026
1106
|
return /[a-zA-Z][0-9a-zA-Z_]*/.test(val);
|
|
1027
|
-
}
|
|
1107
|
+
},
|
|
1028
1108
|
},
|
|
1029
1109
|
{
|
|
1030
1110
|
type: 'confirm',
|
|
1031
1111
|
name: 'hasConfigurator',
|
|
1032
|
-
message: 'Need a configurator for the vertex?'
|
|
1033
|
-
}
|
|
1112
|
+
message: 'Need a configurator for the vertex?',
|
|
1113
|
+
},
|
|
1034
1114
|
]);
|
|
1035
1115
|
mkdirp.sync(dir);
|
|
1036
1116
|
const cwd = !path.isAbsolute(dir) ? path.join(process.cwd(), dir) : dir;
|
|
@@ -1038,28 +1118,28 @@ function init(dir) {
|
|
|
1038
1118
|
console.log(chalk.magenta('Creating package.json...'));
|
|
1039
1119
|
const defPackage = {
|
|
1040
1120
|
name: ans.name,
|
|
1041
|
-
version:
|
|
1121
|
+
version: '',
|
|
1042
1122
|
private: true,
|
|
1043
|
-
type:
|
|
1123
|
+
type: 'module',
|
|
1044
1124
|
scripts: {
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
}
|
|
1125
|
+
test: 'jest --collectCoverage --passWithNoTests',
|
|
1126
|
+
rollup: 'rollup -c rollup.config.js',
|
|
1127
|
+
build: 'run-p rollup',
|
|
1128
|
+
add: 'adaptkit --add',
|
|
1129
|
+
publish: 'npm run build && adaptkit --publish',
|
|
1130
|
+
emulate: 'npm run build && adaptkit --emulate',
|
|
1131
|
+
},
|
|
1052
1132
|
};
|
|
1053
1133
|
writeFile(path.join(cwd, 'package.json'), JSON.stringify(defPackage, null, 2));
|
|
1054
1134
|
writeFile(path.join(cwd, 'README.md'), readmeTemplate);
|
|
1055
1135
|
writeFile(path.join(cwd, 'LICENSE.md'), licenseTemplate);
|
|
1056
1136
|
execSync('npm install --save-dev @mochabug/adapt-plugin-typings typescript jest @jest/globals ts-jest @types/jest ts-node tslib rollup @rollup/plugin-typescript @rollup/plugin-terser @rollup/plugin-node-resolve @rollup/plugin-commonjs npm-run-all', {
|
|
1057
1137
|
cwd: cwd,
|
|
1058
|
-
stdio: 'inherit'
|
|
1138
|
+
stdio: 'inherit',
|
|
1059
1139
|
});
|
|
1060
1140
|
execSync('npm install @mochabug/adapt-plugin-toolkit', {
|
|
1061
1141
|
cwd: cwd,
|
|
1062
|
-
stdio: 'inherit'
|
|
1142
|
+
stdio: 'inherit',
|
|
1063
1143
|
});
|
|
1064
1144
|
console.log(chalk.magenta('Setting up project structure...'));
|
|
1065
1145
|
writeFile(path.join(cwd, 'tsconfig.json'), tsconfig);
|
|
@@ -1071,31 +1151,33 @@ function init(dir) {
|
|
|
1071
1151
|
mkdirp.sync(path.join(cwd, 'assets'));
|
|
1072
1152
|
const manifest = {
|
|
1073
1153
|
name: ans.name,
|
|
1074
|
-
version:
|
|
1154
|
+
version: '0.0.1-beta.1',
|
|
1075
1155
|
label: capitilize(ans.name),
|
|
1076
1156
|
description: `A nice description of what ${ans.name} does`,
|
|
1077
|
-
author:
|
|
1078
|
-
bugs:
|
|
1157
|
+
author: 'John Doe',
|
|
1158
|
+
bugs: 'bugs@foobar.com',
|
|
1079
1159
|
homepage: `https://www.foobar.com`,
|
|
1080
1160
|
repository: `https://github.com`,
|
|
1081
1161
|
vertices: [vertex],
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
pluginMtls: [],
|
|
1088
|
-
oauth2: []
|
|
1162
|
+
assetsDir: 'assets',
|
|
1163
|
+
executorEsm: 'dist/executors.js',
|
|
1164
|
+
variables: [],
|
|
1165
|
+
oauth2: [],
|
|
1166
|
+
mtls: [],
|
|
1089
1167
|
};
|
|
1090
1168
|
if (!vertex.defaultConfig) {
|
|
1091
|
-
throw new Error(
|
|
1169
|
+
throw new Error('This cannot happen');
|
|
1092
1170
|
}
|
|
1093
1171
|
// Add the esm if we have a schema => this means that it has a configurator
|
|
1094
1172
|
if (vertex.hasConfigurator) {
|
|
1095
|
-
manifest.configuratorEsm =
|
|
1173
|
+
manifest.configuratorEsm = 'dist/configurators.js';
|
|
1096
1174
|
}
|
|
1097
1175
|
// Write out the actual manifest and we're done
|
|
1098
|
-
fs.writeFileSync(path.join(cwd, 'manifest.json'), Manifest.toJsonString(manifest, {
|
|
1176
|
+
fs.writeFileSync(path.join(cwd, 'manifest.json'), Manifest.toJsonString(manifest, {
|
|
1177
|
+
enumAsInteger: false,
|
|
1178
|
+
prettySpaces: 2,
|
|
1179
|
+
emitDefaultValues: true,
|
|
1180
|
+
}));
|
|
1099
1181
|
console.log(chalk.bgGreen('Success'));
|
|
1100
1182
|
});
|
|
1101
1183
|
}
|
|
@@ -1111,52 +1193,39 @@ function add(manifest) {
|
|
|
1111
1193
|
},
|
|
1112
1194
|
validate: (val) => {
|
|
1113
1195
|
val = val.trim();
|
|
1114
|
-
if (manifest.vertices.filter(item => item.name === val).length > 0) {
|
|
1196
|
+
if (manifest.vertices.filter((item) => item.name === val).length > 0) {
|
|
1115
1197
|
return false;
|
|
1116
1198
|
}
|
|
1117
1199
|
return /[a-zA-Z][0-9a-zA-Z_]*/.test(val);
|
|
1118
|
-
}
|
|
1200
|
+
},
|
|
1119
1201
|
},
|
|
1120
1202
|
{
|
|
1121
1203
|
type: 'list',
|
|
1122
1204
|
name: 'vertexType',
|
|
1123
1205
|
message: 'Choose your vertex type',
|
|
1124
|
-
choices: ['action', 'browser', 'cron-trigger', 'external-trigger']
|
|
1206
|
+
choices: ['action', 'browser', 'cron-trigger', 'external-trigger'],
|
|
1125
1207
|
},
|
|
1126
1208
|
{
|
|
1127
1209
|
type: 'confirm',
|
|
1128
1210
|
name: 'hasConfigurator',
|
|
1129
|
-
message: 'Need a configurator for the vertex?'
|
|
1130
|
-
}
|
|
1211
|
+
message: 'Need a configurator for the vertex?',
|
|
1212
|
+
},
|
|
1131
1213
|
]);
|
|
1132
1214
|
console.log(chalk.magenta('Creating new vertex templates...'));
|
|
1133
1215
|
const vertex = addVertex('.', ans.vertexName, ans.vertexType, ans.hasConfigurator);
|
|
1134
1216
|
manifest.vertices.push(vertex);
|
|
1135
1217
|
if (!manifest.configuratorEsm && vertex.hasConfigurator) {
|
|
1136
|
-
manifest.configuratorEsm =
|
|
1218
|
+
manifest.configuratorEsm = 'dist/configurators.js';
|
|
1137
1219
|
}
|
|
1138
1220
|
console.log(chalk.magenta('Updating manifest...'));
|
|
1139
|
-
fs.writeFileSync('manifest.json', Manifest.toJsonString(manifest, {
|
|
1221
|
+
fs.writeFileSync('manifest.json', Manifest.toJsonString(manifest, {
|
|
1222
|
+
enumAsInteger: false,
|
|
1223
|
+
prettySpaces: 2,
|
|
1224
|
+
emitDefaultValues: true,
|
|
1225
|
+
}));
|
|
1140
1226
|
console.log(chalk.bgGreen('Success'));
|
|
1141
1227
|
});
|
|
1142
1228
|
}
|
|
1143
|
-
function addPluginConfig(manifest) {
|
|
1144
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1145
|
-
if (manifest.defaultConfig) {
|
|
1146
|
-
console.log(chalk.bgRed("Already contains a configuration in manifest.json"));
|
|
1147
|
-
return;
|
|
1148
|
-
}
|
|
1149
|
-
// Write the default config
|
|
1150
|
-
const configPath = path.join('src', `plugin.json`);
|
|
1151
|
-
fs.writeFileSync(configPath, JSON.stringify({ complete: false, signals: [] }, null, 2));
|
|
1152
|
-
console.log(chalk.green("plugin.json has been written"));
|
|
1153
|
-
manifest.defaultConfig = configPath;
|
|
1154
|
-
console.log(chalk.magenta('Updating manifest...'));
|
|
1155
|
-
fs.writeFileSync('manifest.json', Manifest.toJsonString(manifest, { enumAsInteger: false, prettySpaces: 2, emitDefaultValues: true }));
|
|
1156
|
-
console.log(chalk.bgYellowBright("Make sure at least one vertex is requiring plugin config"));
|
|
1157
|
-
console.log(chalk.green('The plugin config was successfully added'));
|
|
1158
|
-
});
|
|
1159
|
-
}
|
|
1160
1229
|
function publish(manifest, address) {
|
|
1161
1230
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1162
1231
|
const transport = new GrpcTransport({
|
|
@@ -1189,9 +1258,9 @@ function publish(manifest, address) {
|
|
|
1189
1258
|
oneofKind: 'file',
|
|
1190
1259
|
file: {
|
|
1191
1260
|
data: buffer,
|
|
1192
|
-
path: filePath
|
|
1193
|
-
}
|
|
1194
|
-
}
|
|
1261
|
+
path: filePath,
|
|
1262
|
+
},
|
|
1263
|
+
},
|
|
1195
1264
|
};
|
|
1196
1265
|
yield stream.requests.send(message);
|
|
1197
1266
|
lookup[filePath] = true;
|
|
@@ -1202,8 +1271,8 @@ function publish(manifest, address) {
|
|
|
1202
1271
|
const request = {
|
|
1203
1272
|
data: {
|
|
1204
1273
|
oneofKind: 'manifest',
|
|
1205
|
-
manifest: manifest
|
|
1206
|
-
}
|
|
1274
|
+
manifest: manifest,
|
|
1275
|
+
},
|
|
1207
1276
|
};
|
|
1208
1277
|
yield stream.requests.send(request);
|
|
1209
1278
|
yield send('README.md');
|
|
@@ -1211,10 +1280,9 @@ function publish(manifest, address) {
|
|
|
1211
1280
|
yield send(manifest.executorEsm);
|
|
1212
1281
|
yield send(manifest.configuratorEsm);
|
|
1213
1282
|
yield send(manifest.logo, [80, 80]);
|
|
1214
|
-
yield send(manifest.defaultConfig);
|
|
1215
1283
|
// Send everything inside the asset directory as assets
|
|
1216
1284
|
if (manifest.assetsDir && fs.existsSync(manifest.assetsDir)) {
|
|
1217
|
-
const paths = yield
|
|
1285
|
+
const paths = yield fg(path.join(manifest.assetsDir, '**', '*'));
|
|
1218
1286
|
console.log('Found in assets directory:');
|
|
1219
1287
|
console.log(paths);
|
|
1220
1288
|
for (let filepath of paths) {
|
|
@@ -1227,18 +1295,18 @@ function publish(manifest, address) {
|
|
|
1227
1295
|
for (let vertex of manifest.vertices) {
|
|
1228
1296
|
yield send(vertex.logo, [40, 40]);
|
|
1229
1297
|
yield send(vertex.defaultConfig);
|
|
1298
|
+
for (let mtls of vertex.mtls) {
|
|
1299
|
+
yield send(mtls.trustedCa);
|
|
1300
|
+
}
|
|
1230
1301
|
}
|
|
1231
1302
|
// Send the ca bundles
|
|
1232
|
-
for (let mtls of manifest.
|
|
1233
|
-
yield send(mtls.trustedCa);
|
|
1234
|
-
}
|
|
1235
|
-
for (let mtls of manifest.pluginMtls) {
|
|
1303
|
+
for (let mtls of manifest.mtls) {
|
|
1236
1304
|
yield send(mtls.trustedCa);
|
|
1237
1305
|
}
|
|
1238
1306
|
stream.requests.complete();
|
|
1239
1307
|
const result = yield stream;
|
|
1240
1308
|
console.log(result);
|
|
1241
|
-
if (result.status.code ===
|
|
1309
|
+
if (result.status.code === 'OK') {
|
|
1242
1310
|
console.log(chalk.green('Publishing done'));
|
|
1243
1311
|
console.log(chalk.bgGreen('SUCCESS'));
|
|
1244
1312
|
}
|
|
@@ -1251,48 +1319,43 @@ function publish(manifest, address) {
|
|
|
1251
1319
|
function main() {
|
|
1252
1320
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1253
1321
|
program
|
|
1254
|
-
.name(
|
|
1255
|
-
.version(
|
|
1256
|
-
.description(
|
|
1257
|
-
.option(
|
|
1258
|
-
.option(
|
|
1259
|
-
.option(
|
|
1260
|
-
.option(
|
|
1261
|
-
.option("-e, --emulate [url]", "run the plugin in the emulator on the given url (default [HERE]", undefined)
|
|
1322
|
+
.name('Adaptkit')
|
|
1323
|
+
.version('1.0.0')
|
|
1324
|
+
.description('A CLI util to create, manage and publish plugins for mochabug adapt.')
|
|
1325
|
+
.option('-i, --init [dir]', "initialize a new plugin project in the specified directory (default './')", undefined)
|
|
1326
|
+
.option('-a, --add', 'add a new vertex to the plugin. Working directory need to contain a manifest.json file')
|
|
1327
|
+
.option('-p, --publish [url]', 'publish the plugin to your organization (default [HERE])', undefined)
|
|
1328
|
+
.option('-e, --emulate [url]', 'run the plugin in the emulator on the given url (default [HERE]', undefined)
|
|
1262
1329
|
.parse(process.argv);
|
|
1263
1330
|
const options = program.opts();
|
|
1264
1331
|
if (options.init) {
|
|
1265
|
-
console.log(chalk.blueBright(figlet.textSync(
|
|
1332
|
+
console.log(chalk.blueBright(figlet.textSync('Adaptkit')));
|
|
1266
1333
|
let dir = '.';
|
|
1267
|
-
if (typeof options.init !==
|
|
1334
|
+
if (typeof options.init !== 'boolean') {
|
|
1268
1335
|
dir = options.init;
|
|
1269
1336
|
}
|
|
1270
1337
|
yield init(dir);
|
|
1271
1338
|
}
|
|
1272
1339
|
else if (options.add) {
|
|
1273
|
-
console.log(chalk.blueBright(figlet.textSync(
|
|
1340
|
+
console.log(chalk.blueBright(figlet.textSync('Adaptkit')));
|
|
1274
1341
|
yield add(readManifest());
|
|
1275
1342
|
}
|
|
1276
|
-
else if (options.plugin) {
|
|
1277
|
-
console.log(chalk.blueBright(figlet.textSync("Adaptkit")));
|
|
1278
|
-
yield addPluginConfig(readManifest());
|
|
1279
|
-
}
|
|
1280
1343
|
else if (options.publish) {
|
|
1281
|
-
let address =
|
|
1282
|
-
if (typeof options.publish !==
|
|
1344
|
+
let address = 'localhost:51002';
|
|
1345
|
+
if (typeof options.publish !== 'boolean') {
|
|
1283
1346
|
address = options.publish;
|
|
1284
1347
|
}
|
|
1285
1348
|
yield publish(readManifest(), address);
|
|
1286
1349
|
}
|
|
1287
1350
|
else if (options.emulate) {
|
|
1288
|
-
let address =
|
|
1289
|
-
if (typeof options.emulate !==
|
|
1351
|
+
let address = 'localhost:51002';
|
|
1352
|
+
if (typeof options.emulate !== 'boolean') {
|
|
1290
1353
|
address = options.emulate;
|
|
1291
1354
|
}
|
|
1292
1355
|
yield publish(readManifest(), address);
|
|
1293
1356
|
}
|
|
1294
1357
|
else {
|
|
1295
|
-
console.log(chalk.blueBright(figlet.textSync(
|
|
1358
|
+
console.log(chalk.blueBright(figlet.textSync('Adaptkit')));
|
|
1296
1359
|
program.outputHelp();
|
|
1297
1360
|
}
|
|
1298
1361
|
process.exit();
|