@instruments/materialgraph 0.32.0 → 0.35.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/association-types.d.ts +11 -11
- package/associations-client.d.ts +7 -7
- package/associations-client.js +5 -5
- package/brand-types.d.ts +37 -41
- package/brand-types.js +3 -5
- package/brands-client.d.ts +22 -9
- package/brands-client.js +20 -6
- package/by-spec-types.d.ts +2 -3
- package/catalog-discovery-types.d.ts +3 -3
- package/catalogue-client.d.ts +2 -50
- package/catalogue-client.js +2 -10
- package/catalogue-types.d.ts +1 -1
- package/categories-client.d.ts +3 -5
- package/categories-client.js +1 -1
- package/category-types.d.ts +17 -30
- package/citation-types.d.ts +2 -2
- package/client-vocabulary.d.ts +2 -2
- package/client-vocabulary.js +4 -1
- package/client.d.ts +75 -102
- package/client.js +83 -100
- package/color-profiles-types.d.ts +70 -0
- package/colors-client.d.ts +76 -0
- package/colors-client.js +52 -0
- package/find-companions-types.d.ts +8 -8
- package/{find-variants-by-colour-types.d.ts → find-variants-by-color-types.d.ts} +70 -64
- package/find-variants-by-vector-types.d.ts +4 -1
- package/get-variant-types.d.ts +14 -2
- package/http-transport.d.ts +1 -1
- package/http-transport.js +1 -2
- package/identifiers.d.ts +2 -2
- package/identifiers.js +1 -1
- package/index.d.ts +5 -13
- package/index.js +1 -3
- package/list-variant-facets-types.d.ts +4 -4
- package/list-variants-types.d.ts +108 -19
- package/material-asset-types.d.ts +3 -3
- package/material-block-types.d.ts +9 -9
- package/material-types.d.ts +10 -8
- package/operations.d.ts +2 -2
- package/operations.js +14 -24
- package/package.json +2 -2
- package/{resolve-colour-types.d.ts → resolve-color-types.d.ts} +18 -18
- package/response-schemas.generated.d.ts +2 -2
- package/response-schemas.generated.js +40 -68
- package/response-schemas.js +1 -1
- package/samplize-catalogue-types.d.ts +4 -4
- package/samplize-colorvec.js +6 -6
- package/{corpus-scope-types.d.ts → search-catalogue-subset-types.d.ts} +3 -3
- package/search-variants-types.d.ts +91 -0
- package/types.d.ts +31 -283
- package/webmcp.generated.js +4 -9
- package/attribution-types.d.ts +0 -51
- package/attribution-types.js +0 -13
- package/by-colour-types.d.ts +0 -320
- package/colour-region-types.d.ts +0 -18
- package/colours-client.d.ts +0 -70
- package/colours-client.js +0 -38
- package/material-query-plan-types.d.ts +0 -70
- package/palette-search-types.d.ts +0 -171
- package/palette-search-types.js +0 -1
- package/query-understanding-types.d.ts +0 -254
- package/query-understanding-types.js +0 -1
- package/resolve-colour-types.js +0 -1
- package/search-card-types.d.ts +0 -86
- package/search-card-types.js +0 -1
- package/search-index-plan-types.d.ts +0 -74
- package/search-index-plan-types.js +0 -1
- package/search-refinement-types.d.ts +0 -103
- package/search-refinement-types.js +0 -2
- package/search-request-types.d.ts +0 -170
- package/search-request-types.js +0 -1
- package/search-response-receipt-types.d.ts +0 -24
- package/search-response-receipt-types.js +0 -1
- package/search-response-types.d.ts +0 -11
- package/search-response-types.js +0 -1
- package/search-result-validation.d.ts +0 -9
- package/search-result-validation.js +0 -83
- package/spec-types.d.ts +0 -109
- package/spec-types.js +0 -54
- package/specifications.d.ts +0 -34
- package/specifications.js +0 -56
- package/validation.d.ts +0 -43
- package/validation.js +0 -117
- /package/{by-colour-types.js → color-profiles-types.js} +0 -0
- /package/{colour-region-types.js → find-variants-by-color-types.js} +0 -0
- /package/{corpus-scope-types.js → resolve-color-types.js} +0 -0
- /package/{find-variants-by-colour-types.js → search-catalogue-subset-types.js} +0 -0
- /package/{material-query-plan-types.js → search-variants-types.js} +0 -0
|
@@ -1,24 +1,24 @@
|
|
|
1
|
+
import type { ImageReferenceInput } from "./image-reference-types.js";
|
|
1
2
|
/**
|
|
2
|
-
* @module find-variants-by-
|
|
3
|
-
* @description Hand-maintained mirror of `
|
|
3
|
+
* @module find-variants-by-color-types
|
|
4
|
+
* @description Hand-maintained mirror of `find_variants_by_color`'s
|
|
4
5
|
* (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-
|
|
6
|
+
* of truth is `packages/products/src/search/find-variants-by-color.ts` —
|
|
6
7
|
* `rerank`'s `reference.candidates`/`reference.seed` still mirror
|
|
7
|
-
* `compare-
|
|
8
|
+
* `compare-color-similarity.ts`'s own seed shape, but its `matches[]` card
|
|
8
9
|
* is the same shape CONTAINS/PALETTE use, not a copy of that module's result.
|
|
9
10
|
* This SDK has no RUNTIME dependency on `@materialgraph/products` (it's a
|
|
10
11
|
* devDependency only, for the parity tests in `__tests__/`), so the shapes
|
|
11
12
|
* are copied here rather than imported. `contract-parity.test.ts` keeps this
|
|
12
13
|
* mirror honest against the server types.
|
|
13
14
|
*/
|
|
14
|
-
import type {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export type ColourConditionInput = {
|
|
15
|
+
import type { SearchCatalogueSubset, SearchCatalogueSubsetReceipt } from "./search-catalogue-subset-types.js";
|
|
16
|
+
export type FindVariantsByColorMode = "contains" | "palette" | "rerank";
|
|
17
|
+
/** One color condition. `role` defaults to `required`; every other field defaults to absent/false/0. */
|
|
18
|
+
export type ColorConditionInput = {
|
|
19
19
|
/** Name, code or hex (e.g. "sage green"). */
|
|
20
|
-
|
|
21
|
-
/** Must be the swatch's largest
|
|
20
|
+
color?: string;
|
|
21
|
+
/** Must be the swatch's largest color. */
|
|
22
22
|
dominant?: boolean;
|
|
23
23
|
role?: "required" | "preferred";
|
|
24
24
|
/** Target (palette) or minimum (contains) share. */
|
|
@@ -26,29 +26,31 @@ export type ColourConditionInput = {
|
|
|
26
26
|
/** Maximum share, e.g. an accent. */
|
|
27
27
|
shareMax?: number;
|
|
28
28
|
};
|
|
29
|
-
export type
|
|
29
|
+
export type FindVariantsByColorInput = {
|
|
30
30
|
/** Brand slugs or names to filter to. */
|
|
31
31
|
brands?: string[];
|
|
32
|
-
/** One entry per
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
/** One entry per color (exactly one for rerank). */
|
|
33
|
+
colors?: ColorConditionInput[];
|
|
34
|
+
/** Material Bank category IDs or exact source paths, including descendants against actual memberships. Materials and decking only. */
|
|
35
|
+
categoryIds?: string[];
|
|
36
|
+
searchCatalogueSubset?: SearchCatalogueSubset;
|
|
35
37
|
cursor?: string;
|
|
36
|
-
/** Palette only: targets from this image's
|
|
38
|
+
/** Palette only: targets from this image's colors, not `colors[]`. */
|
|
37
39
|
image?: ImageReferenceInput;
|
|
38
40
|
limit?: number;
|
|
39
|
-
mode:
|
|
40
|
-
/**
|
|
41
|
+
mode: FindVariantsByColorMode;
|
|
42
|
+
/** Independent specification type or group keys, e.g. wallcovering or coatings; filters specification types, not source categories. */
|
|
41
43
|
productTypeIds?: string[];
|
|
42
|
-
/** palette: match its palette. rerank: rank by its
|
|
44
|
+
/** palette: match its palette. rerank: rank by its color. */
|
|
43
45
|
targetVariantId?: string;
|
|
44
|
-
/** Ids to reorder by
|
|
46
|
+
/** Ids to reorder by color (rerank). */
|
|
45
47
|
variantIds?: string[];
|
|
46
48
|
};
|
|
47
|
-
export type
|
|
49
|
+
export type ColorConditionReceipt = {
|
|
48
50
|
/** OKLab distance to the matched swatch. Never a probability. */
|
|
49
51
|
distance: number;
|
|
50
52
|
hex: string;
|
|
51
|
-
/** Position in the request's `
|
|
53
|
+
/** Position in the request's `colors[]`. */
|
|
52
54
|
index: number;
|
|
53
55
|
/** The matched swatch's share of its image, 0 to 1. */
|
|
54
56
|
proportion: number;
|
|
@@ -63,16 +65,16 @@ export type PaintCatalogVariant = {
|
|
|
63
65
|
variantId: string;
|
|
64
66
|
variantName: string | null;
|
|
65
67
|
};
|
|
66
|
-
export type
|
|
68
|
+
export type ResolvedColor = {
|
|
67
69
|
catalogueVariant: PaintCatalogVariant | null;
|
|
68
70
|
hex: string;
|
|
69
71
|
index: number;
|
|
70
72
|
/** `region`: a named meaning's own OKLCh bounds, kept — never collapsed to one hex. */
|
|
71
73
|
kind: "point" | "region";
|
|
72
|
-
/** Renormalised share, image-extracted
|
|
74
|
+
/** Renormalised share, image-extracted colors only; else null. */
|
|
73
75
|
share: number | null;
|
|
74
76
|
};
|
|
75
|
-
export type
|
|
77
|
+
export type ColorAlternative = {
|
|
76
78
|
code?: string;
|
|
77
79
|
hex: string;
|
|
78
80
|
libraryId: string;
|
|
@@ -80,18 +82,22 @@ export type ColourAlternative = {
|
|
|
80
82
|
name: string;
|
|
81
83
|
query: string;
|
|
82
84
|
};
|
|
83
|
-
export type
|
|
84
|
-
alternatives:
|
|
85
|
+
export type UnresolvedColor = {
|
|
86
|
+
alternatives: ColorAlternative[];
|
|
85
87
|
index: number;
|
|
86
88
|
input: string | null;
|
|
87
89
|
};
|
|
88
|
-
export type
|
|
90
|
+
export type ColorVariantMatch = {
|
|
91
|
+
/** Accepted primary specification type; null when unknown. */
|
|
92
|
+
productTypeId: string | null;
|
|
89
93
|
brand: string;
|
|
90
94
|
brandId: string;
|
|
91
|
-
category: string;
|
|
95
|
+
category: string | null;
|
|
96
|
+
/** All original source category IDs in source order; empty when unknown. */
|
|
97
|
+
categories: string[];
|
|
92
98
|
code: string | null;
|
|
93
|
-
|
|
94
|
-
/** Share of the request's
|
|
99
|
+
colors: ColorConditionReceipt[];
|
|
100
|
+
/** Share of the request's colors this variant matched, 0 to 1. Never a probability. */
|
|
95
101
|
coverage: number;
|
|
96
102
|
imageUrl: string | null;
|
|
97
103
|
product: string;
|
|
@@ -99,7 +105,7 @@ export type ColourVariantMatch = {
|
|
|
99
105
|
variantId: string;
|
|
100
106
|
variantName: string;
|
|
101
107
|
};
|
|
102
|
-
export type
|
|
108
|
+
export type ColorPageInfo = {
|
|
103
109
|
endCursor: string | null;
|
|
104
110
|
hasNextPage: boolean;
|
|
105
111
|
/**
|
|
@@ -112,21 +118,21 @@ export type ColourPageInfo = {
|
|
|
112
118
|
poolTruncated: boolean;
|
|
113
119
|
};
|
|
114
120
|
type ContainsOrPaletteResult = {
|
|
115
|
-
/**
|
|
121
|
+
/** Color-matched candidates dropped by `list_variants`' hard filters or eligibility. */
|
|
116
122
|
gatedOut: number;
|
|
117
|
-
matches:
|
|
118
|
-
pageInfo:
|
|
119
|
-
|
|
120
|
-
|
|
123
|
+
matches: ColorVariantMatch[];
|
|
124
|
+
pageInfo: ColorPageInfo;
|
|
125
|
+
resolvedColors: ResolvedColor[];
|
|
126
|
+
unresolvedColors: UnresolvedColor[];
|
|
121
127
|
};
|
|
122
|
-
export type
|
|
128
|
+
export type FindVariantsByColorContainsResult = ContainsOrPaletteResult & {
|
|
123
129
|
mode: "contains";
|
|
124
130
|
};
|
|
125
|
-
export type
|
|
131
|
+
export type FindVariantsByColorPaletteResult = ContainsOrPaletteResult & {
|
|
126
132
|
mode: "palette";
|
|
127
133
|
};
|
|
128
|
-
/** `reference.candidates`/`reference.seed`'s shape — mirrors `compare-
|
|
129
|
-
export type
|
|
134
|
+
/** `reference.candidates`/`reference.seed`'s shape — mirrors `compare-color-similarity.ts`'s own seed, unlike `matches[]` below. */
|
|
135
|
+
export type ColorRankedSeed = {
|
|
130
136
|
brand: string;
|
|
131
137
|
brandSlug: string;
|
|
132
138
|
color: string | null;
|
|
@@ -134,16 +140,16 @@ export type ColourRankedSeed = {
|
|
|
134
140
|
product: string;
|
|
135
141
|
productId: string;
|
|
136
142
|
variantId: string;
|
|
137
|
-
/** The variant's own name — paint
|
|
143
|
+
/** The variant's own name — paint colorway names live here (label contract). */
|
|
138
144
|
variantName: string | null;
|
|
139
145
|
};
|
|
140
|
-
/** RERANK's own card — the same shape `
|
|
141
|
-
export type
|
|
146
|
+
/** RERANK's own card — the same shape `ColorVariantMatch` above (`brandId`, `code`), plus its two ranking-only fields. */
|
|
147
|
+
export type ColorRankMatch = {
|
|
142
148
|
brand: string;
|
|
143
149
|
brandId: string;
|
|
144
150
|
code: string | null;
|
|
145
|
-
/**
|
|
146
|
-
|
|
151
|
+
/** Color similarity in [0,1], 1 = identical palette; null when unembedded. */
|
|
152
|
+
colorSimilarity: number | null;
|
|
147
153
|
/** Cosine distance computed in TypeScript (0 = identical); null when unembedded. */
|
|
148
154
|
distance: number | null;
|
|
149
155
|
imageUrl: string | null;
|
|
@@ -152,19 +158,19 @@ export type ColourRankMatch = {
|
|
|
152
158
|
variantId: string;
|
|
153
159
|
variantName: string | null;
|
|
154
160
|
};
|
|
155
|
-
export type
|
|
161
|
+
export type ResolvedColorReference = {
|
|
156
162
|
hex: string;
|
|
157
163
|
name: string | null;
|
|
158
164
|
ref: string;
|
|
159
165
|
};
|
|
160
|
-
export type
|
|
166
|
+
export type CompareColorSimilarityReference = {
|
|
161
167
|
/** Best-per-brand candidates when `resolution === "ambiguous"`; empty otherwise. */
|
|
162
|
-
candidates:
|
|
163
|
-
/** The resolved
|
|
164
|
-
|
|
168
|
+
candidates: ColorRankedSeed[];
|
|
169
|
+
/** The resolved color when the reference was a `color`, else null. */
|
|
170
|
+
color: ResolvedColorReference | null;
|
|
165
171
|
/** The input as given, so an agent can react to a miss. */
|
|
166
172
|
input: {
|
|
167
|
-
|
|
173
|
+
color?: string;
|
|
168
174
|
material?: string;
|
|
169
175
|
oklab?: {
|
|
170
176
|
L: number;
|
|
@@ -173,25 +179,25 @@ export type CompareColourSimilarityReference = {
|
|
|
173
179
|
};
|
|
174
180
|
variantId?: string;
|
|
175
181
|
};
|
|
176
|
-
/** `ambiguous` when a
|
|
182
|
+
/** `ambiguous` when a color-name material reference spans several brands. */
|
|
177
183
|
resolution: "resolved" | "ambiguous";
|
|
178
184
|
/** The resolved seed when the reference was a `material`/`variantId`, else null. */
|
|
179
|
-
seed:
|
|
185
|
+
seed: ColorRankedSeed | null;
|
|
180
186
|
};
|
|
181
|
-
export type
|
|
187
|
+
export type FindVariantsByColorRerankResult = {
|
|
182
188
|
/** Present ONLY when the request narrowed it. ABSENT means the whole graph. */
|
|
183
|
-
|
|
184
|
-
/** Real variant ids outside `
|
|
185
|
-
|
|
186
|
-
/** Candidates ranked by ascending
|
|
187
|
-
matches:
|
|
189
|
+
searchCatalogueSubset?: SearchCatalogueSubsetReceipt;
|
|
190
|
+
/** Real variant ids outside `searchCatalogueSubset` or the materials catalogue. Present when a scope narrowed or any was excluded. */
|
|
191
|
+
excludedBySearchCatalogueSubset?: string[];
|
|
192
|
+
/** Candidates ranked by ascending color distance; unembedded ones last. */
|
|
193
|
+
matches: ColorRankMatch[];
|
|
188
194
|
mode: "rerank";
|
|
189
195
|
/** The reference, echoed with its resolution. */
|
|
190
|
-
reference:
|
|
191
|
-
/** The reference
|
|
192
|
-
|
|
196
|
+
reference: CompareColorSimilarityReference;
|
|
197
|
+
/** The reference color, echoed in the same shape CONTAINS/PALETTE use — always 0 or 1 entries. */
|
|
198
|
+
resolvedColors: ResolvedColor[];
|
|
193
199
|
/** Candidate ids that did not resolve to any variant. */
|
|
194
200
|
unresolved: string[];
|
|
195
201
|
};
|
|
196
|
-
export type
|
|
202
|
+
export type FindVariantsByColorOutput = FindVariantsByColorContainsResult | FindVariantsByColorPaletteResult | FindVariantsByColorRerankResult;
|
|
197
203
|
export {};
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import type { ImageReferenceInput } from "./image-reference-types.js";
|
|
10
10
|
import type { FilterGroups, ListVariantsItem } from "./list-variants-types.js";
|
|
11
|
+
import type { SearchCatalogueSubset } from "./search-catalogue-subset-types.js";
|
|
11
12
|
export declare const FIND_VARIANTS_BY_VECTOR_MODES: readonly ["text", "image", "text_and_image"];
|
|
12
13
|
export type FindVariantsByVectorMode = (typeof FIND_VARIANTS_BY_VECTOR_MODES)[number];
|
|
13
14
|
export type FindVariantsByVectorQuery = {
|
|
@@ -26,6 +27,8 @@ export type FindVariantsByVectorInput = {
|
|
|
26
27
|
/** Default 20. */
|
|
27
28
|
limit?: number;
|
|
28
29
|
query: FindVariantsByVectorQuery;
|
|
30
|
+
/** Only this corpus scope. Absent or all: every variant. */
|
|
31
|
+
searchCatalogueSubset?: SearchCatalogueSubset;
|
|
29
32
|
};
|
|
30
33
|
export type FindVariantsByVectorItem = Omit<ListVariantsItem, "materialBankId"> & {
|
|
31
34
|
/** The variant's Material Bank SKU; null means none is recorded. Always present here, unlike `list_variants`' optional field. */
|
|
@@ -54,7 +57,7 @@ export type FindVariantsByVectorTimings = {
|
|
|
54
57
|
};
|
|
55
58
|
export type FindVariantsByVectorOutput = {
|
|
56
59
|
/** Explicit `{field: "variant", op: "in"}` filter ids that name a real variant outside the materials catalogue — present only when at least one did. */
|
|
57
|
-
|
|
60
|
+
excludedBySearchCatalogueSubset?: string[];
|
|
58
61
|
items: FindVariantsByVectorItem[];
|
|
59
62
|
mode: FindVariantsByVectorMode;
|
|
60
63
|
reference: FindVariantsByVectorReference;
|
package/get-variant-types.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* `__tests__/contract-parity.test.ts` keeps the mirror honest against the
|
|
8
8
|
* server types.
|
|
9
9
|
*/
|
|
10
|
-
import type { ListVariantsNotApplicable, ListVariantsSpecifications } from "./list-variants-types.js";
|
|
10
|
+
import type { ListVariantsNotApplicable, ListVariantsSpecifications, SampleSubject } from "./list-variants-types.js";
|
|
11
11
|
/** The detail to add under `specifications`; absent, the answer is the compact item alone. */
|
|
12
12
|
export type GetVariantOptions = {
|
|
13
13
|
/** Canonical attribute ids, e.g. `["nrc_rating"]`. */
|
|
@@ -24,7 +24,19 @@ export type GetVariantOutput = {
|
|
|
24
24
|
category: {
|
|
25
25
|
id: string;
|
|
26
26
|
name: string;
|
|
27
|
-
};
|
|
27
|
+
} | null;
|
|
28
|
+
categories: {
|
|
29
|
+
id: string;
|
|
30
|
+
name: string;
|
|
31
|
+
}[];
|
|
32
|
+
/** Null for a color sample or an unresolved subject. */
|
|
33
|
+
productType: {
|
|
34
|
+
id: string;
|
|
35
|
+
name: string;
|
|
36
|
+
} | null;
|
|
37
|
+
sampleSubject: SampleSubject;
|
|
38
|
+
/** The represented library color; null when none is established. */
|
|
39
|
+
colorOptionValueId: string | null;
|
|
28
40
|
code: string | null;
|
|
29
41
|
image: {
|
|
30
42
|
alt: string;
|
package/http-transport.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export type RequestOptions = {
|
|
|
13
13
|
export type StreamRequestOptions = {
|
|
14
14
|
/** The streaming media type to negotiate (`text/event-stream`, `application/x-ndjson`). */
|
|
15
15
|
accept: string;
|
|
16
|
-
/** Names this stream in the "returned no body" diagnostic, e.g. `"
|
|
16
|
+
/** Names this stream in the "returned no body" diagnostic, e.g. `"run-event stream"`. */
|
|
17
17
|
subject: string;
|
|
18
18
|
} & RequestOptions;
|
|
19
19
|
/** A read, status-checked HTTP response with its parsed body. */
|
package/http-transport.js
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* The shared low-level HTTP transport for {@link MaterialGraphClient}. It owns
|
|
3
3
|
* URL building, the bearer header, rate-limit capture, response reading, and the
|
|
4
4
|
* one error-mapping path — so the JSON read surface (`client.ts`), the multipart
|
|
5
|
-
* upload, the SSE stream (`runs.ts`)
|
|
6
|
-
* (`match-stream.ts`) all fail identically. Retry-free by design; a single
|
|
5
|
+
* upload, and the SSE stream (`runs.ts`) all fail identically. Retry-free by design; a single
|
|
7
6
|
* failure surfaces as one {@link MaterialGraphError}.
|
|
8
7
|
*/
|
|
9
8
|
import { MaterialGraphError } from "./errors.js";
|
package/identifiers.d.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* `categoryKey`, `jurisdictionId`, `brandSlug`. These ARE meaningful, stable,
|
|
17
17
|
* and yours to compose queries from — but you DISCOVER them rather than
|
|
18
18
|
* invent them (`listVariantFacets()`, `listEnumValues()`,
|
|
19
|
-
* `listAttributes()`, `
|
|
19
|
+
* `listAttributes()`, `categories.list()`, `brands()`).
|
|
20
20
|
* A hand-guessed canonical token is the second-most-common caller bug.
|
|
21
21
|
*
|
|
22
22
|
* Every alias below is exactly `string`. They carry no runtime weight and no
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
export type OpaqueId = string;
|
|
31
31
|
/**
|
|
32
32
|
* A variant id — the identity of ONE buyable material (this product in this
|
|
33
|
-
*
|
|
33
|
+
* colorway/finish). The unit almost every read is keyed on.
|
|
34
34
|
*
|
|
35
35
|
* Opaque: preserve verbatim, never parse or construct one.
|
|
36
36
|
*/
|
package/identifiers.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* `categoryKey`, `jurisdictionId`, `brandSlug`. These ARE meaningful, stable,
|
|
17
17
|
* and yours to compose queries from — but you DISCOVER them rather than
|
|
18
18
|
* invent them (`listVariantFacets()`, `listEnumValues()`,
|
|
19
|
-
* `listAttributes()`, `
|
|
19
|
+
* `listAttributes()`, `categories.list()`, `brands()`).
|
|
20
20
|
* A hand-guessed canonical token is the second-most-common caller bug.
|
|
21
21
|
*
|
|
22
22
|
* Every alias below is exactly `string`. They carry no runtime weight and no
|
package/index.d.ts
CHANGED
|
@@ -2,11 +2,12 @@ export { MaterialGraphClient, DEFAULT_BASE_URL } from "./client.js";
|
|
|
2
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 "./search-variants-types.js";
|
|
5
6
|
export type * from "./list-enum-values-types.js";
|
|
6
7
|
export type * from "./get-variant-types.js";
|
|
7
8
|
export type * from "./image-reference-types.js";
|
|
8
9
|
export type * from "./find-companions-types.js";
|
|
9
|
-
export type * from "./find-variants-by-
|
|
10
|
+
export type * from "./find-variants-by-color-types.js";
|
|
10
11
|
export { FIND_VARIANTS_BY_VECTOR_MODES } from "./find-variants-by-vector-types.js";
|
|
11
12
|
export type * from "./find-variants-by-vector-types.js";
|
|
12
13
|
export { MATERIALGRAPH_API_VERSION, SDK_OPERATIONS } from "./operations.js";
|
|
@@ -18,25 +19,16 @@ export type * from "./citation-types.js";
|
|
|
18
19
|
export { MATERIALGRAPH_PROBLEM_EXTENSIONS, MaterialGraphError, } from "./errors.js";
|
|
19
20
|
export type { MaterialGraphErrorInit, MaterialGraphErrorKind, MaterialGraphRequestMetadata, ProblemDetail, RateLimit, SanitizedErrorValue, SanitizedIssue, SimpleErrorBody, } from "./errors.js";
|
|
20
21
|
export type * from "./types.js";
|
|
21
|
-
export type * from "./search-card-types.js";
|
|
22
22
|
export type * from "./resolve-variant-types.js";
|
|
23
23
|
export type * from "./catalogue-types.js";
|
|
24
|
-
export type * from "./by-colour-types.js";
|
|
25
24
|
export { CategoriesClient } from "./categories-client.js";
|
|
26
25
|
export type * from "./category-types.js";
|
|
27
|
-
export {
|
|
28
|
-
export type {
|
|
29
|
-
export type * from "./
|
|
30
|
-
export type * from "./query-understanding-types.js";
|
|
31
|
-
export type * from "./material-query-plan-types.js";
|
|
26
|
+
export { ColorsClient } from "./colors-client.js";
|
|
27
|
+
export type { ColorsTransport } from "./colors-client.js";
|
|
28
|
+
export type * from "./color-profiles-types.js";
|
|
32
29
|
export type * from "./association-types.js";
|
|
33
30
|
export type * from "./brand-types.js";
|
|
34
31
|
export type * from "./material-asset-types.js";
|
|
35
32
|
export type * from "./material-block-types.js";
|
|
36
33
|
export type * from "./schema-resource-types.js";
|
|
37
|
-
export type * from "./search-refinement-types.js";
|
|
38
|
-
export type * from "./attribution-types.js";
|
|
39
|
-
export { CERTIFICATION_PROGRAMME_ATTRIBUTE_ID } from "./spec-types.js";
|
|
40
|
-
export type * from "./spec-types.js";
|
|
41
|
-
export { certificationProgramme, hasSpec, specTerm } from "./specifications.js";
|
|
42
34
|
export type { SamplizePublicationSource, SamplizeLrvObservation, SamplizeDemand, SamplizeCollectionMembership, SamplizeCatalogueOptions, SamplizeCataloguePage, SamplizeCatalogueProduct, SamplizeHexObservation, } from "./samplize-catalogue-types.js";
|
package/index.js
CHANGED
|
@@ -4,6 +4,4 @@ export { MATERIALGRAPH_API_VERSION, SDK_OPERATIONS } from "./operations.js";
|
|
|
4
4
|
export { TERMINAL_RUN_EVENT_TYPES } from "./run-types.js";
|
|
5
5
|
export { MATERIALGRAPH_PROBLEM_EXTENSIONS, MaterialGraphError, } from "./errors.js";
|
|
6
6
|
export { CategoriesClient } from "./categories-client.js";
|
|
7
|
-
export {
|
|
8
|
-
export { CERTIFICATION_PROGRAMME_ATTRIBUTE_ID } from "./spec-types.js";
|
|
9
|
-
export { certificationProgramme, hasSpec, specTerm } from "./specifications.js";
|
|
7
|
+
export { ColorsClient } from "./colors-client.js";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { FilterGroups } from "./list-variants-types.js";
|
|
1
2
|
/**
|
|
2
3
|
* @module list-variant-facets-types
|
|
3
4
|
* @description Hand-maintained mirror of `list_variant_facets`'s (MG-2294)
|
|
@@ -7,14 +8,13 @@
|
|
|
7
8
|
* dependency on `@materialgraph/products`, so the shapes are copied here and
|
|
8
9
|
* `contract-parity.test.ts` keeps them honest.
|
|
9
10
|
*/
|
|
10
|
-
import type {
|
|
11
|
-
import type { FilterGroups } from "./list-variants-types.js";
|
|
11
|
+
import type { SearchCatalogueSubset } from "./search-catalogue-subset-types.js";
|
|
12
12
|
export type ListVariantFacetsInput = {
|
|
13
|
-
/** 1–10 facetable attribute ids
|
|
13
|
+
/** 1–10 facetable attribute ids, or `brand`. Find attribute ids with `listAttributes()`. */
|
|
14
14
|
attributeIds: string[];
|
|
15
15
|
/** The same kind-grouped filter tree `listVariants()` takes. */
|
|
16
16
|
/** Count only this corpus scope; absent or `all` counts every variant. */
|
|
17
|
-
|
|
17
|
+
searchCatalogueSubset?: SearchCatalogueSubset;
|
|
18
18
|
filters?: FilterGroups;
|
|
19
19
|
/** Top values per categorical or boolean facet, 1–50. Defaults to 10. */
|
|
20
20
|
valuesPerFacet?: number;
|
package/list-variants-types.d.ts
CHANGED
|
@@ -9,11 +9,22 @@
|
|
|
9
9
|
* copied here rather than imported. `contract-parity.test.ts` keeps this
|
|
10
10
|
* mirror honest against the server types.
|
|
11
11
|
*/
|
|
12
|
-
import type {
|
|
12
|
+
import type { SearchCatalogueSubset } from "./search-catalogue-subset-types.js";
|
|
13
13
|
export type FilterOp = "in" | "not_in" | "all" | "exists" | "missing" | "eq" | "gt" | "gte" | "lt" | "lte";
|
|
14
14
|
export type FilterTermCondition = {
|
|
15
15
|
field: string;
|
|
16
16
|
op: "in" | "all" | "not_in";
|
|
17
|
+
/**
|
|
18
|
+
* Meets the condition when the value is stated OR this phrase appears in the
|
|
19
|
+
* variant's text. One to 100 characters, on an `in` or `all` only, never a
|
|
20
|
+
* `not_in`. Term attributes only. Absent: the value must be stated.
|
|
21
|
+
*/
|
|
22
|
+
orText?: string;
|
|
23
|
+
/**
|
|
24
|
+
* `"pass"` on a `not_in` lets the variants that do not state the attribute
|
|
25
|
+
* at all through. Absent: a variant must state the attribute to pass.
|
|
26
|
+
*/
|
|
27
|
+
unstated?: "pass";
|
|
17
28
|
values: string[];
|
|
18
29
|
};
|
|
19
30
|
export type FilterNumericCondition = {
|
|
@@ -26,24 +37,48 @@ export type FilterPresenceCondition = {
|
|
|
26
37
|
op: "exists" | "missing";
|
|
27
38
|
};
|
|
28
39
|
/**
|
|
29
|
-
*
|
|
40
|
+
* A term stated under ANY of `fields` (2–8 distinct term attributes), for a
|
|
41
|
+
* concept stored under several of them. `in`: at least one of `values` under
|
|
42
|
+
* at least one field. `not_in`: at least one field stated at all, and none of
|
|
43
|
+
* `values` under any field.
|
|
44
|
+
*/
|
|
45
|
+
export type FilterAnyFieldCondition = {
|
|
46
|
+
fields: string[];
|
|
47
|
+
op: "in" | "not_in";
|
|
48
|
+
/**
|
|
49
|
+
* Meets the condition when the value is stated OR this phrase appears in the
|
|
50
|
+
* variant's text. One to 100 characters, on an `in` only, never a `not_in`.
|
|
51
|
+
* Absent: the value must be stated.
|
|
52
|
+
*/
|
|
53
|
+
orText?: string;
|
|
54
|
+
/**
|
|
55
|
+
* `"pass"` on a `not_in` lets the variants that state none of the fields
|
|
56
|
+
* through. Absent: at least one field must be stated.
|
|
57
|
+
*/
|
|
58
|
+
unstated?: "pass";
|
|
59
|
+
values: string[];
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* One filter condition, whichever of the four fully-required shapes. No
|
|
30
63
|
* `unit` key (a numeric value is in the attribute's own canonical unit).
|
|
31
64
|
*/
|
|
32
|
-
export type FilterCondition = FilterTermCondition | FilterNumericCondition | FilterPresenceCondition;
|
|
65
|
+
export type FilterCondition = FilterTermCondition | FilterNumericCondition | FilterPresenceCondition | FilterAnyFieldCondition;
|
|
33
66
|
/**
|
|
34
67
|
* `filters`: kind-grouped, not a flat list (MG-2222) — `{terms, numbers,
|
|
35
|
-
* presence}`. Every condition across all
|
|
36
|
-
* within one field is `in
|
|
37
|
-
* empty array carries no
|
|
68
|
+
* presence, anyField}`. Every condition across all four arrays must match
|
|
69
|
+
* (AND); OR within one field is `in`, and `anyField` is OR across several
|
|
70
|
+
* fields. Send only the arrays you need; an omitted or empty array carries no
|
|
71
|
+
* conditions.
|
|
38
72
|
*/
|
|
39
73
|
export type FilterGroups = {
|
|
40
74
|
terms?: FilterTermCondition[];
|
|
41
75
|
numbers?: FilterNumericCondition[];
|
|
42
76
|
presence?: FilterPresenceCondition[];
|
|
77
|
+
anyField?: FilterAnyFieldCondition[];
|
|
43
78
|
};
|
|
44
|
-
/** `optionalFilters`: the same kind-grouped shape as `filters`, with every entry also carrying a required `weight` (1–10). Ranks matched items; never excludes. */
|
|
79
|
+
/** `optionalFilters`: the same kind-grouped shape as `filters` but for `unstated`, with every entry also carrying a required `weight` (1–10). Ranks matched items; never excludes. */
|
|
45
80
|
export type OptionalFilterGroups = {
|
|
46
|
-
terms?: (FilterTermCondition & {
|
|
81
|
+
terms?: (Omit<FilterTermCondition, "unstated"> & {
|
|
47
82
|
weight: number;
|
|
48
83
|
})[];
|
|
49
84
|
numbers?: (FilterNumericCondition & {
|
|
@@ -52,6 +87,9 @@ export type OptionalFilterGroups = {
|
|
|
52
87
|
presence?: (FilterPresenceCondition & {
|
|
53
88
|
weight: number;
|
|
54
89
|
})[];
|
|
90
|
+
anyField?: (Omit<FilterAnyFieldCondition, "unstated"> & {
|
|
91
|
+
weight: number;
|
|
92
|
+
})[];
|
|
55
93
|
};
|
|
56
94
|
export type OrderByEntry = {
|
|
57
95
|
direction: "asc" | "desc";
|
|
@@ -59,23 +97,44 @@ export type OrderByEntry = {
|
|
|
59
97
|
field: string;
|
|
60
98
|
};
|
|
61
99
|
export type ListVariantsInclude = "image" | "url";
|
|
62
|
-
export type ListVariantsCollapse = "product";
|
|
100
|
+
export type ListVariantsCollapse = "product" | "colorway";
|
|
101
|
+
/** A region in OKLCh: lightness and chroma as bounds, hue an arc in degrees that wraps when its start is past its end, null for any hue. */
|
|
102
|
+
export type ColorRegion = {
|
|
103
|
+
chroma: [number, number];
|
|
104
|
+
hue: [number, number] | null;
|
|
105
|
+
lightness: [number, number];
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* A measured-color condition. `in` keeps a variant with a large swatch inside
|
|
109
|
+
* `range`; `not_in` leaves those out and lets a variant with no measured
|
|
110
|
+
* color pass. `preferred` only orders and never narrows.
|
|
111
|
+
*/
|
|
112
|
+
export type ColorRangeCondition = {
|
|
113
|
+
/** The color's own point in the region, `#rrggbb`; it orders matches, nearest first. */
|
|
114
|
+
hex: string;
|
|
115
|
+
intent?: "required" | "preferred";
|
|
116
|
+
op: "in" | "not_in";
|
|
117
|
+
range: ColorRegion;
|
|
118
|
+
};
|
|
63
119
|
export type ListVariantsInput = {
|
|
64
120
|
/** Attribute ids to project under each item's `specifications`. */
|
|
65
121
|
attributes?: string[];
|
|
66
122
|
/**
|
|
67
|
-
* `product`: one row per product, its lead
|
|
68
|
-
* with `variantCount` saying how many
|
|
69
|
-
* cursor pages products.
|
|
123
|
+
* `product`: one row per product, its lead colorway by the page's order,
|
|
124
|
+
* with `variantCount` saying how many colorways stand behind it. The
|
|
125
|
+
* cursor pages products. `colorway`: one row per colorway, so a color
|
|
126
|
+
* sold on several substrates is one row.
|
|
70
127
|
*/
|
|
71
128
|
collapse?: ListVariantsCollapse;
|
|
129
|
+
/** Up to four measured-color regions. */
|
|
130
|
+
colors?: ColorRangeCondition[];
|
|
72
131
|
/**
|
|
73
132
|
* Only variants in this corpus scope: the rows, the page and the cursor.
|
|
74
133
|
* Absent or `all` is every variant.
|
|
75
134
|
*/
|
|
76
|
-
|
|
135
|
+
searchCatalogueSubset?: SearchCatalogueSubset;
|
|
77
136
|
cursor?: string;
|
|
78
|
-
/** Every condition, across `terms`/`numbers`/`presence`, must match. */
|
|
137
|
+
/** Every condition, across `terms`/`numbers`/`presence`/`anyField`, must match. */
|
|
79
138
|
filters?: FilterGroups;
|
|
80
139
|
include?: ListVariantsInclude[];
|
|
81
140
|
/** 1–50; defaults to 10. */
|
|
@@ -89,10 +148,12 @@ export type ListVariantsInput = {
|
|
|
89
148
|
/** Rank only — never excludes. */
|
|
90
149
|
optionalFilters?: OptionalFilterGroups;
|
|
91
150
|
orderBy?: OrderByEntry[];
|
|
151
|
+
/** Words each variant must name in its text, inside the filters. */
|
|
152
|
+
words?: string[];
|
|
92
153
|
};
|
|
93
154
|
/**
|
|
94
155
|
* `score` sums the weights of the matched `optionalFilters`; `matched` lists
|
|
95
|
-
* their positions in the flattened terms-then-numbers-then-presence order
|
|
156
|
+
* their positions in the flattened terms-then-numbers-then-presence-then-anyField order
|
|
96
157
|
* the server reads `optionalFilters` in, not the caller's own array shape.
|
|
97
158
|
*/
|
|
98
159
|
export type ListVariantsPreference = {
|
|
@@ -105,15 +166,36 @@ export type ListVariantsNotApplicable = {
|
|
|
105
166
|
attributes?: string[];
|
|
106
167
|
blocks?: string[];
|
|
107
168
|
};
|
|
169
|
+
/** What a sample represents, independently of its specification type. */
|
|
170
|
+
export type SampleSubject = "material" | "paint_color_sample" | "unknown" | "conflict";
|
|
108
171
|
/**
|
|
109
172
|
* One list item: the compact identity needed to pick a variant, with image
|
|
110
173
|
* and brand page only when requested (`include`) and selected attributes
|
|
111
174
|
* under `specifications`. Leaner than `get_variant`'s item on purpose.
|
|
112
175
|
*/
|
|
113
176
|
export type ListVariantsItem = {
|
|
114
|
-
category:
|
|
177
|
+
category: {
|
|
178
|
+
id: string;
|
|
179
|
+
name: string;
|
|
180
|
+
} | null;
|
|
181
|
+
categories: {
|
|
182
|
+
id: string;
|
|
183
|
+
name: string;
|
|
184
|
+
}[];
|
|
185
|
+
/** Null for a color sample or an unresolved subject. */
|
|
186
|
+
productType: {
|
|
187
|
+
id: string;
|
|
188
|
+
name: string;
|
|
189
|
+
} | null;
|
|
190
|
+
sampleSubject: SampleSubject;
|
|
191
|
+
/** The represented library color; null when none is established. */
|
|
192
|
+
colorOptionValueId: string | null;
|
|
115
193
|
code: string | null;
|
|
116
|
-
|
|
194
|
+
/** Present only when `include` has `image`. */
|
|
195
|
+
image?: {
|
|
196
|
+
alt: string;
|
|
197
|
+
url: string;
|
|
198
|
+
} | null;
|
|
117
199
|
brand: {
|
|
118
200
|
id: string;
|
|
119
201
|
name: string;
|
|
@@ -138,7 +220,7 @@ export type ListVariantsItem = {
|
|
|
138
220
|
};
|
|
139
221
|
export type ListVariantsOutput = {
|
|
140
222
|
/** Explicit `{field: "variant", op: "in"}` ids that name a real variant outside the materials catalogue. Present only when at least one did. */
|
|
141
|
-
|
|
223
|
+
excludedBySearchCatalogueSubset?: string[];
|
|
142
224
|
items: ListVariantsItem[];
|
|
143
225
|
pageInfo: {
|
|
144
226
|
endCursor: string | null;
|
|
@@ -146,8 +228,15 @@ export type ListVariantsOutput = {
|
|
|
146
228
|
};
|
|
147
229
|
/** False: nothing from this page on meets any `optionalFilters` entry. Absent when not measured. */
|
|
148
230
|
preferenceMatchesRemain?: boolean;
|
|
149
|
-
/** Explicit `{field: "variant", op: "in"}` ids
|
|
231
|
+
/** Explicit `{field: "variant", op: "in"}` ids that name a variant in the materials catalogue that this list cannot show in the requested `searchCatalogueSubset`: retired, not orderable, or outside the scope. Read one with `getVariant`. Present only when at least one did. */
|
|
232
|
+
unavailableVariantIds?: string[];
|
|
233
|
+
/** Explicit `{field: "variant", op: "in"}` ids anywhere in `filters.terms` that name no variant at all. */
|
|
150
234
|
unresolvedVariantIds?: string[];
|
|
151
235
|
/** 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
236
|
unstated?: string[];
|
|
237
|
+
/** Each requested word and whether any variant in scope names it. */
|
|
238
|
+
words?: {
|
|
239
|
+
matched: boolean;
|
|
240
|
+
word: string;
|
|
241
|
+
}[];
|
|
153
242
|
};
|