@flusys/nestjs-form-builder 7.0.0 → 7.0.1
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/cjs/config/event-actions.js +4 -0
- package/cjs/services/form-result.service.js +1 -1
- package/cjs/services/form.service.js +1 -4
- package/cjs/services/form.service.spec.js +5 -5
- package/config/event-actions.d.ts +1 -0
- package/fesm/config/event-actions.js +1 -0
- package/fesm/services/form-result.service.js +2 -2
- package/fesm/services/form.service.js +2 -5
- package/fesm/services/form.service.spec.js +5 -5
- package/interfaces/form-builder-module.interface.d.ts +2 -2
- package/package.json +3 -3
- package/services/form.service.d.ts +1 -2
|
@@ -17,6 +17,9 @@ _export(exports, {
|
|
|
17
17
|
},
|
|
18
18
|
get FORM_BUILDER_EVENT_ENTITIES () {
|
|
19
19
|
return FORM_BUILDER_EVENT_ENTITIES;
|
|
20
|
+
},
|
|
21
|
+
get FORM_BUILDER_EVENT_MODULE () {
|
|
22
|
+
return FORM_BUILDER_EVENT_MODULE;
|
|
20
23
|
}
|
|
21
24
|
});
|
|
22
25
|
const FORM_BUILDER_EVENT_ACTIONS = {
|
|
@@ -27,3 +30,4 @@ const FORM_BUILDER_EVENT_ENTITIES = {
|
|
|
27
30
|
FORM: 'form',
|
|
28
31
|
FORM_RESULT: 'form_result'
|
|
29
32
|
};
|
|
33
|
+
const FORM_BUILDER_EVENT_MODULE = 'form-builder';
|
|
@@ -319,7 +319,7 @@ let FormResultService = class FormResultService extends _classes.ApiService {
|
|
|
319
319
|
return count > 0;
|
|
320
320
|
}
|
|
321
321
|
constructor(cacheManager, utilsService, formBuilderConfig, dataSourceProvider){
|
|
322
|
-
super(
|
|
322
|
+
super(_config.FORM_BUILDER_EVENT_ENTITIES.FORM_RESULT, cacheManager, utilsService, FormResultService.name, true, _config.FORM_BUILDER_EVENT_MODULE, dataSourceProvider, _entities.FormResult), _define_property(this, "cacheManager", void 0), _define_property(this, "utilsService", void 0), _define_property(this, "formBuilderConfig", void 0), _define_property(this, "dataSourceProvider", void 0), _define_property(this, "formRepository", void 0), this.cacheManager = cacheManager, this.utilsService = utilsService, this.formBuilderConfig = formBuilderConfig, this.dataSourceProvider = dataSourceProvider, this.formRepository = null;
|
|
323
323
|
}
|
|
324
324
|
};
|
|
325
325
|
_ts_decorate([
|
|
@@ -48,9 +48,6 @@ function _ts_param(paramIndex, decorator) {
|
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
let FormService = class FormService extends _classes.ApiService {
|
|
51
|
-
resolveEntity() {
|
|
52
|
-
return this.formBuilderConfig.isCompanyFeatureEnabled() ? _entities.FormWithCompany : _entities.Form;
|
|
53
|
-
}
|
|
54
51
|
// Entity Conversion
|
|
55
52
|
async convertSingleDtoToEntity(dto, user) {
|
|
56
53
|
let form = {};
|
|
@@ -323,7 +320,7 @@ let FormService = class FormService extends _classes.ApiService {
|
|
|
323
320
|
return this.toPublicForm(form);
|
|
324
321
|
}
|
|
325
322
|
constructor(cacheManager, utilsService, formBuilderConfig, dataSourceProvider){
|
|
326
|
-
super(
|
|
323
|
+
super(_config.FORM_BUILDER_EVENT_ENTITIES.FORM, cacheManager, utilsService, FormService.name, true, _config.FORM_BUILDER_EVENT_MODULE, dataSourceProvider, formBuilderConfig.isCompanyFeatureEnabled() ? _entities.FormWithCompany : _entities.Form), _define_property(this, "cacheManager", void 0), _define_property(this, "utilsService", void 0), _define_property(this, "formBuilderConfig", void 0), this.cacheManager = cacheManager, this.utilsService = utilsService, this.formBuilderConfig = formBuilderConfig;
|
|
327
324
|
}
|
|
328
325
|
};
|
|
329
326
|
FormService = _ts_decorate([
|
|
@@ -120,14 +120,14 @@ describe('FormService', ()=>{
|
|
|
120
120
|
afterEach(()=>{
|
|
121
121
|
jest.clearAllMocks();
|
|
122
122
|
});
|
|
123
|
-
describe('
|
|
124
|
-
it('
|
|
123
|
+
describe('entity selection', ()=>{
|
|
124
|
+
it('uses Form when company feature disabled', async ()=>{
|
|
125
125
|
await buildService(false);
|
|
126
|
-
expect(service
|
|
126
|
+
expect(service['_entity']).toBe(_entities.Form);
|
|
127
127
|
});
|
|
128
|
-
it('
|
|
128
|
+
it('uses FormWithCompany when company feature enabled', async ()=>{
|
|
129
129
|
await buildService(true);
|
|
130
|
-
expect(service
|
|
130
|
+
expect(service['_entity']).toBe(_entities.FormWithCompany);
|
|
131
131
|
});
|
|
132
132
|
});
|
|
133
133
|
// ==========================================================================
|
|
@@ -31,7 +31,7 @@ import { ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
|
|
|
31
31
|
import { UtilsService } from '@flusys/nestjs-shared/modules';
|
|
32
32
|
import { BadRequestException, ForbiddenException, Inject, Injectable, NotFoundException, Scope, UnauthorizedException } from '@nestjs/common';
|
|
33
33
|
import { IsNull } from 'typeorm';
|
|
34
|
-
import { FORM_BUILDER_EVENT_ACTIONS, FORM_MESSAGES, FORM_RESULT_MESSAGES } from '../config';
|
|
34
|
+
import { FORM_BUILDER_EVENT_ACTIONS, FORM_BUILDER_EVENT_ENTITIES, FORM_BUILDER_EVENT_MODULE, FORM_MESSAGES, FORM_RESULT_MESSAGES } from '../config';
|
|
35
35
|
import { SubmitFormDto } from '../dtos/form-result.dto';
|
|
36
36
|
import { Form, FormResult, FormWithCompany } from '../entities';
|
|
37
37
|
import { FormAccessType } from '../enums/form-access-type.enum';
|
|
@@ -309,7 +309,7 @@ export class FormResultService extends ApiService {
|
|
|
309
309
|
return count > 0;
|
|
310
310
|
}
|
|
311
311
|
constructor(cacheManager, utilsService, formBuilderConfig, dataSourceProvider){
|
|
312
|
-
super(
|
|
312
|
+
super(FORM_BUILDER_EVENT_ENTITIES.FORM_RESULT, cacheManager, utilsService, FormResultService.name, true, FORM_BUILDER_EVENT_MODULE, dataSourceProvider, FormResult), _define_property(this, "cacheManager", void 0), _define_property(this, "utilsService", void 0), _define_property(this, "formBuilderConfig", void 0), _define_property(this, "dataSourceProvider", void 0), _define_property(this, "formRepository", void 0), this.cacheManager = cacheManager, this.utilsService = utilsService, this.formBuilderConfig = formBuilderConfig, this.dataSourceProvider = dataSourceProvider, this.formRepository = null;
|
|
313
313
|
}
|
|
314
314
|
}
|
|
315
315
|
_ts_decorate([
|
|
@@ -31,16 +31,13 @@ import { UtilsService } from '@flusys/nestjs-shared/modules';
|
|
|
31
31
|
import { applyCompanyFilter } from '@flusys/nestjs-shared/utils';
|
|
32
32
|
import { BadRequestException, ForbiddenException, Inject, Injectable, NotFoundException, Scope, UnauthorizedException } from '@nestjs/common';
|
|
33
33
|
import { IsNull } from 'typeorm';
|
|
34
|
-
import { FORM_MESSAGES } from '../config';
|
|
34
|
+
import { FORM_BUILDER_EVENT_ENTITIES, FORM_BUILDER_EVENT_MODULE, FORM_MESSAGES } from '../config';
|
|
35
35
|
import { Form, FormWithCompany } from '../entities';
|
|
36
36
|
import { FormAccessType } from '../enums/form-access-type.enum';
|
|
37
37
|
import { validateUserPermissions } from '../utils/permission.utils';
|
|
38
38
|
import { FormBuilderConfigService } from './form-builder-config.service';
|
|
39
39
|
import { FormBuilderDataSourceProvider } from './form-builder-datasource.provider';
|
|
40
40
|
export class FormService extends ApiService {
|
|
41
|
-
resolveEntity() {
|
|
42
|
-
return this.formBuilderConfig.isCompanyFeatureEnabled() ? FormWithCompany : Form;
|
|
43
|
-
}
|
|
44
41
|
// Entity Conversion
|
|
45
42
|
async convertSingleDtoToEntity(dto, user) {
|
|
46
43
|
let form = {};
|
|
@@ -313,7 +310,7 @@ export class FormService extends ApiService {
|
|
|
313
310
|
return this.toPublicForm(form);
|
|
314
311
|
}
|
|
315
312
|
constructor(cacheManager, utilsService, formBuilderConfig, dataSourceProvider){
|
|
316
|
-
super(
|
|
313
|
+
super(FORM_BUILDER_EVENT_ENTITIES.FORM, cacheManager, utilsService, FormService.name, true, FORM_BUILDER_EVENT_MODULE, dataSourceProvider, formBuilderConfig.isCompanyFeatureEnabled() ? FormWithCompany : Form), _define_property(this, "cacheManager", void 0), _define_property(this, "utilsService", void 0), _define_property(this, "formBuilderConfig", void 0), this.cacheManager = cacheManager, this.utilsService = utilsService, this.formBuilderConfig = formBuilderConfig;
|
|
317
314
|
}
|
|
318
315
|
}
|
|
319
316
|
FormService = _ts_decorate([
|
|
@@ -75,14 +75,14 @@ describe('FormService', ()=>{
|
|
|
75
75
|
afterEach(()=>{
|
|
76
76
|
jest.clearAllMocks();
|
|
77
77
|
});
|
|
78
|
-
describe('
|
|
79
|
-
it('
|
|
78
|
+
describe('entity selection', ()=>{
|
|
79
|
+
it('uses Form when company feature disabled', async ()=>{
|
|
80
80
|
await buildService(false);
|
|
81
|
-
expect(service
|
|
81
|
+
expect(service['_entity']).toBe(Form);
|
|
82
82
|
});
|
|
83
|
-
it('
|
|
83
|
+
it('uses FormWithCompany when company feature enabled', async ()=>{
|
|
84
84
|
await buildService(true);
|
|
85
|
-
expect(service
|
|
85
|
+
expect(service['_entity']).toBe(FormWithCompany);
|
|
86
86
|
});
|
|
87
87
|
});
|
|
88
88
|
// ==========================================================================
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ModuleMetadata, Type } from '@nestjs/common';
|
|
2
|
-
import { IBootstrapAppConfig, IDataSourceServiceOptions, IDynamicModuleConfig
|
|
2
|
+
import { IBootstrapAppConfig, IDataSourceServiceOptions, IDynamicModuleConfig } from '@flusys/nestjs-core';
|
|
3
3
|
import { IModuleEventsConfig } from '@flusys/nestjs-shared/interfaces';
|
|
4
4
|
export interface IFormBuilderConfig extends IDataSourceServiceOptions {
|
|
5
5
|
events?: IModuleEventsConfig;
|
|
@@ -8,7 +8,7 @@ export interface FormBuilderModuleOptions extends IDynamicModuleConfig {
|
|
|
8
8
|
bootstrapAppConfig?: IBootstrapAppConfig;
|
|
9
9
|
config?: IFormBuilderConfig;
|
|
10
10
|
}
|
|
11
|
-
export interface FormBuilderOptionsFactory
|
|
11
|
+
export interface FormBuilderOptionsFactory {
|
|
12
12
|
createFormBuilderOptions(): Promise<IFormBuilderConfig> | IFormBuilderConfig;
|
|
13
13
|
}
|
|
14
14
|
export interface FormBuilderModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flusys/nestjs-form-builder",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.1",
|
|
4
4
|
"description": "Dynamic form builder module with schema versioning and access control",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "fesm/index.js",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"express": "^5.0.0"
|
|
85
85
|
},
|
|
86
86
|
"dependencies": {
|
|
87
|
-
"@flusys/nestjs-core": "7.0.
|
|
88
|
-
"@flusys/nestjs-shared": "7.0.
|
|
87
|
+
"@flusys/nestjs-core": "7.0.1",
|
|
88
|
+
"@flusys/nestjs-shared": "7.0.1"
|
|
89
89
|
}
|
|
90
90
|
}
|
|
@@ -2,7 +2,7 @@ import { HybridCache, ApiService } from '@flusys/nestjs-shared/classes';
|
|
|
2
2
|
import { FilterAndPaginationDto } from '@flusys/nestjs-shared/dtos';
|
|
3
3
|
import { ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
|
|
4
4
|
import { UtilsService } from '@flusys/nestjs-shared/modules';
|
|
5
|
-
import {
|
|
5
|
+
import { SelectQueryBuilder } from 'typeorm';
|
|
6
6
|
import { CreateFormDto, UpdateFormDto } from '../dtos/form.dto';
|
|
7
7
|
import { Form } from '../entities';
|
|
8
8
|
import { FormAccessType } from '../enums/form-access-type.enum';
|
|
@@ -14,7 +14,6 @@ export declare class FormService extends ApiService<CreateFormDto, UpdateFormDto
|
|
|
14
14
|
protected utilsService: UtilsService;
|
|
15
15
|
private readonly formBuilderConfig;
|
|
16
16
|
constructor(cacheManager: HybridCache, utilsService: UtilsService, formBuilderConfig: FormBuilderConfigService, dataSourceProvider: FormBuilderDataSourceProvider);
|
|
17
|
-
protected resolveEntity(): EntityTarget<Form>;
|
|
18
17
|
convertSingleDtoToEntity(dto: CreateFormDto | UpdateFormDto, user: ILoggedUserInfo | null): Promise<Form>;
|
|
19
18
|
getSelectQuery(query: SelectQueryBuilder<Form>, _user: ILoggedUserInfo | null, select?: string[]): Promise<{
|
|
20
19
|
query: SelectQueryBuilder<Form>;
|