@instruments/materialgraph 0.32.0 → 0.33.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.
@@ -0,0 +1,73 @@
1
+ /**
2
+ * @module search-variants-types
3
+ * @description Hand-maintained mirror of `search_variants`'s (MG-2223) input
4
+ * and output wire shapes. The source of truth is
5
+ * `packages/products/src/search-variants/search-variants.ts` and
6
+ * `compose-conditions.ts`; this SDK has no runtime dependency on
7
+ * `@materialgraph/products`, so the shapes are copied here and
8
+ * `contract-parity.test.ts` keeps them honest.
9
+ */
10
+ import type { FilterGroups, ListVariantsOutput, OptionalFilterGroups } from "./list-variants-types.js";
11
+ /** Switches one of a previous answer's `choices`: its `handle`, and the `group` and `id` of the alternative to read it as. */
12
+ export type SearchVariantsSelection = {
13
+ group: string;
14
+ handle: string;
15
+ id: string;
16
+ };
17
+ export type SearchVariantsInput = {
18
+ /** Attribute ids to project under each item's `specifications`, as `listVariants()` takes. */
19
+ attributes?: string[];
20
+ /** The previous page's `pageInfo.endCursor`. Tied to the vocabulary version the query was read against, and not a `listVariants()` cursor. */
21
+ cursor?: string;
22
+ /** 1–50; defaults to 10. */
23
+ limit?: number;
24
+ /** What to find, in plain words. 1–200 characters. */
25
+ query: string;
26
+ /** Up to eight choices to switch, from the previous answer's `choices`. */
27
+ selections?: SearchVariantsSelection[];
28
+ };
29
+ /**
30
+ * What became of one phrase of the query. `filter` narrowed the page,
31
+ * `preference` only ranked it, `not_applied` did neither and `note` says why.
32
+ */
33
+ export type SearchVariantsUnderstood = {
34
+ applied: "filter" | "preference" | "not_applied";
35
+ /** The parser's condition id. */
36
+ id: string;
37
+ kind: "category" | "brand" | "term" | "number" | "colour" | "paint";
38
+ /** What the words were read as. */
39
+ label: string;
40
+ note?: string;
41
+ /** The query words it came from. */
42
+ text: string;
43
+ };
44
+ /** One reading of an ambiguous phrase. */
45
+ export type SearchVariantsReading = {
46
+ group: string;
47
+ id: string;
48
+ kind: string;
49
+ label: string;
50
+ };
51
+ /** A phrase with more than one meaning: the reading used, and the others a caller may switch to by `handle`. */
52
+ export type SearchVariantsChoice = {
53
+ alternatives: SearchVariantsReading[];
54
+ basis: string;
55
+ handle: string;
56
+ reason: string;
57
+ selected: SearchVariantsReading;
58
+ text: string;
59
+ };
60
+ /** The `listVariants()` page, with how the words were read beside it. */
61
+ export type SearchVariantsOutput = ListVariantsOutput & {
62
+ choices?: SearchVariantsChoice[];
63
+ /** The `listVariants()` filters that ran: send them, with `optionalFilters` and `name`, to `listVariants()` to narrow or widen this search. */
64
+ filters?: FilterGroups;
65
+ /** The paint name looked up, as `listVariants()` takes it. */
66
+ name?: string;
67
+ /** The `listVariants()` preferences that ran. */
68
+ optionalFilters?: OptionalFilterGroups;
69
+ /** One entry per phrase the parser read, in the parser's order. */
70
+ understood: SearchVariantsUnderstood[];
71
+ /** Words nothing in the vocabulary could read. */
72
+ unresolved?: string[];
73
+ };
@@ -0,0 +1 @@
1
+ export {};