@crustjs/core 0.5.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -569,7 +569,7 @@ type RunOutcome<Result> = {
569
569
  readonly status: "completed";
570
570
  readonly result: Result;
571
571
  } | {
572
- readonly status: "finished";
572
+ readonly status: "handled";
573
573
  readonly by: ExtensionId;
574
574
  } | {
575
575
  readonly status: "failed";
@@ -937,7 +937,7 @@ declare class Crust<Flags extends FlagsDef = {}, A extends ArgsDef = [], Ctx ext
937
937
  }): Promise<CommandSnapshot>;
938
938
  /**
939
939
  * Programmatically invoke a typed command, quietly capturing its output.
940
- * Returns completed, finished, or failed after cleanup without presenting errors.
940
+ * Returns completed, handled, or failed after cleanup without presenting errors.
941
941
  * Use {@link execute} as the streaming terminal adapter.
942
942
  *
943
943
  * @param path - Typed path to the command to invoke (`[]` selects the root)
@@ -1122,15 +1122,15 @@ declare class CrustError<C extends CrustErrorCode = CrustErrorCode> extends Erro
1122
1122
  }
1123
1123
  //#endregion
1124
1124
  //#region src/api/extension.d.ts
1125
- declare const finishedBrand: unique symbol;
1126
- /** Opaque token returned by {@link ExtensionContext.finish} to end an invocation successfully. */
1127
- interface Finished {
1128
- readonly [finishedBrand]: true;
1125
+ declare const handledBrand: unique symbol;
1126
+ /** Opaque token returned by {@link ExtensionContext.handled} to end an invocation successfully. */
1127
+ interface Handled {
1128
+ readonly [handledBrand]: true;
1129
1129
  }
1130
1130
  type InvocationOutcome = {
1131
1131
  readonly status: "completed";
1132
1132
  } | {
1133
- readonly status: "finished";
1133
+ readonly status: "handled";
1134
1134
  readonly by: ExtensionId;
1135
1135
  } | {
1136
1136
  readonly status: "failed";
@@ -1245,20 +1245,20 @@ interface ExtensionContext<Defs extends readonly NamedExtensionFlagDef[] = [], D
1245
1245
  * @example
1246
1246
  * ```ts
1247
1247
  * preRun(ctx) {
1248
- * if (ctx.flags.help === true) return ctx.finish();
1248
+ * if (ctx.flags.help === true) return ctx.handled();
1249
1249
  * }
1250
1250
  * ```
1251
1251
  */
1252
- readonly finish: () => Finished;
1252
+ readonly handled: () => Handled;
1253
1253
  }
1254
1254
  interface ExtensionHooks<Defs extends readonly NamedExtensionFlagDef[] = [], Deps extends ContextMap = {}, MetaKeys extends RootMetaKey = never> {
1255
1255
  /**
1256
1256
  * Runs after routing and input binding (argv parsing for `execute()`, structured
1257
1257
  * binding for typed `run()`), before validation, in `.extend()` order.
1258
- * Return `ctx.finish()` to end the invocation successfully; later pre-run hooks,
1258
+ * Return `ctx.handled()` to end the invocation successfully; later pre-run hooks,
1259
1259
  * validation, schemas, Contexts, and the Command Action do not run.
1260
1260
  */
1261
- readonly preRun?: (ctx: ExtensionContext<Defs, Deps, MetaKeys>) => Awaitable<void | Finished>;
1261
+ readonly preRun?: (ctx: ExtensionContext<Defs, Deps, MetaKeys>) => Awaitable<void | Handled>;
1262
1262
  /**
1263
1263
  * Runs after the invocation settles, in reverse `.extend()` order. This is the
1264
1264
  * `finally` slot for cleanup and post-run side effects.
@@ -2212,4 +2212,4 @@ interface ContextBuilder<Name extends string, Use extends readonly AnyContextFac
2212
2212
  declare function defineContext<Name extends string>(name: Name): ContextBuilder<Name>;
2213
2213
  type FactoryValueOf<F extends AnyContextFactory> = F extends ContextFactory<any, any, infer Value, any, any> ? Awaited<Value> : never;
2214
2214
  //#endregion
2215
- export { CrustError as $, SectionConsumer as A, LocalFlagNameBrand as At, ExtensionBuilder as B, InvocationOptions as C, RunInputArguments as Ct, ParsedArgValue as D, CommandSnapshot as Dt, ParseResult as E, ArgSnapshot as Et, BuildArtifacts as F, defineExtensionId as Ft, ExtensionSectionContribution as G, ExtensionFactory as H, BuildFile as I, InvocationOutcome as J, Finished as K, BuildReport as L, ValueType as M, LocalValueBrand as Mt, FlagEnvironment as N, MergeContext as Nt, ParsedFlagValue as O, FlagSnapshot as Ot, parseFlagValues as P, ExtensionId as Pt, CommandNotFoundErrorDetails as Q, Extension as R, InvocationIO as S, RunInput as St, NamedFlagDef as T, defineCommand as Tt, ExtensionFlagDef as U, ExtensionContext as V, ExtensionHooks as W, RootMetaKey as X, NamedExtensionFlagDef as Y, defineExtension as Z, ExecuteOptions as _, CommandTree as _t, ContextInstance as a, EnvErrorDetails as at, InputArgs as b, RootCommandMeta as bt, FactoryValueOf as c, ValidationErrorDetails as ct, ArgDef as d, CommandDefinition as dt, CrustErrorCode as et, ArgsDef as f, CommandDefinitionBuilder as ft, DeclaredDefault as g, CommandShapeAt as gt, CommandSectionInput as h, CommandShape as ht, ContextFactory as i, DefinitionErrorDetails as it, ValidatedInput as j, EmptyArgNameBrand as jt, SectionAudience as k, LocalFlagBrand as kt, contextSources as l, AnyCrust as lt, CommandSection as m, CommandPath as mt, ContextBag as n, CrustErrorDetailsMap as nt, ContextMap as o, EnvIssue as ot, CommandMeta as p, CommandHandle as pt, InferExtensionFlags as q, ContextBuilder as r, CrustErrorJson as rt, ContextSetup as s, ParseErrorDetails as st, AnyContextFactory as t, CrustErrorDetails as tt, defineContext as u, CommandConfig as ut, FlagDef as v, Crust as vt, MergeFlags as w, RunOutcome as wt, InputFlags as x, RunArguments as xt, FlagsDef as y, CrustCommandContext as yt, ExtensionBuildContext as z };
2215
+ export { CrustError as $, SectionConsumer as A, LocalFlagNameBrand as At, ExtensionBuilder as B, InvocationOptions as C, RunInputArguments as Ct, ParsedArgValue as D, CommandSnapshot as Dt, ParseResult as E, ArgSnapshot as Et, BuildArtifacts as F, defineExtensionId as Ft, ExtensionSectionContribution as G, ExtensionFactory as H, BuildFile as I, InvocationOutcome as J, Handled as K, BuildReport as L, ValueType as M, LocalValueBrand as Mt, FlagEnvironment as N, MergeContext as Nt, ParsedFlagValue as O, FlagSnapshot as Ot, parseFlagValues as P, ExtensionId as Pt, CommandNotFoundErrorDetails as Q, Extension as R, InvocationIO as S, RunInput as St, NamedFlagDef as T, defineCommand as Tt, ExtensionFlagDef as U, ExtensionContext as V, ExtensionHooks as W, RootMetaKey as X, NamedExtensionFlagDef as Y, defineExtension as Z, ExecuteOptions as _, CommandTree as _t, ContextInstance as a, EnvErrorDetails as at, InputArgs as b, RootCommandMeta as bt, FactoryValueOf as c, ValidationErrorDetails as ct, ArgDef as d, CommandDefinition as dt, CrustErrorCode as et, ArgsDef as f, CommandDefinitionBuilder as ft, DeclaredDefault as g, CommandShapeAt as gt, CommandSectionInput as h, CommandShape as ht, ContextFactory as i, DefinitionErrorDetails as it, ValidatedInput as j, EmptyArgNameBrand as jt, SectionAudience as k, LocalFlagBrand as kt, contextSources as l, AnyCrust as lt, CommandSection as m, CommandPath as mt, ContextBag as n, CrustErrorDetailsMap as nt, ContextMap as o, EnvIssue as ot, CommandMeta as p, CommandHandle as pt, InferExtensionFlags as q, ContextBuilder as r, CrustErrorJson as rt, ContextSetup as s, ParseErrorDetails as st, AnyContextFactory as t, CrustErrorDetails as tt, defineContext as u, CommandConfig as ut, FlagDef as v, Crust as vt, MergeFlags as w, RunOutcome as wt, InputFlags as x, RunArguments as xt, FlagsDef as y, CrustCommandContext as yt, ExtensionBuildContext as z };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as CrustError, A as SectionConsumer, At as LocalFlagNameBrand, B as ExtensionBuilder, C as InvocationOptions, Ct as RunInputArguments, D as ParsedArgValue, Dt as CommandSnapshot, E as ParseResult, Et as ArgSnapshot, F as BuildArtifacts, Ft as defineExtensionId, G as ExtensionSectionContribution, H as ExtensionFactory, I as BuildFile, J as InvocationOutcome, K as Finished, L as BuildReport, M as ValueType, Mt as LocalValueBrand, Nt as MergeContext, O as ParsedFlagValue, Ot as FlagSnapshot, Pt as ExtensionId, Q as CommandNotFoundErrorDetails, R as Extension, S as InvocationIO, St as RunInput, T as NamedFlagDef, Tt as defineCommand, U as ExtensionFlagDef, V as ExtensionContext, W as ExtensionHooks, X as RootMetaKey, Y as NamedExtensionFlagDef, Z as defineExtension, _ as ExecuteOptions, _t as CommandTree, a as ContextInstance, at as EnvErrorDetails, b as InputArgs, bt as RootCommandMeta, c as FactoryValueOf, ct as ValidationErrorDetails, d as ArgDef, dt as CommandDefinition, et as CrustErrorCode, f as ArgsDef, ft as CommandDefinitionBuilder, gt as CommandShapeAt, h as CommandSectionInput, ht as CommandShape, i as ContextFactory, it as DefinitionErrorDetails, j as ValidatedInput, jt as EmptyArgNameBrand, k as SectionAudience, kt as LocalFlagBrand, l as contextSources, lt as AnyCrust, m as CommandSection, mt as CommandPath, n as ContextBag, nt as CrustErrorDetailsMap, o as ContextMap, ot as EnvIssue, p as CommandMeta, pt as CommandHandle, q as InferExtensionFlags, r as ContextBuilder, rt as CrustErrorJson, s as ContextSetup, st as ParseErrorDetails, t as AnyContextFactory, tt as CrustErrorDetails, u as defineContext, ut as CommandConfig, v as FlagDef, vt as Crust, w as MergeFlags, wt as RunOutcome, x as InputFlags, xt as RunArguments, y as FlagsDef, yt as CrustCommandContext, z as ExtensionBuildContext } from "./context-9ee4iljp.js";
1
+ import { $ as CrustError, A as SectionConsumer, At as LocalFlagNameBrand, B as ExtensionBuilder, C as InvocationOptions, Ct as RunInputArguments, D as ParsedArgValue, Dt as CommandSnapshot, E as ParseResult, Et as ArgSnapshot, F as BuildArtifacts, Ft as defineExtensionId, G as ExtensionSectionContribution, H as ExtensionFactory, I as BuildFile, J as InvocationOutcome, K as Handled, L as BuildReport, M as ValueType, Mt as LocalValueBrand, Nt as MergeContext, O as ParsedFlagValue, Ot as FlagSnapshot, Pt as ExtensionId, Q as CommandNotFoundErrorDetails, R as Extension, S as InvocationIO, St as RunInput, T as NamedFlagDef, Tt as defineCommand, U as ExtensionFlagDef, V as ExtensionContext, W as ExtensionHooks, X as RootMetaKey, Y as NamedExtensionFlagDef, Z as defineExtension, _ as ExecuteOptions, _t as CommandTree, a as ContextInstance, at as EnvErrorDetails, b as InputArgs, bt as RootCommandMeta, c as FactoryValueOf, ct as ValidationErrorDetails, d as ArgDef, dt as CommandDefinition, et as CrustErrorCode, f as ArgsDef, ft as CommandDefinitionBuilder, gt as CommandShapeAt, h as CommandSectionInput, ht as CommandShape, i as ContextFactory, it as DefinitionErrorDetails, j as ValidatedInput, jt as EmptyArgNameBrand, k as SectionAudience, kt as LocalFlagBrand, l as contextSources, lt as AnyCrust, m as CommandSection, mt as CommandPath, n as ContextBag, nt as CrustErrorDetailsMap, o as ContextMap, ot as EnvIssue, p as CommandMeta, pt as CommandHandle, q as InferExtensionFlags, r as ContextBuilder, rt as CrustErrorJson, s as ContextSetup, st as ParseErrorDetails, t as AnyContextFactory, tt as CrustErrorDetails, u as defineContext, ut as CommandConfig, v as FlagDef, vt as Crust, w as MergeFlags, wt as RunOutcome, x as InputFlags, xt as RunArguments, y as FlagsDef, yt as CrustCommandContext, z as ExtensionBuildContext } from "./context-VtqvNs9V.js";
2
2
  import { resolveArtifactDir } from "@crustjs/utils/artifacts";
3
3
  //#region src/api/flags.d.ts
4
4
  /** Distribute `Omit<_, "name">` over the {@link ArgDef} union. */
@@ -20,4 +20,4 @@ export declare function defineFlag<const N extends string, const D extends FlagD
20
20
  /** Define and own one positional argument; layout belongs to its consuming command. */
21
21
  export declare function defineArg<const N extends string, const D extends UnnamedArgDef>(name: N & EmptyArgNameBrand<N>, def: D & LocalValueBrand<D>): Named<N, D>;
22
22
  //#endregion
23
- export { type AnyContextFactory, type AnyCrust, type ArgDef, type ArgSnapshot, type ArgsDef, type BuildArtifacts, type BuildFile, type BuildReport, type CommandConfig, type CommandDefinition, type CommandDefinitionBuilder, type CommandHandle, type CommandMeta, type CommandNotFoundErrorDetails, type CommandPath, type CommandSection, type CommandSectionInput, type CommandShape, type CommandShapeAt, type CommandSnapshot, type CommandTree, type ContextBag, type ContextBuilder, type ContextFactory, type ContextInstance, type ContextMap, type ContextSetup, Crust, type CrustCommandContext, CrustError, type CrustErrorCode, type CrustErrorDetails, type CrustErrorDetailsMap, type CrustErrorJson, type DefinitionErrorDetails, type EnvErrorDetails, type EnvIssue, type ExecuteOptions, type Extension, type ExtensionBuildContext, type ExtensionBuilder, type ExtensionContext, type ExtensionFactory, type ExtensionFlagDef, type ExtensionHooks, type ExtensionId, type ExtensionSectionContribution, type FactoryValueOf, type Finished, type FlagDef, type FlagSnapshot, type FlagsDef, type InferExtensionFlags, type InputArgs, type InputFlags, type InvocationIO, type InvocationOptions, type InvocationOutcome, type MergeContext, type MergeFlags, type NamedExtensionFlagDef, type NamedFlagDef, type ParseErrorDetails, type ParseResult, type ParsedArgValue, type ParsedFlagValue, type RootCommandMeta, type RootMetaKey, type RunArguments, type RunInput, type RunInputArguments, type RunOutcome, type SectionAudience, type SectionConsumer, type UnnamedArgDef, type ValidatedInput, type ValidationErrorDetails, type ValueType, contextSources, defineCommand, defineContext, defineExtension, defineExtensionId, resolveArtifactDir };
23
+ export { type AnyContextFactory, type AnyCrust, type ArgDef, type ArgSnapshot, type ArgsDef, type BuildArtifacts, type BuildFile, type BuildReport, type CommandConfig, type CommandDefinition, type CommandDefinitionBuilder, type CommandHandle, type CommandMeta, type CommandNotFoundErrorDetails, type CommandPath, type CommandSection, type CommandSectionInput, type CommandShape, type CommandShapeAt, type CommandSnapshot, type CommandTree, type ContextBag, type ContextBuilder, type ContextFactory, type ContextInstance, type ContextMap, type ContextSetup, Crust, type CrustCommandContext, CrustError, type CrustErrorCode, type CrustErrorDetails, type CrustErrorDetailsMap, type CrustErrorJson, type DefinitionErrorDetails, type EnvErrorDetails, type EnvIssue, type ExecuteOptions, type Extension, type ExtensionBuildContext, type ExtensionBuilder, type ExtensionContext, type ExtensionFactory, type ExtensionFlagDef, type ExtensionHooks, type ExtensionId, type ExtensionSectionContribution, type FactoryValueOf, type FlagDef, type FlagSnapshot, type FlagsDef, type Handled, type InferExtensionFlags, type InputArgs, type InputFlags, type InvocationIO, type InvocationOptions, type InvocationOutcome, type MergeContext, type MergeFlags, type NamedExtensionFlagDef, type NamedFlagDef, type ParseErrorDetails, type ParseResult, type ParsedArgValue, type ParsedFlagValue, type RootCommandMeta, type RootMetaKey, type RunArguments, type RunInput, type RunInputArguments, type RunOutcome, type SectionAudience, type SectionConsumer, type UnnamedArgDef, type ValidatedInput, type ValidationErrorDetails, type ValueType, contextSources, defineCommand, defineContext, defineExtension, defineExtensionId, resolveArtifactDir };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { C as normalizeFlag, S as normalizeArg, _ as validateContextAvailability, a as runInvocation, b as validateCommandSections, c as cloneCommandNode, d as createCommandNode, f as registerFlag, g as definingOf, h as defineContext, i as resolveTypedPath, l as cloneFlagRegistry, m as contextSources, n as executeInvocation, o as snapshotCommand, p as defineExtension, r as prepareInvocation, u as installExtensionContexts, w as CrustError } from "./invocation-CD299Gic.js";
1
+ import { C as normalizeFlag, S as normalizeArg, _ as validateContextAvailability, a as runInvocation, b as validateCommandSections, c as cloneCommandNode, d as createCommandNode, f as registerFlag, g as definingOf, h as defineContext, i as resolveTypedPath, l as cloneFlagRegistry, m as contextSources, n as executeInvocation, o as snapshotCommand, p as defineExtension, r as prepareInvocation, u as installExtensionContexts, w as CrustError } from "./invocation-OsKzCgr-.js";
2
2
  import { resolveArtifactDir } from "@crustjs/utils/artifacts";
3
3
  //#region src/identity.ts
4
4
  /** Mint an Extension identity from any non-blank, trimmed string. */
@@ -466,10 +466,10 @@ function createContextResolver(contexts, io, disposal, signal) {
466
466
  }
467
467
  //#endregion
468
468
  //#region src/api/extension.ts
469
- const FINISHED = Object.freeze({ [Symbol("crust.finished")]: true });
469
+ const HANDLED = Object.freeze({ [Symbol("crust.handled")]: true });
470
470
  /** @internal */
471
- function finishInvocation() {
472
- return FINISHED;
471
+ function handledInvocation() {
472
+ return HANDLED;
473
473
  }
474
474
  function createExtension(state) {
475
475
  const flags = Object.freeze(toFlagsRecord(state.flags));
@@ -1194,7 +1194,7 @@ function bind(command, positionals, flagValues, coerceArg, coerceFlag) {
1194
1194
  *
1195
1195
  * This is a pure parse+coerce function — it never throws for missing required
1196
1196
  * values. Use {@link validateParsed} to enforce required constraints after
1197
- * extensions have had a chance to finish an invocation (e.g. `--help`).
1197
+ * extensions have had a chance to handle an invocation (e.g. `--help`).
1198
1198
  *
1199
1199
  * @param command - The command whose arg/flag definitions drive the parsing
1200
1200
  * @param argv - The argv array to parse (typically `process.argv.slice(2)`)
@@ -1740,7 +1740,7 @@ async function dispatch(input, prepared, io, signal, onExtensionContext, onFailu
1740
1740
  rawArgs: parsed.rawArgs,
1741
1741
  signal,
1742
1742
  ctx: resolver.bag(extensions.flatMap((extension) => extension.use)),
1743
- finish: finishInvocation,
1743
+ handled: handledInvocation,
1744
1744
  stdout: io.stdout,
1745
1745
  stderr: io.stderr
1746
1746
  });
@@ -1767,14 +1767,14 @@ async function dispatch(input, prepared, io, signal, onExtensionContext, onFailu
1767
1767
  let outcome = { status: "completed" };
1768
1768
  try {
1769
1769
  try {
1770
- for (const extension of extensions) if (await extension.hooks?.preRun?.(extensionContext) === finishInvocation()) {
1770
+ for (const extension of extensions) if (await extension.hooks?.preRun?.(extensionContext) === handledInvocation()) {
1771
1771
  outcome = {
1772
- status: "finished",
1772
+ status: "handled",
1773
1773
  by: extension.id
1774
1774
  };
1775
1775
  break;
1776
1776
  }
1777
- if (outcome.status !== "finished") result = await terminal();
1777
+ if (outcome.status !== "handled") result = await terminal();
1778
1778
  } catch (error) {
1779
1779
  const by = await onFailure?.(error, extensionContext);
1780
1780
  outcome = {
@@ -1799,8 +1799,8 @@ async function dispatch(input, prepared, io, signal, onExtensionContext, onFailu
1799
1799
  } finally {
1800
1800
  await resolver.settle();
1801
1801
  }
1802
- return outcome.status === "finished" ? {
1803
- status: "finished",
1802
+ return outcome.status === "handled" ? {
1803
+ status: "handled",
1804
1804
  by: outcome.by
1805
1805
  } : {
1806
1806
  status: "completed",
@@ -1833,7 +1833,7 @@ async function renderFailure(error, argv, prepared, io, signal, extensionContext
1833
1833
  flags: Object.freeze({}),
1834
1834
  rawArgs: [],
1835
1835
  signal,
1836
- finish: finishInvocation,
1836
+ handled: handledInvocation,
1837
1837
  stdout: io.stdout,
1838
1838
  stderr: io.stderr,
1839
1839
  ctx: unavailableContext
package/dist/tooling.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Dt as CommandSnapshot, N as FlagEnvironment, Ot as FlagSnapshot, P as parseFlagValues, Pt as ExtensionId, g as DeclaredDefault, m as CommandSection } from "./context-9ee4iljp.js";
1
+ import { Dt as CommandSnapshot, N as FlagEnvironment, Ot as FlagSnapshot, P as parseFlagValues, Pt as ExtensionId, g as DeclaredDefault, m as CommandSection } from "./context-VtqvNs9V.js";
2
2
  import { BUILD_OUT_DIR_ENV } from "@crustjs/utils/artifacts";
3
3
  //#region src/command/invocation.d.ts
4
4
  /**
package/dist/tooling.js CHANGED
@@ -1,4 +1,4 @@
1
- import { s as parseFlagValues, t as SNAPSHOT_PATH_ENV, v as isListed, x as visibleSectionsFor, y as sectionsFor } from "./invocation-CD299Gic.js";
1
+ import { s as parseFlagValues, t as SNAPSHOT_PATH_ENV, v as isListed, x as visibleSectionsFor, y as sectionsFor } from "./invocation-OsKzCgr-.js";
2
2
  import { BUILD_OUT_DIR_ENV } from "@crustjs/utils/artifacts";
3
3
  //#region src/command/documentation.ts
4
4
  function isNonFiniteNumber(value) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crustjs/core",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "Core library for the Crust CLI framework",
5
5
  "type": "module",
6
6
  "sideEffects": false,