@akanjs/cli 0.9.55 → 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.
Files changed (65) hide show
  1. package/cjs/index.js +26 -34
  2. package/cjs/src/guidelines/databaseModule/databaseModule.instruction.md +7 -1
  3. package/cjs/src/guidelines/modelSignal/modelSignal.instruction.md +3 -3
  4. package/cjs/src/guidelines/modelTemplate/modelTemplate.instruction.md +5 -5
  5. package/cjs/src/guidelines/sharedUiUsage/sharedUiUsage.generate.json +0 -7
  6. package/cjs/src/guidelines/sharedUiUsage/sharedUiUsage.instruction.md +7 -7
  7. package/cjs/src/templates/__scalar/__model__/__model__.constant.js +0 -1
  8. package/cjs/src/templates/__scalar/__model__/__model__.dictionary.js +1 -3
  9. package/cjs/src/templates/app/instrumentation.js +32 -0
  10. package/cjs/src/templates/app/lib/___appName__/__appName__.dictionary.js +2 -6
  11. package/cjs/src/templates/app/lib/___appName__/__appName__.signal.js +5 -3
  12. package/cjs/src/templates/app/lib/option.js +6 -1
  13. package/cjs/src/templates/app/main.js +2 -2
  14. package/cjs/src/templates/lib/__lib/lib.dictionary.js +1 -2
  15. package/cjs/src/templates/lib/dict.js +22 -6
  16. package/cjs/src/templates/lib/sig.js +5 -2
  17. package/cjs/src/templates/lib/useClient.js +5 -4
  18. package/cjs/src/templates/libRoot/lib/option.js +5 -1
  19. package/cjs/src/templates/module/__Model__.Template.js +2 -2
  20. package/cjs/src/templates/module/__Model__.Util.js +8 -1
  21. package/cjs/src/templates/module/__model__.constant.js +3 -8
  22. package/cjs/src/templates/module/__model__.dictionary.js +21 -61
  23. package/cjs/src/templates/module/__model__.document.js +7 -2
  24. package/cjs/src/templates/module/__model__.signal.js +14 -28
  25. package/cjs/src/templates/module/__model__.store.js +1 -2
  26. package/cjs/src/templates/server.js +11 -3
  27. package/cjs/src/templates/workspaceRoot/.gitignore.template +2 -0
  28. package/esm/index.js +26 -34
  29. package/esm/src/guidelines/databaseModule/databaseModule.instruction.md +7 -1
  30. package/esm/src/guidelines/modelSignal/modelSignal.instruction.md +3 -3
  31. package/esm/src/guidelines/modelTemplate/modelTemplate.instruction.md +5 -5
  32. package/esm/src/guidelines/sharedUiUsage/sharedUiUsage.generate.json +0 -7
  33. package/esm/src/guidelines/sharedUiUsage/sharedUiUsage.instruction.md +7 -7
  34. package/esm/src/templates/__scalar/__model__/__model__.constant.js +0 -1
  35. package/esm/src/templates/__scalar/__model__/__model__.dictionary.js +1 -3
  36. package/esm/src/templates/app/instrumentation.js +12 -0
  37. package/esm/src/templates/app/lib/___appName__/__appName__.dictionary.js +2 -6
  38. package/esm/src/templates/app/lib/___appName__/__appName__.signal.js +5 -3
  39. package/esm/src/templates/app/lib/option.js +6 -1
  40. package/esm/src/templates/app/main.js +2 -2
  41. package/esm/src/templates/lib/__lib/lib.dictionary.js +1 -2
  42. package/esm/src/templates/lib/dict.js +22 -6
  43. package/esm/src/templates/lib/sig.js +5 -2
  44. package/esm/src/templates/lib/useClient.js +5 -4
  45. package/esm/src/templates/libRoot/lib/option.js +5 -1
  46. package/esm/src/templates/module/__Model__.Template.js +2 -2
  47. package/esm/src/templates/module/__Model__.Util.js +8 -1
  48. package/esm/src/templates/module/__model__.constant.js +3 -8
  49. package/esm/src/templates/module/__model__.dictionary.js +21 -61
  50. package/esm/src/templates/module/__model__.document.js +7 -2
  51. package/esm/src/templates/module/__model__.signal.js +14 -28
  52. package/esm/src/templates/module/__model__.store.js +1 -2
  53. package/esm/src/templates/server.js +11 -3
  54. package/esm/src/templates/workspaceRoot/.gitignore.template +2 -0
  55. package/package.json +1 -1
  56. package/src/guidelines/databaseModule/databaseModule.instruction.md +7 -1
  57. package/src/guidelines/modelSignal/modelSignal.instruction.md +3 -3
  58. package/src/guidelines/modelTemplate/modelTemplate.instruction.md +5 -5
  59. package/src/guidelines/sharedUiUsage/sharedUiUsage.instruction.md +7 -7
  60. package/src/module/module.command.d.ts +1 -1
  61. package/src/module/module.runner.d.ts +1 -1
  62. package/src/module/module.script.d.ts +1 -1
  63. package/src/scalar/scalar.command.d.ts +1 -1
  64. package/src/scalar/scalar.script.d.ts +1 -1
  65. package/src/templates/app/instrumentation.d.ts +6 -0
