@milkio/astra 1.3.61 → 1.3.65
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/index.d.ts +19 -1
- package/index.js +76 -4
- package/package.json +4 -2
package/index.d.ts
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
export type CleanDatabaseHook = (args: {
|
|
2
|
+
world: any;
|
|
3
|
+
databaseId: string;
|
|
4
|
+
}) => void | Promise<void>;
|
|
5
|
+
export type AstraHooks = {
|
|
6
|
+
onCleanDatabase: (hook: CleanDatabaseHook) => void;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* 创建 cleanDatabase 的钩子调度器。每次调用 returned.cleanDatabase() 都会:
|
|
10
|
+
* 生成一个全新随机库名、切换 world.__databaseId、并并行执行所有已注册 hook。
|
|
11
|
+
* 单独导出以便在不启动真实服务的前提下对核心语义做单元测试。
|
|
12
|
+
*/
|
|
13
|
+
export declare function createCleanDatabaseScheduler(cleanHooks: CleanDatabaseHook[], importMetaUrl: string): (this: {
|
|
14
|
+
__databaseId: string | null;
|
|
15
|
+
}) => Promise<string>;
|
|
1
16
|
export type AstraOptionsInit = {
|
|
2
17
|
stargate: {
|
|
3
18
|
$types: any;
|
|
@@ -6,7 +21,7 @@ export type AstraOptionsInit = {
|
|
|
6
21
|
__cookbook: any;
|
|
7
22
|
__astraEmitEvent: any;
|
|
8
23
|
};
|
|
9
|
-
bootstrap: () => Promise<Record<string, any>>;
|
|
24
|
+
bootstrap: (hooks: AstraHooks) => Promise<Record<string, any>>;
|
|
10
25
|
};
|
|
11
26
|
type Mixin<T, U> = U & Omit<T, keyof U>;
|
|
12
27
|
type ExecuteOptions = {
|
|
@@ -54,6 +69,9 @@ export declare function createAstra<AstraOptions extends AstraOptionsInit, Gener
|
|
|
54
69
|
headers?: Record<string, string>;
|
|
55
70
|
timeout?: number;
|
|
56
71
|
}) => Promise<[Partial<Generated["rejectCode"]>, null, ExecuteResultsOption] | [null, Generated["events"][Key], ExecuteResultsOption]>;
|
|
72
|
+
__databaseId: string | null;
|
|
73
|
+
cleanDatabase: () => Promise<string>;
|
|
74
|
+
onCleanDatabase: (hook: CleanDatabaseHook) => void;
|
|
57
75
|
}>]>;
|
|
58
76
|
}>;
|
|
59
77
|
export declare function fetchWithTimeout(url: string, options?: RequestInit & {
|