@akanjs/cli 0.9.42 → 0.9.43

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 (59) hide show
  1. package/cjs/index.js +16 -6
  2. package/cjs/src/guidelines/___library/sharedUiStructureDescription.en.md +0 -1
  3. package/cjs/src/guidelines/modelService/modelService.generate.json +0 -30
  4. package/cjs/src/guidelines/modelService/modelService.instruction.md +0 -164
  5. package/cjs/src/templates/app/lib/___appName__/__appName__.dictionary.js +6 -1
  6. package/cjs/src/templates/app/lib/___appName__/__appName__.service.js +1 -8
  7. package/cjs/src/templates/app/lib/___appName__/__appName__.signal.js +34 -0
  8. package/cjs/src/templates/app/lib/summary/Summary.Zone.js +1 -21
  9. package/cjs/src/templates/app/lib/user/User.Util.js +1 -26
  10. package/cjs/src/templates/app/lib/user/User.Zone.js +2 -30
  11. package/cjs/src/templates/app/lib/user/user.document.js +1 -7
  12. package/cjs/src/templates/app/lib/user/user.service.js +2 -8
  13. package/cjs/src/templates/lib/__lib/lib.service.js +1 -1
  14. package/cjs/src/templates/lib/cnst_.js +5 -2
  15. package/cjs/src/templates/lib/fetch.js +1 -1
  16. package/cjs/src/templates/lib/store.js +0 -1
  17. package/cjs/src/templates/libRoot/lib/summary/Summary.Zone.js +1 -21
  18. package/cjs/src/templates/libRoot/lib/user/User.Util.js +1 -26
  19. package/cjs/src/templates/libRoot/lib/user/User.Zone.js +2 -29
  20. package/cjs/src/templates/libRoot/lib/user/user.document.js +1 -7
  21. package/cjs/src/templates/libRoot/lib/user/user.service.js +2 -8
  22. package/cjs/src/templates/module/__Model__.Util.js +6 -36
  23. package/cjs/src/templates/module/__Model__.Zone.js +2 -26
  24. package/cjs/src/templates/module/__model__.document.js +1 -7
  25. package/cjs/src/templates/module/__model__.service.js +1 -7
  26. package/cjs/src/templates/workspaceRoot/.vscode/settings.json.template +0 -1
  27. package/esm/index.js +16 -6
  28. package/esm/src/guidelines/___library/sharedUiStructureDescription.en.md +0 -1
  29. package/esm/src/guidelines/modelService/modelService.generate.json +0 -30
  30. package/esm/src/guidelines/modelService/modelService.instruction.md +0 -164
  31. package/esm/src/templates/app/lib/___appName__/__appName__.dictionary.js +6 -1
  32. package/esm/src/templates/app/lib/___appName__/__appName__.service.js +1 -8
  33. package/esm/src/templates/app/lib/___appName__/__appName__.signal.js +14 -0
  34. package/esm/src/templates/app/lib/summary/Summary.Zone.js +1 -21
  35. package/esm/src/templates/app/lib/user/User.Util.js +1 -26
  36. package/esm/src/templates/app/lib/user/User.Zone.js +2 -30
  37. package/esm/src/templates/app/lib/user/user.document.js +1 -7
  38. package/esm/src/templates/app/lib/user/user.service.js +2 -8
  39. package/esm/src/templates/lib/__lib/lib.service.js +1 -1
  40. package/esm/src/templates/lib/cnst_.js +5 -2
  41. package/esm/src/templates/lib/fetch.js +1 -1
  42. package/esm/src/templates/lib/store.js +0 -1
  43. package/esm/src/templates/libRoot/lib/summary/Summary.Zone.js +1 -21
  44. package/esm/src/templates/libRoot/lib/user/User.Util.js +1 -26
  45. package/esm/src/templates/libRoot/lib/user/User.Zone.js +2 -29
  46. package/esm/src/templates/libRoot/lib/user/user.document.js +1 -7
  47. package/esm/src/templates/libRoot/lib/user/user.service.js +2 -8
  48. package/esm/src/templates/module/__Model__.Util.js +6 -36
  49. package/esm/src/templates/module/__Model__.Zone.js +2 -26
  50. package/esm/src/templates/module/__model__.document.js +1 -7
  51. package/esm/src/templates/module/__model__.service.js +1 -7
  52. package/esm/src/templates/workspaceRoot/.vscode/settings.json.template +0 -1
  53. package/package.json +1 -1
  54. package/src/guidelines/___library/sharedUiStructureDescription.en.md +0 -1
  55. package/src/guidelines/modelService/modelService.instruction.md +0 -164
  56. package/src/templates/app/{app/[lang]/admin/page.d.ts → lib/___appName__/__appName__.signal.d.ts} +2 -4
  57. package/ui/MultiScrollList.d.ts +4 -1
  58. package/cjs/src/templates/app/app/[lang]/admin/page.js +0 -63
  59. package/esm/src/templates/app/app/[lang]/admin/page.js +0 -43
