@akanjs/cli 2.3.5-rc.3 → 2.3.5-rc.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/cli",
3
- "version": "2.3.5-rc.3",
3
+ "version": "2.3.5-rc.5",
4
4
  "sourceType": "module",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -35,7 +35,7 @@
35
35
  "@langchain/openai": "^1.4.6",
36
36
  "@tailwindcss/node": "^4.3.0",
37
37
  "@trapezedev/project": "^7.1.4",
38
- "akanjs": "2.3.5-rc.3",
38
+ "akanjs": "2.3.5-rc.5",
39
39
  "chalk": "^5.6.2",
40
40
  "commander": "^14.0.3",
41
41
  "daisyui": "^5.5.20",
@@ -13,12 +13,13 @@ export default function getContent(scanInfo: AppInfo | LibInfo | null, dict: { [
13
13
  const libs = scanInfo.getLibs();
14
14
 
15
15
  const signalNames = [...(libs.length === 0 ? ["base"] : libs), ...databaseModules, ...serviceModules];
16
- const fetchSignalChunks = Array.from({ length: Math.ceil(signalNames.length / 4) }, (_, idx) =>
17
- signalNames.slice(idx * 4, idx * 4 + 4),
18
- );
16
+ const importedFetchParts = (libs.length === 0 ? ["base"] : libs).map((signal) => `SafeFetchPart<typeof ${signal}>`);
17
+ const databaseFetchTypes = databaseModules.map((module) => `${capitalize(module)}Fetch`);
18
+ const serviceFetchTypes = serviceModules.map((module) => `${capitalize(module)}Fetch`);
19
+ const fetchTypeParts = [...importedFetchParts, ...databaseFetchTypes, ...serviceFetchTypes];
19
20
 
20
21
  return `
21
- import { FetchClient, type FetchClientType } from "akanjs/fetch";
22
+ import { FetchClient, type GetFetchTypeFromEndpoint, type GetFetchTypeFromSlice } from "akanjs/fetch";
22
23
  import { SignalRegistry, serverSignal${libs.length === 0 ? ", fetch as base" : ""} } from "akanjs/signal";
23
24
  ${libs.map((lib) => `import { fetch as ${lib} } from "@libs/${lib}/server";`).join("\n")}
24
25
 
@@ -59,10 +60,18 @@ ${databaseModules.map((module) => `export const ${module} = SignalRegistry.regis
59
60
  ${serviceModules.map((module) => `export const ${module} = SignalRegistry.registerService("${module}" as const, ${module}Sig.${capitalize(module)}Internal, ${module}Sig.${capitalize(module)}Endpoint, ${capitalize(module)});`).join("\n")}
60
61
 
61
62
  export const fetchSignals = [${signalNames.join(", ")}] as const;
62
- ${fetchSignalChunks
63
- .map((chunk, idx) => `type Fetch${idx} = FetchClientType<readonly [${chunk.map((signal) => `typeof ${signal}`).join(", ")}]>;`)
63
+ type IsAny<Type> = 0 extends 1 & Type ? true : false;
64
+ type SafeFetchPart<Type> = IsAny<Type> extends true ? unknown : Type;
65
+ ${databaseModules
66
+ .map(
67
+ (module) =>
68
+ `type ${capitalize(module)}Fetch = GetFetchTypeFromEndpoint<typeof ${module}Sig.${capitalize(module)}Endpoint, typeof ${module}Sig.${capitalize(module)}Slice> & GetFetchTypeFromSlice<typeof ${module}Sig.${capitalize(module)}Slice>;`,
69
+ )
70
+ .join("\n")}
71
+ ${serviceModules
72
+ .map((module) => `type ${capitalize(module)}Fetch = GetFetchTypeFromEndpoint<typeof ${module}Sig.${capitalize(module)}Endpoint>;`)
64
73
  .join("\n")}
65
- export type Fetch = ${fetchSignalChunks.map((_, idx) => `Fetch${idx}`).join(" & ")};
74
+ export type Fetch = ${fetchTypeParts.length ? fetchTypeParts.join(" &\n ") : "unknown"};
66
75
  export const fetch: Fetch = (FetchClient.from as (...signals: unknown[]) => unknown)(...fetchSignals) as Fetch;
67
76
 
68
77
  export const getSerializedSignal = () => fetch.serializedSignal