@instruments/materialgraph 0.5.0 → 0.6.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.
@@ -8,7 +8,12 @@
8
8
  * every row carries the IDENTICAL, fixed column set, and every attribute cell
9
9
  * states its own verification alongside its value. An unknown is an explicit
10
10
  * `missing` cell with a null value — never a blank that reads as complete.
11
+ *
12
+ * ABSENT IS NOT FALSE, enforced structurally: because the column set is fixed,
13
+ * "we do not know" has to be SAID rather than omitted. Read
14
+ * {@link FinishScheduleCell.state} before printing `value`.
11
15
  */
16
+ import type { RunId, SchemeId, SlotId, VariantId } from "./identifiers.js";
12
17
  /** One schedule column: the attribute and its header text. */
13
18
  export interface FinishScheduleColumn {
14
19
  attributeId: string;
@@ -39,11 +44,16 @@ export interface FinishScheduleCell {
39
44
  confidence: number | null;
40
45
  sourceBasis: string | null;
41
46
  }
42
- /** The rolled-up grade for one row, from its evaluated criterion cells only. */
47
+ /**
48
+ * The rolled-up grade for one row, from its EVALUATED criterion cells only.
49
+ * `meets_all` is all-green on the required cells; `close` means something
50
+ * deviated, went unverified or was missing — never round it up to a pass;
51
+ * `hard_no` means a required cell failed on a real value.
52
+ */
43
53
  export type FinishScheduleGrade = "meets_all" | "close" | "hard_no";
44
54
  /** One row: one slot, one specified material, fully graded. */
45
55
  export interface FinishScheduleRow {
46
- slotId: string;
56
+ slotId: SlotId;
47
57
  slotName: string;
48
58
  /** The space NAME, or null for a spaceless slot. */
49
59
  space: string | null;
@@ -53,7 +63,8 @@ export interface FinishScheduleRow {
53
63
  brand: string;
54
64
  product: string;
55
65
  variant: string;
56
- variantId: string;
66
+ /** Opaque — round-trip verbatim into the material lenses. */
67
+ variantId: VariantId;
57
68
  /** Relative path to the public material record (`/materials/{variantId}`). */
58
69
  recordUrl: string;
59
70
  imageUrl: string | null;
@@ -65,8 +76,8 @@ export interface FinishScheduleRow {
65
76
  }
66
77
  /** A whole composed scheme as an issuable finish schedule. */
67
78
  export interface FinishSchedule {
68
- runId: string;
69
- schemeId: string;
79
+ runId: RunId;
80
+ schemeId: SchemeId;
70
81
  title: string;
71
82
  /** The compose contract version stamped on the Run, or `"unknown"`. */
72
83
  composeVersion: string;
@@ -82,7 +93,7 @@ export interface FinishScheduleResponse {
82
93
  }
83
94
  /** Options for {@link getRunSchedule}. */
84
95
  export interface GetRunScheduleOptions {
85
- /** Which composed scheme to export; defaults to the Run's first scheme. */
86
- schemeId?: string;
96
+ /** Which composed scheme to export; defaults to the Run's first scheme. Opaque. */
97
+ schemeId?: SchemeId;
87
98
  signal?: AbortSignal;
88
99
  }
package/schedule-types.js CHANGED
@@ -1,12 +1 @@
1
- /**
2
- * Finish-schedule wire types (MG-616) — the hand-mirror of
3
- * `@materialgraph/products/schemes/finish-schedule`. Kept in their own module
4
- * rather than `types.ts`, which sits at its source-size baseline.
5
- *
6
- * A finish schedule is a completed compose scheme rendered as ONE ROW PER SLOT:
7
- * the shape a specifier issues. The contract that makes it trustworthy is that
8
- * every row carries the IDENTICAL, fixed column set, and every attribute cell
9
- * states its own verification alongside its value. An unknown is an explicit
10
- * `missing` cell with a null value — never a blank that reads as complete.
11
- */
12
1
  export {};
@@ -1,4 +1,19 @@
1
+ /**
2
+ * Wire types for the governed STATIC schema (`GET /api/v1/schema/*`).
3
+ *
4
+ * THE LENS: "what does the registry DEFINE?" — blocks, attributes, units, value
5
+ * dictionaries, product types and their external mappings. Definitions, not
6
+ * data: nothing here says how many materials carry an attribute or which values
7
+ * the corpus holds. For that, use `mg.specificationFacets()` and
8
+ * `mg.attributeValues()`; for one term explained in prose, `mg.glossary()`; for
9
+ * what one material has been determined on, `mg.materialBlocks()`.
10
+ *
11
+ * Every id here (`attributeId`, `blockId`, product-type keys) is canonical
12
+ * VOCABULARY, not an opaque token — this is where you discover it rather than
13
+ * invent it.
14
+ */
1
15
  import type { OpenEnum } from "./types.js";
16
+ /** The nine governed static resources. */
2
17
  export type SchemaResource = "blocks" | "attributes" | "verticals" | "productTypes" | "units" | "valueDictionaries" | "sourceRequirements" | "productTypeTemplates" | "mappings";
3
18
  export type SchemaResourceRequest = SchemaResource;
4
19
  export interface SchemaLifecycle {
@@ -14,16 +14,36 @@ import type { SearchInput } from "./types.js";
14
14
  * and the `specifications` builders produce values assignable to this type.
15
15
  */
16
16
  /**
17
- * Optional per-filter TRUST bar the matching value must clear. `minConfidence` is
18
- * an explicit confidence floor; `sourceBasis` demands an EXACT source basis (closed
19
- * enum — an unknown basis is rejected); `meetsRequirement` folds the attribute's
20
- * registry confidence requirement server-side.
17
+ * Optional per-filter TRUST bar the matching value must clear.
18
+ *
19
+ * Raising the bar shrinks the result set for a reason worth stating: the
20
+ * materials it removes are not materials that fail the spec, they are materials
21
+ * whose claim is weaker than you demanded. That distinction is the whole point
22
+ * of this object — without it, "no GREENGUARD results" reads as "nobody is
23
+ * certified" when it means "nobody is certified TO THIS EVIDENTIAL STANDARD".
21
24
  */
22
25
  export interface SearchFilterTrust {
26
+ /** Confidence floor, 0–1. A value below it is excluded, not marked failed. */
23
27
  minConfidence?: number;
28
+ /**
29
+ * Demand an EXACT source basis (closed enum — an unknown basis is rejected).
30
+ * Roughly strongest to weakest as evidence:
31
+ * - `tested` — a measured result. The strongest claim available.
32
+ * - `declared` — the manufacturer stated it. Attributable, not independent.
33
+ * - `catalog_feed` — it arrived in a catalog feed. Trusted at ingest, unreviewed.
34
+ * - `derived` — MaterialGraph inferred it. Ours, not the manufacturer's — never
35
+ * present a `derived` value as something the brand claims.
36
+ */
24
37
  sourceBasis?: "catalog_feed" | "declared" | "derived" | "tested";
38
+ /** Fold the attribute's own registry confidence requirement in, server-side. */
25
39
  meetsRequirement?: true;
26
40
  }
41
+ /**
42
+ * One HARD criterion. Applied as a restriction BEFORE ranking, so a filtered
43
+ * search's empty result means "nothing on record satisfies this", never "nothing
44
+ * exists" — the corpus's silence and the world's are different things. Use
45
+ * `preferences` instead when a miss should demote rather than remove.
46
+ */
27
47
  export type SearchFilter = {
28
48
  attributeId: string;
29
49
  term: string;
package/spec-types.d.ts CHANGED
@@ -11,12 +11,21 @@
11
11
  * class, but with an EPD on record" reaches for a NAMED, typed criterion instead
12
12
  * of hand-assembling a magic `attribute:value` string.
13
13
  *
14
- * These criteria drive two operations equally:
15
- * - `client.search({ filters: [...] })` — spec gates layered onto a ranked
16
- * (colour / visual / lexical) search.
17
- * - `client.bySpec(...)` — the value-anchored, spec-only primitive, which takes
14
+ * These criteria drive two operations equally, and choosing between them IS the
15
+ * routing decision:
16
+ * - `client.search({ filters: [...] })` — spec gates layered onto a RANKED
17
+ * (colour / visual / lexical) search. Reach for it when relevance still
18
+ * matters: "something like this seed, but Class A".
19
+ * - `client.bySpec(...)` — the value-anchored, SPEC-ONLY primitive, which takes
18
20
  * the same criteria as `attribute:value` strings (build them with the helpers
19
- * in `./specifications`).
21
+ * in `./specifications`). Reach for it when the spec is the whole question and
22
+ * ranking would be noise.
23
+ *
24
+ * Discover the tokens before you spend them: `client.specificationFacets()` for
25
+ * what is facetable at all, `client.attributeValues()` for one attribute's
26
+ * values, `client.resolveAttribute()` / `client.resolveAttributeValue()` to turn
27
+ * a phrase into a canonical pair. A hand-guessed token returns an honest empty
28
+ * answer, which is the hardest kind of bug to see.
20
29
  */
21
30
  /**
22
31
  * The virtual attribute id that matches a certification PROGRAMME wherever it
package/spec-types.js CHANGED
@@ -11,12 +11,21 @@
11
11
  * class, but with an EPD on record" reaches for a NAMED, typed criterion instead
12
12
  * of hand-assembling a magic `attribute:value` string.
13
13
  *
14
- * These criteria drive two operations equally:
15
- * - `client.search({ filters: [...] })` — spec gates layered onto a ranked
16
- * (colour / visual / lexical) search.
17
- * - `client.bySpec(...)` — the value-anchored, spec-only primitive, which takes
14
+ * These criteria drive two operations equally, and choosing between them IS the
15
+ * routing decision:
16
+ * - `client.search({ filters: [...] })` — spec gates layered onto a RANKED
17
+ * (colour / visual / lexical) search. Reach for it when relevance still
18
+ * matters: "something like this seed, but Class A".
19
+ * - `client.bySpec(...)` — the value-anchored, SPEC-ONLY primitive, which takes
18
20
  * the same criteria as `attribute:value` strings (build them with the helpers
19
- * in `./specifications`).
21
+ * in `./specifications`). Reach for it when the spec is the whole question and
22
+ * ranking would be noise.
23
+ *
24
+ * Discover the tokens before you spend them: `client.specificationFacets()` for
25
+ * what is facetable at all, `client.attributeValues()` for one attribute's
26
+ * values, `client.resolveAttribute()` / `client.resolveAttributeValue()` to turn
27
+ * a phrase into a canonical pair. A hand-guessed token returns an honest empty
28
+ * answer, which is the hardest kind of bug to see.
20
29
  */
21
30
  /**
22
31
  * The virtual attribute id that matches a certification PROGRAMME wherever it
@@ -6,6 +6,11 @@
6
6
  * Split out of `types.ts` for the repository's source-file size budget, the same
7
7
  * reason `catalog-discovery-types.ts` sits beside it; both are re-exported from
8
8
  * `types.ts`, so importers see no difference.
9
+ *
10
+ * THE LENS: entity typeahead — it ranks NAMES, not materials. `mg.search()` is
11
+ * what answers a committed query; `mg.suggestColour()` covers colour names and
12
+ * `mg.searchVocabulary()` covers attribute/value tokens. Suggestions are a page
13
+ * of the best matches, never a census of matching entities.
9
14
  */
10
15
  /** Which kind of entity a suggestion is — and therefore what `refId` means. */
11
16
  export type SuggestKind = "product" | "brand" | "category";
@@ -25,8 +30,12 @@ export interface Suggestion {
25
30
  brandSlug: string | null;
26
31
  brandName: string | null;
27
32
  categoryKey: string | null;
28
- /** A representative variant, so a client can open a material record directly. */
33
+ /**
34
+ * A representative variant, so a client can open a material record directly.
35
+ * Opaque, and null when none was picked — not a product without variants.
36
+ */
29
37
  variantId: string | null;
38
+ /** Variants behind this entity IN MATERIALGRAPH — a coverage figure. */
30
39
  variantCount: number;
31
40
  }
32
41
  /** The suggest response: the query as interpreted, plus the ranked suggestions. */
package/suggest-types.js CHANGED
@@ -6,6 +6,11 @@
6
6
  * Split out of `types.ts` for the repository's source-file size budget, the same
7
7
  * reason `catalog-discovery-types.ts` sits beside it; both are re-exported from
8
8
  * `types.ts`, so importers see no difference.
9
+ *
10
+ * THE LENS: entity typeahead — it ranks NAMES, not materials. `mg.search()` is
11
+ * what answers a committed query; `mg.suggestColour()` covers colour names and
12
+ * `mg.searchVocabulary()` covers attribute/value tokens. Suggestions are a page
13
+ * of the best matches, never a census of matching entities.
9
14
  */
10
15
  /**
11
16
  * Shape the query string for a suggest call.