@mochabug/adaptkit 1.0.0-rc.3 → 1.0.0-rc.5

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.
Files changed (75) hide show
  1. package/assets/build.js +2 -57
  2. package/assets/configurator.html +14 -0
  3. package/assets/configurator.ssg.tsx +2 -16
  4. package/assets/configurator_react.tsx +6 -3
  5. package/assets/executor.html +14 -0
  6. package/assets/executor.ssg.tsx +2 -16
  7. package/assets/executor_browser_react.tsx +6 -3
  8. package/assets/gitignore +3 -1
  9. package/assets/tsconf.json +3 -5
  10. package/bin/add.d.ts +3 -0
  11. package/bin/add.d.ts.map +1 -0
  12. package/bin/genproto/buf/validate/validate_pb.d.ts +8122 -0
  13. package/bin/genproto/buf/validate/validate_pb.d.ts.map +1 -0
  14. package/bin/genproto/google/api/annotations_pb.d.ts +14 -0
  15. package/bin/genproto/google/api/annotations_pb.d.ts.map +1 -0
  16. package/bin/genproto/google/api/client_pb.d.ts +1402 -0
  17. package/bin/genproto/google/api/client_pb.d.ts.map +1 -0
  18. package/bin/genproto/google/api/http_pb.d.ts +837 -0
  19. package/bin/genproto/google/api/http_pb.d.ts.map +1 -0
  20. package/bin/genproto/google/api/launch_stage_pb.d.ts +94 -0
  21. package/bin/genproto/google/api/launch_stage_pb.d.ts.map +1 -0
  22. package/bin/genproto/mochabugapis/adapt/graph/exchange_pb.d.ts +75 -0
  23. package/bin/genproto/mochabugapis/adapt/graph/exchange_pb.d.ts.map +1 -0
  24. package/bin/genproto/mochabugapis/adapt/graph/jtd_schema_pb.d.ts +225 -0
  25. package/bin/genproto/mochabugapis/adapt/graph/jtd_schema_pb.d.ts.map +1 -0
  26. package/bin/genproto/mochabugapis/adapt/graph/receiver_pb.d.ts +67 -0
  27. package/bin/genproto/mochabugapis/adapt/graph/receiver_pb.d.ts.map +1 -0
  28. package/bin/genproto/mochabugapis/adapt/graph/signal_binding_pb.d.ts +133 -0
  29. package/bin/genproto/mochabugapis/adapt/graph/signal_binding_pb.d.ts.map +1 -0
  30. package/bin/genproto/mochabugapis/adapt/graph/signal_descriptor_pb.d.ts +87 -0
  31. package/bin/genproto/mochabugapis/adapt/graph/signal_descriptor_pb.d.ts.map +1 -0
  32. package/bin/genproto/mochabugapis/adapt/graph/transceiver_pb.d.ts +63 -0
  33. package/bin/genproto/mochabugapis/adapt/graph/transceiver_pb.d.ts.map +1 -0
  34. package/bin/genproto/mochabugapis/adapt/graph/transmitter_pb.d.ts +75 -0
  35. package/bin/genproto/mochabugapis/adapt/graph/transmitter_pb.d.ts.map +1 -0
  36. package/bin/genproto/mochabugapis/adapt/graph/vertex_config_pb.d.ts +109 -0
  37. package/bin/genproto/mochabugapis/adapt/graph/vertex_config_pb.d.ts.map +1 -0
  38. package/bin/genproto/mochabugapis/adapt/plugins/v1/file_pb.d.ts +62 -0
  39. package/bin/genproto/mochabugapis/adapt/plugins/v1/file_pb.d.ts.map +1 -0
  40. package/bin/genproto/mochabugapis/adapt/plugins/v1/manifest_pb.d.ts +223 -0
  41. package/bin/genproto/mochabugapis/adapt/plugins/v1/manifest_pb.d.ts.map +1 -0
  42. package/bin/genproto/mochabugapis/adapt/plugins/v1/oauth2_service_pb.d.ts +715 -0
  43. package/bin/genproto/mochabugapis/adapt/plugins/v1/oauth2_service_pb.d.ts.map +1 -0
  44. package/bin/genproto/mochabugapis/adapt/plugins/v1/oneof_service_pb.d.ts +92 -0
  45. package/bin/genproto/mochabugapis/adapt/plugins/v1/oneof_service_pb.d.ts.map +1 -0
  46. package/bin/genproto/mochabugapis/adapt/plugins/v1/plugins_pb.d.ts +194 -0
  47. package/bin/genproto/mochabugapis/adapt/plugins/v1/plugins_pb.d.ts.map +1 -0
  48. package/bin/genproto/mochabugapis/adapt/plugins/v1/service_binding_pb.d.ts +134 -0
  49. package/bin/genproto/mochabugapis/adapt/plugins/v1/service_binding_pb.d.ts.map +1 -0
  50. package/bin/genproto/mochabugapis/adapt/plugins/v1/service_definition_pb.d.ts +116 -0
  51. package/bin/genproto/mochabugapis/adapt/plugins/v1/service_definition_pb.d.ts.map +1 -0
  52. package/bin/genproto/mochabugapis/adapt/plugins/v1/tls_service_pb.d.ts +159 -0
  53. package/bin/genproto/mochabugapis/adapt/plugins/v1/tls_service_pb.d.ts.map +1 -0
  54. package/bin/genproto/mochabugapis/adapt/plugins/v1/variable_service_pb.d.ts +60 -0
  55. package/bin/genproto/mochabugapis/adapt/plugins/v1/variable_service_pb.d.ts.map +1 -0
  56. package/bin/genproto/mochabugapis/adapt/plugins/v1/vertex_pb.d.ts +232 -0
  57. package/bin/genproto/mochabugapis/adapt/plugins/v1/vertex_pb.d.ts.map +1 -0
  58. package/bin/index.d.ts +7 -0
  59. package/bin/index.d.ts.map +1 -0
  60. package/bin/index.js +355 -429
  61. package/bin/index.js.map +4 -4
  62. package/bin/init.d.ts +2 -0
  63. package/bin/init.d.ts.map +1 -0
  64. package/bin/oauth2.d.ts +2 -0
  65. package/bin/oauth2.d.ts.map +1 -0
  66. package/bin/publish.d.ts +23 -0
  67. package/bin/publish.d.ts.map +1 -0
  68. package/bin/utils.d.ts +13 -0
  69. package/bin/utils.d.ts.map +1 -0
  70. package/bin/vertices.d.ts +3 -0
  71. package/bin/vertices.d.ts.map +1 -0
  72. package/package.json +5 -17
  73. package/assets/build-client.js +0 -111
  74. package/assets/global.d.ts +0 -7
  75. package/assets/inject.js +0 -15
