@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.cjs
CHANGED
|
@@ -752,20 +752,66 @@ var noopLogger = {
|
|
|
752
752
|
error() {
|
|
753
753
|
}
|
|
754
754
|
};
|
|
755
|
+
function parseSemver(version) {
|
|
756
|
+
const [withoutBuild] = version.split("+");
|
|
757
|
+
const dash = withoutBuild.indexOf("-");
|
|
758
|
+
const core = (dash === -1 ? withoutBuild : withoutBuild.slice(0, dash)).split(".").map((n) => Number.parseInt(n, 10) || 0);
|
|
759
|
+
const pre = dash === -1 ? [] : withoutBuild.slice(dash + 1).split(".");
|
|
760
|
+
return { core, pre };
|
|
761
|
+
}
|
|
762
|
+
function comparePrerelease(a, b) {
|
|
763
|
+
if (a.length === 0 || b.length === 0) {
|
|
764
|
+
return (a.length === 0 ? 1 : 0) - (b.length === 0 ? 1 : 0);
|
|
765
|
+
}
|
|
766
|
+
for (let i = 0; i < Math.max(a.length, b.length); i++) {
|
|
767
|
+
const ia = a[i];
|
|
768
|
+
const ib = b[i];
|
|
769
|
+
if (ia === void 0 || ib === void 0) {
|
|
770
|
+
return ia === void 0 ? -1 : 1;
|
|
771
|
+
}
|
|
772
|
+
const na = /^\d+$/.test(ia) ? Number(ia) : null;
|
|
773
|
+
const nb = /^\d+$/.test(ib) ? Number(ib) : null;
|
|
774
|
+
if (na !== null && nb !== null) {
|
|
775
|
+
if (na !== nb) {
|
|
776
|
+
return na - nb;
|
|
777
|
+
}
|
|
778
|
+
continue;
|
|
779
|
+
}
|
|
780
|
+
if (na !== null || nb !== null) {
|
|
781
|
+
return na !== null ? -1 : 1;
|
|
782
|
+
}
|
|
783
|
+
if (ia !== ib) {
|
|
784
|
+
return ia < ib ? -1 : 1;
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
return 0;
|
|
788
|
+
}
|
|
755
789
|
function compareSemver(a, b) {
|
|
756
|
-
const pa = a
|
|
757
|
-
const pb = b
|
|
790
|
+
const pa = parseSemver(a);
|
|
791
|
+
const pb = parseSemver(b);
|
|
758
792
|
for (let i = 0; i < 3; i++) {
|
|
759
|
-
const diff = (pa[i] ?? 0) - (pb[i] ?? 0);
|
|
793
|
+
const diff = (pa.core[i] ?? 0) - (pb.core[i] ?? 0);
|
|
760
794
|
if (diff !== 0) {
|
|
761
795
|
return diff;
|
|
762
796
|
}
|
|
763
797
|
}
|
|
764
|
-
return
|
|
798
|
+
return comparePrerelease(pa.pre, pb.pre);
|
|
765
799
|
}
|
|
766
800
|
function nodeVersions(loaded, slug) {
|
|
767
801
|
return loaded.nodes.filter((n) => n.description.slug === slug).map((n) => n.description.version).sort((a, b) => compareSemver(b, a));
|
|
768
802
|
}
|
|
803
|
+
function listNodesNewestFirst(nodes) {
|
|
804
|
+
const bySlug = /* @__PURE__ */ new Map();
|
|
805
|
+
for (const node of nodes) {
|
|
806
|
+
const group = bySlug.get(node.slug);
|
|
807
|
+
if (group) {
|
|
808
|
+
group.push(node);
|
|
809
|
+
} else {
|
|
810
|
+
bySlug.set(node.slug, [node]);
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
return [...bySlug.values()].flatMap((group) => [...group].sort((a, b) => compareSemver(b.version, a.version)));
|
|
814
|
+
}
|
|
769
815
|
function findNode(loaded, slug, version) {
|
|
770
816
|
const matches = loaded.nodes.filter((n) => n.description.slug === slug);
|
|
771
817
|
if (matches.length === 0) {
|
|
@@ -1346,13 +1392,24 @@ function createRequestListener(deps) {
|
|
|
1346
1392
|
handle(req, res, deps).catch((err) => sendError(res, err));
|
|
1347
1393
|
};
|
|
1348
1394
|
}
|
|
1395
|
+
function requestOrigin(req) {
|
|
1396
|
+
const host = req.headers.host;
|
|
1397
|
+
if (!host) {
|
|
1398
|
+
return "http://localhost";
|
|
1399
|
+
}
|
|
1400
|
+
try {
|
|
1401
|
+
return new URL(`http://${host}`).origin;
|
|
1402
|
+
} catch {
|
|
1403
|
+
return "http://localhost";
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1349
1406
|
async function handle(req, res, deps) {
|
|
1350
1407
|
const method = (req.method ?? "GET").toUpperCase();
|
|
1351
1408
|
if (method === "OPTIONS") {
|
|
1352
1409
|
sendJson(res, 204, {});
|
|
1353
1410
|
return;
|
|
1354
1411
|
}
|
|
1355
|
-
const url = new URL(req.url ?? "/",
|
|
1412
|
+
const url = new URL(req.url ?? "/", requestOrigin(req));
|
|
1356
1413
|
let pathname = url.pathname;
|
|
1357
1414
|
if (pathname.startsWith("/api/v1")) {
|
|
1358
1415
|
pathname = pathname.slice("/api/v1".length);
|
|
@@ -1413,7 +1470,7 @@ function handleSchemas(res, deps, seg) {
|
|
|
1413
1470
|
}
|
|
1414
1471
|
async function handleNodes(req, res, method, loaded, store, seg) {
|
|
1415
1472
|
if (seg.length === 1 && method === "GET") {
|
|
1416
|
-
return void sendJson(res, 200, { data: loaded.manifest.nodes.map((n) => nodeToApi(n, nodeApiContext(loaded))) });
|
|
1473
|
+
return void sendJson(res, 200, { data: listNodesNewestFirst(loaded.manifest.nodes).map((n) => nodeToApi(n, nodeApiContext(loaded))) });
|
|
1417
1474
|
}
|
|
1418
1475
|
const slug = seg[1];
|
|
1419
1476
|
if (!slug) {
|
|
@@ -1478,7 +1535,8 @@ function nodeApiContext(loaded) {
|
|
|
1478
1535
|
return { packageInfo: loaded.packageInfo, loadedAt: loaded.loadedAt };
|
|
1479
1536
|
}
|
|
1480
1537
|
function findManifestNode(loaded, slug, version) {
|
|
1481
|
-
const
|
|
1538
|
+
const matches = loaded.manifest.nodes.filter((n) => n.slug === slug);
|
|
1539
|
+
const node = version === "latest" ? listNodesNewestFirst(matches)[0] : matches.find((n) => n.version === version);
|
|
1482
1540
|
if (!node) {
|
|
1483
1541
|
throw new DevApiError(404, `Node '${slug}@${version}' not found.`);
|
|
1484
1542
|
}
|
|
@@ -1556,7 +1614,7 @@ async function handleCredentials(req, res, method, loaded, store, seg, url) {
|
|
|
1556
1614
|
});
|
|
1557
1615
|
}
|
|
1558
1616
|
if (seg[2] === "oauth" && seg[3] === "authorize-url" && method === "POST") {
|
|
1559
|
-
const redirectUri =
|
|
1617
|
+
const redirectUri = `${url.origin}/api/v1/credentials/oauth/callback`;
|
|
1560
1618
|
const result = await buildOAuthAuthorizeUrl(loaded, store, id, { redirectUri, state: id });
|
|
1561
1619
|
return void sendJson(res, 200, { authorize_url: result.authorizeUrl });
|
|
1562
1620
|
}
|