@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.
Files changed (77) hide show
  1. package/dist/cli/index.js +14375 -1652
  2. package/dist/connectors/airtable-oauth.js +282 -46
  3. package/dist/connectors/airtable.js +319 -51
  4. package/dist/connectors/amplitude.js +322 -47
  5. package/dist/connectors/anthropic.js +135 -47
  6. package/dist/connectors/asana.js +327 -49
  7. package/dist/connectors/attio.js +302 -49
  8. package/dist/connectors/aws-billing.js +287 -46
  9. package/dist/connectors/azure-sql.js +421 -102
  10. package/dist/connectors/backlog-api-key.js +317 -47
  11. package/dist/connectors/clickup.js +338 -49
  12. package/dist/connectors/cosmosdb.js +305 -50
  13. package/dist/connectors/customerio.js +319 -47
  14. package/dist/connectors/dbt.js +340 -47
  15. package/dist/connectors/freshdesk.js +342 -53
  16. package/dist/connectors/freshsales.js +333 -52
  17. package/dist/connectors/freshservice.js +361 -53
  18. package/dist/connectors/gamma.js +327 -52
  19. package/dist/connectors/gemini.js +134 -47
  20. package/dist/connectors/github.js +386 -49
  21. package/dist/connectors/gmail-oauth.js +204 -7
  22. package/dist/connectors/gmail.js +350 -47
  23. package/dist/connectors/google-ads.js +288 -46
  24. package/dist/connectors/google-analytics-oauth.js +310 -46
  25. package/dist/connectors/google-analytics.js +547 -87
  26. package/dist/connectors/google-audit-log.js +438 -47
  27. package/dist/connectors/google-calendar-oauth.js +259 -46
  28. package/dist/connectors/google-calendar.js +359 -47
  29. package/dist/connectors/google-docs.js +220 -6
  30. package/dist/connectors/google-drive.js +262 -5
  31. package/dist/connectors/google-search-console-oauth.js +256 -46
  32. package/dist/connectors/google-sheets.js +272 -47
  33. package/dist/connectors/google-slides.js +205 -6
  34. package/dist/connectors/grafana.js +332 -49
  35. package/dist/connectors/hubspot-oauth.js +208 -5
  36. package/dist/connectors/hubspot.js +306 -49
  37. package/dist/connectors/influxdb.js +416 -51
  38. package/dist/connectors/intercom-oauth.js +210 -5
  39. package/dist/connectors/intercom.js +302 -49
  40. package/dist/connectors/jdbc.js +762 -110
  41. package/dist/connectors/jira-api-key.js +326 -47
  42. package/dist/connectors/kintone-api-token.js +281 -47
  43. package/dist/connectors/kintone.js +328 -47
  44. package/dist/connectors/linear.js +330 -49
  45. package/dist/connectors/linkedin-ads.js +268 -50
  46. package/dist/connectors/mailchimp-oauth.js +268 -46
  47. package/dist/connectors/mailchimp.js +320 -49
  48. package/dist/connectors/meta-ads-oauth.js +273 -48
  49. package/dist/connectors/meta-ads.js +285 -50
  50. package/dist/connectors/mixpanel.js +338 -47
  51. package/dist/connectors/monday.js +360 -49
  52. package/dist/connectors/mongodb.js +319 -57
  53. package/dist/connectors/notion-oauth.js +231 -5
  54. package/dist/connectors/notion.js +323 -51
  55. package/dist/connectors/openai.js +134 -47
  56. package/dist/connectors/oracle.js +454 -103
  57. package/dist/connectors/outlook-oauth.js +204 -5
  58. package/dist/connectors/powerbi-oauth.js +498 -5
  59. package/dist/connectors/salesforce.js +384 -49
  60. package/dist/connectors/semrush.js +609 -49
  61. package/dist/connectors/sentry.js +289 -50
  62. package/dist/connectors/shopify-oauth.js +187 -5
  63. package/dist/connectors/shopify.js +357 -47
  64. package/dist/connectors/sqlserver.js +415 -102
  65. package/dist/connectors/stripe-api-key.js +269 -46
  66. package/dist/connectors/stripe-oauth.js +202 -5
  67. package/dist/connectors/supabase.js +303 -48
  68. package/dist/connectors/tableau.js +536 -163
  69. package/dist/connectors/tiktok-ads.js +279 -48
  70. package/dist/connectors/wix-store.js +320 -49
  71. package/dist/connectors/zendesk-oauth.js +239 -5
  72. package/dist/connectors/zendesk.js +358 -47
  73. package/dist/index.d.ts +149 -1
  74. package/dist/index.js +15057 -2117
  75. package/dist/main.js +15005 -2073
  76. package/dist/vite-plugin.js +14752 -2019
  77. package/package.json +1 -1