package/bin/init.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export declare function init(dir: string): Promise<void>;
2
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAwBA,wBAAsB,IAAI,CAAC,GAAG,EAAE,MAAM,iBAwJrC"}
@@ -0,0 +1,2 @@
1
+ export declare function waitForConsent(issuerUrl: string, errorUrl: string, clientId: string): Promise<string | undefined>;
2
+ //# sourceMappingURL=oauth2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth2.d.ts","sourceRoot":"","sources":["../src/oauth2.ts"],"names":[],"mappings":"AAwIA,wBAAsB,cAAc,CAClC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAmK7B"}
@@ -0,0 +1,23 @@
1
+ import { Manifest } from './genproto/mochabugapis/adapt/plugins/v1/manifest_pb';
2
+ interface EmulateOpts {
3
+ cdnFolder?: string;
4
+ assetsFolder?: string;
5
+ configuratorPath?: string;
6
+ executorPath: string;
7
+ manifest: Manifest;
8
+ endpoint: string;
9
+ }
10
+ export declare function emulate(opts: EmulateOpts): Promise<void>;
11
+ interface PublishOpts {
12
+ cdnFolder?: string;
13
+ assetsFolder?: string;
14
+ configuratorPath?: string;
15
+ executorPath: string;
16
+ manifest: Manifest;
17
+ endpoint: string;
18
+ accessToken: string;
19
+ insecure: boolean;
20
+ }
21
+ export declare function publish(opts: PublishOpts): Promise<void>;
22
+ export {};
23
+ //# sourceMappingURL=publish.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../src/publish.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,QAAQ,EAAE,MAAM,sDAAsD,CAAC;AAgKhF,UAAU,WAAW;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAsB,OAAO,CAAC,IAAI,EAAE,WAAW,iBAmB9C;AAED,UAAU,WAAW;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,wBAAsB,OAAO,CAAC,IAAI,EAAE,WAAW,iBA0B9C"}
package/bin/utils.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ import { SignalDescriptor } from './genproto/mochabugapis/adapt/graph/signal_descriptor_pb';
2
+ import { VertexConfigMetadata } from './genproto/mochabugapis/adapt/graph/vertex_config_pb';
3
+ import { Manifest } from './genproto/mochabugapis/adapt/plugins/v1/manifest_pb';
4
+ import { ServiceDefinition } from './genproto/mochabugapis/adapt/plugins/v1/service_definition_pb';
5
+ export declare function readAsset(name: string): string;
6
+ export declare function writeFile(filePath: string, content: string): void;
7
+ export declare function readManifest(filePath: string, src: string): Promise<Manifest | null>;
8
+ export declare function labelize(val: string): string;
9
+ export declare function validateOauthCodeFlow(manifest: Manifest): void;
10
+ export declare function validateLoadServiceDefinition(basePath: string, srv: ServiceDefinition): Promise<void>;
11
+ export declare function validateVertexConfigMetadata(metadata: VertexConfigMetadata, context?: string): Promise<void>;
12
+ export declare function validateSignalDescriptors(descs: SignalDescriptor[], context?: string): Promise<void>;
13
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0DAA0D,CAAC;AAC5F,OAAO,EACL,oBAAoB,EAErB,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EACL,QAAQ,EAET,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gEAAgE,CAAC;AASnG,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAW9C;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,QAI1D;AAED,wBAAsB,YAAY,CAChC,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAoI1B;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,QAsEvD;AAGD,wBAAsB,6BAA6B,CACjD,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,iBAAiB,iBA8EvB;AAYD,wBAAsB,4BAA4B,CAChD,QAAQ,EAAE,oBAAoB,EAC9B,OAAO,GAAE,MAAiB,iBAqG3B;AAED,wBAAsB,yBAAyB,CAC7C,KAAK,EAAE,gBAAgB,EAAE,EACzB,OAAO,GAAE,MAAiB,iBAa3B"}
@@ -0,0 +1,3 @@
1
+ import { VertexJson } from './genproto/mochabugapis/adapt/plugins/v1/vertex_pb';
2
+ export declare function addVertex(cwd: string, name: string, folder: string, type: string, hasConfigurator: boolean, frontendLib?: 'none' | 'react' | undefined): VertexJson;
3
+ //# sourceMappingURL=vertices.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vertices.d.ts","sourceRoot":"","sources":["../src/vertices.ts"],"names":[],"mappings":"AAmBA,OAAO,EAEL,UAAU,EACX,MAAM,oDAAoD,CAAC;AAkB5D,wBAAgB,SAAS,CACvB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,eAAe,EAAE,OAAO,EACxB,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,cA8I3C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mochabug/adaptkit",
3
- "version": "1.0.0-rc.3",
3
+ "version": "1.0.0-rc.5",
4
4
  "description": "A cmd to create, emulate and publish Mochabug Adapt plugins",
