@solidstarters/solid-core 1.2.37 → 1.2.39
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/view-metadata.controller.d.ts +1 -0
- package/dist/controllers/view-metadata.controller.d.ts.map +1 -1
- package/dist/seeders/module-metadata-seeder.service.d.ts.map +1 -1
- package/dist/seeders/module-metadata-seeder.service.js +8 -4
- package/dist/seeders/module-metadata-seeder.service.js.map +1 -1
- package/dist/services/crud.service.d.ts.map +1 -1
- package/dist/services/crud.service.js.map +1 -1
- package/dist/services/solid-introspect.service.d.ts +4 -0
- package/dist/services/solid-introspect.service.d.ts.map +1 -1
- package/dist/services/solid-introspect.service.js +8 -0
- package/dist/services/solid-introspect.service.js.map +1 -1
- package/dist/services/view-metadata.service.d.ts +4 -1
- package/dist/services/view-metadata.service.d.ts.map +1 -1
- package/dist/services/view-metadata.service.js +47 -16
- package/dist/services/view-metadata.service.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/seeders/module-metadata-seeder.service.ts +8 -4
- package/src/services/crud.service.ts +1 -2
- package/src/services/solid-introspect.service.ts +20 -6
- package/src/services/view-metadata.service.ts +63 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidstarters/solid-core",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.39",
|
|
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",
|
|
@@ -70,7 +70,7 @@ export class ModuleMetadataSeederService {
|
|
|
70
70
|
|
|
71
71
|
const settingsSeederData: any = {
|
|
72
72
|
iamAllowPublicRegistration: this.iamConfiguration.allowPublicRegistration,
|
|
73
|
-
iamPasswordRegistrationEnabled:
|
|
73
|
+
iamPasswordRegistrationEnabled: true,
|
|
74
74
|
iamPasswordLessRegistrationEnabled: this.iamConfiguration.passwordlessRegistration,
|
|
75
75
|
iamActivateUserOnRegistration: this.iamConfiguration.activateUserOnRegistration,
|
|
76
76
|
iamGoogleOAuthEnabled: false,
|
|
@@ -205,7 +205,8 @@ export class ModuleMetadataSeederService {
|
|
|
205
205
|
this.logger.debug(`About to add all permissions to the Admin role`);
|
|
206
206
|
await this.roleService.addAllPermissionsToRole("Admin");
|
|
207
207
|
// 2. Give wrapSettings permissions to the Public role.
|
|
208
|
-
const internalRolePermission = [
|
|
208
|
+
const internalRolePermission = [
|
|
209
|
+
'UserController.findMany',
|
|
209
210
|
'UserController.checkIfPermissionExists',
|
|
210
211
|
'UserController.findOne',
|
|
211
212
|
'MenuItemMetadataController.findMany',
|
|
@@ -214,7 +215,10 @@ export class ModuleMetadataSeederService {
|
|
|
214
215
|
'ViewMetadataController.getLayout',
|
|
215
216
|
'ViewMetadataController.findMany',
|
|
216
217
|
'ViewMetadataController.findOne',
|
|
217
|
-
'AuthenticationController.changePassword'
|
|
218
|
+
'AuthenticationController.changePassword',
|
|
219
|
+
'FieldMetadataController.getSelectionDynamicValues',
|
|
220
|
+
'FieldMetadataController.getSelectionDynamicValue',
|
|
221
|
+
'FieldMetadataController.findFieldDefaultMetaData',
|
|
218
222
|
]
|
|
219
223
|
await this.roleService.addPermissionToRole('Internal User', internalRolePermission);
|
|
220
224
|
await this.roleService.addPermissionToRole('Public', ['SettingController.wrapSettings']);
|
|
@@ -366,8 +370,8 @@ export class ModuleMetadataSeederService {
|
|
|
366
370
|
for (let j = 0; j < actions.length; j++) {
|
|
367
371
|
const actionData = actions[j];
|
|
368
372
|
actionData['module'] = await this.moduleMetadataService.findOneByUserKey(actionData.moduleUserKey);
|
|
369
|
-
actionData['model'] = await this.modelMetadataService.findOneByUserKey(actionData.modelUserKey);
|
|
370
373
|
if (actionData.type === 'solid') {
|
|
374
|
+
actionData['model'] = await this.modelMetadataService.findOneByUserKey(actionData.modelUserKey);
|
|
371
375
|
actionData['view'] = await this.solidViewService.findOneByUserKey(actionData.viewUserKey);
|
|
372
376
|
}
|
|
373
377
|
await this.solidActionService.upsert(actionData);
|
|
@@ -40,7 +40,7 @@ import { SolidRequestContextDto } from "src/dtos/solid-request-context.dto";
|
|
|
40
40
|
|
|
41
41
|
const DEFAULT_LIMIT = 10;
|
|
42
42
|
const DEFAULT_OFFSET = 0;
|
|
43
|
-
export class CRUDService<T> { //Add two generic value i.e Person,CreatePersonDto, so we get the proper types in our service
|
|
43
|
+
export class CRUDService<T> { // Add two generic value i.e Person,CreatePersonDto, so we get the proper types in our service
|
|
44
44
|
|
|
45
45
|
constructor(
|
|
46
46
|
readonly modelMetadataService: ModelMetadataService,
|
|
@@ -414,7 +414,6 @@ export class CRUDService<T> { //Add two generic value i.e Person,CreatePersonDto
|
|
|
414
414
|
}
|
|
415
415
|
}
|
|
416
416
|
|
|
417
|
-
|
|
418
417
|
async find(basicFilterDto: BasicFilterDto, solidRequestContext: any = {}) {
|
|
419
418
|
const alias = 'entity';
|
|
420
419
|
// Extract the required keys from the input query
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { classify } from '@angular-devkit/core/src/utils/strings';
|
|
1
2
|
import { Injectable, Logger, OnApplicationBootstrap } from '@nestjs/common';
|
|
2
3
|
import { DiscoveryService, MetadataScanner, Reflector } from '@nestjs/core';
|
|
3
4
|
import { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper';
|
|
@@ -5,6 +6,7 @@ import { IS_COMPUTED_FIELD_PROVIDER } from 'src/decorators/computed-field-provid
|
|
|
5
6
|
import { IS_SELECTION_PROVIDER } from 'src/decorators/selection-provider.decorator';
|
|
6
7
|
import { IS_SOLID_DATABASE_MODULE } from 'src/decorators/solid-database-module.decorator';
|
|
7
8
|
import { SolidRegistry } from 'src/helpers/solid-registry';
|
|
9
|
+
import { CRUDService } from './crud.service';
|
|
8
10
|
|
|
9
11
|
@Injectable()
|
|
10
12
|
export class SolidIntrospectService implements OnApplicationBootstrap {
|
|
@@ -16,9 +18,9 @@ export class SolidIntrospectService implements OnApplicationBootstrap {
|
|
|
16
18
|
) { }
|
|
17
19
|
|
|
18
20
|
private readonly logger = new Logger(SolidIntrospectService.name);
|
|
19
|
-
onApplicationBootstrap() {
|
|
21
|
+
onApplicationBootstrap() {
|
|
20
22
|
this.logger.log('Introspecting the application for Solid metadata');
|
|
21
|
-
|
|
23
|
+
|
|
22
24
|
// Register all seeders
|
|
23
25
|
const seeders = this.discoveryService
|
|
24
26
|
.getProviders()
|
|
@@ -55,7 +57,7 @@ export class SolidIntrospectService implements OnApplicationBootstrap {
|
|
|
55
57
|
.getProviders()
|
|
56
58
|
.filter((provider) => this.isSolidDatabaseModule(provider));
|
|
57
59
|
|
|
58
|
-
|
|
60
|
+
solidDatabaseModules.forEach((solidDatabaseModule) => {
|
|
59
61
|
// @ts-ignore
|
|
60
62
|
this.solidRegistry.registerSolidDatabaseModule(solidDatabaseModule);
|
|
61
63
|
});
|
|
@@ -128,14 +130,13 @@ export class SolidIntrospectService implements OnApplicationBootstrap {
|
|
|
128
130
|
return !!isSolidDatabaseModule;
|
|
129
131
|
}
|
|
130
132
|
|
|
131
|
-
|
|
132
133
|
private isModule(provider: InstanceWrapper): boolean {
|
|
133
134
|
const metatype = provider.metatype;
|
|
134
135
|
// Check if it's a Static Module (Class-Based)
|
|
135
136
|
if (metatype && typeof metatype === 'function' && Reflect.getMetadata('imports', metatype)) {
|
|
136
137
|
return true;
|
|
137
138
|
}
|
|
138
|
-
|
|
139
|
+
|
|
139
140
|
// Ensure provider.instance is an object before checking for 'module'
|
|
140
141
|
if (provider.instance && typeof provider.instance === 'object') {
|
|
141
142
|
// Check if it's a Dynamic Module (Object-Based)
|
|
@@ -143,8 +144,21 @@ export class SolidIntrospectService implements OnApplicationBootstrap {
|
|
|
143
144
|
return true;
|
|
144
145
|
}
|
|
145
146
|
}
|
|
146
|
-
|
|
147
|
+
|
|
147
148
|
return false;
|
|
148
149
|
}
|
|
149
150
|
|
|
151
|
+
/**
|
|
152
|
+
* Given a model singular name this will return the crud service instance.
|
|
153
|
+
* @param modelSingularName
|
|
154
|
+
* @returns
|
|
155
|
+
*/
|
|
156
|
+
getCRUDService(modelSingularName: string): CRUDService<any> {
|
|
157
|
+
const provider = this.getProvider(`${classify(modelSingularName)}Service`);
|
|
158
|
+
return provider?.instance as CRUDService<any>;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
getProvider(providerName: string) {
|
|
162
|
+
return this.discoveryService.getProviders().find((provider) => provider.name === providerName);
|
|
163
|
+
}
|
|
150
164
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
1
|
+
import { BadRequestException, Injectable } from '@nestjs/common';
|
|
2
2
|
import { InjectEntityManager, InjectRepository } from '@nestjs/typeorm';
|
|
3
3
|
import { DiscoveryService } from "@nestjs/core";
|
|
4
4
|
import { EntityManager, Repository } from 'typeorm';
|
|
@@ -17,6 +17,8 @@ import { FieldMetadata } from '../entities/field-metadata.entity';
|
|
|
17
17
|
import { ModelMetadata } from '../entities/model-metadata.entity';
|
|
18
18
|
import { UpdateViewMetadataDto } from '../dtos/update-view-metadata.dto';
|
|
19
19
|
import { ActionMetadataService } from './action-metadata.service';
|
|
20
|
+
import { SolidIntrospectService } from './solid-introspect.service';
|
|
21
|
+
import { BasicFilterDto } from 'src/dtos/basic-filters.dto';
|
|
20
22
|
|
|
21
23
|
@Injectable()
|
|
22
24
|
export class ViewMetadataService extends CRUDService<ViewMetadata> {
|
|
@@ -30,6 +32,7 @@ export class ViewMetadataService extends CRUDService<ViewMetadata> {
|
|
|
30
32
|
readonly discoveryService: DiscoveryService,
|
|
31
33
|
readonly crudHelperService: CrudHelperService,
|
|
32
34
|
readonly actionMetadataService: ActionMetadataService,
|
|
35
|
+
readonly introspectService: SolidIntrospectService,
|
|
33
36
|
@InjectEntityManager()
|
|
34
37
|
readonly entityManager: EntityManager,
|
|
35
38
|
@InjectRepository(ViewMetadata, 'default')
|
|
@@ -58,21 +61,33 @@ export class ViewMetadataService extends CRUDService<ViewMetadata> {
|
|
|
58
61
|
relations: {
|
|
59
62
|
model: {
|
|
60
63
|
userKeyField: true, // Nested population of 'someOtherEntity' within 'model'
|
|
61
|
-
},
|
|
64
|
+
},
|
|
62
65
|
module: true,
|
|
63
66
|
}
|
|
64
67
|
});
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
|
|
69
|
+
if (!entity) {
|
|
70
|
+
throw new BadRequestException(`Unable to identify view for module: ${moduleName}, model: ${modelName} and viewType: ${viewType}`);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// If view entity found then convert layout from "string" to "json".
|
|
74
|
+
entity.layout = JSON.parse(entity.layout);
|
|
75
|
+
if (entity?.layout?.attrs?.createAction) {
|
|
76
|
+
const actionName: string = entity.layout.attrs.createAction;
|
|
77
|
+
entity.layout.attrs.createAction = await this.actionMetadataService.findOneByUserKey(actionName)
|
|
78
|
+
}
|
|
79
|
+
if (entity?.layout?.attrs?.editAction) {
|
|
80
|
+
const actionName: string = entity.layout.attrs.editAction;
|
|
81
|
+
entity.layout.attrs.editAction = await this.actionMetadataService.findOneByUserKey(actionName)
|
|
75
82
|
}
|
|
83
|
+
|
|
84
|
+
// for form views, we need to check if "workflow" field is configured, if configured then return an extra metadata "solidFormViewWorkflowData"
|
|
85
|
+
let workflowFieldName = null;
|
|
86
|
+
let workflowField = null;
|
|
87
|
+
if (viewType === 'form') {
|
|
88
|
+
workflowFieldName = entity.layout?.attrs?.workflowField;
|
|
89
|
+
}
|
|
90
|
+
|
|
76
91
|
// We also need to fetch a map of fields.
|
|
77
92
|
const fields = await this.fieldMetadataRepo.find({
|
|
78
93
|
where: {
|
|
@@ -85,6 +100,11 @@ export class ViewMetadataService extends CRUDService<ViewMetadata> {
|
|
|
85
100
|
for (let i = 0; i < fields.length; i++) {
|
|
86
101
|
const field = fields[i];
|
|
87
102
|
|
|
103
|
+
// We need to identify the workflowField metadata if specified.
|
|
104
|
+
if (workflowFieldName && field.name === workflowFieldName) {
|
|
105
|
+
workflowField = field;
|
|
106
|
+
}
|
|
107
|
+
|
|
88
108
|
// For fields of type relation & relationType many-to-one
|
|
89
109
|
// We fetch metadata regarding the relationCoModelSingularName
|
|
90
110
|
if (field.type === 'relation') {
|
|
@@ -106,10 +126,38 @@ export class ViewMetadataService extends CRUDService<ViewMetadata> {
|
|
|
106
126
|
}
|
|
107
127
|
}
|
|
108
128
|
|
|
109
|
-
|
|
129
|
+
// Check if we were able to resolve an actual workflowField.
|
|
130
|
+
let solidFormViewWorkflowData = [];
|
|
131
|
+
if (viewType === 'form' && workflowField) {
|
|
132
|
+
// check for type of workflow field.
|
|
133
|
+
// for workflowFields of type selectionStatic we simply return the key/values from field metadata AS-IS
|
|
134
|
+
if (workflowField.type === 'selectionStatic') {
|
|
135
|
+
solidFormViewWorkflowData = workflowField.selectionStaticValues.map(item => {
|
|
136
|
+
const [label, value] = item.split(":");
|
|
137
|
+
return { label, value };
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
// for workflowFields of type relation.many-to-one we need to query the co-model, and return data in key/value format.
|
|
141
|
+
if (workflowField.type === 'relation' && workflowField.relationType === 'many-to-one') {
|
|
142
|
+
const comodelCrudService = this.introspectService.getCRUDService(workflowField.relationCoModelSingularName);
|
|
143
|
+
const data = await comodelCrudService.find({ limit: 100, offset: 0, });
|
|
144
|
+
const records = data.records ?? [];
|
|
145
|
+
const workflowFieldMetadata = fieldsMap.get(workflowFieldName);
|
|
146
|
+
const workflowFielUserkey = workflowFieldMetadata['relationModel']['userKeyField']['name'];
|
|
147
|
+
|
|
148
|
+
// iterate over the comodel records extracting the label & value.
|
|
149
|
+
solidFormViewWorkflowData = records.map(item => ({ 'label': item[workflowFielUserkey], 'value': item['id'] }))
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const r = {
|
|
110
155
|
'solidView': entity,
|
|
111
156
|
'solidFieldsMetadata': Object.fromEntries(fieldsMap),
|
|
112
|
-
|
|
157
|
+
'solidFormViewWorkflowData': solidFormViewWorkflowData
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return r;
|
|
113
161
|
}
|
|
114
162
|
|
|
115
163
|
async findOneByUserKey(name: string, relations = {}) {
|
|
@@ -137,6 +185,7 @@ export class ViewMetadataService extends CRUDService<ViewMetadata> {
|
|
|
137
185
|
return this.repo.save(viewData);
|
|
138
186
|
}
|
|
139
187
|
}
|
|
188
|
+
|
|
140
189
|
async createIfNotPresent(updateSolidViewDto: UpdateViewMetadataDto) {
|
|
141
190
|
// First check if module already exists using name
|
|
142
191
|
const existingSolidView = await this.findOneByUserKey(updateSolidViewDto.name);
|