@solidstarters/solid-core 1.2.52 → 1.2.53

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.52",
3
+ "version": "1.2.53",
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",
@@ -321,10 +321,15 @@ export class CreateFieldMetadataDto {
321
321
  @IsOptional()
322
322
  relationCoModelFieldName: string;
323
323
 
324
- @ApiProperty({description: 'Only for type=relation, many-to-many. This field is used to set the owner of the many-to-many relation'})
324
+ @ApiProperty({ description: 'Only for type=relation, many-to-many. This field is used to set the owner of the many-to-many relation' })
325
325
  @IsOptional()
326
326
  isRelationManyToManyOwner: boolean;
327
327
 
328
+
329
+ @ApiProperty({ description: 'Only for type=relation, many-to-many. This field is used to store fixed filters that needs to applied on related model' })
330
+ @IsOptional()
331
+ relationFieldFixedFilter: string;
332
+
328
333
  @ApiProperty({
329
334
  description:
330
335
  'Dynamic provider for selection. Only for type=selectionDynamic',
@@ -102,6 +102,12 @@ export class FieldMetadata extends CommonEntity {
102
102
  @Column({ name: 'is_relation_many_to_many_owner', nullable: true })
103
103
  isRelationManyToManyOwner: boolean;
104
104
 
105
+ // We can store a filter json like this {"fieldName": ${someVarWhichWillComeFromParentModel... or can be hard coded...}}
106
+ // {"type": "INDUSTRY"} .... Eg. static fixedFilter
107
+ // {"country_id", "${country}"} ... Eg. dynamic fixedFilter
108
+ @Column({ name: 'relation_Field_Fixed_Filter', nullable: true })
109
+ relationFieldFixedFilter: string;
110
+
105
111
  @Column({ name: 'selection_dynamic_provider', nullable: true })
106
112
  selectionDynamicProvider: string;
107
113
 
@@ -14,6 +14,7 @@ type FieldOptions = {
14
14
  dataSource: string;
15
15
  fields: any[]; //FIXME This type can be improved
16
16
  modelEnableSoftDelete?: boolean;
17
+ parentModel?: string;
17
18
  };
18
19
  export const REMOVE_FIELDS_COMMAND = 'remove-fields';
19
20
  export const REFRESH_MODEL_COMMAND = 'refresh-model';
@@ -70,6 +71,10 @@ export class SchematicService {
70
71
  modelCommand += ` --model-enable-soft-delete=${fieldOptions.modelEnableSoftDelete}`;
71
72
  }
72
73
 
74
+ if (fieldOptions.parentModel) {
75
+ modelCommand += ` --parent-model=${fieldOptions.parentModel}`;
76
+ }
77
+
73
78
  let fieldCommand = fieldOptions.fields
74
79
  .filter((field) => {
75
80
  return !Object.values(SYSTEM_FIELDS_TO_IGNORE_FOR_CODE_GENERATION).includes(field.name);
@@ -726,6 +726,18 @@
726
726
  "columnName": "relation_model_field_name",
727
727
  "isSystem": true
728
728
  },
729
+ {
730
+ "name": "relationFieldFixedFilter",
731
+ "displayName": "App Description",
732
+ "type": "longText",
733
+ "ormType": "varchar",
734
+ "required": false,
735
+ "unique": false,
736
+ "index": false,
737
+ "private": false,
738
+ "encrypt": false,
739
+ "isSystem": true
740
+ },
729
741
  {
730
742
  "name": "selectionDynamicProvider",
731
743
  "displayName": "Selection Dynamic Provider",
@@ -3874,7 +3886,7 @@
3874
3886
  "body": "",
3875
3887
  "confirmBtnLabel": "Generate Code",
3876
3888
  "cancelBtnLabel": "Cancel",
3877
- "customComponent": "../extension/solid-core/moduleMetadata/list/GenerateModuleCodeRowAction",
3889
+ "customComponent": "GenerateModuleCodeRowAction",
3878
3890
  "customComponentIsSystem": true,
3879
3891
  "endpoint": ""
3880
3892
  }
@@ -4066,7 +4078,7 @@
4066
4078
  "body": "",
4067
4079
  "confirmBtnLabel": "Generate Code",
4068
4080
  "cancelBtnLabel": "Cancel",
4069
- "customComponent": "../extension/solid-core/modelMetadata/list/GenerateModelCodeRowAction",
4081
+ "customComponent": "GenerateModelCodeRowAction",
4070
4082
  "customComponentIsSystem": true,
4071
4083
  "endpoint": ""
4072
4084
  }
@@ -5684,9 +5696,8 @@
5684
5696
  "type": "field",
5685
5697
  "attrs": {
5686
5698
  "name": "name",
5687
- "isSearchable": true,
5688
- "widget": "HarishShortText"
5689
- }
5699
+ "isSearchable": true
5700
+ }
5690
5701
  },
5691
5702
  {
5692
5703
  "type": "field",
@@ -6675,7 +6686,8 @@
6675
6686
  "type": "field",
6676
6687
  "attrs": {
6677
6688
  "name": "username",
6678
- "isSearchable": true
6689
+ "isSearchable": true,
6690
+ "widget": "SolidUserNameAvatarWidget"
6679
6691
  }
6680
6692
  },
6681
6693
  {
@@ -68,9 +68,9 @@ export class FieldMetadataService {
68
68
  private: false,
69
69
  encrypt: false,
70
70
  model: relationModel,
71
- columnName:null,
71
+ columnName: null,
72
72
  relationJoinTableName: null,
73
- id : null,
73
+ id: null,
74
74
  }
75
75
 
76
76
  // Load the inverse field,
@@ -98,9 +98,9 @@ export class FieldMetadataService {
98
98
  private: false,
99
99
  encrypt: false,
100
100
  model: relationModel,
101
- columnName:null,
101
+ columnName: null,
102
102
  relationJoinTableName: null,
103
- id : null,
103
+ id: null,
104
104
  }
105
105
 
106
106
  // Load the inverse field,
@@ -129,10 +129,10 @@ export class FieldMetadataService {
129
129
  private: false,
130
130
  encrypt: false,
131
131
  model: relationModel,
132
- columnName:null,
132
+ columnName: null,
133
133
  relationJoinTableName: null,
134
134
  isRelationManyToManyOwner: false,
135
- id : null,
135
+ id: null,
136
136
  }
137
137
  const savedField = await this.saveInverseField(fieldRepository, relationModel, inverseFieldManyToMany);
138
138
  return savedField;
@@ -141,7 +141,7 @@ export class FieldMetadataService {
141
141
  throw new Error(`Invalid relation type for field ${field.name} with relation type ${field.relationType}`);
142
142
  }
143
143
  }
144
-
144
+
145
145
  private async getRelationModel(modelRepository: Repository<ModelMetadata>, field: FieldMetadata, moduleName: string) {
146
146
  return await modelRepository.findOne({
147
147
  where: {
@@ -750,6 +750,7 @@ export class FieldMetadataService {
750
750
  "columnName",
751
751
  "relationJoinTableName",
752
752
  "isRelationManyToManyOwner",
753
+ "relationFieldFixedFilter"
753
754
  ];
754
755
 
755
756
  case SolidFieldType.mediaSingle:
@@ -1080,7 +1081,7 @@ export class FieldMetadataService {
1080
1081
  fieldsRequiredBasedOnType.forEach((requiredField) => {
1081
1082
  fieldObject[requiredField] = field[requiredField];
1082
1083
  });
1083
-
1084
+
1084
1085
  if (field.type == "mediaSingle" || field.type == "mediaMultiple") {
1085
1086
  if (field.mediaStorageProvider) {
1086
1087
  delete fieldObject.mediaStorageProviderId
@@ -184,6 +184,16 @@ export class ModelMetadataService {
184
184
  relations: {},
185
185
  });
186
186
  createDto['module'] = resolvedModule;
187
+
188
+ const resolvedParentModel = await this.dataSource
189
+ .getRepository(ModelMetadata)
190
+ .findOne({
191
+ where: {
192
+ id: createDto['parentModelId'],
193
+ },
194
+ relations: {},
195
+ });
196
+ createDto['parentModel'] = resolvedParentModel;
187
197
  const { fields: fieldsMetadata, ...modelMetaDataWithoutFields } = createDto;
188
198
  const modelMetadata = this.modelMetadataRepo.create(modelMetaDataWithoutFields);
189
199
  let model = await manager.save(modelMetadata);
@@ -330,7 +340,7 @@ export class ModelMetadataService {
330
340
  where: {
331
341
  id: modelId,
332
342
  },
333
- relations: ["fields", "fields.mediaStorageProvider", "module"], //FIXME: Check with jenender and change to relations to avoid confusion
343
+ relations: ["fields", "fields.mediaStorageProvider", "module", "parentModel"], //FIXME: Check with jenender and change to relations to avoid confusion
334
344
  });
335
345
 
336
346
  const filePath = this.moduleMetadataHelperService.getModuleMetadataFilePath(model.module.name);
@@ -345,6 +355,8 @@ export class ModelMetadataService {
345
355
  dataSourceType: model.dataSourceType,
346
356
  tableName: model.tableName,
347
357
  userKeyFieldUserKey: model.fields.find(field => field.isUserKey)?.name,
358
+ isChild: model?.isChild,
359
+ parentModelUserKey: model?.parentModel?.singularName,
348
360
  fields: []
349
361
  }
350
362
 
@@ -595,7 +607,7 @@ export class ModelMetadataService {
595
607
  where: {
596
608
  id: modelId,
597
609
  },
598
- relations: ["fields", "fields.mediaStorageProvider", "module"], //FIXME: Check with jenender and change to relations to avoid confusion
610
+ relations: ["fields", "fields.mediaStorageProvider", "module", "parentModel"], //FIXME: Check with jenender and change to relations to avoid confusion
599
611
  });
600
612
 
601
613
  const filePath = this.moduleMetadataHelperService.getModuleMetadataFilePath(model.module.name);
@@ -610,6 +622,8 @@ export class ModelMetadataService {
610
622
  dataSourceType: model.dataSourceType,
611
623
  tableName: model.tableName,
612
624
  userKeyFieldUserKey: model.fields.find(field => field.isUserKey)?.name,
625
+ isChild: model.isChild,
626
+ parentModelUserKey: model.parentModel.singularName,
613
627
  fields: []
614
628
  }
615
629
 
@@ -895,7 +909,7 @@ export class ModelMetadataService {
895
909
  }
896
910
 
897
911
  const query = {
898
- populate: ["module", "fields"]
912
+ populate: ["module", "fields", "parentModel"]
899
913
  };
900
914
  const model = options.modelId ? await this.findOne(options.modelId, query) : await this.findOneByUserKey(options.modelUserKey, query.populate);
901
915
 
@@ -917,7 +931,8 @@ export class ModelMetadataService {
917
931
  dataSource: model.dataSource,
918
932
  table: model.tableName,
919
933
  fields: fieldsForRefresh,
920
- modelEnableSoftDelete: model.enableSoftDelete
934
+ modelEnableSoftDelete: model.enableSoftDelete,
935
+ parentModel: model.parentModel?.singularName
921
936
  },
922
937
  dryRun
923
938
  );