@instruments/materialgraph 0.28.0 → 0.30.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/brands-client.d.ts +1 -1
- package/by-colour-types.d.ts +4 -4
- package/catalogue-client.d.ts +3 -3
- package/catalogue-client.js +3 -3
- package/catalogue-types.d.ts +1 -1
- package/client-vocabulary.d.ts +3 -5
- package/client-vocabulary.js +9 -6
- package/client.d.ts +73 -174
- package/client.js +85 -211
- package/colour-region-types.d.ts +18 -0
- package/colours-client.d.ts +10 -83
- package/colours-client.js +1 -85
- package/find-variants-by-colour-types.d.ts +197 -0
- package/find-variants-by-vector-types.d.ts +67 -0
- package/find-variants-by-vector-types.js +5 -0
- package/get-variant-types.d.ts +50 -0
- package/get-variant-types.js +10 -0
- package/identifiers.d.ts +1 -1
- package/identifiers.js +1 -1
- package/image-reference-types.d.ts +18 -0
- package/index.d.ts +8 -7
- package/index.js +1 -1
- package/list-enum-values-types.d.ts +58 -0
- package/list-variants-types.d.ts +6 -2
- package/material-asset-types.d.ts +4 -3
- package/material-types.d.ts +11 -150
- package/operations.d.ts +1 -1
- package/operations.js +26 -88
- package/package.json +1 -1
- package/palette-search-types.d.ts +3 -49
- package/resolve-colour-types.d.ts +5 -5
- package/resolve-variant-types.d.ts +75 -0
- package/{identify-types.js → resolve-variant-types.js} +2 -2
- package/response-schemas.generated.d.ts +1 -1
- package/response-schemas.generated.js +45 -84
- package/run-types.d.ts +23 -216
- package/runs.d.ts +10 -58
- package/runs.js +19 -106
- package/schema-resource-types.d.ts +2 -139
- package/schema-resource-types.js +0 -8
- package/search-card-types.d.ts +1 -1
- package/search-index-plan-types.d.ts +4 -1
- package/search-request-types.d.ts +10 -2
- package/spec-types.d.ts +4 -4
- package/spec-types.js +2 -2
- package/sse.d.ts +2 -2
- package/sse.js +2 -2
- package/types.d.ts +4 -38
- package/webmcp.generated.js +3 -3
- package/workflows-client.d.ts +54 -0
- package/workflows-client.js +41 -0
- package/client-source-material-comments.d.ts +0 -51
- package/client-source-material-comments.js +0 -6
- package/codes-client.d.ts +0 -118
- package/codes-client.js +0 -99
- package/codes-types.d.ts +0 -325
- package/colour-aggregate-types.d.ts +0 -163
- package/coordinate-client.d.ts +0 -23
- package/coordinate-client.js +0 -13
- package/demand-batch-types.d.ts +0 -118
- package/demand-types.d.ts +0 -154
- package/identify-types.d.ts +0 -82
- package/material-composition-client.d.ts +0 -21
- package/material-composition-client.js +0 -13
- package/material-composition-types.d.ts +0 -403
- package/material-composition-types.js +0 -1
- package/source-material-validation.d.ts +0 -7
- package/source-material-validation.js +0 -214
- package/spec-facet-types.d.ts +0 -48
- package/spec-facet-types.js +0 -7
- package/substitute-types.d.ts +0 -102
- package/substitute-types.js +0 -1
- package/suggest-types.d.ts +0 -67
- package/suggest-types.js +0 -28
- package/taxonomy-coverage-types.d.ts +0 -34
- package/taxonomy-coverage-types.js +0 -1
- /package/{codes-types.js → colour-region-types.js} +0 -0
- /package/{colour-aggregate-types.js → find-variants-by-colour-types.js} +0 -0
- /package/{demand-batch-types.js → image-reference-types.js} +0 -0
- /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
|
|
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
|
}
|
|
@@ -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,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 {};
|
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 (`
|
|
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 (`
|
|
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,30 @@
|
|
|
1
1
|
export { MaterialGraphClient, DEFAULT_BASE_URL } from "./client.js";
|
|
2
|
-
export type { MaterialGraphClientOptions
|
|
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-variants-by-colour-types.js";
|
|
9
|
+
export { FIND_VARIANTS_BY_VECTOR_MODES } from "./find-variants-by-vector-types.js";
|
|
10
|
+
export type * from "./find-variants-by-vector-types.js";
|
|
5
11
|
export { MATERIALGRAPH_API_VERSION, SDK_OPERATIONS } from "./operations.js";
|
|
6
12
|
export type { SdkOperation, SdkOperationId } from "./operations.js";
|
|
7
13
|
export type * from "./identifiers.js";
|
|
8
14
|
export { TERMINAL_RUN_EVENT_TYPES } from "./run-types.js";
|
|
9
15
|
export type * from "./run-types.js";
|
|
10
16
|
export type * from "./citation-types.js";
|
|
11
|
-
export type * from "./material-composition-types.js";
|
|
12
17
|
export { MATERIALGRAPH_PROBLEM_EXTENSIONS, MaterialGraphError, } from "./errors.js";
|
|
13
18
|
export type { MaterialGraphErrorInit, MaterialGraphErrorKind, MaterialGraphRequestMetadata, ProblemDetail, RateLimit, SanitizedErrorValue, SanitizedIssue, SimpleErrorBody, } from "./errors.js";
|
|
14
19
|
export type * from "./types.js";
|
|
15
20
|
export type * from "./search-card-types.js";
|
|
16
|
-
export type * from "./
|
|
21
|
+
export type * from "./resolve-variant-types.js";
|
|
17
22
|
export type * from "./catalogue-types.js";
|
|
18
23
|
export type * from "./by-colour-types.js";
|
|
19
24
|
export { CategoriesClient } from "./categories-client.js";
|
|
20
25
|
export type * from "./category-types.js";
|
|
21
|
-
export { CodesClient } from "./codes-client.js";
|
|
22
|
-
export type * from "./codes-types.js";
|
|
23
26
|
export { ColoursClient } from "./colours-client.js";
|
|
24
27
|
export type { ColoursTransport } from "./colours-client.js";
|
|
25
|
-
export type * from "./colour-aggregate-types.js";
|
|
26
28
|
export type * from "./palette-search-types.js";
|
|
27
29
|
export type * from "./query-understanding-types.js";
|
|
28
30
|
export type * from "./match-types.js";
|
|
@@ -34,7 +36,6 @@ export type * from "./brand-types.js";
|
|
|
34
36
|
export type * from "./material-asset-types.js";
|
|
35
37
|
export type * from "./material-block-types.js";
|
|
36
38
|
export type * from "./schema-resource-types.js";
|
|
37
|
-
export type * from "./taxonomy-coverage-types.js";
|
|
38
39
|
export type * from "./search-refinement-types.js";
|
|
39
40
|
export type * from "./attribution-types.js";
|
|
40
41
|
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";
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module list-enum-values-types
|
|
3
|
+
* @description Hand-maintained mirror of `list_enum_values`'s (MG-2225) input
|
|
4
|
+
* and output wire shapes. The source of truth is
|
|
5
|
+
* `packages/products/src/materials/list-enum-values.ts`; this SDK has no
|
|
6
|
+
* runtime dependency on `@materialgraph/products`, so the shapes are copied
|
|
7
|
+
* here and `contract-parity.test.ts` keeps them honest.
|
|
8
|
+
*/
|
|
9
|
+
import type { OpenEnum } from "./types.js";
|
|
10
|
+
/** Options for `listEnumValues()` (GET `/api/v1/catalog/enum-values`). */
|
|
11
|
+
export type ListEnumValuesOptions = {
|
|
12
|
+
/**
|
|
13
|
+
* A value dictionary id, from a `listAttributes()` item's `dictionaryId`.
|
|
14
|
+
* Required without a `query`; with a `query`, omit it to search every
|
|
15
|
+
* dictionary.
|
|
16
|
+
*/
|
|
17
|
+
dictionaryId?: string;
|
|
18
|
+
/** A value name, alias, misspelling or meaning. Omit to browse a dictionary. */
|
|
19
|
+
query?: string;
|
|
20
|
+
/** Items per page, 1 to 50. Default 20. */
|
|
21
|
+
limit?: number;
|
|
22
|
+
/** `pageInfo.endCursor` from the previous page, with the same query and dictionary. */
|
|
23
|
+
cursor?: string;
|
|
24
|
+
};
|
|
25
|
+
/** How an item was found. A distance or similarity compares only within one method. */
|
|
26
|
+
export type EnumValueMatch = {
|
|
27
|
+
method: OpenEnum<"exact" | "alias" | "fuzzy" | "vector">;
|
|
28
|
+
/** The id, label or alias that matched, or null for a match by meaning. */
|
|
29
|
+
matchedText: string | null;
|
|
30
|
+
/** Fuse distance, 0 best. */
|
|
31
|
+
distance?: number;
|
|
32
|
+
/** Set when the query named a deprecated term: the active term it was resolved from. */
|
|
33
|
+
resolvedFrom?: string;
|
|
34
|
+
/** Cosine similarity, 1 best. */
|
|
35
|
+
similarity?: number;
|
|
36
|
+
};
|
|
37
|
+
/** One allowed value of a dictionary. */
|
|
38
|
+
export type EnumValueItem = {
|
|
39
|
+
/** The attributes this value can filter `listVariants()` on; empty when it cannot be filtered on. */
|
|
40
|
+
attributeIds: string[];
|
|
41
|
+
/** The taxonomy's definition when the value resolves to a canonical concept, otherwise null. */
|
|
42
|
+
definition: string | null;
|
|
43
|
+
dictionaryId: string;
|
|
44
|
+
label: string;
|
|
45
|
+
/** Present only when the page answers a query. */
|
|
46
|
+
match?: EnumValueMatch;
|
|
47
|
+
/** The bare term id `listVariants()` accepts for any of `attributeIds`. */
|
|
48
|
+
valueId: string;
|
|
49
|
+
};
|
|
50
|
+
export type ListEnumValuesResult = {
|
|
51
|
+
/** The dictionary the page was read from; null when a query searched every dictionary. */
|
|
52
|
+
dictionaryId: string | null;
|
|
53
|
+
items: EnumValueItem[];
|
|
54
|
+
pageInfo: {
|
|
55
|
+
endCursor: string | null;
|
|
56
|
+
hasNextPage: boolean;
|
|
57
|
+
};
|
|
58
|
+
};
|
package/list-variants-types.d.ts
CHANGED
|
@@ -107,14 +107,14 @@ export type ListVariantsNotApplicable = {
|
|
|
107
107
|
};
|
|
108
108
|
/**
|
|
109
109
|
* One list item: the compact identity needed to pick a variant, with image
|
|
110
|
-
* and
|
|
110
|
+
* and brand page only when requested (`include`) and selected attributes
|
|
111
111
|
* under `specifications`. Leaner than `get_variant`'s item on purpose.
|
|
112
112
|
*/
|
|
113
113
|
export type ListVariantsItem = {
|
|
114
114
|
category: string;
|
|
115
115
|
code: string | null;
|
|
116
116
|
image?: string | null;
|
|
117
|
-
|
|
117
|
+
brand: {
|
|
118
118
|
id: string;
|
|
119
119
|
name: string;
|
|
120
120
|
};
|
|
@@ -137,6 +137,8 @@ export type ListVariantsItem = {
|
|
|
137
137
|
variantId: string;
|
|
138
138
|
};
|
|
139
139
|
export type ListVariantsOutput = {
|
|
140
|
+
/** Explicit `{field: "variant", op: "in"}` ids that name a real variant outside the materials catalogue. Present only when at least one did. */
|
|
141
|
+
excludedByCorpusScope?: string[];
|
|
140
142
|
items: ListVariantsItem[];
|
|
141
143
|
pageInfo: {
|
|
142
144
|
endCursor: string | null;
|
|
@@ -146,4 +148,6 @@ export type ListVariantsOutput = {
|
|
|
146
148
|
preferenceMatchesRemain?: boolean;
|
|
147
149
|
/** Explicit `{field: "variant", op: "in"}` ids anywhere in `filters.terms` that did not resolve to an eligible variant in the requested `corpusScope`. */
|
|
148
150
|
unresolvedVariantIds?: string[];
|
|
151
|
+
/** Filtered attributes no variant in scope states at all. Present only on an empty first page, so its absence means the empty page is a genuine no-match. */
|
|
152
|
+
unstated?: string[];
|
|
149
153
|
};
|
|
@@ -12,7 +12,7 @@ import type { VariantId } from "./identifiers.js";
|
|
|
12
12
|
import type { OpenEnum } from "./types.js";
|
|
13
13
|
/**
|
|
14
14
|
* `available`: MaterialGraph serves the file at `url`. `unknown`: `url` is the
|
|
15
|
-
*
|
|
15
|
+
* brand's own link, unchecked. `unavailable`: no working copy is known and
|
|
16
16
|
* `url` is null.
|
|
17
17
|
*/
|
|
18
18
|
export type VariantAssetAvailability = OpenEnum<"available" | "unknown" | "unavailable">;
|
|
@@ -51,7 +51,7 @@ export type VariantAssetItem = {
|
|
|
51
51
|
/** Images only; absent when unknown. */
|
|
52
52
|
width?: number;
|
|
53
53
|
};
|
|
54
|
-
/** Whether the
|
|
54
|
+
/** Whether the brand's document source was read for this variant. Absent when documents are filtered out. */
|
|
55
55
|
export type VariantDocumentCoverageState = OpenEnum<"available" | "none_declared" | "not_ingested" | "unavailable_source" | "dead_link" | "failed_ingest">;
|
|
56
56
|
export type VariantAssetPageInfo = {
|
|
57
57
|
nextCursor: string | null;
|
|
@@ -104,7 +104,8 @@ export type MaterialDocumentProjectionItem = {
|
|
|
104
104
|
status: MaterialDocumentStatus;
|
|
105
105
|
readable: boolean;
|
|
106
106
|
}[];
|
|
107
|
-
|
|
107
|
+
/** Registry purposes, `unknown` filtered out; absent when none is known. */
|
|
108
|
+
documentTypes?: VariantDocumentType[];
|
|
108
109
|
originalName: string;
|
|
109
110
|
status: MaterialDocumentStatus;
|
|
110
111
|
/** Null for unavailable, dead, or failed source documents. */
|