@solidxai/code-builder 0.1.4 → 0.1.5

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 (43) hide show
  1. package/LICENSE +89 -0
  2. package/README.md +17 -19
  3. package/dist/code-builder/index.js +6 -6
  4. package/dist/code-builder/index.js.map +1 -1
  5. package/dist/code-builder/lib/field/decorator-managers/entity/ManyToManyDecoratorManager.js +6 -5
  6. package/dist/code-builder/lib/field/decorator-managers/entity/ManyToManyDecoratorManager.js.map +1 -1
  7. package/dist/code-builder/lib/field/decorator-managers/entity/ManyToOneDecoratorManager.js +3 -3
  8. package/dist/code-builder/lib/field/decorator-managers/entity/ManyToOneDecoratorManager.js.map +1 -1
  9. package/dist/code-builder/lib/field/decorator-managers/entity/OneToManyDecoratorManager.js +7 -6
  10. package/dist/code-builder/lib/field/decorator-managers/entity/OneToManyDecoratorManager.js.map +1 -1
  11. package/dist/code-builder/lib/field/field-managers/base/BaseFieldManagerForDto.js +5 -4
  12. package/dist/code-builder/lib/field/field-managers/base/BaseFieldManagerForDto.js.map +1 -1
  13. package/dist/code-builder/lib/field/field-managers/base/BaseFieldManagerForEntity.js +5 -4
  14. package/dist/code-builder/lib/field/field-managers/base/BaseFieldManagerForEntity.js.map +1 -1
  15. package/dist/code-builder/lib/field/field-managers/relation/ManyToManyRelationFieldManagerForDto.js +5 -4
  16. package/dist/code-builder/lib/field/field-managers/relation/ManyToManyRelationFieldManagerForDto.js.map +1 -1
  17. package/dist/code-builder/lib/field/field-managers/relation/ManyToManyRelationFieldManagerForEntity.js +6 -5
  18. package/dist/code-builder/lib/field/field-managers/relation/ManyToManyRelationFieldManagerForEntity.js.map +1 -1
  19. package/dist/code-builder/lib/field/field-managers/relation/ManyToOneRelationFieldManagerForEntity.js +7 -6
  20. package/dist/code-builder/lib/field/field-managers/relation/ManyToOneRelationFieldManagerForEntity.js.map +1 -1
  21. package/dist/code-builder/lib/field/field-managers/relation/OneToManyRelationFieldManagerForDto.js +5 -4
  22. package/dist/code-builder/lib/field/field-managers/relation/OneToManyRelationFieldManagerForDto.js.map +1 -1
  23. package/dist/code-builder/lib/field/field-managers/relation/OneToManyRelationFieldManagerForEntity.js +6 -5
  24. package/dist/code-builder/lib/field/field-managers/relation/OneToManyRelationFieldManagerForEntity.js.map +1 -1
  25. package/dist/code-builder/lib/model/helpers.js +30 -29
  26. package/dist/code-builder/lib/model/helpers.js.map +1 -1
  27. package/dist/code-builder/lib/string.utils.d.ts +1 -0
  28. package/dist/code-builder/lib/string.utils.js +7 -0
  29. package/dist/code-builder/lib/string.utils.js.map +1 -0
  30. package/package.json +2 -2
  31. package/src/code-builder/index.ts +6 -9
  32. package/src/code-builder/lib/field/decorator-managers/entity/ManyToManyDecoratorManager.ts +5 -5
  33. package/src/code-builder/lib/field/decorator-managers/entity/ManyToOneDecoratorManager.ts +1 -1
  34. package/src/code-builder/lib/field/decorator-managers/entity/OneToManyDecoratorManager.ts +6 -6
  35. package/src/code-builder/lib/field/field-managers/base/BaseFieldManagerForDto.ts +4 -6
  36. package/src/code-builder/lib/field/field-managers/base/BaseFieldManagerForEntity.ts +3 -9
  37. package/src/code-builder/lib/field/field-managers/relation/ManyToManyRelationFieldManagerForDto.ts +3 -2
  38. package/src/code-builder/lib/field/field-managers/relation/ManyToManyRelationFieldManagerForEntity.ts +4 -3
  39. package/src/code-builder/lib/field/field-managers/relation/ManyToOneRelationFieldManagerForEntity.ts +4 -3
  40. package/src/code-builder/lib/field/field-managers/relation/OneToManyRelationFieldManagerForDto.ts +3 -4
  41. package/src/code-builder/lib/field/field-managers/relation/OneToManyRelationFieldManagerForEntity.ts +4 -4
  42. package/src/code-builder/lib/model/helpers.ts +18 -19
  43. package/src/code-builder/lib/string.utils.ts +3 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidxai/code-builder",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "This package is use to generate code for the @solidxai projects",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -18,7 +18,7 @@
