@constatic/base 0.0.1-beta.4 → 0.0.1-beta.6
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/dist/creators/setup.d.ts +1 -2
- package/dist/env.d.ts +1 -1
- package/dist/env.js +1 -4
- package/dist/utils/schema.d.ts +56 -0
- package/dist/utils/schema.js +0 -0
- package/package.json +5 -3
- package/tsconfig/base.json +21 -0
package/dist/creators/setup.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { type BaseCommandsConfig, type BaseEventsConfig, type BaseRespondersConf
|
|
|
3
3
|
import { Command, type CommandData, type CommandType } from "./commands/command.js";
|
|
4
4
|
import { Event, type EventData } from "./events/event.js";
|
|
5
5
|
import { Responder, type ResponderData, type ResponderType } from "./responders/responder.js";
|
|
6
|
-
interface SetupCreatorsOptions {
|
|
6
|
+
export interface SetupCreatorsOptions {
|
|
7
7
|
commands?: BaseCommandsConfig & {
|
|
8
8
|
defaultMemberPermissions?: PermissionResolvable[];
|
|
9
9
|
};
|
|
@@ -15,4 +15,3 @@ export declare function setupCreators(options?: SetupCreatorsOptions): {
|
|
|
15
15
|
createEvent: <EventName extends keyof ClientEvents>(data: EventData<EventName>) => Event<EventName>;
|
|
16
16
|
createResponder<Path extends string, const Types extends readonly ResponderType[], Parsed, Cache extends CacheType = CacheType>(data: ResponderData<Path, Types, Parsed, Cache>): Responder<Path, Types, Parsed, Cache>;
|
|
17
17
|
};
|
|
18
|
-
export {};
|
package/dist/env.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { StandardSchemaV1 } from "
|
|
1
|
+
import type { StandardSchemaV1 } from "./utils/schema.js";
|
|
2
2
|
type Schema = StandardSchemaV1;
|
|
3
3
|
type Out<T extends Schema> = StandardSchemaV1.InferOutput<T>;
|
|
4
4
|
export declare function validateEnv<T extends Schema>(schema: T): Promise<Out<T>>;
|
package/dist/env.js
CHANGED
|
@@ -3,10 +3,7 @@ import { format, styleText } from "node:util";
|
|
|
3
3
|
async function validateEnv(schema) {
|
|
4
4
|
const result = await schema["~standard"].validate(process.env);
|
|
5
5
|
if (result.issues) {
|
|
6
|
-
|
|
7
|
-
return format(styleText("red", "✖︎ ENV VAR %s ➜ %s"), styleText("bold", issue.path?.join(".") ?? ""), styleText("gray", issue.message));
|
|
8
|
-
});
|
|
9
|
-
console.log(a.join(`
|
|
6
|
+
console.log(result.issues.map((issue) => format(styleText("red", "✖︎ ENV VAR %s ➜ %s"), styleText("bold", issue.path?.join(".") ?? ""), styleText("gray", issue.message))).join(`
|
|
10
7
|
`));
|
|
11
8
|
process.exit(1);
|
|
12
9
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/** The Standard Schema interface. */
|
|
2
|
+
export interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
3
|
+
/** The Standard Schema properties. */
|
|
4
|
+
readonly "~standard": StandardSchemaV1.Props<Input, Output>;
|
|
5
|
+
}
|
|
6
|
+
export declare namespace StandardSchemaV1 {
|
|
7
|
+
/** The Standard Schema properties interface. */
|
|
8
|
+
export interface Props<Input = unknown, Output = Input> {
|
|
9
|
+
/** The version number of the standard. */
|
|
10
|
+
readonly version: 1;
|
|
11
|
+
/** The vendor name of the schema library. */
|
|
12
|
+
readonly vendor: string;
|
|
13
|
+
/** Validates unknown input values. */
|
|
14
|
+
readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
|
|
15
|
+
/** Inferred types associated with the schema. */
|
|
16
|
+
readonly types?: Types<Input, Output> | undefined;
|
|
17
|
+
}
|
|
18
|
+
/** The result interface of the validate function. */
|
|
19
|
+
export type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
20
|
+
/** The result interface if validation succeeds. */
|
|
21
|
+
export interface SuccessResult<Output> {
|
|
22
|
+
/** The typed output value. */
|
|
23
|
+
readonly value: Output;
|
|
24
|
+
/** The non-existent issues. */
|
|
25
|
+
readonly issues?: undefined;
|
|
26
|
+
}
|
|
27
|
+
/** The result interface if validation fails. */
|
|
28
|
+
export interface FailureResult {
|
|
29
|
+
/** The issues of failed validation. */
|
|
30
|
+
readonly issues: ReadonlyArray<Issue>;
|
|
31
|
+
}
|
|
32
|
+
/** The issue interface of the failure output. */
|
|
33
|
+
export interface Issue {
|
|
34
|
+
/** The error message of the issue. */
|
|
35
|
+
readonly message: string;
|
|
36
|
+
/** The path of the issue, if any. */
|
|
37
|
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
38
|
+
}
|
|
39
|
+
/** The path segment interface of the issue. */
|
|
40
|
+
export interface PathSegment {
|
|
41
|
+
/** The key representing a path segment. */
|
|
42
|
+
readonly key: PropertyKey;
|
|
43
|
+
}
|
|
44
|
+
/** The Standard Schema types interface. */
|
|
45
|
+
export interface Types<Input = unknown, Output = Input> {
|
|
46
|
+
/** The input type of the schema. */
|
|
47
|
+
readonly input: Input;
|
|
48
|
+
/** The output type of the schema. */
|
|
49
|
+
readonly output: Output;
|
|
50
|
+
}
|
|
51
|
+
/** Infers the input type of a Standard Schema. */
|
|
52
|
+
export type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["input"];
|
|
53
|
+
/** Infers the output type of a Standard Schema. */
|
|
54
|
+
export type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
|
|
55
|
+
export {};
|
|
56
|
+
}
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constatic/base",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -25,10 +25,12 @@
|
|
|
25
25
|
".": {
|
|
26
26
|
"import": "./dist/index.js",
|
|
27
27
|
"types": "./dist/index.d.ts"
|
|
28
|
-
}
|
|
28
|
+
},
|
|
29
|
+
"./tsconfig": "./tsconfig/base.json"
|
|
29
30
|
},
|
|
30
31
|
"files": [
|
|
31
|
-
"dist"
|
|
32
|
+
"dist",
|
|
33
|
+
"tsconfig"
|
|
32
34
|
],
|
|
33
35
|
"homepage": "https://constatic-docs.vercel.app",
|
|
34
36
|
"imports": {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://www.schemastore.org/tsconfig",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"esModuleInterop": true,
|
|
5
|
+
"forceConsistentCasingInFileNames": true,
|
|
6
|
+
"skipLibCheck": true,
|
|
7
|
+
"resolveJsonModule": true,
|
|
8
|
+
"strict": true,
|
|
9
|
+
|
|
10
|
+
"lib": ["ESNext"],
|
|
11
|
+
"target": "ESNext",
|
|
12
|
+
"module": "NodeNext",
|
|
13
|
+
"moduleResolution": "NodeNext",
|
|
14
|
+
|
|
15
|
+
"noUnusedLocals": true,
|
|
16
|
+
"noUnusedParameters": true,
|
|
17
|
+
"noImplicitReturns": true,
|
|
18
|
+
"noImplicitOverride": true,
|
|
19
|
+
"noEmitOnError": true,
|
|
20
|
+
}
|
|
21
|
+
}
|