@revenexx/integrations-node-devkit 0.7.0 → 0.8.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 +39 -10
- package/dist/{chunk-4QB5F7RT.js → chunk-YUUW37NC.js} +68 -9
- package/dist/chunk-YUUW37NC.js.map +1 -0
- package/dist/cli.cjs +66 -8
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.cjs +68 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -2
- package/dist/index.d.ts +18 -2
- package/dist/index.js +3 -1
- package/package.json +4 -4
- package/preview-host/package.json +1 -1
- package/preview-host/pages/nodes.vue +29 -0
- package/dist/chunk-4QB5F7RT.js.map +0 -1
package/dist/cli.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -47,6 +47,7 @@ __export(index_exports, {
|
|
|
47
47
|
findNode: () => findNode,
|
|
48
48
|
importFresh: () => importFresh,
|
|
49
49
|
interpolateEnv: () => interpolateEnv,
|
|
50
|
+
listNodesNewestFirst: () => listNodesNewestFirst,
|
|
50
51
|
loadEnvFile: () => loadEnvFile,
|
|
51
52
|
loadPackageFromEntry: () => loadPackageFromEntry,
|
|
52
53
|
loadSeedsFromDir: () => loadSeedsFromDir,
|
|
@@ -615,20 +616,66 @@ var noopLogger = {
|
|
|
615
616
|
error() {
|
|
616
617
|
}
|
|
617
618
|
};
|
|
619
|
+
function parseSemver(version) {
|
|
620
|
+
const [withoutBuild] = version.split("+");
|
|
621
|
+
const dash = withoutBuild.indexOf("-");
|
|
622
|
+
const core = (dash === -1 ? withoutBuild : withoutBuild.slice(0, dash)).split(".").map((n) => Number.parseInt(n, 10) || 0);
|
|
623
|
+
const pre = dash === -1 ? [] : withoutBuild.slice(dash + 1).split(".");
|
|
624
|
+
return { core, pre };
|
|
625
|
+
}
|
|
626
|
+
function comparePrerelease(a, b) {
|
|
627
|
+
if (a.length === 0 || b.length === 0) {
|
|
628
|
+
return (a.length === 0 ? 1 : 0) - (b.length === 0 ? 1 : 0);
|
|
629
|
+
}
|
|
630
|
+
for (let i = 0; i < Math.max(a.length, b.length); i++) {
|
|
631
|
+
const ia = a[i];
|
|
632
|
+
const ib = b[i];
|
|
633
|
+
if (ia === void 0 || ib === void 0) {
|
|
634
|
+
return ia === void 0 ? -1 : 1;
|
|
635
|
+
}
|
|
636
|
+
const na = /^\d+$/.test(ia) ? Number(ia) : null;
|
|
637
|
+
const nb = /^\d+$/.test(ib) ? Number(ib) : null;
|
|
638
|
+
if (na !== null && nb !== null) {
|
|
639
|
+
if (na !== nb) {
|
|
640
|
+
return na - nb;
|
|
641
|
+
}
|
|
642
|
+
continue;
|
|
643
|
+
}
|
|
644
|
+
if (na !== null || nb !== null) {
|
|
645
|
+
return na !== null ? -1 : 1;
|
|
646
|
+
}
|
|
647
|
+
if (ia !== ib) {
|
|
648
|
+
return ia < ib ? -1 : 1;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
return 0;
|
|
652
|
+
}
|
|
618
653
|
function compareSemver(a, b) {
|
|
619
|
-
const pa = a
|
|
620
|
-
const pb = b
|
|
654
|
+
const pa = parseSemver(a);
|
|
655
|
+
const pb = parseSemver(b);
|
|
621
656
|
for (let i = 0; i < 3; i++) {
|
|
622
|
-
const diff = (pa[i] ?? 0) - (pb[i] ?? 0);
|
|
657
|
+
const diff = (pa.core[i] ?? 0) - (pb.core[i] ?? 0);
|
|
623
658
|
if (diff !== 0) {
|
|
624
659
|
return diff;
|
|
625
660
|
}
|
|
626
661
|
}
|
|
627
|
-
return
|
|
662
|
+
return comparePrerelease(pa.pre, pb.pre);
|
|
628
663
|
}
|
|
629
664
|
function nodeVersions(loaded, slug) {
|
|
630
665
|
return loaded.nodes.filter((n) => n.description.slug === slug).map((n) => n.description.version).sort((a, b) => compareSemver(b, a));
|
|
631
666
|
}
|
|
667
|
+
function listNodesNewestFirst(nodes) {
|
|
668
|
+
const bySlug = /* @__PURE__ */ new Map();
|
|
669
|
+
for (const node of nodes) {
|
|
670
|
+
const group = bySlug.get(node.slug);
|
|
671
|
+
if (group) {
|
|
672
|
+
group.push(node);
|
|
673
|
+
} else {
|
|
674
|
+
bySlug.set(node.slug, [node]);
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
return [...bySlug.values()].flatMap((group) => [...group].sort((a, b) => compareSemver(b.version, a.version)));
|
|
678
|
+
}
|
|
632
679
|
function findNode(loaded, slug, version) {
|
|
633
680
|
const matches = loaded.nodes.filter((n) => n.description.slug === slug);
|
|
634
681
|
if (matches.length === 0) {
|
|
@@ -1212,13 +1259,24 @@ function createRequestListener(deps) {
|
|
|
1212
1259
|
function createDevServer(deps) {
|
|
1213
1260
|
return import_node_http.default.createServer(createRequestListener(deps));
|
|
1214
1261
|
}
|
|
1262
|
+
function requestOrigin(req) {
|
|
1263
|
+
const host = req.headers.host;
|
|
1264
|
+
if (!host) {
|
|
1265
|
+
return "http://localhost";
|
|
1266
|
+
}
|
|
1267
|
+
try {
|
|
1268
|
+
return new URL(`http://${host}`).origin;
|
|
1269
|
+
} catch {
|
|
1270
|
+
return "http://localhost";
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1215
1273
|
async function handle(req, res, deps) {
|
|
1216
1274
|
const method = (req.method ?? "GET").toUpperCase();
|
|
1217
1275
|
if (method === "OPTIONS") {
|
|
1218
1276
|
sendJson(res, 204, {});
|
|
1219
1277
|
return;
|
|
1220
1278
|
}
|
|
1221
|
-
const url = new URL(req.url ?? "/",
|
|
1279
|
+
const url = new URL(req.url ?? "/", requestOrigin(req));
|
|
1222
1280
|
let pathname = url.pathname;
|
|
1223
1281
|
if (pathname.startsWith("/api/v1")) {
|
|
1224
1282
|
pathname = pathname.slice("/api/v1".length);
|
|
@@ -1279,7 +1337,7 @@ function handleSchemas(res, deps, seg) {
|
|
|
1279
1337
|
}
|
|
1280
1338
|
async function handleNodes(req, res, method, loaded, store, seg) {
|
|
1281
1339
|
if (seg.length === 1 && method === "GET") {
|
|
1282
|
-
return void sendJson(res, 200, { data: loaded.manifest.nodes.map((n) => nodeToApi(n, nodeApiContext(loaded))) });
|
|
1340
|
+
return void sendJson(res, 200, { data: listNodesNewestFirst(loaded.manifest.nodes).map((n) => nodeToApi(n, nodeApiContext(loaded))) });
|
|
1283
1341
|
}
|
|
1284
1342
|
const slug = seg[1];
|
|
1285
1343
|
if (!slug) {
|
|
@@ -1344,7 +1402,8 @@ function nodeApiContext(loaded) {
|
|
|
1344
1402
|
return { packageInfo: loaded.packageInfo, loadedAt: loaded.loadedAt };
|
|
1345
1403
|
}
|
|
1346
1404
|
function findManifestNode(loaded, slug, version) {
|
|
1347
|
-
const
|
|
1405
|
+
const matches = loaded.manifest.nodes.filter((n) => n.slug === slug);
|
|
1406
|
+
const node = version === "latest" ? listNodesNewestFirst(matches)[0] : matches.find((n) => n.version === version);
|
|
1348
1407
|
if (!node) {
|
|
1349
1408
|
throw new DevApiError(404, `Node '${slug}@${version}' not found.`);
|
|
1350
1409
|
}
|
|
@@ -1422,7 +1481,7 @@ async function handleCredentials(req, res, method, loaded, store, seg, url) {
|
|
|
1422
1481
|
});
|
|
1423
1482
|
}
|
|
1424
1483
|
if (seg[2] === "oauth" && seg[3] === "authorize-url" && method === "POST") {
|
|
1425
|
-
const redirectUri =
|
|
1484
|
+
const redirectUri = `${url.origin}/api/v1/credentials/oauth/callback`;
|
|
1426
1485
|
const result = await buildOAuthAuthorizeUrl(loaded, store, id, { redirectUri, state: id });
|
|
1427
1486
|
return void sendJson(res, 200, { authorize_url: result.authorizeUrl });
|
|
1428
1487
|
}
|
|
@@ -1629,6 +1688,7 @@ var DEVKIT_VERSION = JSON.parse((0, import_node_fs4.readFileSync)(manifestUrl, "
|
|
|
1629
1688
|
findNode,
|
|
1630
1689
|
importFresh,
|
|
1631
1690
|
interpolateEnv,
|
|
1691
|
+
listNodesNewestFirst,
|
|
1632
1692
|
loadEnvFile,
|
|
1633
1693
|
loadPackageFromEntry,
|
|
1634
1694
|
loadSeedsFromDir,
|