effx
API reference@effx/ir

canonical

API reference for @effx/ir/canonical

canonical.ts overview


Exports Grouped by Category


utils

JsonCodec

Schema-derived JSON codec for the IR; the only place the wire shape is defined.

Signature

declare const JsonCodec: Schema.toCodecJson<
  Schema.Struct<{
    readonly format: Schema.Literal<"effx-ir">
    readonly version: Schema.Literal<2>
    readonly nodes: Schema.$Array<
      Schema.TaggedUnion<{
        readonly Schema: Schema.TaggedStruct<
          "Schema",
          {
            readonly id: Schema.brand<Schema.String, "effx/StableId">
            readonly ref: Schema.Struct<{
              readonly module: Schema.String
              readonly export: Schema.String
              readonly symbolId: Schema.brand<Schema.String, "effx/StableId">
            }>
          }
        >
        readonly Model: Schema.TaggedStruct<
          "Model",
          {
            readonly id: Schema.brand<Schema.String, "effx/StableId">
            readonly name: Schema.String
            readonly schema: Schema.Struct<{
              readonly module: Schema.String
              readonly export: Schema.String
              readonly symbolId: Schema.brand<Schema.String, "effx/StableId">
            }>
            readonly table: Schema.optionalKey<Schema.String>
            readonly views: Schema.$Array<
              Schema.Struct<{
                readonly name: Schema.String
                readonly schema: Schema.Struct<{
                  readonly module: Schema.String
                  readonly export: Schema.String
                  readonly symbolId: Schema.brand<Schema.String, "effx/StableId">
                }>
              }>
            >
          }
        >
        readonly Service: Schema.TaggedStruct<
          "Service",
          {
            readonly id: Schema.brand<Schema.String, "effx/StableId">
            readonly name: Schema.String
            readonly symbol: Schema.Struct<{
              readonly module: Schema.String
              readonly export: Schema.String
              readonly member: Schema.optionalKey<Schema.String>
            }>
          }
        >
        readonly Operation: Schema.TaggedStruct<
          "Operation",
          {
            readonly id: Schema.brand<Schema.String, "effx/StableId">
            readonly name: Schema.String
            readonly kind: Schema.Literals<readonly ["Query", "Command"]>
            readonly input: Schema.Struct<{
              readonly module: Schema.String
              readonly export: Schema.String
              readonly symbolId: Schema.brand<Schema.String, "effx/StableId">
            }>
            readonly success: Schema.Struct<{
              readonly module: Schema.String
              readonly export: Schema.String
              readonly symbolId: Schema.brand<Schema.String, "effx/StableId">
            }>
            readonly errors: Schema.Struct<{
              readonly values: Schema.$Array<
                Schema.Struct<{
                  readonly module: Schema.String
                  readonly export: Schema.String
                  readonly symbolId: Schema.brand<Schema.String, "effx/StableId">
                }>
              >
              readonly inferred: Schema.Boolean
            }>
            readonly requirements: Schema.Struct<{
              readonly values: Schema.$Array<Schema.brand<Schema.String, "effx/StableId">>
              readonly inferred: Schema.Boolean
            }>
            readonly binding: Schema.optionalKey<Schema.Literal<"external">>
            readonly handler: Schema.optionalKey<
              Schema.Struct<{
                readonly module: Schema.String
                readonly export: Schema.String
                readonly member: Schema.optionalKey<Schema.String>
              }>
            >
          }
        >
        readonly HttpGroup: Schema.TaggedStruct<
          "HttpGroup",
          {
            readonly id: Schema.brand<Schema.String, "effx/StableId">
            readonly root: Schema.String
            readonly rootSymbol: Schema.optionalKey<
              Schema.Struct<{
                readonly module: Schema.String
                readonly export: Schema.String
                readonly member: Schema.optionalKey<Schema.String>
              }>
            >
            readonly group: Schema.String
            readonly title: Schema.optionalKey<Schema.String>
            readonly description: Schema.optionalKey<Schema.String>
            readonly displayName: Schema.optionalKey<Schema.String>
          }
        >
        readonly Capability: Schema.TaggedStruct<
          "Capability",
          {
            readonly id: Schema.brand<Schema.String, "effx/StableId">
            readonly name: Schema.String
            readonly resource: Schema.brand<Schema.String, "effx/StableId">
            readonly focus: Schema.optionalKey<Schema.brand<Schema.String, "effx/StableId">>
          }
        >
        readonly Focus: Schema.TaggedStruct<
          "Focus",
          {
            readonly id: Schema.brand<Schema.String, "effx/StableId">
            readonly root: Schema.brand<Schema.String, "effx/StableId">
            readonly path: Schema.$Array<Schema.String>
          }
        >
        readonly Exposure: Schema.TaggedStruct<
          "Exposure",
          {
            readonly id: Schema.brand<Schema.String, "effx/StableId">
            readonly operation: Schema.brand<Schema.String, "effx/StableId">
            readonly transport: Schema.Union<
              readonly [
                Schema.TaggedStruct<
                  "http",
                  {
                    readonly method: Schema.Literals<readonly ["GET", "POST", "PUT", "PATCH", "DELETE"]>
                    readonly path: Schema.String
                  }
                >,
                Schema.TaggedStruct<"rpc", { readonly name: Schema.String }>,
                Schema.TaggedStruct<"cli", { readonly command: Schema.$Array<Schema.String> }>
              ]
            >
          }
        >
        readonly Extension: Schema.TaggedStruct<
          "Extension",
          {
            readonly id: Schema.brand<Schema.String, "effx/StableId">
            readonly extension: Schema.String
            readonly tag: Schema.String
            readonly data: Schema.Codec<Schema.Json, Schema.Json, never, never>
          }
        >
      }>
    >
    readonly edges: Schema.$Array<
      Schema.Struct<{
        readonly kind: Schema.Literals<
          readonly [
            "InputOf",
            "SuccessOf",
            "ErrorOf",
            "Requires",
            "AuthorizedBy",
            "Focuses",
            "ExposedAs",
            "PersistsAs",
            "ViewOf",
            "ExtensionOf"
          ]
        >
        readonly from: Schema.brand<Schema.String, "effx/StableId">
        readonly to: Schema.brand<Schema.String, "effx/StableId">
        readonly qualifier: Schema.optionalKey<Schema.String>
      }>
    >
  }>
