@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.
- package/output/{ClarifyShell-Dm--LZco.cjs → ClarifyShell-7r92MZg9.cjs} +109 -72
- package/output/ClarifyShell-7r92MZg9.cjs.map +1 -0
- package/output/{ClarifyShell-BQ29N8P5.js → ClarifyShell-D2P0iZ_m.js} +104 -73
- package/output/ClarifyShell-D2P0iZ_m.js.map +1 -0
- package/output/{OpenApiOperation-DIWGdw29.cjs → OpenApiOperation-CyyPlZL6.cjs} +100 -26
- package/output/OpenApiOperation-CyyPlZL6.cjs.map +1 -0
- package/output/{OpenApiOperation-C9xyRo5a.js → OpenApiOperation-Dhlz3JSx.js} +100 -26
- package/output/OpenApiOperation-Dhlz3JSx.js.map +1 -0
- package/output/{PageActions-DEuFHgyB.cjs → PageActions-CTn2XkPg.cjs} +12 -3
- package/output/PageActions-CTn2XkPg.cjs.map +1 -0
- package/output/{PageActions-B_tSec1f.js → PageActions-D0PA8Zv5.js} +7 -4
- package/output/PageActions-D0PA8Zv5.js.map +1 -0
- package/output/app/ContentDiagnostic.d.ts +9 -0
- package/output/app/ErrorBoundary.d.ts +0 -2
- package/output/app/RenderErrorPanel.d.ts +20 -0
- package/output/client.cjs +3 -3
- package/output/client.js +3 -3
- package/output/core/context.d.ts +1 -0
- package/output/core/i18n.d.ts +1 -1
- package/output/core/types.d.ts +1 -0
- package/output/index.cjs +43 -4
- package/output/index.cjs.map +1 -1
- package/output/index.d.ts +5 -3
- package/output/index.js +42 -5
- package/output/index.js.map +1 -1
- package/output/openapi/components/SchemaProperties.d.ts +1 -0
- package/output/openapi/entry.d.ts +5 -0
- package/output/openapi/index.d.ts +2 -2
- package/output/preview.cjs +2 -2
- package/output/preview.js +2 -2
- package/output/{render-CEWLJSmt.js → render-CwSsfrs7.js} +2 -2
- package/output/{render-CEWLJSmt.js.map → render-CwSsfrs7.js.map} +1 -1
- package/output/{render-BCGK1WpS.cjs → render-DXDSIfZ8.cjs} +2 -2
- package/output/{render-BCGK1WpS.cjs.map → render-DXDSIfZ8.cjs.map} +1 -1
- package/output/renderer.css +4 -0
- package/output/server.cjs +2 -2
- package/output/server.js +2 -2
- package/package.json +1 -1
- package/output/ClarifyShell-BQ29N8P5.js.map +0 -1
- package/output/ClarifyShell-Dm--LZco.cjs.map +0 -1
- package/output/OpenApiOperation-C9xyRo5a.js.map +0 -1
- package/output/OpenApiOperation-DIWGdw29.cjs.map +0 -1
- package/output/PageActions-B_tSec1f.js.map +0 -1
- package/output/PageActions-DEuFHgyB.cjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-DakpK96I.cjs");
|
|
2
|
-
const require_PageActions = require("./PageActions-
|
|
2
|
+
const require_PageActions = require("./PageActions-CTn2XkPg.cjs");
|
|
3
3
|
const require_remark = require("./remark-Dv3owbSH.cjs");
|
|
4
4
|
let clsx = require("clsx");
|
|
5
5
|
clsx = require_chunk.__toESM(clsx, 1);
|
|
@@ -1303,10 +1303,10 @@ function schemaToType(schema) {
|
|
|
1303
1303
|
if (!isRecord(schema)) return void 0;
|
|
1304
1304
|
if (isReference(schema)) return resolveReferenceName(schema.$ref);
|
|
1305
1305
|
if (typeof schema.const !== "undefined") return JSON.stringify(schema.const);
|
|
1306
|
-
if (Array.isArray(schema.enum)) return
|
|
1306
|
+
if (Array.isArray(schema.enum)) return "enum";
|
|
1307
1307
|
const oneOf = schema.oneOf ?? schema.anyOf;
|
|
1308
|
-
if (Array.isArray(oneOf)) return oneOf.map(schemaToType).filter(Boolean).join(" | ");
|
|
1309
|
-
if (Array.isArray(schema.allOf)) return schema.allOf.map(schemaToType).filter(Boolean).join(" & ");
|
|
1308
|
+
if (Array.isArray(oneOf)) return oneOf.map((branch) => schemaToType(branch)).filter(Boolean).join(" | ");
|
|
1309
|
+
if (Array.isArray(schema.allOf)) return schema.allOf.map((branch) => schemaToType(branch)).filter(Boolean).join(" & ");
|
|
1310
1310
|
if (schemaHasType(schema, "array")) return `${schemaToType(schema.items) ?? "unknown"}[]`;
|
|
1311
1311
|
const type = Array.isArray(schema.type) ? schema.type.map(String).join(" | ") : schema.type;
|
|
1312
1312
|
return typeof type === "string" ? [type, typeof schema.format === "string" ? `<${schema.format}>` : void 0].filter(Boolean).join("") : void 0;
|
|
@@ -2208,9 +2208,17 @@ function ResponseExamplesPanel(arg0) {
|
|
|
2208
2208
|
}
|
|
2209
2209
|
//#endregion
|
|
2210
2210
|
//#region source/openapi/components/SchemaProperties.tsx
|
|
2211
|
+
function getEnumDescriptions(schema) {
|
|
2212
|
+
const descriptions = schema["x-enumDescriptions"];
|
|
2213
|
+
if (Array.isArray(descriptions)) return descriptions.map((value) => typeof value === "string" ? value : void 0);
|
|
2214
|
+
if (isRecord(descriptions)) return Array.isArray(schema.enum) ? schema.enum.map((value) => {
|
|
2215
|
+
const description = descriptions[String(value)];
|
|
2216
|
+
return typeof description === "string" ? description : void 0;
|
|
2217
|
+
}) : [];
|
|
2218
|
+
return [];
|
|
2219
|
+
}
|
|
2211
2220
|
function getSchemaDetails(schema) {
|
|
2212
2221
|
const details = [
|
|
2213
|
-
Array.isArray(schema.enum) ? `enum: ${schema.enum.map(String).join(", ")}` : void 0,
|
|
2214
2222
|
typeof schema.const !== "undefined" ? `const: ${String(schema.const)}` : void 0,
|
|
2215
2223
|
typeof schema.default !== "undefined" ? `default: ${String(schema.default)}` : void 0,
|
|
2216
2224
|
typeof schema.pattern === "string" ? `pattern: ${schema.pattern}` : void 0,
|
|
@@ -2223,6 +2231,21 @@ function getSchemaDetails(schema) {
|
|
|
2223
2231
|
function getSchemaDescription(schema) {
|
|
2224
2232
|
return typeof schema.description === "string" ? schema.description : void 0;
|
|
2225
2233
|
}
|
|
2234
|
+
function getSchemaNodeType(schema) {
|
|
2235
|
+
return schemaToType(schema);
|
|
2236
|
+
}
|
|
2237
|
+
function getEnumChildren(schema, path) {
|
|
2238
|
+
if (!Array.isArray(schema.enum) || schema.enum.length === 0) return [];
|
|
2239
|
+
const descriptions = getEnumDescriptions(schema);
|
|
2240
|
+
return schema.enum.map((value, index) => ({
|
|
2241
|
+
key: `${path || "root"}.enum[${index}]`,
|
|
2242
|
+
name: String(value),
|
|
2243
|
+
kind: "enum",
|
|
2244
|
+
description: descriptions[index],
|
|
2245
|
+
required: false,
|
|
2246
|
+
children: []
|
|
2247
|
+
}));
|
|
2248
|
+
}
|
|
2226
2249
|
function getComposedBranches(schema) {
|
|
2227
2250
|
const entries = [];
|
|
2228
2251
|
for (const key of [
|
|
@@ -2240,7 +2263,7 @@ function getComposedBranches(schema) {
|
|
|
2240
2263
|
return entries;
|
|
2241
2264
|
}
|
|
2242
2265
|
function getSchemaChildren(arg0) {
|
|
2243
|
-
const { spec,
|
|
2266
|
+
const { spec, path, schema, depth = 0, required = [], seen = /* @__PURE__ */ new Set(), defaultExpanded } = arg0;
|
|
2244
2267
|
if (depth > 12) return [];
|
|
2245
2268
|
if (isReference(schema)) {
|
|
2246
2269
|
if (seen.has(schema.$ref)) return [];
|
|
@@ -2250,7 +2273,8 @@ function getSchemaChildren(arg0) {
|
|
|
2250
2273
|
path,
|
|
2251
2274
|
required,
|
|
2252
2275
|
depth,
|
|
2253
|
-
seen: new Set([...seen, schema.$ref])
|
|
2276
|
+
seen: new Set([...seen, schema.$ref]),
|
|
2277
|
+
defaultExpanded
|
|
2254
2278
|
});
|
|
2255
2279
|
}
|
|
2256
2280
|
if (!isRecord(schema)) return [];
|
|
@@ -2259,9 +2283,11 @@ function getSchemaChildren(arg0) {
|
|
|
2259
2283
|
schema: schema.items,
|
|
2260
2284
|
path: `${path}[]`,
|
|
2261
2285
|
depth: depth + 1,
|
|
2262
|
-
seen
|
|
2286
|
+
seen,
|
|
2287
|
+
defaultExpanded
|
|
2263
2288
|
}) : [];
|
|
2264
2289
|
const objectRequired = Array.isArray(schema.required) ? schema.required.map(String) : required;
|
|
2290
|
+
const enumChildren = getEnumChildren(schema, path);
|
|
2265
2291
|
const properties = isRecord(schema.properties) ? schema.properties : {};
|
|
2266
2292
|
const propertyChildren = Object.entries(properties).map(([name, propertySchema]) => {
|
|
2267
2293
|
const resolvedProperty = resolveSchema(spec, propertySchema);
|
|
@@ -2273,31 +2299,38 @@ function getSchemaChildren(arg0) {
|
|
|
2273
2299
|
schema: isArray ? property.items : propertySchema,
|
|
2274
2300
|
path: isArray ? `${childPath}[]` : childPath,
|
|
2275
2301
|
depth: depth + 1,
|
|
2276
|
-
seen
|
|
2302
|
+
seen,
|
|
2303
|
+
defaultExpanded
|
|
2277
2304
|
});
|
|
2305
|
+
const hasEnumValues = Array.isArray(property.enum) && property.enum.length > 0;
|
|
2278
2306
|
return {
|
|
2279
2307
|
key: childPath,
|
|
2280
2308
|
name,
|
|
2281
|
-
|
|
2309
|
+
kind: "property",
|
|
2310
|
+
type: getSchemaNodeType(property),
|
|
2282
2311
|
description: getSchemaDescription(property),
|
|
2283
2312
|
details: getSchemaDetails(property),
|
|
2284
2313
|
required: objectRequired.includes(name),
|
|
2314
|
+
defaultExpanded: hasEnumValues ? defaultExpanded === true : defaultExpanded ?? depth < 1,
|
|
2285
2315
|
children
|
|
2286
2316
|
};
|
|
2287
2317
|
});
|
|
2288
2318
|
const additionalPropertyChildren = isRecord(schema.additionalProperties) ? [{
|
|
2289
2319
|
key: `${path || "root"}.*`,
|
|
2290
2320
|
name: "*",
|
|
2291
|
-
|
|
2321
|
+
kind: "property",
|
|
2322
|
+
type: getSchemaNodeType(schema.additionalProperties),
|
|
2292
2323
|
description: getSchemaDescription(schema.additionalProperties),
|
|
2293
2324
|
details: getSchemaDetails(schema.additionalProperties),
|
|
2294
2325
|
required: false,
|
|
2326
|
+
defaultExpanded: defaultExpanded ?? depth < 1,
|
|
2295
2327
|
children: getSchemaChildren({
|
|
2296
2328
|
spec,
|
|
2297
2329
|
schema: schema.additionalProperties,
|
|
2298
2330
|
path: `${path || "root"}.*`,
|
|
2299
2331
|
depth: depth + 1,
|
|
2300
|
-
seen
|
|
2332
|
+
seen,
|
|
2333
|
+
defaultExpanded
|
|
2301
2334
|
})
|
|
2302
2335
|
}] : [];
|
|
2303
2336
|
const composedChildren = getComposedBranches(schema).map(({ label, schema: branchSchema }) => {
|
|
@@ -2306,35 +2339,40 @@ function getSchemaChildren(arg0) {
|
|
|
2306
2339
|
return {
|
|
2307
2340
|
key: `${path || "root"}.${label}`,
|
|
2308
2341
|
name: label,
|
|
2309
|
-
|
|
2342
|
+
kind: "property",
|
|
2343
|
+
type: getSchemaNodeType(branch),
|
|
2310
2344
|
description: branch ? getSchemaDescription(branch) : void 0,
|
|
2311
2345
|
details: branch ? getSchemaDetails(branch) : void 0,
|
|
2312
2346
|
required: false,
|
|
2347
|
+
defaultExpanded: defaultExpanded ?? depth < 1,
|
|
2313
2348
|
children: getSchemaChildren({
|
|
2314
2349
|
spec,
|
|
2315
2350
|
schema: branchSchema,
|
|
2316
2351
|
path: `${path || "root"}.${label}`,
|
|
2317
2352
|
required: objectRequired,
|
|
2318
2353
|
depth: depth + 1,
|
|
2319
|
-
seen
|
|
2354
|
+
seen,
|
|
2355
|
+
defaultExpanded
|
|
2320
2356
|
})
|
|
2321
2357
|
};
|
|
2322
2358
|
});
|
|
2323
2359
|
return [
|
|
2324
2360
|
...arrayChildren,
|
|
2361
|
+
...enumChildren,
|
|
2325
2362
|
...propertyChildren,
|
|
2326
2363
|
...additionalPropertyChildren,
|
|
2327
2364
|
...composedChildren
|
|
2328
2365
|
];
|
|
2329
2366
|
}
|
|
2330
|
-
function getRootSchemaNode(spec, schema) {
|
|
2367
|
+
function getRootSchemaNode(spec, schema, defaultExpanded) {
|
|
2331
2368
|
if (isReference(schema)) {
|
|
2332
2369
|
const resolvedSchema = resolveSchema(spec, schema);
|
|
2333
2370
|
const resolved = isRecord(resolvedSchema) ? resolvedSchema : {};
|
|
2334
2371
|
return {
|
|
2335
2372
|
key: schema.$ref,
|
|
2336
2373
|
name: resolveReferenceName(schema.$ref),
|
|
2337
|
-
|
|
2374
|
+
kind: "property",
|
|
2375
|
+
type: getSchemaNodeType(resolved),
|
|
2338
2376
|
description: getSchemaDescription(resolved),
|
|
2339
2377
|
details: getSchemaDetails(resolved),
|
|
2340
2378
|
required: false,
|
|
@@ -2342,7 +2380,8 @@ function getRootSchemaNode(spec, schema) {
|
|
|
2342
2380
|
spec,
|
|
2343
2381
|
schema: resolvedSchema,
|
|
2344
2382
|
path: resolveReferenceName(schema.$ref),
|
|
2345
|
-
seen: new Set([schema.$ref])
|
|
2383
|
+
seen: new Set([schema.$ref]),
|
|
2384
|
+
defaultExpanded
|
|
2346
2385
|
})
|
|
2347
2386
|
};
|
|
2348
2387
|
}
|
|
@@ -2350,24 +2389,58 @@ function getRootSchemaNode(spec, schema) {
|
|
|
2350
2389
|
return {
|
|
2351
2390
|
key: "root",
|
|
2352
2391
|
name: "body",
|
|
2353
|
-
|
|
2392
|
+
kind: "property",
|
|
2393
|
+
type: getSchemaNodeType(schema),
|
|
2354
2394
|
description: getSchemaDescription(schema),
|
|
2355
2395
|
details: getSchemaDetails(schema),
|
|
2356
2396
|
required: false,
|
|
2357
2397
|
children: getSchemaChildren({
|
|
2358
2398
|
spec,
|
|
2359
2399
|
schema,
|
|
2360
|
-
path: ""
|
|
2400
|
+
path: "",
|
|
2401
|
+
defaultExpanded
|
|
2361
2402
|
})
|
|
2362
2403
|
};
|
|
2363
2404
|
}
|
|
2364
|
-
function
|
|
2405
|
+
function EnumValueNode(arg0) {
|
|
2365
2406
|
const { node, depth = 0 } = arg0;
|
|
2407
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
|
|
2408
|
+
className: "clarify-schema-node m-0 px-0 py-2 first:pt-0 last:pb-0",
|
|
2409
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2410
|
+
className: (0, clsx.default)("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"),
|
|
2411
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2412
|
+
className: "min-w-0 flex-1",
|
|
2413
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2414
|
+
className: "flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5",
|
|
2415
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2416
|
+
className: "text-sm/5 font-semibold text-(--clarify-theme-tokens-colors-foreground)",
|
|
2417
|
+
children: node.name
|
|
2418
|
+
})
|
|
2419
|
+
}), node.description || node.details ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2420
|
+
className: "mt-0.5 text-sm/5 text-(--clarify-ui-text-soft) *:first:mt-0 *:last:mb-0",
|
|
2421
|
+
children: [node.description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, {
|
|
2422
|
+
className: "*:first:mt-0 *:last:mb-0",
|
|
2423
|
+
children: node.description
|
|
2424
|
+
}) : null, node.details ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2425
|
+
className: "text-xs text-(--clarify-ui-text-faint)",
|
|
2426
|
+
children: node.details
|
|
2427
|
+
}) : null]
|
|
2428
|
+
}) : null]
|
|
2429
|
+
})
|
|
2430
|
+
})
|
|
2431
|
+
});
|
|
2432
|
+
}
|
|
2433
|
+
function SchemaNode(arg0) {
|
|
2434
|
+
const { node, depth = 0, defaultExpanded } = arg0;
|
|
2366
2435
|
const t = require_PageActions.useBuiltInText();
|
|
2367
|
-
const [expanded, setExpanded] = (0, react.useState)(depth < 1);
|
|
2436
|
+
const [expanded, setExpanded] = (0, react.useState)(defaultExpanded ?? depth < 1);
|
|
2368
2437
|
const hasChildren = node.children.length > 0;
|
|
2438
|
+
if (node.kind === "enum") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EnumValueNode, {
|
|
2439
|
+
node,
|
|
2440
|
+
depth
|
|
2441
|
+
});
|
|
2369
2442
|
const type = [node.type, node.required ? t("openapi.requiredBadge") : void 0].filter(Boolean).join(", ") || void 0;
|
|
2370
|
-
const fallbackDescription = node.required ? t("openapi.required") : t("openapi.optional");
|
|
2443
|
+
const fallbackDescription = hasChildren ? void 0 : node.required ? t("openapi.required") : t("openapi.optional");
|
|
2371
2444
|
const rowClassName = (0, clsx.default)("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");
|
|
2372
2445
|
const content = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2373
2446
|
className: "min-w-0 flex-1",
|
|
@@ -2421,13 +2494,14 @@ function SchemaTree(arg0) {
|
|
|
2421
2494
|
className: (0, clsx.default)("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"),
|
|
2422
2495
|
children: nodes.map((node) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaNode, {
|
|
2423
2496
|
node,
|
|
2424
|
-
depth
|
|
2497
|
+
depth,
|
|
2498
|
+
defaultExpanded: node.defaultExpanded
|
|
2425
2499
|
}, node.key))
|
|
2426
2500
|
});
|
|
2427
2501
|
}
|
|
2428
2502
|
function SchemaProperties(arg0) {
|
|
2429
|
-
const { title, schema, spec } = arg0;
|
|
2430
|
-
const root = getRootSchemaNode(spec, schema);
|
|
2503
|
+
const { title, schema, spec, defaultExpanded } = arg0;
|
|
2504
|
+
const root = getRootSchemaNode(spec, schema, defaultExpanded);
|
|
2431
2505
|
if (!root || root.children.length === 0) return null;
|
|
2432
2506
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: title }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2433
2507
|
className: "clarify-schema-properties my-6",
|
|
@@ -3252,4 +3326,4 @@ Object.defineProperty(exports, "primitives_exports", {
|
|
|
3252
3326
|
}
|
|
3253
3327
|
});
|
|
3254
3328
|
|
|
3255
|
-
//# sourceMappingURL=OpenApiOperation-
|
|
3329
|
+
//# sourceMappingURL=OpenApiOperation-CyyPlZL6.cjs.map
|