@clarify-labs/cli 0.11.17 → 0.11.19
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/output/cli.cjs +1 -1
- package/output/cli.js +1 -1
- package/output/{engine-BNvizszh.cjs → engine-0ROqtF4o.cjs} +47 -18
- package/output/engine-0ROqtF4o.cjs.map +1 -0
- package/output/{engine-CIhcMyvD.js → engine-DH8Hi6Fr.js} +47 -18
- package/output/engine-DH8Hi6Fr.js.map +1 -0
- package/output/index.cjs +1 -1
- package/output/index.js +1 -1
- package/output/plugins/openapi/parser.d.ts +1 -1
- package/output/plugins/openapi/virtual-modules.d.ts +1 -0
- package/output/types.d.ts +5 -0
- package/package.json +3 -3
- package/output/engine-BNvizszh.cjs.map +0 -1
- package/output/engine-CIhcMyvD.js.map +0 -1
package/output/cli.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const require_engine = require("./engine-
|
|
2
|
+
const require_engine = require("./engine-0ROqtF4o.cjs");
|
|
3
3
|
let node_path = require("node:path");
|
|
4
4
|
let node_fs_promises = require("node:fs/promises");
|
|
5
5
|
let node_child_process = require("node:child_process");
|
package/output/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as createClarifyTempDir, c as cliPackageVersion, d as createViteAdapter, i as findRouteConflicts, l as cliPackageVersionWithCaret, n as createClarifyEngine, o as deserializeSearchIndex, r as createClarifyRuntimeAliases, s as searchMcpIndex, u as printCliVersion } from "./engine-
|
|
2
|
+
import { a as createClarifyTempDir, c as cliPackageVersion, d as createViteAdapter, i as findRouteConflicts, l as cliPackageVersionWithCaret, n as createClarifyEngine, o as deserializeSearchIndex, r as createClarifyRuntimeAliases, s as searchMcpIndex, u as printCliVersion } from "./engine-DH8Hi6Fr.js";
|
|
3
3
|
import { dirname, extname, isAbsolute, join, normalize, relative, resolve } from "node:path";
|
|
4
4
|
import { lstat, mkdir, readFile, stat, writeFile } from "node:fs/promises";
|
|
5
5
|
import { spawnSync } from "node:child_process";
|
|
@@ -678,6 +678,7 @@ function routeIntentFromPagesItem(item) {
|
|
|
678
678
|
kind: "openapi",
|
|
679
679
|
ref: item.openapi,
|
|
680
680
|
tagFilter: item.filter?.tags,
|
|
681
|
+
operationOrder: item.operationOrder,
|
|
681
682
|
path: item.path,
|
|
682
683
|
title: item.title,
|
|
683
684
|
icon: item.icon
|
|
@@ -1144,6 +1145,7 @@ var clarifyPagesItemSchema = zod.z.lazy(() => zod.z.union([
|
|
|
1144
1145
|
zod.z.object({
|
|
1145
1146
|
openapi: zod.z.string(),
|
|
1146
1147
|
path: zod.z.string().optional(),
|
|
1148
|
+
operationOrder: zod.z.array(zod.z.string()).optional(),
|
|
1147
1149
|
icon: zod.z.string().optional(),
|
|
1148
1150
|
title: clarifyLocalizedTextSchema.optional(),
|
|
1149
1151
|
filter: zod.z.object({ tags: zod.z.array(zod.z.string()).optional() }).strict().optional()
|
|
@@ -1819,7 +1821,7 @@ function createViteAdapter(engine) {
|
|
|
1819
1821
|
}
|
|
1820
1822
|
var cliPackageVersion = {
|
|
1821
1823
|
name: "@clarify-labs/cli",
|
|
1822
|
-
version: "0.11.
|
|
1824
|
+
version: "0.11.19",
|
|
1823
1825
|
license: "AGPL-3.0-only",
|
|
1824
1826
|
type: "module",
|
|
1825
1827
|
repository: {
|
|
@@ -2628,9 +2630,9 @@ function filterSpecByTags(spec, tags) {
|
|
|
2628
2630
|
};
|
|
2629
2631
|
}
|
|
2630
2632
|
/** Extract endpoint operations from an OpenAPI spec as page sections. */
|
|
2631
|
-
function extractOpenAPISections(spec, filterTags) {
|
|
2633
|
+
function extractOpenAPISections(spec, filterTags, operationOrder) {
|
|
2632
2634
|
normalizeOpenAPISpecSectionIds(spec);
|
|
2633
|
-
const
|
|
2635
|
+
const entries = [];
|
|
2634
2636
|
const items = [...Object.entries(spec.paths ?? {}).map(([path, pathItem]) => ({
|
|
2635
2637
|
path,
|
|
2636
2638
|
pathItem,
|
|
@@ -2648,16 +2650,25 @@ function extractOpenAPISections(spec, filterTags) {
|
|
|
2648
2650
|
const tags = Array.isArray(op?.tags) ? op.tags : void 0;
|
|
2649
2651
|
if (!op || !operationMatchesTags(tags, filterTags)) continue;
|
|
2650
2652
|
const title = typeof op.summary === "string" ? op.summary : `${method.toUpperCase()} ${path}`;
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2653
|
+
entries.push({
|
|
2654
|
+
section: {
|
|
2655
|
+
id: operationSectionId(op),
|
|
2656
|
+
title,
|
|
2657
|
+
level: 2,
|
|
2658
|
+
badge: kind === "webhook" ? "WEBHOOK" : method.toUpperCase(),
|
|
2659
|
+
tags
|
|
2660
|
+
},
|
|
2661
|
+
operationId: typeof op.operationId === "string" ? op.operationId : void 0
|
|
2657
2662
|
});
|
|
2658
2663
|
}
|
|
2659
2664
|
}
|
|
2660
|
-
return
|
|
2665
|
+
if (!operationOrder?.length) return entries.map(({ section }) => section);
|
|
2666
|
+
const orderById = new Map(operationOrder.map((operationId, index) => [operationId, index]));
|
|
2667
|
+
return entries.map((entry, index) => ({
|
|
2668
|
+
...entry,
|
|
2669
|
+
index,
|
|
2670
|
+
order: entry.operationId ? orderById.get(entry.operationId) : void 0
|
|
2671
|
+
})).sort((left, right) => (left.order ?? operationOrder.length) - (right.order ?? operationOrder.length) || left.index - right.index).map(({ section }) => section);
|
|
2661
2672
|
}
|
|
2662
2673
|
async function readOpenAPISpec(filePath, contentProcessor, projectRoot) {
|
|
2663
2674
|
try {
|
|
@@ -2704,7 +2715,7 @@ function collectOpenAPIPageIntents(config) {
|
|
|
2704
2715
|
continue;
|
|
2705
2716
|
}
|
|
2706
2717
|
const intent = routeIntentFromPagesItem(item);
|
|
2707
|
-
if (intent.kind === "openapi" && (intent.path || intent.tagFilter?.length)) intents.push(intent);
|
|
2718
|
+
if (intent.kind === "openapi" && (intent.path || intent.tagFilter?.length || intent.operationOrder?.length)) intents.push(intent);
|
|
2708
2719
|
}
|
|
2709
2720
|
}
|
|
2710
2721
|
function visitPages(pages) {
|
|
@@ -2725,7 +2736,8 @@ function cloneOpenAPIRoute(route, overrides = {}) {
|
|
|
2725
2736
|
source: { ...route.source },
|
|
2726
2737
|
openapi: route.openapi ? {
|
|
2727
2738
|
...route.openapi,
|
|
2728
|
-
tagFilter: route.openapi.tagFilter ? [...route.openapi.tagFilter] : void 0
|
|
2739
|
+
tagFilter: route.openapi.tagFilter ? [...route.openapi.tagFilter] : void 0,
|
|
2740
|
+
operationOrder: route.openapi.operationOrder ? [...route.openapi.operationOrder] : void 0
|
|
2729
2741
|
} : void 0,
|
|
2730
2742
|
alternates: route.alternates ? { ...route.alternates } : void 0,
|
|
2731
2743
|
...overrides
|
|
@@ -2774,9 +2786,21 @@ function expandConfiguredOpenAPIRoutes(routes, config) {
|
|
|
2774
2786
|
const existingKeys = new Set(routes.map((route) => `${route.locale ?? ""}:${route.basePath ?? route.path}`));
|
|
2775
2787
|
for (const intent of openAPIIntents) {
|
|
2776
2788
|
const tagFilter = intent.tagFilter?.filter(Boolean);
|
|
2789
|
+
const operationOrder = intent.operationOrder?.filter(Boolean);
|
|
2777
2790
|
const sourceBasePath = openAPIPagePathFromRef(intent.ref);
|
|
2778
2791
|
const targetBasePath = openAPIPagePathFromRef(intent.ref, tagFilter, intent.path);
|
|
2779
|
-
if (sourceBasePath === targetBasePath && !tagFilter?.length)
|
|
2792
|
+
if (sourceBasePath === targetBasePath && !tagFilter?.length) {
|
|
2793
|
+
if (!operationOrder?.length) continue;
|
|
2794
|
+
for (let index = 0; index < routes.length; index++) {
|
|
2795
|
+
const route = routes[index];
|
|
2796
|
+
if (route.kind !== "openapi" || (route.basePath ?? route.path) !== sourceBasePath) continue;
|
|
2797
|
+
routes[index] = cloneOpenAPIRoute(route, { openapi: {
|
|
2798
|
+
...route.openapi,
|
|
2799
|
+
operationOrder: [...operationOrder]
|
|
2800
|
+
} });
|
|
2801
|
+
}
|
|
2802
|
+
continue;
|
|
2803
|
+
}
|
|
2780
2804
|
for (const route of routes) {
|
|
2781
2805
|
if (route.kind !== "openapi" || (route.basePath ?? route.path) !== sourceBasePath) continue;
|
|
2782
2806
|
const key = `${route.locale ?? ""}:${targetBasePath}`;
|
|
@@ -2789,7 +2813,8 @@ function expandConfiguredOpenAPIRoutes(routes, config) {
|
|
|
2789
2813
|
module: { pageVirtualModuleId: pageVirtualModuleId(path) },
|
|
2790
2814
|
openapi: {
|
|
2791
2815
|
...route.openapi,
|
|
2792
|
-
tagFilter: tagFilter?.length ? tagFilter : void 0
|
|
2816
|
+
tagFilter: tagFilter?.length ? tagFilter : void 0,
|
|
2817
|
+
operationOrder: operationOrder?.length ? [...operationOrder] : void 0
|
|
2793
2818
|
}
|
|
2794
2819
|
}));
|
|
2795
2820
|
}
|
|
@@ -2831,10 +2856,11 @@ function generateOpenAPISpecModule(spec) {
|
|
|
2831
2856
|
return `export default ${JSON.stringify(spec)};`;
|
|
2832
2857
|
}
|
|
2833
2858
|
function generateOpenAPIPageModule(opts) {
|
|
2859
|
+
const routeData = opts.operationOrder?.length ? { operationOrder: opts.operationOrder } : {};
|
|
2834
2860
|
return `import { createOpenApiRouteComponent } from '@clarify-labs/renderer';
|
|
2835
2861
|
import spec from ${JSON.stringify(opts.specModuleId)};
|
|
2836
2862
|
|
|
2837
|
-
export const routeData = {};
|
|
2863
|
+
export const routeData = ${JSON.stringify(routeData)};
|
|
2838
2864
|
|
|
2839
2865
|
export default createOpenApiRouteComponent({ ...routeData, spec });
|
|
2840
2866
|
`;
|
|
@@ -2894,7 +2920,7 @@ var OpenAPIPluginState = class {
|
|
|
2894
2920
|
route.meta.title = spec.info?.title ?? route.meta.title;
|
|
2895
2921
|
route.meta.description = spec.info?.description ?? route.meta.description;
|
|
2896
2922
|
route.meta.updatedAt = updatedAt;
|
|
2897
|
-
route.meta.sections = extractOpenAPISections(spec, route.openapi.tagFilter);
|
|
2923
|
+
route.meta.sections = extractOpenAPISections(spec, route.openapi.tagFilter, route.openapi.operationOrder);
|
|
2898
2924
|
const pageSpec = route.openapi.tagFilter?.length ? filterSpecByTags(specWithMetadata, route.openapi.tagFilter) : specWithMetadata;
|
|
2899
2925
|
const routeSpecModuleId = routeSpecModuleIdFromSourceSpecId(sourceSpecId, route.openapi.tagFilter);
|
|
2900
2926
|
route.openapi.routeSpecModuleId = routeSpecModuleId;
|
|
@@ -2928,7 +2954,10 @@ var OpenAPIPluginState = class {
|
|
|
2928
2954
|
if (!route.openapi?.sourceSpecId) continue;
|
|
2929
2955
|
const routeSpecModuleId = route.openapi.routeSpecModuleId ?? route.openapi.sourceSpecId;
|
|
2930
2956
|
if (!this.specModules.has(routeSpecModuleId)) continue;
|
|
2931
|
-
modules.set(route.module.pageVirtualModuleId, generateOpenAPIPageModule({
|
|
2957
|
+
modules.set(route.module.pageVirtualModuleId, generateOpenAPIPageModule({
|
|
2958
|
+
specModuleId: specVirtualModuleId(routeSpecModuleId),
|
|
2959
|
+
operationOrder: route.openapi.operationOrder
|
|
2960
|
+
}));
|
|
2932
2961
|
}
|
|
2933
2962
|
return modules;
|
|
2934
2963
|
}
|
|
@@ -4276,4 +4305,4 @@ Object.defineProperty(exports, "searchMcpIndex", {
|
|
|
4276
4305
|
}
|
|
4277
4306
|
});
|
|
4278
4307
|
|
|
4279
|
-
//# sourceMappingURL=engine-
|
|
4308
|
+
//# sourceMappingURL=engine-0ROqtF4o.cjs.map
|