@@ -13,13 +13,7 @@ export class UserInput extends by(rootUser.Input, cnst.UserInput) {}
13
13
  export class User extends by(rootUser.Doc, cnst.User) {}
14
14
 
15
15
  @Database.Model(() => cnst.User)
16
- export class UserModel extends into(User, cnst.userCnst) {
17
- async getSummary(): Promise<cnst.UserSummary> {
18
- return {
19
- ...(await this.getDefaultSummary()),
20
- };
21
- }
22
- }
16
+ export class UserModel extends into(User, cnst.userCnst) {}
23
17
 
24
18
  @Database.Middleware(() => cnst.User)
25
19
  export class UserMiddleware extends beyond(UserModel, User) {
@@ -8,14 +8,8 @@ import { cnst } from "../cnst";
8
8
  import * as db from "../db";
9
9
 
10
10
  @Service("UserService")
11
- export class UserService extends ExtendedUserService(db.userDb, LibUserService) {
12
- async summarize${dict.AppName}(): Promise<cnst.${dict.AppName}UserSummary> {
13
- return {
14
- ...(await this.userModel.getSummary()),
15
- };
16
- }
17
- }
18
- `;
11
+ export class UserService extends ExtendedUserService(db.userDb, LibUserService) {}
12
+ `;
19
13
  }
