| 1 | import type * as schemas from "@distilled.cloud/aws/schemas"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { Schema } from "./Schema.ts"; |
| 5 | |
| 6 | /** |
| 7 | * Runtime binding for `schemas:DescribeSchema`. |
| 8 | * |
| 9 | * Reads the bound {@link Schema}'s document — the content, type, version, |
| 10 | * and description — so a function can fetch the authoritative event contract |
| 11 | * at runtime (e.g. to validate incoming payloads against the registered |
| 12 | * schema). The registry and schema names are injected from the binding; pass |
| 13 | * `SchemaVersion` to read a specific version instead of the latest. Provide |
| 14 | * the implementation with `Effect.provide(AWS.Schemas.DescribeSchemaHttp)`. |
| 15 | * ### Reading Schemas |
| 16 | * **Example:** Fetch The Latest Schema Document |
| 17 | * ```typescript |
| 18 | * // init — bind the operation to the schema |
| 19 | * const describeSchema = yield* AWS.Schemas.DescribeSchema(schema); |
| 20 | * |
| 21 | * // runtime |
| 22 | * const { Content, SchemaVersion } = yield* describeSchema(); |
| 23 | * const document = JSON.parse(Content!); |
| 24 | * ``` |
| 25 | * |
| 26 | * @binding |
| 27 | */ |
| 28 | export interface DescribeSchema extends Binding.Service< |
| 29 | DescribeSchema, |
| 30 | "AWS.Schemas.DescribeSchema", |
| 31 | (schema: Schema) => Effect.Effect< |
| 32 | (request?: { |
| 33 | /** The version of the schema to read. Defaults to the latest. */ |
| 34 | SchemaVersion?: string; |
| 35 | }) => Effect.Effect< |
| 36 | schemas.DescribeSchemaResponse, |
| 37 | schemas.DescribeSchemaError |
| 38 | > |
| 39 | > |
| 40 | > {} |
| 41 | export const DescribeSchema = Binding.Service<DescribeSchema>( |
| 42 | "AWS.Schemas.DescribeSchema", |
| 43 | ); |