akanjs 2.3.5-rc.8 → 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
@@ -18,7 +18,7 @@ import type {
18
18
  } from "akanjs/constant";
19
19
  import type { ServiceModel } from "akanjs/service";
20
20
  import type { InternalArgCls } from "./internalArg";
21
- import type { ArgType, SignalOption } from "./types";
21
+ import type { ArgType, SignalOption, SrvMap } from "./types";
22
22
 
23
23
  export type EndpointType = "query" | "mutation" | "pubsub" | "message";
24
24
 
@@ -328,19 +328,19 @@ export type BuildEndpoint<SrvModule extends ServiceModel = ServiceModel> = {
328
328
  query: <Returns extends ConstantFieldTypeInput = ConstantFieldTypeInput, Nullable extends boolean = false>(
329
329
  returnRef: Returns,
330
330
  signalOption?: SignalOption<Returns, Nullable>,
331
- ) => EndpointInfo<"query", SrvModule["srvMap"], [], [], [], [], Returns, never, never, Nullable>;
331
+ ) => EndpointInfo<"query", SrvMap<SrvModule>, [], [], [], [], Returns, never, never, Nullable>;
332
332
  mutation: <Returns extends ConstantFieldTypeInput = ConstantFieldTypeInput, Nullable extends boolean = false>(
333
333
  returnRef: Returns,
334
334
  signalOption?: SignalOption<Returns, Nullable>,
335
- ) => EndpointInfo<"mutation", SrvModule["srvMap"], [], [], [], [], Returns, never, never, Nullable>;
335
+ ) => EndpointInfo<"mutation", SrvMap<SrvModule>, [], [], [], [], Returns, never, never, Nullable>;
336
336
  pubsub: <Returns extends ConstantFieldTypeInput = ConstantFieldTypeInput, Nullable extends boolean = false>(
337
337
  returnRef: Returns,
338
338
  signalOption?: SignalOption<Returns, Nullable>,
339
- ) => EndpointInfo<"pubsub", SrvModule["srvMap"], [], [], [], [], Returns, never, never, Nullable>;
339
+ ) => EndpointInfo<"pubsub", SrvMap<SrvModule>, [], [], [], [], Returns, never, never, Nullable>;
340
340
  message: <Returns extends ConstantFieldTypeInput = ConstantFieldTypeInput, Nullable extends boolean = false>(
341
341
  returnRef: Returns,
342
342
  signalOption?: SignalOption<Returns, Nullable>,
343
- ) => EndpointInfo<"message", SrvModule["srvMap"], [], [], [], [], Returns, never, never, Nullable>;
343
+ ) => EndpointInfo<"message", SrvMap<SrvModule>, [], [], [], [], Returns, never, never, Nullable>;
344
344
  };
345
345
 
