@akanjs/signal 0.0.39 → 0.0.41
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 +1 -0
- package/package.json +1 -1
- package/src/baseFetch.d.ts +6 -0
- package/src/client.d.ts +54 -0
- package/src/doc.d.ts +9 -0
- package/src/gql.d.ts +226 -0
- package/src/immerify.d.ts +2 -0
- package/src/index.d.ts +6 -0
- package/src/signalDecorators.d.ts +295 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src";
|
package/package.json
CHANGED
package/src/client.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type Client as GqlClient } from "@urql/core";
|
|
2
|
+
import type * as dgram from "dgram";
|
|
3
|
+
import { type Socket } from "socket.io-client";
|
|
4
|
+
interface SubscribeOption {
|
|
5
|
+
key: string;
|
|
6
|
+
roomId: string;
|
|
7
|
+
message: {
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
declare class SocketIo {
|
|
12
|
+
socket: Socket;
|
|
13
|
+
roomSubscribeMap: Map<string, SubscribeOption>;
|
|
14
|
+
constructor(uri: string);
|
|
15
|
+
on(event: string, callback: (data: any) => void): void;
|
|
16
|
+
removeListener(event: string, callback?: (data: any) => void): void;
|
|
17
|
+
removeAllListeners(): void;
|
|
18
|
+
hasListeners(event: string): boolean;
|
|
19
|
+
emit(key: string, data: any): void;
|
|
20
|
+
subscribe(option: {
|
|
21
|
+
key: string;
|
|
22
|
+
roomId: string;
|
|
23
|
+
message: {
|
|
24
|
+
[key: string]: any;
|
|
25
|
+
};
|
|
26
|
+
handleEvent: (data: any) => void;
|
|
27
|
+
}): void;
|
|
28
|
+
unsubscribe(roomId: string, handleEvent: (data: any) => void): void;
|
|
29
|
+
disconnect(): this;
|
|
30
|
+
}
|
|
31
|
+
declare class Client {
|
|
32
|
+
static globalIoMap: Map<string, SocketIo>;
|
|
33
|
+
static tokenStore: Map<Client, string>;
|
|
34
|
+
waitUntilWebSocketConnected(ws?: string): Promise<true | undefined>;
|
|
35
|
+
isInitialized: boolean;
|
|
36
|
+
uri: string;
|
|
37
|
+
ws: string;
|
|
38
|
+
udp: dgram.Socket | null;
|
|
39
|
+
gql: GqlClient;
|
|
40
|
+
jwt: string | undefined | null;
|
|
41
|
+
getJwt(): Promise<string | null>;
|
|
42
|
+
io: SocketIo | null;
|
|
43
|
+
init(data?: Partial<Client>): void;
|
|
44
|
+
setIo(ws?: string): void;
|
|
45
|
+
getIo(ws?: string): SocketIo;
|
|
46
|
+
setLink(uri?: string): void;
|
|
47
|
+
setJwt(jwt: string): void;
|
|
48
|
+
reset(): void;
|
|
49
|
+
clone(data?: Partial<Client>): Client;
|
|
50
|
+
terminate(): void;
|
|
51
|
+
setUdp(udp: dgram.Socket): void;
|
|
52
|
+
}
|
|
53
|
+
export declare const client: Client;
|
|
54
|
+
export type { Client, SocketIo };
|
package/src/doc.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Type } from "@akanjs/base";
|
|
2
|
+
import { ArgMeta, SignalType } from "./signalDecorators";
|
|
3
|
+
export declare const makeRequestExample: (sigRef: Type, key: string) => {
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
};
|
|
6
|
+
export declare const getExampleData: (argMetas: ArgMeta[], signalType?: SignalType) => {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
};
|
|
9
|
+
export declare const makeResponseExample: (sigRef: Type, key: string) => string | number | boolean | object | null;
|
package/src/gql.d.ts
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { DataList, Dayjs, Type, Upload } from "@akanjs/base";
|
|
2
|
+
import { FetchPolicy } from "@akanjs/common";
|
|
3
|
+
import { ConstantModel, DocumentModel, FilterType, ProtoFile, QueryOf, SortOf } from "@akanjs/constant";
|
|
4
|
+
import { type Client } from ".";
|
|
5
|
+
import { type ArgMeta, type DefaultSignal, type GqlMeta, type SliceMeta } from "./signalDecorators";
|
|
6
|
+
export declare class GqlStorage {
|
|
7
|
+
}
|
|
8
|
+
export declare class FragmentStorage {
|
|
9
|
+
}
|
|
10
|
+
export declare class PurifyStorage {
|
|
11
|
+
}
|
|
12
|
+
export declare class DefaultStorage {
|
|
13
|
+
}
|
|
14
|
+
export declare class CrystalizeStorage {
|
|
15
|
+
}
|
|
16
|
+
export type PurifyFunc<I, M> = (self: DefaultOf<Pick<M, keyof I extends keyof M ? keyof I : never>>, isChild?: boolean) => DocumentModel<I> | null;
|
|
17
|
+
export type CrystalizeFunc<M> = (self: {
|
|
18
|
+
[K in keyof M as M[K] extends (...args: any) => any ? never : K]: M[K];
|
|
19
|
+
}, isChild?: boolean) => M;
|
|
20
|
+
export type FieldState<T> = T extends string ? T : T extends number ? T : T extends boolean ? T : T extends Dayjs ? T : T extends any[] ? T : T extends {
|
|
21
|
+
id: string;
|
|
22
|
+
} ? T | null : T;
|
|
23
|
+
export type DefaultOf<S> = S extends infer T ? {
|
|
24
|
+
[K in keyof T]: FieldState<T[K]>;
|
|
25
|
+
} : never;
|
|
26
|
+
export interface FetchInitForm<Input, Full, Filter extends FilterType> {
|
|
27
|
+
page?: number;
|
|
28
|
+
limit?: number;
|
|
29
|
+
sort?: SortOf<Filter> | symbol;
|
|
30
|
+
default?: Partial<DefaultOf<Input>>;
|
|
31
|
+
invalidate?: boolean;
|
|
32
|
+
insight?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export type ServerInit<T extends string, Light, Insight = any, QueryArgs = any[], Filter extends FilterType = any> = SliceMeta & {
|
|
35
|
+
[K in `${Uncapitalize<T>}ObjList`]: Light[];
|
|
36
|
+
} & {
|
|
37
|
+
[K in `${Uncapitalize<T>}ObjInsight`]: Insight;
|
|
38
|
+
} & {
|
|
39
|
+
[K in `pageOf${Capitalize<T>}`]: number;
|
|
40
|
+
} & {
|
|
41
|
+
[K in `lastPageOf${Capitalize<T>}`]: number;
|
|
42
|
+
} & {
|
|
43
|
+
[K in `limitOf${Capitalize<T>}`]: number;
|
|
44
|
+
} & {
|
|
45
|
+
[K in `queryArgsOf${Capitalize<T>}`]: QueryArgs;
|
|
46
|
+
} & {
|
|
47
|
+
[K in `sortOf${Capitalize<T>}`]: SortOf<Filter>;
|
|
48
|
+
} & {
|
|
49
|
+
[K in `${Uncapitalize<T>}InitAt`]: Date;
|
|
50
|
+
};
|
|
51
|
+
export type ClientInit<T extends string, Light, Insight = any, QueryArgs = any[], Filter extends FilterType = any> = Promise<ServerInit<T, Light, Insight, QueryArgs, Filter>> | ServerInit<T, Light, Insight, QueryArgs, Filter>;
|
|
52
|
+
export type ServerView<T extends string, M> = {
|
|
53
|
+
refName: T;
|
|
54
|
+
} & {
|
|
55
|
+
[K in `${Uncapitalize<T>}Obj`]: M;
|
|
56
|
+
} & {
|
|
57
|
+
[K in `${Uncapitalize<T>}ViewAt`]: Date;
|
|
58
|
+
};
|
|
59
|
+
export type ClientView<T extends string, M> = Promise<ServerView<T, M>> | ServerView<T, M>;
|
|
60
|
+
export type ServerEdit<T extends string, M> = {
|
|
61
|
+
refName: T;
|
|
62
|
+
} & {
|
|
63
|
+
[K in `${Uncapitalize<T>}Obj`]: M;
|
|
64
|
+
} & {
|
|
65
|
+
[K in `${Uncapitalize<T>}ViewAt`]: Date;
|
|
66
|
+
};
|
|
67
|
+
export type ClientEdit<T extends string, M> = Promise<ServerEdit<T, M>> | ServerEdit<T, M>;
|
|
68
|
+
export type GqlScalarUtil<T extends string, M, I = M> = {
|
|
69
|
+
[K in `default${Capitalize<T>}`]: DefaultOf<M>;
|
|
70
|
+
} & {
|
|
71
|
+
[K in `purify${Capitalize<T>}`]: PurifyFunc<DocumentModel<I>, M>;
|
|
72
|
+
} & {
|
|
73
|
+
[K in `crystalize${Capitalize<T>}`]: CrystalizeFunc<M>;
|
|
74
|
+
};
|
|
75
|
+
type FilterSkipLimitSort<Args, Filter> = Args extends [
|
|
76
|
+
...args: infer QueryArgs,
|
|
77
|
+
skip: number | null,
|
|
78
|
+
limit: number | null,
|
|
79
|
+
sort: string | null
|
|
80
|
+
] ? QueryArgs : never;
|
|
81
|
+
export type FilterListArgs<Args, Filter> = FilterOutInternalArgs<FilterSkipLimitSort<FilterOutInternalArgs<Args>, Filter>>;
|
|
82
|
+
export type FilterStateArgs<Args, Filter> = FilterSkipLimitSort<FilterOutInternalArgs<Args>, Filter>;
|
|
83
|
+
export type DbGraphQL<T extends string, Input, Full, Light extends {
|
|
84
|
+
id: string;
|
|
85
|
+
}, Insight, Filter extends FilterType, Fetch, Signal> = {
|
|
86
|
+
refName: string;
|
|
87
|
+
slices: SliceMeta[];
|
|
88
|
+
} & GetWsMessageOf<Signal> & GetWsPubsubOf<Signal> & GqlScalarUtil<T, Full> & {
|
|
89
|
+
[K in `lightCrystalize${Capitalize<T>}`]: CrystalizeFunc<Light>;
|
|
90
|
+
} & {
|
|
91
|
+
[K in `default${Capitalize<T>}Insight`]: Insight;
|
|
92
|
+
} & {
|
|
93
|
+
[K in `add${Capitalize<T>}Files`]: (fileList: FileList, parentId?: string, option?: FetchPolicy) => Promise<ProtoFile[]>;
|
|
94
|
+
} & {
|
|
95
|
+
[K in `merge${Capitalize<T>}`]: (modelOrId: Full | string, data: Partial<DocumentModel<Input>>, option?: FetchPolicy) => Promise<Full>;
|
|
96
|
+
} & {
|
|
97
|
+
[K in `view${Capitalize<T>}`]: (id: string, option?: FetchPolicy) => Promise<{
|
|
98
|
+
[K in Uncapitalize<T>]: Full;
|
|
99
|
+
} & {
|
|
100
|
+
[K in `${Uncapitalize<T>}View`]: ServerView<T, Full>;
|
|
101
|
+
}>;
|
|
102
|
+
} & {
|
|
103
|
+
[K in `get${Capitalize<T>}View`]: (id: string, option?: FetchPolicy) => ClientView<T, Full>;
|
|
104
|
+
} & {
|
|
105
|
+
[K in `edit${Capitalize<T>}`]: (id: string, option?: FetchPolicy) => Promise<{
|
|
106
|
+
[K in Uncapitalize<T>]: Full;
|
|
107
|
+
} & {
|
|
108
|
+
[K in `${Uncapitalize<T>}Edit`]: ServerEdit<T, Full>;
|
|
109
|
+
}>;
|
|
110
|
+
} & {
|
|
111
|
+
[K in `get${Capitalize<T>}Edit`]: (id: string, option?: FetchPolicy) => ClientEdit<T, Full>;
|
|
112
|
+
} & Fetch & {
|
|
113
|
+
[K in `init${Capitalize<T>}`]: (query?: QueryOf<DocumentModel<Full>>, option?: FetchPolicy & FetchInitForm<Input, Full, Filter>) => Promise<{
|
|
114
|
+
[K in `${Uncapitalize<T>}Init`]: ServerInit<T, Light, Insight, [query?: QueryOf<DocumentModel<Full>>], Filter>;
|
|
115
|
+
} & {
|
|
116
|
+
[K in `${Uncapitalize<T>}List`]: DataList<Light>;
|
|
117
|
+
} & {
|
|
118
|
+
[K in `${Uncapitalize<T>}Insight`]: Insight;
|
|
119
|
+
}>;
|
|
120
|
+
} & {
|
|
121
|
+
[K in `get${Capitalize<T>}Init`]: (query?: QueryOf<DocumentModel<Full>>, option?: FetchPolicy & FetchInitForm<Input, Full, Filter>) => ClientInit<T, Light, Insight, [query?: QueryOf<DocumentModel<Full>>], Filter>;
|
|
122
|
+
} & {
|
|
123
|
+
[K in keyof Signal as K extends `${T}List${infer Suffix}` ? `init${Capitalize<T>}${Suffix}` : never]: K extends `${T}List${infer Suffix}` ? Signal[K] extends (...args: infer Args) => Promise<Full[]> ? (...args: [
|
|
124
|
+
...queryArgs: FilterListArgs<Args, Filter>,
|
|
125
|
+
option?: FetchPolicy & FetchInitForm<Input, Full, Filter>
|
|
126
|
+
]) => Promise<{
|
|
127
|
+
[K in `${Uncapitalize<T>}Init${Suffix}`]: ServerInit<T, Light, Insight, FilterListArgs<Args, Filter>, Filter>;
|
|
128
|
+
} & {
|
|
129
|
+
[K in `${Uncapitalize<T>}List${Suffix}`]: DataList<Light>;
|
|
130
|
+
} & {
|
|
131
|
+
[K in `${Uncapitalize<T>}Insight${Suffix}`]: Insight;
|
|
132
|
+
}> : never : never;
|
|
133
|
+
} & {
|
|
134
|
+
[K in keyof Signal as K extends `${T}List${infer Suffix}` ? `get${Capitalize<T>}Init${Suffix}` : never]: K extends `${T}List${infer Suffix}` ? Signal[K] extends (...args: infer Args) => Promise<Full[]> ? (...args: [
|
|
135
|
+
...queryArgs: FilterListArgs<Args, Filter>,
|
|
136
|
+
option?: FetchPolicy & FetchInitForm<Input, Full, Filter>
|
|
137
|
+
]) => ClientInit<T, Light, Insight, FilterListArgs<Args, Filter>, Filter> : never : never;
|
|
138
|
+
};
|
|
139
|
+
type ConvertArg<T> = T extends Upload[] ? FileList : T;
|
|
140
|
+
type IsInternalArgs<T> = T extends {
|
|
141
|
+
__InternalArg__: any;
|
|
142
|
+
} ? true : T extends {
|
|
143
|
+
__InternalArg__: any;
|
|
144
|
+
} | null ? true : false;
|
|
145
|
+
export type FilterOutInternalArgs<T> = T extends [arg: infer Head, ...args: infer Rest] ? IsInternalArgs<Head> extends true ? FilterOutInternalArgs<Rest> : Head extends undefined ? [arg?: ConvertArg<Head> | undefined, ...args: FilterOutInternalArgs<Rest>] : Head extends null ? [arg?: ConvertArg<Head> | undefined, ...args: FilterOutInternalArgs<Rest>] : [
|
|
146
|
+
arg: ConvertArg<Head>,
|
|
147
|
+
...args: FilterOutInternalArgs<Rest>
|
|
148
|
+
] : [];
|
|
149
|
+
type FunctionToTuple<F extends (...args: any) => any> = F extends (...args: infer A) => any ? A : never;
|
|
150
|
+
type TupleToFunction<T extends any[], R> = (...args: [...args: T, option?: FetchPolicy]) => R;
|
|
151
|
+
export type RemoveInternalArgs<F extends (...args: any) => any, Returns = ReturnType<F>> = TupleToFunction<FilterOutInternalArgs<FunctionToTuple<F>>, Returns>;
|
|
152
|
+
type ApplyPromise<T> = T extends (...args: infer Args) => infer Return ? Return extends Promise<any> ? T : (...args: Args) => Promise<Return> : never;
|
|
153
|
+
type ApplyVoidReturn<T> = T extends (...args: infer Args) => any ? (...args: Args) => void : never;
|
|
154
|
+
export type GetQueryMutationOf<Sig, M = unknown> = {
|
|
155
|
+
[K in keyof Sig as K extends keyof M ? never : Sig[K] extends (...args: any) => Promise<{
|
|
156
|
+
__Returns__: string;
|
|
157
|
+
}> ? never : K]: Sig[K] extends (...args: any) => any ? ApplyPromise<RemoveInternalArgs<Sig[K]>> : never;
|
|
158
|
+
};
|
|
159
|
+
export type GetWsMessageOf<Sig> = {
|
|
160
|
+
[K in keyof Sig as Sig[K] extends (...args: any) => Promise<{
|
|
161
|
+
__Returns__: "Emit";
|
|
162
|
+
}> ? K : Sig[K] extends (...args: any) => {
|
|
163
|
+
__Returns__: "Emit";
|
|
164
|
+
} ? K : never]: Sig[K] extends (...args: any) => any ? ApplyVoidReturn<RemoveInternalArgs<Sig[K], void>> : never;
|
|
165
|
+
} & {
|
|
166
|
+
[K in keyof Sig as K extends string ? Sig[K] extends (...args: any) => Promise<{
|
|
167
|
+
__Returns__: "Emit";
|
|
168
|
+
}> | {
|
|
169
|
+
__Returns__: "Emit";
|
|
170
|
+
} ? `listen${Capitalize<K>}` : never : never]: Sig[K] extends (...args: any) => any ? (handleEvent: (data: Awaited<ReturnType<Sig[K]>>) => any, options?: FetchPolicy) => () => void : never;
|
|
171
|
+
};
|
|
172
|
+
export type GetWsPubsubOf<Sig> = {
|
|
173
|
+
[K in keyof Sig as K extends string ? Sig[K] extends (...args: any) => Promise<{
|
|
174
|
+
__Returns__: "Subscribe";
|
|
175
|
+
}> ? `subscribe${Capitalize<K>}` : Sig[K] extends (...args: any) => {
|
|
176
|
+
__Returns__: "Subscribe";
|
|
177
|
+
} ? `subscribe${Capitalize<K>}` : never : never]: Sig[K] extends (...args: infer Args) => Promise<{
|
|
178
|
+
__Returns__: "Subscribe";
|
|
179
|
+
} & infer Return> ? (...args: [...args: FilterOutInternalArgs<Args>, onData: (data: Return) => void, fetchPolicy?: FetchPolicy]) => () => void : Sig[K] extends (...args: infer Args) => {
|
|
180
|
+
__Returns__: "Subscribe";
|
|
181
|
+
} & infer Return ? (...args: [...args: FilterOutInternalArgs<Args>, onData: (data: Return) => void, fetchPolicy?: FetchPolicy]) => () => void : never;
|
|
182
|
+
};
|
|
183
|
+
export declare const scalarUtilOf: <T extends string, M>(name: T, target: Type<M>) => GqlScalarUtil<T, M>;
|
|
184
|
+
type LightWeightFetch<Fetch, Full, Light> = {
|
|
185
|
+
[K in keyof Fetch]: Fetch[K] extends (...args: infer Args) => Promise<Full[]> ? (...args: Args) => Promise<Light[]> : Fetch[K];
|
|
186
|
+
};
|
|
187
|
+
export declare const getGqlOnStorage: (refName: string) => {
|
|
188
|
+
[key: string]: any;
|
|
189
|
+
};
|
|
190
|
+
export declare const gqlOf: <T extends string, Input, Full extends {
|
|
191
|
+
id: string;
|
|
192
|
+
}, Light extends {
|
|
193
|
+
id: string;
|
|
194
|
+
}, Insight, Summary, Filter extends FilterType, Signal>(constant: ConstantModel<T, Input, Full, Light, Insight, Filter, Summary>, sigRef: Type<Signal>, option?: {
|
|
195
|
+
overwrite?: {
|
|
196
|
+
[key: string]: any;
|
|
197
|
+
};
|
|
198
|
+
}) => DbGraphQL<T, Input, Full, Light, Insight, Filter, LightWeightFetch<GetQueryMutationOf<Signal & DefaultSignal<T, Input, Full, Light, Insight, Filter>, Full>, Full, Light>, Signal>;
|
|
199
|
+
export declare const makeDefault: <T>(target: Type<T>, option?: {
|
|
200
|
+
isChild?: boolean;
|
|
201
|
+
overwrite?: any;
|
|
202
|
+
}) => DefaultOf<T>;
|
|
203
|
+
export declare const makePurify: <I, M = I>(target: Type<I>, option?: {
|
|
204
|
+
overwrite?: any;
|
|
205
|
+
}) => PurifyFunc<I, M>;
|
|
206
|
+
export declare const makeCrystalize: <M>(target: Type<M>, option?: {
|
|
207
|
+
overwrite?: any;
|
|
208
|
+
partial?: string[];
|
|
209
|
+
}) => CrystalizeFunc<M>;
|
|
210
|
+
export declare const makeFragment: (target: Type, option?: {
|
|
211
|
+
overwrite?: any;
|
|
212
|
+
excludeSelf?: boolean;
|
|
213
|
+
partial?: string[];
|
|
214
|
+
}) => string;
|
|
215
|
+
export declare const getGqlStr: (modelRef: Type, gqlMeta: GqlMeta, argMetas: ArgMeta[], returnRef: Type, partial?: string[]) => string;
|
|
216
|
+
export declare const serializeArg: (argMeta: ArgMeta, value: any) => object[] | null;
|
|
217
|
+
export declare const deserializeArg: (argMeta: ArgMeta, value: any) => object[] | null;
|
|
218
|
+
export declare const fetchOf: <Signal>(sigRef: Type<Signal>) => GetWsMessageOf<Signal> & GetWsPubsubOf<Signal> & GetQueryMutationOf<Signal>;
|
|
219
|
+
type CustomFetch<T> = Omit<T, "client" | "clone"> & {
|
|
220
|
+
client: Client;
|
|
221
|
+
clone: (option?: {
|
|
222
|
+
jwt: string | null;
|
|
223
|
+
}) => CustomFetch<T>;
|
|
224
|
+
};
|
|
225
|
+
export declare const makeFetch: <F1 extends object, F2 extends object, F3 extends object, F4 extends object, F5 extends object, F6 extends object, F7 extends object, F8 extends object, F9 extends object, F10 extends object>(fetch1: F1, fetch2?: Partial<F2>, fetch3?: Partial<F3>, fetch4?: Partial<F4>, fetch5?: Partial<F5>, fetch6?: Partial<F6>, fetch7?: Partial<F7>, fetch8?: Partial<F8>, fetch9?: Partial<F9>, fetch10?: Partial<F10>) => CustomFetch<F10 & F9 & F8 & F7 & F6 & F5 & F4 & F3 & F2 & F1>;
|
|
226
|
+
export {};
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
import { BaseObject, Dayjs, Enum, Environment, SingleFieldType, Type } from "@akanjs/base";
|
|
3
|
+
import { ConstantModel, DocumentModel, FilterType, GetActionObject, ReturnType, SortOf } from "@akanjs/constant";
|
|
4
|
+
import type { Job as BullJob } from "bull";
|
|
5
|
+
import type { Request as ExpressRequest, Response as ExpressResponse } from "express";
|
|
6
|
+
import type { Socket } from "socket.io";
|
|
7
|
+
export declare const ssoTypes: readonly ["github", "google", "facebook", "apple", "naver", "kakao"];
|
|
8
|
+
export type SSOType = (typeof ssoTypes)[number];
|
|
9
|
+
export declare class SignalStorage {
|
|
10
|
+
}
|
|
11
|
+
export declare const getAllSignalRefs: () => Type[];
|
|
12
|
+
export declare const getSignalRefsOnStorage: (refName: string) => Type[];
|
|
13
|
+
export type Resolve<T> = T;
|
|
14
|
+
export declare const resolve: <T>(data: any) => Resolve<T>;
|
|
15
|
+
export declare const emit: <T>(data: any) => Resolve<T> & {
|
|
16
|
+
__Returns__: "Emit";
|
|
17
|
+
};
|
|
18
|
+
export declare const done: <T>(data: any) => Resolve<T> & {
|
|
19
|
+
__Returns__: "Done";
|
|
20
|
+
};
|
|
21
|
+
export declare const subscribe: <T>() => Resolve<T> & {
|
|
22
|
+
__Returns__: "Subscribe";
|
|
23
|
+
};
|
|
24
|
+
export interface SignalOption<Response = any> {
|
|
25
|
+
nullable?: boolean;
|
|
26
|
+
name?: string;
|
|
27
|
+
default?: boolean;
|
|
28
|
+
path?: string;
|
|
29
|
+
onlyFor?: "graphql" | "restapi";
|
|
30
|
+
sso?: SSOType;
|
|
31
|
+
serverType?: "federation" | "batch" | "all";
|
|
32
|
+
timeout?: number;
|
|
33
|
+
partial?: (keyof Response)[] | readonly (keyof Response)[];
|
|
34
|
+
cache?: number;
|
|
35
|
+
}
|
|
36
|
+
export interface ResolveFieldMeta {
|
|
37
|
+
returns: ReturnType;
|
|
38
|
+
argsOption: ArgsOption;
|
|
39
|
+
key: string;
|
|
40
|
+
descriptor: PropertyDescriptor;
|
|
41
|
+
}
|
|
42
|
+
export declare const signalTypes: readonly ["graphql", "restapi"];
|
|
43
|
+
export type SignalType = (typeof signalTypes)[number];
|
|
44
|
+
export declare const endpointTypes: readonly ["Query", "Mutation", "Message", "Pubsub", "Process"];
|
|
45
|
+
export type EndpointType = (typeof endpointTypes)[number];
|
|
46
|
+
export declare const guardTypes: readonly ["Public", "None", "User", "Admin", "SuperAdmin", "Every", "Owner"];
|
|
47
|
+
export type GuardType = (typeof guardTypes)[number];
|
|
48
|
+
export declare const roleTypes: readonly ["Public", "User", "Admin", "SuperAdmin"];
|
|
49
|
+
export type RoleType = (typeof roleTypes)[number];
|
|
50
|
+
export declare const argTypes: readonly ["Body", "Param", "Query", "Upload", "Msg", "Room"];
|
|
51
|
+
export type ArgType = (typeof argTypes)[number];
|
|
52
|
+
export declare const internalArgTypes: readonly ["Account", "Me", "Self", "UserIp", "Access", "Parent", "Req", "Res", "Ws", "Job"];
|
|
53
|
+
export type InternalArgType = (typeof internalArgTypes)[number];
|
|
54
|
+
export interface GqlMeta {
|
|
55
|
+
returns: (of?: any) => Type;
|
|
56
|
+
signalOption: SignalOption;
|
|
57
|
+
key: string;
|
|
58
|
+
descriptor: PropertyDescriptor;
|
|
59
|
+
guards: GuardType[];
|
|
60
|
+
type: EndpointType;
|
|
61
|
+
}
|
|
62
|
+
export interface ArgsOption {
|
|
63
|
+
nullable?: boolean;
|
|
64
|
+
example?: string | number | boolean | Dayjs;
|
|
65
|
+
enum?: Enum<string | number>;
|
|
66
|
+
}
|
|
67
|
+
export interface ArgMeta {
|
|
68
|
+
name: string;
|
|
69
|
+
returns: ReturnType;
|
|
70
|
+
argsOption: ArgsOption;
|
|
71
|
+
key: string;
|
|
72
|
+
idx: number;
|
|
73
|
+
type: ArgType;
|
|
74
|
+
}
|
|
75
|
+
export interface InternalArgMeta {
|
|
76
|
+
key: string;
|
|
77
|
+
idx: number;
|
|
78
|
+
type: InternalArgType;
|
|
79
|
+
option?: {
|
|
80
|
+
nullable?: boolean;
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
export interface SliceMeta {
|
|
84
|
+
refName: string;
|
|
85
|
+
sliceName: string;
|
|
86
|
+
argLength: number;
|
|
87
|
+
defaultArgs: any[];
|
|
88
|
+
}
|
|
89
|
+
export interface SignalMeta {
|
|
90
|
+
refName: string;
|
|
91
|
+
slices: SliceMeta[];
|
|
92
|
+
returns?: (of?: any) => Type;
|
|
93
|
+
prefix?: string;
|
|
94
|
+
}
|
|
95
|
+
interface SignalDecoratorInput {
|
|
96
|
+
name: string;
|
|
97
|
+
prefix?: string;
|
|
98
|
+
}
|
|
99
|
+
export declare function Signal(returnsOrObj: (() => Type) | SignalDecoratorInput): (target: Type) => void;
|
|
100
|
+
export declare const createArgMetaDecorator: (type: InternalArgType) => (option?: {
|
|
101
|
+
nullable?: boolean;
|
|
102
|
+
}) => (prototype: object, key: string, idx: number) => void;
|
|
103
|
+
export declare const Account: (option?: {
|
|
104
|
+
nullable?: boolean;
|
|
105
|
+
}) => (prototype: object, key: string, idx: number) => void;
|
|
106
|
+
export type Account<AddData = unknown> = {
|
|
107
|
+
__InternalArg__: "Account";
|
|
108
|
+
self?: Self;
|
|
109
|
+
me?: Me;
|
|
110
|
+
appName: string;
|
|
111
|
+
environment: Environment;
|
|
112
|
+
} & AddData;
|
|
113
|
+
export declare const defaultAccount: Account;
|
|
114
|
+
export declare const Self: (option?: {
|
|
115
|
+
nullable?: boolean;
|
|
116
|
+
}) => (prototype: object, key: string, idx: number) => void;
|
|
117
|
+
export interface Self {
|
|
118
|
+
__InternalArg__: "Self";
|
|
119
|
+
id: string;
|
|
120
|
+
nickname: string;
|
|
121
|
+
roles: string[];
|
|
122
|
+
image: {
|
|
123
|
+
url: string;
|
|
124
|
+
imageSize: [number, number];
|
|
125
|
+
} | null;
|
|
126
|
+
profileStatus: "active" | "prepare" | "applied" | "approved" | "reapplied" | "featured" | "reserved" | "rejected";
|
|
127
|
+
status: "prepare" | "active" | "restricted" | "dormant";
|
|
128
|
+
removedAt: Dayjs | null;
|
|
129
|
+
}
|
|
130
|
+
export declare const Me: (option?: {
|
|
131
|
+
nullable?: boolean;
|
|
132
|
+
}) => (prototype: object, key: string, idx: number) => void;
|
|
133
|
+
export interface Me {
|
|
134
|
+
__InternalArg__: "Me";
|
|
135
|
+
id: string;
|
|
136
|
+
accountId: string;
|
|
137
|
+
roles: string[];
|
|
138
|
+
status: "active";
|
|
139
|
+
removedAt: Dayjs | null;
|
|
140
|
+
}
|
|
141
|
+
export declare const UserIp: (option?: {
|
|
142
|
+
nullable?: boolean;
|
|
143
|
+
}) => (prototype: object, key: string, idx: number) => void;
|
|
144
|
+
export interface UserIp {
|
|
145
|
+
ip: string;
|
|
146
|
+
__InternalArg__: "UserIp";
|
|
147
|
+
}
|
|
148
|
+
export declare const Access: (option?: {
|
|
149
|
+
nullable?: boolean;
|
|
150
|
+
}) => (prototype: object, key: string, idx: number) => void;
|
|
151
|
+
export interface Access {
|
|
152
|
+
__InternalArg__: "Access";
|
|
153
|
+
period: number;
|
|
154
|
+
countryCode?: string;
|
|
155
|
+
countryName?: string;
|
|
156
|
+
city?: string;
|
|
157
|
+
postal?: number;
|
|
158
|
+
location?: {
|
|
159
|
+
type: "Point";
|
|
160
|
+
coordinates: [number, number];
|
|
161
|
+
};
|
|
162
|
+
ipv4?: string;
|
|
163
|
+
state?: string;
|
|
164
|
+
userAgent?: string;
|
|
165
|
+
at: Dayjs;
|
|
166
|
+
}
|
|
167
|
+
export declare const Req: (option?: {
|
|
168
|
+
nullable?: boolean;
|
|
169
|
+
}) => (prototype: object, key: string, idx: number) => void;
|
|
170
|
+
export type Req = {
|
|
171
|
+
__InternalArg__: "Req";
|
|
172
|
+
account: Account;
|
|
173
|
+
user: any;
|
|
174
|
+
} & ExpressRequest;
|
|
175
|
+
export declare const Res: (option?: {
|
|
176
|
+
nullable?: boolean;
|
|
177
|
+
}) => (prototype: object, key: string, idx: number) => void;
|
|
178
|
+
export type Res = {
|
|
179
|
+
__InternalArg__: "Res";
|
|
180
|
+
} & ExpressResponse;
|
|
181
|
+
export declare const Ws: (option?: {
|
|
182
|
+
nullable?: boolean;
|
|
183
|
+
}) => (prototype: object, key: string, idx: number) => void;
|
|
184
|
+
export type Ws = {
|
|
185
|
+
__InternalArg__: "Ws";
|
|
186
|
+
} & {
|
|
187
|
+
socket: Socket;
|
|
188
|
+
subscribe: boolean;
|
|
189
|
+
onSubscribe: (handler: () => void | Promise<void>) => void;
|
|
190
|
+
onUnsubscribe: (handler: () => void | Promise<void>) => void;
|
|
191
|
+
onDisconnect: (handler: () => void | Promise<void>) => void;
|
|
192
|
+
};
|
|
193
|
+
export declare const Job: (option?: {
|
|
194
|
+
nullable?: boolean;
|
|
195
|
+
}) => (prototype: object, key: string, idx: number) => void;
|
|
196
|
+
export type Job = {
|
|
197
|
+
__InternalArg__: "Job";
|
|
198
|
+
} & BullJob;
|
|
199
|
+
type Guard = <Response extends SingleFieldType>(returns: ReturnType<Response>, signalOption?: SignalOption<UnType<Response>>, guards?: GuardType[]) => MethodDecorator;
|
|
200
|
+
export declare const Query: {
|
|
201
|
+
Public: Guard;
|
|
202
|
+
Every: Guard;
|
|
203
|
+
Admin: Guard;
|
|
204
|
+
User: Guard;
|
|
205
|
+
SuperAdmin: Guard;
|
|
206
|
+
None: Guard;
|
|
207
|
+
Owner: Guard;
|
|
208
|
+
};
|
|
209
|
+
export declare const Mutation: {
|
|
210
|
+
Public: Guard;
|
|
211
|
+
Every: Guard;
|
|
212
|
+
Admin: Guard;
|
|
213
|
+
User: Guard;
|
|
214
|
+
SuperAdmin: Guard;
|
|
215
|
+
None: Guard;
|
|
216
|
+
Owner: Guard;
|
|
217
|
+
};
|
|
218
|
+
export declare const Message: {
|
|
219
|
+
Public: Guard;
|
|
220
|
+
Every: Guard;
|
|
221
|
+
Admin: Guard;
|
|
222
|
+
User: Guard;
|
|
223
|
+
SuperAdmin: Guard;
|
|
224
|
+
None: Guard;
|
|
225
|
+
Owner: Guard;
|
|
226
|
+
};
|
|
227
|
+
export declare const Pubsub: {
|
|
228
|
+
Public: Guard;
|
|
229
|
+
Every: Guard;
|
|
230
|
+
Admin: Guard;
|
|
231
|
+
User: Guard;
|
|
232
|
+
SuperAdmin: Guard;
|
|
233
|
+
None: Guard;
|
|
234
|
+
Owner: Guard;
|
|
235
|
+
};
|
|
236
|
+
export declare const Process: {
|
|
237
|
+
Federation: Guard;
|
|
238
|
+
Batch: Guard;
|
|
239
|
+
All: Guard;
|
|
240
|
+
};
|
|
241
|
+
export declare function ResolveField(returns: ReturnType, argsOption?: ArgsOption): (target: any, key: string, descriptor: PropertyDescriptor) => void;
|
|
242
|
+
export declare const Arg: {
|
|
243
|
+
Body: (name: string, returns: ReturnType, argsOption?: ArgsOption) => (prototype: object, key: string, idx: number) => void;
|
|
244
|
+
Param: (name: string, returns: ReturnType, argsOption?: ArgsOption) => (prototype: object, key: string, idx: number) => void;
|
|
245
|
+
Query: (name: string, returns: ReturnType, argsOption?: ArgsOption) => (prototype: object, key: string, idx: number) => void;
|
|
246
|
+
Upload: (name: string, returns: ReturnType, argsOption?: ArgsOption) => (prototype: object, key: string, idx: number) => void;
|
|
247
|
+
Msg: (name: string, returns: ReturnType, argsOption?: ArgsOption) => (prototype: object, key: string, idx: number) => void;
|
|
248
|
+
Room: (name: string, returns: ReturnType, argsOption?: ArgsOption) => (prototype: object, key: string, idx: number) => void;
|
|
249
|
+
};
|
|
250
|
+
export declare function Parent(): (prototype: object, key: string, idx: number) => void;
|
|
251
|
+
export declare function LogSignal<Srv>(srv: Srv): Type<{ [K in keyof Srv as K extends string ? Uncapitalize<K> : never]: Srv[K]; }>;
|
|
252
|
+
type UnType<Class> = Class extends Type<infer T> ? T : never;
|
|
253
|
+
export type DefaultSignal<T extends string, Input, Full, Light, Insight, Filter extends FilterType> = DefaultSignalWithQuerySort<T, Input, Full, Light, Insight, GetActionObject<Filter>, SortOf<Filter>>;
|
|
254
|
+
type DefaultSignalWithQuerySort<T extends string, Input, Full, Light, Insight, Query, Sort> = {
|
|
255
|
+
[K in Uncapitalize<T>]: (id: string) => Promise<Full>;
|
|
256
|
+
} & {
|
|
257
|
+
[K in `light${Capitalize<T>}`]: (id: string) => Promise<Light>;
|
|
258
|
+
} & {
|
|
259
|
+
[K in `${Uncapitalize<T>}List`]: (...args: [query: Query, skip: number | null, limit: number | null, sort: Sort | null]) => Promise<Full[]>;
|
|
260
|
+
} & {
|
|
261
|
+
[K in `${Uncapitalize<T>}Insight`]: (query: Query) => Promise<Insight>;
|
|
262
|
+
} & {
|
|
263
|
+
[K in `${Uncapitalize<T>}Exists`]: (query: Query) => Promise<boolean>;
|
|
264
|
+
} & {
|
|
265
|
+
[K in `create${Capitalize<T>}`]: (data: DocumentModel<Input>, account: Account) => Promise<Full>;
|
|
266
|
+
} & {
|
|
267
|
+
[K in `update${Capitalize<T>}`]: (id: string, data: DocumentModel<Input>, account: Account) => Promise<Full>;
|
|
268
|
+
} & {
|
|
269
|
+
[K in `remove${Capitalize<T>}`]: (id: string, account: Account) => Promise<Full>;
|
|
270
|
+
};
|
|
271
|
+
export declare function DbSignal<Srv>(constant: ConstantModel<string, any, BaseObject & {
|
|
272
|
+
status: string;
|
|
273
|
+
}, BaseObject, {
|
|
274
|
+
count: number;
|
|
275
|
+
}, any>, srv: Srv, option: {
|
|
276
|
+
guards: {
|
|
277
|
+
get: Guard;
|
|
278
|
+
cru: Guard;
|
|
279
|
+
};
|
|
280
|
+
omit?: ("get" | "list" | "insight" | "exist" | "create" | "update" | "remove")[];
|
|
281
|
+
}): Type<{ [K in keyof Srv as K extends string ? Uncapitalize<K> : never]: Srv[K]; }>;
|
|
282
|
+
export declare const getSigMeta: (sigRef: Type) => SignalMeta;
|
|
283
|
+
export declare const getGqlMeta: (sigRef: Type, key: string) => GqlMeta;
|
|
284
|
+
export declare const getGqlMetaMapOnPrototype: (prototype: object) => Map<string, GqlMeta>;
|
|
285
|
+
export declare const getGqlMetas: (sigRef: Type) => GqlMeta[];
|
|
286
|
+
export declare const setGqlMetaMapOnPrototype: (prototype: object, gqlMetaMap: Map<string, GqlMeta>) => void;
|
|
287
|
+
export declare const getArgMetas: (sigRef: Type, key: string) => [ArgMeta[], InternalArgMeta[]];
|
|
288
|
+
export declare const setArgMetas: (sigRef: Type, key: string, argMetas: ArgMeta[], internalArgMetas: InternalArgMeta[]) => void;
|
|
289
|
+
export declare const getResolveFieldMetas: (sigRef: Type) => ResolveFieldMeta[];
|
|
290
|
+
export declare const getControllerPrefix: (sigMeta: SignalMeta) => string | undefined;
|
|
291
|
+
export declare const getControllerPath: (gqlMeta: GqlMeta, paramArgMetas: ArgMeta[]) => string;
|
|
292
|
+
export declare const copySignal: (sigRef: Type) => {
|
|
293
|
+
new (): {};
|
|
294
|
+
};
|
|
295
|
+
export {};
|