@wentools/zli 0.2.0-beta.2dc33a43
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.
- package/LICENSE +21 -0
- package/README.md +226 -0
- package/esm/_dnt.shims.d.ts +6 -0
- package/esm/_dnt.shims.d.ts.map +1 -0
- package/esm/_dnt.shims.js +61 -0
- package/esm/arg.d.ts +9 -0
- package/esm/arg.d.ts.map +1 -0
- package/esm/arg.js +4 -0
- package/esm/create_command.d.ts +28 -0
- package/esm/create_command.d.ts.map +1 -0
- package/esm/create_command.js +17 -0
- package/esm/create_command_directory.d.ts +35 -0
- package/esm/create_command_directory.d.ts.map +1 -0
- package/esm/create_command_directory.js +31 -0
- package/esm/create_flag_arg.d.ts +23 -0
- package/esm/create_flag_arg.d.ts.map +1 -0
- package/esm/create_flag_arg.js +14 -0
- package/esm/create_positional_arg.d.ts +24 -0
- package/esm/create_positional_arg.d.ts.map +1 -0
- package/esm/create_positional_arg.js +15 -0
- package/esm/deps/jsr.io/@wentools/result/0.1.0/src/err/err.d.ts +38 -0
- package/esm/deps/jsr.io/@wentools/result/0.1.0/src/err/err.d.ts.map +1 -0
- package/esm/deps/jsr.io/@wentools/result/0.1.0/src/err/err.js +38 -0
- package/esm/deps/jsr.io/@wentools/result/0.1.0/src/err/index.d.ts +2 -0
- package/esm/deps/jsr.io/@wentools/result/0.1.0/src/err/index.d.ts.map +1 -0
- package/esm/deps/jsr.io/@wentools/result/0.1.0/src/err/index.js +1 -0
- package/esm/deps/jsr.io/@wentools/result/0.1.0/src/index.d.ts +156 -0
- package/esm/deps/jsr.io/@wentools/result/0.1.0/src/index.d.ts.map +1 -0
- package/esm/deps/jsr.io/@wentools/result/0.1.0/src/index.js +65 -0
- package/esm/deps/jsr.io/@wentools/result/0.1.0/src/is_result/index.d.ts +2 -0
- package/esm/deps/jsr.io/@wentools/result/0.1.0/src/is_result/index.d.ts.map +1 -0
- package/esm/deps/jsr.io/@wentools/result/0.1.0/src/is_result/index.js +1 -0
- package/esm/deps/jsr.io/@wentools/result/0.1.0/src/is_result/is_result.d.ts +11 -0
- package/esm/deps/jsr.io/@wentools/result/0.1.0/src/is_result/is_result.d.ts.map +1 -0
- package/esm/deps/jsr.io/@wentools/result/0.1.0/src/is_result/is_result.js +14 -0
- package/esm/deps/jsr.io/@wentools/result/0.1.0/src/propagate_err/index.d.ts +2 -0
- package/esm/deps/jsr.io/@wentools/result/0.1.0/src/propagate_err/index.d.ts.map +1 -0
- package/esm/deps/jsr.io/@wentools/result/0.1.0/src/propagate_err/index.js +1 -0
- package/esm/deps/jsr.io/@wentools/result/0.1.0/src/propagate_err/propagate_err.d.ts +28 -0
- package/esm/deps/jsr.io/@wentools/result/0.1.0/src/propagate_err/propagate_err.d.ts.map +1 -0
- package/esm/deps/jsr.io/@wentools/result/0.1.0/src/propagate_err/propagate_err.js +30 -0
- package/esm/detect_arg_conflicts/detect_arg_conflicts.d.ts +19 -0
- package/esm/detect_arg_conflicts/detect_arg_conflicts.d.ts.map +1 -0
- package/esm/detect_arg_conflicts/detect_arg_conflicts.js +54 -0
- package/esm/detect_arg_conflicts/mod.d.ts +3 -0
- package/esm/detect_arg_conflicts/mod.d.ts.map +1 -0
- package/esm/detect_arg_conflicts/mod.js +1 -0
- package/esm/generate_help_text/generate_help_text.d.ts +13 -0
- package/esm/generate_help_text/generate_help_text.d.ts.map +1 -0
- package/esm/generate_help_text/generate_help_text.js +54 -0
- package/esm/generate_help_text/mod.d.ts +2 -0
- package/esm/generate_help_text/mod.d.ts.map +1 -0
- package/esm/generate_help_text/mod.js +1 -0
- package/esm/infer_args_type.d.ts +29 -0
- package/esm/infer_args_type.d.ts.map +1 -0
- package/esm/infer_args_type.js +6 -0
- package/esm/is_boolean_schema/is_boolean_schema.d.ts +12 -0
- package/esm/is_boolean_schema/is_boolean_schema.d.ts.map +1 -0
- package/esm/is_boolean_schema/is_boolean_schema.js +21 -0
- package/esm/is_boolean_schema/mod.d.ts +2 -0
- package/esm/is_boolean_schema/mod.d.ts.map +1 -0
- package/esm/is_boolean_schema/mod.js +1 -0
- package/esm/mod.d.ts +8 -0
- package/esm/mod.d.ts.map +1 -0
- package/esm/mod.js +1 -0
- package/esm/package.json +3 -0
- package/esm/parse_args/mod.d.ts +3 -0
- package/esm/parse_args/mod.d.ts.map +1 -0
- package/esm/parse_args/mod.js +1 -0
- package/esm/parse_args/parse_args.d.ts +24 -0
- package/esm/parse_args/parse_args.d.ts.map +1 -0
- package/esm/parse_args/parse_args.js +89 -0
- package/esm/run.d.ts +19 -0
- package/esm/run.d.ts.map +1 -0
- package/esm/run.js +152 -0
- package/esm/validate_args/mod.d.ts +3 -0
- package/esm/validate_args/mod.d.ts.map +1 -0
- package/esm/validate_args/mod.js +1 -0
- package/esm/validate_args/validate_args.d.ts +20 -0
- package/esm/validate_args/validate_args.d.ts.map +1 -0
- package/esm/validate_args/validate_args.js +23 -0
- package/esm/zli.d.ts +118 -0
- package/esm/zli.d.ts.map +1 -0
- package/esm/zli.js +124 -0
- package/package.json +39 -0
- package/script/_dnt.shims.d.ts +6 -0
- package/script/_dnt.shims.d.ts.map +1 -0
- package/script/_dnt.shims.js +65 -0
- package/script/arg.d.ts +9 -0
- package/script/arg.d.ts.map +1 -0
- package/script/arg.js +5 -0
- package/script/create_command.d.ts +28 -0
- package/script/create_command.d.ts.map +1 -0
- package/script/create_command.js +20 -0
- package/script/create_command_directory.d.ts +35 -0
- package/script/create_command_directory.d.ts.map +1 -0
- package/script/create_command_directory.js +34 -0
- package/script/create_flag_arg.d.ts +23 -0
- package/script/create_flag_arg.d.ts.map +1 -0
- package/script/create_flag_arg.js +17 -0
- package/script/create_positional_arg.d.ts +24 -0
- package/script/create_positional_arg.d.ts.map +1 -0
- package/script/create_positional_arg.js +18 -0
- package/script/deps/jsr.io/@wentools/result/0.1.0/src/err/err.d.ts +38 -0
- package/script/deps/jsr.io/@wentools/result/0.1.0/src/err/err.d.ts.map +1 -0
- package/script/deps/jsr.io/@wentools/result/0.1.0/src/err/err.js +41 -0
- package/script/deps/jsr.io/@wentools/result/0.1.0/src/err/index.d.ts +2 -0
- package/script/deps/jsr.io/@wentools/result/0.1.0/src/err/index.d.ts.map +1 -0
- package/script/deps/jsr.io/@wentools/result/0.1.0/src/err/index.js +5 -0
- package/script/deps/jsr.io/@wentools/result/0.1.0/src/index.d.ts +156 -0
- package/script/deps/jsr.io/@wentools/result/0.1.0/src/index.d.ts.map +1 -0
- package/script/deps/jsr.io/@wentools/result/0.1.0/src/index.js +77 -0
- package/script/deps/jsr.io/@wentools/result/0.1.0/src/is_result/index.d.ts +2 -0
- package/script/deps/jsr.io/@wentools/result/0.1.0/src/is_result/index.d.ts.map +1 -0
- package/script/deps/jsr.io/@wentools/result/0.1.0/src/is_result/index.js +5 -0
- package/script/deps/jsr.io/@wentools/result/0.1.0/src/is_result/is_result.d.ts +11 -0
- package/script/deps/jsr.io/@wentools/result/0.1.0/src/is_result/is_result.d.ts.map +1 -0
- package/script/deps/jsr.io/@wentools/result/0.1.0/src/is_result/is_result.js +17 -0
- package/script/deps/jsr.io/@wentools/result/0.1.0/src/propagate_err/index.d.ts +2 -0
- package/script/deps/jsr.io/@wentools/result/0.1.0/src/propagate_err/index.d.ts.map +1 -0
- package/script/deps/jsr.io/@wentools/result/0.1.0/src/propagate_err/index.js +5 -0
- package/script/deps/jsr.io/@wentools/result/0.1.0/src/propagate_err/propagate_err.d.ts +28 -0
- package/script/deps/jsr.io/@wentools/result/0.1.0/src/propagate_err/propagate_err.d.ts.map +1 -0
- package/script/deps/jsr.io/@wentools/result/0.1.0/src/propagate_err/propagate_err.js +33 -0
- package/script/detect_arg_conflicts/detect_arg_conflicts.d.ts +19 -0
- package/script/detect_arg_conflicts/detect_arg_conflicts.d.ts.map +1 -0
- package/script/detect_arg_conflicts/detect_arg_conflicts.js +57 -0
- package/script/detect_arg_conflicts/mod.d.ts +3 -0
- package/script/detect_arg_conflicts/mod.d.ts.map +1 -0
- package/script/detect_arg_conflicts/mod.js +5 -0
- package/script/generate_help_text/generate_help_text.d.ts +13 -0
- package/script/generate_help_text/generate_help_text.d.ts.map +1 -0
- package/script/generate_help_text/generate_help_text.js +57 -0
- package/script/generate_help_text/mod.d.ts +2 -0
- package/script/generate_help_text/mod.d.ts.map +1 -0
- package/script/generate_help_text/mod.js +5 -0
- package/script/infer_args_type.d.ts +29 -0
- package/script/infer_args_type.d.ts.map +1 -0
- package/script/infer_args_type.js +7 -0
- package/script/is_boolean_schema/is_boolean_schema.d.ts +12 -0
- package/script/is_boolean_schema/is_boolean_schema.d.ts.map +1 -0
- package/script/is_boolean_schema/is_boolean_schema.js +24 -0
- package/script/is_boolean_schema/mod.d.ts +2 -0
- package/script/is_boolean_schema/mod.d.ts.map +1 -0
- package/script/is_boolean_schema/mod.js +5 -0
- package/script/mod.d.ts +8 -0
- package/script/mod.d.ts.map +1 -0
- package/script/mod.js +5 -0
- package/script/package.json +3 -0
- package/script/parse_args/mod.d.ts +3 -0
- package/script/parse_args/mod.d.ts.map +1 -0
- package/script/parse_args/mod.js +5 -0
- package/script/parse_args/parse_args.d.ts +24 -0
- package/script/parse_args/parse_args.d.ts.map +1 -0
- package/script/parse_args/parse_args.js +92 -0
- package/script/run.d.ts +19 -0
- package/script/run.d.ts.map +1 -0
- package/script/run.js +189 -0
- package/script/validate_args/mod.d.ts +3 -0
- package/script/validate_args/mod.d.ts.map +1 -0
- package/script/validate_args/mod.js +5 -0
- package/script/validate_args/validate_args.d.ts +20 -0
- package/script/validate_args/validate_args.d.ts.map +1 -0
- package/script/validate_args/validate_args.js +26 -0
- package/script/zli.d.ts +118 -0
- package/script/zli.d.ts.map +1 -0
- package/script/zli.js +127 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { err as _Err, ok, type Result, type Err, ResultAsync, okAsync as neverthrowOkAsync } from 'neverthrow';
|
|
2
|
+
/**
|
|
3
|
+
* Create an error object with literal type preservation
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* const error = makeErr('not_found', 'User not found')
|
|
7
|
+
* // ✅ Type: { type: 'not_found', message: string }
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const error = makeErr('not_found', 'User not found', { userId: '123' })
|
|
11
|
+
* // ✅ Type: { type: 'not_found', message: string, userId: string }
|
|
12
|
+
*/
|
|
13
|
+
declare const makeErr: <const TType extends string, TAdditional extends Record<string, unknown> = Record<string, never>>(type: TType, message: string, additional?: TAdditional) => {
|
|
14
|
+
type: TType;
|
|
15
|
+
message: string;
|
|
16
|
+
} & TAdditional;
|
|
17
|
+
/**
|
|
18
|
+
* Create an async Err ResultAsync with automatic literal type preservation
|
|
19
|
+
*
|
|
20
|
+
* Async version of err() - same signature, returns ResultAsync instead of Result.
|
|
21
|
+
* Uses TypeScript 5.0+ const type parameters to preserve literal types automatically.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // ✅ Simple error
|
|
25
|
+
* return errAsync('not_found', 'User not found')
|
|
26
|
+
* // Type: ResultAsync<never, { type: 'not_found', message: string }>
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* // ✅ Error with additional properties
|
|
30
|
+
* return errAsync('not_found', 'User not found', { userId: '123' })
|
|
31
|
+
* // Type: ResultAsync<never, { type: 'not_found', message: string, userId: string }>
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* // ✅ Error with complex additional data
|
|
35
|
+
* return errAsync('validation_failed', 'Invalid input', {
|
|
36
|
+
* field: 'email',
|
|
37
|
+
* errors: ['Invalid format']
|
|
38
|
+
* })
|
|
39
|
+
* // Type: ResultAsync<never, { type: 'validation_failed', message: string, field: string, errors: string[] }>
|
|
40
|
+
*/
|
|
41
|
+
declare const errAsync: <const TType extends string, TAdditional extends Record<string, unknown> = Record<string, never>>(type: TType, message: string, additional?: TAdditional) => ResultAsync<never, {
|
|
42
|
+
type: TType;
|
|
43
|
+
message: string;
|
|
44
|
+
} & TAdditional>;
|
|
45
|
+
/**
|
|
46
|
+
* Re-export okAsync from neverthrow for consistency
|
|
47
|
+
* Creates a successful ResultAsync
|
|
48
|
+
*/
|
|
49
|
+
declare const okAsync: typeof neverthrowOkAsync;
|
|
50
|
+
/**
|
|
51
|
+
* Utility type for defining error types concisely
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* // Instead of:
|
|
55
|
+
* type UserNotFoundError = {
|
|
56
|
+
* type: 'user_not_found'
|
|
57
|
+
* message: string
|
|
58
|
+
* userId: UserId
|
|
59
|
+
* }
|
|
60
|
+
*
|
|
61
|
+
* // Write:
|
|
62
|
+
* type UserNotFoundError = ErrorType<'user_not_found', { userId: UserId }>
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* // Error without additional properties:
|
|
66
|
+
* type InvalidOperationError = ErrorType<'invalid_operation'>
|
|
67
|
+
*/
|
|
68
|
+
type ErrorType<TType extends string, TAdditional extends Record<string, unknown> = Record<string, never>> = {
|
|
69
|
+
type: TType;
|
|
70
|
+
message: string;
|
|
71
|
+
} & TAdditional;
|
|
72
|
+
/**
|
|
73
|
+
* Extract the error type from a Result or Promise<Result>
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* // From async function
|
|
77
|
+
* const getUser = async (id: string): Promise<Result<User, UserNotFoundError>> => { ... }
|
|
78
|
+
* type GetUserError = ExtractError<ReturnType<typeof getUser>>
|
|
79
|
+
* // Type: UserNotFoundError
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* // From Result type directly
|
|
83
|
+
* type MyResult = Result<User, InvalidError>
|
|
84
|
+
* type MyError = ExtractError<MyResult>
|
|
85
|
+
* // Type: InvalidError
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* // Works with composed errors
|
|
89
|
+
* const replaceVersion = async (): Promise<Result<Version, VersionNotFoundError | VersionExistsError>> => { ... }
|
|
90
|
+
* type ReplaceError = ExtractError<ReturnType<typeof replaceVersion>>
|
|
91
|
+
* // Type: VersionNotFoundError | VersionExistsError
|
|
92
|
+
*/
|
|
93
|
+
type ExtractError<TResultOrPromise> = TResultOrPromise extends Promise<Result<unknown, infer TError>> ? TError : TResultOrPromise extends Result<unknown, infer TError> ? TError : never;
|
|
94
|
+
/**
|
|
95
|
+
* Extract the error type from a function that returns Result or Promise<Result>
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* // Simple extraction
|
|
99
|
+
* const getUser = async (id: string): Promise<Result<User, UserNotFoundError>> => { ... }
|
|
100
|
+
* type GetUserError = ExtractFnError<typeof getUser>
|
|
101
|
+
* // Type: UserNotFoundError
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* // Compose errors from multiple functions
|
|
105
|
+
* const getUser = async (id: string): Promise<Result<User, UserNotFoundError>> => { ... }
|
|
106
|
+
* const getImage = async (id: string): Promise<Result<Image, ImageNotFoundError>> => { ... }
|
|
107
|
+
* type CombinedError = ExtractFnError<typeof getUser> | ExtractFnError<typeof getImage>
|
|
108
|
+
* // Type: UserNotFoundError | ImageNotFoundError
|
|
109
|
+
*/
|
|
110
|
+
type ExtractFnError<TFunction extends (...args: unknown[]) => unknown> = ExtractError<ReturnType<TFunction>>;
|
|
111
|
+
/**
|
|
112
|
+
* Extract and combine error types from multiple Result or Promise<Result> types
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* type UserResult = Result<User, UserNotFoundError>
|
|
116
|
+
* type ImageResult = Promise<Result<Image, ImageNotFoundError>>
|
|
117
|
+
* type ProductResult = Result<Product, ProductNotFoundError>
|
|
118
|
+
*
|
|
119
|
+
* type CombinedError = ExtractErrors<[UserResult, ImageResult, ProductResult]>
|
|
120
|
+
* // Type: UserNotFoundError | ImageNotFoundError | ProductNotFoundError
|
|
121
|
+
*/
|
|
122
|
+
type ExtractErrors<TResults extends readonly unknown[]> = TResults extends readonly [
|
|
123
|
+
infer TFirst,
|
|
124
|
+
...infer TRest
|
|
125
|
+
] ? ExtractError<TFirst> | ExtractErrors<TRest> : never;
|
|
126
|
+
/**
|
|
127
|
+
* Extract and combine error types from multiple functions that return Result or Promise<Result>
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* const getUser = async (id: string): Promise<Result<User, UserNotFoundError>> => { ... }
|
|
131
|
+
* const getImage = async (id: string): Promise<Result<Image, ImageNotFoundError>> => { ... }
|
|
132
|
+
* const deleteProduct = async (id: string): Promise<Result<void, ProductNotFoundError>> => { ... }
|
|
133
|
+
*
|
|
134
|
+
* type CombinedError = ExtractFnsError<[typeof getUser, typeof getImage, typeof deleteProduct]>
|
|
135
|
+
* // Type: UserNotFoundError | ImageNotFoundError | ProductNotFoundError
|
|
136
|
+
*/
|
|
137
|
+
type ExtractFnsError<TFunctions extends readonly ((...args: unknown[]) => unknown)[]> = TFunctions extends readonly [
|
|
138
|
+
infer TFirst,
|
|
139
|
+
...infer TRest extends readonly ((...args: unknown[]) => unknown)[]
|
|
140
|
+
] ? ExtractFnError<TFirst & ((...args: unknown[]) => unknown)> | ExtractFnsError<TRest> : never;
|
|
141
|
+
/**
|
|
142
|
+
* Raw error function from neverthrow - use for lifting database errors directly
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* const seedResult = await songSeeds.get.one.byId(songSeedId)
|
|
146
|
+
* if (seedResult.isErr()) {
|
|
147
|
+
* return rawErr(seedResult.error)
|
|
148
|
+
* }
|
|
149
|
+
*/
|
|
150
|
+
declare const rawErr: typeof _Err;
|
|
151
|
+
export { makeErr, errAsync, ok, okAsync, rawErr, _Err, ResultAsync };
|
|
152
|
+
export type { Result, Err, ErrorType, ExtractError, ExtractFnError, ExtractErrors, ExtractFnsError };
|
|
153
|
+
export { err } from './err/index.js';
|
|
154
|
+
export { isResult } from './is_result/index.js';
|
|
155
|
+
export { propagateErr } from './propagate_err/index.js';
|
|
156
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/deps/jsr.io/@wentools/result/0.1.0/src/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { err as _Err, ok, ResultAsync, errAsync as neverthrowErrAsync, okAsync as neverthrowOkAsync, } from 'neverthrow';
|
|
2
|
+
/**
|
|
3
|
+
* Create an error object with literal type preservation
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* const error = makeErr('not_found', 'User not found')
|
|
7
|
+
* // ✅ Type: { type: 'not_found', message: string }
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const error = makeErr('not_found', 'User not found', { userId: '123' })
|
|
11
|
+
* // ✅ Type: { type: 'not_found', message: string, userId: string }
|
|
12
|
+
*/
|
|
13
|
+
const makeErr = (type, message, additional) => ({
|
|
14
|
+
...additional,
|
|
15
|
+
type,
|
|
16
|
+
message,
|
|
17
|
+
});
|
|
18
|
+
/**
|
|
19
|
+
* Create an async Err ResultAsync with automatic literal type preservation
|
|
20
|
+
*
|
|
21
|
+
* Async version of err() - same signature, returns ResultAsync instead of Result.
|
|
22
|
+
* Uses TypeScript 5.0+ const type parameters to preserve literal types automatically.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* // ✅ Simple error
|
|
26
|
+
* return errAsync('not_found', 'User not found')
|
|
27
|
+
* // Type: ResultAsync<never, { type: 'not_found', message: string }>
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* // ✅ Error with additional properties
|
|
31
|
+
* return errAsync('not_found', 'User not found', { userId: '123' })
|
|
32
|
+
* // Type: ResultAsync<never, { type: 'not_found', message: string, userId: string }>
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* // ✅ Error with complex additional data
|
|
36
|
+
* return errAsync('validation_failed', 'Invalid input', {
|
|
37
|
+
* field: 'email',
|
|
38
|
+
* errors: ['Invalid format']
|
|
39
|
+
* })
|
|
40
|
+
* // Type: ResultAsync<never, { type: 'validation_failed', message: string, field: string, errors: string[] }>
|
|
41
|
+
*/
|
|
42
|
+
const errAsync = (type, message, additional) => neverthrowErrAsync({
|
|
43
|
+
...additional,
|
|
44
|
+
type,
|
|
45
|
+
message,
|
|
46
|
+
});
|
|
47
|
+
/**
|
|
48
|
+
* Re-export okAsync from neverthrow for consistency
|
|
49
|
+
* Creates a successful ResultAsync
|
|
50
|
+
*/
|
|
51
|
+
const okAsync = neverthrowOkAsync;
|
|
52
|
+
/**
|
|
53
|
+
* Raw error function from neverthrow - use for lifting database errors directly
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* const seedResult = await songSeeds.get.one.byId(songSeedId)
|
|
57
|
+
* if (seedResult.isErr()) {
|
|
58
|
+
* return rawErr(seedResult.error)
|
|
59
|
+
* }
|
|
60
|
+
*/
|
|
61
|
+
const rawErr = _Err;
|
|
62
|
+
export { makeErr, errAsync, ok, okAsync, rawErr, _Err, ResultAsync };
|
|
63
|
+
export { err } from './err/index.js';
|
|
64
|
+
export { isResult } from './is_result/index.js';
|
|
65
|
+
export { propagateErr } from './propagate_err/index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../src/deps/jsr.io/@wentools/result/0.1.0/src/is_result/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { isResult } from './is_result.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if a value is a neverthrow Result type
|
|
3
|
+
*
|
|
4
|
+
* Uses duck typing to detect Result objects without importing neverthrow types.
|
|
5
|
+
*/
|
|
6
|
+
declare const isResult: (value: unknown) => value is {
|
|
7
|
+
isOk: () => boolean;
|
|
8
|
+
isErr: () => boolean;
|
|
9
|
+
};
|
|
10
|
+
export { isResult };
|
|
11
|
+
//# sourceMappingURL=is_result.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is_result.d.ts","sourceRoot":"","sources":["../../../../../../../../src/deps/jsr.io/@wentools/result/0.1.0/src/is_result/is_result.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,QAAA,MAAM,QAAQ,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI;IAAE,IAAI,EAAE,MAAM,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,OAAO,CAAA;CAStF,CAAA;AAED,OAAO,EAAE,QAAQ,EAAE,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if a value is a neverthrow Result type
|
|
3
|
+
*
|
|
4
|
+
* Uses duck typing to detect Result objects without importing neverthrow types.
|
|
5
|
+
*/
|
|
6
|
+
const isResult = (value) => {
|
|
7
|
+
return (value !== null &&
|
|
8
|
+
typeof value === 'object' &&
|
|
9
|
+
'isOk' in value &&
|
|
10
|
+
'isErr' in value &&
|
|
11
|
+
typeof value.isOk === 'function' &&
|
|
12
|
+
typeof value.isErr === 'function');
|
|
13
|
+
};
|
|
14
|
+
export { isResult };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../src/deps/jsr.io/@wentools/result/0.1.0/src/propagate_err/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { propagateErr } from './propagate_err.js';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Result } from 'neverthrow';
|
|
2
|
+
/**
|
|
3
|
+
* Propagates an error Result to a different success type context.
|
|
4
|
+
*
|
|
5
|
+
* This is safe because error Results never contain the success value - only the error.
|
|
6
|
+
* TypeScript's structural typing prevents direct assignment of Result<T, E> to Result<U, E>
|
|
7
|
+
* even though the error type is identical and we're in the error branch.
|
|
8
|
+
*
|
|
9
|
+
* Common use case: Early return from a function that creates multiple items. If creating
|
|
10
|
+
* item 2 fails with Result<Item, DatabaseError>, we need to return Result<Item[], DatabaseError>.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* const result = await createUser(db, data) // Result<User, DatabaseError>
|
|
14
|
+
* if (result.isErr()) {
|
|
15
|
+
* // Need to return Result<Profile, DatabaseError> but have Result<User, DatabaseError>
|
|
16
|
+
* return propagateErr(result)
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // In bulk creation, propagate single-item error to array context
|
|
21
|
+
* const itemResult = await createItem(data) // Result<Item, Error>
|
|
22
|
+
* if (itemResult.isErr()) {
|
|
23
|
+
* return propagateErr<Item[], Error>(itemResult) // Result<Item[], Error>
|
|
24
|
+
* }
|
|
25
|
+
*/
|
|
26
|
+
declare const propagateErr: <TNew, E>(errorResult: Result<unknown, E>) => Result<TNew, E>;
|
|
27
|
+
export { propagateErr };
|
|
28
|
+
//# sourceMappingURL=propagate_err.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"propagate_err.d.ts","sourceRoot":"","sources":["../../../../../../../../src/deps/jsr.io/@wentools/result/0.1.0/src/propagate_err/propagate_err.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAExC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,QAAA,MAAM,YAAY,GAAI,IAAI,EAAE,CAAC,EAAE,aAAa,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,KAAG,MAAM,CAAC,IAAI,EAAE,CAAC,CAI9E,CAAA;AAED,OAAO,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Propagates an error Result to a different success type context.
|
|
3
|
+
*
|
|
4
|
+
* This is safe because error Results never contain the success value - only the error.
|
|
5
|
+
* TypeScript's structural typing prevents direct assignment of Result<T, E> to Result<U, E>
|
|
6
|
+
* even though the error type is identical and we're in the error branch.
|
|
7
|
+
*
|
|
8
|
+
* Common use case: Early return from a function that creates multiple items. If creating
|
|
9
|
+
* item 2 fails with Result<Item, DatabaseError>, we need to return Result<Item[], DatabaseError>.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const result = await createUser(db, data) // Result<User, DatabaseError>
|
|
13
|
+
* if (result.isErr()) {
|
|
14
|
+
* // Need to return Result<Profile, DatabaseError> but have Result<User, DatabaseError>
|
|
15
|
+
* return propagateErr(result)
|
|
16
|
+
* }
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // In bulk creation, propagate single-item error to array context
|
|
20
|
+
* const itemResult = await createItem(data) // Result<Item, Error>
|
|
21
|
+
* if (itemResult.isErr()) {
|
|
22
|
+
* return propagateErr<Item[], Error>(itemResult) // Result<Item[], Error>
|
|
23
|
+
* }
|
|
24
|
+
*/
|
|
25
|
+
const propagateErr = (errorResult) => {
|
|
26
|
+
// Type assertion is safe: we're only propagating errors, and error Results
|
|
27
|
+
// don't contain the success value. The error type E is preserved exactly.
|
|
28
|
+
return errorResult;
|
|
29
|
+
};
|
|
30
|
+
export { propagateErr };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detect conflicts in argument definitions
|
|
3
|
+
*
|
|
4
|
+
* Checks for:
|
|
5
|
+
* - Duplicate arg names
|
|
6
|
+
* - Duplicate short names
|
|
7
|
+
*
|
|
8
|
+
* Returns list of conflicts found.
|
|
9
|
+
*/
|
|
10
|
+
import type { Arg } from '../arg.js';
|
|
11
|
+
type ArgConflict = {
|
|
12
|
+
type: 'duplicate_name' | 'duplicate_short';
|
|
13
|
+
name: string;
|
|
14
|
+
conflictingArgs: string[];
|
|
15
|
+
};
|
|
16
|
+
declare const detectArgConflicts: (args: readonly Arg[]) => ArgConflict[];
|
|
17
|
+
export { detectArgConflicts };
|
|
18
|
+
export type { ArgConflict };
|
|
19
|
+
//# sourceMappingURL=detect_arg_conflicts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect_arg_conflicts.d.ts","sourceRoot":"","sources":["../../src/detect_arg_conflicts/detect_arg_conflicts.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAEpC,KAAK,WAAW,GAAG;IAClB,IAAI,EAAE,gBAAgB,GAAG,iBAAiB,CAAA;IAC1C,IAAI,EAAE,MAAM,CAAA;IACZ,eAAe,EAAE,MAAM,EAAE,CAAA;CACzB,CAAA;AAED,QAAA,MAAM,kBAAkB,GAAI,MAAM,SAAS,GAAG,EAAE,KAAG,WAAW,EA8C7D,CAAA;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAA;AAC7B,YAAY,EAAE,WAAW,EAAE,CAAA"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detect conflicts in argument definitions
|
|
3
|
+
*
|
|
4
|
+
* Checks for:
|
|
5
|
+
* - Duplicate arg names
|
|
6
|
+
* - Duplicate short names
|
|
7
|
+
*
|
|
8
|
+
* Returns list of conflicts found.
|
|
9
|
+
*/
|
|
10
|
+
const detectArgConflicts = (args) => {
|
|
11
|
+
const conflicts = [];
|
|
12
|
+
const namesSeen = new Map();
|
|
13
|
+
const shortsSeen = new Map();
|
|
14
|
+
for (const arg of args) {
|
|
15
|
+
// Check for duplicate names
|
|
16
|
+
if (namesSeen.has(arg.name)) {
|
|
17
|
+
namesSeen.get(arg.name).push(arg.name);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
namesSeen.set(arg.name, [arg.name]);
|
|
21
|
+
}
|
|
22
|
+
// Check for duplicate shorts
|
|
23
|
+
if (arg.short) {
|
|
24
|
+
if (shortsSeen.has(arg.short)) {
|
|
25
|
+
shortsSeen.get(arg.short).push(arg.name);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
shortsSeen.set(arg.short, [arg.name]);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// Report duplicate names
|
|
33
|
+
for (const [name, argNames] of namesSeen) {
|
|
34
|
+
if (argNames.length > 1) {
|
|
35
|
+
conflicts.push({
|
|
36
|
+
type: 'duplicate_name',
|
|
37
|
+
name,
|
|
38
|
+
conflictingArgs: argNames,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
// Report duplicate shorts
|
|
43
|
+
for (const [short, argNames] of shortsSeen) {
|
|
44
|
+
if (argNames.length > 1) {
|
|
45
|
+
conflicts.push({
|
|
46
|
+
type: 'duplicate_short',
|
|
47
|
+
name: short,
|
|
48
|
+
conflictingArgs: argNames,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return conflicts;
|
|
53
|
+
};
|
|
54
|
+
export { detectArgConflicts };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/detect_arg_conflicts/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAC9D,YAAY,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { detectArgConflicts } from './detect_arg_conflicts.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate help text for commands
|
|
3
|
+
*
|
|
4
|
+
* Creates formatted help text showing:
|
|
5
|
+
* - Description
|
|
6
|
+
* - Usage line
|
|
7
|
+
* - Positional args
|
|
8
|
+
* - Flags
|
|
9
|
+
*/
|
|
10
|
+
import type { Command } from '../create_command.js';
|
|
11
|
+
declare const generateHelpText: (command: Command, commandName?: string) => string;
|
|
12
|
+
export { generateHelpText };
|
|
13
|
+
//# sourceMappingURL=generate_help_text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate_help_text.d.ts","sourceRoot":"","sources":["../../src/generate_help_text/generate_help_text.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAEnD,QAAA,MAAM,gBAAgB,GAAI,SAAS,OAAO,EAAE,cAAc,MAAM,KAAG,MAoDlE,CAAA;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAA"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate help text for commands
|
|
3
|
+
*
|
|
4
|
+
* Creates formatted help text showing:
|
|
5
|
+
* - Description
|
|
6
|
+
* - Usage line
|
|
7
|
+
* - Positional args
|
|
8
|
+
* - Flags
|
|
9
|
+
*/
|
|
10
|
+
const generateHelpText = (command, commandName) => {
|
|
11
|
+
const lines = [];
|
|
12
|
+
// Description
|
|
13
|
+
if (command.description) {
|
|
14
|
+
lines.push(command.description);
|
|
15
|
+
lines.push('');
|
|
16
|
+
}
|
|
17
|
+
// Usage line
|
|
18
|
+
const usageParts = [];
|
|
19
|
+
if (commandName) {
|
|
20
|
+
usageParts.push(commandName);
|
|
21
|
+
}
|
|
22
|
+
const positionals = command.args.filter((arg) => arg.type === 'positional');
|
|
23
|
+
const flags = command.args.filter((arg) => arg.type === 'flag');
|
|
24
|
+
for (const arg of positionals) {
|
|
25
|
+
usageParts.push(`<${arg.name}>`);
|
|
26
|
+
}
|
|
27
|
+
if (flags.length > 0) {
|
|
28
|
+
usageParts.push('[options]');
|
|
29
|
+
}
|
|
30
|
+
lines.push(`Usage: ${usageParts.join(' ')}`);
|
|
31
|
+
lines.push('');
|
|
32
|
+
// Positional arguments
|
|
33
|
+
if (positionals.length > 0) {
|
|
34
|
+
lines.push('Arguments:');
|
|
35
|
+
for (const arg of positionals) {
|
|
36
|
+
const shortPart = arg.short ? `, -${arg.short}` : '';
|
|
37
|
+
const descPart = arg.description ? ` ${arg.description}` : '';
|
|
38
|
+
lines.push(` ${arg.name}${shortPart}${descPart}`);
|
|
39
|
+
}
|
|
40
|
+
lines.push('');
|
|
41
|
+
}
|
|
42
|
+
// Flags
|
|
43
|
+
if (flags.length > 0) {
|
|
44
|
+
lines.push('Options:');
|
|
45
|
+
for (const arg of flags) {
|
|
46
|
+
const shortPart = arg.short ? `-${arg.short}, ` : '';
|
|
47
|
+
const descPart = arg.description ? ` ${arg.description}` : '';
|
|
48
|
+
lines.push(` ${shortPart}--${arg.name}${descPart}`);
|
|
49
|
+
}
|
|
50
|
+
lines.push('');
|
|
51
|
+
}
|
|
52
|
+
return lines.join('\n');
|
|
53
|
+
};
|
|
54
|
+
export { generateHelpText };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/generate_help_text/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { generateHelpText } from './generate_help_text.js';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type utilities for inferring handler arg types from Zod schemas
|
|
3
|
+
*
|
|
4
|
+
* Extracts the TypeScript type from an array of arg definitions.
|
|
5
|
+
*/
|
|
6
|
+
import type { z } from 'zod';
|
|
7
|
+
import type { Arg } from './arg.js';
|
|
8
|
+
/**
|
|
9
|
+
* Infer the handler args object type from an array of arg definitions
|
|
10
|
+
*
|
|
11
|
+
* Takes an array like:
|
|
12
|
+
* [
|
|
13
|
+
* { name: 'email', schema: z.string().email() },
|
|
14
|
+
* { name: 'verbose', schema: z.boolean().optional() }
|
|
15
|
+
* ]
|
|
16
|
+
*
|
|
17
|
+
* And produces:
|
|
18
|
+
* { email: string, verbose?: boolean }
|
|
19
|
+
*/
|
|
20
|
+
type InferArgsType<TArgs extends readonly Arg[]> = TArgs extends readonly [
|
|
21
|
+
infer First,
|
|
22
|
+
...infer Rest
|
|
23
|
+
] ? First extends Arg ? Rest extends readonly Arg[] ? {
|
|
24
|
+
[K in First['name']]: z.infer<First['schema']>;
|
|
25
|
+
} & InferArgsType<Rest> : {
|
|
26
|
+
[K in First['name']]: z.infer<First['schema']>;
|
|
27
|
+
} : never : Record<string, never>;
|
|
28
|
+
export type { InferArgsType };
|
|
29
|
+
//# sourceMappingURL=infer_args_type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"infer_args_type.d.ts","sourceRoot":"","sources":["../src/infer_args_type.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAC5B,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAEnC;;;;;;;;;;;GAWG;AACH,KAAK,aAAa,CAAC,KAAK,SAAS,SAAS,GAAG,EAAE,IAAI,KAAK,SAAS,SAAS;IACzE,MAAM,KAAK;IACX,GAAG,MAAM,IAAI;CACb,GACE,KAAK,SAAS,GAAG,GAChB,IAAI,SAAS,SAAS,GAAG,EAAE,GAC1B;KAAG,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;CAAE,GAAG,aAAa,CAAC,IAAI,CAAC,GACxE;KAAG,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;CAAE,GACnD,KAAK,GACN,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;AAExB,YAAY,EAAE,aAAa,EAAE,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if a Zod schema is a boolean type
|
|
3
|
+
*
|
|
4
|
+
* Uses internal Zod _def API, isolated here for easy testing and maintenance.
|
|
5
|
+
* If Zod changes their internal structure, we only need to update this function.
|
|
6
|
+
*
|
|
7
|
+
* Handles wrapped schemas (default, optional, nullable) by recursively unwrapping.
|
|
8
|
+
*/
|
|
9
|
+
import type { ZodSchema } from 'zod';
|
|
10
|
+
declare const isBooleanSchema: (schema: ZodSchema) => boolean;
|
|
11
|
+
export { isBooleanSchema };
|
|
12
|
+
//# sourceMappingURL=is_boolean_schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is_boolean_schema.d.ts","sourceRoot":"","sources":["../../src/is_boolean_schema/is_boolean_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AAEpC,QAAA,MAAM,eAAe,GAAI,QAAQ,SAAS,KAAG,OAa5C,CAAA;AAED,OAAO,EAAE,eAAe,EAAE,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if a Zod schema is a boolean type
|
|
3
|
+
*
|
|
4
|
+
* Uses internal Zod _def API, isolated here for easy testing and maintenance.
|
|
5
|
+
* If Zod changes their internal structure, we only need to update this function.
|
|
6
|
+
*
|
|
7
|
+
* Handles wrapped schemas (default, optional, nullable) by recursively unwrapping.
|
|
8
|
+
*/
|
|
9
|
+
const isBooleanSchema = (schema) => {
|
|
10
|
+
// Direct boolean check
|
|
11
|
+
if ('type' in schema._def && schema._def.type === 'boolean') {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
// Unwrap wrappers (ZodDefault, ZodOptional, ZodNullable)
|
|
15
|
+
// These store the inner schema in _def.innerType
|
|
16
|
+
if ('innerType' in schema._def) {
|
|
17
|
+
return isBooleanSchema(schema._def.innerType);
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
20
|
+
};
|
|
21
|
+
export { isBooleanSchema };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/is_boolean_schema/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { isBooleanSchema } from './is_boolean_schema.js';
|
package/esm/mod.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { zli } from './zli.js';
|
|
2
|
+
export type { CommandDirectory, CommandEntry } from './run.js';
|
|
3
|
+
export type { Command, CommandHandler, CommandOptions, MaybeResult } from './create_command.js';
|
|
4
|
+
export type { PositionalArg, PositionalArgOptions } from './create_positional_arg.js';
|
|
5
|
+
export type { FlagArg, FlagArgOptions } from './create_flag_arg.js';
|
|
6
|
+
export type { Arg } from './arg.js';
|
|
7
|
+
export type { InferArgsType } from './infer_args_type.js';
|
|
8
|
+
//# sourceMappingURL=mod.d.ts.map
|
package/esm/mod.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,YAAY,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAC9D,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAC/F,YAAY,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AACrF,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACnE,YAAY,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AACnC,YAAY,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA"}
|
package/esm/mod.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { zli } from './zli.js';
|
package/esm/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/parse_args/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA"}
|