>

StringCodec

Signature

declare const StringCodec: Schema.fromJsonString<
  Schema.toCodecJson<
    Schema.Struct<{
      readonly format: Schema.Literal<"effx-ir">
      readonly version: Schema.Literal<2>
      readonly nodes: Schema.$Array<
        Schema.TaggedUnion<{
          readonly Schema: Schema.TaggedStruct<
            "Schema",
            {
              readonly id: Schema.brand<Schema.String, "effx/StableId">
              readonly ref: Schema.Struct<{
                readonly module: Schema.String
                readonly export: Schema.String
                readonly symbolId: Schema.brand<Schema.String, "effx/StableId">
              }>
            }
          >
          readonly Model: Schema.TaggedStruct<
            "Model",
            {
              readonly id: Schema.brand<Schema.String, "effx/StableId">
              readonly name: Schema.String
              readonly schema: Schema.Struct<{
                readonly module: Schema.String
                readonly export: Schema.String
                readonly symbolId: Schema.brand<Schema.String, "effx/StableId">
              }>
              readonly table: Schema.optionalKey<Schema.String>
              readonly views: Schema.$Array<
                Schema.Struct<{
                  readonly name: Schema.String
                  readonly schema: Schema.Struct<{
                    readonly module: Schema.String
                    readonly export: Schema.String
                    readonly symbolId: Schema.brand<Schema.String, "effx/StableId">
                  }>
                }>
              >
            }
          >
          readonly Service: Schema.TaggedStruct<
            "Service",
            {
              readonly id: Schema.brand<Schema.String, "effx/StableId">
              readonly name: Schema.String
              readonly symbol: Schema.Struct<{
                readonly module: Schema.String
                readonly export: Schema.String
                readonly member: Schema.optionalKey<Schema.String>
              }>
            }
          >
          readonly Operation: Schema.TaggedStruct<
            "Operation",
            {
              readonly id: Schema.brand<Schema.String, "effx/StableId">
              readonly name: Schema.String
              readonly kind: Schema.Literals<readonly ["Query", "Command"]>
              readonly input: Schema.Struct<{
                readonly module: Schema.String
                readonly export: Schema.String
                readonly symbolId: Schema.brand<Schema.String, "effx/StableId">
              }>
              readonly success: Schema.Struct<{
                readonly module: Schema.String
                readonly export: Schema.String
                readonly symbolId: Schema.brand<Schema.String, "effx/StableId">
              }>
              readonly errors: Schema.Struct<{
                readonly values: Schema.$Array<
                  Schema.Struct<{
                    readonly module: Schema.String
                    readonly export: Schema.String
                    readonly symbolId: Schema.brand<Schema.String, "effx/StableId">
                  }>
                >
                readonly inferred: Schema.Boolean
              }>
              readonly requirements: Schema.Struct<{
                readonly values: Schema.$Array<Schema.brand<Schema.String, "effx/StableId">>
                readonly inferred: Schema.Boolean
              }>
              readonly binding: Schema.optionalKey<Schema.Literal<"external">>
              readonly handler: Schema.optionalKey<
                Schema.Struct<{
                  readonly module: Schema.String
                  readonly export: Schema.String
                  readonly member: Schema.optionalKey<Schema.String>
                }>
              >
            }
          >
          readonly HttpGroup: Schema.TaggedStruct<
            "HttpGroup",
            {
              readonly id: Schema.brand<Schema.String, "effx/StableId">
              readonly root: Schema.String
              readonly rootSymbol: Schema.optionalKey<
                Schema.Struct<{
                  readonly module: Schema.String
                  readonly export: Schema.String
                  readonly member: Schema.optionalKey<Schema.String>
                }>
              >
              readonly group: Schema.String
              readonly title: Schema.optionalKey<Schema.String>
              readonly description: Schema.optionalKey<Schema.String>
              readonly displayName: Schema.optionalKey<Schema.String>
            }
          >
          readonly Capability: Schema.TaggedStruct<
            "Capability",
            {
              readonly id: Schema.brand<Schema.String, "effx/StableId">
              readonly name: Schema.String
              readonly resource: Schema.brand<Schema.String, "effx/StableId">
              readonly focus: Schema.optionalKey<Schema.brand<Schema.String, "effx/StableId">>
            }
          >
          readonly Focus: Schema.TaggedStruct<
            "Focus",
            {
              readonly id: Schema.brand<Schema.String, "effx/StableId">
              readonly root: Schema.brand<Schema.String, "effx/StableId">
              readonly path: Schema.$Array<Schema.String>
            }
          >
          readonly Exposure: Schema.TaggedStruct<
            "Exposure",
            {
              readonly id: Schema.brand<Schema.String, "effx/StableId">
              readonly operation: Schema.brand<Schema.String, "effx/StableId">
              readonly transport: Schema.Union<
                readonly [
                  Schema.TaggedStruct<
                    "http",
                    {
                      readonly method: Schema.Literals<readonly ["GET", "POST", "PUT", "PATCH", "DELETE"]>
                      readonly path: Schema.String
                    }
                  >,
                  Schema.TaggedStruct<"rpc", { readonly name: Schema.String }>,
                  Schema.TaggedStruct<"cli", { readonly command: Schema.$Array<Schema.String> }>
                ]
              >
            }
          >
          readonly Extension: Schema.TaggedStruct<
            "Extension",
            {
              readonly id: Schema.brand<Schema.String, "effx/StableId">
              readonly extension: Schema.String
              readonly tag: Schema.String
              readonly data: Schema.Codec<Schema.Json, Schema.Json, never, never>
            }
          >
        }>
      >
      readonly edges: Schema.$Array<
        Schema.Struct<{
          readonly kind: Schema.Literals<
            readonly [
              "InputOf",
              "SuccessOf",
              "ErrorOf",
              "Requires",
              "AuthorizedBy",
              "Focuses",
              "ExposedAs",
              "PersistsAs",
              "ViewOf",
              "ExtensionOf"
            ]
          >
          readonly from: Schema.brand<Schema.String, "effx/StableId">
          readonly to: Schema.brand<Schema.String, "effx/StableId">
          readonly qualifier: Schema.optionalKey<Schema.String>
        }>
      >
    }>
  >
