{"version":3,"file":"scope.mjs","names":["scopeKind.actions","serviceKind.specification","scopeKind.specification","scopeKind.scope_type","scopeKind.asset_type","logRead.notification","metricData.notification","startInitial.notification","scopeCreate.notification"],"sources":["../../contract/fixtures/scope-create.json","../../contract/fixtures/scope-start-initial.json","../../contract/fixtures/telemetry-log-read.json","../../contract/fixtures/telemetry-metric-data.json","../../contract/kinds/scope.json","../src/kinds/scope/table.ts","../src/kinds/scope/input.ts","../src/kinds/scope/define.ts"],"sourcesContent":["","","","","","/**\n * A scope's actions as the platform defines them (contract/kinds/scope.json).\n * A well-known action is the platform's: its type, whether it is retried and\n * the parameters it is sent come from the table, and one the table answers\n * with the lifecycle declares the scope's attributes as its results, since the\n * platform copies into the scope's attributes only the result keys an\n * action's results schema declares. Its title names its run on the trace,\n * never what is published. A telemetry action, any key under a telemetry\n * prefix, is the platform's too, with no definition of its own: it is\n * published as any custom action is (contract/kinds/service.json `action`).\n */\n\nimport scopeKind from \"../../../../contract/kinds/scope.json\" with { type: \"json\" };\n\n/** The actions the platform sends a scope today, by the key each is bound to (`[ScopeActions.CREATE_SCOPE]: …`): the contract's well-known actions, then its telemetry ones. */\nexport const ScopeActions = {\n  CREATE_SCOPE: \"create-scope\",\n  DELETE_SCOPE: \"delete-scope\",\n  UPDATE_SCOPE: \"update-scope\",\n  START_INITIAL: \"start-initial\",\n  START_BLUE_GREEN: \"start-blue-green\",\n  SWITCH_TRAFFIC: \"switch-traffic\",\n  FINALIZE_DEPLOYMENT: \"finalize-deployment\",\n  FINALIZE_BLUE_GREEN: \"finalize-blue-green\",\n  ROLLBACK_DEPLOYMENT: \"rollback-deployment\",\n  DELETE_DEPLOYMENT: \"delete-deployment\",\n  DIAGNOSE_SCOPE: \"diagnose-scope\",\n  DIAGNOSE_DEPLOYMENT: \"diagnose-deployment\",\n  KILL_INSTANCES: \"kill-instances\",\n  SET_DESIRED_INSTANCE_COUNT: \"set-desired-instance-count\",\n  PAUSE_AUTOSCALING: \"pause-autoscaling\",\n  RESUME_AUTOSCALING: \"resume-autoscaling\",\n  RESTART_PODS: \"restart-pods\",\n  LOG_READ: \"log:read\",\n  METRIC_LIST: \"metric:list\",\n  METRIC_DATA: \"metric:data\",\n  INSTANCE_DATA: \"instance:data\",\n} as const;\n\n/** A well-known action as the table defines it. */\ninterface WellKnownAction {\n  /** Its run's name on the trace. */\n  title: string;\n  type: string;\n  retryable: boolean;\n  /** How it is answered: `lifecycle`, with the service's lifecycle. */\n  answer: string;\n  /** The parameters the platform sends it, when it sends any, those it always sends `required`. */\n  parameters?: { schema: { required?: string[] } & Record<string, unknown> };\n}\n\n/** The well-known actions, by slug. */\nconst WELL_KNOWN: Record<string, WellKnownAction> = scopeKind.actions;\n\n/** The table's entry for `slug`, when it is a well-known action; never a field the table inherits. */\nfunction wellKnownOf(slug: string): WellKnownAction | undefined {\n  return Object.hasOwn(WELL_KNOWN, slug) ? WELL_KNOWN[slug] : undefined;\n}\n\n/** The contract's telemetry prefixes (`telemetry.prefixes`), as the type of a key reads them; the contract stays what the code matches a key by (`isTelemetry`). */\nexport type TelemetryPrefix = \"log:\" | \"metric:\" | \"parameter:\" | \"instance:\";\n\n/** A telemetry action's key: any under a telemetry prefix. */\nexport type TelemetryKey = `${TelemetryPrefix}${string}`;\n\n/** A well-known action's key, as the type of a key reads it: each of `ScopeActions` but the telemetry ones, the contract's `actions`. */\nexport type WellKnownKey = Exclude<(typeof ScopeActions)[keyof typeof ScopeActions], TelemetryKey>;\n\n/** A text parameter's schema, as the table writes one. */\ntype TextSchema = { type: \"string\" };\n\n/** A number parameter's schema, as the table writes one. */\ntype NumberSchema = { type: \"number\" };\n\n/** A parameters schema as the table writes one: an object, the names it requires, its properties. */\ntype ParametersSchema<Required extends readonly string[], Properties> = { type: \"object\"; required: Required; properties: Properties };\n\n/** The parameters schema of an action about a scope. */\ntype ScopeSchema = ParametersSchema<[\"scope_id\"], { scope_id: TextSchema }>;\n\n/** The parameters schema of an action about a scope's deployment. */\ntype DeploymentSchema = ParametersSchema<[\"scope_id\", \"deployment_id\"], { scope_id: TextSchema; deployment_id: TextSchema }>;\n\n/**\n * The parameters schema the platform sends each well-known action, as the\n * table gives it (`actions.<key>.parameters.schema`), as the type of a key\n * reads it: a literal mirror, since a JSON import widens its text, held equal\n * to the table by `test/kinds/scope/table.test.ts`. None for an action the\n * table sends none; the runtime reads the table.\n */\nexport interface WellKnownParametersSchemas {\n  \"create-scope\": ScopeSchema;\n  \"delete-scope\": ScopeSchema;\n  \"update-scope\": ScopeSchema;\n  \"start-initial\": DeploymentSchema;\n  \"start-blue-green\": DeploymentSchema;\n  \"switch-traffic\": ParametersSchema<[\"scope_id\", \"deployment_id\", \"desired_traffic\"], { scope_id: TextSchema; deployment_id: TextSchema; desired_traffic: NumberSchema }>;\n  \"finalize-deployment\": DeploymentSchema;\n  \"finalize-blue-green\": DeploymentSchema;\n  \"rollback-deployment\": DeploymentSchema;\n  \"delete-deployment\": DeploymentSchema;\n  \"diagnose-scope\": ScopeSchema;\n  \"diagnose-deployment\": DeploymentSchema;\n  \"kill-instances\": ParametersSchema<[\"scope_id\", \"instance_id\", \"deployment_id\"], { scope_id: TextSchema; instance_id: TextSchema; deployment_id: TextSchema }>;\n  \"set-desired-instance-count\": ParametersSchema<[\"desired_instances\"], { desired_instances: NumberSchema }>;\n  \"pause-autoscaling\": undefined;\n  \"resume-autoscaling\": undefined;\n  \"restart-pods\": undefined;\n}\n\n/** A deployment action's key: a well-known action whose parameters require a deployment (`requiresDeployment`), as the type of a key reads it. */\nexport type DeploymentKey = {\n  [Key in WellKnownKey]: WellKnownParametersSchemas[Key] extends { required: readonly (infer Name)[] } ? (\"deployment_id\" extends Name ? Key : never) : never;\n}[WellKnownKey];\n\n/** Whether `slug` is a telemetry action: a key under one of the telemetry prefixes. */\nexport function isTelemetry(slug: string): boolean {\n  return scopeKind.telemetry.prefixes.some((prefix) => slug.startsWith(prefix));\n}\n\n/**\n * The scope's definition of the action `slug`, beneath its author's\n * specification: a well-known action's type, retryability and parameters, and\n * the results of one answered with the lifecycle the attributes' `properties`;\n * a telemetry action's none of its own; nothing for any other key, the\n * author's own. Each definition is a copy: the table stays as it is.\n */\nexport function definitionOf(slug: string, properties: Record<string, unknown>): Record<string, unknown> | undefined {\n  if (isTelemetry(slug)) {\n    return {};\n  }\n  const entry = wellKnownOf(slug);\n  if (entry === undefined) {\n    return undefined;\n  }\n  const { type, retryable, parameters, answer } = structuredClone(entry);\n  return { type, retryable, parameters, ...(answer === \"lifecycle\" ? { results: { schema: { type: \"object\", properties } } } : {}) };\n}\n\n/** Whether the platform sends the action `slug` a deployment: a well-known action whose parameters require its `deployment_id`. */\nexport function requiresDeployment(slug: string): boolean {\n  return wellKnownOf(slug)?.parameters?.schema.required?.includes(\"deployment_id\") ?? false;\n}\n\n/** The title of the action `slug`'s run on the trace, as the table names a well-known action; none for any other. */\nexport function titleOf(slug: string): string | undefined {\n  return wellKnownOf(slug)?.title;\n}\n\n/** Why the scope cannot bind a bare action `slug` the table does not define: it is neither well-known nor telemetry, so it is the author's own and needs its specification. */\nexport function unspecifiedOf(slug: string): string {\n  const prefixes = scopeKind.telemetry.prefixes.join(\", \");\n  return `\"${slug}\" is neither a well-known scope action nor a telemetry one (${prefixes}): give its specification`;\n}\n","/**\n * What a scope's action is about, read from its payload as the platform sends\n * it: its scope by `parameters.scope_id`, `scope.id` or, on a telemetry\n * action, `arguments.scope_id`, the first given; its deployment by\n * `parameters.deployment_id` or `arguments.deployment_id`, and on a telemetry\n * action, after them, `arguments.deploy_id` (log:read's). Each id is read by\n * the base's id rule (`idOf`): text, or a number as its digits.\n *\n * A scope's handler gets them in its input, on the service's (`serviceInputOf`:\n * the parameters, the action, the service and its attributes, the user, the\n * package, the tags, the entity's NRN, whether the platform manages it and the\n * trace it continues): `scope`, the payload's own with its\n * id and its slug (the scope's, else its service's, else its `tags.scope`),\n * and `deployment`, when the action is about one. A route builds it from the\n * payload it is handed, first of its middleware but the lifecycle\n * (`scopeInput`). An action that names no scope fails, MISSING_SCOPE; a\n * deployment action (one the platform sends a deployment) that names no\n * deployment fails, MISSING_DEPLOYMENT, then and again right before its\n * handler (`deploymentGuard`), so its handler gets the deployment, required\n * (`DeploymentInput`). A telemetry\n * action's handler gets a scope's input but the action, which a telemetry\n * payload does not carry (`TelemetryInput`). Its trace reads the same: the\n * run scoped to the scope's NRN, labelled with the scope's and the\n * deployment's ids.\n */\n\nimport { ActionError } from \"../../core/errors\";\nimport { objectOf, type Payload } from \"../../core/payload\";\nimport type { Middleware } from \"../../core/run/route\";\nimport { idOf, textOf } from \"../../core/text\";\nimport { payloadParameters, serviceInputOf, type ServiceInput } from \"../service/input\";\nimport { entityIdOf, type PayloadEntity, type ServicePayload } from \"../service/payload\";\nimport { serviceNrnOf } from \"../service/tracing\";\nimport { isTelemetry } from \"./table\";\n\n/** The scope an action is about, as the platform sends it, with its id and its slug as text. */\nexport interface Scope extends Record<string, unknown> {\n  id: string;\n  slug: string;\n}\n\n/** The deployment an action is about. */\nexport interface Deployment {\n  id: string;\n}\n\n/** What a scope's action handler gets as its input: the service's, its parameters typed `Parameters` and the scope's attributes `Attributes`, with the scope and, when the action is about one, the deployment. */\nexport interface ScopeInput<Parameters = Record<string, unknown>, Attributes = Record<string, unknown>> extends ServiceInput<Parameters, Attributes> {\n  scope: Scope;\n  deployment?: Deployment;\n}\n\n/** What a scope's deployment action handler gets as its input: the scope's, with the deployment its payload names, required. */\nexport interface DeploymentInput<Parameters = Record<string, unknown>, Attributes = Record<string, unknown>> extends ScopeInput<Parameters, Attributes> {\n  deployment: Deployment;\n}\n\n/**\n * What a scope's telemetry action handler gets as its input: the scope's\n * without what a telemetry payload does not carry (its action, whether the\n * platform manages it, a trace to continue), its parameters and its\n * service's attributes untyped (its arguments arrive with it). Every scope's\n * input is one, so a handler of it answers any scope action.\n */\nexport type TelemetryInput = Omit<ScopeInput, \"action\" | \"managed\" | \"trace_context\">;\n\n/** The fields of a scope's action the scope reads beside the service's. */\ninterface ScopePayload extends ServicePayload {\n  /** The scope the action is about, on a telemetry action. */\n  scope?: PayloadEntity | null;\n  /** What a telemetry action names. */\n  arguments?: Record<string, unknown>;\n}\n\n/** Why an action that names no scope fails. */\nconst NO_SCOPE = \"the payload names no scope: no parameters.scope_id, scope.id or arguments.scope_id\";\n\n/** Why a deployment action that names no deployment fails. */\nconst NO_DEPLOYMENT = \"the payload names no deployment: no parameters.deployment_id or arguments.deployment_id\";\n\n/** Why a deployment action whose payload names a deployment fails when the input its handler would get has none. */\nconst DEPLOYMENT_DROPPED = \"the payload names a deployment, but a middleware passed on none to the handler\";\n\n/** The id of the scope `payload` is about: its parameters', else its scope's, else its arguments'. */\nfunction scopeIdOf(payload: ScopePayload): string | undefined {\n  return idOf(objectOf(payload.parameters).scope_id) ?? entityIdOf(payload.scope) ?? idOf(objectOf(payload.arguments).scope_id);\n}\n\n/** The id of the deployment a telemetry action names as log:read does, `arguments.deploy_id`; none for any other action, which the platform never sends one so. */\nfunction telemetryDeploymentIdOf(payload: ScopePayload): string | undefined {\n  return isTelemetry(textOf(payload.action) ?? \"\") ? idOf(objectOf(payload.arguments).deploy_id) : undefined;\n}\n\n/** The id of the deployment `payload` is about: its parameters', else its arguments' `deployment_id`, else, on a telemetry action, their `deploy_id`. */\nfunction deploymentIdOf(payload: ScopePayload): string | undefined {\n  return idOf(objectOf(payload.parameters).deployment_id) ?? idOf(objectOf(payload.arguments).deployment_id) ?? telemetryDeploymentIdOf(payload);\n}\n\n/** The scope `id` of `payload`: its own fields, slugged as the scope, else its service, else its tags say; empty when none says. */\nfunction scopeOf(id: string, payload: ScopePayload): Scope {\n  const sent = objectOf(payload.scope);\n  const slug = textOf(sent.slug) ?? textOf(objectOf(payload.service).slug) ?? textOf(objectOf(payload.tags).scope) ?? \"\";\n  return { ...sent, id, slug };\n}\n\n/** A scope's action input, read from `payload`: the service's, with the scope the action is about and its deployment; an action that names no scope fails, MISSING_SCOPE. */\nfunction scopeInputOf(payload: ScopePayload): ScopeInput {\n  const scopeId = scopeIdOf(payload);\n  if (scopeId === undefined) {\n    throw new ActionError(\"MISSING_SCOPE\", NO_SCOPE);\n  }\n  const deploymentId = deploymentIdOf(payload);\n  return { ...serviceInputOf(payload), scope: scopeOf(scopeId, payload), ...(deploymentId === undefined ? {} : { deployment: { id: deploymentId } }) };\n}\n\n/** Passes on a scope's action input, built from the payload it is handed. */\nexport const scopeInput: Middleware<Payload, ScopeInput> = async (payload, context, next) => next(scopeInputOf(payload));\n\n/** `input` when it holds its deployment (an id, as text); else the action fails, MISSING_DEPLOYMENT, `why` saying why. */\nfunction deploymentChecked(input: ScopeInput, why: string): ScopeInput {\n  if (textOf(objectOf(input.deployment).id) === undefined) {\n    throw new ActionError(\"MISSING_DEPLOYMENT\", why);\n  }\n  return input;\n}\n\n/** Passes on the input of a deployment action it is handed, built from its payload, when it holds the deployment; else the payload names none, MISSING_DEPLOYMENT. */\nexport const deploymentRequired: Middleware<ScopeInput> = async (input, context, next) => next(deploymentChecked(input, NO_DEPLOYMENT));\n\n/**\n * A deployment action's guard, right before its handler: the input the\n * author's middleware passed on, its parameters the payload's own, when it\n * still holds its deployment; else MISSING_DEPLOYMENT, the payload naming\n * none, or a middleware having passed on none.\n */\nexport function deploymentGuard(input: ScopeInput, payload: Payload): ScopeInput {\n  const why = deploymentIdOf(payload) === undefined ? NO_DEPLOYMENT : DEPLOYMENT_DROPPED;\n  return deploymentChecked(payloadParameters(input, payload), why);\n}\n\n/** The NRN a scope's action is scoped to: its scope's, else a service's action's. */\nexport function scopeNrnOf(payload: Payload): string | undefined {\n  return textOf(objectOf((payload as ScopePayload).scope).nrn) ?? serviceNrnOf(payload);\n}\n\n/** What a scope's action is about beyond a service's entities, as its trace's labels: its scope and its deployment, by id. */\nexport function scopeAbout(payload: Payload): Record<string, string | undefined> {\n  return { \"scope.id\": scopeIdOf(payload), \"deployment.id\": deploymentIdOf(payload) };\n}\n","/**\n * defineScope: a scope of its package, a deployment target, on the service's\n * builder (contract/kinds/scope.json). A scope is a `service_specification` of\n * type `scope`, named by the package's slug, its body as its author wrote it\n * over the scope's defaults and the service's beneath them, the asset type it\n * deploys injected first among its attributes' properties (an `asset_type`\n * its author declares wins, whole, so an `assetType` beside it must be its\n * default). It uses no default actions: the default `create`, found by its\n * type, would catch `create-scope`, so a body that says it does is refused.\n * Its actions are bound by their keys and published under it, a well-known\n * one and a telemetry one defined by the scope's table (`./table`) beneath\n * its author's specification; and, with a `scopeType`, the scope type it\n * provides is published under it too.\n *\n * Each action is a route, traced as the run it describes with what a scope's\n * action is about (`./input`). A telemetry action is matched by the payload's\n * `action`, its input built, and answered raw with no lifecycle; it reaches\n * the package through the telemetry source, on the scope as its provider, and\n * tooling offers it from the telemetry fixture (log:read's, so any other\n * without what is the log's own). Any other is a specification's action\n * (`specificationRoute`): its lifecycle reported, then its input built, so\n * an action that names no scope, or a deployment action no deployment, is\n * reported failed; tooling offers it from the scope's fixture, or the\n * deployment's when the platform sends it a deployment. Then the scope's last\n * route fails any other action of it. The\n * author's own routes come after them. The definition's middleware runs\n * inside each of the other actions' routes only, after the scope's own, so it\n * is handed `input.scope`, `input.deployment` and the scope's attributes, its\n * parameters untyped, and the platform hears what it throws; never on a telemetry\n * action's route, whose payload carries no attributes, nor on the scope's\n * last route, nor on an author's own route (`specificationPlugin`).\n *\n * Each action's handler is called `(input, context)`, its input typed by\n * what its key gets (`ScopeHandlerInputOf`) and the scope's schemas: a\n * deployment action's the scope's input with the deployment required, any\n * other well-known action's the scope's, each its parameters its own row of\n * the table (`WellKnownParametersSchemas`) and its return `Partial` of the\n * scope's attributes; a telemetry key's the telemetry input (no action), and\n * a custom key's the scope's, its own\n * `parameters` and `results` schemas'. Each route builds the parameters again\n * from the payload after the definition's middleware, right before the\n * handler, and a deployment action's route checks the deployment again then\n * too, so what that middleware passes on never reaches a handler without what\n * its type says (`deploymentRouteOf`).\n *\n *   export default defineScope({\n *     package: { name: \"my-scope\", version: \"1.0.0\" },\n *     specification: { attributes: { schema: { type: \"object\", properties: { asset_url: { type: \"string\" }, domain: { type: \"string\" } } } } },\n *     actions: {\n *       [ScopeActions.CREATE_SCOPE]: async (input) => ({ domain: `scope-${input.scope.id}.example.com` }),\n *       [ScopeActions.LOG_READ]: async (input) => ({ results: await readLogs(input.scope.id) }),\n *     },\n *   });\n */\n\nimport scopeCreate from \"../../../../contract/fixtures/scope-create.json\" with { type: \"json\" };\nimport startInitial from \"../../../../contract/fixtures/scope-start-initial.json\" with { type: \"json\" };\nimport logRead from \"../../../../contract/fixtures/telemetry-log-read.json\" with { type: \"json\" };\nimport metricData from \"../../../../contract/fixtures/telemetry-metric-data.json\" with { type: \"json\" };\nimport scopeKind from \"../../../../contract/kinds/scope.json\" with { type: \"json\" };\nimport serviceKind from \"../../../../contract/kinds/service.json\" with { type: \"json\" };\nimport { component, ref, type Component } from \"../../core/component\";\nimport { merged } from \"../../core/merge\";\nimport { packageOf, type Package } from \"../../core/package\";\nimport { isJsonObject, objectOf, type Payload } from \"../../core/payload\";\nimport type { Plugin } from \"../../core/run/plugin\";\nimport type { Middleware, Route } from \"../../core/run/route\";\nimport { textOf } from \"../../core/text\";\nimport { where } from \"../../core/where\";\nimport { routeUseOf, specificationPlugin, type KindRoute, type SpecificationOptions, type StoredAttributesOf, type TypedEntry } from \"../service/define\";\nimport { sampleActionOf, specificationSample } from \"../service/samples\";\nimport {\n  actionRoute,\n  actionTracing,\n  asRouteGuard,\n  asRouteMiddleware,\n  attributesProblemsOf,\n  attributesPropertiesOf,\n  boundTo,\n  checkedSpecification,\n  fallbackRoute,\n  namedBody,\n  refusalsOf,\n  specificationRoute,\n  usesDefaultActions,\n  type BoundAction,\n  type Checked,\n  type TracedActionOptions,\n} from \"../service/specification\";\nimport { deploymentGuard, deploymentRequired, scopeAbout, scopeInput, scopeNrnOf, type DeploymentInput, type ScopeInput, type TelemetryInput } from \"./input\";\nimport { definitionOf, isTelemetry, requiresDeployment, titleOf, unspecifiedOf, type DeploymentKey, type TelemetryKey, type WellKnownKey, type WellKnownParametersSchemas } from \"./table\";\nimport type { CustomResultOf, PartSchemaOf, ValuesOf } from \"../service/values\";\n\n/** The parameters the scope's action `Key` gets, its own specification `Declared`: a well-known action's its table row's, a custom one's its `parameters` schema's. */\nexport type ScopeParametersOf<Key, Declared = undefined> = Key extends WellKnownKey ? ValuesOf<WellKnownParametersSchemas[Key]> : ValuesOf<PartSchemaOf<Declared, \"parameters\">>;\n\n/** What the scope's action `Key` returns, the scope's body `Body`: a well-known action, which the table answers with the lifecycle, `Partial` of the scope's attributes; a telemetry one what its payload's output schema says, `unknown`; a custom one its `results` schema's values. */\nexport type ScopeResultOf<Key, Body, Declared = undefined> = Key extends WellKnownKey ? StoredAttributesOf<Body> : Key extends TelemetryKey ? unknown : CustomResultOf<Declared>;\n\n/** What the scope's action `Key` that is no deployment action gets as its input, the scope's body `Body`: its parameters and the scope's attributes. */\nexport interface ScopeActionInputOf<Key, Body, Declared = undefined> extends ScopeInput<ScopeParametersOf<Key, Declared>, StoredAttributesOf<Body>> {}\n\n/** What the scope's deployment action `Key` gets as its input, the scope's body `Body`: its parameters, the scope's attributes and the deployment, required. */\nexport interface DeploymentActionInputOf<Key, Body> extends DeploymentInput<ScopeParametersOf<Key>, StoredAttributesOf<Body>> {}\n\n/** What the scope's action `Key` gets as its input: a telemetry key the telemetry input, a deployment action's the deployment required, any other the scope's. */\nexport type ScopeHandlerInputOf<Key, Body, Declared = undefined> = Key extends TelemetryKey\n  ? TelemetryInput\n  : Key extends DeploymentKey\n    ? DeploymentActionInputOf<Key, Body>\n    : ScopeActionInputOf<Key, Body, Declared>;\n\n/** A scope's actions, by key, each typed by what its key gets (`ScopeHandlerInputOf`) and returns (`ScopeResultOf`), its own specification `Specs[Key]`. */\nexport type ScopeEntries<Specs, Body> = { [Key in keyof Specs]: TypedEntry<ScopeHandlerInputOf<Key, Body, Specs[Key]>, ScopeResultOf<Key, Body, Specs[Key]>, Specs[Key]> };\n\n/**\n * The actions a definition declares when TypeScript infers none of their\n * keys: every entry is a handler that reads its input, which TypeScript\n * types only once their keys are fixed. They are the well-known ones and any\n * telemetry one, each optional.\n */\ntype DefaultScopeSpecs = Partial<Record<WellKnownKey, undefined>> & { [key: TelemetryKey]: undefined };\n\n/** What a scope's middleware is handed: the input of any of its actions but the telemetry ones, its parameters untyped, which the route builds again right before the handler. */\nexport type ScopeMiddlewareInput<Body> = ScopeInput<Record<string, unknown>, StoredAttributesOf<Body>>;\n\n/** What a scope is defined by: its body `Body`, each action's specification `Specs[key]`. */\nexport interface ScopeDefinition<Body = Record<string, unknown>, Specs = Record<string, unknown>> extends SpecificationOptions<ScopeMiddlewareInput<Body>> {\n  /** The service_specification body, as the API takes it; named by the package's slug. */\n  specification: Body;\n  /** The asset type the scope deploys (`docker-image`, `lambda`, `bundle`, …): its `asset_type` attribute's default; the contract's unless given. */\n  assetType?: string;\n  /** The scope type the scope provides, its scope_type body as the API takes it (its `name` the package's and its `description` the name unless given); none without it. */\n  scopeType?: Record<string, unknown>;\n  /** What it answers, by key: its well-known actions (`ScopeActions`), its telemetry ones, and its custom ones, each with its specification. A deployment action's handler gets the deployment, required; any other well-known action's, the scope's input; a telemetry key's, the telemetry input, with no action; a custom key's, the scope's, its parameters and results its own schemas'. */\n  actions: ScopeEntries<Specs, Body>;\n  /** Around each handler of its actions but the telemetry ones, after the kind's own middleware: it is handed the scope's action's input, its parameters untyped. Never on a telemetry action, whose payload carries no attributes. On a deployment action, the deployment is checked again after it, right before the handler: one it passes on without it fails the action, MISSING_DEPLOYMENT. */\n  use?: Middleware<ScopeMiddlewareInput<Body>>[];\n}\n\n/** Who refuses a definition, as its own problems are named. */\nconst DEFINER = \"defineScope\";\n\n/** What a scope's action is of, as its trace calls it. */\nconst KIND = \"scope\";\n\n/** What a scope's specification is published over: the scope's defaults, over the service's. */\nconst SPECIFICATION_DEFAULTS = merged(serviceKind.specification, scopeKind.specification);\n\n/** Why a scope's body may not use the default actions. */\nconst USES_DEFAULTS = \"specification use_default_actions must be false: a scope uses no default actions, as the default create, found by its type, would catch create-scope\";\n\n/** The API's entity name of the scope type a scope provides. */\nconst SCOPE_TYPE_KIND = \"scope_type\";\n\n/** Where a scope type is created and listed, the API's limit on its description, and what its body is over beside its provider. */\nconst { path: scopeTypePath, list: scopeTypeList, description_max: descriptionMax, ...scopeTypeDefaults } = scopeKind.scope_type;\n\n/** The fields of a scope type's body that are text when given: its name and its description, which default to the package's name and to the name. */\nconst SCOPE_TYPE_TEXTS = [\"name\", \"description\"];\n\n/** What is wrong with the asset type a scope is given beside the `asset_type` its attributes declare, which wins whole: it is not text, or it is not that one's default. */\nfunction assetTypeProblemsOf(assetType: unknown, declared: unknown): string[] {\n  if (assetType === undefined) {\n    return [];\n  }\n  const given = textOf(assetType);\n  if (given === undefined) {\n    return [\"assetType must be text: the asset type the scope deploys, as docker-image\"];\n  }\n  const declaredDefault = objectOf(declared).default;\n  if (declared === undefined || declaredDefault === given) {\n    return [];\n  }\n  const named = declaredDefault === undefined ? \"(none)\" : JSON.stringify(declaredDefault);\n  return [`assetType \"${given}\" and the declared asset_type's default ${named} differ: the declared asset_type wins, so give the asset type once`];\n}\n\n/** The asset type attribute a scope's specification is given, the contract's with its default `assetType` when given; and what is wrong with `assetType` beside the attributes' own `properties`. */\nfunction checkedAssetType(assetType: unknown, properties: Record<string, unknown>): Checked<Record<string, unknown>> {\n  return { value: merged(scopeKind.asset_type, { default: textOf(assetType) }), problems: assetTypeProblemsOf(assetType, properties.asset_type) };\n}\n\n/** `body` with the asset type attribute first among its attributes' properties, unless they declare their own; a body that is no object, or whose attributes are malformed, as it is, which the specification refuses. */\nfunction withAssetType(body: unknown, assetType: Record<string, unknown>): unknown {\n  if (!isJsonObject(body) || attributesProblemsOf(body).length > 0) {\n    return body;\n  }\n  const attributes = objectOf(body.attributes);\n  const schema = objectOf(attributes.schema);\n  return { ...body, attributes: { ...attributes, schema: { ...schema, properties: { asset_type: assetType, ...objectOf(schema.properties) } } } };\n}\n\n/**\n * The scope type the specification `declared` provides, when `scopeType`\n * gives one: under it at the scope type's path, its body as written over the\n * contract's defaults and naming its provider, its name the package's and its\n * description the name unless given, cut to the API's limit. And what is\n * wrong with it: it is no object, or a name or a description it gives is not\n * text.\n */\nfunction checkedScopeType(declared: Component, scopeType: unknown, packageName: string): Checked<Component | undefined> {\n  if (scopeType === undefined) {\n    return { value: undefined, problems: [] };\n  }\n  if (!isJsonObject(scopeType)) {\n    return { value: undefined, problems: [\"scopeType must be an object: its scope_type body as the API takes it\"] };\n  }\n  const problems = SCOPE_TYPE_TEXTS.filter((field) => scopeType[field] !== undefined && textOf(scopeType[field]) === undefined).map((field) => `scopeType.${field} must be text`);\n  if (problems.length > 0) {\n    return { value: undefined, problems };\n  }\n  const name = textOf(scopeType.name) ?? packageName;\n  const description = (textOf(scopeType.description) ?? name).slice(0, descriptionMax);\n  const body = namedBody(name, { ...scopeTypeDefaults, provider_id: ref(declared) }, scopeType);\n  body.description = description;\n  return { value: component(SCOPE_TYPE_KIND, declared.name, body, { parent: declared, path: scopeTypePath, list: scopeTypeList }), problems: [] };\n}\n\n/** What the package's channel lets through for the scope's telemetry actions: the telemetry source, filtered on the scope as their provider. */\nfunction telemetryChannel(declared: Component): NonNullable<Route[\"channel\"]> {\n  return { source: scopeKind.telemetry.source, filter: { \"arguments.scope_provider\": { $eq: ref(declared) } } };\n}\n\n/** The telemetry fixtures, each a delivery of its own action. */\nconst TELEMETRY_FIXTURES: Payload[] = [logRead.notification, metricData.notification];\n\n/** What tooling offers to run the telemetry action `slug` with: the telemetry fixture of that action, whole, when there is one; else log:read's, asking `slug` with only the arguments the contract names every telemetry action's and no schema of the log's. */\nfunction telemetrySample(slug: string): Payload {\n  const own = TELEMETRY_FIXTURES.find((fixture) => fixture.action === slug);\n  if (own !== undefined) {\n    return structuredClone(own);\n  }\n  const delivered = structuredClone(logRead.notification);\n  const kept = Object.fromEntries(Object.entries(delivered).filter(([field]) => field !== \"output_schema\"));\n  const sent = objectOf(delivered.arguments);\n  return { ...kept, action: slug, arguments: Object.fromEntries(scopeKind.telemetry.arguments.map((name) => [name, sent[name]])) };\n}\n\n/** What tooling offers to run the action `action` of `declared` with: the deployment's fixture when the platform sends it a deployment, else the scope's, asking it. */\nfunction lifecycleSample(declared: Component, action: BoundAction): Payload {\n  const delivered = requiresDeployment(action.slug) ? startInitial.notification : scopeCreate.notification;\n  return specificationSample(delivered, declared.name, sampleActionOf(action));\n}\n\n/** The scope's input, as a route's middleware: what builds a scope's action's input from its payload. */\nconst [SCOPE_INPUT] = asRouteMiddleware([scopeInput]);\n\n/** How the action `action` of the scope `declared` is traced: its run titled as the table titles it unless its author does, scoped to the scope's NRN and labelled with what it is about. */\nfunction tracedOf(declaredPackage: Package, declared: Component, action: BoundAction): TracedActionOptions {\n  return { package: declaredPackage, kind: KIND, slug: declared.name, action, trace: { title: titleOf(action.slug), nrnOf: scopeNrnOf, about: scopeAbout } };\n}\n\n/** The route that answers a telemetry action of the scope `declared`, traced as `traced` says: matched by the payload's `action`, traced as its run, its input built with no lifecycle, printed raw. */\nfunction telemetryRoute(declared: Component, traced: TracedActionOptions): Route {\n  const { action } = traced;\n  return actionRoute({\n    name: action.slug,\n    match: where({ action: action.slug }),\n    action,\n    use: [SCOPE_INPUT],\n    describe: actionTracing(traced),\n    output: () => \"raw\",\n    channel: telemetryChannel(declared),\n    sample: telemetrySample(action.slug),\n  });\n}\n\n/** The route that answers the deployment action `action`, traced as `traced` says, with the definition's middleware `use`: its deployment checked once the scope's input is built; after `use`, right before the handler, which is typed for them, its parameters built again from the payload and its deployment checked again (`deploymentGuard`). */\nfunction deploymentRouteOf(declared: Component, action: BoundAction, traced: TracedActionOptions, use: Middleware[] | undefined): KindRoute {\n  const route = specificationRoute({ ...traced, name: action.slug, inputBuilder: SCOPE_INPUT, inputChecks: asRouteMiddleware([deploymentRequired]), guard: asRouteGuard(deploymentGuard), sample: lifecycleSample(declared, action) });\n  return { route, use };\n}\n\n/**\n * The route that answers `action` of the scope `declared`: a telemetry\n * action's, with none of the definition's middleware, its payload carrying no\n * attributes; a deployment action's (`deploymentRouteOf`); else a\n * specification's with the scope's input, so the platform hears an action\n * that names no scope failed, with the definition's middleware `use`, then\n * its parameters built again from the payload, right before the handler.\n */\nfunction routeOf(declaredPackage: Package, declared: Component, action: BoundAction, use: Middleware[] | undefined): KindRoute {\n  const traced = tracedOf(declaredPackage, declared, action);\n  if (isTelemetry(action.slug)) {\n    return { route: telemetryRoute(declared, traced) };\n  }\n  if (requiresDeployment(action.slug)) {\n    return deploymentRouteOf(declared, action, traced, use);\n  }\n  return { route: specificationRoute({ ...traced, name: action.slug, inputBuilder: SCOPE_INPUT, sample: lifecycleSample(declared, action) }), use };\n}\n\n/**\n * A scope of its package: its specification, its actions and its scope type\n * published, a route per action, then its last route. A definition with a\n * problem is refused, naming every one at once: the specification's (its\n * body and its attributes, its default actions, its asset type, its scope\n * type, its actions), then the definition's own.\n */\nexport function defineScope<const Body extends Record<string, unknown>, const Specs extends Record<string, unknown> = DefaultScopeSpecs>(definition: ScopeDefinition<Body, Specs>): Plugin {\n  const declaredPackage = packageOf(DEFINER, definition?.package);\n  const properties = attributesPropertiesOf(definition.specification);\n  const assetType = checkedAssetType(definition.assetType, properties);\n  const specification = checkedSpecification(declaredPackage.slug, withAssetType(definition.specification, assetType.value), SPECIFICATION_DEFAULTS);\n  const declared = specification.value;\n  const defaultsProblems = usesDefaultActions(declared) ? [USES_DEFAULTS] : [];\n  const actions = boundTo(declared, definition.actions, { usesDefaults: false, definitionOf: (slug) => definitionOf(slug, properties), unspecifiedOf });\n  const scopeType = checkedScopeType(declared, definition.scopeType, declaredPackage.name);\n  return specificationPlugin(DEFINER, declaredPackage, definition, {\n    components: [declared],\n    routes: actions.value.map((action) => routeOf(declaredPackage, declared, action, routeUseOf(definition.use))),\n    lastRoutes: [fallbackRoute(declared.name)],\n    refusals: refusalsOf(declared.name, [...specification.problems, ...defaultsProblems, ...assetType.problems, ...scopeType.problems, ...actions.problems]),\n  });\n}\n"],"mappings":";;;;;;;;;;;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