akanjs 2.3.5-rc.9 → 2.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.
Files changed (81) hide show
  1. package/base/base.ts +6 -2
  2. package/base/primitiveRegistry.ts +50 -46
  3. package/base/symbols.ts +16 -11
  4. package/base/types.ts +12 -0
  5. package/constant/constantRegistry.ts +10 -9
  6. package/constant/deserialize.ts +7 -7
  7. package/constant/fieldInfo.ts +173 -31
  8. package/constant/getDefault.ts +2 -2
  9. package/constant/immerify.ts +2 -2
  10. package/constant/purify.ts +19 -4
  11. package/constant/serialize.ts +6 -5
  12. package/constant/types.ts +9 -1
  13. package/constant/via.ts +312 -57
  14. package/dictionary/dictInfo.ts +28 -38
  15. package/dictionary/locale.ts +36 -38
  16. package/document/by.ts +84 -21
  17. package/document/database.ts +53 -18
  18. package/document/databaseRegistry.ts +7 -3
  19. package/document/filterMeta.ts +26 -14
  20. package/document/into.ts +71 -76
  21. package/document/types.ts +4 -2
  22. package/fetch/fetchType/endpointFetch.type.ts +6 -3
  23. package/fetch/fetchType/sliceFetch.type.ts +24 -13
  24. package/package.json +1 -1
  25. package/service/predefinedAdaptor/compress.adaptor.ts +9 -9
  26. package/service/predefinedAdaptor/database.adaptor.ts +3 -7
  27. package/service/serve.ts +17 -52
  28. package/service/types.ts +61 -21
  29. package/signal/endpoint.ts +2 -1
  30. package/signal/endpointInfo.ts +53 -23
  31. package/signal/internal.ts +2 -1
  32. package/signal/internalInfo.ts +71 -23
  33. package/signal/serverSignal.ts +23 -57
  34. package/signal/slice.ts +35 -35
  35. package/signal/sliceInfo.ts +63 -47
  36. package/signal/types.ts +23 -17
  37. package/store/action.ts +57 -44
  38. package/store/state.ts +47 -36
  39. package/store/stateBuilder.ts +3 -3
  40. package/store/store.ts +61 -15
  41. package/store/types.ts +16 -6
  42. package/types/base/base.d.ts +5 -1
  43. package/types/base/primitiveRegistry.d.ts +43 -38
  44. package/types/base/symbols.d.ts +5 -0
  45. package/types/base/types.d.ts +1 -0
  46. package/types/constant/constantRegistry.d.ts +3 -8
  47. package/types/constant/deserialize.d.ts +2 -2
  48. package/types/constant/fieldInfo.d.ts +41 -20
  49. package/types/constant/immerify.d.ts +2 -2
  50. package/types/constant/purify.d.ts +3 -2
  51. package/types/constant/serialize.d.ts +2 -2
  52. package/types/constant/types.d.ts +6 -1
  53. package/types/constant/via.d.ts +143 -22
  54. package/types/dictionary/dictInfo.d.ts +18 -11
  55. package/types/dictionary/locale.d.ts +23 -16
  56. package/types/document/by.d.ts +44 -7
  57. package/types/document/database.d.ts +9 -7
  58. package/types/document/databaseRegistry.d.ts +5 -4
  59. package/types/document/filterMeta.d.ts +18 -11
  60. package/types/document/into.d.ts +46 -19
  61. package/types/document/types.d.ts +3 -2
  62. package/types/fetch/fetchType/endpointFetch.type.d.ts +2 -2
  63. package/types/fetch/fetchType/sliceFetch.type.d.ts +11 -11
  64. package/types/service/serve.d.ts +4 -5
  65. package/types/service/serviceModule.d.ts +5 -5
  66. package/types/service/types.d.ts +23 -5
  67. package/types/signal/endpoint.d.ts +2 -1
  68. package/types/signal/endpointInfo.d.ts +40 -15
  69. package/types/signal/internal.d.ts +2 -1
  70. package/types/signal/internalInfo.d.ts +46 -12
  71. package/types/signal/serverSignal.d.ts +15 -12
  72. package/types/signal/slice.d.ts +8 -6
  73. package/types/signal/sliceInfo.d.ts +41 -20
  74. package/types/signal/types.d.ts +23 -17
  75. package/types/store/action.d.ts +25 -22
  76. package/types/store/baseSt.d.ts +42 -13
  77. package/types/store/state.d.ts +23 -26
  78. package/types/store/stateBuilder.d.ts +2 -2
  79. package/types/store/store.d.ts +17 -5
  80. package/types/store/types.d.ts +9 -3
  81. package/ui/Signal/makeExample.ts +3 -3
@@ -1,9 +1,28 @@
1
1
  import type { Cls, MergeAllTypes, PromiseOrObject } from "akanjs/base";
2
2
  import type { Logger } from "akanjs/common";
3
3
  import type { QueryOf } from "akanjs/constant";
4
- import type { CRUDEventType, DatabaseInstance, DataInputOf, Doc as DbDoc, ExtractQuery, ExtractSort, FilterInstance, FindQueryOption, GetDocObject, ListQueryOption, QueryMethodPart, SaveEventType } from "akanjs/document";
4
+ import type { CRUDEventType, DatabaseModel, DataInputOf, FilterInstance, FindQueryOption, GetDocObject, ListQueryOption, QueryMethodPart, SaveEventType } from "akanjs/document";
5
5
  type ServiceMixinOmitKey = "onInit" | "onDestroy" | "_libsOnInit" | "_libsOnDestroy" | "_preCreate" | "_postCreate" | "_preUpdate" | "_postUpdate" | "_preRemove" | "_postRemove" | "_libsPreCreate" | "_libsPostCreate" | "_libsPreUpdate" | "_libsPostUpdate" | "_libsPreRemove" | "_libsPostRemove";
