@solidstarters/solid-core 1.2.61 → 1.2.63

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.61",
3
+ "version": "1.2.63",
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",
@@ -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
  }
@@ -232,105 +232,6 @@ export class ModelMetadataService {
232
232
  model = await manager.save(updatedModelMetadataDto);
233
233
  }
234
234
 
235
- // const modelViews = [{
236
- // name: `${model.singularName}-list-view`,
237
- // displayName: `${model.displayName}`,
238
- // type: 'list',
239
- // context: "{}",
240
- // module: resolvedModule,
241
- // model: model,
242
- // layout: JSON.stringify({
243
- // type: "list",
244
- // attrs: {
245
- // pagination: true,
246
- // pageSizeOptions: [
247
- // 10,
248
- // 25,
249
- // 50
250
- // ],
251
- // enableGlobalSearch: true,
252
- // create: true,
253
- // edit: true,
254
- // delete: true
255
- // },
256
- // children: listViewLayout
257
- // }, null, 2)
258
- // },
259
- // {
260
- // name: `${model.singularName}-form-view`,
261
- // displayName: `${model.displayName}`,
262
- // type: 'form',
263
- // context: "{}",
264
- // module: model.module,
265
- // model: model,
266
- // layout: JSON.stringify(
267
- // {
268
- // type: "form",
269
- // attrs: { name: "form-1", label: `${model.displayName}`, className: "grid" },
270
- // children: [
271
- // {
272
- // type: "sheet",
273
- // attrs: { name: "sheet-1" },
274
- // children: [
275
- // {
276
- // type: "row",
277
- // attrs: { name: "group-1", label: "", className: "" },
278
- // children: [
279
- // {
280
- // type: "column",
281
- // attrs: { name: "group-1", label: "", className: "col-6" },
282
- // children: formViewLayout
283
- // }
284
- // ]
285
- // }
286
- // ]
287
- // }
288
- // ]
289
- // }, null, 2)
290
- // }
291
- // ];
292
- // const viewRepo = manager.getRepository(ViewMetadata);
293
- // for (let j = 0; j < modelViews.length; j++) {
294
- // const view = modelViews[j];
295
- // const createdView = await viewRepo.create(view);
296
- // await viewRepo.save(createdView);
297
- // }
298
-
299
- // const view = await viewRepo.findOneBy({ name: `${model.singularName}-list-view` });
300
-
301
- // const action = {
302
- // displayName: `${model.displayName} List View`,
303
- // name: `${model.singularName}-list-view`,
304
- // type: "solid",
305
- // domain: "",
306
- // context: "",
307
- // customComponent: `/admin/address-master/${model.singularName}/all`,
308
- // customIsModal: true,
309
- // serverEndpoint: "",
310
- // view: view,
311
- // module: resolvedModule,
312
- // model: model
313
- // };
314
- // const actionRepo = manager.getRepository(ActionMetadata);
315
- // const createdAction = await actionRepo.create(action);
316
- // const newAction = await actionRepo.save(createdAction);
317
-
318
- // const adminRole = await this.roleService.findRoleByName('Admin');
319
-
320
- // const menu = {
321
- // displayName: `${model.displayName}`,
322
- // name: `${model.singularName}`,
323
- // sequenceNumber: 1,
324
- // action: newAction,
325
- // module: resolvedModule,
326
- // roles: [adminRole],
327
- // parentMenuItemUserKey: ""
328
- // };
329
-
330
- // const menuRepo = manager.getRepository(MenuItemMetadata);
331
- // const createdMenu = await menuRepo.create(menu);
332
- // await menuRepo.save(createdMenu);
333
-
334
235
  return model;
335
236
  }
336
237
 
@@ -360,122 +261,14 @@ export class ModelMetadataService {
360
261
  fields: []
361
262
  }
362
263
 
363
- const listViewLayoutFields = [{ type: "field", attrs: { name: `id`, sortable: true, filterable: true } }];
364
- const formViewLayoutFields = [];
365
-
366
264
  for (let i = 0; i < model.fields.length; i++) {
367
265
  const field = model.fields[i];
368
- if (!field.isSystem) {
369
-
370
- const fieldObject: Record<string, any> = await this.fieldMetadataService.createFieldConfig(field);
371
- modelMetaData.fields.push(fieldObject);
372
- listViewLayoutFields.push({ type: "field", attrs: { name: `${field.name}`, sortable: true, filterable: true } })
373
- formViewLayoutFields.push({ type: "field", attrs: { name: `${field.name}` } })
374
-
375
- }
376
- }
377
- const column1Fields = [];
378
- const column2Fields = [];
379
-
380
- // Distribute fields between two columns
381
- for (let i = 0; i < formViewLayoutFields.length; i++) {
382
- if (i % 2 === 0) {
383
- column1Fields.push(formViewLayoutFields[i]);
384
- } else {
385
- column2Fields.push(formViewLayoutFields[i]);
386
- }
266
+ if (field.isSystem) continue;
267
+ const fieldObject: Record<string, any> = await this.fieldMetadataService.createFieldConfig(field);
268
+ modelMetaData.fields.push(fieldObject);
387
269
  }