@@ -24,66 +24,26 @@ __export(model_dictionary_exports, {
24
24
  module.exports = __toCommonJS(model_dictionary_exports);
25
25
  function getContent(scanInfo, dict) {
26
26
  return `
27
- import { baseTrans, getBaseSignalTrans, ModelDictionary, SignalDictionary } from "@akanjs/dictionary";
28
-
29
- import type { ${dict.Model}, ${dict.Model}Filter, ${dict.Model}Insight, ${dict.Model}Summary } from "./${dict.model}.constant";
30
- import type { ${dict.Model}Signal } from "./${dict.model}.signal";
31
-
32
- export const modelDictionary = {
33
- ...baseTrans,
34
- modelName: ["${dict.Model}", "${dict.Model}"],
35
- modelDesc: [
36
- "${dict.Model} description",
37
- "${dict.Model} \uC124\uBA85",
38
- ],
39
-
40
- // * ==================== Model ==================== * //
41
- field: ["Field", "\uD544\uB4DC"],
42
- "desc-field": ["Field", "\uD544\uB4DC"],
43
- // * ==================== Model ==================== * //
44
-
45
- // * ==================== Insight ==================== * //
46
- count: ["Count", "\uAC1C\uC218"],
47
- "desc-count": ["${dict.Model} count in current query settting", "\uD604\uC7AC \uCFFC\uB9AC \uC124\uC815\uC5D0 \uB9DE\uB294 \uBC30\uB108 \uC218"],
48
- // * ==================== Insight ==================== * //
49
-
50
- // * ==================== Filter ==================== * //
51
- "qry-inStatus": ["In Status", "\uC0C1\uD0DC"],
52
- "qrydesc-inStatus": ["Filter by status", "\uC0C1\uD0DC\uBCC4 \uD544\uD130\uB9C1"],
53
- "qarg-inStatus-status": ["Status", "\uC0C1\uD0DC"],
54
- "qargdesc-inStatus-status": ["Filter by status", "\uC0C1\uD0DC\uBCC4 \uD544\uD130\uB9C1"],
55
- // * ==================== Filter ==================== * //
56
-
57
- // * ==================== Etc ==================== * //
58
- "enum-status-active": ["Active", "\uD65C\uC131"],
59
- "enumdesc-status-active": ["Active status", "\uD65C\uC131 \uC0C1\uD0DC"],
60
- // * ==================== Etc ==================== * //
61
- } satisfies ModelDictionary<${dict.Model}, ${dict.Model}Insight, ${dict.Model}Filter>;
62
-
63
- export const signalDictionary = {
64
- ...getBaseSignalTrans("${dict.model}" as const),
65
- // * ==================== Endpoint ==================== * //
66
- "api-${dict.model}ListInPublic": ["${dict.Model} List In Public", "\uACF5\uAC1C\uB41C ${dict.Model} \uB9AC\uC2A4\uD2B8"],
67
- "apidesc-${dict.model}ListInPublic": ["Get a list of public ${dict.model}", "\uACF5\uAC1C\uB41C ${dict.Model}\uC758 \uB9AC\uC2A4\uD2B8\uB97C \uAC00\uC838\uC635\uB2C8\uB2E4"],
68
- "arg-${dict.model}ListInPublic-statuses": ["Statuses", "\uC0C1\uD0DC"],
69
- "argdesc-${dict.model}ListInPublic-statuses": ["Statuses to filter", "\uD544\uD130\uB9C1\uD560 \uC0C1\uD0DC"],
70
- "arg-${dict.model}ListInPublic-skip": ["Skip", "\uAC74\uB108\uB6F0\uAE30"],
71
- "argdesc-${dict.model}ListInPublic-skip": ["Number of items to skip", "\uAC74\uB108\uB6F8 \uC544\uC774\uD15C \uC218"],
72
- "arg-${dict.model}ListInPublic-limit": ["Limit", "\uC81C\uD55C"],
73
- "argdesc-${dict.model}ListInPublic-limit": ["Maximum number of items to return", "\uBC18\uD658\uD560 \uCD5C\uB300 \uC544\uC774\uD15C \uC218"],
74
- "arg-${dict.model}ListInPublic-sort": ["Sort", "\uC815\uB82C"],
75
- "argdesc-${dict.model}ListInPublic-sort": ["Sort order of the items", "\uC544\uC774\uD15C\uC758 \uC815\uB82C \uC21C\uC11C"],
76
-
77
- "api-${dict.model}InsightInPublic": ["${dict.Model} Insight In Public", "\uACF5\uAC1C\uB41C ${dict.Model} \uC778\uC0AC\uC774\uD2B8"],
78
- "apidesc-${dict.model}InsightInPublic": [
79
- "Get insight data for public ${dict.model}",
80
- "\uACF5\uAC1C\uB41C ${dict.Model}\uC5D0 \uB300\uD55C \uC778\uC0AC\uC774\uD2B8 \uB370\uC774\uD130\uB97C \uAC00\uC838\uC635\uB2C8\uB2E4",
81
- ],
82
- "arg-${dict.model}InsightInPublic-statuses": ["Statuses", "\uC0C1\uD0DC"],
83
- "argdesc-${dict.model}InsightInPublic-statuses": ["Statuses to filter", "\uD544\uD130\uB9C1\uD560 \uC0C1\uD0DC"],
84
- // * ==================== Endpoint ==================== * //
85
- } satisfies SignalDictionary<${dict.Model}Signal, ${dict.Model}>;
86
-
87
- export const ${dict.model}Dictionary = { ...modelDictionary, ...signalDictionary };
27
+ import { modelDictionary } from "@akanjs/dictionary";
28
+
29
+ import type { ${dict.Model}, ${dict.Model}Insight } from "./${dict.model}.constant";
30
+ import type { ${dict.Model}Filter } from "./${dict.model}.document";
31
+ import type { ${dict.Model}Endpoint, ${dict.Model}Slice } from "./${dict.model}.signal";
32
+
33
+ export const dictionary = modelDictionary(["en", "ko"])
34
+ .of((t) =>
35
+ t(["${dict.Model}", "${dict.Model}"]).desc(["${dict.Model} description", "${dict.Model} \uC124\uBA85"])
36
+ )
37
+ .model<${dict.Model}>((t) => ({
38
+ field: t(["Field", "\uD544\uB4DC"]).desc(["Field description", "\uD544\uB4DC \uC124\uBA85"]),
39
+ }))
40
+ .insight<${dict.Model}Insight>((t) => ({}))
41
+ .query<${dict.Model}Filter>((fn) => ({}))
42
+ .slice<${dict.Model}Slice>((fn) => ({
43
+ inPublic: fn(["${dict.Model} In Public", "${dict.Model} \uACF5\uAC1C"]).arg((t) => ({})),
44
+ }))
45
+ .endpoint<${dict.Model}Endpoint>((fn) => ({}))
46
+ .error({})
47
+ .translate({});
88
48
  `;
89
49
  }
@@ -24,13 +24,18 @@ __export(model_document_exports, {
24
24
  module.exports = __toCommonJS(model_document_exports);
25
25
  function getContent(scanInfo, dict) {
26
26
  return `
27
- import { beyond, by, into, type SchemaOf } from "@akanjs/document";
27
+ import { beyond, by, from, into, type SchemaOf } from "@akanjs/document";
28
28
 
29
29
  import * as cnst from "../cnst";
30
30
 
31
+ export class ${dict.Model}Filter extends from(cnst.${dict.Model}, (filter) => ({
32
+ query: {},
33
+ sort: {},
34
+ })) {}
35
+
31
36
  export class ${dict.Model} extends by(cnst.${dict.Model}) {}
32
37
 
33
- export class ${dict.Model}Model extends into(${dict.Model}, cnst.${dict.model}) {}
38
+ export class ${dict.Model}Model extends into(${dict.Model}, ${dict.Model}Filter, cnst.${dict.model}) {}
34
39
 
35
40
  export class ${dict.Model}Middleware extends beyond(${dict.Model}Model, ${dict.Model}) {
36
41
  onSchema(schema: SchemaOf<${dict.Model}Model, ${dict.Model}>) {
@@ -24,36 +24,22 @@ __export(model_signal_exports, {
24
24
  module.exports = __toCommonJS(model_signal_exports);
25
25
  function getContent(scanInfo, dict) {
26
26
  return `
27
- import { Int } from "@akanjs/base";
28
- import type { SortOf } from "@akanjs/document";
29
- import { Arg, signal, Mutation, Query, resolve } from "@akanjs/signal";
27
+ import { Public } from "@akanjs/nest";
28
+ import { endpoint, internal, slice } from "@akanjs/signal";
29
+ import { Admin } from "@shared/nest";
30
30
 
31
31
  import * as cnst from "../cnst";
32
+ import * as srv from "../srv";
32
33
 
33
- export class ${dict.Model}Signal extends signal(cnst.${dict.model}, cnst.Srvs, {
34
- guards: { get: "Public", cru: "Public },
35
- }) {
36
- // * /////////////////////////////////////
37
- // * Public Slice
38
- @Query.Public(() => [cnst.${dict.Model}])
39
- async ${dict.model}ListInPublic(
40
- @Arg.Query("statuses", () => [String], { nullable: true }) statuses: cnst.${dict.Model}Status[] | null,
41
- @Arg.Query("skip", () => Int, { nullable: true }) skip: number | null,
42
- @Arg.Query("limit", () => Int, { nullable: true }) limit: number | null,
43
- @Arg.Query("sort", () => String, { nullable: true }) sort: SortOf<cnst.${dict.Model}Filter> | null
44
- ) {
45
- const ${dict.models} = await this.${dict.model}Service.listByStatuses(statuses, { skip, limit, sort });
46
- return resolve<cnst.${dict.Model}[]>(${dict.models});
47
- }
48
- @Query.Public(() => cnst.${dict.Model}Insight)
49
- async ${dict.model}InsightInPublic(
50
- @Arg.Query("statuses", () => [String], { nullable: true }) statuses: cnst.${dict.Model}Status[] | null
51
- ) {
52
- const ${dict.model}Insight = await this.${dict.model}Service.insightByStatuses(statuses);
53
- return resolve<cnst.${dict.Model}Insight>(${dict.model}Insight);
54
- }
55
- // * Public Slice
56
- // * /////////////////////////////////////
57
- }
34
+ export class ${dict.Model}Internal extends internal(srv.${dict.model}, () => ({})) {}
35
+
36
+ export class ${dict.Model}Slice extends slice(srv.${dict.model}, { guards: { root: Admin, get: Public, cru: Public } }, (init) => ({
37
+ inPublic: init()
38
+ .exec(function () {
39
+ return this.${dict.model}Service.queryAny();
40
+ }),
41
+ })) {}
42
+
43
+ export class ${dict.Model}Endpoint extends endpoint(srv.${dict.model}, () => ({})) {}
58
44
  `;
59
45
  }
@@ -26,8 +26,7 @@ function getContent(scanInfo, dict) {
26
26
  return `
27
27
  import { store } from "@akanjs/store";
28
28
 
29
- import * as cnst from "../cnst";
30
- import { fetch, sig } from "../useClient";
29
+ import { sig } from "../useClient";
31
30
 
32
31
  export class ${dict.Model}Store extends store(sig.${dict.model}, {
33
32
  // state
@@ -31,15 +31,15 @@ function getContent(scanInfo, dict = {}) {
31
31
  const serviceModules = [...scanInfo.service.entries()].filter(([_, files]) => files.has("service"));
32
32
  const scalarModules = [...scanInfo.scalar.entries()];
33
33
  return `
34
- import { databaseModuleOf, scalarModulesOf, serviceModuleOf, type Module } from "@akanjs/server";
35
- ${libs.map((lib) => `import { registerModules as register${capitalize(lib)}Modules } from "@${lib}/server";`).join("\n")}
34
+ import { databaseModuleOf, scalarModulesOf, serviceModuleOf, type Module, type Middleware } from "@akanjs/server";
35
+ ${libs.map((lib) => `import { registerModules as register${capitalize(lib)}Modules, registerMiddlewares as register${capitalize(lib)}Middlewares } from "@${lib}/server";`).join("\n")}
36
36
 
37
37
  import * as cnst from "./lib/cnst";
38
38
  import * as db from "./lib/db";
39
39
  import * as srv from "./lib/srv";
40
40
  import { allSrvs } from "./lib/srv";
41
41
  import * as sig from "./lib/sig";
42
- import { type ModulesOptions, registerGlobalModule } from "./lib/option";
42
+ import { type ModulesOptions, registerGlobalModule, registerGlobalMiddlewares } from "./lib/option";
43
43
 
44
44
  // database modules
45
45
  ${databaseModules.map(([model]) => {
@@ -67,6 +67,14 @@ ${databaseModules.map(([model]) => ` register${capitalize(model)}Module(),`).
67
67
  return modules;
68
68
  };
69
69
 
70
+ export const registerMiddlewares = (options: ModulesOptions, isChild?: boolean) => {
71
+ const middlewares = [
72
+ ${libs.map((lib) => ` ...(!isChild ? register${capitalize(lib)}Middlewares(options, true) : []),`).join("\n")}
73
+ ...registerGlobalMiddlewares(options),
74
+ ] as Middleware[];
75
+ return middlewares;
76
+ };
77
+
70
78
  export { env } from "./env/env.server.testing";
71
79
  export * as db from "./lib/db";
72
80
  export * as srv from "./lib/srv";
@@ -11,10 +11,12 @@ apps/*/data
11
11
  /releases
12
12
  apps/*/scripts
13
13
  **/.env
14
+ **/env.client.local.ts
14
15
  **/env.client.debug.ts
15
16
  **/env.client.develop.ts
16
17
  **/env.client.main.ts
17
18
  **/env.client.testing.ts
19
+ **/env.server.local.ts
18
20
  **/env.server.debug.ts
19
21
  **/env.server.develop.ts
20
22
  **/env.server.main.ts
package/esm/index.js CHANGED
@@ -208,7 +208,7 @@ var Logger = class _Logger {
208
208
  const contentMsg = this.#colorize(content, logLevel);
209
209
  const timeDiffMsg = clc.yellow(`+${now.diff(_Logger.#startAt, "ms")}ms`);
210
210
  if (typeof window === "undefined")
211
- process[writeStreamType].write(
211
+ process[writeStreamType]?.write(
212
212
  `${processMsg} ${timestampMsg} ${logLevelMsg} ${contextMsg} ${contentMsg} ${timeDiffMsg}
213
213
  `
214
214
  );
@@ -1986,10 +1986,10 @@ var Executor = class _Executor {
1986
1986
  this.logger.verbose(`Remove file ${readPath}`);
1987
1987
  return this;
1988
1988
  }
1989
- removeDir(dirPath) {
1989
+ async removeDir(dirPath) {
1990
1990
  const readPath = this.getPath(dirPath);
1991
1991
  if (fs8.existsSync(readPath))
1992
- fs8.rmSync(readPath, { recursive: true });
1992
+ await fs8.promises.rm(readPath, { recursive: true });
1993
1993
  this.logger.verbose(`Remove directory ${readPath}`);
1994
1994
  return this;
1995
1995
  }
@@ -2037,7 +2037,8 @@ var Executor = class _Executor {
2037
2037
  const dest = this.getPath(destPath);
2038
2038
  if (!fs8.existsSync(src))
2039
2039
  return;
2040
- if (!fs8.existsSync(dest))
2040
+ const isDirectory = fs8.statSync(src).isDirectory();
2041
+ if (!fs8.existsSync(dest) && isDirectory)
2041
2042
  await fsPromise.mkdir(dest, { recursive: true });
2042
2043
  await fsPromise.cp(src, dest, { recursive: true });
2043
2044
  }
@@ -2592,32 +2593,23 @@ var AppExecutor = class _AppExecutor extends SysExecutor {
2592
2593
  return this.#akanConfig;
2593
2594
  }
2594
2595
  async syncAssets(libDeps) {
2595
- const projectPublicLibPath = `${this.cwdPath}/public/libs`;
2596
- const projectAssetsLibPath = `${this.cwdPath}/assets/libs`;
2596
+ const projectPublicPath = `${this.cwdPath}/public`;
2597
+ const projectAssetsPath = `${this.cwdPath}/assets`;
2598
+ const projectPublicLibPath = `${projectPublicPath}/libs`;
2599
+ const projectAssetsLibPath = `${projectAssetsPath}/libs`;
2600
+ await Promise.all([this.removeDir(projectPublicLibPath), this.removeDir(projectAssetsLibPath)]);
2601
+ const targetPublicDeps = libDeps.filter((dep) => this.exists(`${this.workspace.workspaceRoot}/libs/${dep}/public`));
2602
+ const targetAssetsDeps = libDeps.filter((dep) => this.exists(`${this.workspace.workspaceRoot}/libs/${dep}/assets`));
2597
2603
  await Promise.all([
2598
- fs8.existsSync(projectPublicLibPath) && fsPromise.rm(projectPublicLibPath, { recursive: true }),
2599
- fs8.existsSync(projectAssetsLibPath) && fsPromise.rm(projectAssetsLibPath, { recursive: true })
2600
- ]);
2601
- const targetPublicDeps = libDeps.filter(
2602
- (dep) => fs8.existsSync(`${this.workspace.workspaceRoot}/libs/${dep}/public`)
2603
- );
2604
- const targetAssetsDeps = libDeps.filter(
2605
- (dep) => fs8.existsSync(`${this.workspace.workspaceRoot}/libs/${dep}/assets`)
2606
- );
2607
- await Promise.all([
2608
- ...targetPublicDeps.map((dep) => fsPromise.mkdir(`${projectPublicLibPath}/${dep}`, { recursive: true })),
2609
- ...targetAssetsDeps.map((dep) => fsPromise.mkdir(`${projectAssetsLibPath}/${dep}`, { recursive: true }))
2604
+ ...targetPublicDeps.map((dep) => this.mkdir(`${projectPublicLibPath}/${dep}`)),
2605
+ ...targetAssetsDeps.map((dep) => this.mkdir(`${projectAssetsLibPath}/${dep}`))
2610
2606
  ]);
2611
2607
  await Promise.all([
2612
2608
  ...targetPublicDeps.map(
2613
- (dep) => fsPromise.cp(`${this.workspace.workspaceRoot}/libs/${dep}/public`, `${projectPublicLibPath}/${dep}`, {
2614
- recursive: true
2615
- })
2609
+ (dep) => this.cp(`${this.workspace.workspaceRoot}/libs/${dep}/public`, `${projectPublicLibPath}/${dep}`)
2616
2610
  ),
2617
2611
  ...targetAssetsDeps.map(
2618
- (dep) => fsPromise.cp(`${this.workspace.workspaceRoot}/libs/${dep}/assets`, `${projectAssetsLibPath}/${dep}`, {
2619
- recursive: true
2620
- })
2612
+ (dep) => this.cp(`${this.workspace.workspaceRoot}/libs/${dep}/assets`, `${projectAssetsLibPath}/${dep}`)
2621
2613
  )
2622
2614
  ]);
2623
2615
  }
@@ -5923,8 +5915,8 @@ var requestUnit = ({
5923
5915
  var ModuleRunner = class {
5924
5916
  async createModule(workspace, sysType, sysName, moduleName, description) {
5925
5917
  }
5926
- removeModule(module) {
5927
- module.sys.removeDir(`lib/${module.name}`);
5918
+ async removeModule(module) {
5919
+ await module.sys.removeDir(`lib/${module.name}`);
5928
5920
  }
5929
5921
  async createComponentTemplate(module, type) {
5930
5922
  await module.sys.applyTemplate({
@@ -6061,8 +6053,8 @@ var ModuleScript = class {
6061
6053
  await this.createTemplate(executor);
6062
6054
  sys3.log(`Module ${name} created in ${sys3.type}s/${sys3.name}/lib/${name}`);
6063
6055
  }
6064
- removeModule(mod) {
6065
- this.#runner.removeModule(mod);
6056
+ async removeModule(mod) {
6057
+ await this.#runner.removeModule(mod);
6066
6058
  }
6067
6059
  async createService(workspace, name) {
6068
6060
  }
@@ -6140,8 +6132,8 @@ var ModuleCommand = class {
6140
6132
  const name = lowerlize(moduleName.replace(/ /g, ""));
6141
6133
  await this.moduleScript.createModuleTemplate(sys3, name, { page });
6142
6134
  }
6143
- removeModule(module) {
6144
- this.moduleScript.removeModule(module);
6135
+ async removeModule(module) {
6136
+ await this.moduleScript.removeModule(module);
6145
6137
  }
6146
6138
  async createView(module) {
6147
6139
  await this.moduleScript.createView(module);
@@ -6940,8 +6932,8 @@ var ScalarScript = class {
6940
6932
  const { session, scalarNames } = await this.#runner.createScalarConstant(sys3, scalarName);
6941
6933
  await this.#runner.updateScalarDictionaries(sys3, scalarNames, { session });
6942
6934
  }
6943
- removeScalar(sys3, scalarName) {
6944
- sys3.removeDir(`lib/__scalar/${scalarName}`);
6935
+ async removeScalar(sys3, scalarName) {
6936
+ await sys3.removeDir(`lib/__scalar/${scalarName}`);
6945
6937
  }
6946
6938
  };
6947
6939
 
@@ -6951,8 +6943,8 @@ var ScalarCommand = class {
6951
6943
  async createScalar(sys3, scalarName) {
6952
6944
  await this.scalarScript.createScalar(sys3, lowerlize(scalarName.replace(/ /g, "")));
6953
6945
  }
6954
- removeScalar(sys3, scalarName) {
6955
- this.scalarScript.removeScalar(sys3, scalarName);
6946
+ async removeScalar(sys3, scalarName) {
6947
+ await this.scalarScript.removeScalar(sys3, scalarName);
6956
6948
  }
6957
6949
  };
6958
6950
  __decorateClass([
@@ -207,7 +207,7 @@ import * as cnst from "../cnst";
207
207
  import type * as db from "../db";
208
208
 
209
209
  export class UserSignal extends DbSignal(cnst.userCnst, cnst.Srvs, {
210
- guards: { get: Query.Public, cru: Mutation.Admin },
210
+ guards: { root: Admin, get: Query.Public, cru: Mutation.Admin },
211
211
  }) {
212
212
  @Mutation.Public(() => cnst.util.AccessToken)
213
213
  async signin(
@@ -578,30 +578,36 @@ export const Layout = () => (
578
578
  ## Best Practices
579
579
 
580
580
  1. **Naming Conventions**
581
+
581
582
  - Use PascalCase for classes and components (e.g., `UserService`, `User.Unit.tsx`)
582
583
  - Use camelCase for files (e.g., `user.service.ts`, `user.document.ts`)
583
584
 
584
585
  2. **Security**
586
+
585
587
  - Use `@Field.Secret` for sensitive data like passwords
586
588
  - Apply proper permission guards to queries and mutations (`@Query.Admin`, `@Mutation.Public`)
587
589
  - Validate input data using the `validate` option in `@Field.Prop`
588
590
 
589
591
  3. **Code Organization**
592
+
590
593
  - Keep business logic in service files
591
594
  - Use signals for API calls only, not for business logic
592
595
  - Define reusable utility methods in document models
593
596
 
594
597
  4. **Performance**
598
+
595
599
  - Use dataloader pattern (`@Loader.ByField`) for efficient database access
596
600
  - Create proper indexes in the middleware
597
601
  - Use projections to limit returned fields when appropriate
598
602
 
599
603
  5. **Testing**
604
+
600
605
  - Create signal tests for each API endpoint
601
606
  - Mock services for unit testing signals
602
607
  - Use integration tests for testing complex workflows
603
608
 
604
609
  6. **UI Components**
610
+
605
611
  - Follow the separation between Template, Unit, View, and Zone components
606
612
  - Make components reusable across different parts of the application
607
613
  - Use dictionary files for all UI text to support internationalization
@@ -27,7 +27,7 @@ import * as cnst from "../cnst";
27
27
  import type * as db from "../db";
28
28
 
29
29
  export class ModelNameSignal extends DbSignal(cnst.modelNameCnst, cnst.Srvs, {
30
- guards: { get: Query.Public, cru: Mutation.User },
30
+ guards: { root: Admin, get: Query.Public, cru: Mutation.User },
31
31
  }) {
32
32
  // Signal methods here...
33
33
  }
@@ -259,7 +259,7 @@ DbSignal creates standard operations that you don't need to implement:
259
259
 
260
260
  ```typescript
261
261
  export class BoardSignal extends DbSignal(cnst.boardCnst, cnst.Srvs, {
262
- guards: { get: Query.Public, cru: Mutation.Admin },
262
+ guards: { root: Admin, get: Query.Public, cru: Mutation.Admin },
263
263
  }) {
264
264
  // Custom methods beyond CRUD go here
265
265
  }
@@ -378,7 +378,7 @@ async getProjectDetails(
378
378
 
379
379
  ```typescript
380
380
  export class ProductSignal extends DbSignal(cnst.productCnst, cnst.Srvs, {
381
- guards: { get: Query.Public, cru: Mutation.Admin },
381
+ guards: { root: Admin, get: Query.Public, cru: Mutation.Admin },
382
382
  }) {
383
383
  // Custom methods beyond auto-generated CRUD
384
384
  @Query.Public(() => [cnst.Product])
@@ -49,7 +49,7 @@ export const General = ({ id }: { id?: string }) => {
49
49
  return (
50
50
  <div className="grid grid-cols-1 gap-4">
51
51
  <Field.Text
52
- label={l.field("model", "fieldName")}
52
+ label={l("model.fieldName")}
53
53
  value={form.fieldName}
54
54
  onChange={(v) => st.do.setFieldNameOn[Model](v)}
55
55
  />
@@ -139,7 +139,7 @@ useEffect(() => {
139
139
 
140
140
  ```tsx
141
141
  <Field.List
142
- label={l.field("map", "spawnPositions")}
142
+ label={l("map.spawnPositions")}
143
143
  value={form.spawnPositions}
144
144
  onAdd={() => st.do.addSpawnPosition(defaultPosition)}
145
145
  renderItem={(position, idx) => (
@@ -201,12 +201,12 @@ useEffect(() => {
201
201
  const { l } = usePage();
202
202
 
203
203
  // Basic field
204
- <Field.Text label={l.field("model", "name")} />
204
+ <Field.Text label={l("model.name")} />
205
205
 
206
206
  // With description
207
207
  <Field.Text
208
- label={l.field("model", "email")}
209
- desc={l.desc("model", "email")}
208
+ label={l("model.email")}
209
+ desc={l("model.email.desc")}
210
210
  />
211
211
 
212
212
  // Dynamic content
@@ -85,13 +85,6 @@
85
85
  "path": "{apps,libs}/*/lib/*/*.{Template,Unit,View,Zone}.tsx",
86
86
  "filterText": "sliceName",
87
87
  "sample": 5
88
- },
89
- {
90
- "type": "example",
91
- "description": "Internationalization usage examples",
92
- "path": "{apps,libs}/*/lib/*/*.{Template,Unit,View}.tsx",
93
- "filterText": "l.field",
94
- "sample": 3
95
88
  }
96
89
  ],
97
90
  "update": {
@@ -64,8 +64,8 @@ const MyComponent = () => {
64
64
  return (
65
65
  <>
66
66
  <Field.Text
67
- label={l.field("myModel", "title")}
68
- desc={l.desc("myModel", "title")}
67
+ label={l("myModel.title")}
68
+ desc={l("myModel.title.desc")}
69
69
  value={formState.title}
70
70
  onChange={(value) => st.do.setTitleOnMyModel(value)}
71
71
  nullable={false}
@@ -73,8 +73,8 @@ const MyComponent = () => {
73
73
  />
74
74
 
75
75
  <Field.Number
76
- label={l.field("myModel", "amount")}
77
- desc={l.desc("myModel", "amount")}
76
+ label={l("myModel.amount")}
77
+ desc={l("myModel.amount.desc")}
78
78
  value={formState.amount}
79
79
  onChange={(value) => st.do.setAmountOnMyModel(value)}
80
80
  min={0}
@@ -83,8 +83,8 @@ const MyComponent = () => {
83
83
  />
84
84
 
85
85
  <Field.ToggleSelect
86
- label={l.field("myModel", "status")}
87
- desc={l.desc("myModel", "status")}
86
+ label={l("myModel.status")}
87
+ desc={l("myModel.status.desc")}
88
88
  value={formState.status}
89
89
  items={cnst.Status}
90
90
  onChange={(status) => st.do.setStatusOnMyModel(status)}
@@ -266,7 +266,7 @@ Components automatically integrate with the internationalization system:
266
266
  ```tsx
267
267
  const { l } = usePage();
268
268
 
269
- <Field.Text label={l.field("user", "name")} desc={l.desc("user", "name")} placeholder={l("user.namePlaceholder")} />;
269
+ <Field.Text label={l("user.name")} desc={l("user.name.desc")} placeholder={l("user.namePlaceholder")} />;
270
270
  ```
271
271
 
272
272
  ### State Management Integration
@@ -3,7 +3,6 @@ function getContent(scanInfo, dict) {
3
3
  return `
4
4
  import { via } from "@akanjs/constant";
5
5
 
6
-
7
6
  export class ${dict.Model} extends via((field) => ({
8
7
  field: field(String),
9
8
  })) {}
@@ -5,7 +5,7 @@ import { ModelDictionary } from "@akanjs/dictionary";
5
5
 
6
6
  import type { ${dict.Model} } from "./${dict.model}.constant";
7
7
 
8
- export const modelDictionary = {
8
+ export const dictionary = {
9
9
  modelName: ["${dict.Model}", "${dict.Model}"],
10
10
  modelDesc: ["${dict.Model}", "${dict.Model}"],
11
11
 
@@ -17,8 +17,6 @@ export const modelDictionary = {
17
17
  // * ==================== Etc ==================== * //
18
18
  // * ==================== Etc ==================== * //
19
19
  } satisfies ModelDictionary<${dict.Model}>;
20
-
21
- export const ${dict.model}Dictionary = modelDictionary;
22
20
  `;
23
21
  }
24
22
  export {
@@ -0,0 +1,12 @@
1
+ // pkgs/@akanjs/cli/src/templates/app/instrumentation.ts
2
+ function getContent(scanInfo, dict) {
3
+ return `
4
+ import { registerClient } from "./client";
5
+
6
+ export const register = async () => {
7
+ await registerClient();
8
+ };`;
9
+ }
10
+ export {
11
+ getContent as default
12
+ };
@@ -2,13 +2,9 @@
2
2
  function getContent(scanInfo, dict) {
3
3
  return `
4
4
  import type { SignalDictionary } from "@akanjs/dictionary";
5
- import type { ${dict.AppName}Signal } from "./${dict.appName}.signal";
5
+ import type { ${dict.AppName}Endpoint } from "./${dict.appName}.signal";
6
6
 
7
- const dictionary = {} as const;
8
-
9
- export const signalDictionary = {} satisfies SignalDictionary<${dict.AppName}Signal>;
10
-
11
- export const ${dict.appName}Dictionary = { ...dictionary, ...signalDictionary };
7
+ export const dictionary = {} satisfies SignalDictionary<${dict.AppName}Endpoint>;
12
8
  `;
13
9
  }
14
10
  export {
@@ -1,11 +1,13 @@
1
1
  // pkgs/@akanjs/cli/src/templates/app/lib/___appName__/__appName__.signal.ts
2
2
  function getContent(scanInfo, dict) {
3
3
  return `
4
- import { signal } from "@akanjs/signal";
4
+ import { endpoint, internal } from "@akanjs/signal";
5
5
 
6
- import * as cnst from "../cnst";
6
+ import * as srv from "../srv";
7
7
 
8
- export class ${dict.AppName}Signal extends signal("${dict.AppName}" as const, cnst.Srvs) {}
8
+ export class ${dict.AppName}Internal extends internal(srv.${dict.appName}, () => ({})) {}
9
+
10
+ export class ${dict.AppName}Endpoint extends endpoint(srv.${dict.appName}, () => ({})) {}
9
11
  `;
10
12
  }
11
13
  export {
@@ -1,7 +1,7 @@
1
1
  // pkgs/@akanjs/cli/src/templates/app/lib/option.ts
2
2
  function getContent(scanInfo, dict = {}) {
3
3
  return `
4
- import { useGlobals } from "@akanjs/server";
4
+ import { Middleware, useGlobals } from "@akanjs/server";
5
5
 
6
6
  import type { LibOptions } from "./__lib/lib.service";
7
7
 
@@ -15,6 +15,11 @@ export const registerGlobalModule = (options: ModulesOptions) => {
15
15
  useAsyncs: {},
16
16
  });
17
17
  };
18
+
19
+ export const registerGlobalMiddlewares = (options: ModulesOptions) => {
20
+ return [] as Middleware[];
21
+ };
22
+
18
23
  `;
19
24
  }
20
25
  export {
@@ -4,12 +4,12 @@ function getContent(scanInfo, dict) {
4
4
  import { createNestApp } from "@akanjs/server";
5
5
 
6
6
  import { env } from "./env/env.server";
7
- import { registerModules } from "./server";
7
+ import { registerModules, registerMiddlewares } from "./server";
8
8
 
9
9
  const bootstrap = async () => {
10
10
  const serverMode = process.env.SERVER_MODE as "federation" | "batch" | "all" | null;
11
11
  if (!serverMode) throw new Error("SERVER_MODE environment variable is not defined");
12
- await createNestApp({ registerModules, serverMode, env });
12
+ await createNestApp({ registerModules, registerMiddlewares, serverMode, env });
13
13
  };
14
14
  void bootstrap();
15
15
  `;
@@ -19,8 +19,7 @@ ${libs.map((lib) => `import { dict as ${lib} } from "@${lib}/server";`).join("\n
19
19
 
20
20
  ${Object.entries(extendedModels).map(([modelName, extendedModels2]) => {
21
21
  return `export const ${modelName} = {
22
- models: Object.assign({}, ${extendedModels2.map((libName) => `${libName}.${modelName}.modelDictionary`).join(", ")}),
23
- signals: Object.assign({}, ${extendedModels2.map((libName) => `${libName}.${modelName}.signalDictionary`).join(", ")}),
22
+ dictionaries: [${extendedModels2.map((libName) => `${libName}.${modelName}.dictionary`).join(", ")}] as const,
24
23
  };`;
25
24
  }).join("\n")}
26
25