@solidstarters/solid-core 1.2.60 → 1.2.62

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidstarters/solid-core",
3
- "version": "1.2.60",
3
+ "version": "1.2.62",
4
4
  "description": "This module is a NestJS module containing all the required core providers required by a Solid application",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -33,7 +33,7 @@ export class RefreshModelCommand extends CommandRunner {
33
33
  modelUserKey: options.name,
34
34
  dryRun: options.dryRun,
35
35
  };
36
- await this.modelMetadataService.generateCode(codeGenerationOptions);
36
+ await this.modelMetadataService.handleGenerateCode(codeGenerationOptions);
37
37
  }
38
38
 
39
39
  @Option({
@@ -69,7 +69,7 @@ export class ModelMetadataController {
69
69
  @ApiBearerAuth("jwt")
70
70
  @Post(':id/generate-code')
71
71
  generateCode(@Param('id', ParseIntPipe) id: number) {
72
- return this.modelMetadataService.generateCode({ modelId: id});
72
+ return this.modelMetadataService.handleGenerateCode({ modelId: id});
73
73
  }
74
74
 
75
75
 
@@ -4,6 +4,8 @@ import { PaginationQueryDto } from "src/dtos/pagination-query.dto";
4
4
  import { SelectionProvider } from "src/decorators/selection-provider.decorator";
5
5
  import { Injectable } from "@nestjs/common";
6
6
  import { ISelectionProvider, ISelectionProviderContext, ISelectionProviderValues } from "../interfaces";
7
+ import { filter } from "rxjs";
8
+ import { BasicFilterDto } from "src/dtos/basic-filters.dto";
7
9
 
8
10
  interface ListOfValuesProviderContext extends ISelectionProviderContext {
9
11
  type: string;
@@ -31,8 +33,14 @@ export class ListOfValuesSelectionProvider implements ISelectionProvider<ListOfV
31
33
  }
32
34
 
33
35
  async values(query: string, ctxt: ListOfValuesProviderContext): Promise<readonly ISelectionProviderValues[]> {
34
- const paginatedQuery = new PaginationQueryDto(DEFAULT_LIMIT, 0);
35
- const lovs = await this.listOfValuesService.find(paginatedQuery);
36
+ const basicFilterQuery = new BasicFilterDto(DEFAULT_LIMIT, 0);
37
+ basicFilterQuery.filters = {
38
+ type: {
39
+ $eq: ctxt.type
40
+ }
41
+ }
42
+
43
+ const lovs = await this.listOfValuesService.find(basicFilterQuery);
36
44
  const selectionValues = lovs.records.map(lov => {
37
45
  return {
38
46
  label: lov.display,
@@ -8674,13 +8674,5 @@
8674
8674
  ],
8675
8675
  "checksums": [],
8676
8676
  "listOfValues": [
8677
- {
8678
- "type": "industry",
8679
- "value": "IT",
8680
- "display": "IT",
8681
- "description": "Insdustry It list of value",
8682
- "default": true,
8683
- "sequence": 1
8684
- }
8685
8677
  ]
8686
8678
  }
@@ -717,21 +717,22 @@ export class ModelMetadataService {
717
717
  return this.modelMetadataRepo.remove(entity);
718
718
  }
719
719
 
720
- async generateCode(options: CodeGenerationOptions): Promise<string> {
721
- const query = {
722
- populate: ["module", "fields"]
723
- };
724
-
725
- const model = options.modelId
726
- ? await this.findOne(options.modelId, query)
727
- : await this.findOneByUserKey(options.modelUserKey, query.populate);
728
-
729
- options.fieldIdsForRemoval = model.fields
730
- .filter(field => field.isMarkedForRemoval)
731
- .map(field => field.id);
732
-
733
- const refreshModelCodeOutput = await this.generateModelCode(options);
734
- const removeFieldCodeOuput = await this.generateRemoveFieldsCode(options);
720
+ async handleGenerateCode(options: CodeGenerationOptions): Promise<string> {
721
+ const { model, removeFieldCodeOuput, refreshModelCodeOutput } = await this.generateCode(options);
722
+
723
+ // Generate the code for models which are linked to fields having an inverse relation
724
+ const coModelSingularNames = model.fields.
725
+ filter(field => field.type === SolidFieldType.relation && field.relationCreateInverse === true)
726
+ .map(field => field.relationCoModelSingularName);
727
+
728
+ for (const singularName of coModelSingularNames) {
729
+ const coModel = await this.findOneBySingularName(singularName);
730
+ const inverseOptions: CodeGenerationOptions = {
731
+ modelId: coModel.id,
732
+ dryRun: options.dryRun
733
+ };
734
+ await this.generateCode(inverseOptions);
735
+ }
735
736
 
736
737
  const jsonFieldsList = model.fields.filter((field: FieldMetadata) => field.isSystem !== true);
737
738
 
@@ -739,8 +740,7 @@ export class ModelMetadataService {
739
740
  type: "field",
740
741
  attrs: {
741
742
  name: `${field.name}`,
742
- sortable: true,
743
- filterable: true
743
+ isSearchable: true,
744
744
  }
745
745
  }));
746
746
 
@@ -876,6 +876,24 @@ export class ModelMetadataService {
876
876
  return `${removeFieldCodeOuput} \n ${refreshModelCodeOutput}`;
877
877
  }
878
878
 
879
+ private async generateCode(options: CodeGenerationOptions) {
880
+ const query = {
881
+ populate: ["module", "fields"]
882
+ };
883
+
884
+ const model = options.modelId
885
+ ? await this.findOne(options.modelId, query)
886
+ : await this.findOneByUserKey(options.modelUserKey, query.populate);
887
+
888
+ options.fieldIdsForRemoval = model.fields
889
+ .filter(field => field.isMarkedForRemoval)
890
+ .map(field => field.id);
891
+
892
+ const refreshModelCodeOutput = await this.generateModelCode(options);
893
+ const removeFieldCodeOuput = await this.generateRemoveFieldsCode(options);
894
+ return { model, removeFieldCodeOuput, refreshModelCodeOutput };
895
+ }
896
+
879
897
  async generateRemoveFieldsCode(options: CodeGenerationOptions): Promise<string> {
880
898
  if (!options.modelId && !options.modelUserKey) {
881
899
  throw new BadRequestException('Model ID or Model Name is required for generating code');
@@ -375,7 +375,7 @@ export class ModuleMetadataService {
375
375
  modelId: model.id,
376
376
  dryRun: options.dryRun,
377
377
  };
378
- const output = await this.modelMetadataService.generateCode(codeGenerationOptions);
378
+ const output = await this.modelMetadataService.handleGenerateCode(codeGenerationOptions);
379
379
  this.logger.debug(`Schematic output : ${output}`);
380
380
  outputLines.push(output)
381
381
  }
@@ -1,43 +0,0 @@
1
- // many-to-one field
2
- // {
3
- // "name": "module",
4
- // "displayName": "Module",
5
- // "type": "relation",
6
- // "required": true,
7
- // "unique": false,
8
- // "index": true,
9
- // "private": false,
10
- // "encrypt": false,
11
- // "relationType": "many-to-one",
12
- // "relationModelSingularName": "moduleMetadata",
13
- // "relationCreateInverse": true,
14
- // "relationCascade": "set null",
15
- // "relationModelModuleName": "solid-core",
16
- // "isSystem": true
17
- // },
18
-
19
- // one-to-many field
20
- // {
21
- // "name": field.relationModelField,
22
- // Logic to create a oneToMany field definition
23
- // return [
24
- // "name",
25
- // "displayName",
26
- // "description",
27
- // "type",
28
- // "ormType",
29
- // "isSystem",
30
- // "relationType",
31
- // "relationModelFieldName",
32
- // "relationCreateInverse",
33
- // "relationModelSingularName",
34
- // "relationModelModuleName",
35
- // "required",
36
- // "unique",
37
- // "index",
38
- // "private",
39
- // "encrypt",
40
- // "encryptionType",
41
- // "decryptWhen",
42
- // "columnName"
43
- // ];
@@ -1,14 +0,0 @@
1
- # Issues
2
- 1. @Column("text", { array: true, name: 'media_types', nullable: true }) // array type not supported. No impact on code generation. not being used
3
- 2.
4
- default values not allowed for text,blog // Code generation impact. If we want to support default values for long text/rich text, then changes to be made.
5
- date value is not supported propertly in mysql
6
- i.e new Date("2025-02-11T00:00:00.000Z")
7
- 3. Below type of code cannot exist. // No impact on code generation. Not being used.
8
- @Index({ unique: true })
9
- @Column({ unique: true })
10
- 4. // Impact on code generation. unique index to be generated by using @Index and not @Column.
11
- @Index({ unique: true })
12
- @Column({ })
13
- 5. i.e new Date("2025-02-11T00:00:00.000Z")
14
- -> Remove the column default value