@puca/puca-core 7.0.0 → 7.0.2

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.
Files changed (33) hide show
  1. package/dist/core/services/bootstrap-commands.js +27 -0
  2. package/dist/core/services/bootstrap-commands.js.map +1 -1
  3. package/dist/core/services/crud-base-testable.service.d.ts +4 -0
  4. package/dist/core/services/crud-base-testable.service.js +5 -0
  5. package/dist/core/services/crud-base-testable.service.js.map +1 -1
  6. package/dist/core/services/crud-base.controller.d.ts +1 -1
  7. package/dist/core/services/crud-base.controller.js +5 -3
  8. package/dist/core/services/crud-base.controller.js.map +1 -1
  9. package/dist/core/services/crud-front-base.service.d.ts +1 -0
  10. package/dist/core/services/crud-front-base.service.js +4 -0
  11. package/dist/core/services/crud-front-base.service.js.map +1 -1
  12. package/dist/core/services/index.js +2 -2
  13. package/dist/core/services/index.js.map +1 -1
  14. package/dist/core/services/install.service.d.ts +13 -13
  15. package/dist/core/services/install.service.js +199 -138
  16. package/dist/core/services/install.service.js.map +1 -1
  17. package/dist/core/services/life-cycle.service.d.ts +1 -5
  18. package/dist/core/services/life-cycle.service.js +2 -43
  19. package/dist/core/services/life-cycle.service.js.map +1 -1
  20. package/dist/models/crud-controller-especification-enviroment.d.ts +1 -0
  21. package/dist/models/crud-controller-especification.d.ts +1 -0
  22. package/dist/models/crud-controller-especification.js.map +1 -1
  23. package/dist/models/table-dictionary.d.ts +10 -0
  24. package/dist/orm/cases/sql-builder/select.service.js +16 -18
  25. package/dist/orm/cases/sql-builder/select.service.js.map +1 -1
  26. package/dist/orm/interfaces.d.ts +1 -0
  27. package/dist/orm/services/managers/database-manager.service.js +15 -1
  28. package/dist/orm/services/managers/database-manager.service.js.map +1 -1
  29. package/dist/orm/services/sql.service.d.ts +1 -0
  30. package/dist/orm/services/sql.service.js +141 -119
  31. package/dist/orm/services/sql.service.js.map +1 -1
  32. package/dist/tsconfig.tsbuildinfo +1 -1
  33. package/package.json +1 -1
@@ -4,12 +4,16 @@ exports.InstallService = void 0;
4
4
  const _ = require("lodash");
5
5
  const menu_1 = require("../../models/menu");
6
6
  const interfaces_1 = require("../../orm/interfaces");
7
+ const crud_front_base_service_1 = require("./crud-front-base.service");
8
+ const crud_base_service_1 = require("./crud-base.service");
7
9
  class InstallService {
8
- constructor(migrationService, repositoryFactory) {
10
+ constructor(migrationService, repositoryFactory, fileSystemService, moduleConfigService) {
9
11
  this.migrationService = migrationService;
10
12
  this.repositoryFactory = repositoryFactory;
13
+ this.fileSystemService = fileSystemService;
14
+ this.moduleConfigService = moduleConfigService;
11
15
  }
12
- async persistCrudEspecificationIntoDictionary({ user, crudEspecification, crudServiceInstances }) {
16
+ async persistCrudEspecificationIntoDictionary({ user, crudEspecification, moduleEspecification }) {
13
17
  const tableDicionaryRepository = this.repositoryFactory.getInstance({
14
18
  tableName: 'table_dictionary',
15
19
  });
@@ -38,7 +42,14 @@ class InstallService {
38
42
  entity: {
39
43
  puca_pid: td.puca_pid,
40
44
  default_label: ce.table.defaultLabel,
41
- rules: this.computeTablePermission(ce.table.tableName, crudServiceInstances, crudEspecification, '{{alias}}')
45
+ rules: this.internalComputeTablePermission({
46
+ variablePrefix: ce.table.tableName,
47
+ tableName: ce.table.tableName,
48
+ alias: '{{alias}}',
49
+ crudEspecification,
50
+ v2: '$puca_pid',
51
+ moduleEspecification,
52
+ })
42
53
  },
43
54
  user,
44
55
  });
@@ -72,16 +83,26 @@ class InstallService {
72
83
  ]);
73
84
  }));
