convoker 0.3.4 → 0.4.0
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 +1 -1
- package/dist/color/index.d.mts +2 -0
- package/dist/{color.mjs → color/index.mjs} +1 -2
- package/dist/{color-OlJQTTxb.mjs → color-DiZvJ0Fc.mjs} +40 -11
- package/dist/color-DiZvJ0Fc.mjs.map +1 -0
- package/dist/command/index.d.mts +5 -0
- package/dist/command/index.mjs +8 -0
- package/dist/{command-D2UiQBNA.mjs → command-8P8qXJ2o.mjs} +98 -195
- package/dist/command-8P8qXJ2o.mjs.map +1 -0
- package/dist/{index-Dikc5KAP.d.mts → index-BYLskLxk.d.mts} +5 -4
- package/dist/{color-BuHvMolk.d.mts → index-BtbthYjp.d.mts} +13 -3
- package/dist/{input-B12iaqb8.d.mts → index-ClhbwSD8.d.mts} +20 -5
- package/dist/{command-BXmfoT-l.d.mts → index-Cnx4H4D-.d.mts} +10 -25
- package/dist/index.d.mts +33 -69
- package/dist/index.mjs +91 -9
- package/dist/index.mjs.map +1 -0
- package/dist/input/index.d.mts +3 -0
- package/dist/input/index.mjs +4 -0
- package/dist/{input-DRy_sVxZ.mjs → input-XUsy1LCQ.mjs} +5 -3
- package/dist/input-XUsy1LCQ.mjs.map +1 -0
- package/dist/prompt/index.d.mts +4 -4
- package/dist/prompt/index.mjs +4 -6
- package/dist/prompt/raw.d.mts +1 -1
- package/dist/prompt/raw.mjs +1 -2
- package/dist/{prompt-Cvufljin.mjs → prompt-a5Ix_Hyc.mjs} +30 -58
- package/dist/prompt-a5Ix_Hyc.mjs.map +1 -0
- package/dist/{raw--889icsd.mjs → raw-DEtZFeMv.mjs} +4 -21
- package/dist/raw-DEtZFeMv.mjs.map +1 -0
- package/dist/{raw-BqvlveTU.d.mts → raw-cqTp2vds.d.mts} +2 -1
- package/dist/standard-schema-DTuaYJjO.mjs +32 -0
- package/dist/standard-schema-DTuaYJjO.mjs.map +1 -0
- package/dist/{standard-schema-DLeKaehR.d.mts → standard-schema-DXS-QnwX.d.mts} +3 -2
- package/package.json +14 -17
- package/dist/color.d.mts +0 -2
- package/dist/command.d.mts +0 -5
- package/dist/command.mjs +0 -10
- package/dist/error-C1S1gs8L.mjs +0 -115
- package/dist/error.d.mts +0 -5
- package/dist/error.mjs +0 -3
- package/dist/input.d.mts +0 -3
- package/dist/input.mjs +0 -5
- package/dist/standard-schema-DBXbMy6L.mjs +0 -17
- package/dist/utils-ChmY93uA.mjs +0 -45
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region src/input/error.ts
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when the command fails to validate an input.
|
|
4
|
+
*/
|
|
5
|
+
var InputValidationError = class extends Error {
|
|
6
|
+
/**
|
|
7
|
+
* Creates a new input validation error.
|
|
8
|
+
* @param messages The messages.
|
|
9
|
+
*/
|
|
10
|
+
constructor(messages) {
|
|
11
|
+
super(`Validation failed: ${messages.join(", ")}`);
|
|
12
|
+
this.messages = messages;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/input/standard-schema.ts
|
|
18
|
+
/**
|
|
19
|
+
* Validates a value.
|
|
20
|
+
* @param entry The Standard Schema validator.
|
|
21
|
+
* @param value The value to validate.
|
|
22
|
+
* @returns The validated value.
|
|
23
|
+
*/
|
|
24
|
+
async function validate(entry, value) {
|
|
25
|
+
const result = await entry["~standard"].validate(value);
|
|
26
|
+
if (result.issues) throw new InputValidationError(result.issues.map((i) => i.message));
|
|
27
|
+
return result.value;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { InputValidationError as n, validate as t };
|
|
32
|
+
//# sourceMappingURL=standard-schema-DTuaYJjO.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"standard-schema-DTuaYJjO.mjs","names":[],"sources":["../src/input/error.ts","../src/input/standard-schema.ts"],"sourcesContent":["/**\n * Thrown when the command fails to validate an input.\n */\nexport class InputValidationError extends Error {\n /**\n * A list of messages.\n */\n messages: string[];\n\n /**\n * Creates a new input validation error.\n * @param messages The messages.\n */\n constructor(messages: string[]) {\n super(`Validation failed: ${messages.join(\", \")}`);\n this.messages = messages;\n }\n}\n","// * https://standardschema.dev * //\n\nimport { InputValidationError } from \"./error\";\n\n/** The Standard Schema interface. */\nexport interface StandardSchemaV1<Input = unknown, Output = Input> {\n /** The Standard Schema properties. */\n readonly \"~standard\": StandardSchemaV1.Props<Input, Output>;\n}\n\n// eslint-disable-next-line -- this is Standard Schema\nexport declare namespace StandardSchemaV1 {\n /** The Standard Schema properties interface. */\n export interface Props<Input = unknown, Output = Input> {\n /** The version number of the standard. */\n readonly version: 1;\n /** The vendor name of the schema library. */\n readonly vendor: string;\n /** Validates unknown input values. */\n readonly validate: (\n value: unknown,\n ) => Result<Output> | Promise<Result<Output>>;\n /** Inferred types associated with the schema. */\n readonly types?: Types<Input, Output> | undefined;\n }\n\n /** The result interface of the validate function. */\n export type Result<Output> = SuccessResult<Output> | FailureResult;\n\n /** The result interface if validation succeeds. */\n export interface SuccessResult<Output> {\n /** The typed output value. */\n readonly value: Output;\n /** The non-existent issues. */\n readonly issues?: undefined;\n }\n\n /** The result interface if validation fails. */\n export interface FailureResult {\n /** The issues of failed validation. */\n readonly issues: ReadonlyArray<Issue>;\n }\n\n /** The issue interface of the failure output. */\n export interface Issue {\n /** The error message of the issue. */\n readonly message: string;\n /** The path of the issue, if any. */\n readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;\n }\n\n /** The path segment interface of the issue. */\n export interface PathSegment {\n /** The key representing a path segment. */\n readonly key: PropertyKey;\n }\n\n /** The Standard Schema types interface. */\n export interface Types<Input = unknown, Output = Input> {\n /** The input type of the schema. */\n readonly input: Input;\n /** The output type of the schema. */\n readonly output: Output;\n }\n\n /** Infers the input type of a Standard Schema. */\n export type InferInput<Schema extends StandardSchemaV1> = NonNullable<\n Schema[\"~standard\"][\"types\"]\n >[\"input\"];\n\n /** Infers the output type of a Standard Schema. */\n export type InferOutput<Schema extends StandardSchemaV1> = NonNullable<\n Schema[\"~standard\"][\"types\"]\n >[\"output\"];\n}\n\n/**\n * Validates a value.\n * @param entry The Standard Schema validator.\n * @param value The value to validate.\n * @returns The validated value.\n */\nexport async function validate<T extends StandardSchemaV1<any, any>>(\n entry: T,\n value: any,\n): Promise<T extends StandardSchemaV1<any, infer Out> ? Out : never> {\n const result = await entry[\"~standard\"].validate(value);\n if (result.issues) {\n const msgs = result.issues.map((i) => i.message);\n throw new InputValidationError(msgs);\n }\n\n return result.value;\n}\n"],"mappings":";;;;AAGA,IAAa,uBAAb,cAA0C,MAAM;;;;;CAU9C,YAAY,UAAoB;AAC9B,QAAM,sBAAsB,SAAS,KAAK,KAAK,GAAG;AAClD,OAAK,WAAW;;;;;;;;;;;;ACmEpB,eAAsB,SACpB,OACA,OACmE;CACnE,MAAM,SAAS,MAAM,MAAM,aAAa,SAAS,MAAM;AACvD,KAAI,OAAO,OAET,OAAM,IAAI,qBADG,OAAO,OAAO,KAAK,MAAM,EAAE,QAAQ,CACZ;AAGtC,QAAO,OAAO"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region src/standard-schema.d.ts
|
|
1
|
+
//#region src/input/standard-schema.d.ts
|
|
2
2
|
/** The Standard Schema interface. */
|
|
3
3
|
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
4
4
|
/** The Standard Schema properties. */
|
|
@@ -55,4 +55,5 @@ declare namespace StandardSchemaV1 {
|
|
|
55
55
|
type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
|
|
56
56
|
}
|
|
57
57
|
//#endregion
|
|
58
|
-
export { StandardSchemaV1 as t };
|
|
58
|
+
export { StandardSchemaV1 as t };
|
|
59
|
+
//# sourceMappingURL=standard-schema-DXS-QnwX.d.mts.map
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "convoker",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "A simple, type safe CLI framework for TypeScript.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/
|
|
7
|
+
"url": "git+https://github.com/sprucepad/convoker"
|
|
8
8
|
},
|
|
9
9
|
"main": "./dist/index.mjs",
|
|
10
10
|
"types": "./dist/index.d.mts",
|
|
@@ -14,16 +14,16 @@
|
|
|
14
14
|
"import": "./dist/index.mjs"
|
|
15
15
|
},
|
|
16
16
|
"./command": {
|
|
17
|
-
"types": "./dist/command.d.mts",
|
|
18
|
-
"import": "./dist/command.mjs"
|
|
17
|
+
"types": "./dist/command/index.d.mts",
|
|
18
|
+
"import": "./dist/command/index.mjs"
|
|
19
19
|
},
|
|
20
20
|
"./input": {
|
|
21
|
-
"types": "./dist/
|
|
22
|
-
"import": "./dist/input.mjs"
|
|
21
|
+
"types": "./dist/input/index.d.mts",
|
|
22
|
+
"import": "./dist/input/index.mjs"
|
|
23
23
|
},
|
|
24
24
|
"./color": {
|
|
25
|
-
"types": "./dist/color.d.mts",
|
|
26
|
-
"import": "./dist/color.mjs"
|
|
25
|
+
"types": "./dist/color/index.d.mts",
|
|
26
|
+
"import": "./dist/color/index.mjs"
|
|
27
27
|
},
|
|
28
28
|
"./prompt": {
|
|
29
29
|
"types": "./dist/prompt/index.d.mts",
|
|
@@ -32,10 +32,6 @@
|
|
|
32
32
|
"./prompt/raw": {
|
|
33
33
|
"types": "./dist/prompt/raw.d.mts",
|
|
34
34
|
"import": "./dist/prompt/raw.mjs"
|
|
35
|
-
},
|
|
36
|
-
"./error": {
|
|
37
|
-
"types": "./dist/error.d.mts",
|
|
38
|
-
"import": "./dist/error.mjs"
|
|
39
35
|
}
|
|
40
36
|
},
|
|
41
37
|
"type": "module",
|
|
@@ -49,10 +45,11 @@
|
|
|
49
45
|
"argv",
|
|
50
46
|
"option"
|
|
51
47
|
],
|
|
52
|
-
"author": "
|
|
48
|
+
"author": "sprucepad",
|
|
53
49
|
"license": "MIT",
|
|
54
50
|
"devDependencies": {
|
|
55
51
|
"@eslint/js": "^9.36.0",
|
|
52
|
+
"@types/node": "~20.19.30",
|
|
56
53
|
"eslint": "^9.36.0",
|
|
57
54
|
"globals": "^16.4.0",
|
|
58
55
|
"prettier": "^3.6.2",
|
|
@@ -63,12 +60,12 @@
|
|
|
63
60
|
"vitest": "^3.2.4"
|
|
64
61
|
},
|
|
65
62
|
"scripts": {
|
|
66
|
-
"test": "vitest
|
|
63
|
+
"test": "vitest",
|
|
67
64
|
"build": "tsdown",
|
|
68
|
-
"check": "tsc
|
|
65
|
+
"check": "tsc",
|
|
69
66
|
"format": "prettier --check .",
|
|
70
|
-
"format
|
|
67
|
+
"format:fix": "prettier --write .",
|
|
71
68
|
"lint": "eslint .",
|
|
72
|
-
"lint
|
|
69
|
+
"lint:fix": "eslint --fix ."
|
|
73
70
|
}
|
|
74
71
|
}
|
package/dist/color.d.mts
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { A as green, B as reset, D as defineTheme, E as cyanBright, F as magenta, G as whiteBright, H as supportsColor, I as magentaBright, K as yellow, L as overline, M as hidden, N as inverse, O as dim, P as italic, R as red, S as bold, T as cyan, U as underline, V as strikethrough, W as white, _ as bgYellow, a as bgBlueBright, b as blue, c as bgGray, d as bgMagenta, f as bgMagentaBright, g as bgWhiteBright, h as bgWhite, i as bgBlue, j as greenBright, k as gray, l as bgGreen, m as bgRedBright, n as Theme, o as bgCyan, p as bgRed, q as yellowBright, r as bgBlack, s as bgCyanBright, t as DEFAULT_THEME, u as bgGreenBright, v as bgYellowBright, w as createAnsiColor, x as blueBright, y as black, z as redBright } from "./color-BuHvMolk.mjs";
|
|
2
|
-
export { DEFAULT_THEME, Theme, bgBlack, bgBlue, bgBlueBright, bgCyan, bgCyanBright, bgGray, bgGreen, bgGreenBright, bgMagenta, bgMagentaBright, bgRed, bgRedBright, bgWhite, bgWhiteBright, bgYellow, bgYellowBright, black, blue, blueBright, bold, createAnsiColor, cyan, cyanBright, defineTheme, dim, gray, green, greenBright, hidden, inverse, italic, magenta, magentaBright, overline, red, redBright, reset, strikethrough, supportsColor, underline, white, whiteBright, yellow, yellowBright };
|
package/dist/command.d.mts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import "./color-BuHvMolk.mjs";
|
|
2
|
-
import "./standard-schema-DLeKaehR.mjs";
|
|
3
|
-
import "./input-B12iaqb8.mjs";
|
|
4
|
-
import { a as ErrorFn, i as CommandAlias, n as Builder, o as MiddlewareFn, r as Command, s as ParseResult, t as ActionFn } from "./command-BXmfoT-l.mjs";
|
|
5
|
-
export { ActionFn, Builder, Command, CommandAlias, ErrorFn, MiddlewareFn, ParseResult };
|
package/dist/command.mjs
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import "./utils-ChmY93uA.mjs";
|
|
2
|
-
import "./color-OlJQTTxb.mjs";
|
|
3
|
-
import "./error-C1S1gs8L.mjs";
|
|
4
|
-
import "./standard-schema-DBXbMy6L.mjs";
|
|
5
|
-
import "./raw--889icsd.mjs";
|
|
6
|
-
import "./prompt-Cvufljin.mjs";
|
|
7
|
-
import { t as Command } from "./command-D2UiQBNA.mjs";
|
|
8
|
-
import "./input-DRy_sVxZ.mjs";
|
|
9
|
-
|
|
10
|
-
export { Command };
|
package/dist/error-C1S1gs8L.mjs
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { t as __export } from "./chunk-z5eko27R.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/error.ts
|
|
4
|
-
var error_exports = /* @__PURE__ */ __export({
|
|
5
|
-
ConvokerError: () => ConvokerError,
|
|
6
|
-
HelpAskedError: () => HelpAskedError,
|
|
7
|
-
InputValidationError: () => InputValidationError,
|
|
8
|
-
MissingRequiredArgumentError: () => MissingRequiredArgumentError,
|
|
9
|
-
MissingRequiredOptionError: () => MissingRequiredOptionError,
|
|
10
|
-
TooManyArgumentsError: () => TooManyArgumentsError,
|
|
11
|
-
UnknownOptionError: () => UnknownOptionError
|
|
12
|
-
});
|
|
13
|
-
/**
|
|
14
|
-
* Thrown when the command fails to validate an input.
|
|
15
|
-
*/
|
|
16
|
-
var InputValidationError = class extends Error {
|
|
17
|
-
/**
|
|
18
|
-
* Creates a new input validation error.
|
|
19
|
-
* @param messages The messages.
|
|
20
|
-
*/
|
|
21
|
-
constructor(messages) {
|
|
22
|
-
super(`Validation failed: ${messages.join(", ")}`);
|
|
23
|
-
this.messages = messages;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* A Convoker-related error. These are usually handled by default.
|
|
28
|
-
*/
|
|
29
|
-
var ConvokerError = class extends Error {
|
|
30
|
-
/**
|
|
31
|
-
* Creates a new Convoker error.
|
|
32
|
-
* @param message The message.
|
|
33
|
-
* @param command The command.
|
|
34
|
-
*/
|
|
35
|
-
constructor(message, command) {
|
|
36
|
-
super(message);
|
|
37
|
-
this.command = command;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Prints the error's message.
|
|
41
|
-
*/
|
|
42
|
-
print() {
|
|
43
|
-
console.error(this.message);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* When the user asks for help.
|
|
48
|
-
*/
|
|
49
|
-
var HelpAskedError = class extends ConvokerError {
|
|
50
|
-
/**
|
|
51
|
-
* Creates a new help asked error.
|
|
52
|
-
* @param command The command.
|
|
53
|
-
*/
|
|
54
|
-
constructor(command) {
|
|
55
|
-
super("user asked for help!", command);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* When you pass too many arguments.
|
|
60
|
-
*/
|
|
61
|
-
var TooManyArgumentsError = class extends ConvokerError {
|
|
62
|
-
/**
|
|
63
|
-
* Creates a new too many arguments error.
|
|
64
|
-
* @param command The command.
|
|
65
|
-
*/
|
|
66
|
-
constructor(command) {
|
|
67
|
-
super("too many arguments!", command);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
/**
|
|
71
|
-
* When you pass an unknown option, when unknown options aren't allowed.
|
|
72
|
-
*/
|
|
73
|
-
var UnknownOptionError = class extends ConvokerError {
|
|
74
|
-
/**
|
|
75
|
-
* Creates a new unknown option error.
|
|
76
|
-
* @param command The command.
|
|
77
|
-
* @param key The key.
|
|
78
|
-
*/
|
|
79
|
-
constructor(command, key) {
|
|
80
|
-
super(`unknown option: ${key}!`, command);
|
|
81
|
-
this.key = key;
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
/**
|
|
85
|
-
* When a required option is missing.
|
|
86
|
-
*/
|
|
87
|
-
var MissingRequiredOptionError = class extends ConvokerError {
|
|
88
|
-
/**
|
|
89
|
-
* Creates a new missing required option error.
|
|
90
|
-
* @param command The command.
|
|
91
|
-
* @param key The key.
|
|
92
|
-
* @param entry The entry.
|
|
93
|
-
*/
|
|
94
|
-
constructor(command, key, entry) {
|
|
95
|
-
super(`missing required option: ${key}!`, command);
|
|
96
|
-
this.key = key;
|
|
97
|
-
this.entry = entry;
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
var MissingRequiredArgumentError = class extends ConvokerError {
|
|
101
|
-
/**
|
|
102
|
-
* Creates a new missing required argument error.
|
|
103
|
-
* @param command The command.
|
|
104
|
-
* @param key The key.
|
|
105
|
-
* @param entry The entry.
|
|
106
|
-
*/
|
|
107
|
-
constructor(command, key, entry) {
|
|
108
|
-
super(`missing required positional argument: ${key}!`, command);
|
|
109
|
-
this.key = key;
|
|
110
|
-
this.entry = entry;
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
//#endregion
|
|
115
|
-
export { MissingRequiredOptionError as a, error_exports as c, MissingRequiredArgumentError as i, HelpAskedError as n, TooManyArgumentsError as o, InputValidationError as r, UnknownOptionError as s, ConvokerError as t };
|
package/dist/error.d.mts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import "./color-BuHvMolk.mjs";
|
|
2
|
-
import "./standard-schema-DLeKaehR.mjs";
|
|
3
|
-
import "./input-B12iaqb8.mjs";
|
|
4
|
-
import { c as ConvokerError, d as MissingRequiredArgumentError, f as MissingRequiredOptionError, l as HelpAskedError, m as UnknownOptionError, p as TooManyArgumentsError, u as InputValidationError } from "./command-BXmfoT-l.mjs";
|
|
5
|
-
export { ConvokerError, HelpAskedError, InputValidationError, MissingRequiredArgumentError, MissingRequiredOptionError, TooManyArgumentsError, UnknownOptionError };
|
package/dist/error.mjs
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { a as MissingRequiredOptionError, i as MissingRequiredArgumentError, n as HelpAskedError, o as TooManyArgumentsError, r as InputValidationError, s as UnknownOptionError, t as ConvokerError } from "./error-C1S1gs8L.mjs";
|
|
2
|
-
|
|
3
|
-
export { ConvokerError, HelpAskedError, InputValidationError, MissingRequiredArgumentError, MissingRequiredOptionError, TooManyArgumentsError, UnknownOptionError };
|
package/dist/input.d.mts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import "./standard-schema-DLeKaehR.mjs";
|
|
2
|
-
import { a as Kind, c as TypeOf, f as option, i as Input, l as argument, n as InferEntry, o as Option, p as positional, r as InferInput, s as Positional, t as BasicKind, u as convert } from "./input-B12iaqb8.mjs";
|
|
3
|
-
export { BasicKind, InferEntry, InferInput, Input, Kind, Option, Positional, TypeOf, argument, convert, option, positional };
|
package/dist/input.mjs
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import "./error-C1S1gs8L.mjs";
|
|
2
|
-
import "./standard-schema-DBXbMy6L.mjs";
|
|
3
|
-
import { i as convert, n as Positional, o as option, r as argument, s as positional, t as Option } from "./input-DRy_sVxZ.mjs";
|
|
4
|
-
|
|
5
|
-
export { Option, Positional, argument, convert, option, positional };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { r as InputValidationError } from "./error-C1S1gs8L.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/standard-schema.ts
|
|
4
|
-
/**
|
|
5
|
-
* Validates a value.
|
|
6
|
-
* @param entry The Standard Schema validator.
|
|
7
|
-
* @param value The value to validate.
|
|
8
|
-
* @returns The validated value.
|
|
9
|
-
*/
|
|
10
|
-
async function validate(entry, value) {
|
|
11
|
-
const result = await entry["~standard"].validate(value);
|
|
12
|
-
if (result.issues) throw new InputValidationError(result.issues.map((i) => i.message));
|
|
13
|
-
return result.value;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
//#endregion
|
|
17
|
-
export { validate as t };
|
package/dist/utils-ChmY93uA.mjs
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
//#region src/utils.ts
|
|
2
|
-
/**
|
|
3
|
-
* If the runtime is Node.js.
|
|
4
|
-
*/
|
|
5
|
-
const isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
6
|
-
/**
|
|
7
|
-
* If the runtime is Deno.
|
|
8
|
-
*/
|
|
9
|
-
const isDeno = typeof Deno !== "undefined" && typeof Deno.version?.deno === "string";
|
|
10
|
-
/**
|
|
11
|
-
* If the runtime is Bun.
|
|
12
|
-
*/
|
|
13
|
-
const isBun = typeof Bun !== "undefined" && typeof Bun.version === "string";
|
|
14
|
-
/**
|
|
15
|
-
* Checks if a value is a plain object.
|
|
16
|
-
* @param value The value to check.
|
|
17
|
-
* @returns If the value is a plain object.
|
|
18
|
-
*/
|
|
19
|
-
function isPlainObject(value) {
|
|
20
|
-
return value !== null && typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Merges two objects deeply.
|
|
24
|
-
* @param source The source object.
|
|
25
|
-
* @param target The target object.
|
|
26
|
-
* @returns The merged objects.
|
|
27
|
-
*/
|
|
28
|
-
function merge(source, target) {
|
|
29
|
-
if (Array.isArray(source) && Array.isArray(target)) return target;
|
|
30
|
-
if (isPlainObject(source) && isPlainObject(target)) {
|
|
31
|
-
const result = {};
|
|
32
|
-
new Set([...Object.keys(source), ...Object.keys(target)]).forEach((key) => {
|
|
33
|
-
const sourceVal = source[key];
|
|
34
|
-
const targetVal = target[key];
|
|
35
|
-
if (sourceVal !== void 0 && targetVal !== void 0) result[key] = merge(sourceVal, targetVal);
|
|
36
|
-
else if (targetVal !== void 0) result[key] = targetVal;
|
|
37
|
-
else result[key] = sourceVal;
|
|
38
|
-
});
|
|
39
|
-
return result;
|
|
40
|
-
}
|
|
41
|
-
return target;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
//#endregion
|
|
45
|
-
export { merge as i, isDeno as n, isNode as r, isBun as t };
|