>

canonical

Canonical JSON text of the normalized IR. Idempotent: canonical(decode(canonical(x))) == canonical(x).

Signature

declare const canonical: (ir: ApplicationIR) => string

canonicalJson

Signature

declare const canonicalJson: (json: Schema.Json) => string

decode

Both persisted JSON versions decode to v2; malformed versions fail as Schema errors.

Signature

declare const decode: (
  input: unknown,
  options?: ParseOptions | undefined
) => Effect.Effect<
  {
    readonly format: "effx-ir"
    readonly version: 2
    readonly nodes: ReadonlyArray<
      | {
          readonly _tag: "Schema"
          readonly id: string & Brand<"effx/StableId">
          readonly ref: {
            readonly module: string
            readonly export: string
            readonly symbolId: string & Brand<"effx/StableId">
          }
        }
      | {
          readonly views: ReadonlyArray<{
            readonly name: string
            readonly schema: {
              readonly module: string
              readonly export: string
              readonly symbolId: string & Brand<"effx/StableId">
            }
          }>
          readonly name: string
          readonly schema: {
            readonly module: string
            readonly export: string
            readonly symbolId: string & Brand<"effx/StableId">
          }
          readonly _tag: "Model"
          readonly id: string & Brand<"effx/StableId">
          readonly table?: string | undefined
        }
      | {
          readonly _tag: "Service"
          readonly id: string & Brand<"effx/StableId">
          readonly name: string
          readonly symbol: { readonly module: string; readonly export: string; readonly member?: string | undefined }
        }
      | {
          readonly name: string
          readonly errors: {
            readonly values: ReadonlyArray<{
              readonly module: string
              readonly export: string
              readonly symbolId: string & Brand<"effx/StableId">
            }>
            readonly inferred: boolean
          }
          readonly requirements: {
            readonly values: ReadonlyArray<string & Brand<"effx/StableId">>
            readonly inferred: boolean
          }
          readonly _tag: "Operation"
          readonly id: string & Brand<"effx/StableId">
          readonly kind: "Query" | "Command"
          readonly input: {
            readonly module: string
            readonly export: string
            readonly symbolId: string & Brand<"effx/StableId">
          }
          readonly success: {
            readonly module: string
            readonly export: string
            readonly symbolId: string & Brand<"effx/StableId">
          }
          readonly binding?: "external" | undefined
          readonly handler?:
            { readonly module: string; readonly export: string; readonly member?: string | undefined } | undefined
        }
      | {
          readonly _tag: "HttpGroup"
          readonly id: string & Brand<"effx/StableId">
          readonly root: string
          readonly group: string
          readonly rootSymbol?:
            { readonly module: string; readonly export: string; readonly member?: string | undefined } | undefined
          readonly title?: string | undefined
          readonly description?: string | undefined
          readonly displayName?: string | undefined
        }
      | {
          readonly name: string
          readonly _tag: "Capability"
          readonly id: string & Brand<"effx/StableId">
          readonly resource: string & Brand<"effx/StableId">
          readonly focus?: (string & Brand<"effx/StableId">) | undefined
        }
      | {
          readonly _tag: "Focus"
          readonly id: string & Brand<"effx/StableId">
          readonly root: string & Brand<"effx/StableId">
          readonly path: ReadonlyArray<string>
        }
      | {
          readonly _tag: "Exposure"
          readonly id: string & Brand<"effx/StableId">
          readonly operation: string & Brand<"effx/StableId">
          readonly transport:
            | {
                readonly _tag: "http"
                readonly method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE"
                readonly path: string
              }
            | { readonly _tag: "rpc"; readonly name: string }
            | { readonly _tag: "cli"; readonly command: ReadonlyArray<string> }
        }
      | {
          readonly _tag: "Extension"
          readonly id: string & Brand<"effx/StableId">
          readonly extension: string
          readonly tag: string
          readonly data: Schema.Json
        }
    >
    readonly edges: ReadonlyArray<{
      readonly kind:
        | "InputOf"
        | "SuccessOf"
        | "ErrorOf"
        | "Requires"
        | "AuthorizedBy"
        | "Focuses"
        | "ExposedAs"
        | "PersistsAs"
        | "ViewOf"
        | "ExtensionOf"
      readonly from: string & Brand<"effx/StableId">
      readonly to: string & Brand<"effx/StableId">
      readonly qualifier?: string | undefined
    }>
  },
  Schema.SchemaError,
  never
