@squadbase/vite-server 0.1.17-dev.d4fff69 → 0.1.17-dev.e4768d1
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 +4786 -3023
- package/dist/connectors/airtable-oauth.js +39 -15
- package/dist/connectors/airtable.js +86 -15
- package/dist/connectors/amplitude.js +39 -15
- package/dist/connectors/anthropic.js +39 -15
- package/dist/connectors/asana.js +39 -15
- package/dist/connectors/attio.js +39 -15
- package/dist/connectors/aws-billing.js +39 -15
- package/dist/connectors/azure-sql.js +275 -15
- package/dist/connectors/backlog-api-key.js +39 -15
- package/dist/connectors/clickup.js +39 -15
- package/dist/connectors/cosmosdb.js +39 -15
- package/dist/connectors/customerio.js +39 -15
- package/dist/connectors/dbt.js +39 -15
- package/dist/connectors/freshdesk.js +39 -15
- package/dist/connectors/freshsales.js +39 -15
- package/dist/connectors/freshservice.js +39 -15
- package/dist/connectors/gamma.js +39 -15
- package/dist/connectors/gemini.js +39 -15
- package/dist/connectors/github.js +39 -15
- package/dist/connectors/gmail-oauth.js +32 -13
- package/dist/connectors/gmail.js +39 -15
- package/dist/connectors/google-ads.js +39 -15
- package/dist/connectors/google-analytics-oauth.js +39 -15
- package/dist/connectors/google-analytics.js +39 -15
- package/dist/connectors/google-audit-log.js +39 -15
- package/dist/connectors/google-calendar-oauth.js +39 -15
- package/dist/connectors/google-calendar.js +39 -15
- package/dist/connectors/google-docs.js +32 -13
- package/dist/connectors/google-drive.js +32 -13
- package/dist/connectors/google-search-console-oauth.js +39 -15
- package/dist/connectors/google-sheets.js +138 -195
- package/dist/connectors/google-slides.js +32 -13
- package/dist/connectors/grafana.js +39 -15
- package/dist/connectors/hackernews.js +32 -13
- package/dist/connectors/hubspot-oauth.js +32 -13
- package/dist/connectors/hubspot.js +39 -15
- package/dist/connectors/influxdb.js +39 -15
- package/dist/connectors/intercom-oauth.js +32 -13
- package/dist/connectors/intercom.js +39 -15
- package/dist/connectors/jdbc.js +39 -15
- package/dist/connectors/jira-api-key.js +39 -15
- package/dist/connectors/kintone-api-token.js +39 -15
- package/dist/connectors/kintone.js +128 -15
- package/dist/connectors/linear.js +39 -15
- package/dist/connectors/linkedin-ads.js +39 -15
- package/dist/connectors/mailchimp-oauth.js +39 -15
- package/dist/connectors/mailchimp.js +39 -15
- package/dist/connectors/meta-ads-oauth.js +39 -15
- package/dist/connectors/meta-ads.js +39 -15
- package/dist/connectors/mixpanel.js +39 -15
- package/dist/connectors/monday.js +39 -15
- package/dist/connectors/mongodb.js +39 -15
- package/dist/connectors/notion-oauth.js +32 -13
- package/dist/connectors/notion.js +84 -15
- package/dist/connectors/openai.js +39 -15
- package/dist/connectors/oracle.js +277 -15
- package/dist/connectors/outlook-oauth.js +32 -13
- package/dist/connectors/powerbi-oauth.js +32 -13
- package/dist/connectors/salesforce.js +108 -15
- package/dist/connectors/semrush.js +39 -15
- package/dist/connectors/sentry.js +39 -15
- package/dist/connectors/shopify-oauth.js +32 -13
- package/dist/connectors/shopify.js +39 -15
- package/dist/connectors/sqlserver.js +275 -15
- package/dist/connectors/stripe-api-key.js +39 -15
- package/dist/connectors/stripe-oauth.js +32 -13
- package/dist/connectors/supabase.js +284 -15
- package/dist/connectors/tableau.js +39 -15
- package/dist/connectors/tiktok-ads.js +39 -15
- package/dist/connectors/wix-store.js +39 -15
- package/dist/connectors/x.js +39 -15
- package/dist/connectors/zendesk-oauth.js +32 -13
- package/dist/connectors/zendesk.js +39 -15
- package/dist/index.js +4832 -3034
- package/dist/main.js +4832 -3034
- package/dist/vite-plugin.js +4786 -3023
- package/package.json +4 -4
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
-
var __esm = (fn, res) => function __init() {
|
|
4
|
-
|
|
3
|
+
var __esm = (fn, res, err) => function __init() {
|
|
4
|
+
if (err) throw err[0];
|
|
5
|
+
try {
|
|
6
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
7
|
+
} catch (e) {
|
|
8
|
+
throw err = [e], e;
|
|
9
|
+
}
|
|
5
10
|
};
|
|
6
11
|
var __export = (target, all) => {
|
|
7
12
|
for (var name in all)
|
|
@@ -473,6 +478,15 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
473
478
|
* `runSetupFlow` from `setup-flow.ts`.
|
|
474
479
|
*/
|
|
475
480
|
setup;
|
|
481
|
+
/**
|
|
482
|
+
* 統一 introspection。SQL DB の `information_schema` / `SHOW` / `DESCRIBE` や SaaS の
|
|
483
|
+
* メタデータ API といった取得経路の差を吸収し、tables / columns / PK / FK を共通型
|
|
484
|
+
* {@link IntrospectedSchema} へ正規化して返す。取得経路は {@link IntrospectContext} で
|
|
485
|
+
* 抽象化され、SQL DB は `ctx.query`、SaaS は `ctx.proxyFetch` + `ctx.params` を使う。
|
|
486
|
+
* `ctx.profile === true` のときは L2 プロファイル(行数・NULL 率等)も best-effort で埋める。
|
|
487
|
+
* coding-agent の `DataContextIndex` がデータ地図を構築する際に使う。
|
|
488
|
+
*/
|
|
489
|
+
introspect;
|
|
476
490
|
/**
|
|
477
491
|
* Opt-out of the default "verify before save" behavior on connection
|
|
478
492
|
* creation. The backend invokes `checkConnection` synchronously while
|
|
@@ -487,6 +501,14 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
487
501
|
* the default verify-on-create behavior without opt-in.
|
|
488
502
|
*/
|
|
489
503
|
skipConnectionCheckOnCreate;
|
|
504
|
+
/**
|
|
505
|
+
* 決定論的な「立ち上げ survey」レシピ(ルールベース prewarm 基盤)。実装した connector は、LLM を使わずに
|
|
506
|
+
* read-only で自分を survey する probe 列(テーブル/列メタデータ → 小サンプル)を宣言する。coding-agent の
|
|
507
|
+
* recon driver がこれを読み、connector ツールの `execute` を直接呼んで結果を seed にする。未実装の connector は
|
|
508
|
+
* driver 側で safely skip される(その connection は listConnections のみ seed)。標準 `information_schema` を
|
|
509
|
+
* 持つ SQL connector は `makeStandardSqlSurveyProbes` を使える。**probe は必ず read-only**。
|
|
510
|
+
*/
|
|
511
|
+
surveyProbes;
|
|
490
512
|
constructor(config) {
|
|
491
513
|
this.slug = config.slug;
|
|
492
514
|
this.authType = config.authType;
|
|
@@ -504,7 +526,9 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
504
526
|
this.query = config.query;
|
|
505
527
|
this.checkConnection = config.checkConnection;
|
|
506
528
|
this.setup = config.setup;
|
|
529
|
+
this.introspect = config.introspect;
|
|
507
530
|
this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
|
|
531
|
+
this.surveyProbes = config.surveyProbes;
|
|
508
532
|
}
|
|
509
533
|
get connectorKey() {
|
|
510
534
|
return _ConnectorPlugin.deriveKey(this.slug, this.authType);
|
|
@@ -542,25 +566,25 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
542
566
|
if (authType) return `${slug}-${authType}`;
|
|
543
567
|
const LEGACY_NULL_AUTH_TYPE_MAP = {
|
|
544
568
|
// user-password
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
569
|
+
postgresql: "user-password",
|
|
570
|
+
mysql: "user-password",
|
|
571
|
+
clickhouse: "user-password",
|
|
572
|
+
kintone: "user-password",
|
|
549
573
|
"squadbase-db": "user-password",
|
|
550
574
|
// service-account
|
|
551
|
-
|
|
552
|
-
|
|
575
|
+
snowflake: "service-account",
|
|
576
|
+
bigquery: "service-account",
|
|
553
577
|
"google-analytics": "service-account",
|
|
554
578
|
"google-calendar": "service-account",
|
|
555
579
|
"aws-athena": "service-account",
|
|
556
|
-
|
|
580
|
+
redshift: "service-account",
|
|
557
581
|
// api-key
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
582
|
+
databricks: "api-key",
|
|
583
|
+
dbt: "api-key",
|
|
584
|
+
airtable: "api-key",
|
|
585
|
+
openai: "api-key",
|
|
586
|
+
gemini: "api-key",
|
|
587
|
+
anthropic: "api-key",
|
|
564
588
|
"wix-store": "api-key"
|
|
565
589
|
};
|
|
566
590
|
const fallbackAuthType = LEGACY_NULL_AUTH_TYPE_MAP[slug];
|
|
@@ -569,6 +593,84 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
569
593
|
}
|
|
570
594
|
};
|
|
571
595
|
|
|
596
|
+
// ../connectors/src/survey-probe.ts
|
|
597
|
+
function rowsOf(output) {
|
|
598
|
+
if (!output || typeof output !== "object") return [];
|
|
599
|
+
const o = output;
|
|
600
|
+
if (o.success === false) return [];
|
|
601
|
+
return Array.isArray(o.rows) ? o.rows : [];
|
|
602
|
+
}
|
|
603
|
+
function pickString(row, candidates) {
|
|
604
|
+
for (const key of candidates) {
|
|
605
|
+
const v = row[key] ?? row[key.toUpperCase()] ?? row[key.toLowerCase()];
|
|
606
|
+
if (typeof v === "string" && v.length > 0) return v;
|
|
607
|
+
}
|
|
608
|
+
return void 0;
|
|
609
|
+
}
|
|
610
|
+
var TABLE_NAME_FIELDS = [
|
|
611
|
+
"table_name",
|
|
612
|
+
"name",
|
|
613
|
+
"tableName",
|
|
614
|
+
"tab_name",
|
|
615
|
+
"Table",
|
|
616
|
+
"table"
|
|
617
|
+
];
|
|
618
|
+
function makeQuoteIdent(opts) {
|
|
619
|
+
if (opts.bracket) {
|
|
620
|
+
return (name) => `[${name.replaceAll("]", "]]")}]`;
|
|
621
|
+
}
|
|
622
|
+
const q = opts.quote ?? '"';
|
|
623
|
+
return (name) => `${q}${name.replaceAll(q, q + q)}${q}`;
|
|
624
|
+
}
|
|
625
|
+
function sampleSql(ref, limit) {
|
|
626
|
+
return `SELECT * FROM (SELECT * FROM ${ref}) AS _sq LIMIT ${limit}`;
|
|
627
|
+
}
|
|
628
|
+
function distinctTables(prior, max) {
|
|
629
|
+
const names = [];
|
|
630
|
+
const seen = /* @__PURE__ */ new Set();
|
|
631
|
+
for (const row of rowsOf(prior[0]?.output)) {
|
|
632
|
+
const name = pickString(row, TABLE_NAME_FIELDS);
|
|
633
|
+
if (!name || seen.has(name)) continue;
|
|
634
|
+
seen.add(name);
|
|
635
|
+
names.push(name);
|
|
636
|
+
if (names.length >= max) break;
|
|
637
|
+
}
|
|
638
|
+
return names;
|
|
639
|
+
}
|
|
640
|
+
function makeStandardSqlSurveyProbes(opts) {
|
|
641
|
+
const queryTool = opts.queryTool ?? "executeQuery";
|
|
642
|
+
const sampleLimit = opts.sampleLimit ?? 5;
|
|
643
|
+
const maxSampleTables = opts.maxSampleTables ?? 4;
|
|
644
|
+
const quoteIdent = makeQuoteIdent(opts);
|
|
645
|
+
const whereSchema = opts.schemaLiteral ? ` WHERE table_schema = '${opts.schemaLiteral.replaceAll("'", "''")}'` : opts.schemaExpr ? ` WHERE table_schema = ${opts.schemaExpr}` : "";
|
|
646
|
+
return (_connectionId, prior) => {
|
|
647
|
+
if (prior.length === 0) {
|
|
648
|
+
return [
|
|
649
|
+
{
|
|
650
|
+
tool: queryTool,
|
|
651
|
+
input: {
|
|
652
|
+
toolUseIntent: "Survey table/column metadata",
|
|
653
|
+
sql: `SELECT table_name, column_name, data_type FROM information_schema.columns${whereSchema} ORDER BY table_name, ordinal_position LIMIT 1000`
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
];
|
|
657
|
+
}
|
|
658
|
+
if (prior.length === 1) {
|
|
659
|
+
return distinctTables(prior, maxSampleTables).map((name) => {
|
|
660
|
+
const ref = opts.schemaLiteral ? `${quoteIdent(opts.schemaLiteral)}.${quoteIdent(name)}` : quoteIdent(name);
|
|
661
|
+
return {
|
|
662
|
+
tool: queryTool,
|
|
663
|
+
input: {
|
|
664
|
+
toolUseIntent: `Sample ${name}`,
|
|
665
|
+
sql: sampleSql(ref, sampleLimit)
|
|
666
|
+
}
|
|
667
|
+
};
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
return [];
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
|
|
572
674
|
// ../connectors/src/setup-flow.ts
|
|
573
675
|
async function runSetupFlow(flow, params, ctx, config) {
|
|
574
676
|
const runtime = {
|
|
@@ -639,6 +741,55 @@ async function resolveSetupSelection(params) {
|
|
|
639
741
|
return resolved.slice(0, limit);
|
|
640
742
|
}
|
|
641
743
|
|
|
744
|
+
// ../connectors/src/introspect-concurrency.ts
|
|
745
|
+
async function mapWithConcurrency(items, limit, fn) {
|
|
746
|
+
const results = new Array(items.length);
|
|
747
|
+
let next = 0;
|
|
748
|
+
const workers = Array.from(
|
|
749
|
+
{ length: Math.min(Math.max(limit, 1), items.length) },
|
|
750
|
+
async () => {
|
|
751
|
+
for (; ; ) {
|
|
752
|
+
const i = next++;
|
|
753
|
+
if (i >= items.length) return;
|
|
754
|
+
results[i] = await fn(items[i]);
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
);
|
|
758
|
+
await Promise.all(workers);
|
|
759
|
+
return results;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
// ../connectors/src/introspect-profile.ts
|
|
763
|
+
var DEFAULT_MAX_TABLES = 200;
|
|
764
|
+
var DEFAULT_CONCURRENCY = 5;
|
|
765
|
+
var quoteBracket = (schema, name) => `[${schema.replace(/\]/g, "]]")}].[${name.replace(/\]/g, "]]")}]`;
|
|
766
|
+
async function withRowCounts(ctx, schemaPromise, quoteRef, opts = {}) {
|
|
767
|
+
const schema = await schemaPromise;
|
|
768
|
+
if (!ctx.profile || !ctx.query) return schema;
|
|
769
|
+
return attachRowCounts(ctx.query, schema, quoteRef, opts);
|
|
770
|
+
}
|
|
771
|
+
async function attachRowCounts(run, schema, quoteRef, opts = {}) {
|
|
772
|
+
const targets = schema.tables.slice(0, opts.maxTables ?? DEFAULT_MAX_TABLES);
|
|
773
|
+
await mapWithConcurrency(
|
|
774
|
+
targets,
|
|
775
|
+
opts.concurrency ?? DEFAULT_CONCURRENCY,
|
|
776
|
+
async (table) => {
|
|
777
|
+
try {
|
|
778
|
+
const { rows } = await run(
|
|
779
|
+
`SELECT COUNT(*) AS row_count FROM ${quoteRef(table.schema, table.name)}`
|
|
780
|
+
);
|
|
781
|
+
const first = rows[0] ? Object.values(rows[0])[0] : void 0;
|
|
782
|
+
const rowCount = Number(first);
|
|
783
|
+
if (Number.isFinite(rowCount)) {
|
|
784
|
+
table.profile = { ...table.profile ?? {}, rowCount };
|
|
785
|
+
}
|
|
786
|
+
} catch {
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
);
|
|
790
|
+
return schema;
|
|
791
|
+
}
|
|
792
|
+
|
|
642
793
|
// ../connectors/src/auth-types.ts
|
|
643
794
|
var AUTH_TYPES = {
|
|
644
795
|
OAUTH: "oauth",
|
|
@@ -649,6 +800,63 @@ var AUTH_TYPES = {
|
|
|
649
800
|
USER_PASSWORD: "user-password"
|
|
650
801
|
};
|
|
651
802
|
|
|
803
|
+
// ../connectors/src/introspect-information-schema.ts
|
|
804
|
+
function pickCI(row, key) {
|
|
805
|
+
if (key in row) return String(row[key] ?? "");
|
|
806
|
+
const lower = key.toLowerCase();
|
|
807
|
+
for (const k of Object.keys(row)) {
|
|
808
|
+
if (k.toLowerCase() === lower) return String(row[k] ?? "");
|
|
809
|
+
}
|
|
810
|
+
return "";
|
|
811
|
+
}
|
|
812
|
+
function assembleIntrospectedSchema(input) {
|
|
813
|
+
const { colRows, pkRows = [], fkRows = [] } = input;
|
|
814
|
+
const pkSet = /* @__PURE__ */ new Set();
|
|
815
|
+
for (const r of pkRows) {
|
|
816
|
+
pkSet.add(
|
|
817
|
+
`${pickCI(r, "table_schema")}.${pickCI(r, "table_name")}.${pickCI(r, "column_name")}`
|
|
818
|
+
);
|
|
819
|
+
}
|
|
820
|
+
const fkMap = /* @__PURE__ */ new Map();
|
|
821
|
+
for (const r of fkRows) {
|
|
822
|
+
fkMap.set(
|
|
823
|
+
`${pickCI(r, "table_schema")}.${pickCI(r, "table_name")}.${pickCI(r, "column_name")}`,
|
|
824
|
+
{
|
|
825
|
+
schema: pickCI(r, "foreign_table_schema"),
|
|
826
|
+
table: pickCI(r, "foreign_table_name"),
|
|
827
|
+
column: pickCI(r, "foreign_column_name")
|
|
828
|
+
}
|
|
829
|
+
);
|
|
830
|
+
}
|
|
831
|
+
const tableMap = /* @__PURE__ */ new Map();
|
|
832
|
+
for (const r of colRows) {
|
|
833
|
+
const schema = pickCI(r, "table_schema");
|
|
834
|
+
const name = pickCI(r, "table_name");
|
|
835
|
+
const key = `${schema}.${name}`;
|
|
836
|
+
let table = tableMap.get(key);
|
|
837
|
+
if (!table) {
|
|
838
|
+
table = {
|
|
839
|
+
schema,
|
|
840
|
+
name,
|
|
841
|
+
type: pickCI(r, "table_type").toUpperCase() === "VIEW" ? "view" : "table",
|
|
842
|
+
columns: []
|
|
843
|
+
};
|
|
844
|
+
tableMap.set(key, table);
|
|
845
|
+
}
|
|
846
|
+
const colKey = `${schema}.${name}.${pickCI(r, "column_name")}`;
|
|
847
|
+
const column = {
|
|
848
|
+
name: pickCI(r, "column_name"),
|
|
849
|
+
dataType: pickCI(r, "data_type"),
|
|
850
|
+
nullable: pickCI(r, "is_nullable").toUpperCase() === "YES"
|
|
851
|
+
};
|
|
852
|
+
if (pkSet.has(colKey)) column.isPrimaryKey = true;
|
|
853
|
+
const fk = fkMap.get(colKey);
|
|
854
|
+
if (fk) column.foreignKey = fk;
|
|
855
|
+
table.columns.push(column);
|
|
856
|
+
}
|
|
857
|
+
return { tables: [...tableMap.values()] };
|
|
858
|
+
}
|
|
859
|
+
|
|
652
860
|
// ../connectors/src/lib/sql-dml.ts
|
|
653
861
|
function isDmlStatement(sql) {
|
|
654
862
|
const stripped = sql.replace(/^(\s*(--[^\n]*\n|\/\*[\s\S]*?\*\/))+/, "").trimStart();
|
|
@@ -844,6 +1052,52 @@ var sqlserverSetupFlow = createSqlServerSetupFlow({
|
|
|
844
1052
|
forceEncrypt: false
|
|
845
1053
|
});
|
|
846
1054
|
|
|
1055
|
+
// ../connectors/src/connectors/sqlserver/introspect.ts
|
|
1056
|
+
async function introspectMssql(run) {
|
|
1057
|
+
const [{ rows: colRows }, { rows: pkRows }, { rows: fkRows }] = await Promise.all([
|
|
1058
|
+
// 1) 全カラム(型 / nullable)+ テーブル種別(BASE TABLE / VIEW)
|
|
1059
|
+
run(
|
|
1060
|
+
`SELECT c.TABLE_SCHEMA AS table_schema, c.TABLE_NAME AS table_name,
|
|
1061
|
+
c.COLUMN_NAME AS column_name, c.DATA_TYPE AS data_type,
|
|
1062
|
+
c.IS_NULLABLE AS is_nullable, c.ORDINAL_POSITION AS ordinal_position,
|
|
1063
|
+
t.TABLE_TYPE AS table_type
|
|
1064
|
+
FROM INFORMATION_SCHEMA.COLUMNS c
|
|
1065
|
+
JOIN INFORMATION_SCHEMA.TABLES t
|
|
1066
|
+
ON t.TABLE_SCHEMA = c.TABLE_SCHEMA AND t.TABLE_NAME = c.TABLE_NAME
|
|
1067
|
+
WHERE c.TABLE_SCHEMA NOT IN ('sys', 'INFORMATION_SCHEMA')
|
|
1068
|
+
ORDER BY c.TABLE_SCHEMA, c.TABLE_NAME, c.ORDINAL_POSITION`
|
|
1069
|
+
),
|
|
1070
|
+
// 2) 主キー
|
|
1071
|
+
run(
|
|
1072
|
+
`SELECT tc.TABLE_SCHEMA AS table_schema, tc.TABLE_NAME AS table_name,
|
|
1073
|
+
kcu.COLUMN_NAME AS column_name
|
|
1074
|
+
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc
|
|
1075
|
+
JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu
|
|
1076
|
+
ON kcu.CONSTRAINT_NAME = tc.CONSTRAINT_NAME
|
|
1077
|
+
AND kcu.TABLE_SCHEMA = tc.TABLE_SCHEMA
|
|
1078
|
+
AND kcu.TABLE_NAME = tc.TABLE_NAME
|
|
1079
|
+
WHERE tc.CONSTRAINT_TYPE = 'PRIMARY KEY'
|
|
1080
|
+
AND tc.TABLE_SCHEMA NOT IN ('sys', 'INFORMATION_SCHEMA')`
|
|
1081
|
+
),
|
|
1082
|
+
// 3) 外部キー(参照元列 → 参照先列)。sys カタログで複合 FK も 1:1 に解決する。
|
|
1083
|
+
run(
|
|
1084
|
+
`SELECT sch.name AS table_schema, tab.name AS table_name, col.name AS column_name,
|
|
1085
|
+
rsch.name AS foreign_table_schema, rtab.name AS foreign_table_name,
|
|
1086
|
+
rcol.name AS foreign_column_name
|
|
1087
|
+
FROM sys.foreign_key_columns fkc
|
|
1088
|
+
JOIN sys.tables tab ON tab.object_id = fkc.parent_object_id
|
|
1089
|
+
JOIN sys.schemas sch ON sch.schema_id = tab.schema_id
|
|
1090
|
+
JOIN sys.columns col ON col.object_id = fkc.parent_object_id
|
|
1091
|
+
AND col.column_id = fkc.parent_column_id
|
|
1092
|
+
JOIN sys.tables rtab ON rtab.object_id = fkc.referenced_object_id
|
|
1093
|
+
JOIN sys.schemas rsch ON rsch.schema_id = rtab.schema_id
|
|
1094
|
+
JOIN sys.columns rcol ON rcol.object_id = fkc.referenced_object_id
|
|
1095
|
+
AND rcol.column_id = fkc.referenced_column_id`
|
|
1096
|
+
)
|
|
1097
|
+
]);
|
|
1098
|
+
return assembleIntrospectedSchema({ colRows, pkRows, fkRows });
|
|
1099
|
+
}
|
|
1100
|
+
|
|
847
1101
|
// ../connectors/src/connectors/sqlserver/tools/execute-query.ts
|
|
848
1102
|
import { z } from "zod";
|
|
849
1103
|
init_mssql_runner();
|
|
@@ -978,6 +1232,12 @@ The business logic type for this connector is "sql".
|
|
|
978
1232
|
- \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`
|
|
979
1233
|
},
|
|
980
1234
|
tools,
|
|
1235
|
+
// 決定論的な立ち上げ survey(ルールベース prewarm)。SQL Server はユーザーオブジェクトが既定 `dbo`、識別子は `[ ]`。
|
|
1236
|
+
surveyProbes: makeStandardSqlSurveyProbes({
|
|
1237
|
+
schemaLiteral: "dbo",
|
|
1238
|
+
bracket: true
|
|
1239
|
+
}),
|
|
1240
|
+
introspect: (ctx) => withRowCounts(ctx, introspectMssql(ctx.query), quoteBracket),
|
|
981
1241
|
setup: (params, ctx, config) => runSetupFlow(sqlserverSetupFlow, params, ctx, config),
|
|
982
1242
|
async checkConnection(params, _config) {
|
|
983
1243
|
return checkMssqlConnection(
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
-
var __esm = (fn, res) => function __init() {
|
|
3
|
-
|
|
2
|
+
var __esm = (fn, res, err) => function __init() {
|
|
3
|
+
if (err) throw err[0];
|
|
4
|
+
try {
|
|
5
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
6
|
+
} catch (e) {
|
|
7
|
+
throw err = [e], e;
|
|
8
|
+
}
|
|
4
9
|
};
|
|
5
10
|
|
|
6
11
|
// ../connectors/src/parameter-definition.ts
|
|
@@ -155,6 +160,15 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
155
160
|
* `runSetupFlow` from `setup-flow.ts`.
|
|
156
161
|
*/
|
|
157
162
|
setup;
|
|
163
|
+
/**
|
|
164
|
+
* 統一 introspection。SQL DB の `information_schema` / `SHOW` / `DESCRIBE` や SaaS の
|
|
165
|
+
* メタデータ API といった取得経路の差を吸収し、tables / columns / PK / FK を共通型
|
|
166
|
+
* {@link IntrospectedSchema} へ正規化して返す。取得経路は {@link IntrospectContext} で
|
|
167
|
+
* 抽象化され、SQL DB は `ctx.query`、SaaS は `ctx.proxyFetch` + `ctx.params` を使う。
|
|
168
|
+
* `ctx.profile === true` のときは L2 プロファイル(行数・NULL 率等)も best-effort で埋める。
|
|
169
|
+
* coding-agent の `DataContextIndex` がデータ地図を構築する際に使う。
|
|
170
|
+
*/
|
|
171
|
+
introspect;
|
|
158
172
|
/**
|
|
159
173
|
* Opt-out of the default "verify before save" behavior on connection
|
|
160
174
|
* creation. The backend invokes `checkConnection` synchronously while
|
|
@@ -169,6 +183,14 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
169
183
|
* the default verify-on-create behavior without opt-in.
|
|
170
184
|
*/
|
|
171
185
|
skipConnectionCheckOnCreate;
|
|
186
|
+
/**
|
|
187
|
+
* 決定論的な「立ち上げ survey」レシピ(ルールベース prewarm 基盤)。実装した connector は、LLM を使わずに
|
|
188
|
+
* read-only で自分を survey する probe 列(テーブル/列メタデータ → 小サンプル)を宣言する。coding-agent の
|
|
189
|
+
* recon driver がこれを読み、connector ツールの `execute` を直接呼んで結果を seed にする。未実装の connector は
|
|
190
|
+
* driver 側で safely skip される(その connection は listConnections のみ seed)。標準 `information_schema` を
|
|
191
|
+
* 持つ SQL connector は `makeStandardSqlSurveyProbes` を使える。**probe は必ず read-only**。
|
|
192
|
+
*/
|
|
193
|
+
surveyProbes;
|
|
172
194
|
constructor(config) {
|
|
173
195
|
this.slug = config.slug;
|
|
174
196
|
this.authType = config.authType;
|
|
@@ -186,7 +208,9 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
186
208
|
this.query = config.query;
|
|
187
209
|
this.checkConnection = config.checkConnection;
|
|
188
210
|
this.setup = config.setup;
|
|
211
|
+
this.introspect = config.introspect;
|
|
189
212
|
this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
|
|
213
|
+
this.surveyProbes = config.surveyProbes;
|
|
190
214
|
}
|
|
191
215
|
get connectorKey() {
|
|
192
216
|
return _ConnectorPlugin.deriveKey(this.slug, this.authType);
|
|
@@ -224,25 +248,25 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
224
248
|
if (authType) return `${slug}-${authType}`;
|
|
225
249
|
const LEGACY_NULL_AUTH_TYPE_MAP = {
|
|
226
250
|
// user-password
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
251
|
+
postgresql: "user-password",
|
|
252
|
+
mysql: "user-password",
|
|
253
|
+
clickhouse: "user-password",
|
|
254
|
+
kintone: "user-password",
|
|
231
255
|
"squadbase-db": "user-password",
|
|
232
256
|
// service-account
|
|
233
|
-
|
|
234
|
-
|
|
257
|
+
snowflake: "service-account",
|
|
258
|
+
bigquery: "service-account",
|
|
235
259
|
"google-analytics": "service-account",
|
|
236
260
|
"google-calendar": "service-account",
|
|
237
261
|
"aws-athena": "service-account",
|
|
238
|
-
|
|
262
|
+
redshift: "service-account",
|
|
239
263
|
// api-key
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
264
|
+
databricks: "api-key",
|
|
265
|
+
dbt: "api-key",
|
|
266
|
+
airtable: "api-key",
|
|
267
|
+
openai: "api-key",
|
|
268
|
+
gemini: "api-key",
|
|
269
|
+
anthropic: "api-key",
|
|
246
270
|
"wix-store": "api-key"
|
|
247
271
|
};
|
|
248
272
|
const fallbackAuthType = LEGACY_NULL_AUTH_TYPE_MAP[slug];
|
|
@@ -75,6 +75,15 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
75
75
|
* `runSetupFlow` from `setup-flow.ts`.
|
|
76
76
|
*/
|
|
77
77
|
setup;
|
|
78
|
+
/**
|
|
79
|
+
* 統一 introspection。SQL DB の `information_schema` / `SHOW` / `DESCRIBE` や SaaS の
|
|
80
|
+
* メタデータ API といった取得経路の差を吸収し、tables / columns / PK / FK を共通型
|
|
81
|
+
* {@link IntrospectedSchema} へ正規化して返す。取得経路は {@link IntrospectContext} で
|
|
82
|
+
* 抽象化され、SQL DB は `ctx.query`、SaaS は `ctx.proxyFetch` + `ctx.params` を使う。
|
|
83
|
+
* `ctx.profile === true` のときは L2 プロファイル(行数・NULL 率等)も best-effort で埋める。
|
|
84
|
+
* coding-agent の `DataContextIndex` がデータ地図を構築する際に使う。
|
|
85
|
+
*/
|
|
86
|
+
introspect;
|
|
78
87
|
/**
|
|
79
88
|
* Opt-out of the default "verify before save" behavior on connection
|
|
80
89
|
* creation. The backend invokes `checkConnection` synchronously while
|
|
@@ -89,6 +98,14 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
89
98
|
* the default verify-on-create behavior without opt-in.
|
|
90
99
|
*/
|
|
91
100
|
skipConnectionCheckOnCreate;
|
|
101
|
+
/**
|
|
102
|
+
* 決定論的な「立ち上げ survey」レシピ(ルールベース prewarm 基盤)。実装した connector は、LLM を使わずに
|
|
103
|
+
* read-only で自分を survey する probe 列(テーブル/列メタデータ → 小サンプル)を宣言する。coding-agent の
|
|
104
|
+
* recon driver がこれを読み、connector ツールの `execute` を直接呼んで結果を seed にする。未実装の connector は
|
|
105
|
+
* driver 側で safely skip される(その connection は listConnections のみ seed)。標準 `information_schema` を
|
|
106
|
+
* 持つ SQL connector は `makeStandardSqlSurveyProbes` を使える。**probe は必ず read-only**。
|
|
107
|
+
*/
|
|
108
|
+
surveyProbes;
|
|
92
109
|
constructor(config) {
|
|
93
110
|
this.slug = config.slug;
|
|
94
111
|
this.authType = config.authType;
|
|
@@ -106,7 +123,9 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
106
123
|
this.query = config.query;
|
|
107
124
|
this.checkConnection = config.checkConnection;
|
|
108
125
|
this.setup = config.setup;
|
|
126
|
+
this.introspect = config.introspect;
|
|
109
127
|
this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
|
|
128
|
+
this.surveyProbes = config.surveyProbes;
|
|
110
129
|
}
|
|
111
130
|
get connectorKey() {
|
|
112
131
|
return _ConnectorPlugin.deriveKey(this.slug, this.authType);
|
|
@@ -144,25 +163,25 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
144
163
|
if (authType) return `${slug}-${authType}`;
|
|
145
164
|
const LEGACY_NULL_AUTH_TYPE_MAP = {
|
|
146
165
|
// user-password
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
166
|
+
postgresql: "user-password",
|
|
167
|
+
mysql: "user-password",
|
|
168
|
+
clickhouse: "user-password",
|
|
169
|
+
kintone: "user-password",
|
|
151
170
|
"squadbase-db": "user-password",
|
|
152
171
|
// service-account
|
|
153
|
-
|
|
154
|
-
|
|
172
|
+
snowflake: "service-account",
|
|
173
|
+
bigquery: "service-account",
|
|
155
174
|
"google-analytics": "service-account",
|
|
156
175
|
"google-calendar": "service-account",
|
|
157
176
|
"aws-athena": "service-account",
|
|
158
|
-
|
|
177
|
+
redshift: "service-account",
|
|
159
178
|
// api-key
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
179
|
+
databricks: "api-key",
|
|
180
|
+
dbt: "api-key",
|
|
181
|
+
airtable: "api-key",
|
|
182
|
+
openai: "api-key",
|
|
183
|
+
gemini: "api-key",
|
|
184
|
+
anthropic: "api-key",
|
|
166
185
|
"wix-store": "api-key"
|
|
167
186
|
};
|
|
168
187
|
const fallbackAuthType = LEGACY_NULL_AUTH_TYPE_MAP[slug];
|