@msbci/form-server 1.3.0 → 1.3.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@msbci/form-server",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "Form server — REST API with Prisma, multi-tenant, multi-database",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -21,20 +21,6 @@
21
21
  "publishConfig": {
22
22
  "access": "public"
23
23
  },
24
- "dependencies": {
25
- "@prisma/client": "^6.2.0",
26
- "zod": "^3.24.0",
27
- "@msbci/form-core": "1.3.0"
28
- },
29
- "devDependencies": {
30
- "prisma": "^6.2.0",
31
- "tsup": "^8.3.0",
32
- "vitest": "^2.1.0",
33
- "@vitest/coverage-v8": "^2.1.0",
34
- "typescript": "^5.7.0"
35
- },
36
- "sideEffects": false,
37
- "license": "SEE LICENSE IN LICENSE.md",
38
24
  "scripts": {
39
25
  "prisma:generate": "prisma generate --schema=src/prisma/schema.prisma",
40
26
  "prisma:sync": "prisma db push --schema=src/prisma/schema.prisma --skip-generate --accept-data-loss",
@@ -52,5 +38,20 @@
52
38
  "db:generate": "prisma generate --schema=src/prisma/schema.prisma",
53
39
  "db:migrate": "prisma migrate dev --schema=src/prisma/schema.prisma",
54
40
  "db:push": "prisma db push --schema=src/prisma/schema.prisma"
55
- }
56
- }
41
+ },
42
+ "dependencies": {
43
+ "@msbci/form-core": "workspace:*",
44
+ "@prisma/client": "^6.2.0",
45
+ "zod": "^3.24.0"
46
+ },
47
+ "devDependencies": {
48
+ "@types/node": "^20.0.0",
49
+ "@vitest/coverage-v8": "^2.1.0",
50
+ "prisma": "^6.2.0",
51
+ "tsup": "^8.3.0",
52
+ "typescript": "^5.7.0",
53
+ "vitest": "^2.1.0"
54
+ },
55
+ "sideEffects": false,
56
+ "license": "SEE LICENSE IN LICENSE.md"
57
+ }
@@ -40,25 +40,38 @@ model FormDefinition {
40
40
  isPublished Boolean @default(false)
41
41
  tenantId String?
42
42
  formTypeId String?
43
- scopeId String?
44
43
  metadata String? // JSON
45
44
  createdAt DateTime @default(now())
46
45
  updatedAt DateTime @updatedAt
47
46
  createdBy String?
48
47
  updatedBy String?
49
48
 
50
- formType FormType? @relation(fields: [formTypeId], references: [id])
51
- scope Scope? @relation(fields: [scopeId], references: [id])
49
+ formType FormType? @relation(fields: [formTypeId], references: [id])
50
+ scopes FormDefinitionScope[]
52
51
  pages FormPage[]
53
52
  submissions FormSubmission[]
54
53
 
55
54
  @@unique([code, version, tenantId])
56
55
  @@index([tenantId])
57
56
  @@index([formTypeId])
58
- @@index([scopeId])
59
57
  @@map("form_definitions")
60
58
  }
61
59
 
60
+ // Pivot table — one form can reference many scopes (priority = order).
61
+ model FormDefinitionScope {
62
+ formId String
63
+ scopeId String
64
+ order Int @default(0)
65
+
66
+ form FormDefinition @relation(fields: [formId], references: [id], onDelete: Cascade)
67
+ scope Scope @relation(fields: [scopeId], references: [id], onDelete: Cascade)
68
+
69
+ @@id([formId, scopeId])
70
+ @@index([formId, order])
71
+ @@index([scopeId])
72
+ @@map("form_definition_scopes")
73
+ }
74
+
62
75
  // ─── Form Page (navigation unit) ──────────────────────────
63
76
 
64
77
  model FormPage {
@@ -166,19 +179,50 @@ model Scope {
166
179
  description String? // JSON LocalizedString or plain string
167
180
  tenantId String @default("default")
168
181
  metadata String? // JSON
182
+ // Encrypted scope-level headers shared by all DataSourceConfig in the
183
+ // scope. Format produced by utils/encryption.ts. NULL when unset.
184
+ headers String?
169
185
  createdAt DateTime @default(now())
170
186
  updatedAt DateTime @updatedAt
171
187
  createdBy String?
172
188
  updatedBy String?
173
189
 
174
- forms FormDefinition[]
175
- templates VariableTemplate[]
190
+ forms FormDefinitionScope[]
191
+ templates VariableTemplate[]
192
+ dataSources DataSourceConfig[]
176
193
 
177
194
  @@unique([code, tenantId])
178
195
  @@index([tenantId])
179
196
  @@map("scopes")
180
197
  }
181
198
 
199
+ // ─── Data Source Config (admin-managed REST sources) ──────
200
+
201
+ model DataSourceConfig {
202
+ id String @id @default(cuid())
203
+ code String
204
+ name String // JSON LocalizedString
205
+ scopeId String
206
+ url String
207
+ method String @default("GET")
208
+ queryParam String? @default("q")
209
+ valueField String
210
+ labelField String
211
+ headersOverride String? // JSON encrypted (utils/encryption.ts)
212
+ dependencies String? // JSON Record<string,string> (urlParam → varCode)
213
+ metadata String? // JSON
214
+ createdAt DateTime @default(now())
215
+ updatedAt DateTime @updatedAt
216
+ createdBy String?
217
+ updatedBy String?
218
+
219
+ scope Scope @relation(fields: [scopeId], references: [id], onDelete: Cascade)
220
+
221
+ @@unique([code, scopeId])
222
+ @@index([scopeId])
223
+ @@map("data_source_configs")
224
+ }
225
+
182
226
  // ─── Variable Template ────────────────────────────────────
183
227
 
184
228
  model VariableTemplate {