| 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 | |
| 5 | /** |
| 6 | * Runtime binding for `schemas:GetDiscoveredSchema`. |
| 7 | * |
| 8 | * Infers an OpenAPI 3 or JSONSchema Draft 4 schema from up to 10 sample |
| 9 | * events — the same inference the schema discoverer applies to live traffic, |
| 10 | * exposed as an on-demand call. The operation is account-level (it is not |
| 11 | * scoped to any registry or schema). Provide the implementation with |
| 12 | * `Effect.provide(AWS.Schemas.GetDiscoveredSchemaHttp)`. |
| 13 | * ### Discovering Schemas |
| 14 | * **Example:** Infer A Schema From Sample Events |
| 15 | * ```typescript |
| 16 | * // init — account-level, no resource to bind |
| 17 | * const getDiscoveredSchema = yield* AWS.Schemas.GetDiscoveredSchema(); |
| 18 | * |
| 19 | * // runtime — events are full AWS event envelopes as JSON strings |
| 20 | * const { Content } = yield* getDiscoveredSchema({ |
| 21 | * Type: "OpenApi3", |
| 22 | * Events: [JSON.stringify(sampleEvent)], |
| 23 | * }); |
| 24 | * ``` |
| 25 | * |
| 26 | * @binding |
| 27 | */ |
| 28 | export interface GetDiscoveredSchema extends Binding.Service< |
| 29 | GetDiscoveredSchema, |
| 30 | "AWS.Schemas.GetDiscoveredSchema", |
| 31 | () => Effect.Effect< |
| 32 | (request?: { |
| 33 | /** Up to 10 sample events (full AWS event envelopes) as JSON strings. */ |
| 34 | Events?: string[]; |
| 35 | /** The type of schema to infer: `OpenApi3` or `JSONSchemaDraft4`. */ |
| 36 | Type?: string; |
| 37 | }) => Effect.Effect< |
| 38 | schemas.GetDiscoveredSchemaResponse, |
| 39 | schemas.GetDiscoveredSchemaError |
| 40 | > |
| 41 | > |
| 42 | > {} |
| 43 | export const GetDiscoveredSchema = Binding.Service<GetDiscoveredSchema>( |
| 44 | "AWS.Schemas.GetDiscoveredSchema", |
| 45 | ); |