346
346
  export const buildEndpoint = {
@@ -354,21 +354,51 @@ export type EndpointBuilder<SrvModule extends ServiceModel = ServiceModel> = (bu
354
354
  [key: string]: EndpointInfo;
355
355
  };
356
356
 
357
- export type EndpInfoReqType<E> =
358
- E extends EndpointInfo<infer T, any, any, any, any, any, any, any, any, any> ? T : never;
359
- export type EndpInfoSrvs<E> = E extends EndpointInfo<any, infer S, any, any, any, any, any, any, any, any> ? S : never;
360
- export type EndpInfoArgNames<E> =
361
- E extends EndpointInfo<any, any, infer N, any, any, any, any, any, any, any> ? N : never;
362
- export type EndpInfoArgs<E> = E extends EndpointInfo<any, any, any, infer A, any, any, any, any, any, any> ? A : never;
363
- export type EndpInfoInternalArgs<E> =
364
- E extends EndpointInfo<any, any, any, any, infer I, any, any, any, any, any> ? I : never;
365
- export type EndpInfoServerArgs<E> =
366
- E extends EndpointInfo<any, any, any, any, any, infer S, any, any, any, any> ? S : never;
367
- export type EndpInfoReturnRef<E> =
368
- E extends EndpointInfo<any, any, any, any, any, any, infer R, any, any, any> ? R : never;
369
- export type EndpInfoClientReturns<E> =
370
- E extends EndpointInfo<any, any, any, any, any, any, any, infer R, any, any> ? R : never;
371
- export type EndpInfoServerReturns<E> =
372
- E extends EndpointInfo<any, any, any, any, any, any, any, any, infer R, any> ? R : never;
373
- export type EndpInfoNullable<E> =
374
- E extends EndpointInfo<any, any, any, any, any, any, any, any, any, infer N> ? N : never;
357
+ type EndpointInfoEmptyParts = {
358
+ reqType: never;
359
+ srvs: never;
360
+ argNames: never;
361
+ args: never;
362
+ internalArgs: never;
363
+ serverArgs: never;
364
+ returnRef: never;
365
+ clientReturns: never;
366
+ serverReturns: never;
367
+ nullable: never;
368
+ };
369
+ export type EndpointInfoParts<E> =
370
+ E extends EndpointInfo<
371
+ infer ReqType,
372
+ infer Srvs,
373
+ infer ArgNames,
374
+ infer Args,
375
+ infer InternalArgs,
376
+ infer ServerArgs,
377
+ infer Returns,
378
+ infer ClientReturns,
379
+ infer ServerReturns,
380
+ infer Nullable
381
+ >
382
+ ? {
383
+ reqType: ReqType;
384
+ srvs: Srvs;
385
+ argNames: ArgNames;
386
+ args: Args;
387
+ internalArgs: InternalArgs;
388
+ serverArgs: ServerArgs;
389
+ returnRef: Returns;
390
+ clientReturns: ClientReturns;
391
+ serverReturns: ServerReturns;
392
+ nullable: Nullable;
393
+ }
394
+ : EndpointInfoEmptyParts;
395
+ export type EndpInfoReqType<E> = EndpointInfoParts<E>["reqType"];
396
+ export type EndpInfoSrvs<E> = EndpointInfoParts<E>["srvs"];
397
+ export type EndpInfoArgNames<E> = EndpointInfoParts<E>["argNames"];
398
+ export type EndpInfoArgs<E> = EndpointInfoParts<E>["args"];
399
+ export type EndpInfoInternalArgs<E> = EndpointInfoParts<E>["internalArgs"];
400
+ export type EndpInfoServerArgs<E> = EndpointInfoParts<E>["serverArgs"];
401
+ export type EndpInfoReturnRef<E> = EndpointInfoParts<E>["returnRef"];
402
+ export type EndpInfoClientReturns<E> = EndpointInfoParts<E>["clientReturns"];
403
+ export type EndpInfoServerReturns<E> = EndpointInfoParts<E>["serverReturns"];
404
+ export type EndpInfoNullable<E> = EndpointInfoParts<E>["nullable"];
@@ -11,6 +11,7 @@ import {
11
11
  type ServiceModel,
12
12
  } from "akanjs/service";
13
13
  import { type BuildInternal, buildInternal, type InternalBuilder, type InternalInfo } from "./internalInfo";
14
+ import type { SrvRefName } from "./types";
14
15
 
15
16
  export interface Internal extends Adaptor {
16
17
  schedule: ScheduleAdaptor;
@@ -20,7 +21,7 @@ export interface Internal extends Adaptor {
20
21
  export type InternalCls<
21
22
  SrvModule extends ServiceModel = ServiceModel,
22
23
  InternalInfoMap extends { [key: string]: InternalInfo } = { [key: string]: InternalInfo },
23
- > = AdaptorCls & { refName: SrvModule["srv"]["refName"]; srv: SrvModule; [INTERNAL_META]: InternalInfoMap };
24
+ > = AdaptorCls & { refName: SrvRefName<SrvModule>; srv: SrvModule; [INTERNAL_META]: InternalInfoMap };
24
25
 
25
26
  /** Builds an internal adaptor for schedules, queues, processes, and server-only jobs. */
26
27
  export function internal<
@@ -11,7 +11,7 @@ import type {
11
11
  import type { AkanJob, ServiceModel } from "akanjs/service";
12
12
  import { type ArgInfo, EndpointInfo, type InternalArgInfo, type ReturnInfo } from "./endpointInfo";
13
13
  import type { InternalArgCls } from "./internalArg";
14
- import type { SignalOption } from "./types";
14
+ import type { CnstOf, DbDoc, SignalOption, SrvMap } from "./types";
15
15
 
16
16
  type InternalType = "resolveField" | "interval" | "cron" | "timeout" | "init" | "destroy" | "process";
17
17
 
@@ -108,57 +108,105 @@ export class InternalInfo<
108
108
  }
109
109
  }
110
110
 
111
- export type BuildInternal<SrvModule extends ServiceModel, ParentDoc = SrvModule["db"]["_Doc"]> = {
111
+ type InternalInfoEmptyParts = {
112
+ reqType: never;
113
+ srvs: never;
114
+ args: never;
115
+ internalArgs: never;
116
+ defaultArgs: never;
117
+ returns: never;
118
+ serverReturns: never;
119
+ nullable: never;
120
+ };
121
+ export type InternalInfoParts<I> =
122
+ I extends InternalInfo<
123
+ infer ReqType,
124
+ infer Srvs,
125
+ infer Args,
126
+ infer InternalArgs,
127
+ infer DefaultArgs,
128
+ infer Returns,
129
+ infer ServerReturns,
130
+ infer Nullable
131
+ >
132
+ ? {
133
+ reqType: ReqType;
134
+ srvs: Srvs;
135
+ args: Args;
136
+ internalArgs: InternalArgs;
137
+ defaultArgs: DefaultArgs;
138
+ returns: Returns;
139
+ serverReturns: ServerReturns;
140
+ nullable: Nullable;
141
+ }
142
+ : InternalInfoEmptyParts;
143
+ export type InternalInfoReqType<I> = InternalInfoParts<I>["reqType"];
144
+ export type InternalInfoSrvs<I> = InternalInfoParts<I>["srvs"];
145
+ export type InternalInfoServerArgs<I> = InternalInfoParts<I>["args"];
146
+ export type InternalInfoInternalArgs<I> = InternalInfoParts<I>["internalArgs"];
147
+ export type InternalInfoDefaultArgs<I> = InternalInfoParts<I>["defaultArgs"];
148
+ export type InternalInfoReturns<I> = InternalInfoParts<I>["returns"];
149
+ export type InternalInfoServerReturns<I> = InternalInfoParts<I>["serverReturns"];
150
+ export type InternalInfoNullable<I> = InternalInfoParts<I>["nullable"];
151
+
152
+ export type BuildInternal<SrvModule extends ServiceModel, ParentDoc = DbDoc<SrvModule>> = {
112
153
  resolveField: <Returns extends ConstantFieldTypeInput, Nullable extends boolean = false>(
113
154
  returnRef: Returns,
114
155
  signalOption?: Pick<SignalOption<Returns, Nullable>, "nullable">,
115
- ) => InternalInfo<"resolveField", SrvModule["srvMap"], [], [], [ParentDoc], Returns, never, Nullable>;
156
+ ) => InternalInfo<"resolveField", SrvMap<SrvModule>, [], [], [ParentDoc], Returns, never, Nullable>;
116
157
  interval: <Nullable extends boolean = false>(
117
158
  scheduleTime: number,
118
159
  signalOption?: SignalOption<typeof Any, Nullable>,
119
- ) => InternalInfo<"interval", SrvModule["srvMap"], [], [], [], typeof Any, never, Nullable>;
160
+ ) => InternalInfo<"interval", SrvMap<SrvModule>, [], [], [], typeof Any, never, Nullable>;
120
161
  cron: <Nullable extends boolean = false>(
121
162
  scheduleCron: string,
122
163
  signalOption?: SignalOption<typeof Any, Nullable>,
123
- ) => InternalInfo<"cron", SrvModule["srvMap"], [], [], [], typeof Any, never, Nullable>;
164
+ ) => InternalInfo<"cron", SrvMap<SrvModule>, [], [], [], typeof Any, never, Nullable>;
124
165
  timeout: <Nullable extends boolean = false>(
125
166
  timeout: number,
126
167
  signalOption?: SignalOption<typeof Any, Nullable>,
127
- ) => InternalInfo<"timeout", SrvModule["srvMap"], [], [], [], typeof Any, never, Nullable>;
168
+ ) => InternalInfo<"timeout", SrvMap<SrvModule>, [], [], [], typeof Any, never, Nullable>;
128
169
  initialize: <Nullable extends boolean = false>(
129
170
  signalOption?: SignalOption<typeof Any, Nullable>,
130
- ) => InternalInfo<"init", SrvModule["srvMap"], [], [], [], typeof Any, never, Nullable>;
171
+ ) => InternalInfo<"init", SrvMap<SrvModule>, [], [], [], typeof Any, never, Nullable>;
131
172
  destroy: <Nullable extends boolean = false>(
132
173
  signalOption?: SignalOption<typeof Any, Nullable>,
133
- ) => InternalInfo<"destroy", SrvModule["srvMap"], [], [], [], typeof Any, never, Nullable>;
174
+ ) => InternalInfo<"destroy", SrvMap<SrvModule>, [], [], [], typeof Any, never, Nullable>;
134
175
  process: <Returns extends ConstantFieldTypeInput, Nullable extends boolean = false>(
135
176
  returnRef: Returns,
136
177
  signalOption?: SignalOption<Returns, Nullable>,
137
- ) => InternalInfo<"process", SrvModule["srvMap"], [], [], [AkanJob], Returns, never, Nullable>;
178
+ ) => InternalInfo<"process", SrvMap<SrvModule>, [], [], [AkanJob], Returns, never, Nullable>;
138
179
  };
