speexjs 0.2.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/README.md +555 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +1017 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/client/index.d.ts +73 -0
- package/dist/client/index.js +927 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/signals/index.d.ts +62 -0
- package/dist/client/signals/index.js +248 -0
- package/dist/client/signals/index.js.map +1 -0
- package/dist/client/vdom/index.d.ts +50 -0
- package/dist/client/vdom/index.js +540 -0
- package/dist/client/vdom/index.js.map +1 -0
- package/dist/client/vdom/jsx-runtime.d.ts +9 -0
- package/dist/client/vdom/jsx-runtime.js +203 -0
- package/dist/client/vdom/jsx-runtime.js.map +1 -0
- package/dist/index-CMkhSDh7.d.ts +97 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +6402 -0
- package/dist/index.js.map +1 -0
- package/dist/jsx-DGrnv8QB.d.ts +8 -0
- package/dist/response-Ca8KWK5_.d.ts +173 -0
- package/dist/rpc/index.d.ts +70 -0
- package/dist/rpc/index.js +136 -0
- package/dist/rpc/index.js.map +1 -0
- package/dist/schema/index.d.ts +231 -0
- package/dist/schema/index.js +1160 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/server/auth/index.d.ts +61 -0
- package/dist/server/auth/index.js +462 -0
- package/dist/server/auth/index.js.map +1 -0
- package/dist/server/cache/index.d.ts +45 -0
- package/dist/server/cache/index.js +238 -0
- package/dist/server/cache/index.js.map +1 -0
- package/dist/server/container/index.d.ts +20 -0
- package/dist/server/container/index.js +62 -0
- package/dist/server/container/index.js.map +1 -0
- package/dist/server/controller/index.d.ts +37 -0
- package/dist/server/controller/index.js +139 -0
- package/dist/server/controller/index.js.map +1 -0
- package/dist/server/database/index.d.ts +461 -0
- package/dist/server/database/index.js +1977 -0
- package/dist/server/database/index.js.map +1 -0
- package/dist/server/events/index.d.ts +29 -0
- package/dist/server/events/index.js +159 -0
- package/dist/server/events/index.js.map +1 -0
- package/dist/server/gate/index.d.ts +36 -0
- package/dist/server/gate/index.js +169 -0
- package/dist/server/gate/index.js.map +1 -0
- package/dist/server/http/index.d.ts +45 -0
- package/dist/server/http/index.js +871 -0
- package/dist/server/http/index.js.map +1 -0
- package/dist/server/index.d.ts +79 -0
- package/dist/server/index.js +4185 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/middleware/index.d.ts +5 -0
- package/dist/server/middleware/index.js +416 -0
- package/dist/server/middleware/index.js.map +1 -0
- package/dist/server/router/index.d.ts +5 -0
- package/dist/server/router/index.js +231 -0
- package/dist/server/router/index.js.map +1 -0
- package/dist/server/storage/index.d.ts +66 -0
- package/dist/server/storage/index.js +244 -0
- package/dist/server/storage/index.js.map +1 -0
- package/dist/session-guard-CZeN87L9.d.ts +48 -0
- package/dist/types-CXH8hPei.d.ts +38 -0
- package/package.json +138 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
import { Readable } from 'node:stream';
|
|
3
|
+
|
|
4
|
+
declare class HeadersMap {
|
|
5
|
+
private data;
|
|
6
|
+
constructor(initial?: Record<string, string | string[]>);
|
|
7
|
+
get(name: string): string | undefined;
|
|
8
|
+
getAll(name: string): string[];
|
|
9
|
+
set(name: string, value: string): void;
|
|
10
|
+
append(name: string, value: string): void;
|
|
11
|
+
has(name: string): boolean;
|
|
12
|
+
delete(name: string): void;
|
|
13
|
+
entries(): IterableIterator<[string, string]>;
|
|
14
|
+
keys(): IterableIterator<string>;
|
|
15
|
+
values(): IterableIterator<string>;
|
|
16
|
+
toJSON(): Record<string, string | string[]>;
|
|
17
|
+
toNodeHeaders(): Record<string, string | string[]>;
|
|
18
|
+
get size(): number;
|
|
19
|
+
[Symbol.iterator](): IterableIterator<[string, string]>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface UploadedFile {
|
|
23
|
+
readonly fieldName: string;
|
|
24
|
+
readonly originalName: string;
|
|
25
|
+
readonly mimeType: string;
|
|
26
|
+
readonly size: number;
|
|
27
|
+
readonly path: string;
|
|
28
|
+
readonly extension: string;
|
|
29
|
+
move(destination: string, filename?: string): Promise<string>;
|
|
30
|
+
toBuffer(): Promise<Buffer>;
|
|
31
|
+
toBase64(): string;
|
|
32
|
+
isImage(): boolean;
|
|
33
|
+
isVideo(): boolean;
|
|
34
|
+
}
|
|
35
|
+
declare class SuperUploadedFile implements UploadedFile {
|
|
36
|
+
readonly fieldName: string;
|
|
37
|
+
readonly originalName: string;
|
|
38
|
+
readonly mimeType: string;
|
|
39
|
+
readonly size: number;
|
|
40
|
+
readonly path: string;
|
|
41
|
+
readonly extension: string;
|
|
42
|
+
private buffer;
|
|
43
|
+
constructor(opts: {
|
|
44
|
+
fieldName: string;
|
|
45
|
+
originalName: string;
|
|
46
|
+
mimeType: string;
|
|
47
|
+
size: number;
|
|
48
|
+
path: string;
|
|
49
|
+
buffer?: Buffer;
|
|
50
|
+
});
|
|
51
|
+
move(destination: string, filename?: string): Promise<string>;
|
|
52
|
+
toBuffer(): Promise<Buffer>;
|
|
53
|
+
toBase64(): string;
|
|
54
|
+
isImage(): boolean;
|
|
55
|
+
isVideo(): boolean;
|
|
56
|
+
static createFromBuffer(fieldName: string, originalName: string, mimeType: string, buffer: Buffer, tempDir?: string): Promise<SuperUploadedFile>;
|
|
57
|
+
cleanup(): Promise<void>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
interface Schema<T = unknown> {
|
|
61
|
+
parse(input: unknown): T;
|
|
62
|
+
validate(input: unknown): {
|
|
63
|
+
success: boolean;
|
|
64
|
+
data?: T;
|
|
65
|
+
errors?: {
|
|
66
|
+
message: string;
|
|
67
|
+
path?: string;
|
|
68
|
+
}[];
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
declare class SuperRequest {
|
|
72
|
+
private raw;
|
|
73
|
+
private _headers;
|
|
74
|
+
private _query;
|
|
75
|
+
private _cookies;
|
|
76
|
+
private _ip;
|
|
77
|
+
private _params;
|
|
78
|
+
private bodyCache;
|
|
79
|
+
private _bodyReadPromise;
|
|
80
|
+
constructor(raw: IncomingMessage);
|
|
81
|
+
readonly method: string;
|
|
82
|
+
readonly url: string;
|
|
83
|
+
readonly path: string;
|
|
84
|
+
get headers(): HeadersMap;
|
|
85
|
+
get query(): Record<string, string | string[]>;
|
|
86
|
+
get params(): Record<string, string>;
|
|
87
|
+
set params(value: Record<string, string>);
|
|
88
|
+
get ip(): string;
|
|
89
|
+
private ensureBody;
|
|
90
|
+
private readBodyFromStream;
|
|
91
|
+
private isContentType;
|
|
92
|
+
private getMultipartBoundary;
|
|
93
|
+
body(): Promise<unknown>;
|
|
94
|
+
json<T = unknown>(): Promise<T>;
|
|
95
|
+
text(): Promise<string>;
|
|
96
|
+
formData(): Promise<Record<string, string>>;
|
|
97
|
+
file(name: string): Promise<SuperUploadedFile | undefined>;
|
|
98
|
+
files(): Promise<Record<string, SuperUploadedFile>>;
|
|
99
|
+
cookie(name: string): string | undefined;
|
|
100
|
+
validate<T>(schema: Schema<T>): Promise<T>;
|
|
101
|
+
isAjax(): boolean;
|
|
102
|
+
wantsJson(): boolean;
|
|
103
|
+
bearerToken(): string | undefined;
|
|
104
|
+
get rawRequest(): IncomingMessage;
|
|
105
|
+
}
|
|
106
|
+
declare class ValidationError extends Error {
|
|
107
|
+
readonly errors: {
|
|
108
|
+
message: string;
|
|
109
|
+
path?: string;
|
|
110
|
+
}[];
|
|
111
|
+
constructor(message: string, errors: {
|
|
112
|
+
message: string;
|
|
113
|
+
path?: string;
|
|
114
|
+
}[]);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
interface CookieOptions {
|
|
118
|
+
maxAge?: number;
|
|
119
|
+
expires?: Date;
|
|
120
|
+
path?: string;
|
|
121
|
+
domain?: string;
|
|
122
|
+
secure?: boolean;
|
|
123
|
+
httpOnly?: boolean;
|
|
124
|
+
sameSite?: 'strict' | 'lax' | 'none';
|
|
125
|
+
signed?: boolean;
|
|
126
|
+
}
|
|
127
|
+
declare function parseCookies(header: string): Record<string, string>;
|
|
128
|
+
declare function serializeCookie(name: string, value: string, options?: CookieOptions): string;
|
|
129
|
+
declare function clearCookie(name: string, options?: CookieOptions): string;
|
|
130
|
+
|
|
131
|
+
interface FileOptions {
|
|
132
|
+
root?: string;
|
|
133
|
+
maxAge?: number;
|
|
134
|
+
acceptRanges?: boolean;
|
|
135
|
+
cacheControl?: boolean;
|
|
136
|
+
etag?: boolean;
|
|
137
|
+
lastModified?: boolean;
|
|
138
|
+
headers?: Record<string, string>;
|
|
139
|
+
}
|
|
140
|
+
declare class SuperResponse {
|
|
141
|
+
private raw;
|
|
142
|
+
private _statusCode;
|
|
143
|
+
private _headers;
|
|
144
|
+
private _cookies;
|
|
145
|
+
private _body;
|
|
146
|
+
private _sent;
|
|
147
|
+
private _contentTypeSet;
|
|
148
|
+
constructor(raw: ServerResponse);
|
|
149
|
+
status(code: number): this;
|
|
150
|
+
header(name: string, value: string): this;
|
|
151
|
+
setHeader(name: string, value: string): this;
|
|
152
|
+
getHeader(name: string): string | undefined;
|
|
153
|
+
removeHeader(name: string): this;
|
|
154
|
+
hasHeader(name: string): boolean;
|
|
155
|
+
type(contentType: string): this;
|
|
156
|
+
json<T>(data: T, status?: number): this;
|
|
157
|
+
send(body: string | Buffer, status?: number, contentType?: string): this;
|
|
158
|
+
html(html: string, status?: number): this;
|
|
159
|
+
redirect(url: string, status?: 301 | 302 | 307 | 308): this;
|
|
160
|
+
stream(stream: Readable, status?: number): this;
|
|
161
|
+
file(filePath: string, options?: FileOptions): Promise<this>;
|
|
162
|
+
download(filePath: string, filename?: string): Promise<this>;
|
|
163
|
+
attachment(filename?: string): this;
|
|
164
|
+
cookie(name: string, value: string, options?: CookieOptions): this;
|
|
165
|
+
clearCookie(name: string, options?: CookieOptions): this;
|
|
166
|
+
get statusCode(): number;
|
|
167
|
+
get headersSent(): boolean;
|
|
168
|
+
get rawResponse(): ServerResponse;
|
|
169
|
+
flush(): Promise<void>;
|
|
170
|
+
private flushHeaders;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export { type CookieOptions as C, type FileOptions as F, HeadersMap as H, SuperRequest as S, type UploadedFile as U, ValidationError as V, SuperResponse as a, type Schema as b, SuperUploadedFile as c, clearCookie as d, parseCookies as p, serializeCookie as s };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { S as Schema } from '../types-CXH8hPei.js';
|
|
2
|
+
|
|
3
|
+
interface RpcProcedure<TInput = unknown, TOutput = unknown> {
|
|
4
|
+
input?: Schema<TInput>;
|
|
5
|
+
output?: Schema<TOutput>;
|
|
6
|
+
handler: (input: TInput, ctx: RpcContext) => TOutput | Promise<TOutput>;
|
|
7
|
+
}
|
|
8
|
+
interface RpcContext {
|
|
9
|
+
userId?: string | number;
|
|
10
|
+
user?: unknown;
|
|
11
|
+
meta: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
interface RpcDefinitions {
|
|
14
|
+
[key: string]: RpcProcedure;
|
|
15
|
+
}
|
|
16
|
+
declare class RpcError extends Error {
|
|
17
|
+
code: string;
|
|
18
|
+
status: number;
|
|
19
|
+
details?: unknown | undefined;
|
|
20
|
+
constructor(code: string, message: string, status?: number, details?: unknown | undefined);
|
|
21
|
+
}
|
|
22
|
+
type InferRpcInput<T extends RpcDefinitions> = {
|
|
23
|
+
[K in keyof T]: T[K] extends RpcProcedure<infer I, any> ? I : never;
|
|
24
|
+
};
|
|
25
|
+
type InferRpcOutput<T extends RpcDefinitions> = {
|
|
26
|
+
[K in keyof T]: T[K] extends RpcProcedure<any, infer O> ? O : never;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
interface RpcServerOptions<T extends RpcDefinitions> {
|
|
30
|
+
procedures: T;
|
|
31
|
+
context?: () => RpcContext | Promise<RpcContext>;
|
|
32
|
+
middleware?: RpcMiddleware[];
|
|
33
|
+
}
|
|
34
|
+
type RpcMiddleware = (name: string, input: unknown, ctx: RpcContext) => void | Promise<void>;
|
|
35
|
+
declare class RpcServer<T extends RpcDefinitions> {
|
|
36
|
+
private procedures;
|
|
37
|
+
private contextFactory?;
|
|
38
|
+
private middleware;
|
|
39
|
+
constructor(options: RpcServerOptions<T>);
|
|
40
|
+
call<K extends keyof T & string>(name: K, input?: unknown): Promise<InferRpcOutput<T>[K]>;
|
|
41
|
+
toHandler(): (req: any, res: any) => Promise<void>;
|
|
42
|
+
}
|
|
43
|
+
declare function rpc<T extends RpcDefinitions>(options: RpcServerOptions<T>): RpcServer<T>;
|
|
44
|
+
|
|
45
|
+
interface RpcClientOptions {
|
|
46
|
+
baseUrl: string;
|
|
47
|
+
headers?: Record<string, string>;
|
|
48
|
+
fetch?: typeof globalThis.fetch;
|
|
49
|
+
}
|
|
50
|
+
declare class RpcClient {
|
|
51
|
+
private baseUrl;
|
|
52
|
+
private headers;
|
|
53
|
+
private fetchFn;
|
|
54
|
+
constructor(options: RpcClientOptions);
|
|
55
|
+
setHeader(name: string, value: string): void;
|
|
56
|
+
call<T>(procedure: string, input?: unknown): Promise<T>;
|
|
57
|
+
batch<T extends unknown[]>(calls: {
|
|
58
|
+
procedure: string;
|
|
59
|
+
input?: unknown;
|
|
60
|
+
}[]): Promise<T>;
|
|
61
|
+
}
|
|
62
|
+
declare class RpcClientError extends Error {
|
|
63
|
+
code: string;
|
|
64
|
+
status: number;
|
|
65
|
+
details?: unknown | undefined;
|
|
66
|
+
constructor(code: string, message: string, status: number, details?: unknown | undefined);
|
|
67
|
+
}
|
|
68
|
+
declare function createClient(options: RpcClientOptions): RpcClient;
|
|
69
|
+
|
|
70
|
+
export { type InferRpcInput, type InferRpcOutput, RpcClient, RpcClientError, type RpcClientOptions, type RpcContext, type RpcDefinitions, RpcError, type RpcProcedure, RpcServer, type RpcServerOptions, createClient, rpc };
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// src/rpc/types.ts
|
|
2
|
+
var RpcError = class extends Error {
|
|
3
|
+
constructor(code, message, status = 400, details) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.code = code;
|
|
6
|
+
this.status = status;
|
|
7
|
+
this.details = details;
|
|
8
|
+
this.name = "RpcError";
|
|
9
|
+
}
|
|
10
|
+
code;
|
|
11
|
+
status;
|
|
12
|
+
details;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// src/rpc/server/index.ts
|
|
16
|
+
var RpcServer = class {
|
|
17
|
+
procedures;
|
|
18
|
+
contextFactory;
|
|
19
|
+
middleware;
|
|
20
|
+
constructor(options) {
|
|
21
|
+
this.procedures = options.procedures;
|
|
22
|
+
this.contextFactory = options.context;
|
|
23
|
+
this.middleware = options.middleware || [];
|
|
24
|
+
}
|
|
25
|
+
async call(name, input) {
|
|
26
|
+
const proc = this.procedures[name];
|
|
27
|
+
if (!proc) throw new RpcError("NOT_FOUND", `Procedure '${name}' not found`, 404);
|
|
28
|
+
const ctx = this.contextFactory ? await this.contextFactory() : { meta: {} };
|
|
29
|
+
for (const mw of this.middleware) {
|
|
30
|
+
await mw(name, input, ctx);
|
|
31
|
+
}
|
|
32
|
+
let validatedInput = input;
|
|
33
|
+
if (proc.input) {
|
|
34
|
+
const result = proc.input.safeParse(input);
|
|
35
|
+
if (!result.success) {
|
|
36
|
+
throw new RpcError("VALIDATION_ERROR", result.error || "Invalid input", 422, result.error);
|
|
37
|
+
}
|
|
38
|
+
validatedInput = result.data;
|
|
39
|
+
}
|
|
40
|
+
const output = await proc.handler(validatedInput, ctx);
|
|
41
|
+
if (proc.output) {
|
|
42
|
+
const result = proc.output.safeParse(output);
|
|
43
|
+
if (!result.success) {
|
|
44
|
+
throw new RpcError("VALIDATION_ERROR", "Invalid output from server", 500);
|
|
45
|
+
}
|
|
46
|
+
return result.data;
|
|
47
|
+
}
|
|
48
|
+
return output;
|
|
49
|
+
}
|
|
50
|
+
toHandler() {
|
|
51
|
+
return async (req, res) => {
|
|
52
|
+
try {
|
|
53
|
+
const body = typeof req.body === "object" ? req.body : JSON.parse(req.body || "{}");
|
|
54
|
+
const { procedure, input } = body;
|
|
55
|
+
const output = await this.call(procedure, input);
|
|
56
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
57
|
+
res.end(JSON.stringify({ success: true, data: output }));
|
|
58
|
+
} catch (err) {
|
|
59
|
+
if (err instanceof RpcError) {
|
|
60
|
+
res.writeHead(err.status, { "Content-Type": "application/json" });
|
|
61
|
+
res.end(JSON.stringify({
|
|
62
|
+
success: false,
|
|
63
|
+
error: { code: err.code, message: err.message, details: err.details }
|
|
64
|
+
}));
|
|
65
|
+
} else {
|
|
66
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
67
|
+
res.end(JSON.stringify({ success: false, error: { code: "INTERNAL", message: "Internal server error" } }));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
function rpc(options) {
|
|
74
|
+
return new RpcServer(options);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// src/rpc/client/index.ts
|
|
78
|
+
var RpcClient = class {
|
|
79
|
+
baseUrl;
|
|
80
|
+
headers;
|
|
81
|
+
fetchFn;
|
|
82
|
+
constructor(options) {
|
|
83
|
+
this.baseUrl = options.baseUrl.replace(/\/$/, "");
|
|
84
|
+
this.headers = options.headers || {};
|
|
85
|
+
this.fetchFn = options.fetch || globalThis.fetch;
|
|
86
|
+
}
|
|
87
|
+
setHeader(name, value) {
|
|
88
|
+
this.headers[name] = value;
|
|
89
|
+
}
|
|
90
|
+
async call(procedure, input) {
|
|
91
|
+
const response = await this.fetchFn(`${this.baseUrl}/rpc`, {
|
|
92
|
+
method: "POST",
|
|
93
|
+
headers: { "Content-Type": "application/json", ...this.headers },
|
|
94
|
+
body: JSON.stringify({ procedure, input })
|
|
95
|
+
});
|
|
96
|
+
const json = await response.json();
|
|
97
|
+
if (!json.success) {
|
|
98
|
+
throw new RpcClientError(json.error?.code || "UNKNOWN", json.error?.message || "Unknown error", response.status, json.error?.details);
|
|
99
|
+
}
|
|
100
|
+
return json.data;
|
|
101
|
+
}
|
|
102
|
+
async batch(calls) {
|
|
103
|
+
const response = await this.fetchFn(`${this.baseUrl}/rpc/batch`, {
|
|
104
|
+
method: "POST",
|
|
105
|
+
headers: { "Content-Type": "application/json", ...this.headers },
|
|
106
|
+
body: JSON.stringify({ calls })
|
|
107
|
+
});
|
|
108
|
+
const json = await response.json();
|
|
109
|
+
if (!json.success) throw new RpcClientError("BATCH_ERROR", json.error?.message || "Batch failed", response.status);
|
|
110
|
+
return json.data;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
var RpcClientError = class extends Error {
|
|
114
|
+
constructor(code, message, status, details) {
|
|
115
|
+
super(message);
|
|
116
|
+
this.code = code;
|
|
117
|
+
this.status = status;
|
|
118
|
+
this.details = details;
|
|
119
|
+
this.name = "RpcClientError";
|
|
120
|
+
}
|
|
121
|
+
code;
|
|
122
|
+
status;
|
|
123
|
+
details;
|
|
124
|
+
};
|
|
125
|
+
function createClient(options) {
|
|
126
|
+
return new RpcClient(options);
|
|
127
|
+
}
|
|
128
|
+
export {
|
|
129
|
+
RpcClient,
|
|
130
|
+
RpcClientError,
|
|
131
|
+
RpcError,
|
|
132
|
+
RpcServer,
|
|
133
|
+
createClient,
|
|
134
|
+
rpc
|
|
135
|
+
};
|
|
136
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/rpc/types.ts","../../src/rpc/server/index.ts","../../src/rpc/client/index.ts"],"sourcesContent":["import type { Schema } from '../schema/index.js'\n\nexport interface RpcProcedure<TInput = unknown, TOutput = unknown> {\n input?: Schema<TInput>\n output?: Schema<TOutput>\n handler: (input: TInput, ctx: RpcContext) => TOutput | Promise<TOutput>\n}\n\nexport interface RpcContext {\n userId?: string | number\n user?: unknown\n meta: Record<string, unknown>\n}\n\nexport type RpcQuery<TInput, TOutput> = RpcProcedure<TInput, TOutput>\nexport type RpcMutation<TInput, TOutput> = RpcProcedure<TInput, TOutput>\n\nexport interface RpcDefinitions {\n [key: string]: RpcProcedure\n}\n\nexport class RpcError extends Error {\n constructor(\n public code: string,\n message: string,\n public status: number = 400,\n public details?: unknown\n ) {\n super(message)\n this.name = 'RpcError'\n }\n}\n\nexport type InferRpcInput<T extends RpcDefinitions> = {\n [K in keyof T]: T[K] extends RpcProcedure<infer I, any> ? I : never\n}\n\nexport type InferRpcOutput<T extends RpcDefinitions> = {\n [K in keyof T]: T[K] extends RpcProcedure<any, infer O> ? O : never\n}\n","import type { Schema } from '../../schema/index.js'\nimport type { RpcDefinitions, RpcContext, InferRpcOutput } from '../types.js'\nimport { RpcError } from '../types.js'\n\nexport interface RpcServerOptions<T extends RpcDefinitions> {\n procedures: T\n context?: () => RpcContext | Promise<RpcContext>\n middleware?: RpcMiddleware[]\n}\n\ntype RpcMiddleware = (name: string, input: unknown, ctx: RpcContext) => void | Promise<void>\n\nexport class RpcServer<T extends RpcDefinitions> {\n private procedures: T\n private contextFactory?: () => RpcContext | Promise<RpcContext>\n private middleware: RpcMiddleware[]\n\n constructor(options: RpcServerOptions<T>) {\n this.procedures = options.procedures\n this.contextFactory = options.context\n this.middleware = options.middleware || []\n }\n\n async call<K extends keyof T & string>(\n name: K,\n input?: unknown\n ): Promise<InferRpcOutput<T>[K]> {\n const proc = this.procedures[name]\n if (!proc) throw new RpcError('NOT_FOUND', `Procedure '${name}' not found`, 404)\n\n const ctx: RpcContext = this.contextFactory ? await this.contextFactory() : { meta: {} }\n\n for (const mw of this.middleware) {\n await mw(name, input, ctx)\n }\n\n let validatedInput = input\n if (proc.input) {\n const result = (proc.input as Schema<any>).safeParse(input)\n if (!result.success) {\n throw new RpcError('VALIDATION_ERROR', result.error || 'Invalid input', 422, result.error)\n }\n validatedInput = result.data\n }\n\n const output = await proc.handler(validatedInput, ctx)\n\n if (proc.output) {\n const result = (proc.output as Schema<any>).safeParse(output)\n if (!result.success) {\n throw new RpcError('VALIDATION_ERROR', 'Invalid output from server', 500)\n }\n return result.data as InferRpcOutput<T>[K]\n }\n\n return output as InferRpcOutput<T>[K]\n }\n\n toHandler(): (req: any, res: any) => Promise<void> {\n return async (req, res) => {\n try {\n const body = typeof req.body === 'object' ? req.body : JSON.parse(req.body || '{}')\n const { procedure, input } = body\n const output = await this.call(procedure, input)\n res.writeHead(200, { 'Content-Type': 'application/json' })\n res.end(JSON.stringify({ success: true, data: output }))\n } catch (err) {\n if (err instanceof RpcError) {\n res.writeHead(err.status, { 'Content-Type': 'application/json' })\n res.end(JSON.stringify({\n success: false,\n error: { code: err.code, message: err.message, details: err.details }\n }))\n } else {\n res.writeHead(500, { 'Content-Type': 'application/json' })\n res.end(JSON.stringify({ success: false, error: { code: 'INTERNAL', message: 'Internal server error' } }))\n }\n }\n }\n }\n}\n\nexport function rpc<T extends RpcDefinitions>(options: RpcServerOptions<T>): RpcServer<T> {\n return new RpcServer(options)\n}\n","export interface RpcClientOptions {\n baseUrl: string\n headers?: Record<string, string>\n fetch?: typeof globalThis.fetch\n}\n\nexport class RpcClient {\n private baseUrl: string\n private headers: Record<string, string>\n private fetchFn: typeof globalThis.fetch\n\n constructor(options: RpcClientOptions) {\n this.baseUrl = options.baseUrl.replace(/\\/$/, '')\n this.headers = options.headers || {}\n this.fetchFn = options.fetch || globalThis.fetch\n }\n\n setHeader(name: string, value: string): void {\n this.headers[name] = value\n }\n\n async call<T>(procedure: string, input?: unknown): Promise<T> {\n const response = await this.fetchFn(`${this.baseUrl}/rpc`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json', ...this.headers },\n body: JSON.stringify({ procedure, input }),\n })\n\n const json = await response.json()\n if (!json.success) {\n throw new RpcClientError(json.error?.code || 'UNKNOWN', json.error?.message || 'Unknown error', response.status, json.error?.details)\n }\n return json.data as T\n }\n\n async batch<T extends unknown[]>(calls: { procedure: string; input?: unknown }[]): Promise<T> {\n const response = await this.fetchFn(`${this.baseUrl}/rpc/batch`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json', ...this.headers },\n body: JSON.stringify({ calls }),\n })\n const json = await response.json()\n if (!json.success) throw new RpcClientError('BATCH_ERROR', json.error?.message || 'Batch failed', response.status)\n return json.data as T\n }\n}\n\nexport class RpcClientError extends Error {\n constructor(\n public code: string,\n message: string,\n public status: number,\n public details?: unknown\n ) {\n super(message)\n this.name = 'RpcClientError'\n }\n}\n\nexport function createClient(options: RpcClientOptions): RpcClient {\n return new RpcClient(options)\n}\n"],"mappings":";AAqBO,IAAM,WAAN,cAAuB,MAAM;AAAA,EAClC,YACS,MACP,SACO,SAAiB,KACjB,SACP;AACA,UAAM,OAAO;AALN;AAEA;AACA;AAGP,SAAK,OAAO;AAAA,EACd;AAAA,EAPS;AAAA,EAEA;AAAA,EACA;AAKX;;;ACnBO,IAAM,YAAN,MAA0C;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EAER,YAAY,SAA8B;AACxC,SAAK,aAAa,QAAQ;AAC1B,SAAK,iBAAiB,QAAQ;AAC9B,SAAK,aAAa,QAAQ,cAAc,CAAC;AAAA,EAC3C;AAAA,EAEA,MAAM,KACJ,MACA,OAC+B;AAC/B,UAAM,OAAO,KAAK,WAAW,IAAI;AACjC,QAAI,CAAC,KAAM,OAAM,IAAI,SAAS,aAAa,cAAc,IAAI,eAAe,GAAG;AAE/E,UAAM,MAAkB,KAAK,iBAAiB,MAAM,KAAK,eAAe,IAAI,EAAE,MAAM,CAAC,EAAE;AAEvF,eAAW,MAAM,KAAK,YAAY;AAChC,YAAM,GAAG,MAAM,OAAO,GAAG;AAAA,IAC3B;AAEA,QAAI,iBAAiB;AACrB,QAAI,KAAK,OAAO;AACd,YAAM,SAAU,KAAK,MAAsB,UAAU,KAAK;AAC1D,UAAI,CAAC,OAAO,SAAS;AACnB,cAAM,IAAI,SAAS,oBAAoB,OAAO,SAAS,iBAAiB,KAAK,OAAO,KAAK;AAAA,MAC3F;AACA,uBAAiB,OAAO;AAAA,IAC1B;AAEA,UAAM,SAAS,MAAM,KAAK,QAAQ,gBAAgB,GAAG;AAErD,QAAI,KAAK,QAAQ;AACf,YAAM,SAAU,KAAK,OAAuB,UAAU,MAAM;AAC5D,UAAI,CAAC,OAAO,SAAS;AACnB,cAAM,IAAI,SAAS,oBAAoB,8BAA8B,GAAG;AAAA,MAC1E;AACA,aAAO,OAAO;AAAA,IAChB;AAEA,WAAO;AAAA,EACT;AAAA,EAEA,YAAmD;AACjD,WAAO,OAAO,KAAK,QAAQ;AACzB,UAAI;AACF,cAAM,OAAO,OAAO,IAAI,SAAS,WAAW,IAAI,OAAO,KAAK,MAAM,IAAI,QAAQ,IAAI;AAClF,cAAM,EAAE,WAAW,MAAM,IAAI;AAC7B,cAAM,SAAS,MAAM,KAAK,KAAK,WAAW,KAAK;AAC/C,YAAI,UAAU,KAAK,EAAE,gBAAgB,mBAAmB,CAAC;AACzD,YAAI,IAAI,KAAK,UAAU,EAAE,SAAS,MAAM,MAAM,OAAO,CAAC,CAAC;AAAA,MACzD,SAAS,KAAK;AACZ,YAAI,eAAe,UAAU;AAC3B,cAAI,UAAU,IAAI,QAAQ,EAAE,gBAAgB,mBAAmB,CAAC;AAChE,cAAI,IAAI,KAAK,UAAU;AAAA,YACrB,SAAS;AAAA,YACT,OAAO,EAAE,MAAM,IAAI,MAAM,SAAS,IAAI,SAAS,SAAS,IAAI,QAAQ;AAAA,UACtE,CAAC,CAAC;AAAA,QACJ,OAAO;AACL,cAAI,UAAU,KAAK,EAAE,gBAAgB,mBAAmB,CAAC;AACzD,cAAI,IAAI,KAAK,UAAU,EAAE,SAAS,OAAO,OAAO,EAAE,MAAM,YAAY,SAAS,wBAAwB,EAAE,CAAC,CAAC;AAAA,QAC3G;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEO,SAAS,IAA8B,SAA4C;AACxF,SAAO,IAAI,UAAU,OAAO;AAC9B;;;AC9EO,IAAM,YAAN,MAAgB;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EAER,YAAY,SAA2B;AACrC,SAAK,UAAU,QAAQ,QAAQ,QAAQ,OAAO,EAAE;AAChD,SAAK,UAAU,QAAQ,WAAW,CAAC;AACnC,SAAK,UAAU,QAAQ,SAAS,WAAW;AAAA,EAC7C;AAAA,EAEA,UAAU,MAAc,OAAqB;AAC3C,SAAK,QAAQ,IAAI,IAAI;AAAA,EACvB;AAAA,EAEA,MAAM,KAAQ,WAAmB,OAA6B;AAC5D,UAAM,WAAW,MAAM,KAAK,QAAQ,GAAG,KAAK,OAAO,QAAQ;AAAA,MACzD,QAAQ;AAAA,MACR,SAAS,EAAE,gBAAgB,oBAAoB,GAAG,KAAK,QAAQ;AAAA,MAC/D,MAAM,KAAK,UAAU,EAAE,WAAW,MAAM,CAAC;AAAA,IAC3C,CAAC;AAED,UAAM,OAAO,MAAM,SAAS,KAAK;AACjC,QAAI,CAAC,KAAK,SAAS;AACjB,YAAM,IAAI,eAAe,KAAK,OAAO,QAAQ,WAAW,KAAK,OAAO,WAAW,iBAAiB,SAAS,QAAQ,KAAK,OAAO,OAAO;AAAA,IACtI;AACA,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAM,MAA2B,OAA6D;AAC5F,UAAM,WAAW,MAAM,KAAK,QAAQ,GAAG,KAAK,OAAO,cAAc;AAAA,MAC/D,QAAQ;AAAA,MACR,SAAS,EAAE,gBAAgB,oBAAoB,GAAG,KAAK,QAAQ;AAAA,MAC/D,MAAM,KAAK,UAAU,EAAE,MAAM,CAAC;AAAA,IAChC,CAAC;AACD,UAAM,OAAO,MAAM,SAAS,KAAK;AACjC,QAAI,CAAC,KAAK,QAAS,OAAM,IAAI,eAAe,eAAe,KAAK,OAAO,WAAW,gBAAgB,SAAS,MAAM;AACjH,WAAO,KAAK;AAAA,EACd;AACF;AAEO,IAAM,iBAAN,cAA6B,MAAM;AAAA,EACxC,YACS,MACP,SACO,QACA,SACP;AACA,UAAM,OAAO;AALN;AAEA;AACA;AAGP,SAAK,OAAO;AAAA,EACd;AAAA,EAPS;AAAA,EAEA;AAAA,EACA;AAKX;AAEO,SAAS,aAAa,SAAsC;AACjE,SAAO,IAAI,UAAU,OAAO;AAC9B;","names":[]}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { S as Schema, I as Infer } from '../types-CXH8hPei.js';
|
|
2
|
+
export { a as SchemaError } from '../types-CXH8hPei.js';
|
|
3
|
+
|
|
4
|
+
declare function setLocale(locale: 'id' | 'en'): void;
|
|
5
|
+
declare function getLocale(): 'id' | 'en';
|
|
6
|
+
|
|
7
|
+
declare class StringSchema extends Schema<string> {
|
|
8
|
+
private checks;
|
|
9
|
+
min(n: number): this;
|
|
10
|
+
max(n: number): this;
|
|
11
|
+
length(n: number): this;
|
|
12
|
+
email(): this;
|
|
13
|
+
url(): this;
|
|
14
|
+
regex(pattern: RegExp): this;
|
|
15
|
+
includes(substring: string): this;
|
|
16
|
+
startsWith(prefix: string): this;
|
|
17
|
+
endsWith(suffix: string): this;
|
|
18
|
+
trim(): StringTrimSchema;
|
|
19
|
+
lowercase(): StringLowercaseSchema;
|
|
20
|
+
uppercase(): StringUppercaseSchema;
|
|
21
|
+
_parse(value: unknown): string;
|
|
22
|
+
}
|
|
23
|
+
declare class StringTrimSchema extends Schema<string> {
|
|
24
|
+
private readonly inner;
|
|
25
|
+
constructor(inner: StringSchema);
|
|
26
|
+
_parse(value: unknown): string;
|
|
27
|
+
}
|
|
28
|
+
declare class StringLowercaseSchema extends Schema<string> {
|
|
29
|
+
private readonly inner;
|
|
30
|
+
constructor(inner: StringSchema);
|
|
31
|
+
_parse(value: unknown): string;
|
|
32
|
+
}
|
|
33
|
+
declare class StringUppercaseSchema extends Schema<string> {
|
|
34
|
+
private readonly inner;
|
|
35
|
+
constructor(inner: StringSchema);
|
|
36
|
+
_parse(value: unknown): string;
|
|
37
|
+
}
|
|
38
|
+
declare class NumberSchema extends Schema<number> {
|
|
39
|
+
private checks;
|
|
40
|
+
min(n: number): this;
|
|
41
|
+
max(n: number): this;
|
|
42
|
+
int(): this;
|
|
43
|
+
positive(): this;
|
|
44
|
+
negative(): this;
|
|
45
|
+
finite(): this;
|
|
46
|
+
safe(): this;
|
|
47
|
+
_parse(value: unknown): number;
|
|
48
|
+
}
|
|
49
|
+
declare class BooleanSchema extends Schema<boolean> {
|
|
50
|
+
_parse(value: unknown): boolean;
|
|
51
|
+
}
|
|
52
|
+
declare class BigIntSchema extends Schema<bigint> {
|
|
53
|
+
_parse(value: unknown): bigint;
|
|
54
|
+
}
|
|
55
|
+
declare class SymbolSchema extends Schema<symbol> {
|
|
56
|
+
_parse(value: unknown): symbol;
|
|
57
|
+
}
|
|
58
|
+
declare class UndefinedSchema extends Schema<undefined> {
|
|
59
|
+
_parse(value: unknown): undefined;
|
|
60
|
+
}
|
|
61
|
+
declare class NullSchema extends Schema<null> {
|
|
62
|
+
_parse(value: unknown): null;
|
|
63
|
+
}
|
|
64
|
+
declare class NaNSchema extends Schema<number> {
|
|
65
|
+
_parse(value: unknown): number;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
type Shape = Record<string, Schema<unknown>>;
|
|
69
|
+
declare class ObjectSchema<T extends Shape> extends Schema<{
|
|
70
|
+
[K in keyof T]: Infer<T[K]>;
|
|
71
|
+
}> {
|
|
72
|
+
readonly shape: T;
|
|
73
|
+
private isStrictMode;
|
|
74
|
+
private isPassthroughMode;
|
|
75
|
+
constructor(shape: T);
|
|
76
|
+
strict(): this;
|
|
77
|
+
passthrough(): this;
|
|
78
|
+
partial(): ObjectSchema<{
|
|
79
|
+
[K in keyof T]: Schema<Infer<T[K]> | undefined>;
|
|
80
|
+
}>;
|
|
81
|
+
pick<K extends keyof T>(keys: K[]): ObjectSchema<Pick<T, K>>;
|
|
82
|
+
omit<K extends keyof T>(keys: K[]): ObjectSchema<Omit<T, K>>;
|
|
83
|
+
extend<U extends Shape>(shape: U): ObjectSchema<T & U>;
|
|
84
|
+
merge<U extends Shape>(other: ObjectSchema<U>): ObjectSchema<T & U>;
|
|
85
|
+
_parse(value: unknown): {
|
|
86
|
+
[K in keyof T]: Infer<T[K]>;
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
declare class ArraySchema<T> extends Schema<T[]> {
|
|
90
|
+
private readonly itemSchema;
|
|
91
|
+
private checks;
|
|
92
|
+
constructor(itemSchema: Schema<T>);
|
|
93
|
+
min(n: number): this;
|
|
94
|
+
max(n: number): this;
|
|
95
|
+
length(n: number): this;
|
|
96
|
+
nonempty(): this;
|
|
97
|
+
unique(): this;
|
|
98
|
+
_parse(value: unknown): T[];
|
|
99
|
+
}
|
|
100
|
+
type TupleSchemaTypes<T extends Schema<unknown>[]> = {
|
|
101
|
+
[K in keyof T]: Infer<T[K]>;
|
|
102
|
+
};
|
|
103
|
+
declare class TupleSchema<T extends Schema<unknown>[]> extends Schema<TupleSchemaTypes<T>> {
|
|
104
|
+
private readonly schemas;
|
|
105
|
+
constructor(schemas: [...T]);
|
|
106
|
+
_parse(value: unknown): TupleSchemaTypes<T>;
|
|
107
|
+
}
|
|
108
|
+
declare class EnumSchema<T extends string> extends Schema<T> {
|
|
109
|
+
private readonly values;
|
|
110
|
+
constructor(values: readonly T[]);
|
|
111
|
+
_parse(value: unknown): T;
|
|
112
|
+
get enum(): readonly T[];
|
|
113
|
+
}
|
|
114
|
+
declare class UnionSchema<T> extends Schema<T> {
|
|
115
|
+
private readonly schemas;
|
|
116
|
+
constructor(schemas: readonly Schema<unknown>[]);
|
|
117
|
+
_parse(value: unknown): T;
|
|
118
|
+
}
|
|
119
|
+
declare class IntersectionSchema<A, B> extends Schema<A & B> {
|
|
120
|
+
private readonly left;
|
|
121
|
+
private readonly right;
|
|
122
|
+
constructor(left: Schema<A>, right: Schema<B>);
|
|
123
|
+
_parse(value: unknown): A & B;
|
|
124
|
+
}
|
|
125
|
+
declare class RecordSchema<V> extends Schema<Record<string, V>> {
|
|
126
|
+
private readonly valueSchema;
|
|
127
|
+
constructor(valueSchema: Schema<V>);
|
|
128
|
+
_parse(value: unknown): Record<string, V>;
|
|
129
|
+
}
|
|
130
|
+
declare class MapSchema<K, V> extends Schema<Map<K, V>> {
|
|
131
|
+
private readonly keySchema;
|
|
132
|
+
private readonly valueSchema;
|
|
133
|
+
constructor(keySchema: Schema<K>, valueSchema: Schema<V>);
|
|
134
|
+
_parse(value: unknown): Map<K, V>;
|
|
135
|
+
}
|
|
136
|
+
declare class SetSchema<T> extends Schema<Set<T>> {
|
|
137
|
+
private readonly itemSchema;
|
|
138
|
+
constructor(itemSchema: Schema<T>);
|
|
139
|
+
_parse(value: unknown): Set<T>;
|
|
140
|
+
}
|
|
141
|
+
declare class DateSchema extends Schema<Date> {
|
|
142
|
+
_parse(value: unknown): Date;
|
|
143
|
+
}
|
|
144
|
+
type LiteralValue = string | number | boolean | null | undefined;
|
|
145
|
+
declare class LiteralSchema<T extends LiteralValue> extends Schema<T> {
|
|
146
|
+
private readonly expected;
|
|
147
|
+
constructor(expected: T);
|
|
148
|
+
_parse(value: unknown): T;
|
|
149
|
+
}
|
|
150
|
+
declare class AnySchema extends Schema<any> {
|
|
151
|
+
_parse(value: unknown): any;
|
|
152
|
+
}
|
|
153
|
+
declare class UnknownSchema extends Schema<unknown> {
|
|
154
|
+
_parse(value: unknown): unknown;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
declare class NIKSchema extends Schema<string> {
|
|
158
|
+
_parse(value: unknown): string;
|
|
159
|
+
}
|
|
160
|
+
declare class NPWPSchema extends Schema<string> {
|
|
161
|
+
_parse(value: unknown): string;
|
|
162
|
+
}
|
|
163
|
+
declare class PhoneSchema extends Schema<string> {
|
|
164
|
+
_parse(value: unknown): string;
|
|
165
|
+
}
|
|
166
|
+
declare class AlamatSchema extends Schema<string> {
|
|
167
|
+
_parse(value: unknown): string;
|
|
168
|
+
}
|
|
169
|
+
declare class KodeposSchema extends Schema<string> {
|
|
170
|
+
_parse(value: unknown): string;
|
|
171
|
+
}
|
|
172
|
+
declare class RekeningSchema extends Schema<string> {
|
|
173
|
+
_parse(value: unknown): string;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
declare class CoerceStringSchema extends Schema<string> {
|
|
177
|
+
_parse(value: unknown): string;
|
|
178
|
+
}
|
|
179
|
+
declare class CoerceNumberSchema extends Schema<number> {
|
|
180
|
+
_parse(value: unknown): number;
|
|
181
|
+
}
|
|
182
|
+
declare class CoerceBooleanSchema extends Schema<boolean> {
|
|
183
|
+
_parse(value: unknown): boolean;
|
|
184
|
+
}
|
|
185
|
+
declare class CoerceDateSchema extends Schema<Date> {
|
|
186
|
+
_parse(value: unknown): Date;
|
|
187
|
+
}
|
|
188
|
+
declare class StandaloneTransformSchema<T> extends Schema<T> {
|
|
189
|
+
private readonly fn;
|
|
190
|
+
constructor(fn: (value: unknown) => T);
|
|
191
|
+
_parse(value: unknown): T;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
declare const s: {
|
|
195
|
+
readonly string: () => StringSchema;
|
|
196
|
+
readonly number: () => NumberSchema;
|
|
197
|
+
readonly boolean: () => BooleanSchema;
|
|
198
|
+
readonly bigint: () => BigIntSchema;
|
|
199
|
+
readonly symbol: () => SymbolSchema;
|
|
200
|
+
readonly undefined: () => UndefinedSchema;
|
|
201
|
+
readonly null: () => NullSchema;
|
|
202
|
+
readonly nan: () => NaNSchema;
|
|
203
|
+
readonly object: <T extends Record<string, Schema<unknown>>>(shape: T) => ObjectSchema<T>;
|
|
204
|
+
readonly array: <T>(itemSchema: Schema<T>) => ArraySchema<T>;
|
|
205
|
+
readonly tuple: <T extends Schema<unknown>[]>(...schemas: T) => TupleSchema<T>;
|
|
206
|
+
readonly enum: <T extends string>(values: readonly T[]) => EnumSchema<T>;
|
|
207
|
+
readonly union: <T extends Schema<unknown>[]>(...schemas: T) => UnionSchema<T[number] extends Schema<infer U> ? U : never>;
|
|
208
|
+
readonly intersection: <A, B>(left: Schema<A>, right: Schema<B>) => IntersectionSchema<A, B>;
|
|
209
|
+
readonly record: <V>(valueSchema: Schema<V>) => RecordSchema<V>;
|
|
210
|
+
readonly map: <K, V>(keySchema: Schema<K>, valueSchema: Schema<V>) => MapSchema<K, V>;
|
|
211
|
+
readonly set: <T>(itemSchema: Schema<T>) => SetSchema<T>;
|
|
212
|
+
readonly date: () => DateSchema;
|
|
213
|
+
readonly literal: <T extends string | number | boolean | null | undefined>(value: T) => LiteralSchema<T>;
|
|
214
|
+
readonly any: () => AnySchema;
|
|
215
|
+
readonly unknown: () => UnknownSchema;
|
|
216
|
+
readonly nik: () => NIKSchema;
|
|
217
|
+
readonly npwp: () => NPWPSchema;
|
|
218
|
+
readonly phone: () => PhoneSchema;
|
|
219
|
+
readonly alamat: () => AlamatSchema;
|
|
220
|
+
readonly kodepos: () => KodeposSchema;
|
|
221
|
+
readonly rekening: () => RekeningSchema;
|
|
222
|
+
readonly coerce: {
|
|
223
|
+
readonly string: () => CoerceStringSchema;
|
|
224
|
+
readonly number: () => CoerceNumberSchema;
|
|
225
|
+
readonly boolean: () => CoerceBooleanSchema;
|
|
226
|
+
readonly date: () => CoerceDateSchema;
|
|
227
|
+
};
|
|
228
|
+
readonly transform: <T>(fn: (value: unknown) => T) => StandaloneTransformSchema<T>;
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
export { AlamatSchema, AnySchema, ArraySchema, BigIntSchema, BooleanSchema, CoerceBooleanSchema, CoerceDateSchema, CoerceNumberSchema, CoerceStringSchema, DateSchema, EnumSchema, Infer, IntersectionSchema, KodeposSchema, LiteralSchema, MapSchema, NIKSchema, NPWPSchema, NaNSchema, NullSchema, NumberSchema, ObjectSchema, PhoneSchema, RecordSchema, RekeningSchema, Schema, SetSchema, StringSchema, SymbolSchema, TupleSchema, UndefinedSchema, UnionSchema, UnknownSchema, getLocale, s, setLocale };
|