{"version":3,"file":"index.mjs","names":[],"sources":["../src/author.ts","../src/model.ts"],"sourcesContent":["import type {\n  ApplicationMarquette,\n  BackendId,\n  CapabilityDefinition,\n  CapabilityId,\n  EnvironmentId,\n  MarquetteBackend,\n  MarquetteEnvironment,\n  MarquetteProtocol,\n  MarquetteRoute,\n  ProtocolId,\n  ServerEnvironmentId,\n  TargetId,\n} from \"./model.js\";\n\n/**\n * Cross-reference constraints derived from the literals in one marquette.\n *\n * Keeping this type separate makes editor diagnostics point at the authored\n * reference instead of widening every identifier to `string`.\n */\nexport type MarquetteReferenceConstraints<Marquette extends ApplicationMarquette> = {\n  readonly capabilities?: {\n    readonly [Id in CapabilityId<Marquette>]: CapabilityDefinition & { readonly id: Id };\n  };\n  readonly environments?: readonly (MarquetteEnvironment<string, EnvironmentId<Marquette>> & {\n    readonly capabilities?: readonly CapabilityId<Marquette>[];\n    readonly target: TargetId<Marquette>;\n  })[];\n  readonly backends?: readonly (MarquetteBackend<string, ServerEnvironmentId<Marquette>> & {\n    readonly capabilities?: readonly CapabilityId<Marquette>[];\n  })[];\n  readonly protocols?: readonly (MarquetteProtocol<string, BackendId<Marquette>> & {\n    readonly capabilities?: readonly CapabilityId<Marquette>[];\n  })[];\n  readonly routes?: readonly (MarquetteRoute<\n    string,\n    EnvironmentId<Marquette>,\n    BackendId<Marquette>,\n    ProtocolId<Marquette>\n  > & { readonly capabilities?: readonly CapabilityId<Marquette>[] })[];\n};\n\n/**\n * Defines an application marquette while preserving every authored literal.\n *\n * Environment dependencies, backend owners, protocol owners, and route\n * references are checked against identifiers declared in the same object.\n * The function returns its input without allocation or runtime work.\n *\n * @example\n * ```ts\n * const app = defineApplicationMarquette({\n *   application: \"shop\",\n *   targets: [\"web\"],\n *   environments: [\n *     { id: \"web\", target: \"web\", consumer: \"client\", runtime: \"browser\" },\n *   ],\n *   routes: [\n *     { id: \"home\", path: \"/\", environment: \"web\", rendering: \"client\" },\n *   ],\n * });\n * ```\n */\nexport function defineApplicationMarquette<const Marquette extends ApplicationMarquette>(\n  marquette: Marquette & MarquetteReferenceConstraints<NoInfer<Marquette>>,\n): Marquette {\n  return marquette;\n}\n","/** Current serialized application-marquette format. */\nexport const MARQUETTE_FORMAT_VERSION = 1 as const;\n\n/** User-visible target produced by an application marquette. */\nexport type MarquetteTarget = \"web\" | \"native\" | \"desktop\" | \"terminal\";\n\n/** Runtime family that executes one environment. */\nexport type RuntimeFamily =\n  | \"browser\"\n  | \"javascript\"\n  | \"rust\"\n  | \"go\"\n  | \"jvm\"\n  | \"native\"\n  | \"desktop\"\n  | \"terminal\"\n  | \"external\";\n\n/** Side of the application graph that consumes an environment. */\nexport type EnvironmentConsumer = \"client\" | \"server\";\n\n/** Backend implementation family selected by an application. */\nexport type BackendFamily = \"javascript\" | \"rust\" | \"go\" | \"jvm\" | \"external\";\n\n/** Semantic family used by one data or procedure endpoint. */\nexport type ProtocolFamily = \"schema-query\" | \"typed-rpc\" | \"binary-rpc\";\n\n/** Rendering strategy selected for one route or target view. */\nexport type RenderingMode =\n  | \"client\"\n  | \"static\"\n  | \"server\"\n  | \"stream\"\n  | \"partial\"\n  | \"hybrid\"\n  | \"native\"\n  | \"desktop\"\n  | \"terminal\";\n\n/** Versioned capability understood by adapters and developer tools. */\nexport interface CapabilityDefinition {\n  /** Stable lowercase capability identifier. */\n  readonly id: string;\n  /** Summary shown by diagnostics, documentation, and AI tooling. */\n  readonly description: string;\n  /**\n   * Capability contract version.\n   *\n   * @default 1\n   */\n  readonly version?: number;\n}\n\n/** Independently transformed and cached application environment. */\nexport interface MarquetteEnvironment<\n  Id extends string = string,\n  DependencyId extends string = string,\n> {\n  /** Stable identifier, unique within the application. */\n  readonly id: Id;\n  /** User-visible target served by this environment. */\n  readonly target: MarquetteTarget;\n  /** Whether output is consumed by an end user or a trusted runtime. */\n  readonly consumer: EnvironmentConsumer;\n  /** Runtime family that executes the output. */\n  readonly runtime: RuntimeFamily;\n  /**\n   * Authored entry module.\n   *\n   * @default undefined\n   */\n  readonly entry?: string;\n  /**\n   * Environments that must build first.\n   *\n   * @default []\n   */\n  readonly dependsOn?: readonly DependencyId[];\n  /**\n   * Capabilities required from the environment adapter.\n   *\n   * @default []\n   */\n  readonly capabilities?: readonly string[];\n}\n\n/** Backend application or independently deployed service. */\nexport interface MarquetteBackend<\n  Id extends string = string,\n  EnvironmentId extends string = string,\n> {\n  /** Stable backend identifier. */\n  readonly id: Id;\n  /** Backend implementation family. */\n  readonly family: BackendFamily;\n  /**\n   * Server environment that owns local execution.\n   *\n   * @default undefined\n   */\n  readonly environment?: EnvironmentId;\n  /**\n   * Capabilities required from the backend adapter.\n   *\n   * @default []\n   */\n  readonly capabilities?: readonly string[];\n}\n\n/** Protocol endpoint exposed by a backend. */\nexport interface MarquetteProtocol<Id extends string = string, BackendId extends string = string> {\n  /** Stable endpoint identifier. */\n  readonly id: Id;\n  /** Protocol semantic family. */\n  readonly family: ProtocolFamily;\n  /** Backend that owns the endpoint. */\n  readonly backend: BackendId;\n  /**\n   * Capabilities required from the protocol adapter.\n   *\n   * @default []\n   */\n  readonly capabilities?: readonly string[];\n}\n\n/** Typed application route or target view. */\nexport interface MarquetteRoute<\n  Id extends string = string,\n  EnvironmentId extends string = string,\n  BackendId extends string = string,\n  ProtocolId extends string = string,\n> {\n  /** Stable identifier used by generated navigation APIs. */\n  readonly id: Id;\n  /** Logical path, always beginning with `/`. */\n  readonly path: `/${string}`;\n  /** Environment that owns the rendered route. */\n  readonly environment: EnvironmentId;\n  /** Rendering strategy used by the route. */\n  readonly rendering: RenderingMode;\n  /**\n   * Backend used by data loading, mutations, or server rendering.\n   *\n   * @default undefined\n   */\n  readonly backend?: BackendId;\n  /**\n   * Protocol endpoint used as the route data contract.\n   *\n   * @default undefined\n   */\n  readonly protocol?: ProtocolId;\n  /**\n   * Capabilities required by the route.\n   *\n   * @default []\n   */\n  readonly capabilities?: readonly string[];\n}\n\n/** Complete, versioned application marquette. */\nexport interface ApplicationMarquette<\n  Environments extends readonly MarquetteEnvironment[] = readonly MarquetteEnvironment[],\n  Backends extends readonly MarquetteBackend[] = readonly MarquetteBackend[],\n  Protocols extends readonly MarquetteProtocol[] = readonly MarquetteProtocol[],\n  Routes extends readonly MarquetteRoute[] = readonly MarquetteRoute[],\n> {\n  /**\n   * Serialized contract format.\n   *\n   * @default 1\n   */\n  readonly formatVersion?: typeof MARQUETTE_FORMAT_VERSION;\n  /** Stable lowercase application identifier. */\n  readonly application: string;\n  /**\n   * User-visible application targets.\n   *\n   * @default []\n   */\n  readonly targets?: readonly MarquetteTarget[];\n  /**\n   * Versioned capability definitions keyed by identifier.\n   *\n   * @default {}\n   */\n  readonly capabilities?: Readonly<Record<string, CapabilityDefinition>>;\n  /**\n   * Independently transformed application environments.\n   *\n   * @default []\n   */\n  readonly environments?: Environments;\n  /**\n   * Backend applications and services.\n   *\n   * @default []\n   */\n  readonly backends?: Backends;\n  /**\n   * Protocol endpoints.\n   *\n   * @default []\n   */\n  readonly protocols?: Protocols;\n  /**\n   * Typed routes and target views.\n   *\n   * @default []\n   */\n  readonly routes?: Routes;\n}\n\n/** Extracts identifiers only when a collection is present in the authored object. */\ntype DeclaredId<Marquette, Collection extends PropertyKey> = Marquette extends {\n  readonly [Key in Collection]: readonly { readonly id: infer Id extends string }[];\n}\n  ? Id\n  : never;\n\n/** Exact environment identifier union inferred from a marquette. */\nexport type EnvironmentId<Marquette extends ApplicationMarquette> = DeclaredId<\n  Marquette,\n  \"environments\"\n>;\n\n/** Exact server-owned environment identifier union inferred from a marquette. */\nexport type ServerEnvironmentId<Marquette extends ApplicationMarquette> = Marquette extends {\n  readonly environments: readonly (infer Environment)[];\n}\n  ? Environment extends {\n      readonly consumer: \"server\";\n      readonly id: infer Id extends string;\n    }\n    ? Id\n    : never\n  : never;\n\n/** Exact backend identifier union inferred from a marquette. */\nexport type BackendId<Marquette extends ApplicationMarquette> = DeclaredId<Marquette, \"backends\">;\n\n/** Exact protocol identifier union inferred from a marquette. */\nexport type ProtocolId<Marquette extends ApplicationMarquette> = DeclaredId<Marquette, \"protocols\">;\n\n/** Exact route identifier union inferred from a marquette. */\nexport type RouteId<Marquette extends ApplicationMarquette> = DeclaredId<Marquette, \"routes\">;\n\n/** Exact target union inferred from the authored target list. */\nexport type TargetId<Marquette extends ApplicationMarquette> = Marquette extends {\n  readonly targets: readonly (infer Target extends MarquetteTarget)[];\n}\n  ? Target\n  : never;\n\n/** Exact capability identifier union inferred from authored capability keys. */\nexport type CapabilityId<Marquette extends ApplicationMarquette> = Marquette extends {\n  readonly capabilities: Readonly<Record<infer Id extends string, CapabilityDefinition>>;\n}\n  ? Id\n  : never;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAgEA,SAAgB,2BACd,WACW;CACX,OAAO;AACT;;;;ACnEA,MAAa,2BAA2B"}