@gunshi/definition 1.0.0-beta.0 → 1.0.0-beta.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.
Files changed (2) hide show
  1. package/lib/index.d.ts +6 -45
  2. package/package.json +3 -3
package/lib/index.d.ts CHANGED
@@ -55,9 +55,6 @@ interface ArgToken {
55
55
  */
56
56
  inlineValue?: boolean | undefined;
57
57
  }
58
- /**
59
- * Parser Options.
60
- */
61
58
  //#endregion
62
59
  //#region ../../node_modules/.pnpm/args-tokens@1.0.0-beta.1/node_modules/args-tokens/lib/resolver.d.ts
63
60
  //#region src/resolver.d.ts
@@ -638,7 +635,7 @@ interface Args {
638
635
  *
639
636
  * @typeParam T - {@link Args | Arguments} which is an object that defines the command line arguments.
640
637
  */
641
- type ArgValues<T> = T extends Args ? ResolveArgValues<T, { [Arg in keyof T]: ExtractOptionValue<T[Arg]> }> : {
638
+ type ArgValues<T> = T extends Args ? ResolveArgValues<T, { [Arg in keyof T]: ExtractOptionValue<T[Arg]>; }> : {
642
639
  [option: string]: string | boolean | number | (string | boolean | number)[] | undefined;
643
640
  };
644
641
  /**
@@ -670,7 +667,7 @@ type ResolveOptionValue<A extends ArgSchema, T> = A['multiple'] extends true ? T
670
667
  *
671
668
  * @internal
672
669
  */
673
- type ResolveArgValues<A extends Args, V extends Record<keyof A, unknown>> = { -readonly [Arg in keyof A]?: IsPresentArg<A[Arg]> extends true ? unknown : V[Arg] } & { -readonly [Arg in keyof A as IsPresentArg<A[Arg]> extends true ? Arg : never]: V[Arg] } extends (infer P) ? { [K in keyof P]: P[K] } : never;
670
+ type ResolveArgValues<A extends Args, V extends Record<keyof A, unknown>> = { -readonly [Arg in keyof A]?: IsPresentArg<A[Arg]> extends true ? unknown : V[Arg]; } & { -readonly [Arg in keyof A as IsPresentArg<A[Arg]> extends true ? Arg : never]: V[Arg]; } extends (infer P) ? { [K in keyof P]: P[K]; } : never;
674
671
  /**
675
672
  * Whether an argument with the schema `S` has a value: with a default, with `required: true` or as
676
673
  * a required positional argument. For a union of schemas, only when each schema of the union has
@@ -678,16 +675,6 @@ type ResolveArgValues<A extends Args, V extends Record<keyof A, unknown>> = { -r
678
675
  * value, as {@link FilterArgs} does.
679
676
  */
680
677
  type IsPresentArg<S extends ArgSchema> = S extends ArgSchema ? true extends (S['default'] extends {} ? true : S['required'] extends true ? true : false) ? true : IsRequiredPositionalArg<S> : never;
681
- /**
682
- * Filters the arguments based on their default values.
683
- *
684
- * @typeParam A - {@link Args | Arguments}, which is an object that defines the command line arguments.
685
- * @typeParam V - Resolvable argument values.
686
- * @typeParam K - Key of the {@link ArgSchema | argument schema} to filter by.
687
- *
688
- * @internal
689
- */
690
-
691
678
  type IsRequiredPositionalArg<A extends ArgSchema> = A['type'] extends 'positional' ? A['multiple'] extends true ? A['required'] extends true ? true : false : MayBeUnrequired<A> extends true ? A['default'] extends {} ? true : false : true : false;
692
679
  /**
693
680
  * Whether the `required` of `A` may be `false`. An optional `required` of type `boolean`, as in
@@ -698,10 +685,6 @@ type IsRequiredPositionalArg<A extends ArgSchema> = A['type'] extends 'positiona
698
685
  type MayBeUnrequired<A extends ArgSchema> = false extends A['required'] ? [A] extends [{
699
686
  required: unknown;
700
687
  }] ? true : boolean | undefined extends A['required'] ? false : true : false;
701
- /**
702
- * An arguments for {@link resolveArgs | resolve arguments}.
703
- */
704
-
705
688
  /**
706
689
  * Tracks which arguments were explicitly provided by the user.
707
690
  *
@@ -714,7 +697,7 @@ type MayBeUnrequired<A extends ArgSchema> = false extends A['required'] ? [A] ex
714
697
  *
715
698
  * @typeParam A - {@link Args | Arguments}, which is an object that defines the command line arguments.
716
699
  */
717
- type ArgExplicitlyProvided<A extends Args> = { [K in keyof A]: boolean };
700
+ type ArgExplicitlyProvided<A extends Args> = { [K in keyof A]: boolean; };
718
701
  //#endregion
719
702
  //#region ../gunshi/src/plugin/context.d.ts
720
703
  /**
@@ -848,7 +831,7 @@ type Awaitable<T> = T | Promise<T>;
848
831
  *
849
832
  * @typeParam T - The type to be prettified.
850
833
  */
851
- type Prettify<T> = { [K in keyof T]: T[K] } & {};
834
+ type Prettify<T> = { [K in keyof T]: T[K]; } & {};
852
835
  /**
853
836
  * Extend command context type. This type is used to extend the command context with additional properties at {@linkcode CommandContext.extensions}.
854
837
  *
@@ -1566,7 +1549,7 @@ type CommandLoader<G extends GunshiParamsConstraint = DefaultGunshiParams> = ()
1566
1549
  *
1567
1550
  * @internal
1568
1551
  */
1569
- type ExtractExtensionValues<E extends Record<string, CommandContextExtension>> = { [K in keyof E]: E[K] extends CommandContextExtension<infer T> ? T : never };
1552
+ type ExtractExtensionValues<E extends Record<string, CommandContextExtension>> = { [K in keyof E]: E[K] extends CommandContextExtension<infer T> ? T : never; };
1570
1553
  /**
1571
1554
  * Return type of {@link createCommandContext}
1572
1555
  *
@@ -1647,22 +1630,7 @@ interface CommandContextParams<G extends GunshiParams | {
1647
1630
  * @param param - A {@link CommandContextParams | parameters} to create a command context.
1648
1631
  * @returns A {@link CommandContext | command context}, which is readonly.
1649
1632
  */
1650
- declare function createCommandContext<G extends GunshiParamsConstraint = DefaultGunshiParams, V extends ArgValues<ExtractArgs<G>> = ArgValues<ExtractArgs<G>>, C extends Command<G> | LazyCommand<G> = Command<G>, E extends Record<string, CommandContextExtension> = {}>({
1651
- args,
1652
- explicit,
1653
- values,
1654
- positionals,
1655
- rest,
1656
- argv,
1657
- tokens,
1658
- command,
1659
- extensions,
1660
- cliOptions,
1661
- callMode,
1662
- commandPath,
1663
- omitted,
1664
- validationError
1665
- }: CommandContextParams<G, V, C, E>): Promise<CommandContextResult<G, E>>;
1633
+ declare function createCommandContext<G extends GunshiParamsConstraint = DefaultGunshiParams, V extends ArgValues<ExtractArgs<G>> = ArgValues<ExtractArgs<G>>, C extends Command<G> | LazyCommand<G> = Command<G>, E extends Record<string, CommandContextExtension> = {}>({ args, explicit, values, positionals, rest, argv, tokens, command, extensions, cliOptions, callMode, commandPath, omitted, validationError }: CommandContextParams<G, V, C, E>): Promise<CommandContextResult<G, E>>;
1666
1634
  //#endregion
1667
1635
  //#region ../gunshi/src/definition.d.ts
1668
1636
  /**
@@ -1884,12 +1852,5 @@ type LazyWithTypesReturn<FullG extends GunshiParamsConstraint> = <D extends Part
1884
1852
  * @since v0.27.0
1885
1853
  */
1886
1854
  declare function lazyWithTypes<G extends GunshiParamsConstraint>(): LazyWithTypesReturn<NormalizeToGunshiParams<G>>;
1887
- //#endregion
1888
- //#region src/index.d.ts
1889
- /**
1890
- * @author kazuya kawaguchi (a.k.a. kazupon)
1891
- * @license MIT
1892
- */
1893
-
1894
1855
  //#endregion
1895
1856
  export { type ArgSchema, type ArgValues, type Args, type Command, type CommandContextParams, type CommandLoader, type CommandRunner, type DefaultGunshiParams, type ExtendContext, type GunshiParams, type LazyCommand, createCommandContext, define, defineWithTypes, lazy, lazyWithTypes };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gunshi/definition",
3
3
  "description": "utilities for gunshi command definition",
4
- "version": "1.0.0-beta.0",
4
+ "version": "1.0.0-beta.2",
5
5
  "author": {
6
6
  "name": "kazuya kawaguchi",
7
7
  "email": "kawakazu80@gmail.com"
@@ -53,11 +53,11 @@
53
53
  },
54
54
  "devDependencies": {
55
55
  "deno": "^2.7.14",
56
+ "gunshi": "1.0.0-beta.2",
56
57
  "jsr": "^0.14.3",
57
58
  "jsr-exports-lint": "^0.4.2",
58
59
  "publint": "^0.3.20",
59
- "tsdown": "0.21.0",
60
- "gunshi": "1.0.0-beta.0"
60
+ "tsdown": "0.22.14"
61
61
  },
62
62
  "scripts": {
63
63
  "build": "tsdown",