@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
ts 74 lines 2.37 KB
Raw
1 import * as GCP from "@alchemy.run/gcp";
2 import * as Effect from "effect/Effect";
3 import { serveProbes } from "../../bindingHost.ts";
4
5 const location = "us";
6
7 /** Document schema GetDocumentSchema reads. */
8 export const Note = GCP.ContentWarehouse.DocumentSchema("Note", {
9 location,
10 displayName: "binding-note",
11 propertyDefinitions: [{ name: "title", isSearchable: true, textTypeOptions: {} }],
12 });
13
14 /** Document GetDocument reads. */
15 export const Welcome = Effect.gen(function* () {
16 const schema = yield* Note;
17 return yield* GCP.ContentWarehouse.Document("Welcome", {
18 location,
19 documentSchemaName: schema.name,
20 displayName: "binding-welcome",
21 plainText: "hello binding",
22 });
23 });
24
25 /** Rule set GetRuleSet reads. */
26 export const Checks = GCP.ContentWarehouse.RuleSet("Checks", {
27 location,
28 description: "binding rules",
29 source: "alchemy",
30 rules: [
31 {
32 description: "require title",
33 triggerType: "ON_CREATE",
34 condition: "true",
35 actions: [{ dataValidation: { conditions: { display_name: "true" } } }],
36 },
37 ],
38 });
39
40 /** Synonym set GetSynonymSet reads. */
41 export const Sales = GCP.ContentWarehouse.SynonymSet("Sales", {
42 location,
43 synonyms: [{ words: ["sale", "invoice", "bill"] }],
44 });
45
46 /**
47 * Effect-native Cloud Run service exercising every Document AI Warehouse
48 * binding as its own runtime service account. Deployed from
49 * {@link ../Bindings.test.ts}.
50 */
51 export default class ContentWarehouseBindingsHost extends GCP.Function<ContentWarehouseBindingsHost>()(
52 "ContentWarehouseBindingsHost",
53 { main: import.meta.url, invokerIamDisabled: true },
54 Effect.gen(function* () {
55 const getDocumentSchema = yield* GCP.ContentWarehouse.GetDocumentSchema(Note);
56 const getDocument = yield* GCP.ContentWarehouse.GetDocument(Welcome);
57 const getRuleSet = yield* GCP.ContentWarehouse.GetRuleSet(Checks);
58 const getSynonymSet = yield* GCP.ContentWarehouse.GetSynonymSet(Sales);
59
60 return {
61 fetch: serveProbes({
62 getDocumentSchema: getDocumentSchema(),
63 getDocument: getDocument(),
64 getRuleSet: getRuleSet(),
65 getSynonymSet: getSynonymSet(),
66 }),
67 };
68 }).pipe(
69 Effect.provide(GCP.ContentWarehouse.GetDocumentSchemaHttp),
70 Effect.provide(GCP.ContentWarehouse.GetDocumentHttp),
71 Effect.provide(GCP.ContentWarehouse.GetRuleSetHttp),
72 Effect.provide(GCP.ContentWarehouse.GetSynonymSetHttp),
73 ),
74 ) {}