@instruments/materialgraph 0.25.0 → 0.27.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 (158) hide show
  1. package/association-types.d.ts +38 -27
  2. package/associations-client.d.ts +4 -4
  3. package/associations-client.js +3 -10
  4. package/attribution-types.d.ts +4 -4
  5. package/brand-types.d.ts +14 -6
  6. package/brands-client.d.ts +7 -38
  7. package/brands-client.js +10 -40
  8. package/by-colour-types.d.ts +58 -31
  9. package/by-spec-types.d.ts +6 -73
  10. package/by-spec-types.js +7 -5
  11. package/catalog-discovery-types.d.ts +11 -26
  12. package/catalogue-client.d.ts +16 -35
  13. package/catalogue-client.js +32 -67
  14. package/catalogue-types.d.ts +44 -4
  15. package/categories-client.d.ts +63 -0
  16. package/categories-client.js +48 -0
  17. package/category-types.d.ts +114 -0
  18. package/citation-types.d.ts +4 -4
  19. package/client-config.d.ts +4 -6
  20. package/client-config.js +2 -4
  21. package/client-source-material-comments.d.ts +4 -4
  22. package/client-source-material-comments.js +4 -38
  23. package/client-vocabulary.d.ts +7 -9
  24. package/client-vocabulary.js +22 -30
  25. package/client.d.ts +110 -244
  26. package/client.js +217 -387
  27. package/codes-client.d.ts +2 -2
  28. package/codes-client.js +8 -8
  29. package/codes-types.d.ts +55 -34
  30. package/colour-aggregate-types.d.ts +24 -24
  31. package/colours-client.d.ts +6 -11
  32. package/colours-client.js +11 -19
  33. package/coordinate-client.d.ts +2 -2
  34. package/coordinate-client.js +1 -13
  35. package/corpus-scope-types.d.ts +3 -3
  36. package/corpus-scope-types.js +1 -25
  37. package/demand-batch-types.d.ts +18 -18
  38. package/demand-types.d.ts +24 -24
  39. package/errors.d.ts +13 -13
  40. package/errors.js +54 -52
  41. package/http-transport.d.ts +13 -21
  42. package/http-transport.js +31 -28
  43. package/identify-types.d.ts +54 -44
  44. package/identify-types.js +5 -3
  45. package/index.d.ts +11 -27
  46. package/index.js +4 -6
  47. package/list-variant-facets-types.d.ts +60 -0
  48. package/list-variants-types.d.ts +142 -0
  49. package/list-variants-types.js +12 -0
  50. package/match-stream-types.d.ts +45 -32
  51. package/match-stream-types.js +2 -0
  52. package/match-stream.d.ts +2 -2
  53. package/match-stream.js +67 -49
  54. package/match-types.d.ts +32 -8
  55. package/material-asset-types.d.ts +89 -69
  56. package/material-block-types.d.ts +8 -6
  57. package/material-composition-client.d.ts +21 -0
  58. package/material-composition-client.js +13 -0
  59. package/material-composition-types.d.ts +403 -0
  60. package/material-query-plan-types.d.ts +61 -145
  61. package/material-resources-client.d.ts +12 -10
  62. package/material-resources-client.js +27 -22
  63. package/material-types.d.ts +16 -24
  64. package/ndjson.js +16 -8
  65. package/operations.d.ts +6 -6
  66. package/operations.js +29 -156
  67. package/package.json +5 -1
  68. package/palette-search-types.d.ts +87 -52
  69. package/query-understanding-types.d.ts +65 -40
  70. package/resolve-client.d.ts +8 -12
  71. package/resolve-client.js +9 -13
  72. package/resolve-colour-types.d.ts +8 -8
  73. package/resolve-types.d.ts +10 -10
  74. package/response-schemas.d.ts +20 -0
  75. package/response-schemas.generated.d.ts +5 -0
  76. package/response-schemas.generated.js +160 -0
  77. package/response-schemas.js +113 -0
  78. package/run-types.d.ts +64 -145
  79. package/runs.d.ts +9 -58
  80. package/runs.js +60 -149
  81. package/samplize-catalogue-types.d.ts +18 -18
  82. package/samplize-colorvec.d.ts +20 -20
  83. package/samplize-colorvec.js +66 -42
  84. package/schema-resource-types.d.ts +52 -39
  85. package/schema-resource-types.js +5 -5
  86. package/search-card-types.d.ts +26 -4
  87. package/search-index-plan-types.d.ts +70 -0
  88. package/search-refinement-types.d.ts +10 -40
  89. package/search-refinement-types.js +1 -0
  90. package/search-request-types.d.ts +121 -204
  91. package/search-response-receipt-types.d.ts +13 -253
  92. package/search-response-types.d.ts +2 -2
  93. package/search-result-validation.d.ts +3 -19
  94. package/search-result-validation.js +42 -183
  95. package/source-material-validation.d.ts +3 -3
  96. package/source-material-validation.js +35 -39
  97. package/spec-facet-types.d.ts +11 -16
  98. package/spec-types.d.ts +23 -16
  99. package/spec-types.js +8 -7
  100. package/specifications.d.ts +14 -72
  101. package/specifications.js +39 -89
  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 +11 -17
  106. package/suggest-types.js +3 -3
  107. package/taxonomy-coverage-types.d.ts +8 -8
  108. package/types.d.ts +202 -405
  109. package/validation.d.ts +26 -26
  110. package/validation.js +97 -92
  111. package/webmcp.d.ts +3 -3
  112. package/webmcp.generated.js +10 -93
  113. package/brand-most-sampled-types.d.ts +0 -33
  114. package/browse-types.d.ts +0 -236
  115. package/client-browse.d.ts +0 -78
  116. package/client-browse.js +0 -72
  117. package/client-exploration.d.ts +0 -9
  118. package/client-exploration.js +0 -7
  119. package/compare-types.d.ts +0 -89
  120. package/composition-client.d.ts +0 -33
  121. package/composition-client.js +0 -27
  122. package/composition-types.d.ts +0 -455
  123. package/composition-types.js +0 -10
  124. package/correction-types.d.ts +0 -88
  125. package/exploration-types.d.ts +0 -118
  126. package/exploration-types.js +0 -1
  127. package/fan-deck-types.d.ts +0 -42
  128. package/fan-deck-types.js +0 -9
  129. package/match-rejection-types.d.ts +0 -43
  130. package/match-rejection-types.js +0 -7
  131. package/palette-completion-types.d.ts +0 -115
  132. package/palette-completion-types.js +0 -1
  133. package/project-types.d.ts +0 -79
  134. package/project-types.js +0 -9
  135. package/projects.d.ts +0 -13
  136. package/projects.js +0 -46
  137. package/render-assets-types.d.ts +0 -65
  138. package/render-assets-types.js +0 -1
  139. package/run-events.d.ts +0 -106
  140. package/run-events.js +0 -32
  141. package/schedule-reference-types.d.ts +0 -46
  142. package/schedule-reference-types.js +0 -1
  143. package/schedule-references-client.d.ts +0 -14
  144. package/schedule-references-client.js +0 -26
  145. package/schedule-types.d.ts +0 -261
  146. package/schedule-types.js +0 -1
  147. package/search-collapse-types.d.ts +0 -69
  148. package/search-collapse-types.js +0 -1
  149. package/search-mood-types.d.ts +0 -6
  150. package/search-mood-types.js +0 -1
  151. package/search-window-types.d.ts +0 -25
  152. package/search-window-types.js +0 -1
  153. package/slot-pool-types.d.ts +0 -372
  154. package/slot-pool-types.js +0 -1
  155. /package/{brand-most-sampled-types.js → category-types.js} +0 -0
  156. /package/{browse-types.js → list-variant-facets-types.js} +0 -0
  157. /package/{compare-types.js → material-composition-types.js} +0 -0
  158. /package/{correction-types.js → search-index-plan-types.js} +0 -0