74
85
  }
75
- computeTablePermission(tableName, crudServiceInstances, crudEspecification, alias) {
86
+ async computeTablePermission({ tableName }) {
87
+ const context = await this.installContext();
88
+ return this.internalComputeTablePermission({
89
+ variablePrefix: tableName,
90
+ tableName: tableName,
91
+ alias: '{{alias}}',
92
+ crudEspecification: await context.crudEspecification(),
93
+ v2: '$puca_pid',
94
+ moduleEspecification: await context.moduleEspecification()
95
+ });
96
+ }
97
+ internalComputeTablePermission({ variablePrefix, tableName, alias, crudEspecification, v2, moduleEspecification: me }) {
76
98
  const ce = crudEspecification.find(ce => ce.table.tableName === tableName);
77
- const variablePrefix = tableName;
78
- const permissionByName = (permissionName, active) => {
79
- if (!active) {
99
+ const permissionByName = (variablePrefix, permission) => {
100
+ if (!permission) {
80
101
  return { args: null, where: null };
81
102
  }
82
103
  return {
83
104
  args: {
84
- [`${variablePrefix}_permissionName`]: `${ce.table.tableName}-${permissionName}`,
105
+ [`${variablePrefix}_permissionName`]: permission,
85
106
  [`${variablePrefix}_true`]: true,
86
107
  [`${variablePrefix}_currentUser`]: "@currentUser"
87
108
  },
@@ -98,7 +119,8 @@ class InstallService {
98
119
  }
99
120
  }],
100
121
  where: {
101
- and: [{
122
+ and: [
123
+ {
102
124
  v1: 'puca_base_api_system_user_config_definition.name',
103
125
  operator: interfaces_1.ConditionalOpertator.equals,
104
126
  v2: `$${variablePrefix}_permissionName`
@@ -110,7 +132,8 @@ class InstallService {
110
132
  v1: 'puca_base_api_system_user_config.system_user',
111
133
  operator: interfaces_1.ConditionalOpertator.equals,
112
134
  v2: `$${variablePrefix}_currentUser`
113
- }]
135
+ }
136
+ ]
114
137
  }
115
138
  }
116
139
  }
@@ -133,23 +156,23 @@ class InstallService {
133
156
  from: 'puca_base_api_permission',
134
157
  where: {
135
158
  and: [{
136
- v1: 'table_name',
159
+ v1: 'puca_base_api_permission.table_name',
137
160
  operator: interfaces_1.ConditionalOpertator.equals,
138
161
  v2: `$${variablePrefix}_table_name`
139
162
  },
140
163
  {
141
- v1: 'key',
164
+ v1: 'puca_base_api_permission.key',
142
165
  operator: interfaces_1.ConditionalOpertator.equals,
143
166
  v2: `${alias}.puca_pid`
144
167
  },
145
168
  {
146
- v1: 'system_user',
169
+ v1: 'puca_base_api_permission.system_user',
147
170
  operator: interfaces_1.ConditionalOpertator.equals,
148
171
  v2: `$${variablePrefix}_currentUser`
149
172
  },
150
173
  {
151
174
  or: permissionNames.map((rule, i) => ({
152
- v1: 'rule',
175
+ v1: 'puca_base_api_permission.rule',
153
176
  operator: interfaces_1.ConditionalOpertator.equals,
154
177
  v2: `$${variablePrefix}_arg${i}`
155
178
  }))
@@ -159,58 +182,57 @@ class InstallService {
159
182
  }
160
183
  };
161
184
  };
162
- const pInsertByName = permissionByName('new', _.get(ce, ['useAccessControl', 'insert']));
163
- const pUpdateByName = permissionByName('edit', _.get(ce, ['useAccessControl', 'update']));
164
- const pDeleteByName = permissionByName('delete', _.get(ce, ['useAccessControl', 'delete']));
165
- const pListByName = permissionByName('list', _.get(ce, ['useAccessControl', 'select']));
185
+ const moduleAccess = permissionByName(`${variablePrefix}_access`, me.useAccessControl && !ce.ignoreModuleAccessVerification && `${me.module_name}-access`);
186
+ const pInsertByName = permissionByName(`${variablePrefix}_insert`, _.get(ce, ['useAccessControl', 'insert']) && `${ce.table.tableName}-new`);
187
+ const pUpdateByName = permissionByName(`${variablePrefix}_update`, _.get(ce, ['useAccessControl', 'update']) && `${ce.table.tableName}-edit`);
188
+ const pDeleteByName = permissionByName(`${variablePrefix}_delete`, _.get(ce, ['useAccessControl', 'delete']) && `${ce.table.tableName}-delete`);
189
+ const pListByName = permissionByName(`${variablePrefix}_select`, _.get(ce, ['useAccessControl', 'select']) && `${ce.table.tableName}-list`);
166
190
  const pByRow = permissionByRow([
167
191
  'allow', 'admin',
168
192
  "read", "write", "read-write"
169
193
  ], ce.useAccessControlEachRow);
170
- const pByRowExists = (where, mode) => {
171
- return {
172
- exists: {
173
- from: {
174
- table: ce.table.tableName,
175
- alias: ce.table.tableName
176
- },
177
- where: {
178
- and: [
179
- {
180
- v1: `${ce.table.tableName}.puca_pid`,
181
- operator: interfaces_1.ConditionalOpertator.equals,
182
- v2: '$puca_pid'
183
- },
184
- ...where,
185
- _.get(accessRules, [mode, 'where'])
186
- ].filter(f => f)
187
- }
194
+ const simplifyAnd = (and) => {
195
+ const sAnd = and
196
+ .filter(f => f)
197
+ .map(w => {
198
+ if ('and' in w) {
199
+ return simplifyAnd(w.and);
188
200
  }
189
- };
201
+ return w;
202
+ });
203
+ return sAnd.length > 1 ? { and: sAnd } : sAnd[0];
190
204
  };
191
- const service = crudServiceInstances.find(service => service.getTableName() === tableName);
192
- const accessRules = service && service.acessRules ? service.acessRules() : null;
193
- const selectBase = (tableName, field, where) => ({
194
- exists: {
195
- from: tableName,
196
- where: {
197
- and: [
205
+ const pByRowExists = (variablePrefix, tableName, v1, v2, where) => {
206
+ return {
207
+ exists: {
208
+ from: tableName,
209
+ where: simplifyAnd([
198
210
  {
199
- v1: `${tableName}.puca_pid`,
211
+ comment: `prefix: '${variablePrefix}' pByRowExists(${tableName},${v1},${v2},...)`,
212
+ v1,
200
213
  operator: interfaces_1.ConditionalOpertator.equals,
201
- v2: `${alias}.${field}`
214
+ v2
202
215
  },
203
216
  where
204
- ]
217
+ ])
205
218
  }
206
- }
207
- });
219
+ };
220
+ };
208
221
  const modes = ['insert', 'update', 'delete', 'select'];
209
- const parentPermission = Object.entries(ce.parentAccessControl || {}).map(([field, tableName]) => {
210
- const permission = this.computeTablePermission(tableName, crudServiceInstances, crudEspecification, tableName);
222
+ const parentPermission = Object.entries(ce.parentAccessControl || {}).map(([field, reference]) => {
211
223
  const r = {};
212
224
  modes.forEach(mode => {
213
- r[mode] = { where: selectBase(tableName, field, permission[mode].where), args: permission[mode].args };
225
+ const estrategies = {
226
+ insert: `$${field}`,
227
+ update: `${alias}.${field}`,
228
+ delete: `${alias}.${field}`,
229
+ select: `${alias}.${field}`
230
+ };
231
+ const splitedReference = reference.split('.');
232
+ r[mode] = {
233
+ where: pByRowExists(`${variablePrefix}_${splitedReference[0]}`, splitedReference[0], splitedReference[1] ? reference : `${splitedReference[0]}.puca_pid`, estrategies[mode]),
234
+ args: {}
235
+ };
214
236
  });
215
237
  return r;
216
238
  }).reduce((r, permission) => {
@@ -223,77 +245,121 @@ class InstallService {
223
245
  });
224
246
  });
225
247
  return r;
226
- }, {
227
- select: { args: {}, where: { and: [] } },
228
- insert: { args: {}, where: { and: [] } },
229
- update: { args: {}, where: { and: [] } },
230
- delete: { args: {}, where: { and: [] } }
231
- });
248
+ }, modes.reduce((r, mode) => {
249
+ r[mode] = { args: {}, where: { and: [] } };
250
+ return r;
251
+ }, {}));
252
+ const service = crud_base_service_1.instances.find(service => service.getTableName() === tableName);
253
+ const accessRules = service && service.acessRules ? service.acessRules() : null;
232
254
  return {
233
255
  insert: {
234
- args: Object.assign(Object.assign(Object.assign({}, pInsertByName.args), _.get(accessRules, ['insert', 'args'])), _.get(parentPermission, ['insert', 'args'])),
235
- where: {
236
- and: [
237
- pInsertByName.where,
238
- _.get(accessRules, ['insert', 'where']),
239
- _.get(parentPermission, ['insert', 'where'])
240
- ].filter(f => f)
241
- }
256
+ args: Object.assign(Object.assign(Object.assign(Object.assign({}, moduleAccess.args), pInsertByName.args), _.get(accessRules, ['insert', 'args'])), _.get(parentPermission, ['insert', 'args'])),
257
+ where: simplifyAnd([
258
+ moduleAccess.where,
259
+ pInsertByName.where,
260
+ _.get(accessRules, ['insert', 'where']),
261
+ _.get(parentPermission, ['insert', 'where']),
262
+ ])
242
263
  },
243
264
  update: {
244
- args: Object.assign(Object.assign(Object.assign(Object.assign({}, pUpdateByName.args), pByRow.args), _.get(accessRules, ['update', 'args'])), _.get(parentPermission, ['update', 'args'])),
245
- where: pByRowExists([
265
+ args: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, moduleAccess.args), pUpdateByName.args), pByRow.args), _.get(accessRules, ['update', 'args'])), _.get(parentPermission, ['update', 'args'])),
266
+ where: pByRowExists(variablePrefix, ce.table.tableName, `${ce.table.tableName}.puca_pid`, v2, simplifyAnd([
267
+ moduleAccess.where,
246
268
  pUpdateByName.where,
247
269
  pByRow.where,
248
270
  _.get(accessRules, ['update', 'where']),
249
- _.get(parentPermission, ['update', 'where'])
250
- ], 'update')
271
+ _.get(parentPermission, ['update', 'where']),
272
+ ]))
251
273
  },
252
274
  delete: {
253
- args: Object.assign(Object.assign(Object.assign(Object.assign({}, pDeleteByName.args), pByRow.args), _.get(accessRules, ['delete', 'args'])), _.get(parentPermission, ['delete', 'args'])),
254
- where: pByRowExists([
275
+ args: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, moduleAccess.args), pDeleteByName.args), pByRow.args), _.get(accessRules, ['delete', 'args'])), _.get(parentPermission, ['delete', 'args'])),
276
+ where: pByRowExists(variablePrefix, ce.table.tableName, `${ce.table.tableName}.puca_pid`, v2, simplifyAnd([
277
+ moduleAccess.where,
255
278
  pDeleteByName.where,
256
279
  pByRow.where,
257
280
  _.get(accessRules, ['delete', 'where']),
258
281
  _.get(parentPermission, ['delete', 'where'])
259
- ], 'delete')
282
+ ]))
260
283
  },
