@akanjs/cli 0.9.60-canary.1 → 0.9.60-canary.11

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 (37) hide show
  1. package/cjs/index.js +35 -60
  2. package/cjs/src/guidelines/scalarConstant/scalarConstant.generate.json +24 -20
  3. package/cjs/src/guidelines/scalarConstant/scalarConstant.instruction.md +284 -326
  4. package/cjs/src/guidelines/scalarDictionary/scalarDictionary.generate.json +32 -32
  5. package/cjs/src/guidelines/scalarDictionary/scalarDictionary.instruction.md +175 -249
  6. package/cjs/src/templates/__scalar/__model__/__model__.dictionary.js +6 -13
  7. package/cjs/src/templates/module/__Model__.Unit.js +1 -1
  8. package/cjs/src/templates/module/__Model__.View.js +2 -3
  9. package/cjs/src/templates/module/__model__.constant.js +0 -1
  10. package/cjs/src/templates/module/__model__.dictionary.js +0 -1
  11. package/cjs/src/templates/workspaceRoot/package.json.template +5 -5
  12. package/esm/index.js +35 -60
  13. package/esm/src/guidelines/scalarConstant/scalarConstant.generate.json +24 -20
  14. package/esm/src/guidelines/scalarConstant/scalarConstant.instruction.md +284 -326
  15. package/esm/src/guidelines/scalarDictionary/scalarDictionary.generate.json +32 -32
  16. package/esm/src/guidelines/scalarDictionary/scalarDictionary.instruction.md +175 -249
  17. package/esm/src/templates/__scalar/__model__/__model__.dictionary.js +6 -13
  18. package/esm/src/templates/module/__Model__.Unit.js +1 -1
  19. package/esm/src/templates/module/__Model__.View.js +2 -3
  20. package/esm/src/templates/module/__model__.constant.js +0 -1
  21. package/esm/src/templates/module/__model__.dictionary.js +0 -1
  22. package/esm/src/templates/workspaceRoot/package.json.template +5 -5
  23. package/package.json +4 -4
  24. package/src/guidelines/scalarConstant/scalarConstant.instruction.md +284 -326
  25. package/src/guidelines/scalarDictionary/scalarDictionary.instruction.md +175 -249
  26. package/src/library/library.command.d.ts +0 -2
  27. package/src/library/library.runner.d.ts +0 -2
  28. package/src/library/library.script.d.ts +0 -2
  29. package/src/module/module.runner.d.ts +0 -4
  30. package/src/scalar/scalar.command.d.ts +2 -2
  31. package/src/scalar/scalar.runner.d.ts +1 -0
  32. package/src/scalar/scalar.script.d.ts +1 -0
  33. package/cjs/src/guidelines/fieldDecorator/fieldDecorator.generate.json +0 -135
  34. package/cjs/src/guidelines/fieldDecorator/fieldDecorator.instruction.md +0 -606
  35. package/esm/src/guidelines/fieldDecorator/fieldDecorator.generate.json +0 -135
  36. package/esm/src/guidelines/fieldDecorator/fieldDecorator.instruction.md +0 -606
  37. package/src/guidelines/fieldDecorator/fieldDecorator.instruction.md +0 -606
