@flusys/nestjs-form-builder 0.1.0-beta.3 → 1.1.0-beta
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.constants.js +3 -12
- package/cjs/config/index.js +0 -1
- package/cjs/controllers/form-result.controller.js +71 -4
- package/cjs/controllers/form.controller.js +1 -2
- package/cjs/docs/form-builder-swagger.config.js +241 -0
- package/cjs/docs/index.js +11 -0
- package/cjs/dtos/form-result.dto.js +34 -0
- package/cjs/index.js +1 -0
- package/cjs/modules/form-builder.module.js +4 -5
- package/cjs/{config → services}/form-builder-config.service.js +1 -1
- package/cjs/services/form-builder-datasource.provider.js +4 -5
- package/cjs/services/form-result.service.js +146 -30
- package/cjs/services/form.service.js +6 -31
- package/cjs/services/index.js +1 -0
- package/cjs/utils/computed-field.utils.js +211 -0
- package/cjs/utils/index.js +19 -0
- package/cjs/utils/permission.utils.js +57 -0
- package/config/form-builder.constants.d.ts +0 -1
- package/config/index.d.ts +0 -1
- package/controllers/form-result.controller.d.ts +4 -1
- package/docs/form-builder-swagger.config.d.ts +3 -0
- package/docs/index.d.ts +1 -0
- package/dtos/form-result.dto.d.ts +7 -0
- package/fesm/config/form-builder.constants.js +0 -3
- package/fesm/config/index.js +0 -1
- package/fesm/controllers/form-result.controller.js +72 -5
- package/fesm/controllers/form.controller.js +1 -2
- package/fesm/docs/form-builder-swagger.config.js +237 -0
- package/fesm/docs/index.js +1 -0
- package/fesm/dtos/form-result.dto.js +32 -0
- package/fesm/index.js +2 -0
- package/fesm/modules/form-builder.module.js +2 -3
- package/fesm/{config → services}/form-builder-config.service.js +1 -1
- package/fesm/services/form-builder-datasource.provider.js +4 -5
- package/fesm/services/form-result.service.js +147 -31
- package/fesm/services/form.service.js +7 -32
- package/fesm/services/index.js +1 -0
- package/fesm/utils/computed-field.utils.js +207 -0
- package/fesm/utils/index.js +2 -0
- package/fesm/utils/permission.utils.js +61 -0
- package/index.d.ts +1 -0
- package/package.json +8 -3
- package/services/form-result.service.d.ts +4 -4
- package/services/form.service.d.ts +1 -4
- package/services/index.d.ts +1 -0
- package/utils/computed-field.utils.d.ts +48 -0
- package/utils/index.d.ts +2 -0
- package/utils/permission.utils.d.ts +6 -0
- /package/{config → services}/form-builder-config.service.d.ts +0 -0
|
@@ -4,19 +4,10 @@
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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 () {
|
|
7
|
+
Object.defineProperty(exports, "FORM_BUILDER_MODULE_OPTIONS", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function() {
|
|
18
10
|
return FORM_BUILDER_MODULE_OPTIONS;
|
|
19
11
|
}
|
|
20
12
|
});
|
|
21
13
|
const FORM_BUILDER_MODULE_OPTIONS = 'FORM_BUILDER_MODULE_OPTIONS';
|
|
22
|
-
const FORM_BUILDER_DATA_SOURCE_PROVIDER = 'FORM_BUILDER_DATA_SOURCE_PROVIDER';
|
package/cjs/config/index.js
CHANGED
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
_export_star(require("./form-builder.constants"), exports);
|
|
6
|
-
_export_star(require("./form-builder-config.service"), exports);
|
|
7
6
|
function _export_star(from, to) {
|
|
8
7
|
Object.keys(from).forEach(function(k) {
|
|
9
8
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
@@ -46,10 +46,9 @@ function _ts_param(paramIndex, decorator) {
|
|
|
46
46
|
let FormResultController = class FormResultController extends (0, _classes.createApiController)(_dtos.CreateFormResultDto, _dtos.UpdateFormResultDto, _dtos.FormResultResponseDto, {
|
|
47
47
|
security: 'jwt'
|
|
48
48
|
}) {
|
|
49
|
-
//
|
|
49
|
+
// Submit Endpoints
|
|
50
50
|
/**
|
|
51
51
|
* Submit form with authentication
|
|
52
|
-
* Supports authenticated and action_group access types
|
|
53
52
|
*/ async submitForm(dto, user) {
|
|
54
53
|
return this.formResultService.submitForm(dto, user, false);
|
|
55
54
|
}
|
|
@@ -59,15 +58,32 @@ let FormResultController = class FormResultController extends (0, _classes.creat
|
|
|
59
58
|
*/ async submitPublicForm(dto) {
|
|
60
59
|
return this.formResultService.submitForm(dto, null, true);
|
|
61
60
|
}
|
|
62
|
-
//
|
|
61
|
+
// Draft Endpoints
|
|
63
62
|
/**
|
|
64
|
-
* Get
|
|
63
|
+
* Get current user's draft for a form
|
|
64
|
+
*/ async getMyDraft(dto, user) {
|
|
65
|
+
return this.formResultService.getMyDraft(dto.formId, user);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Update existing draft or convert to final submission
|
|
69
|
+
*/ async updateDraft(dto, user) {
|
|
70
|
+
return this.formResultService.updateDraft(dto.draftId, dto, user);
|
|
71
|
+
}
|
|
72
|
+
// Query Endpoints
|
|
73
|
+
/**
|
|
74
|
+
* Get results by form ID with pagination
|
|
65
75
|
*/ async getByFormId(dto, user) {
|
|
66
76
|
return this.formResultService.getByFormId(dto.formId, user, {
|
|
67
77
|
page: dto.page ?? 0,
|
|
68
78
|
pageSize: dto.pageSize ?? 10
|
|
69
79
|
});
|
|
70
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Check if current user has already submitted this form (non-draft)
|
|
83
|
+
* Used for single response mode
|
|
84
|
+
*/ async hasUserSubmitted(dto, user) {
|
|
85
|
+
return this.formResultService.hasUserSubmitted(dto.formId, user);
|
|
86
|
+
}
|
|
71
87
|
constructor(formResultService){
|
|
72
88
|
super(formResultService), _define_property(this, "formResultService", void 0), this.formResultService = formResultService;
|
|
73
89
|
}
|
|
@@ -103,6 +119,40 @@ _ts_decorate([
|
|
|
103
119
|
]),
|
|
104
120
|
_ts_metadata("design:returntype", Promise)
|
|
105
121
|
], FormResultController.prototype, "submitPublicForm", null);
|
|
122
|
+
_ts_decorate([
|
|
123
|
+
(0, _common.Post)('my-draft'),
|
|
124
|
+
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
125
|
+
(0, _swagger.ApiBearerAuth)(),
|
|
126
|
+
(0, _common.HttpCode)(_common.HttpStatus.OK),
|
|
127
|
+
(0, _swagger.ApiOperation)({
|
|
128
|
+
summary: 'Get my draft for a form'
|
|
129
|
+
}),
|
|
130
|
+
_ts_param(0, (0, _common.Body)()),
|
|
131
|
+
_ts_param(1, (0, _decorators.CurrentUser)()),
|
|
132
|
+
_ts_metadata("design:type", Function),
|
|
133
|
+
_ts_metadata("design:paramtypes", [
|
|
134
|
+
typeof _dtos.GetMyDraftDto === "undefined" ? Object : _dtos.GetMyDraftDto,
|
|
135
|
+
typeof _interfaces.ILoggedUserInfo === "undefined" ? Object : _interfaces.ILoggedUserInfo
|
|
136
|
+
]),
|
|
137
|
+
_ts_metadata("design:returntype", Promise)
|
|
138
|
+
], FormResultController.prototype, "getMyDraft", null);
|
|
139
|
+
_ts_decorate([
|
|
140
|
+
(0, _common.Post)('update-draft'),
|
|
141
|
+
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
142
|
+
(0, _swagger.ApiBearerAuth)(),
|
|
143
|
+
(0, _common.HttpCode)(_common.HttpStatus.OK),
|
|
144
|
+
(0, _swagger.ApiOperation)({
|
|
145
|
+
summary: 'Update existing draft'
|
|
146
|
+
}),
|
|
147
|
+
_ts_param(0, (0, _common.Body)()),
|
|
148
|
+
_ts_param(1, (0, _decorators.CurrentUser)()),
|
|
149
|
+
_ts_metadata("design:type", Function),
|
|
150
|
+
_ts_metadata("design:paramtypes", [
|
|
151
|
+
typeof _dtos.UpdateDraftDto === "undefined" ? Object : _dtos.UpdateDraftDto,
|
|
152
|
+
typeof _interfaces.ILoggedUserInfo === "undefined" ? Object : _interfaces.ILoggedUserInfo
|
|
153
|
+
]),
|
|
154
|
+
_ts_metadata("design:returntype", Promise)
|
|
155
|
+
], FormResultController.prototype, "updateDraft", null);
|
|
106
156
|
_ts_decorate([
|
|
107
157
|
(0, _common.Post)('by-form'),
|
|
108
158
|
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
@@ -120,6 +170,23 @@ _ts_decorate([
|
|
|
120
170
|
]),
|
|
121
171
|
_ts_metadata("design:returntype", Promise)
|
|
122
172
|
], FormResultController.prototype, "getByFormId", null);
|
|
173
|
+
_ts_decorate([
|
|
174
|
+
(0, _common.Post)('has-submitted'),
|
|
175
|
+
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
176
|
+
(0, _swagger.ApiBearerAuth)(),
|
|
177
|
+
(0, _common.HttpCode)(_common.HttpStatus.OK),
|
|
178
|
+
(0, _swagger.ApiOperation)({
|
|
179
|
+
summary: 'Check if user has submitted form'
|
|
180
|
+
}),
|
|
181
|
+
_ts_param(0, (0, _common.Body)()),
|
|
182
|
+
_ts_param(1, (0, _decorators.CurrentUser)()),
|
|
183
|
+
_ts_metadata("design:type", Function),
|
|
184
|
+
_ts_metadata("design:paramtypes", [
|
|
185
|
+
typeof _dtos.GetMyDraftDto === "undefined" ? Object : _dtos.GetMyDraftDto,
|
|
186
|
+
typeof _interfaces.ILoggedUserInfo === "undefined" ? Object : _interfaces.ILoggedUserInfo
|
|
187
|
+
]),
|
|
188
|
+
_ts_metadata("design:returntype", Promise)
|
|
189
|
+
], FormResultController.prototype, "hasUserSubmitted", null);
|
|
123
190
|
FormResultController = _ts_decorate([
|
|
124
191
|
(0, _swagger.ApiTags)('Form Builder - Results'),
|
|
125
192
|
(0, _common.Controller)('form-builder/result'),
|
|
@@ -47,10 +47,9 @@ function _ts_param(paramIndex, decorator) {
|
|
|
47
47
|
let FormController = class FormController extends (0, _classes.createApiController)(_dtos.CreateFormDto, _dtos.UpdateFormDto, _dtos.FormResponseDto, {
|
|
48
48
|
security: 'jwt'
|
|
49
49
|
}) {
|
|
50
|
-
//
|
|
50
|
+
// Public Endpoints
|
|
51
51
|
/**
|
|
52
52
|
* Get form access info (no authentication required)
|
|
53
|
-
* Returns access type and requirements for the form
|
|
54
53
|
*/ async getFormAccessInfo(id) {
|
|
55
54
|
return this.formService.getFormAccessInfo(id);
|
|
56
55
|
}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "formBuilderSwaggerConfig", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return formBuilderSwaggerConfig;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
/** Schema properties to exclude when company feature is disabled */ const COMPANY_SCHEMA_EXCLUSIONS = [
|
|
12
|
+
{
|
|
13
|
+
schemaName: 'CreateFormDto',
|
|
14
|
+
properties: [
|
|
15
|
+
'companyId'
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
schemaName: 'UpdateFormDto',
|
|
20
|
+
properties: [
|
|
21
|
+
'companyId'
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
schemaName: 'FormQueryDto',
|
|
26
|
+
properties: [
|
|
27
|
+
'companyId'
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
schemaName: 'FormResponseDto',
|
|
32
|
+
properties: [
|
|
33
|
+
'companyId'
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
];
|
|
37
|
+
function formBuilderSwaggerConfig(bootstrapConfig) {
|
|
38
|
+
const enableCompanyFeature = bootstrapConfig?.enableCompanyFeature ?? true;
|
|
39
|
+
return {
|
|
40
|
+
title: 'Form Builder API',
|
|
41
|
+
description: enableCompanyFeature ? `
|
|
42
|
+
# Form Builder API
|
|
43
|
+
|
|
44
|
+
Dynamic form builder with schema versioning, conditional logic, and access control.
|
|
45
|
+
|
|
46
|
+
## Features
|
|
47
|
+
|
|
48
|
+
### 📋 Form Management
|
|
49
|
+
- Create and manage dynamic forms
|
|
50
|
+
- Schema versioning for form updates
|
|
51
|
+
- Slug-based URLs for sharing
|
|
52
|
+
- **Company isolation**
|
|
53
|
+
|
|
54
|
+
### 🔒 Access Control
|
|
55
|
+
- **Public**: No authentication required
|
|
56
|
+
- **Authenticated**: JWT authentication required
|
|
57
|
+
- **Action Group**: Permission-based access via IAM
|
|
58
|
+
|
|
59
|
+
### 📊 Form Results
|
|
60
|
+
- Submit and track form responses
|
|
61
|
+
- Draft support for partial submissions
|
|
62
|
+
- Schema snapshot preservation
|
|
63
|
+
- **Company-level permissions**
|
|
64
|
+
|
|
65
|
+
### 🔀 Conditional Logic
|
|
66
|
+
- Show/hide fields based on values
|
|
67
|
+
- Show/hide sections dynamically
|
|
68
|
+
- Jump to sections based on conditions
|
|
69
|
+
- Conditional required validation
|
|
70
|
+
|
|
71
|
+
## Multi-Tenant Support
|
|
72
|
+
|
|
73
|
+
Forms and results are automatically isolated by:
|
|
74
|
+
- **Company ID**: Company-level data isolation
|
|
75
|
+
|
|
76
|
+
All queries automatically filter by current user's company context.
|
|
77
|
+
|
|
78
|
+
## Form Access Types
|
|
79
|
+
|
|
80
|
+
### Public Forms
|
|
81
|
+
- No authentication required
|
|
82
|
+
- Anyone can view and submit
|
|
83
|
+
- Use \`/form-builder/form/public/:id\` to get form
|
|
84
|
+
- Use \`/form-builder/result/submit-public\` to submit
|
|
85
|
+
|
|
86
|
+
### Authenticated Forms
|
|
87
|
+
- JWT authentication required
|
|
88
|
+
- User must be logged in
|
|
89
|
+
- Use \`/form-builder/form/authenticated/:id\` to get form
|
|
90
|
+
- Use \`/form-builder/result/submit\` to submit
|
|
91
|
+
|
|
92
|
+
### Action Group Forms
|
|
93
|
+
- Permission-based access via IAM
|
|
94
|
+
- User must have specific permissions
|
|
95
|
+
- Use \`/form-builder/form/authenticated/:id\` to get form
|
|
96
|
+
- Use \`/form-builder/result/submit\` to submit
|
|
97
|
+
|
|
98
|
+
## Draft Support
|
|
99
|
+
|
|
100
|
+
Save form progress and complete later:
|
|
101
|
+
1. Submit with \`isDraft: true\` to save draft
|
|
102
|
+
2. Get draft with \`/form-builder/result/my-draft\`
|
|
103
|
+
3. Update draft with \`/form-builder/result/update-draft\`
|
|
104
|
+
4. Finalize by setting \`isDraft: false\`
|
|
105
|
+
|
|
106
|
+
## Response Format
|
|
107
|
+
|
|
108
|
+
All endpoints return standardized responses with success status, data, message, and timestamp.
|
|
109
|
+
|
|
110
|
+
## Error Handling
|
|
111
|
+
|
|
112
|
+
Errors return structured responses with success false, error message, error code, and timestamp.
|
|
113
|
+
|
|
114
|
+
## Common Error Codes
|
|
115
|
+
|
|
116
|
+
- **400 Bad Request**: Invalid input data
|
|
117
|
+
- **401 Unauthorized**: Missing or invalid authentication
|
|
118
|
+
- **403 Forbidden**: Insufficient permissions or wrong access type
|
|
119
|
+
- **404 Not Found**: Form or result not found
|
|
120
|
+
- **500 Internal Server Error**: Server error
|
|
121
|
+
|
|
122
|
+
## API Endpoints
|
|
123
|
+
|
|
124
|
+
All form builder endpoints are prefixed with \`/form-builder\`:
|
|
125
|
+
- \`/form-builder/form/*\` - Form management
|
|
126
|
+
- \`/form-builder/result/*\` - Form result/submission management
|
|
127
|
+
|
|
128
|
+
## Examples
|
|
129
|
+
|
|
130
|
+
### Get Form Access Info
|
|
131
|
+
|
|
132
|
+
POST /form-builder/form/access-info/:id
|
|
133
|
+
Returns access type and requirements (no auth required)
|
|
134
|
+
|
|
135
|
+
### Submit Public Form
|
|
136
|
+
|
|
137
|
+
POST /form-builder/result/submit-public with JSON body containing formId and formData
|
|
138
|
+
|
|
139
|
+
### Submit Authenticated Form
|
|
140
|
+
|
|
141
|
+
POST /form-builder/result/submit with JWT token and JSON body containing formId and formData
|
|
142
|
+
` : `
|
|
143
|
+
# Form Builder API
|
|
144
|
+
|
|
145
|
+
Dynamic form builder with schema versioning, conditional logic, and access control.
|
|
146
|
+
|
|
147
|
+
## Features
|
|
148
|
+
|
|
149
|
+
### 📋 Form Management
|
|
150
|
+
- Create and manage dynamic forms
|
|
151
|
+
- Schema versioning for form updates
|
|
152
|
+
- Slug-based URLs for sharing
|
|
153
|
+
|
|
154
|
+
### 🔒 Access Control
|
|
155
|
+
- **Public**: No authentication required
|
|
156
|
+
- **Authenticated**: JWT authentication required
|
|
157
|
+
- **Action Group**: Permission-based access via IAM
|
|
158
|
+
|
|
159
|
+
### 📊 Form Results
|
|
160
|
+
- Submit and track form responses
|
|
161
|
+
- Draft support for partial submissions
|
|
162
|
+
- Schema snapshot preservation
|
|
163
|
+
|
|
164
|
+
### 🔀 Conditional Logic
|
|
165
|
+
- Show/hide fields based on values
|
|
166
|
+
- Show/hide sections dynamically
|
|
167
|
+
- Jump to sections based on conditions
|
|
168
|
+
- Conditional required validation
|
|
169
|
+
|
|
170
|
+
## Form Access Types
|
|
171
|
+
|
|
172
|
+
### Public Forms
|
|
173
|
+
- No authentication required
|
|
174
|
+
- Anyone can view and submit
|
|
175
|
+
- Use \`/form-builder/form/public/:id\` to get form
|
|
176
|
+
- Use \`/form-builder/result/submit-public\` to submit
|
|
177
|
+
|
|
178
|
+
### Authenticated Forms
|
|
179
|
+
- JWT authentication required
|
|
180
|
+
- User must be logged in
|
|
181
|
+
- Use \`/form-builder/form/authenticated/:id\` to get form
|
|
182
|
+
- Use \`/form-builder/result/submit\` to submit
|
|
183
|
+
|
|
184
|
+
### Action Group Forms
|
|
185
|
+
- Permission-based access via IAM
|
|
186
|
+
- User must have specific permissions
|
|
187
|
+
- Use \`/form-builder/form/authenticated/:id\` to get form
|
|
188
|
+
- Use \`/form-builder/result/submit\` to submit
|
|
189
|
+
|
|
190
|
+
## Draft Support
|
|
191
|
+
|
|
192
|
+
Save form progress and complete later:
|
|
193
|
+
1. Submit with \`isDraft: true\` to save draft
|
|
194
|
+
2. Get draft with \`/form-builder/result/my-draft\`
|
|
195
|
+
3. Update draft with \`/form-builder/result/update-draft\`
|
|
196
|
+
4. Finalize by setting \`isDraft: false\`
|
|
197
|
+
|
|
198
|
+
## Response Format
|
|
199
|
+
|
|
200
|
+
All endpoints return standardized responses with success status, data, message, and timestamp.
|
|
201
|
+
|
|
202
|
+
## Error Handling
|
|
203
|
+
|
|
204
|
+
Errors return structured responses with success false, error message, error code, and timestamp.
|
|
205
|
+
|
|
206
|
+
## Common Error Codes
|
|
207
|
+
|
|
208
|
+
- **400 Bad Request**: Invalid input data
|
|
209
|
+
- **401 Unauthorized**: Missing or invalid authentication
|
|
210
|
+
- **403 Forbidden**: Insufficient permissions or wrong access type
|
|
211
|
+
- **404 Not Found**: Form or result not found
|
|
212
|
+
- **500 Internal Server Error**: Server error
|
|
213
|
+
|
|
214
|
+
## API Endpoints
|
|
215
|
+
|
|
216
|
+
All form builder endpoints are prefixed with \`/form-builder\`:
|
|
217
|
+
- \`/form-builder/form/*\` - Form management
|
|
218
|
+
- \`/form-builder/result/*\` - Form result/submission management
|
|
219
|
+
|
|
220
|
+
## Examples
|
|
221
|
+
|
|
222
|
+
### Get Form Access Info
|
|
223
|
+
|
|
224
|
+
POST /form-builder/form/access-info/:id
|
|
225
|
+
Returns access type and requirements (no auth required)
|
|
226
|
+
|
|
227
|
+
### Submit Public Form
|
|
228
|
+
|
|
229
|
+
POST /form-builder/result/submit-public with JSON body containing formId and formData
|
|
230
|
+
|
|
231
|
+
### Submit Authenticated Form
|
|
232
|
+
|
|
233
|
+
POST /form-builder/result/submit with JWT token and JSON body containing formId and formData
|
|
234
|
+
`,
|
|
235
|
+
version: '1.0',
|
|
236
|
+
path: 'api/docs/form-builder',
|
|
237
|
+
bearerAuth: true,
|
|
238
|
+
excludeTags: [],
|
|
239
|
+
excludeSchemaProperties: enableCompanyFeature ? undefined : COMPANY_SCHEMA_EXCLUSIONS
|
|
240
|
+
};
|
|
241
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "formBuilderSwaggerConfig", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return _formbuilderswaggerconfig.formBuilderSwaggerConfig;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _formbuilderswaggerconfig = require("./form-builder-swagger.config");
|
|
@@ -18,12 +18,18 @@ _export(exports, {
|
|
|
18
18
|
get FormResultResponseDto () {
|
|
19
19
|
return FormResultResponseDto;
|
|
20
20
|
},
|
|
21
|
+
get GetMyDraftDto () {
|
|
22
|
+
return GetMyDraftDto;
|
|
23
|
+
},
|
|
21
24
|
get GetResultsByFormDto () {
|
|
22
25
|
return GetResultsByFormDto;
|
|
23
26
|
},
|
|
24
27
|
get SubmitFormDto () {
|
|
25
28
|
return SubmitFormDto;
|
|
26
29
|
},
|
|
30
|
+
get UpdateDraftDto () {
|
|
31
|
+
return UpdateDraftDto;
|
|
32
|
+
},
|
|
27
33
|
get UpdateFormResultDto () {
|
|
28
34
|
return UpdateFormResultDto;
|
|
29
35
|
}
|
|
@@ -180,6 +186,34 @@ _ts_decorate([
|
|
|
180
186
|
(0, _classvalidator.IsOptional)(),
|
|
181
187
|
_ts_metadata("design:type", String)
|
|
182
188
|
], FormResultQueryDto.prototype, "submittedById", void 0);
|
|
189
|
+
let GetMyDraftDto = class GetMyDraftDto {
|
|
190
|
+
constructor(){
|
|
191
|
+
_define_property(this, "formId", void 0);
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
_ts_decorate([
|
|
195
|
+
(0, _swagger.ApiProperty)({
|
|
196
|
+
description: 'Form ID to get draft for',
|
|
197
|
+
example: '123e4567-e89b-12d3-a456-426614174000'
|
|
198
|
+
}),
|
|
199
|
+
(0, _classvalidator.IsUUID)(),
|
|
200
|
+
(0, _classvalidator.IsNotEmpty)(),
|
|
201
|
+
_ts_metadata("design:type", String)
|
|
202
|
+
], GetMyDraftDto.prototype, "formId", void 0);
|
|
203
|
+
let UpdateDraftDto = class UpdateDraftDto extends SubmitFormDto {
|
|
204
|
+
constructor(...args){
|
|
205
|
+
super(...args), _define_property(this, "draftId", void 0);
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
_ts_decorate([
|
|
209
|
+
(0, _swagger.ApiProperty)({
|
|
210
|
+
description: 'Draft ID to update',
|
|
211
|
+
example: '123e4567-e89b-12d3-a456-426614174000'
|
|
212
|
+
}),
|
|
213
|
+
(0, _classvalidator.IsUUID)(),
|
|
214
|
+
(0, _classvalidator.IsNotEmpty)(),
|
|
215
|
+
_ts_metadata("design:type", String)
|
|
216
|
+
], UpdateDraftDto.prototype, "draftId", void 0);
|
|
183
217
|
let GetResultsByFormDto = class GetResultsByFormDto {
|
|
184
218
|
constructor(){
|
|
185
219
|
_define_property(this, "formId", void 0);
|
package/cjs/index.js
CHANGED
|
@@ -11,6 +11,7 @@ _export_star(require("./enums/index"), exports);
|
|
|
11
11
|
_export_star(require("./interfaces/index"), exports);
|
|
12
12
|
_export_star(require("./modules/index"), exports);
|
|
13
13
|
_export_star(require("./services/index"), exports);
|
|
14
|
+
_export_star(require("./utils/index"), exports);
|
|
14
15
|
function _export_star(from, to) {
|
|
15
16
|
Object.keys(from).forEach(function(k) {
|
|
16
17
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
@@ -10,7 +10,6 @@ Object.defineProperty(exports, "FormBuilderModule", {
|
|
|
10
10
|
});
|
|
11
11
|
const _modules = require("@flusys/nestjs-shared/modules");
|
|
12
12
|
const _common = require("@nestjs/common");
|
|
13
|
-
const _formbuilderconfigservice = require("../config/form-builder-config.service");
|
|
14
13
|
const _formbuilderconstants = require("../config/form-builder.constants");
|
|
15
14
|
const _controllers = require("../controllers");
|
|
16
15
|
const _services = require("../services");
|
|
@@ -36,7 +35,7 @@ let FormBuilderModule = class FormBuilderModule {
|
|
|
36
35
|
controllers: options.includeController !== false ? controllers : [],
|
|
37
36
|
providers,
|
|
38
37
|
exports: [
|
|
39
|
-
|
|
38
|
+
_services.FormBuilderConfigService,
|
|
40
39
|
_services.FormBuilderDataSourceProvider,
|
|
41
40
|
_services.FormService,
|
|
42
41
|
_services.FormResultService
|
|
@@ -62,14 +61,14 @@ let FormBuilderModule = class FormBuilderModule {
|
|
|
62
61
|
...this.getProviders(options, false)
|
|
63
62
|
],
|
|
64
63
|
exports: [
|
|
65
|
-
|
|
64
|
+
_services.FormBuilderConfigService,
|
|
66
65
|
_services.FormBuilderDataSourceProvider,
|
|
67
66
|
_services.FormService,
|
|
68
67
|
_services.FormResultService
|
|
69
68
|
]
|
|
70
69
|
};
|
|
71
70
|
}
|
|
72
|
-
//
|
|
71
|
+
// Private Helper Methods
|
|
73
72
|
/**
|
|
74
73
|
* Get controllers
|
|
75
74
|
*/ static getControllers(options) {
|
|
@@ -84,7 +83,7 @@ let FormBuilderModule = class FormBuilderModule {
|
|
|
84
83
|
* @param includeOptionsProvider Whether to include the FORM_BUILDER_MODULE_OPTIONS provider
|
|
85
84
|
*/ static getProviders(options, includeOptionsProvider = true) {
|
|
86
85
|
const providers = [
|
|
87
|
-
|
|
86
|
+
_services.FormBuilderConfigService,
|
|
88
87
|
_services.FormBuilderDataSourceProvider,
|
|
89
88
|
_services.FormService,
|
|
90
89
|
_services.FormResultService
|
|
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "FormBuilderConfigService", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
const _common = require("@nestjs/common");
|
|
12
|
-
const _formbuilderconstants = require("
|
|
12
|
+
const _formbuilderconstants = require("../config/form-builder.constants");
|
|
13
13
|
const _formbuildermoduleinterface = require("../interfaces/form-builder-module.interface");
|
|
14
14
|
function _define_property(obj, key, value) {
|
|
15
15
|
if (key in obj) {
|
|
@@ -83,7 +83,7 @@ function _ts_param(paramIndex, decorator) {
|
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
85
|
let FormBuilderDataSourceProvider = class FormBuilderDataSourceProvider extends _modules.MultiTenantDataSourceService {
|
|
86
|
-
//
|
|
86
|
+
// Factory Methods
|
|
87
87
|
/**
|
|
88
88
|
* Build parent options from FormBuilderModuleOptions
|
|
89
89
|
*/ static buildParentOptions(options) {
|
|
@@ -92,7 +92,7 @@ let FormBuilderDataSourceProvider = class FormBuilderDataSourceProvider extends
|
|
|
92
92
|
defaultDatabaseConfig: options.config?.defaultDatabaseConfig
|
|
93
93
|
};
|
|
94
94
|
}
|
|
95
|
-
//
|
|
95
|
+
// Feature Flags
|
|
96
96
|
/**
|
|
97
97
|
* Get global enable company feature flag
|
|
98
98
|
*/ getEnableCompanyFeature() {
|
|
@@ -109,10 +109,9 @@ let FormBuilderDataSourceProvider = class FormBuilderDataSourceProvider extends
|
|
|
109
109
|
*/ getEnableCompanyFeatureForCurrentTenant() {
|
|
110
110
|
return this.getEnableCompanyFeatureForTenant(this.getCurrentTenant() ?? undefined);
|
|
111
111
|
}
|
|
112
|
-
//
|
|
112
|
+
// Entity Management
|
|
113
113
|
/**
|
|
114
114
|
* Get form builder entities based on company feature flag
|
|
115
|
-
* Note: FormResult is always the same - company context derived from Form via formId
|
|
116
115
|
*/ async getFormBuilderEntities(enableCompanyFeature) {
|
|
117
116
|
const enable = enableCompanyFeature ?? this.getEnableCompanyFeature();
|
|
118
117
|
const { Form, FormResult, FormWithCompany } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("../entities")));
|
|
@@ -127,7 +126,7 @@ let FormBuilderDataSourceProvider = class FormBuilderDataSourceProvider extends
|
|
|
127
126
|
FormResult
|
|
128
127
|
];
|
|
129
128
|
}
|
|
130
|
-
//
|
|
129
|
+
// Overrides
|
|
131
130
|
/**
|
|
132
131
|
* Override to dynamically set entities based on tenant config
|
|
133
132
|
*/ async createDataSourceFromConfig(config) {
|