@akanjs/cli 0.9.60-canary.1 → 0.9.60-canary.12
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 +35 -60
- package/cjs/src/guidelines/scalarConstant/scalarConstant.generate.json +24 -20
- package/cjs/src/guidelines/scalarConstant/scalarConstant.instruction.md +284 -326
- package/cjs/src/guidelines/scalarDictionary/scalarDictionary.generate.json +32 -32
- package/cjs/src/guidelines/scalarDictionary/scalarDictionary.instruction.md +175 -249
- package/cjs/src/templates/__scalar/__model__/__model__.dictionary.js +6 -13
- package/cjs/src/templates/module/__Model__.Unit.js +1 -1
- package/cjs/src/templates/module/__Model__.View.js +2 -3
- package/cjs/src/templates/module/__model__.constant.js +0 -1
- package/cjs/src/templates/module/__model__.dictionary.js +0 -1
- package/cjs/src/templates/workspaceRoot/package.json.template +5 -5
- package/esm/index.js +35 -60
- package/esm/src/guidelines/scalarConstant/scalarConstant.generate.json +24 -20
- package/esm/src/guidelines/scalarConstant/scalarConstant.instruction.md +284 -326
- package/esm/src/guidelines/scalarDictionary/scalarDictionary.generate.json +32 -32
- package/esm/src/guidelines/scalarDictionary/scalarDictionary.instruction.md +175 -249
- package/esm/src/templates/__scalar/__model__/__model__.dictionary.js +6 -13
- package/esm/src/templates/module/__Model__.Unit.js +1 -1
- package/esm/src/templates/module/__Model__.View.js +2 -3
- package/esm/src/templates/module/__model__.constant.js +0 -1
- package/esm/src/templates/module/__model__.dictionary.js +0 -1
- package/esm/src/templates/workspaceRoot/package.json.template +5 -5
- package/package.json +4 -4
- package/src/guidelines/scalarConstant/scalarConstant.instruction.md +284 -326
- package/src/guidelines/scalarDictionary/scalarDictionary.instruction.md +175 -249
- package/src/library/library.command.d.ts +0 -2
- package/src/library/library.runner.d.ts +0 -2
- package/src/library/library.script.d.ts +0 -2
- package/src/module/module.runner.d.ts +0 -4
- package/src/scalar/scalar.command.d.ts +2 -2
- package/src/scalar/scalar.runner.d.ts +1 -0
- package/src/scalar/scalar.script.d.ts +1 -0
- package/cjs/src/guidelines/fieldDecorator/fieldDecorator.generate.json +0 -135
- package/cjs/src/guidelines/fieldDecorator/fieldDecorator.instruction.md +0 -606
- package/esm/src/guidelines/fieldDecorator/fieldDecorator.generate.json +0 -135
- package/esm/src/guidelines/fieldDecorator/fieldDecorator.instruction.md +0 -606
- package/src/guidelines/fieldDecorator/fieldDecorator.instruction.md +0 -606
|
@@ -24,21 +24,14 @@ __export(model_dictionary_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(model_dictionary_exports);
|
|
25
25
|
function getContent(scanInfo, dict) {
|
|
26
26
|
return `
|
|
27
|
-
import {
|
|
27
|
+
import { scalarDictionary } from "@akanjs/dictionary";
|
|
28
28
|
|
|
29
29
|
import type { ${dict.Model} } from "./${dict.model}.constant";
|
|
30
30
|
|
|
31
|
-
export const dictionary =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
field: ["Field", "\uD544\uB4DC"],
|
|
37
|
-
"desc-field": ["Field", "\uD544\uB4DC"],
|
|
38
|
-
// * ==================== Model ==================== * //
|
|
39
|
-
|
|
40
|
-
// * ==================== Etc ==================== * //
|
|
41
|
-
// * ==================== Etc ==================== * //
|
|
42
|
-
} satisfies ModelDictionary<${dict.Model}>;
|
|
31
|
+
export const dictionary = scalarDictionary(["en", "ko"])
|
|
32
|
+
.of((t) => t(["${dict.Model}", "${dict.Model}"]).desc(["${dict.Model} description", "${dict.Model} \uC124\uBA85"]))
|
|
33
|
+
.model<${dict.Model}>((t) => ({
|
|
34
|
+
field: t(["Field", "\uD544\uB4DC"]).desc(["Field Description", "\uD544\uB4DC \uC124\uBA85"]),
|
|
35
|
+
}));
|
|
43
36
|
`;
|
|
44
37
|
}
|
|
@@ -33,7 +33,7 @@ import { Link } from "@akanjs/ui";
|
|
|
33
33
|
export const Card = ({ ${dict.model}, href }: ModelProps<"${dict.model}", cnst.Light${dict.Model}>) => {
|
|
34
34
|
const { l } = usePage();
|
|
35
35
|
return (
|
|
36
|
-
<Link href={href} className="
|
|
36
|
+
<Link href={href} className="w-full">
|
|
37
37
|
<div>{l("${dict.model}.id")}:{${dict.model}.id}</div>
|
|
38
38
|
</Link>
|
|
39
39
|
);
|
|
@@ -29,12 +29,11 @@ function getContent(scanInfo, dict) {
|
|
|
29
29
|
import { clsx } from "@akanjs/client";
|
|
30
30
|
import { cnst, usePage } from "@${dict.sysName}/client";
|
|
31
31
|
|
|
32
|
-
interface
|
|
32
|
+
interface GeneralProps {
|
|
33
33
|
className?: string;
|
|
34
34
|
${dict.model}: cnst.${dict.Model};
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
export const General = ({ className, ${dict.model} }: ${dict.Model}ViewProps) => {
|
|
36
|
+
export const General = ({ className, ${dict.model} }: GeneralProps) => {
|
|
38
37
|
const { l } = usePage();
|
|
39
38
|
return (
|
|
40
39
|
<div className={clsx("w-full", className)}>
|
|
@@ -24,7 +24,6 @@ __export(model_constant_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(model_constant_exports);
|
|
25
25
|
function getContent(scanInfo, dict) {
|
|
26
26
|
return `
|
|
27
|
-
import { Int } from "@akanjs/base";
|
|
28
27
|
import { via } from "@akanjs/constant";
|
|
29
28
|
|
|
30
29
|
export class ${dict.Model}Input extends via((field) => ({
|
|
@@ -27,7 +27,6 @@ function getContent(scanInfo, dict) {
|
|
|
27
27
|
import { modelDictionary } from "@akanjs/dictionary";
|
|
28
28
|
|
|
29
29
|
import type { ${dict.Model}, ${dict.Model}Insight } from "./${dict.model}.constant";
|
|
30
|
-
import type { ${dict.Model}Filter } from "./${dict.model}.document";
|
|
31
30
|
import type { ${dict.Model}Endpoint, ${dict.Model}Slice } from "./${dict.model}.signal";
|
|
32
31
|
|
|
33
32
|
export const dictionary = modelDictionary(["en", "ko"])
|
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
"description": "<%= repoName %> workspace",
|
|
4
4
|
"version": "0.0.1",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"next": "16.0.
|
|
7
|
-
"react": "19.2.
|
|
8
|
-
"react-dom": "19.2.
|
|
6
|
+
"next": "16.0.7",
|
|
7
|
+
"react": "19.2.1",
|
|
8
|
+
"react-dom": "19.2.1",
|
|
9
9
|
"tailwindcss": "^4.1.11",
|
|
10
10
|
"daisyui": "^5.5.5"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
13
|
"@types/node": "^22.10.4",
|
|
14
14
|
"@tailwindcss/postcss": "^4.1.11",
|
|
15
|
-
"@types/react": "19.2.
|
|
16
|
-
"@types/react-dom": "19.2.
|
|
15
|
+
"@types/react": "19.2.1",
|
|
16
|
+
"@types/react-dom": "19.2.1",
|
|
17
17
|
"crypto-browserify": "^3.12.1",
|
|
18
18
|
"eslint": "^9.19.0",
|
|
19
19
|
"https-browserify": "^1.0.0",
|
package/esm/index.js
CHANGED
|
@@ -1729,7 +1729,8 @@ ${errorMessages}`);
|
|
|
1729
1729
|
const diagnostics = [
|
|
1730
1730
|
...program2.getSemanticDiagnostics(),
|
|
1731
1731
|
...program2.getSyntacticDiagnostics(),
|
|
1732
|
-
|
|
1732
|
+
// Only check declaration diagnostics when declaration emit is enabled
|
|
1733
|
+
...this.config.options.declaration ? program2.getDeclarationDiagnostics() : []
|
|
1733
1734
|
];
|
|
1734
1735
|
const errors = diagnostics.filter((diagnostic) => diagnostic.category === ts3.DiagnosticCategory.Error);
|
|
1735
1736
|
const warnings = diagnostics.filter((diagnostic) => diagnostic.category === ts3.DiagnosticCategory.Warning);
|
|
@@ -4028,7 +4029,11 @@ var LibraryRunner = class {
|
|
|
4028
4029
|
lib.workspace.unsetTsPaths("lib", lib.name);
|
|
4029
4030
|
}
|
|
4030
4031
|
async installLibrary(workspace, libName) {
|
|
4031
|
-
|
|
4032
|
+
workspace.mkdir("node_modules/.akan");
|
|
4033
|
+
if (workspace.exists("node_modules/.akan/akanjs"))
|
|
4034
|
+
await workspace.removeDir("node_modules/.akan/akanjs");
|
|
4035
|
+
await workspace.exec(`cd node_modules/.akan && git clone git@github.com:akan-team/akanjs.git`);
|
|
4036
|
+
await workspace.cp(`node_modules/.akan/akanjs/libs/${libName}`, `libs/${libName}`);
|
|
4032
4037
|
await workspace.cp(`libs/${libName}/env/env.server.example.ts`, `libs/${libName}/env/env.server.testing.ts`);
|
|
4033
4038
|
workspace.setTsPaths("lib", libName);
|
|
4034
4039
|
await workspace.commit(`Add ${libName} library`);
|
|
@@ -4060,16 +4065,6 @@ var LibraryRunner = class {
|
|
|
4060
4065
|
await lib.workspace.spawn("pnpm", ["install", "--reporter=silent"]);
|
|
4061
4066
|
await lib.workspace.commit(`Merge ${lib.name} library dependencies`);
|
|
4062
4067
|
}
|
|
4063
|
-
async pushLibrary(lib, branch) {
|
|
4064
|
-
await lib.workspace.exec(
|
|
4065
|
-
`git subtree push --prefix=libs/${lib.name} git@github.com:akan-team/${lib.name}.git ${branch}`
|
|
4066
|
-
);
|
|
4067
|
-
}
|
|
4068
|
-
async pullLibrary(lib, branch) {
|
|
4069
|
-
await lib.workspace.exec(
|
|
4070
|
-
`git subtree pull --prefix=libs/${lib.name} git@github.com:akan-team/${lib.name}.git ${branch}`
|
|
4071
|
-
);
|
|
4072
|
-
}
|
|
4073
4068
|
#getEnv(lib, env = {}) {
|
|
4074
4069
|
const rootEnv = dotenv2.parse(lib.workspace.readFile(".env"));
|
|
4075
4070
|
return {
|
|
@@ -4125,19 +4120,6 @@ var LibraryScript = class {
|
|
|
4125
4120
|
await this.#runner.mergeLibraryDependencies(lib);
|
|
4126
4121
|
mergeSpinner.succeed(`${libName} library (libs/${libName}) dependencies merged to root package.json`);
|
|
4127
4122
|
}
|
|
4128
|
-
async pushLibrary(lib, branch) {
|
|
4129
|
-
const pushSpinner = lib.spinning("Pushing library...");
|
|
4130
|
-
await this.#runner.pushLibrary(lib, branch);
|
|
4131
|
-
pushSpinner.succeed(`Library ${lib.name} (libs/${lib.name}) pushed to ${branch} branch`);
|
|
4132
|
-
}
|
|
4133
|
-
async pullLibrary(lib, branch) {
|
|
4134
|
-
const pullSpinner = lib.spinning("Pulling library...");
|
|
4135
|
-
await this.#runner.pullLibrary(lib, branch);
|
|
4136
|
-
pullSpinner.succeed(`Library ${lib.name} (libs/${lib.name}) pulled from ${branch} branch`);
|
|
4137
|
-
const mergeSpinner = lib.spinning("Merging library dependencies...");
|
|
4138
|
-
await this.#runner.mergeLibraryDependencies(lib);
|
|
4139
|
-
mergeSpinner.succeed(`Library ${lib.name} (libs/${lib.name}) dependencies merged to root package.json`);
|
|
4140
|
-
}
|
|
4141
4123
|
async testLibrary(lib) {
|
|
4142
4124
|
const spinner = lib.spinning("Testing library...");
|
|
4143
4125
|
await this.#runner.testLibrary(lib);
|
|
@@ -6030,12 +6012,6 @@ var LibraryCommand = class {
|
|
|
6030
6012
|
async installLibrary(libName, workspace) {
|
|
6031
6013
|
await this.libraryScript.installLibrary(workspace, libName);
|
|
6032
6014
|
}
|
|
6033
|
-
async pushLibrary(lib, branch) {
|
|
6034
|
-
await this.libraryScript.pushLibrary(lib, branch);
|
|
6035
|
-
}
|
|
6036
|
-
async pullLibrary(lib, branch) {
|
|
6037
|
-
await this.libraryScript.pullLibrary(lib, branch);
|
|
6038
|
-
}
|
|
6039
6015
|
};
|
|
6040
6016
|
__decorateClass([
|
|
6041
6017
|
Target.Public(),
|
|
@@ -6055,16 +6031,6 @@ __decorateClass([
|
|
|
6055
6031
|
__decorateParam(0, Argument("libName", { desc: "name of library", nullable: true })),
|
|
6056
6032
|
__decorateParam(1, Workspace())
|
|
6057
6033
|
], LibraryCommand.prototype, "installLibrary", 1);
|
|
6058
|
-
__decorateClass([
|
|
6059
|
-
Target.Public({ devOnly: true }),
|
|
6060
|
-
__decorateParam(0, Lib()),
|
|
6061
|
-
__decorateParam(1, Option("branch", { desc: "branch to push", default: "main" }))
|
|
6062
|
-
], LibraryCommand.prototype, "pushLibrary", 1);
|
|
6063
|
-
__decorateClass([
|
|
6064
|
-
Target.Public(),
|
|
6065
|
-
__decorateParam(0, Lib()),
|
|
6066
|
-
__decorateParam(1, Option("branch", { desc: "branch to pull", default: "main" }))
|
|
6067
|
-
], LibraryCommand.prototype, "pullLibrary", 1);
|
|
6068
6034
|
LibraryCommand = __decorateClass([
|
|
6069
6035
|
Commands()
|
|
6070
6036
|
], LibraryCommand);
|
|
@@ -6433,12 +6399,12 @@ var ModuleRunner = class {
|
|
|
6433
6399
|
},
|
|
6434
6400
|
signal: {
|
|
6435
6401
|
filename: `${module.name}.signal.ts`,
|
|
6436
|
-
content: module.readFile(`${module.name}.signal.
|
|
6437
|
-
},
|
|
6438
|
-
test: {
|
|
6439
|
-
filename: `${module.name}.test.ts`,
|
|
6440
|
-
content: module.readFile(`${module.name}.signal.test.ts`)
|
|
6402
|
+
content: module.readFile(`${module.name}.signal.ts`)
|
|
6441
6403
|
},
|
|
6404
|
+
// test: {
|
|
6405
|
+
// filename: `${module.name}.test.ts`,
|
|
6406
|
+
// content: module.readFile(`${module.name}.signal.test.ts`),
|
|
6407
|
+
// },
|
|
6442
6408
|
unit: {
|
|
6443
6409
|
filename: `${module.name}.Unit.tsx`,
|
|
6444
6410
|
content: module.readFile(`${module.name}.Unit.tsx`)
|
|
@@ -7310,8 +7276,8 @@ var ScalarPrompt = class extends Prompter {
|
|
|
7310
7276
|
}
|
|
7311
7277
|
async requestCreateConstant() {
|
|
7312
7278
|
const constantFiles = await this.sys.getConstantFilesWithLibs();
|
|
7313
|
-
const description = await input5({ message: "description of scalar
|
|
7314
|
-
const schemaDescription = await input5({ message: "schema description of scalar
|
|
7279
|
+
const description = await input5({ message: "description of scalar" });
|
|
7280
|
+
const schemaDescription = await input5({ message: "schema description of scalar" });
|
|
7315
7281
|
await this.sys.applyTemplate({
|
|
7316
7282
|
basePath: "./lib/__scalar",
|
|
7317
7283
|
template: "__scalar",
|
|
@@ -7422,6 +7388,14 @@ ${boilerplate}
|
|
|
7422
7388
|
|
|
7423
7389
|
// pkgs/@akanjs/cli/src/scalar/scalar.runner.ts
|
|
7424
7390
|
var ScalarRunner = class {
|
|
7391
|
+
async applyScalarTemplate(sys3, scalarName) {
|
|
7392
|
+
await sys3.applyTemplate({
|
|
7393
|
+
basePath: "./lib/__scalar",
|
|
7394
|
+
template: "__scalar",
|
|
7395
|
+
dict: { model: scalarName, models: pluralize2(scalarName), sysName: sys3.name },
|
|
7396
|
+
overwrite: false
|
|
7397
|
+
});
|
|
7398
|
+
}
|
|
7425
7399
|
async createScalarConstant(sys3, scalarName) {
|
|
7426
7400
|
const isContinued = sys3.exists(`lib/__scalar/${scalarName}/${scalarName}.constant.ts`);
|
|
7427
7401
|
const prompt = new ScalarPrompt(sys3, scalarName);
|
|
@@ -7430,12 +7404,7 @@ var ScalarRunner = class {
|
|
|
7430
7404
|
const writes = await session.writeTypescripts(request, sys3, { validate });
|
|
7431
7405
|
const scalarNames = writes.map(({ filePath }) => filePath.split("/").at(-2)).filter((name) => !!name);
|
|
7432
7406
|
for (const name of scalarNames)
|
|
7433
|
-
await
|
|
7434
|
-
basePath: "./lib/__scalar",
|
|
7435
|
-
template: "__scalar",
|
|
7436
|
-
dict: { model: name, models: pluralize2(name), sysName: sys3.name },
|
|
7437
|
-
overwrite: false
|
|
7438
|
-
});
|
|
7407
|
+
await this.applyScalarTemplate(sys3, name);
|
|
7439
7408
|
return { session, scalarNames, writes, prompt };
|
|
7440
7409
|
}
|
|
7441
7410
|
async updateScalarDictionaries(sys3, scalarNames, { session }) {
|
|
@@ -7455,6 +7424,9 @@ var ScalarRunner = class {
|
|
|
7455
7424
|
var ScalarScript = class {
|
|
7456
7425
|
#runner = new ScalarRunner();
|
|
7457
7426
|
async createScalar(sys3, scalarName) {
|
|
7427
|
+
await this.#runner.applyScalarTemplate(sys3, scalarName);
|
|
7428
|
+
}
|
|
7429
|
+
async createScalarWithAi(sys3, scalarName) {
|
|
7458
7430
|
const { session, scalarNames } = await this.#runner.createScalarConstant(sys3, scalarName);
|
|
7459
7431
|
await this.#runner.updateScalarDictionaries(sys3, scalarNames, { session });
|
|
7460
7432
|
}
|
|
@@ -7466,22 +7438,25 @@ var ScalarScript = class {
|
|
|
7466
7438
|
// pkgs/@akanjs/cli/src/scalar/scalar.command.ts
|
|
7467
7439
|
var ScalarCommand = class {
|
|
7468
7440
|
scalarScript = new ScalarScript();
|
|
7469
|
-
async createScalar(
|
|
7441
|
+
async createScalar(scalarName, ai, sys3) {
|
|
7442
|
+
if (ai)
|
|
7443
|
+
await this.scalarScript.createScalarWithAi(sys3, lowerlize(scalarName.replace(/ /g, "")));
|
|
7470
7444
|
await this.scalarScript.createScalar(sys3, lowerlize(scalarName.replace(/ /g, "")));
|
|
7471
7445
|
}
|
|
7472
|
-
async removeScalar(
|
|
7446
|
+
async removeScalar(scalarName, sys3) {
|
|
7473
7447
|
await this.scalarScript.removeScalar(sys3, scalarName);
|
|
7474
7448
|
}
|
|
7475
7449
|
};
|
|
7476
7450
|
__decorateClass([
|
|
7477
7451
|
Target.Public(),
|
|
7478
|
-
__decorateParam(0,
|
|
7479
|
-
__decorateParam(1,
|
|
7452
|
+
__decorateParam(0, Argument("scalarName", { desc: "name of scalar" })),
|
|
7453
|
+
__decorateParam(1, Option("ai", { type: "boolean", default: false, desc: "use ai to create scalar" })),
|
|
7454
|
+
__decorateParam(2, Sys())
|
|
7480
7455
|
], ScalarCommand.prototype, "createScalar", 1);
|
|
7481
7456
|
__decorateClass([
|
|
7482
7457
|
Target.Public(),
|
|
7483
|
-
__decorateParam(0,
|
|
7484
|
-
__decorateParam(1,
|
|
7458
|
+
__decorateParam(0, Argument("scalarName", { desc: "name of scalar" })),
|
|
7459
|
+
__decorateParam(1, Sys())
|
|
7485
7460
|
], ScalarCommand.prototype, "removeScalar", 1);
|
|
7486
7461
|
ScalarCommand = __decorateClass([
|
|
7487
7462
|
Commands()
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
16
|
"type": "source",
|
|
17
|
-
"description": "scalar
|
|
18
|
-
"path": "pkgs/@akanjs/constant/src/
|
|
17
|
+
"description": "via() function and scalar implementation",
|
|
18
|
+
"path": "pkgs/@akanjs/constant/src/baseGql.ts"
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
"type": "source",
|
|
@@ -72,30 +72,34 @@
|
|
|
72
72
|
"Purpose of scalar constants in Akan.js",
|
|
73
73
|
"File structure and location conventions",
|
|
74
74
|
"Naming standards for directories, files, classes and enums",
|
|
75
|
-
"Required imports and
|
|
76
|
-
"
|
|
77
|
-
"Field definitions with
|
|
78
|
-
"Field options reference table",
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
75
|
+
"Required imports from @akanjs/constant and @akanjs/base",
|
|
76
|
+
"Basic syntax with via() function",
|
|
77
|
+
"Field definitions with field() helper function",
|
|
78
|
+
"Field options reference table (default, min, max, minlength, maxlength, validate, example)",
|
|
79
|
+
"Available field types (String, Int, Float, Boolean, Date, ID)",
|
|
80
|
+
"Array fields using bracket notation [Type]",
|
|
81
|
+
"Optional fields using .optional() chain method",
|
|
82
|
+
"Enum definition with enumOf(name, values) class pattern",
|
|
83
|
+
"Instance methods in scalar classes",
|
|
82
84
|
"Static methods in scalar classes",
|
|
83
|
-
"Validation rules and checklists",
|
|
84
85
|
"Common mistakes and fixes",
|
|
86
|
+
"Implementation checklist",
|
|
85
87
|
"Full examples of scalar.constant.ts files"
|
|
86
88
|
],
|
|
87
89
|
"rules": [
|
|
88
|
-
"One scalar.constant.ts should contain only one
|
|
89
|
-
"The directory and filename convention is camelCase, such as `
|
|
90
|
-
"The class name should be PascalCase, matching the camelCase directory name (e.g.,
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"
|
|
90
|
+
"One scalar.constant.ts should contain only one scalar class extending via(). If you need more than one scalar model, make another scalar.constant.ts file.",
|
|
91
|
+
"The directory and filename convention is camelCase, such as `encourageInfo/encourageInfo.constant.ts`",
|
|
92
|
+
"The class name should be PascalCase, matching the camelCase directory name (e.g., EncourageInfo for encourageInfo)",
|
|
93
|
+
"Use `extends via((field) => ({...}))` pattern to define scalar classes, not decorators",
|
|
94
|
+
"Import `via` from `@akanjs/constant` and `enumOf`, `ID`, `Int`, `Float`, `dayjs` from `@akanjs/base`",
|
|
95
|
+
"The values of enum strings must be camelCase (e.g., 'waitPay', not 'WAIT_PAY')",
|
|
96
|
+
"Define enums using class pattern: `export class EnumName extends enumOf('enumName', [...] as const) {}`",
|
|
97
|
+
"The first argument of enumOf() is the enum name string used in dictionary/GraphQL",
|
|
98
|
+
"Use .optional() chain method for nullable fields, not { nullable: true } option",
|
|
97
99
|
"Use bracket notation for arrays ([Type]) rather than generics (Array<Type>)",
|
|
98
|
-
"
|
|
100
|
+
"Use factory functions for dynamic defaults: { default: () => dayjs() }, not { default: dayjs() }",
|
|
101
|
+
"Always export both the scalar class and enum classes",
|
|
102
|
+
"Add 'as const' to enum value arrays for better TypeScript type inference"
|
|
99
103
|
]
|
|
100
104
|
},
|
|
101
105
|
"page": "/[lang]/akanjs/(docs)/docs/scalar/constant/page.tsx"
|