@instruments/materialgraph 0.21.0 → 0.23.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.
@@ -1,7 +1,7 @@
1
1
  import { HttpTransport } from "./http-transport.js";
2
- import type { ColourFacetsResponse, ResolveAttributeOptions, ResolveAttributeResponse, ResolveAttributeValueOptions, ResolveAttributeValueResponse, ResolveColourResponse, SuggestColourResponse, SuggestOptions, SuggestResponse } from "./types.js";
2
+ import type { ColourFacetsResponse, ResolveAttributeOptions, ResolveAttributeResponse, ResolveAttributeValueOptions, ResolveAttributeValueResponse, ResolveColourOptions, ResolveColourResponse, SuggestColourResponse, SuggestOptions, SuggestResponse } from "./types.js";
3
3
  export declare function colourFacets(transport: HttpTransport, signal?: AbortSignal): Promise<ColourFacetsResponse>;
4
- export declare function resolveColour(transport: HttpTransport, name: string, signal?: AbortSignal): Promise<ResolveColourResponse>;
4
+ export declare function resolveColour(transport: HttpTransport, name: string, signal?: AbortSignal, options?: ResolveColourOptions): Promise<ResolveColourResponse>;
5
5
  export declare function suggestColour(transport: HttpTransport, q: string, options?: {
6
6
  limit?: number;
7
7
  }, signal?: AbortSignal): Promise<SuggestColourResponse>;
@@ -4,8 +4,8 @@ import { suggestQuery } from "./suggest-types.js";
4
4
  export function colourFacets(transport, signal) {
5
5
  return transport.requestJson(resolveOperation("get_colour_facets"), { signal });
6
6
  }
