Skip to content

GCP.Vision reference

Source: packages/gcp/src/Vision/Product.ts

A Cloud Vision Product Search product. Products hold reference images and can be added to one or more product sets.

Products have no labels field (productLabels are search filters), so ownership rests on the deterministic product id: a product found without prior state is reported as unowned and only taken over with --adopt. Location, product id, and productCategory are identity — changing any of them replaces the product. Display name, description, and labels update in place.

Generated id

const product = yield* GCP.Vision.Product("Shoe", {
displayName: "Trail runner",
productCategory: "apparel-v2",
});

Explicit id and labels

const product = yield* GCP.Vision.Product("Shoe", {
location: "us-west1",
productId: "trail-runner",
displayName: "Trail runner",
productCategory: "apparel-v2",
productLabels: [{ key: "color", value: "blue" }],
});
// Same logical id as before; only the changed props differ.
const product = yield* GCP.Vision.Product("Shoe", {
location: "us-west1",
productId: "trail-runner",
displayName: "Trail runner v2",
productCategory: "apparel-v2",
productLabels: [{ key: "color", value: "green" }],
});

Product.lookup references a product 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 product.

const product = GCP.Vision.Product.lookup({ productId: "my-product" });

Source: packages/gcp/src/Vision/ProductSet.ts

A Cloud Vision Product Search product set.

Product sets have no labels field, so ownership rests on the deterministic product set id: a set found without prior state is reported as unowned and only taken over with --adopt. Location and product set id are identity — changing either replaces the set. Display name and product membership update in place.

Generated id

const set = yield* GCP.Vision.ProductSet("Catalog", {
displayName: "Summer",
});

Explicit id and location

const set = yield* GCP.Vision.ProductSet("Catalog", {
location: "us-west1",
productSetId: "summer-catalog",
displayName: "Summer",
});
// Same logical id as before; only the changed props differ.
const set = yield* GCP.Vision.ProductSet("Catalog", {
location: "us-west1",
productSetId: "summer-catalog",
displayName: "Fall",
products: [shoe.name],
});

ProductSet: Looking up an existing product set

Section titled “ProductSet: Looking up an existing product set”

ProductSet.lookup references a product set 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 product set.

const productSet = GCP.Vision.ProductSet.lookup({ productSetId: "my-product-set" });

Source: packages/gcp/src/Vision/ProductsReferenceImage.ts

A Cloud Vision Product Search reference image attached to a product.

Reference images have no labels or description, so ownership rests on the deterministic image id: an image found without prior state is reported as unowned and only taken over with --adopt. Parent, image id, URI, and bounding polygons are identity — there is no update API, so changing any of them replaces the image.

ProductsReferenceImage: Creating a Reference Image

Section titled “ProductsReferenceImage: Creating a Reference Image”

Image on a product

const product = yield* GCP.Vision.Product("Shoe", {
displayName: "Trail runner",
productCategory: "apparel-v2",
});
const image = yield* GCP.Vision.ProductsReferenceImage("Hero", {
parent: product.name,
uri: "gs://my-bucket/shoe.png",
});

Explicit id and bounding box

const image = yield* GCP.Vision.ProductsReferenceImage("Hero", {
parent: product.name,
referenceImageId: "hero-front",
uri: "gs://my-bucket/shoe.png",
boundingPolys: [
{
vertices: [
{ x: 0, y: 0 },
{ x: 320, y: 0 },
{ x: 320, y: 320 },
{ x: 0, y: 320 },
],
},
],
});

ProductsReferenceImage: Looking up an existing products reference image

Section titled “ProductsReferenceImage: Looking up an existing products reference image”

ProductsReferenceImage.lookup references a products reference image 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 products reference image.

const productsReferenceImage = GCP.Vision.ProductsReferenceImage.lookup({
parent: "my-parent",
referenceImageId: "my-reference-image",
});