@typespec/events
TypeScript icon, indicating that this package has built-in type declarations

0.62.0 • Public • Published

@typespec/events

TypeSpec library providing events bindings

Install

npm install @typespec/events

Decorators

TypeSpec.Events

@contentType

Specifies the content type of the event envelope, event body, or event payload. When applied to an event payload, that field must also have a corresponding @data decorator.

@TypeSpec.Events.contentType(contentType: valueof string)
Target

UnionVariant | ModelProperty

Parameters
Name Type Description
contentType valueof string
Examples
@events
union MixedEvents {
  @contentType("application/json")
  message: {
    id: string,
    text: string,
  },
}
Specify the content type of the event payload.
@events
union MixedEvents {
  {
    done: true,
  },
  {
    done: false,
    @data @contentType("text/plain") value: string,
  },
}

@data

Identifies the payload of an event. Only one field in an event can be marked as the payload.

@TypeSpec.Events.data
Target

ModelProperty

Parameters

None

Examples
@events
union MixedEvents {
  {
    metadata: Record<string>,
    @data payload: string,
  },
}

@events

Specify that this union describes a set of events.

@TypeSpec.Events.events
Target

Union

Parameters

None

Examples
@events
union MixedEvents {
  pingEvent: string,
  doneEvent: "done",
}

Readme

Keywords

Package Sidebar

Install

npm i @typespec/events

Homepage

typespec.io

Weekly Downloads

37

Version

0.62.0

License

MIT

Unpacked Size

36.5 kB

Total Files

45

Last publish

Collaborators

  • microsoft1es
  • azure-sdk