6
- export type DatabaseService<T extends string = string, Input = any, Doc = any, Obj = any, Model = any, Insight = any, Filter extends FilterInstance = FilterInstance, LibSrvs extends Cls[] = [], _Query extends ExtractQuery<Filter> = ExtractQuery<Filter>, _Sort extends ExtractSort<Filter> = ExtractSort<Filter>, _CapitalizedRefName extends Capitalize<T> = Capitalize<T>, _DataInputOfDoc extends DataInputOf<Input, Doc> = DataInputOf<Input, Doc>, _QueryOfDoc extends QueryOf<Doc> = QueryOf<Doc>, _FindQueryOption extends FindQueryOption<_Sort, Obj> = FindQueryOption<_Sort, Obj>, _ListQueryOption extends ListQueryOption<_Sort, Obj> = ListQueryOption<_Sort, Obj>, _DocObjectOfDoc = GetDocObject<Doc>, _MixedLibSrv = MergeAllTypes<LibSrvs, ServiceMixinOmitKey>> = {
6
+ type DatabaseQueryMethods<Query, Sort, Obj, Doc, Insight, FindQueryOption, ListQueryOption, DocQuery> = QueryMethodPart<Query, Sort, Obj, Doc, Insight, FindQueryOption, ListQueryOption, DocQuery>;
7
+ type DocumentLike = {
8
+ id: string;
9
+ set: (...args: never[]) => unknown;
10
+ save: (...args: never[]) => unknown;
11
+ };
12
+ type MixedLibServiceReturn<Value, Doc, DocObjectOfDoc> = Value extends (infer SingleValue)[] ? SingleValue extends DocumentLike ? DocObjectOfDoc extends GetDocObject<SingleValue> ? Doc[] : Value : Value : Value extends DocumentLike ? DocObjectOfDoc extends GetDocObject<Value> ? Doc : Value : Value;
13
+ type MixedLibServiceMethods<MixedLibSrv, Doc, DocObjectOfDoc> = {
14
+ [K in keyof MixedLibSrv]: MixedLibSrv[K] extends (...args: infer Args) => Promise<infer Value> ? (...args: Args) => Promise<MixedLibServiceReturn<Value, Doc, DocObjectOfDoc>> : MixedLibSrv[K];
15
+ };
16
+ export type DbRefName<Db extends DatabaseModel> = Db["refName"];
17
+ export type DbInput<Db extends DatabaseModel> = Db["_Input"];
18
+ export type DbDoc<Db extends DatabaseModel> = Db["_Doc"];
19
+ export type DbObj<Db extends DatabaseModel> = Db["_Obj"];
20
+ export type DbModel<Db extends DatabaseModel> = Db["_Model"];
21
+ export type DbInsight<Db extends DatabaseModel> = Db["_Insight"];
22
+ export type DbFilter<Db extends DatabaseModel> = Db["_Filter"];
23
+ export type DbQuery<Db extends DatabaseModel> = Db["_Query"];
24
+ export type DbSort<Db extends DatabaseModel> = Db["_Sort"];
25
+ export type DatabaseService<T extends string = string, Input = any, Doc = any, Obj = any, Model = any, Insight = any, Filter extends FilterInstance = FilterInstance, LibSrvs extends Cls[] = [], _Query = Filter extends FilterInstance ? any : never, _Sort = Filter extends FilterInstance ? any : never, _CapitalizedRefName extends Capitalize<T> = Capitalize<T>, _DataInputOfDoc extends DataInputOf<Input, Doc> = DataInputOf<Input, Doc>, _QueryOfDoc extends QueryOf<Doc> = QueryOf<Doc>, _FindQueryOption extends FindQueryOption<_Sort, Obj> = FindQueryOption<_Sort, Obj>, _ListQueryOption extends ListQueryOption<_Sort, Obj> = ListQueryOption<_Sort, Obj>, _DocObjectOfDoc = GetDocObject<Doc>, _MixedLibSrv = MergeAllTypes<LibSrvs, ServiceMixinOmitKey>> = {
7
26
  logger: Logger;
8
27
  __databaseModel: Model;
9
28
  __get: (id: string) => Promise<Doc>;
@@ -49,7 +68,6 @@ export type DatabaseService<T extends string = string, Input = any, Doc = any, O
49
68
  [K in `update${_CapitalizedRefName}`]: (id: string, data: Partial<Doc>) => Promise<Doc>;
50
69
  } & {
51
70
  [K in `remove${_CapitalizedRefName}`]: (id: string) => Promise<Doc>;
52
- } & QueryMethodPart<_Query, _Sort, Obj, Doc, Insight, _FindQueryOption, _ListQueryOption, _QueryOfDoc> & {
53
- [K in keyof _MixedLibSrv]: _MixedLibSrv[K] extends (...args: infer Args) => Promise<infer Value> ? Value extends (infer SingleValue)[] ? SingleValue extends DatabaseInstance ? _DocObjectOfDoc extends GetDocObject<SingleValue> ? (...args: Args) => Promise<Doc[]> : _MixedLibSrv[K] : _MixedLibSrv[K] : Value extends DbDoc<any> ? _DocObjectOfDoc extends GetDocObject<Value> ? (...args: Args) => Promise<Doc> : _MixedLibSrv[K] : _MixedLibSrv[K] : _MixedLibSrv[K];
54
- };
71
+ } & DatabaseQueryMethods<_Query, _Sort, Obj, Doc, Insight, _FindQueryOption, _ListQueryOption, _QueryOfDoc> & MixedLibServiceMethods<_MixedLibSrv, Doc, _DocObjectOfDoc>;
72
+ export type DatabaseServiceForModel<Db extends DatabaseModel, LibSrvs extends Cls[] = []> = DatabaseService<DbRefName<Db>, DbInput<Db>, DbDoc<Db>, DbObj<Db>, DbModel<Db>, DbInsight<Db>, DbFilter<Db>, LibSrvs, DbQuery<Db>, DbSort<Db>>;
55
73
  export {};
@@ -2,6 +2,7 @@ import type { Assign } from "akanjs/base";
2
2
  import { ENDPOINT_META } from "akanjs/base";
3
3
  import { type Adaptor, type AdaptorCls, type ServiceModel } from "akanjs/service";
4
4
  import { type EndpointBuilder, type EndpointInfo } from "./endpointInfo.d.ts";
5
+ import type { SrvRefName } from "./types.d.ts";
5
6
  export interface Endpoint extends Adaptor {
6
7
  }
7
8
  export interface EndpointCls<SrvModule extends ServiceModel = ServiceModel, EndpointInfoObj extends {
@@ -9,7 +10,7 @@ export interface EndpointCls<SrvModule extends ServiceModel = ServiceModel, Endp
9
10
  } = {
10
11
  [key: string]: EndpointInfo;
11
12
  }> extends AdaptorCls {
12
- baseName: SrvModule["srv"]["refName"];
13
+ baseName: SrvRefName<SrvModule>;
13
14
  srv: SrvModule;
14
15
  [ENDPOINT_META]: EndpointInfoObj;
15
16
  }
@@ -2,7 +2,7 @@ import { type Dayjs, type EnumInstance, type PromiseOrObject } from "akanjs/base
2
2
  import type { ConstantFieldType, ConstantFieldTypeInput, DocumentModel, FieldToValue, ParamFieldType, PlainTypeToFieldType, PurifiedModel } from "akanjs/constant";
3
3
  import type { ServiceModel } from "akanjs/service";
4
4
  import type { InternalArgCls } from "./internalArg.d.ts";
5
- import type { ArgType, SignalOption } from "./types.d.ts";
5
+ import type { ArgType, SignalOption, SrvMap } from "./types.d.ts";
6
6
  export type EndpointType = "query" | "mutation" | "pubsub" | "message";
7
7
  export interface EndpointArgProps<Optional extends boolean = false> {
8
8
  nullable?: Optional;
@@ -56,22 +56,47 @@ export declare class EndpointInfo<ReqType extends EndpointType = EndpointType, S
56
56
  getPath(key: string): string;
57
57
  }
58
58
  export type BuildEndpoint<SrvModule extends ServiceModel = ServiceModel> = {
59
- query: <Returns extends ConstantFieldTypeInput = ConstantFieldTypeInput, Nullable extends boolean = false>(returnRef: Returns, signalOption?: SignalOption<Returns, Nullable>) => EndpointInfo<"query", SrvModule["srvMap"], [], [], [], [], Returns, never, never, Nullable>;
60
- mutation: <Returns extends ConstantFieldTypeInput = ConstantFieldTypeInput, Nullable extends boolean = false>(returnRef: Returns, signalOption?: SignalOption<Returns, Nullable>) => EndpointInfo<"mutation", SrvModule["srvMap"], [], [], [], [], Returns, never, never, Nullable>;
61
- pubsub: <Returns extends ConstantFieldTypeInput = ConstantFieldTypeInput, Nullable extends boolean = false>(returnRef: Returns, signalOption?: SignalOption<Returns, Nullable>) => EndpointInfo<"pubsub", SrvModule["srvMap"], [], [], [], [], Returns, never, never, Nullable>;
62
- message: <Returns extends ConstantFieldTypeInput = ConstantFieldTypeInput, Nullable extends boolean = false>(returnRef: Returns, signalOption?: SignalOption<Returns, Nullable>) => EndpointInfo<"message", SrvModule["srvMap"], [], [], [], [], Returns, never, never, Nullable>;
59
+ query: <Returns extends ConstantFieldTypeInput = ConstantFieldTypeInput, Nullable extends boolean = false>(returnRef: Returns, signalOption?: SignalOption<Returns, Nullable>) => EndpointInfo<"query", SrvMap<SrvModule>, [], [], [], [], Returns, never, never, Nullable>;
60
+ mutation: <Returns extends ConstantFieldTypeInput = ConstantFieldTypeInput, Nullable extends boolean = false>(returnRef: Returns, signalOption?: SignalOption<Returns, Nullable>) => EndpointInfo<"mutation", SrvMap<SrvModule>, [], [], [], [], Returns, never, never, Nullable>;
61
+ pubsub: <Returns extends ConstantFieldTypeInput = ConstantFieldTypeInput, Nullable extends boolean = false>(returnRef: Returns, signalOption?: SignalOption<Returns, Nullable>) => EndpointInfo<"pubsub", SrvMap<SrvModule>, [], [], [], [], Returns, never, never, Nullable>;
62
+ message: <Returns extends ConstantFieldTypeInput = ConstantFieldTypeInput, Nullable extends boolean = false>(returnRef: Returns, signalOption?: SignalOption<Returns, Nullable>) => EndpointInfo<"message", SrvMap<SrvModule>, [], [], [], [], Returns, never, never, Nullable>;
63
63
  };