18
18
  "schematics"
19
19
  ],
20
20
  "author": "",
21
- "license": "MIT",
21
+ "license": "BUSL-1.1",
22
22
  "schematics": "./dist/collection.json",
23
23
  "dependencies": {
24
24
  "@angular-devkit/core": "^18.0.1",
@@ -1,4 +1,3 @@
1
- import { classify, dasherize } from '@angular-devkit/core/src/utils/strings';
2
1
  import {
3
2
  MergeStrategy,
4
3
  Rule,
@@ -17,16 +16,17 @@ import * as generateModelHelpers from './lib/model/helpers';
17
16
  import { addField, SOLID_CORE_MODULE_NAME, readModelOptionsFromMetadata, readFieldOptionsFromMetadata } from './lib/model/helpers';
18
17
  import { removeField } from './lib/model/helpers';
19
18
  import ts from '@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript';
20
- import { strings } from '@angular-devkit/core';
19
+ import { kebabCase } from 'lodash';
21
20
 
22
- const generateModelUtils = { dasherize, classify, ...generateModelHelpers };
21
+ import { classify } from './lib/string.utils';
22
+ const generateModelUtils = { dasherize: kebabCase, classify, ...generateModelHelpers };
23
23
  // You don't have to export the function as default. You can also have more than one rule factory
24
24
  // per file.
25
25
  export function addModule(options: any): Rule {
26
26
  return (_tree: Tree, _context: SchematicContext) => {
27
27
  const moduleName = options.module;
28
28
  const moduleFolderPath = `src/${moduleName}`;
29
- const moduleFilePath = `${moduleFolderPath}/${strings.dasherize(moduleName)}.module.ts`;
29
+ const moduleFilePath = `${moduleFolderPath}/${kebabCase(moduleName)}.module.ts`;
30
30
 
31
31
  if (_tree.exists(moduleFilePath)) {
32
32
  throw new Error(`Module file already exists at ${moduleFilePath}. Please use a unique module name.`);
@@ -56,7 +56,7 @@ export function refreshModel(options: any): Rule {
56
56
  const modulePath = (options.module === SOLID_CORE_MODULE_NAME) ? `src` : `src/${options.module}`;
57
57
 
58
58
  // If the model related code is not present, then add it by call addModel, else call update field with the fields provided
59
- const modelEntityFilePath = `${modulePath}/entities/${dasherize(options.model)}.entity.ts`;
59
+ const modelEntityFilePath = `${modulePath}/entities/${kebabCase(options.model)}.entity.ts`;
60
60
  const rules : Rule[] = [];
61
61
  if (!tree.exists(modelEntityFilePath)) {
62
62
  rules.push(addModel(options));
@@ -134,12 +134,11 @@ export function removeFields(options: any): Rule {
134
134
  };
135
135
  }
136
136
 
137
-
138
137
  function addModuleImportsAndMetadata(options: any) { // TODO This method should perhaps be moved elsewhere since this is not a seperate command
139
138
  return (tree: Tree, _context: SchematicContext) => {
140
139
  // Handle the module imports
141
140
  const modulePath = (options.module === SOLID_CORE_MODULE_NAME) ? `src` : `src/${options.module}`;
142
- const moduleFilePath = `${modulePath}/${dasherize(options.module)}.module.ts`;
141
+ const moduleFilePath = `${modulePath}/${kebabCase(options.module)}.module.ts`;
143
142
  const moduleImports: generateModelHelpers.ImportData[] = [
144
143
  { symbolName: `TypeOrmModule`, importPath: `@nestjs/typeorm` },
145
144
  generateModelHelpers.getSolidImports(
@@ -214,5 +213,3 @@ function showTree(sourceNode: ts.SourceFile){
214
213
  printAllChildren(sourceNode, 0);
215
214
  }
216
215
 
217
-
218
-
@@ -1,4 +1,5 @@
1
- import { camelize, classify } from "@angular-devkit/core/src/utils/strings";
1
+ import { camelCase } from 'lodash';
2
+ import { classify } from '../../../string.utils';
2
3
  import ts, { ModifierLike, ObjectLiteralElementLike, PropertyDeclaration } from "@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript";
3
4
  import { insertImport } from "@schematics/angular/utility/ast-utils";
4
5
  import { Change } from "@schematics/angular/utility/change";
@@ -43,7 +44,7 @@ export class ManyToManyDecoratorManager implements DecoratorManager {
43
44
 
44
45
  const fieldSourceLineComponents: string[] = [];
45
46
  fieldSourceLineComponents.push(`() => ${classify(this.options.relationModelName)}`);
46
- this.options.relationInverseFieldName ? fieldSourceLineComponents.push(`${camelize(this.options.relationModelName)} => ${camelize(this.options.relationModelName)}.${this.options.relationInverseFieldName}`) : "no-ops";
47
+ this.options.relationInverseFieldName ? fieldSourceLineComponents.push(`${camelCase(this.options.relationModelName)} => ${camelCase(this.options.relationModelName)}.${this.options.relationInverseFieldName}`) : "no-ops";
47
48
  fieldSourceLineComponents.push(`${this.buildRelationOptionsCode()}`);
48
49
  fieldSourceLines.push(`@${this.decoratorName()}(${fieldSourceLineComponents.join(', ')})`);
49
50
 
@@ -162,7 +163,7 @@ export class ManyToManyDecoratorManager implements DecoratorManager {
162
163
  [ts.factory.createParameterDeclaration(
163
164
  undefined,
164
165
  undefined,
165
- ts.factory.createIdentifier(camelize(this.options.relationModelName)),
166
+ ts.factory.createIdentifier(camelCase(this.options.relationModelName)),
166
167
  undefined,
167
168
  undefined,
168
169
  undefined
@@ -170,7 +171,7 @@ export class ManyToManyDecoratorManager implements DecoratorManager {
170
171
  undefined,
171
172
  ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),
172
173
  ts.factory.createPropertyAccessExpression(
173
- ts.factory.createIdentifier(camelize(this.options.relationModelName)),
174
+ ts.factory.createIdentifier(camelCase(this.options.relationModelName)),
174
175
  ts.factory.createIdentifier(this.options.relationInverseFieldName)
175
176
  )
176
177
  );
@@ -219,7 +220,6 @@ export class ManyToManyDecoratorManager implements DecoratorManager {
219
220
  return decoratorOptions;
220
221
  }
221
222
 
222
-
223
223
  private findDecorator(name: string, existingModifiers: ts.NodeArray<ts.ModifierLike> | undefined): ts.Decorator | undefined {
224
224
  return existingModifiers ? existingModifiers.filter((m) => (m.kind === ts.SyntaxKind.Decorator)).map(m => m as ts.Decorator).filter(m => this.containsIdentifierName(m, name)).pop() : undefined;
225
225
  }
@@ -1,9 +1,9 @@
1
- import { classify } from "@angular-devkit/core/src/utils/strings";
2
1
  import ts, { ModifierLike, ObjectLiteralElementLike, PropertyDeclaration } from "@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript";
3
2
  import { insertImport } from "@schematics/angular/utility/ast-utils";
4
3
  import { Change } from "@schematics/angular/utility/change";
5
4
  import { DecoratorManager, DeleteType, PartialAddFieldChange } from "../../FieldManager";
6
5
  import _ from 'lodash';
6
+ import { classify } from '../../../string.utils';
7
7
  interface ManyToOneDecoratorOptions {
8
8
  isManyToOne: boolean;
9
9
  relationCoModelSingularName: string;
@@ -1,4 +1,5 @@
1
- import { camelize, classify } from "@angular-devkit/core/src/utils/strings";
1
+ import { camelCase } from 'lodash';
2
+ import { classify } from '../../../string.utils';
2
3
  import ts, { ModifierLike, ObjectLiteralElementLike, PropertyDeclaration } from "@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript";
3
4
  import { insertImport } from "@schematics/angular/utility/ast-utils";
4
5
  import { Change } from "@schematics/angular/utility/change";
@@ -38,13 +39,13 @@ export class OneToManyDecoratorManager implements DecoratorManager {
38
39
  // changes.push(oneToManyImport);
39
40
  // }
40
41
  // fieldSourceLines.push(
41
- // `@${this.decoratorName()}(() => ${classify(this.options.modelName)}, ${camelize(this.options.modelName)} => ${camelize(this.options.modelName)}.${this.options.fieldName}, ${this.buildRelationOptionsCode()})`,
42
+ // `@${this.decoratorName()}(() => ${classify(this.options.modelName)}, ${camelCase(this.options.modelName)} => ${camelCase(this.options.modelName)}.${this.options.fieldName}, ${this.buildRelationOptionsCode()})`,
42
43
  // );
43
44
  changes.push(...this.decoratorImports());
44
45
 
45
46
  const fieldSourceLineComponents: string[] = [];
46
47
  fieldSourceLineComponents.push(`() => ${classify(this.options.relationModelName)}`);
47
- this.options.relationInverseFieldName ? fieldSourceLineComponents.push(`${camelize(this.options.relationModelName)} => ${camelize(this.options.relationModelName)}.${this.options.relationInverseFieldName}`) : "no-ops";
48
+ this.options.relationInverseFieldName ? fieldSourceLineComponents.push(`${camelCase(this.options.relationModelName)} => ${camelCase(this.options.relationModelName)}.${this.options.relationInverseFieldName}`) : "no-ops";
48
49
  fieldSourceLineComponents.push(`${this.buildRelationOptionsCode()}`);
49
50
  fieldSourceLines.push(`@${this.decoratorName()}(${fieldSourceLineComponents.join(', ')})`);
50
51
 
@@ -147,7 +148,7 @@ export class OneToManyDecoratorManager implements DecoratorManager {
147
148
  [ts.factory.createParameterDeclaration(
148
149
  undefined,
149
150
  undefined,
150
- ts.factory.createIdentifier(camelize(this.options.relationModelName)),
151
+ ts.factory.createIdentifier(camelCase(this.options.relationModelName)),
151
152
  undefined,
152
153
  undefined,
153
154
  undefined
@@ -155,7 +156,7 @@ export class OneToManyDecoratorManager implements DecoratorManager {
155
156
  undefined,
156
157
  ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),
157
158
  ts.factory.createPropertyAccessExpression(
158
- ts.factory.createIdentifier(camelize(this.options.relationModelName)),
159
+ ts.factory.createIdentifier(camelCase(this.options.relationModelName)),
159
160
  ts.factory.createIdentifier(this.options.relationInverseFieldName)
160
161
  )
161
162
  );
@@ -202,7 +203,6 @@ export class OneToManyDecoratorManager implements DecoratorManager {
202
203
  return decoratorOptions;
203
204
  }
204
205
 
205
-
206
206
  private findDecorator(name: string, existingModifiers: ts.NodeArray<ts.ModifierLike> | undefined): ts.Decorator | undefined {
207
207
  return existingModifiers ? existingModifiers.filter((m) => (m.kind === ts.SyntaxKind.Decorator)).map(m => m as ts.Decorator).filter(m => this.containsIdentifierName(m, name)).pop() : undefined;
208
208
  }
@@ -1,4 +1,5 @@
1
- import { classify, dasherize } from '@angular-devkit/core/src/utils/strings';
1
+ import { kebabCase } from 'lodash';
2
+ import { classify } from '../../../string.utils';
2
3
  import { Tree } from '@angular-devkit/schematics';
3
4
  import ts, {
4
5
  ClassDeclaration,
@@ -59,8 +60,8 @@ export abstract class BaseFieldManagerForDto implements FieldManager {
59
60
  protected readonly field: any,
60
61
  protected readonly options: ManagerForDtoOptions,
61
62
  ) {
62
- const sourceFileName = (options.sourceType === DtoSourceType.Create) ? `create-${dasherize(modelName)}.dto.ts` : `update-${dasherize(modelName)}.dto.ts`;
63
- const sourcePath = `src/${dasherize(moduleName)}/dtos/${sourceFileName}`;
63
+ const sourceFileName = (options.sourceType === DtoSourceType.Create) ? `create-${kebabCase(modelName)}.dto.ts` : `update-${kebabCase(modelName)}.dto.ts`;
64
+ const sourcePath = `src/${kebabCase(moduleName)}/dtos/${sourceFileName}`;
64
65
  this.source = createSourceFile(
65
66
  tree,
66
67
  sourcePath,
@@ -96,7 +97,6 @@ export abstract class BaseFieldManagerForDto implements FieldManager {
96
97
  return fieldChanges;
97
98
  }
98
99
 
99
-
100
100
  fieldName(): string {
101
101
  return this.field.name;
102
102
  }
@@ -161,7 +161,6 @@ export abstract class BaseFieldManagerForDto implements FieldManager {
161
161
  const builderChanges: PartialAddFieldChange[] = [];
162
162
  builderChanges.push(...this.applyBuildDecoratorTransformations(...decoratorManagers.reverse()));
163
163
 
164
-
165
164
  // Capture the changes and field source lines
166
165
  builderChanges.forEach((builderChange) => {
167
166
  changes.push(...builderChange.changes);
@@ -226,7 +225,6 @@ export abstract class BaseFieldManagerForDto implements FieldManager {
226
225
  source,
227
226
  )?.parent as PropertyDeclaration;
228
227
 
229
-
230
228
  // FIXME Handle the imports related to the updated field type
231
229
  // Update the entity property declaration type
232
230
  let updatedPropertyDeclarationNode: ts.PropertyDeclaration =
@@ -1,7 +1,5 @@
1
- import {
2
- classify,
3
- dasherize
4
- } from '@angular-devkit/core/src/utils/strings';
1
+ import { kebabCase } from 'lodash';
2
+ import { classify } from '../../../string.utils';
5
3
  import { Tree } from '@angular-devkit/schematics';
6
4
  import ts, {
7
5
  PropertyDeclaration,
@@ -55,7 +53,7 @@ export abstract class BaseFieldManagerForEntity implements FieldManager {
55
53
  // So every operation should use a new instance of the field manager, so updated tree/source is used before each operation
56
54
  this.source = createSourceFile(
57
55
  tree,
58
- `src/${dasherize(moduleName)}/entities/${dasherize(modelName)}.entity.ts`,
56
+ `src/${kebabCase(moduleName)}/entities/${kebabCase(modelName)}.entity.ts`,
59
57
  );
60
58
  const fieldPropertyDeclarationNode = this.getFieldIdentifierNode(
61
59
  this.fieldName(),
@@ -181,7 +179,6 @@ export abstract class BaseFieldManagerForEntity implements FieldManager {
181
179
  const builderChanges: PartialAddFieldChange[] = [];
182
180
  builderChanges.push(...this.applyBuildDecoratorTransformations(...decoratorManagers.reverse()));
183
181
 
184
-
185
182
  // Capture the changes and field source lines
186
183
  builderChanges.forEach((builderChange) => {
187
184
  changes.push(...builderChange.changes);
@@ -287,7 +284,6 @@ export abstract class BaseFieldManagerForEntity implements FieldManager {
287
284
  source,
288
285
  )?.parent as PropertyDeclaration;
289
286
 
290
-
291
287
  // FIXME Handle the imports related to the updated field type
292
288
  // Update the entity property declaration type
293
289
  let updatedPropertyDeclarationNode: ts.PropertyDeclaration =
@@ -483,7 +479,6 @@ export abstract class BaseFieldManagerForEntity implements FieldManager {
483
479
  return `${this.field.relationCoModelSingularName}s`;
484
480
  }
485
481
 
486
-
487
482
  private isManyToOne(): boolean {
488
483
  return (this.field.type === 'relation' && this.field.relationType === RelationType.ManyToOne);
489
484
  }
@@ -492,7 +487,6 @@ export abstract class BaseFieldManagerForEntity implements FieldManager {
492
487
  return (this.field.type === 'relation' && this.field.relationType === RelationType.OneToMany);
493
488
  }
494
489
 
495
-
496
490
  protected isAdditionalFieldRequired(): boolean {
497
491
  return false;
498
492
  }
@@ -1,4 +1,5 @@
1
- import { classify, dasherize } from '@angular-devkit/core/src/utils/strings';
1
+ import { kebabCase } from 'lodash';
2
+ import { classify } from '../../../string.utils';
2
3
  import { Tree } from '@angular-devkit/schematics';
3
4
  import ts, { PropertyDeclaration } from '@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript';
4
5
  import { Change } from '@schematics/angular/utility/change';
@@ -270,7 +271,7 @@ export class ManyToManyRelationFieldManagerForDto
270
271
  }
271
272
 
272
273
  relatedFieldImport(): Change {
273
- const relatedEntityImportName = `update-${dasherize(this.field.relationCoModelSingularName)}.dto`;
274
+ const relatedEntityImportName = `update-${kebabCase(this.field.relationCoModelSingularName)}.dto`;
274
275
  const relatedEntityPath = this.field.relationModelModuleName ? `src/${this.field.relationModelModuleName}/dtos/${relatedEntityImportName}` : `./${relatedEntityImportName}`;
275
276
  return safeInsertImport(this.source, `Update${classify(this.field.relationCoModelSingularName)}Dto`, relatedEntityPath, this.moduleName);
276
277
  // return insertImport(this.source, this.source.fileName, `Update${classify(this.field.relationCoModelSingularName)}Dto`, relatedEntityPath);
@@ -1,4 +1,5 @@
1
- import { classify, dasherize } from '@angular-devkit/core/src/utils/strings';
1
+ import { kebabCase } from 'lodash';
2
+ import { classify } from '../../../string.utils';
2
3
  import ts from '@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript';
3
4
  import { Change } from '@schematics/angular/utility/change';
4
5
  import { FieldChange, FieldManager, FieldType, safeInsertImport } from '../../FieldManager';
@@ -51,8 +52,8 @@ export class ManyToManyRelationFieldManagerForEntity
51
52
  }
52
53
 
53
54
  relatedFieldImport(): Change {
54
- const relatedEntityImportName = `${dasherize(this.field.relationCoModelSingularName)}.entity`;
55
- const relatedEntityPath = this.field.relationModelModuleName ? `src/${dasherize(this.field.relationModelModuleName)}/entities/${relatedEntityImportName}` : `./${relatedEntityImportName}`;
55
+ const relatedEntityImportName = `${kebabCase(this.field.relationCoModelSingularName)}.entity`;
56
+ const relatedEntityPath = this.field.relationModelModuleName ? `src/${kebabCase(this.field.relationModelModuleName)}/entities/${relatedEntityImportName}` : `./${relatedEntityImportName}`;
56
57
  return safeInsertImport(this.source, classify(this.field.relationCoModelSingularName), relatedEntityPath, this.moduleName);
57
58
  }
58
59
 
@@ -1,4 +1,5 @@
1
- import { classify, dasherize } from '@angular-devkit/core/src/utils/strings';
1
+ import { kebabCase } from 'lodash';
2
+ import { classify } from '../../../string.utils';
2
3
  import ts from '@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript';
3
4
  import { Change } from '@schematics/angular/utility/change';
4
5
  import { FieldChange, FieldManager, FieldType, safeInsertImport } from '../../FieldManager';
@@ -45,8 +46,8 @@ export class ManyToOneRelationFieldManagerForEntity
45
46
  }
46
47
 
47
48
  relatedFieldImport(): Change {
48
- const relatedEntityImportName = `${dasherize(this.field.relationCoModelSingularName)}.entity`;
49
- const relatedEntityPath = this.field.relationModelModuleName ? `src/${dasherize(this.field.relationModelModuleName)}/entities/${relatedEntityImportName}` : `./${relatedEntityImportName}`;
49
+ const relatedEntityImportName = `${kebabCase(this.field.relationCoModelSingularName)}.entity`;
50
+ const relatedEntityPath = this.field.relationModelModuleName ? `src/${kebabCase(this.field.relationModelModuleName)}/entities/${relatedEntityImportName}` : `./${relatedEntityImportName}`;
50
51
  return safeInsertImport(this.source, classify(this.field.relationCoModelSingularName), relatedEntityPath, this.moduleName);
51
52
  }
52
53
 
@@ -1,4 +1,5 @@
1
- import { classify, dasherize } from '@angular-devkit/core/src/utils/strings';
1
+ import { kebabCase } from 'lodash';
2
+ import { classify } from '../../../string.utils';
2
3
  import { Tree } from '@angular-devkit/schematics';
3
4
  import ts, { PropertyDeclaration } from '@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript';
4
5
  import { Change } from '@schematics/angular/utility/change';
@@ -134,7 +135,6 @@ export class OneToManyRelationFieldManagerForDto
134
135
 
135
136
  }
136
137
 
137
-
138
138
  override updateField(): FieldChange[] {
139
139
  const fieldChanges: FieldChange[] = super.updateField();
140
140
 
@@ -215,7 +215,6 @@ export class OneToManyRelationFieldManagerForDto
215
215
  }
216
216
  }
217
217
 
218
-
219
218
  override removeAdditionalField(): FieldChange[] {
220
219
  const fieldChanges: FieldChange[] = [];
221
220
 
@@ -243,7 +242,7 @@ export class OneToManyRelationFieldManagerForDto
243
242
  }
244
243
 
245
244
  relatedFieldImport(): Change {
246
- const relatedEntityImportName = `update-${dasherize(this.field.relationCoModelSingularName)}.dto`;
245
+ const relatedEntityImportName = `update-${kebabCase(this.field.relationCoModelSingularName)}.dto`;
247
246
  const relatedEntityPath = this.field.relationModelModuleName ? `src/${this.field.relationModelModuleName}/dtos/${relatedEntityImportName}` : `./${relatedEntityImportName}`;
248
247
  return safeInsertImport(this.source, `Update${classify(this.field.relationCoModelSingularName)}Dto`, relatedEntityPath, this.moduleName);
249
248
  // return insertImport(this.source, this.source.fileName, `Update${classify(this.field.relationCoModelSingularName)}Dto`, relatedEntityPath);
@@ -1,4 +1,5 @@
1
- import { classify, dasherize } from '@angular-devkit/core/src/utils/strings';
1
+ import { kebabCase } from 'lodash';
2
+ import { classify } from '../../../string.utils';
2
3
  import ts from '@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript';
3
4
  import { Change } from '@schematics/angular/utility/change';
4
5
  import { FieldChange, FieldManager, FieldType, safeInsertImport } from '../../FieldManager';
@@ -29,12 +30,11 @@ export class OneToManyRelationFieldManagerForEntity
29
30
  }
30
31
 
31
32
  relatedFieldImport(): Change {
32
- const relatedEntityImportName = `${dasherize(this.field.relationCoModelSingularName)}.entity`;
33
- const relatedEntityPath = this.field.relationModelModuleName ? `src/${dasherize(this.field.relationModelModuleName)}/entities/${relatedEntityImportName}` : `./${relatedEntityImportName}`;
33
+ const relatedEntityImportName = `${kebabCase(this.field.relationCoModelSingularName)}.entity`;
34
+ const relatedEntityPath = this.field.relationModelModuleName ? `src/${kebabCase(this.field.relationModelModuleName)}/entities/${relatedEntityImportName}` : `./${relatedEntityImportName}`;
34
35
  return safeInsertImport(this.source, classify(this.field.relationCoModelSingularName), relatedEntityPath, this.moduleName);
35
36
  }
36
37
 
37
-
38
38
  fieldType(): FieldType { // The inverse field type will remain the same for both one-to-many and many-to-many relations
39
39
  const type = `${classify(this.field.relationCoModelSingularName)}`
40
40
  const text = `${type}[]`
@@ -1,4 +1,5 @@
1
- import { classify, dasherize } from '@angular-devkit/core/src/utils/strings';
1
+ import { kebabCase } from 'lodash';
2
+ import { classify } from '../string.utils';
2
3
  import { Tree } from '@angular-devkit/schematics';
3
4
  import { MetadataManager } from '@nestjs/schematics';
4
5
  import ts from '@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript';
@@ -17,7 +18,6 @@ import { SupportedDatabases } from '../field/db-helpers';
17
18
  export const SOLID_CORE_MODULE_NAME = 'solid-core';
18
19
  export const SOLID_CORE_MODULE_NPM_PACKAGE_NAME = '@solidxai/core';
19
20
 
20
-
21
21
  // export const CHECKSUM_FILE_PATH = 'code-builder/output/checksums.json';
22
22
  export const CHECKSUM_HASH_ALGORITHM = 'md5';
23
23
  export enum Command {
@@ -95,27 +95,27 @@ export function getSolidImports(
95
95
  case SolidProviderType.Dto:
96
96
  return {
97
97
  symbolName: `Create${classify(modelName)}Dto`,
98
- importPath: `./dtos/create-${dasherize(modelName)}.dto`,
98
+ importPath: `./dtos/create-${kebabCase(modelName)}.dto`,
99
99
  };
100
100
  case SolidProviderType.Service:
101
101
  return {
102
102
  symbolName: `${classify(modelName)}Service`,
103
- importPath: `./services/${dasherize(modelName)}.service`,
103
+ importPath: `./services/${kebabCase(modelName)}.service`,
104
104
  };
105
105
  case SolidProviderType.Controller:
106
106
  return {
107
107
  symbolName: `${classify(modelName)}Controller`,
108
- importPath: `./controllers/${dasherize(modelName)}.controller`,
108
+ importPath: `./controllers/${kebabCase(modelName)}.controller`,
109
109
  };
110
110
  case SolidProviderType.Entity:
111
111
  return {
112
112
  symbolName: `${classify(modelName)}`,
113
- importPath: `./entities/${dasherize(modelName)}.entity`,
113
+ importPath: `./entities/${kebabCase(modelName)}.entity`,
114
114
  };
115
115
  case SolidProviderType.Repository:
116
116
  return {
117
117
  symbolName: `${classify(modelName)}Repository`,
118
- importPath: `./repositories/${dasherize(modelName)}.repository`,
118
+ importPath: `./repositories/${kebabCase(modelName)}.repository`,
119
119
  };
120
120
  default:
121
121
  throw Error('Invalid SolidProviderType');
@@ -251,7 +251,7 @@ function getModuleMetadataFilePath(moduleName: string) {
251
251
  return `src/${moduleName}/seeders/seed-data/${moduleName}-metadata.json`
252
252
  }
253
253
  else {
254
- return `module-metadata/${dasherize(moduleName)}/${dasherize(moduleName)}-metadata.json`;
254
+ return `module-metadata/${kebabCase(moduleName)}/${kebabCase(moduleName)}-metadata.json`;
255
255
  }
256
256
  }
257
257
 
@@ -262,7 +262,6 @@ function getModuleMetadataFilePath(moduleName: string) {
262
262
  // return checksums.filter((checksum: Checksum) => checksum.filePath === filePath).pop();
263
263
  // }
264
264
 
265
-
266
265
  function applyChanges(tree: Tree, filePath: string, changes: Change[]) {
267
266
  /*
268
267
  //Given the filePath, generate a checksum of the file from the content of the file
@@ -416,15 +415,15 @@ export function getSourceFilePathsAffected(command: Command, options: any): stri
416
415
  const sourceFilePaths: string[] = [];
417
416
  switch (command) {
418
417
  case Command.AddModule:
419
- sourceFilePaths.push(`src/${dasherize(options.module)}/${dasherize(options.module)}.module.ts`);
418
+ sourceFilePaths.push(`src/${kebabCase(options.module)}/${kebabCase(options.module)}.module.ts`);
420
419
  break;
421
420
  case Command.AddModel:
422
- sourceFilePaths.push(`src/${dasherize(options.module)}/${dasherize(options.module)}.module.ts`);
423
- sourceFilePaths.push(`src/${dasherize(options.module)}/services/${dasherize(options.model)}.service.ts`);
424
- sourceFilePaths.push(`src/${dasherize(options.module)}/controllers/${dasherize(options.model)}.controller.ts`);
425
- sourceFilePaths.push(`src/${dasherize(options.module)}/entities/${dasherize(options.model)}.entity.ts`);
426
- sourceFilePaths.push(`src/${dasherize(options.module)}/dtos/create-${dasherize(options.model)}.dto.ts`);
427
- sourceFilePaths.push(`src/${dasherize(options.module)}/dtos/update-${dasherize(options.model)}.dto.ts`);
421
+ sourceFilePaths.push(`src/${kebabCase(options.module)}/${kebabCase(options.module)}.module.ts`);
422
+ sourceFilePaths.push(`src/${kebabCase(options.module)}/services/${kebabCase(options.model)}.service.ts`);
423
+ sourceFilePaths.push(`src/${kebabCase(options.module)}/controllers/${kebabCase(options.model)}.controller.ts`);
424
+ sourceFilePaths.push(`src/${kebabCase(options.module)}/entities/${kebabCase(options.model)}.entity.ts`);
425
+ sourceFilePaths.push(`src/${kebabCase(options.module)}/dtos/create-${kebabCase(options.model)}.dto.ts`);
426
+ sourceFilePaths.push(`src/${kebabCase(options.module)}/dtos/update-${kebabCase(options.model)}.dto.ts`);
428
427
  break;
429
428
  default:
430
429
  throw Error('Invalid command');
@@ -543,7 +542,7 @@ export function outputEntitySuperClassImport(module: string, isLegacyTable: bool
543
542
  let importPath: string = isLegacyTableWithId ? SOLID_CORE_MODULE_NPM_PACKAGE_NAME : isLegacyTable ? SOLID_CORE_MODULE_NPM_PACKAGE_NAME : calculateModuleFileImportPath(module, `src/entities/common.entity`);
544
543
  let importSymbol: string = isLegacyTableWithId ? "LegacyCommonWithIdEntity" : isLegacyTable ? "LegacyCommonEntity" : "CommonEntity";
545
544
  if (parentModel != null) {
546
- importPath = calculateParentModuleFileImportPath(parentModule, `src/${dasherize(parentModule)}/entities/${dasherize(parentModel)}.entity`);
545
+ importPath = calculateParentModuleFileImportPath(parentModule, `src/${kebabCase(parentModule)}/entities/${kebabCase(parentModel)}.entity`);
547
546
  importSymbol = `${classify(parentModel)}`;
548
547
  }
549
548
  return `import { ${importSymbol} } from '${importPath}';`;
@@ -556,10 +555,10 @@ export function outputParentImportPathForDto(parentModel: string | null = null,
556
555
  let importPath = ``;
557
556
  let importSymbol = ``;
558
557
  if (context === DtoSourceType.Update) {
559
- importPath = parentModule === SOLID_CORE_MODULE_NAME ? SOLID_CORE_MODULE_NPM_PACKAGE_NAME : `src/${dasherize(parentModule)}/dtos/update-${dasherize(parentModel)}.dto.ts`;
558
+ importPath = parentModule === SOLID_CORE_MODULE_NAME ? SOLID_CORE_MODULE_NPM_PACKAGE_NAME : `src/${kebabCase(parentModule)}/dtos/update-${kebabCase(parentModel)}.dto.ts`;
560
559
  importSymbol = `Update${classify(parentModel)}Dto`;
561
560
  } else if (context === DtoSourceType.Create) {
562
- importPath = parentModule === SOLID_CORE_MODULE_NAME ? SOLID_CORE_MODULE_NPM_PACKAGE_NAME : `src/${dasherize(parentModule)}/dtos/create-${dasherize(parentModel)}.dto.ts`;
561
+ importPath = parentModule === SOLID_CORE_MODULE_NAME ? SOLID_CORE_MODULE_NPM_PACKAGE_NAME : `src/${kebabCase(parentModule)}/dtos/create-${kebabCase(parentModel)}.dto.ts`;
563
562
  importSymbol = `Create${classify(parentModel)}Dto`;
564
563
  }
565
564
  return `import { ${importSymbol} } from '${importPath}';`;
@@ -0,0 +1,3 @@
1
+ import { upperFirst, camelCase } from 'lodash';
2
+
3
+ export const classify = (s: string): string => upperFirst(camelCase(s));