@@ -18,35 +18,35 @@ import type { DemandMomentum, DemandQuarter, DemandSignal, OpenEnum } from "./ty
18
18
  * Body for `POST /api/v1/demand/batch` — enrich 1–48 already-selected candidate
19
19
  * ids with their real specification demand, in input order and cardinality.
20
20
  */
21
- export interface DemandBatchInput {
21
+ export type DemandBatchInput = {
22
22
  /** 1–48 canonical variant ids. Order AND cardinality are preserved — duplicates are echoed, never collapsed. */
23
23
  variantIds: VariantId[];
24
24
  /** The behavioural signal to read demand from. Defaults to `sampled` (order co-occurrence) server-side. */
25
25
  signal?: DemandSignal;
26
26
  /** Optional declared context (e.g. `{ projectType: "hospitality" }`) — echoed for provenance, never used to rank or filter. */
27
27
  context?: Record<string, string>;
28
- }
28
+ };
29
29
  /** Headline population behind the metric — this variant's own counts. */
30
- export interface DemandBatchPopulation {
30
+ export type DemandBatchPopulation = {
31
31
  specCount: number;
32
32
  projectCount: number;
33
33
  customerCount: number;
34
- }
34
+ };
35
35
  /** The consideration→specification funnel (project-grain; `exclusionRate` is annotate-only). */