64
64
  export declare const buildEndpoint: BuildEndpoint<any>;
65
65
  export type EndpointBuilder<SrvModule extends ServiceModel = ServiceModel> = (builder: BuildEndpoint<SrvModule>) => {
66
66
  [key: string]: EndpointInfo;
67
67
  };
68
- export type EndpInfoReqType<E> = E extends EndpointInfo<infer T, any, any, any, any, any, any, any, any, any> ? T : never;
69
- export type EndpInfoSrvs<E> = E extends EndpointInfo<any, infer S, any, any, any, any, any, any, any, any> ? S : never;
70
- export type EndpInfoArgNames<E> = E extends EndpointInfo<any, any, infer N, any, any, any, any, any, any, any> ? N : never;
71
- export type EndpInfoArgs<E> = E extends EndpointInfo<any, any, any, infer A, any, any, any, any, any, any> ? A : never;
72
- export type EndpInfoInternalArgs<E> = E extends EndpointInfo<any, any, any, any, infer I, any, any, any, any, any> ? I : never;
73
- export type EndpInfoServerArgs<E> = E extends EndpointInfo<any, any, any, any, any, infer S, any, any, any, any> ? S : never;
74
- export type EndpInfoReturnRef<E> = E extends EndpointInfo<any, any, any, any, any, any, infer R, any, any, any> ? R : never;
75
- export type EndpInfoClientReturns<E> = E extends EndpointInfo<any, any, any, any, any, any, any, infer R, any, any> ? R : never;
76
- export type EndpInfoServerReturns<E> = E extends EndpointInfo<any, any, any, any, any, any, any, any, infer R, any> ? R : never;
77
- export type EndpInfoNullable<E> = E extends EndpointInfo<any, any, any, any, any, any, any, any, any, infer N> ? N : never;
68
+ type EndpointInfoEmptyParts = {
69
+ reqType: never;
70
+ srvs: never;
71
+ argNames: never;
72
+ args: never;
73
+ internalArgs: never;
74
+ serverArgs: never;
75
+ returnRef: never;
76
+ clientReturns: never;
77
+ serverReturns: never;
78
+ nullable: never;
79
+ };
80
+ export type EndpointInfoParts<E> = E extends EndpointInfo<infer ReqType, infer Srvs, infer ArgNames, infer Args, infer InternalArgs, infer ServerArgs, infer Returns, infer ClientReturns, infer ServerReturns, infer Nullable> ? {
81
+ reqType: ReqType;
82
+ srvs: Srvs;
83
+ argNames: ArgNames;
84
+ args: Args;
85
+ internalArgs: InternalArgs;
86
+ serverArgs: ServerArgs;
87
+ returnRef: Returns;
88
+ clientReturns: ClientReturns;
89
+ serverReturns: ServerReturns;
90
+ nullable: Nullable;
91
+ } : EndpointInfoEmptyParts;
92
+ export type EndpInfoReqType<E> = EndpointInfoParts<E>["reqType"];
93
+ export type EndpInfoSrvs<E> = EndpointInfoParts<E>["srvs"];
94
+ export type EndpInfoArgNames<E> = EndpointInfoParts<E>["argNames"];
95
+ export type EndpInfoArgs<E> = EndpointInfoParts<E>["args"];
96
+ export type EndpInfoInternalArgs<E> = EndpointInfoParts<E>["internalArgs"];
97
+ export type EndpInfoServerArgs<E> = EndpointInfoParts<E>["serverArgs"];
98
+ export type EndpInfoReturnRef<E> = EndpointInfoParts<E>["returnRef"];
99
+ export type EndpInfoClientReturns<E> = EndpointInfoParts<E>["clientReturns"];
100
+ export type EndpInfoServerReturns<E> = EndpointInfoParts<E>["serverReturns"];
101
+ export type EndpInfoNullable<E> = EndpointInfoParts<E>["nullable"];
102
+ export {};
@@ -1,6 +1,7 @@
1
1
  import { INTERNAL_META, type MergeAllKeyOfObjects } from "akanjs/base";
2
2
  import { type Adaptor, type AdaptorCls, type QueueAdaptor, type ScheduleAdaptor, type ServiceModel } from "akanjs/service";
3
3
  import { type BuildInternal, type InternalBuilder, type InternalInfo } from "./internalInfo.d.ts";
4
+ import type { SrvRefName } from "./types.d.ts";
4
5
  export interface Internal extends Adaptor {
5
6
  schedule: ScheduleAdaptor;
6
7
  queue: QueueAdaptor;
@@ -10,7 +11,7 @@ export type InternalCls<SrvModule extends ServiceModel = ServiceModel, InternalI
10
11
  } = {
11
12
  [key: string]: InternalInfo;
12
13
  }> = AdaptorCls & {
13
- refName: SrvModule["srv"]["refName"];
14
+ refName: SrvRefName<SrvModule>;
14
15
  srv: SrvModule;
15
16
  [INTERNAL_META]: InternalInfoMap;
16
17
  };
