@akanjs/signal 0.9.56 → 0.9.57
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/cjs/src/apiInfo.js +19 -37
- package/cjs/src/base.signal.js +3 -0
- package/cjs/src/doc.js +7 -9
- package/cjs/src/internalApiInfo.js +9 -4
- package/cjs/src/signalDecorators.js +50 -299
- package/cjs/src/signalInfo.js +9 -1
- package/cjs/src/sliceInfo.js +15 -14
- package/esm/src/apiInfo.js +24 -38
- package/esm/src/base.signal.js +4 -1
- package/esm/src/doc.js +8 -10
- package/esm/src/internalApiInfo.js +10 -5
- package/esm/src/signalDecorators.js +51 -300
- package/esm/src/signalInfo.js +9 -1
- package/esm/src/sliceInfo.js +21 -15
- package/package.json +1 -1
- package/src/apiInfo.d.ts +24 -24
- package/src/base.signal.d.ts +22 -98
- package/src/doc.d.ts +5 -5
- package/src/fetch.d.ts +8 -8
- package/src/gql.d.ts +17 -32
- package/src/internalApiInfo.d.ts +26 -24
- package/src/signalDecorators.d.ts +35 -204
- package/src/signalInfo.d.ts +15 -7
- package/src/sliceInfo.d.ts +25 -33
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
|
-
import { BaseObject, Dayjs,
|
|
2
|
+
import { Assign, BaseInsight, BaseObject, Dayjs, EnumInstance, Environment, MergeAllTypes, Type, UnType } from "@akanjs/base";
|
|
3
3
|
import { ConstantModel, DocumentModel, GqlReturn, PurifiedModel, QueryOf } from "@akanjs/constant";
|
|
4
|
-
import type { Doc,
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import
|
|
8
|
-
import type
|
|
9
|
-
import { BuildSliceSignal, SliceApiBuilder } from ".";
|
|
10
|
-
import { type ApiBuilder, type BuildApiSignal } from "./apiInfo";
|
|
4
|
+
import type { Doc, ExtractSort, FilterInstance } from "@akanjs/document";
|
|
5
|
+
import type { Guard, InternalParam } from "@akanjs/nest";
|
|
6
|
+
import type { ServiceModule, Sig } from "@akanjs/service";
|
|
7
|
+
import { BuildSliceSignal, SliceApiBuilder, SliceInfo } from ".";
|
|
8
|
+
import { type ApiBuilder, ApiInfo, BuildApiSignal } from "./apiInfo";
|
|
11
9
|
import { BuildInternalApiSignal, InternalApiBuilder } from "./internalApiInfo";
|
|
12
|
-
export declare const ssoTypes: readonly ["github", "google", "facebook", "apple", "naver", "kakao"];
|
|
13
|
-
export type SSOType = (typeof ssoTypes)[number];
|
|
14
10
|
export declare class SignalStorage {
|
|
15
11
|
}
|
|
16
|
-
export declare const getAllSignalRefs: () =>
|
|
17
|
-
export declare const getSignalRefsOnStorage: (refName: string) =>
|
|
12
|
+
export declare const getAllSignalRefs: () => (new (...args: any[]) => any)[];
|
|
13
|
+
export declare const getSignalRefsOnStorage: (refName: string) => (new (...args: any[]) => any)[];
|
|
18
14
|
export declare const setSignalRefOnStorage: (refName: string, signalRef: Type) => void;
|
|
19
15
|
export type Resolve<T> = T;
|
|
20
16
|
export declare const resolve: <T>(data: any) => Resolve<T>;
|
|
@@ -44,11 +40,11 @@ export interface SignalOption<Response = any, Nullable extends boolean = false,
|
|
|
44
40
|
default?: boolean;
|
|
45
41
|
path?: string;
|
|
46
42
|
onlyFor?: "graphql" | "restapi";
|
|
47
|
-
sso?: SSOType;
|
|
48
43
|
serverMode?: "federation" | "batch" | "all";
|
|
49
44
|
timeout?: number;
|
|
50
45
|
partial?: _Key[] | readonly _Key[];
|
|
51
46
|
cache?: number;
|
|
47
|
+
guards?: Type<Guard>[];
|
|
52
48
|
scheduleType?: "init" | "destroy" | "cron" | "interval" | "timeout";
|
|
53
49
|
scheduleCron?: string;
|
|
54
50
|
scheduleTime?: number;
|
|
@@ -65,26 +61,19 @@ export declare const signalTypes: readonly ["graphql", "restapi"];
|
|
|
65
61
|
export type SignalType = (typeof signalTypes)[number];
|
|
66
62
|
export declare const endpointTypes: readonly ["Query", "Mutation", "Message", "Pubsub", "Process", "Schedule", "ResolveField"];
|
|
67
63
|
export type EndpointType = (typeof endpointTypes)[number];
|
|
68
|
-
export declare const guardTypes: readonly ["Public", "None", "User", "Admin", "SuperAdmin", "Every", "Owner"];
|
|
69
|
-
export type GuardType = (typeof guardTypes)[number];
|
|
70
|
-
export declare const roleTypes: readonly ["Public", "User", "Admin", "SuperAdmin"];
|
|
71
|
-
export type RoleType = (typeof roleTypes)[number];
|
|
72
64
|
export declare const argTypes: readonly ["Body", "Param", "Query", "Upload", "Msg", "Room"];
|
|
73
65
|
export type ArgType = (typeof argTypes)[number];
|
|
74
|
-
export declare const internalArgTypes: readonly ["Account", "Me", "Self", "UserIp", "Access", "Parent", "Req", "Res", "Ws", "Job"];
|
|
75
|
-
export type InternalArgType = (typeof internalArgTypes)[number];
|
|
76
66
|
export interface GqlMeta {
|
|
77
67
|
returns: (of?: any) => Type;
|
|
78
|
-
signalOption: SignalOption<any,
|
|
68
|
+
signalOption: SignalOption<any, boolean, any>;
|
|
79
69
|
key: string;
|
|
80
70
|
descriptor: PropertyDescriptor;
|
|
81
|
-
guards: GuardType[];
|
|
82
71
|
type: EndpointType;
|
|
83
72
|
}
|
|
84
73
|
export interface ArgsOption {
|
|
85
74
|
nullable?: boolean;
|
|
86
75
|
example?: string | number | boolean | Dayjs;
|
|
87
|
-
enum?:
|
|
76
|
+
enum?: EnumInstance;
|
|
88
77
|
}
|
|
89
78
|
export interface ArgMeta {
|
|
90
79
|
name: string;
|
|
@@ -97,7 +86,7 @@ export interface ArgMeta {
|
|
|
97
86
|
export interface InternalArgMeta {
|
|
98
87
|
key: string;
|
|
99
88
|
idx: number;
|
|
100
|
-
type:
|
|
89
|
+
type: InternalParam;
|
|
101
90
|
option?: {
|
|
102
91
|
nullable?: boolean;
|
|
103
92
|
};
|
|
@@ -116,182 +105,25 @@ export interface SignalMeta {
|
|
|
116
105
|
prefix?: string;
|
|
117
106
|
enabled: boolean;
|
|
118
107
|
}
|
|
119
|
-
export declare const createArgMetaDecorator: (type: InternalArgType) => (option?: {
|
|
120
|
-
nullable?: boolean;
|
|
121
|
-
}) => (prototype: object, key: string, idx: number) => void;
|
|
122
|
-
export declare const Account: (option?: {
|
|
123
|
-
nullable?: boolean;
|
|
124
|
-
}) => (prototype: object, key: string, idx: number) => void;
|
|
125
108
|
export type Account<AddData = unknown> = {
|
|
126
|
-
__InternalArg__: "Account";
|
|
127
|
-
self?: Self;
|
|
128
|
-
me?: Me;
|
|
129
109
|
appName: string;
|
|
130
110
|
environment: Environment;
|
|
131
111
|
} & AddData;
|
|
132
112
|
export declare const defaultAccount: Account;
|
|
133
|
-
|
|
134
|
-
nullable?: boolean;
|
|
135
|
-
}) => (prototype: object, key: string, idx: number) => void;
|
|
136
|
-
export interface Self {
|
|
137
|
-
__InternalArg__: "Self";
|
|
138
|
-
id: string;
|
|
139
|
-
nickname: string;
|
|
140
|
-
roles: string[];
|
|
141
|
-
image: {
|
|
142
|
-
url: string;
|
|
143
|
-
imageSize: [number, number];
|
|
144
|
-
} | null;
|
|
145
|
-
profileStatus: "active" | "prepare" | "applied" | "approved" | "reapplied" | "featured" | "reserved" | "rejected";
|
|
146
|
-
status: "prepare" | "active" | "restricted" | "dormant";
|
|
147
|
-
removedAt: Dayjs | null;
|
|
148
|
-
}
|
|
149
|
-
export declare const Me: (option?: {
|
|
150
|
-
nullable?: boolean;
|
|
151
|
-
}) => (prototype: object, key: string, idx: number) => void;
|
|
152
|
-
export interface Me {
|
|
153
|
-
__InternalArg__: "Me";
|
|
154
|
-
id: string;
|
|
155
|
-
accountId: string;
|
|
156
|
-
roles: string[];
|
|
157
|
-
status: "active";
|
|
158
|
-
removedAt: Dayjs | null;
|
|
159
|
-
}
|
|
160
|
-
export declare const UserIp: (option?: {
|
|
161
|
-
nullable?: boolean;
|
|
162
|
-
}) => (prototype: object, key: string, idx: number) => void;
|
|
163
|
-
export interface UserIp {
|
|
164
|
-
ip: string;
|
|
165
|
-
__InternalArg__: "UserIp";
|
|
166
|
-
}
|
|
167
|
-
export declare const Access: (option?: {
|
|
168
|
-
nullable?: boolean;
|
|
169
|
-
}) => (prototype: object, key: string, idx: number) => void;
|
|
170
|
-
export interface Access {
|
|
171
|
-
__InternalArg__: "Access";
|
|
172
|
-
period: number;
|
|
173
|
-
countryCode?: string;
|
|
174
|
-
countryName?: string;
|
|
175
|
-
city?: string;
|
|
176
|
-
postal?: number;
|
|
177
|
-
location?: {
|
|
178
|
-
type: "Point";
|
|
179
|
-
coordinates: [number, number];
|
|
180
|
-
};
|
|
181
|
-
ipv4?: string;
|
|
182
|
-
state?: string;
|
|
183
|
-
userAgent?: string;
|
|
184
|
-
at: Dayjs;
|
|
185
|
-
}
|
|
186
|
-
export declare const Req: (option?: {
|
|
187
|
-
nullable?: boolean;
|
|
188
|
-
}) => (prototype: object, key: string, idx: number) => void;
|
|
189
|
-
export type Req = {
|
|
190
|
-
__InternalArg__: "Req";
|
|
191
|
-
account: Account;
|
|
192
|
-
user: any;
|
|
193
|
-
} & ExpressRequest;
|
|
194
|
-
export declare const Res: (option?: {
|
|
195
|
-
nullable?: boolean;
|
|
196
|
-
}) => (prototype: object, key: string, idx: number) => void;
|
|
197
|
-
export type Res = {
|
|
198
|
-
__InternalArg__: "Res";
|
|
199
|
-
} & ExpressResponse;
|
|
200
|
-
export declare const Ws: (option?: {
|
|
201
|
-
nullable?: boolean;
|
|
202
|
-
}) => (prototype: object, key: string, idx: number) => void;
|
|
203
|
-
export type Ws = {
|
|
204
|
-
__InternalArg__: "Ws";
|
|
205
|
-
} & {
|
|
206
|
-
socket: Socket;
|
|
207
|
-
subscribe: boolean;
|
|
208
|
-
onSubscribe: (handler: () => void | Promise<void>) => void;
|
|
209
|
-
onUnsubscribe: (handler: () => void | Promise<void>) => void;
|
|
210
|
-
onDisconnect: (handler: () => void | Promise<void>) => void;
|
|
211
|
-
};
|
|
212
|
-
export declare const Job: (option?: {
|
|
213
|
-
nullable?: boolean;
|
|
214
|
-
}) => (prototype: object, key: string, idx: number) => void;
|
|
215
|
-
export type Job = {
|
|
216
|
-
__InternalArg__: "Job";
|
|
217
|
-
} & BullJob;
|
|
218
|
-
type Guard = <Response extends SingleFieldType>(returns: GqlReturn<Response>, signalOption?: SignalOption<UnType<Response>>, guards?: GuardType[]) => MethodDecorator;
|
|
219
|
-
export declare const Query: {
|
|
220
|
-
Public: Guard;
|
|
221
|
-
Every: Guard;
|
|
222
|
-
Admin: Guard;
|
|
223
|
-
User: Guard;
|
|
224
|
-
SuperAdmin: Guard;
|
|
225
|
-
None: Guard;
|
|
226
|
-
Owner: Guard;
|
|
227
|
-
};
|
|
228
|
-
export declare const Mutation: {
|
|
229
|
-
Public: Guard;
|
|
230
|
-
Every: Guard;
|
|
231
|
-
Admin: Guard;
|
|
232
|
-
User: Guard;
|
|
233
|
-
SuperAdmin: Guard;
|
|
234
|
-
None: Guard;
|
|
235
|
-
Owner: Guard;
|
|
236
|
-
};
|
|
237
|
-
export declare const Message: {
|
|
238
|
-
Public: Guard;
|
|
239
|
-
Every: Guard;
|
|
240
|
-
Admin: Guard;
|
|
241
|
-
User: Guard;
|
|
242
|
-
SuperAdmin: Guard;
|
|
243
|
-
None: Guard;
|
|
244
|
-
Owner: Guard;
|
|
245
|
-
};
|
|
246
|
-
export declare const Pubsub: {
|
|
247
|
-
Public: Guard;
|
|
248
|
-
Every: Guard;
|
|
249
|
-
Admin: Guard;
|
|
250
|
-
User: Guard;
|
|
251
|
-
SuperAdmin: Guard;
|
|
252
|
-
None: Guard;
|
|
253
|
-
Owner: Guard;
|
|
254
|
-
};
|
|
255
|
-
export declare const Process: {
|
|
256
|
-
Federation: Guard;
|
|
257
|
-
Batch: Guard;
|
|
258
|
-
All: Guard;
|
|
259
|
-
};
|
|
260
|
-
export declare const Schedule: {
|
|
261
|
-
Init: (options?: InitOption) => MethodDecorator;
|
|
262
|
-
Cron: (cron: string, options?: TimerOption) => MethodDecorator;
|
|
263
|
-
Interval: (interval: number, options?: TimerOption) => MethodDecorator;
|
|
264
|
-
Timeout: (timeout: number, options?: TimerOption) => MethodDecorator;
|
|
265
|
-
Destroy: (options?: InitOption) => MethodDecorator;
|
|
266
|
-
};
|
|
267
|
-
export declare function ResolveField(returns: GqlReturn, argsOption?: ArgsOption): (target: any, key: string, descriptor: PropertyDescriptor) => void;
|
|
268
|
-
export declare const Arg: {
|
|
269
|
-
Body: (name: string, returns: GqlReturn, argsOption?: ArgsOption) => (prototype: object, key: string, idx: number) => void;
|
|
270
|
-
Param: (name: string, returns: GqlReturn, argsOption?: ArgsOption) => (prototype: object, key: string, idx: number) => void;
|
|
271
|
-
Query: (name: string, returns: GqlReturn, argsOption?: ArgsOption) => (prototype: object, key: string, idx: number) => void;
|
|
272
|
-
Upload: (name: string, returns: GqlReturn, argsOption?: ArgsOption) => (prototype: object, key: string, idx: number) => void;
|
|
273
|
-
Msg: (name: string, returns: GqlReturn, argsOption?: ArgsOption) => (prototype: object, key: string, idx: number) => void;
|
|
274
|
-
Room: (name: string, returns: GqlReturn, argsOption?: ArgsOption) => (prototype: object, key: string, idx: number) => void;
|
|
275
|
-
};
|
|
276
|
-
export declare function Parent(): (prototype: object, key: string, idx: number) => void;
|
|
277
|
-
interface SigOptionV2 {
|
|
113
|
+
interface SliceOption {
|
|
278
114
|
guards?: {
|
|
279
|
-
|
|
280
|
-
|
|
115
|
+
root?: Type<Guard> | Type<Guard>[];
|
|
116
|
+
get?: Type<Guard> | Type<Guard>[];
|
|
117
|
+
cru?: Type<Guard> | Type<Guard>[];
|
|
281
118
|
};
|
|
282
119
|
prefix?: string;
|
|
283
120
|
}
|
|
284
|
-
type ExtendedGqlReturn<Return,
|
|
285
|
-
type
|
|
286
|
-
[K in keyof
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
})> : _Endpoints[K] extends (...args: infer Args) => infer Return & {
|
|
291
|
-
__Returns__?: infer Rts;
|
|
292
|
-
} ? (...args: Args) => ExtendedGqlReturn<Return, Input, Full, Light, Insight> & (Rts extends unknown ? unknown : {
|
|
293
|
-
__Returns__: Rts;
|
|
294
|
-
}) : never;
|
|
121
|
+
type ExtendedGqlReturn<Return, Full, Light, Insight, _UnTypeReturn = UnType<Return>> = Return extends (infer R)[] ? ExtendedGqlReturn<R, Full, Light, Insight>[] : Full extends _UnTypeReturn ? Type<Full> : Light extends _UnTypeReturn ? Type<Light> : Insight extends _UnTypeReturn ? Type<Insight> : Return;
|
|
122
|
+
type ExtendSlices<T extends string, Full extends BaseObject, Light extends BaseObject, Insight extends BaseInsight, LibSlices extends Type[], _Slices = MergeAllTypes<LibSlices>> = {
|
|
123
|
+
[K in keyof _Slices]: _Slices[K] extends SliceInfo<T, any, any, any, infer Srvs, infer ArgNames, infer Args, infer InternalArgs, infer ServerArgs> ? SliceInfo<T, Full, Light, Insight, Srvs, ArgNames, Args, InternalArgs, ServerArgs> : never;
|
|
124
|
+
};
|
|
125
|
+
type ExtendEndpoints<Full extends BaseObject, Light extends BaseObject, Insight extends BaseInsight, LibEndpoints extends Type[], _Endpoints = MergeAllTypes<LibEndpoints>> = {
|
|
126
|
+
[K in keyof _Endpoints]: _Endpoints[K] extends ApiInfo<infer ReqType, infer Srvs, infer ArgNames, infer Args, infer InternalArgs, infer ServerArgs, infer Returns, infer ServerReturns, infer Nullable> ? ApiInfo<ReqType, Srvs, ArgNames, Args, InternalArgs, ServerArgs, ExtendedGqlReturn<Returns, Full, Light, Insight>, ServerReturns, Nullable> : never;
|
|
295
127
|
};
|
|
296
128
|
export interface SrvOption<T extends string, Srv extends {
|
|
297
129
|
[key: string]: Type;
|
|
@@ -302,19 +134,18 @@ export interface SrvOption<T extends string, Srv extends {
|
|
|
302
134
|
}
|
|
303
135
|
export declare function internal<Srv extends {
|
|
304
136
|
[key: string]: any;
|
|
305
|
-
}, Full, InternalBuilder extends InternalApiBuilder<Srv, Doc<Full>>, LibInternals extends Type[]>(srv: ServiceModule<string, Srv, any, Full, any, any>, internalBuilder: InternalBuilder, ...libInternals: LibInternals): Type<
|
|
306
|
-
export declare function slice<T extends string, Input, Full extends BaseObject
|
|
307
|
-
status: string;
|
|
308
|
-
}, Light extends BaseObject, Insight extends {
|
|
309
|
-
count: number;
|
|
310
|
-
}, Srv extends {
|
|
137
|
+
}, Full, InternalBuilder extends InternalApiBuilder<Srv, Doc<Full>>, LibInternals extends Type[]>(srv: ServiceModule<string, Srv, any, Full, any, any>, internalBuilder: InternalBuilder, ...libInternals: LibInternals): Type<ReturnType<InternalBuilder> & MergeAllTypes<LibInternals>>;
|
|
138
|
+
export declare function slice<T extends string, Input, Full extends BaseObject, Light extends BaseObject, Insight extends BaseInsight, Srv extends {
|
|
311
139
|
[key: string]: any;
|
|
312
|
-
}, SliceBuilder extends SliceApiBuilder<Full, Light, Insight, Srv>, LibSlices extends Type[]
|
|
313
|
-
|
|
140
|
+
}, SliceBuilder extends SliceApiBuilder<T, Full, Light, Insight, Srv>, LibSlices extends Type[], _Query = QueryOf<DocumentModel<Full>>>(srv: ServiceModule<T, Srv, Input, Full, Light, Insight>, option: SliceOption, sliceBuilder: SliceBuilder, ...libSlices: LibSlices): Type<ReturnType<SliceBuilder> & {
|
|
141
|
+
[""]: SliceInfo<T, Full, Light, Insight, Srv, ["query"], [_Query], [], [_Query]>;
|
|
142
|
+
} & ExtendSlices<T, Full, Light, Insight, LibSlices>>;
|
|
143
|
+
export declare function endpoint<Input, Full extends BaseObject, Light extends BaseObject, Insight extends BaseInsight, Srv extends {
|
|
314
144
|
[key: string]: any;
|
|
315
|
-
}, Builder extends ApiBuilder<Srv>,
|
|
316
|
-
export declare const mergeSignals: <Endpoint, Internal, Slice
|
|
317
|
-
export
|
|
145
|
+
}, Builder extends ApiBuilder<Srv>, LibEndpoints extends Type[]>(srv: ServiceModule<string, Srv, Input, Full, Light, Insight>, builder: Builder, ...libEndpoints: LibEndpoints): Type<Assign<ReturnType<Builder>, ExtendEndpoints<Full, Light, Insight, LibEndpoints>>>;
|
|
146
|
+
export declare const mergeSignals: <Endpoint, Internal, Slice>(endpointRef: Type<Endpoint>, internalRef: Type<Internal>, sliceRef?: Type<Slice>) => Type<BuildApiSignal<Endpoint> & BuildInternalApiSignal<Internal> & BuildSliceSignal<Slice>>;
|
|
147
|
+
export declare const serverSignalOf: <Signal>(sigRef: Type<Signal>) => Type<Sig<Signal>>;
|
|
148
|
+
export type DefaultSignal<T extends string, Input, Full, Light, Insight, Filter extends FilterInstance, _CapitalizedT extends string = Capitalize<T>, _PurifiedInput = PurifiedModel<Input>, _QueryOfDoc = QueryOf<DocumentModel<Full>>, _Sort = ExtractSort<Filter>> = {
|
|
318
149
|
[K in T]: (id: string) => Promise<Full>;
|
|
319
150
|
} & {
|
|
320
151
|
[K in `light${_CapitalizedT}`]: (id: string) => Promise<Light>;
|
|
@@ -323,11 +154,11 @@ export type DefaultSignal<T extends string, Input, Full, Light, Insight, Filter
|
|
|
323
154
|
} & {
|
|
324
155
|
[K in `${T}Insight`]: (query: _QueryOfDoc) => Promise<Insight>;
|
|
325
156
|
} & {
|
|
326
|
-
[K in `create${_CapitalizedT}`]: (data: _PurifiedInput
|
|
157
|
+
[K in `create${_CapitalizedT}`]: (data: _PurifiedInput) => Promise<Full>;
|
|
327
158
|
} & {
|
|
328
|
-
[K in `update${_CapitalizedT}`]: (id: string, data: _PurifiedInput
|
|
159
|
+
[K in `update${_CapitalizedT}`]: (id: string, data: _PurifiedInput) => Promise<Full>;
|
|
329
160
|
} & {
|
|
330
|
-
[K in `remove${_CapitalizedT}`]: (id: string
|
|
161
|
+
[K in `remove${_CapitalizedT}`]: (id: string) => Promise<Full>;
|
|
331
162
|
};
|
|
332
163
|
export declare const getSigMeta: (sigRef: Type) => SignalMeta;
|
|
333
164
|
export declare const setSigMeta: (sigRef: Type, sigMeta: SignalMeta) => void;
|
package/src/signalInfo.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { GqlScalarName, Type } from "@akanjs/base";
|
|
2
|
-
import { ArgsOption, ArgType,
|
|
2
|
+
import { ArgsOption, ArgType, SliceMeta } from "./signalDecorators";
|
|
3
3
|
export declare const signalInfo: {
|
|
4
|
-
database: Map<string,
|
|
5
|
-
service: Map<string,
|
|
4
|
+
database: Map<string, new (...args: any[]) => any>;
|
|
5
|
+
service: Map<string, new (...args: any[]) => any>;
|
|
6
6
|
serializedSignals: SerializedSignal[];
|
|
7
7
|
setDatabase(refName: string, signal: Type): void;
|
|
8
|
-
getDatabase(refName: string):
|
|
8
|
+
getDatabase(refName: string): (new (...args: any[]) => any) | undefined;
|
|
9
9
|
setRefNameTemp(sigRef: Type, refName: string): void;
|
|
10
10
|
getRefNameTemp(sigRef: Type): string;
|
|
11
11
|
setPrefixTemp(sigRef: Type, prefix: string): void;
|
|
@@ -13,14 +13,14 @@ export declare const signalInfo: {
|
|
|
13
13
|
setHandlerKey(execFn: (...args: any) => any, key: string): void;
|
|
14
14
|
getHandlerKey(execFn: (...args: any) => any): string;
|
|
15
15
|
setService(refName: string, signal: Type): void;
|
|
16
|
-
getService(refName: string):
|
|
16
|
+
getService(refName: string): (new (...args: any[]) => any) | undefined;
|
|
17
17
|
registerSignals<Signals extends Type[]>(...signals: Signals): Signals;
|
|
18
18
|
serialize(sigRef: Type): SerializedSignal;
|
|
19
19
|
initialize(): object;
|
|
20
20
|
buildFetch(signals?: SerializedSignal[], cnstInfo?: {
|
|
21
21
|
database: Map<string, import("@akanjs/constant").ConstantModel<any, any, any, any, any, any, import("@akanjs/constant").DefaultOf<any>, import("@akanjs/constant").DefaultOf<any>, import("@akanjs/base").GetStateObject<any>, import("@akanjs/base").GetStateObject<any>, import("@akanjs/constant").DefaultOf<any>, any, any, any, import("mongoose").FilterQuery<any>>>;
|
|
22
22
|
scalar: Map<string, import("@akanjs/constant").ScalarConstantModel<any, any, any, any, any>>;
|
|
23
|
-
modelRefNameMap: Map<
|
|
23
|
+
modelRefNameMap: Map<new (...args: any[]) => any, string>;
|
|
24
24
|
getRefName<AllowEmpty extends boolean = false>(modelRef: Type, { allowEmpty }?: {
|
|
25
25
|
allowEmpty?: AllowEmpty;
|
|
26
26
|
}): AllowEmpty extends true ? string | undefined : string;
|
|
@@ -62,9 +62,17 @@ export interface SerializedArg {
|
|
|
62
62
|
argsOption: ArgsOption;
|
|
63
63
|
arrDepth: number;
|
|
64
64
|
}
|
|
65
|
+
export interface SerializedSignalOption {
|
|
66
|
+
nullable?: boolean;
|
|
67
|
+
path?: string;
|
|
68
|
+
onlyFor?: "restapi" | "graphql";
|
|
69
|
+
partial?: string[];
|
|
70
|
+
guards?: string[];
|
|
71
|
+
name?: string;
|
|
72
|
+
}
|
|
65
73
|
export interface SerializedEndpoint {
|
|
66
74
|
type: "query" | "mutation" | "pubsub" | "message";
|
|
67
|
-
signalOption?:
|
|
75
|
+
signalOption?: SerializedSignalOption;
|
|
68
76
|
returns: SerializedReturns;
|
|
69
77
|
args: SerializedArg[];
|
|
70
78
|
}
|
package/src/sliceInfo.d.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { BaseObject, PromiseOrObject, Type, UnType } from "@akanjs/base";
|
|
1
|
+
import { BaseInsight, BaseObject, MergedValues, PromiseOrObject, Type, UnType } from "@akanjs/base";
|
|
2
2
|
import { ConstantFieldTypeInput, DocumentModel, FieldToValue, ParamFieldType, PlainTypeToFieldType, PurifiedModel, QueryOf } from "@akanjs/constant";
|
|
3
|
+
import type { InternalParam } from "@akanjs/nest";
|
|
3
4
|
import { ApiArgProps } from "./apiInfo";
|
|
4
|
-
import {
|
|
5
|
-
export declare class SliceInfo<Full extends BaseObject, Light extends BaseObject, Insight extends {
|
|
6
|
-
count: number;
|
|
7
|
-
}, Srvs extends {
|
|
5
|
+
import { ArgType, SignalOption } from "./signalDecorators";
|
|
6
|
+
export declare class SliceInfo<T extends string, Full extends BaseObject, Light extends BaseObject, Insight extends BaseInsight, Srvs extends {
|
|
8
7
|
[key: string]: any;
|
|
9
8
|
} = {
|
|
10
9
|
[key: string]: any;
|
|
11
|
-
}, Args extends any[] = [], InternalArgs extends any[] = [], ServerArgs extends any[] = []> {
|
|
10
|
+
}, ArgNames extends string[] = [], Args extends any[] = [], InternalArgs extends any[] = [], ServerArgs extends any[] = []> {
|
|
11
|
+
readonly refName: T;
|
|
12
12
|
readonly full: Type<Full>;
|
|
13
13
|
readonly light: Type<Light>;
|
|
14
14
|
readonly insight: Type<Insight>;
|
|
15
|
+
readonly argNames: ArgNames;
|
|
15
16
|
readonly args: {
|
|
16
17
|
type: ArgType;
|
|
17
18
|
name: string;
|
|
@@ -19,43 +20,33 @@ export declare class SliceInfo<Full extends BaseObject, Light extends BaseObject
|
|
|
19
20
|
option?: ApiArgProps<boolean>;
|
|
20
21
|
}[];
|
|
21
22
|
readonly internalArgs: {
|
|
22
|
-
type:
|
|
23
|
+
type: InternalParam;
|
|
23
24
|
option?: ApiArgProps<boolean>;
|
|
24
25
|
}[];
|
|
25
26
|
readonly signalOption: SignalOption;
|
|
26
|
-
readonly guards: GuardType[];
|
|
27
27
|
execFn: ((...args: [...ServerArgs, ...InternalArgs]) => QueryOf<DocumentModel<Full>>) | null;
|
|
28
|
-
constructor(full: Type<Full>, light: Type<Light>, insight: Type<Insight>,
|
|
29
|
-
param<Arg extends ParamFieldType, _ClientArg = FieldToValue<Arg>, _ServerArg = DocumentModel<_ClientArg>>(name:
|
|
30
|
-
body<ExplicitType = unknown, Arg extends ConstantFieldTypeInput = PlainTypeToFieldType<ExplicitType>, _ArgType = unknown extends ExplicitType ? FieldToValue<Arg> : ExplicitType, _ClientArg = PurifiedModel<_ArgType>, _ServerArg = DocumentModel<_ArgType>>(name:
|
|
31
|
-
search<ExplicitType = unknown, Arg extends ConstantFieldTypeInput = PlainTypeToFieldType<ExplicitType>, _ArgType = unknown extends ExplicitType ? FieldToValue<Arg> : ExplicitType, _ClientArg = PurifiedModel<_ArgType>, _ServerArg = DocumentModel<_ArgType>>(name:
|
|
32
|
-
with<ArgType extends
|
|
28
|
+
constructor(refName: T, full: Type<Full>, light: Type<Light>, insight: Type<Insight>, signalOption?: SignalOption);
|
|
29
|
+
param<ArgName extends string, Arg extends ParamFieldType, _ClientArg = FieldToValue<Arg>, _ServerArg = DocumentModel<_ClientArg>>(name: ArgName, argRef: Arg, option?: Omit<ApiArgProps, "nullable">): SliceInfo<T, Full, Light, Insight, Srvs, [...ArgNames, ArgName], [...Args, arg: _ClientArg], InternalArgs, [...ServerArgs, arg: _ServerArg]>;
|
|
30
|
+
body<ArgName extends string, ExplicitType = unknown, Arg extends ConstantFieldTypeInput = PlainTypeToFieldType<ExplicitType>, _ArgType = unknown extends ExplicitType ? FieldToValue<Arg> : ExplicitType, _ClientArg = PurifiedModel<_ArgType>, _ServerArg = DocumentModel<_ArgType>>(name: ArgName, argRef: Arg, option?: ApiArgProps): SliceInfo<T, Full, Light, Insight, Srvs, [...ArgNames, ArgName], [...Args, arg: _ClientArg], InternalArgs, [...ServerArgs, arg: _ServerArg]>;
|
|
31
|
+
search<ArgName extends string, ExplicitType = unknown, Arg extends ConstantFieldTypeInput = PlainTypeToFieldType<ExplicitType>, _ArgType = unknown extends ExplicitType ? FieldToValue<Arg> : ExplicitType, _ClientArg = PurifiedModel<_ArgType>, _ServerArg = DocumentModel<_ArgType>>(name: ArgName, argRef: Arg, option?: Omit<ApiArgProps, "nullable">): SliceInfo<T, Full, Light, Insight, Srvs, [...ArgNames, ArgName], [...Args, arg: _ClientArg | null], InternalArgs, [...ServerArgs, arg: _ServerArg | undefined]>;
|
|
32
|
+
with<ArgType, Optional extends boolean = false>(argType: InternalParam<ArgType>, option?: ApiArgProps<Optional>): SliceInfo<T, Full, Light, Insight, Srvs, ArgNames, Args, [...InternalArgs, arg: ArgType | (Optional extends true ? null : never)], ServerArgs>;
|
|
33
33
|
exec(query: (this: {
|
|
34
34
|
[K in keyof Srvs as K extends string ? Uncapitalize<K> : never]: Srvs[K];
|
|
35
35
|
}, ...args: [...ServerArgs, ...InternalArgs]) => PromiseOrObject<QueryOf<DocumentModel<Full>>>): this;
|
|
36
36
|
applySliceMeta(refName: string, sigRef: Type, key: string): void;
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
} = {
|
|
41
|
-
count: number;
|
|
42
|
-
}, _Query extends QueryOf<DocumentModel<Full>> = QueryOf<DocumentModel<Full>>, _ApiMap = ReturnType<SliceBuilder>> = {
|
|
43
|
-
[K in `${T}List`]: (query: _Query | null, skip: number | null, limit: number | null, sort: string | null) => Promise<Full[]>;
|
|
44
|
-
} & {
|
|
45
|
-
[K in `${T}Insight`]: (query: _Query) => Promise<Insight>;
|
|
46
|
-
} & {
|
|
47
|
-
[K in keyof _ApiMap as `${T}List${Capitalize<K & string>}`]: _ApiMap[K] extends SliceInfo<infer Full, any, infer Insight, any, infer Args, any, any> ? (...args: [...Args, skip: number | null, limit: number | null, sort: string | null]) => Promise<Full[]> : never;
|
|
38
|
+
type SliceToSignal<T extends string, Full extends BaseObject, Insight extends BaseInsight, Args extends any[], Suffix extends string, _CapitalizedSuffix extends string = Capitalize<Suffix>> = {
|
|
39
|
+
[K in `${T}List${_CapitalizedSuffix}`]: (...args: [...Args, skip: number | null, limit: number | null, sort: string | null]) => Promise<Full[]>;
|
|
48
40
|
} & {
|
|
49
|
-
[K in
|
|
41
|
+
[K in `${T}Insight${_CapitalizedSuffix}`]: (...args: Args) => Promise<Insight>;
|
|
50
42
|
};
|
|
51
|
-
export
|
|
52
|
-
|
|
53
|
-
}
|
|
43
|
+
export type BuildSliceSignal<SliceInfoMap> = MergedValues<{
|
|
44
|
+
[K in keyof SliceInfoMap]: SliceInfoMap[K] extends SliceInfo<infer T, infer Full, any, infer Insight, any, any, infer Args, any, any> ? SliceToSignal<T, Full, Insight, Args, K & string> : never;
|
|
45
|
+
}>;
|
|
46
|
+
export declare const sliceInit: <T extends string, Full extends BaseObject, Light extends BaseObject, Insight extends BaseInsight, Srvs extends {
|
|
54
47
|
[key: string]: any;
|
|
55
|
-
}>(full: Type<Full>, light: Type<Light>, insight: Type<Insight>) => (
|
|
56
|
-
export type SliceApiBuilder<Full extends BaseObject, Light extends BaseObject, Insight extends {
|
|
57
|
-
count: number;
|
|
58
|
-
}, Srvs extends {
|
|
48
|
+
}>(refName: T, full: Type<Full>, light: Type<Light>, insight: Type<Insight>) => (signalOption?: SignalOption) => SliceInfo<T, Full, Light, Insight, Srvs, [], [], [], []>;
|
|
49
|
+
export type SliceApiBuilder<T extends string, Full extends BaseObject, Light extends BaseObject, Insight extends BaseInsight, Srvs extends {
|
|
59
50
|
[key: string]: any;
|
|
60
51
|
} = {
|
|
61
52
|
[key: string]: any;
|
|
@@ -63,6 +54,7 @@ export type SliceApiBuilder<Full extends BaseObject, Light extends BaseObject, I
|
|
|
63
54
|
[key: string]: any;
|
|
64
55
|
} = {
|
|
65
56
|
[K in keyof Srvs as K extends string ? Uncapitalize<K> : never]: UnType<Srvs[K]>;
|
|
66
|
-
}> = (init: (
|
|
67
|
-
[key: string]: SliceInfo<any, any, any, any, any, any>;
|
|
57
|
+
}> = (init: (signalOption?: SignalOption) => SliceInfo<T, Full, Light, Insight, _ThisSrvs>) => {
|
|
58
|
+
[key: string]: SliceInfo<T, any, any, any, any, any, any, any, any>;
|
|
68
59
|
};
|
|
60
|
+
export {};
|