@milkio/stargate-worker 1.3.3 → 1.3.5
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/package.json +1 -1
- package/index.d.ts +0 -66
- package/utils/create-id.d.ts +0 -1
package/package.json
CHANGED
package/index.d.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
export type MilkioStargateOptions = {
|
|
2
|
-
port: {
|
|
3
|
-
postMessage: (data: any) => void;
|
|
4
|
-
addEventListener: (event: "message", callback: (event: {
|
|
5
|
-
data: any;
|
|
6
|
-
}) => void) => void;
|
|
7
|
-
removeEventListener: (event: "message", callback: (event: {
|
|
8
|
-
data: any;
|
|
9
|
-
}) => void) => void;
|
|
10
|
-
};
|
|
11
|
-
cacheStorage?: CacheStorage;
|
|
12
|
-
cacheEncryption?: boolean;
|
|
13
|
-
onLog?: (level: string, args: any[]) => void;
|
|
14
|
-
};
|
|
15
|
-
export type Mixin<T, U> = U & Omit<T, keyof U>;
|
|
16
|
-
export type CacheStrategy = 'off' | 'fallback' | 'throttle';
|
|
17
|
-
export type RetryStrategy = boolean | number;
|
|
18
|
-
export interface CacheStorage {
|
|
19
|
-
get: (key: string) => Promise<{
|
|
20
|
-
data: any;
|
|
21
|
-
timestamp: number;
|
|
22
|
-
} | null>;
|
|
23
|
-
set: (key: string, data: any) => Promise<void>;
|
|
24
|
-
}
|
|
25
|
-
export type ExecuteOptions<T extends any = any> = {
|
|
26
|
-
params?: Record<any, any>;
|
|
27
|
-
headers?: Record<string, string>;
|
|
28
|
-
cacheStrategy?: CacheStrategy;
|
|
29
|
-
cacheThrottleMs?: number;
|
|
30
|
-
onCacheHit?: (result: T) => void | Promise<void>;
|
|
31
|
-
retryStrategy?: RetryStrategy;
|
|
32
|
-
};
|
|
33
|
-
export type ExecuteResultsOption = {
|
|
34
|
-
executeId: string;
|
|
35
|
-
};
|
|
36
|
-
export type GeneratorGeneric<T> = T extends AsyncGenerator<infer I> ? I : never;
|
|
37
|
-
export declare function createStargateWorker<Generated extends {
|
|
38
|
-
routeSchema: any;
|
|
39
|
-
rejectCode: any;
|
|
40
|
-
}>(stargateOptions: MilkioStargateOptions): Promise<{
|
|
41
|
-
close(): void;
|
|
42
|
-
execute<Path extends keyof Generated["routeSchema"]>(path: Path, options: Mixin<ExecuteOptions<Generated["routeSchema"][Path]["types"]["result"]>, {
|
|
43
|
-
params?: Generated["routeSchema"][Path]["types"]["params"];
|
|
44
|
-
}>): Promise<Generated["routeSchema"][Path]["types"]["\uD83E\uDD5B"] extends boolean ? // action
|
|
45
|
-
[Partial<Generated["rejectCode"]>, null, ExecuteResultsOption] | [null, Generated["routeSchema"][Path]["types"]["result"], ExecuteResultsOption] : // stream
|
|
46
|
-
[Partial<Generated["rejectCode"]>, null, ExecuteResultsOption] | [null, AsyncGenerator<[Partial<Generated["rejectCode"]>, null] | [null, GeneratorGeneric<Generated["routeSchema"][Path]["types"]["result"]>], undefined>, ExecuteResultsOption]>;
|
|
47
|
-
$types: {
|
|
48
|
-
generated: Generated;
|
|
49
|
-
error: Generated["rejectCode"];
|
|
50
|
-
params: { [Path in keyof Generated["routeSchema"]]: Generated["routeSchema"][Path]["types"]["params"]; };
|
|
51
|
-
results: { [Path in keyof Generated["routeSchema"]]: Generated["routeSchema"][Path]["types"]["\uD83E\uDD5B"] extends boolean ? Generated["routeSchema"][Path]["types"]["result"] : AsyncGenerator<[Partial<Generated["rejectCode"]>, null] | [null, GeneratorGeneric<Generated["routeSchema"][Path]["types"]["result"]>], undefined>; };
|
|
52
|
-
};
|
|
53
|
-
}>;
|
|
54
|
-
export type MilkioFlow<T, TReturn = any, TNext = any> = {
|
|
55
|
-
emit: (flow: T) => void;
|
|
56
|
-
[Symbol.asyncIterator]: () => MilkioFlow<T>;
|
|
57
|
-
next(...[value]: [] | [TNext]): Promise<IteratorResult<T, TReturn>>;
|
|
58
|
-
return(data: undefined, disablePostCloseMessage?: true): Promise<IteratorResult<T, TReturn>>;
|
|
59
|
-
throw(error: any, disablePostCloseMessage?: true): Promise<IteratorResult<T, TReturn>>;
|
|
60
|
-
};
|
|
61
|
-
export declare function createFlow<T>(stargateOptions: MilkioStargateOptions, executeId: string): MilkioFlow<T>;
|
|
62
|
-
export declare function reviveJSONParse<T>(json: T): T;
|
|
63
|
-
export declare function createDefaultCacheStorage(options?: {
|
|
64
|
-
encryption?: boolean;
|
|
65
|
-
encryptionKey?: string;
|
|
66
|
-
}): Promise<CacheStorage>;
|
package/utils/create-id.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const __createId: () => string;
|