milkio 1.0.0-alpha.98 → 1.0.0-beta.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/action/index.d.ts +11 -0
- package/bootstrap/index.d.ts +3 -0
- package/command/index.d.ts +12 -0
- package/config/index.d.ts +8 -0
- package/context/index.d.ts +30 -0
- package/event/index.d.ts +42 -0
- package/exception/index.d.ts +44 -0
- package/execute/execute-id-generator.d.ts +2 -0
- package/execute/index.d.ts +30 -0
- package/flow/index.d.ts +8 -0
- package/handler/index.d.ts +3 -0
- package/index.d.ts +19 -0
- package/index.js +2369 -0
- package/listener/index.d.ts +16 -0
- package/logger/index.d.ts +20 -0
- package/meta/index.d.ts +12 -0
- package/package.json +1 -24
- package/step/index.d.ts +11 -0
- package/stream/index.d.ts +11 -0
- package/type-safety/index.d.ts +9 -0
- package/types/index.d.ts +58 -0
- package/utils/create-id.d.ts +1 -0
- package/utils/headers-to-json.d.ts +1 -0
- package/utils/send-cookbook-event.d.ts +7 -0
- package/utils/trie.d.ts +7 -0
- package/world/index.d.ts +47 -0
- package/.co.toml +0 -2
- package/README.md +0 -3
- package/action/index.ts +0 -19
- package/bootstrap/index.ts +0 -7
- package/command/index.ts +0 -57
- package/config/index.ts +0 -33
- package/context/index.ts +0 -28
- package/event/index.ts +0 -48
- package/exception/index.ts +0 -48
- package/execute/execute-id-generator.ts +0 -7
- package/execute/index.ts +0 -135
- package/flow/index.ts +0 -60
- package/handler/index.ts +0 -7
- package/index.ts +0 -19
- package/listener/index.ts +0 -287
- package/logger/index.ts +0 -78
- package/meta/index.ts +0 -12
- package/step/index.ts +0 -36
- package/stream/index.ts +0 -19
- package/tsconfig.json +0 -31
- package/type-safety/index.ts +0 -16
- package/types/index.ts +0 -69
- package/utils/create-id.ts +0 -11
- package/utils/headers-to-json.ts +0 -7
- package/utils/send-cookbook-event.ts +0 -27
- package/utils/trie.ts +0 -54
- package/world/index.ts +0 -102
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { $context, $meta } from "../index.ts";
|
|
2
|
+
export declare function action<ActionInitT extends ActionInit>(init: ActionInitT): Action<ActionInitT>;
|
|
3
|
+
export type ActionInit = {
|
|
4
|
+
meta?: $meta;
|
|
5
|
+
handler: (context: $context, params: any) => Promise<unknown>;
|
|
6
|
+
};
|
|
7
|
+
export type Action<ActionInitT extends ActionInit> = {
|
|
8
|
+
$milkioType: "action";
|
|
9
|
+
meta: ActionInitT["meta"] extends undefined ? {} : ActionInitT["meta"];
|
|
10
|
+
handler: ActionInitT["handler"];
|
|
11
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { GeneratedInit } from "../index.ts";
|
|
2
|
+
export declare function command<CommandInitT extends CommandInit>(init: CommandInitT): Command<CommandInitT>;
|
|
3
|
+
export interface CommandInit {
|
|
4
|
+
handler: (commands: Array<string>, options: Record<string, string>) => Promise<unknown>;
|
|
5
|
+
}
|
|
6
|
+
export interface Command<CommandInitT extends CommandInit> {
|
|
7
|
+
$milkioType: "command";
|
|
8
|
+
handler: CommandInitT["handler"];
|
|
9
|
+
}
|
|
10
|
+
export declare function __initCommander(generated: GeneratedInit, runtime: any): (argv: Array<string>, options?: {
|
|
11
|
+
onNotFound?: () => any;
|
|
12
|
+
}) => Promise<any>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function config<ConfigT extends Config>(config: ConfigT): ConfigT;
|
|
2
|
+
export type Config = (mode: string) => Promise<Record<string, unknown>> | Record<string, unknown>;
|
|
3
|
+
export interface ConfigEnvironments<T extends Config> {
|
|
4
|
+
[key: string]: (env: Record<string, string>) => Partial<Awaited<ReturnType<T>>> | Promise<Partial<Awaited<ReturnType<T>>>>;
|
|
5
|
+
}
|
|
6
|
+
export declare function envToString(value: string | number | undefined, defaultValue: string): string;
|
|
7
|
+
export declare function envToNumber(value: string | undefined, defaultValue: number): number;
|
|
8
|
+
export declare function envToBoolean(value: string | number | undefined, defaultValue: boolean): boolean;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { MilkioHttpRequest, MilkioHttpResponse, $types, Logger, Action, MilkioRuntimeInit, MilkioInit } from "../index.ts";
|
|
2
|
+
export interface $context {
|
|
3
|
+
_: MilkioRuntimeInit<MilkioInit>;
|
|
4
|
+
develop: boolean;
|
|
5
|
+
executeId: string;
|
|
6
|
+
emit: MilkioRuntimeInit<MilkioInit>["emit"];
|
|
7
|
+
path: string;
|
|
8
|
+
logger: Logger;
|
|
9
|
+
http: ContextHttp<Record<any, any>>;
|
|
10
|
+
config: Readonly<Awaited<ReturnType<$types["configSchema"]["get"]>>>;
|
|
11
|
+
call: <Module extends Promise<{
|
|
12
|
+
default: Action<any>;
|
|
13
|
+
}>>(module: Module, params: Parameters<Awaited<Module>["default"]["handler"]>[1]) => Promise<ReturnType<Awaited<Module>["default"]["handler"]>>;
|
|
14
|
+
onFinally: (handler: () => void | Promise<void>) => void;
|
|
15
|
+
}
|
|
16
|
+
export interface ContextHttp<ParamsParsed = any> {
|
|
17
|
+
url: URL;
|
|
18
|
+
ip: string;
|
|
19
|
+
path: {
|
|
20
|
+
string: keyof $types["generated"]["routeSchema"];
|
|
21
|
+
array: Array<string>;
|
|
22
|
+
};
|
|
23
|
+
params: {
|
|
24
|
+
string: string;
|
|
25
|
+
parsed: ParamsParsed;
|
|
26
|
+
};
|
|
27
|
+
request: MilkioHttpRequest;
|
|
28
|
+
response: MilkioHttpResponse;
|
|
29
|
+
}
|
|
30
|
+
export type ContextCreatedHandler = (context: $context) => Promise<void> | void;
|
package/event/index.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { $context, ContextHttp, Results, Logger, $meta } from "../index.ts";
|
|
2
|
+
export interface $events {
|
|
3
|
+
"milkio:httpRequest": {
|
|
4
|
+
executeId: string;
|
|
5
|
+
path: string;
|
|
6
|
+
logger: Logger;
|
|
7
|
+
http: ContextHttp<Record<string, any>>;
|
|
8
|
+
};
|
|
9
|
+
"milkio:httpResponse": {
|
|
10
|
+
executeId: string;
|
|
11
|
+
path: string;
|
|
12
|
+
logger: Logger;
|
|
13
|
+
http: ContextHttp<Record<string, any>>;
|
|
14
|
+
context: $context;
|
|
15
|
+
};
|
|
16
|
+
"milkio:httpNotFound": {
|
|
17
|
+
executeId: string;
|
|
18
|
+
path: string;
|
|
19
|
+
logger: Logger;
|
|
20
|
+
http: ContextHttp<Record<string, any>>;
|
|
21
|
+
};
|
|
22
|
+
"milkio:executeBefore": {
|
|
23
|
+
executeId: string;
|
|
24
|
+
path: string;
|
|
25
|
+
logger: Logger;
|
|
26
|
+
meta: $meta;
|
|
27
|
+
context: $context;
|
|
28
|
+
};
|
|
29
|
+
"milkio:executeAfter": {
|
|
30
|
+
executeId: string;
|
|
31
|
+
path: string;
|
|
32
|
+
logger: Logger;
|
|
33
|
+
meta: $meta;
|
|
34
|
+
context: $context;
|
|
35
|
+
results: Results<any>;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export declare function __initEventManager(): {
|
|
39
|
+
on: <Key extends keyof $events, Handler extends (event: $events[Key]) => void>(key: Key, handler: Handler) => () => void;
|
|
40
|
+
off: <Key extends keyof $events, Handler extends (event: $events[Key]) => void>(key: Key, handler: Handler) => void;
|
|
41
|
+
emit: <Key extends keyof $events, Value extends $events[Key]>(key: Key, value: Value) => Promise<void>;
|
|
42
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { MilkioResponseReject, Logger } from "../index.ts";
|
|
2
|
+
export interface $rejectCode {
|
|
3
|
+
FAIL: string;
|
|
4
|
+
REQUEST_FAIL: any;
|
|
5
|
+
NOT_DEVELOP_MODE: string;
|
|
6
|
+
REQUEST_TIMEOUT: {
|
|
7
|
+
timeout: number;
|
|
8
|
+
message: string;
|
|
9
|
+
};
|
|
10
|
+
NOT_FOUND: {
|
|
11
|
+
path: string;
|
|
12
|
+
};
|
|
13
|
+
PARAMS_TYPE_INCORRECT: {
|
|
14
|
+
path: string;
|
|
15
|
+
expected: string;
|
|
16
|
+
value: any;
|
|
17
|
+
message: string;
|
|
18
|
+
} | null;
|
|
19
|
+
RESULTS_TYPE_INCORRECT: {
|
|
20
|
+
path: string;
|
|
21
|
+
expected: string;
|
|
22
|
+
value: any;
|
|
23
|
+
message: string;
|
|
24
|
+
} | null;
|
|
25
|
+
UNACCEPTABLE: {
|
|
26
|
+
expected: string;
|
|
27
|
+
message: string;
|
|
28
|
+
};
|
|
29
|
+
PARAMS_TYPE_NOT_SUPPORTED: {
|
|
30
|
+
expected: string;
|
|
31
|
+
};
|
|
32
|
+
RESULTS_TYPE_NOT_SUPPORTED: {
|
|
33
|
+
expected: string;
|
|
34
|
+
};
|
|
35
|
+
INTERNAL_SERVER_ERROR: undefined;
|
|
36
|
+
}
|
|
37
|
+
export declare function reject<Code extends keyof $rejectCode, RejectData extends $rejectCode[Code]>(code: Code, data: RejectData): MilkioRejectError<Code, RejectData>;
|
|
38
|
+
export type MilkioRejectError<Code extends keyof $rejectCode = keyof $rejectCode, RejectData extends $rejectCode[Code] = $rejectCode[Code]> = {
|
|
39
|
+
code: Code;
|
|
40
|
+
data: RejectData;
|
|
41
|
+
stack: string;
|
|
42
|
+
$milkioReject: true;
|
|
43
|
+
};
|
|
44
|
+
export declare function exceptionHandler(executeId: string, logger: Logger, error: MilkioRejectError<any, any> | any): MilkioResponseReject;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { $context, $meta, Logger, Results, GeneratedInit } from "../index.ts";
|
|
2
|
+
export declare function __initExecuter(generated: GeneratedInit, runtime: any): {
|
|
3
|
+
__call: (context: $context, module: {
|
|
4
|
+
default: any;
|
|
5
|
+
}, params?: any) => Promise<any>;
|
|
6
|
+
__execute: (routeSchema: any, options: {
|
|
7
|
+
createdExecuteId: string;
|
|
8
|
+
createdLogger: Logger;
|
|
9
|
+
path: string;
|
|
10
|
+
headers: Record<string, string> | Headers;
|
|
11
|
+
mixinContext: Record<any, any> | undefined;
|
|
12
|
+
} & ({
|
|
13
|
+
params: Record<any, any>;
|
|
14
|
+
paramsType: "raw";
|
|
15
|
+
} | {
|
|
16
|
+
params: string;
|
|
17
|
+
paramsType: "string";
|
|
18
|
+
})) => Promise<{
|
|
19
|
+
executeId: string;
|
|
20
|
+
headers: Headers;
|
|
21
|
+
params: Record<any, unknown>;
|
|
22
|
+
results: Results<any>;
|
|
23
|
+
context: $context;
|
|
24
|
+
meta: Readonly<$meta>;
|
|
25
|
+
type: "action" | "stream";
|
|
26
|
+
emptyResult: boolean;
|
|
27
|
+
resultsTypeSafety: boolean;
|
|
28
|
+
finales: Array<() => void | Promise<void>>;
|
|
29
|
+
}>;
|
|
30
|
+
};
|
package/flow/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type MilkioFlow<T, TReturn = any, TNext = any> = {
|
|
2
|
+
emit: (flow: T) => void;
|
|
3
|
+
[Symbol.asyncIterator]: () => MilkioFlow<T>;
|
|
4
|
+
next(...[value]: [] | [TNext]): Promise<IteratorResult<T, TReturn>>;
|
|
5
|
+
return(): Promise<IteratorResult<T, TReturn>>;
|
|
6
|
+
throw(error: any): Promise<IteratorResult<T, TReturn>>;
|
|
7
|
+
};
|
|
8
|
+
export declare function createFlow<T>(): MilkioFlow<T>;
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export * from "./type-safety/index.ts";
|
|
2
|
+
export * from "@southern-aurora/tson";
|
|
3
|
+
export * from "./types/index.ts";
|
|
4
|
+
export * from "./config/index.ts";
|
|
5
|
+
export * from "./execute/index.ts";
|
|
6
|
+
export * from "./bootstrap/index.ts";
|
|
7
|
+
export * from "./event/index.ts";
|
|
8
|
+
export * from "./flow/index.ts";
|
|
9
|
+
export * from "./handler/index.ts";
|
|
10
|
+
export * from "./world/index.ts";
|
|
11
|
+
export * from "./command/index.ts";
|
|
12
|
+
export * from "./action/index.ts";
|
|
13
|
+
export * from "./stream/index.ts";
|
|
14
|
+
export * from "./logger/index.ts";
|
|
15
|
+
export * from "./context/index.ts";
|
|
16
|
+
export * from "./meta/index.ts";
|
|
17
|
+
export * from "./step/index.ts";
|
|
18
|
+
export * from "./listener/index.ts";
|
|
19
|
+
export * from "./exception/index.ts";
|