@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.
- package/cjs/index.js +26 -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/__scalar/__model__/__model__.constant.js +0 -1
- package/cjs/src/templates/__scalar/__model__/__model__.dictionary.js +1 -3
- package/cjs/src/templates/app/instrumentation.js +32 -0
- package/cjs/src/templates/app/lib/___appName__/__appName__.dictionary.js +2 -6
- package/cjs/src/templates/app/lib/___appName__/__appName__.signal.js +5 -3
- 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 -61
- package/cjs/src/templates/module/__model__.document.js +7 -2
- package/cjs/src/templates/module/__model__.signal.js +14 -28
- package/cjs/src/templates/module/__model__.store.js +1 -2
- package/cjs/src/templates/server.js +11 -3
- package/cjs/src/templates/workspaceRoot/.gitignore.template +2 -0
- package/esm/index.js +26 -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/__scalar/__model__/__model__.constant.js +0 -1
- package/esm/src/templates/__scalar/__model__/__model__.dictionary.js +1 -3
- package/esm/src/templates/app/instrumentation.js +12 -0
- package/esm/src/templates/app/lib/___appName__/__appName__.dictionary.js +2 -6
- package/esm/src/templates/app/lib/___appName__/__appName__.signal.js +5 -3
- 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 -61
- package/esm/src/templates/module/__model__.document.js +7 -2
- package/esm/src/templates/module/__model__.signal.js +14 -28
- package/esm/src/templates/module/__model__.store.js +1 -2
- package/esm/src/templates/server.js +11 -3
- package/esm/src/templates/workspaceRoot/.gitignore.template +2 -0
- 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/src/templates/app/instrumentation.d.ts +6 -0
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
|
}
|
|
@@ -2059,7 +2059,8 @@ var Executor = class _Executor {
|
|
|
2059
2059
|
const dest = this.getPath(destPath);
|
|
2060
2060
|
if (!import_fs4.default.existsSync(src))
|
|
2061
2061
|
return;
|
|
2062
|
-
|
|
2062
|
+
const isDirectory = import_fs4.default.statSync(src).isDirectory();
|
|
2063
|
+
if (!import_fs4.default.existsSync(dest) && isDirectory)
|
|
2063
2064
|
await import_promises.default.mkdir(dest, { recursive: true });
|
|
2064
2065
|
await import_promises.default.cp(src, dest, { recursive: true });
|
|
2065
2066
|
}
|
|
@@ -2614,32 +2615,23 @@ var AppExecutor = class _AppExecutor extends SysExecutor {
|
|
|
2614
2615
|
return this.#akanConfig;
|
|
2615
2616
|
}
|
|
2616
2617
|
async syncAssets(libDeps) {
|
|
2617
|
-
const
|
|
2618
|
-
const
|
|
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`));
|
|
2619
2625
|
await Promise.all([
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
]);
|
|
2623
|
-
const targetPublicDeps = libDeps.filter(
|
|
2624
|
-
(dep) => import_fs4.default.existsSync(`${this.workspace.workspaceRoot}/libs/${dep}/public`)
|
|
2625
|
-
);
|
|
2626
|
-
const targetAssetsDeps = libDeps.filter(
|
|
2627
|
-
(dep) => import_fs4.default.existsSync(`${this.workspace.workspaceRoot}/libs/${dep}/assets`)
|
|
2628
|
-
);
|
|
2629
|
-
await Promise.all([
|
|
2630
|
-
...targetPublicDeps.map((dep) => import_promises.default.mkdir(`${projectPublicLibPath}/${dep}`, { recursive: true })),
|
|
2631
|
-
...targetAssetsDeps.map((dep) => import_promises.default.mkdir(`${projectAssetsLibPath}/${dep}`, { recursive: true }))
|
|
2626
|
+
...targetPublicDeps.map((dep) => this.mkdir(`${projectPublicLibPath}/${dep}`)),
|
|
2627
|
+
...targetAssetsDeps.map((dep) => this.mkdir(`${projectAssetsLibPath}/${dep}`))
|
|
2632
2628
|
]);
|
|
2633
2629
|
await Promise.all([
|
|
2634
2630
|
...targetPublicDeps.map(
|
|
2635
|
-
(dep) =>
|
|
2636
|
-
recursive: true
|
|
2637
|
-
})
|
|
2631
|
+
(dep) => this.cp(`${this.workspace.workspaceRoot}/libs/${dep}/public`, `${projectPublicLibPath}/${dep}`)
|
|
2638
2632
|
),
|
|
2639
2633
|
...targetAssetsDeps.map(
|
|
2640
|
-
(dep) =>
|
|
2641
|
-
recursive: true
|
|
2642
|
-
})
|
|
2634
|
+
(dep) => this.cp(`${this.workspace.workspaceRoot}/libs/${dep}/assets`, `${projectAssetsLibPath}/${dep}`)
|
|
2643
2635
|
)
|
|
2644
2636
|
]);
|
|
2645
2637
|
}
|
|
@@ -5942,8 +5934,8 @@ var requestUnit = ({
|
|
|
5942
5934
|
var ModuleRunner = class {
|
|
5943
5935
|
async createModule(workspace, sysType, sysName, moduleName, description) {
|
|
5944
5936
|
}
|
|
5945
|
-
removeModule(module2) {
|
|
5946
|
-
module2.sys.removeDir(`lib/${module2.name}`);
|
|
5937
|
+
async removeModule(module2) {
|
|
5938
|
+
await module2.sys.removeDir(`lib/${module2.name}`);
|
|
5947
5939
|
}
|
|
5948
5940
|
async createComponentTemplate(module2, type) {
|
|
5949
5941
|
await module2.sys.applyTemplate({
|
|
@@ -6080,8 +6072,8 @@ var ModuleScript = class {
|
|
|
6080
6072
|
await this.createTemplate(executor);
|
|
6081
6073
|
sys3.log(`Module ${name} created in ${sys3.type}s/${sys3.name}/lib/${name}`);
|
|
6082
6074
|
}
|
|
6083
|
-
removeModule(mod) {
|
|
6084
|
-
this.#runner.removeModule(mod);
|
|
6075
|
+
async removeModule(mod) {
|
|
6076
|
+
await this.#runner.removeModule(mod);
|
|
6085
6077
|
}
|
|
6086
6078
|
async createService(workspace, name) {
|
|
6087
6079
|
}
|
|
@@ -6159,8 +6151,8 @@ var ModuleCommand = class {
|
|
|
6159
6151
|
const name = lowerlize(moduleName.replace(/ /g, ""));
|
|
6160
6152
|
await this.moduleScript.createModuleTemplate(sys3, name, { page });
|
|
6161
6153
|
}
|
|
6162
|
-
removeModule(module2) {
|
|
6163
|
-
this.moduleScript.removeModule(module2);
|
|
6154
|
+
async removeModule(module2) {
|
|
6155
|
+
await this.moduleScript.removeModule(module2);
|
|
6164
6156
|
}
|
|
6165
6157
|
async createView(module2) {
|
|
6166
6158
|
await this.moduleScript.createView(module2);
|
|
@@ -6960,8 +6952,8 @@ var ScalarScript = class {
|
|
|
6960
6952
|
const { session, scalarNames } = await this.#runner.createScalarConstant(sys3, scalarName);
|
|
6961
6953
|
await this.#runner.updateScalarDictionaries(sys3, scalarNames, { session });
|
|
6962
6954
|
}
|
|
6963
|
-
removeScalar(sys3, scalarName) {
|
|
6964
|
-
sys3.removeDir(`lib/__scalar/${scalarName}`);
|
|
6955
|
+
async removeScalar(sys3, scalarName) {
|
|
6956
|
+
await sys3.removeDir(`lib/__scalar/${scalarName}`);
|
|
6965
6957
|
}
|
|
6966
6958
|
};
|
|
6967
6959
|
|
|
@@ -6971,8 +6963,8 @@ var ScalarCommand = class {
|
|
|
6971
6963
|
async createScalar(sys3, scalarName) {
|
|
6972
6964
|
await this.scalarScript.createScalar(sys3, lowerlize(scalarName.replace(/ /g, "")));
|
|
6973
6965
|
}
|
|
6974
|
-
removeScalar(sys3, scalarName) {
|
|
6975
|
-
this.scalarScript.removeScalar(sys3, scalarName);
|
|
6966
|
+
async removeScalar(sys3, scalarName) {
|
|
6967
|
+
await this.scalarScript.removeScalar(sys3, scalarName);
|
|
6976
6968
|
}
|
|
6977
6969
|
};
|
|
6978
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
|
|
@@ -28,7 +28,7 @@ import { ModelDictionary } from "@akanjs/dictionary";
|
|
|
28
28
|
|
|
29
29
|
import type { ${dict.Model} } from "./${dict.model}.constant";
|
|
30
30
|
|
|
31
|
-
export const
|
|
31
|
+
export const dictionary = {
|
|
32
32
|
modelName: ["${dict.Model}", "${dict.Model}"],
|
|
33
33
|
modelDesc: ["${dict.Model}", "${dict.Model}"],
|
|
34
34
|
|
|
@@ -40,7 +40,5 @@ export const modelDictionary = {
|
|
|
40
40
|
// * ==================== Etc ==================== * //
|
|
41
41
|
// * ==================== Etc ==================== * //
|
|
42
42
|
} satisfies ModelDictionary<${dict.Model}>;
|
|
43
|
-
|
|
44
|
-
export const ${dict.model}Dictionary = modelDictionary;
|
|
45
43
|
`;
|
|
46
44
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
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/instrumentation.ts
|
|
20
|
+
var instrumentation_exports = {};
|
|
21
|
+
__export(instrumentation_exports, {
|
|
22
|
+
default: () => getContent
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(instrumentation_exports);
|
|
25
|
+
function getContent(scanInfo, dict) {
|
|
26
|
+
return `
|
|
27
|
+
import { registerClient } from "./client";
|
|
28
|
+
|
|
29
|
+
export const register = async () => {
|
|
30
|
+
await registerClient();
|
|
31
|
+
};`;
|
|
32
|
+
}
|
|
@@ -25,12 +25,8 @@ module.exports = __toCommonJS(appName_dictionary_exports);
|
|
|
25
25
|
function getContent(scanInfo, dict) {
|
|
26
26
|
return `
|
|
27
27
|
import type { SignalDictionary } from "@akanjs/dictionary";
|
|
28
|
-
import type { ${dict.AppName}
|
|
28
|
+
import type { ${dict.AppName}Endpoint } from "./${dict.appName}.signal";
|
|
29
29
|
|
|
30
|
-
const dictionary = {}
|
|
31
|
-
|
|
32
|
-
export const signalDictionary = {} satisfies SignalDictionary<${dict.AppName}Signal>;
|
|
33
|
-
|
|
34
|
-
export const ${dict.appName}Dictionary = { ...dictionary, ...signalDictionary };
|
|
30
|
+
export const dictionary = {} satisfies SignalDictionary<${dict.AppName}Endpoint>;
|
|
35
31
|
`;
|
|
36
32
|
}
|
|
@@ -24,10 +24,12 @@ __export(appName_signal_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(appName_signal_exports);
|
|
25
25
|
function getContent(scanInfo, dict) {
|
|
26
26
|
return `
|
|
27
|
-
import {
|
|
27
|
+
import { endpoint, internal } from "@akanjs/signal";
|
|
28
28
|
|
|
29
|
-
import * as
|
|
29
|
+
import * as srv from "../srv";
|
|
30
30
|
|
|
31
|
-
export class ${dict.AppName}
|
|
31
|
+
export class ${dict.AppName}Internal extends internal(srv.${dict.appName}, () => ({})) {}
|
|
32
|
+
|
|
33
|
+
export class ${dict.AppName}Endpoint extends endpoint(srv.${dict.appName}, () => ({})) {}
|
|
32
34
|
`;
|
|
33
35
|
}
|
|
@@ -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
|
|