388
- const action = {
389
- displayName: `${model.displayName} List View`,
390
- name: `${model.singularName}-list-view`,
391
- type: "solid",
392
- domain: "",
393
- context: "",
394
- customComponent: `/admin/address-master/${model.singularName}/all`,
395
- customIsModal: true,
396
- serverEndpoint: "",
397
- viewUserKey: `${model.singularName}-list-view`,
398
- moduleUserKey: `${model.module.name}`,
399
- modelUserKey: `${model.singularName}`
400
- };
401
-
402
- const menu = {
403
- displayName: `${model.displayName}`,
404
- name: `${model.singularName}-menu-item`,
405
- sequenceNumber: 1,
406
- actionUserKey: `${model.singularName}-list-view`,
407
- moduleUserKey: `${model.module.name}`,
408
- parentMenuItemUserKey: ""
409
- };
410
-
411
- const modelListview = {
412
- name: `${model.singularName}-list-view`,
413
- displayName: `${model.displayName}`,
414
- type: "list",
415
- context: "{}",
416
- moduleUserKey: `${model.module.name}`,
417
- modelUserKey: `${model.singularName}`,
418
- layout: {
419
- type: "list",
420
- attrs: {
421
- pagination: true,
422
- pageSizeOptions: [
423
- 10,
424
- 25,
425
- 50
426
- ],
427
- enableGlobalSearch: true,
428
- create: true,
429
- edit: true,
430
- delete: true
431
- },
432
- children: listViewLayoutFields
433
- }
434
- };
435
-
436
-
437
- const modelFormView = {
438
- name: `${model.singularName}-form-view`,
439
- displayName: `${model.displayName}`,
440
- type: "form",
441
- context: "{}",
442
- moduleUserKey: `${model.module.name}`,
443
- modelUserKey: `${model.singularName}`,
444
- layout: {
445
- type: "form",
446
- attrs: { name: "form-1", label: `${model.displayName}`, className: "grid" },
447
- children: [
448
- {
449
- type: "sheet",
450
- attrs: { name: "sheet-1" },
451
- children: [
452
- {
453
- type: "row",
454
- attrs: { name: "sheet-1" },
455
- children: [
456
- {
457
- type: "column",
458
- attrs: { name: "group-1", label: "", className: "col-6" },
459
- children: column1Fields
460
- },
461
- {
462
- type: "column",
463
- attrs: { name: "group-2", label: "", className: "col-6" },
464
- children: column2Fields
465
- }]
466
- },
467
- ]
468
- }
469
- ]
470
- }
471
- };
472
270
  // Update the `models` array
473
271
  metaData.moduleMetadata.models.push(modelMetaData);
474
- metaData.menus.push(menu);
475
- metaData.actions.push(action);
476
- metaData.views.push(modelListview);
477
- metaData.views.push(modelFormView);
478
-
479
272
 
480
273
  // Write the updated object back to the file
481
274
  const updatedContent = JSON.stringify(metaData, null, 2);
@@ -734,14 +527,170 @@ export class ModelMetadataService {
734
527
  await this.generateCode(inverseOptions);
735
528
  }
736
529
 
