microsoft/typespec
Publicmirrored from https://github.com/microsoft/typespecAvailable
packages/events/src/lib.ts
28lines · modecode
| 1 | import { createTypeSpecLibrary, paramMessage } from "@typespec/compiler"; |
| 2 | |
| 3 | export const $lib = createTypeSpecLibrary({ |
| 4 | name: "@typespec/events", |
| 5 | diagnostics: { |
| 6 | "invalid-content-type-target": { |
| 7 | severity: "error", |
| 8 | messages: { |
| 9 | default: `@contentType can only be specified on the top-level event envelope, or the event payload marked with @data`, |
| 10 | }, |
| 11 | }, |
| 12 | "multiple-event-payloads": { |
| 13 | severity: "error", |
| 14 | messages: { |
| 15 | default: paramMessage`Event payload already applied to ${"dataPath"} but also exists under ${"currentPath"}`, |
| 16 | |
| 17 | payloadInIndexedModel: paramMessage`Event payload applied from inside a Record or Array at ${"dataPath"}`, |
| 18 | }, |
| 19 | }, |
| 20 | }, |
| 21 | state: { |
| 22 | events: { description: "State for the @events decorator." }, |
| 23 | contentType: { description: "State for the @contentType decorator." }, |
| 24 | data: { description: "State for the @data decorator." }, |
| 25 | }, |
| 26 | }); |
| 27 | |
| 28 | export const { reportDiagnostic, createDiagnostic, stateKeys: EventsStateKeys } = $lib; |
| 29 | |