@instruments/materialgraph 0.29.0 → 0.31.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.
Files changed (89) hide show
  1. package/brands-client.d.ts +1 -1
  2. package/by-colour-types.d.ts +4 -4
  3. package/catalogue-client.d.ts +3 -3
  4. package/catalogue-client.js +3 -3
  5. package/catalogue-types.d.ts +1 -1
  6. package/client-vocabulary.d.ts +3 -5
  7. package/client-vocabulary.js +9 -6
  8. package/client.d.ts +85 -174
  9. package/client.js +98 -211
  10. package/colour-region-types.d.ts +18 -0
  11. package/colours-client.d.ts +10 -83
  12. package/colours-client.js +1 -85
  13. package/errors.d.ts +1 -1
  14. package/errors.js +1 -0
  15. package/find-companions-types.d.ts +70 -0
  16. package/find-companions-types.js +12 -0
  17. package/find-variants-by-colour-types.d.ts +197 -0
  18. package/find-variants-by-vector-types.d.ts +67 -0
  19. package/find-variants-by-vector-types.js +5 -0
  20. package/get-variant-types.d.ts +50 -0
  21. package/get-variant-types.js +10 -0
  22. package/http-transport.d.ts +1 -1
  23. package/identifiers.d.ts +1 -1
  24. package/identifiers.js +1 -1
  25. package/image-reference-types.d.ts +18 -0
  26. package/index.d.ts +9 -7
  27. package/index.js +1 -1
  28. package/list-enum-values-types.d.ts +58 -0
  29. package/list-variants-types.d.ts +6 -2
  30. package/material-asset-types.d.ts +2 -2
  31. package/material-types.d.ts +13 -151
  32. package/operations.d.ts +1 -1
  33. package/operations.js +27 -88
  34. package/package.json +1 -1
  35. package/palette-search-types.d.ts +3 -49
  36. package/resolve-colour-types.d.ts +5 -5
  37. package/resolve-variant-types.d.ts +75 -0
  38. package/{identify-types.js → resolve-variant-types.js} +2 -2
  39. package/response-schemas.generated.d.ts +1 -1
  40. package/response-schemas.generated.js +46 -84
  41. package/run-types.d.ts +23 -216
  42. package/runs.d.ts +10 -58
  43. package/runs.js +19 -106
  44. package/schema-resource-types.d.ts +2 -139
  45. package/schema-resource-types.js +0 -8
  46. package/search-card-types.d.ts +1 -1
  47. package/search-index-plan-types.d.ts +6 -2
  48. package/search-request-types.d.ts +10 -2
  49. package/spec-types.d.ts +4 -4
  50. package/spec-types.js +2 -2
  51. package/specifications.d.ts +1 -9
  52. package/specifications.js +0 -12
  53. package/sse.d.ts +2 -2
  54. package/sse.js +2 -2
  55. package/types.d.ts +4 -38
  56. package/validation.d.ts +0 -74
  57. package/validation.js +2 -116
  58. package/webmcp.generated.js +9 -9
  59. package/workflows-client.d.ts +54 -0
  60. package/workflows-client.js +41 -0
  61. package/client-source-material-comments.d.ts +0 -51
  62. package/client-source-material-comments.js +0 -6
  63. package/codes-client.d.ts +0 -118
  64. package/codes-client.js +0 -99
  65. package/codes-types.d.ts +0 -325
  66. package/colour-aggregate-types.d.ts +0 -163
  67. package/coordinate-client.d.ts +0 -23
  68. package/coordinate-client.js +0 -13
  69. package/demand-batch-types.d.ts +0 -118
  70. package/demand-types.d.ts +0 -154
  71. package/identify-types.d.ts +0 -82
  72. package/material-composition-client.d.ts +0 -21
  73. package/material-composition-client.js +0 -13
  74. package/material-composition-types.d.ts +0 -403
  75. package/material-composition-types.js +0 -1
  76. package/source-material-validation.d.ts +0 -7
  77. package/source-material-validation.js +0 -214
  78. package/spec-facet-types.d.ts +0 -48
  79. package/spec-facet-types.js +0 -7
  80. package/substitute-types.d.ts +0 -102
  81. package/substitute-types.js +0 -1
  82. package/suggest-types.d.ts +0 -67
  83. package/suggest-types.js +0 -28
  84. package/taxonomy-coverage-types.d.ts +0 -34
  85. package/taxonomy-coverage-types.js +0 -1
  86. /package/{codes-types.js → colour-region-types.js} +0 -0
  87. /package/{colour-aggregate-types.js → find-variants-by-colour-types.js} +0 -0
  88. /package/{demand-batch-types.js → image-reference-types.js} +0 -0
  89. /package/{demand-types.js → list-enum-values-types.js} +0 -0
