@instruments/materialgraph 0.26.0 → 0.27.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/association-types.d.ts +18 -7
  2. package/attribution-types.d.ts +2 -2
  3. package/brand-types.d.ts +8 -0
  4. package/brands-client.d.ts +5 -36
  5. package/brands-client.js +7 -33
  6. package/by-colour-types.d.ts +40 -13
  7. package/by-spec-types.d.ts +0 -67
  8. package/by-spec-types.js +7 -5
  9. package/catalog-discovery-types.d.ts +1 -16
  10. package/catalogue-client.d.ts +12 -31
  11. package/catalogue-client.js +10 -46
  12. package/catalogue-types.d.ts +40 -0
  13. package/categories-client.d.ts +63 -0
  14. package/categories-client.js +48 -0
  15. package/category-types.d.ts +114 -0
  16. package/client-config.d.ts +2 -4
  17. package/client-config.js +2 -4
  18. package/client-vocabulary.d.ts +2 -4
  19. package/client-vocabulary.js +11 -9
  20. package/client.d.ts +103 -203
  21. package/client.js +128 -251
  22. package/codes-types.d.ts +21 -0
  23. package/colours-client.d.ts +4 -9
  24. package/colours-client.js +0 -8
  25. package/errors.d.ts +1 -1
  26. package/errors.js +1 -0
  27. package/identify-types.d.ts +49 -39
  28. package/identify-types.js +5 -3
  29. package/index.d.ts +11 -21
  30. package/index.js +4 -4
  31. package/list-variant-facets-types.d.ts +60 -0
  32. package/list-variants-types.d.ts +149 -0
  33. package/list-variants-types.js +12 -0
  34. package/match-stream-types.d.ts +13 -0
  35. package/match-stream-types.js +2 -0
  36. package/match-stream.js +12 -8
  37. package/match-types.d.ts +24 -0
  38. package/material-asset-types.d.ts +69 -49
  39. package/material-block-types.d.ts +2 -0
  40. package/material-composition-client.d.ts +21 -0
  41. package/material-composition-client.js +13 -0
  42. package/material-composition-types.d.ts +403 -0
  43. package/material-query-plan-types.d.ts +57 -141
  44. package/material-resources-client.d.ts +9 -7
  45. package/material-resources-client.js +19 -4
  46. package/material-types.d.ts +6 -14
  47. package/operations.d.ts +1 -1
  48. package/operations.js +20 -117
  49. package/package.json +5 -1
  50. package/palette-search-types.d.ts +59 -24
  51. package/query-understanding-types.d.ts +27 -5
  52. package/resolve-client.d.ts +6 -10
  53. package/resolve-client.js +5 -7
  54. package/response-schemas.d.ts +20 -0
  55. package/response-schemas.generated.d.ts +5 -0
  56. package/response-schemas.generated.js +160 -0
  57. package/response-schemas.js +113 -0
  58. package/run-types.d.ts +12 -93
  59. package/runs.d.ts +1 -37
  60. package/runs.js +2 -79
  61. package/schema-resource-types.d.ts +14 -1
  62. package/search-card-types.d.ts +22 -0
  63. package/search-index-plan-types.d.ts +70 -0
  64. package/search-refinement-types.d.ts +8 -38
  65. package/search-refinement-types.js +1 -0
  66. package/search-request-types.d.ts +117 -200
  67. package/search-response-receipt-types.d.ts +12 -268
  68. package/search-result-validation.d.ts +0 -16
  69. package/search-result-validation.js +22 -180
  70. package/spec-facet-types.d.ts +3 -8
  71. package/spec-types.d.ts +17 -10
  72. package/spec-types.js +8 -7
  73. package/specifications.d.ts +13 -55
  74. package/specifications.js +29 -73
  75. package/suggest-types.d.ts +4 -10
  76. package/suggest-types.js +1 -1
  77. package/types.d.ts +135 -338
  78. package/webmcp.d.ts +1 -1
  79. package/webmcp.generated.js +10 -94
  80. package/brand-most-sampled-types.d.ts +0 -33
  81. package/browse-types.d.ts +0 -236
  82. package/client-browse.d.ts +0 -78
  83. package/client-browse.js +0 -71
  84. package/client-exploration.d.ts +0 -9
  85. package/client-exploration.js +0 -5
  86. package/compare-types.d.ts +0 -89
  87. package/composition-client.d.ts +0 -33
  88. package/composition-client.js +0 -28
  89. package/composition-types.d.ts +0 -455
  90. package/composition-types.js +0 -10
  91. package/correction-types.d.ts +0 -88
  92. package/exploration-types.d.ts +0 -118
  93. package/exploration-types.js +0 -1
  94. package/fan-deck-types.d.ts +0 -42
  95. package/fan-deck-types.js +0 -9
  96. package/match-rejection-types.d.ts +0 -43
  97. package/match-rejection-types.js +0 -7
  98. package/palette-completion-types.d.ts +0 -115
  99. package/palette-completion-types.js +0 -1
  100. package/render-assets-types.d.ts +0 -65
  101. package/render-assets-types.js +0 -1
  102. package/search-collapse-types.d.ts +0 -69
  103. package/search-collapse-types.js +0 -1
  104. package/search-mood-types.d.ts +0 -6
  105. package/search-mood-types.js +0 -1
  106. package/search-window-types.d.ts +0 -25
  107. package/search-window-types.js +0 -1
  108. package/slot-pool-types.d.ts +0 -372
  109. package/slot-pool-types.js +0 -1
  110. /package/{brand-most-sampled-types.js → category-types.js} +0 -0
  111. /package/{browse-types.js → list-variant-facets-types.js} +0 -0
  112. /package/{compare-types.js → material-composition-types.js} +0 -0
  113. /package/{correction-types.js → search-index-plan-types.js} +0 -0