package/cjs/index.js CHANGED
@@ -1750,7 +1750,8 @@ ${errorMessages}`);
1750
1750
  const diagnostics = [
1751
1751
  ...program2.getSemanticDiagnostics(),
1752
1752
  ...program2.getSyntacticDiagnostics(),
1753
- ...program2.getDeclarationDiagnostics()
1753
+ // Only check declaration diagnostics when declaration emit is enabled
1754
+ ...this.config.options.declaration ? program2.getDeclarationDiagnostics() : []
1754
1755
  ];
1755
1756
  const errors = diagnostics.filter((diagnostic) => diagnostic.category === ts3.DiagnosticCategory.Error);
1756
1757
  const warnings = diagnostics.filter((diagnostic) => diagnostic.category === ts3.DiagnosticCategory.Warning);
@@ -4047,7 +4048,11 @@ var LibraryRunner = class {
4047
4048
  lib.workspace.unsetTsPaths("lib", lib.name);
4048
4049
  }
4049
4050
  async installLibrary(workspace, libName) {
4050
- await workspace.exec(`git subtree add --prefix=libs/${libName} git@github.com:akan-team/${libName}.git main`);
4051
+ workspace.mkdir("node_modules/.akan");
4052
+ if (workspace.exists("node_modules/.akan/akanjs"))
4053
+ await workspace.removeDir("node_modules/.akan/akanjs");
4054
+ await workspace.exec(`cd node_modules/.akan && git clone git@github.com:akan-team/${libName}.git`);
4055
+ await workspace.cp(`node_modules/.akan/akanjs/libs/${libName}`, `libs/${libName}`);
4051
4056
  await workspace.cp(`libs/${libName}/env/env.server.example.ts`, `libs/${libName}/env/env.server.testing.ts`);
4052
4057
  workspace.setTsPaths("lib", libName);
4053
4058
  await workspace.commit(`Add ${libName} library`);
@@ -4079,16 +4084,6 @@ var LibraryRunner = class {
4079
4084
  await lib.workspace.spawn("pnpm", ["install", "--reporter=silent"]);
4080
4085
  await lib.workspace.commit(`Merge ${lib.name} library dependencies`);
4081
4086
  }
4082
- async pushLibrary(lib, branch) {
4083
- await lib.workspace.exec(
4084
- `git subtree push --prefix=libs/${lib.name} git@github.com:akan-team/${lib.name}.git ${branch}`
4085
- );
4086
- }
4087
- async pullLibrary(lib, branch) {
4088
- await lib.workspace.exec(
4089
- `git subtree pull --prefix=libs/${lib.name} git@github.com:akan-team/${lib.name}.git ${branch}`
4090
- );
4091
- }
4092
4087
  #getEnv(lib, env = {}) {
4093
4088
  const rootEnv = import_dotenv2.default.parse(lib.workspace.readFile(".env"));
4094
4089
  return {
@@ -4144,19 +4139,6 @@ var LibraryScript = class {
4144
4139
  await this.#runner.mergeLibraryDependencies(lib);
4145
4140
  mergeSpinner.succeed(`${libName} library (libs/${libName}) dependencies merged to root package.json`);
4146
4141
  }
4147
- async pushLibrary(lib, branch) {
4148
- const pushSpinner = lib.spinning("Pushing library...");
4149
- await this.#runner.pushLibrary(lib, branch);
4150
- pushSpinner.succeed(`Library ${lib.name} (libs/${lib.name}) pushed to ${branch} branch`);
4151
- }
4152
- async pullLibrary(lib, branch) {
4153
- const pullSpinner = lib.spinning("Pulling library...");
4154
- await this.#runner.pullLibrary(lib, branch);
4155
- pullSpinner.succeed(`Library ${lib.name} (libs/${lib.name}) pulled from ${branch} branch`);
4156
- const mergeSpinner = lib.spinning("Merging library dependencies...");
4157
- await this.#runner.mergeLibraryDependencies(lib);
4158
- mergeSpinner.succeed(`Library ${lib.name} (libs/${lib.name}) dependencies merged to root package.json`);
4159
- }
4160
4142
  async testLibrary(lib) {
4161
4143
  const spinner = lib.spinning("Testing library...");
4162
4144
  await this.#runner.testLibrary(lib);
@@ -6049,12 +6031,6 @@ var LibraryCommand = class {
6049
6031
  async installLibrary(libName, workspace) {
6050
6032
  await this.libraryScript.installLibrary(workspace, libName);
6051
6033
  }
6052
- async pushLibrary(lib, branch) {
6053
- await this.libraryScript.pushLibrary(lib, branch);
6054
- }
6055
- async pullLibrary(lib, branch) {
6056
- await this.libraryScript.pullLibrary(lib, branch);
6057
- }
6058
6034
  };
6059
6035
  __decorateClass([
6060
6036
  Target.Public(),
@@ -6074,16 +6050,6 @@ __decorateClass([
6074
6050
  __decorateParam(0, Argument("libName", { desc: "name of library", nullable: true })),
6075
6051
  __decorateParam(1, Workspace())
6076
6052
  ], LibraryCommand.prototype, "installLibrary", 1);
6077
- __decorateClass([
6078
- Target.Public({ devOnly: true }),
6079
- __decorateParam(0, Lib()),
6080
- __decorateParam(1, Option("branch", { desc: "branch to push", default: "main" }))
6081
- ], LibraryCommand.prototype, "pushLibrary", 1);
6082
- __decorateClass([
6083
- Target.Public(),
6084
- __decorateParam(0, Lib()),
6085
- __decorateParam(1, Option("branch", { desc: "branch to pull", default: "main" }))
6086
- ], LibraryCommand.prototype, "pullLibrary", 1);
6087
6053
  LibraryCommand = __decorateClass([
6088
6054
  Commands()
6089
6055
  ], LibraryCommand);
@@ -6452,12 +6418,12 @@ var ModuleRunner = class {
6452
6418
  },
6453
6419
  signal: {
6454
6420
  filename: `${module2.name}.signal.ts`,
6455
- content: module2.readFile(`${module2.name}.signal.spec.ts`)
6456
- },
6457
- test: {
6458
- filename: `${module2.name}.test.ts`,
6459
- content: module2.readFile(`${module2.name}.signal.test.ts`)
6421
+ content: module2.readFile(`${module2.name}.signal.ts`)
6460
6422
  },
6423
+ // test: {
6424
+ // filename: `${module.name}.test.ts`,
6425
+ // content: module.readFile(`${module.name}.signal.test.ts`),
6426
+ // },
6461
6427
  unit: {
6462
6428
  filename: `${module2.name}.Unit.tsx`,
6463
6429
  content: module2.readFile(`${module2.name}.Unit.tsx`)
@@ -7330,8 +7296,8 @@ var ScalarPrompt = class extends Prompter {
7330
7296
  }
7331
7297
  async requestCreateConstant() {
7332
7298
  const constantFiles = await this.sys.getConstantFilesWithLibs();
7333
- const description = await (0, import_prompts10.input)({ message: "description of scalar scalar" });
7334
- const schemaDescription = await (0, import_prompts10.input)({ message: "schema description of scalar scalar" });
7299
+ const description = await (0, import_prompts10.input)({ message: "description of scalar" });
7300
+ const schemaDescription = await (0, import_prompts10.input)({ message: "schema description of scalar" });
7335
7301
  await this.sys.applyTemplate({
7336
7302
  basePath: "./lib/__scalar",
7337
7303
  template: "__scalar",
@@ -7442,6 +7408,14 @@ ${boilerplate}
7442
7408
 
7443
7409
  // pkgs/@akanjs/cli/src/scalar/scalar.runner.ts
7444
7410
  var ScalarRunner = class {
7411
+ async applyScalarTemplate(sys3, scalarName) {
7412
+ await sys3.applyTemplate({
7413
+ basePath: "./lib/__scalar",
7414
+ template: "__scalar",
7415
+ dict: { model: scalarName, models: (0, import_pluralize3.default)(scalarName), sysName: sys3.name },
7416
+ overwrite: false
7417
+ });
7418
+ }
7445
7419
  async createScalarConstant(sys3, scalarName) {
7446
7420
  const isContinued = sys3.exists(`lib/__scalar/${scalarName}/${scalarName}.constant.ts`);
7447
7421
  const prompt = new ScalarPrompt(sys3, scalarName);
@@ -7450,12 +7424,7 @@ var ScalarRunner = class {
7450
7424
  const writes = await session.writeTypescripts(request, sys3, { validate });
7451
7425
  const scalarNames = writes.map(({ filePath }) => filePath.split("/").at(-2)).filter((name) => !!name);
7452
7426
  for (const name of scalarNames)
7453
- await sys3.applyTemplate({
7454
- basePath: "./lib/__scalar",
7455
- template: "__scalar",
7456
- dict: { model: name, models: (0, import_pluralize3.default)(name), sysName: sys3.name },
7457
- overwrite: false
7458
- });
7427
+ await this.applyScalarTemplate(sys3, name);
7459
7428
  return { session, scalarNames, writes, prompt };
7460
7429
  }
7461
7430
  async updateScalarDictionaries(sys3, scalarNames, { session }) {
@@ -7475,6 +7444,9 @@ var ScalarRunner = class {
7475
7444
  var ScalarScript = class {
7476
7445
  #runner = new ScalarRunner();
7477
7446
  async createScalar(sys3, scalarName) {
7447
+ await this.#runner.applyScalarTemplate(sys3, scalarName);
7448
+ }
7449
+ async createScalarWithAi(sys3, scalarName) {
7478
7450
  const { session, scalarNames } = await this.#runner.createScalarConstant(sys3, scalarName);
7479
7451
  await this.#runner.updateScalarDictionaries(sys3, scalarNames, { session });
7480
7452
  }
@@ -7486,22 +7458,25 @@ var ScalarScript = class {
7486
7458
  // pkgs/@akanjs/cli/src/scalar/scalar.command.ts
7487
7459
  var ScalarCommand = class {
7488
7460
  scalarScript = new ScalarScript();
7489
- async createScalar(sys3, scalarName) {
7461
+ async createScalar(scalarName, ai, sys3) {
7462
+ if (ai)
7463
+ await this.scalarScript.createScalarWithAi(sys3, lowerlize(scalarName.replace(/ /g, "")));
7490
7464
  await this.scalarScript.createScalar(sys3, lowerlize(scalarName.replace(/ /g, "")));
7491
7465
  }
7492
- async removeScalar(sys3, scalarName) {
7466
+ async removeScalar(scalarName, sys3) {
7493
7467
  await this.scalarScript.removeScalar(sys3, scalarName);
7494
7468
  }
7495
7469
  };
7496
7470
  __decorateClass([
7497
7471
  Target.Public(),
7498
- __decorateParam(0, Sys()),
7499
- __decorateParam(1, Argument("scalarName", { desc: "name of scalar scalar" }))
7472
+ __decorateParam(0, Argument("scalarName", { desc: "name of scalar" })),
7473
+ __decorateParam(1, Option("ai", { type: "boolean", default: false, desc: "use ai to create scalar" })),
7474
+ __decorateParam(2, Sys())
7500
7475
  ], ScalarCommand.prototype, "createScalar", 1);
7501
7476
  __decorateClass([
7502
7477
  Target.Public(),
7503
- __decorateParam(0, Sys()),
7504
- __decorateParam(1, Argument("scalarName", { desc: "name of scalar scalar" }))
7478
+ __decorateParam(0, Argument("scalarName", { desc: "name of scalar" })),
7479
+ __decorateParam(1, Sys())
7505
7480
  ], ScalarCommand.prototype, "removeScalar", 1);
7506
7481
  ScalarCommand = __decorateClass([
7507
7482
  Commands()
@@ -14,8 +14,8 @@
14
14
  },
15
15
  {
16
16
  "type": "source",
17
- "description": "scalar metadata implementation",
18
- "path": "pkgs/@akanjs/constant/src/scalar.ts"
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 framework types",
76
- "Model definition with @Model.Scalar decorator",
77
- "Field definitions with @Field.Prop and other decorators",
78
- "Field options reference table",
79
- "Array fields implementation",
80
- "Map fields implementation",
81
- "Enum implementation with enumOf",
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 @Model.Scalar class. If you need more than one scalar model, make another scalar.constant.ts file.",
89
- "The directory and filename convention is camelCase, such as `geoLocation/geoLocation.constant.ts`",
90
- "The class name should be PascalCase, matching the camelCase directory name (e.g., GeoLocation for geoLocation)",
91
- "The @Model.Scalar parameter MUST match the class name exactly",
92
- "The values of enum strings must be camelCase (not uppercase)",
93
- "Do not forget to import required imports like enumOf, Float, type Dayjs, etc.",
94
- "Do not add options that don't exist in Field.Prop decorator. Carefully check that each option exists.",
95
- "Always use Dayjs type for Date fields, not JavaScript's native Date",
96
- "For nullable fields, add both the { nullable: true } option and the TypeScript union type (Type | null)",
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
- "Always export both const and type for enums created with enumOf"
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"