@msbci/form-server 1.2.0 → 1.3.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.
@@ -40,6 +40,7 @@ model FormDefinition {
40
40
  isPublished Boolean @default(false)
41
41
  tenantId String?
42
42
  formTypeId String?
43
+ scopeId String?
43
44
  metadata String? // JSON
44
45
  createdAt DateTime @default(now())
45
46
  updatedAt DateTime @updatedAt
@@ -47,12 +48,14 @@ model FormDefinition {
47
48
  updatedBy String?
48
49
 
49
50
  formType FormType? @relation(fields: [formTypeId], references: [id])
51
+ scope Scope? @relation(fields: [scopeId], references: [id])
50
52
  pages FormPage[]
51
53
  submissions FormSubmission[]
52
54
 
53
55
  @@unique([code, version, tenantId])
54
56
  @@index([tenantId])
55
57
  @@index([formTypeId])
58
+ @@index([scopeId])
56
59
  @@map("form_definitions")
57
60
  }
58
61
 
@@ -142,11 +145,79 @@ model FormVariable {
142
145
  rosterId String?
143
146
  roster FormRoster? @relation("RosterVariables", fields: [rosterId], references: [id], onDelete: Cascade)
144
147
 
148
+ // Optional link to a reusable VariableTemplate (Option B — resolved
149
+ // in-memory at load time). Local overrides live in `templateOverrides`.
150
+ templateId String?
151
+ template VariableTemplate? @relation(fields: [templateId], references: [id])
152
+ templateOverrides String? // JSON: Partial<IVariableTemplateOverrides>
153
+
145
154
  @@index([pageId])
146
155
  @@index([rosterId])
156
+ @@index([templateId])
147
157
  @@map("form_variables")
148
158
  }
149
159
 
160
+ // ─── Scope ────────────────────────────────────────────────
161
+
162
+ model Scope {
163
+ id String @id @default(cuid())
164
+ code String
165
+ name String // JSON LocalizedString or plain string
166
+ description String? // JSON LocalizedString or plain string
167
+ tenantId String @default("default")
168
+ metadata String? // JSON
169
+ createdAt DateTime @default(now())
170
+ updatedAt DateTime @updatedAt
171
+ createdBy String?
172
+ updatedBy String?
173
+
174
+ forms FormDefinition[]
175
+ templates VariableTemplate[]
176
+
177
+ @@unique([code, tenantId])
178
+ @@index([tenantId])
179
+ @@map("scopes")
180
+ }
181
+
182
+ // ─── Variable Template ────────────────────────────────────
183
+
184
+ model VariableTemplate {
185
+ id String @id @default(cuid())
186
+ code String
187
+ name String // JSON LocalizedString or plain string
188
+ scopeId String
189
+ tenantId String @default("default")
190
+
191
+ // Overridable fields (mirrors IFormVariable, minus instance-only ones)
192
+ variableType String
193
+ description String? // JSON LocalizedString or plain string
194
+ placeholder String? // JSON LocalizedString or plain string
195
+ isRequired Boolean @default(false)
196
+ isReadonly Boolean @default(false)
197
+ isHidden Boolean @default(false)
198
+ options String? // JSON: IVariableOption[]
199
+ validationRules String? // JSON: IValidationRule[]
200
+ conditions String? // JSON: IConditionRule[]
201
+ expression String?
202
+ dataSourceId String?
203
+ dataSourceDependencies String? // JSON: Record<string, string>
204
+ style String? // JSON: IComponentStyle
205
+ metadata String? // JSON
206
+
207
+ createdAt DateTime @default(now())
208
+ updatedAt DateTime @updatedAt
209
+ createdBy String?
210
+ updatedBy String?
211
+
212
+ scope Scope @relation(fields: [scopeId], references: [id])
213
+ variables FormVariable[]
214
+
215
+ @@unique([code, scopeId])
216
+ @@index([scopeId])
217
+ @@index([tenantId])
218
+ @@map("variable_templates")
219
+ }
220
+
150
221
  // ─── Form Submission ──────────────────────────────────────
151
222
 
152
223
  model FormSubmission {