@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
package/sse.js CHANGED
@@ -26,13 +26,15 @@ export class SseDecoder {
26
26
  const frames = [];
27
27
  for (;;) {
28
28
  const lineEnd = this.#nextLineEnd();
29
- if (lineEnd === null)
29
+ if (lineEnd === null) {
30
30
  break;
31
+ }
31
32
  const line = this.#buffer.slice(0, lineEnd.index);
32
33
  this.#buffer = this.#buffer.slice(lineEnd.nextIndex);
33
34
  const frame = this.#consumeLine(line);
34
- if (frame)
35
+ if (frame) {
35
36
  frames.push(frame);
37
+ }
36
38
  }
37
39
  return frames;
38
40
  }
@@ -45,8 +47,9 @@ export class SseDecoder {
45
47
  : this.#buffer;
46
48
  this.#buffer = "";
47
49
  const frame = this.#consumeLine(line);
48
- if (frame)
50
+ if (frame) {
49
51
  return [frame];
52
+ }
50
53
  }
51
54
  const frame = this.#dispatch();
52
55
  return frame ? [frame] : [];
@@ -55,11 +58,13 @@ export class SseDecoder {
55
58
  #nextLineEnd() {
56
59
  for (let i = 0; i < this.#buffer.length; i += 1) {
57
60
  const char = this.#buffer[i];
58
- if (char === "\n")
61
+ if (char === "\n") {
59
62
  return { index: i, nextIndex: i + 1 };
63
+ }
60
64
  if (char === "\r") {
61
- if (i === this.#buffer.length - 1)
65
+ if (i === this.#buffer.length - 1) {
62
66
  return null;
67
+ }
63
68
  return this.#buffer[i + 1] === "\n"
64
69
  ? { index: i, nextIndex: i + 2 }
65
70
  : { index: i, nextIndex: i + 1 };
@@ -68,15 +73,18 @@ export class SseDecoder {
68
73
  return null;
69
74
  }
70
75
  #consumeLine(line) {
71
- if (line.length === 0)
76
+ if (line.length === 0) {
72
77
  return this.#dispatch();
73
- if (line.startsWith(":"))
78
+ }
79
+ if (line.startsWith(":")) {
74
80
  return undefined;
81
+ }
75
82
  const colon = line.indexOf(":");
76
83
  const field = colon === -1 ? line : line.slice(0, colon);
77
84
  let value = colon === -1 ? "" : line.slice(colon + 1);
78
- if (value.startsWith(" "))
85
+ if (value.startsWith(" ")) {
79
86
  value = value.slice(1);
87
+ }
80
88
  if (field === "data") {
81
89
  this.#dataLines.push(value);
82
90
  this.#hasFields = true;
@@ -92,13 +100,16 @@ export class SseDecoder {
92
100
  return undefined;
93
101
  }
94
102
  #dispatch() {
95
- if (!this.#hasFields)
103
+ if (!this.#hasFields) {
96
104
  return undefined;
105
+ }
97
106
  const frame = { data: this.#dataLines.join("\n") };
98
- if (this.#event !== undefined)
107
+ if (this.#event !== undefined) {
99
108
  frame.event = this.#event;
100
- if (this.#id !== undefined)
109
+ }
110
+ if (this.#id !== undefined) {
101
111
  frame.id = this.#id;
112
+ }
102
113
  this.#dataLines = [];
103
114
  this.#event = undefined;
104
115
  this.#id = undefined;
@@ -117,28 +128,33 @@ export async function* readSseFrames(body, signal) {
117
128
  const sse = new SseDecoder();
118
129
  try {
119
130
  for (;;) {
120
- if (signal?.aborted)
131
+ if (signal?.aborted) {
121
132
  return;
133
+ }
122
134
  let result;
123
135
  try {
124
136
  result = await reader.read();
125
137
  }
126
138
  catch (error) {
127
- if (signal?.aborted)
139
+ if (signal?.aborted) {
128
140
  return;
141
+ }
129
142
  throw error;
130
143
  }
131
144
  if (result.done) {
132
- for (const frame of sse.push(decoder.decode()))
145
+ for (const frame of sse.push(decoder.decode())) {
133
146
  yield frame;
134
- for (const frame of sse.flush())
147
+ }
148
+ for (const frame of sse.flush()) {
135
149
  yield frame;
150
+ }
136
151
  return;
137
152
  }
138
153
  const text = decoder.decode(result.value, { stream: true });
139
154
  for (const frame of sse.push(text)) {
140
- if (signal?.aborted)
155
+ if (signal?.aborted) {
141
156
  return;
157
+ }
142
158
  yield frame;
143
159
  }
144
160
  }
@@ -2,40 +2,40 @@ import type { BySpecVerdict } from "./by-spec-types.js";
2
2
  import type { VariantId } from "./identifiers.js";
3
3
  import type { MaterialSuccessor } from "./material-types.js";
4
4
  export type SubstituteSignatureFamily = "textile" | "tile" | "coating" | "lighting_electrical" | "acoustic" | "surface" | "furniture" | "sanitaryware" | "fittings" | "architectural_hardware";
5
- export interface SubstituteSignatureCriterion {
5
+ export type SubstituteSignatureCriterion = {
6
6
  role: "primary_material" | "performance";
7
7
  attributeId: string;
8
8
  term: string;
9
- }
10
- export interface AvailableSubstituteSignature {
9
+ };
10
+ export type AvailableSubstituteSignature = {
11
11
  family: SubstituteSignatureFamily;
12
12
  form: string;
13
13
  criteria: [SubstituteSignatureCriterion, SubstituteSignatureCriterion];
14
- }
15
- export interface UnsupportedSubstituteSignature {
14
+ };
15
+ export type UnsupportedSubstituteSignature = {
16
16
  family: SubstituteSignatureFamily;
17
17
  form: string;
18
18
  reason: string;
19
- }
20
- export interface InsufficientSubstituteSignature {
19
+ };
20
+ export type InsufficientSubstituteSignature = {
21
21
  family: SubstituteSignatureFamily;
22
22
  form: string;
23
23
  missingRoles: ("primary_material" | "performance")[];
24
- }
25
- export interface FindSubstitutesOptions {
24
+ };
25
+ export type FindSubstitutesOptions = {
26
26
  excludeBrands?: string[];
27
27
  diversityBoost?: number;
28
28
  limit?: number;
29
29
  cursor?: string;
30
30
  includeSamplingArtifacts?: boolean;
31
31
  includeUnavailable?: boolean;
32
- }
33
- export interface SubstituteMatchedCriterion {
32
+ };
33
+ export type SubstituteMatchedCriterion = {
34
34
  attributeId: string;
35
35
  confidence: number | null;
36
36
  sourceBasis: string | null;
37
- }
38
- export interface SubstituteResultItem {
37
+ };
38
+ export type SubstituteResultItem = {
39
39
  variantId: VariantId;
40
40
  brandSlug: string;
41
41
  brand: string;
@@ -50,8 +50,8 @@ export interface SubstituteResultItem {
50
50
  diversityAdjustment: number;
51
51
  score: number;
52
52
  verdict: BySpecVerdict;
53
- }
54
- export interface AvailableSubstitutesResponse {
53
+ };
54
+ export type AvailableSubstitutesResponse = {
55
55
  status: "available";
56
56
  signatureUsed: AvailableSubstituteSignature;
57
57
  items: SubstituteResultItem[];
@@ -69,7 +69,7 @@ export interface AvailableSubstitutesResponse {
69
69
  poolTruncated: boolean;
70
70
  supersededBy: MaterialSuccessor | null;
71
71
  nextCursor?: string;
72
- }
72
+ };
73
73
  /**
74
74
  * MG-1686. The search read a bounded window of the matches and nothing in it
75
75
  * reached the page, while more matches existed past the window. It is not an
@@ -77,7 +77,7 @@ export interface AvailableSubstitutesResponse {
77
77
  * empty `items`. `reason` names what happened and the next move; follow
78
78
  * `nextCursor` when it is present.
79
79
  */
80
- export interface InconclusiveSubstitutesResponse {
80
+ export type InconclusiveSubstitutesResponse = {
81
81
  status: "inconclusive";
82
82
  signatureUsed: AvailableSubstituteSignature;
83
83
  items: [];
@@ -86,17 +86,17 @@ export interface InconclusiveSubstitutesResponse {
86
86
  reason: string;
87
87
  supersededBy: MaterialSuccessor | null;
88
88
  nextCursor?: string;
89
- }
90
- export interface UnsupportedSubstitutesResponse {
89
+ };
90
+ export type UnsupportedSubstitutesResponse = {
91
91
  status: "unsupported";
92
92
  signature: UnsupportedSubstituteSignature;
93
93
  items: [];
94
94
  supersededBy: MaterialSuccessor | null;
95
- }
96
- export interface InsufficientSubstitutesResponse {
95
+ };
96
+ export type InsufficientSubstitutesResponse = {
97
97
  status: "insufficient_signature";
98
98
  signature: InsufficientSubstituteSignature;
99
99
  items: [];
100
100
  supersededBy: MaterialSuccessor | null;
101
- }
101
+ };
102
102
  export type FindSubstitutesResponse = AvailableSubstitutesResponse | InconclusiveSubstitutesResponse | UnsupportedSubstitutesResponse | InsufficientSubstitutesResponse;
@@ -18,7 +18,7 @@ export type SuggestKind = "product" | "brand" | "category";
18
18
  /** How the query met the suggestion's label. Strongest first. */
19
19
  export type SuggestMatch = "prefix" | "word" | "contains" | "fuzzy";
20
20
  /** One ranked typeahead suggestion, carrying the identity it resolves to. */
21
- export interface Suggestion {
21
+ export type Suggestion = {
22
22
  kind: SuggestKind;
23
23
  /** The entity's name as written, for display. */
24
24
  label: string;
@@ -38,25 +38,25 @@ export interface Suggestion {
38
38
  variantId: string | null;
39
39
  /** Variants behind this entity IN MATERIALGRAPH — a coverage figure. */
40
40
  variantCount: number;
41
- }
41
+ };
42
42
  /** The suggest response: the query as interpreted, plus the ranked suggestions. */
43
- export interface SuggestResponse {
43
+ export type SuggestResponse = {
44
44
  /** The normalised query the corpus was matched against. */
45
45
  query: string;
46
46
  /** Ranked best-match-first. Empty when nothing came close — a miss, not an error. */
47
47
  suggestions: Suggestion[];
48
48
  /** Present only when a narrowing governed corpus was applied. */
49
49
  corpusScope?: CorpusScopeReceipt;
50
- }
50
+ };
51
51
  /** Options for {@link MaterialGraphClient.suggest}. */
52
- export interface SuggestOptions {
52
+ export type SuggestOptions = {
53
53
  /** How many suggestions to return (1–20, default 8). */
54
54
  limit?: number;
55
55
  /** Restrict to these kinds. Omit for all of them. */
56
56
  kind?: SuggestKind | SuggestKind[];
57
57
  /** Governed corpus membership; absent means the whole graph. */
58
58
  corpusScope?: CorpusScope;
59
- }
59
+ };
60
60
  /**
61
61
  * Shape the query string for a suggest call.
62
62
  *
@@ -65,7 +65,7 @@ export interface SuggestOptions {
65
65
  * here rather than being sent as repeated `?kind=` pairs the route would ignore.
66
66
  * Undefined members are dropped by the transport.
67
67
  */
68
- export declare function suggestQuery(q: string, options?: SuggestOptions): {
68
+ export declare const suggestQuery: (q: string, options?: SuggestOptions) => {
69
69
  q: string;
70
70
  limit?: number;
71
71
  kind?: string;
package/suggest-types.js CHANGED
@@ -20,9 +20,9 @@
20
20
  * here rather than being sent as repeated `?kind=` pairs the route would ignore.
21
21
  * Undefined members are dropped by the transport.
22
22
  */
23
- export function suggestQuery(q, options) {
23
+ export const suggestQuery = (q, options) => {
24
24
  const kind = Array.isArray(options?.kind)
25
25
  ? options.kind.join(",")
26
26
  : options?.kind;
27
- return { q, limit: options?.limit, kind, corpusScope: options?.corpusScope };
28
- }
27
+ return { corpusScope: options?.corpusScope, kind, limit: options?.limit, q };
28
+ };
@@ -1,5 +1,5 @@
1
1
  /** Exact, source-path-grained status coverage for primary product typing. */
2
- export interface ProductTypeStatusCoverageCounts {
2
+ export type ProductTypeStatusCoverageCounts = {
3
3
  variants: number;
4
4
  accepted: number;
5
5
  proposed: number;
@@ -8,13 +8,13 @@ export interface ProductTypeStatusCoverageCounts {
8
8
  proposedUnknownConfidence: number;
9
9
  otherStatus: number;
10
10
  missingPrimary: number;
11
- }
12
- export interface ProductTypeStatusCoverageSourcePath extends ProductTypeStatusCoverageCounts {
11
+ };
12
+ export type ProductTypeStatusCoverageSourcePath = {
13
13
  /** Complete stored source path; null means the product retained no path. */
14
14
  sourcePath: string | null;
15
- }
15
+ } & ProductTypeStatusCoverageCounts;
16
16
  /** Current primary-assignment coverage, never an inferred acceptance decision. */
17
- export interface ProductTypeStatusCoverage {
17
+ export type ProductTypeStatusCoverage = {
18
18
  computedAt: string;
19
19
  basis: {
20
20
  count: "exact";
@@ -26,9 +26,9 @@ export interface ProductTypeStatusCoverage {
26
26
  };
27
27
  totals: ProductTypeStatusCoverageCounts;
28
28
  sourcePaths: ProductTypeStatusCoverageSourcePath[];
29
- }
30
- export interface ProductTypeCoverageOptions {
29
+ };
30
+ export type ProductTypeCoverageOptions = {
31
31
  [key: string]: number | undefined;
32
32
  /** Reporting cutoff in [0,1], default 0.85; it never accepts a proposal. */
33
33
  comparisonThreshold?: number;
34
- }
34
+ };