139
180
 
140
181
  export type InternalBuilder<
141
182
  SrvModule extends ServiceModel,
142
- _FullCls extends ConstantCls = SrvModule["cnst"]["full"],
183
+ _Cnst = CnstOf<SrvModule>,
184
+ _FullCls extends ConstantCls = [_Cnst] extends [never]
185
+ ? never
186
+ : _Cnst extends { full: infer Full extends ConstantCls }
187
+ ? Full
188
+ : never,
143
189
  _FieldObj extends FieldObject = _FullCls[typeof FIELD_META],
144
190
  _ResolveFieldObj extends FieldObject = {
145
191
  [K in keyof _FieldObj as _FieldObj[K] extends ConstantField<"resolve", any, any, any, any, any>
146
192
  ? K
147
193
  : never]: _FieldObj[K];
148
194
  },
149
- > = (builder: BuildInternal<SrvModule>) => SrvModule["cnst"] extends never
150
- ? { [key: string]: InternalInfo<Exclude<InternalType, "resolveField">> }
151
- : {
152
- [K in keyof _ResolveFieldObj]: _ResolveFieldObj[K] extends ConstantField<
153
- "resolve",
154
- infer Value,
155
- any,
156
- any,
157
- infer Nullable
158
- >
159
- ? InternalInfo<"resolveField", any, any, any, any, NonNullable<Value>, Nullable>
160
- : InternalInfo<Exclude<InternalType, "resolveField">>;
161
- };
195
+ > = (builder: BuildInternal<SrvModule>) => [_Cnst] extends [never]
196
+ ? { [key: string]: InternalInfo<InternalType> }
197
+ : [_FullCls] extends [never]
198
+ ? { [key: string]: InternalInfo<InternalType> }
199
+ : {
200
+ [K in keyof _ResolveFieldObj]: _ResolveFieldObj[K] extends ConstantField<
201
+ "resolve",
202
+ infer Value,
203
+ any,
204
+ any,
205
+ infer Nullable
206
+ >
207
+ ? InternalInfo<"resolveField", any, any, any, any, NonNullable<Value>, Nullable>
208
+ : InternalInfo<Exclude<InternalType, "resolveField">>;
209
+ } & { [key: string]: InternalInfo<InternalType> };
162
210
 