@@ -0,0 +1,63 @@
1
+ /**
2
+ * The category-tree surface, namespaced as `mg.categories` (MG-2226). Replaces
3
+ * `taxonomy()` / `GET /api/v1/taxonomy/categories`, retired with no shim.
4
+ *
5
+ * `list()` pages the tree (roots, one node's children, or a name/meaning
6
+ * search), and `get(id)` reads one node in full: its place, the names and
7
+ * phrases that find it, and the canonical taxonomy concepts it relates to.
8
+ *
9
+ * A category id is a TREE KEY, never a canonical `product_category` value,
10
+ * see {@link CategoryItem.id}. `list()` items are lean (id, name, parent,
11
+ * whether it has children, and how it matched); `get(id)` has the rest. Page
12
+ * with `pageInfo.nextCursor` as `cursor`, repeating the same `query` and
13
+ * `parentId`.
14
+ *
15
+ * The namespace holds no transport of its own: the client hands it a bound
16
+ * `get` callback, so auth, rate-limit accounting and error shaping stay in
17
+ * exactly one place. `mg.browse` and `mg.codes` set the precedent for a
18
+ * namespace over flat methods.
19
+ */
20
+ import type { CategoriesGetResult, CategoriesListInput, CategoriesListResult } from "./category-types.js";
21
+ import type { QueryParams } from "./http-transport.js";
22
+ import type { SdkOperationId } from "./operations.js";
23
+ /** The client's own request primitive, handed down so this file owns no transport. */
24
+ export type CategoriesTransport = {
25
+ get<T>(operationId: SdkOperationId, query?: QueryParams, signal?: AbortSignal, pathParams?: Readonly<Record<string, string>>): Promise<T>;
26
+ };
27
+ export declare class CategoriesClient {
28
+ #private;
29
+ constructor(transport: CategoriesTransport);
30
+ /**
31
+ * One bounded page of the category tree (GET `/api/v1/categories`). With
32
+ * nothing set, the top-level categories; `parentId` alone, that category's
33
+ * direct children; `query`, every category (or only `parentId` and
34
+ * everything under it) by name, phrase, near spelling or meaning: the
35
+ * first method that finds anything wins, and every match it finds is
36
+ * returned, ranked by method then distance.
37
+ *
38
+ * An unknown `parentId`, or a cursor from another `query`/`parentId`, is a
39
+ * 400. No match is a successful empty page, never an error.
40
+ *
41
+ * @example
42
+ * const roots = await mg.categories.list();
43
+ * const tiles = await mg.categories.list({ parentId: "tile_surfaces" });
44
+ * const found = await mg.categories.list({ query: "wallpaper" });
45
+ */
46
+ list(input?: CategoriesListInput, signal?: AbortSignal): Promise<CategoriesListResult>;
47
+ /**
48
+ * One category by id (GET `/api/v1/categories/{id}`): its place in the tree
49
+ * (ancestors, children), the names and phrases that find it, and the
50
+ * canonical taxonomy concepts it relates to. `productCategory.concepts[].termId`
51
+ * is what a record's `product_category` attribute holds; category filters
52
+ * elsewhere take the id, never that termId.
53
+ *
54
+ * An id that names no category is a 404; a canonical `product_category`
55
+ * termId passed as `id` is a 404 naming it as one, so find the category with
56
+ * {@link CategoriesClient.list} instead.
57
+ *
58
+ * @example
59
+ * const category = await mg.categories.get("wall_paneling");
60
+ * category.productCategory.concepts.map((c) => c.termId); // ["wall_panel"]
61
+ */
62
+ get(id: string, signal?: AbortSignal): Promise<CategoriesGetResult>;
63
+ }
@@ -0,0 +1,48 @@
1
+ export class CategoriesClient {
2
+ #transport;
3
+ constructor(transport) {
4
+ this.#transport = transport;
5
+ }
6
+ /**
7
+ * One bounded page of the category tree (GET `/api/v1/categories`). With
8
+ * nothing set, the top-level categories; `parentId` alone, that category's
9
+ * direct children; `query`, every category (or only `parentId` and
10
+ * everything under it) by name, phrase, near spelling or meaning: the
11
+ * first method that finds anything wins, and every match it finds is
12
+ * returned, ranked by method then distance.
13
+ *
14
+ * An unknown `parentId`, or a cursor from another `query`/`parentId`, is a
15
+ * 400. No match is a successful empty page, never an error.
16
+ *
17
+ * @example
18
+ * const roots = await mg.categories.list();
19
+ * const tiles = await mg.categories.list({ parentId: "tile_surfaces" });
20
+ * const found = await mg.categories.list({ query: "wallpaper" });
21
+ */
22
+ async list(input = {}, signal) {
23
+ return await this.#transport.get("list_categories", {
24
+ cursor: input.cursor,
25
+ limit: input.limit,
26
+ parentId: input.parentId,
27
+ query: input.query,
28
+ }, signal);
29
+ }
30
+ /**
31
+ * One category by id (GET `/api/v1/categories/{id}`): its place in the tree
32
+ * (ancestors, children), the names and phrases that find it, and the
33
+ * canonical taxonomy concepts it relates to. `productCategory.concepts[].termId`
34
+ * is what a record's `product_category` attribute holds; category filters
35
+ * elsewhere take the id, never that termId.
36
+ *
37
+ * An id that names no category is a 404; a canonical `product_category`
38
+ * termId passed as `id` is a 404 naming it as one, so find the category with
39
+ * {@link CategoriesClient.list} instead.
40
+ *
41
+ * @example
42
+ * const category = await mg.categories.get("wall_paneling");
43
+ * category.productCategory.concepts.map((c) => c.termId); // ["wall_panel"]
44
+ */
45
+ async get(id, signal) {
46
+ return await this.#transport.get("get_category", undefined, signal, { id });
47
+ }
48
+ }
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Hand-mirrored wire types for the category tree surface
3
+ * (`GET /api/v1/categories` - `list_categories`, `GET /api/v1/categories/{id}` -
4
+ * `get_category`; MG-2226). Like the rest of the SDK these interfaces have NO
5
+ * runtime dependency on any `@materialgraph/*` package - they mirror the
6
+ * `listCategoriesInputSchema` / `listCategoriesResultSchema` /
7
+ * `getCategoryInputSchema` / `getCategoryResultSchema` Zod contracts the routes
8
+ * are built from.
9
+ *
10
+ * A category id is a TREE KEY (a product-type group or a product type, e.g.
11
+ * `"tile_surfaces"`), never a canonical `product_category` value (a termId such
12
+ * as `"wall_panel"`). The two vocabularies look alike and are not
13
+ * interchangeable, and a termId passed where an id belongs is refused, naming
14
+ * which it is. `get(id).productCategory` is where a category relates to its
15
+ * termIds; category filters elsewhere in the SDK take the id, never the termId.
16
+ */
17
+ import type { OpenEnum } from "./types.js";
18
+ /** A category named by id, as in `ancestors` and `children`. */
19
+ export type CategoryRef = {
20
+ id: string;
21
+ name: string;
22
+ };
23
+ export type CategoryKind = OpenEnum<"group" | "product_type">;
24
+ /**
25
+ * How one item matched a `query`: `exact` (the id or a name), `alias` (a
26
+ * phrase that names the category), `fuzzy` (a near spelling) or `vector`
27
+ * (similar meaning, from the served vocabulary embeddings). Earlier methods
28
+ * are surer; a page holds matches from one method only.
29
+ */
30
+ export type CategoryMatch = {
31
+ /** The name, former name or phrase that matched. Null for `vector`, which compares meaning. */
32
+ matchedText: string | null;
33
+ method: OpenEnum<"exact" | "alias" | "fuzzy" | "vector">;
34
+ };
35
+ /**
36
+ * One item on a `categories.list` page: what picks the next call. `get(id)`
37
+ * has the description, ancestors, children, names and concepts.
38
+ */
39
+ export type CategoryItem = {
40
+ /** Whether `categories.list({ parentId: this.id })` lists anything. */
41
+ hasChildren: boolean;
42
+ /** A tree key, not a canonical `product_category` value. */
43
+ id: string;
44
+ /** Present only when the page answers a `query`. */
45
+ match?: CategoryMatch;
46
+ name: string;
47
+ /** The parent category's id, or null for a top-level category. */
48
+ parentId: string | null;
49
+ };
50
+ export type CategoriesPageInfo = {
51
+ /** Pass back as `cursor` with the same `query` and `parentId` for the next page. */
52
+ nextCursor: string | null;
53
+ returnedCount: number;
54
+ totalMatches: number;
55
+ };
56
+ export type CategoriesListInput = {
57
+ /** `pageInfo.nextCursor` from the previous page, with the same `query` and `parentId`. */
58
+ cursor?: string;
59
+ /** Items per page, 1 to 50. Default 20. */
60
+ limit?: number;
61
+ /** A category id. Alone, lists its children; with `query`, searches it and everything under it. */
62
+ parentId?: string;
63
+ /** A category name or description, e.g. `"wallpaper"` or `"beds"`. */
64
+ query?: string;
65
+ };
66
+ export type CategoriesListResult = {
67
+ items: CategoryItem[];
68
+ /** Present only when the query is refused as a category, and says why. */
69
+ notice?: string;
70
+ pageInfo: CategoriesPageInfo;
71
+ };
72
+ /**
73
+ * One canonical taxonomy concept a category relates to. `termId` is the value
74
+ * a record's `product_category` attribute holds, not the category id. `match`
75
+ * is present only for product types: `exact` (the same thing), `close`,
76
+ * `broad` (the concept contains this type) or `narrow` (the concept is one
77
+ * kind within this type).
78
+ */
79
+ export type CategoryConcept = {
80
+ label: string;
81
+ match?: OpenEnum<"exact" | "close" | "broad" | "narrow">;
82
+ termId: string;
83
+ uri: string;
84
+ };
85
+ export type CategoryProductCategory = {
86
+ concepts: CategoryConcept[];
87
+ /**
88
+ * The `product_category` value a record holds when the category alone
89
+ * decides it. Null for groups and for `conditional` or `unmapped` types.
90
+ */
91
+ recordValue: string | null;
92
+ /**
93
+ * `mapped`: the category fixes its canonical concepts. `conditional`: each
94
+ * record's own data chooses between them. `unmapped`: no canonical concept
95
+ * fits yet.
96
+ */
97
+ status: OpenEnum<"mapped" | "conditional" | "unmapped">;
98
+ };
99
+ export type CategoriesGetResult = {
100
+ /** Phrases that name this category in a `query`. */
101
+ aliases: string[];
102
+ /** The categories above this one, root first. Empty for a top-level category. */
103
+ ancestors: CategoryRef[];
104
+ /** The categories directly under this one, by name. */
105
+ children: CategoryRef[];
106
+ description: string | null;
107
+ /** Names this category carried before a rename; they still find it. */
108
+ formerNames: string[];
109
+ /** A tree key, not a canonical `product_category` value. */
110
+ id: string;
111
+ kind: CategoryKind;
112
+ name: string;
113
+ productCategory: CategoryProductCategory;
114
+ };
@@ -1,12 +1,10 @@
1
1
  /**
2
- * Construction-time configuration for {@link MaterialGraphClient} and the two
3
- * published constants callers read off it. Split out of `client.ts` so the
2
+ * Construction-time configuration for {@link MaterialGraphClient} and the
3
+ * published constant callers read off it. Split out of `client.ts` so the
4
4
  * client file carries lenses rather than setup.
5
5
  */
