@sx3/ultra 0.0.1
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 +512 -0
- package/dist/auth.d.mts +56 -0
- package/dist/auth.mjs +84 -0
- package/dist/client.d.mts +27 -0
- package/dist/client.mjs +131 -0
- package/dist/context-ChCsZh7S.d.mts +17 -0
- package/dist/context.d.mts +2 -0
- package/dist/context.mjs +10 -0
- package/dist/cors.d.mts +16 -0
- package/dist/cors.mjs +58 -0
- package/dist/crypto.d.mts +7 -0
- package/dist/crypto.mjs +44 -0
- package/dist/error-CII1zMOR.mjs +45 -0
- package/dist/error.d.mts +25 -0
- package/dist/error.mjs +3 -0
- package/dist/http-BqWCMASL.d.mts +10 -0
- package/dist/http.d.mts +3 -0
- package/dist/http.mjs +1 -0
- package/dist/middleware-COKreBGP.d.mts +43 -0
- package/dist/middleware.d.mts +4 -0
- package/dist/middleware.mjs +1 -0
- package/dist/procedure-BN1rLLRX.mjs +86 -0
- package/dist/procedure.d.mts +4 -0
- package/dist/procedure.mjs +3 -0
- package/dist/response-CNhIkAYG.mjs +59 -0
- package/dist/response.d.mts +5 -0
- package/dist/response.mjs +3 -0
- package/dist/rpc-Ch2UXReT.d.mts +23 -0
- package/dist/rpc-_rBI0z-9.mjs +7 -0
- package/dist/rpc.d.mts +2 -0
- package/dist/rpc.mjs +3 -0
- package/dist/session.d.mts +115 -0
- package/dist/session.mjs +181 -0
- package/dist/types-Cn69QrjS.d.mts +11 -0
- package/dist/types.d.mts +2 -0
- package/dist/types.mjs +1 -0
- package/dist/ultra.d.mts +69 -0
- package/dist/ultra.mjs +273 -0
- package/dist/validation-CkRfxQJ_.d.mts +57 -0
- package/dist/validation-Cop5Wvlr.mjs +12 -0
- package/dist/validation.d.mts +2 -0
- package/dist/validation.mjs +3 -0
- package/package.json +55 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
//#region src/validation.d.ts
|
|
2
|
+
/** The Standard Schema interface. */
|
|
3
|
+
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
4
|
+
/** The Standard Schema properties. */
|
|
5
|
+
readonly '~standard': Props<Input, Output>;
|
|
6
|
+
}
|
|
7
|
+
/** The Standard Schema properties interface. */
|
|
8
|
+
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
|
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
20
|
+
/** The result interface if validation succeeds. */
|
|
21
|
+
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
|
+
interface FailureResult {
|
|
29
|
+
/** The issues of failed validation. */
|
|
30
|
+
readonly issues: ReadonlyArray<Issue>;
|
|
31
|
+
}
|
|
32
|
+
/** The issue interface of the failure output. */
|
|
33
|
+
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
|
+
interface PathSegment {
|
|
41
|
+
/** The key representing a path segment. */
|
|
42
|
+
readonly key: PropertyKey;
|
|
43
|
+
}
|
|
44
|
+
/** The Standard Schema types interface. */
|
|
45
|
+
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
|
+
type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['input'];
|
|
53
|
+
/** Infers the output type of a Standard Schema. */
|
|
54
|
+
type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['output'];
|
|
55
|
+
declare function validate<T extends StandardSchemaV1>(schema: T, input: InferInput<T>): Promise<InferOutput<T>>;
|
|
56
|
+
//#endregion
|
|
57
|
+
export { PathSegment as a, StandardSchemaV1 as c, validate as d, Issue as i, SuccessResult as l, InferInput as n, Props as o, InferOutput as r, Result as s, FailureResult as t, Types as u };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { a as ValidationError } from "./error-CII1zMOR.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/validation.ts
|
|
4
|
+
async function validate(schema, input) {
|
|
5
|
+
let result = schema["~standard"].validate(input);
|
|
6
|
+
if (result instanceof Promise) result = await result;
|
|
7
|
+
if (result.issues) throw new ValidationError(JSON.stringify(result.issues, null, 2));
|
|
8
|
+
return result.value;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { validate as t };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as PathSegment, c as StandardSchemaV1, d as validate, i as Issue, l as SuccessResult, n as InferInput, o as Props, r as InferOutput, s as Result, t as FailureResult, u as Types } from "./validation-CkRfxQJ_.mjs";
|
|
2
|
+
export { FailureResult, InferInput, InferOutput, Issue, PathSegment, Props, Result, StandardSchemaV1, SuccessResult, Types, validate };
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sx3/ultra",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"private": false,
|
|
6
|
+
"description": "Ultra: type-safe RPC over HTTP/WebSocket for Bun",
|
|
7
|
+
"author": "SX3",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"homepage": "https://github.com/SX-3/ultra",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/SX-3/ultra"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/SX-3/ultra/issues"
|
|
16
|
+
},
|
|
17
|
+
"keywords": ["RPC", "HTTP", "WebSocket", "Bun", "Framework", "TypeScript"],
|
|
18
|
+
"sideEffects": false,
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/ultra.d.mts",
|
|
22
|
+
"import": "./dist/ultra.mjs",
|
|
23
|
+
"default": "./dist/ultra.mjs"
|
|
24
|
+
},
|
|
25
|
+
"./*": {
|
|
26
|
+
"types": "./dist/*.d.mts",
|
|
27
|
+
"import": "./dist/*.mjs",
|
|
28
|
+
"default": "./dist/*.mjs"
|
|
29
|
+
},
|
|
30
|
+
"./package.json": "./package.json"
|
|
31
|
+
},
|
|
32
|
+
"main": "./dist/ultra.mjs",
|
|
33
|
+
"module": "./dist/ultra.mjs",
|
|
34
|
+
"types": "./dist/ultra.d.mts",
|
|
35
|
+
"files": [
|
|
36
|
+
"dist"
|
|
37
|
+
],
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsdown",
|
|
40
|
+
"dev": "tsdown --watch",
|
|
41
|
+
"test": "bun test",
|
|
42
|
+
"lint": "eslint ."
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"typescript": "^5"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@antfu/eslint-config": "^6.7.1",
|
|
49
|
+
"@types/bun": "latest",
|
|
50
|
+
"bun-git-hooks": "^0.3.1",
|
|
51
|
+
"eslint": "^9.39.2",
|
|
52
|
+
"eslint-plugin-format": "^1.1.0",
|
|
53
|
+
"tsdown": "^0.18.2"
|
|
54
|
+
}
|
|
55
|
+
}
|