effx
API reference@effx/runtime

decorators

API reference for @effx/runtime/decorators

decorators.ts overview


Exports Grouped by Category


utils

Annotate

Generic source annotation (spec 0015): records exactly { name, args }, the record an applied definition records (spec 0020 §2.1). An extension, not the runtime, gives the name its meaning.

Signature

declare const Annotate: (name: string, ...args: Annotation["args"]) => MethodDecorator

Authorize

Signature

declare const Authorize: Definition<"Authorize", "operation", readonly [Arg<Capability, CapabilityMarker>], undefined>

ClassDecorator (type alias)

Signature

type ClassDecorator = <Class extends abstract new (...args: never) => object>(
  value: Class,
  context: ClassDecoratorContext<Class>
) => undefined

Cli

Signature

declare const Cli: Definition<"Cli", "operation", readonly [Arg<string, string>], undefined>

Command

Signature

declare const Command: Definition<
  "Command",
  "operation",
  {
    readonly name: OptionalArg<string, string>
    readonly input: Arg<Schema.Top, SchemaMarker>
    readonly success: Arg<Schema.Top, SchemaMarker>
  },
  undefined
>

Errors

Signature

declare const Errors: Definition<"Errors", "operation", RestArgs<Schema.Top, SchemaMarker>, undefined>

Foldkit

Signature

declare const Foldkit: {
  Command: Definition<
    "Foldkit.Command",
    "operation",
    { readonly success: Arg<Schema.Top, SchemaMarker>; readonly failure: Arg<Schema.Top, SchemaMarker> },
    undefined
  >
}

Http

Signature

