@akanjs/signal 0.9.48 → 0.9.49

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.
@@ -0,0 +1,68 @@
1
+ import { BaseObject, PromiseOrObject, Type, UnType } from "@akanjs/base";
2
+ import { ConstantFieldTypeInput, DocumentModel, FieldToValue, ParamFieldType, PlainTypeToFieldType, PurifiedModel, QueryOf } from "@akanjs/constant";
3
+ import { ApiArgProps } from "./apiInfo";
4
+ import { Access, Account, ArgType, GuardType, InternalArgType, Job, Me, Req, Res, Self, SignalOption, UserIp, Ws } from "./signalDecorators";
5
+ export declare class SliceInfo<Full extends BaseObject, Light extends BaseObject, Insight extends {
6
+ count: number;
7
+ }, Srvs extends {
8
+ [key: string]: any;
9
+ } = {
10
+ [key: string]: any;
11
+ }, Args extends any[] = [], InternalArgs extends any[] = [], ServerArgs extends any[] = []> {
12
+ readonly full: Type<Full>;
13
+ readonly light: Type<Light>;
14
+ readonly insight: Type<Insight>;
15
+ readonly args: {
16
+ type: ArgType;
17
+ name: string;
18
+ argRef: ConstantFieldTypeInput;
19
+ option?: ApiArgProps<boolean>;
20
+ }[];
21
+ readonly internalArgs: {
22
+ type: InternalArgType;
23
+ option?: ApiArgProps<boolean>;
24
+ }[];
25
+ readonly signalOption: SignalOption;
26
+ readonly guards: GuardType[];
27
+ execFn: ((...args: [...ServerArgs, ...InternalArgs]) => QueryOf<DocumentModel<Full>>) | null;
28
+ constructor(full: Type<Full>, light: Type<Light>, insight: Type<Insight>, signalOptionOrGuard?: SignalOption | GuardType, ...guards: GuardType[]);
29
+ param<Arg extends ParamFieldType, _ClientArg = FieldToValue<Arg>, _ServerArg = DocumentModel<_ClientArg>>(name: string, argRef: Arg, option?: Omit<ApiArgProps, "nullable">): SliceInfo<Full, Light, Insight, Srvs, [...Args, arg: _ClientArg], InternalArgs, [...ServerArgs, arg: _ServerArg]>;
30
+ body<ExplicitType = unknown, Arg extends ConstantFieldTypeInput = PlainTypeToFieldType<ExplicitType>, _ArgType = unknown extends ExplicitType ? FieldToValue<Arg> : ExplicitType, _ClientArg = PurifiedModel<_ArgType>, _ServerArg = DocumentModel<_ArgType>>(name: string, argRef: Arg, option?: ApiArgProps): SliceInfo<Full, Light, Insight, Srvs, [...Args, arg: _ClientArg], InternalArgs, [...ServerArgs, arg: _ServerArg]>;
31
+ search<ExplicitType = unknown, Arg extends ConstantFieldTypeInput = PlainTypeToFieldType<ExplicitType>, _ArgType = unknown extends ExplicitType ? FieldToValue<Arg> : ExplicitType, _ClientArg = PurifiedModel<_ArgType>, _ServerArg = DocumentModel<_ArgType>>(name: string, argRef: Arg, option?: Omit<ApiArgProps, "nullable">): SliceInfo<Full, Light, Insight, Srvs, [...Args, arg: _ClientArg | null], InternalArgs, [...ServerArgs, arg: _ServerArg | undefined]>;
32
+ with<ArgType extends InternalArgType>(argType: Exclude<ArgType, "Parent">, option?: ApiArgProps): SliceInfo<Full, Light, Insight, Srvs, Args, [...InternalArgs, arg: ArgType extends "Account" ? Account : ArgType extends "Me" ? Me : ArgType extends "Self" ? Self : ArgType extends "UserIp" ? UserIp : ArgType extends "Access" ? Access : ArgType extends "Req" ? Req : ArgType extends "Res" ? Res : ArgType extends "Ws" ? Ws : ArgType extends "Job" ? Job : never], ServerArgs>;
33
+ exec(query: (this: {
34
+ [K in keyof Srvs as K extends string ? Uncapitalize<K> : never]: Srvs[K];
35
+ }, ...args: [...ServerArgs, ...InternalArgs]) => PromiseOrObject<QueryOf<DocumentModel<Full>>>): this;
36
+ applySliceMeta(refName: string, sigRef: Type, key: string): void;
37
+ }
38
+ export type BuildSliceSignal<T extends string, SliceBuilder extends SliceApiBuilder<any, any, any>, Full extends BaseObject = BaseObject, Light extends BaseObject = BaseObject, Insight extends {
39
+ count: number;
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;
48
+ } & {
49
+ [K in keyof _ApiMap as `${T}Insight${Capitalize<K & string>}`]: _ApiMap[K] extends SliceInfo<any, any, infer Insight, any, infer Args, any, any> ? (...args: Args) => Promise<Insight> : never;
50
+ };
51
+ export declare const sliceInit: <Full extends BaseObject, Light extends BaseObject, Insight extends {
52
+ count: number;
53
+ }, Srvs extends {
54
+ [key: string]: any;
55
+ }>(full: Type<Full>, light: Type<Light>, insight: Type<Insight>) => (signalOptionOrGuard?: SignalOption | GuardType, ...guards: GuardType[]) => SliceInfo<Full, Light, Insight, Srvs, [], [], []>;
56
+ export type SliceApiBuilder<Full extends BaseObject, Light extends BaseObject, Insight extends {
57
+ count: number;
58
+ }, Srvs extends {
59
+ [key: string]: any;
60
+ } = {
61
+ [key: string]: any;
62
+ }, _ThisSrvs extends {
63
+ [key: string]: any;
64
+ } = {
65
+ [K in keyof Srvs as K extends string ? Uncapitalize<K> : never]: UnType<Srvs[K]>;
66
+ }> = (init: (signalOptionOrGuard?: SignalOption | GuardType, ...guards: GuardType[]) => SliceInfo<Full, Light, Insight, _ThisSrvs>) => {
67
+ [key: string]: SliceInfo<any, any, any, any, any, any>;
68
+ };