>

decodeString

JSON text in either persisted version (any whitespace/key order).

Signature

declare const decodeString: (
  input: unknown,
  options?: ParseOptions | undefined
) => Effect.Effect<
  {
    readonly format: "effx-ir"
    readonly version: 2
    readonly nodes: ReadonlyArray<
      | {
          readonly _tag: "Schema"
          readonly id: string & Brand<"effx/StableId">
          readonly ref: {
            readonly module: string
            readonly export: string
            readonly symbolId: string & Brand<"effx/StableId">
          }
        }
      | {
          readonly views: ReadonlyArray<{
            readonly name: string
            readonly schema: {
              readonly module: string
              readonly export: string
              readonly symbolId: string & Brand<"effx/StableId">
            }
          }>
          readonly name: string
          readonly schema: {
            readonly module: string
            readonly export: string
            readonly symbolId: string & Brand<"effx/StableId">
          }
          readonly _tag: "Model"
          readonly id: string & Brand<"effx/StableId">
          readonly table?: string | undefined
        }
      | {
          readonly _tag: "Service"
          readonly id: string & Brand<"effx/StableId">
          readonly name: string
          readonly symbol: { readonly module: string; readonly export: string; readonly member?: string | undefined }
        }
      | {
          readonly name: string
          readonly errors: {
            readonly values: ReadonlyArray<{
              readonly module: string
              readonly export: string
              readonly symbolId: string & Brand<"effx/StableId">
            }>
            readonly inferred: boolean
          }
          readonly requirements: {
            readonly values: ReadonlyArray<string & Brand<"effx/StableId">>
            readonly inferred: boolean
          }
          readonly _tag: "Operation"
          readonly id: string & Brand<"effx/StableId">
          readonly kind: "Query" | "Command"
          readonly input: {
            readonly module: string
            readonly export: string
            readonly symbolId: string & Brand<"effx/StableId">
          }
          readonly success: {
            readonly module: string
            readonly export: string
            readonly symbolId: string & Brand<"effx/StableId">
          }
          readonly binding?: "external" | undefined
          readonly handler?:
            { readonly module: string; readonly export: string; readonly member?: string | undefined } | undefined
        }
      | {
          readonly _tag: "HttpGroup"
          readonly id: string & Brand<"effx/StableId">
          readonly root: string
          readonly group: string
          readonly rootSymbol?:
            { readonly module: string; readonly export: string; readonly member?: string | undefined } | undefined
          readonly title?: string | undefined
          readonly description?: string | undefined
          readonly displayName?: string | undefined
        }
      | {
          readonly name: string
          readonly _tag: "Capability"
          readonly id: string & Brand<"effx/StableId">
          readonly resource: string & Brand<"effx/StableId">
          readonly focus?: (string & Brand<"effx/StableId">) | undefined
        }
      | {
          readonly _tag: "Focus"
          readonly id: string & Brand<"effx/StableId">
          readonly root: string & Brand<"effx/StableId">
          readonly path: ReadonlyArray<string>
        }
      | {
          readonly _tag: "Exposure"
          readonly id: string & Brand<"effx/StableId">
          readonly operation: string & Brand<"effx/StableId">
          readonly transport:
            | {
                readonly _tag: "http"
                readonly method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE"
                readonly path: string
              }
            | { readonly _tag: "rpc"; readonly name: string }
            | { readonly _tag: "cli"; readonly command: ReadonlyArray<string> }
        }
      | {
          readonly _tag: "Extension"
          readonly id: string & Brand<"effx/StableId">
          readonly extension: string
          readonly tag: string
          readonly data: Schema.Json
        }
    >
    readonly edges: ReadonlyArray<{
      readonly kind:
        | "InputOf"
        | "SuccessOf"
        | "ErrorOf"
        | "Requires"
        | "AuthorizedBy"
        | "Focuses"
        | "ExposedAs"
        | "PersistsAs"
        | "ViewOf"
        | "ExtensionOf"
      readonly from: string & Brand<"effx/StableId">
      readonly to: string & Brand<"effx/StableId">
      readonly qualifier?: string | undefined
    }>
  },
  Schema.SchemaError,
  never