package/colours-client.js CHANGED
@@ -3,80 +3,11 @@ export class ColoursClient {
3
3
  constructor(transport) {
4
4
  this.#transport = transport;
5
5
  }
6
- /**
7
- * THE QUESTION: "what colours does this CATEGORY come in?" — the representative
8
- * palette of 1–8 categories in ONE call (GET `/api/v1/colours/profiles`).
9
- *
10
- * An aggregate over a category, not a list of materials: use `mg.byColour()` or
11
- * `mg.search()` when you want the materials themselves, and
12
- * {@link ColoursClient.stats} for coverage across the whole corpus rather than
13
- * one category's palette. Check `basis` — this reads a scheduled materialized
14
- * view, so it can lag the catalog.
15
- *
16
- * `groupBy: "group"` takes product-type GROUP keys and merges every leaf type
17
- * under a group into one histogram BEFORE ranking — a group's palette, not the
18
- * union of its leaves' heads. `select: "diverse"` returns visually spread
19
- * swatches (greedy max-min over OKLab, 0.02 minimum separation, backfilled by
20
- * frequency if fewer survive) instead of the most frequent ones; a client
21
- * cannot recover that spread from a truncated frequency list, which is why it
22
- * is a server mode rather than a local sort.
23
- *
24
- * `groupBy: "merged"` merges across the KEYS as well and returns ONE profile
25
- * over the union of their leaves — the palette of a caller-defined facet such
26
- * as "Wood" (`wood_surface` + `wood_flooring`) that the taxonomy holds no
27
- * single node for, and that no combination of per-key responses reconstructs.
28
- * Its keys may sit at either tier, `categoryKey` is those keys sorted and
29
- * joined with `+`, and `members` hands them back so nothing has to split it.
30
- *
31
- * A selected category with no colour data comes back as a zero-count profile,
32
- * not a missing key.
33
- */
34
- async profiles(params, signal) {
35
- return await this.#transport.get("get_category_colour_profiles", {
36
- groupBy: params.groupBy,
37
- productTypeIds: params.productTypeIds.join(","),
38
- select: params.select,
39
- topN: params.topN,
40
- }, signal);
41
- }
42
- /**
43
- * THE QUESTION: "how much colour does the graph hold AT ALL?" — corpus-level
44
- * coverage, before you trust any colour answer.
45
- *
46
- * The sanity check under every other colour call. Use
47
- * {@link ColoursClient.profiles} for one category's palette and
48
- * `mg.colourFacets()` for the vocabulary. `basis.omissions` lists what this
49
- * call deliberately does not answer — read it rather than assuming silence.
50
- *
51
- * Corpus colour coverage (GET `/api/v1/colours/stats`): how much of the graph
52
- * carries colour at all, the split across the canonical colour families, and
53
- * coverage per product-type group. `basis` states the source and freshness of
54
- * each section plus `basis.omissions` — what this call deliberately does not
55
- * answer, listed rather than silently absent.
56
- *
57
- * Pass `{ groupBy: "brand,category" }` for the whole brand x category x
58
- * family matrix in one call, or a `brandSlug`/`categoryKey` scope for a slice
59
- * of it — either way it arrives as `rows`, each row carrying `brandId` and
60
- * `brandSlug` to join on. Without any of those parameters the payload is the
61
- * platform-wide one and `rows` is absent. `families` is never scoped by them.
62
- */
63
- async stats(params = {}, signal) {
64
- return await this.#transport.get("get_colour_stats", {
65
- brandId: params.brandId,
66
- brandSlug: params.brandSlug,
67
- categoryKey: params.categoryKey,
68
- family: params.family,
69
- groupBy: params.groupBy,
70
- limit: params.limit,
71
- }, signal);
72
- }
73
6
  /**
74
7
  * THE QUESTION: "what goes with this WHOLE PALETTE?" — N colours at once, at
75
8
  * stated proportions, not one colour repeated (POST `/api/v1/search/palettes`).
76
9
  *
77
- * Use `mg.byColour()` for a single colour, {@link ColoursClient.gradient} when
78
- * the colours form an ordered TRANSITION rather than a set, and
79
- * `mg.coordinate()` when the scheme is made of materials rather than colours.
10
+ * Use `mg.byColour()` for a single colour.
80
11
  *
81
12
  * Each colour scores `sim × prop`: `sim` is OKLab closeness on the same
82
13
  * mapping `byColour` ranks with, and `prop` rewards a candidate whose own
@@ -104,19 +35,4 @@ export class ColoursClient {
104
35
  async palette(input, signal) {
105
36
  return await this.#transport.post("search_by_palette", input, signal);
106
37
  }
107
- /**
108
- * THE QUESTION: "what moves from this colour to that one?" — materials that
109
- * travel ALONG a transition, in order (POST `/api/v1/search/gradients`).
110
- *
111
- * Order is the whole point: use {@link ColoursClient.palette} when the colours
112
- * are a set rather than a path, and `mg.byColour()` for a single colour.
113
- *
114
- * Not a palette: the score is multiplied by `coverage`, the share of the path
115
- * the candidate actually spans, so a material owning only one end ranks below
116
- * one that travels the whole way, and a flat single-colour material is
117
- * rejected outright however close its hue sits to the path.
118
- */
119
- async gradient(input, signal) {
120
- return await this.#transport.post("search_by_gradient", input, signal);
121
- }
122
38
  }