36
- export interface DemandBatchFunnel {
36
+ export type DemandBatchFunnel = {
37
37
  consideredProjects: number;
38
38
  specifiedProjects: number;
39
39
  excludedCount: number;
40
40
  exclusionRate: number;
41
- }
41
+ };
42
42
  /** Per-result guardrail status — present on `internal` (`mg:admin`) results only. */
43
- export interface DemandBatchEvidence {
43
+ export type DemandBatchEvidence = {
44
44
  belowPrivacyFloor: boolean;
45
45
  belowQualityFloor: boolean;
46
46
  suppressedForPublic: boolean;
47
- }
47
+ };
48
48
  /** A variant that carries a usable demand signal. */
49
- export interface DemandBatchAvailableResult {
49
+ export type DemandBatchAvailableResult = {
50
50
  variantId: VariantId;
51
51
  state: "available";
52
52
  population: DemandBatchPopulation;
@@ -57,28 +57,28 @@ export interface DemandBatchAvailableResult {
57
57
  funnel: DemandBatchFunnel | null;
58
58
  /** Exact guardrail evidence for `internal` callers; null for public. */
59
59
  evidence: DemandBatchEvidence | null;
60
- }
60
+ };
61
61
  /**
62
62
  * A variant with a stats row that is below the public quality floor. We HAVE a
63
63
  * reading and are declining to publish it — not a claim that nobody specifies it.
64
64
  */
65
- export interface DemandBatchInsufficientResult {
65
+ export type DemandBatchInsufficientResult = {
66
66
  variantId: VariantId;
67
67
  state: "insufficient_data";
68
- }
68
+ };
69
69
  /**
70
70
  * A variant with no stats — indistinguishable from a privacy-suppressed one for
71
71
  * public callers, and therefore never reportable as "nobody specifies this".
72
72
  */
73
- export interface DemandBatchNoSignalResult {
73
+ export type DemandBatchNoSignalResult = {
74
74
  variantId: VariantId;
75
75
  state: "no_signal";
76
- }
76
+ };
77
77
  /** A requested id that resolves to no real variant. */
78
- export interface DemandBatchUnknownResult {
78
+ export type DemandBatchUnknownResult = {
79
79
  variantId: VariantId;
80
80
  state: "unknown_variant";
81
- }
81
+ };
82
82
  /**
83
83
  * One discriminated result per input id, in input order and cardinality.
84
84
  *
@@ -88,7 +88,7 @@ export interface DemandBatchUnknownResult {
88
88
  */
89
89
  export type DemandBatchResult = DemandBatchAvailableResult | DemandBatchInsufficientResult | DemandBatchNoSignalResult | DemandBatchUnknownResult;
90
90
  /** The `POST /api/v1/demand/batch` envelope. */
91
- export interface DemandBatchResponse {
91
+ export type DemandBatchResponse = {
92
92
  /** The completed ingestion-session id these counts were mined in (the dataset generation). */
93
93
  generationId: string;
94
94
  metric: "specification_demand";
@@ -115,4 +115,4 @@ export interface DemandBatchResponse {
115
115
  /** The echoed declared context, or null when none was supplied. */
116
116
  context: Record<string, string> | null;
117
117
  results: DemandBatchResult[];
118
- }
118
+ };
package/demand-types.d.ts CHANGED
@@ -15,7 +15,7 @@
15
15
  import type { ProductId, VariantId } from "./identifiers.js";
16
16
  import type { CompanionDemand, DemandMomentum, DemandQuarter, OpenEnum } from "./types.js";
17
17
  /** A resolved seed material (identity block shared by the demand reads). */
18
- export interface DemandSeed {
18
+ export type DemandSeed = {
19
19
  /** Opaque — round-trip verbatim. */
20
20
  variantId: VariantId;
21
21
  brand: string;
@@ -25,16 +25,16 @@ export interface DemandSeed {
25
25
  imageUrl: string | null;
26
26
  brandSlug: string;
27
27
  productId: ProductId;
28
- }
28
+ };
29
29
  /** Headline demand stats for a seed: counts, quarterly series, momentum. */
30
- export interface MaterialDemandStats {
30
+ export type MaterialDemandStats = {
31
31
  specCount: number;
32
32
  projectCount: number;
33
33
  customerCount: number;
34
34
  /** Sparse — a quarter with no activity is ABSENT, not a zero row. */
35
35
  byQuarter: DemandQuarter[];
36
36
  momentum: DemandMomentum;
37
- }
37
+ };
38
38
  /**
39
39
  * `getMaterialDemand` result, passed through verbatim by the `/demand` route.
40
40
  *
@@ -42,14 +42,14 @@ export interface MaterialDemandStats {
42
42
  * the publication floor. It is never a reading of zero, and never licenses
43
43
  * "nobody specifies this".
44
44
  */
45
- export interface MaterialDemandResult {
45
+ export type MaterialDemandResult = {
46
46
  found: boolean;
47
47
  query: string;
48
48
  seed: DemandSeed | null;
49
49
  /** The only window v1 serves. Activity outside it is unread, not absent. */
50
50
  window: "trailing_36mo";
51
51
  demand: MaterialDemandStats | null;
52
- }
52
+ };
53
53
  /**
54
54
  * `getCoSpecifiedMaterials` result, passed through verbatim. The `companions`
55
55
  * list (materials specified alongside the seed) is included but left loosely
@@ -59,7 +59,7 @@ export interface MaterialDemandResult {
59
59
  * phrase matched several materials and `seedAlternatives` holds them — pick one
60
60
  * and re-ask by `variantId` rather than treating the first as the answer.
61
61
  */
62
- export interface CoSpecifiedResult {
62
+ export type CoSpecifiedResult = {
63
63
  found: boolean;
64
64
  resolution: OpenEnum<"resolved" | "ambiguous" | "not_found">;
65
65
  query: string;
@@ -67,25 +67,25 @@ export interface CoSpecifiedResult {
67
67
  seedCategory: string | null;
68
68
  seedAlternatives: DemandSeed[];
69
69
  companions?: unknown[];
70
- }
70
+ };
71
71
  /** The `/api/v1/demand` envelope — both domain reads side by side, verbatim. */
72
- export interface DemandResponse {
72
+ export type DemandResponse = {
73
73
  query: string;
74
74
  demand: MaterialDemandResult;
75
75
  cospec: CoSpecifiedResult;
76
- }
76
+ };
77
77
  /** Seed a demand read by EXACTLY ONE of `variantId` or `material`. */
78
- export interface DemandParams {
78
+ export type DemandParams = {
79
79
  /** An exact variant id. Opaque — pass through verbatim. */
80
80
  variantId?: VariantId;
81
81
  /** Free text ("Brand Product Colour"), resolved server-side. May be ambiguous. */
82
82
  material?: string;
83
- }
84
- export interface CoordinateSeed extends DemandSeed {
83
+ };
84
+ export type CoordinateSeed = {
85
85
  /** The input reference this seed resolved from. */
86
86
  resolvedFrom: string;
87
- }
88
- export interface CoordinateCompanion {
87
+ } & DemandSeed;
88
+ export type CoordinateCompanion = {
89
89
  /** Opaque — round-trip verbatim. */
90
90
  variantId: VariantId;
91
91
  brand: string;
@@ -118,37 +118,37 @@ export interface CoordinateCompanion {
118
118
  totalLift: number;
119
119
  liftLabel: string;
120
120
  seedMatchCount: number;
121
- seedContributions: Array<{
121
+ seedContributions: {
122
122
  seedVariantId: VariantId;
123
123
  lift: number;
124
- }>;
124
+ }[];
125
125
  demand: CompanionDemand | null;
126
- swatches: Array<{
126
+ swatches: {
127
127
  hex: string;
128
128
  proportion: number;
129
- }>;
129
+ }[];
130
130
  /** Annotate-only appearance similarity — never reorders companions in v1. */
131
131
  colourFit: number | null;
132
- }
132
+ };
133
133
  /**
134
134
  * The `POST /api/v1/pairings/coordinate` envelope. `unresolved` lists the input
135
135
  * references that matched nothing — read it before presenting `companions` as
136
136
  * "what goes with your palette", because a companion set derived from two of
137
137
  * four seeds is a different claim.
138
138
  */
139
- export interface CoordinateResponse {
139
+ export type CoordinateResponse = {
140
140
  seeds: CoordinateSeed[];
141
141
  /** Input references that resolved to no material. Never silently dropped. */
142
142
  unresolved: string[];
143
143
  window: "trailing_36mo";
144
144
  companions: CoordinateCompanion[];
145
- }
145
+ };
146
146
  /** Body for `POST /api/v1/pairings/coordinate`. */
147
- export interface CoordinateInput {
147
+ export type CoordinateInput = {
148
148
  /** Free-text material references, resolved server-side; misses land in `unresolved`. */
149
149
  materials?: string[];
150
150
  /** Exact variant ids. Opaque — pass through verbatim. */
151
151
  variantIds?: VariantId[];
152
152
  projectType?: string;
153
153
  limit?: number;
154
- }
154
+ };
package/errors.d.ts CHANGED
@@ -2,9 +2,9 @@
2
2
  export type MaterialGraphErrorKind = "problem" | "simple" | "network" | "timeout" | "aborted" | "rate_limited" | "unexpected";
3
3
  export type SanitizedErrorValue = null | boolean | number | string | SanitizedErrorValue[] | SanitizedIssue;
4
4
  /** A bounded, recursively sanitized validation-issue record. */
5
- export interface SanitizedIssue {
5
+ export type SanitizedIssue = {
6
6
  [key: string]: SanitizedErrorValue;
7
- }
7
+ };
8
8
  /** Normalized RFC 7807 body. Unknown response fields are intentionally discarded. */
9
9
  export interface ProblemDetail {
10
10
  type: string;
@@ -25,22 +25,22 @@ export interface ProblemDetail {
25
25
  readonly [extension: string]: unknown;
26
26
  }
27
27
  /** Normalized residual `{ error }` body. Unknown response fields are discarded. */
28
- export interface SimpleErrorBody {
28
+ export type SimpleErrorBody = {
29
29
  error: string;
30
30
  issues?: SanitizedIssue[];
31
- }
31
+ };
32
32
  /** Parsed `X-RateLimit-*` / `Retry-After` headers. `null` means absent. */
33
- export interface RateLimit {
33
+ export type RateLimit = {
34
34
  limit: number | null;
35
35
  remaining: number | null;
36
36
  reset: number | null;
37
37
  retryAfter: number | null;
38
- }
39
- export interface MaterialGraphRequestMetadata {
38
+ };
39
+ export type MaterialGraphRequestMetadata = {
40
40
  method: string;
41
41
  origin: string;
42
42
  path: string;
43
- }
43
+ };
44
44
  export interface MaterialGraphErrorInit {
45
45
  kind: MaterialGraphErrorKind;
46
46
  status?: number;
@@ -55,18 +55,18 @@ export interface MaterialGraphErrorInit {
55
55
  /** Accepted for compatibility but deliberately never retained on the public error. */
56
56
  cause?: unknown;
57
57
  }
58
- interface ResponseErrorInput extends MaterialGraphRequestMetadata {
58
+ type ResponseErrorInput = {
59
59
  status: number;
60
60
  body: unknown;
61
61
  responseText: string;
62
62
  rateLimit: RateLimit | null;
63
63
  apiKey: string;
64
64
  queryValues: readonly string[];
65
- }
66
- interface TransportErrorInput extends MaterialGraphRequestMetadata {
65
+ } & MaterialGraphRequestMetadata;
66
+ type TransportErrorInput = {
67
67
  cause: unknown;
68
68
  callerSignal?: AbortSignal;
69
- }
69
+ } & MaterialGraphRequestMetadata;
70
70
  /**
71
71
  * MaterialGraph's documented problem EXTENSION members — the only non-standard
72
72
  * keys this client retains.
@@ -89,7 +89,7 @@ interface TransportErrorInput extends MaterialGraphRequestMetadata {
89
89
  * member to a problem response means adding it here too, and
90
90
  * `problem-extension-parity.test.ts` fails when the two disagree.
91
91
  */
92
- export declare const MATERIALGRAPH_PROBLEM_EXTENSIONS: readonly ["ambiguous_brands", "brand_candidates", "content_length", "did_you_mean", "empty_brands", "limit_bytes", "missing_env", "orderable_attributes", "populated_alternatives", "unknown_attributes", "unknown_brands", "unknown_fields", "unorderable_attribute", "valid_group_keys", "valid_type_keys"];
92
+ export declare const MATERIALGRAPH_PROBLEM_EXTENSIONS: readonly ["ambiguous_brands", "brand_candidates", "content_length", "did_you_mean", "empty_brands", "limit_bytes", "missing_env", "orderable_attributes", "populated_alternatives", "refused_criteria", "unknown_attributes", "unknown_brands", "unknown_fields", "unorderable_attribute", "valid_group_keys", "valid_type_keys"];
93
93
  /** The one error class thrown by all SDK transport and HTTP failures. */
94
94
  export declare class MaterialGraphError extends Error {
95
95
  readonly kind: MaterialGraphErrorKind;
package/errors.js CHANGED
@@ -32,6 +32,7 @@ export const MATERIALGRAPH_PROBLEM_EXTENSIONS = [
32
32
  "missing_env",
33
33
  "orderable_attributes",
34
34
  "populated_alternatives",
35
+ "refused_criteria",
35
36
  "unknown_attributes",
36
37
  "unknown_brands",
37
38
  "unknown_fields",
@@ -43,38 +44,36 @@ const PROBLEM_EXTENSION_KEYS = new Set(MATERIALGRAPH_PROBLEM_EXTENSIONS);
43
44
  const MAX_UNEXPECTED_TEXT = 768;
44
45
  const MAX_EXTENSION_DEPTH = 8;
45
46
  const MAX_EXTENSION_ITEMS = 100;
46
- const MAX_EXTENSION_STRING = 1_024;
47
- function isRecord(value) {
48
- return typeof value === "object" && value !== null;
49
- }
50
- function redact(text, secrets) {
51
- return secrets.reduce((sanitized, secret) => {
52
- if (secret.length === 0)
53
- return sanitized;
54
- return sanitized.split(secret).join("[REDACTED]");
55
- }, text);
56
- }
57
- function safeString(text, secrets) {
58
- return redact(text, secrets).slice(0, MAX_EXTENSION_STRING);
59
- }
60
- function secretVariants(apiKey, queryValues) {
61
- return [
62
- apiKey,
63
- ...queryValues,
64
- ...queryValues.map(encodeURIComponent),
65
- ...queryValues.map((value) => new URLSearchParams([["value", value]]).toString().slice("value=".length)),
66
- ];
67
- }
68
- function requestMetadata(input) {
69
- return { method: input.method, origin: input.origin, path: input.path };
70
- }
47
+ const MAX_EXTENSION_STRING = 1024;
48
+ const isRecord = (value) => typeof value === "object" && value !== null;
49
+ const redact = (text, secrets) => secrets.reduce((sanitized, secret) => {
50
+ if (secret.length === 0) {
51
+ return sanitized;
52
+ }
53
+ return sanitized.split(secret).join("[REDACTED]");
54
+ }, text);
55
+ const safeString = (text, secrets) => redact(text, secrets).slice(0, MAX_EXTENSION_STRING);
56
+ const secretVariants = (apiKey, queryValues) => [
57
+ apiKey,
58
+ ...queryValues,
59
+ ...queryValues.map(encodeURIComponent),
60
+ ...queryValues.map((value) => new URLSearchParams([["value", value]]).toString().slice("value=".length)),
61
+ ];
62
+ const requestMetadata = (input) => ({
63
+ method: input.method,
64
+ origin: input.origin,
65
+ path: input.path,
66
+ });
71
67
  function sanitizeValue(value, secrets, depth = 0) {
72
- if (depth >= MAX_EXTENSION_DEPTH)
68
+ if (depth >= MAX_EXTENSION_DEPTH) {
73
69
  return undefined;
74
- if (value === null || typeof value === "boolean")
70
+ }
71
+ if (value === null || typeof value === "boolean") {
75
72
  return value;
76
- if (typeof value === "number")
73
+ }
74
+ if (typeof value === "number") {
77
75
  return Number.isFinite(value) ? value : undefined;
76
+ }
78
77
  if (typeof value === "string") {
79
78
  return safeString(value, secrets);
80
79
  }
@@ -84,8 +83,9 @@ function sanitizeValue(value, secrets, depth = 0) {
84
83
  .map((item) => sanitizeValue(item, secrets, depth + 1))
85
84
  .filter((item) => item !== undefined);
86
85
  }
87
- if (!isRecord(value))
86
+ if (!isRecord(value)) {
88
87
  return undefined;
88
+ }
89
89
  return sanitizeRecord(value, secrets, depth);
90
90
  }
91
91
  function sanitizeRecord(value, secrets, depth) {
@@ -99,15 +99,16 @@ function sanitizeRecord(value, secrets, depth) {
99
99
  });
100
100
  return Object.fromEntries(entries);
101
101
  }
102
- function sanitizeIssues(value, secrets) {
103
- if (!Array.isArray(value))
102
+ const sanitizeIssues = (value, secrets) => {
103
+ if (!Array.isArray(value)) {
104
104
  return undefined;
105
+ }
105
106
  return value
106
107
  .slice(0, MAX_EXTENSION_ITEMS)
107
108
  .filter((issue) => isRecord(issue) && !Array.isArray(issue))
108
109
  .map((issue) => sanitizeRecord(issue, secrets, 0));
109
- }
110
- function sanitizeSuggestions(value, secrets) {
110
+ };
111
+ const sanitizeSuggestions = (value, secrets) => {
111
112
  if (!Array.isArray(value) ||
112
113
  value.some((suggestion) => typeof suggestion !== "string")) {
113
114
  return undefined;
@@ -115,8 +116,8 @@ function sanitizeSuggestions(value, secrets) {
115
116
  return value
116
117
  .slice(0, MAX_EXTENSION_ITEMS)
117
118
  .map((suggestion) => safeString(suggestion, secrets));
118
- }
119
- function normalizeProblem(body, secrets) {
119
+ };
120
+ const normalizeProblem = (body, secrets) => {
120
121
  if (!isRecord(body) ||
121
122
  typeof body.type !== "string" ||
122
123
  typeof body.title !== "string" ||
@@ -150,24 +151,25 @@ function normalizeProblem(body, secrets) {
150
151
  : {}),
151
152
  ...(issues === undefined ? {} : { issues }),
152
153
  };
153
- }
154
- function normalizeSimple(body, secrets) {
155
- if (!isRecord(body) || typeof body.error !== "string")
154
+ };
155
+ const normalizeSimple = (body, secrets) => {
156
+ if (!isRecord(body) || typeof body.error !== "string") {
156
157
  return undefined;
158
+ }
157
159
  const issues = sanitizeIssues(body.issues, secrets);
158
160
  return {
159
161
  error: safeString(body.error, secrets),
160
162
  ...(issues === undefined ? {} : { issues }),
161
163
  };
162
- }
163
- function unexpectedMessage(status, responseText, secrets) {
164
+ };
165
+ const unexpectedMessage = (status, responseText, secrets) => {
164
166
  const sanitized = redact(responseText, secrets)
165
167
  .trim()
166
168
  .slice(0, MAX_UNEXPECTED_TEXT);
167
169
  return sanitized.length > 0
168
170
  ? `MaterialGraph request failed with HTTP ${status}: ${sanitized}`
169
171
  : `MaterialGraph request failed with HTTP ${status}`;
170
- }
172
+ };
171
173
  /** The one error class thrown by all SDK transport and HTTP failures. */
172
174
  export class MaterialGraphError extends Error {
173
175
  kind;
@@ -237,42 +239,42 @@ export class MaterialGraphError extends Error {
237
239
  simple?.error ??
238
240
  "MaterialGraph rate limit exceeded (429)", {
239
241
  ...metadata,
240
- status: input.status,
241
- rateLimit: input.rateLimit,
242
242
  kind: "rate_limited",
243
- retriable: false,
244
- traceId: problem?.trace_id,
245
243
  problem,
244
+ rateLimit: input.rateLimit,
245
+ retriable: false,
246
246
  simple,
247
+ status: input.status,
248
+ traceId: problem?.trace_id,
247
249
  });
248
250
  }
249
251
  if (problem !== undefined) {
250
252
  return new MaterialGraphError(problem.detail || problem.title, {
251
253
  ...metadata,
252
- status: input.status,
253
- rateLimit: input.rateLimit,
254
254
  kind: "problem",
255
+ problem,
256
+ rateLimit: input.rateLimit,
255
257
  retriable: retriable || problem.is_retriable,
258
+ status: input.status,
256
259
  traceId: problem.trace_id,
257
- problem,
258
260
  });
259
261
  }
260
262
  if (simple !== undefined) {
261
263
  return new MaterialGraphError(simple.error, {
262
264
  ...metadata,
263
- status: input.status,
264
- rateLimit: input.rateLimit,
265
265
  kind: "simple",
266
+ rateLimit: input.rateLimit,
266
267
  retriable,
267
268
  simple,
269
+ status: input.status,
268
270
  });
269
271
  }
270
272
  return new MaterialGraphError(unexpectedMessage(input.status, input.responseText, secrets), {
271
273
  ...metadata,
272
274
  kind: "unexpected",
273
- status: input.status,
274
- retriable,
275
275
  rateLimit: input.rateLimit,
276
+ retriable,
277
+ status: input.status,
276
278
  });
277
279
  }
278
280
  }
@@ -1,48 +1,40 @@
1
- /**
2
- * The shared low-level HTTP transport for {@link MaterialGraphClient}. It owns
3
- * URL building, the bearer header, rate-limit capture, response reading, and the
4
- * one error-mapping path — so the JSON read surface (`client.ts`), the multipart
5
- * upload, the SSE stream (`runs.ts`), and the NDJSON Match stream
6
- * (`match-stream.ts`) all fail identically. Retry-free by design; a single
7
- * failure surfaces as one {@link MaterialGraphError}.
8
- */
9
- import { type RateLimit } from "./errors.js";
10
- import { type SdkOperation } from "./operations.js";
11
- export type QueryValue = string | number | boolean | undefined | null | Array<string | number | boolean>;
1
+ import type { RateLimit } from "./errors.js";
2
+ import type { SdkOperation } from "./operations.js";
3
+ export type QueryValue = string | number | boolean | undefined | null | (string | number | boolean)[];
12
4
  export type QueryParams = Record<string, QueryValue>;
13
- export interface RequestOptions {
5
+ export type RequestOptions = {
14
6
  /** Required by state-changing operations that support safe retries. */
15
7
  idempotencyKey?: string;
16
8
  query?: QueryParams;
17
9
  body?: unknown;
18
10
  signal?: AbortSignal;
19
11
  pathParams?: Readonly<Record<string, string>>;
20
- }
21
- export interface StreamRequestOptions extends RequestOptions {
12
+ };
13
+ export type StreamRequestOptions = {
22
14
  /** The streaming media type to negotiate (`text/event-stream`, `application/x-ndjson`). */
23
15
  accept: string;
24
16
  /** Names this stream in the "returned no body" diagnostic, e.g. `"match stream"`. */
25
17
  subject: string;
26
- }
18
+ } & RequestOptions;
27
19
  /** A read, status-checked HTTP response with its parsed body. */
28
- export interface SentResponse {
20
+ export type SentResponse = {
29
21
  response: Response;
30
22
  text: string;
31
23
  parsed: unknown;
32
- }
33
- interface SendInput {
24
+ };
25
+ type SendInput = {
34
26
  method: string;
35
27
  url: string;
36
28
  headers: Record<string, string>;
37
29
  /** The only bodies the SDK sends: a JSON string or a multipart `FormData`. */
38
30
  body?: string | FormData;
39
31
  signal?: AbortSignal;
40
- }
41
- export interface HttpTransportOptions {
32
+ };
33
+ export type HttpTransportOptions = {
42
34
  apiKey: string;
43
35
  baseUrl: string;
44
36
  fetch: typeof fetch;
45
- }
37
+ };
46
38
  export declare class HttpTransport {
47
39
  #private;
48
40
  readonly baseUrl: string;