>

encode

ApplicationIR.Type is the Schema-derived JSON wire shape, so encoding is a pure identity projection.

Signature

declare const encode: (ir: ApplicationIR) => Schema.Json

semanticHash

Lowercase hex sha-256 of the canonical UTF-8 bytes, via the platform Crypto service.

Signature

declare const semanticHash: (ir: {
  readonly format: "effx-ir"
  readonly version: 2
  readonly nodes: ReadonlyArray<
    | {
        readonly _tag: "Schema"
        readonly id: string & Brand<"effx/StableId">
        readonly ref: {
          readonly module: string
          readonly export: string
          readonly symbolId: string & Brand<"effx/StableId">
        }
      }
    | {
        readonly views: ReadonlyArray<{
          readonly name: string
          readonly schema: {
            readonly module: string
            readonly export: string
            readonly symbolId: string & Brand<"effx/StableId">
          }
        }>
        readonly name: string
        readonly schema: {
          readonly module: string
          readonly export: string
          readonly symbolId: string & Brand<"effx/StableId">
        }
        readonly _tag: "Model"
        readonly id: string & Brand<"effx/StableId">
        readonly table?: string | undefined
      }
    | {
        readonly _tag: "Service"
        readonly id: string & Brand<"effx/StableId">
        readonly name: string
        readonly symbol: { readonly module: string; readonly export: string; readonly member?: string | undefined }
      }
    | {
        readonly name: string
        readonly errors: {
          readonly values: ReadonlyArray<{
            readonly module: string
            readonly export: string
            readonly symbolId: string & Brand<"effx/StableId">
          }>
          readonly inferred: boolean
        }
        readonly requirements: {
          readonly values: ReadonlyArray<string & Brand<"effx/StableId">>
          readonly inferred: boolean
        }
        readonly _tag: "Operation"
        readonly id: string & Brand<"effx/StableId">
        readonly kind: "Query" | "Command"
        readonly input: {
          readonly module: string
          readonly export: string
          readonly symbolId: string & Brand<"effx/StableId">
        }
        readonly success: {
          readonly module: string
          readonly export: string
          readonly symbolId: string & Brand<"effx/StableId">
        }
        readonly binding?: "external" | undefined
        readonly handler?:
          { readonly module: string; readonly export: string; readonly member?: string | undefined } | undefined
      }
    | {
        readonly _tag: "HttpGroup"
        readonly id: string & Brand<"effx/StableId">
        readonly root: string
        readonly group: string
        readonly rootSymbol?:
          { readonly module: string; readonly export: string; readonly member?: string | undefined } | undefined
        readonly title?: string | undefined
        readonly description?: string | undefined
        readonly displayName?: string | undefined
      }
    | {
        readonly name: string
        readonly _tag: "Capability"
        readonly id: string & Brand<"effx/StableId">
        readonly resource: string & Brand<"effx/StableId">
        readonly focus?: (string & Brand<"effx/StableId">) | undefined
      }
    | {
        readonly _tag: "Focus"
        readonly id: string & Brand<"effx/StableId">
        readonly root: string & Brand<"effx/StableId">
        readonly path: ReadonlyArray<string>
      }
    | {
        readonly _tag: "Exposure"
        readonly id: string & Brand<"effx/StableId">
        readonly operation: string & Brand<"effx/StableId">
        readonly transport:
          | {
              readonly _tag: "http"
              readonly method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE"
              readonly path: string
            }
          | { readonly _tag: "rpc"; readonly name: string }
          | { readonly _tag: "cli"; readonly command: ReadonlyArray<string> }
      }
    | {
        readonly _tag: "Extension"
        readonly id: string & Brand<"effx/StableId">
        readonly extension: string
        readonly tag: string
        readonly data: Schema.Json
      }
  >
  readonly edges: ReadonlyArray<{
    readonly kind:
      | "InputOf"
      | "SuccessOf"
      | "ErrorOf"
      | "Requires"
      | "AuthorizedBy"
      | "Focuses"
      | "ExposedAs"
      | "PersistsAs"
      | "ViewOf"
      | "ExtensionOf"
    readonly from: string & Brand<"effx/StableId">
    readonly to: string & Brand<"effx/StableId">
    readonly qualifier?: string | undefined
  }>
}) => Effect.Effect<string, PlatformError, Crypto.Crypto>

On this page