@svgrid/enterprise 1.2.0 → 2.0.1

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.
Files changed (159) hide show
  1. package/dist/cdn/svgrid-enterprise.svelte-external.js +26039 -805
  2. package/dist/designer/assets/index-Dp44bTid.js +939 -0
  3. package/dist/designer/assets/index-RJp6x8tw.css +1 -0
  4. package/dist/designer/assets/jszip.min-CjMo-QGg.js +2 -0
  5. package/dist/designer/index.html +13 -0
  6. package/dist/node/studio.js +22554 -0
  7. package/package.json +92 -83
  8. package/src/SvAuthGate.svelte +115 -0
  9. package/src/SvBoard.dom.test.ts +67 -0
  10. package/src/SvBoard.svelte +192 -0
  11. package/src/SvExportMenu.svelte +553 -0
  12. package/src/SvFileInput.svelte +113 -0
  13. package/src/SvGridEditPanel.dom.test.ts +146 -0
  14. package/src/SvGridEditPanel.svelte +793 -0
  15. package/src/SvGridMasterDetail.svelte +95 -0
  16. package/src/SvImportDialog.svelte +1020 -0
  17. package/src/SvLookupInput.svelte +180 -0
  18. package/src/SvRecordDetail.dom.test.ts +137 -0
  19. package/src/SvRecordDetail.svelte +288 -0
  20. package/src/SvSchedule.dom.test.ts +57 -0
  21. package/src/SvSchedule.svelte +156 -0
  22. package/src/SvSchemaChart.svelte +233 -0
  23. package/src/SvSchemaDashboard.svelte +130 -0
  24. package/src/ai-export-pdf.test.ts +74 -0
  25. package/src/ai-export-xlsx.test.ts +87 -0
  26. package/src/ai-export.test.ts +110 -0
  27. package/src/ai.ts +1188 -782
  28. package/src/edit-panel.test.ts +213 -0
  29. package/src/edit-panel.ts +228 -0
  30. package/src/export-conditional.test.ts +60 -0
  31. package/src/export-conditional.ts +94 -0
  32. package/src/export-ooxml.test.ts +152 -0
  33. package/src/export-ooxml.ts +485 -0
  34. package/src/export-pdf.test.ts +138 -0
  35. package/src/export-pdf.ts +245 -0
  36. package/src/export-print.test.ts +66 -0
  37. package/src/export-print.ts +132 -0
  38. package/src/export-serialize.test.ts +56 -0
  39. package/src/export-serialize.ts +24 -0
  40. package/src/export-xls.ts +196 -0
  41. package/src/export-xlsx-roundtrip.test.ts +120 -0
  42. package/src/export-xlsx.test.ts +150 -0
  43. package/src/export.test.ts +349 -0
  44. package/src/export.ts +1452 -549
  45. package/src/import-automap.test.ts +131 -0
  46. package/src/import-hardening.test.ts +158 -0
  47. package/src/import.ts +1042 -648
  48. package/src/index.ts +282 -0
  49. package/src/install.ts +134 -114
  50. package/src/license-core.test.ts +23 -0
  51. package/src/license-core.ts +35 -0
  52. package/src/license.ts +103 -90
  53. package/src/master-detail.test.ts +61 -0
  54. package/src/master-detail.ts +42 -0
  55. package/src/print.ts +107 -127
  56. package/src/schema-designer.test.ts +121 -0
  57. package/src/schema-designer.ts +142 -0
  58. package/src/schema.test.ts +268 -0
  59. package/src/schema.ts +499 -0
  60. package/src/smart-shim.ts +107 -105
  61. package/src/sources/aggregate.test.ts +79 -0
  62. package/src/sources/aggregate.ts +102 -0
  63. package/src/sources/auth-supabase.test.ts +80 -0
  64. package/src/sources/auth-supabase.ts +87 -0
  65. package/src/sources/dashboard.kpi.test.ts +50 -0
  66. package/src/sources/dashboard.test.ts +61 -0
  67. package/src/sources/dashboard.ts +136 -0
  68. package/src/sources/field-inference.test.ts +60 -0
  69. package/src/sources/field-inference.ts +63 -0
  70. package/src/sources/filters.test.ts +58 -0
  71. package/src/sources/filters.ts +64 -0
  72. package/src/sources/index.ts +67 -0
  73. package/src/sources/introspect-supabase.test.ts +100 -0
  74. package/src/sources/introspect-supabase.ts +119 -0
  75. package/src/sources/realtime-supabase.test.ts +93 -0
  76. package/src/sources/realtime-supabase.ts +99 -0
  77. package/src/sources/relation-lookup.test.ts +99 -0
  78. package/src/sources/relation-lookup.ts +128 -0
  79. package/src/sources/rest-adapters.test.ts +95 -0
  80. package/src/sources/rest-adapters.ts +120 -0
  81. package/src/sources/rest.test.ts +104 -0
  82. package/src/sources/rest.ts +129 -0
  83. package/src/sources/schema-from-columns.test.ts +106 -0
  84. package/src/sources/schema-from-columns.ts +88 -0
  85. package/src/sources/supabase.test.ts +110 -0
  86. package/src/sources/supabase.ts +99 -0
  87. package/src/sources/with-entity-rules.test.ts +104 -0
  88. package/src/sources/with-entity-rules.ts +78 -0
  89. package/src/sources/with-relation-labels.test.ts +75 -0
  90. package/src/sources/with-relation-labels.ts +73 -0
  91. package/src/studio/bug-report.test.ts +101 -0
  92. package/src/studio/bug-report.ts +165 -0
  93. package/src/studio/cli.test.ts +187 -0
  94. package/src/studio/cli.ts +112 -0
  95. package/src/studio/csv.test.ts +90 -0
  96. package/src/studio/csv.ts +165 -0
  97. package/src/studio/db-connect-string.test.ts +94 -0
  98. package/src/studio/db-connect-string.ts +128 -0
  99. package/src/studio/emit-project.test.ts +923 -0
  100. package/src/studio/emit-project.ts +1273 -0
  101. package/src/studio/emit-schema.test.ts +94 -0
  102. package/src/studio/emit-schema.ts +920 -0
  103. package/src/studio/index.ts +195 -0
  104. package/src/studio/introspect-db.test.ts +186 -0
  105. package/src/studio/introspect-db.ts +312 -0
  106. package/src/studio/introspect-prisma.test.ts +99 -0
  107. package/src/studio/introspect-prisma.ts +175 -0
  108. package/src/studio/introspect.test.ts +172 -0
  109. package/src/studio/introspect.ts +310 -0
  110. package/src/studio/pipeline.test.ts +42 -0
  111. package/src/studio/project-robust.test.ts +157 -0
  112. package/src/studio/project.test.ts +473 -0
  113. package/src/studio/project.ts +916 -0
  114. package/src/studio/sample-data.test.ts +58 -0
  115. package/src/studio/sample-data.ts +200 -0
  116. package/src/studio/samples/ats.ts +202 -0
  117. package/src/studio/samples/clinic.ts +177 -0
  118. package/src/studio/samples/crm.ts +250 -0
  119. package/src/studio/samples/ecommerce.ts +187 -0
  120. package/src/studio/samples/events.ts +199 -0
  121. package/src/studio/samples/fleet.ts +184 -0
  122. package/src/studio/samples/gym.ts +213 -0
  123. package/src/studio/samples/hr.ts +193 -0
  124. package/src/studio/samples/index.ts +55 -0
  125. package/src/studio/samples/insurance.ts +195 -0
  126. package/src/studio/samples/inventory.ts +182 -0
  127. package/src/studio/samples/invoicing.ts +162 -0
  128. package/src/studio/samples/library.ts +180 -0
  129. package/src/studio/samples/live-data.test.ts +98 -0
  130. package/src/studio/samples/live-data.ts +308 -0
  131. package/src/studio/samples/projects.ts +190 -0
  132. package/src/studio/samples/realestate.ts +196 -0
  133. package/src/studio/samples/restaurant.ts +187 -0
  134. package/src/studio/samples/samples.test.ts +208 -0
  135. package/src/studio/samples/school.ts +197 -0
  136. package/src/studio/samples/seed-floor.test.ts +25 -0
  137. package/src/studio/samples/shared.ts +305 -0
  138. package/src/studio/samples/subscriptions.ts +183 -0
  139. package/src/studio/samples/support.ts +182 -0
  140. package/src/studio/scaffold-app.test.ts +91 -0
  141. package/src/studio/scaffold-app.ts +161 -0
  142. package/src/studio/scaffold.test.ts +178 -0
  143. package/src/studio/scaffold.ts +374 -0
  144. package/src/studio/themes.ts +172 -0
  145. package/src/studio/verify.test.ts +47 -0
  146. package/src/studio/verify.ts +79 -0
  147. package/src/sveltekit/in-memory.test.ts +104 -0
  148. package/src/sveltekit/in-memory.ts +129 -0
  149. package/src/sveltekit/index.ts +23 -0
  150. package/src/sveltekit/query-plan.test.ts +109 -0
  151. package/src/sveltekit/query-plan.ts +125 -0
  152. package/src/sveltekit/sql-source.test.ts +185 -0
  153. package/src/sveltekit/sql-source.ts +166 -0
  154. package/src/sveltekit/sql.test.ts +80 -0
  155. package/src/sveltekit/sql.ts +131 -0
  156. package/src/sveltekit/transport.test.ts +175 -0
  157. package/src/sveltekit/transport.ts +254 -0
  158. package/src/sveltekit/types.ts +11 -0
  159. package/src/upgrade-prompt.ts +149 -148
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Connection-string helpers for the Studio "connect your database" flow. A
3
+ * guided form collects host / port / database / user / password / SSL and
4
+ * `buildConnectionString` assembles the driver-ready URL, so users never have to
5
+ * hand-write `postgresql://user:pass@host:5432/db`. `parseConnectionString` does
6
+ * the reverse (best-effort) to pre-fill the form from a pasted URL, and
7
+ * `redactConnectionString` masks the password for display / logs.
8
+ *
9
+ * Pure and node-safe (no driver, no node APIs) - shared by the designer server,
10
+ * the CLI, and the (private) designer SPA, which imports it from
11
+ * `@svgrid/enterprise/studio`.
12
+ */
13
+ import type { SqlDialectName } from './introspect-db.js'
14
+
15
+ export type SqlConnectionParts = {
16
+ host?: string
17
+ port?: number | string
18
+ database?: string
19
+ user?: string
20
+ password?: string
21
+ /** Require TLS (adds the dialect's SSL query param). */
22
+ ssl?: boolean
23
+ /** SQLite only: path to the `.db` file (host / user / etc are ignored). */
24
+ file?: string
25
+ }
26
+
27
+ /** The npm driver package each dialect needs installed to connect. */
28
+ export const DRIVER_PACKAGE: Record<SqlDialectName, string> = {
29
+ postgres: 'pg',
30
+ supabase: 'pg',
31
+ mysql: 'mysql2',
32
+ mssql: 'mssql',
33
+ sqlite: 'better-sqlite3',
34
+ }
35
+
36
+ /** The default TCP port per dialect (null for the file-based SQLite). */
37
+ export const DEFAULT_PORT: Record<SqlDialectName, number | null> = {
38
+ postgres: 5432,
39
+ supabase: 5432,
40
+ mysql: 3306,
41
+ mssql: 1433,
42
+ sqlite: null,
43
+ }
44
+
45
+ /** SQLite is a file on disk - the form shows a path field, not host/port/auth. */
46
+ export function isFileDialect(dialect: SqlDialectName): boolean {
47
+ return dialect === 'sqlite'
48
+ }
49
+
50
+ function urlScheme(dialect: SqlDialectName): string {
51
+ if (dialect === 'mysql') return 'mysql'
52
+ if (dialect === 'mssql') return 'mssql'
53
+ return 'postgresql' // postgres + supabase
54
+ }
55
+
56
+ function sslQuery(dialect: SqlDialectName, ssl?: boolean): string {
57
+ if (!ssl) return ''
58
+ if (dialect === 'mysql') return `?ssl=${encodeURIComponent('{"rejectUnauthorized":true}')}`
59
+ if (dialect === 'mssql') return '?encrypt=true&trustServerCertificate=true'
60
+ return '?sslmode=require' // postgres + supabase
61
+ }
62
+
63
+ /**
64
+ * Assemble a driver-ready connection string from the guided-form fields. SQLite
65
+ * returns the bare file path (what better-sqlite3 expects); every other dialect
66
+ * returns a URL with the credentials percent-encoded so passwords containing
67
+ * `@`, `:` or `/` don't corrupt it.
68
+ */
69
+ export function buildConnectionString(dialect: SqlDialectName, parts: SqlConnectionParts): string {
70
+ if (isFileDialect(dialect)) {
71
+ const file = (parts.file ?? parts.database ?? '').trim()
72
+ if (!file) throw new Error('buildConnectionString: SQLite needs a database file path')
73
+ return file
74
+ }
75
+ const host = (parts.host ?? '').trim() || 'localhost'
76
+ const portRaw = parts.port != null && `${parts.port}`.trim() !== '' ? Number(parts.port) : DEFAULT_PORT[dialect]
77
+ const port = Number.isFinite(portRaw as number) ? (portRaw as number) : null
78
+ const db = (parts.database ?? '').trim()
79
+ const user = (parts.user ?? '').trim()
80
+ const pass = parts.password ?? ''
81
+ const auth = user
82
+ ? `${encodeURIComponent(user)}${pass ? `:${encodeURIComponent(pass)}` : ''}@`
83
+ : ''
84
+ const hostPort = port ? `${host}:${port}` : host
85
+ const dbPath = db ? `/${encodeURIComponent(db)}` : ''
86
+ return `${urlScheme(dialect)}://${auth}${hostPort}${dbPath}${sslQuery(dialect, parts.ssl)}`
87
+ }
88
+
89
+ /**
90
+ * Best-effort inverse of `buildConnectionString` - split a pasted URL back into
91
+ * form fields so the guided form can pre-fill. Returns `{}` when the input isn't
92
+ * a parseable URL (the caller keeps whatever the user typed).
93
+ */
94
+ export function parseConnectionString(dialect: SqlDialectName, value: string): SqlConnectionParts {
95
+ const raw = (value ?? '').trim()
96
+ if (!raw) return {}
97
+ if (isFileDialect(dialect)) return { file: raw }
98
+ try {
99
+ const u = new URL(raw)
100
+ const parts: SqlConnectionParts = {}
101
+ if (u.hostname) parts.host = u.hostname
102
+ if (u.port) parts.port = Number(u.port)
103
+ const db = u.pathname.replace(/^\//, '')
104
+ if (db) parts.database = decodeURIComponent(db)
105
+ if (u.username) parts.user = decodeURIComponent(u.username)
106
+ if (u.password) parts.password = decodeURIComponent(u.password)
107
+ const q = u.searchParams
108
+ if (q.get('sslmode') === 'require' || q.has('ssl') || q.get('encrypt') === 'true') parts.ssl = true
109
+ return parts
110
+ } catch {
111
+ return {}
112
+ }
113
+ }
114
+
115
+ /** Mask the password in a connection string for display / logging. */
116
+ export function redactConnectionString(value: string): string {
117
+ const raw = (value ?? '').trim()
118
+ if (!raw) return raw
119
+ try {
120
+ const u = new URL(raw)
121
+ if (!u.password) return raw
122
+ u.password = '***'
123
+ return u.toString()
124
+ } catch {
125
+ // key=value strings (e.g. mssql "Password=...") and bare paths.
126
+ return raw.replace(/(password|pwd)=([^;&\s]+)/gi, '$1=***')
127
+ }
128
+ }