@revenexx/integrations-node-devkit 0.2.1 → 0.3.0
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 +35 -13
- package/dist/{chunk-UBYGZFB7.js → chunk-PS3HCKE7.js} +263 -68
- package/dist/chunk-PS3HCKE7.js.map +1 -0
- package/dist/cli.cjs +426 -545
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +140 -452
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +258 -68
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +80 -8
- package/dist/index.d.ts +80 -8
- package/dist/index.js +1 -1
- package/package.json +7 -4
- package/preview-host/app.vue +22 -0
- package/preview-host/assets/css/main.css +22 -0
- package/preview-host/composables/devkit-console-stubs.ts +52 -0
- package/preview-host/middleware/hide-workflows.global.ts +13 -0
- package/preview-host/nuxt.config.ts +38 -0
- package/preview-host/package.json +37 -0
- package/preview-host/pages/index.vue +63 -0
- package/preview-host/pages/nodes.vue +208 -0
- package/dist/chunk-UBYGZFB7.js.map +0 -1
package/dist/cli.cjs
CHANGED
|
@@ -28,11 +28,11 @@ var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${_
|
|
|
28
28
|
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
29
29
|
|
|
30
30
|
// src/cli.ts
|
|
31
|
-
var
|
|
31
|
+
var import_node_fs6 = require("fs");
|
|
32
32
|
var import_node_http2 = require("http");
|
|
33
33
|
var import_node_module = require("module");
|
|
34
|
-
var
|
|
35
|
-
var
|
|
34
|
+
var import_node_path5 = require("path");
|
|
35
|
+
var import_node_url3 = require("url");
|
|
36
36
|
|
|
37
37
|
// src/env.ts
|
|
38
38
|
var import_node_fs = require("fs");
|
|
@@ -46,15 +46,25 @@ function resolveEnvFile(argv, cwd = process.cwd()) {
|
|
|
46
46
|
if (argv.includes("--no-env")) {
|
|
47
47
|
return { path: null, explicit: false };
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
let named = null;
|
|
50
|
+
for (let i = 0; i < argv.length; i++) {
|
|
51
|
+
if (argv[i] !== "--env") {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
const value = argv[++i];
|
|
55
|
+
if (!value || value.startsWith("-")) {
|
|
56
|
+
throw new Error("--env requires a path.");
|
|
57
|
+
}
|
|
58
|
+
named = { path: (0, import_node_path.resolve)(cwd, value), explicit: true, raw: value };
|
|
52
59
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
60
|
+
return named ?? { path: (0, import_node_path.resolve)(cwd, ".env"), explicit: false };
|
|
61
|
+
}
|
|
62
|
+
function missingFileMessage(choice, cwd) {
|
|
63
|
+
const raw = choice.raw;
|
|
64
|
+
if (raw && raw === (0, import_node_path.basename)(raw) && (0, import_node_fs.existsSync)((0, import_node_path.resolve)(cwd, `.env.${raw}`))) {
|
|
65
|
+
return `--env: ${choice.path} does not exist. Did you mean --env .env.${raw}? The flag takes a path, not an environment name.`;
|
|
56
66
|
}
|
|
57
|
-
return
|
|
67
|
+
return `--env: ${choice.path} does not exist.`;
|
|
58
68
|
}
|
|
59
69
|
function loadEnvFile(argv, options = {}) {
|
|
60
70
|
const { cwd = process.cwd(), warn = (message) => console.warn(message) } = options;
|
|
@@ -62,26 +72,26 @@ function loadEnvFile(argv, options = {}) {
|
|
|
62
72
|
if (nodeFlag) {
|
|
63
73
|
warn(`Note: ${nodeFlag} is a Node flag and Node has already applied it. The devkit's own flag is --env <path>.`);
|
|
64
74
|
}
|
|
65
|
-
const
|
|
66
|
-
if (!path) {
|
|
75
|
+
const choice = resolveEnvFile(argv, cwd);
|
|
76
|
+
if (!choice.path) {
|
|
67
77
|
return null;
|
|
68
78
|
}
|
|
69
|
-
if (!(0, import_node_fs.existsSync)(path)) {
|
|
70
|
-
if (explicit) {
|
|
71
|
-
throw new Error(
|
|
79
|
+
if (!(0, import_node_fs.existsSync)(choice.path)) {
|
|
80
|
+
if (choice.explicit) {
|
|
81
|
+
throw new Error(missingFileMessage(choice, cwd));
|
|
72
82
|
}
|
|
73
83
|
return null;
|
|
74
84
|
}
|
|
75
85
|
if (typeof process.loadEnvFile !== "function") {
|
|
76
|
-
warn(`Ignoring ${path}: env-file support needs Node >= ${ENV_FILE_MIN_NODE} (running ${process.version}).`);
|
|
86
|
+
warn(`Ignoring ${choice.path}: env-file support needs Node >= ${ENV_FILE_MIN_NODE} (running ${process.version}).`);
|
|
77
87
|
return null;
|
|
78
88
|
}
|
|
79
|
-
process.loadEnvFile(path);
|
|
80
|
-
return path;
|
|
89
|
+
process.loadEnvFile(choice.path);
|
|
90
|
+
return choice.path;
|
|
81
91
|
}
|
|
82
92
|
|
|
83
93
|
// src/index.ts
|
|
84
|
-
var
|
|
94
|
+
var import_node_fs4 = require("fs");
|
|
85
95
|
|
|
86
96
|
// src/errors.ts
|
|
87
97
|
var DevApiError = class extends Error {
|
|
@@ -96,9 +106,31 @@ var DevApiError = class extends Error {
|
|
|
96
106
|
};
|
|
97
107
|
|
|
98
108
|
// src/loader.ts
|
|
109
|
+
var import_node_fs2 = require("fs");
|
|
110
|
+
var import_node_path2 = require("path");
|
|
99
111
|
var import_node_url = require("url");
|
|
100
112
|
var import_integrations_node_sdk = require("@revenexx/integrations-node-sdk");
|
|
101
|
-
|
|
113
|
+
var UNKNOWN_PACKAGE = { name: "unknown", version: "0.0.0", label: "Local package" };
|
|
114
|
+
function readPackageInfo(entryPath) {
|
|
115
|
+
let dir = (0, import_node_path2.dirname)(entryPath);
|
|
116
|
+
for (let up = 0; up < 6; up += 1) {
|
|
117
|
+
const candidate = (0, import_node_path2.join)(dir, "package.json");
|
|
118
|
+
if ((0, import_node_fs2.existsSync)(candidate)) {
|
|
119
|
+
try {
|
|
120
|
+
const pkg = JSON.parse((0, import_node_fs2.readFileSync)(candidate, "utf-8"));
|
|
121
|
+
if (pkg.name) {
|
|
122
|
+
return { name: pkg.name, version: pkg.version ?? "0.0.0", label: pkg.name.split("/").pop() ?? pkg.name };
|
|
123
|
+
}
|
|
124
|
+
} catch {
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const parent = (0, import_node_path2.dirname)(dir);
|
|
128
|
+
if (parent === dir) break;
|
|
129
|
+
dir = parent;
|
|
130
|
+
}
|
|
131
|
+
return UNKNOWN_PACKAGE;
|
|
132
|
+
}
|
|
133
|
+
function resolveExports(mod, packageInfo = UNKNOWN_PACKAGE) {
|
|
102
134
|
if (!Array.isArray(mod.NODES)) {
|
|
103
135
|
throw new Error("Package entry does not export a `NODES` array. Export `NODES: INode[]`.");
|
|
104
136
|
}
|
|
@@ -115,7 +147,9 @@ function resolveExports(mod) {
|
|
|
115
147
|
nodes,
|
|
116
148
|
credentials,
|
|
117
149
|
templates,
|
|
118
|
-
manifest: (0, import_integrations_node_sdk.buildManifest)(nodes, credentials, templates)
|
|
150
|
+
manifest: (0, import_integrations_node_sdk.buildManifest)(nodes, credentials, templates),
|
|
151
|
+
packageInfo,
|
|
152
|
+
loadedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
119
153
|
};
|
|
120
154
|
}
|
|
121
155
|
var tsxRegistered = false;
|
|
@@ -127,6 +161,10 @@ async function ensureTsxRegistered() {
|
|
|
127
161
|
register();
|
|
128
162
|
tsxRegistered = true;
|
|
129
163
|
}
|
|
164
|
+
var RELOADABLE_SOURCE = /\.(?:[cm]?[jt]sx?|json)$/;
|
|
165
|
+
function isReloadableSource(file) {
|
|
166
|
+
return RELOADABLE_SOURCE.test(file);
|
|
167
|
+
}
|
|
130
168
|
async function importFresh(entryPath) {
|
|
131
169
|
if (/\.[cm]?tsx?$/.test(entryPath)) {
|
|
132
170
|
await ensureTsxRegistered();
|
|
@@ -135,17 +173,19 @@ async function importFresh(entryPath) {
|
|
|
135
173
|
return await import(href);
|
|
136
174
|
}
|
|
137
175
|
async function loadPackageFromEntry(entryPath) {
|
|
138
|
-
return resolveExports(await importFresh(entryPath));
|
|
176
|
+
return resolveExports(await importFresh(entryPath), readPackageInfo(entryPath));
|
|
139
177
|
}
|
|
140
178
|
|
|
141
179
|
// src/persistence.ts
|
|
142
|
-
var
|
|
143
|
-
var
|
|
180
|
+
var import_node_fs3 = require("fs");
|
|
181
|
+
var import_node_path3 = require("path");
|
|
144
182
|
|
|
145
183
|
// src/store.ts
|
|
146
184
|
var import_node_crypto = require("crypto");
|
|
147
185
|
var DEV_TENANT_ID = "dev-tenant";
|
|
148
|
-
var
|
|
186
|
+
var BLOB_DEFINITION_VERSION = "v0-draft";
|
|
187
|
+
var EXECUTION_MODES = ["async_only", "sync_only", "caller_decides"];
|
|
188
|
+
var STORE_SCHEMA_VERSION = 2;
|
|
149
189
|
function now() {
|
|
150
190
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
151
191
|
}
|
|
@@ -188,6 +228,9 @@ var DevStore = class {
|
|
|
188
228
|
status: input.status ?? "active",
|
|
189
229
|
config: input.config,
|
|
190
230
|
durableCreds: input.durableCreds ?? null,
|
|
231
|
+
lastTestAt: null,
|
|
232
|
+
lastTestOk: null,
|
|
233
|
+
lastTestMessage: null,
|
|
191
234
|
createdAt: ts,
|
|
192
235
|
updatedAt: ts
|
|
193
236
|
};
|
|
@@ -216,6 +259,21 @@ var DevStore = class {
|
|
|
216
259
|
this.touch();
|
|
217
260
|
return record;
|
|
218
261
|
}
|
|
262
|
+
/**
|
|
263
|
+
* Records the outcome of a credential test. The service persists this on the
|
|
264
|
+
* record and reports it back from `POST /credentials/{id}/test`.
|
|
265
|
+
*/
|
|
266
|
+
recordCredentialTest(id, result) {
|
|
267
|
+
const record = this.credentials.get(id);
|
|
268
|
+
if (!record) {
|
|
269
|
+
return void 0;
|
|
270
|
+
}
|
|
271
|
+
record.lastTestAt = now();
|
|
272
|
+
record.lastTestOk = result.ok;
|
|
273
|
+
record.lastTestMessage = result.message ?? null;
|
|
274
|
+
this.touch();
|
|
275
|
+
return record;
|
|
276
|
+
}
|
|
219
277
|
deleteCredential(id) {
|
|
220
278
|
const deleted = this.credentials.delete(id);
|
|
221
279
|
if (deleted) {
|
|
@@ -262,7 +320,12 @@ var DevStore = class {
|
|
|
262
320
|
const record = {
|
|
263
321
|
id: this.nextWorkflowId++,
|
|
264
322
|
name: input.name,
|
|
265
|
-
|
|
323
|
+
description: input.description ?? null,
|
|
324
|
+
blob: input.blob,
|
|
325
|
+
blobDefinitionVersion: input.blobDefinitionVersion ?? BLOB_DEFINITION_VERSION,
|
|
326
|
+
active: input.active ?? true,
|
|
327
|
+
executionMode: input.executionMode ?? EXECUTION_MODES[0],
|
|
328
|
+
revision: 1,
|
|
266
329
|
buildStatus: "ready",
|
|
267
330
|
createdAt: ts,
|
|
268
331
|
updatedAt: ts
|
|
@@ -276,7 +339,8 @@ var DevStore = class {
|
|
|
276
339
|
if (!record) {
|
|
277
340
|
return void 0;
|
|
278
341
|
}
|
|
279
|
-
Object.
|
|
342
|
+
const defined = Object.fromEntries(Object.entries(patch).filter(([, v]) => v !== void 0));
|
|
343
|
+
Object.assign(record, defined, { revision: record.revision + 1, updatedAt: now() });
|
|
280
344
|
this.touch();
|
|
281
345
|
return record;
|
|
282
346
|
}
|
|
@@ -417,16 +481,23 @@ function applySeeds(store, seeds, env = process.env) {
|
|
|
417
481
|
});
|
|
418
482
|
}
|
|
419
483
|
for (const workflow of seeds.workflows ?? []) {
|
|
420
|
-
|
|
484
|
+
const resolved = interpolateEnv(workflow, env);
|
|
485
|
+
store.createWorkflow({
|
|
486
|
+
name: resolved.name,
|
|
487
|
+
blob: resolved.blob ?? resolved.definition ?? {},
|
|
488
|
+
description: resolved.description,
|
|
489
|
+
active: resolved.active,
|
|
490
|
+
executionMode: resolved.executionMode
|
|
491
|
+
});
|
|
421
492
|
}
|
|
422
493
|
}
|
|
423
494
|
function loadState(file, log = console.warn) {
|
|
424
|
-
if (!(0,
|
|
495
|
+
if (!(0, import_node_fs3.existsSync)(file)) {
|
|
425
496
|
return null;
|
|
426
497
|
}
|
|
427
498
|
let parsed;
|
|
428
499
|
try {
|
|
429
|
-
parsed = JSON.parse((0,
|
|
500
|
+
parsed = JSON.parse((0, import_node_fs3.readFileSync)(file, "utf-8"));
|
|
430
501
|
} catch {
|
|
431
502
|
log(`Ignoring ${file}: not valid JSON.`);
|
|
432
503
|
return null;
|
|
@@ -438,14 +509,14 @@ function loadState(file, log = console.warn) {
|
|
|
438
509
|
return parsed;
|
|
439
510
|
}
|
|
440
511
|
function saveState(file, snapshot) {
|
|
441
|
-
(0,
|
|
442
|
-
(0,
|
|
512
|
+
(0, import_node_fs3.mkdirSync)((0, import_node_path3.dirname)(file), { recursive: true });
|
|
513
|
+
(0, import_node_fs3.writeFileSync)(file, JSON.stringify(snapshot, null, 2), "utf-8");
|
|
443
514
|
}
|
|
444
515
|
var SEED_ENTRY_CANDIDATES = ["index.ts", "index.mjs", "index.js", "seeds.ts", "seeds.js"];
|
|
445
516
|
async function loadSeedsFromDir(dir) {
|
|
446
517
|
for (const candidate of SEED_ENTRY_CANDIDATES) {
|
|
447
|
-
const path = (0,
|
|
448
|
-
if ((0,
|
|
518
|
+
const path = (0, import_node_path3.resolve)(dir, candidate);
|
|
519
|
+
if ((0, import_node_fs3.existsSync)(path)) {
|
|
449
520
|
const mod = await importFresh(path);
|
|
450
521
|
return mod.default ?? mod.seeds ?? {};
|
|
451
522
|
}
|
|
@@ -711,6 +782,56 @@ async function validateNodeConfig(loaded, store, input) {
|
|
|
711
782
|
}
|
|
712
783
|
return { valid: Object.keys(errors).length === 0, errors };
|
|
713
784
|
}
|
|
785
|
+
var MIN_TIMEOUT_MS = 1e3;
|
|
786
|
+
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
787
|
+
var ExecuteTimeout = class extends Error {
|
|
788
|
+
};
|
|
789
|
+
async function executeNodeTest(loaded, store, input) {
|
|
790
|
+
const node = findNode(loaded, input.slug, input.version);
|
|
791
|
+
const logs = [];
|
|
792
|
+
const record = (level) => (message, meta) => {
|
|
793
|
+
logs.push(meta === void 0 ? { level, message } : { level, message, meta });
|
|
794
|
+
};
|
|
795
|
+
const timeoutMs = Math.max(MIN_TIMEOUT_MS, input.timeoutMs ?? DEFAULT_TIMEOUT_MS);
|
|
796
|
+
const controller = new AbortController();
|
|
797
|
+
let timer;
|
|
798
|
+
const expired = new Promise((_resolve, reject) => {
|
|
799
|
+
timer = setTimeout(() => {
|
|
800
|
+
controller.abort();
|
|
801
|
+
reject(new ExecuteTimeout());
|
|
802
|
+
}, timeoutMs);
|
|
803
|
+
});
|
|
804
|
+
const ctx = {
|
|
805
|
+
signal: controller.signal,
|
|
806
|
+
logger: { info: record("info"), warn: record("warn"), error: record("error") },
|
|
807
|
+
secrets: {
|
|
808
|
+
async get(key) {
|
|
809
|
+
const secret = store.getSecret(key);
|
|
810
|
+
if (!secret) {
|
|
811
|
+
throw new DevApiError(404, `Secret '${key}' not found.`);
|
|
812
|
+
}
|
|
813
|
+
return secret.value;
|
|
814
|
+
}
|
|
815
|
+
},
|
|
816
|
+
credentials: {
|
|
817
|
+
async get(id) {
|
|
818
|
+
return (await resolveCredentialInstance(loaded, store, id)).credentials;
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
};
|
|
822
|
+
try {
|
|
823
|
+
const result = await Promise.race([node.execute(ctx, { ...input.config, ...input.inputs }), expired]);
|
|
824
|
+
return { outputs: result.outputs ?? {}, branch: result.branch ?? null, logs };
|
|
825
|
+
} catch (err) {
|
|
826
|
+
if (err instanceof DevApiError) {
|
|
827
|
+
throw err;
|
|
828
|
+
}
|
|
829
|
+
const reason = err instanceof ExecuteTimeout || controller.signal.aborted ? `timed out after ${timeoutMs} ms` : err.message;
|
|
830
|
+
throw new DevApiError(502, `Node execution failed: ${reason}`, { logs: logs.map((l) => `${l.level}: ${l.message}`) });
|
|
831
|
+
} finally {
|
|
832
|
+
clearTimeout(timer);
|
|
833
|
+
}
|
|
834
|
+
}
|
|
714
835
|
async function testCredentialConfig(loaded, store, typeSlug, config) {
|
|
715
836
|
const cred = findCredential(loaded, typeSlug);
|
|
716
837
|
return cred.test(credentialContext(store), config);
|
|
@@ -752,16 +873,22 @@ async function exchangeOAuthCode(loaded, store, credentialId, params) {
|
|
|
752
873
|
var import_node_http = __toESM(require("http"), 1);
|
|
753
874
|
|
|
754
875
|
// src/http.ts
|
|
876
|
+
var API_VERSION = "1.0.0";
|
|
877
|
+
var BASE_HEADERS = {
|
|
878
|
+
"X-Api-Version": API_VERSION,
|
|
879
|
+
"Access-Control-Allow-Origin": "*",
|
|
880
|
+
"Access-Control-Allow-Headers": "*",
|
|
881
|
+
"Access-Control-Allow-Methods": "GET,POST,PUT,PATCH,DELETE,OPTIONS"
|
|
882
|
+
};
|
|
755
883
|
function sendJson(res, status, body) {
|
|
756
884
|
const payload = JSON.stringify(body);
|
|
757
|
-
res.writeHead(status, {
|
|
758
|
-
"Content-Type": "application/json",
|
|
759
|
-
"Access-Control-Allow-Origin": "*",
|
|
760
|
-
"Access-Control-Allow-Headers": "*",
|
|
761
|
-
"Access-Control-Allow-Methods": "GET,POST,PUT,PATCH,DELETE,OPTIONS"
|
|
762
|
-
});
|
|
885
|
+
res.writeHead(status, { "Content-Type": "application/json", ...BASE_HEADERS });
|
|
763
886
|
res.end(payload);
|
|
764
887
|
}
|
|
888
|
+
function sendNoContent(res) {
|
|
889
|
+
res.writeHead(204, BASE_HEADERS);
|
|
890
|
+
res.end();
|
|
891
|
+
}
|
|
765
892
|
function sendError(res, err) {
|
|
766
893
|
if (err instanceof DevApiError) {
|
|
767
894
|
sendJson(res, err.status, err.errors ? { message: err.message, errors: err.errors } : { message: err.message });
|
|
@@ -799,20 +926,24 @@ function hasDynamicSchema(desc) {
|
|
|
799
926
|
function hasDynamicOutputs(desc) {
|
|
800
927
|
return (desc.outputs ?? []).some((o) => o.resolveOutputs === true);
|
|
801
928
|
}
|
|
802
|
-
function nodeToApi(desc) {
|
|
929
|
+
function nodeToApi(desc, ctx) {
|
|
803
930
|
const [namespace] = desc.slug.split(":");
|
|
804
931
|
return {
|
|
805
932
|
name: desc.name,
|
|
806
933
|
namespace: namespace ?? null,
|
|
807
934
|
slug: desc.slug,
|
|
808
935
|
version: desc.version,
|
|
936
|
+
// The contract declares `package` and both timestamps as present. Nodes here
|
|
937
|
+
// come from the developer's working tree, so the package identity is read from
|
|
938
|
+
// their package.json and the timestamps are when the mock loaded the entry.
|
|
939
|
+
package: ctx?.packageInfo ?? null,
|
|
809
940
|
manifest_version: import_integrations_node_sdk3.MANIFEST_VERSION,
|
|
810
941
|
manifest: desc,
|
|
811
942
|
has_dynamic_options: hasDynamicOptions(desc),
|
|
812
943
|
has_dynamic_schema: hasDynamicSchema(desc),
|
|
813
944
|
has_dynamic_outputs: hasDynamicOutputs(desc),
|
|
814
|
-
created_at: null,
|
|
815
|
-
updated_at: null
|
|
945
|
+
created_at: ctx?.loadedAt ?? null,
|
|
946
|
+
updated_at: ctx?.loadedAt ?? null
|
|
816
947
|
};
|
|
817
948
|
}
|
|
818
949
|
function credentialTypeToApi(desc) {
|
|
@@ -822,6 +953,7 @@ function credentialTypeToApi(desc) {
|
|
|
822
953
|
name: desc.name,
|
|
823
954
|
description: desc.description ?? null,
|
|
824
955
|
icon: desc.icon ?? null,
|
|
956
|
+
images: desc.images ?? [],
|
|
825
957
|
auth_kind: desc.authKind,
|
|
826
958
|
fields: desc.fields
|
|
827
959
|
};
|
|
@@ -857,7 +989,16 @@ function workflowToApi(record) {
|
|
|
857
989
|
return {
|
|
858
990
|
id: record.id,
|
|
859
991
|
name: record.name,
|
|
860
|
-
|
|
992
|
+
description: record.description,
|
|
993
|
+
blob_definition_version: record.blobDefinitionVersion,
|
|
994
|
+
blob: record.blob,
|
|
995
|
+
active: record.active,
|
|
996
|
+
execution_mode: record.executionMode,
|
|
997
|
+
revision: record.revision,
|
|
998
|
+
// The service reports blob-validation warnings here. The mock's validation is
|
|
999
|
+
// schema-light (see the fidelity caveats), so it never has any — but the field
|
|
1000
|
+
// is part of the contract and clients may read it.
|
|
1001
|
+
warnings: [],
|
|
861
1002
|
build_status: record.buildStatus,
|
|
862
1003
|
created_at: record.createdAt,
|
|
863
1004
|
updated_at: record.updatedAt
|
|
@@ -886,6 +1027,7 @@ function templateSummaryToApi(t) {
|
|
|
886
1027
|
shortDescription: t.shortDescription ?? null,
|
|
887
1028
|
description: t.description ?? null,
|
|
888
1029
|
icon: t.icon ?? null,
|
|
1030
|
+
images: t.images ?? [],
|
|
889
1031
|
industries: t.industries ?? [],
|
|
890
1032
|
vendors: t.vendors ?? [],
|
|
891
1033
|
triggerTypes: (t.triggers ?? []).map((tr) => tr.type)
|
|
@@ -894,9 +1036,13 @@ function templateSummaryToApi(t) {
|
|
|
894
1036
|
function templateFullToApi(t) {
|
|
895
1037
|
return {
|
|
896
1038
|
...templateSummaryToApi(t),
|
|
897
|
-
|
|
1039
|
+
// snake_case per the contract, even though the surrounding template fields are
|
|
1040
|
+
// camelCase and the SDK's own field is `blobVersion`.
|
|
1041
|
+
blob_version: t.blobVersion,
|
|
898
1042
|
definition: t.definition,
|
|
899
|
-
|
|
1043
|
+
// `config` is optional in the SDK (a manual trigger has none) but declared in
|
|
1044
|
+
// the contract, so normalise it to an object rather than omitting it.
|
|
1045
|
+
triggers: (t.triggers ?? []).map((tr) => ({ ...tr, config: tr.config ?? {} }))
|
|
900
1046
|
};
|
|
901
1047
|
}
|
|
902
1048
|
|
|
@@ -924,13 +1070,15 @@ async function handle(req, res, deps) {
|
|
|
924
1070
|
switch (seg[0]) {
|
|
925
1071
|
case void 0:
|
|
926
1072
|
case "health":
|
|
1073
|
+
// The service's health route is `/up` (Laravel's default); `/health` is kept
|
|
1074
|
+
// because the devkit has always answered there.
|
|
1075
|
+
case "up":
|
|
927
1076
|
return void sendJson(res, 200, { status: "ok" });
|
|
928
1077
|
case "me":
|
|
929
1078
|
return void sendJson(res, 200, {
|
|
930
|
-
id: "dev-user",
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
tenant_id: DEV_TENANT_ID
|
|
1079
|
+
user: { id: 1, zitadel_id: "dev-user", email: "dev@revenexx.test", name: "Dev User" },
|
|
1080
|
+
context: { tenant_id: DEV_TENANT_ID, active_plane: "public", roles: ["admin", "user"] },
|
|
1081
|
+
claims: { iss: "https://id.revenexx.test", sub: "dev-user", aud: ["devkit"] }
|
|
934
1082
|
});
|
|
935
1083
|
case "schemas":
|
|
936
1084
|
return handleSchemas(res, deps, seg);
|
|
@@ -957,15 +1105,22 @@ function handleSchemas(res, deps, seg) {
|
|
|
957
1105
|
throw new DevApiError(404, "Schema domain required.");
|
|
958
1106
|
}
|
|
959
1107
|
const schemas = deps.schemas ?? {};
|
|
960
|
-
|
|
1108
|
+
if (!version) {
|
|
1109
|
+
const versions = Object.keys(schemas).filter((key) => key.startsWith(`${domain}/`)).map((key) => key.slice(domain.length + 1)).sort();
|
|
1110
|
+
if (versions.length === 0 && !schemas[domain]) {
|
|
1111
|
+
throw new DevApiError(404, `Unknown schema domain '${domain}'. Vendor it into assets/schemas.`);
|
|
1112
|
+
}
|
|
1113
|
+
return void sendJson(res, 200, { domain, versions });
|
|
1114
|
+
}
|
|
1115
|
+
const schema = schemas[`${domain}/${version}`];
|
|
961
1116
|
if (!schema) {
|
|
962
|
-
throw new DevApiError(404, `
|
|
1117
|
+
throw new DevApiError(404, `Unknown schema version '${domain}/${version}'. Vendor it into assets/schemas.`);
|
|
963
1118
|
}
|
|
964
|
-
sendJson(res, 200, schema);
|
|
1119
|
+
sendJson(res, 200, { domain, version, schema });
|
|
965
1120
|
}
|
|
966
1121
|
async function handleNodes(req, res, method, loaded, store, seg) {
|
|
967
1122
|
if (seg.length === 1 && method === "GET") {
|
|
968
|
-
return void sendJson(res, 200, { data: loaded.manifest.nodes.map(nodeToApi) });
|
|
1123
|
+
return void sendJson(res, 200, { data: loaded.manifest.nodes.map((n) => nodeToApi(n, nodeApiContext(loaded))) });
|
|
969
1124
|
}
|
|
970
1125
|
const slug = seg[1];
|
|
971
1126
|
if (!slug) {
|
|
@@ -1006,15 +1161,36 @@ async function handleNodes(req, res, method, loaded, store, seg) {
|
|
|
1006
1161
|
});
|
|
1007
1162
|
return void sendJson(res, 200, result);
|
|
1008
1163
|
}
|
|
1164
|
+
if (seg[3] === "execute:test" && method === "POST") {
|
|
1165
|
+
const body = await readJson(req);
|
|
1166
|
+
const result = await executeNodeTest(loaded, store, {
|
|
1167
|
+
slug,
|
|
1168
|
+
version,
|
|
1169
|
+
config: body.config ?? {},
|
|
1170
|
+
inputs: body.inputs ?? {},
|
|
1171
|
+
timeoutMs: body.timeout_ms
|
|
1172
|
+
});
|
|
1173
|
+
return void sendJson(res, 200, result);
|
|
1174
|
+
}
|
|
1009
1175
|
if (seg.length === 3 && method === "GET") {
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
return void
|
|
1176
|
+
return void sendJson(res, 200, nodeToApi(findManifestNode(loaded, slug, version), nodeApiContext(loaded)));
|
|
1177
|
+
}
|
|
1178
|
+
if (seg.length === 3 && method === "DELETE") {
|
|
1179
|
+
findManifestNode(loaded, slug, version);
|
|
1180
|
+
return void sendNoContent(res);
|
|
1015
1181
|
}
|
|
1016
1182
|
throw new DevApiError(404, `No route for nodes/${seg.slice(1).join("/")}`);
|
|
1017
1183
|
}
|
|
1184
|
+
function nodeApiContext(loaded) {
|
|
1185
|
+
return { packageInfo: loaded.packageInfo, loadedAt: loaded.loadedAt };
|
|
1186
|
+
}
|
|
1187
|
+
function findManifestNode(loaded, slug, version) {
|
|
1188
|
+
const node = loaded.manifest.nodes.find((n) => n.slug === slug && (version === "latest" || n.version === version));
|
|
1189
|
+
if (!node) {
|
|
1190
|
+
throw new DevApiError(404, `Node '${slug}@${version}' not found.`);
|
|
1191
|
+
}
|
|
1192
|
+
return node;
|
|
1193
|
+
}
|
|
1018
1194
|
function handleCredentialTypes(res, loaded, seg) {
|
|
1019
1195
|
if (seg.length === 1) {
|
|
1020
1196
|
return void sendJson(res, 200, {
|
|
@@ -1078,7 +1254,13 @@ async function handleCredentials(req, res, method, loaded, store, seg, url) {
|
|
|
1078
1254
|
}
|
|
1079
1255
|
if (seg[2] === "test" && method === "POST") {
|
|
1080
1256
|
const result = await testCredentialInstance(loaded, store, id);
|
|
1081
|
-
|
|
1257
|
+
const record = store.recordCredentialTest(id, { ok: result.ok, message: result.message ?? null });
|
|
1258
|
+
return void sendJson(res, 200, {
|
|
1259
|
+
ok: result.ok,
|
|
1260
|
+
message: result.message ?? null,
|
|
1261
|
+
last_test_at: record?.lastTestAt ?? null,
|
|
1262
|
+
last_test_ok: record?.lastTestOk ?? result.ok
|
|
1263
|
+
});
|
|
1082
1264
|
}
|
|
1083
1265
|
if (seg[2] === "oauth" && seg[3] === "authorize-url" && method === "POST") {
|
|
1084
1266
|
const redirectUri = "http://localhost/api/v1/credentials/oauth/callback";
|
|
@@ -1103,7 +1285,7 @@ async function handleCredentials(req, res, method, loaded, store, seg, url) {
|
|
|
1103
1285
|
}
|
|
1104
1286
|
if (method === "DELETE") {
|
|
1105
1287
|
store.deleteCredential(id);
|
|
1106
|
-
return void
|
|
1288
|
+
return void sendNoContent(res);
|
|
1107
1289
|
}
|
|
1108
1290
|
}
|
|
1109
1291
|
throw new DevApiError(404, `No route for credentials/${seg.slice(1).join("/")}`);
|
|
@@ -1111,7 +1293,7 @@ async function handleCredentials(req, res, method, loaded, store, seg, url) {
|
|
|
1111
1293
|
async function handleSecrets(req, res, method, store, seg) {
|
|
1112
1294
|
if (seg.length === 1) {
|
|
1113
1295
|
if (method === "GET") {
|
|
1114
|
-
return void sendJson(res, 200, {
|
|
1296
|
+
return void sendJson(res, 200, { keys: store.listSecrets().map((s) => s.key) });
|
|
1115
1297
|
}
|
|
1116
1298
|
if (method === "POST") {
|
|
1117
1299
|
const body = await readJson(req);
|
|
@@ -1133,7 +1315,7 @@ async function handleSecrets(req, res, method, store, seg) {
|
|
|
1133
1315
|
}
|
|
1134
1316
|
if (method === "DELETE") {
|
|
1135
1317
|
store.deleteSecret(key);
|
|
1136
|
-
return void
|
|
1318
|
+
return void sendNoContent(res);
|
|
1137
1319
|
}
|
|
1138
1320
|
}
|
|
1139
1321
|
throw new DevApiError(404, `No route for secrets/${seg.slice(1).join("/")}`);
|
|
@@ -1149,16 +1331,17 @@ async function handleTemplates(req, res, method, loaded, store, seg) {
|
|
|
1149
1331
|
throw new DevApiError(404, `Template '${slug}' not found.`);
|
|
1150
1332
|
}
|
|
1151
1333
|
if (seg.length === 2 && method === "GET") {
|
|
1152
|
-
return void sendJson(res, 200, templateFullToApi(template));
|
|
1334
|
+
return void sendJson(res, 200, { data: templateFullToApi(template) });
|
|
1153
1335
|
}
|
|
1154
1336
|
if (seg[2] === "requirements" && method === "GET") {
|
|
1155
|
-
return void sendJson(res, 200, { data: {
|
|
1337
|
+
return void sendJson(res, 200, { data: { credentialTypes: [], secrets: [] } });
|
|
1156
1338
|
}
|
|
1157
1339
|
if (seg[2] === "instantiate" && method === "POST") {
|
|
1158
1340
|
const body = await readJson(req);
|
|
1159
1341
|
const workflow = store.createWorkflow({
|
|
1160
1342
|
name: body.name ?? String(template.name),
|
|
1161
|
-
|
|
1343
|
+
blob: template.definition,
|
|
1344
|
+
blobDefinitionVersion: template.blobVersion
|
|
1162
1345
|
});
|
|
1163
1346
|
for (const trigger of template.triggers ?? []) {
|
|
1164
1347
|
store.createTrigger({
|
|
@@ -1183,7 +1366,11 @@ async function handleWorkflows(req, res, method, store, seg) {
|
|
|
1183
1366
|
const body = await readJson(req);
|
|
1184
1367
|
const workflow = store.createWorkflow({
|
|
1185
1368
|
name: body.name ?? "Untitled workflow",
|
|
1186
|
-
|
|
1369
|
+
blob: body.blob ?? {},
|
|
1370
|
+
blobDefinitionVersion: body.blob_definition_version,
|
|
1371
|
+
description: body.description,
|
|
1372
|
+
active: body.active,
|
|
1373
|
+
executionMode: body.execution_mode
|
|
1187
1374
|
});
|
|
1188
1375
|
return void sendJson(res, 201, workflowToApi(workflow));
|
|
1189
1376
|
}
|
|
@@ -1224,7 +1411,7 @@ async function handleWorkflows(req, res, method, store, seg) {
|
|
|
1224
1411
|
}
|
|
1225
1412
|
if (triggerId && method === "DELETE") {
|
|
1226
1413
|
store.deleteTrigger(triggerId);
|
|
1227
|
-
return void
|
|
1414
|
+
return void sendNoContent(res);
|
|
1228
1415
|
}
|
|
1229
1416
|
}
|
|
1230
1417
|
if (seg.length === 2) {
|
|
@@ -1237,7 +1424,14 @@ async function handleWorkflows(req, res, method, store, seg) {
|
|
|
1237
1424
|
}
|
|
1238
1425
|
if (method === "PUT") {
|
|
1239
1426
|
const body = await readJson(req);
|
|
1240
|
-
const updated = store.updateWorkflow(id, {
|
|
1427
|
+
const updated = store.updateWorkflow(id, {
|
|
1428
|
+
name: body.name,
|
|
1429
|
+
blob: body.blob,
|
|
1430
|
+
blobDefinitionVersion: body.blob_definition_version,
|
|
1431
|
+
description: body.description,
|
|
1432
|
+
active: body.active,
|
|
1433
|
+
executionMode: body.execution_mode
|
|
1434
|
+
});
|
|
1241
1435
|
if (!updated) {
|
|
1242
1436
|
throw new DevApiError(404, `Workflow '${id}' not found.`);
|
|
1243
1437
|
}
|
|
@@ -1245,7 +1439,7 @@ async function handleWorkflows(req, res, method, store, seg) {
|
|
|
1245
1439
|
}
|
|
1246
1440
|
if (method === "DELETE") {
|
|
1247
1441
|
store.deleteWorkflow(id);
|
|
1248
|
-
return void
|
|
1442
|
+
return void sendNoContent(res);
|
|
1249
1443
|
}
|
|
1250
1444
|
}
|
|
1251
1445
|
if ((seg[2] === "credentials" || seg[2] === "credential-types") && method === "GET") {
|
|
@@ -1256,452 +1450,109 @@ async function handleWorkflows(req, res, method, store, seg) {
|
|
|
1256
1450
|
|
|
1257
1451
|
// src/index.ts
|
|
1258
1452
|
var manifestUrl = new URL("../package.json", importMetaUrl);
|
|
1259
|
-
var DEVKIT_VERSION = JSON.parse((0,
|
|
1260
|
-
|
|
1261
|
-
// src/preview/scaffold.ts
|
|
1262
|
-
var import_node_fs4 = require("fs");
|
|
1263
|
-
var import_node_path3 = require("path");
|
|
1453
|
+
var DEVKIT_VERSION = JSON.parse((0, import_node_fs4.readFileSync)(manifestUrl, "utf8")).version;
|
|
1264
1454
|
|
|
1265
|
-
// src/preview/
|
|
1266
|
-
var
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
vueFlowControls: "^1.1.3",
|
|
1275
|
-
vueFlowMinimap: "^1.5.4",
|
|
1276
|
-
vueFlowNodeToolbar: "^1.1.1",
|
|
1277
|
-
dagre: "^3.0.0",
|
|
1278
|
-
lucide: "^1.0.0",
|
|
1279
|
-
solarIcons: "^1.2.1",
|
|
1280
|
-
// studio-integrations 0.5.x embeds a TipTap rich-text editor and vue-sonner toasts.
|
|
1281
|
-
tiptap: "^3.28.0",
|
|
1282
|
-
vueSonner: "^2.0.0",
|
|
1283
|
-
tailwindVite: "^4.0.0",
|
|
1284
|
-
tailwind: "^4.0.0"
|
|
1285
|
-
};
|
|
1286
|
-
var PACKAGE_JSON = `{
|
|
1287
|
-
"name": "integrations-preview-host",
|
|
1288
|
-
"private": true,
|
|
1289
|
-
"type": "module",
|
|
1290
|
-
"scripts": {
|
|
1291
|
-
"dev": "nuxt dev",
|
|
1292
|
-
"build": "nuxt build"
|
|
1293
|
-
},
|
|
1294
|
-
"dependencies": {
|
|
1295
|
-
"@revenexx/studio": "${VERSIONS.studio}",
|
|
1296
|
-
"@revenexx/studio-integrations": "${VERSIONS.studioIntegrations}",
|
|
1297
|
-
"@revenexx/studio-shared": "${VERSIONS.studioShared}",
|
|
1298
|
-
"@solar-icons/nuxt": "${VERSIONS.solarIcons}",
|
|
1299
|
-
"@dagrejs/dagre": "${VERSIONS.dagre}",
|
|
1300
|
-
"@tiptap/core": "${VERSIONS.tiptap}",
|
|
1301
|
-
"@tiptap/extension-document": "${VERSIONS.tiptap}",
|
|
1302
|
-
"@tiptap/extension-history": "${VERSIONS.tiptap}",
|
|
1303
|
-
"@tiptap/extension-paragraph": "${VERSIONS.tiptap}",
|
|
1304
|
-
"@tiptap/extension-text": "${VERSIONS.tiptap}",
|
|
1305
|
-
"@tiptap/pm": "${VERSIONS.tiptap}",
|
|
1306
|
-
"@tiptap/vue-3": "${VERSIONS.tiptap}",
|
|
1307
|
-
"@vue-flow/background": "${VERSIONS.vueFlowBackground}",
|
|
1308
|
-
"@vue-flow/controls": "${VERSIONS.vueFlowControls}",
|
|
1309
|
-
"@vue-flow/core": "${VERSIONS.vueFlowCore}",
|
|
1310
|
-
"@vue-flow/minimap": "${VERSIONS.vueFlowMinimap}",
|
|
1311
|
-
"@vue-flow/node-toolbar": "${VERSIONS.vueFlowNodeToolbar}",
|
|
1312
|
-
"lucide-vue-next": "${VERSIONS.lucide}",
|
|
1313
|
-
"nuxt": "${VERSIONS.nuxt}",
|
|
1314
|
-
"vue": "${VERSIONS.vue}",
|
|
1315
|
-
"vue-sonner": "${VERSIONS.vueSonner}"
|
|
1316
|
-
},
|
|
1317
|
-
"devDependencies": {
|
|
1318
|
-
"@tailwindcss/vite": "${VERSIONS.tailwindVite}",
|
|
1319
|
-
"tailwindcss": "${VERSIONS.tailwind}"
|
|
1320
|
-
}
|
|
1321
|
-
}
|
|
1322
|
-
`;
|
|
1323
|
-
var NUXT_CONFIG = `import tailwindcss from '@tailwindcss/vite';
|
|
1324
|
-
|
|
1325
|
-
// Minimal preview host for local integration-node development.
|
|
1326
|
-
// Generated by \`integrations-devkit init-preview\` \u2014 safe to edit or delete
|
|
1327
|
-
// (it lives under the gitignored .revenexx-dev/).
|
|
1328
|
-
export default defineNuxtConfig({
|
|
1329
|
-
compatibilityDate: '2025-01-01',
|
|
1330
|
-
// SPA: no SSR, so the studio's browser-only composables (localStorage etc.)
|
|
1331
|
-
// behave exactly as in the real cockpit, and boot is fast.
|
|
1332
|
-
ssr: false,
|
|
1333
|
-
// studio-shared 0.2.x ships as a Nuxt MODULE (not a layer) \u2014 it must be
|
|
1334
|
-
// registered in 'modules', before studio-integrations which builds on it.
|
|
1335
|
-
// @solar-icons/nuxt provides the #solar-icons alias the studio components import.
|
|
1336
|
-
modules: ['@revenexx/studio-shared', '@solar-icons/nuxt', '@revenexx/studio-integrations'],
|
|
1337
|
-
css: ['~/assets/css/main.css'],
|
|
1338
|
-
vite: { plugins: [tailwindcss()] },
|
|
1339
|
-
runtimeConfig: {
|
|
1340
|
-
public: {
|
|
1341
|
-
// Overridden at runtime by NUXT_PUBLIC_* env (see .env / the preview command).
|
|
1342
|
-
integrationsApi: '',
|
|
1343
|
-
devToken: '',
|
|
1344
|
-
devTenant: '',
|
|
1345
|
-
},
|
|
1346
|
-
},
|
|
1347
|
-
});
|
|
1348
|
-
`;
|
|
1349
|
-
var MAIN_CSS = `@import "tailwindcss";
|
|
1350
|
-
@import "@revenexx/studio/tokens";
|
|
1351
|
-
@import "@revenexx/studio/fonts";
|
|
1352
|
-
|
|
1353
|
-
@source "../../node_modules/@revenexx/studio/dist";
|
|
1354
|
-
@source "../../node_modules/@revenexx/studio-shared/components";
|
|
1355
|
-
@source "../../node_modules/@revenexx/studio-integrations/dist/runtime";
|
|
1356
|
-
|
|
1357
|
-
/* Phase 1: workflow EXECUTION is not wired up in the devkit preview yet, so the
|
|
1358
|
-
Workflows surface is hidden until phase 2. This hides the sidebar nav entry
|
|
1359
|
-
and any deep links to the workflow editor; the routes are also redirected by
|
|
1360
|
-
middleware/hide-workflows.global.ts. */
|
|
1361
|
-
a[href^="/integrations/workflows"] { display: none !important; }
|
|
1362
|
-
li:has(> a[href^="/integrations/workflows"]) { display: none !important; }
|
|
1363
|
-
`;
|
|
1364
|
-
var APP_VUE = `<script setup lang="ts">
|
|
1365
|
-
import { Toaster } from '@revenexx/studio'
|
|
1366
|
-
|
|
1367
|
-
useHead({ title: 'Integration Studio \u2014 devkit preview' })
|
|
1368
|
-
</script>
|
|
1369
|
-
|
|
1370
|
-
<template>
|
|
1371
|
-
<div class="flex h-svh flex-col overflow-hidden bg-[#f3f1fa] text-foreground">
|
|
1372
|
-
<NuxtLoadingIndicator color="var(--color-primary, #620DFF)" :height="3" />
|
|
1373
|
-
<div class="min-h-0 flex-1 pt-3">
|
|
1374
|
-
<NuxtPage />
|
|
1375
|
-
</div>
|
|
1376
|
-
<Toaster rich-colors position="bottom-right" :duration="3500" close-button />
|
|
1377
|
-
</div>
|
|
1378
|
-
</template>
|
|
1379
|
-
`;
|
|
1380
|
-
var INDEX_VUE = `<template>
|
|
1381
|
-
<div class="mx-auto flex min-h-full max-w-xl flex-col justify-center gap-6 px-6 py-12">
|
|
1382
|
-
<div>
|
|
1383
|
-
<p class="text-mono text-muted-foreground">Integrations \xB7 node devkit</p>
|
|
1384
|
-
<h1 class="mt-1 text-2xl font-medium">Integration Studio \u2014 Preview</h1>
|
|
1385
|
-
<p class="mt-2 text-sm text-muted-foreground">
|
|
1386
|
-
Lokaler Host f\xFCr <code>@revenexx/studio-integrations</code> gegen die Mock-API
|
|
1387
|
-
deines Node-Pakets. Authentifizierung ist ein festes Dev-Token \u2014 nichts einzugeben.
|
|
1388
|
-
</p>
|
|
1389
|
-
</div>
|
|
1390
|
-
|
|
1391
|
-
<div class="rounded-lg border border-black/[0.06] bg-card p-5 text-sm shadow-sm">
|
|
1392
|
-
<p class="text-mono text-muted-foreground">Session</p>
|
|
1393
|
-
<dl class="mt-2 grid grid-cols-[7rem_1fr] gap-y-1">
|
|
1394
|
-
<dt class="text-muted-foreground">Mock API</dt>
|
|
1395
|
-
<dd class="truncate font-mono text-xs leading-5">{{ api }}</dd>
|
|
1396
|
-
<dt class="text-muted-foreground">Tenant</dt>
|
|
1397
|
-
<dd class="font-mono text-xs leading-5">{{ tenant }}</dd>
|
|
1398
|
-
</dl>
|
|
1399
|
-
</div>
|
|
1400
|
-
|
|
1401
|
-
<div class="rounded-lg border border-black/[0.06] bg-card p-5 shadow-sm">
|
|
1402
|
-
<p class="text-mono text-muted-foreground">Einstieg</p>
|
|
1403
|
-
<div class="mt-3 flex flex-col gap-4">
|
|
1404
|
-
<NuxtLink
|
|
1405
|
-
to="/nodes"
|
|
1406
|
-
class="inline-flex w-fit items-center gap-2 rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:opacity-90"
|
|
1407
|
-
>
|
|
1408
|
-
Lokale Nodes \xF6ffnen \u2014 Preview + Validierung
|
|
1409
|
-
</NuxtLink>
|
|
1410
|
-
<div class="flex flex-wrap gap-x-4 gap-y-1.5">
|
|
1411
|
-
<NuxtLink
|
|
1412
|
-
v-for="link in quickLinks"
|
|
1413
|
-
:key="link.to"
|
|
1414
|
-
:to="link.to"
|
|
1415
|
-
class="text-sm text-primary hover:underline"
|
|
1416
|
-
>
|
|
1417
|
-
{{ link.label }}
|
|
1418
|
-
</NuxtLink>
|
|
1419
|
-
</div>
|
|
1420
|
-
</div>
|
|
1421
|
-
</div>
|
|
1422
|
-
</div>
|
|
1423
|
-
</template>
|
|
1424
|
-
|
|
1425
|
-
<script setup lang="ts">
|
|
1426
|
-
const rc = useRuntimeConfig().public
|
|
1427
|
-
const api = rc.integrationsApi
|
|
1428
|
-
const tenant = (rc.devTenant as string) || 'dev-tenant'
|
|
1429
|
-
|
|
1430
|
-
const quickLinks = [
|
|
1431
|
-
{ to: '/integrations', label: 'Overview' },
|
|
1432
|
-
{ to: '/integrations/credentials', label: 'Credentials' },
|
|
1433
|
-
{ to: '/integrations/secrets', label: 'Secrets' },
|
|
1434
|
-
{ to: '/nodes', label: 'Local nodes' },
|
|
1435
|
-
]
|
|
1436
|
-
</script>
|
|
1437
|
-
`;
|
|
1438
|
-
var NODES_VUE = `<template>
|
|
1439
|
-
<div class="ndx-page">
|
|
1440
|
-
<div class="ndx-inner">
|
|
1441
|
-
<header class="ndx-head">
|
|
1442
|
-
<h1>Lokale Nodes</h1>
|
|
1443
|
-
<p>Mock-API: <code>{{ apiUrl }}</code></p>
|
|
1444
|
-
<p v-if="loadError" class="ndx-err">{{ loadError }}</p>
|
|
1445
|
-
</header>
|
|
1446
|
-
|
|
1447
|
-
<p v-if="loading">Lade Nodes\u2026</p>
|
|
1448
|
-
<p v-else-if="nodes.length === 0">Keine Nodes gefunden. Exportiert dein Paket <code>NODES</code>?</p>
|
|
1449
|
-
|
|
1450
|
-
<ul v-else class="ndx-grid">
|
|
1451
|
-
<li v-for="n in nodes" :key="n.slug + '@' + n.version" class="ndx-card" @click="openNode(n)">
|
|
1452
|
-
<div class="ndx-card-title">{{ label(n) }}</div>
|
|
1453
|
-
<div class="ndx-card-slug">{{ n.slug }} \xB7 v{{ n.version }}</div>
|
|
1454
|
-
<div class="ndx-badges">
|
|
1455
|
-
<span v-if="n.has_dynamic_options" class="ndx-badge">dynamic options</span>
|
|
1456
|
-
<span v-if="n.has_dynamic_schema" class="ndx-badge">dynamic schema</span>
|
|
1457
|
-
<span v-if="n.has_dynamic_outputs" class="ndx-badge">dynamic outputs</span>
|
|
1458
|
-
</div>
|
|
1459
|
-
</li>
|
|
1460
|
-
</ul>
|
|
1461
|
-
</div>
|
|
1462
|
-
|
|
1463
|
-
<!-- REUSE of the exact editor lightbox: studio <Dialog> owns the modal
|
|
1464
|
-
chrome, <IntegrationsNodeInspector> is the content \u2014 mirrors
|
|
1465
|
-
WorkflowEditor.vue's <Dialog><DialogContent><NodeInspector/> block. -->
|
|
1466
|
-
<Dialog :open="!!selection" @update:open="(v) => { if (!v) requestClose() }">
|
|
1467
|
-
<DialogContent :show-close-button="false" class="flex h-[min(680px,86vh)] w-[min(1100px,94vw)] max-w-none flex-col gap-0 overflow-hidden rounded-lg p-0 sm:max-w-none">
|
|
1468
|
-
<div v-if="result === 'ok'" class="ndx-strip ndx-strip-ok">\u2713 Payload g\xFCltig \u2014 alles gut.</div>
|
|
1469
|
-
<div v-else-if="result === 'err'" class="ndx-strip ndx-strip-err">\u2717 Payload ung\xFCltig \u2014 {{ errorCount }} Feld(er) pr\xFCfen (rot markiert).</div>
|
|
1470
|
-
<div v-else-if="formError" class="ndx-strip ndx-strip-err">{{ formError }}</div>
|
|
1471
|
-
<IntegrationsNodeInspector
|
|
1472
|
-
v-if="selection"
|
|
1473
|
-
:selection="selection"
|
|
1474
|
-
:secret-keys="secretKeys"
|
|
1475
|
-
:refused-fields="refused"
|
|
1476
|
-
@update="onSubmit"
|
|
1477
|
-
@close="requestClose" />
|
|
1478
|
-
</DialogContent>
|
|
1479
|
-
</Dialog>
|
|
1480
|
-
</div>
|
|
1481
|
-
</template>
|
|
1482
|
-
|
|
1483
|
-
<script setup lang="ts">
|
|
1484
|
-
import { computed, onMounted, ref } from 'vue'
|
|
1485
|
-
import { Dialog, DialogContent } from '@revenexx/studio'
|
|
1486
|
-
|
|
1487
|
-
interface ApiNode {
|
|
1488
|
-
name: string | Record<string, string>
|
|
1489
|
-
slug: string
|
|
1490
|
-
version: string
|
|
1491
|
-
manifest?: { name?: string | Record<string, string> }
|
|
1492
|
-
has_dynamic_options?: boolean
|
|
1493
|
-
has_dynamic_schema?: boolean
|
|
1494
|
-
has_dynamic_outputs?: boolean
|
|
1495
|
-
}
|
|
1496
|
-
|
|
1497
|
-
const apiUrl = useRuntimeConfig().public.integrationsApi
|
|
1498
|
-
const client = useIntegrationsApi()
|
|
1499
|
-
// load() fills the reactive catalog the inspector reads via findManifest();
|
|
1500
|
-
// resolveLocalized() turns a LocalizedString into the active-locale string.
|
|
1501
|
-
const { load, resolveLocalized } = useIntegrationsNodes()
|
|
1502
|
-
|
|
1503
|
-
const nodes = ref<ApiNode[]>([])
|
|
1504
|
-
const loading = ref(true)
|
|
1505
|
-
const loadError = ref<string | null>(null)
|
|
1506
|
-
|
|
1507
|
-
const selection = ref<any>(null)
|
|
1508
|
-
const secretKeys = ref<string[]>([])
|
|
1509
|
-
const refused = ref<Record<string, string>>({})
|
|
1510
|
-
const result = ref<string | null>(null)
|
|
1511
|
-
const formError = ref<string | null>(null)
|
|
1512
|
-
// Set synchronously in onSubmit so the inspector's own Save (it emits update THEN
|
|
1513
|
-
// close) does NOT close the dialog \u2014 we keep it open to show the verdict.
|
|
1514
|
-
const validating = ref(false)
|
|
1515
|
-
|
|
1516
|
-
const errorCount = computed(() => Object.keys(refused.value).length)
|
|
1517
|
-
|
|
1518
|
-
function label(n: ApiNode): string {
|
|
1519
|
-
return resolveLocalized(n.manifest?.name ?? n.name) || n.slug
|
|
1520
|
-
}
|
|
1521
|
-
|
|
1522
|
-
onMounted(async () => {
|
|
1523
|
-
await load()
|
|
1524
|
-
try {
|
|
1525
|
-
const res = await client.get<any>('/nodes')
|
|
1526
|
-
nodes.value = (Array.isArray(res) ? res : res?.data ?? []) as ApiNode[]
|
|
1527
|
-
} catch (e: any) {
|
|
1528
|
-
loadError.value = e?.message ?? 'Nodes konnten nicht geladen werden.'
|
|
1529
|
-
} finally {
|
|
1530
|
-
loading.value = false
|
|
1531
|
-
}
|
|
1532
|
-
try {
|
|
1533
|
-
const secrets = await client.get<any>('/secrets')
|
|
1534
|
-
const list = (Array.isArray(secrets) ? secrets : secrets?.data ?? []) as Array<{ key: string }>
|
|
1535
|
-
secretKeys.value = list.map(s => s.key).filter(Boolean)
|
|
1536
|
-
} catch {
|
|
1537
|
-
// secrets are optional for the preview
|
|
1538
|
-
}
|
|
1539
|
-
})
|
|
1540
|
-
|
|
1541
|
-
function openNode(n: ApiNode) {
|
|
1542
|
-
refused.value = {}
|
|
1543
|
-
result.value = null
|
|
1544
|
-
formError.value = null
|
|
1545
|
-
// Synthetic WorkflowNode selection (distinguished by nodeSlug); the inspector
|
|
1546
|
-
// resolves its manifest from the catalog load() populated above.
|
|
1547
|
-
selection.value = { id: 'preview', nodeSlug: n.slug, nodeVersion: n.version, name: label(n), config: {} }
|
|
1548
|
-
}
|
|
1549
|
-
|
|
1550
|
-
async function onSubmit(draft: any) {
|
|
1551
|
-
validating.value = true
|
|
1552
|
-
refused.value = {}
|
|
1553
|
-
result.value = null
|
|
1554
|
-
formError.value = null
|
|
1555
|
-
try {
|
|
1556
|
-
const slug = encodeURIComponent(draft.nodeSlug)
|
|
1557
|
-
const version = encodeURIComponent(draft.nodeVersion || 'latest')
|
|
1558
|
-
const res = await client.post<any>(
|
|
1559
|
-
'/nodes/' + slug + '/' + version + '/config:validate',
|
|
1560
|
-
{ config: draft.config ?? {} },
|
|
1561
|
-
)
|
|
1562
|
-
if (res.valid) {
|
|
1563
|
-
result.value = 'ok'
|
|
1564
|
-
} else {
|
|
1565
|
-
refused.value = Object.fromEntries(
|
|
1566
|
-
Object.entries(res.errors ?? {}).map(([k, msgs]) => [k, (msgs as string[]).join(' ')]),
|
|
1567
|
-
)
|
|
1568
|
-
result.value = 'err'
|
|
1569
|
-
}
|
|
1570
|
-
} catch (e: any) {
|
|
1571
|
-
formError.value = e?.message ?? 'Validierung fehlgeschlagen.'
|
|
1572
|
-
} finally {
|
|
1573
|
-
validating.value = false
|
|
1574
|
-
}
|
|
1575
|
-
}
|
|
1576
|
-
|
|
1577
|
-
// The inspector emits close on both Save and Cancel; the studio Dialog emits it
|
|
1578
|
-
// on Esc / backdrop. Hold the close while a Save-validation is in flight so the
|
|
1579
|
-
// dialog stays open to show the result; otherwise close (discard).
|
|
1580
|
-
function requestClose() {
|
|
1581
|
-
if (validating.value) return
|
|
1582
|
-
selection.value = null
|
|
1583
|
-
refused.value = {}
|
|
1584
|
-
result.value = null
|
|
1585
|
-
formError.value = null
|
|
1586
|
-
}
|
|
1587
|
-
</script>
|
|
1588
|
-
|
|
1589
|
-
<style scoped>
|
|
1590
|
-
/* The app shell (app.vue) is h-svh + overflow-hidden, so this page must own its
|
|
1591
|
-
own vertical scroll \u2014 otherwise the node list is clipped and can't scroll. */
|
|
1592
|
-
.ndx-page { height: 100%; overflow-y: auto; }
|
|
1593
|
-
.ndx-inner { max-width: 60rem; margin: 0 auto; padding: 2rem; font-family: sans-serif; }
|
|
1594
|
-
.ndx-head h1 { font-size: 1.5rem; font-weight: 600; }
|
|
1595
|
-
.ndx-err { color: #b91c1c; }
|
|
1596
|
-
.ndx-grid { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1rem; margin-top: 1.5rem; }
|
|
1597
|
-
.ndx-card { border: 1px solid #d1d5db; border-radius: 0.5rem; padding: 1rem; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
|
|
1598
|
-
.ndx-card:hover { border-color: #6366f1; box-shadow: 0 1px 6px rgba(0,0,0,.08); }
|
|
1599
|
-
.ndx-card-title { font-weight: 600; }
|
|
1600
|
-
.ndx-card-slug { color: #6b7280; font-size: .85rem; margin-top: .25rem; }
|
|
1601
|
-
.ndx-badges { margin-top: .5rem; display: flex; flex-wrap: wrap; gap: .35rem; }
|
|
1602
|
-
.ndx-badge { font-size: .7rem; background: #eef2ff; color: #4338ca; border-radius: .25rem; padding: .1rem .4rem; }
|
|
1603
|
-
|
|
1604
|
-
/* Verdict strip shown at the top of the reused dialog content (does not close). */
|
|
1605
|
-
.ndx-strip { flex: 0 0 auto; padding: .5rem 1rem; font-size: .85rem; font-weight: 600; }
|
|
1606
|
-
.ndx-strip-ok { background: #dcfce7; color: #166534; }
|
|
1607
|
-
.ndx-strip-err { background: #fee2e2; color: #991b1b; }
|
|
1608
|
-
</style>
|
|
1609
|
-
`;
|
|
1610
|
-
var GITIGNORE = `node_modules/
|
|
1455
|
+
// src/preview/host.ts
|
|
1456
|
+
var import_node_crypto2 = require("crypto");
|
|
1457
|
+
var import_node_fs5 = require("fs");
|
|
1458
|
+
var import_node_os = require("os");
|
|
1459
|
+
var import_node_path4 = require("path");
|
|
1460
|
+
var import_node_url2 = require("url");
|
|
1461
|
+
var INSTALL_MARKER = ".devkit-install-complete";
|
|
1462
|
+
var COPY_MARKER = ".devkit-copy-complete";
|
|
1463
|
+
var HOST_GITIGNORE = `node_modules/
|
|
1611
1464
|
.nuxt/
|
|
1465
|
+
.nuxt-*/
|
|
1612
1466
|
.output/
|
|
1613
1467
|
.data/
|
|
1468
|
+
.env
|
|
1469
|
+
${COPY_MARKER}
|
|
1470
|
+
${INSTALL_MARKER}
|
|
1614
1471
|
`;
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
return { tenants: ref([]), onlyTenantSlug: ref(null), load: async () => {} }
|
|
1472
|
+
function resolveHostDir(options) {
|
|
1473
|
+
const root = options.cacheRoot ?? process.env.XDG_CACHE_HOME ?? (0, import_node_path4.join)((0, import_node_os.homedir)(), ".cache");
|
|
1474
|
+
return (0, import_node_path4.join)(root, "revenexx", "devkit-preview", options.version);
|
|
1619
1475
|
}
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1476
|
+
function shippedHostDir() {
|
|
1477
|
+
let dir = (0, import_node_path4.dirname)((0, import_node_url2.fileURLToPath)(importMetaUrl));
|
|
1478
|
+
for (let up = 0; up < 5; up += 1) {
|
|
1479
|
+
const candidate = (0, import_node_path4.join)(dir, "preview-host");
|
|
1480
|
+
if ((0, import_node_fs5.existsSync)((0, import_node_path4.join)(candidate, "nuxt.config.ts"))) {
|
|
1481
|
+
return candidate;
|
|
1482
|
+
}
|
|
1483
|
+
const parent = (0, import_node_path4.dirname)(dir);
|
|
1484
|
+
if (parent === dir) break;
|
|
1485
|
+
dir = parent;
|
|
1627
1486
|
}
|
|
1487
|
+
throw new Error("Preview host not found: no preview-host/nuxt.config.ts above this module. Reinstall @revenexx/integrations-node-devkit.");
|
|
1628
1488
|
}
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1489
|
+
function materializeHost(options) {
|
|
1490
|
+
const log = options.log ?? (() => {
|
|
1491
|
+
});
|
|
1492
|
+
const source = options.sourceDir ?? shippedHostDir();
|
|
1493
|
+
const dir = (0, import_node_path4.resolve)(options.targetDir);
|
|
1494
|
+
const managed = options.managed ?? false;
|
|
1495
|
+
const intact = managed ? hostIsComplete(dir) : hostExists(dir);
|
|
1496
|
+
const alreadyIntact = intact && !options.force;
|
|
1497
|
+
if (!alreadyIntact) {
|
|
1498
|
+
(0, import_node_fs5.mkdirSync)(dir, { recursive: true });
|
|
1499
|
+
(0, import_node_fs5.rmSync)((0, import_node_path4.join)(dir, COPY_MARKER), { force: true });
|
|
1500
|
+
(0, import_node_fs5.cpSync)(source, dir, { recursive: true, filter: (src) => !isInsideNodeModules(source, src) });
|
|
1501
|
+
(0, import_node_fs5.writeFileSync)((0, import_node_path4.join)(dir, COPY_MARKER), `${(/* @__PURE__ */ new Date()).toISOString()}
|
|
1502
|
+
`, "utf-8");
|
|
1503
|
+
(0, import_node_fs5.writeFileSync)((0, import_node_path4.join)(dir, ".gitignore"), HOST_GITIGNORE, "utf-8");
|
|
1504
|
+
log(`Preview host ready in ${dir}`);
|
|
1505
|
+
}
|
|
1506
|
+
const envPath = (0, import_node_path4.join)(dir, ".env");
|
|
1507
|
+
if (managed || !(0, import_node_fs5.existsSync)(envPath)) {
|
|
1508
|
+
(0, import_node_fs5.writeFileSync)(envPath, envFile(options), "utf-8");
|
|
1509
|
+
}
|
|
1510
|
+
return { dir, copied: !alreadyIntact };
|
|
1511
|
+
}
|
|
1512
|
+
function isInsideNodeModules(source, src) {
|
|
1513
|
+
const rel = (0, import_node_path4.relative)(source, src);
|
|
1514
|
+
return rel !== "" && rel.split(import_node_path4.sep).includes("node_modules");
|
|
1515
|
+
}
|
|
1516
|
+
function envFile(options) {
|
|
1517
|
+
return `# Generated by integrations-devkit \u2014 overrides the Nuxt runtimeConfig.public.* values.
|
|
1518
|
+
# The \`preview\` command also passes these to the Nuxt child process; this file is
|
|
1519
|
+
# what makes a manual \`npm run dev\` in this directory work.
|
|
1520
|
+
NUXT_PUBLIC_INTEGRATIONS_API=${options.integrationsApiUrl}
|
|
1521
|
+
NUXT_PUBLIC_DEV_TOKEN=${options.devToken ?? "dev"}
|
|
1522
|
+
NUXT_PUBLIC_DEV_TENANT=${options.devTenant ?? "dev-tenant"}
|
|
1523
|
+
`;
|
|
1637
1524
|
}
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
getCredential: async () => ({}),
|
|
1642
|
-
createCredential: async () => ({}),
|
|
1643
|
-
}
|
|
1525
|
+
function hostBuildDir(hostDir, consumerDir) {
|
|
1526
|
+
const key = (0, import_node_crypto2.createHash)("sha256").update(consumerDir).digest("hex").slice(0, 12);
|
|
1527
|
+
return (0, import_node_path4.join)(hostDir, `.nuxt-${key}`);
|
|
1644
1528
|
}
|
|
1645
|
-
|
|
1646
|
-
return
|
|
1529
|
+
function hostExists(dir) {
|
|
1530
|
+
return (0, import_node_fs5.existsSync)((0, import_node_path4.join)(dir, "package.json")) && (0, import_node_fs5.existsSync)((0, import_node_path4.join)(dir, "nuxt.config.ts"));
|
|
1647
1531
|
}
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
if (to.path === '/integrations/workflows' || to.path.startsWith('/integrations/workflows/')) {
|
|
1651
|
-
return navigateTo('/integrations')
|
|
1652
|
-
}
|
|
1653
|
-
})
|
|
1654
|
-
`;
|
|
1655
|
-
function previewTemplates(options) {
|
|
1656
|
-
const env = `# Overrides the Nuxt runtimeConfig.public.* values.
|
|
1657
|
-
NUXT_PUBLIC_INTEGRATIONS_API=${options.integrationsApiUrl}
|
|
1658
|
-
NUXT_PUBLIC_DEV_TOKEN=dev
|
|
1659
|
-
NUXT_PUBLIC_DEV_TENANT=dev-tenant
|
|
1660
|
-
`;
|
|
1661
|
-
return {
|
|
1662
|
-
"package.json": PACKAGE_JSON,
|
|
1663
|
-
"nuxt.config.ts": NUXT_CONFIG,
|
|
1664
|
-
"assets/css/main.css": MAIN_CSS,
|
|
1665
|
-
"app.vue": APP_VUE,
|
|
1666
|
-
"pages/index.vue": INDEX_VUE,
|
|
1667
|
-
"pages/nodes.vue": NODES_VUE,
|
|
1668
|
-
"composables/devkit-console-stubs.ts": CONSOLE_STUBS,
|
|
1669
|
-
"middleware/hide-workflows.global.ts": HIDE_WORKFLOWS_MW,
|
|
1670
|
-
".env": env,
|
|
1671
|
-
".gitignore": GITIGNORE
|
|
1672
|
-
};
|
|
1532
|
+
function hostIsComplete(dir) {
|
|
1533
|
+
return hostExists(dir) && (0, import_node_fs5.existsSync)((0, import_node_path4.join)(dir, COPY_MARKER));
|
|
1673
1534
|
}
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
});
|
|
1679
|
-
const files = previewTemplates({ integrationsApiUrl: options.integrationsApiUrl });
|
|
1680
|
-
const written = [];
|
|
1681
|
-
const skipped = [];
|
|
1682
|
-
for (const [relative, content] of Object.entries(files)) {
|
|
1683
|
-
const target = (0, import_node_path3.resolve)(options.dir, relative);
|
|
1684
|
-
if ((0, import_node_fs4.existsSync)(target) && !options.force) {
|
|
1685
|
-
skipped.push(relative);
|
|
1686
|
-
continue;
|
|
1687
|
-
}
|
|
1688
|
-
(0, import_node_fs4.mkdirSync)((0, import_node_path3.dirname)(target), { recursive: true });
|
|
1689
|
-
(0, import_node_fs4.writeFileSync)(target, content, "utf-8");
|
|
1690
|
-
written.push(relative);
|
|
1535
|
+
function hostNeedsInstall(dir) {
|
|
1536
|
+
const marker = (0, import_node_path4.join)(dir, INSTALL_MARKER);
|
|
1537
|
+
if (!(0, import_node_fs5.existsSync)((0, import_node_path4.join)(dir, "node_modules")) || !(0, import_node_fs5.existsSync)(marker)) {
|
|
1538
|
+
return true;
|
|
1691
1539
|
}
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
}
|
|
1695
|
-
|
|
1696
|
-
log(`Kept ${skipped.length} existing file(s) (use --force to overwrite).`);
|
|
1540
|
+
try {
|
|
1541
|
+
return (0, import_node_fs5.readFileSync)(marker, "utf-8").trim() !== manifestFingerprint(dir);
|
|
1542
|
+
} catch {
|
|
1543
|
+
return true;
|
|
1697
1544
|
}
|
|
1698
|
-
return { dir: options.dir, written, skipped };
|
|
1699
1545
|
}
|
|
1700
|
-
function
|
|
1701
|
-
|
|
1546
|
+
function markHostInstalled(dir) {
|
|
1547
|
+
(0, import_node_fs5.writeFileSync)((0, import_node_path4.join)(dir, INSTALL_MARKER), `${manifestFingerprint(dir)}
|
|
1548
|
+
`, "utf-8");
|
|
1702
1549
|
}
|
|
1703
|
-
function
|
|
1704
|
-
|
|
1550
|
+
function clearHostInstallMarker(dir) {
|
|
1551
|
+
(0, import_node_fs5.rmSync)((0, import_node_path4.join)(dir, INSTALL_MARKER), { force: true });
|
|
1552
|
+
}
|
|
1553
|
+
function manifestFingerprint(dir) {
|
|
1554
|
+
const pkg = JSON.parse((0, import_node_fs5.readFileSync)((0, import_node_path4.join)(dir, "package.json"), "utf-8"));
|
|
1555
|
+
return JSON.stringify({ dependencies: pkg.dependencies ?? {}, devDependencies: pkg.devDependencies ?? {} });
|
|
1705
1556
|
}
|
|
1706
1557
|
|
|
1707
1558
|
// src/cli.ts
|
|
@@ -1709,14 +1560,14 @@ function parseArgs(argv) {
|
|
|
1709
1560
|
const cwd = process.cwd();
|
|
1710
1561
|
const opts = {
|
|
1711
1562
|
entry: "",
|
|
1712
|
-
seedDir: (0,
|
|
1713
|
-
stateFile: (0,
|
|
1563
|
+
seedDir: (0, import_node_path5.resolve)(cwd, "dev/seeds"),
|
|
1564
|
+
stateFile: (0, import_node_path5.resolve)(cwd, ".revenexx-dev/state.json"),
|
|
1714
1565
|
persist: true,
|
|
1715
1566
|
port: Number.parseInt(process.env.PORT ?? "3555", 10),
|
|
1716
1567
|
uiDir: null,
|
|
1717
1568
|
serveUi: true,
|
|
1718
1569
|
open: false,
|
|
1719
|
-
previewDir:
|
|
1570
|
+
previewDir: null,
|
|
1720
1571
|
force: false
|
|
1721
1572
|
};
|
|
1722
1573
|
let command = null;
|
|
@@ -1733,19 +1584,19 @@ function parseArgs(argv) {
|
|
|
1733
1584
|
command = "preview";
|
|
1734
1585
|
break;
|
|
1735
1586
|
case "--dir":
|
|
1736
|
-
opts.previewDir = (0,
|
|
1587
|
+
opts.previewDir = (0, import_node_path5.resolve)(cwd, argv[++i] ?? "");
|
|
1737
1588
|
break;
|
|
1738
1589
|
case "--force":
|
|
1739
1590
|
opts.force = true;
|
|
1740
1591
|
break;
|
|
1741
1592
|
case "--entry":
|
|
1742
|
-
opts.entry = (0,
|
|
1593
|
+
opts.entry = (0, import_node_path5.resolve)(cwd, argv[++i] ?? "");
|
|
1743
1594
|
break;
|
|
1744
1595
|
case "--seed":
|
|
1745
|
-
opts.seedDir = (0,
|
|
1596
|
+
opts.seedDir = (0, import_node_path5.resolve)(cwd, argv[++i] ?? "");
|
|
1746
1597
|
break;
|
|
1747
1598
|
case "--state":
|
|
1748
|
-
opts.stateFile = (0,
|
|
1599
|
+
opts.stateFile = (0, import_node_path5.resolve)(cwd, argv[++i] ?? "");
|
|
1749
1600
|
break;
|
|
1750
1601
|
case "--no-persist":
|
|
1751
1602
|
opts.persist = false;
|
|
@@ -1754,7 +1605,7 @@ function parseArgs(argv) {
|
|
|
1754
1605
|
opts.port = Number.parseInt(argv[++i] ?? "3555", 10);
|
|
1755
1606
|
break;
|
|
1756
1607
|
case "--ui":
|
|
1757
|
-
opts.uiDir = (0,
|
|
1608
|
+
opts.uiDir = (0, import_node_path5.resolve)(cwd, argv[++i] ?? "");
|
|
1758
1609
|
break;
|
|
1759
1610
|
case "--no-ui":
|
|
1760
1611
|
opts.serveUi = false;
|
|
@@ -1763,7 +1614,8 @@ function parseArgs(argv) {
|
|
|
1763
1614
|
opts.open = true;
|
|
1764
1615
|
break;
|
|
1765
1616
|
// Both are consumed by loadEnvFile() before parsing; listed here so they
|
|
1766
|
-
// do not fall through to the unknown-option branch.
|
|
1617
|
+
// do not fall through to the unknown-option branch. A repeated `--env`
|
|
1618
|
+
// resolves to the last one, so each occurrence skips its own value.
|
|
1767
1619
|
case "--env":
|
|
1768
1620
|
i++;
|
|
1769
1621
|
break;
|
|
@@ -1787,23 +1639,23 @@ function parseArgs(argv) {
|
|
|
1787
1639
|
}
|
|
1788
1640
|
}
|
|
1789
1641
|
if (!opts.entry) {
|
|
1790
|
-
const src = (0,
|
|
1791
|
-
opts.entry = (0,
|
|
1642
|
+
const src = (0, import_node_path5.resolve)(cwd, "src/index.ts");
|
|
1643
|
+
opts.entry = (0, import_node_fs6.existsSync)(src) ? src : (0, import_node_path5.resolve)(cwd, "dist/index.js");
|
|
1792
1644
|
}
|
|
1793
1645
|
return { command, options: opts };
|
|
1794
1646
|
}
|
|
1795
1647
|
function loadSchemas() {
|
|
1796
|
-
const here = (0,
|
|
1797
|
-
const schemasDir = (0,
|
|
1648
|
+
const here = (0, import_node_url3.fileURLToPath)(new URL(".", importMetaUrl));
|
|
1649
|
+
const schemasDir = (0, import_node_path5.resolve)(here, "..", "assets", "schemas");
|
|
1798
1650
|
const schemas = {};
|
|
1799
|
-
if (!(0,
|
|
1651
|
+
if (!(0, import_node_fs6.existsSync)(schemasDir)) {
|
|
1800
1652
|
return schemas;
|
|
1801
1653
|
}
|
|
1802
|
-
for (const file of (0,
|
|
1803
|
-
if ((0,
|
|
1654
|
+
for (const file of (0, import_node_fs6.readdirSync)(schemasDir)) {
|
|
1655
|
+
if ((0, import_node_path5.extname)(file) !== ".json") {
|
|
1804
1656
|
continue;
|
|
1805
1657
|
}
|
|
1806
|
-
const parsed = JSON.parse((0,
|
|
1658
|
+
const parsed = JSON.parse((0, import_node_fs6.readFileSync)((0, import_node_path5.join)(schemasDir, file), "utf-8"));
|
|
1807
1659
|
const base = file.replace(/\.json$/, "");
|
|
1808
1660
|
const dash = base.indexOf("-");
|
|
1809
1661
|
if (dash > 0) {
|
|
@@ -1819,15 +1671,15 @@ function loadSchemas() {
|
|
|
1819
1671
|
}
|
|
1820
1672
|
function resolveUiDir(explicit) {
|
|
1821
1673
|
if (explicit) {
|
|
1822
|
-
return (0,
|
|
1674
|
+
return (0, import_node_fs6.existsSync)(explicit) ? explicit : null;
|
|
1823
1675
|
}
|
|
1824
1676
|
const candidates = ["@revenexx/studio-integrations"];
|
|
1825
1677
|
const req = (0, import_node_module.createRequire)(importMetaUrl);
|
|
1826
1678
|
for (const pkg of candidates) {
|
|
1827
1679
|
try {
|
|
1828
1680
|
const entry = req.resolve(`${pkg}/package.json`);
|
|
1829
|
-
const dist = (0,
|
|
1830
|
-
if ((0,
|
|
1681
|
+
const dist = (0, import_node_path5.resolve)(entry, "..", "dist");
|
|
1682
|
+
if ((0, import_node_fs6.existsSync)((0, import_node_path5.join)(dist, "index.html"))) {
|
|
1831
1683
|
return dist;
|
|
1832
1684
|
}
|
|
1833
1685
|
} catch {
|
|
@@ -1848,17 +1700,17 @@ var MIME = {
|
|
|
1848
1700
|
};
|
|
1849
1701
|
function serveStatic(uiDir, req, res) {
|
|
1850
1702
|
const url = new URL(req.url ?? "/", "http://localhost");
|
|
1851
|
-
const
|
|
1852
|
-
let filePath = (0,
|
|
1853
|
-
if (!filePath.startsWith(uiDir) || !(0,
|
|
1854
|
-
filePath = (0,
|
|
1703
|
+
const relative2 = url.pathname === "/" ? "index.html" : url.pathname.replace(/^\/+/, "");
|
|
1704
|
+
let filePath = (0, import_node_path5.resolve)(uiDir, relative2);
|
|
1705
|
+
if (!filePath.startsWith(uiDir) || !(0, import_node_fs6.existsSync)(filePath)) {
|
|
1706
|
+
filePath = (0, import_node_path5.join)(uiDir, "index.html");
|
|
1855
1707
|
}
|
|
1856
|
-
if (!(0,
|
|
1708
|
+
if (!(0, import_node_fs6.existsSync)(filePath)) {
|
|
1857
1709
|
res.writeHead(404).end("UI build not found");
|
|
1858
1710
|
return;
|
|
1859
1711
|
}
|
|
1860
|
-
res.writeHead(200, { "Content-Type": MIME[(0,
|
|
1861
|
-
res.end((0,
|
|
1712
|
+
res.writeHead(200, { "Content-Type": MIME[(0, import_node_path5.extname)(filePath)] ?? "application/octet-stream" });
|
|
1713
|
+
res.end((0, import_node_fs6.readFileSync)(filePath));
|
|
1862
1714
|
}
|
|
1863
1715
|
async function startMock(options) {
|
|
1864
1716
|
let loaded = await loadPackageFromEntry(options.entry);
|
|
@@ -1932,11 +1784,11 @@ async function run(options) {
|
|
|
1932
1784
|
process.on("SIGTERM", shutdown);
|
|
1933
1785
|
}
|
|
1934
1786
|
function watchAndReload(entry, onChange) {
|
|
1935
|
-
const dir = (0,
|
|
1787
|
+
const dir = (0, import_node_path5.resolve)(entry, "..");
|
|
1936
1788
|
let timer;
|
|
1937
1789
|
try {
|
|
1938
|
-
const watcher = (0,
|
|
1939
|
-
if (file &&
|
|
1790
|
+
const watcher = (0, import_node_fs6.watch)(dir, { recursive: true }, (_event, file) => {
|
|
1791
|
+
if (file && isReloadableSource(file.toString())) {
|
|
1940
1792
|
clearTimeout(timer);
|
|
1941
1793
|
timer = setTimeout(onChange, 200);
|
|
1942
1794
|
}
|
|
@@ -1955,15 +1807,34 @@ async function runNpmInstall(dir) {
|
|
|
1955
1807
|
child.on("error", reject);
|
|
1956
1808
|
});
|
|
1957
1809
|
}
|
|
1810
|
+
function noteLegacyPreviewDir() {
|
|
1811
|
+
const legacy = (0, import_node_path5.resolve)(process.cwd(), ".revenexx-dev/preview");
|
|
1812
|
+
if ((0, import_node_fs6.existsSync)(legacy)) {
|
|
1813
|
+
console.log(`Note: ${legacy} is no longer used \u2014 the preview host now lives in a shared cache. You can delete it to reclaim the space.`);
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1958
1816
|
async function preview(options) {
|
|
1959
|
-
const dir = options.previewDir;
|
|
1960
1817
|
const apiUrl = `http://localhost:${options.port}/api/v1`;
|
|
1961
|
-
|
|
1962
|
-
|
|
1818
|
+
const managed = options.previewDir === null;
|
|
1819
|
+
const targetDir = options.previewDir ?? resolveHostDir({ version: DEVKIT_VERSION });
|
|
1820
|
+
noteLegacyPreviewDir();
|
|
1821
|
+
const { dir } = materializeHost({
|
|
1822
|
+
targetDir,
|
|
1823
|
+
integrationsApiUrl: apiUrl,
|
|
1824
|
+
force: options.force,
|
|
1825
|
+
managed,
|
|
1826
|
+
log: (msg) => console.log(msg)
|
|
1827
|
+
});
|
|
1828
|
+
if (managed) {
|
|
1829
|
+
console.log(` Host (devkit ${DEVKIT_VERSION}, shared across repos) ${dir}`);
|
|
1830
|
+
}
|
|
1831
|
+
if (options.force) {
|
|
1832
|
+
clearHostInstallMarker(dir);
|
|
1963
1833
|
}
|
|
1964
|
-
if (
|
|
1965
|
-
console.log("Installing preview-host dependencies (
|
|
1834
|
+
if (hostNeedsInstall(dir)) {
|
|
1835
|
+
console.log("Installing preview-host dependencies (this pulls Nuxt + the studio packages and may take a while)\u2026");
|
|
1966
1836
|
await runNpmInstall(dir);
|
|
1837
|
+
markHostInstalled(dir);
|
|
1967
1838
|
}
|
|
1968
1839
|
const mock = await startMock({ ...options, serveUi: false });
|
|
1969
1840
|
console.log(`
|
|
@@ -1977,7 +1848,10 @@ async function preview(options) {
|
|
|
1977
1848
|
...process.env,
|
|
1978
1849
|
NUXT_PUBLIC_INTEGRATIONS_API: apiUrl,
|
|
1979
1850
|
NUXT_PUBLIC_DEV_TOKEN: process.env.NUXT_PUBLIC_DEV_TOKEN ?? "dev",
|
|
1980
|
-
NUXT_PUBLIC_DEV_TENANT: process.env.NUXT_PUBLIC_DEV_TENANT ?? "dev-tenant"
|
|
1851
|
+
NUXT_PUBLIC_DEV_TENANT: process.env.NUXT_PUBLIC_DEV_TENANT ?? "dev-tenant",
|
|
1852
|
+
// Keep the shared host's dependency install shared but its BUILD per repo,
|
|
1853
|
+
// so two node packages previewing at once do not compile over each other.
|
|
1854
|
+
DEVKIT_NUXT_BUILD_DIR: hostBuildDir(dir, process.cwd())
|
|
1981
1855
|
}
|
|
1982
1856
|
});
|
|
1983
1857
|
const shutdown = () => {
|
|
@@ -1999,30 +1873,37 @@ async function openBrowser(url) {
|
|
|
1999
1873
|
}
|
|
2000
1874
|
async function main() {
|
|
2001
1875
|
const argv = process.argv.slice(2);
|
|
2002
|
-
const
|
|
1876
|
+
const envFile2 = loadEnvFile(argv);
|
|
2003
1877
|
const { command, options } = parseArgs(argv);
|
|
2004
1878
|
if (command === "version") {
|
|
2005
1879
|
console.log(DEVKIT_VERSION);
|
|
2006
1880
|
return;
|
|
2007
1881
|
}
|
|
2008
|
-
if (
|
|
2009
|
-
console.log(`Loaded env from ${
|
|
1882
|
+
if (envFile2) {
|
|
1883
|
+
console.log(`Loaded env from ${envFile2}`);
|
|
2010
1884
|
}
|
|
2011
1885
|
if (command === "reset") {
|
|
2012
|
-
const { rmSync } = await import("fs");
|
|
2013
|
-
|
|
1886
|
+
const { rmSync: rmSync2 } = await import("fs");
|
|
1887
|
+
rmSync2(options.stateFile, { force: true });
|
|
2014
1888
|
console.log(`Removed ${options.stateFile}`);
|
|
2015
1889
|
return;
|
|
2016
1890
|
}
|
|
2017
1891
|
if (command === "init-preview") {
|
|
2018
|
-
|
|
2019
|
-
|
|
1892
|
+
if (options.previewDir === null) {
|
|
1893
|
+
console.error("init-preview needs an explicit target: `integrations-devkit init-preview --dir ./my-preview`.");
|
|
1894
|
+
console.error("It exists to give you an UNMANAGED copy of the preview host to modify. For the normal preview, just run `integrations-devkit preview` \u2014");
|
|
1895
|
+
console.error("that materializes the host into a shared cache and keeps it in step with the devkit version.");
|
|
1896
|
+
process.exit(1);
|
|
1897
|
+
}
|
|
1898
|
+
const { dir } = materializeHost({
|
|
1899
|
+
targetDir: options.previewDir,
|
|
2020
1900
|
integrationsApiUrl: `http://localhost:${options.port}/api/v1`,
|
|
2021
1901
|
force: options.force,
|
|
2022
1902
|
log: (msg) => console.log(msg)
|
|
2023
1903
|
});
|
|
2024
|
-
console.log(
|
|
2025
|
-
|
|
1904
|
+
console.log("\nThis copy is yours and will NOT be updated by devkit upgrades.");
|
|
1905
|
+
console.log(`Run it with: \`cd ${dir} && npm install && npm run dev\` (plus \`integrations-devkit --no-ui\` for the mock),`);
|
|
1906
|
+
console.log(`or \`integrations-devkit preview --dir ${dir}\` to have both started for you.`);
|
|
2026
1907
|
return;
|
|
2027
1908
|
}
|
|
2028
1909
|
if (command === "preview") {
|