@instruments/materialgraph 0.19.0 → 0.21.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.
- package/attribution-types.d.ts +51 -0
- package/attribution-types.js +13 -0
- package/brand-most-sampled-types.d.ts +33 -0
- package/brand-most-sampled-types.js +1 -0
- package/by-colour-types.d.ts +9 -0
- package/catalogue-client.d.ts +70 -0
- package/catalogue-client.js +44 -0
- package/colours-client.d.ts +8 -3
- package/colours-client.js +8 -0
- package/compare-types.d.ts +89 -0
- package/compare-types.js +1 -0
- package/correction-types.d.ts +88 -0
- package/correction-types.js +1 -0
- package/exploration-types.d.ts +1 -0
- package/http-transport.d.ts +2 -0
- package/http-transport.js +6 -1
- package/identify-types.d.ts +72 -0
- package/identify-types.js +7 -0
- package/index.d.ts +7 -0
- package/match-stream-types.d.ts +13 -0
- package/match-types.d.ts +10 -0
- package/material-block-types.d.ts +4 -0
- package/operations.d.ts +1 -1
- package/operations.js +42 -2
- package/package.json +12 -1
- package/palette-completion-types.d.ts +115 -0
- package/palette-completion-types.js +1 -0
- package/samplize-colorvec.d.ts +70 -0
- package/samplize-colorvec.js +167 -0
- package/search-card-types.d.ts +55 -0
- package/search-card-types.js +1 -0
- package/search-response-types.d.ts +11 -0
- package/search-response-types.js +1 -0
- package/substitute-types.d.ts +28 -1
- package/types.d.ts +32 -44
- package/webmcp.d.ts +17 -0
- package/webmcp.generated.d.ts +2 -0
- package/webmcp.generated.js +90 -0
- package/webmcp.js +1 -0
package/match-types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ResponseAttribution } from "./attribution-types.js";
|
|
1
2
|
import type { CorpusScope } from "./corpus-scope-types.js";
|
|
2
3
|
/**
|
|
3
4
|
* @module sdk/match-types
|
|
@@ -37,6 +38,15 @@ export interface MatchColourReading {
|
|
|
37
38
|
measurable: boolean;
|
|
38
39
|
}
|
|
39
40
|
export interface MatchResponse {
|
|
41
|
+
/**
|
|
42
|
+
* Result attribution (MG-1131). `basis` is always `"match"` here — this route
|
|
43
|
+
* has no `mode`, so this is the field that lets a Match outcome be grouped
|
|
44
|
+
* alongside a `search()` one. Store it beside the query and each item's
|
|
45
|
+
* `resultId` beside the outcome.
|
|
46
|
+
*
|
|
47
|
+
* ABSENT only from a response produced by a server predating MG-1131.
|
|
48
|
+
*/
|
|
49
|
+
attribution?: ResponseAttribution;
|
|
40
50
|
/** THIS answer, capped by `limit`. Not a total. */
|
|
41
51
|
results: SearchResultItem[];
|
|
42
52
|
inferredCategories: MatchCategoryInference[];
|
|
@@ -52,6 +52,10 @@ export interface MaterialBlockProjectionField {
|
|
|
52
52
|
value: MaterialBlockFieldValue;
|
|
53
53
|
unit?: string;
|
|
54
54
|
status: MaterialBlockFieldStatus;
|
|
55
|
+
/** Provenance supplied by the graph when a source-backed claim supports this field. */
|
|
56
|
+
sourceBasis?: string;
|
|
57
|
+
/** Claim confidence supplied by the graph; absence means no confidence was emitted. */
|
|
58
|
+
confidence?: number;
|
|
55
59
|
}
|
|
56
60
|
export interface MaterialBlockProjectionItem {
|
|
57
61
|
canonicalBlockId: string;
|
package/operations.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const MATERIALGRAPH_API_VERSION = "0.7.0";
|
|
2
|
-
declare const OPERATION_DEFINITIONS: readonly [readonly ["scheduleReferences.list", "GET", "/api/v1/schedules/{scheduleId}/references", "list_schedule_reference_feedback"], readonly ["scheduleReferences.put", "PUT", "/api/v1/schedules/{scheduleId}/references/{referenceId}", "put_schedule_reference_feedback"], 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 ["search", "POST", "/api/v1/search", "search_materials_post"], readonly ["planQuery", "POST", "/api/v1/search/plan", "plan_material_query"], readonly ["samplizeCatalogue", "GET", "/api/v1/catalogues/samplize/products", "samplize_catalogue_products"], readonly ["searchGet", "GET", "/api/v1/search", "search_materials_get"], readonly ["match", "POST", "/api/v1/search/match", "match_material"], readonly ["byColour", "GET", "/api/v1/search/colours", "search_by_colour"], readonly ["material", "GET", "/api/v1/materials/{variantId}", "get_material"], 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 ["siblings", "GET", "/api/v1/materials/{variantId}/siblings", "get_material_siblings"], readonly ["materialBlocks", "GET", "/api/v1/materials/{variantId}/blocks", "list_material_blocks"], readonly ["materialAssets", "GET", "/api/v1/materials/{variantId}/assets", "list_material_assets"], readonly ["materialRenderAssets", "GET", "/api/v1/materials/{variantId}/render-assets", "get_material_render_assets"], readonly ["materialDocuments", "GET", "/api/v1/materials/{variantId}/documents", "list_material_documents"], readonly ["exploration.operators", "GET", "/api/v1/materials/{variantId}/operators", "list_material_operators"], readonly ["exploration.candidates", "POST", "/api/v1/materials/{variantId}/candidates", "read_material_candidates"], readonly ["schema", "GET", "/api/v1/schema/blocks", "list_schema_blocks"], readonly ["schema", "GET", "/api/v1/schema/attributes", "list_schema_attributes"], readonly ["schema", "GET", "/api/v1/schema/verticals", "list_schema_verticals"], readonly ["schema", "GET", "/api/v1/schema/product-types", "list_schema_product_types"], readonly ["schema", "GET", "/api/v1/schema/units", "list_schema_units"], readonly ["schema", "GET", "/api/v1/schema/value-dictionaries", "list_schema_value_dictionaries"], readonly ["schema", "GET", "/api/v1/schema/source-requirements", "list_schema_source_requirements"], readonly ["schema", "GET", "/api/v1/schema/product-type-templates", "list_schema_product_type_templates"], readonly ["schema", "GET", "/api/v1/schema/mappings", "list_schema_mappings"], readonly ["pairings", "GET", "/api/v1/materials/{variantId}/pairings", "get_material_pairings"], readonly ["findSubstitutes", "POST", "/api/v1/materials/{variantId}/substitutes", "find_material_substitutes"], 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 ["materials", "POST", "/api/v1/materials/batch", "get_materials_batch_post"], readonly ["materialsCached", "GET", "/api/v1/materials/batch", "get_materials_batch_get"], readonly ["browse", "GET", "/api/v1/search/browse", "search_browse_by_colour"], readonly ["colourFacets", "GET", "/api/v1/colours/facets", "get_colour_facets"], readonly ["colours.profiles", "GET", "/api/v1/colours/profiles", "get_category_colour_profiles"], readonly ["colours.stats", "GET", "/api/v1/colours/stats", "get_colour_stats"], readonly ["resolveColour", "GET", "/api/v1/search/colours/resolve", "resolve_colour_name"], readonly ["suggestColour", "GET", "/api/v1/search/colours/suggest", "suggest_colour_names"], readonly ["suggest", "GET", "/api/v1/search/suggest", "search_suggest"], readonly ["resolveAttribute", "GET", "/api/v1/catalog/attributes/resolve", "catalog_resolve_attribute"], readonly ["resolveAttributeValue", "GET", "/api/v1/catalog/attributes/{attributeId}/values/resolve", "catalog_resolve_value"], readonly ["searchVocabulary", "GET", "/api/v1/catalog/vocabulary/search", "catalog_vocabulary_search"], readonly ["resolve", "POST", "/api/v1/resolve", "resolve_phrases"], readonly ["bySpec", "GET", "/api/v1/search/specifications", "catalog_by_spec"], readonly ["taxonomy", "GET", "/api/v1/taxonomy/categories", "get_category_taxonomy"], readonly ["productTypeCoverage", "GET", "/api/v1/taxonomy/coverage", "get_product_type_status_coverage"], readonly ["whoami", "GET", "/api/v1/whoami", "whoami"], readonly ["coordinate", "POST", "/api/v1/pairings/coordinate", "coordinate_materials"], readonly ["demand", "GET", "/api/v1/demand", "get_material_demand"], readonly ["colours.palette", "POST", "/api/v1/search/palettes", "search_by_palette"], readonly ["extractPalette", "POST", "/api/v1/search/palettes/extract", "extract_image_palette"], readonly ["colours.gradient", "POST", "/api/v1/search/gradients", "search_by_gradient"], readonly ["specificationFacets", "GET", "/api/v1/catalog/specifications/facets", "list_spec_facets"], readonly ["attributeValues", "GET", "/api/v1/catalog/attributes/{attributeId}/values", "list_attribute_values"], readonly ["applicableSpecs", "GET", "/api/v1/taxonomy/categories/{key}/specs", "get_applicable_specs"], readonly ["glossary", "GET", "/api/v1/glossary/{term}", "explain_material_term"], readonly ["brands", "GET", "/api/v1/brands", "list_brands"], readonly ["brand", "GET", "/api/v1/brands/{brandSlug}", "get_brand_profile"], readonly ["brandColourDeck", "GET", "/api/v1/brands/{brandSlug}/colours", "brand_colour_deck"], readonly ["uploadSourceMaterial", "POST", "/api/v1/source-material", "upload_source_material"], readonly ["sourceMaterialBatch", "GET", "/api/v1/source-material/{batchId}", "get_source_material_batch"], readonly ["sourceMaterialComments", "GET", "/api/v1/source-material/{batchId}/sources/{sourceId}/comments", "list_source_material_comments"], readonly ["sourceMaterialComments", "POST", "/api/v1/source-material/{batchId}/sources/{sourceId}/comments", "post_source_material_comment"], readonly ["capabilities", "GET", "/api/v1/capabilities", "list_public_capabilities"], readonly ["createRun", "POST", "/api/v1/runs", "create_public_run"], readonly ["listRuns", "GET", "/api/v1/runs", "list_public_runs"], readonly ["run", "GET", "/api/v1/runs/{runId}", "get_public_run"], readonly ["runSchedule", "GET", "/api/v1/runs/{runId}/schedule", "get_run_finish_schedule"], readonly ["citation", "GET", "/api/v1/citations/{citationId}", "get_verdict_citation"], readonly ["streamRunEvents", "GET", "/api/v1/runs/{runId}/events", "list_public_run_events"], readonly ["resumeRun", "POST", "/api/v1/runs/{runId}/resume", "resume_public_run"], readonly ["cancelRun", "POST", "/api/v1/runs/{runId}/cancel", "cancel_public_run"], readonly ["varyScheme", "POST", "/api/v1/schemes/vary", "vary_schemes"], readonly ["slotPools", "POST", "/api/v1/schemes/pools", "slot_pools"], readonly ["createProject", "POST", "/api/v1/projects", "create_box_project"], readonly ["listProjects", "GET", "/api/v1/projects", "list_box_projects"], readonly ["getProject", "GET", "/api/v1/projects/{projectId}", "get_box_project"], readonly ["appendProjectEvent", "POST", "/api/v1/projects/{projectId}/events", "append_box_project_event"], readonly ["demandBatch", "POST", "/api/v1/demand/batch", "get_demand_batch"], readonly ["codeAdvisory", "POST", "/api/v1/codes/advisory", "resolveCodeAdvisory"], readonly ["codes.context", "GET", "/api/v1/codes/context", "list_code_context"], readonly ["codes.requirements", "GET", "/api/v1/codes/requirements", "list_code_requirements"]];
|
|
2
|
+
declare const OPERATION_DEFINITIONS: readonly [readonly ["brandMostSampled", "GET", "/api/v1/brands/most-sampled", "brands.most_sampled"], readonly ["colours.complete", "POST", "/api/v1/colours/palettes/complete", "complete_interior_palette"], readonly ["colours.discover", "GET", "/api/v1/colours/palettes", "discover_interior_palettes"], readonly ["samplizeColorVecCache", "GET", "/api/v1/catalogues/samplize/colorvec", "samplize_colorvec_cache"], readonly ["samplizeCatalogueSearch", "POST", "/api/v1/catalogues/samplize/search", "samplize_catalogue_search"], readonly ["scheduleReferences.list", "GET", "/api/v1/schedules/{scheduleId}/references", "list_schedule_reference_feedback"], readonly ["scheduleReferences.put", "PUT", "/api/v1/schedules/{scheduleId}/references/{referenceId}", "put_schedule_reference_feedback"], 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 ["search", "POST", "/api/v1/search", "search_materials_post"], readonly ["identify", "POST", "/api/v1/identify", "retrieval.identify"], readonly ["compare", "POST", "/api/v1/compare", "retrieval.compare"], readonly ["createCorrection", "POST", "/api/v1/corrections", "corrections.create"], readonly ["getCorrection", "GET", "/api/v1/corrections/{correctionId}", "corrections.get"], readonly ["listCorrections", "GET", "/api/v1/corrections", "corrections.list"], readonly ["planQuery", "POST", "/api/v1/search/plan", "plan_material_query"], readonly ["samplizeCatalogue", "GET", "/api/v1/catalogues/samplize/products", "samplize_catalogue_products"], readonly ["searchGet", "GET", "/api/v1/search", "search_materials_get"], readonly ["match", "POST", "/api/v1/search/match", "match_material"], readonly ["byColour", "GET", "/api/v1/search/colours", "search_by_colour"], readonly ["material", "GET", "/api/v1/materials/{variantId}", "get_material"], 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 ["siblings", "GET", "/api/v1/materials/{variantId}/siblings", "get_material_siblings"], readonly ["materialBlocks", "GET", "/api/v1/materials/{variantId}/blocks", "list_material_blocks"], readonly ["materialAssets", "GET", "/api/v1/materials/{variantId}/assets", "list_material_assets"], readonly ["materialRenderAssets", "GET", "/api/v1/materials/{variantId}/render-assets", "get_material_render_assets"], readonly ["materialDocuments", "GET", "/api/v1/materials/{variantId}/documents", "list_material_documents"], readonly ["exploration.operators", "GET", "/api/v1/materials/{variantId}/operators", "list_material_operators"], readonly ["exploration.candidates", "POST", "/api/v1/materials/{variantId}/candidates", "read_material_candidates"], readonly ["schema", "GET", "/api/v1/schema/blocks", "list_schema_blocks"], readonly ["schema", "GET", "/api/v1/schema/attributes", "list_schema_attributes"], readonly ["schema", "GET", "/api/v1/schema/verticals", "list_schema_verticals"], readonly ["schema", "GET", "/api/v1/schema/product-types", "list_schema_product_types"], readonly ["schema", "GET", "/api/v1/schema/units", "list_schema_units"], readonly ["schema", "GET", "/api/v1/schema/value-dictionaries", "list_schema_value_dictionaries"], readonly ["schema", "GET", "/api/v1/schema/source-requirements", "list_schema_source_requirements"], readonly ["schema", "GET", "/api/v1/schema/product-type-templates", "list_schema_product_type_templates"], readonly ["schema", "GET", "/api/v1/schema/mappings", "list_schema_mappings"], readonly ["pairings", "GET", "/api/v1/materials/{variantId}/pairings", "get_material_pairings"], readonly ["findSubstitutes", "POST", "/api/v1/materials/{variantId}/substitutes", "find_material_substitutes"], 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 ["materials", "POST", "/api/v1/materials/batch", "get_materials_batch_post"], readonly ["materialsCached", "GET", "/api/v1/materials/batch", "get_materials_batch_get"], readonly ["browse", "GET", "/api/v1/search/browse", "search_browse_by_colour"], readonly ["colourFacets", "GET", "/api/v1/colours/facets", "get_colour_facets"], readonly ["colours.profiles", "GET", "/api/v1/colours/profiles", "get_category_colour_profiles"], readonly ["colours.stats", "GET", "/api/v1/colours/stats", "get_colour_stats"], readonly ["resolveColour", "GET", "/api/v1/search/colours/resolve", "resolve_colour_name"], readonly ["suggestColour", "GET", "/api/v1/search/colours/suggest", "suggest_colour_names"], readonly ["suggest", "GET", "/api/v1/search/suggest", "search_suggest"], readonly ["resolveAttribute", "GET", "/api/v1/catalog/attributes/resolve", "catalog_resolve_attribute"], readonly ["resolveAttributeValue", "GET", "/api/v1/catalog/attributes/{attributeId}/values/resolve", "catalog_resolve_value"], readonly ["searchVocabulary", "GET", "/api/v1/catalog/vocabulary/search", "catalog_vocabulary_search"], readonly ["resolve", "POST", "/api/v1/resolve", "resolve_phrases"], readonly ["bySpec", "GET", "/api/v1/search/specifications", "catalog_by_spec"], readonly ["taxonomy", "GET", "/api/v1/taxonomy/categories", "get_category_taxonomy"], readonly ["productTypeCoverage", "GET", "/api/v1/taxonomy/coverage", "get_product_type_status_coverage"], readonly ["whoami", "GET", "/api/v1/whoami", "whoami"], readonly ["coordinate", "POST", "/api/v1/pairings/coordinate", "coordinate_materials"], readonly ["demand", "GET", "/api/v1/demand", "get_material_demand"], readonly ["colours.palette", "POST", "/api/v1/search/palettes", "search_by_palette"], readonly ["extractPalette", "POST", "/api/v1/search/palettes/extract", "extract_image_palette"], readonly ["colours.gradient", "POST", "/api/v1/search/gradients", "search_by_gradient"], readonly ["specificationFacets", "GET", "/api/v1/catalog/specifications/facets", "list_spec_facets"], readonly ["attributeValues", "GET", "/api/v1/catalog/attributes/{attributeId}/values", "list_attribute_values"], readonly ["applicableSpecs", "GET", "/api/v1/taxonomy/categories/{key}/specs", "get_applicable_specs"], readonly ["glossary", "GET", "/api/v1/glossary/{term}", "explain_material_term"], readonly ["brands", "GET", "/api/v1/brands", "list_brands"], readonly ["brand", "GET", "/api/v1/brands/{brandSlug}", "get_brand_profile"], readonly ["brandColourDeck", "GET", "/api/v1/brands/{brandSlug}/colours", "brand_colour_deck"], readonly ["uploadSourceMaterial", "POST", "/api/v1/source-material", "upload_source_material"], readonly ["sourceMaterialBatch", "GET", "/api/v1/source-material/{batchId}", "get_source_material_batch"], readonly ["sourceMaterialComments.list", "GET", "/api/v1/source-material/{batchId}/sources/{sourceId}/comments", "list_source_material_comments"], readonly ["sourceMaterialComments.post", "POST", "/api/v1/source-material/{batchId}/sources/{sourceId}/comments", "post_source_material_comment"], readonly ["capabilities", "GET", "/api/v1/capabilities", "list_public_capabilities"], readonly ["createRun", "POST", "/api/v1/runs", "create_public_run"], readonly ["listRuns", "GET", "/api/v1/runs", "list_public_runs"], readonly ["run", "GET", "/api/v1/runs/{runId}", "get_public_run"], readonly ["runSchedule", "GET", "/api/v1/runs/{runId}/schedule", "get_run_finish_schedule"], readonly ["citation", "GET", "/api/v1/citations/{citationId}", "get_verdict_citation"], readonly ["streamRunEvents", "GET", "/api/v1/runs/{runId}/events", "list_public_run_events"], readonly ["resumeRun", "POST", "/api/v1/runs/{runId}/resume", "resume_public_run"], readonly ["cancelRun", "POST", "/api/v1/runs/{runId}/cancel", "cancel_public_run"], readonly ["varyScheme", "POST", "/api/v1/schemes/vary", "vary_schemes"], readonly ["slotPools", "POST", "/api/v1/schemes/pools", "slot_pools"], readonly ["createProject", "POST", "/api/v1/projects", "create_box_project"], readonly ["listProjects", "GET", "/api/v1/projects", "list_box_projects"], readonly ["getProject", "GET", "/api/v1/projects/{projectId}", "get_box_project"], readonly ["appendProjectEvent", "POST", "/api/v1/projects/{projectId}/events", "append_box_project_event"], readonly ["demandBatch", "POST", "/api/v1/demand/batch", "get_demand_batch"], readonly ["codeAdvisory", "POST", "/api/v1/codes/advisory", "resolveCodeAdvisory"], readonly ["codes.context", "GET", "/api/v1/codes/context", "list_code_context"], readonly ["codes.requirements", "GET", "/api/v1/codes/requirements", "list_code_requirements"]];
|
|
3
3
|
export type SdkOperationId = (typeof OPERATION_DEFINITIONS)[number][3];
|
|
4
4
|
export type SdkOperation = Readonly<{
|
|
5
5
|
clientMethod: (typeof OPERATION_DEFINITIONS)[number][0];
|
package/operations.js
CHANGED
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
import { MaterialGraphError } from "./errors.js";
|
|
2
2
|
export const MATERIALGRAPH_API_VERSION = "0.7.0";
|
|
3
3
|
const OPERATION_DEFINITIONS = [
|
|
4
|
+
[
|
|
5
|
+
"brandMostSampled",
|
|
6
|
+
"GET",
|
|
7
|
+
"/api/v1/brands/most-sampled",
|
|
8
|
+
"brands.most_sampled",
|
|
9
|
+
],
|
|
10
|
+
[
|
|
11
|
+
"colours.complete",
|
|
12
|
+
"POST",
|
|
13
|
+
"/api/v1/colours/palettes/complete",
|
|
14
|
+
"complete_interior_palette",
|
|
15
|
+
],
|
|
16
|
+
[
|
|
17
|
+
"colours.discover",
|
|
18
|
+
"GET",
|
|
19
|
+
"/api/v1/colours/palettes",
|
|
20
|
+
"discover_interior_palettes",
|
|
21
|
+
],
|
|
22
|
+
[
|
|
23
|
+
"samplizeColorVecCache",
|
|
24
|
+
"GET",
|
|
25
|
+
"/api/v1/catalogues/samplize/colorvec",
|
|
26
|
+
"samplize_colorvec_cache",
|
|
27
|
+
],
|
|
28
|
+
[
|
|
29
|
+
"samplizeCatalogueSearch",
|
|
30
|
+
"POST",
|
|
31
|
+
"/api/v1/catalogues/samplize/search",
|
|
32
|
+
"samplize_catalogue_search",
|
|
33
|
+
],
|
|
4
34
|
[
|
|
5
35
|
"scheduleReferences.list",
|
|
6
36
|
"GET",
|
|
@@ -33,6 +63,16 @@ const OPERATION_DEFINITIONS = [
|
|
|
33
63
|
"list_catalog_product_references",
|
|
34
64
|
],
|
|
35
65
|
["search", "POST", "/api/v1/search", "search_materials_post"],
|
|
66
|
+
["identify", "POST", "/api/v1/identify", "retrieval.identify"],
|
|
67
|
+
["compare", "POST", "/api/v1/compare", "retrieval.compare"],
|
|
68
|
+
["createCorrection", "POST", "/api/v1/corrections", "corrections.create"],
|
|
69
|
+
[
|
|
70
|
+
"getCorrection",
|
|
71
|
+
"GET",
|
|
72
|
+
"/api/v1/corrections/{correctionId}",
|
|
73
|
+
"corrections.get",
|
|
74
|
+
],
|
|
75
|
+
["listCorrections", "GET", "/api/v1/corrections", "corrections.list"],
|
|
36
76
|
["planQuery", "POST", "/api/v1/search/plan", "plan_material_query"],
|
|
37
77
|
[
|
|
38
78
|
"samplizeCatalogue",
|
|
@@ -270,13 +310,13 @@ const OPERATION_DEFINITIONS = [
|
|
|
270
310
|
"get_source_material_batch",
|
|
271
311
|
],
|
|
272
312
|
[
|
|
273
|
-
"sourceMaterialComments",
|
|
313
|
+
"sourceMaterialComments.list",
|
|
274
314
|
"GET",
|
|
275
315
|
"/api/v1/source-material/{batchId}/sources/{sourceId}/comments",
|
|
276
316
|
"list_source_material_comments",
|
|
277
317
|
],
|
|
278
318
|
[
|
|
279
|
-
"sourceMaterialComments",
|
|
319
|
+
"sourceMaterialComments.post",
|
|
280
320
|
"POST",
|
|
281
321
|
"/api/v1/source-material/{batchId}/sources/{sourceId}/comments",
|
|
282
322
|
"post_source_material_comment",
|
package/package.json
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instruments/materialgraph",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
7
|
"types": "./index.d.ts",
|
|
8
8
|
"import": "./index.js"
|
|
9
|
+
},
|
|
10
|
+
"./webmcp": {
|
|
11
|
+
"types": "./webmcp.d.ts",
|
|
12
|
+
"import": "./webmcp.js"
|
|
13
|
+
},
|
|
14
|
+
"./samplize-colorvec": {
|
|
15
|
+
"types": "./samplize-colorvec.d.ts",
|
|
16
|
+
"import": "./samplize-colorvec.js"
|
|
9
17
|
}
|
|
10
18
|
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@instruments/colorscope": "7.6.0"
|
|
21
|
+
},
|
|
11
22
|
"license": "Proprietary",
|
|
12
23
|
"engines": {
|
|
13
24
|
"node": ">=24.0.0"
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/** Public wire types; the SDK does not load the producer corpus. */
|
|
2
|
+
export type CompositionalRole = "Foundation" | "Supporting" | "Accent";
|
|
3
|
+
export interface RetainedColor {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly hex: string;
|
|
6
|
+
readonly role?: CompositionalRole;
|
|
7
|
+
readonly paintVariantId?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface CompletionRequest {
|
|
10
|
+
readonly inputs: readonly RetainedColor[];
|
|
11
|
+
readonly maxDistance?: number;
|
|
12
|
+
readonly limit?: number;
|
|
13
|
+
readonly white?: "published" | "perceptual";
|
|
14
|
+
readonly memberCount?: number;
|
|
15
|
+
readonly excludeHexes?: readonly string[];
|
|
16
|
+
}
|
|
17
|
+
export interface CompletionAssignment {
|
|
18
|
+
readonly input: RetainedColor;
|
|
19
|
+
readonly referenceIndex: number;
|
|
20
|
+
readonly referenceHex: string;
|
|
21
|
+
readonly distance: number;
|
|
22
|
+
}
|
|
23
|
+
export interface CompletionMember {
|
|
24
|
+
readonly hex: string;
|
|
25
|
+
readonly referenceHex: string;
|
|
26
|
+
readonly referenceIndex: number;
|
|
27
|
+
readonly inputIds: readonly string[];
|
|
28
|
+
readonly role: CompositionalRole;
|
|
29
|
+
readonly proportion: number;
|
|
30
|
+
readonly sourceRole: string | null;
|
|
31
|
+
readonly sourceRelation: string | null;
|
|
32
|
+
}
|
|
33
|
+
export interface PaletteCompletion {
|
|
34
|
+
readonly uses?: readonly {
|
|
35
|
+
readonly inputId: string;
|
|
36
|
+
readonly role: CompositionalRole;
|
|
37
|
+
readonly proportions: readonly number[];
|
|
38
|
+
}[];
|
|
39
|
+
readonly id: string;
|
|
40
|
+
readonly reference: {
|
|
41
|
+
readonly anchorIndex?: number | null;
|
|
42
|
+
readonly libraryId: string;
|
|
43
|
+
readonly paletteId: string;
|
|
44
|
+
readonly name: string | null;
|
|
45
|
+
readonly maker: string | null;
|
|
46
|
+
readonly intent: "joint" | "alternatives";
|
|
47
|
+
readonly provenance: "authored" | "derived" | "generated";
|
|
48
|
+
};
|
|
49
|
+
readonly assignments: readonly CompletionAssignment[];
|
|
50
|
+
readonly members: readonly CompletionMember[];
|
|
51
|
+
readonly evidenceBasis: "published-composition" | "published-pair" | "nearby-adaptation";
|
|
52
|
+
readonly proportionBasis: "sourced" | "proposed";
|
|
53
|
+
readonly worstDistance: number;
|
|
54
|
+
readonly totalDistance: number;
|
|
55
|
+
}
|
|
56
|
+
export type PaletteCompleteInput = CompletionRequest & {
|
|
57
|
+
sourceVersion: string;
|
|
58
|
+
};
|
|
59
|
+
export interface PaletteDiscoverInput {
|
|
60
|
+
sourceVersion: string;
|
|
61
|
+
character?: "warm" | "cool" | "very-light" | "light" | "dark" | "muted" | "soft" | "vivid";
|
|
62
|
+
moreLike?: string;
|
|
63
|
+
cursor?: string;
|
|
64
|
+
limit?: number;
|
|
65
|
+
}
|
|
66
|
+
export interface MaterializedPalette {
|
|
67
|
+
completion: PaletteCompletion;
|
|
68
|
+
samples: Array<{
|
|
69
|
+
retainedPaint?: {
|
|
70
|
+
variantId: string;
|
|
71
|
+
name: string;
|
|
72
|
+
maker: string;
|
|
73
|
+
};
|
|
74
|
+
referenceIndex: number;
|
|
75
|
+
inputIds: readonly string[];
|
|
76
|
+
hex: string;
|
|
77
|
+
product: {
|
|
78
|
+
variantId: string;
|
|
79
|
+
productId: string;
|
|
80
|
+
hex: string;
|
|
81
|
+
name: string;
|
|
82
|
+
brand: {
|
|
83
|
+
slug: string;
|
|
84
|
+
name: string;
|
|
85
|
+
};
|
|
86
|
+
} | null;
|
|
87
|
+
status: string;
|
|
88
|
+
distance: number | null;
|
|
89
|
+
units: "oklab-euclidean";
|
|
90
|
+
}>;
|
|
91
|
+
}
|
|
92
|
+
interface PaletteVersions {
|
|
93
|
+
sourceVersion: string;
|
|
94
|
+
corpusVersion: string;
|
|
95
|
+
algorithmVersion: string;
|
|
96
|
+
transport: "colorscope-package";
|
|
97
|
+
}
|
|
98
|
+
export interface PaletteCompleteResponse extends PaletteVersions {
|
|
99
|
+
results: MaterializedPalette[];
|
|
100
|
+
coverage: {
|
|
101
|
+
status: string;
|
|
102
|
+
supported: number;
|
|
103
|
+
};
|
|
104
|
+
tolerance: {
|
|
105
|
+
bound: number;
|
|
106
|
+
units: string;
|
|
107
|
+
policy: string;
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
export interface PaletteDiscoverResponse extends PaletteVersions {
|
|
111
|
+
results: MaterializedPalette[];
|
|
112
|
+
total: number;
|
|
113
|
+
nextCursor: string | null;
|
|
114
|
+
}
|
|
115
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export declare const SAMPLIZE_COLORVEC_RANKING_VERSION = "solid-colorvec-cosine-v2";
|
|
2
|
+
export declare const SAMPLIZE_COLORVEC_EMBEDDING_VERSION = "oklch-anchor-quantiles-v12";
|
|
3
|
+
export interface SamplizeColorVecPaint {
|
|
4
|
+
variantId: string;
|
|
5
|
+
hex: string;
|
|
6
|
+
brand: string;
|
|
7
|
+
oklab: {
|
|
8
|
+
L: number;
|
|
9
|
+
a: number;
|
|
10
|
+
b: number;
|
|
11
|
+
};
|
|
12
|
+
family: string;
|
|
13
|
+
lightness: string;
|
|
14
|
+
intensity: string;
|
|
15
|
+
vector: number[] | string;
|
|
16
|
+
}
|
|
17
|
+
export interface SamplizeColorVecCache {
|
|
18
|
+
sourceVersion: string;
|
|
19
|
+
dictionaryVersion: string;
|
|
20
|
+
embeddingVersion: string;
|
|
21
|
+
rankingVersion: string;
|
|
22
|
+
generatedAt: string;
|
|
23
|
+
paints: SamplizeColorVecPaint[];
|
|
24
|
+
}
|
|
25
|
+
export interface SamplizeColorVecInput {
|
|
26
|
+
hex?: string;
|
|
27
|
+
reference?: string;
|
|
28
|
+
palette?: Array<{
|
|
29
|
+
hex: string;
|
|
30
|
+
proportion: number;
|
|
31
|
+
}>;
|
|
32
|
+
direction?: "similar" | "lighter" | "darker" | "muted";
|
|
33
|
+
brand?: string[];
|
|
34
|
+
family?: string[];
|
|
35
|
+
lightness?: string[];
|
|
36
|
+
intensity?: string[];
|
|
37
|
+
lightnessMin?: number;
|
|
38
|
+
lightnessMax?: number;
|
|
39
|
+
temperatureMin?: number;
|
|
40
|
+
temperatureMax?: number;
|
|
41
|
+
limit?: number;
|
|
42
|
+
}
|
|
43
|
+
export declare const samplizeSolidColorVector: (hex: string) => number[];
|
|
44
|
+
/** Canonical constraints are shared by full-cache similarity and constrained text retrieval. */
|
|
45
|
+
export declare function selectSamplizeEligiblePaints<T extends Omit<SamplizeColorVecPaint, "vector">>(paints: T[], input: SamplizeColorVecInput): {
|
|
46
|
+
reference: T | undefined;
|
|
47
|
+
eligible: T[];
|
|
48
|
+
counts: Record<"brand" | "family" | "intensity" | "lightness", Record<string, number>>;
|
|
49
|
+
};
|
|
50
|
+
/** Official portable MG ranking over its complete versioned sampling-channel projection. */
|
|
51
|
+
export declare function createSamplizeColorVecIndex(cache: SamplizeColorVecCache): {
|
|
52
|
+
search(input: SamplizeColorVecInput): {
|
|
53
|
+
ids: string[];
|
|
54
|
+
groups: {
|
|
55
|
+
hex: string;
|
|
56
|
+
proportion: number;
|
|
57
|
+
quota: number;
|
|
58
|
+
ids: string[];
|
|
59
|
+
shortfall: number;
|
|
60
|
+
}[];
|
|
61
|
+
limited: boolean;
|
|
62
|
+
eligibleCount: number;
|
|
63
|
+
counts: Record<"brand" | "family" | "intensity" | "lightness", Record<string, number>>;
|
|
64
|
+
sourceVersion: string;
|
|
65
|
+
dictionaryVersion: string;
|
|
66
|
+
embeddingVersion: string;
|
|
67
|
+
rankingVersion: string;
|
|
68
|
+
countBasis: "complete-catalogue";
|
|
69
|
+
};
|
|
70
|
+
};
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { EMBEDDING_VERSION, EMBEDDING_VECTOR_SIZE, embeddingCosineSimilarity, paletteToEmbedding, } from "@instruments/colorscope/embedding";
|
|
2
|
+
export const SAMPLIZE_COLORVEC_RANKING_VERSION = "solid-colorvec-cosine-v2";
|
|
3
|
+
export const SAMPLIZE_COLORVEC_EMBEDDING_VERSION = EMBEDDING_VERSION;
|
|
4
|
+
const decodeVector = (encoded) => {
|
|
5
|
+
const bytes = Uint8Array.from(atob(encoded), (c) => c.charCodeAt(0));
|
|
6
|
+
if (bytes.length !== EMBEDDING_VECTOR_SIZE * 4)
|
|
7
|
+
throw new Error("Invalid colour vector size.");
|
|
8
|
+
const view = new DataView(bytes.buffer);
|
|
9
|
+
return Array.from({ length: EMBEDDING_VECTOR_SIZE }, (_, i) => view.getFloat32(i * 4, true));
|
|
10
|
+
};
|
|
11
|
+
const facets = ["brand", "family", "lightness", "intensity"];
|
|
12
|
+
const identityOrder = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
|
|
13
|
+
export const samplizeSolidColorVector = (hex) => {
|
|
14
|
+
if (!/^#[0-9a-f]{6}$/i.test(hex))
|
|
15
|
+
throw new Error("A six-digit published colour is required.");
|
|
16
|
+
return paletteToEmbedding([{ hex, proportion: 1 }], { validateOklab: true });
|
|
17
|
+
};
|
|
18
|
+
/** Canonical constraints are shared by full-cache similarity and constrained text retrieval. */
|
|
19
|
+
export function selectSamplizeEligiblePaints(paints, input) {
|
|
20
|
+
const reference = input.reference
|
|
21
|
+
? paints.find((p) => p.variantId === input.reference)
|
|
22
|
+
: undefined;
|
|
23
|
+
if (input.reference && !reference)
|
|
24
|
+
throw new Error("The reference is absent from this catalogue version.");
|
|
25
|
+
const low = input.lightnessMin ?? 0, high = input.lightnessMax ?? 1;
|
|
26
|
+
const cool = input.temperatureMin ?? -0.4, warm = input.temperatureMax ?? 0.4;
|
|
27
|
+
if (![low, high, cool, warm].every(Number.isFinite) ||
|
|
28
|
+
low > high ||
|
|
29
|
+
cool > warm)
|
|
30
|
+
throw new Error("Appearance ranges must be finite and ordered.");
|
|
31
|
+
const candidates = paints.filter((p) => {
|
|
32
|
+
if (!reference)
|
|
33
|
+
return true;
|
|
34
|
+
if (p.variantId === reference.variantId)
|
|
35
|
+
return false;
|
|
36
|
+
if (input.direction === "lighter")
|
|
37
|
+
return p.oklab.L > reference.oklab.L;
|
|
38
|
+
if (input.direction === "darker")
|
|
39
|
+
return p.oklab.L < reference.oklab.L;
|
|
40
|
+
if (input.direction === "muted")
|
|
41
|
+
return (Math.hypot(p.oklab.a, p.oklab.b) <
|
|
42
|
+
Math.hypot(reference.oklab.a, reference.oklab.b));
|
|
43
|
+
return true;
|
|
44
|
+
});
|
|
45
|
+
const matches = (p, omit) => p.oklab.L >= low &&
|
|
46
|
+
p.oklab.L <= high &&
|
|
47
|
+
p.oklab.b >= cool &&
|
|
48
|
+
p.oklab.b <= warm &&
|
|
49
|
+
facets.every((f) => f === omit || !input[f]?.length || input[f].includes(p[f]));
|
|
50
|
+
const counts = {
|
|
51
|
+
brand: {},
|
|
52
|
+
family: {},
|
|
53
|
+
lightness: {},
|
|
54
|
+
intensity: {},
|
|
55
|
+
};
|
|
56
|
+
for (const p of candidates)
|
|
57
|
+
for (const f of facets)
|
|
58
|
+
if (matches(p, f))
|
|
59
|
+
counts[f][p[f]] = (counts[f][p[f]] ?? 0) + 1;
|
|
60
|
+
const eligible = candidates.filter((p) => matches(p));
|
|
61
|
+
return { reference, eligible, counts };
|
|
62
|
+
}
|
|
63
|
+
/** Official portable MG ranking over its complete versioned sampling-channel projection. */
|
|
64
|
+
export function createSamplizeColorVecIndex(cache) {
|
|
65
|
+
if (cache.embeddingVersion !== EMBEDDING_VERSION ||
|
|
66
|
+
cache.rankingVersion !== SAMPLIZE_COLORVEC_RANKING_VERSION)
|
|
67
|
+
throw new Error("The colour cache uses an incompatible embedding or ranking version. Refresh it before searching.");
|
|
68
|
+
if (!cache.sourceVersion ||
|
|
69
|
+
!cache.dictionaryVersion ||
|
|
70
|
+
!Number.isFinite(Date.parse(cache.generatedAt)))
|
|
71
|
+
throw new Error("The colour cache is missing its provenance.");
|
|
72
|
+
const paints = cache.paints.map((p) => ({
|
|
73
|
+
...p,
|
|
74
|
+
vector: typeof p.vector === "string" ? decodeVector(p.vector) : p.vector,
|
|
75
|
+
}));
|
|
76
|
+
const identities = new Set();
|
|
77
|
+
for (const paint of paints) {
|
|
78
|
+
if (identities.has(paint.variantId) ||
|
|
79
|
+
paint.vector.length !== EMBEDDING_VECTOR_SIZE ||
|
|
80
|
+
!paint.vector.every(Number.isFinite) ||
|
|
81
|
+
![paint.oklab.L, paint.oklab.a, paint.oklab.b].every(Number.isFinite))
|
|
82
|
+
throw new Error("The colour cache contains invalid or duplicate paint records.");
|
|
83
|
+
identities.add(paint.variantId);
|
|
84
|
+
}
|
|
85
|
+
const vectors = new Map();
|
|
86
|
+
const vectorFor = (hex) => {
|
|
87
|
+
const key = hex.toLowerCase();
|
|
88
|
+
let value = vectors.get(key);
|
|
89
|
+
if (!value) {
|
|
90
|
+
value = samplizeSolidColorVector(hex);
|
|
91
|
+
if (vectors.size >= 512)
|
|
92
|
+
vectors.delete(vectors.keys().next().value);
|
|
93
|
+
vectors.set(key, value);
|
|
94
|
+
}
|
|
95
|
+
return value;
|
|
96
|
+
};
|
|
97
|
+
return {
|
|
98
|
+
search(input) {
|
|
99
|
+
const limit = input.limit ?? 48;
|
|
100
|
+
if (!Number.isInteger(limit) || limit < 1 || limit > 100)
|
|
101
|
+
throw new Error("Choose between 1 and 100 suggestions.");
|
|
102
|
+
const { reference, eligible, counts } = selectSamplizeEligiblePaints(paints, input);
|
|
103
|
+
const palette = (input.palette?.length
|
|
104
|
+
? input.palette
|
|
105
|
+
: [{ hex: input.hex ?? reference?.hex ?? "", proportion: 1 }])
|
|
106
|
+
.map((p) => ({ ...p, hex: p.hex.toLowerCase() }))
|
|
107
|
+
.sort((a, b) => b.proportion - a.proportion || identityOrder(a.hex, b.hex));
|
|
108
|
+
if (palette.length > 12 ||
|
|
109
|
+
palette.some((p) => !Number.isFinite(p.proportion) ||
|
|
110
|
+
p.proportion <= 0 ||
|
|
111
|
+
p.proportion > 1))
|
|
112
|
+
throw new Error("Supply up to twelve positive image colour shares.");
|
|
113
|
+
const total = palette.reduce((sum, p) => sum + p.proportion, 0);
|
|
114
|
+
const buckets = palette.map((p, position) => ({
|
|
115
|
+
...p,
|
|
116
|
+
position,
|
|
117
|
+
vector: vectorFor(p.hex),
|
|
118
|
+
quota: Math.floor((limit * p.proportion) / total),
|
|
119
|
+
remainder: ((limit * p.proportion) / total) % 1,
|
|
120
|
+
paints: [],
|
|
121
|
+
}));
|
|
122
|
+
let remaining = limit - buckets.reduce((sum, p) => sum + p.quota, 0);
|
|
123
|
+
for (const p of [...buckets].sort((a, b) => b.remainder - a.remainder || a.position - b.position))
|
|
124
|
+
if (remaining-- > 0)
|
|
125
|
+
p.quota++;
|
|
126
|
+
for (const paint of eligible) {
|
|
127
|
+
let best = buckets[0], score = embeddingCosineSimilarity(paint.vector, best.vector);
|
|
128
|
+
for (let i = 1; i < buckets.length; i++) {
|
|
129
|
+
const candidate = buckets[i], next = embeddingCosineSimilarity(paint.vector, candidate.vector);
|
|
130
|
+
if (next > score) {
|
|
131
|
+
best = candidate;
|
|
132
|
+
score = next;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
best.paints.push({ id: paint.variantId, score });
|
|
136
|
+
}
|
|
137
|
+
const groups = buckets
|
|
138
|
+
.sort((a, b) => b.proportion - a.proportion || a.position - b.position)
|
|
139
|
+
.map((p) => {
|
|
140
|
+
const ids = p.paints
|
|
141
|
+
.sort((a, b) => b.score - a.score || identityOrder(a.id, b.id))
|
|
142
|
+
.slice(0, p.quota)
|
|
143
|
+
.map((paint) => paint.id);
|
|
144
|
+
return {
|
|
145
|
+
hex: p.hex,
|
|
146
|
+
proportion: p.proportion,
|
|
147
|
+
quota: p.quota,
|
|
148
|
+
ids,
|
|
149
|
+
shortfall: p.quota - ids.length,
|
|
150
|
+
};
|
|
151
|
+
});
|
|
152
|
+
const ids = groups.flatMap((p) => p.ids);
|
|
153
|
+
return {
|
|
154
|
+
ids,
|
|
155
|
+
groups,
|
|
156
|
+
limited: eligible.length > ids.length,
|
|
157
|
+
eligibleCount: eligible.length,
|
|
158
|
+
counts,
|
|
159
|
+
sourceVersion: cache.sourceVersion,
|
|
160
|
+
dictionaryVersion: cache.dictionaryVersion,
|
|
161
|
+
embeddingVersion: cache.embeddingVersion,
|
|
162
|
+
rankingVersion: cache.rankingVersion,
|
|
163
|
+
countBasis: "complete-catalogue",
|
|
164
|
+
};
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module sdk/search-card-types
|
|
3
|
+
* @description The `view:"card"` search projection — the lean grid item and the
|
|
4
|
+
* envelope that carries it.
|
|
5
|
+
*
|
|
6
|
+
* Split out of `types.ts` — which is over the repository's source-size limit —
|
|
7
|
+
* along the same seam `match-types.ts` took: one view of one surface, and
|
|
8
|
+
* nothing else. The full-view item and the shared envelope stay in `types.ts`,
|
|
9
|
+
* which this module reads `SearchResponse` from.
|
|
10
|
+
*/
|
|
11
|
+
import type { ProductId, VariantId } from "./identifiers.js";
|
|
12
|
+
import type { OpenEnum, SearchData, SearchResponse } from "./types.js";
|
|
13
|
+
/**
|
|
14
|
+
* The lean `view:"card"` result item — identity + name + thumbnail + score.
|
|
15
|
+
*
|
|
16
|
+
* A PROJECTION, not a smaller answer: a field the card omits (palette, verdict,
|
|
17
|
+
* signals, availability) is unread here, never known-absent. Re-read the same
|
|
18
|
+
* `variantId` at `view: "full"` or via `material()` before claiming anything the
|
|
19
|
+
* card does not carry.
|
|
20
|
+
*/
|
|
21
|
+
export interface SearchCardItem {
|
|
22
|
+
/** Accepted sampleability fact. Absent means unknown, never false. */
|
|
23
|
+
sampleable?: boolean;
|
|
24
|
+
/** Opaque — round-trip verbatim. */
|
|
25
|
+
variantId: VariantId;
|
|
26
|
+
productId: ProductId | null;
|
|
27
|
+
brandSlug: string | null;
|
|
28
|
+
brand: string;
|
|
29
|
+
/** Product name (the full item's `product`). */
|
|
30
|
+
name: string;
|
|
31
|
+
variantName: string | null;
|
|
32
|
+
imageUrl: string | null;
|
|
33
|
+
projectSaveCapability?: "allowed";
|
|
34
|
+
sourceStatus?: "provisional";
|
|
35
|
+
score: number;
|
|
36
|
+
/**
|
|
37
|
+
* Resolved values for the attribute ids sent in `returnAttributes`, keyed by
|
|
38
|
+
* attribute id. ABSENT entirely when `returnAttributes` was not sent.
|
|
39
|
+
*
|
|
40
|
+
* Three states, all different, and reading them as two is the mistake this
|
|
41
|
+
* shape exists to prevent: no `attributes` key means you did not ask; a key
|
|
42
|
+
* whose value is `null` means this material carries no accepted value for that
|
|
43
|
+
* attribute; anything else is what the graph holds. Values resolve with the
|
|
44
|
+
* normal variant-over-product precedence, and an array is a multi-valued
|
|
45
|
+
* attribute rather than a list of candidates.
|
|
46
|
+
*/
|
|
47
|
+
attributes?: Record<string, string | string[] | null>;
|
|
48
|
+
}
|
|
49
|
+
/** The `view:"card"` response form — the lean grid projection of {@link SearchResponse}. */
|
|
50
|
+
export interface SearchCardResponse extends Omit<SearchResponse, "data"> {
|
|
51
|
+
data: Omit<SearchData, "view" | "results"> & {
|
|
52
|
+
view: OpenEnum<"card">;
|
|
53
|
+
results: SearchCardItem[];
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SearchData } from "./types.js";
|
|
2
|
+
/** Canonical Search wire response. Raw SDK methods preserve this envelope. */
|
|
3
|
+
export interface SearchResponse {
|
|
4
|
+
data: SearchData;
|
|
5
|
+
meta: {
|
|
6
|
+
operationId: "search_materials_post" | "search_materials_get";
|
|
7
|
+
requestId: string;
|
|
8
|
+
};
|
|
9
|
+
links: Record<string, never>;
|
|
10
|
+
warnings: never[];
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|