@instruments/materialgraph 0.37.3 → 0.39.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 (43) hide show
  1. package/associations-client.js +12 -3
  2. package/by-spec-types.d.ts +1 -1
  3. package/catalogue-types.d.ts +36 -37
  4. package/categories-client.d.ts +2 -2
  5. package/client-response-schema.d.ts +3 -0
  6. package/client-response-schema.js +79 -0
  7. package/client.d.ts +9 -4
  8. package/client.js +46 -18
  9. package/color-profiles-types.d.ts +0 -10
  10. package/colors-client.d.ts +7 -5
  11. package/colors-client.js +6 -3
  12. package/errors.d.ts +4 -4
  13. package/errors.js +13 -10
  14. package/find-variants-by-color-types.d.ts +6 -8
  15. package/find-variants-by-vector-types.d.ts +3 -0
  16. package/get-variant-types.d.ts +22 -1
  17. package/http-transport.d.ts +2 -1
  18. package/http-transport.js +12 -10
  19. package/index.d.ts +22 -21
  20. package/material-block-types.d.ts +7 -1
  21. package/material-resources-client.js +4 -1
  22. package/nearest-paints-types.d.ts +33 -0
  23. package/nearest-paints-types.js +1 -0
  24. package/operation-responses.d.ts +65 -0
  25. package/operation-responses.js +1 -0
  26. package/operations.d.ts +4 -12
  27. package/operations.generated.d.ts +11 -0
  28. package/operations.generated.js +189 -0
  29. package/operations.js +10 -178
  30. package/package.json +2 -2
  31. package/parse-operation-response.d.ts +5 -0
  32. package/parse-operation-response.js +202 -0
  33. package/response-schemas.generated.d.ts +1 -1
  34. package/response-schemas.generated.js +35 -32
  35. package/runs.d.ts +2 -1
  36. package/runs.js +45 -12
  37. package/samplize-catalogue-types.d.ts +8 -8
  38. package/samplize-colorvec.js +111 -80
  39. package/search-variants-types.d.ts +1 -1
  40. package/sse.d.ts +2 -1
  41. package/sse.js +7 -5
  42. package/types.d.ts +6 -6
  43. package/webmcp.generated.js +3 -3
package/errors.js CHANGED
@@ -47,12 +47,15 @@ const MAX_EXTENSION_DEPTH = 8;
47
47
  const MAX_EXTENSION_ITEMS = 100;
48
48
  const MAX_EXTENSION_STRING = 1024;
49
49
  const isRecord = (value) => typeof value === "object" && value !== null;
