@pipelex/mthds-form 0.8.0 → 0.10.0
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 +9 -3
- package/dist/{chunk-4BSBBG2T.js → chunk-4JQAJT7C.js} +3 -3
- package/dist/{chunk-4BSBBG2T.js.map → chunk-4JQAJT7C.js.map} +1 -1
- package/dist/{chunk-T4NSAGOS.js → chunk-4KGQ65TQ.js} +4 -4
- package/dist/{chunk-T4NSAGOS.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-IIU3YK4O.js → chunk-DARLDVJM.js} +3 -3
- package/dist/{chunk-IIU3YK4O.js.map → chunk-DARLDVJM.js.map} +1 -1
- package/dist/{chunk-25I6JDIK.js → chunk-FABY3DEY.js} +2 -2
- package/dist/chunk-FABY3DEY.js.map +1 -0
- package/dist/chunk-G6BWZUGV.js +2840 -0
- package/dist/chunk-G6BWZUGV.js.map +1 -0
- package/dist/{chunk-R7B7ID25.js → chunk-IUWLOSAM.js} +4 -4
- package/dist/{chunk-R7B7ID25.js.map → chunk-IUWLOSAM.js.map} +1 -1
- package/dist/chunk-TID7ZN63.js +198 -0
- package/dist/chunk-TID7ZN63.js.map +1 -0
- package/dist/{chunk-XYQ7NXQZ.js → chunk-WYH56SOZ.js} +2 -2
- package/dist/chunk-WYH56SOZ.js.map +1 -0
- package/dist/chunk-XCO6GTEC.js +38 -0
- package/dist/chunk-XCO6GTEC.js.map +1 -0
- package/dist/{chunk-YEVVR6FE.js → chunk-Y2ND6W4W.js} +3 -3
- package/dist/{chunk-YEVVR6FE.js.map → chunk-Y2ND6W4W.js.map} +1 -1
- package/dist/{chunk-J4L32LD6.js → chunk-ZB4RYUKV.js} +5 -5
- package/dist/chunk-ZB4RYUKV.js.map +1 -0
- package/dist/core/contracts.d.ts +4 -4
- package/dist/core/contracts.js +1 -1
- package/dist/core/derive.d.ts +1 -0
- package/dist/core/derive.js +3 -3
- 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/gate.js +3 -3
- package/dist/core/gating-fields.d.ts +1 -0
- package/dist/core/gating-fields.js +2 -2
- package/dist/core/index.d.ts +3 -2
- package/dist/core/index.js +11 -10
- 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 +75 -19
- package/dist/core/native-content.js +1 -1
- package/dist/core/output-form.js +2 -2
- 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 +4 -4
- package/dist/field-renderer-BSU2hMf6.d.ts +34 -0
- package/dist/generative/index.d.ts +2106 -0
- package/dist/generative/index.js +3093 -0
- package/dist/generative/index.js.map +1 -0
- package/dist/layout-design.mthds +452 -0
- package/dist/react/index.d.ts +107 -45
- package/dist/react/index.js +8 -2614
- package/dist/react/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +19 -7
- 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-45C2MKK6.js +0 -94
- package/dist/chunk-45C2MKK6.js.map +0 -1
- package/dist/chunk-J4L32LD6.js.map +0 -1
- package/dist/chunk-XYQ7NXQZ.js.map +0 -1
|
@@ -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,MAA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E,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/contracts.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export { IOMultiplicity, PipeIOContract, PipeIOContracts, PipeInputContract, Pip
|
|
|
12
12
|
* predicates that turn a declared slot into a gating answer, and the lookup
|
|
13
13
|
* that tolerates both key conventions a real payload arrives with.
|
|
14
14
|
*
|
|
15
|
-
* `mthds` is a TYPES-ONLY
|
|
15
|
+
* `mthds` is a TYPES-ONLY dependency: every import here is `import type`,
|
|
16
16
|
* so nothing survives into `dist/` and no consumer ships the standard's CLI.
|
|
17
17
|
* `scripts/assert-bundle.mjs` holds that on the built graph and lint holds it
|
|
18
18
|
* on the source. See docs/dependency-budget.md.
|
|
@@ -34,9 +34,9 @@ export { IOMultiplicity, PipeIOContract, PipeIOContracts, PipeInputContract, Pip
|
|
|
34
34
|
* which lint and graph surfaces read and a form does not.
|
|
35
35
|
*
|
|
36
36
|
* Kept as an alias rather than renamed because a consumer imports it by this
|
|
37
|
-
* name; a host that would rather read the standard's spelling
|
|
38
|
-
* installed
|
|
39
|
-
*
|
|
37
|
+
* name; a host that would rather read the standard's spelling gets `mthds`
|
|
38
|
+
* installed alongside this package and can import `PresenceMarker` straight
|
|
39
|
+
* from `mthds/protocol`.
|
|
40
40
|
*/
|
|
41
41
|
type InputPresence = PresenceMarker;
|
|
42
42
|
/** Namespaced pipe ref (`<domain>.<pipe_code>`) - the identity convention the
|
package/dist/core/contracts.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { buildPipeRef, getPipeIOContract, inputMustBeFilled, isFixedCountInput, isOptionalInput, isPluralInput } from '../chunk-
|
|
1
|
+
export { buildPipeRef, getPipeIOContract, inputMustBeFilled, isFixedCountInput, isOptionalInput, isPluralInput } from '../chunk-WYH56SOZ.js';
|
|
2
2
|
import '../chunk-V3OV2XQT.js';
|
|
3
3
|
//# sourceMappingURL=contracts.js.map
|
|
4
4
|
//# sourceMappingURL=contracts.js.map
|
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,7 +1,7 @@
|
|
|
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
|
-
import '../chunk-
|
|
4
|
+
import '../chunk-WYH56SOZ.js';
|
|
5
5
|
import '../chunk-V3OV2XQT.js';
|
|
6
6
|
//# sourceMappingURL=derive.js.map
|
|
7
7
|
//# sourceMappingURL=derive.js.map
|
|
@@ -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/gate.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export { apiInputsFromSchemaData, buildRunInputsSchema, gateRunInputs, prepareRunInputs, validateRunInputs } from '../chunk-
|
|
1
|
+
export { apiInputsFromSchemaData, buildRunInputsSchema, gateRunInputs, prepareRunInputs, validateRunInputs } from '../chunk-IUWLOSAM.js';
|
|
2
2
|
import '../chunk-GCXV76WU.js';
|
|
3
3
|
import '../chunk-LBFZXYCY.js';
|
|
4
4
|
import '../chunk-PM55AHRO.js';
|
|
5
5
|
import '../chunk-VTPUDBSJ.js';
|
|
6
6
|
import '../chunk-GKV77RAS.js';
|
|
7
|
-
import '../chunk-
|
|
7
|
+
import '../chunk-Y2ND6W4W.js';
|
|
8
8
|
import '../chunk-OD3VYXUY.js';
|
|
9
|
-
import '../chunk-
|
|
9
|
+
import '../chunk-WYH56SOZ.js';
|
|
10
10
|
import '../chunk-V3OV2XQT.js';
|
|
11
11
|
//# sourceMappingURL=gate.js.map
|
|
12
12
|
//# sourceMappingURL=gate.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { gatingFieldsFromInputs } from '../chunk-
|
|
1
|
+
export { gatingFieldsFromInputs } from '../chunk-Y2ND6W4W.js';
|
|
2
2
|
import '../chunk-OD3VYXUY.js';
|
|
3
|
-
import '../chunk-
|
|
3
|
+
import '../chunk-WYH56SOZ.js';
|
|
4
4
|
import '../chunk-V3OV2XQT.js';
|
|
5
5
|
//# sourceMappingURL=gating-fields.js.map
|
|
6
6
|
//# sourceMappingURL=gating-fields.js.map
|
package/dist/core/index.d.ts
CHANGED
|
@@ -3,8 +3,9 @@ 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,
|
|
7
|
-
export {
|
|
6
|
+
export { DOCUMENT_FORMATS, FileFormat, IMAGE_FORMATS, acceptLabel, acceptMap, formatsForKind, isAcceptedFile } from './file-formats.js';
|
|
7
|
+
export { narrowFileFormats } from './narrow-file-formats.js';
|
|
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';
|
|
10
11
|
export { RunInputsGateResult, RunInputsVerdict, apiInputsFromSchemaData, buildRunInputsSchema, gateRunInputs, prepareRunInputs, validateRunInputs } from './gate.js';
|
package/dist/core/index.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
export { describeValidationError, displayValue, valueAtProperty } from '../chunk-RPA7DNSK.js';
|
|
2
|
-
export { apiInputsFromRunValues, fieldsForContract, inputDataFromWorkingMemory, outputsFromPipeOutput, rjsfDataFromRunValues, runValuesFromStore, setValueAtPath, storeInputDataFromRunValues } from '../chunk-
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export { NATIVE_COMPOSITE_CONCEPT_REF, NATIVE_DATE_CONCEPT_REF, NATIVE_HTML_CONCEPT_REF, TYPED_SCALAR_MARKERS, formatDateContent, hasTypedScalarMarkers, isNativeCompositeNode, isNativeDateNode, isNativeHtmlNode, isViewableUrl, readCompositeContent, readDateContent, readDocumentContent, readHtmlContent, readImageContent } from '../chunk-
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
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';
|
|
6
|
+
export { getPipeOutputForm } from '../chunk-DARLDVJM.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';
|
|
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';
|
|
12
13
|
export { computeReadiness, fieldFilled, isFilled, mustBeFilled } from '../chunk-PM55AHRO.js';
|
|
13
14
|
export { validateRunInputsSchema } from '../chunk-VTPUDBSJ.js';
|
|
14
15
|
export { asCalendarDate, dayWithinDateTime, isAcceptableDate, isAcceptableDateTime, toDateInputValue, toStoredDateValue } from '../chunk-GKV77RAS.js';
|
|
15
|
-
import '../chunk-
|
|
16
|
+
import '../chunk-Y2ND6W4W.js';
|
|
16
17
|
export { collapseNullable, collectSchemaDefs, derefSchema, flattenAnyOf, hoistDefsToRoot, resolveSchemaIndirection, schemaTypeOf } from '../chunk-OD3VYXUY.js';
|
|
17
|
-
export { buildPipeRef, getPipeIOContract, inputMustBeFilled, isFixedCountInput, isOptionalInput, isPluralInput } from '../chunk-
|
|
18
|
+
export { buildPipeRef, getPipeIOContract, inputMustBeFilled, isFixedCountInput, isOptionalInput, isPluralInput } from '../chunk-WYH56SOZ.js';
|
|
18
19
|
import '../chunk-V3OV2XQT.js';
|
|
19
20
|
//# sourceMappingURL=index.js.map
|
|
20
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -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
|
*
|
|
@@ -184,14 +193,50 @@ declare function isNativeCompositeNode(node: {
|
|
|
184
193
|
declare function readDateContent(value: unknown): DateContentView | undefined;
|
|
185
194
|
/** `{date}` / `{date, time}` as one line, which is how both are read aloud. */
|
|
186
195
|
declare function formatDateContent(content: DateContentView): string;
|
|
196
|
+
/** What a `data:` URL says about the bytes it carries. */
|
|
197
|
+
interface DataUrlView {
|
|
198
|
+
/** Lowercased, without its parameters; `text/plain` when the URL declares none. */
|
|
199
|
+
mediaType: string;
|
|
200
|
+
/** The size of the DECODED payload, in bytes. */
|
|
201
|
+
bytes: number;
|
|
202
|
+
}
|
|
187
203
|
/**
|
|
188
|
-
*
|
|
204
|
+
* A `data:` URL's media type and decoded size, or `undefined` for any other URL.
|
|
189
205
|
*
|
|
190
|
-
* A
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
206
|
+
* A host that encodes a picked file in the browser writes the file itself into
|
|
207
|
+
* the value's `url`, so a thirty-kilobyte PDF is a forty-thousand-character
|
|
208
|
+
* string, and printed where a reference would be it tells a person nothing. Its
|
|
209
|
+
* type and its size are what they can read.
|
|
210
|
+
*
|
|
211
|
+
* The size is COUNTED rather than decoded. A base64 payload's size follows from
|
|
212
|
+
* how many symbols it holds, and decoding a megabyte to measure it would be the
|
|
213
|
+
* frozen main thread {@link stripUrlWhitespace} is written to avoid. This is a
|
|
214
|
+
* reading for display, not a gate: whether the URL may be painted is still
|
|
215
|
+
* {@link viewableUrl}'s answer alone.
|
|
216
|
+
*/
|
|
217
|
+
declare function readDataUrl(candidate: string): DataUrlView | undefined;
|
|
218
|
+
/**
|
|
219
|
+
* The URL a browser can paint, normalised — or `undefined` when there is none.
|
|
220
|
+
*
|
|
221
|
+
* **The string this returns is the string a sink must use.** That is the whole
|
|
222
|
+
* point of returning one rather than answering yes or no: the gate judges a
|
|
223
|
+
* normalised URL, so handing the caller back the raw member would let the two
|
|
224
|
+
* diverge again on exactly the whitespace the parser strips.
|
|
225
|
+
*
|
|
226
|
+
* The gate parses rather than prefix-matches, and branches on the protocol the
|
|
227
|
+
* parser reports:
|
|
228
|
+
*
|
|
229
|
+
* - `http:` and `https:` are viewable.
|
|
230
|
+
* - `blob:` is viewable. A blob URL is bound to the origin that minted it, so a
|
|
231
|
+
* payload cannot forge one that points anywhere else.
|
|
232
|
+
* - `data:` is viewable only for a media type in {@link VIEWABLE_DATA_MEDIA_TYPES}.
|
|
233
|
+
* `data:text/html` is a document at the EMBEDDING page's own origin, which is
|
|
234
|
+
* what made an unsandboxed frame over a payload URL a real hole.
|
|
235
|
+
* - Everything else is not: `javascript:`, `file:` (a run on a developer's
|
|
236
|
+
* machine writes one, and a browser refuses to load it from an http page) and
|
|
237
|
+
* `pipelex-storage://`, which cannot be resolved client-side at all — that is
|
|
238
|
+
* the upload seam's job (see [../../docs/upload-seam.md]), and a renderer with
|
|
239
|
+
* no resolver must show the reference rather than a broken `<img>`.
|
|
195
240
|
*
|
|
196
241
|
* **A root-relative path counts**, and leaving it out was a real bug rather
|
|
197
242
|
* than an omission. A host's URL resolver naturally hands back a path on its
|
|
@@ -201,8 +246,19 @@ declare function formatDateContent(content: DateContentView): string;
|
|
|
201
246
|
* away and the arms fell back to the payload's `public_url`: a presigned URL
|
|
202
247
|
* that had already expired. The image stayed broken with the fix in place.
|
|
203
248
|
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
249
|
+
* A path is rejected when it is protocol-relative — `//host/x`, and the two
|
|
250
|
+
* backslash spellings the parser reads the same way (`\\host\x`, `/\host/x`) —
|
|
251
|
+
* and then checked against the sentinel as well. An accepted path is returned
|
|
252
|
+
* relative, because making it absolute against a sentinel would point it at
|
|
253
|
+
* nowhere.
|
|
254
|
+
*/
|
|
255
|
+
declare function viewableUrl(candidate: string | undefined): string | undefined;
|
|
256
|
+
/**
|
|
257
|
+
* Whether a browser can paint this URL as-is — {@link viewableUrl} as a guard.
|
|
258
|
+
*
|
|
259
|
+
* Prefer `viewableUrl` wherever the URL is then USED: this answers the question
|
|
260
|
+
* without handing back the normalised string, so a caller that acts on the raw
|
|
261
|
+
* candidate acts on a string the gate did not judge.
|
|
206
262
|
*/
|
|
207
263
|
declare function isViewableUrl(url: string | undefined): url is string;
|
|
208
264
|
/**
|
|
@@ -216,4 +272,4 @@ declare const TYPED_SCALAR_MARKERS: readonly ["__class__", "__module__"];
|
|
|
216
272
|
/** Whether a record carries the typed-scalar markers. Informational. */
|
|
217
273
|
declare function hasTypedScalarMarkers(value: unknown): boolean;
|
|
218
274
|
|
|
219
|
-
export { type CompositeMember, 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, readDateContent, readDocumentContent, readHtmlContent, readImageContent };
|
|
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, readDateContent, readDocumentContent, readHtmlContent, readImageContent } 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/output-form.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { getPipeOutputForm } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
export { getPipeOutputForm } from '../chunk-DARLDVJM.js';
|
|
2
|
+
import '../chunk-WYH56SOZ.js';
|
|
3
3
|
import '../chunk-V3OV2XQT.js';
|
|
4
4
|
//# sourceMappingURL=output-form.js.map
|
|
5
5
|
//# sourceMappingURL=output-form.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,11 +1,11 @@
|
|
|
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';
|
|
7
7
|
import '../chunk-OD3VYXUY.js';
|
|
8
|
-
import '../chunk-
|
|
8
|
+
import '../chunk-WYH56SOZ.js';
|
|
9
9
|
import '../chunk-V3OV2XQT.js';
|
|
10
10
|
//# sourceMappingURL=values.js.map
|
|
11
11
|
//# sourceMappingURL=values.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { RunField } from './core/descriptor.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Ambient state that any field in the tree may need, threaded unchanged through
|
|
6
|
+
* the recursion so containers don't have to re-plumb it for every child.
|
|
7
|
+
*/
|
|
8
|
+
interface FieldEnv {
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
/** A file field asks its parent to upload; the parent sets the value later. */
|
|
11
|
+
onDropFile?: (id: string, file: File) => void;
|
|
12
|
+
/** Ids currently mid-upload. */
|
|
13
|
+
uploadingIds?: ReadonlySet<string>;
|
|
14
|
+
/** Resolve a `pipelex-storage://` URI to a browser-viewable URL (for previews
|
|
15
|
+
* of already-stored files). */
|
|
16
|
+
resolveUrl?: (uri: string) => Promise<string | null>;
|
|
17
|
+
}
|
|
18
|
+
interface FieldRendererProps {
|
|
19
|
+
field: RunField;
|
|
20
|
+
value: unknown;
|
|
21
|
+
onChange: (value: unknown) => void;
|
|
22
|
+
/** Unique, stable id used for label linkage and upload tracking. */
|
|
23
|
+
id: string;
|
|
24
|
+
error?: string;
|
|
25
|
+
env?: FieldEnv;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The single dispatch point: a normalized `RunField` → the matching control.
|
|
29
|
+
* Object and list fields recurse back through here, so the whole form is one
|
|
30
|
+
* data-driven tree with no per-type branching anywhere else.
|
|
31
|
+
*/
|
|
32
|
+
declare function FieldRenderer({ field, value, onChange, id, error, env }: FieldRendererProps): react.JSX.Element;
|
|
33
|
+
|
|
34
|
+
export { type FieldEnv as F, FieldRenderer as a, type FieldRendererProps as b };
|