@squadbase/vite-server 0.1.12-dev.a9ac647 → 0.1.17-dev.3b633bb
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/cli/index.js +14375 -1652
- package/dist/connectors/airtable-oauth.js +282 -46
- package/dist/connectors/airtable.js +319 -51
- package/dist/connectors/amplitude.js +322 -47
- package/dist/connectors/anthropic.js +135 -47
- package/dist/connectors/asana.js +327 -49
- package/dist/connectors/attio.js +302 -49
- package/dist/connectors/aws-billing.js +287 -46
- package/dist/connectors/azure-sql.js +421 -102
- package/dist/connectors/backlog-api-key.js +317 -47
- package/dist/connectors/clickup.js +338 -49
- package/dist/connectors/cosmosdb.js +305 -50
- package/dist/connectors/customerio.js +319 -47
- package/dist/connectors/dbt.js +340 -47
- package/dist/connectors/freshdesk.js +342 -53
- package/dist/connectors/freshsales.js +333 -52
- package/dist/connectors/freshservice.js +361 -53
- package/dist/connectors/gamma.js +327 -52
- package/dist/connectors/gemini.js +134 -47
- package/dist/connectors/github.js +386 -49
- package/dist/connectors/gmail-oauth.js +204 -7
- package/dist/connectors/gmail.js +350 -47
- package/dist/connectors/google-ads.js +288 -46
- package/dist/connectors/google-analytics-oauth.js +310 -46
- package/dist/connectors/google-analytics.js +547 -87
- package/dist/connectors/google-audit-log.js +438 -47
- package/dist/connectors/google-calendar-oauth.js +259 -46
- package/dist/connectors/google-calendar.js +359 -47
- package/dist/connectors/google-docs.js +220 -6
- package/dist/connectors/google-drive.js +262 -5
- package/dist/connectors/google-search-console-oauth.js +256 -46
- package/dist/connectors/google-sheets.js +272 -47
- package/dist/connectors/google-slides.js +205 -6
- package/dist/connectors/grafana.js +332 -49
- package/dist/connectors/hubspot-oauth.js +208 -5
- package/dist/connectors/hubspot.js +306 -49
- package/dist/connectors/influxdb.js +416 -51
- package/dist/connectors/intercom-oauth.js +210 -5
- package/dist/connectors/intercom.js +302 -49
- package/dist/connectors/jdbc.js +762 -110
- package/dist/connectors/jira-api-key.js +326 -47
- package/dist/connectors/kintone-api-token.js +281 -47
- package/dist/connectors/kintone.js +328 -47
- package/dist/connectors/linear.js +330 -49
- package/dist/connectors/linkedin-ads.js +268 -50
- package/dist/connectors/mailchimp-oauth.js +268 -46
- package/dist/connectors/mailchimp.js +320 -49
- package/dist/connectors/meta-ads-oauth.js +273 -48
- package/dist/connectors/meta-ads.js +285 -50
- package/dist/connectors/mixpanel.js +338 -47
- package/dist/connectors/monday.js +360 -49
- package/dist/connectors/mongodb.js +319 -57
- package/dist/connectors/notion-oauth.js +231 -5
- package/dist/connectors/notion.js +323 -51
- package/dist/connectors/openai.js +134 -47
- package/dist/connectors/oracle.js +454 -103
- package/dist/connectors/outlook-oauth.js +204 -5
- package/dist/connectors/powerbi-oauth.js +498 -5
- package/dist/connectors/salesforce.js +384 -49
- package/dist/connectors/semrush.js +609 -49
- package/dist/connectors/sentry.js +289 -50
- package/dist/connectors/shopify-oauth.js +187 -5
- package/dist/connectors/shopify.js +357 -47
- package/dist/connectors/sqlserver.js +415 -102
- package/dist/connectors/stripe-api-key.js +269 -46
- package/dist/connectors/stripe-oauth.js +202 -5
- package/dist/connectors/supabase.js +303 -48
- package/dist/connectors/tableau.js +536 -163
- package/dist/connectors/tiktok-ads.js +279 -48
- package/dist/connectors/wix-store.js +320 -49
- package/dist/connectors/zendesk-oauth.js +239 -5
- package/dist/connectors/zendesk.js +358 -47
- package/dist/index.d.ts +149 -1
- package/dist/index.js +15057 -2117
- package/dist/main.js +15005 -2073
- package/dist/vite-plugin.js +14752 -2019
- package/package.json +1 -1
|
@@ -1,101 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
description;
|
|
6
|
-
envVarBaseKey;
|
|
7
|
-
type;
|
|
8
|
-
secret;
|
|
9
|
-
required;
|
|
10
|
-
constructor(config) {
|
|
11
|
-
this.slug = config.slug;
|
|
12
|
-
this.name = config.name;
|
|
13
|
-
this.description = config.description;
|
|
14
|
-
this.envVarBaseKey = config.envVarBaseKey;
|
|
15
|
-
this.type = config.type;
|
|
16
|
-
this.secret = config.secret;
|
|
17
|
-
this.required = config.required;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Get the parameter value from a ConnectorConnectionObject.
|
|
21
|
-
*/
|
|
22
|
-
getValue(connection2) {
|
|
23
|
-
const param = connection2.parameters.find(
|
|
24
|
-
(p) => p.parameterSlug === this.slug
|
|
25
|
-
);
|
|
26
|
-
if (!param || param.value == null) {
|
|
27
|
-
throw new Error(
|
|
28
|
-
`Parameter "${this.slug}" not found or has no value in connection "${connection2.id}"`
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
return param.value;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Try to get the parameter value. Returns undefined if not found (for optional params).
|
|
35
|
-
*/
|
|
36
|
-
tryGetValue(connection2) {
|
|
37
|
-
const param = connection2.parameters.find(
|
|
38
|
-
(p) => p.parameterSlug === this.slug
|
|
39
|
-
);
|
|
40
|
-
if (!param || param.value == null) return void 0;
|
|
41
|
-
return param.value;
|
|
42
|
-
}
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
+
var __esm = (fn, res) => function __init() {
|
|
4
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
43
5
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
sshHost: new ParameterDefinition({
|
|
48
|
-
slug: "ssh-host",
|
|
49
|
-
name: "SSH Tunnel Host",
|
|
50
|
-
description: "Optional. Hostname of the SSH bastion to tunnel through. Leave empty to connect directly.",
|
|
51
|
-
envVarBaseKey: "SSH_TUNNEL_HOST",
|
|
52
|
-
type: "text",
|
|
53
|
-
secret: false,
|
|
54
|
-
required: false
|
|
55
|
-
}),
|
|
56
|
-
sshPort: new ParameterDefinition({
|
|
57
|
-
slug: "ssh-port",
|
|
58
|
-
name: "SSH Tunnel Port",
|
|
59
|
-
description: "Optional. SSH port of the bastion host (default: 22).",
|
|
60
|
-
envVarBaseKey: "SSH_TUNNEL_PORT",
|
|
61
|
-
type: "text",
|
|
62
|
-
secret: false,
|
|
63
|
-
required: false
|
|
64
|
-
}),
|
|
65
|
-
sshUsername: new ParameterDefinition({
|
|
66
|
-
slug: "ssh-username",
|
|
67
|
-
name: "SSH Tunnel Username",
|
|
68
|
-
description: "Optional. Username for SSH authentication. Required when SSH Tunnel Host is set.",
|
|
69
|
-
envVarBaseKey: "SSH_TUNNEL_USERNAME",
|
|
70
|
-
type: "text",
|
|
71
|
-
secret: false,
|
|
72
|
-
required: false
|
|
73
|
-
}),
|
|
74
|
-
sshPrivateKeyBase64: new ParameterDefinition({
|
|
75
|
-
slug: "ssh-private-key-base64",
|
|
76
|
-
name: "SSH Private Key",
|
|
77
|
-
description: "Optional. Private key (PEM, base64-encoded) used for SSH authentication. Required when SSH Tunnel Host is set.",
|
|
78
|
-
envVarBaseKey: "SSH_TUNNEL_PRIVATE_KEY_BASE64",
|
|
79
|
-
type: "base64EncodedText",
|
|
80
|
-
secret: true,
|
|
81
|
-
required: false
|
|
82
|
-
}),
|
|
83
|
-
sshPassphrase: new ParameterDefinition({
|
|
84
|
-
slug: "ssh-passphrase",
|
|
85
|
-
name: "SSH Private Key Passphrase",
|
|
86
|
-
description: "Optional. Passphrase for the SSH private key, if it is encrypted.",
|
|
87
|
-
envVarBaseKey: "SSH_TUNNEL_PASSPHRASE",
|
|
88
|
-
type: "text",
|
|
89
|
-
secret: true,
|
|
90
|
-
required: false
|
|
91
|
-
})
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
92
9
|
};
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
10
|
+
|
|
11
|
+
// ../connectors/src/parameter-definition.ts
|
|
12
|
+
var ParameterDefinition;
|
|
13
|
+
var init_parameter_definition = __esm({
|
|
14
|
+
"../connectors/src/parameter-definition.ts"() {
|
|
15
|
+
"use strict";
|
|
16
|
+
ParameterDefinition = class {
|
|
17
|
+
slug;
|
|
18
|
+
name;
|
|
19
|
+
description;
|
|
20
|
+
envVarBaseKey;
|
|
21
|
+
type;
|
|
22
|
+
secret;
|
|
23
|
+
required;
|
|
24
|
+
constructor(config) {
|
|
25
|
+
this.slug = config.slug;
|
|
26
|
+
this.name = config.name;
|
|
27
|
+
this.description = config.description;
|
|
28
|
+
this.envVarBaseKey = config.envVarBaseKey;
|
|
29
|
+
this.type = config.type;
|
|
30
|
+
this.secret = config.secret;
|
|
31
|
+
this.required = config.required;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get the parameter value from a ConnectorConnectionObject.
|
|
35
|
+
*/
|
|
36
|
+
getValue(connection2) {
|
|
37
|
+
const param = connection2.parameters.find(
|
|
38
|
+
(p) => p.parameterSlug === this.slug
|
|
39
|
+
);
|
|
40
|
+
if (!param || param.value == null) {
|
|
41
|
+
throw new Error(
|
|
42
|
+
`Parameter "${this.slug}" not found or has no value in connection "${connection2.id}"`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
return param.value;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Try to get the parameter value. Returns undefined if not found (for optional params).
|
|
49
|
+
*/
|
|
50
|
+
tryGetValue(connection2) {
|
|
51
|
+
const param = connection2.parameters.find(
|
|
52
|
+
(p) => p.parameterSlug === this.slug
|
|
53
|
+
);
|
|
54
|
+
if (!param || param.value == null) return void 0;
|
|
55
|
+
return param.value;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
97
58
|
}
|
|
98
59
|
});
|
|
60
|
+
|
|
61
|
+
// ../connectors/src/lib/ssh-tunnel.ts
|
|
99
62
|
function connectionParamsToRecord(connection2) {
|
|
100
63
|
const out = {};
|
|
101
64
|
for (const p of connection2.parameters) {
|
|
@@ -166,11 +129,68 @@ async function maybeOpenSshTunnelHostPort(params, dbHost, dbPort) {
|
|
|
166
129
|
}
|
|
167
130
|
};
|
|
168
131
|
}
|
|
132
|
+
var sshTunnelParameters, NOOP_TUNNEL_HOSTPORT;
|
|
133
|
+
var init_ssh_tunnel = __esm({
|
|
134
|
+
"../connectors/src/lib/ssh-tunnel.ts"() {
|
|
135
|
+
"use strict";
|
|
136
|
+
init_parameter_definition();
|
|
137
|
+
sshTunnelParameters = {
|
|
138
|
+
sshHost: new ParameterDefinition({
|
|
139
|
+
slug: "ssh-host",
|
|
140
|
+
name: "SSH Tunnel Host",
|
|
141
|
+
description: "Optional. Hostname of the SSH bastion to tunnel through. Leave empty to connect directly.",
|
|
142
|
+
envVarBaseKey: "SSH_TUNNEL_HOST",
|
|
143
|
+
type: "text",
|
|
144
|
+
secret: false,
|
|
145
|
+
required: false
|
|
146
|
+
}),
|
|
147
|
+
sshPort: new ParameterDefinition({
|
|
148
|
+
slug: "ssh-port",
|
|
149
|
+
name: "SSH Tunnel Port",
|
|
150
|
+
description: "Optional. SSH port of the bastion host (default: 22).",
|
|
151
|
+
envVarBaseKey: "SSH_TUNNEL_PORT",
|
|
152
|
+
type: "text",
|
|
153
|
+
secret: false,
|
|
154
|
+
required: false
|
|
155
|
+
}),
|
|
156
|
+
sshUsername: new ParameterDefinition({
|
|
157
|
+
slug: "ssh-username",
|
|
158
|
+
name: "SSH Tunnel Username",
|
|
159
|
+
description: "Optional. Username for SSH authentication. Required when SSH Tunnel Host is set.",
|
|
160
|
+
envVarBaseKey: "SSH_TUNNEL_USERNAME",
|
|
161
|
+
type: "text",
|
|
162
|
+
secret: false,
|
|
163
|
+
required: false
|
|
164
|
+
}),
|
|
165
|
+
sshPrivateKeyBase64: new ParameterDefinition({
|
|
166
|
+
slug: "ssh-private-key-base64",
|
|
167
|
+
name: "SSH Private Key",
|
|
168
|
+
description: "Optional. Private key (PEM, base64-encoded) used for SSH authentication. Required when SSH Tunnel Host is set.",
|
|
169
|
+
envVarBaseKey: "SSH_TUNNEL_PRIVATE_KEY_BASE64",
|
|
170
|
+
type: "base64EncodedText",
|
|
171
|
+
secret: true,
|
|
172
|
+
required: false
|
|
173
|
+
}),
|
|
174
|
+
sshPassphrase: new ParameterDefinition({
|
|
175
|
+
slug: "ssh-passphrase",
|
|
176
|
+
name: "SSH Private Key Passphrase",
|
|
177
|
+
description: "Optional. Passphrase for the SSH private key, if it is encrypted.",
|
|
178
|
+
envVarBaseKey: "SSH_TUNNEL_PASSPHRASE",
|
|
179
|
+
type: "text",
|
|
180
|
+
secret: true,
|
|
181
|
+
required: false
|
|
182
|
+
})
|
|
183
|
+
};
|
|
184
|
+
NOOP_TUNNEL_HOSTPORT = (host, port) => ({
|
|
185
|
+
host,
|
|
186
|
+
port,
|
|
187
|
+
close: async () => {
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
});
|
|
169
192
|
|
|
170
193
|
// ../connectors/src/connectors/sqlserver/utils.ts
|
|
171
|
-
var SQLSERVER_PREFIX_RE = /^(?:jdbc:)?sqlserver:\/\//i;
|
|
172
|
-
var TRUE_VALUES = /* @__PURE__ */ new Set(["true", "1", "yes"]);
|
|
173
|
-
var FALSE_VALUES = /* @__PURE__ */ new Set(["false", "0", "no"]);
|
|
174
194
|
function parseBoolean(value) {
|
|
175
195
|
if (value == null) return void 0;
|
|
176
196
|
const lower = value.toLowerCase();
|
|
@@ -237,8 +257,34 @@ function toMssqlConfig(parsed, defaults = {}) {
|
|
|
237
257
|
function redactSqlServerUrl(jdbcUrl) {
|
|
238
258
|
return jdbcUrl.replace(/(:\/\/)([^@/;]+)@/, "$1***@").replace(/(password\s*=\s*)([^;]+)/gi, "$1***");
|
|
239
259
|
}
|
|
260
|
+
async function runSqlServerSetupQuery(params, sql, forceEncrypt) {
|
|
261
|
+
const { runMssqlQuery: runMssqlQuery2 } = await Promise.resolve().then(() => (init_mssql_runner(), mssql_runner_exports));
|
|
262
|
+
const parsed = parseSqlServerJdbcUrl(params["jdbc-url"] ?? "", {
|
|
263
|
+
username: params["username"],
|
|
264
|
+
password: params["password"]
|
|
265
|
+
});
|
|
266
|
+
const result = await runMssqlQuery2(parsed, sql, {
|
|
267
|
+
forceEncrypt,
|
|
268
|
+
tunnelParams: params
|
|
269
|
+
});
|
|
270
|
+
return result.rows;
|
|
271
|
+
}
|
|
272
|
+
var SQLSERVER_PREFIX_RE, TRUE_VALUES, FALSE_VALUES;
|
|
273
|
+
var init_utils = __esm({
|
|
274
|
+
"../connectors/src/connectors/sqlserver/utils.ts"() {
|
|
275
|
+
"use strict";
|
|
276
|
+
SQLSERVER_PREFIX_RE = /^(?:jdbc:)?sqlserver:\/\//i;
|
|
277
|
+
TRUE_VALUES = /* @__PURE__ */ new Set(["true", "1", "yes"]);
|
|
278
|
+
FALSE_VALUES = /* @__PURE__ */ new Set(["false", "0", "no"]);
|
|
279
|
+
}
|
|
280
|
+
});
|
|
240
281
|
|
|
241
282
|
// ../connectors/src/lib/mssql-runner.ts
|
|
283
|
+
var mssql_runner_exports = {};
|
|
284
|
+
__export(mssql_runner_exports, {
|
|
285
|
+
checkMssqlConnection: () => checkMssqlConnection,
|
|
286
|
+
runMssqlQuery: () => runMssqlQuery
|
|
287
|
+
});
|
|
242
288
|
async function importMssql() {
|
|
243
289
|
const mod = await import("mssql");
|
|
244
290
|
return mod.default ?? mod;
|
|
@@ -287,8 +333,20 @@ async function checkMssqlConnection(url, credentials, options = {}) {
|
|
|
287
333
|
return { success: false, error: msg };
|
|
288
334
|
}
|
|
289
335
|
}
|
|
336
|
+
var init_mssql_runner = __esm({
|
|
337
|
+
"../connectors/src/lib/mssql-runner.ts"() {
|
|
338
|
+
"use strict";
|
|
339
|
+
init_ssh_tunnel();
|
|
340
|
+
init_utils();
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
// ../connectors/src/connectors/sqlserver/sdk/index.ts
|
|
345
|
+
init_mssql_runner();
|
|
290
346
|
|
|
291
347
|
// ../connectors/src/connectors/sqlserver/parameters.ts
|
|
348
|
+
init_parameter_definition();
|
|
349
|
+
init_ssh_tunnel();
|
|
292
350
|
var parameters = {
|
|
293
351
|
jdbcUrl: new ParameterDefinition({
|
|
294
352
|
slug: "jdbc-url",
|
|
@@ -321,6 +379,7 @@ var parameters = {
|
|
|
321
379
|
};
|
|
322
380
|
|
|
323
381
|
// ../connectors/src/connectors/sqlserver/sdk/index.ts
|
|
382
|
+
init_utils();
|
|
324
383
|
function createClient(params) {
|
|
325
384
|
const jdbcUrl = params[parameters.jdbcUrl.slug];
|
|
326
385
|
if (!jdbcUrl) {
|
|
@@ -404,6 +463,28 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
404
463
|
tools;
|
|
405
464
|
query;
|
|
406
465
|
checkConnection;
|
|
466
|
+
/**
|
|
467
|
+
* SQPD-1212: Logic-based, rule-driven connection setup. Connectors that
|
|
468
|
+
* implement this expose a step-by-step exploration flow (database/schema/
|
|
469
|
+
* table/etc. discovery) that the dashboard backend drives via the
|
|
470
|
+
* `/connections/:connectionId/setup` endpoint. Implement by delegating to
|
|
471
|
+
* `runSetupFlow` from `setup-flow.ts`.
|
|
472
|
+
*/
|
|
473
|
+
setup;
|
|
474
|
+
/**
|
|
475
|
+
* Opt-out of the default "verify before save" behavior on connection
|
|
476
|
+
* creation. The backend invokes `checkConnection` synchronously while
|
|
477
|
+
* creating the connection and aborts (no row inserted) if it fails — this
|
|
478
|
+
* flag disables that for connectors where the check cannot succeed pre-save:
|
|
479
|
+
*
|
|
480
|
+
* - `squadbase-db` populates `connection-url` only after Neon provisioning
|
|
481
|
+
* - OAuth connectors require an OAuth-aware proxyFetch keyed by the
|
|
482
|
+
* connectionId, which doesn't exist until the row is saved
|
|
483
|
+
*
|
|
484
|
+
* Exceptions are the explicit position; new credential-input connectors get
|
|
485
|
+
* the default verify-on-create behavior without opt-in.
|
|
486
|
+
*/
|
|
487
|
+
skipConnectionCheckOnCreate;
|
|
407
488
|
constructor(config) {
|
|
408
489
|
this.slug = config.slug;
|
|
409
490
|
this.authType = config.authType;
|
|
@@ -420,6 +501,8 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
420
501
|
this.tools = config.tools;
|
|
421
502
|
this.query = config.query;
|
|
422
503
|
this.checkConnection = config.checkConnection;
|
|
504
|
+
this.setup = config.setup;
|
|
505
|
+
this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
|
|
423
506
|
}
|
|
424
507
|
get connectorKey() {
|
|
425
508
|
return _ConnectorPlugin.deriveKey(this.slug, this.authType);
|
|
@@ -484,6 +567,76 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
484
567
|
}
|
|
485
568
|
};
|
|
486
569
|
|
|
570
|
+
// ../connectors/src/setup-flow.ts
|
|
571
|
+
async function runSetupFlow(flow, params, ctx, config) {
|
|
572
|
+
const runtime = {
|
|
573
|
+
params,
|
|
574
|
+
language: ctx.language,
|
|
575
|
+
config
|
|
576
|
+
};
|
|
577
|
+
let state = flow.initialState();
|
|
578
|
+
let answerIdx = 0;
|
|
579
|
+
const pendingParameterUpdates = [];
|
|
580
|
+
for (const step of flow.steps) {
|
|
581
|
+
const ans = ctx.answers[answerIdx];
|
|
582
|
+
if (ans && ans.questionSlug === step.slug) {
|
|
583
|
+
state = step.applyAnswer(state, ans.answer);
|
|
584
|
+
if (step.toParameterUpdates) {
|
|
585
|
+
pendingParameterUpdates.push(...step.toParameterUpdates(state));
|
|
586
|
+
}
|
|
587
|
+
answerIdx += 1;
|
|
588
|
+
continue;
|
|
589
|
+
}
|
|
590
|
+
const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
|
|
591
|
+
if (step.type === "text") {
|
|
592
|
+
if (step.fetchOptions) {
|
|
593
|
+
const options2 = await step.fetchOptions(state, runtime);
|
|
594
|
+
if (options2.length === 0) {
|
|
595
|
+
continue;
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
return {
|
|
599
|
+
type: "nextQuestion",
|
|
600
|
+
questionSlug: step.slug,
|
|
601
|
+
question: step.question[ctx.language],
|
|
602
|
+
questionType: "text",
|
|
603
|
+
allowFreeText: resolvedAllowFreeText,
|
|
604
|
+
...pendingParameterUpdates.length > 0 && {
|
|
605
|
+
parameterUpdates: pendingParameterUpdates
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
|
|
610
|
+
if (options.length === 0) {
|
|
611
|
+
continue;
|
|
612
|
+
}
|
|
613
|
+
return {
|
|
614
|
+
type: "nextQuestion",
|
|
615
|
+
questionSlug: step.slug,
|
|
616
|
+
question: step.question[ctx.language],
|
|
617
|
+
questionType: step.type,
|
|
618
|
+
options,
|
|
619
|
+
allowFreeText: resolvedAllowFreeText,
|
|
620
|
+
...pendingParameterUpdates.length > 0 && {
|
|
621
|
+
parameterUpdates: pendingParameterUpdates
|
|
622
|
+
}
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
const dataInvestigationResult = await flow.finalize(state, runtime);
|
|
626
|
+
return {
|
|
627
|
+
type: "fulfilled",
|
|
628
|
+
dataInvestigationResult,
|
|
629
|
+
...pendingParameterUpdates.length > 0 && {
|
|
630
|
+
parameterUpdates: pendingParameterUpdates
|
|
631
|
+
}
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
async function resolveSetupSelection(params) {
|
|
635
|
+
const { selected, allSentinel, fetchAll, limit } = params;
|
|
636
|
+
const resolved = selected.includes(allSentinel) ? await fetchAll() : selected.filter((v) => v !== allSentinel);
|
|
637
|
+
return resolved.slice(0, limit);
|
|
638
|
+
}
|
|
639
|
+
|
|
487
640
|
// ../connectors/src/auth-types.ts
|
|
488
641
|
var AUTH_TYPES = {
|
|
489
642
|
OAUTH: "oauth",
|
|
@@ -510,6 +663,9 @@ function unwrapSampleLimit(sql) {
|
|
|
510
663
|
return { inner, limit };
|
|
511
664
|
}
|
|
512
665
|
|
|
666
|
+
// ../connectors/src/connectors/sqlserver/index.ts
|
|
667
|
+
init_mssql_runner();
|
|
668
|
+
|
|
513
669
|
// ../connectors/src/connectors/sqlserver/setup.ts
|
|
514
670
|
var sqlserverOnboarding = new ConnectorOnboarding({
|
|
515
671
|
dataOverviewInstructions: {
|
|
@@ -524,8 +680,143 @@ var sqlserverOnboarding = new ConnectorOnboarding({
|
|
|
524
680
|
}
|
|
525
681
|
});
|
|
526
682
|
|
|
683
|
+
// ../connectors/src/connectors/sqlserver/setup-flow.ts
|
|
684
|
+
init_utils();
|
|
685
|
+
var ALL_TABLES = "__ALL_TABLES__";
|
|
686
|
+
var SQLSERVER_SETUP_MAX_TABLES = 20;
|
|
687
|
+
var INTERNAL_SCHEMAS = /* @__PURE__ */ new Set([
|
|
688
|
+
"sys",
|
|
689
|
+
"information_schema",
|
|
690
|
+
"guest",
|
|
691
|
+
"db_owner",
|
|
692
|
+
"db_accessadmin",
|
|
693
|
+
"db_securityadmin",
|
|
694
|
+
"db_ddladmin",
|
|
695
|
+
"db_backupoperator",
|
|
696
|
+
"db_datareader",
|
|
697
|
+
"db_datawriter",
|
|
698
|
+
"db_denydatareader",
|
|
699
|
+
"db_denydatawriter"
|
|
700
|
+
]);
|
|
701
|
+
function isInternalSchema(name) {
|
|
702
|
+
return INTERNAL_SCHEMAS.has(name.toLowerCase());
|
|
703
|
+
}
|
|
704
|
+
function quoteLiteral(value) {
|
|
705
|
+
return "'" + value.replace(/'/g, "''") + "'";
|
|
706
|
+
}
|
|
707
|
+
function buildFlow(options) {
|
|
708
|
+
const { connectorName, forceEncrypt } = options;
|
|
709
|
+
async function fetchTableNames(params, schema) {
|
|
710
|
+
const rows = await runSqlServerSetupQuery(
|
|
711
|
+
params,
|
|
712
|
+
`SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
|
|
713
|
+
WHERE TABLE_TYPE IN ('BASE TABLE', 'VIEW')
|
|
714
|
+
AND TABLE_SCHEMA = ${quoteLiteral(schema)}
|
|
715
|
+
ORDER BY TABLE_NAME`,
|
|
716
|
+
forceEncrypt
|
|
717
|
+
);
|
|
718
|
+
return rows.map((r) => String(r["TABLE_NAME"] ?? "")).filter((name) => name);
|
|
719
|
+
}
|
|
720
|
+
return {
|
|
721
|
+
initialState: () => ({}),
|
|
722
|
+
steps: [
|
|
723
|
+
{
|
|
724
|
+
slug: "schema",
|
|
725
|
+
type: "select",
|
|
726
|
+
question: {
|
|
727
|
+
ja: "\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u306B\u4F7F\u3046\u30B9\u30AD\u30FC\u30DE\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044",
|
|
728
|
+
en: "Select the schema to use for setup"
|
|
729
|
+
},
|
|
730
|
+
async fetchOptions(_state, rt) {
|
|
731
|
+
const rows = await runSqlServerSetupQuery(
|
|
732
|
+
rt.params,
|
|
733
|
+
`SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA ORDER BY SCHEMA_NAME`,
|
|
734
|
+
forceEncrypt
|
|
735
|
+
);
|
|
736
|
+
return rows.map((r) => String(r["SCHEMA_NAME"] ?? "")).filter((name) => name && !isInternalSchema(name)).map((value) => ({ value }));
|
|
737
|
+
},
|
|
738
|
+
applyAnswer: (state, answer) => ({ ...state, schema: answer[0] })
|
|
739
|
+
},
|
|
740
|
+
{
|
|
741
|
+
slug: "tables",
|
|
742
|
+
type: "multiSelect",
|
|
743
|
+
question: {
|
|
744
|
+
ja: "\u5BFE\u8C61\u30C6\u30FC\u30D6\u30EB\u30FB\u30D3\u30E5\u30FC\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044\uFF08\u8907\u6570\u9078\u629E\u53EF\uFF09",
|
|
745
|
+
en: "Select target tables and views (multi-select allowed)"
|
|
746
|
+
},
|
|
747
|
+
async fetchOptions(state, rt) {
|
|
748
|
+
if (!state.schema) return [];
|
|
749
|
+
const names = await fetchTableNames(rt.params, state.schema);
|
|
750
|
+
const tableOptions = names.map((value) => ({ value }));
|
|
751
|
+
return [
|
|
752
|
+
{
|
|
753
|
+
value: ALL_TABLES,
|
|
754
|
+
label: rt.language === "ja" ? "\u3059\u3079\u3066\u306E\u30C6\u30FC\u30D6\u30EB\u30FB\u30D3\u30E5\u30FC" : "All tables and views"
|
|
755
|
+
},
|
|
756
|
+
...tableOptions
|
|
757
|
+
];
|
|
758
|
+
},
|
|
759
|
+
applyAnswer: (state, answer) => ({ ...state, tables: answer })
|
|
760
|
+
}
|
|
761
|
+
],
|
|
762
|
+
async finalize(state, rt) {
|
|
763
|
+
if (!state.schema || !state.tables) {
|
|
764
|
+
throw new Error(`${connectorName} setup: incomplete state on finalize`);
|
|
765
|
+
}
|
|
766
|
+
const schema = state.schema;
|
|
767
|
+
const targetTables = await resolveSetupSelection({
|
|
768
|
+
selected: state.tables,
|
|
769
|
+
allSentinel: ALL_TABLES,
|
|
770
|
+
fetchAll: () => fetchTableNames(rt.params, schema),
|
|
771
|
+
limit: SQLSERVER_SETUP_MAX_TABLES
|
|
772
|
+
});
|
|
773
|
+
const sections = [
|
|
774
|
+
`## ${connectorName}`,
|
|
775
|
+
"",
|
|
776
|
+
`### Schema: ${schema}`,
|
|
777
|
+
""
|
|
778
|
+
];
|
|
779
|
+
for (const table of targetTables) {
|
|
780
|
+
const cols = await runSqlServerSetupQuery(
|
|
781
|
+
rt.params,
|
|
782
|
+
`SELECT COLUMN_NAME, DATA_TYPE, IS_NULLABLE, COLUMN_DEFAULT
|
|
783
|
+
FROM INFORMATION_SCHEMA.COLUMNS
|
|
784
|
+
WHERE TABLE_SCHEMA = ${quoteLiteral(schema)}
|
|
785
|
+
AND TABLE_NAME = ${quoteLiteral(table)}
|
|
786
|
+
ORDER BY ORDINAL_POSITION`,
|
|
787
|
+
forceEncrypt
|
|
788
|
+
);
|
|
789
|
+
sections.push(`#### Table: ${table}`, "");
|
|
790
|
+
sections.push("| Column | Type | Nullable | Default |");
|
|
791
|
+
sections.push("|--------|------|----------|---------|");
|
|
792
|
+
for (const c of cols) {
|
|
793
|
+
const name = String(c["COLUMN_NAME"] ?? "");
|
|
794
|
+
const type = String(c["DATA_TYPE"] ?? "");
|
|
795
|
+
const nullable = String(c["IS_NULLABLE"] ?? "");
|
|
796
|
+
const defaultValue = c["COLUMN_DEFAULT"] == null ? "-" : String(c["COLUMN_DEFAULT"]);
|
|
797
|
+
sections.push(
|
|
798
|
+
`| ${name} | ${type} | ${nullable} | ${defaultValue} |`
|
|
799
|
+
);
|
|
800
|
+
}
|
|
801
|
+
sections.push("");
|
|
802
|
+
}
|
|
803
|
+
return sections.join("\n");
|
|
804
|
+
}
|
|
805
|
+
};
|
|
806
|
+
}
|
|
807
|
+
function createSqlServerSetupFlow(options) {
|
|
808
|
+
return buildFlow(options);
|
|
809
|
+
}
|
|
810
|
+
var sqlserverSetupFlow = createSqlServerSetupFlow({
|
|
811
|
+
connectorName: "SQL Server",
|
|
812
|
+
forceEncrypt: false
|
|
813
|
+
});
|
|
814
|
+
|
|
527
815
|
// ../connectors/src/connectors/sqlserver/tools/execute-query.ts
|
|
528
816
|
import { z } from "zod";
|
|
817
|
+
init_mssql_runner();
|
|
818
|
+
init_ssh_tunnel();
|
|
819
|
+
init_utils();
|
|
529
820
|
var MAX_ROWS = 500;
|
|
530
821
|
var inputSchema = z.object({
|
|
531
822
|
toolUseIntent: z.string().optional().describe(
|
|
@@ -599,6 +890,7 @@ Avoid loading large amounts of data; always include \`TOP\` in queries.`,
|
|
|
599
890
|
});
|
|
600
891
|
|
|
601
892
|
// ../connectors/src/connectors/sqlserver/index.ts
|
|
893
|
+
init_utils();
|
|
602
894
|
var tools = { executeQuery: executeQueryTool };
|
|
603
895
|
var sqlserverConnector = new ConnectorPlugin({
|
|
604
896
|
slug: "sqlserver",
|
|
@@ -647,6 +939,7 @@ The business logic type for this connector is "sql".
|
|
|
647
939
|
- \u884C\u6570\u5236\u9650\u306E\u4E92\u63DB\u6027: \u30D7\u30E9\u30C3\u30C8\u30D5\u30A9\u30FC\u30E0\u306E server-logic \u30B9\u30AD\u30FC\u30DE\u63A8\u8AD6\u306F\u3001\u30AF\u30A8\u30EA\u3092 \`SELECT * FROM (<inner>) AS _sq LIMIT N\` \u306E\u5F62\u3067\u30E9\u30C3\u30D7\u3057\u3066\u304F\u308B\u3053\u3068\u304C\u3042\u308A\u307E\u3059\u3002T-SQL \u306B\u306F \`LIMIT\` \u304C\u7121\u3044\u305F\u3081\u3001\u30B3\u30CD\u30AF\u30BF\u306F \`query()\` \u5185\u3067\u3053\u306E\u30E9\u30C3\u30D1\u3092\u691C\u51FA\u3057\u3001\`<inner>\` \u3092\u305D\u306E\u307E\u307E\u5B9F\u884C\u3057\u3066 JS \u5074\u3067\u5148\u982D N \u884C\u306B\u5207\u308A\u8A70\u3081\u307E\u3059\u3002\u5229\u7528\u8005\u5074\u3067\u5BFE\u51E6\u3059\u308B\u5FC5\u8981\u306F\u3042\u308A\u307E\u305B\u3093\u304C\u3001\u81EA\u5206\u3067\u66F8\u304F SQL \u3067\u306F \`LIMIT\` \u3092\u4F7F\u308F\u305A \`TOP\` / \`OFFSET ... FETCH NEXT\` \u3092\u4F7F\u3063\u3066\u304F\u3060\u3055\u3044\u3002`
|
|
648
940
|
},
|
|
649
941
|
tools,
|
|
942
|
+
setup: (params, ctx, config) => runSetupFlow(sqlserverSetupFlow, params, ctx, config),
|
|
650
943
|
async checkConnection(params, _config) {
|
|
651
944
|
return checkMssqlConnection(
|
|
652
945
|
params[parameters.jdbcUrl.slug],
|
|
@@ -699,6 +992,7 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
699
992
|
import { getContext } from "hono/context-storage";
|
|
700
993
|
import { getCookie } from "hono/cookie";
|
|
701
994
|
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
995
|
+
var TABLEAU_SESSION_SENTINEL_URL = "squadbase://tableau-session/";
|
|
702
996
|
function normalizeHeaders(input) {
|
|
703
997
|
const out = {};
|
|
704
998
|
if (!input) return out;
|
|
@@ -707,6 +1001,11 @@ function normalizeHeaders(input) {
|
|
|
707
1001
|
});
|
|
708
1002
|
return out;
|
|
709
1003
|
}
|
|
1004
|
+
function extractInputUrl(input) {
|
|
1005
|
+
if (typeof input === "string") return input;
|
|
1006
|
+
if (input instanceof URL) return input.href;
|
|
1007
|
+
return input.url;
|
|
1008
|
+
}
|
|
710
1009
|
function createSandboxProxyFetch(connectionId) {
|
|
711
1010
|
return async (input, init) => {
|
|
712
1011
|
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
@@ -716,10 +1015,17 @@ function createSandboxProxyFetch(connectionId) {
|
|
|
716
1015
|
"Connection proxy is not configured. Please check your deployment settings."
|
|
717
1016
|
);
|
|
718
1017
|
}
|
|
719
|
-
const originalUrl =
|
|
1018
|
+
const originalUrl = extractInputUrl(input);
|
|
1019
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
1020
|
+
if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
|
|
1021
|
+
const sessionUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
1022
|
+
return fetch(sessionUrl, {
|
|
1023
|
+
method: "POST",
|
|
1024
|
+
headers: { Authorization: `Bearer ${token}` }
|
|
1025
|
+
});
|
|
1026
|
+
}
|
|
720
1027
|
const originalMethod = init?.method ?? "GET";
|
|
721
1028
|
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
722
|
-
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
723
1029
|
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
724
1030
|
return fetch(proxyUrl, {
|
|
725
1031
|
method: "POST",
|
|
@@ -745,10 +1051,9 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
745
1051
|
}
|
|
746
1052
|
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
747
1053
|
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
1054
|
+
const sessionUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
748
1055
|
return async (input, init) => {
|
|
749
|
-
const originalUrl =
|
|
750
|
-
const originalMethod = init?.method ?? "GET";
|
|
751
|
-
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
1056
|
+
const originalUrl = extractInputUrl(input);
|
|
752
1057
|
const c = getContext();
|
|
753
1058
|
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
754
1059
|
if (!appSession) {
|
|
@@ -756,6 +1061,14 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
756
1061
|
"No authentication method available for connection proxy."
|
|
757
1062
|
);
|
|
758
1063
|
}
|
|
1064
|
+
if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
|
|
1065
|
+
return fetch(sessionUrl, {
|
|
1066
|
+
method: "POST",
|
|
1067
|
+
headers: { Authorization: `Bearer ${appSession}` }
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1070
|
+
const originalMethod = init?.method ?? "GET";
|
|
1071
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
759
1072
|
return fetch(proxyUrl, {
|
|
760
1073
|
method: "POST",
|
|
761
1074
|
headers: {
|