@pipelex/mthds-form 0.34.0 → 0.35.1
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/dist/{chunk-5RV3ASMO.js → chunk-TD62R3P6.js} +348 -190
- package/dist/chunk-TD62R3P6.js.map +1 -0
- package/dist/{chunk-XYS5KCXB.js → chunk-XLTYIIUY.js} +127 -10
- package/dist/chunk-XLTYIIUY.js.map +1 -0
- package/dist/{field-renderer-BYN6YrU-.d.ts → field-presentation-D5BkBSjX.d.ts} +49 -9
- package/dist/generative/headless/index.d.ts +36 -2
- package/dist/generative/headless/index.js +2 -1
- package/dist/generative/index.d.ts +27 -19
- package/dist/generative/index.js +31 -30
- package/dist/generative/index.js.map +1 -1
- package/dist/layout-sample.mthds +85 -0
- package/dist/react/index.d.ts +49 -61
- package/dist/react/index.js +1 -1
- package/dist/styles.css +1 -1
- package/package.json +3 -2
- package/dist/chunk-5RV3ASMO.js.map +0 -1
- package/dist/chunk-XYS5KCXB.js.map +0 -1
|
@@ -2,6 +2,7 @@ import { isNativeValueNode, readDateContent, formatDateContent, isNativeHtmlNode
|
|
|
2
2
|
import { APP_STYLES } from './chunk-PNNWNRPG.js';
|
|
3
3
|
import { isFilled } from './chunk-TF4RTKLH.js';
|
|
4
4
|
import { hasOwnProp } from './chunk-V3OV2XQT.js';
|
|
5
|
+
import { isAcceptableDate } from './chunk-GKV77RAS.js';
|
|
5
6
|
import { defineSchema, defineCatalog, validateSpec, compileSpecStream } from '@json-render/core';
|
|
6
7
|
import { z } from 'zod';
|
|
7
8
|
|
|
@@ -1272,7 +1273,7 @@ function nonScalarReads(spec, parents, root, fieldAt) {
|
|
|
1272
1273
|
for (const [key, element] of Object.entries(spec.elements)) {
|
|
1273
1274
|
const itemPath = itemPathResolver(spec, key, parents);
|
|
1274
1275
|
const listy = lists.get(element.type);
|
|
1275
|
-
const
|
|
1276
|
+
const check2 = (prop, path) => {
|
|
1276
1277
|
if (!isUnder(root, path)) return;
|
|
1277
1278
|
const field = fieldAt(path);
|
|
1278
1279
|
if (!field) return;
|
|
@@ -1456,13 +1457,13 @@ function nonScalarReads(spec, parents, root, fieldAt) {
|
|
|
1456
1457
|
}
|
|
1457
1458
|
if (typeof value !== "object" || value === null) return;
|
|
1458
1459
|
const record = value;
|
|
1459
|
-
if (typeof record.$state === "string")
|
|
1460
|
+
if (typeof record.$state === "string") check2(prop, record.$state);
|
|
1460
1461
|
if (typeof record.$item === "string") {
|
|
1461
1462
|
const path = itemPath(record.$item);
|
|
1462
|
-
if (path !== void 0)
|
|
1463
|
+
if (path !== void 0) check2(prop, path);
|
|
1463
1464
|
}
|
|
1464
1465
|
if (typeof record.$template === "string") {
|
|
1465
|
-
for (const path of interpolatedPaths(record.$template, itemPath))
|
|
1466
|
+
for (const path of interpolatedPaths(record.$template, itemPath)) check2(prop, path);
|
|
1466
1467
|
}
|
|
1467
1468
|
for (const [name, entry] of Object.entries(record)) {
|
|
1468
1469
|
if (name !== "$cond") walk(prop, entry);
|
|
@@ -2222,8 +2223,8 @@ function layoutCheck(spec, { frame, descriptor }) {
|
|
|
2222
2223
|
return { problems: [checksFailedLine(error)], checksFailed: true };
|
|
2223
2224
|
}
|
|
2224
2225
|
}
|
|
2225
|
-
function layoutCheckProblems(spec,
|
|
2226
|
-
return layoutCheck(spec,
|
|
2226
|
+
function layoutCheckProblems(spec, check2) {
|
|
2227
|
+
return layoutCheck(spec, check2).problems;
|
|
2227
2228
|
}
|
|
2228
2229
|
function pressRuns(spec) {
|
|
2229
2230
|
const isRun = (binding) => typeof binding === "object" && binding !== null && binding.action === "run";
|
|
@@ -2430,7 +2431,7 @@ function resultBrief(subject, field, state, { frame = "page", style } = {}) {
|
|
|
2430
2431
|
description: subject.description,
|
|
2431
2432
|
paths,
|
|
2432
2433
|
...style ? { style: styleOf(style) } : {},
|
|
2433
|
-
sample_state: JSON.stringify(state, null, 2)
|
|
2434
|
+
...state === void 0 ? {} : { sample_state: JSON.stringify(state, null, 2) }
|
|
2434
2435
|
};
|
|
2435
2436
|
}
|
|
2436
2437
|
function specToJsonl(spec) {
|
|
@@ -2529,6 +2530,122 @@ function payloadToState(field, payload) {
|
|
|
2529
2530
|
}
|
|
2530
2531
|
}
|
|
2531
2532
|
|
|
2533
|
+
// src/generative/written-sample.ts
|
|
2534
|
+
var CODE_FENCE = /^```[\w-]*[ \t]*\r?\n([\s\S]*?)\r?\n?```$/;
|
|
2535
|
+
function isLeftOut(field) {
|
|
2536
|
+
return field.kind === "document" || field.kind === "image" || isDelegatedResult(field, "result");
|
|
2537
|
+
}
|
|
2538
|
+
function isRecord3(value) {
|
|
2539
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2540
|
+
}
|
|
2541
|
+
function kindInWords(field) {
|
|
2542
|
+
switch (field.kind) {
|
|
2543
|
+
case "text":
|
|
2544
|
+
case "prose":
|
|
2545
|
+
return "a text";
|
|
2546
|
+
case "number":
|
|
2547
|
+
return field.integer ? "a whole number" : "a number";
|
|
2548
|
+
case "boolean":
|
|
2549
|
+
return "true or false";
|
|
2550
|
+
case "enum":
|
|
2551
|
+
return `one of ${field.options.map((option) => JSON.stringify(option)).join(", ")}`;
|
|
2552
|
+
case "date":
|
|
2553
|
+
return "a day written as YYYY-MM-DD";
|
|
2554
|
+
case "object":
|
|
2555
|
+
return "a structure";
|
|
2556
|
+
case "list":
|
|
2557
|
+
return "a list";
|
|
2558
|
+
case "document":
|
|
2559
|
+
case "image":
|
|
2560
|
+
case "unknown":
|
|
2561
|
+
return "nothing";
|
|
2562
|
+
default:
|
|
2563
|
+
return field;
|
|
2564
|
+
}
|
|
2565
|
+
}
|
|
2566
|
+
function holdsKind(field, value) {
|
|
2567
|
+
switch (field.kind) {
|
|
2568
|
+
case "text":
|
|
2569
|
+
case "prose":
|
|
2570
|
+
return typeof value === "string";
|
|
2571
|
+
case "number":
|
|
2572
|
+
return typeof value === "number" && Number.isFinite(value) && (!field.integer || Number.isInteger(value));
|
|
2573
|
+
case "boolean":
|
|
2574
|
+
return typeof value === "boolean";
|
|
2575
|
+
case "enum":
|
|
2576
|
+
return typeof value === "string" && field.options.includes(value);
|
|
2577
|
+
case "date":
|
|
2578
|
+
return typeof value === "string" && isAcceptableDate(value);
|
|
2579
|
+
case "object":
|
|
2580
|
+
return isRecord3(value);
|
|
2581
|
+
case "list":
|
|
2582
|
+
return Array.isArray(value);
|
|
2583
|
+
case "document":
|
|
2584
|
+
case "image":
|
|
2585
|
+
case "unknown":
|
|
2586
|
+
return false;
|
|
2587
|
+
default:
|
|
2588
|
+
return field;
|
|
2589
|
+
}
|
|
2590
|
+
}
|
|
2591
|
+
function limitInWords(amount, least, most, unit) {
|
|
2592
|
+
if (least !== void 0 && amount < least) return `should hold at least ${least}${unit}`;
|
|
2593
|
+
if (most !== void 0 && amount > most) return `should hold at most ${most}${unit}`;
|
|
2594
|
+
return void 0;
|
|
2595
|
+
}
|
|
2596
|
+
function outsideLimits(field, value) {
|
|
2597
|
+
switch (field.kind) {
|
|
2598
|
+
case "number":
|
|
2599
|
+
return typeof value === "number" ? limitInWords(value, field.min, field.max, "") : void 0;
|
|
2600
|
+
case "text":
|
|
2601
|
+
case "prose":
|
|
2602
|
+
return typeof value === "string" ? limitInWords([...value].length, field.minLength, field.maxLength, " characters") : void 0;
|
|
2603
|
+
case "list":
|
|
2604
|
+
return Array.isArray(value) && !isLeftOut(field.item) ? limitInWords(value.length, field.itemCount, field.maxItemCount, " items") : void 0;
|
|
2605
|
+
default:
|
|
2606
|
+
return void 0;
|
|
2607
|
+
}
|
|
2608
|
+
}
|
|
2609
|
+
function check(field, value, path, problems) {
|
|
2610
|
+
if (value === null || value === void 0) return;
|
|
2611
|
+
if (isLeftOut(field)) {
|
|
2612
|
+
problems.push(`${path} should be left out of a sample, and it holds something`);
|
|
2613
|
+
return;
|
|
2614
|
+
}
|
|
2615
|
+
if (!holdsKind(field, value)) {
|
|
2616
|
+
problems.push(`${path} should hold ${kindInWords(field)}`);
|
|
2617
|
+
return;
|
|
2618
|
+
}
|
|
2619
|
+
const limit = outsideLimits(field, value);
|
|
2620
|
+
if (limit !== void 0) problems.push(`${path} ${limit}`);
|
|
2621
|
+
if (field.kind === "object" && isRecord3(value)) {
|
|
2622
|
+
const members = new Map(field.fields.map((member) => [member.name, member]));
|
|
2623
|
+
for (const [key, held] of Object.entries(value)) {
|
|
2624
|
+
const member = members.get(key);
|
|
2625
|
+
if (member) check(member, held, joinPath(path, key), problems);
|
|
2626
|
+
else problems.push(`${joinPath(path, key)} is not a member the method returns`);
|
|
2627
|
+
}
|
|
2628
|
+
}
|
|
2629
|
+
if (field.kind === "list" && Array.isArray(value)) {
|
|
2630
|
+
value.forEach(
|
|
2631
|
+
(item, index) => check(field.item, item, joinPath(path, String(index)), problems)
|
|
2632
|
+
);
|
|
2633
|
+
}
|
|
2634
|
+
}
|
|
2635
|
+
function writtenSampleOf(field, text) {
|
|
2636
|
+
const trimmed = text.trim();
|
|
2637
|
+
const fenced = CODE_FENCE.exec(trimmed);
|
|
2638
|
+
let state;
|
|
2639
|
+
try {
|
|
2640
|
+
state = JSON.parse(fenced ? fenced[1] : trimmed);
|
|
2641
|
+
} catch {
|
|
2642
|
+
return { state: void 0, problems: ["the written sample is not JSON"] };
|
|
2643
|
+
}
|
|
2644
|
+
const problems = [];
|
|
2645
|
+
check(field, state, RESULT_ROOT, problems);
|
|
2646
|
+
return { state, problems };
|
|
2647
|
+
}
|
|
2648
|
+
|
|
2532
2649
|
// src/generative/fixture.ts
|
|
2533
2650
|
function fixtureId(fixture) {
|
|
2534
2651
|
return [
|
|
@@ -2569,6 +2686,6 @@ function findFixture(fixtures, pipeRef, id) {
|
|
|
2569
2686
|
return found;
|
|
2570
2687
|
}
|
|
2571
2688
|
|
|
2572
|
-
export { COMPONENT_NAMES, COMPONENT_RENDERINGS, COMPOSER_COMPONENTS, CUSTOM_COMPONENTS, DESIGNER_BRIEF_CONCEPT, DESIGNER_CATALOG_CONCEPT, FRAMES, FRAME_COMPONENTS, ICON_NAMES, INPUTS_ROOT, METRIC_FORMATS, PICKED_SHADCN, PRODUCT_COMPONENTS, PROMPT_HASH, REPAIR_ATTEMPTS, RESULT_COMPONENTS, RESULT_ROOT, absoluteHatchPath, baseCatalog, catalog, componentNamesFor, definitionChain, designerCatalog, fieldAtSegments, findFixture, fixtureId, fixtureLabel, formatProblems, frameCatalog, frameComponents, inputBrief, inputFieldAtPath, isDelegatedInput, isDelegatedResult, joinPath, jsonlLines, layoutCheck, layoutCheckProblems, layoutFits, layoutProblems, payloadToState, promptHashSubject, repeatBasePathOf, resultBrief, resultFieldAtPath, seedLine, segmentsUnder, shareAmount, specFromJsonl, specToJsonl, unwrapped, validateAgainstCatalog };
|
|
2573
|
-
//# sourceMappingURL=chunk-
|
|
2574
|
-
//# sourceMappingURL=chunk-
|
|
2689
|
+
export { COMPONENT_NAMES, COMPONENT_RENDERINGS, COMPOSER_COMPONENTS, CUSTOM_COMPONENTS, DESIGNER_BRIEF_CONCEPT, DESIGNER_CATALOG_CONCEPT, FRAMES, FRAME_COMPONENTS, ICON_NAMES, INPUTS_ROOT, METRIC_FORMATS, PICKED_SHADCN, PRODUCT_COMPONENTS, PROMPT_HASH, REPAIR_ATTEMPTS, RESULT_COMPONENTS, RESULT_ROOT, absoluteHatchPath, baseCatalog, catalog, componentNamesFor, definitionChain, designerCatalog, fieldAtSegments, findFixture, fixtureId, fixtureLabel, formatProblems, frameCatalog, frameComponents, inputBrief, inputFieldAtPath, isDelegatedInput, isDelegatedResult, joinPath, jsonlLines, layoutCheck, layoutCheckProblems, layoutFits, layoutProblems, payloadToState, promptHashSubject, repeatBasePathOf, resultBrief, resultFieldAtPath, seedLine, segmentsUnder, shareAmount, specFromJsonl, specToJsonl, unwrapped, validateAgainstCatalog, writtenSampleOf };
|
|
2690
|
+
//# sourceMappingURL=chunk-XLTYIIUY.js.map
|
|
2691
|
+
//# sourceMappingURL=chunk-XLTYIIUY.js.map
|