effx
API reference@effx/compilerlift

rules

API reference for @effx/compiler/lift/rules

rules.ts overview


Exports Grouped by Category


utils

AccessEmit

What an access builder stands for: every Http.Access field except the annotator, which the rule names, and the resolver, which resolver evaluates to an id that LiftInput.names maps to a real export.

Signature

declare const AccessEmit: Schema.Struct<{
  readonly exposure: Schema.Codec<TemplateExpr, TemplateExpr, never, never>
  readonly acceptedCredentials: Schema.Codec<TemplateExpr, TemplateExpr, never, never>
  readonly principalKinds: Schema.Codec<TemplateExpr, TemplateExpr, never, never>
  readonly capabilities: Schema.Codec<TemplateExpr, TemplateExpr, never, never>
  readonly requirements: Schema.Codec<TemplateExpr, TemplateExpr, never, never>
  readonly concealment: Schema.Codec<TemplateExpr, TemplateExpr, never, never>
  readonly decisionTime: Schema.Codec<TemplateExpr, TemplateExpr, never, never>
}>

AccessEmit (type alias)

Signature

type AccessEmit = typeof AccessEmit.Type

ArgPattern

A builder takes one object literal ({ capability, decisionTime }) or positional literal arguments.

Signature

declare const ArgPattern: Schema.TaggedUnion<{
  readonly Object: Schema.TaggedStruct<
    "Object",
    {
      readonly fields: Schema.$Array<
        Schema.Struct<{
          readonly name: Schema.String
          readonly kind: Schema.Literals<readonly ["string", "strings", "boolean"]>
          readonly required: Schema.Boolean
          readonly default: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>
        }>
      >
    }
  >
  readonly Positional: Schema.TaggedStruct<
    "Positional",
    {
      readonly params: Schema.$Array<
        Schema.Struct<{
          readonly name: Schema.String
          readonly kind: Schema.Literals<readonly ["string", "strings", "boolean"]>
          readonly required: Schema.Boolean
          readonly default: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>
        }>
      >
    }
  >
}>

ArgPattern (type alias)

Signature

type ArgPattern = typeof ArgPattern.Type

ArgSpec

One argument of a registered builder call: its name, the literal kind it accepts, and its default.

Signature

declare const ArgSpec: Schema.Struct<{
  readonly name: Schema.String
  readonly kind: Schema.Literals<readonly ["string", "strings", "boolean"]>
  readonly required: Schema.Boolean
  readonly default: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>
}>

ArgSpec (type alias)

Signature

type ArgSpec = typeof ArgSpec.Type

LiftRule

The lift rules. Schema-valued slots are SchemaRefs and function-valued slots SymbolRefs, exactly the references the IR records, so a rule can never name a symbol the IR cannot hold.

  • SuccessWrapper: callee(S) stands for success S plus the response headers, status and conditional flag of the helper. With schema set the helper takes no schema argument and stands for that schema (spec 0019 §0.5: the body-less HttpApiSchema.NoContent family).
  • NoSchemaSuccess: callee(...) is a success helper whose body has no Schema (spec 0019 §3.3: the document body of a runtime content type). It makes EFFX3007 the cause of its endpoint, not EFFX3006.
  • ProblemRegistry: response(union) where union is union(identifier, [codes]) stands for Http.Problems { registry, codes, identifier }. The generated spelling registry(identifier, [codes]) is recognized through the same rule.
  • Metadata: callee(summary, description) and the generated annotator({ … }) stand for the endpoint metadata with that annotator.
  • Access: apply(endpoint, callee(args)) (or callee(args) alone when apply is absent) stands for Http.Access; the generated annotator({ … }) spelling is recognized through the same rule.

Signature