530
+ await this.generateVAMConfig(model.id);
531
+
532
+ return `${removeFieldCodeOuput} \n ${refreshModelCodeOutput}`;
533
+ }
534
+
535
+ // Generate the View, Action and Menu configuration for the model
536
+ private async generateVAMConfig(modelId: number) {
537
+ try {
538
+ return await this.dataSource.transaction(async (manager: EntityManager) => {
539
+ const modelRepository = manager.getRepository(ModelMetadata);
540
+ const model = await modelRepository.findOne({
541
+ where: {
542
+ id: modelId
543
+ },
544
+ relations: ["fields", "module"]
545
+ });
546
+ await this.populateVAMConfigInDb(model);
547
+ await this.populateVAMConfigInFile(model);
548
+ });
549
+ } catch (error) {
550
+ this.logger.error('generateVAMConfig Transaction failed:', error);
551
+ throw error;
552
+ }
553
+ }
554
+
555
+ private async populateVAMConfigInFile(model: ModelMetadata) {
556
+ try {
557
+ const filePath = this.moduleMetadataHelperService.getModuleMetadataFilePath(model.module.name);
558
+ const metaData = await this.moduleMetadataHelperService.getModuleMetadataConfiguration(filePath);
559
+
560
+ const listViewLayoutFields = [{ type: "field", attrs: { name: `id`, sortable: true, filterable: true } }];
561
+ const formViewLayoutFields = [];
562
+
563
+ for (let i = 0; i < model.fields.length; i++) {
564
+ const field = model.fields[i];
565
+ if (field.isSystem) continue;
566
+ listViewLayoutFields.push({ type: "field", attrs: { name: `${field.name}`, sortable: true, filterable: true } })
567
+ formViewLayoutFields.push({ type: "field", attrs: { name: `${field.name}` } })
568
+ }
569
+ this.populateVAMConfigInFileInternal(formViewLayoutFields, model, listViewLayoutFields, metaData);
570
+ // Write the updated object back to the file
571
+ const updatedContent = JSON.stringify(metaData, null, 2);
572
+ await fs.writeFile(filePath, updatedContent);
573
+
574
+ } catch (error) {
575
+ // console.error('File creation failed:', error);
576
+ this.logger.error('File updation failed for View, action, menus config:', error);
577
+ throw new Error('File updation failed for View, action, menus config'); // Trigger rollback
578
+ }
579
+ }
580
+
581
+ // Populate the View, Actions and Menus in the config file
582
+ private populateVAMConfigInFileInternal(formViewLayoutFields: any[], model: ModelMetadata, listViewLayoutFields: { type: string; attrs: { name: string; sortable: boolean; filterable: boolean; }; }[], metaData: any) {
583
+ const column1Fields = [];
584
+ const column2Fields = [];
585
+
586
+ // Distribute fields between two columns
587
+ for (let i = 0; i < formViewLayoutFields.length; i++) {
588
+ if (i % 2 === 0) {
589
+ column1Fields.push(formViewLayoutFields[i]);
590
+ } else {
591
+ column2Fields.push(formViewLayoutFields[i]);
592
+ }
593
+ }
594
+ const action = {
595
+ displayName: `${model.displayName} List View`,
596
+ name: `${model.singularName}-list-view`,
597
+ type: "solid",
598
+ domain: "",
599
+ context: "",
600
+ customComponent: `/admin/address-master/${model.singularName}/all`,
601
+ customIsModal: true,
602
+ serverEndpoint: "",
603
+ viewUserKey: `${model.singularName}-list-view`,
604
+ moduleUserKey: `${model.module.name}`,
605
+ modelUserKey: `${model.singularName}`
606
+ };
607
+
608
+ const menu = {
609
+ displayName: `${model.displayName}`,
610
+ name: `${model.singularName}-menu-item`,
611
+ sequenceNumber: 1,
612
+ actionUserKey: `${model.singularName}-list-view`,
613
+ moduleUserKey: `${model.module.name}`,
614
+ parentMenuItemUserKey: ""
615
+ };
616
+
617
+ const modelListview = {
618
+ name: `${model.singularName}-list-view`,
619
+ displayName: `${model.displayName}`,
620
+ type: "list",
621
+ context: "{}",
622
+ moduleUserKey: `${model.module.name}`,
623
+ modelUserKey: `${model.singularName}`,
624
+ layout: {
625
+ type: "list",
626
+ attrs: {
627
+ pagination: true,
628
+ pageSizeOptions: [
629
+ 10,
630
+ 25,
631
+ 50
632
+ ],
633
+ enableGlobalSearch: true,
634
+ create: true,
635
+ edit: true,
636
+ delete: true
637
+ },
638
+ children: listViewLayoutFields
639
+ }
640
+ };
641
+
642
+
643
+ const modelFormView = {
644
+ name: `${model.singularName}-form-view`,
645
+ displayName: `${model.displayName}`,
646
+ type: "form",
647
+ context: "{}",
648
+ moduleUserKey: `${model.module.name}`,
649
+ modelUserKey: `${model.singularName}`,
650
+ layout: {
651
+ type: "form",
652
+ attrs: { name: "form-1", label: `${model.displayName}`, className: "grid" },
653
+ children: [
654
+ {
655
+ type: "sheet",
656
+ attrs: { name: "sheet-1" },
657
+ children: [
658
+ {
659
+ type: "row",
660
+ attrs: { name: "sheet-1" },
661
+ children: [
662
+ {
663
+ type: "column",
664
+ attrs: { name: "group-1", label: "", className: "col-6" },
665
+ children: column1Fields
666
+ },
667
+ {
668
+ type: "column",
669
+ attrs: { name: "group-2", label: "", className: "col-6" },
670
+ children: column2Fields
671
+ }
672
+ ]
673
+ },
674
+ ]
675
+ }
676
+ ]
677
+ }
678
+ };
679
+ metaData.menus.push(menu);
680
+ metaData.actions.push(action);
681
+ metaData.views.push(modelListview);
682
+ metaData.views.push(modelFormView);
683
+ }
684
+
685
+ //Populate the View, Actions and Menus in the database
686
+ private async populateVAMConfigInDb(model: ModelMetadata) {
737
687
  const jsonFieldsList = model.fields.filter((field: FieldMetadata) => field.isSystem !== true);
738
688
 
739
689
  const listViewLayout = jsonFieldsList.map(field => ({
740
690
  type: "field",
741
691
  attrs: {
742
692
  name: `${field.name}`,
743
- sortable: true,
744
- filterable: true
693
+ isSearchable: true,
745
694
  }
746
695
  }));
747
696
 
@@ -873,8 +822,6 @@ export class ModelMetadataService {
873
822
  const createdMenu = menuRepo.create(menuData);
874
823
  await menuRepo.save(createdMenu);
875
824
  }
876
-
877
- return `${removeFieldCodeOuput} \n ${refreshModelCodeOutput}`;
878
825
  }
879
826
 
880
827
  private async generateCode(options: CodeGenerationOptions) {
@@ -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