microsoft/typespec

Public

mirrored from https://github.com/microsoft/typespecAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
copilot/fix-8128

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

packages/events/src/lib.ts

28lines · modecode

1import { createTypeSpecLibrary, paramMessage } from "@typespec/compiler";
2
3export 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
28export const { reportDiagnostic, createDiagnostic, stateKeys: EventsStateKeys } = $lib;
29