@instruments/materialgraph 1.0.1 → 1.2.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/client.d.ts CHANGED
@@ -11,6 +11,7 @@ import type { FindVariantsByVectorInput, FindVariantsByVectorOutput } from "./fi
11
11
  import type { GetVariantOptions, GetVariantOutput } from "./get-variant-types.js";
12
12
  import type { VariantId } from "./identifiers.js";
13
13
  import type { ListEnumValuesOptions, ListEnumValuesResult } from "./list-enum-values-types.js";
14
+ import type { ListSampledTogetherPairsInput, ListSampledTogetherPairsOutput } from "./list-sampled-together-pairs-types.js";
14
15
  import type { ListVariantFacetsInput, ListVariantFacetsOutput } from "./list-variant-facets-types.js";
15
16
  import type { ListVariantsInput, ListVariantsOutput } from "./list-variants-types.js";
16
17
  import type { ListVariantAssetsOptions, MaterialDocumentPageOptions, VariantAssetPage } from "./material-asset-types.js";
@@ -214,6 +215,14 @@ export declare class MaterialGraphClient extends CatalogClient {
214
215
  * before presenting: a scheme of four that resolved two is a different claim.
215
216
  */
216
217
  findSampledTogether(input: FindSampledTogetherInput, signal?: AbortSignal): Promise<FindSampledTogetherOutput>;
218
+ /**
219
+ * Every Sampled Together pair in the current generation (GET
220
+ * `/api/v1/variants/sampled-together/pairs`), trailing 36 months, sampled,
221
+ * each pair once with `a < b`. `aProjects` and `bProjects` are each side's
222
+ * own project total, so a sample pack can be dropped without one call per
223
+ * variant. Follow `nextCursor` until it is null; a page is not a total.
224
+ */
225
+ listSampledTogetherPairs(input?: ListSampledTogetherPairsInput, signal?: AbortSignal): Promise<ListSampledTogetherPairsOutput>;
217
226
  /**
218
227
  * THE QUESTION: "what looks or feels like this?" (POST
219
228
  * `/api/v1/variants/by-vector`, MG-2231). Eligible variants ranked by
package/client.js CHANGED
@@ -326,6 +326,22 @@ export class MaterialGraphClient extends CatalogClient {
326
326
  async findSampledTogether(input, signal) {
327
327
  return await this.#get("find_sampled_together", { ...input }, signal);
328
328
  }
329
+ /**
330
+ * Every Sampled Together pair in the current generation (GET
331
+ * `/api/v1/variants/sampled-together/pairs`), trailing 36 months, sampled,
332
+ * each pair once with `a < b`. `aProjects` and `bProjects` are each side's
333
+ * own project total, so a sample pack can be dropped without one call per
334
+ * variant. Follow `nextCursor` until it is null; a page is not a total.
335
+ */
336
+ async listSampledTogetherPairs(input = {}, signal) {
337
+ return await this.#get("list_sampled_together_pairs", {
338
+ ...(input.cursor === undefined ? {} : { cursor: input.cursor }),
339
+ ...(input.limit === undefined ? {} : { limit: String(input.limit) }),
340
+ ...(input.minProjects === undefined
341
+ ? {}
342
+ : { minProjects: String(input.minProjects) }),
343
+ }, signal);
344
+ }
329
345
  /**
330
346
  * THE QUESTION: "what looks or feels like this?" (POST
331
347
  * `/api/v1/variants/by-vector`, MG-2231). Eligible variants ranked by
package/errors.d.ts CHANGED
@@ -88,8 +88,7 @@ type TransportErrorInput = {
88
88
  * field was added to remove. All ten members below were unreachable.
89
89
  *
90
90
  * So: the server's own contract is retained, and nothing else is. Adding a
91
- * member to a problem response means adding it here too, and
92
- * `problem-extension-parity.test.ts` fails when the two disagree.
91
+ * member to a problem response means adding it here too.
93
92
  */
94
93
  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", "unknown_parameters", "unorderable_attribute", "valid_group_keys", "valid_type_keys"];
95
94
  /** The one error class thrown by all SDK transport and HTTP failures. */
package/errors.js CHANGED
@@ -19,8 +19,7 @@ const RETRIABLE_STATUS = new Set([502, 503, 504]);
19
19
  * field was added to remove. All ten members below were unreachable.