declare const LiftRule: Schema.TaggedUnion<{
  readonly SuccessWrapper: Schema.TaggedStruct<
    "SuccessWrapper",
    {
      readonly callee: Schema.Struct<{
        readonly module: Schema.String
        readonly export: Schema.String
        readonly member: Schema.optionalKey<Schema.String>
      }>
      readonly schema: Schema.optionalKey<
        Schema.Struct<{
          readonly module: Schema.String
          readonly export: Schema.String
          readonly symbolId: Schema.brand<Schema.String, "effx/StableId">
        }>
      >
      readonly responseHeaders: Schema.optionalKey<
        Schema.Struct<{
          readonly module: Schema.String
          readonly export: Schema.String
          readonly symbolId: Schema.brand<Schema.String, "effx/StableId">
        }>
      >
      readonly conditional: Schema.optionalKey<Schema.Literal<true>>
      readonly status: Schema.optionalKey<Schema.Int>
    }
  >
  readonly NoSchemaSuccess: Schema.TaggedStruct<
    "NoSchemaSuccess",
    {
      readonly callee: Schema.Struct<{
        readonly module: Schema.String
        readonly export: Schema.String
        readonly member: Schema.optionalKey<Schema.String>
      }>
    }
  >
  readonly ProblemRegistry: Schema.TaggedStruct<
    "ProblemRegistry",
    {
      readonly response: Schema.Struct<{
        readonly module: Schema.String
        readonly export: Schema.String
        readonly member: Schema.optionalKey<Schema.String>
      }>
      readonly union: Schema.Struct<{
        readonly module: Schema.String
        readonly export: Schema.String
        readonly member: Schema.optionalKey<Schema.String>
      }>
      readonly registry: Schema.Struct<{
        readonly module: Schema.String
        readonly export: Schema.String
        readonly member: Schema.optionalKey<Schema.String>
      }>
    }
  >
  readonly Metadata: Schema.TaggedStruct<
    "Metadata",
    {
      readonly callee: Schema.Struct<{
        readonly module: Schema.String
        readonly export: Schema.String
        readonly member: Schema.optionalKey<Schema.String>
      }>
      readonly annotator: Schema.Struct<{
        readonly module: Schema.String
        readonly export: Schema.String
        readonly member: Schema.optionalKey<Schema.String>
      }>
      readonly positional: Schema.$Array<Schema.Literals<readonly ["summary", "description"]>>
    }
  >
  readonly Access: Schema.TaggedStruct<
    "Access",
    {
      readonly callee: Schema.Struct<{
        readonly module: Schema.String
        readonly export: Schema.String
        readonly member: Schema.optionalKey<Schema.String>
      }>
      readonly apply: Schema.optionalKey<
        Schema.Struct<{
          readonly module: Schema.String
          readonly export: Schema.String
          readonly member: Schema.optionalKey<Schema.String>
        }>
      >
      readonly annotator: Schema.Struct<{
        readonly module: Schema.String
        readonly export: Schema.String
        readonly member: Schema.optionalKey<Schema.String>
      }>
      readonly arguments: Schema.TaggedUnion<{
        readonly Object: Schema.TaggedStruct<
          "Object",
          {
            readonly fields: Schema.$Array<
              Schema.Struct<{
                readonly name: Schema.String
                readonly kind: Schema.Literals<readonly ["string", "strings", "boolean"]>
                readonly required: Schema.Boolean
                readonly default: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>
              }>
            >
          }
        >
        readonly Positional: Schema.TaggedStruct<
          "Positional",
          {
            readonly params: Schema.$Array<
              Schema.Struct<{
                readonly name: Schema.String
                readonly kind: Schema.Literals<readonly ["string", "strings", "boolean"]>
                readonly required: Schema.Boolean
                readonly default: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>
              }>
            >
          }
        >
      }>
      readonly resolver: Schema.Codec<TemplateExpr, TemplateExpr, never, never>
      readonly emit: Schema.Struct<{
        readonly exposure: Schema.Codec<TemplateExpr, TemplateExpr, never, never>
        readonly acceptedCredentials: Schema.Codec<TemplateExpr, TemplateExpr, never, never>
        readonly principalKinds: Schema.Codec<TemplateExpr, TemplateExpr, never, never>
        readonly capabilities: Schema.Codec<TemplateExpr, TemplateExpr, never, never>
        readonly requirements: Schema.Codec<TemplateExpr, TemplateExpr, never, never>
        readonly concealment: Schema.Codec<TemplateExpr, TemplateExpr, never, never>
        readonly decisionTime: Schema.Codec<TemplateExpr, TemplateExpr, never, never>
      }>
    }
  >
}>

LiftRule (type alias)

Signature

type LiftRule = typeof LiftRule.Type

TemplateExpr

Signature

declare const TemplateExpr: Schema.Codec<TemplateExpr, TemplateExpr, never, never>

TemplateExpr (type alias)

A closed, total expression language over the literal arguments of one builder call (spec 0019 §5.2: $arg, $const, $ifPresent, plus the few forms the four mono-web access builders need). It evaluates to JSON only; it has no loops, no application symbols and no evaluation of source.

Signature

type TemplateExpr =
  | { readonly _tag: "Const"; readonly value: Schema.Json }
  | { readonly _tag: "Arg"; readonly name: string }
  | {
      readonly _tag: "IfPresent"
      readonly arg: string
      readonly present: TemplateExpr
      readonly absent: TemplateExpr
    }
  | {
      readonly _tag: "IfTrue"
      readonly arg: string
      readonly whenTrue: TemplateExpr
      readonly whenFalse: TemplateExpr
    }
  | { readonly _tag: "Object"; readonly fields: ReadonlyArray<TemplateField> }
  | { readonly _tag: "Array"; readonly items: ReadonlyArray<TemplateExpr> }
  | { readonly _tag: "Concat"; readonly parts: ReadonlyArray<TemplateExpr> }
  | { readonly _tag: "Map"; readonly arg: string; readonly body: TemplateExpr }
  | { readonly _tag: "Item" }

TemplateField (interface)

One entry of an object literal built by a template.

Signature

export interface TemplateField {
  readonly key: string
  readonly value: TemplateExpr
}

On this page