163
211
  export const buildInternal = {
164
212
  resolveField: (returnRef: Cls, signalOption?: SignalOption) =>
@@ -11,82 +11,48 @@ import {
11
11
  } from "akanjs/service";
12
12
  import type { ServerWebSocket } from "bun";
13
13
  import type { EndpointCls } from "./endpoint";
14
- import type { EndpointInfo } from "./endpointInfo";
14
+ import type { EndpInfoClientReturns, EndpInfoReqType, EndpInfoServerArgs, EndpointInfo } from "./endpointInfo";
15
15
  import type { InternalCls } from "./internal";
16
- import type { InternalInfo } from "./internalInfo";
16
+ import type { InternalInfo, InternalInfoReqType, InternalInfoServerArgs } from "./internalInfo";
17
+
18
+ type EndpointPubsubPayload<E> = EndpInfoClientReturns<E> | DocumentModel<EndpInfoClientReturns<E>>;
17
19
 
18
20
  export interface ServerSignal extends Adaptor {
19
21
  readonly websocket: ServerWebSocket;
20
22
  readonly queue: QueueAdaptor;
21
23
  }
22
24
 
23
- type EndpointServerSignalMethods<EnpCls> = EnpCls extends { [ENDPOINT_META]: infer EndpointInfoObj }
25
+ type EndpointServerSignalMethods<EnpCls> = [EnpCls] extends [{ [ENDPOINT_META]: infer EndpointInfoObj }]
24
26
  ? {
25
- [K in keyof EndpointInfoObj as EndpointInfoObj[K] extends EndpointInfo<
26
- "pubsub",
27
- any,
28
- any,
29
- any,
30
- any,
31
- any,
32
- any,
33
- any,
34
- any
35
- >
36
- ? K
37
- : never]: EndpointInfoObj[K] extends EndpointInfo<
38
- any,
39
- any,
40
- any,
41
- any,
42
- any,
43
- infer ServerArgs,
44
- any,
45
- infer ClientReturns,
46
- any,
47
- any
48
- >
49
- ? (...args: [...ServerArgs, data: DocumentModel<ClientReturns>]) => void
50
- : never;
27
+ [K in keyof EndpointInfoObj as EndpInfoReqType<EndpointInfoObj[K]> extends "pubsub" ? K : never]: (
28
+ ...args: [...EndpInfoServerArgs<EndpointInfoObj[K]>, data: EndpointPubsubPayload<EndpointInfoObj[K]>]
29
+ ) => void;
51
30
  }
52
- : never;
31
+ : Record<never, never>;
53
32
 
54
- type InternalServerSignalMethods<IntCls> = IntCls extends { [INTERNAL_META]: infer InternalInfoObj }
33
+ type InternalServerSignalMethods<IntCls> = [IntCls] extends [{ [INTERNAL_META]: infer InternalInfoObj }]
55
34
  ? {
56
- [K in keyof InternalInfoObj as InternalInfoObj[K] extends InternalInfo<
57
- "process",
58
- any,
59
- any,
60
- any,
61
- any,
62
- any,
63
- any,
64
- any
65
- >
66
- ? K
67
- : never]: InternalInfoObj[K] extends InternalInfo<
68
- any,
69
- any,
70
- infer ServerArgs,
71
- any,
72
- any,
73
- any,
74
- infer ServerReturns
75
- >
76
- ? (...args: [...args: ServerArgs, jobOptions?: AkanJobOptions]) => Promise<AkanJob<any, ServerReturns>>
77
- : never;
35
+ [K in keyof InternalInfoObj as InternalInfoReqType<InternalInfoObj[K]> extends "process" ? K : never]: (
36
+ ...args: [...args: InternalInfoServerArgs<InternalInfoObj[K]>, jobOptions?: AkanJobOptions]
37
+ ) => Promise<AkanJob<unknown, unknown>>;
78
38
  }
79
- : never;
39
+ : Record<never, never>;
80
40
 
81
- type ServerSignalClsStatics = {
41
+ export type ServerSignalClsStatics = {
82
42
  readonly refName: string;
83
43
  readonly [INJECT_META]: { queue: QueueAdaptor };
84
44
  readonly [ENDPOINT_META]: { [key: string]: EndpointInfo };
85
45
  readonly [INTERNAL_META]: { [key: string]: InternalInfo };
86
46
  };
87
47
 
88
- export type ServerSignalCls<EnpCls = any, IntCls = any> = AdaptorCls<
89
- EndpointServerSignalMethods<EnpCls> & InternalServerSignalMethods<IntCls> & ServerSignal
48
+ export type ServerSignalMethods<EnpCls, IntCls> = EndpointServerSignalMethods<EnpCls> &
49
+ InternalServerSignalMethods<IntCls>;
50
+
51
+ export type TypedServerSignalCls<EnpCls, IntCls> = AdaptorCls<ServerSignalMethods<EnpCls, IntCls> & ServerSignal> &
52
+ ServerSignalClsStatics;
53
+
54
+ export type ServerSignalCls<EnpCls = unknown, IntCls = unknown> = AdaptorCls<
55
+ ServerSignalMethods<EnpCls, IntCls> & ServerSignal
90
56
  > &
91
57
  ServerSignalClsStatics;
92
58
 
package/signal/slice.ts CHANGED
@@ -4,7 +4,17 @@ import type { DocumentModel, QueryOf } from "akanjs/constant";
4
4
  import type { FilterInstance } from "akanjs/document";
5
5
  import { type Adaptor, type AdaptorCls, dangerouslyAdapt, type ServiceModel } from "akanjs/service";
6
6
  import type { Guard, GuardCls } from "./guard";
7
- import { buildSlice, type SliceBuilder, type SliceInfo } from "./sliceInfo";
7
+ import {
8
+ buildSlice,
9
+ type SliceBuilder,
10
+ type SliceInfo,
11
+ type SliceInfoArgNames,
12
+ type SliceInfoArgs,
13
+ type SliceInfoInternalArgs,
14
+ type SliceInfoServerArgs,
15
+ type SliceInfoSrvs,
16
+ } from "./sliceInfo";
17
+ import type { CnstFull, CnstInput, CnstInsight, CnstLight, DbFilter, SrvMap, SrvRefName } from "./types";
8
18
 
9
19
  export interface Slice extends Adaptor {}
10
20
 
@@ -12,7 +22,7 @@ export type SliceCls<
12
22
  SrvModule extends ServiceModel = ServiceModel,
13
23
  SliceInfoObj extends { [key: string]: SliceInfo } = { [key: string]: SliceInfo },
14
24
  > = AdaptorCls & {
15
- baseName: SrvModule["srv"]["refName"];
25
+ baseName: SrvRefName<SrvModule>;
16
26
  srv: SrvModule;
17
27
  [SLICE_META]: SliceInfoObj;
18
28
  getGuards: GuardCls[];
@@ -28,41 +38,31 @@ interface RootSliceOption {
28
38
  prefix?: string;
29
39
  }
30
40
 
41
+ type RootSliceQuery<SrvModule extends ServiceModel, Full = CnstFull<SrvModule>> = QueryOf<DocumentModel<Full>>;
42
+
31
43
  type ExtendSliceInfoObj<
32
44
  SrvModule extends ServiceModel,
33
45
  LibSlices extends SliceCls[],
34
- _Input = NonNullable<SrvModule["cnst"]>["_Input"],
35
- _Full = NonNullable<SrvModule["cnst"]>["_Full"],
36
- _Light = NonNullable<SrvModule["cnst"]>["_Light"],
37
- _Insight = NonNullable<SrvModule["cnst"]>["_Insight"],
38
- _Filter extends FilterInstance = any,
46
+ _Input = CnstInput<SrvModule>,
47
+ _Full = CnstFull<SrvModule>,
48
+ _Light = CnstLight<SrvModule>,
49
+ _Insight = CnstInsight<SrvModule>,
50
+ _Filter extends FilterInstance = DbFilter<SrvModule>,
39
51
  _Merged = MergeAllKeyOfObjects<LibSlices, typeof SLICE_META>,
40
52
  > = {
41
- [K in keyof _Merged]: _Merged[K] extends SliceInfo<
42
- any,
43
- any,
44
- any,
45
- any,
46
- any,
47
- any,
48
- infer Srvs,
49
- infer ArgNames,
50
- infer Args,
51
- infer InternalArgs,
52
- infer ServerArgs
53
- >
53
+ [K in keyof _Merged]: _Merged[K] extends SliceInfo
54
54
  ? SliceInfo<
55
- SrvModule["srv"]["refName"],
55
+ SrvRefName<SrvModule>,
56
56
  _Input,
57
57
  _Full,
58
58
  _Light,
59
59
  _Insight,
60
60
  _Filter,
61
- Srvs,
62
- ArgNames,
63
- Args,
64
- InternalArgs,
65
- ServerArgs
61
+ SliceInfoSrvs<_Merged[K]>,
62
+ SliceInfoArgNames<_Merged[K]>,
63
+ SliceInfoArgs<_Merged[K]>,
64
+ SliceInfoInternalArgs<_Merged[K]>,
65
+ SliceInfoServerArgs<_Merged[K]>
66
66
  >
67
67
  : never;
68
68
  };
@@ -72,12 +72,12 @@ export function slice<
72
72
  SrvModule extends ServiceModel,
73
73
  BuildSlice extends SliceBuilder<SrvModule>,
74
74
  LibSlices extends SliceCls[],
75
- _Input = NonNullable<SrvModule["cnst"]>["_Input"],
76
- _Full = NonNullable<SrvModule["cnst"]>["_Full"],
77
- _Light = NonNullable<SrvModule["cnst"]>["_Light"],
78
- _Insight = NonNullable<SrvModule["cnst"]>["_Insight"],
79
- _Filter extends FilterInstance = NonNullable<SrvModule["db"]>["_Filter"],
80
- _Query = QueryOf<DocumentModel<_Full>>,
75
+ _Input = CnstInput<SrvModule>,
76
+ _Full = CnstFull<SrvModule>,
77
+ _Light = CnstLight<SrvModule>,
78
+ _Insight = CnstInsight<SrvModule>,
79
+ _Filter extends FilterInstance = DbFilter<SrvModule>,
80
+ _Query = RootSliceQuery<SrvModule, _Full>,
81
81
  >(
82
82
  srv: SrvModule,
83
83
  option: RootSliceOption,
@@ -90,13 +90,13 @@ export function slice<
90
90
  LibSlices extends []
91
91
  ? {
92
92
  [""]: SliceInfo<
93
- SrvModule["srv"]["refName"],
93
+ SrvRefName<SrvModule>,
94
94
  _Input,
95
95
  _Full,
96
96
  _Light,
97
97
  _Insight,
98
98
  _Filter,
99
- SrvModule["srvMap"],
99
+ SrvMap<SrvModule>,
100
100
  ["query"],
101
101
  [_Query],
102
102
  [],
@@ -146,7 +146,7 @@ export function slice<
146
146
  .search<"query", object>("query", Any)
147
147
  .exec((query) => query ?? {}),
148
148
  },
149
- sliceBuilder(init),
149
+ sliceBuilder(init as Parameters<BuildSlice>[0]),
150
150
  );
151
151
  };
152
152
  libSlices.forEach((libSlice) => {
@@ -10,7 +10,7 @@ import type {
10
10
  PurifiedModel,
11
11
  QueryOf,
12
12
  } from "akanjs/constant";
13
- import type { ExtractSort, FilterCls, FilterInstance } from "akanjs/document";
13
+ import type { FilterCls, FilterInstance } from "akanjs/document";
14
14
  import type { ServiceModel } from "akanjs/service";
15
15
  import {
16
16
  type ArgInfo,
@@ -20,7 +20,7 @@ import {
20
20
  type InternalArgProps,
21
21
  } from "./endpointInfo";
22
22
  import type { InternalArgCls } from "./internalArg";
23
- import type { SignalOption } from "./types";
23
+ import type { CnstFull, CnstInput, CnstInsight, CnstLight, DbFilter, SignalOption, SrvMap, SrvRefName } from "./types";
24
24
 
25
25
  export class SliceInfo<
26
26
  RefName extends string = string,
@@ -192,7 +192,7 @@ export const buildSlice =
192
192
  filter: FilterCls<Filter>,
193
193
  ) =>
194
194
  (signalOption?: SignalOption) =>
195
- new SliceInfo<T, Input, Full, Light, Insight, Filter, SrvModule["srvMap"], [], [], [], []>(
195
+ new SliceInfo<T, Input, Full, Light, Insight, Filter, SrvMap<SrvModule>, [], [], [], []>(
196
196
  refName,
197
197
  input,
198
198
  full,
@@ -202,53 +202,69 @@ export const buildSlice =
202
202
  signalOption,
203
203
  );
204
204
 
205
- export type SliceInfoRefName<S> =
206
- S extends SliceInfo<infer R, any, any, any, any, any, any, any, any, any, any> ? R : never;
207
- export type SliceInfoInput<S> =
208
- S extends SliceInfo<any, infer I, any, any, any, any, any, any, any, any, any> ? I : never;
209
- export type SliceInfoFull<S> =
210
- S extends SliceInfo<any, any, infer F, any, any, any, any, any, any, any, any> ? F : never;
211
- export type SliceInfoLight<S> =
212
- S extends SliceInfo<any, any, any, infer L, any, any, any, any, any, any, any> ? L : never;
213
- export type SliceInfoInsight<S> =
214
- S extends SliceInfo<any, any, any, any, infer I, any, any, any, any, any, any> ? I : never;
215
- export type SliceInfoFilter<S> =
216
- S extends SliceInfo<any, any, any, any, any, infer F, any, any, any, any, any> ? F : never;
217
- export type SliceInfoSrvs<S> =
218
- S extends SliceInfo<any, any, any, any, any, any, infer S2, any, any, any, any> ? S2 : never;
219
- export type SliceInfoArgNames<S> =
220
- S extends SliceInfo<any, any, any, any, any, any, any, infer N, any, any, any> ? N : never;
221
- export type SliceInfoArgs<S> =
222
- S extends SliceInfo<any, any, any, any, any, any, any, any, infer A, any, any> ? A : never;
223
- export type SliceInfoInternalArgs<S> =
224
- S extends SliceInfo<any, any, any, any, any, any, any, any, any, infer I, any> ? I : never;
225
- export type SliceInfoServerArgs<S> =
226
- S extends SliceInfo<any, any, any, any, any, any, any, any, any, any, infer S2> ? S2 : never;
205
+ type SliceInfoEmptyParts = {
206
+ refName: never;
207
+ input: never;
208
+ full: never;
209
+ light: never;
210
+ insight: never;
211
+ filter: never;
212
+ srvs: never;
213
+ argNames: never;
214
+ args: never;
215
+ internalArgs: never;
216
+ serverArgs: never;
217
+ };
218
+ export type SliceInfoParts<S> =
219
+ S extends SliceInfo<
220
+ infer RefName,
221
+ infer Input,
222
+ infer Full,
223
+ infer Light,
224
+ infer Insight,
225
+ infer Filter,
226
+ infer Srvs,
227
+ infer ArgNames,
228
+ infer Args,
229
+ infer InternalArgs,
230
+ infer ServerArgs
231
+ >
232
+ ? {
233
+ refName: RefName;
234
+ input: Input;
235
+ full: Full;
236
+ light: Light;
237
+ insight: Insight;
238
+ filter: Filter;
239
+ srvs: Srvs;
240
+ argNames: ArgNames;
241
+ args: Args;
242
+ internalArgs: InternalArgs;
243
+ serverArgs: ServerArgs;
244
+ }
245
+ : SliceInfoEmptyParts;
246
+ export type SliceInfoRefName<S> = SliceInfoParts<S>["refName"];
247
+ export type SliceInfoInput<S> = SliceInfoParts<S>["input"];
248
+ export type SliceInfoFull<S> = SliceInfoParts<S>["full"];
249
+ export type SliceInfoLight<S> = SliceInfoParts<S>["light"];
250
+ export type SliceInfoInsight<S> = SliceInfoParts<S>["insight"];
251
+ export type SliceInfoFilter<S> = SliceInfoParts<S>["filter"];
252
+ export type SliceInfoSrvs<S> = SliceInfoParts<S>["srvs"];
253
+ export type SliceInfoArgNames<S> = SliceInfoParts<S>["argNames"];
254
+ export type SliceInfoArgs<S> = SliceInfoParts<S>["args"];
255
+ export type SliceInfoInternalArgs<S> = SliceInfoParts<S>["internalArgs"];
256
+ export type SliceInfoServerArgs<S> = SliceInfoParts<S>["serverArgs"];
227
257
 
228
258
  export type SliceBuilder<
229
259
  SrvModule extends ServiceModel,
230
- _Input = NonNullable<SrvModule["cnst"]>["_Input"],
231
- _Full = NonNullable<SrvModule["cnst"]>["_Full"],
232
- _Light = NonNullable<SrvModule["cnst"]>["_Light"],
233
- _Insight = NonNullable<SrvModule["cnst"]>["_Insight"],
234
- _Filter extends FilterInstance = NonNullable<SrvModule["db"]>["_Filter"],
235
- _Sort = ExtractSort<_Filter>,
260
+ _Input = CnstInput<SrvModule>,
261
+ _Full = CnstFull<SrvModule>,
262
+ _Light = CnstLight<SrvModule>,
263
+ _Insight = CnstInsight<SrvModule>,
264
+ _Filter extends FilterInstance = DbFilter<SrvModule>,
265
+ _SliceInfo = SliceInfo<SrvRefName<SrvModule>, _Input, _Full, _Light, _Insight, _Filter, SrvMap<SrvModule>>,
236
266
  > = (
237
267
  init: (
238
268
  signalOption?: SignalOption,
239
- ) => SliceInfo<
240
- SrvModule["srv"]["refName"],
241
- _Input,
242
- _Full,
243
- _Light,
244
- _Insight,
245
- _Filter,
246
- SrvModule["srvMap"],
247
- [],
248
- [],
249
- [],
250
- []
251
- >,
252
- ) => {
253
- [key: string]: SliceInfo<SrvModule["srv"]["refName"], _Input, _Full, _Light, _Insight, _Filter, SrvModule["srvMap"]>;
254
- };
269
+ ) => SliceInfo<SrvRefName<SrvModule>, _Input, _Full, _Light, _Insight, _Filter, SrvMap<SrvModule>, [], [], [], []>,
270
+ ) => Record<string, _SliceInfo>;