@flusys/nestjs-form-builder 1.0.0-rc → 2.0.0
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/README.md +35 -8
- package/cjs/controllers/form-result.controller.js +8 -8
- package/cjs/docs/form-builder-swagger.config.js +6 -100
- package/cjs/dtos/form-result.dto.js +5 -53
- package/cjs/dtos/form.dto.js +20 -123
- package/cjs/entities/form-with-company.entity.js +12 -2
- package/cjs/entities/form.entity.js +103 -3
- package/cjs/entities/index.js +28 -16
- package/cjs/interfaces/form-result.interface.js +1 -6
- package/cjs/modules/form-builder.module.js +57 -83
- package/cjs/services/form-builder-config.service.js +2 -2
- package/cjs/services/form-builder-datasource.provider.js +11 -26
- package/cjs/services/form-result.service.js +81 -122
- package/cjs/services/form.service.js +33 -50
- package/cjs/utils/computed-field.utils.js +17 -29
- package/dtos/form-result.dto.d.ts +2 -8
- package/dtos/form.dto.d.ts +6 -21
- package/entities/form-with-company.entity.d.ts +2 -2
- package/entities/form.entity.d.ts +12 -2
- package/entities/index.d.ts +7 -2
- package/fesm/controllers/form-result.controller.js +9 -9
- package/fesm/docs/form-builder-swagger.config.js +6 -100
- package/fesm/dtos/form-result.dto.js +5 -53
- package/fesm/dtos/form.dto.js +21 -124
- package/fesm/entities/form-with-company.entity.js +12 -2
- package/fesm/entities/form.entity.js +104 -4
- package/fesm/entities/index.js +18 -24
- package/fesm/modules/form-builder.module.js +57 -83
- package/fesm/services/form-builder-config.service.js +2 -2
- package/fesm/services/form-builder-datasource.provider.js +11 -26
- package/fesm/services/form-result.service.js +81 -122
- package/fesm/services/form.service.js +33 -50
- package/fesm/utils/computed-field.utils.js +17 -29
- package/interfaces/form-result.interface.d.ts +2 -8
- package/interfaces/form.interface.d.ts +2 -8
- package/modules/form-builder.module.d.ts +4 -3
- package/package.json +3 -3
- package/services/form-builder-config.service.d.ts +2 -2
- package/services/form-builder-datasource.provider.d.ts +3 -6
- package/services/form-result.service.d.ts +4 -0
- package/services/form.service.d.ts +12 -10
- package/cjs/entities/form-base.entity.js +0 -113
- package/entities/form-base.entity.d.ts +0 -13
- package/fesm/entities/form-base.entity.js +0 -106
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
const enableCompanyFeature = bootstrapConfig?.enableCompanyFeature ?? true;
|
|
35
35
|
return {
|
|
36
36
|
title: 'Form Builder API',
|
|
37
|
-
description:
|
|
37
|
+
description: `
|
|
38
38
|
# Form Builder API
|
|
39
39
|
|
|
40
40
|
Dynamic form builder with schema versioning, conditional logic, and access control.
|
|
@@ -44,8 +44,7 @@ Dynamic form builder with schema versioning, conditional logic, and access contr
|
|
|
44
44
|
### 📋 Form Management
|
|
45
45
|
- Create and manage dynamic forms
|
|
46
46
|
- Schema versioning for form updates
|
|
47
|
-
- Slug-based URLs for sharing
|
|
48
|
-
- **Company isolation**
|
|
47
|
+
- Slug-based URLs for sharing${enableCompanyFeature ? '\n- **Company isolation**' : ''}
|
|
49
48
|
|
|
50
49
|
### 🔒 Access Control
|
|
51
50
|
- **Public**: No authentication required
|
|
@@ -55,114 +54,21 @@ Dynamic form builder with schema versioning, conditional logic, and access contr
|
|
|
55
54
|
### 📊 Form Results
|
|
56
55
|
- Submit and track form responses
|
|
57
56
|
- Draft support for partial submissions
|
|
58
|
-
- Schema snapshot preservation
|
|
59
|
-
- **Company-level permissions**
|
|
57
|
+
- Schema snapshot preservation${enableCompanyFeature ? '\n- **Company-level permissions**' : ''}
|
|
60
58
|
|
|
61
59
|
### 🔀 Conditional Logic
|
|
62
60
|
- Show/hide fields based on values
|
|
63
61
|
- Show/hide sections dynamically
|
|
64
62
|
- Jump to sections based on conditions
|
|
65
63
|
- Conditional required validation
|
|
66
|
-
|
|
64
|
+
${enableCompanyFeature ? `
|
|
67
65
|
## Multi-Tenant Support
|
|
68
66
|
|
|
69
67
|
Forms and results are automatically isolated by:
|
|
70
68
|
- **Company ID**: Company-level data isolation
|
|
71
69
|
|
|
72
70
|
All queries automatically filter by current user's company context.
|
|
73
|
-
|
|
74
|
-
## Form Access Types
|
|
75
|
-
|
|
76
|
-
### Public Forms
|
|
77
|
-
- No authentication required
|
|
78
|
-
- Anyone can view and submit
|
|
79
|
-
- Use \`/form-builder/form/public/:id\` to get form
|
|
80
|
-
- Use \`/form-builder/result/submit-public\` to submit
|
|
81
|
-
|
|
82
|
-
### Authenticated Forms
|
|
83
|
-
- JWT authentication required
|
|
84
|
-
- User must be logged in
|
|
85
|
-
- Use \`/form-builder/form/authenticated/:id\` to get form
|
|
86
|
-
- Use \`/form-builder/result/submit\` to submit
|
|
87
|
-
|
|
88
|
-
### Action Group Forms
|
|
89
|
-
- Permission-based access via IAM
|
|
90
|
-
- User must have specific permissions
|
|
91
|
-
- Use \`/form-builder/form/authenticated/:id\` to get form
|
|
92
|
-
- Use \`/form-builder/result/submit\` to submit
|
|
93
|
-
|
|
94
|
-
## Draft Support
|
|
95
|
-
|
|
96
|
-
Save form progress and complete later:
|
|
97
|
-
1. Submit with \`isDraft: true\` to save draft
|
|
98
|
-
2. Get draft with \`/form-builder/result/my-draft\`
|
|
99
|
-
3. Update draft with \`/form-builder/result/update-draft\`
|
|
100
|
-
4. Finalize by setting \`isDraft: false\`
|
|
101
|
-
|
|
102
|
-
## Response Format
|
|
103
|
-
|
|
104
|
-
All endpoints return standardized responses with success status, data, message, and timestamp.
|
|
105
|
-
|
|
106
|
-
## Error Handling
|
|
107
|
-
|
|
108
|
-
Errors return structured responses with success false, error message, error code, and timestamp.
|
|
109
|
-
|
|
110
|
-
## Common Error Codes
|
|
111
|
-
|
|
112
|
-
- **400 Bad Request**: Invalid input data
|
|
113
|
-
- **401 Unauthorized**: Missing or invalid authentication
|
|
114
|
-
- **403 Forbidden**: Insufficient permissions or wrong access type
|
|
115
|
-
- **404 Not Found**: Form or result not found
|
|
116
|
-
- **500 Internal Server Error**: Server error
|
|
117
|
-
|
|
118
|
-
## API Endpoints
|
|
119
|
-
|
|
120
|
-
All form builder endpoints are prefixed with \`/form-builder\`:
|
|
121
|
-
- \`/form-builder/form/*\` - Form management
|
|
122
|
-
- \`/form-builder/result/*\` - Form result/submission management
|
|
123
|
-
|
|
124
|
-
## Examples
|
|
125
|
-
|
|
126
|
-
### Get Form Access Info
|
|
127
|
-
|
|
128
|
-
POST /form-builder/form/access-info/:id
|
|
129
|
-
Returns access type and requirements (no auth required)
|
|
130
|
-
|
|
131
|
-
### Submit Public Form
|
|
132
|
-
|
|
133
|
-
POST /form-builder/result/submit-public with JSON body containing formId and formData
|
|
134
|
-
|
|
135
|
-
### Submit Authenticated Form
|
|
136
|
-
|
|
137
|
-
POST /form-builder/result/submit with JWT token and JSON body containing formId and formData
|
|
138
|
-
` : `
|
|
139
|
-
# Form Builder API
|
|
140
|
-
|
|
141
|
-
Dynamic form builder with schema versioning, conditional logic, and access control.
|
|
142
|
-
|
|
143
|
-
## Features
|
|
144
|
-
|
|
145
|
-
### 📋 Form Management
|
|
146
|
-
- Create and manage dynamic forms
|
|
147
|
-
- Schema versioning for form updates
|
|
148
|
-
- Slug-based URLs for sharing
|
|
149
|
-
|
|
150
|
-
### 🔒 Access Control
|
|
151
|
-
- **Public**: No authentication required
|
|
152
|
-
- **Authenticated**: JWT authentication required
|
|
153
|
-
- **Action Group**: Permission-based access via IAM
|
|
154
|
-
|
|
155
|
-
### 📊 Form Results
|
|
156
|
-
- Submit and track form responses
|
|
157
|
-
- Draft support for partial submissions
|
|
158
|
-
- Schema snapshot preservation
|
|
159
|
-
|
|
160
|
-
### 🔀 Conditional Logic
|
|
161
|
-
- Show/hide fields based on values
|
|
162
|
-
- Show/hide sections dynamically
|
|
163
|
-
- Jump to sections based on conditions
|
|
164
|
-
- Conditional required validation
|
|
165
|
-
|
|
71
|
+
` : ''}
|
|
166
72
|
## Form Access Types
|
|
167
73
|
|
|
168
74
|
### Public Forms
|
|
@@ -227,7 +133,7 @@ POST /form-builder/result/submit-public with JSON body containing formId and for
|
|
|
227
133
|
### Submit Authenticated Form
|
|
228
134
|
|
|
229
135
|
POST /form-builder/result/submit with JWT token and JSON body containing formId and formData
|
|
230
|
-
|
|
136
|
+
`,
|
|
231
137
|
version: '1.0',
|
|
232
138
|
path: 'api/docs/form-builder',
|
|
233
139
|
bearerAuth: true,
|
|
@@ -22,6 +22,7 @@ function _ts_metadata(k, v) {
|
|
|
22
22
|
}
|
|
23
23
|
import { ApiProperty, PartialType } from '@nestjs/swagger';
|
|
24
24
|
import { IsBoolean, IsInt, IsNotEmpty, IsObject, IsOptional, IsUUID, Min } from 'class-validator';
|
|
25
|
+
import { IdentityResponseDto } from '@flusys/nestjs-shared/dtos';
|
|
25
26
|
export class SubmitFormDto {
|
|
26
27
|
constructor(){
|
|
27
28
|
_define_property(this, "formId", void 0);
|
|
@@ -66,6 +67,7 @@ _ts_decorate([
|
|
|
66
67
|
description: 'Additional metadata',
|
|
67
68
|
required: false
|
|
68
69
|
}),
|
|
70
|
+
IsObject(),
|
|
69
71
|
IsOptional(),
|
|
70
72
|
_ts_metadata("design:type", typeof Record === "undefined" ? Object : Record)
|
|
71
73
|
], SubmitFormDto.prototype, "metadata", void 0);
|
|
@@ -180,29 +182,11 @@ _ts_decorate([
|
|
|
180
182
|
IsOptional(),
|
|
181
183
|
_ts_metadata("design:type", Number)
|
|
182
184
|
], GetResultsByFormDto.prototype, "pageSize", void 0);
|
|
183
|
-
export class FormResultResponseDto {
|
|
184
|
-
constructor(){
|
|
185
|
-
_define_property(this, "
|
|
186
|
-
_define_property(this, "formId", void 0);
|
|
187
|
-
_define_property(this, "schemaVersionSnapshot", void 0);
|
|
188
|
-
_define_property(this, "schemaVersion", void 0);
|
|
189
|
-
_define_property(this, "data", void 0);
|
|
190
|
-
_define_property(this, "submittedById", void 0);
|
|
191
|
-
_define_property(this, "submittedAt", void 0);
|
|
192
|
-
_define_property(this, "isDraft", void 0);
|
|
193
|
-
_define_property(this, "metadata", void 0);
|
|
194
|
-
_define_property(this, "createdAt", void 0);
|
|
195
|
-
_define_property(this, "updatedAt", void 0);
|
|
196
|
-
_define_property(this, "deletedAt", void 0);
|
|
197
|
-
_define_property(this, "createdById", void 0);
|
|
198
|
-
_define_property(this, "updatedById", void 0);
|
|
199
|
-
_define_property(this, "deletedById", void 0);
|
|
185
|
+
export class FormResultResponseDto extends IdentityResponseDto {
|
|
186
|
+
constructor(...args){
|
|
187
|
+
super(...args), _define_property(this, "formId", void 0), _define_property(this, "schemaVersionSnapshot", void 0), _define_property(this, "schemaVersion", void 0), _define_property(this, "data", void 0), _define_property(this, "submittedById", void 0), _define_property(this, "submittedAt", void 0), _define_property(this, "isDraft", void 0), _define_property(this, "metadata", void 0);
|
|
200
188
|
}
|
|
201
189
|
}
|
|
202
|
-
_ts_decorate([
|
|
203
|
-
ApiProperty(),
|
|
204
|
-
_ts_metadata("design:type", String)
|
|
205
|
-
], FormResultResponseDto.prototype, "id", void 0);
|
|
206
190
|
_ts_decorate([
|
|
207
191
|
ApiProperty(),
|
|
208
192
|
_ts_metadata("design:type", String)
|
|
@@ -237,35 +221,3 @@ _ts_decorate([
|
|
|
237
221
|
}),
|
|
238
222
|
_ts_metadata("design:type", Object)
|
|
239
223
|
], FormResultResponseDto.prototype, "metadata", void 0);
|
|
240
|
-
_ts_decorate([
|
|
241
|
-
ApiProperty(),
|
|
242
|
-
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
243
|
-
], FormResultResponseDto.prototype, "createdAt", void 0);
|
|
244
|
-
_ts_decorate([
|
|
245
|
-
ApiProperty(),
|
|
246
|
-
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
247
|
-
], FormResultResponseDto.prototype, "updatedAt", void 0);
|
|
248
|
-
_ts_decorate([
|
|
249
|
-
ApiProperty({
|
|
250
|
-
required: false
|
|
251
|
-
}),
|
|
252
|
-
_ts_metadata("design:type", Object)
|
|
253
|
-
], FormResultResponseDto.prototype, "deletedAt", void 0);
|
|
254
|
-
_ts_decorate([
|
|
255
|
-
ApiProperty({
|
|
256
|
-
required: false
|
|
257
|
-
}),
|
|
258
|
-
_ts_metadata("design:type", Object)
|
|
259
|
-
], FormResultResponseDto.prototype, "createdById", void 0);
|
|
260
|
-
_ts_decorate([
|
|
261
|
-
ApiProperty({
|
|
262
|
-
required: false
|
|
263
|
-
}),
|
|
264
|
-
_ts_metadata("design:type", Object)
|
|
265
|
-
], FormResultResponseDto.prototype, "updatedById", void 0);
|
|
266
|
-
_ts_decorate([
|
|
267
|
-
ApiProperty({
|
|
268
|
-
required: false
|
|
269
|
-
}),
|
|
270
|
-
_ts_metadata("design:type", Object)
|
|
271
|
-
], FormResultResponseDto.prototype, "deletedById", void 0);
|
package/fesm/dtos/form.dto.js
CHANGED
|
@@ -20,9 +20,10 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
20
20
|
function _ts_metadata(k, v) {
|
|
21
21
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
22
22
|
}
|
|
23
|
-
import { ApiProperty, PartialType } from '@nestjs/swagger';
|
|
23
|
+
import { ApiProperty, PartialType, PickType } from '@nestjs/swagger';
|
|
24
24
|
import { IsArray, IsBoolean, IsEnum, IsNotEmpty, IsObject, IsOptional, IsString, IsUUID, MaxLength } from 'class-validator';
|
|
25
25
|
import { FormAccessType } from '../enums/form-access-type.enum';
|
|
26
|
+
import { IdentityResponseDto } from '@flusys/nestjs-shared/dtos';
|
|
26
27
|
export class CreateFormDto {
|
|
27
28
|
constructor(){
|
|
28
29
|
_define_property(this, "name", void 0);
|
|
@@ -132,6 +133,7 @@ _ts_decorate([
|
|
|
132
133
|
description: 'Additional metadata',
|
|
133
134
|
required: false
|
|
134
135
|
}),
|
|
136
|
+
IsObject(),
|
|
135
137
|
IsOptional(),
|
|
136
138
|
_ts_metadata("design:type", typeof Record === "undefined" ? Object : Record)
|
|
137
139
|
], CreateFormDto.prototype, "metadata", void 0);
|
|
@@ -157,31 +159,11 @@ _ts_decorate([
|
|
|
157
159
|
IsOptional(),
|
|
158
160
|
_ts_metadata("design:type", Number)
|
|
159
161
|
], UpdateFormDto.prototype, "schemaVersion", void 0);
|
|
160
|
-
export class FormResponseDto {
|
|
161
|
-
constructor(){
|
|
162
|
-
_define_property(this, "
|
|
163
|
-
_define_property(this, "name", void 0);
|
|
164
|
-
_define_property(this, "description", void 0);
|
|
165
|
-
_define_property(this, "slug", void 0);
|
|
166
|
-
_define_property(this, "schema", void 0);
|
|
167
|
-
_define_property(this, "schemaVersion", void 0);
|
|
168
|
-
_define_property(this, "accessType", void 0);
|
|
169
|
-
_define_property(this, "actionGroups", void 0);
|
|
170
|
-
_define_property(this, "companyId", void 0);
|
|
171
|
-
_define_property(this, "isActive", void 0);
|
|
172
|
-
_define_property(this, "metadata", void 0);
|
|
173
|
-
_define_property(this, "createdAt", void 0);
|
|
174
|
-
_define_property(this, "updatedAt", void 0);
|
|
175
|
-
_define_property(this, "deletedAt", void 0);
|
|
176
|
-
_define_property(this, "createdById", void 0);
|
|
177
|
-
_define_property(this, "updatedById", void 0);
|
|
178
|
-
_define_property(this, "deletedById", void 0);
|
|
162
|
+
export class FormResponseDto extends IdentityResponseDto {
|
|
163
|
+
constructor(...args){
|
|
164
|
+
super(...args), _define_property(this, "name", void 0), _define_property(this, "description", void 0), _define_property(this, "slug", void 0), _define_property(this, "schema", void 0), _define_property(this, "schemaVersion", void 0), _define_property(this, "accessType", void 0), _define_property(this, "actionGroups", void 0), _define_property(this, "companyId", void 0), _define_property(this, "isActive", void 0), _define_property(this, "metadata", void 0);
|
|
179
165
|
}
|
|
180
166
|
}
|
|
181
|
-
_ts_decorate([
|
|
182
|
-
ApiProperty(),
|
|
183
|
-
_ts_metadata("design:type", String)
|
|
184
|
-
], FormResponseDto.prototype, "id", void 0);
|
|
185
167
|
_ts_decorate([
|
|
186
168
|
ApiProperty(),
|
|
187
169
|
_ts_metadata("design:type", String)
|
|
@@ -226,105 +208,20 @@ _ts_decorate([
|
|
|
226
208
|
}),
|
|
227
209
|
_ts_metadata("design:type", Object)
|
|
228
210
|
], FormResponseDto.prototype, "metadata", void 0);
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
], FormResponseDto.prototype, "updatedAt", void 0);
|
|
237
|
-
_ts_decorate([
|
|
238
|
-
ApiProperty({
|
|
239
|
-
required: false
|
|
240
|
-
}),
|
|
241
|
-
_ts_metadata("design:type", Object)
|
|
242
|
-
], FormResponseDto.prototype, "deletedAt", void 0);
|
|
243
|
-
_ts_decorate([
|
|
244
|
-
ApiProperty({
|
|
245
|
-
required: false
|
|
246
|
-
}),
|
|
247
|
-
_ts_metadata("design:type", Object)
|
|
248
|
-
], FormResponseDto.prototype, "createdById", void 0);
|
|
249
|
-
_ts_decorate([
|
|
250
|
-
ApiProperty({
|
|
251
|
-
required: false
|
|
252
|
-
}),
|
|
253
|
-
_ts_metadata("design:type", Object)
|
|
254
|
-
], FormResponseDto.prototype, "updatedById", void 0);
|
|
255
|
-
_ts_decorate([
|
|
256
|
-
ApiProperty({
|
|
257
|
-
required: false
|
|
258
|
-
}),
|
|
259
|
-
_ts_metadata("design:type", Object)
|
|
260
|
-
], FormResponseDto.prototype, "deletedById", void 0);
|
|
261
|
-
export class PublicFormResponseDto {
|
|
262
|
-
constructor(){
|
|
263
|
-
_define_property(this, "id", void 0);
|
|
264
|
-
_define_property(this, "name", void 0);
|
|
265
|
-
_define_property(this, "description", void 0);
|
|
266
|
-
_define_property(this, "schema", void 0);
|
|
267
|
-
_define_property(this, "schemaVersion", void 0);
|
|
268
|
-
}
|
|
211
|
+
export class PublicFormResponseDto extends PickType(FormResponseDto, [
|
|
212
|
+
'id',
|
|
213
|
+
'name',
|
|
214
|
+
'description',
|
|
215
|
+
'schema',
|
|
216
|
+
'schemaVersion'
|
|
217
|
+
]) {
|
|
269
218
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
]
|
|
278
|
-
_ts_decorate([
|
|
279
|
-
ApiProperty(),
|
|
280
|
-
_ts_metadata("design:type", Object)
|
|
281
|
-
], PublicFormResponseDto.prototype, "description", void 0);
|
|
282
|
-
_ts_decorate([
|
|
283
|
-
ApiProperty(),
|
|
284
|
-
_ts_metadata("design:type", typeof Record === "undefined" ? Object : Record)
|
|
285
|
-
], PublicFormResponseDto.prototype, "schema", void 0);
|
|
286
|
-
_ts_decorate([
|
|
287
|
-
ApiProperty(),
|
|
288
|
-
_ts_metadata("design:type", Number)
|
|
289
|
-
], PublicFormResponseDto.prototype, "schemaVersion", void 0);
|
|
290
|
-
export class FormAccessInfoResponseDto {
|
|
291
|
-
constructor(){
|
|
292
|
-
_define_property(this, "id", void 0);
|
|
293
|
-
_define_property(this, "name", void 0);
|
|
294
|
-
_define_property(this, "description", void 0);
|
|
295
|
-
_define_property(this, "accessType", void 0);
|
|
296
|
-
_define_property(this, "actionGroups", void 0);
|
|
297
|
-
_define_property(this, "isActive", void 0);
|
|
298
|
-
}
|
|
219
|
+
export class FormAccessInfoResponseDto extends PickType(FormResponseDto, [
|
|
220
|
+
'id',
|
|
221
|
+
'name',
|
|
222
|
+
'description',
|
|
223
|
+
'accessType',
|
|
224
|
+
'actionGroups',
|
|
225
|
+
'isActive'
|
|
226
|
+
]) {
|
|
299
227
|
}
|
|
300
|
-
_ts_decorate([
|
|
301
|
-
ApiProperty(),
|
|
302
|
-
_ts_metadata("design:type", String)
|
|
303
|
-
], FormAccessInfoResponseDto.prototype, "id", void 0);
|
|
304
|
-
_ts_decorate([
|
|
305
|
-
ApiProperty(),
|
|
306
|
-
_ts_metadata("design:type", String)
|
|
307
|
-
], FormAccessInfoResponseDto.prototype, "name", void 0);
|
|
308
|
-
_ts_decorate([
|
|
309
|
-
ApiProperty(),
|
|
310
|
-
_ts_metadata("design:type", Object)
|
|
311
|
-
], FormAccessInfoResponseDto.prototype, "description", void 0);
|
|
312
|
-
_ts_decorate([
|
|
313
|
-
ApiProperty({
|
|
314
|
-
enum: FormAccessType
|
|
315
|
-
}),
|
|
316
|
-
_ts_metadata("design:type", typeof FormAccessType === "undefined" ? Object : FormAccessType)
|
|
317
|
-
], FormAccessInfoResponseDto.prototype, "accessType", void 0);
|
|
318
|
-
_ts_decorate([
|
|
319
|
-
ApiProperty({
|
|
320
|
-
type: [
|
|
321
|
-
String
|
|
322
|
-
],
|
|
323
|
-
required: false
|
|
324
|
-
}),
|
|
325
|
-
_ts_metadata("design:type", Object)
|
|
326
|
-
], FormAccessInfoResponseDto.prototype, "actionGroups", void 0);
|
|
327
|
-
_ts_decorate([
|
|
328
|
-
ApiProperty(),
|
|
329
|
-
_ts_metadata("design:type", Boolean)
|
|
330
|
-
], FormAccessInfoResponseDto.prototype, "isActive", void 0);
|
|
@@ -21,8 +21,8 @@ function _ts_metadata(k, v) {
|
|
|
21
21
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
22
22
|
}
|
|
23
23
|
import { Column, Entity, Index } from 'typeorm';
|
|
24
|
-
import {
|
|
25
|
-
export class FormWithCompany extends
|
|
24
|
+
import { Form } from './form.entity';
|
|
25
|
+
export class FormWithCompany extends Form {
|
|
26
26
|
constructor(...args){
|
|
27
27
|
super(...args), _define_property(this, "companyId", void 0);
|
|
28
28
|
}
|
|
@@ -41,5 +41,15 @@ FormWithCompany = _ts_decorate([
|
|
|
41
41
|
}),
|
|
42
42
|
Index([
|
|
43
43
|
'companyId'
|
|
44
|
+
]),
|
|
45
|
+
Index([
|
|
46
|
+
'companyId',
|
|
47
|
+
'slug'
|
|
48
|
+
], {
|
|
49
|
+
unique: true
|
|
50
|
+
}),
|
|
51
|
+
Index([
|
|
52
|
+
'companyId',
|
|
53
|
+
'isActive'
|
|
44
54
|
])
|
|
45
55
|
], FormWithCompany);
|
|
@@ -1,15 +1,115 @@
|
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
|
+
if (key in obj) {
|
|
3
|
+
Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
} else {
|
|
10
|
+
obj[key] = value;
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
1
14
|
function _ts_decorate(decorators, target, key, desc) {
|
|
2
15
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
16
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
17
|
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;
|
|
5
18
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
19
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
20
|
+
function _ts_metadata(k, v) {
|
|
21
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
22
|
+
}
|
|
23
|
+
import { Identity } from '@flusys/nestjs-shared/entities';
|
|
24
|
+
import { Column, Entity, Index } from 'typeorm';
|
|
25
|
+
import { FormAccessType } from '../enums/form-access-type.enum';
|
|
26
|
+
export class Form extends Identity {
|
|
27
|
+
constructor(...args){
|
|
28
|
+
super(...args), _define_property(this, "name", void 0), _define_property(this, "description", void 0), _define_property(this, "slug", void 0), _define_property(this, "schema", void 0), _define_property(this, "schemaVersion", void 0), _define_property(this, "accessType", void 0), _define_property(this, "actionGroups", void 0), _define_property(this, "isActive", void 0), _define_property(this, "metadata", void 0);
|
|
29
|
+
}
|
|
10
30
|
}
|
|
31
|
+
_ts_decorate([
|
|
32
|
+
Column({
|
|
33
|
+
type: 'varchar',
|
|
34
|
+
length: 255,
|
|
35
|
+
nullable: false
|
|
36
|
+
}),
|
|
37
|
+
_ts_metadata("design:type", String)
|
|
38
|
+
], Form.prototype, "name", void 0);
|
|
39
|
+
_ts_decorate([
|
|
40
|
+
Column({
|
|
41
|
+
type: 'varchar',
|
|
42
|
+
length: 500,
|
|
43
|
+
nullable: true
|
|
44
|
+
}),
|
|
45
|
+
_ts_metadata("design:type", Object)
|
|
46
|
+
], Form.prototype, "description", void 0);
|
|
47
|
+
_ts_decorate([
|
|
48
|
+
Column({
|
|
49
|
+
type: 'varchar',
|
|
50
|
+
length: 255,
|
|
51
|
+
nullable: true
|
|
52
|
+
}),
|
|
53
|
+
_ts_metadata("design:type", Object)
|
|
54
|
+
], Form.prototype, "slug", void 0);
|
|
55
|
+
_ts_decorate([
|
|
56
|
+
Column({
|
|
57
|
+
type: 'json',
|
|
58
|
+
nullable: false
|
|
59
|
+
}),
|
|
60
|
+
_ts_metadata("design:type", typeof Record === "undefined" ? Object : Record)
|
|
61
|
+
], Form.prototype, "schema", void 0);
|
|
62
|
+
_ts_decorate([
|
|
63
|
+
Column({
|
|
64
|
+
type: 'int',
|
|
65
|
+
nullable: false,
|
|
66
|
+
default: 1,
|
|
67
|
+
name: 'schema_version'
|
|
68
|
+
}),
|
|
69
|
+
_ts_metadata("design:type", Number)
|
|
70
|
+
], Form.prototype, "schemaVersion", void 0);
|
|
71
|
+
_ts_decorate([
|
|
72
|
+
Column({
|
|
73
|
+
type: 'enum',
|
|
74
|
+
enum: FormAccessType,
|
|
75
|
+
default: FormAccessType.AUTHENTICATED,
|
|
76
|
+
name: 'access_type'
|
|
77
|
+
}),
|
|
78
|
+
_ts_metadata("design:type", typeof FormAccessType === "undefined" ? Object : FormAccessType)
|
|
79
|
+
], Form.prototype, "accessType", void 0);
|
|
80
|
+
_ts_decorate([
|
|
81
|
+
Column({
|
|
82
|
+
type: 'simple-array',
|
|
83
|
+
nullable: true,
|
|
84
|
+
name: 'action_groups'
|
|
85
|
+
}),
|
|
86
|
+
_ts_metadata("design:type", Object)
|
|
87
|
+
], Form.prototype, "actionGroups", void 0);
|
|
88
|
+
_ts_decorate([
|
|
89
|
+
Column({
|
|
90
|
+
type: 'boolean',
|
|
91
|
+
nullable: false,
|
|
92
|
+
default: true,
|
|
93
|
+
name: 'is_active'
|
|
94
|
+
}),
|
|
95
|
+
_ts_metadata("design:type", Boolean)
|
|
96
|
+
], Form.prototype, "isActive", void 0);
|
|
97
|
+
_ts_decorate([
|
|
98
|
+
Column('simple-json', {
|
|
99
|
+
nullable: true
|
|
100
|
+
}),
|
|
101
|
+
_ts_metadata("design:type", Object)
|
|
102
|
+
], Form.prototype, "metadata", void 0);
|
|
11
103
|
Form = _ts_decorate([
|
|
12
104
|
Entity({
|
|
13
105
|
name: 'form'
|
|
14
|
-
})
|
|
106
|
+
}),
|
|
107
|
+
Index([
|
|
108
|
+
'slug'
|
|
109
|
+
], {
|
|
110
|
+
unique: true
|
|
111
|
+
}),
|
|
112
|
+
Index([
|
|
113
|
+
'isActive'
|
|
114
|
+
])
|
|
15
115
|
], Form);
|
package/fesm/entities/index.js
CHANGED
|
@@ -1,29 +1,23 @@
|
|
|
1
|
-
//
|
|
2
|
-
export * from './form-base.entity';
|
|
1
|
+
// Entities without company feature
|
|
3
2
|
export * from './form.entity';
|
|
4
|
-
export * from './form-with-company.entity';
|
|
5
|
-
// Form Result Entity (single - no company variant needed)
|
|
6
3
|
export * from './form-result.entity';
|
|
7
|
-
//
|
|
4
|
+
// Entities with company feature
|
|
5
|
+
export * from './form-with-company.entity';
|
|
8
6
|
import { Form } from './form.entity';
|
|
9
|
-
import { FormWithCompany } from './form-with-company.entity';
|
|
10
7
|
import { FormResult } from './form-result.entity';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
return [
|
|
26
|
-
Form,
|
|
27
|
-
FormResult
|
|
28
|
-
];
|
|
8
|
+
import { FormWithCompany } from './form-with-company.entity';
|
|
9
|
+
// Core entities (no company feature)
|
|
10
|
+
export const FormCoreEntities = [
|
|
11
|
+
Form,
|
|
12
|
+
FormResult
|
|
13
|
+
];
|
|
14
|
+
// Company-specific entities
|
|
15
|
+
export const FormCompanyEntities = [
|
|
16
|
+
FormWithCompany,
|
|
17
|
+
FormResult
|
|
18
|
+
];
|
|
19
|
+
export function getFormBuilderEntitiesByConfig(enableCompanyFeature) {
|
|
20
|
+
return enableCompanyFeature ? FormCompanyEntities : FormCoreEntities;
|
|
29
21
|
}
|
|
22
|
+
// Base type aliases for backwards compatibility with services
|
|
23
|
+
export { Form as FormBase } from './form.entity';
|