t3-code-android-nightly/.repos/alchemy-effect/packages/alchemy/test/GCP/ContentWarehouse/fixtures/bindings-host.ts
Julius Marminge 6f9cea00ae
chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-05 13:22:30 -07:00

77 lines
2.4 KiB
TypeScript

import * as GCP from "@/GCP";
import * as Effect from "effect/Effect";
import { serveProbes } from "../../bindingHost.ts";
const location = "us";
/** Document schema GetDocumentSchema reads. */
export const Note = GCP.ContentWarehouse.DocumentSchema("Note", {
location,
displayName: "binding-note",
propertyDefinitions: [
{ name: "title", isSearchable: true, textTypeOptions: {} },
],
});
/** Document GetDocument reads. */
export const Welcome = Effect.gen(function* () {
const schema = yield* Note;
return yield* GCP.ContentWarehouse.Document("Welcome", {
location,
documentSchemaName: schema.name,
displayName: "binding-welcome",
plainText: "hello binding",
});
});
/** Rule set GetRuleSet reads. */
export const Checks = GCP.ContentWarehouse.RuleSet("Checks", {
location,
description: "binding rules",
source: "alchemy",
rules: [
{
description: "require title",
triggerType: "ON_CREATE",
condition: "true",
actions: [{ dataValidation: { conditions: { display_name: "true" } } }],
},
],
});
/** Synonym set GetSynonymSet reads. */
export const Sales = GCP.ContentWarehouse.SynonymSet("Sales", {
location,
synonyms: [{ words: ["sale", "invoice", "bill"] }],
});
/**
* Effect-native Cloud Run service exercising every Document AI Warehouse
* binding as its own runtime service account. Deployed from
* {@link ../Bindings.test.ts}.
*/
export default class ContentWarehouseBindingsHost extends GCP.Function<ContentWarehouseBindingsHost>()(
"ContentWarehouseBindingsHost",
{ main: import.meta.url, invokerIamDisabled: true },
Effect.gen(function* () {
const getDocumentSchema =
yield* GCP.ContentWarehouse.GetDocumentSchema(Note);
const getDocument = yield* GCP.ContentWarehouse.GetDocument(Welcome);
const getRuleSet = yield* GCP.ContentWarehouse.GetRuleSet(Checks);
const getSynonymSet = yield* GCP.ContentWarehouse.GetSynonymSet(Sales);
return {
fetch: serveProbes({
getDocumentSchema: getDocumentSchema(),
getDocument: getDocument(),
getRuleSet: getRuleSet(),
getSynonymSet: getSynonymSet(),
}),
};
}).pipe(
Effect.provide(GCP.ContentWarehouse.GetDocumentSchemaHttp),
Effect.provide(GCP.ContentWarehouse.GetDocumentHttp),
Effect.provide(GCP.ContentWarehouse.GetRuleSetHttp),
Effect.provide(GCP.ContentWarehouse.GetSynonymSetHttp),
),
) {}