declare const Http: {
  Group: Definition<
    "Http.Group",
    "group",
    readonly [
      Arg<
        Readonly<{
          readonly root: string | { readonly identifier: string }
          readonly group: string
          readonly title?: string | undefined
          readonly description?: string | undefined
          readonly displayName?: string | undefined
          readonly defaults?:
            | Readonly<{
                readonly middleware?: ReadonlyArray<ServiceLike> | undefined
                readonly metadata?: Readonly<{ readonly annotator?: HttpOperationAnnotator | undefined }> | undefined
                readonly problems?: Readonly<{ readonly registry?: ProblemRegistry | undefined }> | undefined
                readonly access?:
                  | Readonly<{
                      readonly annotator?: ((spec: HttpAccessAnnotationSpec) => Context<never>) | undefined
                      readonly exposure?: "External" | "Internal" | undefined
                      readonly acceptedCredentials?: readonly [string, ...string[]] | undefined
                      readonly principalKinds?:
                        | readonly [
                            "Anonymous" | "Person" | "ServicePrincipal" | "CapabilityHolder",
                            ...("Anonymous" | "Person" | "ServicePrincipal" | "CapabilityHolder")[]
                          ]
                        | undefined
                      readonly concealment?:
                        | TaggedLive<{
                            readonly Reveal: {}
                            readonly NotFound: {
                              readonly stages: Arg<readonly [string, ...string[]], readonly [string, ...string[]]>
                            }
                          }>
                        | undefined
                    }>
                  | undefined
              }>
            | undefined
        }>,
        Readonly<{
          readonly root: string | RootSymbolMarker
          readonly group: string
          readonly title?: string | undefined
          readonly description?: string | undefined
          readonly displayName?: string | undefined
          readonly defaults?:
            | Readonly<{
                readonly middleware?: ReadonlyArray<SymbolMarker> | undefined
                readonly metadata?: Readonly<{ readonly annotator?: SymbolMarker | undefined }> | undefined
                readonly problems?: Readonly<{ readonly registry?: SymbolMarker | undefined }> | undefined
                readonly access?:
                  | Readonly<{
                      readonly annotator?: SymbolMarker | undefined
                      readonly exposure?: "External" | "Internal" | undefined
                      readonly acceptedCredentials?: readonly [string, ...string[]] | undefined
                      readonly principalKinds?:
                        | readonly [
                            "Anonymous" | "Person" | "ServicePrincipal" | "CapabilityHolder",
                            ...("Anonymous" | "Person" | "ServicePrincipal" | "CapabilityHolder")[]
                          ]
                        | undefined
                      readonly concealment?:
                        | TaggedRead<{
                            readonly Reveal: {}
                            readonly NotFound: {
                              readonly stages: Arg<readonly [string, ...string[]], readonly [string, ...string[]]>
                            }
                          }>
                        | undefined
                    }>
                  | undefined
              }>
            | undefined
        }>
      >
    ],
    undefined
  >
  group: (options: HttpGroupOptions) => HttpGroupValue
  headers: <S extends Schema.Top>(schema: S) => S & { readonly "~effx/Http/Headers": true }
  Access: Definition<
    "Http.Access",
    "operation",
    readonly [
      Arg<
        Readonly<{
          readonly capabilities: TaggedLive<{
            readonly None: {}
            readonly One: { readonly capability: Arg<string, string> }
            readonly Any: { readonly capabilities: Arg<readonly [string, ...string[]], readonly [string, ...string[]]> }
            readonly All: { readonly capabilities: Arg<readonly [string, ...string[]], readonly [string, ...string[]]> }
          }>
          readonly requirements: ReadonlyArray<
            Readonly<{ readonly id: string; readonly parameters?: { readonly [key: string]: JsonValue } | undefined }>
          >
          readonly canonicalScopeResolver: object
          readonly annotator?: ((spec: HttpAccessAnnotationSpec) => Context<never>) | undefined
          readonly exposure?: "External" | "Internal" | undefined
          readonly acceptedCredentials?: readonly [string, ...string[]] | undefined
          readonly principalKinds?:
            | readonly [
                "Anonymous" | "Person" | "ServicePrincipal" | "CapabilityHolder",
                ...("Anonymous" | "Person" | "ServicePrincipal" | "CapabilityHolder")[]
              ]
            | undefined
          readonly concealment?:
            | TaggedLive<{
                readonly Reveal: {}
                readonly NotFound: {
                  readonly stages: Arg<readonly [string, ...string[]], readonly [string, ...string[]]>
                }
              }>
            | undefined
          readonly decisionTime?: "SnapshotRead" | "Transaction" | undefined
          readonly snapshotDecisionForCommand?: boolean | undefined
        }>,
        Readonly<{
          readonly annotator: SymbolMarker
          readonly exposure: "External" | "Internal"
          readonly acceptedCredentials: readonly [string, ...string[]]
          readonly principalKinds: readonly [
            "Anonymous" | "Person" | "ServicePrincipal" | "CapabilityHolder",
            ...("Anonymous" | "Person" | "ServicePrincipal" | "CapabilityHolder")[]
          ]
          readonly capabilities: TaggedRead<{
            readonly None: {}
            readonly One: { readonly capability: Arg<string, string> }
            readonly Any: { readonly capabilities: Arg<readonly [string, ...string[]], readonly [string, ...string[]]> }
            readonly All: { readonly capabilities: Arg<readonly [string, ...string[]], readonly [string, ...string[]]> }
          }>
          readonly requirements: ReadonlyArray<
            Readonly<{ readonly id: string; readonly parameters?: { readonly [key: string]: JsonValue } | undefined }>
          >
          readonly canonicalScopeResolver: SymbolMarker
          readonly concealment: TaggedRead<{
            readonly Reveal: {}
            readonly NotFound: { readonly stages: Arg<readonly [string, ...string[]], readonly [string, ...string[]]> }
          }>
          readonly decisionTime: "SnapshotRead" | "Transaction"
          readonly snapshotDecisionForCommand?: boolean | undefined
        }>
      >
    ],
    undefined
  >
  Contract: Definition<
    "Http.Contract",
    "operation",
    readonly [
      Arg<
        Readonly<{
          readonly root?: string | undefined
          readonly group?: string | undefined
          readonly params?: Schema.Top | undefined
          readonly query?: true | Schema.Top | undefined
          readonly headers?: Schema.Top | undefined
          readonly payload?: Schema.Top | undefined
          readonly payloadIsQuery?: boolean | undefined
          readonly success?: Schema.Top | undefined
          readonly status?: number | undefined
          readonly mediaType?: string | undefined
          readonly responseHeaders?: Schema.Top | undefined
          readonly conditional?: boolean | undefined
          readonly middleware?: ReadonlyArray<ServiceLike> | undefined
          readonly metadata?:
            | Readonly<{
                readonly annotator?: HttpOperationAnnotator | undefined
                readonly operationId?: string | undefined
                readonly summary?: string | undefined
                readonly description?: string | undefined
                readonly tags?: ReadonlyArray<string> | undefined
                readonly commandIdentity?: ExportedFunctionSymbol | undefined
              }>
            | undefined
        }>,
        Readonly<{
          readonly group: string
          readonly success: SchemaMarker
          readonly root?: string | undefined
          readonly params?: SchemaMarker | undefined
          readonly query?: SchemaMarker | undefined
          readonly headers?: SchemaMarker | undefined
          readonly payload?: SchemaMarker | undefined
          readonly payloadIsQuery?: boolean | undefined
          readonly status?: number | undefined
          readonly mediaType?: string | undefined
          readonly responseHeaders?: SchemaMarker | undefined
          readonly conditional?: boolean | undefined
          readonly middleware?: ReadonlyArray<SymbolMarker> | undefined
          readonly metadata?:
            | Readonly<{
                readonly annotator?: SymbolMarker | undefined
                readonly operationId?: string | undefined
                readonly summary?: string | undefined
                readonly description?: string | undefined
                readonly tags?: ReadonlyArray<string> | undefined
                readonly commandIdentity?: SymbolMarker | undefined
              }>
            | undefined
        }>
      >
    ],
    undefined
  >
  Problems: <Code extends string>(
    options: HttpProblemsOptions<Code>
  ) => Applied<typeof Builtins.HttpProblems.name, "operation">
  Get: Definition<"Http.Get", "operation", readonly [Arg<string, string>], undefined>
  Post: Definition<"Http.Post", "operation", readonly [Arg<string, string>], undefined>
  Put: Definition<"Http.Put", "operation", readonly [Arg<string, string>], undefined>
  Patch: Definition<"Http.Patch", "operation", readonly [Arg<string, string>], undefined>
  Delete: Definition<"Http.Delete", "operation", readonly [Arg<string, string>], undefined>
}

