@flusys/nestjs-form-builder 0.1.0-beta.3
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/form-builder-config.service.js +79 -0
- package/cjs/config/form-builder.constants.js +22 -0
- package/cjs/config/index.js +19 -0
- package/cjs/controllers/form-result.controller.js +131 -0
- package/cjs/controllers/form.controller.js +177 -0
- package/cjs/controllers/index.js +19 -0
- package/cjs/dtos/form-result.dto.js +309 -0
- package/cjs/dtos/form.dto.js +396 -0
- package/cjs/dtos/index.js +19 -0
- package/cjs/entities/form-base.entity.js +113 -0
- package/cjs/entities/form-result.entity.js +106 -0
- package/cjs/entities/form-with-company.entity.js +55 -0
- package/cjs/entities/form.entity.js +25 -0
- package/cjs/entities/index.js +40 -0
- package/cjs/enums/form-access-type.enum.js +19 -0
- package/cjs/enums/index.js +18 -0
- package/cjs/index.js +26 -0
- package/cjs/interfaces/form-builder-module.interface.js +4 -0
- package/cjs/interfaces/form-result.interface.js +9 -0
- package/cjs/interfaces/form.interface.js +4 -0
- package/cjs/interfaces/index.js +20 -0
- package/cjs/modules/form-builder.module.js +162 -0
- package/cjs/modules/index.js +18 -0
- package/cjs/services/form-builder-datasource.provider.js +213 -0
- package/cjs/services/form-result.service.js +252 -0
- package/cjs/services/form.service.js +335 -0
- package/cjs/services/index.js +20 -0
- package/config/form-builder-config.service.d.ts +10 -0
- package/config/form-builder.constants.d.ts +2 -0
- package/config/index.d.ts +2 -0
- package/controllers/form-result.controller.d.ts +24 -0
- package/controllers/form.controller.d.ts +23 -0
- package/controllers/index.d.ts +2 -0
- package/dtos/form-result.dto.d.ts +48 -0
- package/dtos/form.dto.d.ts +63 -0
- package/dtos/index.d.ts +2 -0
- package/entities/form-base.entity.d.ts +13 -0
- package/entities/form-result.entity.d.ts +11 -0
- package/entities/form-with-company.entity.d.ts +4 -0
- package/entities/form.entity.d.ts +3 -0
- package/entities/index.d.ts +5 -0
- package/enums/form-access-type.enum.d.ts +5 -0
- package/enums/index.d.ts +1 -0
- package/fesm/config/form-builder-config.service.js +69 -0
- package/fesm/config/form-builder.constants.js +6 -0
- package/fesm/config/index.js +2 -0
- package/fesm/controllers/form-result.controller.js +121 -0
- package/fesm/controllers/form.controller.js +167 -0
- package/fesm/controllers/index.js +2 -0
- package/fesm/dtos/form-result.dto.js +281 -0
- package/fesm/dtos/form.dto.js +370 -0
- package/fesm/dtos/index.js +2 -0
- package/fesm/entities/form-base.entity.js +106 -0
- package/fesm/entities/form-result.entity.js +96 -0
- package/fesm/entities/form-with-company.entity.js +45 -0
- package/fesm/entities/form.entity.js +15 -0
- package/fesm/entities/index.js +29 -0
- package/fesm/enums/form-access-type.enum.js +9 -0
- package/fesm/enums/index.js +1 -0
- package/fesm/index.js +16 -0
- package/fesm/interfaces/form-builder-module.interface.js +3 -0
- package/fesm/interfaces/form-result.interface.js +6 -0
- package/fesm/interfaces/form.interface.js +3 -0
- package/fesm/interfaces/index.js +3 -0
- package/fesm/modules/form-builder.module.js +152 -0
- package/fesm/modules/index.js +1 -0
- package/fesm/services/form-builder-datasource.provider.js +162 -0
- package/fesm/services/form-result.service.js +242 -0
- package/fesm/services/form.service.js +325 -0
- package/fesm/services/index.js +3 -0
- package/index.d.ts +8 -0
- package/interfaces/form-builder-module.interface.d.ts +23 -0
- package/interfaces/form-result.interface.d.ts +18 -0
- package/interfaces/form.interface.d.ts +29 -0
- package/interfaces/index.d.ts +3 -0
- package/modules/form-builder.module.d.ts +9 -0
- package/modules/index.d.ts +1 -0
- package/package.json +84 -0
- package/services/form-builder-datasource.provider.d.ts +25 -0
- package/services/form-result.service.d.ts +41 -0
- package/services/form.service.d.ts +45 -0
- package/services/index.d.ts +3 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "FormBuilderConfigService", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return FormBuilderConfigService;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _common = require("@nestjs/common");
|
|
12
|
+
const _formbuilderconstants = require("./form-builder.constants");
|
|
13
|
+
const _formbuildermoduleinterface = require("../interfaces/form-builder-module.interface");
|
|
14
|
+
function _define_property(obj, key, value) {
|
|
15
|
+
if (key in obj) {
|
|
16
|
+
Object.defineProperty(obj, key, {
|
|
17
|
+
value: value,
|
|
18
|
+
enumerable: true,
|
|
19
|
+
configurable: true,
|
|
20
|
+
writable: true
|
|
21
|
+
});
|
|
22
|
+
} else {
|
|
23
|
+
obj[key] = value;
|
|
24
|
+
}
|
|
25
|
+
return obj;
|
|
26
|
+
}
|
|
27
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
28
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
29
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
30
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
31
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
32
|
+
}
|
|
33
|
+
function _ts_metadata(k, v) {
|
|
34
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
35
|
+
}
|
|
36
|
+
function _ts_param(paramIndex, decorator) {
|
|
37
|
+
return function(target, key) {
|
|
38
|
+
decorator(target, key, paramIndex);
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
let FormBuilderConfigService = class FormBuilderConfigService {
|
|
42
|
+
/**
|
|
43
|
+
* Check if company feature is enabled
|
|
44
|
+
*/ isCompanyFeatureEnabled() {
|
|
45
|
+
return this.options.bootstrapAppConfig?.enableCompanyFeature ?? false;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get database mode
|
|
49
|
+
*/ getDatabaseMode() {
|
|
50
|
+
return this.options.bootstrapAppConfig?.databaseMode ?? 'single';
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Check if multi-tenant mode is enabled
|
|
54
|
+
*/ isMultiTenant() {
|
|
55
|
+
return this.getDatabaseMode() === 'multi-tenant';
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get module options
|
|
59
|
+
*/ getOptions() {
|
|
60
|
+
return this.options;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get form builder configuration
|
|
64
|
+
*/ getConfig() {
|
|
65
|
+
return this.options.config;
|
|
66
|
+
}
|
|
67
|
+
constructor(options){
|
|
68
|
+
_define_property(this, "options", void 0);
|
|
69
|
+
this.options = options;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
FormBuilderConfigService = _ts_decorate([
|
|
73
|
+
(0, _common.Injectable)(),
|
|
74
|
+
_ts_param(0, (0, _common.Inject)(_formbuilderconstants.FORM_BUILDER_MODULE_OPTIONS)),
|
|
75
|
+
_ts_metadata("design:type", Function),
|
|
76
|
+
_ts_metadata("design:paramtypes", [
|
|
77
|
+
typeof _formbuildermoduleinterface.FormBuilderModuleOptions === "undefined" ? Object : _formbuildermoduleinterface.FormBuilderModuleOptions
|
|
78
|
+
])
|
|
79
|
+
], FormBuilderConfigService);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Form Builder Module Options Token
|
|
3
|
+
*/ "use strict";
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
function _export(target, all) {
|
|
8
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
_export(exports, {
|
|
14
|
+
get FORM_BUILDER_DATA_SOURCE_PROVIDER () {
|
|
15
|
+
return FORM_BUILDER_DATA_SOURCE_PROVIDER;
|
|
16
|
+
},
|
|
17
|
+
get FORM_BUILDER_MODULE_OPTIONS () {
|
|
18
|
+
return FORM_BUILDER_MODULE_OPTIONS;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
const FORM_BUILDER_MODULE_OPTIONS = 'FORM_BUILDER_MODULE_OPTIONS';
|
|
22
|
+
const FORM_BUILDER_DATA_SOURCE_PROVIDER = 'FORM_BUILDER_DATA_SOURCE_PROVIDER';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_export_star(require("./form-builder.constants"), exports);
|
|
6
|
+
_export_star(require("./form-builder-config.service"), exports);
|
|
7
|
+
function _export_star(from, to) {
|
|
8
|
+
Object.keys(from).forEach(function(k) {
|
|
9
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
10
|
+
Object.defineProperty(to, k, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function() {
|
|
13
|
+
return from[k];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
return from;
|
|
19
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "FormResultController", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return FormResultController;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _classes = require("@flusys/nestjs-shared/classes");
|
|
12
|
+
const _decorators = require("@flusys/nestjs-shared/decorators");
|
|
13
|
+
const _guards = require("@flusys/nestjs-shared/guards");
|
|
14
|
+
const _interfaces = require("@flusys/nestjs-shared/interfaces");
|
|
15
|
+
const _common = require("@nestjs/common");
|
|
16
|
+
const _swagger = require("@nestjs/swagger");
|
|
17
|
+
const _dtos = require("../dtos");
|
|
18
|
+
const _formresultservice = require("../services/form-result.service");
|
|
19
|
+
function _define_property(obj, key, value) {
|
|
20
|
+
if (key in obj) {
|
|
21
|
+
Object.defineProperty(obj, key, {
|
|
22
|
+
value: value,
|
|
23
|
+
enumerable: true,
|
|
24
|
+
configurable: true,
|
|
25
|
+
writable: true
|
|
26
|
+
});
|
|
27
|
+
} else {
|
|
28
|
+
obj[key] = value;
|
|
29
|
+
}
|
|
30
|
+
return obj;
|
|
31
|
+
}
|
|
32
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
33
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
34
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
35
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
36
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
37
|
+
}
|
|
38
|
+
function _ts_metadata(k, v) {
|
|
39
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
40
|
+
}
|
|
41
|
+
function _ts_param(paramIndex, decorator) {
|
|
42
|
+
return function(target, key) {
|
|
43
|
+
decorator(target, key, paramIndex);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
let FormResultController = class FormResultController extends (0, _classes.createApiController)(_dtos.CreateFormResultDto, _dtos.UpdateFormResultDto, _dtos.FormResultResponseDto, {
|
|
47
|
+
security: 'jwt'
|
|
48
|
+
}) {
|
|
49
|
+
// ==================== Submit Endpoints ====================
|
|
50
|
+
/**
|
|
51
|
+
* Submit form with authentication
|
|
52
|
+
* Supports authenticated and action_group access types
|
|
53
|
+
*/ async submitForm(dto, user) {
|
|
54
|
+
return this.formResultService.submitForm(dto, user, false);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Submit public form (no authentication required)
|
|
58
|
+
* Only works for forms with accessType = 'public'
|
|
59
|
+
*/ async submitPublicForm(dto) {
|
|
60
|
+
return this.formResultService.submitForm(dto, null, true);
|
|
61
|
+
}
|
|
62
|
+
// ==================== Query Endpoints ====================
|
|
63
|
+
/**
|
|
64
|
+
* Get results by form ID with pagination (POST-only RPC)
|
|
65
|
+
*/ async getByFormId(dto, user) {
|
|
66
|
+
return this.formResultService.getByFormId(dto.formId, user, {
|
|
67
|
+
page: dto.page ?? 0,
|
|
68
|
+
pageSize: dto.pageSize ?? 10
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
constructor(formResultService){
|
|
72
|
+
super(formResultService), _define_property(this, "formResultService", void 0), this.formResultService = formResultService;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
_ts_decorate([
|
|
76
|
+
(0, _common.Post)('submit'),
|
|
77
|
+
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
78
|
+
(0, _swagger.ApiBearerAuth)(),
|
|
79
|
+
(0, _common.HttpCode)(_common.HttpStatus.CREATED),
|
|
80
|
+
(0, _swagger.ApiOperation)({
|
|
81
|
+
summary: 'Submit form result (authenticated)'
|
|
82
|
+
}),
|
|
83
|
+
_ts_param(0, (0, _common.Body)()),
|
|
84
|
+
_ts_param(1, (0, _decorators.CurrentUser)()),
|
|
85
|
+
_ts_metadata("design:type", Function),
|
|
86
|
+
_ts_metadata("design:paramtypes", [
|
|
87
|
+
typeof _dtos.SubmitFormDto === "undefined" ? Object : _dtos.SubmitFormDto,
|
|
88
|
+
typeof _interfaces.ILoggedUserInfo === "undefined" ? Object : _interfaces.ILoggedUserInfo
|
|
89
|
+
]),
|
|
90
|
+
_ts_metadata("design:returntype", Promise)
|
|
91
|
+
], FormResultController.prototype, "submitForm", null);
|
|
92
|
+
_ts_decorate([
|
|
93
|
+
(0, _common.Post)('submit-public'),
|
|
94
|
+
(0, _decorators.Public)(),
|
|
95
|
+
(0, _common.HttpCode)(_common.HttpStatus.CREATED),
|
|
96
|
+
(0, _swagger.ApiOperation)({
|
|
97
|
+
summary: 'Submit public form (no auth required)'
|
|
98
|
+
}),
|
|
99
|
+
_ts_param(0, (0, _common.Body)()),
|
|
100
|
+
_ts_metadata("design:type", Function),
|
|
101
|
+
_ts_metadata("design:paramtypes", [
|
|
102
|
+
typeof _dtos.SubmitFormDto === "undefined" ? Object : _dtos.SubmitFormDto
|
|
103
|
+
]),
|
|
104
|
+
_ts_metadata("design:returntype", Promise)
|
|
105
|
+
], FormResultController.prototype, "submitPublicForm", null);
|
|
106
|
+
_ts_decorate([
|
|
107
|
+
(0, _common.Post)('by-form'),
|
|
108
|
+
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
109
|
+
(0, _swagger.ApiBearerAuth)(),
|
|
110
|
+
(0, _common.HttpCode)(_common.HttpStatus.OK),
|
|
111
|
+
(0, _swagger.ApiOperation)({
|
|
112
|
+
summary: 'Get results by form ID'
|
|
113
|
+
}),
|
|
114
|
+
_ts_param(0, (0, _common.Body)()),
|
|
115
|
+
_ts_param(1, (0, _decorators.CurrentUser)()),
|
|
116
|
+
_ts_metadata("design:type", Function),
|
|
117
|
+
_ts_metadata("design:paramtypes", [
|
|
118
|
+
typeof _dtos.GetResultsByFormDto === "undefined" ? Object : _dtos.GetResultsByFormDto,
|
|
119
|
+
typeof _interfaces.ILoggedUserInfo === "undefined" ? Object : _interfaces.ILoggedUserInfo
|
|
120
|
+
]),
|
|
121
|
+
_ts_metadata("design:returntype", Promise)
|
|
122
|
+
], FormResultController.prototype, "getByFormId", null);
|
|
123
|
+
FormResultController = _ts_decorate([
|
|
124
|
+
(0, _swagger.ApiTags)('Form Builder - Results'),
|
|
125
|
+
(0, _common.Controller)('form-builder/result'),
|
|
126
|
+
_ts_param(0, (0, _common.Inject)(_formresultservice.FormResultService)),
|
|
127
|
+
_ts_metadata("design:type", Function),
|
|
128
|
+
_ts_metadata("design:paramtypes", [
|
|
129
|
+
typeof _formresultservice.FormResultService === "undefined" ? Object : _formresultservice.FormResultService
|
|
130
|
+
])
|
|
131
|
+
], FormResultController);
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "FormController", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return FormController;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _classes = require("@flusys/nestjs-shared/classes");
|
|
12
|
+
const _decorators = require("@flusys/nestjs-shared/decorators");
|
|
13
|
+
const _guards = require("@flusys/nestjs-shared/guards");
|
|
14
|
+
const _interfaces = require("@flusys/nestjs-shared/interfaces");
|
|
15
|
+
const _common = require("@nestjs/common");
|
|
16
|
+
const _swagger = require("@nestjs/swagger");
|
|
17
|
+
const _dtos = require("../dtos");
|
|
18
|
+
const _formaccesstypeenum = require("../enums/form-access-type.enum");
|
|
19
|
+
const _formservice = require("../services/form.service");
|
|
20
|
+
function _define_property(obj, key, value) {
|
|
21
|
+
if (key in obj) {
|
|
22
|
+
Object.defineProperty(obj, key, {
|
|
23
|
+
value: value,
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
writable: true
|
|
27
|
+
});
|
|
28
|
+
} else {
|
|
29
|
+
obj[key] = value;
|
|
30
|
+
}
|
|
31
|
+
return obj;
|
|
32
|
+
}
|
|
33
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
34
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
35
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
36
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
37
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
38
|
+
}
|
|
39
|
+
function _ts_metadata(k, v) {
|
|
40
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
41
|
+
}
|
|
42
|
+
function _ts_param(paramIndex, decorator) {
|
|
43
|
+
return function(target, key) {
|
|
44
|
+
decorator(target, key, paramIndex);
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
let FormController = class FormController extends (0, _classes.createApiController)(_dtos.CreateFormDto, _dtos.UpdateFormDto, _dtos.FormResponseDto, {
|
|
48
|
+
security: 'jwt'
|
|
49
|
+
}) {
|
|
50
|
+
// ==================== Public Endpoints ====================
|
|
51
|
+
/**
|
|
52
|
+
* Get form access info (no authentication required)
|
|
53
|
+
* Returns access type and requirements for the form
|
|
54
|
+
*/ async getFormAccessInfo(id) {
|
|
55
|
+
return this.formService.getFormAccessInfo(id);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get public form for submission (no authentication required)
|
|
59
|
+
* Only works for forms with accessType = 'public'
|
|
60
|
+
*/ async getPublicForm(id) {
|
|
61
|
+
return this.formService.getPublicForm(id);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Get form for authenticated submission
|
|
65
|
+
* Works for 'authenticated' and 'action_group' access types
|
|
66
|
+
*/ async getAuthenticatedForm(id, user) {
|
|
67
|
+
return this.formService.getAuthenticatedForm(id, user);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Get form by slug
|
|
71
|
+
*/ async getBySlug(slug, _user) {
|
|
72
|
+
return this.formService.getBySlug(slug);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Get public form by slug (no authentication required)
|
|
76
|
+
*/ async getPublicFormBySlug(slug) {
|
|
77
|
+
const form = await this.formService.getBySlug(slug);
|
|
78
|
+
if (!form) return null;
|
|
79
|
+
// Only return if form is public and active
|
|
80
|
+
if (form.accessType !== _formaccesstypeenum.FormAccessType.PUBLIC || !form.isActive) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
id: form.id,
|
|
85
|
+
name: form.name,
|
|
86
|
+
description: form.description,
|
|
87
|
+
schema: form.schema,
|
|
88
|
+
schemaVersion: form.schemaVersion
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
constructor(formService){
|
|
92
|
+
super(formService), _define_property(this, "formService", void 0), this.formService = formService;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
_ts_decorate([
|
|
96
|
+
(0, _common.Post)('access-info/:id'),
|
|
97
|
+
(0, _decorators.Public)(),
|
|
98
|
+
(0, _common.HttpCode)(_common.HttpStatus.OK),
|
|
99
|
+
(0, _swagger.ApiOperation)({
|
|
100
|
+
summary: 'Get form access info (no auth required)'
|
|
101
|
+
}),
|
|
102
|
+
_ts_param(0, (0, _common.Param)('id')),
|
|
103
|
+
_ts_metadata("design:type", Function),
|
|
104
|
+
_ts_metadata("design:paramtypes", [
|
|
105
|
+
String
|
|
106
|
+
]),
|
|
107
|
+
_ts_metadata("design:returntype", Promise)
|
|
108
|
+
], FormController.prototype, "getFormAccessInfo", null);
|
|
109
|
+
_ts_decorate([
|
|
110
|
+
(0, _common.Post)('public/:id'),
|
|
111
|
+
(0, _decorators.Public)(),
|
|
112
|
+
(0, _common.HttpCode)(_common.HttpStatus.OK),
|
|
113
|
+
(0, _swagger.ApiOperation)({
|
|
114
|
+
summary: 'Get public form for submission (no auth required)'
|
|
115
|
+
}),
|
|
116
|
+
_ts_param(0, (0, _common.Param)('id')),
|
|
117
|
+
_ts_metadata("design:type", Function),
|
|
118
|
+
_ts_metadata("design:paramtypes", [
|
|
119
|
+
String
|
|
120
|
+
]),
|
|
121
|
+
_ts_metadata("design:returntype", Promise)
|
|
122
|
+
], FormController.prototype, "getPublicForm", null);
|
|
123
|
+
_ts_decorate([
|
|
124
|
+
(0, _common.Post)('authenticated/:id'),
|
|
125
|
+
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
126
|
+
(0, _swagger.ApiBearerAuth)(),
|
|
127
|
+
(0, _common.HttpCode)(_common.HttpStatus.OK),
|
|
128
|
+
(0, _swagger.ApiOperation)({
|
|
129
|
+
summary: 'Get form for authenticated submission'
|
|
130
|
+
}),
|
|
131
|
+
_ts_param(0, (0, _common.Param)('id')),
|
|
132
|
+
_ts_param(1, (0, _decorators.CurrentUser)()),
|
|
133
|
+
_ts_metadata("design:type", Function),
|
|
134
|
+
_ts_metadata("design:paramtypes", [
|
|
135
|
+
String,
|
|
136
|
+
typeof _interfaces.ILoggedUserInfo === "undefined" ? Object : _interfaces.ILoggedUserInfo
|
|
137
|
+
]),
|
|
138
|
+
_ts_metadata("design:returntype", Promise)
|
|
139
|
+
], FormController.prototype, "getAuthenticatedForm", null);
|
|
140
|
+
_ts_decorate([
|
|
141
|
+
(0, _common.Post)('by-slug/:slug'),
|
|
142
|
+
(0, _common.HttpCode)(_common.HttpStatus.OK),
|
|
143
|
+
(0, _swagger.ApiOperation)({
|
|
144
|
+
summary: 'Get form by slug'
|
|
145
|
+
}),
|
|
146
|
+
_ts_param(0, (0, _common.Param)('slug')),
|
|
147
|
+
_ts_param(1, (0, _decorators.CurrentUser)()),
|
|
148
|
+
_ts_metadata("design:type", Function),
|
|
149
|
+
_ts_metadata("design:paramtypes", [
|
|
150
|
+
String,
|
|
151
|
+
typeof _interfaces.ILoggedUserInfo === "undefined" ? Object : _interfaces.ILoggedUserInfo
|
|
152
|
+
]),
|
|
153
|
+
_ts_metadata("design:returntype", Promise)
|
|
154
|
+
], FormController.prototype, "getBySlug", null);
|
|
155
|
+
_ts_decorate([
|
|
156
|
+
(0, _common.Post)('public/by-slug/:slug'),
|
|
157
|
+
(0, _decorators.Public)(),
|
|
158
|
+
(0, _common.HttpCode)(_common.HttpStatus.OK),
|
|
159
|
+
(0, _swagger.ApiOperation)({
|
|
160
|
+
summary: 'Get public form by slug (no auth required)'
|
|
161
|
+
}),
|
|
162
|
+
_ts_param(0, (0, _common.Param)('slug')),
|
|
163
|
+
_ts_metadata("design:type", Function),
|
|
164
|
+
_ts_metadata("design:paramtypes", [
|
|
165
|
+
String
|
|
166
|
+
]),
|
|
167
|
+
_ts_metadata("design:returntype", Promise)
|
|
168
|
+
], FormController.prototype, "getPublicFormBySlug", null);
|
|
169
|
+
FormController = _ts_decorate([
|
|
170
|
+
(0, _swagger.ApiTags)('Form Builder - Forms'),
|
|
171
|
+
(0, _common.Controller)('form-builder/form'),
|
|
172
|
+
_ts_param(0, (0, _common.Inject)(_formservice.FormService)),
|
|
173
|
+
_ts_metadata("design:type", Function),
|
|
174
|
+
_ts_metadata("design:paramtypes", [
|
|
175
|
+
typeof _formservice.FormService === "undefined" ? Object : _formservice.FormService
|
|
176
|
+
])
|
|
177
|
+
], FormController);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_export_star(require("./form.controller"), exports);
|
|
6
|
+
_export_star(require("./form-result.controller"), exports);
|
|
7
|
+
function _export_star(from, to) {
|
|
8
|
+
Object.keys(from).forEach(function(k) {
|
|
9
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
10
|
+
Object.defineProperty(to, k, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function() {
|
|
13
|
+
return from[k];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
return from;
|
|
19
|
+
}
|