@pipelex/mthds-form 0.9.0 → 0.10.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/README.md +3 -0
- package/dist/{chunk-S4CB423P.js → chunk-4JQAJT7C.js} +3 -3
- package/dist/{chunk-S4CB423P.js.map → chunk-4JQAJT7C.js.map} +1 -1
- package/dist/{chunk-YABRYTQ4.js → chunk-4KGQ65TQ.js} +3 -3
- package/dist/{chunk-YABRYTQ4.js.map → chunk-4KGQ65TQ.js.map} +1 -1
- package/dist/chunk-CAKQ5VFT.js +35 -0
- package/dist/chunk-CAKQ5VFT.js.map +1 -0
- package/dist/{chunk-25I6JDIK.js → chunk-FABY3DEY.js} +2 -2
- package/dist/chunk-FABY3DEY.js.map +1 -0
- package/dist/{chunk-AZZAAGNX.js → chunk-TID7ZN63.js} +7 -3
- package/dist/chunk-TID7ZN63.js.map +1 -0
- package/dist/{chunk-KG4IYFWI.js → chunk-W56WIIVC.js} +174 -51
- package/dist/chunk-W56WIIVC.js.map +1 -0
- package/dist/chunk-XCO6GTEC.js +38 -0
- package/dist/chunk-XCO6GTEC.js.map +1 -0
- package/dist/{chunk-KIEOLP2L.js → chunk-ZB4RYUKV.js} +4 -4
- package/dist/chunk-ZB4RYUKV.js.map +1 -0
- package/dist/core/derive.d.ts +1 -0
- package/dist/core/derive.js +2 -2
- package/dist/core/descriptor.d.ts +13 -2
- package/dist/core/descriptor.js +1 -1
- package/dist/core/file-formats.d.ts +34 -7
- package/dist/core/file-formats.js +1 -1
- package/dist/core/gating-fields.d.ts +1 -0
- package/dist/core/index.d.ts +2 -1
- package/dist/core/index.js +7 -6
- package/dist/core/narrow-file-formats.d.ts +50 -0
- package/dist/core/narrow-file-formats.js +4 -0
- package/dist/core/narrow-file-formats.js.map +1 -0
- package/dist/core/native-content.d.ts +20 -11
- package/dist/core/native-content.js +1 -1
- package/dist/core/readiness.d.ts +1 -0
- package/dist/core/stuff-files.d.ts +1 -0
- package/dist/core/stuff-files.js +2 -2
- package/dist/core/values.d.ts +1 -0
- package/dist/core/values.js +3 -3
- package/dist/generative/index.d.ts +105 -12
- package/dist/generative/index.js +79 -157
- package/dist/generative/index.js.map +1 -1
- package/dist/{ui-designer.mthds → layout-design.mthds} +177 -29
- package/dist/react/index.d.ts +66 -10
- package/dist/react/index.js +5 -5
- package/dist/styles.css +1 -1
- package/package.json +3 -3
- package/dist/chunk-25I6JDIK.js.map +0 -1
- package/dist/chunk-2JWRG53S.js +0 -33
- package/dist/chunk-2JWRG53S.js.map +0 -1
- package/dist/chunk-AZZAAGNX.js.map +0 -1
- package/dist/chunk-KG4IYFWI.js.map +0 -1
- package/dist/chunk-KIEOLP2L.js.map +0 -1
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// src/core/file-formats.ts
|
|
2
|
+
var DOCUMENT_FORMATS = [
|
|
3
|
+
{ mimeType: "application/pdf", extensions: [".pdf"], label: "PDF" },
|
|
4
|
+
{ mimeType: "image/jpeg", extensions: [".jpg", ".jpeg"], label: "JPG" },
|
|
5
|
+
{ mimeType: "image/png", extensions: [".png"], label: "PNG" }
|
|
6
|
+
];
|
|
7
|
+
var IMAGE_FORMATS = [
|
|
8
|
+
{ mimeType: "image/png", extensions: [".png"], label: "PNG" },
|
|
9
|
+
{ mimeType: "image/jpeg", extensions: [".jpg", ".jpeg"], label: "JPG" },
|
|
10
|
+
{ mimeType: "image/webp", extensions: [".webp"], label: "WEBP" }
|
|
11
|
+
];
|
|
12
|
+
function formatsForKind(kind) {
|
|
13
|
+
return kind === "image" ? IMAGE_FORMATS : DOCUMENT_FORMATS;
|
|
14
|
+
}
|
|
15
|
+
function normalizeMimeType(type) {
|
|
16
|
+
return type.split(";", 1)[0]?.trim().toLowerCase() ?? "";
|
|
17
|
+
}
|
|
18
|
+
function acceptLabel(formats) {
|
|
19
|
+
return formats.map((format) => format.label).join(", ");
|
|
20
|
+
}
|
|
21
|
+
function formatOfFilename(formats, filename) {
|
|
22
|
+
const name = filename.toLowerCase();
|
|
23
|
+
return formats.find((format) => format.extensions.some((ext) => name.endsWith(ext)));
|
|
24
|
+
}
|
|
25
|
+
function isAcceptedFile(formats, file) {
|
|
26
|
+
const mimeType = normalizeMimeType(file.type);
|
|
27
|
+
if (mimeType) return formats.some((format) => format.mimeType === mimeType);
|
|
28
|
+
return formatOfFilename(formats, file.name) !== void 0;
|
|
29
|
+
}
|
|
30
|
+
function acceptMap(formats) {
|
|
31
|
+
const map = {};
|
|
32
|
+
for (const format of formats) map[format.mimeType] = [...format.extensions];
|
|
33
|
+
return map;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { DOCUMENT_FORMATS, IMAGE_FORMATS, acceptLabel, acceptMap, formatOfFilename, formatsForKind, isAcceptedFile, normalizeMimeType };
|
|
37
|
+
//# sourceMappingURL=chunk-XCO6GTEC.js.map
|
|
38
|
+
//# sourceMappingURL=chunk-XCO6GTEC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/file-formats.ts"],"names":[],"mappings":";AA2EO,IAAM,gBAAA,GAA0C;AAAA,EACrD,EAAE,UAAU,iBAAA,EAAmB,UAAA,EAAY,CAAC,MAAM,CAAA,EAAG,OAAO,KAAA,EAAM;AAAA,EAClE,EAAE,UAAU,YAAA,EAAc,UAAA,EAAY,CAAC,MAAA,EAAQ,OAAO,CAAA,EAAG,KAAA,EAAO,KAAA,EAAM;AAAA,EACtE,EAAE,UAAU,WAAA,EAAa,UAAA,EAAY,CAAC,MAAM,CAAA,EAAG,OAAO,KAAA;AACxD;AAUO,IAAM,aAAA,GAAuC;AAAA,EAClD,EAAE,UAAU,WAAA,EAAa,UAAA,EAAY,CAAC,MAAM,CAAA,EAAG,OAAO,KAAA,EAAM;AAAA,EAC5D,EAAE,UAAU,YAAA,EAAc,UAAA,EAAY,CAAC,MAAA,EAAQ,OAAO,CAAA,EAAG,KAAA,EAAO,KAAA,EAAM;AAAA,EACtE,EAAE,UAAU,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AAA;AACT","file":"chunk-XCO6GTEC.js","sourcesContent":["/**\n * What a `document` or an `image` slot actually accepts.\n *\n * **This is a client-side mirror of a runtime fact, and the fact was measured\n * rather than read off a list.** The wire says a slot's kind is `document` or\n * `image` and stops there — which bytes a runtime can decode is a property of\n * that runtime, not of the method — so the list has to live on this side, and\n * the only honest place is one module that says where it came from.\n *\n * There is no single enum to copy. In `pipelex`, what a slot accepts is derived\n * per model:\n *\n * ModelSpec.supported_document_types = {\"pdf\",\"docx\",\"pptx\"} & set(inputs)\n * ModelSpec.is_vision_supported = \"images\" in inputs\n *\n * so the effective set is that vocabulary intersected with the **model deck's**\n * declared `inputs`. No model in the shipped deck declares `docx` or `pptx`;\n * every LLM entry is `[\"text\", \"images\", \"pdf\"]`, and the default extract model\n * (`azure-document-intelligence`) is `[\"image\", \"pdf\"]`.\n *\n * Confirmed by running each format end to end:\n *\n * | Format | PipeExtract | PipeLLM |\n * | --- | --- | --- |\n * | PDF | yes | yes |\n * | PNG | yes | n/a |\n * | JPEG | yes | n/a |\n * | WEBP | no | no |\n * | DOCX | no | no — `does not support docx documents` |\n * | PPTX | no | no — detected as `zip`, so it never even reaches the check |\n *\n * The gateway states its own list in the failure: *\"Supported formats:\n * application/pdf, image/jpeg, image/png as base64 data URLs.\"*\n *\n * Images were measured the same way: PNG, JPEG and WEBP pass; BMP and TIFF fail\n * on the provider's image enum; GIF fails too, though it is *in* that enum — it\n * arrives at the provider as a document block rather than an image one, which\n * looks like a routing bug upstream rather than an unsupported format.\n *\n * **A document slot's PNG and JPEG only work in an extract pipe.** The\n * descriptor never says which operator consumes the slot, so this table cannot\n * distinguish them; it matches the extract model's declared inputs, because\n * extraction is the operator that actually reads a document's bytes.\n *\n * What was here before was built on `DocumentFormat` (PDF/DOCX/PPTX), an enum\n * that is referenced nowhere in the runtime outside commented-out code and is\n * being deleted. A dead enum is the worst kind of source: it reads exactly like\n * a live one.\n *\n * A stale entry here is worse than no list at all, because it refuses a file the\n * runtime would have taken. If the deck grows a format, this table moves with it.\n *\n * **The table is the source; a field's `formats` is what gets read.** The\n * helpers below take a format LIST rather than a kind, because what a given\n * slot accepts can be narrower than its kind: a host whose server takes only\n * some of these types narrows the field tree once (`narrowFileFormats`), and\n * the dropzone's hint, its picker filter and its check all read the narrowed\n * list, so the three cannot disagree with each other or with that server.\n *\n * Pure data and pure functions over it. No React, no ajv, nothing imported.\n */\n\n/** One accepted format: its MIME type and the extensions that carry it. */\nexport interface FileFormat {\n mimeType: string;\n /** Leading dot, lowercase — the shape a file input's `accept` wants. */\n extensions: string[];\n /** How the format is named to a user, uppercase. */\n label: string;\n}\n\n/**\n * What a `document` slot takes: PDF, plus the two image formats the extract\n * model reads as a single-page document.\n */\nexport const DOCUMENT_FORMATS: readonly FileFormat[] = [\n { mimeType: 'application/pdf', extensions: ['.pdf'], label: 'PDF' },\n { mimeType: 'image/jpeg', extensions: ['.jpg', '.jpeg'], label: 'JPG' },\n { mimeType: 'image/png', extensions: ['.png'], label: 'PNG' },\n];\n\n/**\n * What an `image` slot takes: PNG, JPEG, WEBP — all three measured through the\n * vision path.\n *\n * `.jpg` and `.jpeg` both ride `image/jpeg`. `JPG` is the label because that is\n * the spelling the runtime uses, but a file named `.jpeg` is the same bytes and\n * must not be refused over its spelling.\n */\nexport const IMAGE_FORMATS: readonly FileFormat[] = [\n { mimeType: 'image/png', extensions: ['.png'], label: 'PNG' },\n { mimeType: 'image/jpeg', extensions: ['.jpg', '.jpeg'], label: 'JPG' },\n { mimeType: 'image/webp', extensions: ['.webp'], label: 'WEBP' },\n];\n\n/**\n * The source table: every format a slot of this kind can take, before a host\n * narrows it. `buildRunFields` stamps this onto each `document` and `image`\n * field as its `formats`, and everything downstream reads the field's list\n * rather than coming back here - which is what lets a host narrow one list and\n * have the hint, the picker and the check all follow it.\n */\nexport function formatsForKind(kind: 'document' | 'image'): readonly FileFormat[] {\n return kind === 'image' ? IMAGE_FORMATS : DOCUMENT_FORMATS;\n}\n\n/**\n * A MIME type as the table spells it: no parameters, no surrounding space,\n * lowercase. `APPLICATION/PDF; version=1.7` is `application/pdf`.\n */\nexport function normalizeMimeType(type: string): string {\n return type.split(';', 1)[0]?.trim().toLowerCase() ?? '';\n}\n\n/** `\"PDF, JPG, PNG\"` - the hint shown under a dropzone. */\nexport function acceptLabel(formats: readonly FileFormat[]): string {\n return formats.map((format) => format.label).join(', ');\n}\n\n/**\n * The format a filename's extension names, among these formats, or `undefined`\n * when it names none of them. Case-insensitive, because `PHOTO.PNG` is a PNG.\n */\nexport function formatOfFilename(\n formats: readonly FileFormat[],\n filename: string,\n): FileFormat | undefined {\n const name = filename.toLowerCase();\n return formats.find((format) => format.extensions.some((ext) => name.endsWith(ext)));\n}\n\n/**\n * Whether a picked file is one of these formats.\n *\n * Checks the MIME type first and falls back to the extension, because a\n * browser's `File.type` is empty often enough to matter: an OS with no handler\n * registered for `.docx` reports `''`, and refusing that file would be refusing\n * a valid one over a fact about the user's machine. A wrong-but-present MIME\n * type is still a rejection — that is the case this exists for.\n *\n * It takes the field's own list, never the kind's, so a slot a host narrowed\n * refuses exactly what its hint no longer names.\n */\nexport function isAcceptedFile(\n formats: readonly FileFormat[],\n file: { name: string; type: string },\n): boolean {\n const mimeType = normalizeMimeType(file.type);\n if (mimeType) return formats.some((format) => format.mimeType === mimeType);\n return formatOfFilename(formats, file.name) !== undefined;\n}\n\n/**\n * The accept map a file input wants: MIME type to extensions.\n *\n * Shaped for `react-dropzone`'s `accept`, which is the same shape the DOM's\n * `accept` attribute is built from. Listing extensions BESIDE the MIME type is\n * what makes the empty-`File.type` case above work in the OS picker too.\n */\nexport function acceptMap(formats: readonly FileFormat[]): Record<string, string[]> {\n const map: Record<string, string[]> = {};\n for (const format of formats) map[format.mimeType] = [...format.extensions];\n return map;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { formatsForKind } from './chunk-XCO6GTEC.js';
|
|
2
2
|
import { collectSchemaDefs, resolveSchemaNode } from './chunk-OD3VYXUY.js';
|
|
3
3
|
import { buildPipeRef } from './chunk-WYH56SOZ.js';
|
|
4
4
|
import { ownProp } from './chunk-V3OV2XQT.js';
|
|
@@ -85,7 +85,7 @@ function mapNode(node, name, rawSchema, defs) {
|
|
|
85
85
|
return { ...common, kind: "enum", options: node.choices.map(String) };
|
|
86
86
|
case "document":
|
|
87
87
|
case "image":
|
|
88
|
-
return { ...common, kind: node.kind,
|
|
88
|
+
return { ...common, kind: node.kind, formats: formatsForKind(node.kind) };
|
|
89
89
|
case "object": {
|
|
90
90
|
const props = schema?.properties;
|
|
91
91
|
return {
|
|
@@ -133,5 +133,5 @@ function buildRunFields(descriptor, inputs) {
|
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
export { buildResultField, buildRunFields, getPipeInputForm };
|
|
136
|
-
//# sourceMappingURL=chunk-
|
|
137
|
-
//# sourceMappingURL=chunk-
|
|
136
|
+
//# sourceMappingURL=chunk-ZB4RYUKV.js.map
|
|
137
|
+
//# sourceMappingURL=chunk-ZB4RYUKV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/derive.ts"],"names":[],"mappings":";;;;;;AA8CO,SAAS,gBAAA,CACd,SAAA,EACA,MAAA,EACA,QAAA,EACqC;AACrC,EAAA,IAAI,CAAC,SAAA,IAAa,CAAC,QAAA,EAAU,OAAO,MAAA;AACpC,EAAA,IAAI,MAAA,EAAQ;AACV,IAAA,MAAM,QAAQ,OAAA,CAAQ,SAAA,EAAW,YAAA,CAAa,MAAA,EAAQ,QAAQ,CAAC,CAAA;AAC/D,IAAA,IAAI,OAAO,OAAO,KAAA;AAAA,EACpB;AACA,EAAA,OAAO,OAAA,CAAQ,WAAW,QAAQ,CAAA;AACpC;AAaA,SAAS,iBAAiB,MAAA,EAAoD;AAC5E,EAAA,MAAM,QAAQ,MAAA,EAAQ,UAAA;AACtB,EAAA,MAAM,OAAO,KAAA,GAAQ,MAAA,CAAO,IAAA,CAAK,KA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AAS,gBAAA,CACd,YACA,MAAA,EACU;AACV,EAAA,MAAM,OAAO,UAAA,CAAW,KAAA;AACxB,EAAA,MAAM,OAAmC,EAAC;AAC1C,EAAA,iBAAA,CAAkB,MAAA,EAAsB,IAAA,EAAM,EAAE,cAAA,EAAgB,MAAM,CAAA;AAetE,EAAA,MAAM,aAAa,IAAA,CAAK,IAAA,KAAS,QAAA,GAAW,MAAA,GAAY,iBAAiB,MAAoB,CAAA;AAC7F,EAAA,MAAM,QACJ,UAAA,KAAe,MAAA,GACV,MAAA,GACC,MAAA,CAAsB,WAA0C,UAAU,CAAA;AAElF,EAAA,MAAM,QAAQ,OAAA,CAAQ,IAAA,EAAM,IAAA,CAAK,IAAA,EAAM,OAAO,IAAI,CAAA;AAClD,EAAA,OAAO,eAAe,MAAA,GAAY,KAAA,GAAQ,EAAE,GAAG,KAAA,EAAO,YAAY,UAAA,EAAW;AAC/E;AAEO,SAAS,cAAA,CACd,YACA,MAAA,EACY;AACZ,EAAA,OAAO,UAAA,CAAW,MAAA,CAAO,GAAA,CAAI,CAAC,IAAA,KAAS;AACrC,IAAA,MAAM,KAAA,GAAQ,OAAA,CAAQ,MAAA,EAAQ,IAAA,CAAK,IAAI,CAAA;AACvC,IAAA,MAAM,OAAmC,EAAC;AAC1C,IAAA,IAAI,KAAA,oBAAyB,KAAA,CAAM,WAAA,EAAa,MAAM,EAAE,cAAA,EAAgB,MAAM,CAAA;AAC9E,IAAA,MAAM,QAAQ,OAAA,CAAQ,IAAA,EAAM,KAAK,IAAA,EAAM,KAAA,EAAO,aAAuC,IAAI,CAAA;AACzF,IAAA,OAAO,EAAE,GAAG,KAAA,EAAO,QAAA,EAAU,KAAK,QAAA,EAAU,MAAA,EAAQ,KAAK,MAAA,EAAO;AAAA,EAClE,CAAC,CAAA;AACH","file":"chunk-ZB4RYUKV.js","sourcesContent":["/**\n * The ONE derivation function: wire input-form descriptor → `RunField[]`.\n *\n * `buildRunFields` maps the standard's per-pipe descriptor STRUCTURALLY onto\n * the kernel's `RunField` shape. It decides nothing: what a field IS - its\n * kind, its constraints, its refinement chain, whether Run gates on it - is\n * stated by the wire, derived by the engine from the resolved library. The\n * heuristics that used to live here (native-concept sets, the url-bearing\n * object test, the depth-based prose/label rule) are deleted, not bypassed;\n * docs/derivation-swap.md is the record of that swap and of every behaviour\n * that moved with it.\n *\n * The contract is still consulted, for exactly two facts the wire deliberately\n * does not carry:\n *\n * - **`contentKey`** - the single property a native scalar's value sits inside\n * on the wire (`TextContent {text}`, `NumberContent {number}`). A renderer\n * holds the bare scalar; the value bridge wraps by this name. It is read off\n * the contract's `json_schema` because it is a fact about the PAYLOAD shape,\n * which is the schema's job - the descriptor describes the form, never the\n * payload.\n * - **Nested list bounds** - the wire puts `item_count` only on a top-level\n * fixed `[N]` slot, but the model behind a structured concept may state\n * `minItems`/`maxItems` on an array property of its own, and ajv enforces\n * them. Reading them off the schema is what keeps readiness from being more\n * permissive than the gate.\n *\n * Both are structural reads (a property count, two keywords ajv itself\n * enforces), not judgements - the mapper stays honest about owning no taxonomy.\n */\n\nimport type { PipeInputFormDescriptor } from 'mthds/protocol';\nimport type { InputForm, InputFormField, InputFormItem } from 'mthds/protocol';\n\nimport { buildPipeRef, type PipeInputContract } from './contracts';\nimport { formatsForKind } from './file-formats';\nimport type { RunField, RunFieldCommon } from './descriptor';\nimport { ownProp } from './own-property';\nimport { collectSchemaDefs, resolveSchemaNode, type JsonSchema } from './schema-utils';\n\n/**\n * Look up a pipe's input-form descriptor by pipe code, tolerant of both key\n * conventions - the exact mirror of `getPipeIOContract`, because the standard\n * keys `input_form` by the same `pipe_ref` set as `pipe_io_contracts` and a\n * host tracks the same bare codes either way.\n */\nexport function getPipeInputForm(\n inputForm: InputForm | null | undefined,\n domain: string | null | undefined,\n pipeCode: string | null | undefined,\n): PipeInputFormDescriptor | undefined {\n if (!inputForm || !pipeCode) return undefined;\n if (domain) {\n const byRef = ownProp(inputForm, buildPipeRef(domain, pipeCode));\n if (byRef) return byRef;\n }\n return ownProp(inputForm, pipeCode);\n}\n\n/**\n * The single property a scalar content model holds its value in - `TextContent\n * {text}`, `NumberContent {number}`, `YesNoContent {yes_no}`.\n *\n * A wrapper is a schema declaring EXACTLY ONE property. A multi-property\n * content model (`DateContent {date, time}`, `HtmlContent {inner_html,\n * css_class}`) is not one and deliberately answers `undefined` - those travel\n * as the structures they are, which the wire now also says by giving them\n * `kind: \"object\"`. Reading the declared shape rather than keeping a list of\n * wrapping concepts is what covers a concept nobody remembered to add.\n */\nfunction scalarWrapperKey(schema: JsonSchema | undefined): string | undefined {\n const props = schema?.properties as Record<string, JsonSchema> | undefined;\n const keys = props ? Object.keys(props) : [];\n return keys.length === 1 ? keys[0] : undefined;\n}\n\nfunction numOrUndef(v: unknown): number | undefined {\n return typeof v === 'number' ? v : undefined;\n}\n\n/** The inclusive bound a control can express for a wire-stated exclusive one.\n * On an integer the open interval has a nearest neighbour and the conversion\n * is exact (`> 0` IS `>= 1`), so `toNearest` steps off the endpoint onto it.\n * It rounds rather than adding one, because the endpoint need not be integral\n * - JSON Schema allows `> 0.5` on an integer node, whose nearest neighbour is\n * `1`, not `1.5`. On a float the interval has no nearest neighbour, and the\n * answer is to publish no bound at all: a control that only clamps cannot\n * express an open interval, and naming the excluded endpoint would advertise\n * the one value the gate is about to refuse. */\nfunction inclusiveFrom(\n bound: number | undefined,\n integer: boolean | undefined,\n toNearest: (endpoint: number) => number,\n): number | undefined {\n return typeof bound === 'number' && integer === true ? toNearest(bound) : undefined;\n}\n\n/** Resolve one schema node the same way the gate's validator will see it -\n * to the FIXPOINT, so a nullable `$ref` (pydantic's Optional concept-typed\n * field) yields its definition rather than an unresolved reference. */\nfunction resolveSchema(\n schema: JsonSchema | undefined,\n defs: Record<string, JsonSchema>,\n): JsonSchema | undefined {\n return schema ? resolveSchemaNode(schema, defs) : undefined;\n}\n\n/** The slots every wire node carries, mapped onto the descriptor's names. */\nfunction commonOf(node: InputFormItem, name: string): RunFieldCommon {\n return {\n name,\n title: node.title,\n conceptRef: node.concept_ref,\n refines: node.refines,\n description: node.description,\n required: node.required,\n defaultValue: node.default_value,\n examples: node.examples,\n hints: node.hints,\n };\n}\n\n/**\n * Map one wire node onto a `RunField`, walking the aligned `json_schema` node\n * beside it. The schema walk supplies only `contentKey` and list bounds (see\n * the module header); a missing or misaligned schema degrades to their absence,\n * never to a different field.\n */\nfunction mapNode(\n node: InputFormItem,\n name: string,\n rawSchema: JsonSchema | undefined,\n defs: Record<string, JsonSchema>,\n): RunField {\n const schema = resolveSchema(rawSchema, defs);\n const common = commonOf(node, name);\n\n switch (node.kind) {\n case 'text':\n case 'prose':\n return {\n ...common,\n contentKey: scalarWrapperKey(schema),\n kind: node.kind,\n minLength: node.min_length,\n maxLength: node.max_length,\n pattern: node.pattern,\n format: node.format,\n };\n case 'date':\n return { ...common, kind: 'date', datetime: node.datetime };\n case 'number':\n return {\n ...common,\n contentKey: scalarWrapperKey(schema),\n kind: 'number',\n integer: node.integer,\n // A number control clamps; it does not express open intervals. So an\n // exclusive bound becomes the nearest inclusive one where that is\n // exact (integers) and is dropped where it is not (floats) - never\n // the excluded endpoint itself, which the control would clamp onto\n // and the gate would then refuse. ajv enforces the exact keyword off\n // the schema either way, so the bound is a hint, never the rule.\n min:\n node.minimum ??\n inclusiveFrom(\n node.exclusive_minimum,\n node.integer,\n (endpoint) => Math.floor(endpoint) + 1,\n ),\n max:\n node.maximum ??\n inclusiveFrom(\n node.exclusive_maximum,\n node.integer,\n (endpoint) => Math.ceil(endpoint) - 1,\n ),\n };\n case 'boolean':\n return { ...common, contentKey: scalarWrapperKey(schema), kind: 'boolean' };\n case 'enum':\n // The wire carries the authored `choices` verbatim (`unknown[]`); the\n // control set renders and stores strings, as it always has.\n return { ...common, kind: 'enum', options: node.choices.map(String) };\n case 'document':\n case 'image':\n // `formats` is a renderer-side affordance the wire deliberately does not\n // state - which bytes a runtime can decode is a property of the runtime,\n // not of the method. The list is therefore ours, and it is one table\n // (`./file-formats`) rather than a literal here. The field carries the\n // LIST, not a label made from it, so the hint a user reads, the filter the\n // dropzone applies and the check it enforces all read one value and cannot\n // disagree - and a host narrowing it (`narrowFileFormats`) moves all three.\n // They used to disagree: this line advertised `TXT`, which no format\n // covered, and later the hint was a label while the filter and the check\n // went back to the kind's table, so rewriting the label moved nothing else.\n return { ...common, kind: node.kind, formats: formatsForKind(node.kind) };\n case 'object': {\n const props = schema?.properties as Record<string, JsonSchema> | undefined;\n return {\n ...common,\n kind: 'object',\n fields: node.fields.map((child: InputFormField) =>\n mapNode(child, child.name, props ? ownProp(props, child.name) : undefined, defs),\n ),\n };\n }\n case 'list': {\n // The item keeps the parent's name (unused for labels - the index labels\n // items), exactly as the wire's `item` carries no `name` of its own.\n const item = mapNode(node.item, name, schema?.items as JsonSchema | undefined, defs);\n const itemCount = node.item_count ?? numOrUndef(schema?.minItems);\n const maxItemCount = numOrUndef(schema?.maxItems) ?? node.item_count;\n return {\n ...common,\n kind: 'list',\n item,\n ...(itemCount === undefined ? {} : { itemCount }),\n ...(maxItemCount === undefined ? {} : { maxItemCount }),\n };\n }\n case 'unknown':\n return { ...common, kind: 'unknown' };\n }\n // Version drift: the wire states a kind this build's pinned `mthds` does not\n // define. The switch above is exhaustive over `InputFormItem`, so\n // `satisfies never` keeps the build LOUD when the PIN grows a kind - and\n // this return keeps the mapper TOTAL when a SERVER is ahead of that pin,\n // which no type can rule out. The standard's own escape hatch is the honest\n // answer (`unknown` exists so a derivation can be total truthfully): the\n // field keeps its name and falls back to raw entry against the contract's\n // `json_schema`. Returning nothing produced a field with no `name` at all -\n // unaddressable by the value bridge and unnameable by readiness.\n node satisfies never;\n return { ...common, kind: 'unknown' };\n}\n\n/**\n * Map a pipe's wire input-form descriptor onto the kernel's field descriptors,\n * with the pipe's input contracts beside it for the two schema-derived facts.\n *\n * The order is the DESCRIPTOR's - authored input order, the fact the contract's\n * `inputs` map deliberately does not carry. `required`, `presence` and `gating`\n * are taken from the wire verbatim: the standard's top-level type ties\n * `required` to the presence marker, and `gating` is the producer-derived\n * answer `mustBeFilled` reads - the kernel re-derives none of them.\n */\n/**\n * The same mapping, for a single node that belongs to no slot — a pipe's OUTPUT.\n *\n * `buildRunFields` maps a descriptor's fields and then stamps each with the slot\n * facts (`presence`, `gating`) the wire states per input. An output has no slot,\n * so this stamps nothing: the node arrives without them and leaves without them,\n * which is exactly what the standard's optional members are for.\n *\n * Everything else is shared, deliberately. An output is a concept ref like an\n * input is, so its kinds, its nesting, its list bounds and its `contentKey` are\n * the same questions with the same answers — and a second mapper would be a\n * second place for them to drift.\n *\n * ## `schema` is REQUIRED, and that is the whole point\n *\n * It was optional once, and the renderer paid for it: with no schema it could\n * not know that `native.Text`'s payload sits under `text`, so it worked the\n * unwrapping out by COUNTING the value's properties, and worked a plural payload\n * out by looking for an `items` key. Both are shape sniffing — the exact pattern\n * [../../docs/derivation-swap.md] records deleting from the input side, where\n * `contentKey` is read off a schema and handed to a control as a property NAME.\n *\n * So the parameter is required, the two heuristics are gone, and what the\n * argument must be is stated precisely: **the schema of the PAYLOAD**, which for\n * every kind but `object` is the content model that wraps it —\n * `TextContent {text}` for a `native.Text` output, `ListContent {items}` for a\n * plural one. That is a change the standard has to make on the output contract\n * (see `./output-form`); until it does, a producer supplies it beside the\n * descriptor.\n */\nexport function buildResultField(\n descriptor: { field: InputFormField },\n schema: Record<string, unknown>,\n): RunField {\n const node = descriptor.field;\n const defs: Record<string, JsonSchema> = {};\n collectSchemaDefs(schema as JsonSchema, defs, { traverseArrays: true });\n\n // Unwrap the content model, ONCE, at the top.\n //\n // A result's payload is its concept's content model, and for every kind but\n // `object` that model is a wrapper: the value sits under a single property the\n // schema names. Reading it here rather than in `mapNode` is what keeps the\n // schema walk ALIGNED with the descriptor beneath it — a plural output's node\n // is a `list`, so the schema it must be walked against is the `items` array,\n // not the `ListContent` object around it.\n //\n // Gated on the node's stated KIND, never on the value: an `object` output IS\n // its content model, and a structured concept that happens to declare exactly\n // one field would otherwise be mistaken for a wrapper. The kind comes from the\n // descriptor, so this is a read of what the field is, not a guess at it.\n const wrapperKey = node.kind === 'object' ? undefined : scalarWrapperKey(schema as JsonSchema);\n const inner =\n wrapperKey === undefined\n ? (schema as JsonSchema)\n : ((schema as JsonSchema).properties as Record<string, JsonSchema>)[wrapperKey];\n\n const field = mapNode(node, node.name, inner, defs);\n return wrapperKey === undefined ? field : { ...field, contentKey: wrapperKey };\n}\n\nexport function buildRunFields(\n descriptor: PipeInputFormDescriptor,\n inputs: Record<string, PipeInputContract>,\n): RunField[] {\n return descriptor.fields.map((node) => {\n const input = ownProp(inputs, node.name);\n const defs: Record<string, JsonSchema> = {};\n if (input) collectSchemaDefs(input.json_schema, defs, { traverseArrays: true });\n const field = mapNode(node, node.name, input?.json_schema as JsonSchema | undefined, defs);\n return { ...field, presence: node.presence, gating: node.gating };\n });\n}\n"]}
|
package/dist/core/derive.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { InputFormField, PipeInputFormDescriptor, PipeInputContract, InputForm } from 'mthds/protocol';
|
|
2
2
|
import { RunField } from './descriptor.js';
|
|
3
3
|
import './contracts.js';
|
|
4
|
+
import './file-formats.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* The ONE derivation function: wire input-form descriptor → `RunField[]`.
|
package/dist/core/derive.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { buildResultField, buildRunFields, getPipeInputForm } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
export { buildResultField, buildRunFields, getPipeInputForm } from '../chunk-ZB4RYUKV.js';
|
|
2
|
+
import '../chunk-XCO6GTEC.js';
|
|
3
3
|
import '../chunk-OD3VYXUY.js';
|
|
4
4
|
import '../chunk-WYH56SOZ.js';
|
|
5
5
|
import '../chunk-V3OV2XQT.js';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { InputPresence } from './contracts.js';
|
|
2
|
+
import { FileFormat } from './file-formats.js';
|
|
2
3
|
import 'mthds/protocol';
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -123,8 +124,18 @@ interface EnumRunField extends RunFieldCommon {
|
|
|
123
124
|
}
|
|
124
125
|
interface FileRunField extends RunFieldCommon {
|
|
125
126
|
kind: 'document' | 'image';
|
|
126
|
-
/**
|
|
127
|
-
|
|
127
|
+
/**
|
|
128
|
+
* The formats this slot accepts, in the order the hint names them. The ONE
|
|
129
|
+
* list the file control reads for all three of its answers - the hint under
|
|
130
|
+
* the dropzone, the OS picker's filter and the check a picked or dropped file
|
|
131
|
+
* must pass - so none of them can promise what another refuses.
|
|
132
|
+
*
|
|
133
|
+
* Not a wire fact: which bytes a runtime can decode is a property of the
|
|
134
|
+
* runtime, so `buildRunFields` stamps the kind's whole table here
|
|
135
|
+
* (`formatsForKind`), and a host whose own upload path takes less narrows the
|
|
136
|
+
* tree with `narrowFileFormats`.
|
|
137
|
+
*/
|
|
138
|
+
formats: readonly FileFormat[];
|
|
128
139
|
}
|
|
129
140
|
interface ObjectRunField extends RunFieldCommon {
|
|
130
141
|
kind: 'object';
|
package/dist/core/descriptor.js
CHANGED
|
@@ -50,7 +50,14 @@
|
|
|
50
50
|
* A stale entry here is worse than no list at all, because it refuses a file the
|
|
51
51
|
* runtime would have taken. If the deck grows a format, this table moves with it.
|
|
52
52
|
*
|
|
53
|
-
*
|
|
53
|
+
* **The table is the source; a field's `formats` is what gets read.** The
|
|
54
|
+
* helpers below take a format LIST rather than a kind, because what a given
|
|
55
|
+
* slot accepts can be narrower than its kind: a host whose server takes only
|
|
56
|
+
* some of these types narrows the field tree once (`narrowFileFormats`), and
|
|
57
|
+
* the dropzone's hint, its picker filter and its check all read the narrowed
|
|
58
|
+
* list, so the three cannot disagree with each other or with that server.
|
|
59
|
+
*
|
|
60
|
+
* Pure data and pure functions over it. No React, no ajv, nothing imported.
|
|
54
61
|
*/
|
|
55
62
|
/** One accepted format: its MIME type and the extensions that carry it. */
|
|
56
63
|
interface FileFormat {
|
|
@@ -74,19 +81,39 @@ declare const DOCUMENT_FORMATS: readonly FileFormat[];
|
|
|
74
81
|
* must not be refused over its spelling.
|
|
75
82
|
*/
|
|
76
83
|
declare const IMAGE_FORMATS: readonly FileFormat[];
|
|
84
|
+
/**
|
|
85
|
+
* The source table: every format a slot of this kind can take, before a host
|
|
86
|
+
* narrows it. `buildRunFields` stamps this onto each `document` and `image`
|
|
87
|
+
* field as its `formats`, and everything downstream reads the field's list
|
|
88
|
+
* rather than coming back here - which is what lets a host narrow one list and
|
|
89
|
+
* have the hint, the picker and the check all follow it.
|
|
90
|
+
*/
|
|
77
91
|
declare function formatsForKind(kind: 'document' | 'image'): readonly FileFormat[];
|
|
78
|
-
/** `"PDF, DOCX, PPTX"` — the hint shown under a dropzone. */
|
|
79
|
-
declare function acceptLabelForKind(kind: 'document' | 'image'): string;
|
|
80
92
|
/**
|
|
81
|
-
*
|
|
93
|
+
* A MIME type as the table spells it: no parameters, no surrounding space,
|
|
94
|
+
* lowercase. `APPLICATION/PDF; version=1.7` is `application/pdf`.
|
|
95
|
+
*/
|
|
96
|
+
declare function normalizeMimeType(type: string): string;
|
|
97
|
+
/** `"PDF, JPG, PNG"` - the hint shown under a dropzone. */
|
|
98
|
+
declare function acceptLabel(formats: readonly FileFormat[]): string;
|
|
99
|
+
/**
|
|
100
|
+
* The format a filename's extension names, among these formats, or `undefined`
|
|
101
|
+
* when it names none of them. Case-insensitive, because `PHOTO.PNG` is a PNG.
|
|
102
|
+
*/
|
|
103
|
+
declare function formatOfFilename(formats: readonly FileFormat[], filename: string): FileFormat | undefined;
|
|
104
|
+
/**
|
|
105
|
+
* Whether a picked file is one of these formats.
|
|
82
106
|
*
|
|
83
107
|
* Checks the MIME type first and falls back to the extension, because a
|
|
84
108
|
* browser's `File.type` is empty often enough to matter: an OS with no handler
|
|
85
109
|
* registered for `.docx` reports `''`, and refusing that file would be refusing
|
|
86
110
|
* a valid one over a fact about the user's machine. A wrong-but-present MIME
|
|
87
111
|
* type is still a rejection — that is the case this exists for.
|
|
112
|
+
*
|
|
113
|
+
* It takes the field's own list, never the kind's, so a slot a host narrowed
|
|
114
|
+
* refuses exactly what its hint no longer names.
|
|
88
115
|
*/
|
|
89
|
-
declare function isAcceptedFile(
|
|
116
|
+
declare function isAcceptedFile(formats: readonly FileFormat[], file: {
|
|
90
117
|
name: string;
|
|
91
118
|
type: string;
|
|
92
119
|
}): boolean;
|
|
@@ -97,6 +124,6 @@ declare function isAcceptedFile(kind: 'document' | 'image', file: {
|
|
|
97
124
|
* `accept` attribute is built from. Listing extensions BESIDE the MIME type is
|
|
98
125
|
* what makes the empty-`File.type` case above work in the OS picker too.
|
|
99
126
|
*/
|
|
100
|
-
declare function
|
|
127
|
+
declare function acceptMap(formats: readonly FileFormat[]): Record<string, string[]>;
|
|
101
128
|
|
|
102
|
-
export { DOCUMENT_FORMATS, type FileFormat, IMAGE_FORMATS,
|
|
129
|
+
export { DOCUMENT_FORMATS, type FileFormat, IMAGE_FORMATS, acceptLabel, acceptMap, formatOfFilename, formatsForKind, isAcceptedFile, normalizeMimeType };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { DOCUMENT_FORMATS, IMAGE_FORMATS,
|
|
1
|
+
export { DOCUMENT_FORMATS, IMAGE_FORMATS, acceptLabel, acceptMap, formatOfFilename, formatsForKind, isAcceptedFile, normalizeMimeType } from '../chunk-XCO6GTEC.js';
|
|
2
2
|
//# sourceMappingURL=file-formats.js.map
|
|
3
3
|
//# sourceMappingURL=file-formats.js.map
|
package/dist/core/index.d.ts
CHANGED
|
@@ -3,7 +3,8 @@ export { IOMultiplicity, InputForm, InputFormTopLevelField, OutputForm, PipeIOCo
|
|
|
3
3
|
export { buildResultField, buildRunFields, getPipeInputForm } from './derive.js';
|
|
4
4
|
export { getPipeOutputForm } from './output-form.js';
|
|
5
5
|
export { StuffFile, collectStuffFiles } from './stuff-files.js';
|
|
6
|
-
export { DOCUMENT_FORMATS, FileFormat, IMAGE_FORMATS,
|
|
6
|
+
export { DOCUMENT_FORMATS, FileFormat, IMAGE_FORMATS, acceptLabel, acceptMap, formatsForKind, isAcceptedFile } from './file-formats.js';
|
|
7
|
+
export { narrowFileFormats } from './narrow-file-formats.js';
|
|
7
8
|
export { CompositeMember, DataUrlView, DateContentView, DocumentContentView, HtmlContentView, ImageContentView, NATIVE_COMPOSITE_CONCEPT_REF, NATIVE_DATE_CONCEPT_REF, NATIVE_HTML_CONCEPT_REF, TYPED_SCALAR_MARKERS, formatDateContent, hasTypedScalarMarkers, isNativeCompositeNode, isNativeDateNode, isNativeHtmlNode, isViewableUrl, readCompositeContent, readDataUrl, readDateContent, readDocumentContent, readHtmlContent, readImageContent, viewableUrl } from './native-content.js';
|
|
8
9
|
export { Readiness, computeReadiness, fieldFilled, isFilled, mustBeFilled } from './readiness.js';
|
|
9
10
|
export { InputPresence, buildPipeRef, getPipeIOContract, inputMustBeFilled, isFixedCountInput, isOptionalInput, isPluralInput } from './contracts.js';
|
package/dist/core/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export { describeValidationError, displayValue, valueAtProperty } from '../chunk-RPA7DNSK.js';
|
|
2
|
-
export { apiInputsFromRunValues, fieldsForContract, inputDataFromWorkingMemory, outputsFromPipeOutput, rjsfDataFromRunValues, runValuesFromStore, setValueAtPath, storeInputDataFromRunValues } from '../chunk-
|
|
2
|
+
export { apiInputsFromRunValues, fieldsForContract, inputDataFromWorkingMemory, outputsFromPipeOutput, rjsfDataFromRunValues, runValuesFromStore, setValueAtPath, storeInputDataFromRunValues } from '../chunk-4KGQ65TQ.js';
|
|
3
|
+
export { collectStuffFiles } from '../chunk-4JQAJT7C.js';
|
|
4
|
+
export { narrowFileFormats } from '../chunk-CAKQ5VFT.js';
|
|
5
|
+
export { NATIVE_COMPOSITE_CONCEPT_REF, NATIVE_DATE_CONCEPT_REF, NATIVE_HTML_CONCEPT_REF, TYPED_SCALAR_MARKERS, formatDateContent, hasTypedScalarMarkers, isNativeCompositeNode, isNativeDateNode, isNativeHtmlNode, isViewableUrl, readCompositeContent, readDataUrl, readDateContent, readDocumentContent, readHtmlContent, readImageContent, viewableUrl } from '../chunk-TID7ZN63.js';
|
|
3
6
|
export { getPipeOutputForm } from '../chunk-DARLDVJM.js';
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export { conceptCategory } from '../chunk-25I6JDIK.js';
|
|
8
|
-
export { DOCUMENT_FORMATS, IMAGE_FORMATS, acceptLabelForKind, acceptMapForKind, formatsForKind, isAcceptedFile } from '../chunk-2JWRG53S.js';
|
|
7
|
+
export { buildResultField, buildRunFields, getPipeInputForm } from '../chunk-ZB4RYUKV.js';
|
|
8
|
+
export { conceptCategory } from '../chunk-FABY3DEY.js';
|
|
9
|
+
export { DOCUMENT_FORMATS, IMAGE_FORMATS, acceptLabel, acceptMap, formatsForKind, isAcceptedFile } from '../chunk-XCO6GTEC.js';
|
|
9
10
|
export { apiInputsFromSchemaData, buildRunInputsSchema, gateRunInputs, prepareRunInputs, validateRunInputs } from '../chunk-IUWLOSAM.js';
|
|
10
11
|
export { deflateAllInputs, deflateInput, healStringWrappers, inflateAllInputs, inflateInput, pruneEmptyOptionals, resolveConceptCode } from '../chunk-GCXV76WU.js';
|
|
11
12
|
export { normalizeSchemaForRjsf, prepareSchemaForRjsf } from '../chunk-LBFZXYCY.js';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { RunField } from './descriptor.js';
|
|
2
|
+
import './contracts.js';
|
|
3
|
+
import 'mthds/protocol';
|
|
4
|
+
import './file-formats.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Narrowing what a form's file slots accept to what a host will take.
|
|
8
|
+
*
|
|
9
|
+
* `buildRunFields` gives every `document` and `image` field the whole of its
|
|
10
|
+
* kind's table (`./file-formats`): everything the runtime can decode. A host's
|
|
11
|
+
* own upload path can be narrower - a method that only ever reads photographs,
|
|
12
|
+
* a server that stores only some types - and a dropzone that advertises more
|
|
13
|
+
* than the server takes refuses the file only after the upload has been asked
|
|
14
|
+
* for. So a host narrows the tree once, with the same list its server checks
|
|
15
|
+
* uploads against, and the control reads the narrowed list for its hint, its
|
|
16
|
+
* picker filter and its check.
|
|
17
|
+
*
|
|
18
|
+
* It reads `RunField`, the kernel's own output, and never a JSON Schema: which
|
|
19
|
+
* bytes a runtime can decode is not a wire fact, so there is nothing in the
|
|
20
|
+
* schema to read, and the two schema walks the kernel allows stay the only two.
|
|
21
|
+
*
|
|
22
|
+
* It lives in the core rather than on `FieldEnv` so that a host's server, which
|
|
23
|
+
* renders no control, can hold the very list its form was narrowed with.
|
|
24
|
+
*
|
|
25
|
+
* Pure: no React, no ajv, and the input tree is never mutated.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The field tree with every `document` and `image` field narrowed to the
|
|
30
|
+
* formats whose MIME type is in `mimeTypes`, walking nested structures and
|
|
31
|
+
* list items.
|
|
32
|
+
*
|
|
33
|
+
* One list serves every slot: it is intersected with each slot's own formats,
|
|
34
|
+
* so a list of PDF, PNG and JPEG leaves a document slot with all three and an
|
|
35
|
+
* image slot with PNG and JPEG. Narrowing never widens a slot - a MIME type the
|
|
36
|
+
* slot's kind cannot take is simply not in the intersection - and each slot
|
|
37
|
+
* keeps its own table's order, whatever order the list is in. MIME types are
|
|
38
|
+
* compared the way `isAcceptedFile` compares them: without parameters, and
|
|
39
|
+
* case-insensitively.
|
|
40
|
+
*
|
|
41
|
+
* **Throws when a slot would be left accepting nothing**, naming the field. A
|
|
42
|
+
* dropzone that refuses every file is a host's configuration error, and a form
|
|
43
|
+
* that renders one has already failed the person holding the file.
|
|
44
|
+
*
|
|
45
|
+
* The input tree is never mutated: a file slot, a structure or a list comes
|
|
46
|
+
* back as a copy, and every other field as the same object it was.
|
|
47
|
+
*/
|
|
48
|
+
declare function narrowFileFormats(fields: readonly RunField[], mimeTypes: readonly string[]): RunField[];
|
|
49
|
+
|
|
50
|
+
export { narrowFileFormats };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"narrow-file-formats.js"}
|
|
@@ -132,10 +132,7 @@ declare function readCompositeContent(value: unknown): CompositeMember[] | undef
|
|
|
132
132
|
* wants the markup rendered just the same. `refines` is on the wire for exactly
|
|
133
133
|
* this question.
|
|
134
134
|
*/
|
|
135
|
-
declare function isNativeHtmlNode(node:
|
|
136
|
-
conceptRef?: string;
|
|
137
|
-
refines?: readonly string[];
|
|
138
|
-
}): boolean;
|
|
135
|
+
declare function isNativeHtmlNode(node: NativeNode): boolean;
|
|
139
136
|
/**
|
|
140
137
|
* Whether a node IS a `native.Date` — the other content model the kind
|
|
141
138
|
* vocabulary cannot name.
|
|
@@ -150,10 +147,7 @@ declare function isNativeHtmlNode(node: {
|
|
|
150
147
|
* A `date` FIELD inside a structure is a different thing and needs none of this:
|
|
151
148
|
* it carries `kind: "date"` already.
|
|
152
149
|
*/
|
|
153
|
-
declare function isNativeDateNode(node:
|
|
154
|
-
conceptRef?: string;
|
|
155
|
-
refines?: readonly string[];
|
|
156
|
-
}): boolean;
|
|
150
|
+
declare function isNativeDateNode(node: NativeNode): boolean;
|
|
157
151
|
/**
|
|
158
152
|
* Whether a node is a `native.Composite` — a named bag of contents.
|
|
159
153
|
*
|
|
@@ -168,10 +162,25 @@ declare function isNativeDateNode(node: {
|
|
|
168
162
|
* of ordinary `StuffContent`s. Keyed by concept, a renderer can at least show
|
|
169
163
|
* the members as the named things they are. See `CompositeValue`.
|
|
170
164
|
*/
|
|
171
|
-
declare function isNativeCompositeNode(node:
|
|
165
|
+
declare function isNativeCompositeNode(node: NativeNode): boolean;
|
|
166
|
+
/**
|
|
167
|
+
* Whether a node is one of the three natives the kind vocabulary cannot name —
|
|
168
|
+
* a date, a page, a composite — which a renderer reads by CONCEPT before it
|
|
169
|
+
* reads the kind. A list of one answers no (the predicates refuse a `list`
|
|
170
|
+
* node), and its item answers yes.
|
|
171
|
+
*
|
|
172
|
+
* One answer, read twice: the result view renders a list whose item answers yes
|
|
173
|
+
* one value per line rather than as a table, and the generative layer delegates
|
|
174
|
+
* that list to the kernel, because no catalog component reads a native value.
|
|
175
|
+
* Not re-exported: a host asks the three predicates it needs.
|
|
176
|
+
*/
|
|
177
|
+
declare function isNativeValueNode(node: NativeNode): boolean;
|
|
178
|
+
/** What the native predicates read off a node: its stated kind and its concept. */
|
|
179
|
+
interface NativeNode {
|
|
180
|
+
kind?: string;
|
|
172
181
|
conceptRef?: string;
|
|
173
182
|
refines?: readonly string[];
|
|
174
|
-
}
|
|
183
|
+
}
|
|
175
184
|
/**
|
|
176
185
|
* Read a `date`-kind value, in any of the three shapes a run produces.
|
|
177
186
|
*
|
|
@@ -263,4 +272,4 @@ declare const TYPED_SCALAR_MARKERS: readonly ["__class__", "__module__"];
|
|
|
263
272
|
/** Whether a record carries the typed-scalar markers. Informational. */
|
|
264
273
|
declare function hasTypedScalarMarkers(value: unknown): boolean;
|
|
265
274
|
|
|
266
|
-
export { type CompositeMember, type DataUrlView, type DateContentView, type DocumentContentView, type HtmlContentView, type ImageContentView, NATIVE_COMPOSITE_CONCEPT_REF, NATIVE_DATE_CONCEPT_REF, NATIVE_HTML_CONCEPT_REF, TYPED_SCALAR_MARKERS, formatDateContent, hasTypedScalarMarkers, isNativeCompositeNode, isNativeDateNode, isNativeHtmlNode, isViewableUrl, readCompositeContent, readDataUrl, readDateContent, readDocumentContent, readHtmlContent, readImageContent, viewableUrl };
|
|
275
|
+
export { type CompositeMember, type DataUrlView, type DateContentView, type DocumentContentView, type HtmlContentView, type ImageContentView, NATIVE_COMPOSITE_CONCEPT_REF, NATIVE_DATE_CONCEPT_REF, NATIVE_HTML_CONCEPT_REF, TYPED_SCALAR_MARKERS, formatDateContent, hasTypedScalarMarkers, isNativeCompositeNode, isNativeDateNode, isNativeHtmlNode, isNativeValueNode, isViewableUrl, readCompositeContent, readDataUrl, readDateContent, readDocumentContent, readHtmlContent, readImageContent, viewableUrl };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { NATIVE_COMPOSITE_CONCEPT_REF, NATIVE_DATE_CONCEPT_REF, NATIVE_HTML_CONCEPT_REF, TYPED_SCALAR_MARKERS, formatDateContent, hasTypedScalarMarkers, isNativeCompositeNode, isNativeDateNode, isNativeHtmlNode, isViewableUrl, readCompositeContent, readDataUrl, readDateContent, readDocumentContent, readHtmlContent, readImageContent, viewableUrl } from '../chunk-
|
|
1
|
+
export { NATIVE_COMPOSITE_CONCEPT_REF, NATIVE_DATE_CONCEPT_REF, NATIVE_HTML_CONCEPT_REF, TYPED_SCALAR_MARKERS, formatDateContent, hasTypedScalarMarkers, isNativeCompositeNode, isNativeDateNode, isNativeHtmlNode, isNativeValueNode, isViewableUrl, readCompositeContent, readDataUrl, readDateContent, readDocumentContent, readHtmlContent, readImageContent, viewableUrl } from '../chunk-TID7ZN63.js';
|
|
2
2
|
import '../chunk-V3OV2XQT.js';
|
|
3
3
|
//# sourceMappingURL=native-content.js.map
|
|
4
4
|
//# sourceMappingURL=native-content.js.map
|
package/dist/core/readiness.d.ts
CHANGED
package/dist/core/stuff-files.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { collectStuffFiles } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
export { collectStuffFiles } from '../chunk-4JQAJT7C.js';
|
|
2
|
+
import '../chunk-TID7ZN63.js';
|
|
3
3
|
import '../chunk-V3OV2XQT.js';
|
|
4
4
|
//# sourceMappingURL=stuff-files.js.map
|
|
5
5
|
//# sourceMappingURL=stuff-files.js.map
|
package/dist/core/values.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PipeInputContract, PipeIOContract, PipeInputFormDescriptor } from 'mthds/protocol';
|
|
2
2
|
import { RunField } from './descriptor.js';
|
|
3
3
|
import './contracts.js';
|
|
4
|
+
import './file-formats.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Bridges the `MethodRunner`'s field values to the rest of the host.
|
package/dist/core/values.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { apiInputsFromRunValues, fieldsForContract, inputDataFromWorkingMemory, outputsFromPipeOutput, rjsfDataFromRunValues, runValuesFromStore, setValueAtPath, storeInputDataFromRunValues } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
1
|
+
export { apiInputsFromRunValues, fieldsForContract, inputDataFromWorkingMemory, outputsFromPipeOutput, rjsfDataFromRunValues, runValuesFromStore, setValueAtPath, storeInputDataFromRunValues } from '../chunk-4KGQ65TQ.js';
|
|
2
|
+
import '../chunk-ZB4RYUKV.js';
|
|
3
|
+
import '../chunk-XCO6GTEC.js';
|
|
4
4
|
import '../chunk-GCXV76WU.js';
|
|
5
5
|
import '../chunk-PM55AHRO.js';
|
|
6
6
|
import '../chunk-GKV77RAS.js';
|