@akanjs/cli 0.9.56 → 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.
- package/cjs/index.js +25 -34
- package/cjs/src/guidelines/databaseModule/databaseModule.instruction.md +7 -1
- package/cjs/src/guidelines/modelSignal/modelSignal.instruction.md +3 -3
- package/cjs/src/guidelines/modelTemplate/modelTemplate.instruction.md +5 -5
- package/cjs/src/guidelines/sharedUiUsage/sharedUiUsage.generate.json +0 -7
- package/cjs/src/guidelines/sharedUiUsage/sharedUiUsage.instruction.md +7 -7
- package/cjs/src/templates/app/lib/option.js +6 -1
- package/cjs/src/templates/app/main.js +2 -2
- package/cjs/src/templates/lib/__lib/lib.dictionary.js +1 -2
- package/cjs/src/templates/lib/dict.js +22 -6
- package/cjs/src/templates/lib/sig.js +5 -2
- package/cjs/src/templates/lib/useClient.js +5 -4
- package/cjs/src/templates/libRoot/lib/option.js +5 -1
- package/cjs/src/templates/module/__Model__.Template.js +2 -2
- package/cjs/src/templates/module/__Model__.Util.js +8 -1
- package/cjs/src/templates/module/__model__.constant.js +3 -8
- package/cjs/src/templates/module/__model__.dictionary.js +21 -59
- package/cjs/src/templates/module/__model__.document.js +1 -1
- package/cjs/src/templates/module/__model__.signal.js +5 -4
- package/cjs/src/templates/server.js +11 -3
- package/esm/index.js +25 -34
- package/esm/src/guidelines/databaseModule/databaseModule.instruction.md +7 -1
- package/esm/src/guidelines/modelSignal/modelSignal.instruction.md +3 -3
- package/esm/src/guidelines/modelTemplate/modelTemplate.instruction.md +5 -5
- package/esm/src/guidelines/sharedUiUsage/sharedUiUsage.generate.json +0 -7
- package/esm/src/guidelines/sharedUiUsage/sharedUiUsage.instruction.md +7 -7
- package/esm/src/templates/app/lib/option.js +6 -1
- package/esm/src/templates/app/main.js +2 -2
- package/esm/src/templates/lib/__lib/lib.dictionary.js +1 -2
- package/esm/src/templates/lib/dict.js +22 -6
- package/esm/src/templates/lib/sig.js +5 -2
- package/esm/src/templates/lib/useClient.js +5 -4
- package/esm/src/templates/libRoot/lib/option.js +5 -1
- package/esm/src/templates/module/__Model__.Template.js +2 -2
- package/esm/src/templates/module/__Model__.Util.js +8 -1
- package/esm/src/templates/module/__model__.constant.js +3 -8
- package/esm/src/templates/module/__model__.dictionary.js +21 -59
- package/esm/src/templates/module/__model__.document.js +1 -1
- package/esm/src/templates/module/__model__.signal.js +5 -4
- package/esm/src/templates/server.js +11 -3
- package/package.json +1 -1
- package/src/guidelines/databaseModule/databaseModule.instruction.md +7 -1
- package/src/guidelines/modelSignal/modelSignal.instruction.md +3 -3
- package/src/guidelines/modelTemplate/modelTemplate.instruction.md +5 -5
- package/src/guidelines/sharedUiUsage/sharedUiUsage.instruction.md +7 -7
- package/src/module/module.command.d.ts +1 -1
- package/src/module/module.runner.d.ts +1 -1
- package/src/module/module.script.d.ts +1 -1
- package/src/scalar/scalar.command.d.ts +1 -1
- package/src/scalar/scalar.script.d.ts +1 -1
package/cjs/index.js
CHANGED
|
@@ -228,7 +228,7 @@ var Logger = class _Logger {
|
|
|
228
228
|
const contentMsg = this.#colorize(content, logLevel);
|
|
229
229
|
const timeDiffMsg = clc.yellow(`+${now.diff(_Logger.#startAt, "ms")}ms`);
|
|
230
230
|
if (typeof window === "undefined")
|
|
231
|
-
process[writeStreamType]
|
|
231
|
+
process[writeStreamType]?.write(
|
|
232
232
|
`${processMsg} ${timestampMsg} ${logLevelMsg} ${contextMsg} ${contentMsg} ${timeDiffMsg}
|
|
233
233
|
`
|
|
234
234
|
);
|
|
@@ -2008,10 +2008,10 @@ var Executor = class _Executor {
|
|
|
2008
2008
|
this.logger.verbose(`Remove file ${readPath}`);
|
|
2009
2009
|
return this;
|
|
2010
2010
|
}
|
|
2011
|
-
removeDir(dirPath) {
|
|
2011
|
+
async removeDir(dirPath) {
|
|
2012
2012
|
const readPath = this.getPath(dirPath);
|
|
2013
2013
|
if (import_fs4.default.existsSync(readPath))
|
|
2014
|
-
import_fs4.default.
|
|
2014
|
+
await import_fs4.default.promises.rm(readPath, { recursive: true });
|
|
2015
2015
|
this.logger.verbose(`Remove directory ${readPath}`);
|
|
2016
2016
|
return this;
|
|
2017
2017
|
}
|
|
@@ -2057,9 +2057,9 @@ var Executor = class _Executor {
|
|
|
2057
2057
|
async cp(srcPath, destPath) {
|
|
2058
2058
|
const src = this.getPath(srcPath);
|
|
2059
2059
|
const dest = this.getPath(destPath);
|
|
2060
|
-
const isDirectory = import_fs4.default.statSync(src).isDirectory();
|
|
2061
2060
|
if (!import_fs4.default.existsSync(src))
|
|
2062
2061
|
return;
|
|
2062
|
+
const isDirectory = import_fs4.default.statSync(src).isDirectory();
|
|
2063
2063
|
if (!import_fs4.default.existsSync(dest) && isDirectory)
|
|
2064
2064
|
await import_promises.default.mkdir(dest, { recursive: true });
|
|
2065
2065
|
await import_promises.default.cp(src, dest, { recursive: true });
|
|
@@ -2615,32 +2615,23 @@ var AppExecutor = class _AppExecutor extends SysExecutor {
|
|
|
2615
2615
|
return this.#akanConfig;
|
|
2616
2616
|
}
|
|
2617
2617
|
async syncAssets(libDeps) {
|
|
2618
|
-
const
|
|
2619
|
-
const
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
const
|
|
2625
|
-
(dep) => import_fs4.default.existsSync(`${this.workspace.workspaceRoot}/libs/${dep}/public`)
|
|
2626
|
-
);
|
|
2627
|
-
const targetAssetsDeps = libDeps.filter(
|
|
2628
|
-
(dep) => import_fs4.default.existsSync(`${this.workspace.workspaceRoot}/libs/${dep}/assets`)
|
|
2629
|
-
);
|
|
2618
|
+
const projectPublicPath = `${this.cwdPath}/public`;
|
|
2619
|
+
const projectAssetsPath = `${this.cwdPath}/assets`;
|
|
2620
|
+
const projectPublicLibPath = `${projectPublicPath}/libs`;
|
|
2621
|
+
const projectAssetsLibPath = `${projectAssetsPath}/libs`;
|
|
2622
|
+
await Promise.all([this.removeDir(projectPublicLibPath), this.removeDir(projectAssetsLibPath)]);
|
|
2623
|
+
const targetPublicDeps = libDeps.filter((dep) => this.exists(`${this.workspace.workspaceRoot}/libs/${dep}/public`));
|
|
2624
|
+
const targetAssetsDeps = libDeps.filter((dep) => this.exists(`${this.workspace.workspaceRoot}/libs/${dep}/assets`));
|
|
2630
2625
|
await Promise.all([
|
|
2631
|
-
...targetPublicDeps.map((dep) =>
|
|
2632
|
-
...targetAssetsDeps.map((dep) =>
|
|
2626
|
+
...targetPublicDeps.map((dep) => this.mkdir(`${projectPublicLibPath}/${dep}`)),
|
|
2627
|
+
...targetAssetsDeps.map((dep) => this.mkdir(`${projectAssetsLibPath}/${dep}`))
|
|
2633
2628
|
]);
|
|
2634
2629
|
await Promise.all([
|
|
2635
2630
|
...targetPublicDeps.map(
|
|
2636
|
-
(dep) =>
|
|
2637
|
-
recursive: true
|
|
2638
|
-
})
|
|
2631
|
+
(dep) => this.cp(`${this.workspace.workspaceRoot}/libs/${dep}/public`, `${projectPublicLibPath}/${dep}`)
|
|
2639
2632
|
),
|
|
2640
2633
|
...targetAssetsDeps.map(
|
|
2641
|
-
(dep) =>
|
|
2642
|
-
recursive: true
|
|
2643
|
-
})
|
|
2634
|
+
(dep) => this.cp(`${this.workspace.workspaceRoot}/libs/${dep}/assets`, `${projectAssetsLibPath}/${dep}`)
|
|
2644
2635
|
)
|
|
2645
2636
|
]);
|
|
2646
2637
|
}
|
|
@@ -5943,8 +5934,8 @@ var requestUnit = ({
|
|
|
5943
5934
|
var ModuleRunner = class {
|
|
5944
5935
|
async createModule(workspace, sysType, sysName, moduleName, description) {
|
|
5945
5936
|
}
|
|
5946
|
-
removeModule(module2) {
|
|
5947
|
-
module2.sys.removeDir(`lib/${module2.name}`);
|
|
5937
|
+
async removeModule(module2) {
|
|
5938
|
+
await module2.sys.removeDir(`lib/${module2.name}`);
|
|
5948
5939
|
}
|
|
5949
5940
|
async createComponentTemplate(module2, type) {
|
|
5950
5941
|
await module2.sys.applyTemplate({
|
|
@@ -6081,8 +6072,8 @@ var ModuleScript = class {
|
|
|
6081
6072
|
await this.createTemplate(executor);
|
|
6082
6073
|
sys3.log(`Module ${name} created in ${sys3.type}s/${sys3.name}/lib/${name}`);
|
|
6083
6074
|
}
|
|
6084
|
-
removeModule(mod) {
|
|
6085
|
-
this.#runner.removeModule(mod);
|
|
6075
|
+
async removeModule(mod) {
|
|
6076
|
+
await this.#runner.removeModule(mod);
|
|
6086
6077
|
}
|
|
6087
6078
|
async createService(workspace, name) {
|
|
6088
6079
|
}
|
|
@@ -6160,8 +6151,8 @@ var ModuleCommand = class {
|
|
|
6160
6151
|
const name = lowerlize(moduleName.replace(/ /g, ""));
|
|
6161
6152
|
await this.moduleScript.createModuleTemplate(sys3, name, { page });
|
|
6162
6153
|
}
|
|
6163
|
-
removeModule(module2) {
|
|
6164
|
-
this.moduleScript.removeModule(module2);
|
|
6154
|
+
async removeModule(module2) {
|
|
6155
|
+
await this.moduleScript.removeModule(module2);
|
|
6165
6156
|
}
|
|
6166
6157
|
async createView(module2) {
|
|
6167
6158
|
await this.moduleScript.createView(module2);
|
|
@@ -6961,8 +6952,8 @@ var ScalarScript = class {
|
|
|
6961
6952
|
const { session, scalarNames } = await this.#runner.createScalarConstant(sys3, scalarName);
|
|
6962
6953
|
await this.#runner.updateScalarDictionaries(sys3, scalarNames, { session });
|
|
6963
6954
|
}
|
|
6964
|
-
removeScalar(sys3, scalarName) {
|
|
6965
|
-
sys3.removeDir(`lib/__scalar/${scalarName}`);
|
|
6955
|
+
async removeScalar(sys3, scalarName) {
|
|
6956
|
+
await sys3.removeDir(`lib/__scalar/${scalarName}`);
|
|
6966
6957
|
}
|
|
6967
6958
|
};
|
|
6968
6959
|
|
|
@@ -6972,8 +6963,8 @@ var ScalarCommand = class {
|
|
|
6972
6963
|
async createScalar(sys3, scalarName) {
|
|
6973
6964
|
await this.scalarScript.createScalar(sys3, lowerlize(scalarName.replace(/ /g, "")));
|
|
6974
6965
|
}
|
|
6975
|
-
removeScalar(sys3, scalarName) {
|
|
6976
|
-
this.scalarScript.removeScalar(sys3, scalarName);
|
|
6966
|
+
async removeScalar(sys3, scalarName) {
|
|
6967
|
+
await this.scalarScript.removeScalar(sys3, scalarName);
|
|
6977
6968
|
}
|
|
6978
6969
|
};
|
|
6979
6970
|
__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
|
|
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
|
|
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
|
|
204
|
+
<Field.Text label={l("model.name")} />
|
|
205
205
|
|
|
206
206
|
// With description
|
|
207
207
|
<Field.Text
|
|
208
|
-
label={l
|
|
209
|
-
desc={l
|
|
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
|
|
68
|
-
desc={l
|
|
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
|
|
77
|
-
desc={l
|
|
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
|
|
87
|
-
desc={l
|
|
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
|
|
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
|
|
@@ -24,7 +24,7 @@ __export(option_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(option_exports);
|
|
25
25
|
function getContent(scanInfo, dict = {}) {
|
|
26
26
|
return `
|
|
27
|
-
import { useGlobals } from "@akanjs/server";
|
|
27
|
+
import { Middleware, useGlobals } from "@akanjs/server";
|
|
28
28
|
|
|
29
29
|
import type { LibOptions } from "./__lib/lib.service";
|
|
30
30
|
|
|
@@ -38,5 +38,10 @@ export const registerGlobalModule = (options: ModulesOptions) => {
|
|
|
38
38
|
useAsyncs: {},
|
|
39
39
|
});
|
|
40
40
|
};
|
|
41
|
+
|
|
42
|
+
export const registerGlobalMiddlewares = (options: ModulesOptions) => {
|
|
43
|
+
return [] as Middleware[];
|
|
44
|
+
};
|
|
45
|
+
|
|
41
46
|
`;
|
|
42
47
|
}
|
|
@@ -27,12 +27,12 @@ function getContent(scanInfo, dict) {
|
|
|
27
27
|
import { createNestApp } from "@akanjs/server";
|
|
28
28
|
|
|
29
29
|
import { env } from "./env/env.server";
|
|
30
|
-
import { registerModules } from "./server";
|
|
30
|
+
import { registerModules, registerMiddlewares } from "./server";
|
|
31
31
|
|
|
32
32
|
const bootstrap = async () => {
|
|
33
33
|
const serverMode = process.env.SERVER_MODE as "federation" | "batch" | "all" | null;
|
|
34
34
|
if (!serverMode) throw new Error("SERVER_MODE environment variable is not defined");
|
|
35
|
-
await createNestApp({ registerModules, serverMode, env });
|
|
35
|
+
await createNestApp({ registerModules, registerMiddlewares, serverMode, env });
|
|
36
36
|
};
|
|
37
37
|
void bootstrap();
|
|
38
38
|
`;
|
|
@@ -42,8 +42,7 @@ ${libs.map((lib) => `import { dict as ${lib} } from "@${lib}/server";`).join("\n
|
|
|
42
42
|
|
|
43
43
|
${Object.entries(extendedModels).map(([modelName, extendedModels2]) => {
|
|
44
44
|
return `export const ${modelName} = {
|
|
45
|
-
|
|
46
|
-
signals: Object.assign({}, ${extendedModels2.map((libName) => `${libName}.${modelName}.signalDictionary`).join(", ")}),
|
|
45
|
+
dictionaries: [${extendedModels2.map((libName) => `${libName}.${modelName}.dictionary`).join(", ")}] as const,
|
|
47
46
|
};`;
|
|
48
47
|
}).join("\n")}
|
|
49
48
|
|
|
@@ -22,6 +22,7 @@ __export(dict_exports, {
|
|
|
22
22
|
default: () => getContent
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(dict_exports);
|
|
25
|
+
var capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
25
26
|
function getContent(scanInfo, dict = {}) {
|
|
26
27
|
if (!scanInfo)
|
|
27
28
|
return null;
|
|
@@ -29,7 +30,7 @@ function getContent(scanInfo, dict = {}) {
|
|
|
29
30
|
const scalarModules = scanInfo.getScalarModules();
|
|
30
31
|
const serviceModules = scanInfo.getServiceModules();
|
|
31
32
|
return `
|
|
32
|
-
import { makeDictionary, makeTrans } from "@akanjs/dictionary";
|
|
33
|
+
import { makeDictionary, makeTrans, registerScalarTrans, registerServiceTrans, registerModelTrans } from "@akanjs/dictionary";
|
|
33
34
|
|
|
34
35
|
import { allLibs } from "./__lib/lib.dictionary";
|
|
35
36
|
${databaseModules.map((module2) => `import * as ${module2} from "./${module2}/${module2}.dictionary";`).join("\n")}
|
|
@@ -40,14 +41,29 @@ ${databaseModules.map((module2) => `export * as ${module2} from "./${module2}/${
|
|
|
40
41
|
${serviceModules.map((module2) => `export * as ${module2} from "./_${module2}/${module2}.dictionary";`).join("\n")}
|
|
41
42
|
${scalarModules.map((module2) => `export * as ${module2} from "./__scalar/${module2}/${module2}.dictionary";`).join("\n")}
|
|
42
43
|
|
|
44
|
+
${databaseModules.map((module2) => `import type * as ${module2}Cnst from "./${module2}/${module2}.constant";`).join("\n")}
|
|
45
|
+
${scalarModules.map((module2) => `import type * as ${module2}Cnst from "./__scalar/${module2}/${module2}.constant";`).join("\n")}
|
|
46
|
+
|
|
47
|
+
${databaseModules.map((module2) => `import type * as ${module2}Doc from "./${module2}/${module2}.document";`).join("\n")}
|
|
48
|
+
|
|
49
|
+
${databaseModules.map((module2) => `import type * as ${module2}Sig from "./${module2}/${module2}.signal";`).join("\n")}
|
|
50
|
+
${serviceModules.map((module2) => `import type * as ${module2}Sig from "./_${module2}/${module2}.signal";`).join("\n")}
|
|
51
|
+
|
|
43
52
|
export const dictionary = makeDictionary(...allLibs, {
|
|
44
53
|
${[
|
|
45
|
-
...databaseModules.map((module2) =>
|
|
46
|
-
|
|
47
|
-
|
|
54
|
+
...databaseModules.map((module2) => {
|
|
55
|
+
const Module = capitalize(module2);
|
|
56
|
+
return `${module2}: registerModelTrans<"${module2}", ${module2}Cnst.${Module}, ${module2}Cnst.${Module}Insight, ${module2}Doc.${Module}Filter, ${module2}Sig.${Module}Slice, ${module2}Sig.${Module}Endpoint, typeof ${module2}.dictionary>(${module2}.dictionary)`;
|
|
57
|
+
}),
|
|
58
|
+
...scalarModules.map(
|
|
59
|
+
(module2) => `${module2}: registerScalarTrans<"${module2}", ${module2}Cnst.${capitalize(module2)}, typeof ${module2}.dictionary>(${module2}.dictionary)`
|
|
60
|
+
),
|
|
61
|
+
...serviceModules.map(
|
|
62
|
+
(module2) => `${module2}: registerServiceTrans<"${module2}", ${module2}Sig.${capitalize(module2)}Endpoint, typeof ${module2}.dictionary>(${module2}.dictionary)`
|
|
63
|
+
)
|
|
48
64
|
].join(",\n ")}
|
|
49
|
-
}
|
|
65
|
+
});
|
|
50
66
|
|
|
51
|
-
export const { Revert, translate, msg } = makeTrans(dictionary);
|
|
67
|
+
export const { Revert, translate, msg, __Dict_Key__, __Error_Key__ } = makeTrans(dictionary);
|
|
52
68
|
`;
|
|
53
69
|
}
|
|
@@ -30,7 +30,7 @@ function getContent(scanInfo, dict = {}) {
|
|
|
30
30
|
const scalarConstantModules = [...scanInfo.scalar.entries()].filter(([_, files]) => files.has("constant")).map(([module2]) => module2);
|
|
31
31
|
const serviceModules = [...scanInfo.service.entries()].filter(([_, files]) => files.has("signal")).map(([module2]) => module2);
|
|
32
32
|
return `
|
|
33
|
-
import { fetchOf, gqlOf, makeFetch, mergeSignals, signalInfo } from "@akanjs/signal";
|
|
33
|
+
import { fetchOf, gqlOf, makeFetch, mergeSignals, serverSignalOf, signalInfo } from "@akanjs/signal";
|
|
34
34
|
|
|
35
35
|
import { root, libFetches } from "./__lib/lib.signal";
|
|
36
36
|
import * as cnst from "./cnst";
|
|
@@ -46,9 +46,12 @@ ${[...scanInfo.database.entries()].filter(([_, files]) => files.has("signal")).m
|
|
|
46
46
|
([module2]) => `export class ${capitalize(module2)}Signal extends mergeSignals(${module2}Sig.${capitalize(module2)}Endpoint, ${module2}Sig.${capitalize(module2)}Internal, ${module2}Sig.${capitalize(module2)}Slice) {}`
|
|
47
47
|
).join("\n")}
|
|
48
48
|
${[...scanInfo.service.entries()].filter(([_, files]) => files.has("signal")).map(
|
|
49
|
-
([module2]) => `export
|
|
49
|
+
([module2]) => `export class ${capitalize(module2)}Signal extends mergeSignals(${module2}Sig.${capitalize(module2)}Endpoint, ${module2}Sig.${capitalize(module2)}Internal) {}`
|
|
50
50
|
).join("\n")}
|
|
51
51
|
|
|
52
|
+
${[...scanInfo.database.entries()].filter(([_, files]) => files.has("signal")).map(([module2]) => `export class ${capitalize(module2)} extends serverSignalOf(${capitalize(module2)}Signal) {}`).join("\n")}
|
|
53
|
+
${[...scanInfo.service.entries()].filter(([_, files]) => files.has("signal")).map(([module2]) => `export class ${capitalize(module2)} extends serverSignalOf(${capitalize(module2)}Signal) {}`).join("\n")}
|
|
54
|
+
|
|
52
55
|
const signals = signalInfo.registerSignals(
|
|
53
56
|
${[...databaseModules, ...serviceModules].map((module2) => ` ${capitalize(module2)}Signal,`).join("\n")}
|
|
54
57
|
);
|
|
@@ -25,13 +25,14 @@ module.exports = __toCommonJS(useClient_exports);
|
|
|
25
25
|
function getContent(scanInfo, dict = {}) {
|
|
26
26
|
return `
|
|
27
27
|
import { makePageProto } from "@akanjs/client";
|
|
28
|
-
import type * as signal from "./sig";
|
|
29
|
-
import * as cnst from "./cnst";
|
|
30
28
|
|
|
31
|
-
import
|
|
29
|
+
import * as cnst from "./cnst";
|
|
30
|
+
import type { __Dict_Key__, __Error_Key__ } from "./dict";
|
|
31
|
+
import type * as signal from "./sig";
|
|
32
32
|
|
|
33
33
|
export const { msg, Revert, usePage, sig, fetch, registerClient } = makePageProto<
|
|
34
|
-
typeof
|
|
34
|
+
typeof __Dict_Key__,
|
|
35
|
+
typeof __Error_Key__,
|
|
35
36
|
typeof signal.fetch,
|
|
36
37
|
typeof signal
|
|
37
38
|
>(cnst);
|
|
@@ -24,7 +24,7 @@ __export(option_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(option_exports);
|
|
25
25
|
function getContent(scanInfo, dict = {}) {
|
|
26
26
|
return `
|
|
27
|
-
import { useGlobals } from "@akanjs/server";
|
|
27
|
+
import { Middleware, useGlobals } from "@akanjs/server";
|
|
28
28
|
|
|
29
29
|
import type { LibOptions } from "./__lib/lib.service";
|
|
30
30
|
|
|
@@ -38,5 +38,9 @@ export const registerGlobalModule = (options: ModulesOptions) => {
|
|
|
38
38
|
useAsyncs: {},
|
|
39
39
|
});
|
|
40
40
|
};
|
|
41
|
+
|
|
42
|
+
export const registerGlobalMiddlewares = (options: ModulesOptions) => {
|
|
43
|
+
return [] as Middleware[];
|
|
44
|
+
};
|
|
41
45
|
`;
|
|
42
46
|
}
|
|
@@ -40,8 +40,8 @@ export const General = ({ className }: ${dict.Model}EditProps) => {
|
|
|
40
40
|
return (
|
|
41
41
|
<Layout.Template className={className}>
|
|
42
42
|
<Field.Text
|
|
43
|
-
label={l
|
|
44
|
-
desc={l
|
|
43
|
+
label={l("${dict.model}.id")}
|
|
44
|
+
desc={l("${dict.model}.id.desc")}
|
|
45
45
|
value={${dict.model}Form.id}
|
|
46
46
|
onChange={st.do.setIdOn${dict.Model}}
|
|
47
47
|
/>
|
|
@@ -28,12 +28,19 @@ function getContent(scanInfo, dict) {
|
|
|
28
28
|
content: `
|
|
29
29
|
"use client";
|
|
30
30
|
import { Model } from "@akanjs/ui";
|
|
31
|
+
import { usePage } from "@${dict.sysName}/client";
|
|
32
|
+
import { BiTrash } from "react-icons/bi";
|
|
31
33
|
|
|
32
34
|
interface RemoveProps {
|
|
33
35
|
${dict.model}Id: string;
|
|
34
36
|
}
|
|
35
37
|
export const Remove = ({ ${dict.model}Id }: RemoveProps) => {
|
|
36
|
-
|
|
38
|
+
const { l } = usePage();
|
|
39
|
+
return (
|
|
40
|
+
<Model.Remove modelId={${dict.model}Id} sliceName="${dict.model}">
|
|
41
|
+
<BiTrash /> {l("base.remove")}
|
|
42
|
+
</Model.Remove>
|
|
43
|
+
);
|
|
37
44
|
};
|
|
38
45
|
`
|
|
39
46
|
};
|
|
@@ -24,21 +24,16 @@ __export(model_constant_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(model_constant_exports);
|
|
25
25
|
function getContent(scanInfo, dict) {
|
|
26
26
|
return `
|
|
27
|
-
import {
|
|
27
|
+
import { Int } from "@akanjs/base";
|
|
28
28
|
import { via } from "@akanjs/constant";
|
|
29
29
|
|
|
30
|
-
export const ${dict.Model}Status = enumOf(["active"] as const);
|
|
31
|
-
export type ${dict.Model}Status = enumOf<typeof ${dict.Model}Status>;
|
|
32
|
-
|
|
33
30
|
export class ${dict.Model}Input extends via((field) => ({
|
|
34
31
|
field: field(String).optional(),
|
|
35
32
|
})) {}
|
|
36
33
|
|
|
37
|
-
export class ${dict.Model}Object extends via(${dict.Model}Input, (field) => ({
|
|
38
|
-
status: field(${dict.Model}Status, { default: "active" }),
|
|
39
|
-
})) {}
|
|
34
|
+
export class ${dict.Model}Object extends via(${dict.Model}Input, (field) => ({})) {}
|
|
40
35
|
|
|
41
|
-
export class Light${dict.Model} extends via(${dict.Model}Object, [
|
|
36
|
+
export class Light${dict.Model} extends via(${dict.Model}Object, [] as const, (resolve) => ({})) {}
|
|
42
37
|
|
|
43
38
|
export class ${dict.Model} extends via(${dict.Model}Object, Light${dict.Model}, (resolve) => ({})) {}
|
|
44
39
|
|
|
@@ -24,64 +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 {
|
|
28
|
-
|
|
29
|
-
import type { ${dict.Model}, ${dict.Model}
|
|
30
|
-
import type { ${dict.Model}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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}>;
|
|
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({});
|
|
86
48
|
`;
|
|
87
49
|
}
|
|
@@ -24,7 +24,7 @@ __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
|
|
|
@@ -24,18 +24,19 @@ __export(model_signal_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(model_signal_exports);
|
|
25
25
|
function getContent(scanInfo, dict) {
|
|
26
26
|
return `
|
|
27
|
+
import { Public } from "@akanjs/nest";
|
|
27
28
|
import { endpoint, internal, slice } from "@akanjs/signal";
|
|
29
|
+
import { Admin } from "@shared/nest";
|
|
28
30
|
|
|
29
31
|
import * as cnst from "../cnst";
|
|
30
32
|
import * as srv from "../srv";
|
|
31
33
|
|
|
32
34
|
export class ${dict.Model}Internal extends internal(srv.${dict.model}, () => ({})) {}
|
|
33
35
|
|
|
34
|
-
export class ${dict.Model}Slice extends slice(srv.${dict.model}, { guards: { get:
|
|
36
|
+
export class ${dict.Model}Slice extends slice(srv.${dict.model}, { guards: { root: Admin, get: Public, cru: Public } }, (init) => ({
|
|
35
37
|
inPublic: init()
|
|
36
|
-
.
|
|
37
|
-
|
|
38
|
-
return this.${dict.model}Service.queryByStatuses(statuses);
|
|
38
|
+
.exec(function () {
|
|
39
|
+
return this.${dict.model}Service.queryAny();
|
|
39
40
|
}),
|
|
40
41
|
})) {}
|
|
41
42
|
|