261
284
  select: {
262
- args: Object.assign(Object.assign(Object.assign(Object.assign({}, pListByName.args), pByRow.args), _.get(accessRules, ['select', 'args'])), _.get(parentPermission, ['select', 'args'])),
263
- where: {
264
- and: [
265
- pListByName.where,
266
- pByRow.where,
267
- _.get(accessRules, ['select', 'where']),
268
- _.get(parentPermission, ['select', 'where'])
269
- ].filter(f => f)
270
- }
285
+ args: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, moduleAccess.args), pListByName.args), pByRow.args), _.get(accessRules, ['select', 'args'])), _.get(parentPermission, ['select', 'args'])),
286
+ where: simplifyAnd([
287
+ moduleAccess.where,
288
+ pListByName.where,
289
+ pByRow.where,
290
+ _.get(accessRules, ['select', 'where']),
291
+ _.get(parentPermission, ['select', 'where'])
292
+ ])
271
293
  }
272
294
  };
273
295
  }
274
- async install({ user, especification, crudEspecification, userConfigDefinitions, crudServiceInstances }) {
296
+ async install() {
297
+ const context = await this.installContext();
298
+ await this.internalInstall({
299
+ user: await context.user(),
300
+ moduleEspecification: await context.moduleEspecification(),
301
+ crudEspecification: await context.crudEspecification(),
302
+ userConfigDefinitions: await context.userConfigDefinitions(),
303
+ });
304
+ }
305
+ async installContext() {
306
+ const repository = this.repositoryFactory.getInstance({
307
+ tableName: 'puca_base_api_system_user',
308
+ });
309
+ const user = () => repository.findOneBy({
310
+ fields: ['puca_pid', 'username'],
311
+ key: 'username',
312
+ value: 'puca-user',
313
+ });
314
+ const moduleEspecification = async () => {
315
+ const ddlCommands = await this.fileSystemService.readJSONFile('./ddls.json', {
316
+ throwErrors: false,
317
+ });
318
+ const moduleConfig = await this.moduleConfigService.getModuleConfig();
319
+ const menuPlan = (await this.fileSystemService.readJSONFile('./menus.json', {
320
+ throwErrors: false,
321
+ })) || [];
322
+ return {
323
+ module_name: moduleConfig.name,
324
+ label: moduleConfig.label,
325
+ version: moduleConfig.version,
326
+ ddlCommands,
327
+ menu: menuPlan,
328
+ active: true,
329
+ showOnMenu: _.get(moduleConfig, 'showOnMenu', true),
330
+ useAccessControl: moduleConfig.useAccessControl,
331
+ indexPage: moduleConfig.indexPage
332
+ };
333
+ };
334
+ const userConfigDefinitions = () => this.fileSystemService.readJSONFile('./user-configs.json', {
335
+ throwErrors: false,
336
+ }) || [];
337
+ const crudEspecification = async () => (await Promise.all(crud_front_base_service_1.instances.map(crud_front_base_service_1.crudControllerEspecificationEnviromentToCrudControllerEspecificationList))).reduce((a, b) => a.concat(b), []);
338
+ return { user, moduleEspecification, crudEspecification, userConfigDefinitions };
339
+ }
340
+ async internalInstall({ user, moduleEspecification, crudEspecification, userConfigDefinitions, }) {
275
341
  await this.installDdls({
276
- especification,
342
+ moduleEspecification,
277
343
  user,
278
344
  });
279
345
  await this.installMenu({
280
346
  crudEspecification,
281
- especification,
347
+ moduleEspecification,
282
348
  user,
283
349
  });
284
350
  await this.installUserConfigDefinitions({
285
351
  user,
286
- especification,
352
+ moduleEspecification,
287
353
  userConfigDefinitions,
288
- crudEspecification,
354
+ crudEspecification: crudEspecification.filter(ce => (ce.name || 'default') === 'default'),
289
355
  });
290
356
  await this.persistCrudEspecificationIntoDictionary({
291
357
  user,
292
358
  crudEspecification: crudEspecification.filter(ce => (ce.name || 'default') === 'default'),
293
- crudServiceInstances
359
+ moduleEspecification
294
360
  });
295
361
  }
296
- async installUserConfigDefinitions({ userConfigDefinitions, user, especification, crudEspecification, }) {
362
+ async installUserConfigDefinitions({ userConfigDefinitions, user, moduleEspecification, crudEspecification, }) {
297
363
  if (!userConfigDefinitions) {
298
364
  userConfigDefinitions = [];
299
365
  }
@@ -303,70 +369,65 @@ class InstallService {
303
369
  const oldUserConfig = (await userConfigRepository.findBy({
304
370
  fields: ['puca_pid', 'name'],
305
371
  key: 'module',
306
- value: especification.module_name,
372
+ value: moduleEspecification.module_name,
307
373
  user,
308
374
  })).data;
309
375
  const allUserConfigDefinitions = [
310
376
  ...userConfigDefinitions,
311
- especification.useAccessControl
312
- ? {
313
- description: `Acesso ao módulo (${especification.label})`,
314
- module: especification.module_name,
315
- name: `${especification.module_name}-access`,
377
+ ...(moduleEspecification.useAccessControl ? [
378
+ {
379
+ description: `Acesso ao módulo (${moduleEspecification.label})`,
380
+ module: moduleEspecification.module_name,
381
+ name: `${moduleEspecification.module_name}-access`,
316
382
  type: interfaces_1.TableFieldTypeEnum.BOOLEAN,
317
- }
318
- : null,
383
+ },
384
+ {
385
+ description: `Acesso ao módulo via menu (${moduleEspecification.label})`,
386
+ module: moduleEspecification.module_name,
387
+ name: `${moduleEspecification.module_name}-menu-access`,
388
+ type: interfaces_1.TableFieldTypeEnum.BOOLEAN,
389
+ },
390
+ ] : []),
319
391
  ...crudEspecification
320
- .filter(ce => _.get(ce, ['useAccessControl', 'insert']) &&
321
- _.get(ce, ['features', 'editor', 'active'], true) &&
322
- _.get(ce, ['features', 'editor', 'new'], true))
392
+ .filter(ce => _.get(ce, ['useAccessControl', 'insert']))
323
393
  .reduce((a, b) => {
324
394
  a.push({
325
395
  description: `Permissão de criação (${b.table.defaultLabel})`,
326
- module: especification.module_name,
327
- name: `${b.table.tableName}-new` +
328
- ((b.name || 'default') !== 'default' ? `-${b.name}` : ''),
396
+ module: moduleEspecification.module_name,
397
+ name: `${b.table.tableName}-new`,
329
398
  type: interfaces_1.TableFieldTypeEnum.BOOLEAN,
330
399
  });
331
400
  return a;
332
401
  }, []),
333
402
  ...crudEspecification
334
- .filter(ce => _.get(ce, ['useAccessControl', 'update']) &&
335
- _.get(ce, ['features', 'editor', 'active'], true) &&
336
- _.get(ce, ['features', 'editor', 'edit'], true))
403
+ .filter(ce => _.get(ce, ['useAccessControl', 'update']))
337
404
  .reduce((a, b) => {
338
405
  a.push({
339
406
  description: `Permissão de edição (${b.table.defaultLabel})`,
340
- module: especification.module_name,
341
- name: `${b.table.tableName}-edit` +
342
- ((b.name || 'default') !== 'default' ? `-${b.name}` : ''),
407
+ module: moduleEspecification.module_name,
408
+ name: `${b.table.tableName}-edit`,
343
409
  type: interfaces_1.TableFieldTypeEnum.BOOLEAN,
344
410
  });
345
411
  return a;
346
412
  }, []),
347
413
  ...crudEspecification
348
- .filter(ce => _.get(ce, ['useAccessControl', 'delete']) &&
349
- _.get(ce, ['features', 'editor', 'active'], true) &&
350
- _.get(ce, ['features', 'editor', 'delete'], true))
414
+ .filter(ce => _.get(ce, ['useAccessControl', 'delete']))
351
415
  .reduce((a, b) => {
352
416
  a.push({
353
417
  description: `Permissão de deleção (${b.table.defaultLabel})`,
354
- module: especification.module_name,
355
- name: `${b.table.tableName}-delete` +
356
- ((b.name || 'default') !== 'default' ? `-${b.name}` : ''),
418
+ module: moduleEspecification.module_name,
419
+ name: `${b.table.tableName}-delete`,
357
420
  type: interfaces_1.TableFieldTypeEnum.BOOLEAN,
358
421
  });
359
422
  return a;
360
423
  }, []),
361
424
  ...crudEspecification
362
- .filter(ce => _.get(ce, ['useAccessControl', 'select']) &&
363
- _.get(ce, ['features', 'list', 'active'], true))
425
+ .filter(ce => _.get(ce, ['useAccessControl', 'select']))
364
426
  .reduce((a, b) => {
365
427
  a.push({
366
428
  description: `Acesso à listagem (${b.table.defaultLabel})`,
367
- module: especification.module_name,
368
- name: `${b.table.tableName}-list` +
369
- ((b.name || 'default') !== 'default' ? `-${b.name}` : ''),
429
+ module: moduleEspecification.module_name,
430
+ name: `${b.table.tableName}-list`,
370
431
  type: interfaces_1.TableFieldTypeEnum.BOOLEAN,
371
432
  });
372
433
  return a;
@@ -386,32 +447,32 @@ class InstallService {
386
447
  tableName: 'puca_base_api_menu',
387
448
  });
388
449
  }
389
- async installMenu({ user, especification, crudEspecification, }) {
450
+ async installMenu({ user, moduleEspecification, crudEspecification, }) {
390
451
  if (!crudEspecification) {
391
452
  crudEspecification = [];
392
453
  }
393
- const formMenuName = `${especification.module_name}_main`;
394
- const formMenuDictionary = `forms_dictionary_${especification.module_name}`;
395
- const formForms = `forms_${especification.module_name}`;
454
+ const formMenuName = `${moduleEspecification.module_name}_main`;
455
+ const formMenuDictionary = `forms_dictionary_${moduleEspecification.module_name}`;
456
+ const formForms = `forms_${moduleEspecification.module_name}`;
396
457
  const activeCrudEspecification = crudEspecification.filter(c => c.showOnMenu);
397
- const formMenuLink = especification.indexPage || especification.module_name;
398
- const formMenus = especification.showOnMenu
458
+ const formMenuLink = moduleEspecification.indexPage || moduleEspecification.module_name;
459
+ const formMenus = moduleEspecification.showOnMenu
399
460
  ? [
400
461
  {
401
462
  name: formMenuName,
402
- label: especification.label,
463
+ label: moduleEspecification.label,
403
464
  auth: menu_1.EnumMenuAuth.yes,
404
465
  link: formMenuLink,
405
466
  module: null,
406
467
  active: null,
407
- feature_tags: especification.featureTags,
408
- access_condition: especification.useAccessControl &&
409
- `${especification.module_name}-access`,
468
+ feature_tags: moduleEspecification.featureTags,
469
+ access_condition: moduleEspecification.useAccessControl &&
470
+ `${moduleEspecification.module_name}-menu-access`,
410
471
  },
411
472
  activeCrudEspecification.some(e => _.get(e.features, ['dictionary', 'active'], true) && (e.name || 'default') === 'default')
412
473
  ? {
413
474
  name: formMenuDictionary,
414
- label: especification.label,
475
+ label: moduleEspecification.label,
415
476
  auth: menu_1.EnumMenuAuth.yes,
416
477
  link: `puca-crud-front/dictionary`,
417
478
  parent: 'puca-dictionary-main',
@@ -453,7 +514,7 @@ class InstallService {
453
514
  module: null,
454
515
  active: null,
455
516
  feature_tags: _.get(e.list, 'featureTags'),
456
- access_condition: _.get(especification.useAccessControl, ['select']) &&
517
+ access_condition: _.get(moduleEspecification.useAccessControl, ['select']) &&
457
518
  `${e.table.tableName}-list`,
458
519
  }
459
520
  : null,
@@ -474,17 +535,17 @@ class InstallService {
474
535
  .reduce((a, b) => a.concat(b), []),
475
536
  ]
476
537
  : [];
477
- const newMenus = [...(especification.menu || []), ...formMenus].filter(m => m);
538
+ const newMenus = [...(moduleEspecification.menu || []), ...formMenus].filter(m => m);
478
539
  const menuRepository = this.getMenuRepository();
479
540
  const oldMenus = (await menuRepository.findByIn({
480
541
  fields: ['puca_pid', 'name', 'module', 'menu_type'],
481
542
  key: 'module',
482
- values: [especification.module_name],
543
+ values: [moduleEspecification.module_name],
483
544
  user,
484
545
  })).filter(o => !o.menu_type || o.menu_type === menu_1.MenuType.DEV_MENU);
485
546
  const saves = [
486
547
  ...newMenus.map(nm => {
487
- const m = Object.assign(Object.assign(Object.assign({}, oldMenus.find(om => om.name === nm.name)), nm), { module: nm.module || especification.module_name, active: true, version: especification.version });
548
+ const m = Object.assign(Object.assign(Object.assign({}, oldMenus.find(om => om.name === nm.name)), nm), { module: nm.module || moduleEspecification.module_name, active: true, version: moduleEspecification.version });
488
549
  return m;
489
550
  }),
490
551
  ...oldMenus
@@ -498,13 +559,13 @@ class InstallService {
498
559
  await menuRepository.save({ entity: saves[i], user });
499
560
  }
500
561
  }
501
- async installDdls({ user, especification, }) {
502
- const { ddlCommands } = especification;
562
+ async installDdls({ user, moduleEspecification, }) {
563
+ const { ddlCommands } = moduleEspecification;
503
564
  if (!_.isEmpty(ddlCommands)) {
504
565
  await this.migrationService.install({
505
566
  ddlCommands,
506
567
  user,
507
- moduleName: especification.module_name,
568
+ moduleName: moduleEspecification.module_name,
508
569
  });
509
570
  }
510
571
  }