20
14
  export {
21
15
  getContent as default
@@ -37,7 +37,7 @@ ${databaseModulesWithoutExtendModels.map((module) => ` @Srv() protected readonl
37
37
  async get${capitalize(scanInfo.name)}Summary() {
38
38
  return {
39
39
  ${databaseModulesWithoutExtendModels.map((module) => ` ...(await this.${module}Service.summarize()),`).join("\n")}
40
- ...(await this.userService.summarize${capitalize(scanInfo.name)}()),
40
+ ...(await this.userService.summarize()),
41
41
  };
42
42
  }
43
43
  ${scanInfo.exec.type === "app" ? `
@@ -1,4 +1,5 @@
1
1
  // pkgs/@akanjs/cli/src/templates/lib/cnst_.ts
2
+ var capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);
2
3
  function getContent(scanInfo, dict = {}) {
3
4
  if (!scanInfo)
4
5
  return null;
@@ -6,10 +7,11 @@ function getContent(scanInfo, dict = {}) {
6
7
  const scalarModules = scanInfo.getScalarModules();
7
8
  const rootLib = scanInfo.akanConfig.rootLib;
8
9
  return `
9
- import { cnstOf } from "@akanjs/constant";
10
+ import { cnstOf, scalarCnstOf } from "@akanjs/constant";
10
11
 
11
12
  ${rootLib ? `import { root } from "./__lib/lib.constant";` : ""}
12
13
  ${databaseModules.map((module) => `import * as ${module} from "./${module}/${module}.constant";`).join("\n")}
14
+ ${scalarModules.map((module) => `import { ${capitalize(module)} } from "./__scalar/${module}/${module}.constant";`).join("\n")}
13
15
 
14
16
  export * from "./__lib/lib.constant";
15
17
  ${databaseModules.map((module) => `export * from "./${module}/${module}.constant";`).join("\n")}
@@ -17,13 +19,14 @@ ${scalarModules.map((module) => `export * from "./__scalar/${module}/${module}.c
17
19
 
18
20
  ${databaseModules.map((module) => {
19
21
  const names = {
20
- Module: module.charAt(0).toUpperCase() + module.slice(1)
22
+ Module: capitalize(module)
21
23
  };
22
24
  if (module === "setting" || module === "summary")
23
25
  return `export const ${module}Cnst = cnstOf("${module}" as const, ${module}.${names.Module}Input, ${module}.${names.Module}, ${module}.Light${names.Module}, ${rootLib ? "root" : module}.${names.Module}Insight, ${rootLib ? "root" : module}.${names.Module}Filter);`;
24
26
  else
25
27
  return `export const ${module}Cnst = cnstOf("${module}" as const, ${module}.${names.Module}Input, ${module}.${names.Module}, ${module}.Light${names.Module}, ${module}.${names.Module}Insight, ${module}.${names.Module}Filter, ${module}.${names.Module}Summary);`;
26
28
  }).join("\n")}
29
+ ${scalarModules.map((module) => `export const ${module}Cnst = scalarCnstOf("${module}" as const, ${capitalize(module)});`).join("\n")}
27
30
  `;
28
31
  }
29
32
  export {
@@ -17,7 +17,7 @@ ${databaseModules.map((module) => `${["user", "setting", "summary"].includes(mod
17
17
 
18
18
  export const fetch = makeFetch(...libFetches, {
19
19
  ${databaseModules.map((module) => `...${module}Gql,`).join("\n")}
20
- ${scalarConstantModules.map((module) => `...scalarUtilOf("${module}" as const, cnst.${capitalize(module)}),`).join("\n")}
20
+ ${scalarConstantModules.map((module) => `...scalarUtilOf(cnst.${module}Cnst),`).join("\n")}
21
21
  ${serviceModules.map((module) => `...fetchOf(sig.${capitalize(module)}Signal),`).join("\n")}
22
22
  ${databaseModules.map((module) => `${module}Gql,`).join("\n")}
23
23
  });
@@ -18,7 +18,6 @@ ${databaseModules.map((module) => `import { ${capitalize(module)}Store } from ".
18
18
  ${serviceModules.map((module) => `import { ${capitalize(module)}Store } from "./_${module}/${module}.store";`).join("\n")}
19
19
  export class RootStore extends MixStore(
20
20
  ...libStores,
21
- ${names.Name}Store,
22
21
  ${[...databaseModules, ...serviceModules].map((module) => `${capitalize(module)}Store`).join(",\n ")}
23
22
  ) {}
24
23
 
@@ -4,29 +4,9 @@ function getContent(scanInfo, dict) {
4
4
  filename: "Summary.Zone.tsx",
5
5
  content: `
6
6
  "use client";
7
- import { ModelsProps } from "@akanjs/client";
8
- import { DefaultOf } from "@akanjs/signal";
9
- import { cnst, st, Summary } from "@${dict.libName}/client";
10
- import { Data } from "@akanjs/ui";
7
+ import { st, Summary } from "@${dict.libName}/client";
11
8
  import { Loading } from "@akanjs/ui";
12
9
 
13
- export const Admin = ({ sliceName = "summary", init, query }: ModelsProps<cnst.Summary>) => {
14
- return (
15
- <Data.ListContainer
16
- init={init}
17
- query={query}
18
- sliceName={sliceName}
19
- renderItem={Summary.Unit.Card}
20
- renderTemplate={Summary.Template.General}
21
- renderTitle={(summary: DefaultOf<cnst.Summary>) => \`\${summary.at}\`}
22
- renderView={(summary: cnst.Summary) => <Summary.View.General summary={summary} />}
23
- type="list"
24
- columns={["type", "status", "createdAt"]}
25
- actions={(summary: cnst.LightSummary, idx) => ["remove", "edit"]}
26
- />
27
- );
28
- };
29
-
30
10
  export const Dashboard = () => {
31
11
  const summary = st.use.summary();
32
12
  if (!summary) return <Loading.Skeleton active />;
@@ -4,34 +4,9 @@ function getContent(scanInfo, dict) {
4
4
  filename: "User.Util.tsx",
5
5
  content: `
6
6
  "use client";
7
- import { clsx, ModelDashboardProps, ModelInsightProps } from "@akanjs/client";
8
- import { getQueryMap } from "@akanjs/constant";
9
- import { cnst, st } from "@${dict.libName}/client";
10
- import { Data } from "@akanjs/ui";
7
+ import { clsx, st } from "@${dict.libName}/client";
11
8
  import { AiOutlineEdit, AiOutlineLock, AiOutlineUnlock } from "react-icons/ai";
12
9
 
13
- export const Stat = ({
14
- className,
15
- summary,
16
- sliceName = "user",
17
- queryMap = getQueryMap(cnst.UserSummary),
18
- hidePresents,
19
- }: ModelDashboardProps<cnst.Summary>) => {
20
- return (
21
- <Data.Dashboard
22
- className={clsx("", className)}
23
- summary={summary}
24
- sliceName={sliceName}
25
- queryMap={queryMap}
26
- columns={["totalUser", "dau"]}
27
- hidePresents={hidePresents}
28
- />
29
- );
30
- };
31
- export const Insight = ({ className, insight, sliceName = "user" }: ModelInsightProps<cnst.UserInsight>) => {
32
- return <Data.Insight className={clsx("", className)} insight={insight} sliceName={sliceName} columns={["count"]} />;
33
- };
34
-
35
10
  interface EditSelfProps {
36
11
  className?: string;
37
12
  }
@@ -4,36 +4,9 @@ function getContent(scanInfo, dict) {
4
4
  filename: "User.Zone.tsx",
5
5
  content: `
6
6
  "use client";
7
- import { ModelsProps } from "@akanjs/client";
8
- import { DefaultOf } from "@akanjs/signal";
9
- import { cnst, st, User } from "@${dict.libName}/client";
10
- import { Data, Model } from "@akanjs/ui";
7
+ import { st, User } from "@${dict.libName}/client";
8
+ import { Model } from "@akanjs/ui";
11
9
 
12
- export const Admin = ({ sliceName = "user", init, query }: ModelsProps<cnst.User>) => {
13
- return (
14
- <Data.ListContainer
15
- init={init}
16
- query={query}
17
- sliceName={sliceName}
18
- renderItem={User.Unit.Card}
19
- renderDashboard={User.Util.Stat}
20
- renderInsight={User.Util.Insight}
21
- renderTemplate={User.Template.General}
22
- renderTitle={(user: DefaultOf<cnst.User>) => \`\${user.nickname}\`}
23
- renderView={(user: cnst.User) => <User.View.General user={user} />}
24
- type="list"
25
- columns={["nickname", "status", "lastLoginAt", "createdAt"]}
26
- actions={(user: cnst.LightUser, idx) => [
27
- "remove",
28
- "edit",
29
- "view",
30
- user.status === "active"
31
- ? { type: "restrict", render: () => <User.Util.Restrict id={user.id} /> }
32
- : { type: "release", render: () => <User.Util.Release id={user.id} /> },
33
- ]}
34
- />
35
- );
36
- };
37
10
 
38
11
  interface SelfProps {
39
12
  className?: string;
@@ -13,13 +13,7 @@ export class UserInput extends by(rootUser.Input, cnst.UserInput) {}
13
13
  export class User extends by(rootUser.Doc, cnst.User) {}
14
14
 
15
15
  @Database.Model(() => cnst.User)
16
- export class UserModel extends into(User, cnst.userCnst) {
17
- async getSummary(): Promise<cnst.UserSummary> {
18
- return {
19
- ...(await this.getDefaultSummary()),
20
- };
21
- }
22
- }
16
+ export class UserModel extends into(User, cnst.userCnst) {}
23
17
 
24
18
  @Database.Middleware(() => cnst.User)
25
19
  export class UserMiddleware extends beyond(UserModel, User) {
@@ -8,14 +8,8 @@ import { cnst } from "../cnst";
8
8
  import * as db from "../db";
9
9
 
10
10
  @Service("UserService")
11
- export class UserService extends ExtendedUserService(db.userDb, LibUserService) {
12
- async summarize${dict.LibName}(): Promise<cnst.${dict.LibName}UserSummary> {
13
- return {
14
- ...(await this.userModel.getSummary()),
15
- };
16
- }
17
- }
18
- `;
11
+ export class UserService extends ExtendedUserService(db.userDb, LibUserService) {}
12
+ `;
19
13
  }
20
14
  export {
21
15
  getContent as default
@@ -4,43 +4,13 @@ function getContent(scanInfo, dict) {
4
4
  filename: `${dict.Model}.Util.tsx`,
5
5
  content: `
6
6
  "use client";
7
- import { ModelDashboardProps, ModelInsightProps } from "@akanjs/client";
8
- import { getQueryMap } from "@akanjs/constant";
9
- import { cnst } from "@${dict.sysName}/client";
10
- import { Data } from "@akanjs/ui";
7
+ import { Model } from "@akanjs/ui";
11
8
 
12
- export const Stat = ({
13
- className,
14
- summary,
15
- sliceName = "${dict.model}",
16
- queryMap = getQueryMap(cnst.${dict.Model}Summary),
17
- hidePresents,
18
- }: ModelDashboardProps<cnst.Summary>) => {
19
- return (
20
- <Data.Dashboard
21
- className={className}
22
- summary={summary}
23
- sliceName={sliceName}
24
- queryMap={queryMap}
25
- columns={["total${dict.Model}"]}
26
- hidePresents={hidePresents}
27
- />
28
- );
29
- };
30
-
31
- export const Insight = ({
32
- className,
33
- insight,
34
- sliceName = "${dict.model}",
35
- }: ModelInsightProps<cnst.${dict.Model}Insight>) => {
36
- return (
37
- <Data.Insight
38
- className={className}
39
- insight={insight}
40
- sliceName={sliceName}
41
- columns={["count"]}
42
- />
43
- );
9
+ interface RemoveProps {
10
+ ${dict.model}Id: string;
11
+ }
12
+ export const Remove = ({ ${dict.model}Id }: RemoveProps) => {
13
+ return <Model.Remove modelId={${dict.model}Id} sliceName="${dict.model}" />;
44
14
  };
45
15
  `
46
16
  };
@@ -4,33 +4,9 @@ function getContent(scanInfo, dict) {
4
4
  filename: `${dict.Model}.Zone.tsx`,
5
5
  content: `
6
6
  "use client";
7
- import { Data, Load } from "@akanjs/ui";
8
- import { ModelsProps } from "@akanjs/client";
7
+ import { Load } from "@akanjs/ui";
9
8
  import { cnst, ${dict.Model} } from "@${dict.sysName}/client";
10
- import { ClientInit, ClientView, DefaultOf } from "@akanjs/signal";
11
-
12
- export const Admin = ({ sliceName = "${dict.model}", init, query }: ModelsProps<cnst.${dict.Model}>) => {
13
- return (
14
- <Data.ListContainer
15
- init={init}
16
- query={query}
17
- sliceName={sliceName}
18
- renderItem={${dict.Model}.Unit.Card}
19
- renderDashboard={${dict.Model}.Util.Stat}
20
- renderInsight={${dict.Model}.Util.Insight}
21
- renderTemplate={${dict.Model}.Template.General}
22
- renderTitle={(${dict.model}: DefaultOf<cnst.${dict.Model}>) => \`${dict.Model} - \${${dict.model}.id ? ${dict.model}.id : "New"}\`}
23
- renderView={(${dict.model}: cnst.${dict.Model}) => <${dict.Model}.View.General ${dict.model}={${dict.model}} />}
24
- columns={[
25
- "id",
26
- "status",
27
- "createdAt",
28
- "updatedAt",
29
- ]}
30
- actions={(${dict.model}: cnst.Light${dict.Model}, idx) => ["remove", "edit", "view"]}
31
- />
32
- );
33
- };
9
+ import { ClientInit, ClientView } from "@akanjs/signal";
34
10
 
35
11
  interface CardProps {
36
12
  className?: string;
@@ -12,13 +12,7 @@ export class ${dict.Model}Input extends by(cnst.${dict.Model}Input) {}
12
12
  export class ${dict.Model} extends by(cnst.${dict.Model}) {}
13
13
 
14
14
  @Database.Model(() => cnst.${dict.Model})
15
- export class ${dict.Model}Model extends into(${dict.Model}, cnst.${dict.model}Cnst) {
16
- async getSummary(): Promise<cnst.${dict.Model}Summary> {
17
- return {
18
- ...(await this.getDefaultSummary()),
19
- };
20
- }
21
- }
15
+ export class ${dict.Model}Model extends into(${dict.Model}, cnst.${dict.model}Cnst) {}
22
16
 
23
17
  @Database.Middleware(() => cnst.${dict.Model})
24
18
  export class ${dict.Model}Middleware extends beyond(${dict.Model}Model, ${dict.Model}) {
@@ -7,13 +7,7 @@ import { cnst } from "../cnst";
7
7
  import * as db from "../db";
8
8
 
9
9
  @Service("${dict.Model}Service")
10
- export class ${dict.Model}Service extends DbService(db.${dict.model}Db) {
11
- async summarize(): Promise<cnst.${dict.Model}Summary> {
12
- return {
13
- ...(await this.${dict.model}Model.getSummary()),
14
- };
15
- }
16
- }
10
+ export class ${dict.Model}Service extends DbService(db.${dict.model}Db) {}
17
11
  `;
18
12
  }
19
13
  export {
@@ -2,7 +2,6 @@
2
2
  "testing.saveBeforeTest": false,
3
3
  "jest.autoRun": "false",
4
4
  "jestTestExplorer.flattenExplorer": false,
5
- "eslint.validate": ["json"],
6
5
  "prettier.configPath": ".prettierrc.json",
7
6
  "tailwindCSS.classAttributes": ["class", "className", ".*Class", ".*ClassName"],
8
7
  "colorize.languages": ["typescript", "javascript", "css", "scss"],
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "type": "module",
3
3
  "sourceType": "module",
4
4
  "name": "@akanjs/cli",
5
- "version": "0.9.42",
5
+ "version": "0.9.43",
6
6
  "bin": {
7
7
  "akan": "esm/index.js"
8
8
  },
@@ -733,7 +733,6 @@ SlateContent
733
733
  Purpose: Metadata-driven property editing
734
734
 
735
735
  - prop: string - Property name
736
- - slice: StoreOf<any, any> - Store slice
737
736
  - renderTemplate?: (form: any) => ReactNode - Custom edit renderer
738
737
  - renderView?: (model: any) => ReactNode - Custom view renderer
739
738
  - modelPath?: string - Model path in store
@@ -136,97 +136,6 @@ Injects a websocket server instance for real-time communication:
136
136
  protected readonly websocket: Websocket<ChatSignal>;
137
137
  ```
138
138
 
139
- ## Lifecycle Methods
140
-
141
- Akan.js services can implement lifecycle hooks that are called by the NestJS framework.
142
-
143
- ### onModuleInit()
144
-
145
- Called once the module has been initialized by NestJS. Use this for setup operations:
146
-
147
- ```typescript
148
- async onModuleInit() {
149
- // Initialize service resources
150
- await this.loadInitialData();
151
- this.setupEventListeners();
152
- this.logger.log('Service initialized successfully');
153
- }
154
- ```
155
-
156
- Common use cases:
157
-
158
- - Initializing in-memory cache
159
- - Setting up event listeners
160
- - Loading configuration data
161
- - Establishing connections to external services
162
-
163
- ### onModuleDestroy()
164
-
165
- Called just before the application shuts down. Use this for cleanup operations:
166
-
167
- ```typescript
168
- async onModuleDestroy() {
169
- // Clean up resources
170
- await Promise.all(this.connections.map(conn => conn.close()));
171
- this.clearTimers();
172
- this.logger.log('Service resources released');
173
- }
174
- ```
175
-
176
- Common use cases:
177
-
178
- - Closing database connections
179
- - Releasing external resources
180
- - Clearing timers and intervals
181
- - Unregistering event listeners
182
-
183
- ## Scheduled Tasks
184
-
185
- Akan.js provides decorators for scheduling recurring tasks.
186
-
187
- ### @Cron Decorator
188
-
189
- Executes methods on a cron schedule:
190
-
191
- ```typescript
192
- @Cron("0 0 * * *") // Run at midnight every day
193
- async dailyCleanup() {
194
- await this.cleanupExpiredRecords();
195
- this.logger.log('Daily cleanup completed');
196
- }
197
-
198
- @Cron("*/5 * * * *", { serverMode: "batch" }) // Run every 5 minutes, only in batch mode
199
- async periodicSync() {
200
- await this.syncExternalData();
201
- }
202
- ```
203
-
204
- The first parameter uses standard cron syntax:
205
-
206
- - `* * * * *` = minute hour day-of-month month day-of-week
207
- - Special patterns like `@daily`, `@hourly` are also supported
208
-
209
- Options include:
210
-
211
- - `serverMode`: Restrict to a specific server mode (e.g., "batch")
212
- - `name`: Assign a name to the scheduled job
213
- - `timeZone`: Specify the timezone for the schedule
214
-
215
- ### @Interval Decorator
216
-
217
- Executes methods at fixed time intervals in milliseconds:
218
-
219
- ```typescript
220
- @Interval(60000) // Run every minute (60,000 ms)
221
- async checkStatus() {
222
- await this.monitorSystemHealth();
223
- }
224
- ```
225
-
226
- Options:
227
-
228
- - `name`: Assign a name to the interval
229
-
230
139
  ## Database Operations
231
140
 
232
141
  When extending `DbService`, your service automatically inherits numerous methods for working with the database model.
@@ -606,34 +515,6 @@ class PaymentService extends DbService(db.paymentDb) {
606
515
  }
607
516
  ```
608
517
 
609
- ### 3. Proper Resource Management
610
-
611
- Clean up resources in lifecycle hooks:
612
-
613
- ```typescript
614
- @Service("ExternalApiService")
615
- class ExternalApiService extends LogService("ExternalApiService") {
616
- private client: ApiClient;
617
- private timers: NodeJS.Timeout[] = [];
618
-
619
- async onModuleInit() {
620
- this.client = new ApiClient();
621
- await this.client.connect();
622
-
623
- this.timers.push(setInterval(() => this.refreshToken(), 3600000));
624
- }
625
-
626
- async onModuleDestroy() {
627
- // Clean up resources
628
- await this.client.disconnect();
629
-
630
- for (const timer of this.timers) {
631
- clearInterval(timer);
632
- }
633
- }
634
- }
635
- ```
636
-
637
518
  ### 4. Transaction Safety
638
519
 
639
520
  Use hooks for validating operations:
@@ -818,25 +699,6 @@ export class OrderService extends DbService(db.orderDb) {
818
699
 
819
700
  return data;
820
701
  }
821
-
822
- // Scheduled task
823
- @Cron("0 0 * * *", { serverMode: "batch" })
824
- async cleanupAbandonedOrders() {
825
- const cutoffDate = dayjs().subtract(7, "days");
826
- const orders = await this.listPendingOrders(cutoffDate);
827
-
828
- for (const order of orders) {
829
- await this.cancelOrder(order.id);
830
- this.logger.log(`Cancelled abandoned order: ${order.id}`);
831
- }
832
- }
833
-
834
- // Summary method
835
- async summarize(): Promise<cnst.OrderSummary> {
836
- return {
837
- ...(await this.orderModel.getSummary()),
838
- };
839
- }
840
702
  }
841
703
  ```
842
704
 
@@ -894,32 +756,6 @@ If a service isn't being injected correctly:
894
756
  }
895
757
  ```
896
758
 
897
- ### Scheduled Tasks Not Running
898
-
899
- 1. Verify cron syntax:
900
-
901
- ```typescript
902
- // Correct syntax
903
- @Cron("0 * * * *") // Every hour at minute 0
904
-
905
- // Incorrect syntax
906
- @Cron("0 * * *") // Missing day-of-week field
907
- ```
908
-
909
- 2. Check server mode restrictions:
910
-
911
- ```typescript
912
- // Only runs in batch mode
913
- @Cron("0 * * * *", { serverMode: "batch" })
914
- ```
915
-
916
- 3. Ensure the service is properly initialized:
917
- ```typescript
918
- onModuleInit() {
919
- this.logger.log('Service initialized'); // Is this being logged?
920
- }
921
- ```
922
-
923
759
  ## Summary
924
760
 
925
761
  Model services in Akan.js are powerful components that encapsulate business logic and data operations. By following the patterns and best practices outlined in this guide, you can create maintainable, scalable services that effectively implement your application's domain logic while maintaining clean separation of concerns.
@@ -1,9 +1,7 @@
1
1
  import type { AppInfo, LibInfo } from "@akanjs/devkit";
2
2
  interface Dict {
3
3
  appName: string;
4
+ AppName: string;
4
5
  }
5
- export default function getContent(scanInfo: AppInfo | LibInfo | null, dict: Dict): {
6
- filename: string;
7
- content: string;
8
- };
6
+ export default function getContent(scanInfo: AppInfo | LibInfo | null, dict: Dict): string;
9
7
  export {};
@@ -2,7 +2,10 @@ import React from "react";
2
2
  interface MultiScrollListProps {
3
3
  logList: {
4
4
  title: string;
5
- logs: string[];
5
+ logs: {
6
+ type: string;
7
+ content: string;
8
+ }[];
6
9
  color: string;
7
10
  }[];
8
11
  maxLength?: number;
@@ -1,63 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // pkgs/@akanjs/cli/src/templates/app/app/[lang]/admin/page.tsx
20
- var page_exports = {};
21
- __export(page_exports, {
22
- default: () => getContent
23
- });
24
- module.exports = __toCommonJS(page_exports);
25
- function getContent(scanInfo, dict) {
26
- return {
27
- filename: "page.tsx",
28
- content: `
29
- "use client";
30
- import { Admin } from "@shared/client";
31
- import { User, st } from "@${dict.appName}/client";
32
-
33
- export default function Page() {
34
- const me = st.use.me();
35
- return (
36
- <Admin.Zone.Layout
37
- password
38
- // ssoTypes={["google"]}
39
- logo={<div className="text-white ">${dict.appName}</div>}
40
- pageMenus={[
41
- {
42
- key: "data",
43
- title: "Data",
44
- menus: [
45
- // Admin.Menu.Admin,
46
- // User.Menu.Admin,
47
- ],
48
- },
49
- {
50
- key: "api",
51
- title: "API Doc",
52
- menus: [
53
- // Admin.Menu.Doc,
54
- // User.Menu.Doc,
55
- ],
56
- },
57
- ]}
58
- />
59
- );
60
- }
61
- `
62
- };
63
- }