MethodDecorator (type alias)

TC39 standard method decorator. Records the annotation on the method function and returns undefined: the method is never replaced and no behaviour is generated (ADR 0001).

Signature

type MethodDecorator = <This, Args extends ReadonlyArray<never>, Return>(
  value: (this: This, ...args: Args) => Return,
  context: ClassMethodDecoratorContext<This, (this: This, ...args: Args) => Return>
) => undefined

PersistentModel

Class decorator; the decorated class is the model schema, recorded as schema (the definition's selfAs, spec 0002).

Signature

declare const PersistentModel: Definition<
  "PersistentModel",
  "model",
  {
    readonly table: Arg<string, string>
    readonly schema: InjectedArg<SchemaMarker>
    readonly views: OptionalArg<Readonly<Record<string, Schema.Top>>, Readonly<Record<string, SchemaMarker>>>
    readonly focus: OptionalArg<
      Readonly<Record<string, ReadonlyArray<string> | Focus>>,
      Readonly<Record<string, ReadonlyArray<string>>>
    >
  },
  undefined
>

Query

Signature

declare const Query: Definition<
  "Query",
  "operation",
  {
    readonly name: OptionalArg<string, string>
    readonly input: Arg<Schema.Top, SchemaMarker>
    readonly success: Arg<Schema.Top, SchemaMarker>
  },
  undefined
>

Requirements

Signature

declare const Requirements: Definition<"Requirements", "operation", RestArgs<ServiceLike, SymbolMarker>, undefined>

Rpc

Signature

declare const Rpc: Definition<"Rpc", "operation", readonly [Arg<string, string>], undefined>

On this page