5
5
  "main": "bin/index.js",
6
6
  "type": "module",
@@ -21,7 +21,7 @@
21
21
  ],
22
22
  "scripts": {
23
23
  "generate": "rm -rf src/genproto && buf generate --include-imports --path api/mochabugapis/adapt/plugins --path api/mochabugapis/adapt/graph",
24
- "build": "npm run generate && node build.js"
24
+ "build": "npm run generate && node build.js && tsc --emitDeclarationOnly"
25
25
  },
26
26
  "keywords": [
27
27
  "plugin",
@@ -36,27 +36,15 @@
36
36
  "author": "Mikael Hedberg",
37
37
  "license": "Apache-2.0",
38
38
  "devDependencies": {
39
- "@rollup/plugin-commonjs": "^28.0.3",
40
- "@rollup/plugin-json": "^6.1.0",
41
- "@rollup/plugin-node-resolve": "^16.0.1",
42
- "@rollup/plugin-replace": "^6.0.2",
43
- "@rollup/plugin-terser": "^0.4.4",
44
- "@rollup/plugin-typescript": "^12.1.2",
45
- "@types/archiver": "^6.0.3",
46
- "@types/babel__traverse": "^7.20.6",
47
39
  "@types/express": "^5.0.1",
48
40
  "@types/figlet": "^1.7.0",
49
- "@types/node": "^22.13.10",
50
- "@types/semver": "^7.5.8",
41
+ "@types/node": "^22.13.14",
42
+ "@types/semver": "^7.7.0",
51
43
  "@types/update-notifier": "^6.0.8",
52
44
  "esbuild": "^0.25.1",
53
45
  "typescript": "^5.8.2"
54
46
  },
55
47
  "dependencies": {
56
- "@babel/parser": "^7.26.10",
57
- "@babel/traverse": "^7.26.10",
58
- "@babel/types": "^7.26.10",
59
- "@bufbuild/buf": "^1.50.1",
60
48
  "@connectrpc/connect": "^2.0.2",
61
49
  "@connectrpc/connect-node": "^2.0.2",
62
50
  "@inquirer/prompts": "^7.4.0",
@@ -74,4 +62,4 @@
74
62
  "sharp": "^0.33.5",
75
63
  "update-notifier": "^7.3.1"
76
64
  }
77
- }
65
+ }
@@ -1,111 +0,0 @@
1
- import { build } from 'esbuild';
2
- import { sync as glob } from 'glob';
3
- import fs from 'node:fs';
4
- import path from 'node:path';
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
- // Load all of the vertex.json so that we can check for correct vertex names
19
- const vertexDefinitions = glob('./src/vertices/**/vertex.json').map((file) => JSON.parse(fs.readFileSync(file, 'utf8')));
20
-
21
- fs.rmSync('./cdn', { recursive: true });
22
-
23
- // Build the client and place all the assets onto the corresponding CDN for the plugin
24
- const loader = {
25
- '.css': 'css',
26
- '.woff': 'file',
27
- '.woff2': 'file',
28
- '.png': 'file',
29
- '.jpg': 'file',
30
- '.jpeg': 'file',
31
- '.gif': 'file',
32
- '.svg': 'file',
33
- '.ttf': 'file',
34
- '.otf': 'file',
35
- };
36
- const result = await build({
37
- entryPoints: glob('./src/vertices/**/ui/*.main.tsx'),
38
- outdir: 'cdn',
39
- bundle: true,
40
- minify: true,
41
- platform: 'browser',
42
- splitting: true,
43
- tsconfig: 'tsconfig.json',
44
- format: 'esm',
45
- metafile: true,
46
- publicPath: CDN_PATH,
47
- loader,
48
- });
49
-
50
- const entrypoints = {
51
- configurators: {},
52
- executors: {},
53
- vertices: [],
54
- };
55
- for (const [outputPath, outputMeta] of Object.entries(result.metafile.outputs)) {
56
- if (!outputMeta.entryPoint) {
57
- continue;
58
- }
59
- let vertex = path.dirname(path.dirname(path.relative('./src/vertices', outputMeta.entryPoint)));
60
- if (entrypoints.vertices.findIndex((v) => v === vertex) === -1 && vertexDefinitions.find((v) => v.name === vertex)) {
61
- entrypoints.vertices.push(vertex);
62
- }
63
- if (outputMeta.entryPoint.endsWith('executor.main.tsx')) {
64
- entrypoints.executors[vertex] = { js: `${CDN_PATH}/${outputPath.substring(4)}` };
65
- if (outputMeta.cssBundle) {
66
- entrypoints.executors[vertex].css = `${CDN_PATH}/${outputMeta.cssBundle.substring(4)}`;
67
- }
68
- } else if (outputMeta.entryPoint.endsWith('configurator.main.tsx')) {
69
- entrypoints.configurators[vertex] = { js: `${CDN_PATH}/${outputPath.substring(4)}` };
70
- if (outputMeta.cssBundle) {
71
- entrypoints.configurators[vertex].css = `${CDN_PATH}/${outputMeta.cssBundle.substring(4)}`;
72
- }
73
- }
74
- }
75
-
76
- // Build the static site, make sure that we have the CDN as the public path for the assets
77
- await build({
78
- entryPoints: glob('./src/vertices/**/*.ssg.tsx'),
79
- outdir: 'dist',
80
- tsconfig: 'tsconfig.json',
81
- bundle: true,
82
- minify: true,
83
- platform: 'node',
84
- format: 'cjs',
85
- target: 'esnext',
86
- publicPath: CDN_PATH,
87
- loader,
88
- outExtension: {
89
- '.js': '.cjs',
90
- },
91
- });
92
-
93
- const configIndices = {};
94
- for (const file of glob('./dist/**/configurator.ssg.cjs')) {
95
- const { default: render } = await import(`file://${path.resolve(file)}`);
96
- const vertex = entrypoints.vertices.length === 1 ? entrypoints.vertices[0] : path.dirname(path.dirname(path.relative('./dist', file)));
97
- const entrypoint = entrypoints.configurators[vertex];
98
- if (entrypoint) {
99
- configIndices[vertex] = render.default(entrypoint.js, entrypoint.css);
100
- }
101
- }
102
- fs.writeFileSync('./dist/configurator-index-html.json', JSON.stringify(configIndices));
103
- const execIndices = {};
104
- for (const file of glob('./dist/**/executor.ssg.cjs')) {
105
- const { default: render } = await import(`file://${path.resolve(file)}`);
106
- const vertex = entrypoints.vertices.length === 1 ? entrypoints.vertices[0] : path.dirname(path.dirname(path.relative('./dist', file)));
107
-
108
- const entrypoint = entrypoints.executors[vertex];
109
- execIndices[vertex] = render.default(entrypoint.js, entrypoint.css);
110
- }
111
- fs.writeFileSync('./dist/executor-index-html.json', JSON.stringify(execIndices));
@@ -1,7 +0,0 @@
1
- declare global {
2
- const PLUGINS_CDN: string;
3
- const CONFIGURATOR_INDEX_HTML: Record<string, string>;
4
- const EXECUTOR_INDEX_HTML: Record<string, string>;
5
- }
6
-
7
- export {};
package/assets/inject.js DELETED
@@ -1,15 +0,0 @@
1
- import 'unenv/runtime/polyfill/node-global'
2
- import 'unenv/runtime/polyfill/process'
3
- import 'unenv/runtime/polyfill/performance'
4
- import processModule from '@cloudflare/unenv-preset/runtime/node/process/index'
5
- if (typeof globalThis.process === 'undefined') {
6
- globalThis.process = processModule
7
- }
8
- import consoleModule from '@cloudflare/unenv-preset/runtime/node/console/index'
9
- if (typeof globalThis.console === 'undefined') {
10
- globalThis.console = consoleModule
11
- }
12
- import perfModule from 'unenv/runtime/polyfill/performance'
13
- if (typeof globalThis.performance === 'undefined') {
14
- globalThis.performance = perfModule
15
- }