@solidstarters/solid-core 1.2.15 → 1.2.17
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/dist/controllers/google-authentication.controller.d.ts +8 -0
- package/dist/controllers/google-authentication.controller.d.ts.map +1 -1
- package/dist/helpers/schematic.service.d.ts.map +1 -1
- package/dist/helpers/schematic.service.js +2 -1
- package/dist/helpers/schematic.service.js.map +1 -1
- package/dist/seeders/seed-data/solid-core-metadata.json +2 -2
- package/dist/services/authentication.service.d.ts +8 -0
- package/dist/services/authentication.service.d.ts.map +1 -1
- package/dist/services/authentication.service.js +1 -1
- package/dist/services/authentication.service.js.map +1 -1
- package/dist/services/model-metadata.service.d.ts.map +1 -1
- package/dist/services/model-metadata.service.js +107 -92
- package/dist/services/model-metadata.service.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -1
- package/src/helpers/schematic.service.ts +2 -1
- package/src/seeders/seed-data/solid-core-metadata.json +2 -2
- package/src/services/authentication.service.ts +1 -1
- package/src/services/model-metadata.service.ts +228 -98
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidstarters/solid-core",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.17",
|
|
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",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"class-validator": "^0.14.1",
|
|
44
44
|
"handlebars": "^4.7.8",
|
|
45
45
|
"ioredis": "^5.4.1",
|
|
46
|
+
"lodash": "^4.17.21",
|
|
46
47
|
"luxon": "^3.4.4",
|
|
47
48
|
"mailgen": "^2.0.28",
|
|
48
49
|
"mongoose": "^8.7.0",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Injectable, Logger } from '@nestjs/common';
|
|
2
2
|
import { CommandService } from './command.service';
|
|
3
|
+
import { snakeCase } from "lodash";
|
|
3
4
|
|
|
4
5
|
export const ADD_MODULE_COMMAND = 'add-module';
|
|
5
6
|
export type GenerateModuleOptions = {
|
|
@@ -54,7 +55,7 @@ export class SchematicService {
|
|
|
54
55
|
// console.log('fieldOptions', fieldOptions);
|
|
55
56
|
let modelCommand = `${baseCommand} --module=${fieldOptions.module} --model=${fieldOptions.model}`;
|
|
56
57
|
if (fieldOptions.moduleDisplayName) {
|
|
57
|
-
modelCommand += ` --module-display-name=${fieldOptions.moduleDisplayName}`;
|
|
58
|
+
modelCommand += ` --module-display-name=${snakeCase(fieldOptions.moduleDisplayName)}`;
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
if (fieldOptions.table) {
|
|
@@ -2770,7 +2770,7 @@
|
|
|
2770
2770
|
"body": "",
|
|
2771
2771
|
"confirmBtnLabel": "Generate Code",
|
|
2772
2772
|
"cancelBtnLabel": "Cancel",
|
|
2773
|
-
"customComponent": "
|
|
2773
|
+
"customComponent": "../extension/solid-core/moduleMetadata/list/GenerateModuleCodeRowAction",
|
|
2774
2774
|
"customComponentIsSystem": true,
|
|
2775
2775
|
"endpoint": ""
|
|
2776
2776
|
}
|
|
@@ -2962,7 +2962,7 @@
|
|
|
2962
2962
|
"body": "",
|
|
2963
2963
|
"confirmBtnLabel": "Generate Code",
|
|
2964
2964
|
"cancelBtnLabel": "Cancel",
|
|
2965
|
-
"customComponent": "
|
|
2965
|
+
"customComponent": "../extension/solid-core/modelMetadata/list/GenerateModelCodeRowAction",
|
|
2966
2966
|
"customComponentIsSystem": true,
|
|
2967
2967
|
"endpoint": ""
|
|
2968
2968
|
}
|
|
@@ -925,7 +925,7 @@ export class AuthenticationService {
|
|
|
925
925
|
await this.validateUserUsingGoogle(user);
|
|
926
926
|
|
|
927
927
|
// finally we simply generate the tokens.
|
|
928
|
-
const tokens = this.generateTokens(user);
|
|
928
|
+
const tokens = await this.generateTokens(user);
|
|
929
929
|
return {
|
|
930
930
|
user: {
|
|
931
931
|
email: user.email,
|
|
@@ -23,6 +23,7 @@ import { ViewMetadata } from '../entities/view-metadata.entity';
|
|
|
23
23
|
import { ActionMetadata } from '../entities/action-metadata.entity';
|
|
24
24
|
import { MenuItemMetadata } from '../entities/menu-item-metadata.entity';
|
|
25
25
|
import { RoleMetadataService } from './role-metadata.service';
|
|
26
|
+
import { PermissionMetadataSeederService } from 'src/seeders/permission-metadata-seeder.service';
|
|
26
27
|
|
|
27
28
|
@Injectable()
|
|
28
29
|
export class ModelMetadataService {
|
|
@@ -195,104 +196,104 @@ export class ModelMetadataService {
|
|
|
195
196
|
model = await manager.save(updatedModelMetadataDto);
|
|
196
197
|
}
|
|
197
198
|
|
|
198
|
-
const modelViews = [{
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
}
|
|
254
|
-
];
|
|
255
|
-
const viewRepo = manager.getRepository(ViewMetadata);
|
|
256
|
-
for (let j = 0; j < modelViews.length; j++) {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
const view = await viewRepo.findOneBy({ name: `${model.singularName}-list-view` });
|
|
263
|
-
|
|
264
|
-
const action = {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
};
|
|
277
|
-
const actionRepo = manager.getRepository(ActionMetadata);
|
|
278
|
-
const createdAction = await actionRepo.create(action);
|
|
279
|
-
const newAction = await actionRepo.save(createdAction);
|
|
280
|
-
|
|
281
|
-
const adminRole = await this.roleService.findRoleByName('Admin');
|
|
282
|
-
|
|
283
|
-
const menu = {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
};
|
|
292
|
-
|
|
293
|
-
const menuRepo = manager.getRepository(MenuItemMetadata);
|
|
294
|
-
const createdMenu = await menuRepo.create(menu);
|
|
295
|
-
await menuRepo.save(createdMenu);
|
|
199
|
+
// const modelViews = [{
|
|
200
|
+
// name: `${model.singularName}-list-view`,
|
|
201
|
+
// displayName: `${model.displayName}`,
|
|
202
|
+
// type: 'list',
|
|
203
|
+
// context: "{}",
|
|
204
|
+
// module: resolvedModule,
|
|
205
|
+
// model: model,
|
|
206
|
+
// layout: JSON.stringify({
|
|
207
|
+
// type: "list",
|
|
208
|
+
// attrs: {
|
|
209
|
+
// pagination: true,
|
|
210
|
+
// pageSizeOptions: [
|
|
211
|
+
// 10,
|
|
212
|
+
// 25,
|
|
213
|
+
// 50
|
|
214
|
+
// ],
|
|
215
|
+
// enableGlobalSearch: true,
|
|
216
|
+
// create: true,
|
|
217
|
+
// edit: true,
|
|
218
|
+
// delete: true
|
|
219
|
+
// },
|
|
220
|
+
// children: listViewLayout
|
|
221
|
+
// }, null, 2)
|
|
222
|
+
// },
|
|
223
|
+
// {
|
|
224
|
+
// name: `${model.singularName}-form-view`,
|
|
225
|
+
// displayName: `${model.displayName}`,
|
|
226
|
+
// type: 'form',
|
|
227
|
+
// context: "{}",
|
|
228
|
+
// module: model.module,
|
|
229
|
+
// model: model,
|
|
230
|
+
// layout: JSON.stringify(
|
|
231
|
+
// {
|
|
232
|
+
// type: "form",
|
|
233
|
+
// attrs: { name: "form-1", label: `${model.displayName}`, className: "grid" },
|
|
234
|
+
// children: [
|
|
235
|
+
// {
|
|
236
|
+
// type: "sheet",
|
|
237
|
+
// attrs: { name: "sheet-1" },
|
|
238
|
+
// children: [
|
|
239
|
+
// {
|
|
240
|
+
// type: "row",
|
|
241
|
+
// attrs: { name: "group-1", label: "", className: "" },
|
|
242
|
+
// children: [
|
|
243
|
+
// {
|
|
244
|
+
// type: "column",
|
|
245
|
+
// attrs: { name: "group-1", label: "", className: "col-6" },
|
|
246
|
+
// children: formViewLayout
|
|
247
|
+
// }
|
|
248
|
+
// ]
|
|
249
|
+
// }
|
|
250
|
+
// ]
|
|
251
|
+
// }
|
|
252
|
+
// ]
|
|
253
|
+
// }, null, 2)
|
|
254
|
+
// }
|
|
255
|
+
// ];
|
|
256
|
+
// const viewRepo = manager.getRepository(ViewMetadata);
|
|
257
|
+
// for (let j = 0; j < modelViews.length; j++) {
|
|
258
|
+
// const view = modelViews[j];
|
|
259
|
+
// const createdView = await viewRepo.create(view);
|
|
260
|
+
// await viewRepo.save(createdView);
|
|
261
|
+
// }
|
|
262
|
+
|
|
263
|
+
// const view = await viewRepo.findOneBy({ name: `${model.singularName}-list-view` });
|
|
264
|
+
|
|
265
|
+
// const action = {
|
|
266
|
+
// displayName: `${model.displayName} List View`,
|
|
267
|
+
// name: `${model.singularName}-list-view`,
|
|
268
|
+
// type: "solid",
|
|
269
|
+
// domain: "",
|
|
270
|
+
// context: "",
|
|
271
|
+
// customComponent: `/admin/address-master/${model.singularName}/all`,
|
|
272
|
+
// customIsModal: true,
|
|
273
|
+
// serverEndpoint: "",
|
|
274
|
+
// view: view,
|
|
275
|
+
// module: resolvedModule,
|
|
276
|
+
// model: model
|
|
277
|
+
// };
|
|
278
|
+
// const actionRepo = manager.getRepository(ActionMetadata);
|
|
279
|
+
// const createdAction = await actionRepo.create(action);
|
|
280
|
+
// const newAction = await actionRepo.save(createdAction);
|
|
281
|
+
|
|
282
|
+
// const adminRole = await this.roleService.findRoleByName('Admin');
|
|
283
|
+
|
|
284
|
+
// const menu = {
|
|
285
|
+
// displayName: `${model.displayName}`,
|
|
286
|
+
// name: `${model.singularName}`,
|
|
287
|
+
// sequenceNumber: 1,
|
|
288
|
+
// action: newAction,
|
|
289
|
+
// module: resolvedModule,
|
|
290
|
+
// roles: [adminRole],
|
|
291
|
+
// parentMenuItemUserKey: ""
|
|
292
|
+
// };
|
|
293
|
+
|
|
294
|
+
// const menuRepo = manager.getRepository(MenuItemMetadata);
|
|
295
|
+
// const createdMenu = await menuRepo.create(menu);
|
|
296
|
+
// await menuRepo.save(createdMenu);
|
|
296
297
|
|
|
297
298
|
return model;
|
|
298
299
|
}
|
|
@@ -687,9 +688,138 @@ export class ModelMetadataService {
|
|
|
687
688
|
|
|
688
689
|
const refreshModelCodeOutput = await this.generateModelCode(options);
|
|
689
690
|
const removeFieldCodeOuput = await this.generateRemoveFieldsCode(options);
|
|
691
|
+
|
|
692
|
+
// Extract listViewLayout and formViewLayout from model fields
|
|
693
|
+
const listViewLayout = model.fields.map(field => ({
|
|
694
|
+
type: "field",
|
|
695
|
+
attrs: {
|
|
696
|
+
name: `${field.name}`,
|
|
697
|
+
label: `${field.displayName}`,
|
|
698
|
+
sortable: true,
|
|
699
|
+
filterable: true
|
|
700
|
+
}
|
|
701
|
+
}));
|
|
702
|
+
|
|
703
|
+
const formViewLayout = model.fields.map(field => ({
|
|
704
|
+
type: "field",
|
|
705
|
+
attrs: {
|
|
706
|
+
name: `${field.name}`,
|
|
707
|
+
label: `${field.displayName}`
|
|
708
|
+
}
|
|
709
|
+
}));
|
|
710
|
+
|
|
711
|
+
// Fetch module data
|
|
712
|
+
const resolvedModule = await this.dataSource.getRepository(ModuleMetadata).findOne({
|
|
713
|
+
where: { id: model.module.id }
|
|
714
|
+
});
|
|
715
|
+
|
|
716
|
+
// Generate model views
|
|
717
|
+
const modelViews = [
|
|
718
|
+
{
|
|
719
|
+
name: `${model.singularName}-list-view`,
|
|
720
|
+
displayName: `${model.displayName}`,
|
|
721
|
+
type: 'list',
|
|
722
|
+
context: "{}",
|
|
723
|
+
module: resolvedModule,
|
|
724
|
+
model: model,
|
|
725
|
+
layout: JSON.stringify({
|
|
726
|
+
type: "list",
|
|
727
|
+
attrs: {
|
|
728
|
+
pagination: true,
|
|
729
|
+
pageSizeOptions: [10, 25, 50],
|
|
730
|
+
enableGlobalSearch: true,
|
|
731
|
+
create: true,
|
|
732
|
+
edit: true,
|
|
733
|
+
delete: true
|
|
734
|
+
},
|
|
735
|
+
children: listViewLayout
|
|
736
|
+
}, null, 2)
|
|
737
|
+
},
|
|
738
|
+
{
|
|
739
|
+
name: `${model.singularName}-form-view`,
|
|
740
|
+
displayName: `${model.displayName}`,
|
|
741
|
+
type: 'form',
|
|
742
|
+
context: "{}",
|
|
743
|
+
module: resolvedModule,
|
|
744
|
+
model: model,
|
|
745
|
+
layout: JSON.stringify({
|
|
746
|
+
type: "form",
|
|
747
|
+
attrs: { name: "form-1", label: `${model.displayName}`, className: "grid" },
|
|
748
|
+
children: [
|
|
749
|
+
{
|
|
750
|
+
type: "sheet",
|
|
751
|
+
attrs: { name: "sheet-1" },
|
|
752
|
+
children: [
|
|
753
|
+
{
|
|
754
|
+
type: "row",
|
|
755
|
+
attrs: { name: "group-1", label: "", className: "" },
|
|
756
|
+
children: [
|
|
757
|
+
{
|
|
758
|
+
type: "column",
|
|
759
|
+
attrs: { name: "group-1", label: "", className: "col-6" },
|
|
760
|
+
children: formViewLayout
|
|
761
|
+
}
|
|
762
|
+
]
|
|
763
|
+
}
|
|
764
|
+
]
|
|
765
|
+
}
|
|
766
|
+
]
|
|
767
|
+
}, null, 2)
|
|
768
|
+
}
|
|
769
|
+
];
|
|
770
|
+
|
|
771
|
+
// Save views
|
|
772
|
+
const viewRepo = this.dataSource.getRepository(ViewMetadata);
|
|
773
|
+
for (const view of modelViews) {
|
|
774
|
+
const createdView = viewRepo.create(view);
|
|
775
|
+
await viewRepo.save(createdView);
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
// Fetch the list view
|
|
779
|
+
const view = await viewRepo.findOneBy({ name: `${model.singularName}-list-view` });
|
|
780
|
+
|
|
781
|
+
// Generate action
|
|
782
|
+
const action = {
|
|
783
|
+
displayName: `${model.displayName} List View`,
|
|
784
|
+
name: `${model.singularName}-list-view`,
|
|
785
|
+
type: "solid",
|
|
786
|
+
domain: "",
|
|
787
|
+
context: "",
|
|
788
|
+
customComponent: `/admin/address-master/${model.singularName}/all`,
|
|
789
|
+
customIsModal: true,
|
|
790
|
+
serverEndpoint: "",
|
|
791
|
+
view: view,
|
|
792
|
+
module: resolvedModule,
|
|
793
|
+
model: model
|
|
794
|
+
};
|
|
795
|
+
|
|
796
|
+
// Save action
|
|
797
|
+
const actionRepo = this.dataSource.getRepository(ActionMetadata);
|
|
798
|
+
const createdAction = actionRepo.create(action);
|
|
799
|
+
const newAction = await actionRepo.save(createdAction);
|
|
800
|
+
|
|
801
|
+
// Fetch Admin Role
|
|
802
|
+
const adminRole = await this.roleService.findRoleByName('Admin');
|
|
803
|
+
|
|
804
|
+
// Generate menu
|
|
805
|
+
const menu = {
|
|
806
|
+
displayName: `${model.displayName}`,
|
|
807
|
+
name: `${model.singularName}`,
|
|
808
|
+
sequenceNumber: 1,
|
|
809
|
+
action: newAction,
|
|
810
|
+
module: resolvedModule,
|
|
811
|
+
roles: [adminRole],
|
|
812
|
+
parentMenuItemUserKey: ""
|
|
813
|
+
};
|
|
814
|
+
|
|
815
|
+
// Save menu
|
|
816
|
+
const menuRepo = this.dataSource.getRepository(MenuItemMetadata);
|
|
817
|
+
const createdMenu = menuRepo.create(menu);
|
|
818
|
+
await menuRepo.save(createdMenu);
|
|
690
819
|
return `${removeFieldCodeOuput} \n ${refreshModelCodeOutput}`;
|
|
691
820
|
}
|
|
692
821
|
|
|
822
|
+
|
|
693
823
|
async generateRemoveFieldsCode(options: CodeGenerationOptions): Promise<string> {
|
|
694
824
|
if (!options.modelId && !options.modelUserKey) {
|
|
695
825
|
throw new BadRequestException('Model ID or Model Name is required for generating code');
|