@clarify-labs/renderer 0.9.3 → 0.9.4

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.
Files changed (44) hide show
  1. package/output/{ClarifyShell-Dm--LZco.cjs → ClarifyShell-7r92MZg9.cjs} +109 -72
  2. package/output/ClarifyShell-7r92MZg9.cjs.map +1 -0
  3. package/output/{ClarifyShell-BQ29N8P5.js → ClarifyShell-D2P0iZ_m.js} +104 -73
  4. package/output/ClarifyShell-D2P0iZ_m.js.map +1 -0
  5. package/output/{OpenApiOperation-DIWGdw29.cjs → OpenApiOperation-CyyPlZL6.cjs} +100 -26
  6. package/output/OpenApiOperation-CyyPlZL6.cjs.map +1 -0
  7. package/output/{OpenApiOperation-C9xyRo5a.js → OpenApiOperation-Dhlz3JSx.js} +100 -26
  8. package/output/OpenApiOperation-Dhlz3JSx.js.map +1 -0
  9. package/output/{PageActions-DEuFHgyB.cjs → PageActions-CTn2XkPg.cjs} +12 -3
  10. package/output/PageActions-CTn2XkPg.cjs.map +1 -0
  11. package/output/{PageActions-B_tSec1f.js → PageActions-D0PA8Zv5.js} +7 -4
  12. package/output/PageActions-D0PA8Zv5.js.map +1 -0
  13. package/output/app/ContentDiagnostic.d.ts +9 -0
  14. package/output/app/ErrorBoundary.d.ts +0 -2
  15. package/output/app/RenderErrorPanel.d.ts +20 -0
  16. package/output/client.cjs +3 -3
  17. package/output/client.js +3 -3
  18. package/output/core/context.d.ts +1 -0
  19. package/output/core/i18n.d.ts +1 -1
  20. package/output/core/types.d.ts +1 -0
  21. package/output/index.cjs +43 -4
  22. package/output/index.cjs.map +1 -1
  23. package/output/index.d.ts +5 -3
  24. package/output/index.js +42 -5
  25. package/output/index.js.map +1 -1
  26. package/output/openapi/components/SchemaProperties.d.ts +1 -0
  27. package/output/openapi/entry.d.ts +5 -0
  28. package/output/openapi/index.d.ts +2 -2
  29. package/output/preview.cjs +2 -2
  30. package/output/preview.js +2 -2
  31. package/output/{render-CEWLJSmt.js → render-CwSsfrs7.js} +2 -2
  32. package/output/{render-CEWLJSmt.js.map → render-CwSsfrs7.js.map} +1 -1
  33. package/output/{render-BCGK1WpS.cjs → render-DXDSIfZ8.cjs} +2 -2
  34. package/output/{render-BCGK1WpS.cjs.map → render-DXDSIfZ8.cjs.map} +1 -1
  35. package/output/renderer.css +4 -0
  36. package/output/server.cjs +2 -2
  37. package/output/server.js +2 -2
  38. package/package.json +1 -1
  39. package/output/ClarifyShell-BQ29N8P5.js.map +0 -1
  40. package/output/ClarifyShell-Dm--LZco.cjs.map +0 -1
  41. package/output/OpenApiOperation-C9xyRo5a.js.map +0 -1
  42. package/output/OpenApiOperation-DIWGdw29.cjs.map +0 -1
  43. package/output/PageActions-B_tSec1f.js.map +0 -1
  44. package/output/PageActions-DEuFHgyB.cjs.map +0 -1
@@ -1,4 +1,4 @@
1
- import { C as isExternalHref, D as useBuiltInText, E as copyTextToClipboard, M as useLocale, c as lucideIconRegistry, h as useTheme, j as useConfig, l as resolveLucideIconName, n as PageTitleActions, o as useSectionStore, s as remToPx, w as localizeHref } from "./PageActions-B_tSec1f.js";
1
+ import { C as isExternalHref, D as useBuiltInText, E as copyTextToClipboard, N as useLocale, c as lucideIconRegistry, h as useTheme, j as useConfig, l as resolveLucideIconName, n as PageTitleActions, o as useSectionStore, s as remToPx, w as localizeHref } from "./PageActions-D0PA8Zv5.js";
2
2
  import { t as markdownRemarkPlugins } from "./remark-Dd2WU50s.js";