package/errors.d.ts CHANGED
@@ -89,7 +89,7 @@ type TransportErrorInput = {
89
89
  * member to a problem response means adding it here too, and
90
90
  * `problem-extension-parity.test.ts` fails when the two disagree.
91
91
  */
92
- export declare const MATERIALGRAPH_PROBLEM_EXTENSIONS: readonly ["ambiguous_brands", "brand_candidates", "content_length", "did_you_mean", "empty_brands", "limit_bytes", "missing_env", "orderable_attributes", "populated_alternatives", "refused_criteria", "unknown_attributes", "unknown_brands", "unknown_fields", "unorderable_attribute", "valid_group_keys", "valid_type_keys"];
92
+ export declare const MATERIALGRAPH_PROBLEM_EXTENSIONS: readonly ["ambiguous_brands", "brand_candidates", "content_length", "did_you_mean", "empty_brands", "limit_bytes", "missing_env", "orderable_attributes", "populated_alternatives", "refused_criteria", "unknown_attributes", "unknown_brands", "unknown_fields", "unknown_parameters", "unorderable_attribute", "valid_group_keys", "valid_type_keys"];
93
93
  /** The one error class thrown by all SDK transport and HTTP failures. */
94
94
  export declare class MaterialGraphError extends Error {
95
95
  readonly kind: MaterialGraphErrorKind;
package/errors.js CHANGED
@@ -36,6 +36,7 @@ export const MATERIALGRAPH_PROBLEM_EXTENSIONS = [
36
36
  "unknown_attributes",
37
37
  "unknown_brands",
38
38
  "unknown_fields",
39
+ "unknown_parameters",
39
40
  "unorderable_attribute",
40
41
  "valid_group_keys",
41
42
  "valid_type_keys",
@@ -0,0 +1,70 @@
1
+ /**
2
+ * @module find-companions-types
3
+ * @description Hand-maintained mirror of `find_companions`' (MG-2332) input and
4
+ * output wire shapes. The source of truth is
5
+ * `packages/products/src/cospec/schema.ts` (`findCompanionsInputSchema`,
6
+ * `findCompanionsResultSchema`). This SDK has no RUNTIME dependency on
7
+ * `@materialgraph/products` (it's a devDependency only, for the parity tests in
8
+ * `__tests__/`), so the shapes are copied here rather than imported.
9
+ * `contract-parity.test.ts` keeps this mirror honest against the server types,
10
+ * the project-type list included.
11
+ */
12
+ /** The closed sector vocabulary co-specification evidence is tagged with. */
13
+ export type CompanionProjectType = "Workplace" | "Residential" | "Institution Education" | "Hospitality: Hotel" | "Mixed-Use & Multi-Unit Residential" | "Healthcare" | "Hospitality: Restaurant" | "Government" | "Senior Living" | "Retail" | "Other" | "Sports Entertainment" | "Wellness" | "Medical Dental" | "Aviation" | "Industrial" | "Tech" | "Transportation" | "Single Family" | "Condominium Cooperative" | "Marine" | "Power & Energy" | "University Design Program: Interior Design" | "Non-Billable" | "University Design Program: Interior Architecture" | "University Design Program: Architecture" | "Historic Preservation";
14
+ /** At least one of `variantIds` and `materials`, at most twelve together. */
15
+ export type FindCompanionsInput = {
16
+ /** Optional row fields: image adds imageUrl, colour adds swatches. */
17
+ include?: ("image" | "colour")[];
18
+ /** Ops and audit switch: leave sample cards in. Default false. */
19
+ includeSamplingArtifacts?: boolean;
20
+ /** Companions to return, default 20, at most 100. */
21
+ limit?: number;
22
+ /** Names to resolve when you hold no ids. Misses come back unresolved. */
23
+ materials?: string[];
24
+ /** Only companions sampled together in projects of this sector. */
25
+ projectType?: CompanionProjectType;
26
+ /** Variants to find companions for. */
27
+ variantIds?: string[];
28
+ };
29
+ export type FindCompanionsRow = {
30
+ brand: string;
31
+ /** Palette likeness to the seeds. Present with `include: ["colour"]`; never reorders. */
32
+ colourFit?: number | null;
33
+ /** Present with `include: ["image"]`. */
34
+ imageUrl?: string | null;
35
+ /** Mean lift over the seeds it pairs with; above 1 is above average. */
36
+ lift: number;
37
+ product: string;
38
+ /** Why it was suggested, in one line. */
39
+ reason: string;
40
+ /** `companion` is another brand; `brand_sibling` and `colourway` share the seed's. */
41
+ relation: "companion" | "brand_sibling" | "colourway";
42
+ /** How many seeds it was sampled with. */
43
+ seedMatchCount: number;
44
+ /** Present with `include: ["colour"]`. */
45
+ swatches?: {
46
+ hex: string;
47
+ proportion: number;
48
+ }[];
49
+ variantId: string;
50
+ variantName: string | null;
51
+ };
52
+ export type FindCompanionsOutput = {
53
+ /** Strongest first: seeds matched, then summed lift, one row per product. */
54
+ companions: FindCompanionsRow[];
55
+ /** The seeds as resolved, so a caller sees what a name became. */
56
+ seeds: {
57
+ brand: string;
58
+ /** Present with `include: ["image"]`. */
59
+ imageUrl?: string | null;
60
+ product: string;
61
+ /** The id or name this seed came from. */
62
+ resolvedFrom: string;
63
+ variantId: string;
64
+ variantName: string | null;
65
+ }[];
66
+ /** Seed ids outside the materials catalogue; present only when at least one was. */
67
+ excludedByCorpusScope?: string[];
68
+ /** References that matched no variant. */
69
+ unresolved: string[];
70
+ };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @module find-companions-types
3
+ * @description Hand-maintained mirror of `find_companions`' (MG-2332) input and
4
+ * output wire shapes. The source of truth is
5
+ * `packages/products/src/cospec/schema.ts` (`findCompanionsInputSchema`,
6
+ * `findCompanionsResultSchema`). This SDK has no RUNTIME dependency on
7
+ * `@materialgraph/products` (it's a devDependency only, for the parity tests in
8
+ * `__tests__/`), so the shapes are copied here rather than imported.
9
+ * `contract-parity.test.ts` keeps this mirror honest against the server types,
10
+ * the project-type list included.
11
+ */
12
+ export {};
@@ -0,0 +1,197 @@
1
+ /**
2
+ * @module find-variants-by-colour-types
3
+ * @description Hand-maintained mirror of `find_variants_by_colour`'s
4
+ * (MG-2217/MG-2230/MG-2247/MG-2328) input and output wire shapes. The source
5
+ * of truth is `packages/products/src/search/find-variants-by-colour.ts` —
6
+ * `rerank`'s `reference.candidates`/`reference.seed` still mirror
7
+ * `compare-colour-similarity.ts`'s own seed shape, but its `matches[]` card
8
+ * is the same shape CONTAINS/PALETTE use, not a copy of that module's result.
9
+ * This SDK has no RUNTIME dependency on `@materialgraph/products` (it's a
10
+ * devDependency only, for the parity tests in `__tests__/`), so the shapes
11
+ * are copied here rather than imported. `contract-parity.test.ts` keeps this
12
+ * mirror honest against the server types.
13
+ */
14
+ import type { CorpusScope, CorpusScopeReceipt } from "./corpus-scope-types.js";
15
+ import type { ImageReferenceInput } from "./image-reference-types.js";
16
+ export type FindVariantsByColourMode = "contains" | "palette" | "rerank";
17
+ /** One colour condition. `role` defaults to `required`; every other field defaults to absent/false/0. */
18
+ export type ColourConditionInput = {
19
+ /** Name, code or hex (e.g. "sage green"). */
20
+ colour?: string;
21
+ /** Must be the swatch's largest colour. */
22
+ dominant?: boolean;
23
+ role?: "required" | "preferred";
24
+ /** Target (palette) or minimum (contains) share. */
25
+ share?: number;
26
+ /** Maximum share, e.g. an accent. */
27
+ shareMax?: number;
28
+ };
29
+ export type FindVariantsByColourInput = {
30
+ /** Brand slugs or names to filter to. */
31
+ brands?: string[];
32
+ /** One entry per colour (exactly one for rerank). */
33
+ colours?: ColourConditionInput[];
34
+ corpusScope?: CorpusScope;
35
+ cursor?: string;
36
+ /** Palette only: targets from this image's colours, not `colours[]`. */
37
+ image?: ImageReferenceInput;
38
+ limit?: number;
39
+ mode: FindVariantsByColourMode;
40
+ /** Category keys, e.g. wallcovering, floor_tile, upholstery. */
41
+ productTypeIds?: string[];
42
+ /** palette: match its palette. rerank: rank by its colour. */
43
+ targetVariantId?: string;
44
+ /** Ids to reorder by colour (rerank). */
45
+ variantIds?: string[];
46
+ };
47
+ export type ColourConditionReceipt = {
48
+ /** OKLab distance to the matched swatch. Never a probability. */
49
+ distance: number;
50
+ hex: string;
51
+ /** Position in the request's `colours[]`. */
52
+ index: number;
53
+ /** The matched swatch's share of its image, 0 to 1. */
54
+ proportion: number;
55
+ /** Requested target share, palette only; null otherwise. Ranked by, not filtered. */
56
+ target: number | null;
57
+ };
58
+ export type PaintCatalogVariant = {
59
+ brand: string;
60
+ color: string | null;
61
+ imageUrl: string | null;
62
+ product: string;
63
+ variantId: string;
64
+ variantName: string | null;
65
+ };
66
+ export type ResolvedColour = {
67
+ catalogueVariant: PaintCatalogVariant | null;
68
+ hex: string;
69
+ index: number;
70
+ /** `region`: a named meaning's own OKLCh bounds, kept — never collapsed to one hex. */
71
+ kind: "point" | "region";
72
+ /** Renormalised share, image-extracted colours only; else null. */
73
+ share: number | null;
74
+ };
75
+ export type ColourAlternative = {
76
+ code?: string;
77
+ hex: string;
78
+ libraryId: string;
79
+ libraryName: string;
80
+ name: string;
81
+ query: string;
82
+ };
83
+ export type UnresolvedColour = {
84
+ alternatives: ColourAlternative[];
85
+ index: number;
86
+ input: string | null;
87
+ };
88
+ export type ColourVariantMatch = {
89
+ brand: string;
90
+ brandId: string;
91
+ category: string;
92
+ code: string | null;
93
+ colours: ColourConditionReceipt[];
94
+ /** Share of the request's colours this variant matched, 0 to 1. Never a probability. */
95
+ coverage: number;
96
+ imageUrl: string | null;
97
+ product: string;
98
+ productId: string;
99
+ variantId: string;
100
+ variantName: string;
101
+ };
102
+ export type ColourPageInfo = {
103
+ endCursor: string | null;
104
+ hasNextPage: boolean;
105
+ /**
106
+ * True when matches exist that the ranked pool never checked, so a
107
+ * narrower scope would surface them; the page may under-report, never
108
+ * over-report. `contains`: set on every page once the gated set outgrew
109
+ * its ColorVec ordering, and always when unscoped. `palette`: set only on
110
+ * the page where paging stops at the pool's 400 cap.
111
+ */
112
+ poolTruncated: boolean;
113
+ };
114
+ type ContainsOrPaletteResult = {
115
+ /** Colour-matched candidates dropped by `list_variants`' hard filters or eligibility. */
116
+ gatedOut: number;
117
+ matches: ColourVariantMatch[];
118
+ pageInfo: ColourPageInfo;
119
+ resolvedColours: ResolvedColour[];
120
+ unresolvedColours: UnresolvedColour[];
121
+ };
122
+ export type FindVariantsByColourContainsResult = ContainsOrPaletteResult & {
123
+ mode: "contains";
124
+ };
125
+ export type FindVariantsByColourPaletteResult = ContainsOrPaletteResult & {
126
+ mode: "palette";
127
+ };
128
+ /** `reference.candidates`/`reference.seed`'s shape — mirrors `compare-colour-similarity.ts`'s own seed, unlike `matches[]` below. */
129
+ export type ColourRankedSeed = {
130
+ brand: string;
131
+ brandSlug: string;
132
+ color: string | null;
133
+ imageUrl: string | null;
134
+ product: string;
135
+ productId: string;
136
+ variantId: string;
137
+ /** The variant's own name — paint colourway names live here (label contract). */
138
+ variantName: string | null;
139
+ };
140
+ /** RERANK's own card — the same shape `ColourVariantMatch` above (`brandId`, `code`), plus its two ranking-only fields. */
141
+ export type ColourRankMatch = {
142
+ brand: string;
143
+ brandId: string;
144
+ code: string | null;
145
+ /** Colour similarity in [0,1], 1 = identical palette; null when unembedded. */
146
+ colourSimilarity: number | null;
147
+ /** Cosine distance computed in TypeScript (0 = identical); null when unembedded. */
148
+ distance: number | null;
149
+ imageUrl: string | null;
150
+ product: string;
151
+ productId: string;
152
+ variantId: string;
153
+ variantName: string | null;
154
+ };
155
+ export type ResolvedColourReference = {
156
+ hex: string;
157
+ name: string | null;
158
+ ref: string;
159
+ };
160
+ export type CompareColourSimilarityReference = {
161
+ /** Best-per-brand candidates when `resolution === "ambiguous"`; empty otherwise. */
162
+ candidates: ColourRankedSeed[];
163
+ /** The resolved colour when the reference was a `colour`, else null. */
164
+ colour: ResolvedColourReference | null;
165
+ /** The input as given, so an agent can react to a miss. */
166
+ input: {
167
+ colour?: string;
168
+ material?: string;
169
+ oklab?: {
170
+ L: number;
171
+ a: number;
172
+ b: number;
173
+ };
174
+ variantId?: string;
175
+ };
176
+ /** `ambiguous` when a colour-name material reference spans several brands. */
177
+ resolution: "resolved" | "ambiguous";
178
+ /** The resolved seed when the reference was a `material`/`variantId`, else null. */
179
+ seed: ColourRankedSeed | null;
180
+ };
181
+ export type FindVariantsByColourRerankResult = {
182
+ /** Present ONLY when the request narrowed it. ABSENT means the whole graph. */
183
+ corpusScope?: CorpusScopeReceipt;
184
+ /** Real variant ids outside `corpusScope` or the materials catalogue. Present when a scope narrowed or any was excluded. */
185
+ excludedByCorpusScope?: string[];
186
+ /** Candidates ranked by ascending colour distance; unembedded ones last. */
187
+ matches: ColourRankMatch[];
188
+ mode: "rerank";
189
+ /** The reference, echoed with its resolution. */
190
+ reference: CompareColourSimilarityReference;
191
+ /** The reference colour, echoed in the same shape CONTAINS/PALETTE use — always 0 or 1 entries. */
192
+ resolvedColours: ResolvedColour[];
193
+ /** Candidate ids that did not resolve to any variant. */
194
+ unresolved: string[];
195
+ };
196
+ export type FindVariantsByColourOutput = FindVariantsByColourContainsResult | FindVariantsByColourPaletteResult | FindVariantsByColourRerankResult;
197
+ export {};
@@ -0,0 +1,67 @@
1
+ /**
2
+ * @module find-variants-by-vector-types
3
+ * @description Hand-maintained mirror of `find_variants_by_vector`'s
4
+ * (MG-2231) input and output wire shapes. The source of truth is
5
+ * `packages/products/src/vector-discovery/find-variants-by-vector.ts`; this
6
+ * SDK has no runtime dependency on `@materialgraph/products`, so the shapes
7
+ * are copied here and `contract-parity.test.ts` keeps them honest.
8
+ */
9
+ import type { ImageReferenceInput } from "./image-reference-types.js";
10
+ import type { FilterGroups, ListVariantsItem } from "./list-variants-types.js";
11
+ export declare const FIND_VARIANTS_BY_VECTOR_MODES: readonly ["text", "image", "text_and_image"];
12
+ export type FindVariantsByVectorMode = (typeof FIND_VARIANTS_BY_VECTOR_MODES)[number];
13
+ export type FindVariantsByVectorQuery = {
14
+ /** Exactly one reference. Only for image modes. */
15
+ image?: ImageReferenceInput;
16
+ mode: FindVariantsByVectorMode;
17
+ /** Description, mood words included. Only for text modes. */
18
+ text?: string;
19
+ };
20
+ export type FindVariantsByVectorInput = {
21
+ /** Attribute or block ids to add. */
22
+ attributes?: string[];
23
+ /** Variant ids to leave out. A seed image's own variant is always left out. */
24
+ excludeVariantIds?: string[];
25
+ filters?: FilterGroups;
26
+ /** Default 20. */
27
+ limit?: number;
28
+ query: FindVariantsByVectorQuery;
29
+ };
30
+ export type FindVariantsByVectorItem = Omit<ListVariantsItem, "materialBankId"> & {
31
+ /** The variant's Material Bank SKU; null means none is recorded. Always present here, unlike `list_variants`' optional field. */
32
+ materialBankId: string | null;
33
+ /** Voyage cosine to the query. Ranks only; not a probability. */
34
+ similarity: number;
35
+ };
36
+ export type FindVariantsByVectorReference = {
37
+ id: string;
38
+ kind: "url" | "assetId" | "variantId" | "sourceId";
39
+ } | null;
40
+ export type FindVariantsByVectorScan = {
41
+ /** True when no further candidates match; false means more may exist. */
42
+ exhausted: boolean;
43
+ read: number;
44
+ rejected: number;
45
+ route: "lane" | "metadata" | "allowlist";
46
+ };
47
+ export type FindVariantsByVectorTimings = {
48
+ embedMs: number;
49
+ filterMs: number;
50
+ referenceMs: number;
51
+ totalMs: number;
52
+ vectorMs: number;
53
+ verifyMs: number;
54
+ };
55
+ export type FindVariantsByVectorOutput = {
56
+ /** Explicit `{field: "variant", op: "in"}` filter ids that name a real variant outside the materials catalogue — present only when at least one did. */
57
+ excludedByCorpusScope?: string[];
58
+ items: FindVariantsByVectorItem[];
59
+ mode: FindVariantsByVectorMode;
60
+ reference: FindVariantsByVectorReference;
61
+ scan: FindVariantsByVectorScan;
62
+ timings: FindVariantsByVectorTimings;
63
+ /** Explicit `{field: "variant", op: "in"}` filter ids that named no eligible variant — present only when at least one did. */
64
+ unresolvedVariantIds?: string[];
65
+ /** Filtered attributes no variant in scope states at all. Present only on an empty page, so its absence means the empty page is a genuine no-match. */
66
+ unstated?: string[];
67
+ };
@@ -0,0 +1,5 @@
1
+ export const FIND_VARIANTS_BY_VECTOR_MODES = [
2
+ "text",
3
+ "image",
4
+ "text_and_image",
5
+ ];
@@ -0,0 +1,50 @@
1
+ /**
2
+ * @module get-variant-types
3
+ * @description Hand-maintained mirror of `get_variant`'s (MG-2251) input and
4
+ * output wire shapes. The source of truth is
5
+ * `packages/products/src/variants/get-variant.ts`, but this SDK has no RUNTIME
6
+ * dependency on `@materialgraph/products`, so the shapes are copied here and
7
+ * `__tests__/contract-parity.test.ts` keeps the mirror honest against the
8
+ * server types.
9
+ */
10
+ import type { ListVariantsNotApplicable, ListVariantsSpecifications } from "./list-variants-types.js";
11
+ /** The detail to add under `specifications`; absent, the answer is the compact item alone. */
12
+ export type GetVariantOptions = {
13
+ /** Canonical attribute ids, e.g. `["nrc_rating"]`. */
14
+ attributes?: readonly string[];
15
+ /** Canonical block ids, returned whole, e.g. `["acoustic"]`. */
16
+ blocks?: readonly string[];
17
+ };
18
+ /**
19
+ * One variant: the compact identity, and `specifications` only for the
20
+ * attributes and blocks that were asked for. A null value is unknown, never
21
+ * false or zero.
22
+ */
23
+ export type GetVariantOutput = {
24
+ category: {
25
+ id: string;
26
+ name: string;
27
+ };
28
+ code: string | null;
29
+ image: {
30
+ alt: string;
31
+ url: string;
32
+ } | null;
33
+ /** The brand. `id` is the slug `get_brand` takes. */
34
+ brand: {
35
+ id: string;
36
+ name: string;
37
+ };
38
+ /** The variant's Material Bank SKU. Absent means none is recorded. */
39
+ materialBankId?: string;
40
+ name: string;
41
+ /** Requested blocks or attributes the variant's product type does not carry. */
42
+ notApplicable?: ListVariantsNotApplicable;
43
+ product: {
44
+ id: string;
45
+ name: string;
46
+ };
47
+ specifications?: ListVariantsSpecifications;
48
+ url: string | null;
49
+ variantId: string;
50
+ };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @module get-variant-types
3
+ * @description Hand-maintained mirror of `get_variant`'s (MG-2251) input and
4
+ * output wire shapes. The source of truth is
5
+ * `packages/products/src/variants/get-variant.ts`, but this SDK has no RUNTIME
6
+ * dependency on `@materialgraph/products`, so the shapes are copied here and
7
+ * `__tests__/contract-parity.test.ts` keeps the mirror honest against the
8
+ * server types.
9
+ */
10
+ export {};
@@ -1,6 +1,6 @@
1
1
  import type { RateLimit } from "./errors.js";
2
2
  import type { SdkOperation } from "./operations.js";
3
- export type QueryValue = string | number | boolean | undefined | null | (string | number | boolean)[];
3
+ type QueryValue = string | number | boolean | undefined | null | (string | number | boolean)[];
4
4
  export type QueryParams = Record<string, QueryValue>;
5
5
  export type RequestOptions = {
6
6
  /** Required by state-changing operations that support safe retries. */
package/identifiers.d.ts CHANGED
@@ -15,7 +15,7 @@
15
15
  * - **Canonical vocabulary** — `attributeId`, `term`, `productTypeId`,
16
16
  * `categoryKey`, `jurisdictionId`, `brandSlug`. These ARE meaningful, stable,
17
17
  * and yours to compose queries from — but you DISCOVER them rather than
18
- * invent them (`specificationFacets()`, `attributeValues()`,
18
+ * invent them (`listVariantFacets()`, `listEnumValues()`,
19
19
  * `listAttributes()`, `taxonomy()`, `colourFacets()`, `codes.context()`).
20
20
  * A hand-guessed canonical token is the second-most-common caller bug.
21
21
  *
package/identifiers.js CHANGED
@@ -15,7 +15,7 @@
15
15
  * - **Canonical vocabulary** — `attributeId`, `term`, `productTypeId`,
16
16
  * `categoryKey`, `jurisdictionId`, `brandSlug`. These ARE meaningful, stable,
17
17
  * and yours to compose queries from — but you DISCOVER them rather than
18
- * invent them (`specificationFacets()`, `attributeValues()`,
18
+ * invent them (`listVariantFacets()`, `listEnumValues()`,
19
19
  * `listAttributes()`, `taxonomy()`, `colourFacets()`, `codes.context()`).
20
20
  * A hand-guessed canonical token is the second-most-common caller bug.
21
21
  *
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @module image-reference-types
3
+ * @description The one image-reference shape the vector-discovery lenses
4
+ * share (`@materialgraph/products/vector-discovery/image-reference`'s
5
+ * `imageReferenceInputSchema`): a catalogue asset, an upload, a public URL,
6
+ * or an existing variant's own image. Exactly one field is set per call; the
7
+ * server refuses more than one.
8
+ */
9
+ export type ImageReferenceInput = {
10
+ /** Catalogue asset id. */
11
+ assetId?: string;
12
+ /** Upload id (`smf_...`) from source-material. */
13
+ sourceId?: string;
14
+ /** Public HTTPS image URL. */
15
+ url?: string;
16
+ /** Variant whose image to use. */
17
+ variantId?: string;
18
+ };
package/index.d.ts CHANGED
@@ -1,28 +1,31 @@
1
1
  export { MaterialGraphClient, DEFAULT_BASE_URL } from "./client.js";
2
- export type { MaterialGraphClientOptions, SourceMaterialCommentsNamespace, } from "./client.js";
2
+ export type { MaterialGraphClientOptions } from "./client.js";
3
3
  export type * from "./list-variants-types.js";
4
4
  export type * from "./list-variant-facets-types.js";
5
+ export type * from "./list-enum-values-types.js";
6
+ export type * from "./get-variant-types.js";
7
+ export type * from "./image-reference-types.js";
8
+ export type * from "./find-companions-types.js";
9
+ export type * from "./find-variants-by-colour-types.js";
10
+ export { FIND_VARIANTS_BY_VECTOR_MODES } from "./find-variants-by-vector-types.js";
11
+ export type * from "./find-variants-by-vector-types.js";
5
12
  export { MATERIALGRAPH_API_VERSION, SDK_OPERATIONS } from "./operations.js";
6
13
  export type { SdkOperation, SdkOperationId } from "./operations.js";
7
14
  export type * from "./identifiers.js";
8
15
  export { TERMINAL_RUN_EVENT_TYPES } from "./run-types.js";
9
16
  export type * from "./run-types.js";
10
17
  export type * from "./citation-types.js";
11
- export type * from "./material-composition-types.js";
12
18
  export { MATERIALGRAPH_PROBLEM_EXTENSIONS, MaterialGraphError, } from "./errors.js";
13
19
  export type { MaterialGraphErrorInit, MaterialGraphErrorKind, MaterialGraphRequestMetadata, ProblemDetail, RateLimit, SanitizedErrorValue, SanitizedIssue, SimpleErrorBody, } from "./errors.js";
14
20
  export type * from "./types.js";
15
21
  export type * from "./search-card-types.js";
16
- export type * from "./identify-types.js";
22
+ export type * from "./resolve-variant-types.js";
17
23
  export type * from "./catalogue-types.js";
18
24
  export type * from "./by-colour-types.js";
19
25
  export { CategoriesClient } from "./categories-client.js";
20
26
  export type * from "./category-types.js";
21
- export { CodesClient } from "./codes-client.js";
22
- export type * from "./codes-types.js";
23
27
  export { ColoursClient } from "./colours-client.js";
24
28
  export type { ColoursTransport } from "./colours-client.js";
25
- export type * from "./colour-aggregate-types.js";
26
29
  export type * from "./palette-search-types.js";
27
30
  export type * from "./query-understanding-types.js";
28
31
  export type * from "./match-types.js";
@@ -34,7 +37,6 @@ export type * from "./brand-types.js";
34
37
  export type * from "./material-asset-types.js";
35
38
  export type * from "./material-block-types.js";
36
39
  export type * from "./schema-resource-types.js";
37
- export type * from "./taxonomy-coverage-types.js";
38
40
  export type * from "./search-refinement-types.js";
39
41
  export type * from "./attribution-types.js";
40
42
  export { CERTIFICATION_PROGRAMME_ATTRIBUTE_ID } from "./spec-types.js";
package/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  export { MaterialGraphClient, DEFAULT_BASE_URL } from "./client.js";
2
+ export { FIND_VARIANTS_BY_VECTOR_MODES } from "./find-variants-by-vector-types.js";
2
3
  export { MATERIALGRAPH_API_VERSION, SDK_OPERATIONS } from "./operations.js";
3
4
  export { TERMINAL_RUN_EVENT_TYPES } from "./run-types.js";
4
5
  export { MATERIALGRAPH_PROBLEM_EXTENSIONS, MaterialGraphError, } from "./errors.js";
5
6
  export { CategoriesClient } from "./categories-client.js";
6
- export { CodesClient } from "./codes-client.js";
7
7
  export { ColoursClient } from "./colours-client.js";
8
8
  export { MATCH_ERROR_REASONS, MATCH_IMAGE_TYPES, MATCH_OUTCOMES, MATCH_MATERIAL_FUNCTIONS, MATCH_STREAM_EVENT_TYPES, MATCH_SURFACE_STATUSES, MATCH_WORKFLOW_STEPS, } from "./match-stream-types.js";
9
9
  export { CERTIFICATION_PROGRAMME_ATTRIBUTE_ID } from "./spec-types.js";