@svgrid/enterprise 1.2.0 → 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/dist/cdn/svgrid-enterprise.svelte-external.js +26039 -805
- package/dist/designer/assets/index-Dp44bTid.js +939 -0
- package/dist/designer/assets/index-RJp6x8tw.css +1 -0
- package/dist/designer/assets/jszip.min-CjMo-QGg.js +2 -0
- package/dist/designer/index.html +13 -0
- package/dist/node/studio.js +22554 -0
- package/package.json +10 -3
- package/src/SvAuthGate.svelte +115 -0
- package/src/SvBoard.dom.test.ts +67 -0
- package/src/SvBoard.svelte +192 -0
- package/src/SvExportMenu.svelte +553 -0
- package/src/SvFileInput.svelte +113 -0
- package/src/SvGridEditPanel.dom.test.ts +146 -0
- package/src/SvGridEditPanel.svelte +793 -0
- package/src/SvGridMasterDetail.svelte +95 -0
- package/src/SvImportDialog.svelte +1020 -0
- package/src/SvLookupInput.svelte +180 -0
- package/src/SvRecordDetail.dom.test.ts +137 -0
- package/src/SvRecordDetail.svelte +288 -0
- package/src/SvSchedule.dom.test.ts +57 -0
- package/src/SvSchedule.svelte +156 -0
- package/src/SvSchemaChart.svelte +233 -0
- package/src/SvSchemaDashboard.svelte +130 -0
- package/src/ai-export-pdf.test.ts +74 -0
- package/src/ai-export-xlsx.test.ts +87 -0
- package/src/ai-export.test.ts +110 -0
- package/src/ai.ts +1188 -782
- package/src/edit-panel.test.ts +213 -0
- package/src/edit-panel.ts +228 -0
- package/src/export-conditional.test.ts +60 -0
- package/src/export-conditional.ts +94 -0
- package/src/export-ooxml.test.ts +152 -0
- package/src/export-ooxml.ts +485 -0
- package/src/export-pdf.test.ts +138 -0
- package/src/export-pdf.ts +245 -0
- package/src/export-print.test.ts +66 -0
- package/src/export-print.ts +132 -0
- package/src/export-serialize.test.ts +56 -0
- package/src/export-serialize.ts +24 -0
- package/src/export-xls.ts +196 -0
- package/src/export-xlsx-roundtrip.test.ts +120 -0
- package/src/export-xlsx.test.ts +150 -0
- package/src/export.test.ts +349 -0
- package/src/export.ts +1452 -549
- package/src/import-automap.test.ts +131 -0
- package/src/import-hardening.test.ts +158 -0
- package/src/import.ts +1042 -648
- package/src/index.ts +282 -0
- package/src/install.ts +134 -114
- package/src/license-core.test.ts +23 -0
- package/src/license-core.ts +35 -0
- package/src/license.ts +103 -90
- package/src/master-detail.test.ts +61 -0
- package/src/master-detail.ts +42 -0
- package/src/print.ts +107 -127
- package/src/schema-designer.test.ts +121 -0
- package/src/schema-designer.ts +142 -0
- package/src/schema.test.ts +268 -0
- package/src/schema.ts +499 -0
- package/src/smart-shim.ts +107 -105
- package/src/sources/aggregate.test.ts +79 -0
- package/src/sources/aggregate.ts +102 -0
- package/src/sources/auth-supabase.test.ts +80 -0
- package/src/sources/auth-supabase.ts +87 -0
- package/src/sources/dashboard.kpi.test.ts +50 -0
- package/src/sources/dashboard.test.ts +61 -0
- package/src/sources/dashboard.ts +136 -0
- package/src/sources/field-inference.test.ts +60 -0
- package/src/sources/field-inference.ts +63 -0
- package/src/sources/filters.test.ts +58 -0
- package/src/sources/filters.ts +64 -0
- package/src/sources/index.ts +67 -0
- package/src/sources/introspect-supabase.test.ts +100 -0
- package/src/sources/introspect-supabase.ts +119 -0
- package/src/sources/realtime-supabase.test.ts +93 -0
- package/src/sources/realtime-supabase.ts +99 -0
- package/src/sources/relation-lookup.test.ts +99 -0
- package/src/sources/relation-lookup.ts +128 -0
- package/src/sources/rest-adapters.test.ts +95 -0
- package/src/sources/rest-adapters.ts +120 -0
- package/src/sources/rest.test.ts +104 -0
- package/src/sources/rest.ts +129 -0
- package/src/sources/schema-from-columns.test.ts +106 -0
- package/src/sources/schema-from-columns.ts +88 -0
- package/src/sources/supabase.test.ts +110 -0
- package/src/sources/supabase.ts +99 -0
- package/src/sources/with-entity-rules.test.ts +104 -0
- package/src/sources/with-entity-rules.ts +78 -0
- package/src/sources/with-relation-labels.test.ts +75 -0
- package/src/sources/with-relation-labels.ts +73 -0
- package/src/studio/bug-report.test.ts +101 -0
- package/src/studio/bug-report.ts +165 -0
- package/src/studio/cli.test.ts +187 -0
- package/src/studio/cli.ts +112 -0
- package/src/studio/csv.test.ts +90 -0
- package/src/studio/csv.ts +165 -0
- package/src/studio/db-connect-string.test.ts +94 -0
- package/src/studio/db-connect-string.ts +128 -0
- package/src/studio/emit-project.test.ts +923 -0
- package/src/studio/emit-project.ts +1273 -0
- package/src/studio/emit-schema.test.ts +94 -0
- package/src/studio/emit-schema.ts +920 -0
- package/src/studio/index.ts +195 -0
- package/src/studio/introspect-db.test.ts +186 -0
- package/src/studio/introspect-db.ts +312 -0
- package/src/studio/introspect-prisma.test.ts +99 -0
- package/src/studio/introspect-prisma.ts +175 -0
- package/src/studio/introspect.test.ts +172 -0
- package/src/studio/introspect.ts +310 -0
- package/src/studio/pipeline.test.ts +42 -0
- package/src/studio/project-robust.test.ts +157 -0
- package/src/studio/project.test.ts +473 -0
- package/src/studio/project.ts +916 -0
- package/src/studio/sample-data.test.ts +58 -0
- package/src/studio/sample-data.ts +200 -0
- package/src/studio/samples/ats.ts +202 -0
- package/src/studio/samples/clinic.ts +177 -0
- package/src/studio/samples/crm.ts +250 -0
- package/src/studio/samples/ecommerce.ts +187 -0
- package/src/studio/samples/events.ts +199 -0
- package/src/studio/samples/fleet.ts +184 -0
- package/src/studio/samples/gym.ts +213 -0
- package/src/studio/samples/hr.ts +193 -0
- package/src/studio/samples/index.ts +55 -0
- package/src/studio/samples/insurance.ts +195 -0
- package/src/studio/samples/inventory.ts +182 -0
- package/src/studio/samples/invoicing.ts +162 -0
- package/src/studio/samples/library.ts +180 -0
- package/src/studio/samples/live-data.test.ts +98 -0
- package/src/studio/samples/live-data.ts +308 -0
- package/src/studio/samples/projects.ts +190 -0
- package/src/studio/samples/realestate.ts +196 -0
- package/src/studio/samples/restaurant.ts +187 -0
- package/src/studio/samples/samples.test.ts +208 -0
- package/src/studio/samples/school.ts +197 -0
- package/src/studio/samples/seed-floor.test.ts +25 -0
- package/src/studio/samples/shared.ts +305 -0
- package/src/studio/samples/subscriptions.ts +183 -0
- package/src/studio/samples/support.ts +182 -0
- package/src/studio/scaffold-app.test.ts +91 -0
- package/src/studio/scaffold-app.ts +161 -0
- package/src/studio/scaffold.test.ts +178 -0
- package/src/studio/scaffold.ts +374 -0
- package/src/studio/themes.ts +172 -0
- package/src/studio/verify.test.ts +47 -0
- package/src/studio/verify.ts +79 -0
- package/src/sveltekit/in-memory.test.ts +104 -0
- package/src/sveltekit/in-memory.ts +129 -0
- package/src/sveltekit/index.ts +23 -0
- package/src/sveltekit/query-plan.test.ts +109 -0
- package/src/sveltekit/query-plan.ts +125 -0
- package/src/sveltekit/sql-source.test.ts +185 -0
- package/src/sveltekit/sql-source.ts +166 -0
- package/src/sveltekit/sql.test.ts +80 -0
- package/src/sveltekit/sql.ts +131 -0
- package/src/sveltekit/transport.test.ts +175 -0
- package/src/sveltekit/transport.ts +254 -0
- package/src/sveltekit/types.ts +11 -0
- 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
|
+
}
|