6
6
  /** The hosted API origin the client talks to unless `baseUrl` overrides it. */
7
7
  export declare const DEFAULT_BASE_URL = "https://beta.materialgraph.com";
8
- /** The server's per-call ceiling on batch material lookups, enforced client-side. */
9
- export declare const MAX_BATCH_IDS = 100;
10
8
  export type MaterialGraphClientOptions = {
11
9
  /** A `mg_read_*` API key, presented as `Authorization: Bearer <key>`. */
12
10
  apiKey: string;
package/client-config.js CHANGED
@@ -1,9 +1,7 @@
1
1
  /**
2
- * Construction-time configuration for {@link MaterialGraphClient} and the two
3
- * published constants callers read off it. Split out of `client.ts` so the
2
+ * Construction-time configuration for {@link MaterialGraphClient} and the
3
+ * published constant callers read off it. Split out of `client.ts` so the
4
4
  * client file carries lenses rather than setup.
5
5
  */
6
6
  /** The hosted API origin the client talks to unless `baseUrl` overrides it. */
7
7
  export const DEFAULT_BASE_URL = "https://beta.materialgraph.com";
8
- /** The server's per-call ceiling on batch material lookups, enforced client-side. */
9
- export const MAX_BATCH_IDS = 100;
@@ -1,10 +1,8 @@
1
1
  import type { HttpTransport } from "./http-transport.js";
2
- import type { ColourFacetsResponse, ResolveAttributeOptions, ResolveAttributeResponse, ResolveAttributeValueOptions, ResolveAttributeValueResponse, ResolveColourOptions, ResolveColourResponse, SuggestColourResponse, SuggestOptions, SuggestResponse } from "./types.js";
3
- export declare const colourFacets: (transport: HttpTransport, signal?: AbortSignal) => Promise<ColourFacetsResponse>;
2
+ import type { ListAttributesOptions, ListAttributesResult, ResolveColourOptions, ResolveColourResponse, SuggestColourResponse, SuggestOptions, SuggestResponse } from "./types.js";
4
3
  export declare const resolveColour: (transport: HttpTransport, name: string, signal?: AbortSignal, options?: ResolveColourOptions) => Promise<ResolveColourResponse>;
5
4
  export declare const suggestColour: (transport: HttpTransport, q: string, options?: {
6
5
  limit?: number;
7
6
  }, signal?: AbortSignal) => Promise<SuggestColourResponse>;
8
7
  export declare const suggest: (transport: HttpTransport, q: string, options?: SuggestOptions, signal?: AbortSignal) => Promise<SuggestResponse>;
9
- export declare const resolveAttribute: (transport: HttpTransport, q: string, options?: ResolveAttributeOptions, signal?: AbortSignal) => Promise<ResolveAttributeResponse>;
10
- export declare const resolveAttributeValue: (transport: HttpTransport, attributeId: string, query: string, options?: ResolveAttributeValueOptions, signal?: AbortSignal) => Promise<ResolveAttributeValueResponse>;
8
+ export declare const listAttributes: (transport: HttpTransport, options?: ListAttributesOptions, signal?: AbortSignal) => Promise<ListAttributesResult>;
@@ -1,22 +1,24 @@
1
1
  import { resolveOperation } from "./operations.js";
2
2
  import { suggestQuery } from "./suggest-types.js";
3
- export const colourFacets = async (transport, signal) => await transport.requestJson(resolveOperation("get_colour_facets"), { signal });
4
3
  export const resolveColour = async (transport, name, signal, options) => await transport.requestJson(resolveOperation("resolve_colour_name"), { query: { corpusScope: options?.corpusScope, name }, signal });
5
4
  export const suggestColour = async (transport, q, options, signal) => await transport.requestJson(resolveOperation("suggest_colour_names"), { query: { limit: options?.limit, q }, signal });
6
5
  export const suggest = async (transport, q, options, signal) => await transport.requestJson(resolveOperation("search_suggest"), {
7
6
  query: suggestQuery(q, options),
8
7
  signal,
9
8
  });
10
- export const resolveAttribute = async (transport, q, options, signal) => await transport.requestJson(resolveOperation("catalog_resolve_attribute"), {
9
+ /**
10
+ * A comma list, or nothing at all for an empty one. `[].join(",")` is `""`, and
11
+ * an absent parameter is the one honest spelling of "no restriction".
12
+ */
13
+ const commaList = (values) => values === undefined || values.length === 0 ? undefined : values.join(",");
14
+ export const listAttributes = async (transport, options, signal) => await transport.requestJson(resolveOperation("catalog_list_attributes"), {
11
15
  query: {
12
- facetableOnly: options?.facetableOnly,
16
+ blockIds: commaList(options?.blockIds),
17
+ categoryIds: commaList(options?.categoryIds),
18
+ cursor: options?.cursor,
19
+ filterableOnly: options?.filterableOnly,
13
20
  limit: options?.limit,
14
- q,
21
+ query: options?.query,
15
22
  },
16
23
  signal,
17
24
  });
18
- export const resolveAttributeValue = async (transport, attributeId, query, options, signal) => await transport.requestJson(resolveOperation("catalog_resolve_value"), {
19
- pathParams: { attributeId },
20
- query: { limit: options?.limit, q: query },
21
- signal,
22
- });