@instruments/materialgraph 0.24.0 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/association-types.d.ts +20 -20
  2. package/associations-client.d.ts +4 -4
  3. package/associations-client.js +3 -10
  4. package/attribution-types.d.ts +3 -3
  5. package/brand-most-sampled-types.d.ts +4 -4
  6. package/brand-types.d.ts +6 -6
  7. package/brands-client.d.ts +4 -4
  8. package/brands-client.js +9 -13
  9. package/browse-types.d.ts +8 -8
  10. package/by-colour-types.d.ts +18 -18
  11. package/by-spec-types.d.ts +14 -14
  12. package/catalog-discovery-types.d.ts +14 -14
  13. package/catalogue-client.d.ts +4 -4
  14. package/catalogue-client.js +38 -37
  15. package/catalogue-types.d.ts +4 -4
  16. package/citation-types.d.ts +4 -4
  17. package/client-browse.d.ts +4 -4
  18. package/client-browse.js +24 -25
  19. package/client-config.d.ts +2 -2
  20. package/client-exploration.d.ts +3 -3
  21. package/client-exploration.js +4 -6
  22. package/client-source-material-comments.d.ts +4 -4
  23. package/client-source-material-comments.js +4 -38
  24. package/client-vocabulary.d.ts +8 -8
  25. package/client-vocabulary.js +20 -30
  26. package/client.d.ts +11 -45
  27. package/client.js +143 -188
  28. package/codes-client.d.ts +2 -2
  29. package/codes-client.js +8 -8
  30. package/codes-types.d.ts +34 -34
  31. package/colour-aggregate-types.d.ts +24 -24
  32. package/colours-client.d.ts +2 -2
  33. package/colours-client.js +15 -15
  34. package/compare-types.d.ts +10 -10
  35. package/composition-client.d.ts +3 -3
  36. package/composition-client.js +8 -7
  37. package/composition-types.d.ts +12 -12
  38. package/coordinate-client.d.ts +2 -2
  39. package/coordinate-client.js +1 -13
  40. package/corpus-scope-types.d.ts +3 -3
  41. package/corpus-scope-types.js +1 -25
  42. package/correction-types.d.ts +10 -10
  43. package/demand-batch-types.d.ts +18 -18
  44. package/demand-types.d.ts +24 -24
  45. package/errors.d.ts +12 -12
  46. package/errors.js +53 -52
  47. package/exploration-types.d.ts +29 -22
  48. package/fan-deck-types.d.ts +6 -6
  49. package/http-transport.d.ts +13 -21
  50. package/http-transport.js +31 -28
  51. package/identify-types.d.ts +10 -10
  52. package/index.d.ts +0 -6
  53. package/index.js +0 -2
  54. package/match-rejection-types.d.ts +6 -6
  55. package/match-stream-types.d.ts +32 -32
  56. package/match-stream.d.ts +2 -2
  57. package/match-stream.js +55 -41
  58. package/match-types.d.ts +8 -8
  59. package/material-asset-types.d.ts +26 -26
  60. package/material-block-types.d.ts +6 -6
  61. package/material-query-plan-types.d.ts +26 -26
  62. package/material-resources-client.d.ts +5 -5
  63. package/material-resources-client.js +10 -20
  64. package/material-types.d.ts +12 -12
  65. package/ndjson.js +16 -8
  66. package/operations.d.ts +6 -6
  67. package/operations.js +9 -39
  68. package/package.json +2 -2
  69. package/palette-completion-types.d.ts +22 -22
  70. package/palette-search-types.d.ts +28 -28
  71. package/query-understanding-types.d.ts +43 -36
  72. package/render-assets-types.d.ts +8 -8
  73. package/resolve-client.d.ts +2 -2
  74. package/resolve-client.js +4 -6
  75. package/resolve-colour-types.d.ts +22 -6
  76. package/resolve-types.d.ts +10 -10
  77. package/run-types.d.ts +70 -70
  78. package/runs.d.ts +13 -26
  79. package/runs.js +77 -89
  80. package/samplize-catalogue-types.d.ts +18 -18
  81. package/samplize-colorvec.d.ts +20 -20
  82. package/samplize-colorvec.js +66 -42
  83. package/schema-resource-types.d.ts +38 -38
  84. package/schema-resource-types.js +5 -5
  85. package/search-card-types.d.ts +14 -5
  86. package/search-collapse-types.d.ts +4 -4
  87. package/search-mood-types.d.ts +2 -2
  88. package/search-refinement-types.d.ts +8 -8
  89. package/search-request-types.d.ts +6 -6
  90. package/search-response-receipt-types.d.ts +135 -34
  91. package/search-response-types.d.ts +2 -2
  92. package/search-result-validation.d.ts +3 -3
  93. package/search-result-validation.js +53 -36
  94. package/search-window-types.d.ts +2 -2
  95. package/slot-pool-types.d.ts +20 -20
  96. package/source-material-validation.d.ts +3 -3
  97. package/source-material-validation.js +35 -39
  98. package/spec-facet-types.d.ts +10 -10
  99. package/spec-types.d.ts +6 -6
  100. package/specifications.d.ts +9 -25
  101. package/specifications.js +15 -21
  102. package/sse.d.ts +2 -2
  103. package/sse.js +32 -16
  104. package/substitute-types.d.ts +22 -22
  105. package/suggest-types.d.ts +7 -7
  106. package/suggest-types.js +3 -3
  107. package/taxonomy-coverage-types.d.ts +8 -8
  108. package/types.d.ts +119 -119
  109. package/validation.d.ts +26 -26
  110. package/validation.js +97 -92
  111. package/webmcp.d.ts +2 -2
  112. package/webmcp.generated.js +94 -87
  113. package/project-types.d.ts +0 -79
  114. package/project-types.js +0 -9
  115. package/projects.d.ts +0 -13
  116. package/projects.js +0 -46
  117. package/run-events.d.ts +0 -106
  118. package/run-events.js +0 -32
  119. package/schedule-reference-types.d.ts +0 -46
  120. package/schedule-reference-types.js +0 -1
  121. package/schedule-references-client.d.ts +0 -14
  122. package/schedule-references-client.js +0 -26
  123. package/schedule-types.d.ts +0 -261
  124. package/schedule-types.js +0 -1