3
3
  import clsx from "clsx";
4
4
  import { Children, createContext, createElement, forwardRef, isValidElement, useContext, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
@@ -1312,10 +1312,10 @@ function schemaToType(schema) {
1312
1312
  if (!isRecord(schema)) return void 0;
1313
1313
  if (isReference(schema)) return resolveReferenceName(schema.$ref);
1314
1314
  if (typeof schema.const !== "undefined") return JSON.stringify(schema.const);
1315
- if (Array.isArray(schema.enum)) return schema.enum.map(String).join(" | ");
1315
+ if (Array.isArray(schema.enum)) return "enum";
1316
1316
  const oneOf = schema.oneOf ?? schema.anyOf;
1317
- if (Array.isArray(oneOf)) return oneOf.map(schemaToType).filter(Boolean).join(" | ");
1318
- if (Array.isArray(schema.allOf)) return schema.allOf.map(schemaToType).filter(Boolean).join(" & ");
1317
+ if (Array.isArray(oneOf)) return oneOf.map((branch) => schemaToType(branch)).filter(Boolean).join(" | ");
1318
+ if (Array.isArray(schema.allOf)) return schema.allOf.map((branch) => schemaToType(branch)).filter(Boolean).join(" & ");
1319
1319
  if (schemaHasType(schema, "array")) return `${schemaToType(schema.items) ?? "unknown"}[]`;
1320
1320
  const type = Array.isArray(schema.type) ? schema.type.map(String).join(" | ") : schema.type;
1321
1321
  return typeof type === "string" ? [type, typeof schema.format === "string" ? `<${schema.format}>` : void 0].filter(Boolean).join("") : void 0;
@@ -2217,9 +2217,17 @@ function ResponseExamplesPanel(arg0) {
2217
2217
  }
2218
2218
  //#endregion
2219
2219
  //#region source/openapi/components/SchemaProperties.tsx
2220
+ function getEnumDescriptions(schema) {
2221
+ const descriptions = schema["x-enumDescriptions"];
2222
+ if (Array.isArray(descriptions)) return descriptions.map((value) => typeof value === "string" ? value : void 0);
2223
+ if (isRecord(descriptions)) return Array.isArray(schema.enum) ? schema.enum.map((value) => {
2224
+ const description = descriptions[String(value)];
2225
+ return typeof description === "string" ? description : void 0;
2226
+ }) : [];
2227
+ return [];
2228
+ }
2220
2229
  function getSchemaDetails(schema) {
2221
2230
  const details = [
2222
- Array.isArray(schema.enum) ? `enum: ${schema.enum.map(String).join(", ")}` : void 0,
2223
2231
  typeof schema.const !== "undefined" ? `const: ${String(schema.const)}` : void 0,
2224
2232
  typeof schema.default !== "undefined" ? `default: ${String(schema.default)}` : void 0,
2225
2233
  typeof schema.pattern === "string" ? `pattern: ${schema.pattern}` : void 0,
@@ -2232,6 +2240,21 @@ function getSchemaDetails(schema) {
2232
2240
  function getSchemaDescription(schema) {
2233
2241
  return typeof schema.description === "string" ? schema.description : void 0;
2234
2242
  }
2243
+ function getSchemaNodeType(schema) {
2244
+ return schemaToType(schema);
2245
+ }
2246
+ function getEnumChildren(schema, path) {
2247
+ if (!Array.isArray(schema.enum) || schema.enum.length === 0) return [];
2248
+ const descriptions = getEnumDescriptions(schema);
2249
+ return schema.enum.map((value, index) => ({
2250
+ key: `${path || "root"}.enum[${index}]`,
2251
+ name: String(value),
2252
+ kind: "enum",
2253
+ description: descriptions[index],
2254
+ required: false,
2255
+ children: []
2256
+ }));
2257
+ }
2235
2258
  function getComposedBranches(schema) {
2236
2259
  const entries = [];
2237
2260
  for (const key of [
@@ -2249,7 +2272,7 @@ function getComposedBranches(schema) {
2249
2272
  return entries;
2250
2273
  }
2251
2274
  function getSchemaChildren(arg0) {
2252
- const { spec, schema, path, required = [], depth = 0, seen = /* @__PURE__ */ new Set() } = arg0;
2275
+ const { spec, path, schema, depth = 0, required = [], seen = /* @__PURE__ */ new Set(), defaultExpanded } = arg0;
2253
2276
  if (depth > 12) return [];
2254
2277
  if (isReference(schema)) {
2255
2278
  if (seen.has(schema.$ref)) return [];
@@ -2259,7 +2282,8 @@ function getSchemaChildren(arg0) {
2259
2282
  path,
2260
2283
  required,
2261
2284
  depth,
2262
- seen: new Set([...seen, schema.$ref])
2285
+ seen: new Set([...seen, schema.$ref]),
2286
+ defaultExpanded
2263
2287
  });
2264
2288
  }
2265
2289
  if (!isRecord(schema)) return [];
@@ -2268,9 +2292,11 @@ function getSchemaChildren(arg0) {
2268
2292
  schema: schema.items,
2269
2293
  path: `${path}[]`,
2270
2294
  depth: depth + 1,
2271
- seen
2295
+ seen,
2296
+ defaultExpanded
2272
2297
  }) : [];
2273
2298
  const objectRequired = Array.isArray(schema.required) ? schema.required.map(String) : required;
2299
+ const enumChildren = getEnumChildren(schema, path);
2274
2300
  const properties = isRecord(schema.properties) ? schema.properties : {};
2275
2301
  const propertyChildren = Object.entries(properties).map(([name, propertySchema]) => {
2276
2302
  const resolvedProperty = resolveSchema(spec, propertySchema);
@@ -2282,31 +2308,38 @@ function getSchemaChildren(arg0) {
2282
2308
  schema: isArray ? property.items : propertySchema,
2283
2309
  path: isArray ? `${childPath}[]` : childPath,
2284
2310
  depth: depth + 1,
2285
- seen
2311
+ seen,
2312
+ defaultExpanded
2286
2313
  });
2314
+ const hasEnumValues = Array.isArray(property.enum) && property.enum.length > 0;
2287
2315
  return {
2288
2316
  key: childPath,
2289
2317
  name,
2290
- type: schemaToType(propertySchema),
2318
+ kind: "property",
2319
+ type: getSchemaNodeType(property),
2291
2320
  description: getSchemaDescription(property),
2292
2321
  details: getSchemaDetails(property),
2293
2322
  required: objectRequired.includes(name),
2323
+ defaultExpanded: hasEnumValues ? defaultExpanded === true : defaultExpanded ?? depth < 1,
2294
2324
  children
2295
2325
  };
2296
2326
  });
2297
2327
  const additionalPropertyChildren = isRecord(schema.additionalProperties) ? [{
2298
2328
  key: `${path || "root"}.*`,
2299
2329
  name: "*",
2300
- type: schemaToType(schema.additionalProperties),
2330
+ kind: "property",
2331
+ type: getSchemaNodeType(schema.additionalProperties),
2301
2332
  description: getSchemaDescription(schema.additionalProperties),
2302
2333
  details: getSchemaDetails(schema.additionalProperties),
2303
2334
  required: false,
2335
+ defaultExpanded: defaultExpanded ?? depth < 1,
2304
2336
  children: getSchemaChildren({
2305
2337
  spec,
2306
2338
  schema: schema.additionalProperties,
2307
2339
  path: `${path || "root"}.*`,
2308
2340
  depth: depth + 1,
2309
- seen
2341
+ seen,
2342
+ defaultExpanded
2310
2343
  })
2311
2344
  }] : [];
2312
2345
  const composedChildren = getComposedBranches(schema).map(({ label, schema: branchSchema }) => {
@@ -2315,35 +2348,40 @@ function getSchemaChildren(arg0) {
2315
2348
  return {
2316
2349
  key: `${path || "root"}.${label}`,
2317
2350
  name: label,
2318
- type: schemaToType(branchSchema),
2351
+ kind: "property",
2352
+ type: getSchemaNodeType(branch),
2319
2353
  description: branch ? getSchemaDescription(branch) : void 0,
2320
2354
  details: branch ? getSchemaDetails(branch) : void 0,
2321
2355
  required: false,
2356
+ defaultExpanded: defaultExpanded ?? depth < 1,
2322
2357
  children: getSchemaChildren({
2323
2358
  spec,
2324
2359
  schema: branchSchema,
2325
2360
  path: `${path || "root"}.${label}`,
2326
2361
  required: objectRequired,
2327
2362
  depth: depth + 1,
2328
- seen
2363
+ seen,
2364
+ defaultExpanded
2329
2365
  })
2330
2366
  };
2331
2367
  });
2332
2368
  return [
2333
2369
  ...arrayChildren,
2370
+ ...enumChildren,
2334
2371
  ...propertyChildren,
2335
2372
  ...additionalPropertyChildren,
2336
2373
  ...composedChildren
2337
2374
  ];
2338
2375
  }
2339
- function getRootSchemaNode(spec, schema) {
2376
+ function getRootSchemaNode(spec, schema, defaultExpanded) {
2340
2377
  if (isReference(schema)) {
2341
2378
  const resolvedSchema = resolveSchema(spec, schema);
2342
2379
  const resolved = isRecord(resolvedSchema) ? resolvedSchema : {};
2343
2380
  return {
2344
2381
  key: schema.$ref,
2345
2382
  name: resolveReferenceName(schema.$ref),
2346
- type: schemaToType(schema),
2383
+ kind: "property",
2384
+ type: getSchemaNodeType(resolved),
2347
2385
  description: getSchemaDescription(resolved),
2348
2386
  details: getSchemaDetails(resolved),
2349
2387
  required: false,
@@ -2351,7 +2389,8 @@ function getRootSchemaNode(spec, schema) {
2351
2389
  spec,
2352
2390
  schema: resolvedSchema,
2353
2391
  path: resolveReferenceName(schema.$ref),
2354
- seen: new Set([schema.$ref])
2392
+ seen: new Set([schema.$ref]),
2393
+ defaultExpanded
2355
2394
  })
2356
2395
  };
2357
2396
  }
@@ -2359,24 +2398,58 @@ function getRootSchemaNode(spec, schema) {
2359
2398
  return {
2360
2399
  key: "root",
2361
2400
  name: "body",
2362
- type: schemaToType(schema),
2401
+ kind: "property",
2402
+ type: getSchemaNodeType(schema),
2363
2403
  description: getSchemaDescription(schema),
2364
2404
  details: getSchemaDetails(schema),
2365
2405
  required: false,
2366
2406
  children: getSchemaChildren({
2367
2407
  spec,
2368
2408
  schema,
2369
- path: ""
2409
+ path: "",
2410
+ defaultExpanded
2370
2411
  })
2371
2412
  };
2372
2413
  }
2373
- function SchemaNode(arg0) {
2414
+ function EnumValueNode(arg0) {
2374
2415
  const { node, depth = 0 } = arg0;
2416
+ return /* @__PURE__ */ jsx("li", {
2417
+ className: "clarify-schema-node m-0 px-0 py-2 first:pt-0 last:pb-0",
2418
+ children: /* @__PURE__ */ jsx("div", {
2419
+ className: clsx("flex min-w-0 items-start rounded py-0.5 text-left", depth > 0 ? "-mx-2 w-(--clarify-schema-row-nested-width) px-2" : "w-full px-1"),
2420
+ children: /* @__PURE__ */ jsxs("div", {
2421
+ className: "min-w-0 flex-1",
2422
+ children: [/* @__PURE__ */ jsx("div", {
2423
+ className: "flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5",
2424
+ children: /* @__PURE__ */ jsx("span", {
2425
+ className: "text-sm/5 font-semibold text-(--clarify-theme-tokens-colors-foreground)",
2426
+ children: node.name
2427
+ })
2428
+ }), node.description || node.details ? /* @__PURE__ */ jsxs("div", {
2429
+ className: "mt-0.5 text-sm/5 text-(--clarify-ui-text-soft) *:first:mt-0 *:last:mb-0",
2430
+ children: [node.description ? /* @__PURE__ */ jsx(Markdown, {
2431
+ className: "*:first:mt-0 *:last:mb-0",
2432
+ children: node.description
2433
+ }) : null, node.details ? /* @__PURE__ */ jsx("p", {
2434
+ className: "text-xs text-(--clarify-ui-text-faint)",
2435
+ children: node.details
2436
+ }) : null]
2437
+ }) : null]
2438
+ })
2439
+ })
2440
+ });
2441
+ }
2442
+ function SchemaNode(arg0) {
2443
+ const { node, depth = 0, defaultExpanded } = arg0;
2375
2444
  const t = useBuiltInText();
2376
- const [expanded, setExpanded] = useState(depth < 1);
2445
+ const [expanded, setExpanded] = useState(defaultExpanded ?? depth < 1);
2377
2446
  const hasChildren = node.children.length > 0;
2447
+ if (node.kind === "enum") return /* @__PURE__ */ jsx(EnumValueNode, {
2448
+ node,
2449
+ depth
2450
+ });
2378
2451
  const type = [node.type, node.required ? t("openapi.requiredBadge") : void 0].filter(Boolean).join(", ") || void 0;
2379
- const fallbackDescription = node.required ? t("openapi.required") : t("openapi.optional");
2452
+ const fallbackDescription = hasChildren ? void 0 : node.required ? t("openapi.required") : t("openapi.optional");
2380
2453
  const rowClassName = clsx("flex min-w-0 items-start rounded py-0.5 text-left", depth > 0 ? "-mx-2 w-(--clarify-schema-row-nested-width) px-2" : "w-full px-1");
2381
2454
  const content = /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("div", {
2382
2455
  className: "min-w-0 flex-1",
@@ -2430,13 +2503,14 @@ function SchemaTree(arg0) {
2430
2503
  className: clsx("m-0 list-none divide-y divide-(--clarify-theme-tokens-colors-border) p-0", depth > 0 && "mt-2 rounded-lg bg-(--clarify-ui-subtle-background) px-2 py-1"),
2431
2504
  children: nodes.map((node) => /* @__PURE__ */ jsx(SchemaNode, {
2432
2505
  node,
2433
- depth
2506
+ depth,
2507
+ defaultExpanded: node.defaultExpanded
2434
2508
  }, node.key))
2435
2509
  });
2436
2510
  }
2437
2511
  function SchemaProperties(arg0) {
2438
- const { title, schema, spec } = arg0;
2439
- const root = getRootSchemaNode(spec, schema);
2512
+ const { title, schema, spec, defaultExpanded } = arg0;
2513
+ const root = getRootSchemaNode(spec, schema, defaultExpanded);
2440
2514
  if (!root || root.children.length === 0) return null;
2441
2515
  return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", { children: title }), /* @__PURE__ */ jsx("div", {
2442
2516
  className: "clarify-schema-properties my-6",
@@ -3082,4 +3156,4 @@ function OpenApiOperation(arg0) {
3082
3156
  //#endregion
3083
3157
  export { Button as A, Code as C, Card as D, Mermaid as E, CardGroup as O, Collapse as S, Pre as T, HeroPattern as _, authPlaceholder as a, Tag as b, getServerKey as c, getRequestBody$1 as d, Markdown as f, GridPattern as g, Prose as h, ResponseExamplesPanel as i, Callout as k, getServers as l, WebFrame as m, OpenApiOperation as n, defaultServerVariables as o, primitives_exports as p, RequestExamplesPanel as r, getAuthOptions as s, EndpointIdentity as t, getMediaTypeEntries as u, Logo as v, CodeGroup as w, Feedback as x, Heading as y };
3084
3158
 
3085
- //# sourceMappingURL=OpenApiOperation-C9xyRo5a.js.map
3159
+ //# sourceMappingURL=OpenApiOperation-Dhlz3JSx.js.map