50
- const redact = (text, secrets) => secrets.reduce((sanitized, secret) => {
51
- if (secret.length === 0) {
52
- return sanitized;
50
+ const redact = (text, secrets) => {
51
+ let sanitized = text;
52
+ for (const secret of secrets) {
53
+ if (secret.length > 0) {
54
+ sanitized = sanitized.split(secret).join("[REDACTED]");
55
+ }
53
56
  }
54
- return sanitized.split(secret).join("[REDACTED]");
55
- }, text);
57
+ return sanitized;
58
+ };
56
59
  const safeString = (text, secrets) => redact(text, secrets).slice(0, MAX_EXTENSION_STRING);
57
60
  const secretVariants = (apiKey, queryValues) => [
58
61
  apiKey,
@@ -65,7 +68,7 @@ const requestMetadata = (input) => ({
65
68
  origin: input.origin,
66
69
  path: input.path,
67
70
  });
68
- function sanitizeValue(value, secrets, depth = 0) {
71
+ const sanitizeValue = (value, secrets, depth = 0) => {
69
72
  if (depth >= MAX_EXTENSION_DEPTH) {
70
73
  return undefined;
71
74
  }
@@ -88,8 +91,8 @@ function sanitizeValue(value, secrets, depth = 0) {
88
91
  return undefined;
89
92
  }
90
93
  return sanitizeRecord(value, secrets, depth);
91
- }
92
- function sanitizeRecord(value, secrets, depth) {
94
+ };
95
+ const sanitizeRecord = (value, secrets, depth) => {
93
96
  const entries = Object.entries(value)
94
97
  .slice(0, MAX_EXTENSION_ITEMS)
95
98
  .flatMap(([key, item]) => {
@@ -99,7 +102,7 @@ function sanitizeRecord(value, secrets, depth) {
99
102
  : [[safeString(key, secrets), sanitized]];
100
103
  });
101
104
  return Object.fromEntries(entries);
102
- }
105
+ };
103
106
  const sanitizeIssues = (value, secrets) => {
104
107
  if (!Array.isArray(value)) {
105
108
  return undefined;
@@ -111,7 +114,7 @@ const sanitizeIssues = (value, secrets) => {
111
114
  };
112
115
  const sanitizeSuggestions = (value, secrets) => {
113
116
  if (!Array.isArray(value) ||
114
- value.some((suggestion) => typeof suggestion !== "string")) {
117
+ !value.every((suggestion) => typeof suggestion === "string")) {
115
118
  return undefined;
116
119
  }
117
120
  return value
@@ -47,14 +47,14 @@ export type FindVariantsByColorInput = {
47
47
  variantIds?: string[];
48
48
  };
49
49
  export type ColorConditionReceipt = {
50
- /** OKLab distance to the matched swatch. Never a probability. */
50
+ /** CIEDE2000 difference to the assigned settled swatch. Never a probability. */
51
51
  distance: number;
52
52
  hex: string;
53
53
  /** Position in the request's `colors[]`. */
54
54
  index: number;
55
- /** The matched swatch's share of its image, 0 to 1. */
55
+ /** The assigned swatch's share of the settled palette, 0 to 1. */
56
56
  proportion: number;
57
- /** Requested target share, palette only; null otherwise. Ranked by, not filtered. */
57
+ /** Requested share used for ColorVec retrieval, palette only; null otherwise. */
58
58
  target: number | null;
59
59
  };
60
60
  export type PaintCatalogVariant = {
@@ -71,7 +71,7 @@ export type ResolvedColor = {
71
71
  index: number;
72
72
  /** `region`: a named meaning's own OKLCh bounds, kept — never collapsed to one hex. */
73
73
  kind: "point" | "region";
74
- /** Renormalised share, image-extracted colors only; else null. */
74
+ /** Image-extracted or stored target-variant swatch share; else null. */
75
75
  share: number | null;
76
76
  };
77
77
  export type ColorAlternative = {
@@ -143,14 +143,12 @@ export type ColorRankedSeed = {
143
143
  /** The variant's own name — paint colorway names live here (label contract). */
144
144
  variantName: string | null;
145
145
  };
146
- /** RERANK's own card — the same shape `ColorVariantMatch` above (`brandId`, `code`), plus its two ranking-only fields. */
146
+ /** RERANK's own card — the same shape `ColorVariantMatch` above (`brandId`, `code`), plus its perceptual distance. */
147
147
  export type ColorRankMatch = {
148
148
  brand: string;
149
149
  brandId: string;
150
150
  code: string | null;
151
- /** Color similarity in [0,1], 1 = identical palette; null when unembedded. */
152
- colorSimilarity: number | null;
153
- /** Cosine distance computed in TypeScript (0 = identical); null when unembedded. */
151
+ /** CIEDE2000 difference to the settled reference color (0 = identical); null without a settled palette. */
154
152
  distance: number | null;
155
153
  imageUrl: string | null;
156
154
  product: string;
@@ -1,3 +1,4 @@
1
+ import type { PaintCatalogVariant } from "./find-variants-by-color-types.js";
1
2
  /**
2
3
  * @module find-variants-by-vector-types
3
4
  * @description Hand-maintained mirror of `find_variants_by_vector`'s
@@ -61,6 +62,8 @@ export type FindVariantsByVectorOutput = {
61
62
  items: FindVariantsByVectorItem[];
62
63
  mode: FindVariantsByVectorMode;
63
64
  reference: FindVariantsByVectorReference;
65
+ /** The exact brand paint named by the text query, when held in the catalogue. */
66
+ namedPaint?: PaintCatalogVariant;
64
67
  scan: FindVariantsByVectorScan;
65
68
  timings: FindVariantsByVectorTimings;
66
69
  /** Explicit `{field: "variant", op: "in"}` filter ids that named no eligible variant — present only when at least one did. */
@@ -8,6 +8,7 @@
8
8
  * server types.
9
9
  */
10
10
  import type { ListVariantsNotApplicable, ListVariantsSpecifications, SampleSubject } from "./list-variants-types.js";
11
+ import type { VariantColorPalette } from "./material-block-types.js";
11
12
  /** The detail to add under `specifications`; absent, the answer is the compact item alone. */
12
13
  export type GetVariantOptions = {
13
14
  /** Canonical attribute ids, e.g. `["nrc_rating"]`. */
@@ -21,6 +22,20 @@ export type GetVariantOptions = {
21
22
  * false or zero.
22
23
  */
23
24
  export type GetVariantOutput = {
25
+ eligible: boolean;
26
+ channels: string[];
27
+ palette: {
28
+ hex: string;
29
+ share: number;
30
+ dominant: boolean;
31
+ method: "stated" | "isolated" | "crop";
32
+ }[];
33
+ attributes: Record<string, {
34
+ value: unknown;
35
+ valueSource: "brand" | "material_bank" | "samplize" | "measured" | null;
36
+ wording: string | null;
37
+ level: "variant" | "product" | "brand";
38
+ }>;
24
39
  category: {
25
40
  id: string;
26
41
  name: string;
@@ -56,7 +71,13 @@ export type GetVariantOutput = {
56
71
  id: string;
57
72
  name: string;
58
73
  };
59
- specifications?: ListVariantsSpecifications;
74
+ specifications?: ListVariantsSpecifications & {
75
+ color?: Record<string, unknown> & {
76
+ /** Measured bands, largest share first; paints use one declared color band. Absent means unknown. */
77
+ color_palette?: VariantColorPalette;
78
+ light_reflectance_value?: unknown;
79
+ };
80
+ };
60
81
  url: string | null;
61
82
  variantId: string;
62
83
  };
@@ -1,4 +1,5 @@
1
1
  import type { RateLimit } from "./errors.js";
2
+ import type { JsonOperationId, OperationResponses } from "./operation-responses.js";
2
3
  import type { SdkOperation } from "./operations.js";
3
4
  type QueryValue = string | number | boolean | undefined | null | (string | number | boolean)[];
4
5
  export type QueryParams = Record<string, QueryValue>;
@@ -63,6 +64,6 @@ export declare class HttpTransport {
63
64
  */
64
65
  openStream(sdkOperation: SdkOperation, options: StreamRequestOptions): Promise<ReadableStream<Uint8Array>>;
65
66
  /** Execute a registered JSON operation and return its typed body. */
66
- requestJson<T>(sdkOperation: SdkOperation, options?: RequestOptions): Promise<T>;
67
+ requestJson<K extends JsonOperationId>(sdkOperation: SdkOperation<K>, options?: RequestOptions): Promise<OperationResponses[K]>;
67
68
  }
68
69
  export {};
package/http-transport.js CHANGED
@@ -7,18 +7,19 @@
7
7
  */
8
8
  import { MaterialGraphError } from "./errors.js";
9
9
  import { operationPath } from "./operations.js";
10
- const parseIntOrNull = (value) => {
11
- if (value === null) {
10
+ import { parseOperationResponse } from "./parse-operation-response.js";
11
+ const parseNumberOrNull = (value) => {
12
+ if (value === null || value.trim() === "") {
12
13
  return null;
13
14
  }
14
- const parsed = Number.parseInt(value, 10);
15
- return Number.isNaN(parsed) ? null : parsed;
15
+ const parsed = Number(value);
16
+ return Number.isFinite(parsed) ? parsed : null;
16
17
  };
17
18
  const parseRateLimit = (headers) => {
18
- const limit = parseIntOrNull(headers.get("x-ratelimit-limit"));
19
- const remaining = parseIntOrNull(headers.get("x-ratelimit-remaining"));
20
- const reset = parseIntOrNull(headers.get("x-ratelimit-reset"));
21
- const retryAfter = parseIntOrNull(headers.get("retry-after"));
19
+ const limit = parseNumberOrNull(headers.get("x-ratelimit-limit"));
20
+ const remaining = parseNumberOrNull(headers.get("x-ratelimit-remaining"));
21
+ const reset = parseNumberOrNull(headers.get("x-ratelimit-reset"));
22
+ const retryAfter = parseNumberOrNull(headers.get("retry-after"));
22
23
  if (limit === null &&
23
24
  remaining === null &&
24
25
  reset === null &&
@@ -214,7 +215,8 @@ export class HttpTransport {
214
215
  body: hasBody ? JSON.stringify(options.body) : undefined,
215
216
  headers: this.authHeaders({
216
217
  ...(hasBody ? { "Content-Type": "application/json" } : {}),
217
- ...(options.idempotencyKey
218
+ ...(options.idempotencyKey !== undefined &&
219
+ options.idempotencyKey !== ""
218
220
  ? { "Idempotency-Key": options.idempotencyKey }
219
221
  : {}),
220
222
  }),
@@ -222,6 +224,6 @@ export class HttpTransport {
222
224
  signal: options.signal,
223
225
  url,
224
226
  });
225
- return parsed;
227
+ return await parseOperationResponse(sdkOperation.operationId, parsed);
226
228
  }
227
229
  }
package/index.d.ts CHANGED
@@ -1,33 +1,34 @@
1
1
  export { MaterialGraphClient, DEFAULT_BASE_URL } from "./client.js";
2
2
  export type { MaterialGraphClientOptions } from "./client.js";
3
- export type * from "./list-variants-types.js";
4
- export type * from "./list-variant-facets-types.js";
5
- export type * from "./search-variants-types.js";
6
- export type * from "./list-enum-values-types.js";
7
- export type * from "./get-variant-types.js";
8
- export type * from "./image-reference-types.js";
9
- export type * from "./find-sampled-together-types.js";
10
- export type * from "./find-variants-by-color-types.js";
3
+ export type { FilterOp, FilterTermCondition, FilterNumericCondition, FilterPresenceCondition, FilterAnyFieldCondition, FilterCondition, FilterGroups, OptionalFilterGroups, OrderByEntry, ListVariantsInclude, ListVariantsCollapse, ColorRegion, ColorRangeCondition, ListVariantsInput, ListVariantsPreference, ListVariantsSpecifications, ListVariantsNotApplicable, SampleSubject, ListVariantsItem, ListVariantsOutput, } from "./list-variants-types.js";
4
+ export type { ListVariantFacetsInput, VariantFacetValue, CategoricalVariantFacet, BooleanVariantFacet, NumericVariantFacet, VariantFacet, ListVariantFacetsOutput, } from "./list-variant-facets-types.js";
5
+ export type { SearchVariantsSelection, SearchVariantsInput, SearchVariantsUnderstood, SearchVariantsReading, SearchVariantsChoice, SearchVariantsOutput, } from "./search-variants-types.js";
6
+ export type { ListEnumValuesOptions, EnumValueMatch, EnumValueItem, ListEnumValuesResult, } from "./list-enum-values-types.js";
7
+ export type { GetVariantOptions, GetVariantOutput, } from "./get-variant-types.js";
8
+ export type { ImageReferenceInput } from "./image-reference-types.js";
9
+ export type { SampledTogetherProjectType, FindSampledTogetherInput, FindSampledTogetherRow, FindSampledTogetherOutput, } from "./find-sampled-together-types.js";
10
+ export type { FindVariantsByColorMode, ColorConditionInput, FindVariantsByColorInput, ColorConditionReceipt, PaintCatalogVariant, ResolvedColor, ColorAlternative, UnresolvedColor, ColorVariantMatch, ColorPageInfo, FindVariantsByColorContainsResult, FindVariantsByColorPaletteResult, ColorRankedSeed, ColorRankMatch, ResolvedColorReference, CompareColorSimilarityReference, FindVariantsByColorRerankResult, FindVariantsByColorOutput, } from "./find-variants-by-color-types.js";
11
11
  export { FIND_VARIANTS_BY_VECTOR_MODES } from "./find-variants-by-vector-types.js";
12
- export type * from "./find-variants-by-vector-types.js";
12
+ export type { FindVariantsByVectorMode, FindVariantsByVectorQuery, FindVariantsByVectorInput, FindVariantsByVectorItem, FindVariantsByVectorReference, FindVariantsByVectorScan, FindVariantsByVectorTimings, FindVariantsByVectorOutput, } from "./find-variants-by-vector-types.js";
13
13
  export { MATERIALGRAPH_API_VERSION, SDK_OPERATIONS } from "./operations.js";
14
14
  export type { SdkOperation, SdkOperationId } from "./operations.js";
15
- export type * from "./identifiers.js";
15
+ export type { OpaqueId, VariantId, ProductId, RunId, BatchId, SourceFileId, ProjectId, SchemeId, SlotId, Cursor, } from "./identifiers.js";
16
16
  export { TERMINAL_RUN_EVENT_TYPES } from "./run-types.js";
17
- export type * from "./run-types.js";
17
+ export type { FileInput, UploadSourceMaterialInput, SourceMaterialReceiptFile, SourceMaterialBatchReceipt, PublicRunStatus, PublicRunFailure, PublicRunArtifactRef, PublicRun, CreatePublicRunRequest, CreatePublicRunResponse, PublicRunResponse, RunEvent, StreamRunEventsOptions, DrainRunEventsOptions, } from "./run-types.js";
18
18
  export { MATERIALGRAPH_PROBLEM_EXTENSIONS, MaterialGraphError, } from "./errors.js";
19
19
  export type { MaterialGraphErrorInit, MaterialGraphErrorKind, MaterialGraphRequestMetadata, ProblemDetail, RateLimit, SanitizedErrorValue, SanitizedIssue, SimpleErrorBody, } from "./errors.js";
20
- export type * from "./types.js";
21
- export type * from "./resolve-variant-types.js";
22
- export type * from "./catalogue-types.js";
20
+ export type { OpenEnum, JsonValue, OklabTriple, MaterialColor, ImageSource, MaterialAvailability, MaterialTile, DemandMomentum, CompanionDemand, ProjectTypeShare, CospecPairing, ColorPairing, PairingOrderMode, PairingRanking, PairingOrdering, PairingItem, PairingsResponse, AttributeMatch, AttributeListItem, OutsideScopeAttribute, ListAttributesResult, WhoamiResponse, PairingsOptions, ListAttributesOptions, ExtractedPalette, ExtractPaletteResponse, ExtractPaletteInput, ResolveValueCandidate, ValueResolution, ResolveColorOptions, ResolveColorCatalogueVariant, ResolveColorVariant, ResolveColorResponse, BySpecVerdictState, BySpecVerdictCell, BySpecVerdict, MaterialVerdict, BySpecUnresolvedCriterion, } from "./types.js";
21
+ export type { ResolveVariantInput, ResolveVariantSubject, ResolveVariantEvidence, ResolveVariantReceipt, ResolveVariantUnresolvedReason, ResolveVariantOutput, } from "./resolve-variant-types.js";
22
+ export type { CatalogueReference, CatalogueReferenceAbsenceReason, CatalogueReferencePublication, CatalogueReferenceResult, CatalogueReferenceBatchResponse, CatalogueCollectionsOptions, CatalogueCollectionSampleProduct, CatalogueChannelCollection, CatalogueChannelCollectionsResponse, CatalogueDocumentAccess, CatalogueDocumentAccessResult, CatalogDocument, CatalogEdition, CatalogAvailableReceipt, CatalogFailureReceipt, UnavailableCatalogDocument, CatalogPublication, CatalogDocumentList, CatalogProductReferenceList, CatalogProductReferenceUnavailable, CatalogProductReferenceReadResult, CataloguePageRequiredArtifact, CataloguePageAvailableArtifact, CataloguePage, CatalogPageListResult, CataloguePageRepresentationReadResult, } from "./catalogue-types.js";
23
23
  export { CategoriesClient } from "./categories-client.js";
24
- export type * from "./category-types.js";
24
+ export type { CategoryRef, CategoryKind, CategoryMatch, CategoryItem, CategoriesPageInfo, CategoriesListInput, CategoriesListResult, CategoryConcept, CategoryProductCategory, CategoriesGetResult, } from "./category-types.js";
25
25
  export { ColorsClient } from "./colors-client.js";
26
26
  export type { ColorsTransport } from "./colors-client.js";
27
- export type * from "./color-profiles-types.js";
28
- export type * from "./association-types.js";
29
- export type * from "./brand-types.js";
30
- export type * from "./material-asset-types.js";
31
- export type * from "./material-block-types.js";
32
- export type * from "./schema-resource-types.js";
27
+ export type { CategoryTier, CategoryColor, CategoryColorProfile, CategoryColorProfilesResponse, ColorProfilesParams, } from "./color-profiles-types.js";
28
+ export type { DeclaredProvenance, DeclaredAssociationSubject, DeclaredAssociation, DeclaredAssociationsResponse, AssociatedOptions, ApplicabilitySubject, ApplicabilityCoverageState, ApplicabilityCoverage, ApplicabilityFact, ApplicabilitySourceEntry, UnresolvedApplicabilityEndpoint, ApplicabilityResponse, ApplicabilityOptions, } from "./association-types.js";
29
+ export type { BrandsOptions, BrandItem, ListBrandsPage, } from "./brand-types.js";
30
+ export type { VariantAssetAvailability, VariantImageRole, VariantImagePresentation, VariantDocumentType, VariantAssetKind, VariantAssetItem, VariantDocumentCoverageState, VariantAssetPageInfo, ListVariantAssetsOptions, VariantAssetPage, MaterialDocumentStatus, MaterialDocumentCoverageState, MaterialDocumentScope, MaterialDocumentSource, MaterialDocumentProjectionItem, MaterialDocumentCoverageSource, MaterialDocumentCoverage, MaterialDocumentCoverageSummary, MaterialDocumentPageOptions, MaterialDocumentPage, } from "./material-asset-types.js";
31
+ export type { MaterialCoverageStatus, MaterialBlockStatus, MaterialBlockFieldStatus, MaterialBlockFieldValue, MaterialBlockProjectionField, MaterialBlockProjectionItem, MaterialBlockProjection, VariantColorPalette, } from "./material-block-types.js";
32
+ export type { SchemaResource, SCHEMA_RESOURCE_OPERATION_IDS, SchemaResourceRequest, SchemaLifecycle, SchemaExternalMapping, SchemaMatchStrength, SchemaValueDictionaryTerm, SchemaValueDictionaryItem, SchemaResourceItemMap, SchemaResourceResponse, } from "./schema-resource-types.js";
33
33
  export type { SamplizePublicationSource, SamplizeLrvObservation, SamplizeDemand, SamplizeCollectionMembership, SamplizeCatalogueOptions, SamplizeCataloguePage, SamplizeCatalogueProduct, SamplizeHexObservation, } from "./samplize-catalogue-types.js";
34
+ export type { NearestPaintsParams, NearestPaintCard, NearestPaintsHexResult, NearestPaintsOutput, } from "./nearest-paints-types.js";
@@ -35,6 +35,12 @@ import type { OpenEnum } from "./types.js";
35
35
  export type MaterialCoverageStatus = OpenEnum<"complete" | "partial" | "missing" | "not_applicable">;
36
36
  export type MaterialBlockStatus = MaterialCoverageStatus;
37
37
  export type MaterialBlockFieldStatus = MaterialCoverageStatus;
38
+ /** Stored image bands, or one declared paint color regardless of image bands. Hexes use uppercase #RRGGBB. */
39
+ export type VariantColorPalette = {
40
+ hex: string;
41
+ share: number;
42
+ dominant: boolean;
43
+ }[];
38
44
  /**
39
45
  * A field's value. `null` is AMBIGUOUS on its own — pair it with `status`:
40
46
  * `complete` + `null` is a determined absence, `missing` + `null` is unread.
@@ -55,7 +61,7 @@ export type MaterialBlockProjectionField = {
55
61
  unit?: string;
56
62
  status: MaterialBlockFieldStatus;
57
63
  /** Provenance supplied by the graph when a source-backed claim supports this field. */
58
- valueOrigin?: string;
64
+ valueSource?: string;
59
65
  /** Claim confidence supplied by the graph; absence means no confidence was emitted. */
60
66
  confidence?: number;
61
67
  };
@@ -1,6 +1,9 @@
1
1
  import { resolveOperation } from "./operations.js";
2
2
  /** Read known and explicitly unobserved canonical material fields. */
3
- export const materialBlocks = async (transport, variantId, signal) => await transport.requestJson(resolveOperation("list_material_blocks"), { pathParams: { variantId }, signal });
3
+ export const materialBlocks = async (transport, variantId, signal) => await transport.requestJson(resolveOperation("list_material_blocks"), {
4
+ pathParams: { variantId },
5
+ signal,
6
+ });
4
7
  /**
5
8
  * Read one bounded, filtered, cursor-paged page of a variant's images and
6
9
  * files. `imageRoles` narrows only images and `documentTypes` narrows only
@@ -0,0 +1,33 @@
1
+ export type NearestPaintsParams = {
2
+ hexes: string[];
3
+ limit?: number;
4
+ };
5
+ export type NearestPaintCard = {
6
+ variantId: string;
7
+ name: string;
8
+ brand: {
9
+ id: string;
10
+ name: string;
11
+ };
12
+ code: string | null;
13
+ hex: string;
14
+ sampleSubject: "material" | "paint_color_sample" | "unknown" | "conflict";
15
+ productType: {
16
+ id: string;
17
+ name: string;
18
+ } | null;
19
+ image: {
20
+ url: string;
21
+ alt: string;
22
+ } | null;
23
+ lrv: number | null;
24
+ deltaE: number;
25
+ closeness: "very-near" | "very-close" | "close" | "related" | "unrelated";
26
+ };
27
+ export type NearestPaintsHexResult = {
28
+ hex: string;
29
+ paints: NearestPaintCard[];
30
+ };
31
+ export type NearestPaintsOutput = {
32
+ results: NearestPaintsHexResult[];
33
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,65 @@
1
+ /** Response types belong to operation ids, never a caller-selected generic. */
2
+ import type { ApplicabilityResponse, DeclaredAssociationsResponse } from "./association-types.js";
3
+ import type { ListBrandsPage } from "./brand-types.js";
4
+ import type { CatalogDocumentList, CatalogPageListResult, CatalogProductReferenceReadResult, CatalogueChannelCollectionsResponse, CatalogueDocumentAccessResult, CataloguePageRepresentationReadResult, CatalogueReferenceBatchResponse } from "./catalogue-types.js";
5
+ import type { CategoriesGetResult, CategoriesListResult } from "./category-types.js";
6
+ import type { CategoryColorProfilesResponse } from "./color-profiles-types.js";
7
+ import type { FindSampledTogetherOutput } from "./find-sampled-together-types.js";
8
+ import type { FindVariantsByColorOutput } from "./find-variants-by-color-types.js";
9
+ import type { FindVariantsByVectorOutput } from "./find-variants-by-vector-types.js";
10
+ import type { GetVariantOutput } from "./get-variant-types.js";
11
+ import type { ListEnumValuesResult } from "./list-enum-values-types.js";
12
+ import type { ListVariantFacetsOutput } from "./list-variant-facets-types.js";
13
+ import type { ListVariantsOutput } from "./list-variants-types.js";
14
+ import type { MaterialDocumentPage, VariantAssetPage } from "./material-asset-types.js";
15
+ import type { MaterialBlockProjection } from "./material-block-types.js";
16
+ import type { NearestPaintsOutput } from "./nearest-paints-types.js";
17
+ import type { ResolveVariantOutput } from "./resolve-variant-types.js";
18
+ import type { CreatePublicRunResponse, PublicRunResponse, SourceMaterialBatchReceipt } from "./run-types.js";
19
+ import type { SamplizeCataloguePage } from "./samplize-catalogue-types.js";
20
+ import type { SchemaResourceResponse } from "./schema-resource-types.js";
21
+ import type { SearchVariantsOutput } from "./search-variants-types.js";
22
+ import type { ExtractPaletteResponse, ListAttributesResult, PairingsResponse, ResolveColorResponse, WhoamiResponse } from "./types.js";
23
+ export type OperationResponses = {
24
+ find_nearest_paints: NearestPaintsOutput;
25
+ get_catalogue_generation: {
26
+ generation: number;
27
+ };
28
+ catalog_list_attributes: ListAttributesResult;
29
+ catalog_list_enum_values: ListEnumValuesResult;
30
+ create_public_run: CreatePublicRunResponse;
31
+ extract_image_palette: ExtractPaletteResponse;
32
+ find_sampled_together: FindSampledTogetherOutput;
33
+ find_variants_by_color: FindVariantsByColorOutput;
34
+ find_variants_by_vector: FindVariantsByVectorOutput;
35
+ get_applicability: ApplicabilityResponse;
36
+ get_catalog_page_representation: CataloguePageRepresentationReadResult;
37
+ get_catalogue_document_access: CatalogueDocumentAccessResult;
38
+ get_catalogue_references_batch: CatalogueReferenceBatchResponse;
39
+ get_category: CategoriesGetResult;
40
+ get_category_color_profiles: CategoryColorProfilesResponse;
41
+ get_material_pairings: PairingsResponse;
42
+ get_public_run: PublicRunResponse;
43
+ get_variant: GetVariantOutput;
44
+ list_associated_finishes: DeclaredAssociationsResponse;
45
+ list_associated_products: DeclaredAssociationsResponse;
46
+ list_brands: ListBrandsPage;
47
+ list_catalog_documents: CatalogDocumentList;
48
+ list_catalog_pages: CatalogPageListResult;
49
+ list_catalog_product_references: CatalogProductReferenceReadResult;
50
+ list_catalogue_channel_collections: CatalogueChannelCollectionsResponse;
51
+ list_categories: CategoriesListResult;
52
+ list_material_blocks: MaterialBlockProjection;
53
+ list_material_documents: MaterialDocumentPage;
54
+ list_schema_value_dictionaries: SchemaResourceResponse;
55
+ list_variant_assets: VariantAssetPage;
56
+ list_variant_facets: ListVariantFacetsOutput;
57
+ list_variants: ListVariantsOutput;
58
+ resolve_color_name: ResolveColorResponse;
59
+ resolve_variant: ResolveVariantOutput;
60
+ samplize_catalogue_products: SamplizeCataloguePage;
61
+ search_variants: SearchVariantsOutput;
62
+ upload_source_material: SourceMaterialBatchReceipt;
63
+ whoami: WhoamiResponse;
64
+ };
65
+ export type JsonOperationId = keyof OperationResponses;
@@ -0,0 +1 @@
1
+ export {};
package/operations.d.ts CHANGED
@@ -1,13 +1,6 @@
1
- export declare const MATERIALGRAPH_API_VERSION = "0.8.0";
2
- declare const OPERATION_DEFINITIONS: readonly [readonly ["catalogs", "GET", "/api/v1/catalogs", "list_catalog_documents"], readonly ["catalogPages", "GET", "/api/v1/catalogs/{catalogId}/pages", "list_catalog_pages"], readonly ["catalogPageRepresentation", "GET", "/api/v1/catalog-pages/{pageId}/representation", "get_catalog_page_representation"], readonly ["catalogReferences", "GET", "/api/v1/catalogs/{catalogId}/references", "list_catalog_product_references"], readonly ["samplizeCatalogue", "GET", "/api/v1/catalogues/samplize/products", "samplize_catalogue_products"], readonly ["catalogueReferences", "POST", "/api/v1/catalogues/references", "get_catalogue_references_batch"], readonly ["catalogueCollections", "GET", "/api/v1/catalogues/collections", "list_catalogue_channel_collections"], readonly ["catalogueDocumentAccess", "GET", "/api/v1/catalogues/documents/{documentId}", "get_catalogue_document_access"], readonly ["materialBlocks", "GET", "/api/v1/materials/{variantId}/blocks", "list_material_blocks"], readonly ["listVariantAssets", "GET", "/api/v1/variants/{variantId}/assets", "list_variant_assets"], readonly ["materialDocuments", "GET", "/api/v1/materials/{variantId}/documents", "list_material_documents"], readonly ["schema", "GET", "/api/v1/schema/value-dictionaries", "list_schema_value_dictionaries"], readonly ["pairings", "GET", "/api/v1/materials/{variantId}/pairings", "get_material_pairings"], readonly ["associatedFinishes", "GET", "/api/v1/associated/finishes", "list_associated_finishes"], readonly ["associatedProducts", "GET", "/api/v1/associated/products", "list_associated_products"], readonly ["applicability", "GET", "/api/v1/applicability", "get_applicability"], readonly ["listVariants", "GET", "/api/v1/variants", "list_variants"], readonly ["listVariantFacets", "POST", "/api/v1/variants/facets", "list_variant_facets"], readonly ["searchVariants", "POST", "/api/v1/variants/search", "search_variants"], readonly ["findVariantsByColor", "POST", "/api/v1/variants/by-color", "find_variants_by_color"], readonly ["findVariantsByVector", "POST", "/api/v1/variants/by-vector", "find_variants_by_vector"], readonly ["findSampledTogether", "POST", "/api/v1/variants/sampled-together", "find_sampled_together"], readonly ["resolveVariant", "POST", "/api/v1/variants/resolve", "resolve_variant"], readonly ["getVariant", "GET", "/api/v1/variants/{variantId}", "get_variant"], readonly ["resolveColor", "GET", "/api/v1/search/colors/resolve", "resolve_color_name"], readonly ["listAttributes", "GET", "/api/v1/catalog/attributes", "catalog_list_attributes"], readonly ["listEnumValues", "GET", "/api/v1/catalog/enum-values", "catalog_list_enum_values"], readonly ["categories.list", "GET", "/api/v1/categories", "list_categories"], readonly ["categories.get", "GET", "/api/v1/categories/{id}", "get_category"], readonly ["whoami", "GET", "/api/v1/whoami", "whoami"], readonly ["colors.profiles", "GET", "/api/v1/colors/profiles", "get_category_color_profiles"], readonly ["extractPalette", "POST", "/api/v1/search/palettes/extract", "extract_image_palette"], readonly ["brands", "GET", "/api/v1/brands", "list_brands"], readonly ["uploadSourceMaterial", "POST", "/api/v1/source-material", "upload_source_material"], readonly ["workflows.start", "POST", "/api/v1/workflows/{workflowId}/runs", "create_public_run"], readonly ["workflows.run", "GET", "/api/v1/workflows/{workflowId}/runs/{runId}", "get_public_run"], readonly ["workflows.streamRunEvents", "GET", "/api/v1/workflows/{workflowId}/runs/{runId}/events", "list_public_run_events"]];
3
- export type SdkOperationId = (typeof OPERATION_DEFINITIONS)[number][3];
4
- export type SdkOperation = Readonly<{
5
- clientMethod: (typeof OPERATION_DEFINITIONS)[number][0];
6
- method: (typeof OPERATION_DEFINITIONS)[number][1];
7
- path: (typeof OPERATION_DEFINITIONS)[number][2];
8
- operationId: SdkOperationId;
9
- }>;
10
- export declare const SDK_OPERATIONS: readonly SdkOperation[];
1
+ import { type SdkOperation, type SdkOperationId } from "./operations.generated.js";
2
+ export { MATERIALGRAPH_API_VERSION, SDK_OPERATIONS, } from "./operations.generated.js";
3
+ export type { SdkOperation, SdkOperationId } from "./operations.generated.js";
11
4
  /** Look up a registered operation by its OpenAPI `operationId`. */
12
5
  export declare const findSdkOperation: (operationId: SdkOperationId) => SdkOperation | undefined;
13
6
  /**
@@ -15,7 +8,6 @@ export declare const findSdkOperation: (operationId: SdkOperationId) => SdkOpera
15
8
  * a literal `operationId` wants — lived as a private copy in `client.ts`
16
9
  * before the association lens would have made it a second.
17
10
  */
18
- export declare const resolveOperation: (operationId: SdkOperationId) => SdkOperation;
11
+ export declare const resolveOperation: <K extends SdkOperationId>(operationId: K) => SdkOperation<K>;
19
12
  /** Substitute `{param}` path placeholders with percent-encoded values. */
20
13
  export declare const operationPath: (sdkOperation: SdkOperation, pathParams?: Readonly<Record<string, string>>) => string;
21
- export {};
@@ -0,0 +1,11 @@
1
+ export declare const MATERIALGRAPH_API_VERSION = "0.8.0";
2
+ declare const OPERATION_DEFINITIONS: readonly [readonly ["colors.nearestPaints", "GET", "/api/v1/colors/nearest-paints", "find_nearest_paints"], readonly ["getCatalogueGeneration", "GET", "/api/v1/catalog/generation", "get_catalogue_generation"], readonly ["catalogs", "GET", "/api/v1/catalogs", "list_catalog_documents"], readonly ["catalogPages", "GET", "/api/v1/catalogs/{catalogId}/pages", "list_catalog_pages"], readonly ["catalogPageRepresentation", "GET", "/api/v1/catalog-pages/{pageId}/representation", "get_catalog_page_representation"], readonly ["catalogReferences", "GET", "/api/v1/catalogs/{catalogId}/references", "list_catalog_product_references"], readonly ["samplizeCatalogue", "GET", "/api/v1/catalogues/samplize/products", "samplize_catalogue_products"], readonly ["catalogueReferences", "POST", "/api/v1/catalogues/references", "get_catalogue_references_batch"], readonly ["catalogueCollections", "GET", "/api/v1/catalogues/collections", "list_catalogue_channel_collections"], readonly ["catalogueDocumentAccess", "GET", "/api/v1/catalogues/documents/{documentId}", "get_catalogue_document_access"], readonly ["materialBlocks", "GET", "/api/v1/materials/{variantId}/blocks", "list_material_blocks"], readonly ["listVariantAssets", "GET", "/api/v1/variants/{variantId}/assets", "list_variant_assets"], readonly ["materialDocuments", "GET", "/api/v1/materials/{variantId}/documents", "list_material_documents"], readonly ["schema", "GET", "/api/v1/schema/value-dictionaries", "list_schema_value_dictionaries"], readonly ["pairings", "GET", "/api/v1/materials/{variantId}/pairings", "get_material_pairings"], readonly ["associatedFinishes", "GET", "/api/v1/associated/finishes", "list_associated_finishes"], readonly ["associatedProducts", "GET", "/api/v1/associated/products", "list_associated_products"], readonly ["applicability", "GET", "/api/v1/applicability", "get_applicability"], readonly ["listVariants", "GET", "/api/v1/variants", "list_variants"], readonly ["listVariantFacets", "POST", "/api/v1/variants/facets", "list_variant_facets"], readonly ["searchVariants", "POST", "/api/v1/variants/search", "search_variants"], readonly ["findVariantsByColor", "GET", "/api/v1/variants/by-color", "find_variants_by_color"], readonly ["findVariantsByVector", "POST", "/api/v1/variants/by-vector", "find_variants_by_vector"], readonly ["findSampledTogether", "GET", "/api/v1/variants/sampled-together", "find_sampled_together"], readonly ["resolveVariant", "POST", "/api/v1/variants/resolve", "resolve_variant"], readonly ["getVariant", "GET", "/api/v1/variants/{variantId}", "get_variant"], readonly ["resolveColor", "GET", "/api/v1/search/colors/resolve", "resolve_color_name"], readonly ["listAttributes", "GET", "/api/v1/catalog/attributes", "catalog_list_attributes"], readonly ["listEnumValues", "GET", "/api/v1/catalog/enum-values", "catalog_list_enum_values"], readonly ["categories.list", "GET", "/api/v1/categories", "list_categories"], readonly ["categories.get", "GET", "/api/v1/categories/{id}", "get_category"], readonly ["whoami", "GET", "/api/v1/whoami", "whoami"], readonly ["colors.profiles", "GET", "/api/v1/colors/profiles", "get_category_color_profiles"], readonly ["extractPalette", "POST", "/api/v1/search/palettes/extract", "extract_image_palette"], readonly ["brands", "GET", "/api/v1/brands", "list_brands"], readonly ["uploadSourceMaterial", "POST", "/api/v1/source-material", "upload_source_material"], readonly ["workflows.start", "POST", "/api/v1/workflows/{workflowId}/runs", "create_public_run"], readonly ["workflows.run", "GET", "/api/v1/workflows/{workflowId}/runs/{runId}", "get_public_run"], readonly ["workflows.streamRunEvents", "GET", "/api/v1/workflows/{workflowId}/runs/{runId}/events", "list_public_run_events"]];
3
+ export type SdkOperationId = (typeof OPERATION_DEFINITIONS)[number][3];
4
+ export type SdkOperation<K extends SdkOperationId = SdkOperationId> = Readonly<{
5
+ clientMethod: (typeof OPERATION_DEFINITIONS)[number][0];
6
+ method: (typeof OPERATION_DEFINITIONS)[number][1];
7
+ path: (typeof OPERATION_DEFINITIONS)[number][2];
8
+ operationId: K;
9
+ }>;
10
+ export declare const SDK_OPERATIONS: readonly SdkOperation[];
11
+ export {};