@@ -7,15 +7,15 @@
7
7
  */
8
8
  import type { OpenEnum } from "./types.js";
9
9
  /** Options for resolving a free-text value against one attribute's dictionary. */
10
- export interface ResolveAttributeValueOptions {
10
+ export type ResolveAttributeValueOptions = {
11
11
  limit?: number;
12
- }
12
+ };
13
13
  /**
14
14
  * One ranked canonical value candidate. `tier` says HOW it matched, strongest
15
15
  * first: `exact_id` > `exact_alias` > `lexical` > `semantic`. A `semantic` hit
16
16
  * is a guess worth confirming, not an equivalence.
17
17
  */
18
- export interface ResolveValueCandidate {
18
+ export type ResolveValueCandidate = {
19
19
  id: string;
20
20
  label: string;
21
21
  dictionaryId?: string;
@@ -23,7 +23,7 @@ export interface ResolveValueCandidate {
23
23
  tier: OpenEnum<"exact_id" | "exact_alias" | "lexical" | "semantic">;
24
24
  /** Present only for a colour_family candidate resolved via the colorscope fallback. */
25
25
  via?: OpenEnum<"colorscope">;
26
- }
26
+ };
27
27
  /**
28
28
  * The resolver's verdict on ONE free-text token — the single shape every
29
29
  * resolving surface speaks, so a caller learns to read it once. Returned whole
@@ -45,15 +45,15 @@ export interface ResolveValueCandidate {
45
45
  * `query` is the trimmed token that was actually resolved, which is how you tell
46
46
  * WHICH half of a failed `attribute:value` pair was the problem.
47
47
  */
48
- export interface ValueResolution {
48
+ export type ValueResolution = {
49
49
  status: OpenEnum<"resolved" | "ambiguous" | "unresolved">;
50
50
  query: string;
51
51
  best: ResolveValueCandidate | null;
52
52
  candidates: ResolveValueCandidate[];
53
53
  recommendedAction: OpenEnum<"use_best" | "choose_from_candidates" | "ask_user" | "none_found">;
54
- }
54
+ };
55
55
  /** Response from resolving a free-text value against one attribute's dictionary. */
56
- export interface ResolveAttributeValueResponse {
56
+ export type ResolveAttributeValueResponse = {
57
57
  attribute: {
58
58
  id: string;
59
59
  name: string;
@@ -61,20 +61,20 @@ export interface ResolveAttributeValueResponse {
61
61
  };
62
62
  /** The verdict on `q`. Read `recommendedAction` — see {@link ValueResolution}. */
63
63
  resolution: ValueResolution;
64
- }
64
+ };
65
65
  /** Options for searching registry attributes and value-dictionary terms together. */
66
- export interface VocabularySearchOptions {
66
+ export type VocabularySearchOptions = {
67
67
  limit?: number;
68
68
  kind?: "attribute" | "term";
69
- }
69
+ };
70
70
  /** One ranked cross-vocabulary candidate. */
71
- export interface VocabularySearchCandidate extends ResolveValueCandidate {
71
+ export type VocabularySearchCandidate = {
72
72
  kind: OpenEnum<"attribute" | "term">;
73
73
  /** Present for terms: attributes whose value dictionary owns this term. */
74
74
  attributeIds?: string[];
75
- }
75
+ } & ResolveValueCandidate;
76
76
  /** Response from the cross-vocabulary catalog search. */
77
- export interface VocabularySearchResponse {
77
+ export type VocabularySearchResponse = {
78
78
  query: string;
79
79
  results: VocabularySearchCandidate[];
80
- }
80
+ };
@@ -44,10 +44,10 @@ export declare class CatalogueClient {
44
44
  samplizeColorVecCache(sourceVersion: string, signal?: AbortSignal): Promise<SamplizeColorVecCache>;
45
45
  /** MG-owned full-catalogue facets and directional colour refinement before page limiting. */
46
46
  samplizeCatalogueSearch(input: {
47
- palette?: Array<{
47
+ palette?: {
48
48
  hex: string;
49
49
  proportion: number;
50
- }>;
50
+ }[];
51
51
  query?: string;
52
52
  reference?: string;
53
53
  direction?: "similar" | "lighter" | "darker" | "muted";
@@ -73,13 +73,13 @@ export declare class CatalogueClient {
73
73
  rankingVersion?: string;
74
74
  dictionaryVersion?: string;
75
75
  eligibleCount?: number;
76
- groups?: Array<{
76
+ groups?: {
77
77
  hex: string;
78
78
  proportion: number;
79
79
  quota: number;
80
80
  ids: string[];
81
81
  shortfall: number;
82
- }>;
82
+ }[];
83
83
  ids: string[];
84
84
  limited: boolean;
85
85
  sourceVersion: string;
@@ -6,33 +6,34 @@ export class CatalogueClient {
6
6
  this.#transport = transport;
7
7
  }
8
8
  /** Brand products ranked by observed Material Bank sample-order lines, with window provenance. */
9
- brandMostSampled(brandId, options = {}, signal) {
10
- return this.#transport.requestJson(resolveOperation("brands.most_sampled"), { query: { brandId, ...options }, signal });
9
+ async brandMostSampled(brandId, options = {}, signal) {
10
+ return await this.#transport.requestJson(resolveOperation("brands.most_sampled"), { query: { brandId, ...options }, signal });
11
11
  }
12
12
  /** Compare canonical Variants without searching or ranking them. */
13
- compare(input, signal) {
14
- return this.#transport.requestJson(resolveOperation("retrieval.compare"), {
13
+ async compare(input, signal) {
14
+ return await this.#transport.requestJson(resolveOperation("retrieval.compare"), {
15
15
  body: input,
16
16
  signal,
17
17
  });
18
18
  }
19
19
  /** Submit confirmed caller-authored review work; never changes accepted truth. */
20
- createCorrection(input, options) {
21
- if (!/^[\x21-\x7e]{1,200}$/.test(options.idempotencyKey))
20
+ async createCorrection(input, options) {
21
+ if (!/^[\u0021-\u007E]{1,200}$/u.test(options.idempotencyKey)) {
22
22
  throw new Error("A valid Idempotency-Key is required for Correction submission.");
23
- return this.#transport.requestJson(resolveOperation("corrections.create"), {
23
+ }
24
+ return await this.#transport.requestJson(resolveOperation("corrections.create"), {
24
25
  body: input,
25
26
  ...options,
26
27
  });
27
28
  }
28
- getCorrection(correctionId, signal) {
29
- return this.#transport.requestJson(resolveOperation("corrections.get"), {
29
+ async getCorrection(correctionId, signal) {
30
+ return await this.#transport.requestJson(resolveOperation("corrections.get"), {
30
31
  pathParams: { correctionId },
31
32
  signal,
32
33
  });
33
34
  }
34
- listCorrections(input = {}, signal) {
35
- return this.#transport.requestJson(resolveOperation("corrections.list"), {
35
+ async listCorrections(input = {}, signal) {
36
+ return await this.#transport.requestJson(resolveOperation("corrections.list"), {
36
37
  query: input,
37
38
  signal,
38
39
  });
@@ -44,40 +45,40 @@ export class CatalogueClient {
44
45
  * returns the original receipt. This judges the match ranking and is never a
45
46
  * catalogue correction - wrong product facts go through `createCorrection`.
46
47
  */
47
- rejectMatchResult(responseId, input, signal) {
48
- return this.#transport.requestJson(resolveOperation("reject_match_result"), { pathParams: { responseId }, body: input, signal });
48
+ async rejectMatchResult(responseId, input, signal) {
49
+ return await this.#transport.requestJson(resolveOperation("reject_match_result"), { body: input, pathParams: { responseId }, signal });
49
50
  }
50
51
  /** Read one match response back with every rejection recorded against it. */
51
- matchRejections(responseId, signal) {
52
- return this.#transport.requestJson(resolveOperation("list_match_rejections"), { pathParams: { responseId }, signal });
52
+ async matchRejections(responseId, signal) {
53
+ return await this.#transport.requestJson(resolveOperation("list_match_rejections"), { pathParams: { responseId }, signal });
53
54
  }
54
55
  /** Identify the canonical graph subject for one explicitly selected page. */
55
- identify(input, signal) {
56
- return this.#transport.requestJson(resolveOperation("retrieval.identify"), { body: input, signal });
56
+ async identify(input, signal) {
57
+ return await this.#transport.requestJson(resolveOperation("retrieval.identify"), { body: input, signal });
57
58
  }
58
59
  /** Complete producer-owned vectors and classifications for portable colour matching. */
59
- samplizeColorVecCache(sourceVersion, signal) {
60
- return this.#transport.requestJson(resolveOperation("samplize_colorvec_cache"), { query: { sourceVersion }, signal });
60
+ async samplizeColorVecCache(sourceVersion, signal) {
61
+ return await this.#transport.requestJson(resolveOperation("samplize_colorvec_cache"), { query: { sourceVersion }, signal });
61
62
  }
62
63
  /** MG-owned full-catalogue facets and directional colour refinement before page limiting. */
63
- samplizeCatalogueSearch(input, signal) {
64
- return this.#transport.requestJson(resolveOperation("samplize_catalogue_search"), { body: input, signal });
64
+ async samplizeCatalogueSearch(input, signal) {
65
+ return await this.#transport.requestJson(resolveOperation("samplize_catalogue_search"), { body: input, signal });
65
66
  }
66
67
  /** Complete version-pinned Samplize paint corpus; stock never limits eligibility. */
67
- samplizeCatalogue(options = {}, signal) {
68
- return this.#transport.requestJson(resolveOperation("samplize_catalogue_products"), { query: { ...options }, signal });
68
+ async samplizeCatalogue(options = {}, signal) {
69
+ return await this.#transport.requestJson(resolveOperation("samplize_catalogue_products"), { query: { ...options }, signal });
69
70
  }
70
71
  /**
71
72
  * Read exact, verified brand-publication page relationships for variants.
72
73
  * Missing evidence stays explicit; this operation never guesses a page from
73
74
  * a generic PDF.
74
75
  */
75
- catalogueReferences(input, signal) {
76
- return this.#transport.requestJson(resolveOperation("get_catalogue_references_batch"), { body: input, signal });
76
+ async catalogueReferences(input, signal) {
77
+ return await this.#transport.requestJson(resolveOperation("get_catalogue_references_batch"), { body: input, signal });
77
78
  }
78
79
  /** List product collections with governed catalogue-channel membership. */
79
- catalogueCollections(options = {}, signal) {
80
- return this.#transport.requestJson(resolveOperation("list_catalogue_channel_collections"), {
80
+ async catalogueCollections(options = {}, signal) {
81
+ return await this.#transport.requestJson(resolveOperation("list_catalogue_channel_collections"), {
81
82
  query: {
82
83
  limit: options.limit,
83
84
  offset: options.offset,
@@ -87,23 +88,23 @@ export class CatalogueClient {
87
88
  });
88
89
  }
89
90
  /** List immutable catalog documents retained from verified source material. */
90
- catalogs(signal) {
91
- return this.#transport.requestJson(resolveOperation("list_catalog_documents"), { signal });
91
+ async catalogs(signal) {
92
+ return await this.#transport.requestJson(resolveOperation("list_catalog_documents"), { signal });
92
93
  }
93
94
  /** List stable one-based page identities and their representation status. */
94
- catalogPages(catalogId, options = {}, signal) {
95
- return this.#transport.requestJson(resolveOperation("list_catalog_pages"), { pathParams: { catalogId }, query: options, signal });
95
+ async catalogPages(catalogId, options = {}, signal) {
96
+ return await this.#transport.requestJson(resolveOperation("list_catalog_pages"), { pathParams: { catalogId }, query: options, signal });
96
97
  }
97
98
  /** Read a retained page representation or its exact missing-artifact receipt. */
98
- catalogPageRepresentation(pageId, signal) {
99
- return this.#transport.requestJson(resolveOperation("get_catalog_page_representation"), { pathParams: { pageId }, signal });
99
+ async catalogPageRepresentation(pageId, signal) {
100
+ return await this.#transport.requestJson(resolveOperation("get_catalog_page_representation"), { pathParams: { pageId }, signal });
100
101
  }
101
102
  /** Read every verified product/page reference for one retained catalog. */
102
- catalogReferences(catalogId, signal) {
103
- return this.#transport.requestJson(resolveOperation("list_catalog_product_references"), { pathParams: { catalogId }, signal });
103
+ async catalogReferences(catalogId, signal) {
104
+ return await this.#transport.requestJson(resolveOperation("list_catalog_product_references"), { pathParams: { catalogId }, signal });
104
105
  }
105
106
  /** Resolve browser-safe access to one immutable catalogue document. */
106
- catalogueDocumentAccess(documentId, signal) {
107
- return this.#transport.requestJson(resolveOperation("get_catalogue_document_access"), { pathParams: { documentId }, signal });
107
+ async catalogueDocumentAccess(documentId, signal) {
108
+ return await this.#transport.requestJson(resolveOperation("get_catalogue_document_access"), { pathParams: { documentId }, signal });
108
109
  }
109
110
  }
@@ -188,10 +188,10 @@ export interface CatalogAvailableReceipt {
188
188
  pageCount: number;
189
189
  };
190
190
  render: {
191
- failedPages: Array<{
191
+ failedPages: {
192
192
  documentPage: number;
193
193
  reason: string;
194
- }>;
194
+ }[];
195
195
  renderedPages: number;
196
196
  status: "complete" | "partial" | "not_recorded";
197
197
  };
@@ -347,10 +347,10 @@ export type CatalogPageListResult = {
347
347
  };
348
348
  representationCoverage: {
349
349
  available: number;
350
- failuresByReason: Array<{
350
+ failuresByReason: {
351
351
  count: number;
352
352
  reason: "retained_representation_not_found";
353
- }>;
353
+ }[];
354
354
  total: number;
355
355
  unavailable: number;
356
356
  };
@@ -1,10 +1,10 @@
1
1
  /** Small handle carried by a verdict cell. Resolve it only when evidence is opened. */
2
- export interface VerdictCitation {
2
+ export type VerdictCitation = {
3
3
  citationId: string;
4
4
  sourceType: string;
5
5
  count: number;
6
- }
7
- export interface ResolvedVerdictCitation {
6
+ };
7
+ export type ResolvedVerdictCitation = {
8
8
  citationId: string;
9
9
  sourceType: string;
10
10
  source: {
@@ -31,4 +31,4 @@ export interface ResolvedVerdictCitation {
31
31
  };
32
32
  };
33
33
  };
34
- }
34
+ };
@@ -17,10 +17,10 @@ import type { BrowseParams, BrowseResponse } from "./browse-types.js";
17
17
  * states no total, so a corpus claim can only come from `.pages()`. Never report
18
18
  * one page's length as "how many materials there are".
19
19
  */
20
- export interface BrowseNamespace {
20
+ export type BrowseNamespace = {
21
21
  (params: BrowseParams, signal?: AbortSignal): Promise<BrowseResponse>;
22
22
  pages(params: BrowseParams, signal?: AbortSignal): AsyncGenerator<BrowseResponse, void, unknown>;
23
- }
23
+ };
24
24
  /** Fetch one page. The client supplies this, so the transport stays private. */
25
25
  export type BrowsePageFetcher = (params: BrowseParams, signal?: AbortSignal) => Promise<BrowseResponse>;
26
26
  /**
@@ -45,7 +45,7 @@ export type BrowsePageFetcher = (params: BrowseParams, signal?: AbortSignal) =>
45
45
  * the array shape and the comma-joined string are each doing exactly what the
46
46
  * server expects rather than being two spellings of one idea.
47
47
  */
48
- export declare function browseQuery(params: BrowseParams): {
48
+ export declare const browseQuery: (params: BrowseParams) => {
49
49
  sort: BrowseParams["sort"];
50
50
  cursor: BrowseParams["cursor"];
51
51
  limit: BrowseParams["limit"];
@@ -75,4 +75,4 @@ export declare function browsePages(fetchPage: BrowsePageFetcher, params: Browse
75
75
  * const page = await client.browse({ sort: "lightest" });
76
76
  * for await (const page of client.browse.pages({ sort: "lightest" })) { … }
77
77
  */
78
- export declare function createBrowseNamespace(fetchPage: BrowsePageFetcher): BrowseNamespace;
78
+ export declare const createBrowseNamespace: (fetchPage: BrowsePageFetcher) => BrowseNamespace;
package/client-browse.js CHANGED
@@ -20,26 +20,24 @@
20
20
  * the array shape and the comma-joined string are each doing exactly what the
21
21
  * server expects rather than being two spellings of one idea.
22
22
  */
23
- export function browseQuery(params) {
24
- return {
25
- sort: params.sort,
26
- cursor: params.cursor,
27
- limit: params.limit,
28
- count: params.count,
29
- types: params.types,
30
- brands: params.brands,
31
- role: params.role,
32
- filters: params.filters?.map((entry) => JSON.stringify(entry)),
33
- facetCounts: params.facetCounts?.join(","),
34
- corpusScope: params.corpusScope,
35
- // `orderBy` is JSON-encoded and `returnAttributes` comma-joined because that
36
- // is what the route reads — the same two transports `filters` and
37
- // `facetCounts` already use. Enrolled HERE at the same time they shipped on
38
- // the route, which is the thing the three misses above did not do.
39
- orderBy: params.orderBy ? JSON.stringify(params.orderBy) : undefined,
40
- returnAttributes: params.returnAttributes?.join(","),
41
- };
42
- }
23
+ export const browseQuery = (params) => ({
24
+ brands: params.brands,
25
+ corpusScope: params.corpusScope,
26
+ count: params.count,
27
+ cursor: params.cursor,
28
+ facetCounts: params.facetCounts?.join(","),
29
+ filters: params.filters?.map((entry) => JSON.stringify(entry)),
30
+ limit: params.limit,
31
+ // `orderBy` is JSON-encoded and `returnAttributes` comma-joined because that
32
+ // is what the route reads — the same two transports `filters` and
33
+ // `facetCounts` already use. Enrolled HERE at the same time they shipped on
34
+ // the route, which is the thing the three misses above did not do.
35
+ orderBy: params.orderBy ? JSON.stringify(params.orderBy) : undefined,
36
+ returnAttributes: params.returnAttributes?.join(","),
37
+ role: params.role,
38
+ sort: params.sort,
39
+ types: params.types,
40
+ });
43
41
  /**
44
42
  * Walk every page from `params.cursor` onward.
45
43
  *
@@ -49,12 +47,13 @@ export function browseQuery(params) {
49
47
  * not an error anyone can see.
50
48
  */
51
49
  export async function* browsePages(fetchPage, params, signal) {
52
- let cursor = params.cursor;
50
+ let { cursor } = params;
53
51
  for (;;) {
54
52
  const page = await fetchPage({ ...params, cursor }, signal);
55
53
  yield page;
56
- if (page.cursor === undefined || page.results.length === 0)
54
+ if (page.cursor === undefined || page.results.length === 0) {
57
55
  return;
56
+ }
58
57
  cursor = page.cursor;
59
58
  }
60
59
  }
@@ -65,8 +64,8 @@ export async function* browsePages(fetchPage, params, signal) {
65
64
  * const page = await client.browse({ sort: "lightest" });
66
65
  * for await (const page of client.browse.pages({ sort: "lightest" })) { … }
67
66
  */
68
- export function createBrowseNamespace(fetchPage) {
69
- const browse = (params, signal) => fetchPage(params, signal);
67
+ export const createBrowseNamespace = (fetchPage) => {
68
+ const browse = async (params, signal) => await fetchPage(params, signal);
70
69
  browse.pages = (params, signal) => browsePages(fetchPage, params, signal);
71
70
  return browse;
72
- }
71
+ };
@@ -7,11 +7,11 @@
7
7
  export declare const DEFAULT_BASE_URL = "https://beta.materialgraph.com";
8
8
  /** The server's per-call ceiling on batch material lookups, enforced client-side. */
9
9
  export declare const MAX_BATCH_IDS = 100;
10
- export interface MaterialGraphClientOptions {
10
+ export type MaterialGraphClientOptions = {
11
11
  /** A `mg_read_*` API key, presented as `Authorization: Bearer <key>`. */
12
12
  apiKey: string;
13
13
  /** Override the API origin. Defaults to {@link DEFAULT_BASE_URL}. */
14
14
  baseUrl?: string;
15
15
  /** Inject a custom `fetch` (tests, proxies). Defaults to the global `fetch`. */
16
16
  fetch?: typeof fetch;
17
- }
17
+ };
@@ -2,8 +2,8 @@ import type { CandidateReadInput, CandidateReadResponse, GraphOperatorEvidence }
2
2
  import type { HttpTransport } from "./http-transport.js";
3
3
  import type { VariantId } from "./identifiers.js";
4
4
  /** Discovery and traversal share one namespace so availability precedes use. */
5
- export interface ExplorationNamespace {
5
+ export type ExplorationNamespace = {
6
6
  operators(variantId: VariantId, signal?: AbortSignal): Promise<GraphOperatorEvidence>;
7
7
  candidates(variantId: VariantId, input: CandidateReadInput, signal?: AbortSignal): Promise<CandidateReadResponse>;
8
- }
9
- export declare function createExplorationNamespace(transport: HttpTransport): ExplorationNamespace;
8
+ };
9
+ export declare const createExplorationNamespace: (transport: HttpTransport) => ExplorationNamespace;
@@ -1,7 +1,5 @@
1
1
  import { resolveOperation } from "./operations.js";
2
- export function createExplorationNamespace(transport) {
3
- return {
4
- operators: (variantId, signal) => transport.requestJson(resolveOperation("list_material_operators"), { pathParams: { variantId }, signal }),
5
- candidates: (variantId, input, signal) => transport.requestJson(resolveOperation("read_material_candidates"), { body: input, pathParams: { variantId }, signal }),
6
- };
7
- }
2
+ export const createExplorationNamespace = (transport) => ({
3
+ candidates: async (variantId, input, signal) => await transport.requestJson(resolveOperation("read_material_candidates"), { body: input, pathParams: { variantId }, signal }),
4
+ operators: async (variantId, signal) => await transport.requestJson(resolveOperation("list_material_operators"), { pathParams: { variantId }, signal }),
5
+ });
@@ -29,9 +29,9 @@
29
29
  * namespace over a batch's files to rebuild what that read returns. Reach for
30
30
  * `list` when you are watching a single file.
31
31
  */
32
- import { HttpTransport } from "./http-transport.js";
32
+ import type { HttpTransport } from "./http-transport.js";
33
33
  import type { PostSourceMaterialCommentInput, PostSourceMaterialCommentResult, SourceMaterialCommentThread } from "./run-types.js";
34
- export interface SourceMaterialCommentsNamespace {
34
+ export type SourceMaterialCommentsNamespace = {
35
35
  /**
36
36
  * One file's thread, oldest root first, each root carrying its replies.
37
37
  * `comments` is always an array; `truncated` says whether you are holding the
@@ -46,6 +46,6 @@ export interface SourceMaterialCommentsNamespace {
46
46
  * permanent duplicate.
47
47
  */
48
48
  post(batchId: string, sourceId: string, input: PostSourceMaterialCommentInput, signal?: AbortSignal): Promise<PostSourceMaterialCommentResult>;
49
- }
49
+ };
50
50
  /** Bind the comment operations to the client's shared transport. */
51
- export declare function createSourceMaterialCommentsNamespace(transport: HttpTransport): SourceMaterialCommentsNamespace;
51
+ export declare const createSourceMaterialCommentsNamespace: (transport: HttpTransport) => SourceMaterialCommentsNamespace;
@@ -1,40 +1,6 @@
1
- /**
2
- * The per-file comment surface, namespaced as `mg.sourceMaterialComments` — the
3
- * argument people leave on one uploaded file (MG-1345).
4
- *
5
- * A namespace rather than two more flat methods on an already-large facade,
6
- * following `mg.codes` and `mg.colours`: reading a thread and adding to it are
7
- * one family, they share a `(batchId, sourceId)` referent, and neither makes
8
- * sense without the other. The namespace holds no transport of its own — the
9
- * client hands it the shared one, so auth, rate-limit accounting and error
10
- * shaping stay in one place.
11
- *
12
- * TWO RULES A CONSUMER MUST NOT GET WRONG.
13
- *
14
- * **The author name is REPORTED, never verified.** Every comment carries
15
- * `author.attribution: "reported"` — a name somebody typed — plus `recordedBy`,
16
- * the authenticated principal that actually wrote the row. Render "recorded as
17
- * from Ruth Fielding", never "Ruth Fielding said". The API takes a machine key,
18
- * and the person whose argument a remark carries is usually not the person at
19
- * the keyboard; presenting the one as the other is the failure this field
20
- * exists to prevent.
21
- *
22
- * **A reply is not a root.** {@link SourceMaterialCommentsNamespace.post}
23
- * returns a result discriminated on `kind`: switch on it rather than reaching
24
- * for `replies`, which a `reply` does not have. Threads are one level deep and
25
- * the database enforces it, so a reply can never grow replies of its own.
26
- *
27
- * ROUTING OUT OF THIS NAMESPACE. `mg.sourceMaterialBatch(batchId)` already
28
- * inlines every file's thread, so opening a batch is ONE call — do not loop this
29
- * namespace over a batch's files to rebuild what that read returns. Reach for
30
- * `list` when you are watching a single file.
31
- */
32
- import { HttpTransport } from "./http-transport.js";
33
1
  import { listSourceMaterialComments, postSourceMaterialComment, } from "./runs.js";
34
2
  /** Bind the comment operations to the client's shared transport. */
35
- export function createSourceMaterialCommentsNamespace(transport) {
36
- return {
37
- list: (batchId, sourceId, signal) => listSourceMaterialComments(transport, batchId, sourceId, signal),
38
- post: (batchId, sourceId, input, signal) => postSourceMaterialComment(transport, batchId, sourceId, input, signal),
39
- };
40
- }
3
+ export const createSourceMaterialCommentsNamespace = (transport) => ({
4
+ list: async (batchId, sourceId, signal) => await listSourceMaterialComments(transport, batchId, sourceId, signal),
5
+ post: async (batchId, sourceId, input, signal) => await postSourceMaterialComment(transport, batchId, sourceId, input, signal),
6
+ });
@@ -1,10 +1,10 @@
1
- import { HttpTransport } from "./http-transport.js";
1
+ import type { HttpTransport } from "./http-transport.js";
2
2
  import type { ColourFacetsResponse, ResolveAttributeOptions, ResolveAttributeResponse, ResolveAttributeValueOptions, ResolveAttributeValueResponse, ResolveColourOptions, ResolveColourResponse, SuggestColourResponse, SuggestOptions, SuggestResponse } from "./types.js";
3
- export declare function colourFacets(transport: HttpTransport, signal?: AbortSignal): Promise<ColourFacetsResponse>;
4
- export declare function resolveColour(transport: HttpTransport, name: string, signal?: AbortSignal, options?: ResolveColourOptions): Promise<ResolveColourResponse>;
5
- export declare function suggestColour(transport: HttpTransport, q: string, options?: {
3
+ export declare const colourFacets: (transport: HttpTransport, signal?: AbortSignal) => Promise<ColourFacetsResponse>;
4
+ export declare const resolveColour: (transport: HttpTransport, name: string, signal?: AbortSignal, options?: ResolveColourOptions) => Promise<ResolveColourResponse>;
5
+ export declare const suggestColour: (transport: HttpTransport, q: string, options?: {
6
6
  limit?: number;
7
- }, signal?: AbortSignal): Promise<SuggestColourResponse>;
8
- export declare function suggest(transport: HttpTransport, q: string, options?: SuggestOptions, signal?: AbortSignal): Promise<SuggestResponse>;
9
- export declare function resolveAttribute(transport: HttpTransport, q: string, options?: ResolveAttributeOptions, signal?: AbortSignal): Promise<ResolveAttributeResponse>;
10
- export declare function resolveAttributeValue(transport: HttpTransport, attributeId: string, query: string, options?: ResolveAttributeValueOptions, signal?: AbortSignal): Promise<ResolveAttributeValueResponse>;
7
+ }, signal?: AbortSignal) => Promise<SuggestColourResponse>;
8
+ 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>;
@@ -1,32 +1,22 @@
1
- import { HttpTransport } from "./http-transport.js";
2
1
  import { resolveOperation } from "./operations.js";
3
2
  import { suggestQuery } from "./suggest-types.js";
4
- export function colourFacets(transport, signal) {
5
- return transport.requestJson(resolveOperation("get_colour_facets"), { signal });
6
- }
7
- export function resolveColour(transport, name, signal, options) {
8
- return transport.requestJson(resolveOperation("resolve_colour_name"), { query: { name, corpusScope: options?.corpusScope }, signal });
9
- }
10
- export function suggestColour(transport, q, options, signal) {
11
- return transport.requestJson(resolveOperation("suggest_colour_names"), { query: { q, limit: options?.limit }, signal });
12
- }
13
- export function suggest(transport, q, options, signal) {
14
- return transport.requestJson(resolveOperation("search_suggest"), { query: suggestQuery(q, options), signal });
15
- }
16
- export function resolveAttribute(transport, q, options, signal) {
17
- return transport.requestJson(resolveOperation("catalog_resolve_attribute"), {
18
- query: {
19
- q,
20
- limit: options?.limit,
21
- facetableOnly: options?.facetableOnly,
22
- },
23
- signal,
24
- });
25
- }
26
- export function resolveAttributeValue(transport, attributeId, query, options, signal) {
27
- return transport.requestJson(resolveOperation("catalog_resolve_value"), {
28
- query: { q: query, limit: options?.limit },
29
- pathParams: { attributeId },
30
- signal,
31
- });
32
- }
3
+ export const colourFacets = async (transport, signal) => await transport.requestJson(resolveOperation("get_colour_facets"), { signal });
4
+ export const resolveColour = async (transport, name, signal, options) => await transport.requestJson(resolveOperation("resolve_colour_name"), { query: { corpusScope: options?.corpusScope, name }, signal });
5
+ export const suggestColour = async (transport, q, options, signal) => await transport.requestJson(resolveOperation("suggest_colour_names"), { query: { limit: options?.limit, q }, signal });
6
+ export const suggest = async (transport, q, options, signal) => await transport.requestJson(resolveOperation("search_suggest"), {
7
+ query: suggestQuery(q, options),
8
+ signal,
9
+ });
10
+ export const resolveAttribute = async (transport, q, options, signal) => await transport.requestJson(resolveOperation("catalog_resolve_attribute"), {
11
+ query: {
12
+ facetableOnly: options?.facetableOnly,
13
+ limit: options?.limit,
14
+ q,
15
+ },
16
+ signal,
17
+ });
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
+ });