7
- export function resolveColour(transport, name, signal) {
8
- return transport.requestJson(resolveOperation("resolve_colour_name"), { query: { name }, signal });
7
+ export function resolveColour(transport, name, signal, options) {
8
+ return transport.requestJson(resolveOperation("resolve_colour_name"), { query: { name, corpusScope: options?.corpusScope }, signal });
9
9
  }
10
10
  export function suggestColour(transport, q, options, signal) {
11
11
  return transport.requestJson(resolveOperation("suggest_colour_names"), { query: { q, limit: options?.limit }, signal });
package/client.d.ts CHANGED
@@ -30,7 +30,7 @@ import type { SchemaResource, SchemaResourceResponse } from "./schema-resource-t
30
30
  import type { SlotPoolsRequest, SlotPoolsResponse } from "./slot-pool-types.js";
31
31
  import type { FindSubstitutesOptions, FindSubstitutesResponse } from "./substitute-types.js";
32
32
  import type { ProductTypeCoverageOptions, ProductTypeStatusCoverage } from "./taxonomy-coverage-types.js";
33
- import type { ApplicableSpecsResponse, BrandOptions, BySpecOptions, BySpecResponse, ColourFacetsResponse, CoordinateInput, CoordinateResponse, DemandBatchInput, DemandBatchResponse, DemandParams, DemandResponse, ExtractPaletteInput, ExtractPaletteResponse, GlossaryTermResponse, MaterialResponse, MaterialsBatchDetailResponse, MaterialsBatchGetOptions, MaterialsBatchOptions, MaterialsBatchTileResponse, PairingsOptions, PairingsResponse, ResolveAttributeOptions, ResolveAttributeResponse, ResolveAttributeValueOptions, ResolveAttributeValueResponse, ResolveColourResponse, SearchGetParams, SearchInput, SearchResponse, SiblingsResponse, SpecFacetsDistributionResponse, SpecFacetsListResponse, SuggestColourResponse, SuggestOptions, SuggestResponse, TaxonomyResponse, VocabularySearchOptions, WhoamiResponse } from "./types.js";
33
+ import type { ApplicableSpecsResponse, BrandOptions, BySpecOptions, BySpecResponse, ColourFacetsResponse, CoordinateInput, CoordinateResponse, DemandBatchInput, DemandBatchResponse, DemandParams, DemandResponse, ExtractPaletteInput, ExtractPaletteResponse, GlossaryTermResponse, MaterialResponse, MaterialsBatchDetailResponse, MaterialsBatchGetOptions, MaterialsBatchOptions, MaterialsBatchTileResponse, PairingsOptions, PairingsResponse, ResolveAttributeOptions, ResolveAttributeResponse, ResolveAttributeValueOptions, ResolveAttributeValueResponse, ResolveColourOptions, ResolveColourResponse, SearchGetParams, SearchInput, SearchResponse, SiblingsResponse, SpecFacetsDistributionResponse, SpecFacetsListResponse, SuggestColourResponse, SuggestOptions, SuggestResponse, TaxonomyResponse, VocabularySearchOptions, WhoamiResponse } from "./types.js";
34
34
  /**
35
35
  * The MaterialGraph client — every lens on the graph, on one object.
36
36
  *
@@ -287,8 +287,8 @@ export declare class MaterialGraphClient extends CatalogueClient {
287
287
  }, signal?: AbortSignal): Promise<MaterialsBatchTileResponse>;
288
288
  /** Vocabulary families and counts; use `colours.profiles()` for a material palette. */
289
289
  colourFacets(signal?: AbortSignal): Promise<ColourFacetsResponse>;
290
- /** Resolve a colour name to its canonical hex when recognised. */
291
- resolveColour(name: string, signal?: AbortSignal): Promise<ResolveColourResponse>;
290
+ /** Resolve a colour name to its hex, and the named paint's catalogue variant. */
291
+ resolveColour(name: string, signal?: AbortSignal, options?: ResolveColourOptions): Promise<ResolveColourResponse>;
292
292
  /** Ranked colour-name typeahead (GET `/api/v1/search/colours/suggest`). */
293
293
  suggestColour(q: string, options?: {
294
294
  limit?: number;
package/client.js CHANGED
@@ -362,9 +362,9 @@ export class MaterialGraphClient extends CatalogueClient {
362
362
  colourFacets(signal) {
363
363
  return colourFacetsCall(this.#transport, signal);
364
364
  }
365
- /** Resolve a colour name to its canonical hex when recognised. */
366
- resolveColour(name, signal) {
367
- return resolveColourCall(this.#transport, name, signal);
365
+ /** Resolve a colour name to its hex, and the named paint's catalogue variant. */
366
+ resolveColour(name, signal, options) {
367
+ return resolveColourCall(this.#transport, name, signal, options);
368
368
  }
369
369
  /** Ranked colour-name typeahead (GET `/api/v1/search/colours/suggest`). */
370
370
  suggestColour(q, options, signal) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instruments/materialgraph",
3
- "version": "0.21.0",
3
+ "version": "0.23.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Colour-name resolution (GET `/api/v1/search/colours/resolve`): the resolved
3
+ * colour, and whether the named paint is a variant in the catalogue.
4
+ */
5
+ import type { CorpusScope } from "./corpus-scope-types.js";
6
+ import type { VariantId } from "./identifiers.js";
7
+ import type { OpenEnum } from "./types.js";
8
+ /** Options for `resolveColour`. */
9
+ export interface ResolveColourOptions {
10
+ /**
11
+ * Sets `inScope` on each catalogue variant the lookup reports. It never
12
+ * narrows the lookup. Absent leaves every `inScope` null.
13
+ */
14
+ corpusScope?: CorpusScope;
15
+ }
16
+ /** One catalogue variant carrying the named paint. */
17
+ export interface ResolveColourCatalogueVariant {
18
+ variantId: VariantId;
19
+ /** The brand exactly as stored, suspect or not. */
20
+ brand: {
21
+ id: string;
22
+ slug: string;
23
+ name: string;
24
+ };
25
+ /** Whether the variant is in the requested scope; null when none was asked for. */
26
+ inScope: boolean | null;
27
+ /**
28
+ * True when the stored brand is Samplize, a sampling channel, and the listing
29
+ * is not Samplize's own: the colour is another maker's, so `brand` is not who
30
+ * made it. The variant is still the right one for the name.
31
+ */
32
+ parentageSuspect: boolean;
33
+ }
34
+ /**
35
+ * Whether the named paint is a variant in the catalogue. Exact, global, and
36
+ * never narrowed by `corpusScope`, and run only for a `brand` library hit.
37
+ * `not-in-catalogue` means the catalogue was searched and nothing carries the
38
+ * paint; `not-looked-up` means there was no one maker's paint to search for.
39
+ */
40
+ export type ResolveColourVariant = ({
41
+ status: "matched";
42
+ } & ResolveColourCatalogueVariant) | {
43
+ status: "ambiguous";
44
+ candidates: ResolveColourCatalogueVariant[];
45
+ } | {
46
+ status: "not-in-catalogue";
47
+ } | {
48
+ status: "not-looked-up";
49
+ reason: OpenEnum<"reference-colour" | "descriptive-colour" | "no-paint-identity" | "generic-colour" | "several-paints">;
50
+ };
51
+ export interface ResolveColourResponse {
52
+ match: {
53
+ hex: string;
54
+ name: string;
55
+ code?: string;
56
+ /** The ColorScope library the colour resolved in. Not necessarily a maker. */
57
+ libraryId?: string;
58
+ /**
59
+ * The library's own type: `brand` is a maker's paint, `reference` a colour
60
+ * standard (RAL, Pantone, HKS), `core` ColorScope's descriptive vocabulary.
61
+ * Present exactly when `libraryId` is. Only a `brand` hit is looked up.
62
+ */
63
+ libraryType?: OpenEnum<"brand" | "reference" | "core" | "consumer">;
64
+ /** The catalogue lookup for the name. Absent from servers that predate it. */
65
+ variant?: ResolveColourVariant;
66
+ } | null;
67
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,11 @@
1
1
  export interface SamplizeCatalogueOptions {
2
2
  limit?: number;
3
+ /** Continue with unchanged filters and sourceVersion; omit when filters change. */
3
4
  after?: string;
5
+ /** Exact canonical identities, at most 100. Unknown/ineligible IDs are omitted; no substitution. Combined filters intersect. */
6
+ variantIds?: string[];
7
+ /** Exact source collection handle; publisher remains Samplize. */
8
+ collectionHandle?: string;
4
9
  /** Pin every subsequent page to the version returned by the first page. */
5
10
  sourceVersion?: string;
6
11
  }
@@ -49,6 +54,7 @@ export interface SamplizeCataloguePage {
49
54
  corpusScope: "samplizeCatalogue";
50
55
  sourceVersion: string;
51
56
  source: Record<string, unknown>;
57
+ /** Number of eligible records matching the supplied filters. */
52
58
  total: number;
53
59
  items: SamplizeCatalogueProduct[];
54
60
  nextCursor: string | null;
@@ -37,7 +37,7 @@ export interface SearchEmptyOutcomeCounts {
37
37
  */
38
38
  export type SearchEmptyOutcome = {
39
39
  kind: "proven-corpus-empty";
40
- basis: OpenEnum<"spec-allowlist" | "brand-scope">;
40
+ basis: OpenEnum<"spec-allowlist" | "brand-scope" | "brand-product-type">;
41
41
  exhaustive: true;
42
42
  sourceEmpty?: boolean | null;
43
43
  counts?: SearchEmptyOutcomeCounts;
package/types.d.ts CHANGED
@@ -625,14 +625,6 @@ export interface MaterialsBatchDetailResponse {
625
625
  /** Requested ids that resolved to nothing. Echoed verbatim, opaque. */
626
626
  missingIds: VariantId[];
627
627
  }
628
- export interface ResolveColourResponse {
629
- match: {
630
- hex: string;
631
- name: string;
632
- code?: string;
633
- libraryId?: string;
634
- } | null;
635
- }
636
628
  export interface SuggestColourResponse {
637
629
  suggestions: Array<{
638
630
  term: string;
@@ -655,6 +647,7 @@ export interface ResolveAttributeResponse {
655
647
  }
656
648
  export type * from "./catalog-discovery-types.js";
657
649
  export type * from "./resolve-types.js";
650
+ export type * from "./resolve-colour-types.js";
658
651
  export type * from "./suggest-types.js";
659
652
  export type * from "./by-spec-types.js";
660
653
  export interface WhoamiResponse {