@revenexx/integrations-node-devkit 0.2.2 → 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-2GVOKLIW.js → chunk-PS3HCKE7.js} +237 -52
- package/dist/chunk-PS3HCKE7.js.map +1 -0
- package/dist/cli.cjs +399 -529
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +138 -451
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +233 -53
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +59 -6
- package/dist/index.d.ts +59 -6
- 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-2GVOKLIW.js.map +0 -1
package/README.md
CHANGED
|
@@ -57,10 +57,17 @@ host app. The devkit scaffolds and runs that host for you:
|
|
|
57
57
|
npm run preview
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
This (1)
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
This (1) copies the host into a shared cache directory, (2) `npm install`s it there
|
|
61
|
+
(heavy the first time — pulls Nuxt + the studio packages), (3) starts the mock API,
|
|
62
|
+
and (4) runs `nuxt dev` wired to the mock. Open
|
|
63
|
+
**http://localhost:3000/integrations**.
|
|
64
|
+
|
|
65
|
+
**The host does not go into your repo.** It is copied to
|
|
66
|
+
`${XDG_CACHE_HOME:-~/.cache}/revenexx/devkit-preview/<devkit-version>/`, so every
|
|
67
|
+
one of your node packages shares a single dependency install, and a devkit upgrade
|
|
68
|
+
can never leave you running a stale host. Your repo only gets
|
|
69
|
+
`.revenexx-dev/state.json`. If you still have a `.revenexx-dev/preview/` from an
|
|
70
|
+
older devkit, it is unused and can be deleted.
|
|
64
71
|
|
|
65
72
|
No auth shim is needed: `@revenexx/studio-shared`'s standalone
|
|
66
73
|
`usePlatformAuth`/`usePlatformTenant` read a dev token/tenant from
|
|
@@ -68,15 +75,24 @@ No auth shim is needed: `@revenexx/studio-shared`'s standalone
|
|
|
68
75
|
mock ignores the values). `runtimeConfig.public.integrationsApi` is pointed at
|
|
69
76
|
the mock automatically.
|
|
70
77
|
|
|
71
|
-
|
|
72
|
-
|
|
78
|
+
The managed copy is a disposable artifact — don't edit it, it is replaced on the
|
|
79
|
+
next version bump. To change the host, take a copy that is yours:
|
|
80
|
+
|
|
81
|
+
- `integrations-devkit init-preview --dir ./my-preview` — an **unmanaged** copy,
|
|
82
|
+
never touched by devkit upgrades.
|
|
83
|
+
- `integrations-devkit preview --dir ./my-preview` — run that copy instead.
|
|
73
84
|
|
|
74
85
|
> **Scope:** the preview targets the **slimmed** studio build — node listing +
|
|
75
|
-
> credential/template management + **config-field resolving
|
|
76
|
-
>
|
|
77
|
-
>
|
|
78
|
-
>
|
|
79
|
-
|
|
86
|
+
> credential/template management + **config-field resolving** (the UI
|
|
87
|
+
> `POST`s to `/nodes/{slug}/{version}/config:resolve`, which the mock serves).
|
|
88
|
+
> The **Workflows** surface is hidden until phase 2, because workflow execution is
|
|
89
|
+
> not mocked; the Temporal parts (run history, `…/runs/*`) are intentionally absent.
|
|
90
|
+
|
|
91
|
+
The mock is checked against the service's own OpenAPI contract — see
|
|
92
|
+
[docs/architecture.md](docs/architecture.md#staying-in-step-with-the-real-api).
|
|
93
|
+
One caveat to know up front: `POST /nodes/{slug}/{version}/config:validate` is a
|
|
94
|
+
**devkit-only** endpoint used by the preview's node page. It does not exist in the
|
|
95
|
+
real API.
|
|
80
96
|
|
|
81
97
|
Pass `--ui <dir>` to `integrations-devkit` if you instead have a prebuilt static SPA.
|
|
82
98
|
|
|
@@ -92,6 +108,8 @@ Pass `--ui <dir>` to `integrations-devkit` if you instead have a prebuilt static
|
|
|
92
108
|
| `--ui <dir>` | resolve UI package | Static UI build to serve |
|
|
93
109
|
| `--no-ui` | off | Run API-only |
|
|
94
110
|
| `--open` | off | Open the preview in a browser |
|
|
111
|
+
| `--dir <path>` | managed cache | Use this preview-host dir instead (unmanaged) |
|
|
112
|
+
| `--force` | off | Re-copy the host even if the target looks complete |
|
|
95
113
|
| `reset` (subcommand) | | Delete the session overlay |
|
|
96
114
|
|
|
97
115
|
## Seeds + persistence (layered)
|
|
@@ -176,5 +194,9 @@ This is a faithful **dev** stand-in, not the production service:
|
|
|
176
194
|
reproduced.
|
|
177
195
|
- Workflow-blob validation is light and schema-based; the production service
|
|
178
196
|
does deeper cross-validation on save.
|
|
179
|
-
- Workflow **run execution** is not included (v1)
|
|
180
|
-
|
|
197
|
+
- Workflow **run execution** is not included (v1), so the Workflows surface is
|
|
198
|
+
hidden in the preview.
|
|
199
|
+
- `assets/schemas/` is still empty, so `GET /schemas/{domain}` 404s and the UI's
|
|
200
|
+
client-side schema validation is inactive.
|
|
201
|
+
- `POST /nodes/{slug}/{version}/config:validate` exists only here, not in the real
|
|
202
|
+
API.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import { readFileSync as
|
|
2
|
+
import { readFileSync as readFileSync3 } from "fs";
|
|
3
3
|
|
|
4
4
|
// src/env.ts
|
|
5
5
|
import { existsSync } from "fs";
|
|
@@ -70,9 +70,31 @@ var DevApiError = class extends Error {
|
|
|
70
70
|
};
|
|
71
71
|
|
|
72
72
|
// src/loader.ts
|
|
73
|
+
import { existsSync as existsSync2, readFileSync } from "fs";
|
|
74
|
+
import { dirname, join } from "path";
|
|
73
75
|
import { pathToFileURL } from "url";
|
|
74
76
|
import { buildManifest } from "@revenexx/integrations-node-sdk";
|
|
75
|
-
|
|
77
|
+
var UNKNOWN_PACKAGE = { name: "unknown", version: "0.0.0", label: "Local package" };
|
|
78
|
+
function readPackageInfo(entryPath) {
|
|
79
|
+
let dir = dirname(entryPath);
|
|
80
|
+
for (let up = 0; up < 6; up += 1) {
|
|
81
|
+
const candidate = join(dir, "package.json");
|
|
82
|
+
if (existsSync2(candidate)) {
|
|
83
|
+
try {
|
|
84
|
+
const pkg = JSON.parse(readFileSync(candidate, "utf-8"));
|
|
85
|
+
if (pkg.name) {
|
|
86
|
+
return { name: pkg.name, version: pkg.version ?? "0.0.0", label: pkg.name.split("/").pop() ?? pkg.name };
|
|
87
|
+
}
|
|
88
|
+
} catch {
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const parent = dirname(dir);
|
|
92
|
+
if (parent === dir) break;
|
|
93
|
+
dir = parent;
|
|
94
|
+
}
|
|
95
|
+
return UNKNOWN_PACKAGE;
|
|
96
|
+
}
|
|
97
|
+
function resolveExports(mod, packageInfo = UNKNOWN_PACKAGE) {
|
|
76
98
|
if (!Array.isArray(mod.NODES)) {
|
|
77
99
|
throw new Error("Package entry does not export a `NODES` array. Export `NODES: INode[]`.");
|
|
78
100
|
}
|
|
@@ -89,7 +111,9 @@ function resolveExports(mod) {
|
|
|
89
111
|
nodes,
|
|
90
112
|
credentials,
|
|
91
113
|
templates,
|
|
92
|
-
manifest: buildManifest(nodes, credentials, templates)
|
|
114
|
+
manifest: buildManifest(nodes, credentials, templates),
|
|
115
|
+
packageInfo,
|
|
116
|
+
loadedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
93
117
|
};
|
|
94
118
|
}
|
|
95
119
|
var tsxRegistered = false;
|
|
@@ -101,6 +125,10 @@ async function ensureTsxRegistered() {
|
|
|
101
125
|
register();
|
|
102
126
|
tsxRegistered = true;
|
|
103
127
|
}
|
|
128
|
+
var RELOADABLE_SOURCE = /\.(?:[cm]?[jt]sx?|json)$/;
|
|
129
|
+
function isReloadableSource(file) {
|
|
130
|
+
return RELOADABLE_SOURCE.test(file);
|
|
131
|
+
}
|
|
104
132
|
async function importFresh(entryPath) {
|
|
105
133
|
if (/\.[cm]?tsx?$/.test(entryPath)) {
|
|
106
134
|
await ensureTsxRegistered();
|
|
@@ -109,17 +137,19 @@ async function importFresh(entryPath) {
|
|
|
109
137
|
return await import(href);
|
|
110
138
|
}
|
|
111
139
|
async function loadPackageFromEntry(entryPath) {
|
|
112
|
-
return resolveExports(await importFresh(entryPath));
|
|
140
|
+
return resolveExports(await importFresh(entryPath), readPackageInfo(entryPath));
|
|
113
141
|
}
|
|
114
142
|
|
|
115
143
|
// src/persistence.ts
|
|
116
|
-
import { existsSync as
|
|
117
|
-
import { dirname, resolve as resolve2 } from "path";
|
|
144
|
+
import { existsSync as existsSync3, mkdirSync, readFileSync as readFileSync2, writeFileSync } from "fs";
|
|
145
|
+
import { dirname as dirname2, resolve as resolve2 } from "path";
|
|
118
146
|
|
|
119
147
|
// src/store.ts
|
|
120
148
|
import { randomUUID } from "crypto";
|
|
121
149
|
var DEV_TENANT_ID = "dev-tenant";
|
|
122
|
-
var
|
|
150
|
+
var BLOB_DEFINITION_VERSION = "v0-draft";
|
|
151
|
+
var EXECUTION_MODES = ["async_only", "sync_only", "caller_decides"];
|
|
152
|
+
var STORE_SCHEMA_VERSION = 2;
|
|
123
153
|
function now() {
|
|
124
154
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
125
155
|
}
|
|
@@ -162,6 +192,9 @@ var DevStore = class {
|
|
|
162
192
|
status: input.status ?? "active",
|
|
163
193
|
config: input.config,
|
|
164
194
|
durableCreds: input.durableCreds ?? null,
|
|
195
|
+
lastTestAt: null,
|
|
196
|
+
lastTestOk: null,
|
|
197
|
+
lastTestMessage: null,
|
|
165
198
|
createdAt: ts,
|
|
166
199
|
updatedAt: ts
|
|
167
200
|
};
|
|
@@ -190,6 +223,21 @@ var DevStore = class {
|
|
|
190
223
|
this.touch();
|
|
191
224
|
return record;
|
|
192
225
|
}
|
|
226
|
+
/**
|
|
227
|
+
* Records the outcome of a credential test. The service persists this on the
|
|
228
|
+
* record and reports it back from `POST /credentials/{id}/test`.
|
|
229
|
+
*/
|
|
230
|
+
recordCredentialTest(id, result) {
|
|
231
|
+
const record = this.credentials.get(id);
|
|
232
|
+
if (!record) {
|
|
233
|
+
return void 0;
|
|
234
|
+
}
|
|
235
|
+
record.lastTestAt = now();
|
|
236
|
+
record.lastTestOk = result.ok;
|
|
237
|
+
record.lastTestMessage = result.message ?? null;
|
|
238
|
+
this.touch();
|
|
239
|
+
return record;
|
|
240
|
+
}
|
|
193
241
|
deleteCredential(id) {
|
|
194
242
|
const deleted = this.credentials.delete(id);
|
|
195
243
|
if (deleted) {
|
|
@@ -236,7 +284,12 @@ var DevStore = class {
|
|
|
236
284
|
const record = {
|
|
237
285
|
id: this.nextWorkflowId++,
|
|
238
286
|
name: input.name,
|
|
239
|
-
|
|
287
|
+
description: input.description ?? null,
|
|
288
|
+
blob: input.blob,
|
|
289
|
+
blobDefinitionVersion: input.blobDefinitionVersion ?? BLOB_DEFINITION_VERSION,
|
|
290
|
+
active: input.active ?? true,
|
|
291
|
+
executionMode: input.executionMode ?? EXECUTION_MODES[0],
|
|
292
|
+
revision: 1,
|
|
240
293
|
buildStatus: "ready",
|
|
241
294
|
createdAt: ts,
|
|
242
295
|
updatedAt: ts
|
|
@@ -250,7 +303,8 @@ var DevStore = class {
|
|
|
250
303
|
if (!record) {
|
|
251
304
|
return void 0;
|
|
252
305
|
}
|
|
253
|
-
Object.
|
|
306
|
+
const defined = Object.fromEntries(Object.entries(patch).filter(([, v]) => v !== void 0));
|
|
307
|
+
Object.assign(record, defined, { revision: record.revision + 1, updatedAt: now() });
|
|
254
308
|
this.touch();
|
|
255
309
|
return record;
|
|
256
310
|
}
|
|
@@ -391,16 +445,23 @@ function applySeeds(store, seeds, env = process.env) {
|
|
|
391
445
|
});
|
|
392
446
|
}
|
|
393
447
|
for (const workflow of seeds.workflows ?? []) {
|
|
394
|
-
|
|
448
|
+
const resolved = interpolateEnv(workflow, env);
|
|
449
|
+
store.createWorkflow({
|
|
450
|
+
name: resolved.name,
|
|
451
|
+
blob: resolved.blob ?? resolved.definition ?? {},
|
|
452
|
+
description: resolved.description,
|
|
453
|
+
active: resolved.active,
|
|
454
|
+
executionMode: resolved.executionMode
|
|
455
|
+
});
|
|
395
456
|
}
|
|
396
457
|
}
|
|
397
458
|
function loadState(file, log = console.warn) {
|
|
398
|
-
if (!
|
|
459
|
+
if (!existsSync3(file)) {
|
|
399
460
|
return null;
|
|
400
461
|
}
|
|
401
462
|
let parsed;
|
|
402
463
|
try {
|
|
403
|
-
parsed = JSON.parse(
|
|
464
|
+
parsed = JSON.parse(readFileSync2(file, "utf-8"));
|
|
404
465
|
} catch {
|
|
405
466
|
log(`Ignoring ${file}: not valid JSON.`);
|
|
406
467
|
return null;
|
|
@@ -412,14 +473,14 @@ function loadState(file, log = console.warn) {
|
|
|
412
473
|
return parsed;
|
|
413
474
|
}
|
|
414
475
|
function saveState(file, snapshot) {
|
|
415
|
-
mkdirSync(
|
|
476
|
+
mkdirSync(dirname2(file), { recursive: true });
|
|
416
477
|
writeFileSync(file, JSON.stringify(snapshot, null, 2), "utf-8");
|
|
417
478
|
}
|
|
418
479
|
var SEED_ENTRY_CANDIDATES = ["index.ts", "index.mjs", "index.js", "seeds.ts", "seeds.js"];
|
|
419
480
|
async function loadSeedsFromDir(dir) {
|
|
420
481
|
for (const candidate of SEED_ENTRY_CANDIDATES) {
|
|
421
482
|
const path = resolve2(dir, candidate);
|
|
422
|
-
if (
|
|
483
|
+
if (existsSync3(path)) {
|
|
423
484
|
const mod = await importFresh(path);
|
|
424
485
|
return mod.default ?? mod.seeds ?? {};
|
|
425
486
|
}
|
|
@@ -687,6 +748,56 @@ async function validateNodeConfig(loaded, store, input) {
|
|
|
687
748
|
}
|
|
688
749
|
return { valid: Object.keys(errors).length === 0, errors };
|
|
689
750
|
}
|
|
751
|
+
var MIN_TIMEOUT_MS = 1e3;
|
|
752
|
+
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
753
|
+
var ExecuteTimeout = class extends Error {
|
|
754
|
+
};
|
|
755
|
+
async function executeNodeTest(loaded, store, input) {
|
|
756
|
+
const node = findNode(loaded, input.slug, input.version);
|
|
757
|
+
const logs = [];
|
|
758
|
+
const record = (level) => (message, meta) => {
|
|
759
|
+
logs.push(meta === void 0 ? { level, message } : { level, message, meta });
|
|
760
|
+
};
|
|
761
|
+
const timeoutMs = Math.max(MIN_TIMEOUT_MS, input.timeoutMs ?? DEFAULT_TIMEOUT_MS);
|
|
762
|
+
const controller = new AbortController();
|
|
763
|
+
let timer;
|
|
764
|
+
const expired = new Promise((_resolve, reject) => {
|
|
765
|
+
timer = setTimeout(() => {
|
|
766
|
+
controller.abort();
|
|
767
|
+
reject(new ExecuteTimeout());
|
|
768
|
+
}, timeoutMs);
|
|
769
|
+
});
|
|
770
|
+
const ctx = {
|
|
771
|
+
signal: controller.signal,
|
|
772
|
+
logger: { info: record("info"), warn: record("warn"), error: record("error") },
|
|
773
|
+
secrets: {
|
|
774
|
+
async get(key) {
|
|
775
|
+
const secret = store.getSecret(key);
|
|
776
|
+
if (!secret) {
|
|
777
|
+
throw new DevApiError(404, `Secret '${key}' not found.`);
|
|
778
|
+
}
|
|
779
|
+
return secret.value;
|
|
780
|
+
}
|
|
781
|
+
},
|
|
782
|
+
credentials: {
|
|
783
|
+
async get(id) {
|
|
784
|
+
return (await resolveCredentialInstance(loaded, store, id)).credentials;
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
};
|
|
788
|
+
try {
|
|
789
|
+
const result = await Promise.race([node.execute(ctx, { ...input.config, ...input.inputs }), expired]);
|
|
790
|
+
return { outputs: result.outputs ?? {}, branch: result.branch ?? null, logs };
|
|
791
|
+
} catch (err) {
|
|
792
|
+
if (err instanceof DevApiError) {
|
|
793
|
+
throw err;
|
|
794
|
+
}
|
|
795
|
+
const reason = err instanceof ExecuteTimeout || controller.signal.aborted ? `timed out after ${timeoutMs} ms` : err.message;
|
|
796
|
+
throw new DevApiError(502, `Node execution failed: ${reason}`, { logs: logs.map((l) => `${l.level}: ${l.message}`) });
|
|
797
|
+
} finally {
|
|
798
|
+
clearTimeout(timer);
|
|
799
|
+
}
|
|
800
|
+
}
|
|
690
801
|
async function testCredentialConfig(loaded, store, typeSlug, config) {
|
|
691
802
|
const cred = findCredential(loaded, typeSlug);
|
|
692
803
|
return cred.test(credentialContext(store), config);
|
|
@@ -728,16 +839,22 @@ async function exchangeOAuthCode(loaded, store, credentialId, params) {
|
|
|
728
839
|
import http from "http";
|
|
729
840
|
|
|
730
841
|
// src/http.ts
|
|
842
|
+
var API_VERSION = "1.0.0";
|
|
843
|
+
var BASE_HEADERS = {
|
|
844
|
+
"X-Api-Version": API_VERSION,
|
|
845
|
+
"Access-Control-Allow-Origin": "*",
|
|
846
|
+
"Access-Control-Allow-Headers": "*",
|
|
847
|
+
"Access-Control-Allow-Methods": "GET,POST,PUT,PATCH,DELETE,OPTIONS"
|
|
848
|
+
};
|
|
731
849
|
function sendJson(res, status, body) {
|
|
732
850
|
const payload = JSON.stringify(body);
|
|
733
|
-
res.writeHead(status, {
|
|
734
|
-
"Content-Type": "application/json",
|
|
735
|
-
"Access-Control-Allow-Origin": "*",
|
|
736
|
-
"Access-Control-Allow-Headers": "*",
|
|
737
|
-
"Access-Control-Allow-Methods": "GET,POST,PUT,PATCH,DELETE,OPTIONS"
|
|
738
|
-
});
|
|
851
|
+
res.writeHead(status, { "Content-Type": "application/json", ...BASE_HEADERS });
|
|
739
852
|
res.end(payload);
|
|
740
853
|
}
|
|
854
|
+
function sendNoContent(res) {
|
|
855
|
+
res.writeHead(204, BASE_HEADERS);
|
|
856
|
+
res.end();
|
|
857
|
+
}
|
|
741
858
|
function sendError(res, err) {
|
|
742
859
|
if (err instanceof DevApiError) {
|
|
743
860
|
sendJson(res, err.status, err.errors ? { message: err.message, errors: err.errors } : { message: err.message });
|
|
@@ -775,20 +892,24 @@ function hasDynamicSchema(desc) {
|
|
|
775
892
|
function hasDynamicOutputs(desc) {
|
|
776
893
|
return (desc.outputs ?? []).some((o) => o.resolveOutputs === true);
|
|
777
894
|
}
|
|
778
|
-
function nodeToApi(desc) {
|
|
895
|
+
function nodeToApi(desc, ctx) {
|
|
779
896
|
const [namespace] = desc.slug.split(":");
|
|
780
897
|
return {
|
|
781
898
|
name: desc.name,
|
|
782
899
|
namespace: namespace ?? null,
|
|
783
900
|
slug: desc.slug,
|
|
784
901
|
version: desc.version,
|
|
902
|
+
// The contract declares `package` and both timestamps as present. Nodes here
|
|
903
|
+
// come from the developer's working tree, so the package identity is read from
|
|
904
|
+
// their package.json and the timestamps are when the mock loaded the entry.
|
|
905
|
+
package: ctx?.packageInfo ?? null,
|
|
785
906
|
manifest_version: MANIFEST_VERSION,
|
|
786
907
|
manifest: desc,
|
|
787
908
|
has_dynamic_options: hasDynamicOptions(desc),
|
|
788
909
|
has_dynamic_schema: hasDynamicSchema(desc),
|
|
789
910
|
has_dynamic_outputs: hasDynamicOutputs(desc),
|
|
790
|
-
created_at: null,
|
|
791
|
-
updated_at: null
|
|
911
|
+
created_at: ctx?.loadedAt ?? null,
|
|
912
|
+
updated_at: ctx?.loadedAt ?? null
|
|
792
913
|
};
|
|
793
914
|
}
|
|
794
915
|
function credentialTypeToApi(desc) {
|
|
@@ -798,6 +919,7 @@ function credentialTypeToApi(desc) {
|
|
|
798
919
|
name: desc.name,
|
|
799
920
|
description: desc.description ?? null,
|
|
800
921
|
icon: desc.icon ?? null,
|
|
922
|
+
images: desc.images ?? [],
|
|
801
923
|
auth_kind: desc.authKind,
|
|
802
924
|
fields: desc.fields
|
|
803
925
|
};
|
|
@@ -833,7 +955,16 @@ function workflowToApi(record) {
|
|
|
833
955
|
return {
|
|
834
956
|
id: record.id,
|
|
835
957
|
name: record.name,
|
|
836
|
-
|
|
958
|
+
description: record.description,
|
|
959
|
+
blob_definition_version: record.blobDefinitionVersion,
|
|
960
|
+
blob: record.blob,
|
|
961
|
+
active: record.active,
|
|
962
|
+
execution_mode: record.executionMode,
|
|
963
|
+
revision: record.revision,
|
|
964
|
+
// The service reports blob-validation warnings here. The mock's validation is
|
|
965
|
+
// schema-light (see the fidelity caveats), so it never has any — but the field
|
|
966
|
+
// is part of the contract and clients may read it.
|
|
967
|
+
warnings: [],
|
|
837
968
|
build_status: record.buildStatus,
|
|
838
969
|
created_at: record.createdAt,
|
|
839
970
|
updated_at: record.updatedAt
|
|
@@ -862,6 +993,7 @@ function templateSummaryToApi(t) {
|
|
|
862
993
|
shortDescription: t.shortDescription ?? null,
|
|
863
994
|
description: t.description ?? null,
|
|
864
995
|
icon: t.icon ?? null,
|
|
996
|
+
images: t.images ?? [],
|
|
865
997
|
industries: t.industries ?? [],
|
|
866
998
|
vendors: t.vendors ?? [],
|
|
867
999
|
triggerTypes: (t.triggers ?? []).map((tr) => tr.type)
|
|
@@ -870,9 +1002,13 @@ function templateSummaryToApi(t) {
|
|
|
870
1002
|
function templateFullToApi(t) {
|
|
871
1003
|
return {
|
|
872
1004
|
...templateSummaryToApi(t),
|
|
873
|
-
|
|
1005
|
+
// snake_case per the contract, even though the surrounding template fields are
|
|
1006
|
+
// camelCase and the SDK's own field is `blobVersion`.
|
|
1007
|
+
blob_version: t.blobVersion,
|
|
874
1008
|
definition: t.definition,
|
|
875
|
-
|
|
1009
|
+
// `config` is optional in the SDK (a manual trigger has none) but declared in
|
|
1010
|
+
// the contract, so normalise it to an object rather than omitting it.
|
|
1011
|
+
triggers: (t.triggers ?? []).map((tr) => ({ ...tr, config: tr.config ?? {} }))
|
|
876
1012
|
};
|
|
877
1013
|
}
|
|
878
1014
|
|
|
@@ -903,13 +1039,15 @@ async function handle(req, res, deps) {
|
|
|
903
1039
|
switch (seg[0]) {
|
|
904
1040
|
case void 0:
|
|
905
1041
|
case "health":
|
|
1042
|
+
// The service's health route is `/up` (Laravel's default); `/health` is kept
|
|
1043
|
+
// because the devkit has always answered there.
|
|
1044
|
+
case "up":
|
|
906
1045
|
return void sendJson(res, 200, { status: "ok" });
|
|
907
1046
|
case "me":
|
|
908
1047
|
return void sendJson(res, 200, {
|
|
909
|
-
id: "dev-user",
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
tenant_id: DEV_TENANT_ID
|
|
1048
|
+
user: { id: 1, zitadel_id: "dev-user", email: "dev@revenexx.test", name: "Dev User" },
|
|
1049
|
+
context: { tenant_id: DEV_TENANT_ID, active_plane: "public", roles: ["admin", "user"] },
|
|
1050
|
+
claims: { iss: "https://id.revenexx.test", sub: "dev-user", aud: ["devkit"] }
|
|
913
1051
|
});
|
|
914
1052
|
case "schemas":
|
|
915
1053
|
return handleSchemas(res, deps, seg);
|
|
@@ -936,15 +1074,22 @@ function handleSchemas(res, deps, seg) {
|
|
|
936
1074
|
throw new DevApiError(404, "Schema domain required.");
|
|
937
1075
|
}
|
|
938
1076
|
const schemas = deps.schemas ?? {};
|
|
939
|
-
|
|
1077
|
+
if (!version) {
|
|
1078
|
+
const versions = Object.keys(schemas).filter((key) => key.startsWith(`${domain}/`)).map((key) => key.slice(domain.length + 1)).sort();
|
|
1079
|
+
if (versions.length === 0 && !schemas[domain]) {
|
|
1080
|
+
throw new DevApiError(404, `Unknown schema domain '${domain}'. Vendor it into assets/schemas.`);
|
|
1081
|
+
}
|
|
1082
|
+
return void sendJson(res, 200, { domain, versions });
|
|
1083
|
+
}
|
|
1084
|
+
const schema = schemas[`${domain}/${version}`];
|
|
940
1085
|
if (!schema) {
|
|
941
|
-
throw new DevApiError(404, `
|
|
1086
|
+
throw new DevApiError(404, `Unknown schema version '${domain}/${version}'. Vendor it into assets/schemas.`);
|
|
942
1087
|
}
|
|
943
|
-
sendJson(res, 200, schema);
|
|
1088
|
+
sendJson(res, 200, { domain, version, schema });
|
|
944
1089
|
}
|
|
945
1090
|
async function handleNodes(req, res, method, loaded, store, seg) {
|
|
946
1091
|
if (seg.length === 1 && method === "GET") {
|
|
947
|
-
return void sendJson(res, 200, { data: loaded.manifest.nodes.map(nodeToApi) });
|
|
1092
|
+
return void sendJson(res, 200, { data: loaded.manifest.nodes.map((n) => nodeToApi(n, nodeApiContext(loaded))) });
|
|
948
1093
|
}
|
|
949
1094
|
const slug = seg[1];
|
|
950
1095
|
if (!slug) {
|
|
@@ -985,15 +1130,36 @@ async function handleNodes(req, res, method, loaded, store, seg) {
|
|
|
985
1130
|
});
|
|
986
1131
|
return void sendJson(res, 200, result);
|
|
987
1132
|
}
|
|
1133
|
+
if (seg[3] === "execute:test" && method === "POST") {
|
|
1134
|
+
const body = await readJson(req);
|
|
1135
|
+
const result = await executeNodeTest(loaded, store, {
|
|
1136
|
+
slug,
|
|
1137
|
+
version,
|
|
1138
|
+
config: body.config ?? {},
|
|
1139
|
+
inputs: body.inputs ?? {},
|
|
1140
|
+
timeoutMs: body.timeout_ms
|
|
1141
|
+
});
|
|
1142
|
+
return void sendJson(res, 200, result);
|
|
1143
|
+
}
|
|
988
1144
|
if (seg.length === 3 && method === "GET") {
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
return void
|
|
1145
|
+
return void sendJson(res, 200, nodeToApi(findManifestNode(loaded, slug, version), nodeApiContext(loaded)));
|
|
1146
|
+
}
|
|
1147
|
+
if (seg.length === 3 && method === "DELETE") {
|
|
1148
|
+
findManifestNode(loaded, slug, version);
|
|
1149
|
+
return void sendNoContent(res);
|
|
994
1150
|
}
|
|
995
1151
|
throw new DevApiError(404, `No route for nodes/${seg.slice(1).join("/")}`);
|
|
996
1152
|
}
|
|
1153
|
+
function nodeApiContext(loaded) {
|
|
1154
|
+
return { packageInfo: loaded.packageInfo, loadedAt: loaded.loadedAt };
|
|
1155
|
+
}
|
|
1156
|
+
function findManifestNode(loaded, slug, version) {
|
|
1157
|
+
const node = loaded.manifest.nodes.find((n) => n.slug === slug && (version === "latest" || n.version === version));
|
|
1158
|
+
if (!node) {
|
|
1159
|
+
throw new DevApiError(404, `Node '${slug}@${version}' not found.`);
|
|
1160
|
+
}
|
|
1161
|
+
return node;
|
|
1162
|
+
}
|
|
997
1163
|
function handleCredentialTypes(res, loaded, seg) {
|
|
998
1164
|
if (seg.length === 1) {
|
|
999
1165
|
return void sendJson(res, 200, {
|
|
@@ -1057,7 +1223,13 @@ async function handleCredentials(req, res, method, loaded, store, seg, url) {
|
|
|
1057
1223
|
}
|
|
1058
1224
|
if (seg[2] === "test" && method === "POST") {
|
|
1059
1225
|
const result = await testCredentialInstance(loaded, store, id);
|
|
1060
|
-
|
|
1226
|
+
const record = store.recordCredentialTest(id, { ok: result.ok, message: result.message ?? null });
|
|
1227
|
+
return void sendJson(res, 200, {
|
|
1228
|
+
ok: result.ok,
|
|
1229
|
+
message: result.message ?? null,
|
|
1230
|
+
last_test_at: record?.lastTestAt ?? null,
|
|
1231
|
+
last_test_ok: record?.lastTestOk ?? result.ok
|
|
1232
|
+
});
|
|
1061
1233
|
}
|
|
1062
1234
|
if (seg[2] === "oauth" && seg[3] === "authorize-url" && method === "POST") {
|
|
1063
1235
|
const redirectUri = "http://localhost/api/v1/credentials/oauth/callback";
|
|
@@ -1082,7 +1254,7 @@ async function handleCredentials(req, res, method, loaded, store, seg, url) {
|
|
|
1082
1254
|
}
|
|
1083
1255
|
if (method === "DELETE") {
|
|
1084
1256
|
store.deleteCredential(id);
|
|
1085
|
-
return void
|
|
1257
|
+
return void sendNoContent(res);
|
|
1086
1258
|
}
|
|
1087
1259
|
}
|
|
1088
1260
|
throw new DevApiError(404, `No route for credentials/${seg.slice(1).join("/")}`);
|
|
@@ -1090,7 +1262,7 @@ async function handleCredentials(req, res, method, loaded, store, seg, url) {
|
|
|
1090
1262
|
async function handleSecrets(req, res, method, store, seg) {
|
|
1091
1263
|
if (seg.length === 1) {
|
|
1092
1264
|
if (method === "GET") {
|
|
1093
|
-
return void sendJson(res, 200, {
|
|
1265
|
+
return void sendJson(res, 200, { keys: store.listSecrets().map((s) => s.key) });
|
|
1094
1266
|
}
|
|
1095
1267
|
if (method === "POST") {
|
|
1096
1268
|
const body = await readJson(req);
|
|
@@ -1112,7 +1284,7 @@ async function handleSecrets(req, res, method, store, seg) {
|
|
|
1112
1284
|
}
|
|
1113
1285
|
if (method === "DELETE") {
|
|
1114
1286
|
store.deleteSecret(key);
|
|
1115
|
-
return void
|
|
1287
|
+
return void sendNoContent(res);
|
|
1116
1288
|
}
|
|
1117
1289
|
}
|
|
1118
1290
|
throw new DevApiError(404, `No route for secrets/${seg.slice(1).join("/")}`);
|
|
@@ -1128,16 +1300,17 @@ async function handleTemplates(req, res, method, loaded, store, seg) {
|
|
|
1128
1300
|
throw new DevApiError(404, `Template '${slug}' not found.`);
|
|
1129
1301
|
}
|
|
1130
1302
|
if (seg.length === 2 && method === "GET") {
|
|
1131
|
-
return void sendJson(res, 200, templateFullToApi(template));
|
|
1303
|
+
return void sendJson(res, 200, { data: templateFullToApi(template) });
|
|
1132
1304
|
}
|
|
1133
1305
|
if (seg[2] === "requirements" && method === "GET") {
|
|
1134
|
-
return void sendJson(res, 200, { data: {
|
|
1306
|
+
return void sendJson(res, 200, { data: { credentialTypes: [], secrets: [] } });
|
|
1135
1307
|
}
|
|
1136
1308
|
if (seg[2] === "instantiate" && method === "POST") {
|
|
1137
1309
|
const body = await readJson(req);
|
|
1138
1310
|
const workflow = store.createWorkflow({
|
|
1139
1311
|
name: body.name ?? String(template.name),
|
|
1140
|
-
|
|
1312
|
+
blob: template.definition,
|
|
1313
|
+
blobDefinitionVersion: template.blobVersion
|
|
1141
1314
|
});
|
|
1142
1315
|
for (const trigger of template.triggers ?? []) {
|
|
1143
1316
|
store.createTrigger({
|
|
@@ -1162,7 +1335,11 @@ async function handleWorkflows(req, res, method, store, seg) {
|
|
|
1162
1335
|
const body = await readJson(req);
|
|
1163
1336
|
const workflow = store.createWorkflow({
|
|
1164
1337
|
name: body.name ?? "Untitled workflow",
|
|
1165
|
-
|
|
1338
|
+
blob: body.blob ?? {},
|
|
1339
|
+
blobDefinitionVersion: body.blob_definition_version,
|
|
1340
|
+
description: body.description,
|
|
1341
|
+
active: body.active,
|
|
1342
|
+
executionMode: body.execution_mode
|
|
1166
1343
|
});
|
|
1167
1344
|
return void sendJson(res, 201, workflowToApi(workflow));
|
|
1168
1345
|
}
|
|
@@ -1203,7 +1380,7 @@ async function handleWorkflows(req, res, method, store, seg) {
|
|
|
1203
1380
|
}
|
|
1204
1381
|
if (triggerId && method === "DELETE") {
|
|
1205
1382
|
store.deleteTrigger(triggerId);
|
|
1206
|
-
return void
|
|
1383
|
+
return void sendNoContent(res);
|
|
1207
1384
|
}
|
|
1208
1385
|
}
|
|
1209
1386
|
if (seg.length === 2) {
|
|
@@ -1216,7 +1393,14 @@ async function handleWorkflows(req, res, method, store, seg) {
|
|
|
1216
1393
|
}
|
|
1217
1394
|
if (method === "PUT") {
|
|
1218
1395
|
const body = await readJson(req);
|
|
1219
|
-
const updated = store.updateWorkflow(id, {
|
|
1396
|
+
const updated = store.updateWorkflow(id, {
|
|
1397
|
+
name: body.name,
|
|
1398
|
+
blob: body.blob,
|
|
1399
|
+
blobDefinitionVersion: body.blob_definition_version,
|
|
1400
|
+
description: body.description,
|
|
1401
|
+
active: body.active,
|
|
1402
|
+
executionMode: body.execution_mode
|
|
1403
|
+
});
|
|
1220
1404
|
if (!updated) {
|
|
1221
1405
|
throw new DevApiError(404, `Workflow '${id}' not found.`);
|
|
1222
1406
|
}
|
|
@@ -1224,7 +1408,7 @@ async function handleWorkflows(req, res, method, store, seg) {
|
|
|
1224
1408
|
}
|
|
1225
1409
|
if (method === "DELETE") {
|
|
1226
1410
|
store.deleteWorkflow(id);
|
|
1227
|
-
return void
|
|
1411
|
+
return void sendNoContent(res);
|
|
1228
1412
|
}
|
|
1229
1413
|
}
|
|
1230
1414
|
if ((seg[2] === "credentials" || seg[2] === "credential-types") && method === "GET") {
|
|
@@ -1235,7 +1419,7 @@ async function handleWorkflows(req, res, method, store, seg) {
|
|
|
1235
1419
|
|
|
1236
1420
|
// src/index.ts
|
|
1237
1421
|
var manifestUrl = new URL("../package.json", import.meta.url);
|
|
1238
|
-
var DEVKIT_VERSION = JSON.parse(
|
|
1422
|
+
var DEVKIT_VERSION = JSON.parse(readFileSync3(manifestUrl, "utf8")).version;
|
|
1239
1423
|
|
|
1240
1424
|
export {
|
|
1241
1425
|
ENV_FILE_MIN_NODE,
|
|
@@ -1245,6 +1429,7 @@ export {
|
|
|
1245
1429
|
DevApiError,
|
|
1246
1430
|
resolveExports,
|
|
1247
1431
|
ensureTsxRegistered,
|
|
1432
|
+
isReloadableSource,
|
|
1248
1433
|
importFresh,
|
|
1249
1434
|
loadPackageFromEntry,
|
|
1250
1435
|
DEV_TENANT_ID,
|
|
@@ -1270,4 +1455,4 @@ export {
|
|
|
1270
1455
|
createDevServer,
|
|
1271
1456
|
DEVKIT_VERSION
|
|
1272
1457
|
};
|
|
1273
|
-
//# sourceMappingURL=chunk-
|
|
1458
|
+
//# sourceMappingURL=chunk-PS3HCKE7.js.map
|