@@ -3,7 +3,7 @@ import type { ConstantCls, ConstantField, ConstantFieldTypeInput, DocumentModel,
3
3
  import type { AkanJob, ServiceModel } from "akanjs/service";
4
4
  import { type ArgInfo, type InternalArgInfo, type ReturnInfo } from "./endpointInfo.d.ts";
5
5
  import type { InternalArgCls } from "./internalArg.d.ts";
6
- import type { SignalOption } from "./types.d.ts";
6
+ import type { CnstOf, DbDoc, SignalOption, SrvMap } from "./types.d.ts";
7
7
  type InternalType = "resolveField" | "interval" | "cron" | "timeout" | "init" | "destroy" | "process";
8
8
  interface InternalArgProps<Nullable extends boolean = false> {
9
9
  nullable?: Nullable;
@@ -25,21 +25,55 @@ export declare class InternalInfo<ReqType extends InternalType = InternalType, S
25
25
  with<ArgType, Optional extends boolean = false>(argRef: InternalArgCls<ArgType>, option?: InternalArgProps<Optional>): InternalInfo<ReqType, Srvs, Args, [...InternalArgs, arg: NonNullable<ArgType> | (Optional extends true ? null : ReqType extends "resolveField" ? null : never)], DefaultArgs, Returns, ServerReturns, Nullable>;
26
26
  exec<ExecReturn extends ReqType extends "process" | "resolveField" ? PromiseOrObject<DocumentModel<FieldToValue<Returns>> | (Nullable extends true ? null : never)> : PromiseOrObject<void>>(execFn: (this: Srvs, ...args: [...Args, ...DefaultArgs, ...InternalArgs]) => ExecReturn): InternalInfo<ReqType, Srvs, Args, InternalArgs, DefaultArgs, Returns, ExecReturn, Nullable>;
27
27
  }
28
- export type BuildInternal<SrvModule extends ServiceModel, ParentDoc = SrvModule["db"]["_Doc"]> = {
29
- resolveField: <Returns extends ConstantFieldTypeInput, Nullable extends boolean = false>(returnRef: Returns, signalOption?: Pick<SignalOption<Returns, Nullable>, "nullable">) => InternalInfo<"resolveField", SrvModule["srvMap"], [], [], [ParentDoc], Returns, never, Nullable>;
30
- interval: <Nullable extends boolean = false>(scheduleTime: number, signalOption?: SignalOption<typeof Any, Nullable>) => InternalInfo<"interval", SrvModule["srvMap"], [], [], [], typeof Any, never, Nullable>;
31
- cron: <Nullable extends boolean = false>(scheduleCron: string, signalOption?: SignalOption<typeof Any, Nullable>) => InternalInfo<"cron", SrvModule["srvMap"], [], [], [], typeof Any, never, Nullable>;
32
- timeout: <Nullable extends boolean = false>(timeout: number, signalOption?: SignalOption<typeof Any, Nullable>) => InternalInfo<"timeout", SrvModule["srvMap"], [], [], [], typeof Any, never, Nullable>;
33
- initialize: <Nullable extends boolean = false>(signalOption?: SignalOption<typeof Any, Nullable>) => InternalInfo<"init", SrvModule["srvMap"], [], [], [], typeof Any, never, Nullable>;
34
- destroy: <Nullable extends boolean = false>(signalOption?: SignalOption<typeof Any, Nullable>) => InternalInfo<"destroy", SrvModule["srvMap"], [], [], [], typeof Any, never, Nullable>;
35
- process: <Returns extends ConstantFieldTypeInput, Nullable extends boolean = false>(returnRef: Returns, signalOption?: SignalOption<Returns, Nullable>) => InternalInfo<"process", SrvModule["srvMap"], [], [], [AkanJob], Returns, never, Nullable>;
28
+ type InternalInfoEmptyParts = {
29
+ reqType: never;
30
+ srvs: never;
31
+ args: never;
32
+ internalArgs: never;
33
+ defaultArgs: never;
34
+ returns: never;
35
+ serverReturns: never;
36
+ nullable: never;
36
37
  };
37
- export type InternalBuilder<SrvModule extends ServiceModel, _FullCls extends ConstantCls = SrvModule["cnst"]["full"], _FieldObj extends FieldObject = _FullCls[typeof FIELD_META], _ResolveFieldObj extends FieldObject = {
38
+ export type InternalInfoParts<I> = I extends InternalInfo<infer ReqType, infer Srvs, infer Args, infer InternalArgs, infer DefaultArgs, infer Returns, infer ServerReturns, infer Nullable> ? {
39
+ reqType: ReqType;
40
+ srvs: Srvs;
41
+ args: Args;
42
+ internalArgs: InternalArgs;
43
+ defaultArgs: DefaultArgs;
44
+ returns: Returns;
45
+ serverReturns: ServerReturns;
46
+ nullable: Nullable;
47
+ } : InternalInfoEmptyParts;
48
+ export type InternalInfoReqType<I> = InternalInfoParts<I>["reqType"];
49
+ export type InternalInfoSrvs<I> = InternalInfoParts<I>["srvs"];
50
+ export type InternalInfoServerArgs<I> = InternalInfoParts<I>["args"];
51
+ export type InternalInfoInternalArgs<I> = InternalInfoParts<I>["internalArgs"];
52
+ export type InternalInfoDefaultArgs<I> = InternalInfoParts<I>["defaultArgs"];
53
+ export type InternalInfoReturns<I> = InternalInfoParts<I>["returns"];
54
+ export type InternalInfoServerReturns<I> = InternalInfoParts<I>["serverReturns"];
55
+ export type InternalInfoNullable<I> = InternalInfoParts<I>["nullable"];
56
+ export type BuildInternal<SrvModule extends ServiceModel, ParentDoc = DbDoc<SrvModule>> = {
57
+ resolveField: <Returns extends ConstantFieldTypeInput, Nullable extends boolean = false>(returnRef: Returns, signalOption?: Pick<SignalOption<Returns, Nullable>, "nullable">) => InternalInfo<"resolveField", SrvMap<SrvModule>, [], [], [ParentDoc], Returns, never, Nullable>;
58
+ interval: <Nullable extends boolean = false>(scheduleTime: number, signalOption?: SignalOption<typeof Any, Nullable>) => InternalInfo<"interval", SrvMap<SrvModule>, [], [], [], typeof Any, never, Nullable>;
59
+ cron: <Nullable extends boolean = false>(scheduleCron: string, signalOption?: SignalOption<typeof Any, Nullable>) => InternalInfo<"cron", SrvMap<SrvModule>, [], [], [], typeof Any, never, Nullable>;
60
+ timeout: <Nullable extends boolean = false>(timeout: number, signalOption?: SignalOption<typeof Any, Nullable>) => InternalInfo<"timeout", SrvMap<SrvModule>, [], [], [], typeof Any, never, Nullable>;
61
+ initialize: <Nullable extends boolean = false>(signalOption?: SignalOption<typeof Any, Nullable>) => InternalInfo<"init", SrvMap<SrvModule>, [], [], [], typeof Any, never, Nullable>;
62
+ destroy: <Nullable extends boolean = false>(signalOption?: SignalOption<typeof Any, Nullable>) => InternalInfo<"destroy", SrvMap<SrvModule>, [], [], [], typeof Any, never, Nullable>;
63
+ process: <Returns extends ConstantFieldTypeInput, Nullable extends boolean = false>(returnRef: Returns, signalOption?: SignalOption<Returns, Nullable>) => InternalInfo<"process", SrvMap<SrvModule>, [], [], [AkanJob], Returns, never, Nullable>;
64
+ };
65
+ export type InternalBuilder<SrvModule extends ServiceModel, _Cnst = CnstOf<SrvModule>, _FullCls extends ConstantCls = [_Cnst] extends [never] ? never : _Cnst extends {
66
+ full: infer Full extends ConstantCls;
67
+ } ? Full : never, _FieldObj extends FieldObject = _FullCls[typeof FIELD_META], _ResolveFieldObj extends FieldObject = {
38
68
  [K in keyof _FieldObj as _FieldObj[K] extends ConstantField<"resolve", any, any, any, any, any> ? K : never]: _FieldObj[K];
39
- }> = (builder: BuildInternal<SrvModule>) => SrvModule["cnst"] extends never ? {
40
- [key: string]: InternalInfo<Exclude<InternalType, "resolveField">>;
69
+ }> = (builder: BuildInternal<SrvModule>) => [_Cnst] extends [never] ? {
70
+ [key: string]: InternalInfo<InternalType>;
71
+ } : [_FullCls] extends [never] ? {
72
+ [key: string]: InternalInfo<InternalType>;
41
73
  } : {
42
74
  [K in keyof _ResolveFieldObj]: _ResolveFieldObj[K] extends ConstantField<"resolve", infer Value, any, any, infer Nullable> ? InternalInfo<"resolveField", any, any, any, any, NonNullable<Value>, Nullable> : InternalInfo<Exclude<InternalType, "resolveField">>;
75
+ } & {
76
+ [key: string]: InternalInfo<InternalType>;
43
77
  };
44
78
  export declare const buildInternal: BuildInternal<any, any>;
45
79
  export {};
@@ -2,23 +2,24 @@ import { ENDPOINT_META, INJECT_META, INTERNAL_META } from "akanjs/base";
2
2
  import type { DocumentModel } from "akanjs/constant";
3
3
  import { type Adaptor, type AdaptorCls, type AkanJob, type AkanJobOptions, type QueueAdaptor } from "akanjs/service";
4
4
  import type { ServerWebSocket } from "bun";
5
- import type { EndpointInfo } from "./endpointInfo.d.ts";
6
- import type { InternalInfo } from "./internalInfo.d.ts";
5
+ import type { EndpInfoClientReturns, EndpInfoReqType, EndpInfoServerArgs, EndpointInfo } from "./endpointInfo.d.ts";
6
+ import type { InternalInfo, InternalInfoReqType, InternalInfoServerArgs } from "./internalInfo.d.ts";
7
+ type EndpointPubsubPayload<E> = EndpInfoClientReturns<E> | DocumentModel<EndpInfoClientReturns<E>>;
7
8
  export interface ServerSignal extends Adaptor {
8
9
  readonly websocket: ServerWebSocket;
9
10
  readonly queue: QueueAdaptor;
10
11
  }
11
- type EndpointServerSignalMethods<EnpCls> = EnpCls extends {
12
+ type EndpointServerSignalMethods<EnpCls> = [EnpCls] extends [{
12
13
  [ENDPOINT_META]: infer EndpointInfoObj;
13
- } ? {
14
- [K in keyof EndpointInfoObj as EndpointInfoObj[K] extends EndpointInfo<"pubsub", any, any, any, any, any, any, any, any> ? K : never]: EndpointInfoObj[K] extends EndpointInfo<any, any, any, any, any, infer ServerArgs, any, infer ClientReturns, any, any> ? (...args: [...ServerArgs, data: DocumentModel<ClientReturns>]) => void : never;
15
- } : never;
16
- type InternalServerSignalMethods<IntCls> = IntCls extends {
14
+ }] ? {
15
+ [K in keyof EndpointInfoObj as EndpInfoReqType<EndpointInfoObj[K]> extends "pubsub" ? K : never]: (...args: [...EndpInfoServerArgs<EndpointInfoObj[K]>, data: EndpointPubsubPayload<EndpointInfoObj[K]>]) => void;
16
+ } : Record<never, never>;
17
+ type InternalServerSignalMethods<IntCls> = [IntCls] extends [{
17
18
  [INTERNAL_META]: infer InternalInfoObj;
18
- } ? {
19
- [K in keyof InternalInfoObj as InternalInfoObj[K] extends InternalInfo<"process", any, any, any, any, any, any, any> ? K : never]: InternalInfoObj[K] extends InternalInfo<any, any, infer ServerArgs, any, any, any, infer ServerReturns> ? (...args: [...args: ServerArgs, jobOptions?: AkanJobOptions]) => Promise<AkanJob<any, ServerReturns>> : never;
20
- } : never;
21
- type ServerSignalClsStatics = {
19
+ }] ? {
20
+ [K in keyof InternalInfoObj as InternalInfoReqType<InternalInfoObj[K]> extends "process" ? K : never]: (...args: [...args: InternalInfoServerArgs<InternalInfoObj[K]>, jobOptions?: AkanJobOptions]) => Promise<AkanJob<unknown, unknown>>;
21
+ } : Record<never, never>;
22
+ export type ServerSignalClsStatics = {
22
23
  readonly refName: string;
23
24
  readonly [INJECT_META]: {
24
25
  queue: QueueAdaptor;
@@ -30,7 +31,9 @@ type ServerSignalClsStatics = {
30
31
  [key: string]: InternalInfo;
31
32
  };
32
33
  };
33
- export type ServerSignalCls<EnpCls = any, IntCls = any> = AdaptorCls<EndpointServerSignalMethods<EnpCls> & InternalServerSignalMethods<IntCls> & ServerSignal> & ServerSignalClsStatics;
34
+ export type ServerSignalMethods<EnpCls, IntCls> = EndpointServerSignalMethods<EnpCls> & InternalServerSignalMethods<IntCls>;
35
+ export type TypedServerSignalCls<EnpCls, IntCls> = AdaptorCls<ServerSignalMethods<EnpCls, IntCls> & ServerSignal> & ServerSignalClsStatics;
36
+ export type ServerSignalCls<EnpCls = unknown, IntCls = unknown> = AdaptorCls<ServerSignalMethods<EnpCls, IntCls> & ServerSignal> & ServerSignalClsStatics;
34
37
  /** Composes endpoint and internal classes into a server-side signal class. */
35
38
  export declare const serverSignal: <EnpCls, IntCls>(endpointRef: EnpCls, internalRef: IntCls) => ServerSignalCls<EnpCls, IntCls>;
36
39
  export {};
@@ -3,7 +3,8 @@ import type { DocumentModel, QueryOf } from "akanjs/constant";
3
3
  import type { FilterInstance } from "akanjs/document";
4
4
  import { type Adaptor, type AdaptorCls, type ServiceModel } from "akanjs/service";
5
5
  import type { Guard, GuardCls } from "./guard.d.ts";
6
- import { type SliceBuilder, type SliceInfo } from "./sliceInfo.d.ts";
6
+ import { type SliceBuilder, type SliceInfo, type SliceInfoArgNames, type SliceInfoArgs, type SliceInfoInternalArgs, type SliceInfoServerArgs, type SliceInfoSrvs } from "./sliceInfo.d.ts";
7
+ import type { CnstFull, CnstInput, CnstInsight, CnstLight, DbFilter, SrvMap, SrvRefName } from "./types.d.ts";
7
8
  export interface Slice extends Adaptor {
8
9
  }
9
10
  export type SliceCls<SrvModule extends ServiceModel = ServiceModel, SliceInfoObj extends {
@@ -11,7 +12,7 @@ export type SliceCls<SrvModule extends ServiceModel = ServiceModel, SliceInfoObj
11
12
  } = {
12
13
  [key: string]: SliceInfo;
13
14
  }> = AdaptorCls & {
14
- baseName: SrvModule["srv"]["refName"];
15
+ baseName: SrvRefName<SrvModule>;
15
16
  srv: SrvModule;
16
17
  [SLICE_META]: SliceInfoObj;
17
18
  getGuards: GuardCls[];
@@ -25,12 +26,13 @@ interface RootSliceOption {
25
26
  };
26
27
  prefix?: string;
27
28
  }
28
- type ExtendSliceInfoObj<SrvModule extends ServiceModel, LibSlices extends SliceCls[], _Input = NonNullable<SrvModule["cnst"]>["_Input"], _Full = NonNullable<SrvModule["cnst"]>["_Full"], _Light = NonNullable<SrvModule["cnst"]>["_Light"], _Insight = NonNullable<SrvModule["cnst"]>["_Insight"], _Filter extends FilterInstance = any, _Merged = MergeAllKeyOfObjects<LibSlices, typeof SLICE_META>> = {
29
- [K in keyof _Merged]: _Merged[K] extends SliceInfo<any, any, any, any, any, any, infer Srvs, infer ArgNames, infer Args, infer InternalArgs, infer ServerArgs> ? SliceInfo<SrvModule["srv"]["refName"], _Input, _Full, _Light, _Insight, _Filter, Srvs, ArgNames, Args, InternalArgs, ServerArgs> : never;
29
+ type RootSliceQuery<SrvModule extends ServiceModel, Full = CnstFull<SrvModule>> = QueryOf<DocumentModel<Full>>;
30
+ type ExtendSliceInfoObj<SrvModule extends ServiceModel, LibSlices extends SliceCls[], _Input = CnstInput<SrvModule>, _Full = CnstFull<SrvModule>, _Light = CnstLight<SrvModule>, _Insight = CnstInsight<SrvModule>, _Filter extends FilterInstance = DbFilter<SrvModule>, _Merged = MergeAllKeyOfObjects<LibSlices, typeof SLICE_META>> = {
31
+ [K in keyof _Merged]: _Merged[K] extends SliceInfo ? SliceInfo<SrvRefName<SrvModule>, _Input, _Full, _Light, _Insight, _Filter, SliceInfoSrvs<_Merged[K]>, SliceInfoArgNames<_Merged[K]>, SliceInfoArgs<_Merged[K]>, SliceInfoInternalArgs<_Merged[K]>, SliceInfoServerArgs<_Merged[K]>> : never;
30
32
  };
31
33
  /** Builds database-backed slice APIs for list, insight, init, view, edit, create, update, and remove flows. */
32
- export declare function slice<SrvModule extends ServiceModel, BuildSlice extends SliceBuilder<SrvModule>, LibSlices extends SliceCls[], _Input = NonNullable<SrvModule["cnst"]>["_Input"], _Full = NonNullable<SrvModule["cnst"]>["_Full"], _Light = NonNullable<SrvModule["cnst"]>["_Light"], _Insight = NonNullable<SrvModule["cnst"]>["_Insight"], _Filter extends FilterInstance = NonNullable<SrvModule["db"]>["_Filter"], _Query = QueryOf<DocumentModel<_Full>>>(srv: SrvModule, option: RootSliceOption, sliceBuilder: BuildSlice, ...libSlices: LibSlices): SliceCls<SrvModule, Assign<ReturnType<BuildSlice>, LibSlices extends [] ? {
33
- [""]: SliceInfo<SrvModule["srv"]["refName"], _Input, _Full, _Light, _Insight, _Filter, SrvModule["srvMap"], [
34
+ export declare function slice<SrvModule extends ServiceModel, BuildSlice extends SliceBuilder<SrvModule>, LibSlices extends SliceCls[], _Input = CnstInput<SrvModule>, _Full = CnstFull<SrvModule>, _Light = CnstLight<SrvModule>, _Insight = CnstInsight<SrvModule>, _Filter extends FilterInstance = DbFilter<SrvModule>, _Query = RootSliceQuery<SrvModule, _Full>>(srv: SrvModule, option: RootSliceOption, sliceBuilder: BuildSlice, ...libSlices: LibSlices): SliceCls<SrvModule, Assign<ReturnType<BuildSlice>, LibSlices extends [] ? {
35
+ [""]: SliceInfo<SrvRefName<SrvModule>, _Input, _Full, _Light, _Insight, _Filter, SrvMap<SrvModule>, [
34
36
  "query"
35
37
  ], [
36
38
  _Query
@@ -1,10 +1,10 @@
1
1
  import type { Cls, PromiseOrObject } from "akanjs/base";
2
2
  import type { BaseInsight, BaseObject, ConstantFieldTypeInput, DocumentModel, FieldToValue, ParamFieldType, PlainTypeToFieldType, PurifiedModel, QueryOf } from "akanjs/constant";
3
- import type { ExtractSort, FilterCls, FilterInstance } from "akanjs/document";
3
+ import type { FilterCls, FilterInstance } from "akanjs/document";
4
4
  import type { ServiceModel } from "akanjs/service";
5
5
  import { type ArgInfo, type EndpointArgProps, type InternalArgInfo, type InternalArgProps } from "./endpointInfo.d.ts";
6
6
  import type { InternalArgCls } from "./internalArg.d.ts";
7
- import type { SignalOption } from "./types.d.ts";
7
+ import type { CnstFull, CnstInput, CnstInsight, CnstLight, DbFilter, SignalOption, SrvMap, SrvRefName } from "./types.d.ts";
8
8
  export declare class SliceInfo<RefName extends string = string, Input = any, Full = any, Light = any, Insight = any, Filter extends FilterInstance = any, Srvs extends {
9
9
  [key: string]: any;
10
10
  } = {
@@ -30,22 +30,43 @@ export declare class SliceInfo<RefName extends string = string, Input = any, Ful
30
30
  [K in keyof Srvs as K extends string ? Uncapitalize<K> : never]: Srvs[K];
31
31
  }, ...args: [...ServerArgs, ...InternalArgs]) => PromiseOrObject<QueryOf<DocumentModel<Full>>>): this;
32
32
  }
33
- export declare const buildSlice: <T extends string, Input extends Cls<any>, Full extends BaseObject, Light extends BaseObject, Insight extends BaseInsight, Filter extends FilterInstance, SrvModule extends ServiceModel>(refName: T, input: Cls<Input>, full: Cls<Full>, light: Cls<Light>, insight: Cls<Insight>, filter: FilterCls<Filter>) => (signalOption?: SignalOption) => SliceInfo<T, Input, Full, Light, Insight, Filter, SrvModule["srvMap"], [], [], [], []>;
34
- export type SliceInfoRefName<S> = S extends SliceInfo<infer R, any, any, any, any, any, any, any, any, any, any> ? R : never;
35
- export type SliceInfoInput<S> = S extends SliceInfo<any, infer I, any, any, any, any, any, any, any, any, any> ? I : never;
36
- export type SliceInfoFull<S> = S extends SliceInfo<any, any, infer F, any, any, any, any, any, any, any, any> ? F : never;
37
- export type SliceInfoLight<S> = S extends SliceInfo<any, any, any, infer L, any, any, any, any, any, any, any> ? L : never;
38
- export type SliceInfoInsight<S> = S extends SliceInfo<any, any, any, any, infer I, any, any, any, any, any, any> ? I : never;
39
- export type SliceInfoFilter<S> = S extends SliceInfo<any, any, any, any, any, infer F, any, any, any, any, any> ? F : never;
40
- export type SliceInfoSrvs<S> = S extends SliceInfo<any, any, any, any, any, any, infer S2, any, any, any, any> ? S2 : never;
41
- export type SliceInfoArgNames<S> = S extends SliceInfo<any, any, any, any, any, any, any, infer N, any, any, any> ? N : never;
42
- export type SliceInfoArgs<S> = S extends SliceInfo<any, any, any, any, any, any, any, any, infer A, any, any> ? A : never;
43
- export type SliceInfoInternalArgs<S> = S extends SliceInfo<any, any, any, any, any, any, any, any, any, infer I, any> ? I : never;
44
- export type SliceInfoServerArgs<S> = S extends SliceInfo<any, any, any, any, any, any, any, any, any, any, infer S2> ? S2 : never;
45
- export type SliceBuilder<SrvModule extends ServiceModel, _Input = NonNullable<SrvModule["cnst"]>["_Input"], _Full = NonNullable<SrvModule["cnst"]>["_Full"], _Light = NonNullable<SrvModule["cnst"]>["_Light"], _Insight = NonNullable<SrvModule["cnst"]>["_Insight"], _Filter extends FilterInstance = NonNullable<SrvModule["db"]>["_Filter"], _Sort = ExtractSort<_Filter>> = (init: (signalOption?: SignalOption) => SliceInfo<SrvModule["srv"]["refName"], _Input, _Full, _Light, _Insight, _Filter, SrvModule["srvMap"], [
46
- ], [
47
- ], [
48
- ], [
49
- ]>) => {
50
- [key: string]: SliceInfo<SrvModule["srv"]["refName"], _Input, _Full, _Light, _Insight, _Filter, SrvModule["srvMap"]>;
33
+ export declare const buildSlice: <T extends string, Input extends Cls<any>, Full extends BaseObject, Light extends BaseObject, Insight extends BaseInsight, Filter extends FilterInstance, SrvModule extends ServiceModel>(refName: T, input: Cls<Input>, full: Cls<Full>, light: Cls<Light>, insight: Cls<Insight>, filter: FilterCls<Filter>) => (signalOption?: SignalOption) => SliceInfo<T, Input, Full, Light, Insight, Filter, SrvMap<SrvModule>, [], [], [], []>;
34
+ type SliceInfoEmptyParts = {
35
+ refName: never;
36
+ input: never;
37
+ full: never;
38
+ light: never;
39
+ insight: never;
40
+ filter: never;
41
+ srvs: never;
42
+ argNames: never;
43
+ args: never;
44
+ internalArgs: never;
45
+ serverArgs: never;
51
46
  };
47
+ export type SliceInfoParts<S> = S extends SliceInfo<infer RefName, infer Input, infer Full, infer Light, infer Insight, infer Filter, infer Srvs, infer ArgNames, infer Args, infer InternalArgs, infer ServerArgs> ? {
48
+ refName: RefName;
49
+ input: Input;
50
+ full: Full;
51
+ light: Light;
52
+ insight: Insight;
53
+ filter: Filter;
54
+ srvs: Srvs;
55
+ argNames: ArgNames;
56
+ args: Args;
57
+ internalArgs: InternalArgs;
58
+ serverArgs: ServerArgs;
59
+ } : SliceInfoEmptyParts;
60
+ export type SliceInfoRefName<S> = SliceInfoParts<S>["refName"];
61
+ export type SliceInfoInput<S> = SliceInfoParts<S>["input"];
62
+ export type SliceInfoFull<S> = SliceInfoParts<S>["full"];
63
+ export type SliceInfoLight<S> = SliceInfoParts<S>["light"];
64
+ export type SliceInfoInsight<S> = SliceInfoParts<S>["insight"];
65
+ export type SliceInfoFilter<S> = SliceInfoParts<S>["filter"];
66
+ export type SliceInfoSrvs<S> = SliceInfoParts<S>["srvs"];
67
+ export type SliceInfoArgNames<S> = SliceInfoParts<S>["argNames"];
68
+ export type SliceInfoArgs<S> = SliceInfoParts<S>["args"];
69
+ export type SliceInfoInternalArgs<S> = SliceInfoParts<S>["internalArgs"];
70
+ export type SliceInfoServerArgs<S> = SliceInfoParts<S>["serverArgs"];
71
+ export type SliceBuilder<SrvModule extends ServiceModel, _Input = CnstInput<SrvModule>, _Full = CnstFull<SrvModule>, _Light = CnstLight<SrvModule>, _Insight = CnstInsight<SrvModule>, _Filter extends FilterInstance = DbFilter<SrvModule>, _SliceInfo = SliceInfo<SrvRefName<SrvModule>, _Input, _Full, _Light, _Insight, _Filter, SrvMap<SrvModule>>> = (init: (signalOption?: SignalOption) => SliceInfo<SrvRefName<SrvModule>, _Input, _Full, _Light, _Insight, _Filter, SrvMap<SrvModule>, [], [], [], []>) => Record<string, _SliceInfo>;
72
+ export {};
@@ -5,11 +5,14 @@ import type { MiddlewareCls } from "./middleware.d.ts";
5
5
  import type { SliceCls } from "./slice.d.ts";
6
6
  export type CnstOf<S extends ServiceModel> = NonNullable<S["cnst"]>;
7
7
  export type DbOf<S extends ServiceModel> = NonNullable<S["db"]>;
8
+ export type SrvOf<S extends ServiceModel> = S["srv"];
9
+ export type SrvRefName<S extends ServiceModel> = SrvOf<S>["refName"];
10
+ export type SrvMap<S extends ServiceModel> = S["srvMap"];
8
11
  export type CnstRefName<S extends ServiceModel> = CnstOf<S>["refName"];
9
12
  export type CnstInput<S extends ServiceModel> = CnstOf<S>["_Input"];
10
- export type CnstFull<S extends ServiceModel> = CnstOf<S>["_Full"];
11
- export type CnstLight<S extends ServiceModel> = CnstOf<S>["_Light"];
12
- export type CnstInsight<S extends ServiceModel> = CnstOf<S>["_Insight"];
13
+ export type CnstFull<S extends ServiceModel> = UnCls<CnstOf<S>["full"]> & CnstOf<S>["_Full"];
14
+ export type CnstLight<S extends ServiceModel> = UnCls<CnstOf<S>["light"]> & CnstOf<S>["_Light"];
15
+ export type CnstInsight<S extends ServiceModel> = UnCls<CnstOf<S>["insight"]> & CnstOf<S>["_Insight"];
13
16
  export type CnstDefault<S extends ServiceModel> = CnstOf<S>["_Default"];
14
17
  export type CnstDefaultInput<S extends ServiceModel> = CnstOf<S>["_DefaultInput"];
15
18
  export type CnstDefaultState<S extends ServiceModel> = CnstOf<S>["_DefaultState"];
@@ -18,22 +21,25 @@ export type CnstStateInsight<S extends ServiceModel> = CnstOf<S>["_StateInsight"
18
21
  export type CnstPurifiedInput<S extends ServiceModel> = CnstOf<S>["_PurifiedInput"];
19
22
  export type CnstCapitalizedRefName<S extends ServiceModel> = CnstOf<S>["_CapitalizedRefName"];
20
23
  export type DbFilter<S extends ServiceModel> = DbOf<S>["_Filter"];
24
+ export type DbDoc<S extends ServiceModel> = DbOf<S>["_Doc"];
25
+ export type DbQuery<S extends ServiceModel> = DbOf<S>["_Query"];
21
26
  export type DbSort<S extends ServiceModel> = DbOf<S>["_Sort"];
22
27
  export type SlceSrv<S extends SliceCls> = S["srv"];
23
- export type SlceCnstRefName<S extends SliceCls> = S["srv"]["cnst"]["refName"];
24
- export type SlceCnstInput<S extends SliceCls> = S["srv"]["cnst"]["_Input"];
25
- export type SlceCnstFull<S extends SliceCls> = S["srv"]["cnst"]["_Full"];
26
- export type SlceCnstLight<S extends SliceCls> = S["srv"]["cnst"]["_Light"];
27
- export type SlceCnstInsight<S extends SliceCls> = S["srv"]["cnst"]["_Insight"];
28
- export type SlceCnstDefault<S extends SliceCls> = S["srv"]["cnst"]["_Default"];
29
- export type SlceCnstDefaultInput<S extends SliceCls> = S["srv"]["cnst"]["_DefaultInput"];
30
- export type SlceCnstDefaultState<S extends SliceCls> = S["srv"]["cnst"]["_DefaultState"];
31
- export type SlceCnstPurifiedInput<S extends SliceCls> = S["srv"]["cnst"]["_PurifiedInput"];
32
- export type SlceCnstCapitalizedRefName<S extends SliceCls> = S["srv"]["cnst"]["_CapitalizedRefName"];
33
- export type SlceCnstStateLight<S extends SliceCls> = S["srv"]["cnst"]["_StateLight"];
34
- export type SlceCnstStateInsight<S extends SliceCls> = S["srv"]["cnst"]["_StateInsight"];
35
- export type SlceDbFilter<S extends SliceCls> = S["srv"]["db"]["_Filter"];
36
- export type SlceDbSort<S extends SliceCls> = S["srv"]["db"]["_Sort"];
28
+ export type SlceCnstRefName<S extends SliceCls> = CnstRefName<SlceSrv<S>>;
29
+ export type SlceCnstInput<S extends SliceCls> = CnstInput<SlceSrv<S>>;
30
+ export type SlceCnstFull<S extends SliceCls> = CnstFull<SlceSrv<S>>;
31
+ export type SlceCnstLight<S extends SliceCls> = CnstLight<SlceSrv<S>>;
32
+ export type SlceCnstInsight<S extends SliceCls> = CnstInsight<SlceSrv<S>>;
33
+ export type SlceCnstDefault<S extends SliceCls> = CnstDefault<SlceSrv<S>>;
34
+ export type SlceCnstDefaultInput<S extends SliceCls> = CnstDefaultInput<SlceSrv<S>>;
35
+ export type SlceCnstDefaultState<S extends SliceCls> = CnstDefaultState<SlceSrv<S>>;
36
+ export type SlceCnstPurifiedInput<S extends SliceCls> = CnstPurifiedInput<SlceSrv<S>>;
37
+ export type SlceCnstCapitalizedRefName<S extends SliceCls> = CnstCapitalizedRefName<SlceSrv<S>>;
38
+ export type SlceCnstStateLight<S extends SliceCls> = CnstStateLight<SlceSrv<S>>;
39
+ export type SlceCnstStateInsight<S extends SliceCls> = CnstStateInsight<SlceSrv<S>>;
40
+ export type SlceDbFilter<S extends SliceCls> = DbFilter<SlceSrv<S>>;
41
+ export type SlceDbQuery<S extends SliceCls> = DbQuery<SlceSrv<S>>;
42
+ export type SlceDbSort<S extends SliceCls> = DbSort<SlceSrv<S>>;
37
43
  export declare const argTypes: readonly ["body", "param", "search", "upload", "msg", "room"];
38
44
  export type ArgType = (typeof argTypes)[number];
39
45
  interface InitOption {
@@ -1,10 +1,20 @@
1
- import { type GetStateObject, type SLICE_META } from "akanjs/base";
1
+ import { type GetStateObject } from "akanjs/base";
2
2
  import { type FetchPolicy } from "akanjs/common";
3
3
  import { type DefaultOf, type FieldState, type ProtoFile } from "akanjs/constant";
4
4
  import type { ExtractSort, FilterInstance } from "akanjs/document";
5
5
  import type { FetchInitForm, FetchProxy } from "akanjs/fetch";
6
- import type { SerializedSlice, SliceCls, SliceInfoArgs } from "akanjs/signal";
7
- import type { SetGet } from "./types.d.ts";
6
+ import type { SerializedSlice, SlceCnstCapitalizedRefName, SlceCnstDefault, SlceCnstDefaultInput, SlceCnstFull, SlceCnstInput, SlceCnstLight, SlceCnstRefName, SlceDbFilter, SlceDbSort, SliceCls } from "akanjs/signal";
7
+ import type { SetGet, StoreSliceArgs, StoreSliceMap, StoreSliceSuffixCap } from "./types.d.ts";
8
+ type _SliceMap<S extends SliceCls> = StoreSliceMap<S>;
9
+ type _ActionRefName<S extends SliceCls> = SlceCnstRefName<S>;
10
+ type _ActionCap<S extends SliceCls> = SlceCnstCapitalizedRefName<S>;
11
+ type _ActionInput<S extends SliceCls> = SlceCnstInput<S>;
12
+ type _ActionFull<S extends SliceCls> = SlceCnstFull<S>;
13
+ type _ActionLight<S extends SliceCls> = SlceCnstLight<S>;
14
+ type _ActionDefault<S extends SliceCls> = SlceCnstDefault<S>;
15
+ type _ActionDefaultInput<S extends SliceCls> = SlceCnstDefaultInput<S>;
16
+ type _ActionFilter<S extends SliceCls> = SlceDbFilter<S>;
17
+ type _ActionSort<S extends SliceCls> = SlceDbSort<S>;
8
18
  export interface CreateOption<Full extends {
9
19
  id: string;
10
20
  }> {
@@ -105,37 +115,30 @@ type FormSetter<Full, RefName extends string, _CapitalizedRefName extends string
105
115
  } & {
106
116
  [K in `writeOn${_CapitalizedRefName}`]: (path: string | (string | number)[], value: any) => void;
107
117
  };
108
- type _SliceActionMap<SlceCls extends SliceCls> = SlceCls[typeof SLICE_META];
109
- type _ActSuffixCap<SlceCls extends SliceCls, Suffix extends keyof _SliceActionMap<SlceCls>> = Capitalize<Suffix & string>;
110
- type _ActArgs<SlceCls extends SliceCls, Suffix extends keyof _SliceActionMap<SlceCls>> = SliceInfoArgs<_SliceActionMap<SlceCls>[Suffix]>;
111
- type DefaultSliceActionFields<SlceCls extends SliceCls, _CapRef extends string, _FetchInitFormWithFetchPolicy, _Light, _Sort> = {
112
- [Suffix in keyof _SliceActionMap<SlceCls> as `init${_CapRef}${_ActSuffixCap<SlceCls, Suffix>}`]: (...args: [...args: _ActArgs<SlceCls, Suffix>, initForm?: _FetchInitFormWithFetchPolicy]) => Promise<void>;
113
- } & {
114
- [Suffix in keyof _SliceActionMap<SlceCls> as `refresh${_CapRef}${_ActSuffixCap<SlceCls, Suffix>}`]: (initForm?: _FetchInitFormWithFetchPolicy & {
115
- queryArgs?: _ActArgs<SlceCls, Suffix>;
118
+ type DefaultSliceActionFields<SlceCls extends SliceCls, _CapRef extends string, _FetchInitFormWithFetchPolicy, _Light, _Sort, _Suffixes extends keyof _SliceMap<SlceCls> = keyof _SliceMap<SlceCls>> = {
119
+ [Suffix in _Suffixes as `init${_CapRef}${StoreSliceSuffixCap<SlceCls, Suffix>}`]: (...args: [...args: StoreSliceArgs<SlceCls, Suffix>, initForm?: _FetchInitFormWithFetchPolicy]) => Promise<void>;
120
+ } & {
121
+ [Suffix in _Suffixes as `refresh${_CapRef}${StoreSliceSuffixCap<SlceCls, Suffix>}`]: (initForm?: _FetchInitFormWithFetchPolicy & {
122
+ queryArgs?: StoreSliceArgs<SlceCls, Suffix>;
116
123
  }) => Promise<void>;
117
124
  } & {
118
- [Suffix in keyof _SliceActionMap<SlceCls> as `select${_CapRef}${_ActSuffixCap<SlceCls, Suffix>}`]: (model: _Light | _Light[], options?: {
125
+ [Suffix in _Suffixes as `select${_CapRef}${StoreSliceSuffixCap<SlceCls, Suffix>}`]: (model: _Light | _Light[], options?: {
119
126
  refresh?: boolean;
120
127
  remove?: boolean;
121
128
  }) => void;
122
129
  } & {
123
- [Suffix in keyof _SliceActionMap<SlceCls> as `setPageOf${_CapRef}${_ActSuffixCap<SlceCls, Suffix>}`]: (page: number, options?: FetchPolicy) => Promise<void>;
124
- } & {
125
- [Suffix in keyof _SliceActionMap<SlceCls> as `addPageOf${_CapRef}${_ActSuffixCap<SlceCls, Suffix>}`]: (page: number, options?: FetchPolicy) => Promise<void>;
126
- } & {
127
- [Suffix in keyof _SliceActionMap<SlceCls> as `setLimitOf${_CapRef}${_ActSuffixCap<SlceCls, Suffix>}`]: (limit: number, options?: FetchPolicy) => Promise<void>;
130
+ [Suffix in _Suffixes as `setPageOf${_CapRef}${StoreSliceSuffixCap<SlceCls, Suffix>}` | `addPageOf${_CapRef}${StoreSliceSuffixCap<SlceCls, Suffix>}` | `setLimitOf${_CapRef}${StoreSliceSuffixCap<SlceCls, Suffix>}`]: (value: number, options?: FetchPolicy) => Promise<void>;
128
131
  } & {
129
- [Suffix in keyof _SliceActionMap<SlceCls> as `setQueryArgsOf${_CapRef}${_ActSuffixCap<SlceCls, Suffix>}`]: (...args: [...args: _ActArgs<SlceCls, Suffix>, options?: FetchPolicy] | [
130
- setQueryArgs: (...prevQueryArgs: _ActArgs<SlceCls, Suffix>) => _ActArgs<SlceCls, Suffix>,
132
+ [Suffix in _Suffixes as `setQueryArgsOf${_CapRef}${StoreSliceSuffixCap<SlceCls, Suffix>}`]: (...args: [...args: StoreSliceArgs<SlceCls, Suffix>, options?: FetchPolicy] | [
133
+ setQueryArgs: (...prevQueryArgs: StoreSliceArgs<SlceCls, Suffix>) => StoreSliceArgs<SlceCls, Suffix>,
131
134
  options?: FetchPolicy
132
135
  ]) => Promise<void>;
133
136
  } & {
134
- [Suffix in keyof _SliceActionMap<SlceCls> as `setSortOf${_CapRef}${_ActSuffixCap<SlceCls, Suffix>}`]: (sort: _Sort, options?: FetchPolicy) => Promise<void>;
137
+ [Suffix in _Suffixes as `setSortOf${_CapRef}${StoreSliceSuffixCap<SlceCls, Suffix>}`]: (sort: _Sort, options?: FetchPolicy) => Promise<void>;
135
138
  };
136
- export type DefaultAction<SlceCls extends SliceCls, _RefName extends string = SlceCls["srv"]["cnst"]["refName"], _Input = SlceCls["srv"]["cnst"]["_Input"], _Full extends {
139
+ export type DefaultAction<SlceCls extends SliceCls, _RefName extends string = _ActionRefName<SlceCls>, _Input = _ActionInput<SlceCls>, _Full extends {
137
140
  id: string;
138
- } = SlceCls["srv"]["cnst"]["_Full"], _Light = SlceCls["srv"]["cnst"]["_Light"], _Filter extends FilterInstance = SlceCls["srv"]["db"]["_Filter"], _CapitalizedRefName extends string = Capitalize<_RefName>, _Default = SlceCls["srv"]["cnst"]["_Default"], _DefaultInput = SlceCls["srv"]["cnst"]["_DefaultInput"], _Sort = SlceCls["srv"]["db"]["_Sort"], _CreateOption = CreateOption<_Full>, _FetchInitFormWithFetchPolicy = FetchInitForm<_Input, _Filter, _DefaultInput, _Sort> & FetchPolicy> = BaseAction<_RefName, _Input, _Full, _Light, _CapitalizedRefName, _CreateOption> & FormSetter<_Full, _RefName, _CapitalizedRefName, _Default> & DefaultSliceActionFields<SlceCls, _CapitalizedRefName, _FetchInitFormWithFetchPolicy, _Light, _Sort>;
141
+ } = _ActionFull<SlceCls>, _Light = _ActionLight<SlceCls>, _Filter extends FilterInstance = _ActionFilter<SlceCls>, _CapitalizedRefName extends string = _ActionCap<SlceCls>, _Default = _ActionDefault<SlceCls>, _DefaultInput = _ActionDefaultInput<SlceCls>, _Sort = _ActionSort<SlceCls>, _CreateOption = CreateOption<_Full>, _FetchInitFormWithFetchPolicy = FetchInitForm<_Input, _Filter, _DefaultInput, _Sort> & FetchPolicy> = BaseAction<_RefName, _Input, _Full, _Light, _CapitalizedRefName, _CreateOption> & FormSetter<_Full, _RefName, _CapitalizedRefName, _Default> & DefaultSliceActionFields<SlceCls, _CapitalizedRefName, _FetchInitFormWithFetchPolicy, _Light, _Sort>;
139
142
  export declare const makeFormSetter: (refName: string, fetch: FetchProxy<any>) => {
140
143
  [x: string]: (this: SetGet, path: string | (string | number)[], value: any) => void;
141
144
  };