20
20
  *
21
21
  * So: the server's own contract is retained, and nothing else is. Adding a
22
- * member to a problem response means adding it here too, and
23
- * `problem-extension-parity.test.ts` fails when the two disagree.
22
+ * member to a problem response means adding it here too.
24
23
  */
25
24
  export const MATERIALGRAPH_PROBLEM_EXTENSIONS = [
26
25
  "ambiguous_brands",
@@ -51,7 +51,7 @@ export type FindSampledTogetherRow = {
51
51
  variantName: string | null;
52
52
  };
53
53
  export type FindSampledTogetherOutput = {
54
- /** Other brands first, then seeds matched, then lift weighted by projects; one row per product. */
54
+ /** Other brands first; within each, product type groups in turn, each group best first (seeds matched, then lift weighted by projects); one row per product. */
55
55
  sampledTogether: FindSampledTogetherRow[];
56
56
  /** The seeds as resolved, so a caller sees what a name became. */
57
57
  seeds: {
@@ -67,10 +67,12 @@ export type PaintCatalogVariant = {
67
67
  variantName: string | null;
68
68
  };
69
69
  export type ResolvedColor = {
70
+ /** Other meanings of the same words, offered: ColorScope's color when a paint's exact name led. */
71
+ alternatives?: ColorAlternative[];
70
72
  catalogVariant: PaintCatalogVariant | null;
71
73
  hex: string;
72
74
  index: number;
73
- /** `region`: a named meaning's own OKLCh bounds, kept — never collapsed to one hex. */
75
+ /** `region`: a color family's own OKLCh bounds. `point`: a paint, hex or named color, held within ColorScope's Related band and ordered by Closeness. */
74
76
  kind: "point" | "region";
75
77
  /** Image-extracted or stored target-variant swatch share; else null. */
76
78
  share: number | null;
@@ -46,6 +46,7 @@ export type GetVariantIfc = {
46
46
  * false or zero.
47
47
  */
48
48
  export type GetVariantOutput = {
49
+ /** Whether this variant may appear in its Brand's catalog. Material-only lists also require Search Catalog membership. Reads by id include ineligible variants. */
49
50
  eligible: boolean;
50
51
  channels: string[];
51
52
  palette: {
@@ -93,6 +94,8 @@ export type GetVariantOutput = {
93
94
  /** The variant's Material Bank SKU. Absent means none is recorded. */
94
95
  materialBankId?: string;
95
96
  name: string;
97
+ /** The trimmed source variant label; null when unknown. Separate from surface finish and derived color names. */
98
+ variantLabel: string | null;
96
99
  /** Requested blocks or attributes the variant's product type does not carry. */
97
100
  notApplicable?: ListVariantsNotApplicable;
98
101
  /** Present when `ifc` was asked for. */
package/index.d.ts CHANGED
@@ -7,6 +7,7 @@ export type { ListEnumValuesOptions, EnumValueMatch, EnumValueItem, ListEnumValu
7
7
  export type { GetVariantIfc, GetVariantOptions, GetVariantOutput, } from "./get-variant-types.js";
8
8
  export type { ImageReferenceInput } from "./image-reference-types.js";
9
9
  export type { SampledTogetherProjectType, FindSampledTogetherInput, FindSampledTogetherRow, FindSampledTogetherOutput, } from "./find-sampled-together-types.js";
10
+ export type { ListSampledTogetherPairsInput, ListSampledTogetherPairsOutput, SampledTogetherPair, } from "./list-sampled-together-pairs-types.js";
10
11
  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
12
  export { FIND_VARIANTS_BY_VECTOR_MODES } from "./find-variants-by-vector-types.js";
12
13
  export type { FindVariantsByVectorMode, FindVariantsByVectorQuery, FindVariantsByVectorInput, FindVariantsByVectorItem, FindVariantsByVectorReference, FindVariantsByVectorScan, FindVariantsByVectorTimings, FindVariantsByVectorOutput, } from "./find-variants-by-vector-types.js";
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @module list-sampled-together-pairs-types
3
+ * @description Hand-maintained mirror of `list_sampled_together_pairs`' wire
4
+ * shapes. The source of truth is
5
+ * `packages/sampling/src/sampled-together-pairs.ts`; this SDK has no runtime
6
+ * dependency on `@materialgraph/sampling`, so the shapes are copied here.
7
+ */
8
+ export type ListSampledTogetherPairsInput = {
9
+ /** `nextCursor` from the previous page. */
10
+ cursor?: string;
11
+ /** Pairs per page, at most 5,000. Default 2,000. */
12
+ limit?: number;
13
+ /** Smallest project count a pair needs. Default 3. */
14
+ minProjects?: number;
15
+ };
16
+ export type SampledTogetherPair = {
17
+ a: string;
18
+ b: string;
19
+ /** Projects that sampled both. */
20
+ projects: number;
21
+ customers: number;
22
+ /** Above 1 is sampled together more often than chance. */
23
+ lift: number;
24
+ lastSampledTogetherAt: string | null;
25
+ /** Each side's own sampled project total; null when unknown. */
26
+ aProjects: number | null;
27
+ bProjects: number | null;
28
+ };
29
+ export type ListSampledTogetherPairsOutput = {
30
+ window: "trailing_36mo";
31
+ signal: "sampled";
32
+ windowStart: string | null;
33
+ /** How fresh the pair evidence is. */
34
+ windowEnd: string | null;
35
+ /** End of the window the per-side totals were counted over. */
36
+ projectTotalsWindowEnd: string | null;
37
+ pairs: SampledTogetherPair[];
38
+ nextCursor: string | null;
39
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @module list-sampled-together-pairs-types
3
+ * @description Hand-maintained mirror of `list_sampled_together_pairs`' wire
4
+ * shapes. The source of truth is
5
+ * `packages/sampling/src/sampled-together-pairs.ts`; this SDK has no runtime
6
+ * dependency on `@materialgraph/sampling`, so the shapes are copied here.
7
+ */
8
+ export {};
@@ -207,6 +207,8 @@ export type ListVariantsItem = {
207
207
  /** The variant's Material Bank SKU. Absent means none is recorded. */
208
208
  materialBankId?: string;
209
209
  name: string;
210
+ /** The trimmed source variant label; null when unknown. Separate from surface finish and derived color names. */
211
+ variantLabel: string | null;
210
212
  notApplicable?: ListVariantsNotApplicable;
211
213
  preference?: ListVariantsPreference;
212
214
  product: {
@@ -9,6 +9,7 @@ import type { FindVariantsByColorOutput } from "./find-variants-by-color-types.j
9
9
  import type { FindVariantsByVectorOutput } from "./find-variants-by-vector-types.js";
10
10
  import type { GetVariantOutput } from "./get-variant-types.js";
11
11
  import type { ListEnumValuesResult } from "./list-enum-values-types.js";
12
+ import type { ListSampledTogetherPairsOutput } from "./list-sampled-together-pairs-types.js";
12
13
  import type { ListVariantFacetsOutput } from "./list-variant-facets-types.js";
13
14
  import type { ListVariantsOutput } from "./list-variants-types.js";
14
15
  import type { MaterialDocumentPage, VariantAssetPage } from "./material-asset-types.js";
@@ -30,6 +31,7 @@ export type OperationResponses = {
30
31
  create_public_run: CreatePublicRunResponse;
31
32
  extract_image_palette: ExtractPaletteResponse;
32
33
  find_sampled_together: FindSampledTogetherOutput;
34
+ list_sampled_together_pairs: ListSampledTogetherPairsOutput;
33
35
  find_variants_by_color: FindVariantsByColorOutput;
34
36
  find_variants_by_vector: FindVariantsByVectorOutput;
35
37
  get_applicability: ApplicabilityResponse;
@@ -1,5 +1,5 @@
1
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 ["getCatalogGeneration", "GET", "/api/v1/catalog/generation", "get_catalog_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 ["samplizeCatalog", "GET", "/api/v1/catalogs/samplize/products", "samplize_catalog_products"], readonly ["catalogReferencesForVariants", "POST", "/api/v1/catalogs/references", "get_catalog_references_batch"], readonly ["catalogCollections", "GET", "/api/v1/catalogs/collections", "list_catalog_channel_collections"], readonly ["catalogDocumentAccess", "GET", "/api/v1/catalogs/documents/{documentId}", "get_catalog_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"]];
2
+ declare const OPERATION_DEFINITIONS: readonly [readonly ["colors.nearestPaints", "GET", "/api/v1/colors/nearest-paints", "find_nearest_paints"], readonly ["getCatalogGeneration", "GET", "/api/v1/catalog/generation", "get_catalog_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 ["samplizeCatalog", "GET", "/api/v1/catalogs/samplize/products", "samplize_catalog_products"], readonly ["catalogReferencesForVariants", "POST", "/api/v1/catalogs/references", "get_catalog_references_batch"], readonly ["catalogCollections", "GET", "/api/v1/catalogs/collections", "list_catalog_channel_collections"], readonly ["catalogDocumentAccess", "GET", "/api/v1/catalogs/documents/{documentId}", "get_catalog_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 ["listSampledTogetherPairs", "GET", "/api/v1/variants/sampled-together/pairs", "list_sampled_together_pairs"], 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
3
  export type SdkOperationId = (typeof OPERATION_DEFINITIONS)[number][3];
4
4
  export type SdkOperation<K extends SdkOperationId = SdkOperationId> = Readonly<{
5
5
  clientMethod: (typeof OPERATION_DEFINITIONS)[number][0];
@@ -125,6 +125,12 @@ const OPERATION_DEFINITIONS = [
125
125
  "/api/v1/variants/sampled-together",
126
126
  "find_sampled_together",
127
127
  ],
128
+ [
129
+ "listSampledTogetherPairs",
130
+ "GET",
131
+ "/api/v1/variants/sampled-together/pairs",
132
+ "list_sampled_together_pairs",
133
+ ],
128
134
  ["resolveVariant", "POST", "/api/v1/variants/resolve", "resolve_variant"],
129
135
  ["getVariant", "GET", "/api/v1/variants/{variantId}", "get_variant"],
130
136
  [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instruments/materialgraph",
3
- "version": "1.0.1",
3
+ "version": "1.2.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,5 +1,5 @@
1
1
  /** The API contract version the schemas were generated from. */
2
2
  export declare const RESPONSE_SCHEMA_API_VERSION = "0.8.0";
3
3
  /** Every SDK operation whose success response has a published JSON Schema. */
4
- export declare const RESPONSE_SCHEMA_OPERATION_IDS: readonly ["find_nearest_paints", "get_catalog_generation", "list_catalog_documents", "list_catalog_pages", "get_catalog_page_representation", "list_catalog_product_references", "samplize_catalog_products", "get_catalog_references_batch", "list_catalog_channel_collections", "get_catalog_document_access", "list_material_blocks", "list_variant_assets", "list_material_documents", "list_schema_value_dictionaries", "get_material_pairings", "list_associated_finishes", "list_associated_products", "get_applicability", "list_variants", "list_variant_facets", "search_variants", "find_variants_by_color", "find_variants_by_vector", "find_sampled_together", "resolve_variant", "get_variant", "resolve_color_name", "catalog_list_attributes", "catalog_list_enum_values", "list_categories", "get_category", "whoami", "get_category_color_profiles", "extract_image_palette", "list_brands", "upload_source_material", "create_public_run", "get_public_run"];
4
+ export declare const RESPONSE_SCHEMA_OPERATION_IDS: readonly ["find_nearest_paints", "get_catalog_generation", "list_catalog_documents", "list_catalog_pages", "get_catalog_page_representation", "list_catalog_product_references", "samplize_catalog_products", "get_catalog_references_batch", "list_catalog_channel_collections", "get_catalog_document_access", "list_material_blocks", "list_variant_assets", "list_material_documents", "list_schema_value_dictionaries", "get_material_pairings", "list_associated_finishes", "list_associated_products", "get_applicability", "list_variants", "list_variant_facets", "search_variants", "find_variants_by_color", "find_variants_by_vector", "find_sampled_together", "list_sampled_together_pairs", "resolve_variant", "get_variant", "resolve_color_name", "catalog_list_attributes", "catalog_list_enum_values", "list_categories", "get_category", "whoami", "get_category_color_profiles", "extract_image_palette", "list_brands", "upload_source_material", "create_public_run", "get_public_run"];
5
5
  export declare const RESPONSE_SCHEMA_CATALOG_JSON: string;