@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.
@@ -647,6 +647,7 @@ function routeIntentFromPagesItem(item) {
647
647
  kind: "openapi",
648
648
  ref: item.openapi,
649
649
  tagFilter: item.filter?.tags,
650
+ operationOrder: item.operationOrder,
650
651
  path: item.path,
651
652
  title: item.title,
652
653
  icon: item.icon
@@ -1113,6 +1114,7 @@ var clarifyPagesItemSchema = z.lazy(() => z.union([
1113
1114
  z.object({
1114
1115
  openapi: z.string(),
1115
1116
  path: z.string().optional(),
1117
+ operationOrder: z.array(z.string()).optional(),
1116
1118
  icon: z.string().optional(),
1117
1119
  title: clarifyLocalizedTextSchema.optional(),
1118
1120
  filter: z.object({ tags: z.array(z.string()).optional() }).strict().optional()
@@ -1788,7 +1790,7 @@ function createViteAdapter(engine) {
1788
1790
  }
1789
1791
  var cliPackageVersion = {
1790
1792
  name: "@clarify-labs/cli",
1791
- version: "0.11.17",
1793
+ version: "0.11.19",
1792
1794
  license: "AGPL-3.0-only",
1793
1795
  type: "module",
1794
1796
  repository: {
@@ -2597,9 +2599,9 @@ function filterSpecByTags(spec, tags) {
2597
2599
  };
2598
2600
  }
2599
2601
  /** Extract endpoint operations from an OpenAPI spec as page sections. */
2600
- function extractOpenAPISections(spec, filterTags) {
2602
+ function extractOpenAPISections(spec, filterTags, operationOrder) {
2601
2603
  normalizeOpenAPISpecSectionIds(spec);
2602
- const sections = [];
2604
+ const entries = [];
2603
2605
  const items = [...Object.entries(spec.paths ?? {}).map(([path, pathItem]) => ({
2604
2606
  path,
2605
2607
  pathItem,
@@ -2617,16 +2619,25 @@ function extractOpenAPISections(spec, filterTags) {
2617
2619
  const tags = Array.isArray(op?.tags) ? op.tags : void 0;
2618
2620
  if (!op || !operationMatchesTags(tags, filterTags)) continue;
2619
2621
  const title = typeof op.summary === "string" ? op.summary : `${method.toUpperCase()} ${path}`;
2620
- sections.push({
2621
- id: operationSectionId(op),
2622
- title,
2623
- level: 2,
2624
- badge: kind === "webhook" ? "WEBHOOK" : method.toUpperCase(),
2625
- tags
2622
+ entries.push({
2623
+ section: {
2624
+ id: operationSectionId(op),
2625
+ title,
2626
+ level: 2,
2627
+ badge: kind === "webhook" ? "WEBHOOK" : method.toUpperCase(),
2628
+ tags
2629
+ },
2630
+ operationId: typeof op.operationId === "string" ? op.operationId : void 0
2626
2631
  });
2627
2632
  }
2628
2633
  }
2629
- return sections;
2634
+ if (!operationOrder?.length) return entries.map(({ section }) => section);
2635
+ const orderById = new Map(operationOrder.map((operationId, index) => [operationId, index]));
2636
+ return entries.map((entry, index) => ({
2637
+ ...entry,
2638
+ index,
2639
+ order: entry.operationId ? orderById.get(entry.operationId) : void 0
2640
+ })).sort((left, right) => (left.order ?? operationOrder.length) - (right.order ?? operationOrder.length) || left.index - right.index).map(({ section }) => section);
2630
2641
  }
2631
2642
  async function readOpenAPISpec(filePath, contentProcessor, projectRoot) {
2632
2643
  try {
@@ -2673,7 +2684,7 @@ function collectOpenAPIPageIntents(config) {
2673
2684
  continue;
2674
2685
  }
2675
2686
  const intent = routeIntentFromPagesItem(item);
2676
- if (intent.kind === "openapi" && (intent.path || intent.tagFilter?.length)) intents.push(intent);
2687
+ if (intent.kind === "openapi" && (intent.path || intent.tagFilter?.length || intent.operationOrder?.length)) intents.push(intent);
2677
2688
  }
2678
2689
  }
2679
2690
  function visitPages(pages) {
@@ -2694,7 +2705,8 @@ function cloneOpenAPIRoute(route, overrides = {}) {
2694
2705
  source: { ...route.source },
2695
2706
  openapi: route.openapi ? {
2696
2707
  ...route.openapi,
2697
- tagFilter: route.openapi.tagFilter ? [...route.openapi.tagFilter] : void 0
2708
+ tagFilter: route.openapi.tagFilter ? [...route.openapi.tagFilter] : void 0,
2709
+ operationOrder: route.openapi.operationOrder ? [...route.openapi.operationOrder] : void 0
2698
2710
  } : void 0,
2699
2711
  alternates: route.alternates ? { ...route.alternates } : void 0,
2700
2712
  ...overrides
@@ -2743,9 +2755,21 @@ function expandConfiguredOpenAPIRoutes(routes, config) {
2743
2755
  const existingKeys = new Set(routes.map((route) => `${route.locale ?? ""}:${route.basePath ?? route.path}`));
2744
2756
  for (const intent of openAPIIntents) {
2745
2757
  const tagFilter = intent.tagFilter?.filter(Boolean);
2758
+ const operationOrder = intent.operationOrder?.filter(Boolean);
2746
2759
  const sourceBasePath = openAPIPagePathFromRef(intent.ref);
2747
2760
  const targetBasePath = openAPIPagePathFromRef(intent.ref, tagFilter, intent.path);
2748
- if (sourceBasePath === targetBasePath && !tagFilter?.length) continue;
2761
+ if (sourceBasePath === targetBasePath && !tagFilter?.length) {
2762
+ if (!operationOrder?.length) continue;
2763
+ for (let index = 0; index < routes.length; index++) {
2764
+ const route = routes[index];
2765
+ if (route.kind !== "openapi" || (route.basePath ?? route.path) !== sourceBasePath) continue;
2766
+ routes[index] = cloneOpenAPIRoute(route, { openapi: {
2767
+ ...route.openapi,
2768
+ operationOrder: [...operationOrder]
2769
+ } });
2770
+ }
2771
+ continue;
2772
+ }
2749
2773
  for (const route of routes) {
2750
2774
  if (route.kind !== "openapi" || (route.basePath ?? route.path) !== sourceBasePath) continue;
2751
2775
  const key = `${route.locale ?? ""}:${targetBasePath}`;
@@ -2758,7 +2782,8 @@ function expandConfiguredOpenAPIRoutes(routes, config) {
2758
2782
  module: { pageVirtualModuleId: pageVirtualModuleId(path) },
2759
2783
  openapi: {
2760
2784
  ...route.openapi,
2761
- tagFilter: tagFilter?.length ? tagFilter : void 0
2785
+ tagFilter: tagFilter?.length ? tagFilter : void 0,
2786
+ operationOrder: operationOrder?.length ? [...operationOrder] : void 0
2762
2787
  }
2763
2788
  }));
2764
2789
  }
@@ -2800,10 +2825,11 @@ function generateOpenAPISpecModule(spec) {
2800
2825
  return `export default ${JSON.stringify(spec)};`;
2801
2826
  }
2802
2827
  function generateOpenAPIPageModule(opts) {
2828
+ const routeData = opts.operationOrder?.length ? { operationOrder: opts.operationOrder } : {};
2803
2829
  return `import { createOpenApiRouteComponent } from '@clarify-labs/renderer';
2804
2830
  import spec from ${JSON.stringify(opts.specModuleId)};
2805
2831
 
2806
- export const routeData = {};
2832
+ export const routeData = ${JSON.stringify(routeData)};
2807
2833
 
2808
2834
  export default createOpenApiRouteComponent({ ...routeData, spec });
2809
2835
  `;
@@ -2863,7 +2889,7 @@ var OpenAPIPluginState = class {
2863
2889
  route.meta.title = spec.info?.title ?? route.meta.title;
2864
2890
  route.meta.description = spec.info?.description ?? route.meta.description;
2865
2891
  route.meta.updatedAt = updatedAt;
2866
- route.meta.sections = extractOpenAPISections(spec, route.openapi.tagFilter);
2892
+ route.meta.sections = extractOpenAPISections(spec, route.openapi.tagFilter, route.openapi.operationOrder);
2867
2893
  const pageSpec = route.openapi.tagFilter?.length ? filterSpecByTags(specWithMetadata, route.openapi.tagFilter) : specWithMetadata;
2868
2894
  const routeSpecModuleId = routeSpecModuleIdFromSourceSpecId(sourceSpecId, route.openapi.tagFilter);
2869
2895
  route.openapi.routeSpecModuleId = routeSpecModuleId;
@@ -2897,7 +2923,10 @@ var OpenAPIPluginState = class {
2897
2923
  if (!route.openapi?.sourceSpecId) continue;
2898
2924
  const routeSpecModuleId = route.openapi.routeSpecModuleId ?? route.openapi.sourceSpecId;
2899
2925
  if (!this.specModules.has(routeSpecModuleId)) continue;
2900
- modules.set(route.module.pageVirtualModuleId, generateOpenAPIPageModule({ specModuleId: specVirtualModuleId(routeSpecModuleId) }));
2926
+ modules.set(route.module.pageVirtualModuleId, generateOpenAPIPageModule({
2927
+ specModuleId: specVirtualModuleId(routeSpecModuleId),
2928
+ operationOrder: route.openapi.operationOrder
2929
+ }));
2901
2930
  }
2902
2931
  return modules;
2903
2932
  }
@@ -4174,4 +4203,4 @@ function createClarifyEngine(options = {}) {
4174
4203
  //#endregion
4175
4204
  export { createClarifyTempDir as a, cliPackageVersion as c, createViteAdapter as d, defineConfig as f, findRouteConflicts as i, cliPackageVersionWithCaret as l, createClarifyEngine as n, deserializeSearchIndex as o, createClarifyRuntimeAliases as r, searchMcpIndex as s, ClarifyEngine as t, printCliVersion as u };
4176
4205
 
4177
- //# sourceMappingURL=engine-CIhcMyvD.js.map
4206
+ //# sourceMappingURL=engine-DH8Hi6Fr.js.map