@@ -1,101 +1,64 @@
1
- // ../connectors/src/parameter-definition.ts
2
- var ParameterDefinition = class {
3
- slug;
4
- name;
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
- // ../connectors/src/lib/ssh-tunnel.ts
46
- var sshTunnelParameters = {
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
- var NOOP_TUNNEL_HOSTPORT = (host, port) => ({
94
- host,
95
- port,
96
- close: async () => {
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/oracle/utils.ts
171
- var JDBC_THIN_PREFIX_RE = /^jdbc:oracle:thin:/i;
172
- var JDBC_OCI_PREFIX_RE = /^jdbc:oracle:oci/i;
173
- var URL_PREFIX_RE = /^oracle:\/\//i;
174
194
  function parseOracleJdbcUrl(jdbcUrl, options = {}) {
175
195
  const trimmed = jdbcUrl.trim();
176
196
  if (JDBC_OCI_PREFIX_RE.test(trimmed)) {
@@ -242,9 +262,34 @@ function rewriteOracleConnectStringHostPort(connectString, host, port) {
242
262
  if (!parts) return connectString;
243
263
  return `${host}:${port}${parts.trailing}`;
244
264
  }
265
+ async function runOracleSetupQuery(params, sql) {
266
+ const { runOracleQuery: runOracleQuery2 } = await Promise.resolve().then(() => (init_oracle_runner(), oracle_runner_exports));
267
+ const parsed = parseOracleJdbcUrl(params["jdbc-url"] ?? "", {
268
+ username: params["username"],
269
+ password: params["password"]
270
+ });
271
+ const cleanSql = sql.replace(/;\s*$/, "");
272
+ const result = await runOracleQuery2(parsed, cleanSql, {
273
+ tunnelParams: params
274
+ });
275
+ return result.rows;
276
+ }
277
+ var JDBC_THIN_PREFIX_RE, JDBC_OCI_PREFIX_RE, URL_PREFIX_RE;
278
+ var init_utils = __esm({
279
+ "../connectors/src/connectors/oracle/utils.ts"() {
280
+ "use strict";
281
+ JDBC_THIN_PREFIX_RE = /^jdbc:oracle:thin:/i;
282
+ JDBC_OCI_PREFIX_RE = /^jdbc:oracle:oci/i;
283
+ URL_PREFIX_RE = /^oracle:\/\//i;
284
+ }
285
+ });
245
286
 
246
287
  // ../connectors/src/lib/oracle-runner.ts
247
- var GLOBAL_ORACLEDB_PATH = "/usr/lib/node_modules/oracledb/index.js";
288
+ var oracle_runner_exports = {};
289
+ __export(oracle_runner_exports, {
290
+ checkOracleConnection: () => checkOracleConnection,
291
+ runOracleQuery: () => runOracleQuery
292
+ });
248
293
  async function importOracleDb() {
249
294
  let mod;
250
295
  try {
@@ -320,8 +365,22 @@ async function checkOracleConnection(url, credentials, options = {}) {
320
365
  return { success: false, error: msg };
321
366
  }
322
367
  }
368
+ var GLOBAL_ORACLEDB_PATH;
369
+ var init_oracle_runner = __esm({
370
+ "../connectors/src/lib/oracle-runner.ts"() {
371
+ "use strict";
372
+ init_ssh_tunnel();
373
+ init_utils();
374
+ GLOBAL_ORACLEDB_PATH = "/usr/lib/node_modules/oracledb/index.js";
375
+ }
376
+ });
377
+
378
+ // ../connectors/src/connectors/oracle/sdk/index.ts
379
+ init_oracle_runner();
323
380
 
324
381
  // ../connectors/src/connectors/oracle/parameters.ts
382
+ init_parameter_definition();
383
+ init_ssh_tunnel();
325
384
  var parameters = {
326
385
  jdbcUrl: new ParameterDefinition({
327
386
  slug: "jdbc-url",
@@ -354,6 +413,7 @@ var parameters = {
354
413
  };
355
414
 
356
415
  // ../connectors/src/connectors/oracle/sdk/index.ts
416
+ init_utils();
357
417
  function createClient(params) {
358
418
  const jdbcUrl = params[parameters.jdbcUrl.slug];
359
419
  if (!jdbcUrl) {
@@ -438,6 +498,28 @@ var ConnectorPlugin = class _ConnectorPlugin {
438
498
  tools;
439
499
  query;
440
500
  checkConnection;
501
+ /**
502
+ * SQPD-1212: Logic-based, rule-driven connection setup. Connectors that
503
+ * implement this expose a step-by-step exploration flow (database/schema/
504
+ * table/etc. discovery) that the dashboard backend drives via the
505
+ * `/connections/:connectionId/setup` endpoint. Implement by delegating to
506
+ * `runSetupFlow` from `setup-flow.ts`.
507
+ */
508
+ setup;
509
+ /**
510
+ * Opt-out of the default "verify before save" behavior on connection
511
+ * creation. The backend invokes `checkConnection` synchronously while
512
+ * creating the connection and aborts (no row inserted) if it fails — this
513
+ * flag disables that for connectors where the check cannot succeed pre-save:
514
+ *
515
+ * - `squadbase-db` populates `connection-url` only after Neon provisioning
516
+ * - OAuth connectors require an OAuth-aware proxyFetch keyed by the
517
+ * connectionId, which doesn't exist until the row is saved
518
+ *
519
+ * Exceptions are the explicit position; new credential-input connectors get
520
+ * the default verify-on-create behavior without opt-in.
521
+ */
522
+ skipConnectionCheckOnCreate;
441
523
  constructor(config) {
442
524
  this.slug = config.slug;
443
525
  this.authType = config.authType;
@@ -454,6 +536,8 @@ var ConnectorPlugin = class _ConnectorPlugin {
454
536
  this.tools = config.tools;
455
537
  this.query = config.query;
456
538
  this.checkConnection = config.checkConnection;
539
+ this.setup = config.setup;
540
+ this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
457
541
  }
458
542
  get connectorKey() {
459
543
  return _ConnectorPlugin.deriveKey(this.slug, this.authType);
@@ -518,6 +602,76 @@ var ConnectorPlugin = class _ConnectorPlugin {
518
602
  }
519
603
  };
520
604
 
605
+ // ../connectors/src/setup-flow.ts
606
+ async function runSetupFlow(flow, params, ctx, config) {
607
+ const runtime = {
608
+ params,
609
+ language: ctx.language,
610
+ config
611
+ };
612
+ let state = flow.initialState();
613
+ let answerIdx = 0;
614
+ const pendingParameterUpdates = [];
615
+ for (const step of flow.steps) {
616
+ const ans = ctx.answers[answerIdx];
617
+ if (ans && ans.questionSlug === step.slug) {
618
+ state = step.applyAnswer(state, ans.answer);
619
+ if (step.toParameterUpdates) {
620
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
621
+ }
622
+ answerIdx += 1;
623
+ continue;
624
+ }
625
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
626
+ if (step.type === "text") {
627
+ if (step.fetchOptions) {
628
+ const options2 = await step.fetchOptions(state, runtime);
629
+ if (options2.length === 0) {
630
+ continue;
631
+ }
632
+ }
633
+ return {
634
+ type: "nextQuestion",
635
+ questionSlug: step.slug,
636
+ question: step.question[ctx.language],
637
+ questionType: "text",
638
+ allowFreeText: resolvedAllowFreeText,
639
+ ...pendingParameterUpdates.length > 0 && {
640
+ parameterUpdates: pendingParameterUpdates
641
+ }
642
+ };
643
+ }
644
+ const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
645
+ if (options.length === 0) {
646
+ continue;
647
+ }
648
+ return {
649
+ type: "nextQuestion",
650
+ questionSlug: step.slug,
651
+ question: step.question[ctx.language],
652
+ questionType: step.type,
653
+ options,
654
+ allowFreeText: resolvedAllowFreeText,
655
+ ...pendingParameterUpdates.length > 0 && {
656
+ parameterUpdates: pendingParameterUpdates
657
+ }
658
+ };
659
+ }
660
+ const dataInvestigationResult = await flow.finalize(state, runtime);
661
+ return {
662
+ type: "fulfilled",
663
+ dataInvestigationResult,
664
+ ...pendingParameterUpdates.length > 0 && {
665
+ parameterUpdates: pendingParameterUpdates
666
+ }
667
+ };
668
+ }
669
+ async function resolveSetupSelection(params) {
670
+ const { selected, allSentinel, fetchAll, limit } = params;
671
+ const resolved = selected.includes(allSentinel) ? await fetchAll() : selected.filter((v) => v !== allSentinel);
672
+ return resolved.slice(0, limit);
673
+ }
674
+
521
675
  // ../connectors/src/auth-types.ts
522
676
  var AUTH_TYPES = {
523
677
  OAUTH: "oauth",
@@ -544,6 +698,9 @@ function unwrapSampleLimit(sql) {
544
698
  return { inner, limit };
545
699
  }
546
700
 
701
+ // ../connectors/src/connectors/oracle/index.ts
702
+ init_oracle_runner();
703
+
547
704
  // ../connectors/src/connectors/oracle/setup.ts
548
705
  var oracleOnboarding = new ConnectorOnboarding({
549
706
  dataOverviewInstructions: {
@@ -560,8 +717,180 @@ var oracleOnboarding = new ConnectorOnboarding({
560
717
  }
561
718
  });
562
719
 
720
+ // ../connectors/src/connectors/oracle/setup-flow.ts
721
+ init_utils();
722
+ var ALL_TABLES = "__ALL_TABLES__";
723
+ var ORACLE_SETUP_MAX_TABLES = 20;
724
+ var INTERNAL_OWNERS = /* @__PURE__ */ new Set([
725
+ "SYS",
726
+ "SYSTEM",
727
+ "XDB",
728
+ "OUTLN",
729
+ "ANONYMOUS",
730
+ "APEX_PUBLIC_USER",
731
+ "APPQOSSYS",
732
+ "AUDSYS",
733
+ "CTXSYS",
734
+ "DBSFWUSER",
735
+ "DBSNMP",
736
+ "DIP",
737
+ "DVF",
738
+ "DVSYS",
739
+ "EXFSYS",
740
+ "FLOWS_FILES",
741
+ "GGSYS",
742
+ "GSMADMIN_INTERNAL",
743
+ "GSMCATUSER",
744
+ "GSMUSER",
745
+ "LBACSYS",
746
+ "MDDATA",
747
+ "MDSYS",
748
+ "OJVMSYS",
749
+ "OLAPSYS",
750
+ "ORACLE_OCM",
751
+ "ORDDATA",
752
+ "ORDPLUGINS",
753
+ "ORDSYS",
754
+ "PDBADMIN",
755
+ "REMOTE_SCHEDULER_AGENT",
756
+ "SI_INFORMTN_SCHEMA",
757
+ "SPATIAL_CSW_ADMIN_USR",
758
+ "SPATIAL_WFS_ADMIN_USR",
759
+ "SQLTXADMIN",
760
+ "SQLTXPLAIN",
761
+ "SYSBACKUP",
762
+ "SYSDG",
763
+ "SYSKM",
764
+ "SYSRAC",
765
+ "SYS$UMF",
766
+ "TSMSYS",
767
+ "WMSYS",
768
+ "XS$NULL"
769
+ ]);
770
+ function isInternalOwner(name) {
771
+ const upper = name.toUpperCase();
772
+ if (INTERNAL_OWNERS.has(upper)) return true;
773
+ if (upper.startsWith("APEX_")) return true;
774
+ return false;
775
+ }
776
+ function quoteLiteral(value) {
777
+ return "'" + value.replace(/'/g, "''") + "'";
778
+ }
779
+ async function fetchTableAndViewNames(params, owner) {
780
+ const rows = await runOracleSetupQuery(
781
+ params,
782
+ `SELECT TABLE_NAME FROM ALL_TABLES WHERE OWNER = ${quoteLiteral(owner)}
783
+ UNION
784
+ SELECT VIEW_NAME FROM ALL_VIEWS WHERE OWNER = ${quoteLiteral(owner)}
785
+ ORDER BY 1`
786
+ );
787
+ return rows.map((r) => String(r["TABLE_NAME"] ?? r["VIEW_NAME"] ?? "")).filter((name) => name);
788
+ }
789
+ var oracleSetupFlow = {
790
+ initialState: () => ({}),
791
+ steps: [
792
+ {
793
+ slug: "owner",
794
+ type: "select",
795
+ question: {
796
+ ja: "\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u306B\u4F7F\u3046\u30B9\u30AD\u30FC\u30DE\uFF08\u30AA\u30FC\u30CA\u30FC\uFF09\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044",
797
+ en: "Select the schema (owner) to use for setup"
798
+ },
799
+ async fetchOptions(_state, rt) {
800
+ const rows = await runOracleSetupQuery(
801
+ rt.params,
802
+ `SELECT USERNAME FROM ALL_USERS ORDER BY USERNAME`
803
+ );
804
+ return rows.map((r) => String(r["USERNAME"] ?? "")).filter((name) => name && !isInternalOwner(name)).map((value) => ({ value }));
805
+ },
806
+ applyAnswer: (state, answer) => ({ ...state, owner: answer[0] })
807
+ },
808
+ {
809
+ slug: "tables",
810
+ type: "multiSelect",
811
+ question: {
812
+ 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",
813
+ en: "Select target tables and views (multi-select allowed)"
814
+ },
815
+ async fetchOptions(state, rt) {
816
+ if (!state.owner) return [];
817
+ const names = await fetchTableAndViewNames(rt.params, state.owner);
818
+ const tableOptions = names.map((value) => ({ value }));
819
+ return [
820
+ {
821
+ value: ALL_TABLES,
822
+ label: rt.language === "ja" ? "\u3059\u3079\u3066\u306E\u30C6\u30FC\u30D6\u30EB\u30FB\u30D3\u30E5\u30FC" : "All tables and views"
823
+ },
824
+ ...tableOptions
825
+ ];
826
+ },
827
+ applyAnswer: (state, answer) => ({ ...state, tables: answer })
828
+ }
829
+ ],
830
+ async finalize(state, rt) {
831
+ if (!state.owner || !state.tables) {
832
+ throw new Error("Oracle setup: incomplete state on finalize");
833
+ }
834
+ const owner = state.owner;
835
+ const targetTables = await resolveSetupSelection({
836
+ selected: state.tables,
837
+ allSentinel: ALL_TABLES,
838
+ fetchAll: () => fetchTableAndViewNames(rt.params, owner),
839
+ limit: ORACLE_SETUP_MAX_TABLES
840
+ });
841
+ const typeRows = targetTables.length > 0 ? await runOracleSetupQuery(
842
+ rt.params,
843
+ `SELECT OBJECT_NAME, OBJECT_TYPE FROM ALL_OBJECTS
844
+ WHERE OWNER = ${quoteLiteral(owner)}
845
+ AND OBJECT_NAME IN (${targetTables.map(quoteLiteral).join(", ")})
846
+ AND OBJECT_TYPE IN ('TABLE', 'VIEW')`
847
+ ) : [];
848
+ const typeMap = new Map(
849
+ typeRows.map((r) => [
850
+ String(r["OBJECT_NAME"] ?? ""),
851
+ String(r["OBJECT_TYPE"] ?? "TABLE")
852
+ ])
853
+ );
854
+ const sections = [
855
+ "## Oracle Database",
856
+ "",
857
+ `### Schema: ${owner}`,
858
+ ""
859
+ ];
860
+ for (const table of targetTables) {
861
+ const heading = typeMap.get(table) === "VIEW" ? "View" : "Table";
862
+ const cols = await runOracleSetupQuery(
863
+ rt.params,
864
+ `SELECT COLUMN_NAME, DATA_TYPE, NULLABLE, DATA_DEFAULT
865
+ FROM ALL_TAB_COLUMNS
866
+ WHERE OWNER = ${quoteLiteral(owner)}
867
+ AND TABLE_NAME = ${quoteLiteral(table)}
868
+ ORDER BY COLUMN_ID`
869
+ );
870
+ sections.push(`#### ${heading}: ${table}`, "");
871
+ sections.push("| Column | Type | Nullable | Default |");
872
+ sections.push("|--------|------|----------|---------|");
873
+ for (const c of cols) {
874
+ const name = String(c["COLUMN_NAME"] ?? "");
875
+ const type = String(c["DATA_TYPE"] ?? "");
876
+ const nullable = String(c["NULLABLE"] ?? "");
877
+ const defaultRaw = c["DATA_DEFAULT"];
878
+ const defaultValue = defaultRaw == null ? "-" : String(defaultRaw).trim() || "-";
879
+ sections.push(
880
+ `| ${name} | ${type} | ${nullable} | ${defaultValue} |`
881
+ );
882
+ }
883
+ sections.push("");
884
+ }
885
+ return sections.join("\n");
886
+ }
887
+ };
888
+
563
889
  // ../connectors/src/connectors/oracle/tools/execute-query.ts
564
890
  import { z } from "zod";
891
+ init_oracle_runner();
892
+ init_ssh_tunnel();
893
+ init_utils();
565
894
  var MAX_ROWS = 500;
566
895
  var inputSchema = z.object({
567
896
  toolUseIntent: z.string().optional().describe(
@@ -637,6 +966,7 @@ Do NOT terminate statements with a semicolon; the driver rejects trailing termin
637
966
  });
638
967
 
639
968
  // ../connectors/src/connectors/oracle/index.ts
969
+ init_utils();
640
970
  var tools = { executeQuery: executeQueryTool };
641
971
  var oracleConnector = new ConnectorPlugin({
642
972
  slug: "oracle",
@@ -689,6 +1019,7 @@ The business logic type for this connector is "sql".
689
1019
  - \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\u3002Oracle \u306B\u306F \`LIMIT\` \u30AD\u30FC\u30EF\u30FC\u30C9\u304C\u5B58\u5728\u3057\u306A\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 \`FETCH FIRST N ROWS ONLY\` / \`OFFSET m ROWS FETCH NEXT N ROWS ONLY\` / \`ROWNUM\` \u3092\u4F7F\u3063\u3066\u304F\u3060\u3055\u3044\u3002`
690
1020
  },
691
1021
  tools,
1022
+ setup: (params, ctx, config) => runSetupFlow(oracleSetupFlow, params, ctx, config),
692
1023
  async checkConnection(params, _config) {
693
1024
  return checkOracleConnection(
694
1025
  params[parameters.jdbcUrl.slug],
@@ -743,6 +1074,7 @@ function resolveEnvVarOptional(entry, key) {
743
1074
  import { getContext } from "hono/context-storage";
744
1075
  import { getCookie } from "hono/cookie";
745
1076
  var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
1077
+ var TABLEAU_SESSION_SENTINEL_URL = "squadbase://tableau-session/";
746
1078
  function normalizeHeaders(input) {
747
1079
  const out = {};
748
1080
  if (!input) return out;
@@ -751,6 +1083,11 @@ function normalizeHeaders(input) {
751
1083
  });
752
1084
  return out;
753
1085
  }
1086
+ function extractInputUrl(input) {
1087
+ if (typeof input === "string") return input;
1088
+ if (input instanceof URL) return input.href;
1089
+ return input.url;
1090
+ }
754
1091
  function createSandboxProxyFetch(connectionId) {
755
1092
  return async (input, init) => {
756
1093
  const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
@@ -760,10 +1097,17 @@ function createSandboxProxyFetch(connectionId) {
760
1097
  "Connection proxy is not configured. Please check your deployment settings."
761
1098
  );
762
1099
  }
763
- const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
1100
+ const originalUrl = extractInputUrl(input);
1101
+ const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
1102
+ if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
1103
+ const sessionUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
1104
+ return fetch(sessionUrl, {
1105
+ method: "POST",
1106
+ headers: { Authorization: `Bearer ${token}` }
1107
+ });
1108
+ }
764
1109
  const originalMethod = init?.method ?? "GET";
765
1110
  const originalBody = init?.body ? JSON.parse(init.body) : void 0;
766
- const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
767
1111
  const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
768
1112
  return fetch(proxyUrl, {
769
1113
  method: "POST",
@@ -789,10 +1133,9 @@ function createDeployedAppProxyFetch(connectionId) {
789
1133
  }
790
1134
  const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
791
1135
  const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
1136
+ const sessionUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
792
1137
  return async (input, init) => {
793
- const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
794
- const originalMethod = init?.method ?? "GET";
795
- const originalBody = init?.body ? JSON.parse(init.body) : void 0;
1138
+ const originalUrl = extractInputUrl(input);
796
1139
  const c = getContext();
797
1140
  const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
798
1141
  if (!appSession) {
@@ -800,6 +1143,14 @@ function createDeployedAppProxyFetch(connectionId) {
800
1143
  "No authentication method available for connection proxy."
801
1144
  );
802
1145
  }
1146
+ if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
1147
+ return fetch(sessionUrl, {
1148
+ method: "POST",
1149
+ headers: { Authorization: `Bearer ${appSession}` }
1150
+ });
1151
+ }
1152
+ const originalMethod = init?.method ?? "GET";
1153
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
803
1154
  return fetch(proxyUrl, {
804
1155
  method: "POST",
805
1156
  headers: {