Skip to content

GCP.RecommendationEngine reference

Source: packages/gcp/src/RecommendationEngine/CatalogsCatalogItem.ts

A Recommendations AI catalog item.

Catalog items have no labels field. Their description and tags feed recommendations, so Alchemy writes no ownership marker into them: a generated item id identifies the item, and read reports an explicit id it has no state for as unowned. Catalog, location, and item id are immutable. Title, description, categories, tags, and product metadata update in place.

CatalogsCatalogItem: Creating a Catalog Item

Section titled “CatalogsCatalogItem: Creating a Catalog Item”

Item on the default catalog

const item = yield* GCP.RecommendationEngine.CatalogsCatalogItem("Shirt", {
title: "Cotton tee",
categoryHierarchies: [{ categories: ["Apparel", "T-Shirts"] }],
productMetadata: {
currencyCode: "USD",
exactPrice: { displayPrice: 20 },
stockState: "IN_STOCK",
},
});

Explicit catalog and item id

const item = yield* GCP.RecommendationEngine.CatalogsCatalogItem("Shirt", {
catalog: "default_catalog",
location: "global",
catalogItemId: "cotton-tee",
title: "Cotton tee",
description: "Soft cotton t-shirt",
});

CatalogsCatalogItem: Updating a Catalog Item

Section titled “CatalogsCatalogItem: Updating a Catalog Item”
const item = yield* GCP.RecommendationEngine.CatalogsCatalogItem("Shirt", {
title: "Linen tee",
categoryHierarchies: [{ categories: ["Apparel", "T-Shirts"] }],
productMetadata: {
currencyCode: "USD",
exactPrice: { displayPrice: 24 },
},
});

CatalogsCatalogItem: Looking up an existing catalogs catalog item

Section titled “CatalogsCatalogItem: Looking up an existing catalogs catalog item”

CatalogsCatalogItem.lookup references a catalogs catalog item Alchemy doesn’t manage (created in the console or by another stack). It is read during plan/deploy, never created, updated or deleted, and binds like a declared catalogs catalog item.

const catalogsCatalogItem = GCP.RecommendationEngine.CatalogsCatalogItem.lookup({
catalogItemId: "my-catalog-item",
});

Source: packages/gcp/src/RecommendationEngine/GetCatalogItem.ts

Runtime binding for Recommendations AI catalogItems.get.

Bind this operation to a CatalogsCatalogItem in a Function or Action init phase. Provide GetCatalogItemHttp.

Grants roles/automlrecommendations.viewer on the project: Recommendations AI has no resource-level IAM.

const getCatalogItem = yield* GCP.RecommendationEngine.GetCatalogItem(item);
const live = yield* getCatalogItem();

Source: packages/gcp/src/RecommendationEngine/GetCatalogItemHttp.ts Kind: Layer · Provides: GCP.RecommendationEngine.GetCatalogItem

HTTP implementation of GetCatalogItem.