@flusys/nestjs-form-builder 4.1.1 → 5.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.
@@ -32,6 +32,7 @@ import { ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
32
32
  import { Controller, HttpCode, HttpStatus, Inject, Param, Post, UseGuards } from '@nestjs/common';
33
33
  import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
34
34
  import { CreateFormDto, FormResponseDto, UpdateFormDto } from '../dtos';
35
+ import { FORM_MESSAGES } from '../config';
35
36
  import { FormService } from '../services/form.service';
36
37
  export class FormController extends createApiController(CreateFormDto, UpdateFormDto, FormResponseDto, {
37
38
  entityName: 'form',
@@ -84,29 +85,49 @@ export class FormController extends createApiController(CreateFormDto, UpdateFor
84
85
  /**
85
86
  * Get form access info (no authentication required)
86
87
  */ async getFormAccessInfo(id) {
87
- return this.formService.getFormAccessInfo(id);
88
+ const data = await this.formService.getFormAccessInfo(id);
89
+ return {
90
+ success: true,
91
+ message: 'Form access info retrieved',
92
+ messageKey: FORM_MESSAGES.GET_ACCESS_INFO_SUCCESS,
93
+ data
94
+ };
88
95
  }
89
- /**
90
- * Get public form for submission (no authentication required)
91
- * Only works for forms with accessType = 'public'
92
- */ async getPublicForm(id) {
93
- return this.formService.getPublicForm(id);
96
+ async getPublicForm(id) {
97
+ const data = await this.formService.getPublicForm(id);
98
+ return {
99
+ success: true,
100
+ message: 'Form retrieved',
101
+ messageKey: FORM_MESSAGES.GET_SUCCESS,
102
+ data
103
+ };
94
104
  }
95
- /**
96
- * Get form for authenticated submission
97
- * Works for 'authenticated' and 'action_group' access types
98
- */ async getAuthenticatedForm(id, user) {
99
- return this.formService.getAuthenticatedForm(id, user);
105
+ async getAuthenticatedForm(id, user) {
106
+ const data = await this.formService.getAuthenticatedForm(id, user);
107
+ return {
108
+ success: true,
109
+ message: 'Form retrieved',
110
+ messageKey: FORM_MESSAGES.GET_SUCCESS,
111
+ data
112
+ };
100
113
  }
101
- /**
102
- * Get form by slug
103
- */ async getBySlug(slug, _user) {
104
- return this.formService.getBySlug(slug);
114
+ async getBySlug(slug, _user) {
115
+ const data = await this.formService.getBySlug(slug);
116
+ return {
117
+ success: true,
118
+ message: 'Form retrieved',
119
+ messageKey: FORM_MESSAGES.GET_SUCCESS,
120
+ data
121
+ };
105
122
  }
106
- /**
107
- * Get public form by slug (no authentication required)
108
- */ async getPublicFormBySlug(slug) {
109
- return this.formService.getPublicFormBySlug(slug);
123
+ async getPublicFormBySlug(slug) {
124
+ const data = await this.formService.getPublicFormBySlug(slug);
125
+ return {
126
+ success: true,
127
+ message: 'Form retrieved',
128
+ messageKey: FORM_MESSAGES.GET_SUCCESS,
129
+ data
130
+ };
110
131
  }
111
132
  constructor(formService){
112
133
  super(formService), _define_property(this, "formService", void 0), this.formService = formService;
@@ -32,10 +32,13 @@
32
32
  * @returns Swagger configuration with appropriate excludeSchemaProperties based on enableCompanyFeature
33
33
  */ export function formBuilderSwaggerConfig(bootstrapConfig) {
34
34
  const enableCompanyFeature = bootstrapConfig?.enableCompanyFeature ?? true;
35
+ const isMultiTenant = bootstrapConfig?.databaseMode === 'multi-tenant';
36
+ const multiTenantNote = isMultiTenant ? `\n> **Multi-Tenant Mode**: Include \`x-tenant-id\` header to target a specific tenant database.\n` : '';
35
37
  return {
36
38
  title: 'Form Builder API',
37
39
  description: `
38
40
  # Form Builder API
41
+ ${multiTenantNote}
39
42
 
40
43
  Dynamic form builder with schema versioning, conditional logic, and access control.
41
44
 
@@ -28,7 +28,6 @@ export class SubmitFormDto {
28
28
  _define_property(this, "formId", void 0);
29
29
  _define_property(this, "data", void 0);
30
30
  _define_property(this, "isDraft", void 0);
31
- _define_property(this, "metadata", void 0);
32
31
  }
33
32
  }
34
33
  _ts_decorate([
@@ -62,15 +61,6 @@ _ts_decorate([
62
61
  IsOptional(),
63
62
  _ts_metadata("design:type", Boolean)
64
63
  ], SubmitFormDto.prototype, "isDraft", void 0);
65
- _ts_decorate([
66
- ApiProperty({
67
- description: 'Additional metadata',
68
- required: false
69
- }),
70
- IsObject(),
71
- IsOptional(),
72
- _ts_metadata("design:type", typeof Record === "undefined" ? Object : Record)
73
- ], SubmitFormDto.prototype, "metadata", void 0);
74
64
  export class CreateFormResultDto extends SubmitFormDto {
75
65
  constructor(...args){
76
66
  super(...args), _define_property(this, "schemaVersionSnapshot", void 0), _define_property(this, "schemaVersion", void 0), _define_property(this, "submittedById", void 0);
@@ -184,7 +174,7 @@ _ts_decorate([
184
174
  ], GetResultsByFormDto.prototype, "pageSize", void 0);
185
175
  export class FormResultResponseDto extends IdentityResponseDto {
186
176
  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);
177
+ 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);
188
178
  }
189
179
  }
190
180
  _ts_decorate([
@@ -215,9 +205,3 @@ _ts_decorate([
215
205
  ApiProperty(),
216
206
  _ts_metadata("design:type", Boolean)
217
207
  ], FormResultResponseDto.prototype, "isDraft", void 0);
218
- _ts_decorate([
219
- ApiProperty({
220
- required: false
221
- }),
222
- _ts_metadata("design:type", Object)
223
- ], FormResultResponseDto.prototype, "metadata", void 0);
@@ -34,7 +34,6 @@ export class CreateFormDto {
34
34
  _define_property(this, "actionGroups", void 0);
35
35
  _define_property(this, "companyId", void 0);
36
36
  _define_property(this, "isActive", void 0);
37
- _define_property(this, "metadata", void 0);
38
37
  }
39
38
  }
40
39
  _ts_decorate([
@@ -128,15 +127,6 @@ _ts_decorate([
128
127
  IsOptional(),
129
128
  _ts_metadata("design:type", Boolean)
130
129
  ], CreateFormDto.prototype, "isActive", void 0);
131
- _ts_decorate([
132
- ApiProperty({
133
- description: 'Additional metadata',
134
- required: false
135
- }),
136
- IsObject(),
137
- IsOptional(),
138
- _ts_metadata("design:type", typeof Record === "undefined" ? Object : Record)
139
- ], CreateFormDto.prototype, "metadata", void 0);
140
130
  export class UpdateFormDto extends PartialType(CreateFormDto) {
141
131
  constructor(...args){
142
132
  super(...args), _define_property(this, "id", void 0), _define_property(this, "schemaVersion", void 0);
@@ -161,7 +151,7 @@ _ts_decorate([
161
151
  ], UpdateFormDto.prototype, "schemaVersion", void 0);
162
152
  export class FormResponseDto extends IdentityResponseDto {
163
153
  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);
154
+ 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);
165
155
  }
166
156
  }
167
157
  _ts_decorate([
@@ -202,12 +192,6 @@ _ts_decorate([
202
192
  ApiProperty(),
203
193
  _ts_metadata("design:type", Boolean)
204
194
  ], FormResponseDto.prototype, "isActive", void 0);
205
- _ts_decorate([
206
- ApiProperty({
207
- required: false
208
- }),
209
- _ts_metadata("design:type", Object)
210
- ], FormResponseDto.prototype, "metadata", void 0);
211
195
  export class PublicFormResponseDto extends PickType(FormResponseDto, [
212
196
  'id',
213
197
  'name',
@@ -24,7 +24,7 @@ import { Identity } from '@flusys/nestjs-shared';
24
24
  import { Column, Entity, Index } from 'typeorm';
25
25
  export class FormResult extends Identity {
26
26
  constructor(...args){
27
- 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);
27
+ 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);
28
28
  }
29
29
  }
30
30
  _ts_decorate([
@@ -83,12 +83,6 @@ _ts_decorate([
83
83
  }),
84
84
  _ts_metadata("design:type", Boolean)
85
85
  ], FormResult.prototype, "isDraft", void 0);
86
- _ts_decorate([
87
- Column('simple-json', {
88
- nullable: true
89
- }),
90
- _ts_metadata("design:type", Object)
91
- ], FormResult.prototype, "metadata", void 0);
92
86
  FormResult = _ts_decorate([
93
87
  Entity({
94
88
  name: 'form_result'
@@ -25,7 +25,7 @@ import { Column, Entity, Index } from 'typeorm';
25
25
  import { FormAccessType } from '../enums/form-access-type.enum';
26
26
  export class Form extends Identity {
27
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);
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);
29
29
  }
30
30
  }
31
31
  _ts_decorate([
@@ -79,7 +79,7 @@ _ts_decorate([
79
79
  ], Form.prototype, "accessType", void 0);
80
80
  _ts_decorate([
81
81
  Column({
82
- type: 'simple-array',
82
+ type: 'json',
83
83
  nullable: true,
84
84
  name: 'action_groups'
85
85
  }),
@@ -94,12 +94,6 @@ _ts_decorate([
94
94
  }),
95
95
  _ts_metadata("design:type", Boolean)
96
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);
103
97
  Form = _ts_decorate([
104
98
  Entity({
105
99
  name: 'form'
@@ -129,7 +129,6 @@ export class FormResultService extends RequestScopedApiService {
129
129
  'submittedById',
130
130
  'submittedAt',
131
131
  'isDraft',
132
- 'metadata',
133
132
  'createdAt',
134
133
  'updatedAt'
135
134
  ];
@@ -172,7 +171,6 @@ export class FormResultService extends RequestScopedApiService {
172
171
  submittedById: entity.submittedById,
173
172
  submittedAt: entity.submittedAt,
174
173
  isDraft: entity.isDraft,
175
- metadata: entity.metadata,
176
174
  createdAt: entity.createdAt,
177
175
  updatedAt: entity.updatedAt,
178
176
  deletedAt: entity.deletedAt,
@@ -198,8 +196,7 @@ export class FormResultService extends RequestScopedApiService {
198
196
  data: dto.data,
199
197
  schemaVersionSnapshot: form.schema,
200
198
  schemaVersion: form.schemaVersion,
201
- submittedAt: new Date(),
202
- metadata: dto.metadata ?? existingDraft.metadata
199
+ submittedAt: new Date()
203
200
  });
204
201
  const saved = await this.repository.save(existingDraft);
205
202
  return this.convertEntityToResponseDto(saved, false);
@@ -214,8 +211,7 @@ export class FormResultService extends RequestScopedApiService {
214
211
  data: this.applyComputedFields(dto.data, form, isDraft),
215
212
  submittedById: user?.id ?? null,
216
213
  submittedAt: new Date(),
217
- isDraft,
218
- metadata: dto.metadata ?? null
214
+ isDraft
219
215
  });
220
216
  return this.convertEntityToResponseDto(saved, false);
221
217
  }
@@ -251,8 +247,7 @@ export class FormResultService extends RequestScopedApiService {
251
247
  schemaVersionSnapshot: form.schema,
252
248
  schemaVersion: form.schemaVersion,
253
249
  submittedAt: new Date(),
254
- isDraft,
255
- metadata: dto.metadata ?? draft.metadata
250
+ isDraft
256
251
  });
257
252
  const saved = await this.repository.save(draft);
258
253
  return this.convertEntityToResponseDto(saved, false);
@@ -104,7 +104,6 @@ export class FormService extends RequestScopedApiService {
104
104
  'accessType',
105
105
  'actionGroups',
106
106
  'isActive',
107
- 'metadata',
108
107
  'createdAt',
109
108
  'updatedAt'
110
109
  ];
@@ -143,7 +142,6 @@ export class FormService extends RequestScopedApiService {
143
142
  actionGroups: entity.actionGroups,
144
143
  isActive: entity.isActive,
145
144
  companyId: entityWithCompany.companyId ?? null,
146
- metadata: entity.metadata,
147
145
  createdAt: entity.createdAt,
148
146
  updatedAt: entity.updatedAt,
149
147
  deletedAt: entity.deletedAt,
@@ -7,5 +7,4 @@ export interface IFormResult extends IIdentity {
7
7
  submittedById: string | null;
8
8
  submittedAt: Date;
9
9
  isDraft: boolean;
10
- metadata: Record<string, unknown> | null;
11
10
  }
@@ -10,7 +10,6 @@ export interface IForm extends IIdentity {
10
10
  actionGroups: string[] | null;
11
11
  isActive: boolean;
12
12
  companyId: string | null;
13
- metadata: Record<string, unknown> | null;
14
13
  }
15
14
  export interface IPublicForm {
16
15
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flusys/nestjs-form-builder",
3
- "version": "4.1.1",
3
+ "version": "5.0.0",
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": "^4.18.0"
85
85
  },
86
86
  "dependencies": {
87
- "@flusys/nestjs-core": "4.1.1",
88
- "@flusys/nestjs-shared": "4.1.1"
87
+ "@flusys/nestjs-core": "5.0.0",
88
+ "@flusys/nestjs-shared": "5.0.0"
89
89
  }
90
90
  }