@squadbase/connectors 0.0.5 → 0.0.7
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/chunk-5YEHPSNW.js +79 -0
- package/dist/index.js +173 -220
- package/dist/sdk.d.ts +39 -0
- package/dist/sdk.js +78 -0
- package/package.json +5 -1
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// 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(connection) {
|
|
23
|
+
const param = connection.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 "${connection.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(connection) {
|
|
37
|
+
const param = connection.parameters.find(
|
|
38
|
+
(p) => p.parameterSlug === this.slug
|
|
39
|
+
);
|
|
40
|
+
if (!param || param.value == null) return void 0;
|
|
41
|
+
return param.value;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// src/connectors/kintone/parameters.ts
|
|
46
|
+
var parameters = {
|
|
47
|
+
baseUrl: new ParameterDefinition({
|
|
48
|
+
slug: "base-url",
|
|
49
|
+
name: "kintone Base URL",
|
|
50
|
+
description: "The base URL of your kintone environment (e.g., https://example.cybozu.com).",
|
|
51
|
+
envVarBaseKey: "KINTONE_BASE_URL",
|
|
52
|
+
type: "text",
|
|
53
|
+
secret: false,
|
|
54
|
+
required: true
|
|
55
|
+
}),
|
|
56
|
+
username: new ParameterDefinition({
|
|
57
|
+
slug: "username",
|
|
58
|
+
name: "kintone Username",
|
|
59
|
+
description: "The username (login name) for kintone authentication.",
|
|
60
|
+
envVarBaseKey: "KINTONE_USERNAME",
|
|
61
|
+
type: "text",
|
|
62
|
+
secret: false,
|
|
63
|
+
required: true
|
|
64
|
+
}),
|
|
65
|
+
password: new ParameterDefinition({
|
|
66
|
+
slug: "password",
|
|
67
|
+
name: "kintone Password",
|
|
68
|
+
description: "The password for kintone authentication.",
|
|
69
|
+
envVarBaseKey: "KINTONE_PASSWORD",
|
|
70
|
+
type: "text",
|
|
71
|
+
secret: true,
|
|
72
|
+
required: true
|
|
73
|
+
})
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export {
|
|
77
|
+
ParameterDefinition,
|
|
78
|
+
parameters
|
|
79
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ParameterDefinition,
|
|
3
|
+
parameters
|
|
4
|
+
} from "./chunk-5YEHPSNW.js";
|
|
5
|
+
|
|
1
6
|
// src/connector-setup.ts
|
|
2
7
|
var ConnectorSetup = class {
|
|
3
8
|
prompts;
|
|
@@ -9,50 +14,6 @@ var ConnectorSetup = class {
|
|
|
9
14
|
}
|
|
10
15
|
};
|
|
11
16
|
|
|
12
|
-
// src/parameter-definition.ts
|
|
13
|
-
var ParameterDefinition = class {
|
|
14
|
-
slug;
|
|
15
|
-
name;
|
|
16
|
-
description;
|
|
17
|
-
envVarBaseKey;
|
|
18
|
-
type;
|
|
19
|
-
secret;
|
|
20
|
-
required;
|
|
21
|
-
constructor(config) {
|
|
22
|
-
this.slug = config.slug;
|
|
23
|
-
this.name = config.name;
|
|
24
|
-
this.description = config.description;
|
|
25
|
-
this.envVarBaseKey = config.envVarBaseKey;
|
|
26
|
-
this.type = config.type;
|
|
27
|
-
this.secret = config.secret;
|
|
28
|
-
this.required = config.required;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Get the parameter value from a ConnectorConnectionObject.
|
|
32
|
-
*/
|
|
33
|
-
getValue(connection) {
|
|
34
|
-
const param = connection.parameters.find(
|
|
35
|
-
(p) => p.parameterSlug === this.slug
|
|
36
|
-
);
|
|
37
|
-
if (!param || param.value == null) {
|
|
38
|
-
throw new Error(
|
|
39
|
-
`Parameter "${this.slug}" not found or has no value in connection "${connection.id}"`
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
return param.value;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Try to get the parameter value. Returns undefined if not found (for optional params).
|
|
46
|
-
*/
|
|
47
|
-
tryGetValue(connection) {
|
|
48
|
-
const param = connection.parameters.find(
|
|
49
|
-
(p) => p.parameterSlug === this.slug
|
|
50
|
-
);
|
|
51
|
-
if (!param || param.value == null) return void 0;
|
|
52
|
-
return param.value;
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
|
|
56
17
|
// src/connector-tool.ts
|
|
57
18
|
var ConnectorTool = class {
|
|
58
19
|
name;
|
|
@@ -264,7 +225,7 @@ Follow these steps to set up the Snowflake connection.
|
|
|
264
225
|
});
|
|
265
226
|
|
|
266
227
|
// src/connectors/snowflake/parameters.ts
|
|
267
|
-
var
|
|
228
|
+
var parameters2 = {
|
|
268
229
|
account: new ParameterDefinition({
|
|
269
230
|
slug: "account",
|
|
270
231
|
name: "Snowflake Account",
|
|
@@ -358,11 +319,11 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
358
319
|
try {
|
|
359
320
|
const snowflake = (await import("snowflake-sdk")).default;
|
|
360
321
|
snowflake.configure({ logLevel: "ERROR" });
|
|
361
|
-
const account =
|
|
362
|
-
const user =
|
|
363
|
-
const role =
|
|
364
|
-
const warehouse =
|
|
365
|
-
const privateKeyBase64 =
|
|
322
|
+
const account = parameters2.account.getValue(connection);
|
|
323
|
+
const user = parameters2.user.getValue(connection);
|
|
324
|
+
const role = parameters2.role.getValue(connection);
|
|
325
|
+
const warehouse = parameters2.warehouse.getValue(connection);
|
|
326
|
+
const privateKeyBase64 = parameters2.privateKeyBase64.getValue(connection);
|
|
366
327
|
const privateKey = Buffer.from(privateKeyBase64, "base64").toString(
|
|
367
328
|
"utf-8"
|
|
368
329
|
);
|
|
@@ -429,7 +390,7 @@ var snowflakeConnector = new ConnectorPlugin({
|
|
|
429
390
|
name: "Snowflake",
|
|
430
391
|
description: "Connect to Snowflake for cloud data warehousing and analytics.",
|
|
431
392
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/6oyVtAcP3pMlXaOrts9unk/b7a9dc25d15c388b66e983041b855447/snowflake.svg",
|
|
432
|
-
parameters,
|
|
393
|
+
parameters: parameters2,
|
|
433
394
|
releaseFlag: { dev1: true, dev2: true, prod: true },
|
|
434
395
|
setup: snowflakeSetup,
|
|
435
396
|
systemPrompt: `## Snowflake SQL Notes
|
|
@@ -446,14 +407,14 @@ var snowflakeConnector = new ConnectorPlugin({
|
|
|
446
407
|
const snowflake = (await import("snowflake-sdk")).default;
|
|
447
408
|
snowflake.configure({ logLevel: "ERROR" });
|
|
448
409
|
const privateKey = Buffer.from(
|
|
449
|
-
params[
|
|
410
|
+
params[parameters2.privateKeyBase64.slug],
|
|
450
411
|
"base64"
|
|
451
412
|
).toString("utf-8");
|
|
452
413
|
const conn = snowflake.createConnection({
|
|
453
|
-
account: params[
|
|
454
|
-
username: params[
|
|
455
|
-
role: params[
|
|
456
|
-
warehouse: params[
|
|
414
|
+
account: params[parameters2.account.slug],
|
|
415
|
+
username: params[parameters2.user.slug],
|
|
416
|
+
role: params[parameters2.role.slug],
|
|
417
|
+
warehouse: params[parameters2.warehouse.slug],
|
|
457
418
|
authenticator: "SNOWFLAKE_JWT",
|
|
458
419
|
privateKey
|
|
459
420
|
});
|
|
@@ -485,14 +446,14 @@ var snowflakeConnector = new ConnectorPlugin({
|
|
|
485
446
|
const snowflake = (await import("snowflake-sdk")).default;
|
|
486
447
|
snowflake.configure({ logLevel: "ERROR" });
|
|
487
448
|
const privateKey = Buffer.from(
|
|
488
|
-
params[
|
|
449
|
+
params[parameters2.privateKeyBase64.slug],
|
|
489
450
|
"base64"
|
|
490
451
|
).toString("utf-8");
|
|
491
452
|
const conn = snowflake.createConnection({
|
|
492
|
-
account: params[
|
|
493
|
-
username: params[
|
|
494
|
-
role: params[
|
|
495
|
-
warehouse: params[
|
|
453
|
+
account: params[parameters2.account.slug],
|
|
454
|
+
username: params[parameters2.user.slug],
|
|
455
|
+
role: params[parameters2.role.slug],
|
|
456
|
+
warehouse: params[parameters2.warehouse.slug],
|
|
496
457
|
authenticator: "SNOWFLAKE_JWT",
|
|
497
458
|
privateKey
|
|
498
459
|
});
|
|
@@ -521,7 +482,7 @@ var snowflakeConnector = new ConnectorPlugin({
|
|
|
521
482
|
});
|
|
522
483
|
|
|
523
484
|
// src/connectors/snowflake-pat/parameters.ts
|
|
524
|
-
var
|
|
485
|
+
var parameters3 = {
|
|
525
486
|
account: new ParameterDefinition({
|
|
526
487
|
slug: "account",
|
|
527
488
|
name: "Snowflake Account",
|
|
@@ -615,11 +576,11 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
615
576
|
try {
|
|
616
577
|
const snowflake = (await import("snowflake-sdk")).default;
|
|
617
578
|
snowflake.configure({ logLevel: "ERROR" });
|
|
618
|
-
const account =
|
|
619
|
-
const user =
|
|
620
|
-
const role =
|
|
621
|
-
const warehouse =
|
|
622
|
-
const password =
|
|
579
|
+
const account = parameters3.account.getValue(connection);
|
|
580
|
+
const user = parameters3.user.getValue(connection);
|
|
581
|
+
const role = parameters3.role.getValue(connection);
|
|
582
|
+
const warehouse = parameters3.warehouse.getValue(connection);
|
|
583
|
+
const password = parameters3.pat.getValue(connection);
|
|
623
584
|
const conn = snowflake.createConnection({
|
|
624
585
|
account,
|
|
625
586
|
username: user,
|
|
@@ -682,7 +643,7 @@ var snowflakePatConnector = new ConnectorPlugin({
|
|
|
682
643
|
name: "Snowflake (PAT)",
|
|
683
644
|
description: "Connect to Snowflake using a Personal Access Token (PAT).",
|
|
684
645
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/6oyVtAcP3pMlXaOrts9unk/b7a9dc25d15c388b66e983041b855447/snowflake.svg",
|
|
685
|
-
parameters:
|
|
646
|
+
parameters: parameters3,
|
|
686
647
|
releaseFlag: { dev1: true, dev2: false, prod: false },
|
|
687
648
|
setup: snowflakeSetup,
|
|
688
649
|
systemPrompt: `## Snowflake SQL Notes
|
|
@@ -699,11 +660,11 @@ var snowflakePatConnector = new ConnectorPlugin({
|
|
|
699
660
|
const snowflake = (await import("snowflake-sdk")).default;
|
|
700
661
|
snowflake.configure({ logLevel: "ERROR" });
|
|
701
662
|
const conn = snowflake.createConnection({
|
|
702
|
-
account: params[
|
|
703
|
-
username: params[
|
|
704
|
-
role: params[
|
|
705
|
-
warehouse: params[
|
|
706
|
-
password: params[
|
|
663
|
+
account: params[parameters3.account.slug],
|
|
664
|
+
username: params[parameters3.user.slug],
|
|
665
|
+
role: params[parameters3.role.slug],
|
|
666
|
+
warehouse: params[parameters3.warehouse.slug],
|
|
667
|
+
password: params[parameters3.pat.slug]
|
|
707
668
|
});
|
|
708
669
|
await new Promise((resolve, reject) => {
|
|
709
670
|
conn.connect((err) => {
|
|
@@ -738,11 +699,11 @@ var snowflakePatConnector = new ConnectorPlugin({
|
|
|
738
699
|
const snowflake = (await import("snowflake-sdk")).default;
|
|
739
700
|
snowflake.configure({ logLevel: "ERROR" });
|
|
740
701
|
const conn = snowflake.createConnection({
|
|
741
|
-
account: params[
|
|
742
|
-
username: params[
|
|
743
|
-
role: params[
|
|
744
|
-
warehouse: params[
|
|
745
|
-
password: params[
|
|
702
|
+
account: params[parameters3.account.slug],
|
|
703
|
+
username: params[parameters3.user.slug],
|
|
704
|
+
role: params[parameters3.role.slug],
|
|
705
|
+
warehouse: params[parameters3.warehouse.slug],
|
|
706
|
+
password: params[parameters3.pat.slug]
|
|
746
707
|
});
|
|
747
708
|
await new Promise((resolve, reject) => {
|
|
748
709
|
conn.connect((err) => {
|
|
@@ -774,7 +735,7 @@ var snowflakePatConnector = new ConnectorPlugin({
|
|
|
774
735
|
});
|
|
775
736
|
|
|
776
737
|
// src/connectors/postgresql/parameters.ts
|
|
777
|
-
var
|
|
738
|
+
var parameters4 = {
|
|
778
739
|
connectionUrl: new ParameterDefinition({
|
|
779
740
|
slug: "connection-url",
|
|
780
741
|
name: "PostgreSQL Connection URL",
|
|
@@ -831,7 +792,7 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
831
792
|
let connectionUrl;
|
|
832
793
|
try {
|
|
833
794
|
const { Pool } = await import("pg");
|
|
834
|
-
connectionUrl =
|
|
795
|
+
connectionUrl = parameters4.connectionUrl.getValue(connection);
|
|
835
796
|
const pool = new Pool({
|
|
836
797
|
connectionString: connectionUrl,
|
|
837
798
|
ssl: { rejectUnauthorized: false },
|
|
@@ -869,7 +830,7 @@ var postgresqlConnector = new ConnectorPlugin({
|
|
|
869
830
|
name: "PostgreSQL",
|
|
870
831
|
description: "Connect to PostgreSQL databases for relational data storage and querying.",
|
|
871
832
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/42AHi2uqteUn65MyqdN6V7/a0f68f12af6aac96bbcda5980f43de07/elephant.png",
|
|
872
|
-
parameters:
|
|
833
|
+
parameters: parameters4,
|
|
873
834
|
releaseFlag: { dev1: true, dev2: true, prod: true },
|
|
874
835
|
systemPrompt: `## PostgreSQL SQL Notes
|
|
875
836
|
- Schema exploration:
|
|
@@ -880,7 +841,7 @@ var postgresqlConnector = new ConnectorPlugin({
|
|
|
880
841
|
async checkConnection(params, _config) {
|
|
881
842
|
const { Pool } = await import("pg");
|
|
882
843
|
const pool = new Pool({
|
|
883
|
-
connectionString: params[
|
|
844
|
+
connectionString: params[parameters4.connectionUrl.slug],
|
|
884
845
|
ssl: { rejectUnauthorized: false },
|
|
885
846
|
connectionTimeoutMillis: 1e4
|
|
886
847
|
});
|
|
@@ -897,7 +858,7 @@ var postgresqlConnector = new ConnectorPlugin({
|
|
|
897
858
|
const { Pool } = await import("pg");
|
|
898
859
|
const { text, values } = buildPositionalParams(sql, namedParams);
|
|
899
860
|
const pool = new Pool({
|
|
900
|
-
connectionString: params[
|
|
861
|
+
connectionString: params[parameters4.connectionUrl.slug],
|
|
901
862
|
ssl: { rejectUnauthorized: false },
|
|
902
863
|
connectionTimeoutMillis: 1e4,
|
|
903
864
|
statement_timeout: 6e4
|
|
@@ -912,7 +873,7 @@ var postgresqlConnector = new ConnectorPlugin({
|
|
|
912
873
|
});
|
|
913
874
|
|
|
914
875
|
// src/connectors/mysql/parameters.ts
|
|
915
|
-
var
|
|
876
|
+
var parameters5 = {
|
|
916
877
|
connectionUrl: new ParameterDefinition({
|
|
917
878
|
slug: "connection-url",
|
|
918
879
|
name: "MySQL Connection URL",
|
|
@@ -969,7 +930,7 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
969
930
|
let connectionUrl;
|
|
970
931
|
try {
|
|
971
932
|
const mysql = await import("mysql2/promise");
|
|
972
|
-
connectionUrl =
|
|
933
|
+
connectionUrl = parameters5.connectionUrl.getValue(connection);
|
|
973
934
|
const pool = mysql.createPool({
|
|
974
935
|
uri: connectionUrl,
|
|
975
936
|
connectTimeout: CONNECT_TIMEOUT_MS2
|
|
@@ -1009,7 +970,7 @@ var mysqlConnector = new ConnectorPlugin({
|
|
|
1009
970
|
name: "MySQL",
|
|
1010
971
|
description: "Connect to MySQL databases for relational data storage and querying.",
|
|
1011
972
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/6ghPFeGgl7uBs5NHH1a4L/512c9433beec5b595caa41f04921c1f9/logo-mysql-170x115.png",
|
|
1012
|
-
parameters:
|
|
973
|
+
parameters: parameters5,
|
|
1013
974
|
releaseFlag: { dev1: true, dev2: true, prod: true },
|
|
1014
975
|
systemPrompt: `## MySQL SQL Notes
|
|
1015
976
|
- Schema exploration:
|
|
@@ -1020,7 +981,7 @@ var mysqlConnector = new ConnectorPlugin({
|
|
|
1020
981
|
async checkConnection(params, _config) {
|
|
1021
982
|
const mysql = await import("mysql2/promise");
|
|
1022
983
|
const pool = mysql.createPool({
|
|
1023
|
-
uri: params[
|
|
984
|
+
uri: params[parameters5.connectionUrl.slug],
|
|
1024
985
|
connectTimeout: 1e4
|
|
1025
986
|
});
|
|
1026
987
|
try {
|
|
@@ -1036,7 +997,7 @@ var mysqlConnector = new ConnectorPlugin({
|
|
|
1036
997
|
const mysql = await import("mysql2/promise");
|
|
1037
998
|
const { text, values } = buildQuestionmarkParams(sql, namedParams);
|
|
1038
999
|
const pool = mysql.createPool({
|
|
1039
|
-
uri: params[
|
|
1000
|
+
uri: params[parameters5.connectionUrl.slug],
|
|
1040
1001
|
connectTimeout: 1e4
|
|
1041
1002
|
});
|
|
1042
1003
|
try {
|
|
@@ -1057,7 +1018,7 @@ var mysqlConnector = new ConnectorPlugin({
|
|
|
1057
1018
|
import { z as z5 } from "zod";
|
|
1058
1019
|
|
|
1059
1020
|
// src/connectors/bigquery/parameters.ts
|
|
1060
|
-
var
|
|
1021
|
+
var parameters6 = {
|
|
1061
1022
|
serviceAccountKeyJsonBase64: new ParameterDefinition({
|
|
1062
1023
|
slug: "service-account-key-json-base64",
|
|
1063
1024
|
name: "Google Cloud Service Account JSON",
|
|
@@ -1114,7 +1075,7 @@ var listProjectsTool = new ConnectorTool({
|
|
|
1114
1075
|
};
|
|
1115
1076
|
}
|
|
1116
1077
|
try {
|
|
1117
|
-
const serviceAccountJsonBase64 =
|
|
1078
|
+
const serviceAccountJsonBase64 = parameters6.serviceAccountKeyJsonBase64.getValue(connection);
|
|
1118
1079
|
const credentials = JSON.parse(
|
|
1119
1080
|
Buffer.from(serviceAccountJsonBase64, "base64").toString("utf-8")
|
|
1120
1081
|
);
|
|
@@ -1150,10 +1111,10 @@ var bigquerySetup = new ConnectorSetup({
|
|
|
1150
1111
|
|
|
1151
1112
|
#### \u30B9\u30C6\u30C3\u30D71: \u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u9078\u629E
|
|
1152
1113
|
1. \`${listProjectsToolName}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u3001\u30B5\u30FC\u30D3\u30B9\u30A2\u30AB\u30A6\u30F3\u30C8\u304C\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306AGCP\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u4E00\u89A7\u3092\u53D6\u5F97\u3059\u308B
|
|
1153
|
-
2. \`updateConnectionParameters\` \u3092\u547C\u3073\u51FA\
|
|
1114
|
+
2. \`updateConnectionParameters\` \u3092\u547C\u3073\u51FA\u3059:
|
|
1154
1115
|
- \`parameterSlug\`: \`"project-id"\`
|
|
1155
1116
|
- \`options\`: \u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u4E00\u89A7\u3002\u5404 option \u306E \`label\` \u306F \`\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u540D (id: \u30D7\u30ED\u30B8\u30A7\u30AF\u30C8ID)\` \u306E\u5F62\u5F0F\u3001\`value\` \u306F\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8ID
|
|
1156
|
-
3. \
|
|
1117
|
+
3. \u30E6\u30FC\u30B6\u30FC\u304C\u9078\u629E\u3057\u305F\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E \`label\` \u304C\u30E1\u30C3\u30BB\u30FC\u30B8\u3068\u3057\u3066\u5C4A\u304F\u306E\u3067\u3001\u30B9\u30C6\u30C3\u30D72\u306B\u9032\u3080
|
|
1157
1118
|
|
|
1158
1119
|
#### \u30B9\u30C6\u30C3\u30D72: \u30C7\u30FC\u30BF\u30BB\u30C3\u30C8\u9078\u629E
|
|
1159
1120
|
1. \`SELECT schema_name FROM INFORMATION_SCHEMA.SCHEMATA\` \u3092\u5B9F\u884C\u3057\u3066\u30C7\u30FC\u30BF\u30BB\u30C3\u30C8\u4E00\u89A7\u3092\u53D6\u5F97\u3059\u308B
|
|
@@ -1167,14 +1128,13 @@ var bigquerySetup = new ConnectorSetup({
|
|
|
1167
1128
|
- **\u30C6\u30FC\u30D6\u30EB\u304C2\u3064\u4EE5\u4E0A**: \`askUserQuestion\`\uFF08multiSelect: true\uFF09\u3067\u30E6\u30FC\u30B6\u30FC\u306B\u63D0\u793A\u3057\u3001\u4F7F\u7528\u3059\u308B\u30C6\u30FC\u30D6\u30EB\u3092\u9078\u629E\u3055\u305B\u308B\u3002description \u306B\u306F\u30C7\u30FC\u30BF\u30BB\u30C3\u30C8\u540D\u3092\u8A18\u8F09\u3059\u308B
|
|
1168
1129
|
- **\u30C6\u30FC\u30D6\u30EB\u304C1\u3064\u3060\u3051**: askUserQuestion \u306F\u4F7F\u308F\u305A\u81EA\u52D5\u63A1\u7528
|
|
1169
1130
|
|
|
1170
|
-
#### \u30B9\u30C6\u30C3\u30D74: \
|
|
1171
|
-
5. \`updateConnectionContext\` \
|
|
1131
|
+
#### \u30B9\u30C6\u30C3\u30D74: \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u5B8C\u4E86
|
|
1132
|
+
5. \`updateConnectionContext\` \u3092\u547C\u3073\u51FA\u3059:
|
|
1172
1133
|
- \`dataset\`: \u9078\u629E\u3055\u308C\u305F\u30C7\u30FC\u30BF\u30BB\u30C3\u30C8\u540D\uFF08\u8907\u6570\u306E\u5834\u5408\u306F\u30AB\u30F3\u30DE\u533A\u5207\u308A\uFF09
|
|
1173
1134
|
- \`tables\`: \u9078\u629E\u3055\u308C\u305F\u30C6\u30FC\u30D6\u30EB\u540D\uFF08\u8907\u6570\u306E\u5834\u5408\u306F\u30AB\u30F3\u30DE\u533A\u5207\u308A\uFF09
|
|
1174
1135
|
- \`note\`: \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u5185\u5BB9\u306E\u7C21\u5358\u306A\u8AAC\u660E
|
|
1175
1136
|
|
|
1176
1137
|
### \u91CD\u8981\u306A\u5236\u7D04
|
|
1177
|
-
- askUserQuestion \u306E options \u306B\u306F\u6700\u4F4E2\u4EF6\u5FC5\u8981\u30021\u4EF6\u3057\u304B\u306A\u3044\u5834\u5408\u306F askUserQuestion \u3092\u547C\u3070\u305A\u6B21\u306E\u30B9\u30C6\u30C3\u30D7\u306B\u9032\u3080\u3053\u3068
|
|
1178
1138
|
- **\u30C6\u30FC\u30D6\u30EB\u306E\u884C\u30C7\u30FC\u30BF\u3092\u8AAD\u307F\u53D6\u3089\u306A\u3044\u3053\u3068**\u3002\u5B9F\u884C\u3057\u3066\u3088\u3044\u306E\u306F\u4E0A\u8A18\u624B\u9806\u3067\u6307\u5B9A\u3055\u308C\u305F\u30E1\u30BF\u30C7\u30FC\u30BF\u53D6\u5F97\u30AF\u30A8\u30EA\u306E\u307F\u3002\u305D\u308C\u4EE5\u5916\u306E\u30AF\u30A8\u30EA\u306F\u5B9F\u884C\u7981\u6B62
|
|
1179
1139
|
|
|
1180
1140
|
### \u5B9F\u884C\u65B9\u91DD
|
|
@@ -1188,10 +1148,10 @@ Follow these steps to set up the BigQuery connection.
|
|
|
1188
1148
|
|
|
1189
1149
|
#### Step 1: Project Selection
|
|
1190
1150
|
1. Call \`${listProjectsToolName}\` to get the list of GCP projects accessible with the service account credentials
|
|
1191
|
-
2. Call \`updateConnectionParameters
|
|
1151
|
+
2. Call \`updateConnectionParameters\`:
|
|
1192
1152
|
- \`parameterSlug\`: \`"project-id"\`
|
|
1193
1153
|
- \`options\`: The project list. Each option's \`label\` should be \`Project Name (id: project-id)\`, \`value\` should be the project ID
|
|
1194
|
-
3.
|
|
1154
|
+
3. The \`label\` of the user's selected project will arrive as a message. Proceed to Step 2
|
|
1195
1155
|
|
|
1196
1156
|
#### Step 2: Dataset Selection
|
|
1197
1157
|
1. Run \`SELECT schema_name FROM INFORMATION_SCHEMA.SCHEMATA\` to get the list of datasets
|
|
@@ -1205,14 +1165,13 @@ Follow these steps to set up the BigQuery connection.
|
|
|
1205
1165
|
- **2 or more tables**: Present them to the user via \`askUserQuestion\` (multiSelect: true) and let them select which tables to use. Include the dataset name in the description
|
|
1206
1166
|
- **Exactly 1 table**: Do NOT call askUserQuestion. Auto-select it
|
|
1207
1167
|
|
|
1208
|
-
#### Step 4:
|
|
1209
|
-
5. Call \`updateConnectionContext
|
|
1168
|
+
#### Step 4: Complete Setup
|
|
1169
|
+
5. Call \`updateConnectionContext\`:
|
|
1210
1170
|
- \`dataset\`: Selected dataset name(s) (comma-separated if multiple)
|
|
1211
1171
|
- \`tables\`: Selected table name(s) (comma-separated if multiple)
|
|
1212
1172
|
- \`note\`: Brief description of the setup
|
|
1213
1173
|
|
|
1214
1174
|
### Important Constraints
|
|
1215
|
-
- askUserQuestion options requires at least 2 items. If there is only 1 item, do NOT call askUserQuestion \u2014 proceed to the next step directly
|
|
1216
1175
|
- **Do NOT read table row data**. Only the metadata queries specified in the steps above are allowed. All other queries are forbidden
|
|
1217
1176
|
|
|
1218
1177
|
### Execution Policy
|
|
@@ -1264,8 +1223,8 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
1264
1223
|
);
|
|
1265
1224
|
try {
|
|
1266
1225
|
const { BigQuery } = await import("@google-cloud/bigquery");
|
|
1267
|
-
const projectId =
|
|
1268
|
-
const serviceAccountJsonBase64 =
|
|
1226
|
+
const projectId = parameters6.projectId.getValue(connection);
|
|
1227
|
+
const serviceAccountJsonBase64 = parameters6.serviceAccountKeyJsonBase64.getValue(connection);
|
|
1269
1228
|
const credentials = JSON.parse(
|
|
1270
1229
|
Buffer.from(serviceAccountJsonBase64, "base64").toString("utf-8")
|
|
1271
1230
|
);
|
|
@@ -1295,7 +1254,7 @@ var bigqueryConnector = new ConnectorPlugin({
|
|
|
1295
1254
|
name: "BigQuery",
|
|
1296
1255
|
description: "Connect to Google BigQuery for data warehouse and analytics.",
|
|
1297
1256
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/6nlehQyOmdbktG5hOYkYMr/6ca559140d5ddc7dadc5eac88858a563/bigquery.svg",
|
|
1298
|
-
parameters:
|
|
1257
|
+
parameters: parameters6,
|
|
1299
1258
|
releaseFlag: { dev1: true, dev2: true, prod: true },
|
|
1300
1259
|
setup: bigquerySetup,
|
|
1301
1260
|
systemPrompt: `## BigQuery SQL Notes
|
|
@@ -1309,10 +1268,10 @@ var bigqueryConnector = new ConnectorPlugin({
|
|
|
1309
1268
|
async checkConnection(params, _config) {
|
|
1310
1269
|
const { BigQuery } = await import("@google-cloud/bigquery");
|
|
1311
1270
|
const credentials = JSON.parse(
|
|
1312
|
-
Buffer.from(params[
|
|
1271
|
+
Buffer.from(params[parameters6.serviceAccountKeyJsonBase64.slug], "base64").toString("utf-8")
|
|
1313
1272
|
);
|
|
1314
1273
|
const bq = new BigQuery({
|
|
1315
|
-
projectId: params[
|
|
1274
|
+
projectId: params[parameters6.projectId.slug],
|
|
1316
1275
|
credentials
|
|
1317
1276
|
});
|
|
1318
1277
|
try {
|
|
@@ -1327,10 +1286,10 @@ var bigqueryConnector = new ConnectorPlugin({
|
|
|
1327
1286
|
const { BigQuery } = await import("@google-cloud/bigquery");
|
|
1328
1287
|
const resolvedSql = replaceLiteralParams(sql, namedParams);
|
|
1329
1288
|
const credentials = JSON.parse(
|
|
1330
|
-
Buffer.from(params[
|
|
1289
|
+
Buffer.from(params[parameters6.serviceAccountKeyJsonBase64.slug], "base64").toString("utf-8")
|
|
1331
1290
|
);
|
|
1332
1291
|
const bq = new BigQuery({
|
|
1333
|
-
projectId: params[
|
|
1292
|
+
projectId: params[parameters6.projectId.slug],
|
|
1334
1293
|
credentials
|
|
1335
1294
|
});
|
|
1336
1295
|
const [job] = await bq.createQueryJob({ query: resolvedSql });
|
|
@@ -1457,10 +1416,10 @@ var bigquerySetup2 = new ConnectorSetup({
|
|
|
1457
1416
|
|
|
1458
1417
|
#### \u30B9\u30C6\u30C3\u30D71: \u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u9078\u629E
|
|
1459
1418
|
1. \`${listProjectsToolName2}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u3001OAuth\u3067\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306AGCP\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u4E00\u89A7\u3092\u53D6\u5F97\u3059\u308B
|
|
1460
|
-
2. \`updateConnectionParameters\` \u3092\u547C\u3073\u51FA\
|
|
1419
|
+
2. \`updateConnectionParameters\` \u3092\u547C\u3073\u51FA\u3059:
|
|
1461
1420
|
- \`parameterSlug\`: \`"project-id"\`
|
|
1462
1421
|
- \`options\`: \u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u4E00\u89A7\u3002\u5404 option \u306E \`label\` \u306F \`\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u540D (id: \u30D7\u30ED\u30B8\u30A7\u30AF\u30C8ID)\` \u306E\u5F62\u5F0F\u3001\`value\` \u306F\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8ID
|
|
1463
|
-
3. \
|
|
1422
|
+
3. \u30E6\u30FC\u30B6\u30FC\u304C\u9078\u629E\u3057\u305F\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E \`label\` \u304C\u30E1\u30C3\u30BB\u30FC\u30B8\u3068\u3057\u3066\u5C4A\u304F\u306E\u3067\u3001\u30B9\u30C6\u30C3\u30D72\u306B\u9032\u3080
|
|
1464
1423
|
|
|
1465
1424
|
#### \u30B9\u30C6\u30C3\u30D72: \u30C7\u30FC\u30BF\u30BB\u30C3\u30C8\u9078\u629E
|
|
1466
1425
|
1. \`SELECT schema_name FROM INFORMATION_SCHEMA.SCHEMATA\` \u3092\u5B9F\u884C\u3057\u3066\u30C7\u30FC\u30BF\u30BB\u30C3\u30C8\u4E00\u89A7\u3092\u53D6\u5F97\u3059\u308B
|
|
@@ -1474,14 +1433,13 @@ var bigquerySetup2 = new ConnectorSetup({
|
|
|
1474
1433
|
- **\u30C6\u30FC\u30D6\u30EB\u304C2\u3064\u4EE5\u4E0A**: \`askUserQuestion\`\uFF08multiSelect: true\uFF09\u3067\u30E6\u30FC\u30B6\u30FC\u306B\u63D0\u793A\u3057\u3001\u4F7F\u7528\u3059\u308B\u30C6\u30FC\u30D6\u30EB\u3092\u9078\u629E\u3055\u305B\u308B\u3002description \u306B\u306F\u30C7\u30FC\u30BF\u30BB\u30C3\u30C8\u540D\u3092\u8A18\u8F09\u3059\u308B
|
|
1475
1434
|
- **\u30C6\u30FC\u30D6\u30EB\u304C1\u3064\u3060\u3051**: askUserQuestion \u306F\u4F7F\u308F\u305A\u81EA\u52D5\u63A1\u7528
|
|
1476
1435
|
|
|
1477
|
-
#### \u30B9\u30C6\u30C3\u30D74: \
|
|
1478
|
-
5. \`updateConnectionContext\` \
|
|
1436
|
+
#### \u30B9\u30C6\u30C3\u30D74: \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u5B8C\u4E86
|
|
1437
|
+
5. \`updateConnectionContext\` \u3092\u547C\u3073\u51FA\u3059:
|
|
1479
1438
|
- \`dataset\`: \u9078\u629E\u3055\u308C\u305F\u30C7\u30FC\u30BF\u30BB\u30C3\u30C8\u540D\uFF08\u8907\u6570\u306E\u5834\u5408\u306F\u30AB\u30F3\u30DE\u533A\u5207\u308A\uFF09
|
|
1480
1439
|
- \`tables\`: \u9078\u629E\u3055\u308C\u305F\u30C6\u30FC\u30D6\u30EB\u540D\uFF08\u8907\u6570\u306E\u5834\u5408\u306F\u30AB\u30F3\u30DE\u533A\u5207\u308A\uFF09
|
|
1481
1440
|
- \`note\`: \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u5185\u5BB9\u306E\u7C21\u5358\u306A\u8AAC\u660E
|
|
1482
1441
|
|
|
1483
1442
|
### \u91CD\u8981\u306A\u5236\u7D04
|
|
1484
|
-
- askUserQuestion \u306E options \u306B\u306F\u6700\u4F4E2\u4EF6\u5FC5\u8981\u30021\u4EF6\u3057\u304B\u306A\u3044\u5834\u5408\u306F askUserQuestion \u3092\u547C\u3070\u305A\u6B21\u306E\u30B9\u30C6\u30C3\u30D7\u306B\u9032\u3080\u3053\u3068
|
|
1485
1443
|
- **\u30C6\u30FC\u30D6\u30EB\u306E\u884C\u30C7\u30FC\u30BF\u3092\u8AAD\u307F\u53D6\u3089\u306A\u3044\u3053\u3068**\u3002\u5B9F\u884C\u3057\u3066\u3088\u3044\u306E\u306F\u4E0A\u8A18\u624B\u9806\u3067\u6307\u5B9A\u3055\u308C\u305F\u30E1\u30BF\u30C7\u30FC\u30BF\u53D6\u5F97\u30AF\u30A8\u30EA\u306E\u307F\u3002\u305D\u308C\u4EE5\u5916\u306E\u30AF\u30A8\u30EA\u306F\u5B9F\u884C\u7981\u6B62
|
|
1486
1444
|
|
|
1487
1445
|
### \u5B9F\u884C\u65B9\u91DD
|
|
@@ -1495,10 +1453,10 @@ Follow these steps to set up the BigQuery connection.
|
|
|
1495
1453
|
|
|
1496
1454
|
#### Step 1: Project Selection
|
|
1497
1455
|
1. Call \`${listProjectsToolName2}\` to get the list of GCP projects accessible with the OAuth credentials
|
|
1498
|
-
2. Call \`updateConnectionParameters
|
|
1456
|
+
2. Call \`updateConnectionParameters\`:
|
|
1499
1457
|
- \`parameterSlug\`: \`"project-id"\`
|
|
1500
1458
|
- \`options\`: The project list. Each option's \`label\` should be \`Project Name (id: project-id)\`, \`value\` should be the project ID
|
|
1501
|
-
3.
|
|
1459
|
+
3. The \`label\` of the user's selected project will arrive as a message. Proceed to Step 2
|
|
1502
1460
|
|
|
1503
1461
|
#### Step 2: Dataset Selection
|
|
1504
1462
|
1. Run \`SELECT schema_name FROM INFORMATION_SCHEMA.SCHEMATA\` to get the list of datasets
|
|
@@ -1512,14 +1470,13 @@ Follow these steps to set up the BigQuery connection.
|
|
|
1512
1470
|
- **2 or more tables**: Present them to the user via \`askUserQuestion\` (multiSelect: true) and let them select which tables to use. Include the dataset name in the description
|
|
1513
1471
|
- **Exactly 1 table**: Do NOT call askUserQuestion. Auto-select it
|
|
1514
1472
|
|
|
1515
|
-
#### Step 4:
|
|
1516
|
-
5. Call \`updateConnectionContext
|
|
1473
|
+
#### Step 4: Complete Setup
|
|
1474
|
+
5. Call \`updateConnectionContext\`:
|
|
1517
1475
|
- \`dataset\`: Selected dataset name(s) (comma-separated if multiple)
|
|
1518
1476
|
- \`tables\`: Selected table name(s) (comma-separated if multiple)
|
|
1519
1477
|
- \`note\`: Brief description of the setup
|
|
1520
1478
|
|
|
1521
1479
|
### Important Constraints
|
|
1522
|
-
- askUserQuestion options requires at least 2 items. If there is only 1 item, do NOT call askUserQuestion \u2014 proceed to the next step directly
|
|
1523
1480
|
- **Do NOT read table row data**. Only the metadata queries specified in the steps above are allowed. All other queries are forbidden
|
|
1524
1481
|
|
|
1525
1482
|
### Execution Policy
|
|
@@ -1528,7 +1485,7 @@ Follow these steps to set up the BigQuery connection.
|
|
|
1528
1485
|
});
|
|
1529
1486
|
|
|
1530
1487
|
// src/connectors/bigquery-oauth/parameters.ts
|
|
1531
|
-
var
|
|
1488
|
+
var parameters7 = {
|
|
1532
1489
|
projectId: new ParameterDefinition({
|
|
1533
1490
|
slug: "project-id",
|
|
1534
1491
|
name: "Google Cloud Project ID",
|
|
@@ -1622,7 +1579,7 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
1622
1579
|
error: `Connection ${connectionId} not found`
|
|
1623
1580
|
};
|
|
1624
1581
|
}
|
|
1625
|
-
const gcpProjectId =
|
|
1582
|
+
const gcpProjectId = parameters7.projectId.getValue(connection);
|
|
1626
1583
|
console.log(
|
|
1627
1584
|
`[connector-query] bigquery-oauth/${connection.name}: ${sql}`
|
|
1628
1585
|
);
|
|
@@ -1689,7 +1646,7 @@ var bigqueryOauthConnector = new ConnectorPlugin({
|
|
|
1689
1646
|
name: "BigQuery (OAuth)",
|
|
1690
1647
|
description: "Connect to Google BigQuery for data warehouse and analytics using OAuth.",
|
|
1691
1648
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/6nlehQyOmdbktG5hOYkYMr/6ca559140d5ddc7dadc5eac88858a563/bigquery.svg",
|
|
1692
|
-
parameters:
|
|
1649
|
+
parameters: parameters7,
|
|
1693
1650
|
releaseFlag: { dev1: true, dev2: false, prod: false },
|
|
1694
1651
|
setup: bigquerySetup2,
|
|
1695
1652
|
proxyPolicy: {
|
|
@@ -1708,7 +1665,7 @@ var bigqueryOauthConnector = new ConnectorPlugin({
|
|
|
1708
1665
|
tools: tools6,
|
|
1709
1666
|
async checkConnection(params, config) {
|
|
1710
1667
|
const { proxyFetch } = config;
|
|
1711
|
-
const projectId = params[
|
|
1668
|
+
const projectId = params[parameters7.projectId.slug];
|
|
1712
1669
|
const url = `https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/queries`;
|
|
1713
1670
|
try {
|
|
1714
1671
|
const res = await proxyFetch(url, {
|
|
@@ -1727,7 +1684,7 @@ var bigqueryOauthConnector = new ConnectorPlugin({
|
|
|
1727
1684
|
},
|
|
1728
1685
|
async query(params, sql, namedParams, context) {
|
|
1729
1686
|
const { proxyFetch } = context;
|
|
1730
|
-
const projectId = params[
|
|
1687
|
+
const projectId = params[parameters7.projectId.slug];
|
|
1731
1688
|
const resolvedSql = replaceLiteralParams(sql, namedParams);
|
|
1732
1689
|
const url = `https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/queries`;
|
|
1733
1690
|
const res = await proxyFetch(url, {
|
|
@@ -1745,7 +1702,7 @@ var bigqueryOauthConnector = new ConnectorPlugin({
|
|
|
1745
1702
|
});
|
|
1746
1703
|
|
|
1747
1704
|
// src/connectors/aws-athena/parameters.ts
|
|
1748
|
-
var
|
|
1705
|
+
var parameters8 = {
|
|
1749
1706
|
awsAccessKeyId: new ParameterDefinition({
|
|
1750
1707
|
slug: "aws-access-key-id",
|
|
1751
1708
|
name: "AWS Access Key ID",
|
|
@@ -1842,8 +1799,8 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
1842
1799
|
GetQueryExecutionCommand,
|
|
1843
1800
|
GetQueryResultsCommand
|
|
1844
1801
|
} = await import("@aws-sdk/client-athena");
|
|
1845
|
-
const workgroup =
|
|
1846
|
-
const outputLocation =
|
|
1802
|
+
const workgroup = parameters8.workgroup.tryGetValue(connection);
|
|
1803
|
+
const outputLocation = parameters8.outputLocation.tryGetValue(connection);
|
|
1847
1804
|
if (!workgroup && !outputLocation) {
|
|
1848
1805
|
return {
|
|
1849
1806
|
success: false,
|
|
@@ -1851,10 +1808,10 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
1851
1808
|
};
|
|
1852
1809
|
}
|
|
1853
1810
|
const client = new AthenaClient({
|
|
1854
|
-
region:
|
|
1811
|
+
region: parameters8.awsRegion.getValue(connection),
|
|
1855
1812
|
credentials: {
|
|
1856
|
-
accessKeyId:
|
|
1857
|
-
secretAccessKey:
|
|
1813
|
+
accessKeyId: parameters8.awsAccessKeyId.getValue(connection),
|
|
1814
|
+
secretAccessKey: parameters8.awsSecretAccessKey.getValue(connection)
|
|
1858
1815
|
}
|
|
1859
1816
|
});
|
|
1860
1817
|
const startParams = { QueryString: sql };
|
|
@@ -1918,7 +1875,7 @@ var awsAthenaConnector = new ConnectorPlugin({
|
|
|
1918
1875
|
name: "AWS Athena",
|
|
1919
1876
|
description: "Connect to AWS Athena for serverless SQL queries on S3 data.",
|
|
1920
1877
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/5x0vIHtUHfJJMZUv4RFOYZ/5059bac389f0169542f39cdb4b387d2c/Athena.svg",
|
|
1921
|
-
parameters:
|
|
1878
|
+
parameters: parameters8,
|
|
1922
1879
|
releaseFlag: { dev1: true, dev2: true, prod: true },
|
|
1923
1880
|
systemPrompt: `## AWS Athena SQL Notes
|
|
1924
1881
|
- Uses Presto/Trino based SQL syntax
|
|
@@ -1936,8 +1893,8 @@ var awsAthenaConnector = new ConnectorPlugin({
|
|
|
1936
1893
|
StartQueryExecutionCommand,
|
|
1937
1894
|
GetQueryExecutionCommand
|
|
1938
1895
|
} = await import("@aws-sdk/client-athena");
|
|
1939
|
-
const workgroup = params[
|
|
1940
|
-
const outputLocation = params[
|
|
1896
|
+
const workgroup = params[parameters8.workgroup.slug];
|
|
1897
|
+
const outputLocation = params[parameters8.outputLocation.slug];
|
|
1941
1898
|
if (!workgroup && !outputLocation) {
|
|
1942
1899
|
return {
|
|
1943
1900
|
success: false,
|
|
@@ -1945,10 +1902,10 @@ var awsAthenaConnector = new ConnectorPlugin({
|
|
|
1945
1902
|
};
|
|
1946
1903
|
}
|
|
1947
1904
|
const client = new AthenaClient({
|
|
1948
|
-
region: params[
|
|
1905
|
+
region: params[parameters8.awsRegion.slug],
|
|
1949
1906
|
credentials: {
|
|
1950
|
-
accessKeyId: params[
|
|
1951
|
-
secretAccessKey: params[
|
|
1907
|
+
accessKeyId: params[parameters8.awsAccessKeyId.slug],
|
|
1908
|
+
secretAccessKey: params[parameters8.awsSecretAccessKey.slug]
|
|
1952
1909
|
}
|
|
1953
1910
|
});
|
|
1954
1911
|
const startParams = { QueryString: "SELECT 1" };
|
|
@@ -1993,16 +1950,16 @@ var awsAthenaConnector = new ConnectorPlugin({
|
|
|
1993
1950
|
GetQueryResultsCommand
|
|
1994
1951
|
} = await import("@aws-sdk/client-athena");
|
|
1995
1952
|
const resolvedSql = replaceLiteralParams(sql, namedParams);
|
|
1996
|
-
const workgroup = params[
|
|
1997
|
-
const outputLocation = params[
|
|
1953
|
+
const workgroup = params[parameters8.workgroup.slug];
|
|
1954
|
+
const outputLocation = params[parameters8.outputLocation.slug];
|
|
1998
1955
|
if (!workgroup && !outputLocation) {
|
|
1999
1956
|
throw new Error("Either workgroup or output-location is required");
|
|
2000
1957
|
}
|
|
2001
1958
|
const client = new AthenaClient({
|
|
2002
|
-
region: params[
|
|
1959
|
+
region: params[parameters8.awsRegion.slug],
|
|
2003
1960
|
credentials: {
|
|
2004
|
-
accessKeyId: params[
|
|
2005
|
-
secretAccessKey: params[
|
|
1961
|
+
accessKeyId: params[parameters8.awsAccessKeyId.slug],
|
|
1962
|
+
secretAccessKey: params[parameters8.awsSecretAccessKey.slug]
|
|
2006
1963
|
}
|
|
2007
1964
|
});
|
|
2008
1965
|
const startParams = { QueryString: resolvedSql };
|
|
@@ -2047,7 +2004,7 @@ var awsAthenaConnector = new ConnectorPlugin({
|
|
|
2047
2004
|
});
|
|
2048
2005
|
|
|
2049
2006
|
// src/connectors/redshift/parameters.ts
|
|
2050
|
-
var
|
|
2007
|
+
var parameters9 = {
|
|
2051
2008
|
awsAccessKeyId: new ParameterDefinition({
|
|
2052
2009
|
slug: "aws-access-key-id",
|
|
2053
2010
|
name: "AWS Access Key ID",
|
|
@@ -2173,14 +2130,14 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
2173
2130
|
DescribeStatementCommand,
|
|
2174
2131
|
GetStatementResultCommand
|
|
2175
2132
|
} = await import("@aws-sdk/client-redshift-data");
|
|
2176
|
-
const awsAccessKeyId =
|
|
2177
|
-
const awsSecretAccessKey =
|
|
2178
|
-
const awsRegion =
|
|
2179
|
-
const database =
|
|
2180
|
-
const clusterIdentifier =
|
|
2181
|
-
const workgroupName =
|
|
2182
|
-
const secretArn =
|
|
2183
|
-
const dbUser =
|
|
2133
|
+
const awsAccessKeyId = parameters9.awsAccessKeyId.getValue(connection);
|
|
2134
|
+
const awsSecretAccessKey = parameters9.awsSecretAccessKey.getValue(connection);
|
|
2135
|
+
const awsRegion = parameters9.awsRegion.getValue(connection);
|
|
2136
|
+
const database = parameters9.database.getValue(connection);
|
|
2137
|
+
const clusterIdentifier = parameters9.clusterIdentifier.tryGetValue(connection);
|
|
2138
|
+
const workgroupName = parameters9.workgroupName.tryGetValue(connection);
|
|
2139
|
+
const secretArn = parameters9.secretArn.tryGetValue(connection);
|
|
2140
|
+
const dbUser = parameters9.dbUser.tryGetValue(connection);
|
|
2184
2141
|
if (!clusterIdentifier && !workgroupName) {
|
|
2185
2142
|
return {
|
|
2186
2143
|
success: false,
|
|
@@ -2251,7 +2208,7 @@ var redshiftConnector = new ConnectorPlugin({
|
|
|
2251
2208
|
name: "Redshift",
|
|
2252
2209
|
description: "Connect to Amazon Redshift for data warehouse analytics.",
|
|
2253
2210
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/AEwW2psmrnZ7htTVsgA9t/a637e31707c5d760be73ce1d8ec75580/aws-redshift-logo.svg",
|
|
2254
|
-
parameters:
|
|
2211
|
+
parameters: parameters9,
|
|
2255
2212
|
releaseFlag: { dev1: true, dev2: true, prod: true },
|
|
2256
2213
|
systemPrompt: `## Redshift SQL Notes
|
|
2257
2214
|
- Uses PostgreSQL based SQL syntax
|
|
@@ -2269,10 +2226,10 @@ var redshiftConnector = new ConnectorPlugin({
|
|
|
2269
2226
|
ExecuteStatementCommand,
|
|
2270
2227
|
DescribeStatementCommand
|
|
2271
2228
|
} = await import("@aws-sdk/client-redshift-data");
|
|
2272
|
-
const clusterIdentifier = params[
|
|
2273
|
-
const workgroupName = params[
|
|
2274
|
-
const secretArn = params[
|
|
2275
|
-
const dbUser = params[
|
|
2229
|
+
const clusterIdentifier = params[parameters9.clusterIdentifier.slug];
|
|
2230
|
+
const workgroupName = params[parameters9.workgroupName.slug];
|
|
2231
|
+
const secretArn = params[parameters9.secretArn.slug];
|
|
2232
|
+
const dbUser = params[parameters9.dbUser.slug];
|
|
2276
2233
|
if (!clusterIdentifier && !workgroupName) {
|
|
2277
2234
|
return {
|
|
2278
2235
|
success: false,
|
|
@@ -2280,15 +2237,15 @@ var redshiftConnector = new ConnectorPlugin({
|
|
|
2280
2237
|
};
|
|
2281
2238
|
}
|
|
2282
2239
|
const client = new RedshiftDataClient({
|
|
2283
|
-
region: params[
|
|
2240
|
+
region: params[parameters9.awsRegion.slug],
|
|
2284
2241
|
credentials: {
|
|
2285
|
-
accessKeyId: params[
|
|
2286
|
-
secretAccessKey: params[
|
|
2242
|
+
accessKeyId: params[parameters9.awsAccessKeyId.slug],
|
|
2243
|
+
secretAccessKey: params[parameters9.awsSecretAccessKey.slug]
|
|
2287
2244
|
}
|
|
2288
2245
|
});
|
|
2289
2246
|
const { Id: statementId } = await client.send(
|
|
2290
2247
|
new ExecuteStatementCommand({
|
|
2291
|
-
Database: params[
|
|
2248
|
+
Database: params[parameters9.database.slug],
|
|
2292
2249
|
Sql: "SELECT 1",
|
|
2293
2250
|
...clusterIdentifier && { ClusterIdentifier: clusterIdentifier },
|
|
2294
2251
|
...workgroupName && { WorkgroupName: workgroupName },
|
|
@@ -2329,23 +2286,23 @@ var redshiftConnector = new ConnectorPlugin({
|
|
|
2329
2286
|
GetStatementResultCommand
|
|
2330
2287
|
} = await import("@aws-sdk/client-redshift-data");
|
|
2331
2288
|
const resolvedSql = replaceLiteralParams(sql, namedParams);
|
|
2332
|
-
const clusterIdentifier = params[
|
|
2333
|
-
const workgroupName = params[
|
|
2334
|
-
const secretArn = params[
|
|
2335
|
-
const dbUser = params[
|
|
2289
|
+
const clusterIdentifier = params[parameters9.clusterIdentifier.slug];
|
|
2290
|
+
const workgroupName = params[parameters9.workgroupName.slug];
|
|
2291
|
+
const secretArn = params[parameters9.secretArn.slug];
|
|
2292
|
+
const dbUser = params[parameters9.dbUser.slug];
|
|
2336
2293
|
if (!clusterIdentifier && !workgroupName) {
|
|
2337
2294
|
throw new Error("Either cluster-identifier or workgroup-name is required");
|
|
2338
2295
|
}
|
|
2339
2296
|
const client = new RedshiftDataClient({
|
|
2340
|
-
region: params[
|
|
2297
|
+
region: params[parameters9.awsRegion.slug],
|
|
2341
2298
|
credentials: {
|
|
2342
|
-
accessKeyId: params[
|
|
2343
|
-
secretAccessKey: params[
|
|
2299
|
+
accessKeyId: params[parameters9.awsAccessKeyId.slug],
|
|
2300
|
+
secretAccessKey: params[parameters9.awsSecretAccessKey.slug]
|
|
2344
2301
|
}
|
|
2345
2302
|
});
|
|
2346
2303
|
const { Id: statementId } = await client.send(
|
|
2347
2304
|
new ExecuteStatementCommand({
|
|
2348
|
-
Database: params[
|
|
2305
|
+
Database: params[parameters9.database.slug],
|
|
2349
2306
|
Sql: resolvedSql,
|
|
2350
2307
|
...clusterIdentifier && { ClusterIdentifier: clusterIdentifier },
|
|
2351
2308
|
...workgroupName && { WorkgroupName: workgroupName },
|
|
@@ -2383,7 +2340,7 @@ var redshiftConnector = new ConnectorPlugin({
|
|
|
2383
2340
|
});
|
|
2384
2341
|
|
|
2385
2342
|
// src/connectors/databricks/parameters.ts
|
|
2386
|
-
var
|
|
2343
|
+
var parameters10 = {
|
|
2387
2344
|
host: new ParameterDefinition({
|
|
2388
2345
|
slug: "host",
|
|
2389
2346
|
name: "Databricks Workspace Host",
|
|
@@ -2455,9 +2412,9 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
2455
2412
|
);
|
|
2456
2413
|
try {
|
|
2457
2414
|
const { DBSQLClient } = await import("@databricks/sql");
|
|
2458
|
-
const host =
|
|
2459
|
-
const token =
|
|
2460
|
-
const httpPath =
|
|
2415
|
+
const host = parameters10.host.getValue(connection);
|
|
2416
|
+
const token = parameters10.token.getValue(connection);
|
|
2417
|
+
const httpPath = parameters10.httpPath.getValue(connection);
|
|
2461
2418
|
const client = new DBSQLClient();
|
|
2462
2419
|
await client.connect({ host, path: httpPath, token });
|
|
2463
2420
|
let session;
|
|
@@ -2498,7 +2455,7 @@ var databricksConnector = new ConnectorPlugin({
|
|
|
2498
2455
|
name: "Databricks",
|
|
2499
2456
|
description: "Connect to Databricks for data lakehouse and SQL analytics.",
|
|
2500
2457
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/6QgcrfpQOKg18P7DdgKerd/af55bf0d871339049824dd167b97a29f/databricks-icon.svg",
|
|
2501
|
-
parameters:
|
|
2458
|
+
parameters: parameters10,
|
|
2502
2459
|
releaseFlag: { dev1: true, dev2: true, prod: true },
|
|
2503
2460
|
systemPrompt: `## Databricks SQL Notes
|
|
2504
2461
|
- Uses Spark SQL / Databricks SQL syntax
|
|
@@ -2513,9 +2470,9 @@ var databricksConnector = new ConnectorPlugin({
|
|
|
2513
2470
|
const { DBSQLClient } = await import("@databricks/sql");
|
|
2514
2471
|
const client = new DBSQLClient();
|
|
2515
2472
|
await client.connect({
|
|
2516
|
-
host: params[
|
|
2517
|
-
path: params[
|
|
2518
|
-
token: params[
|
|
2473
|
+
host: params[parameters10.host.slug],
|
|
2474
|
+
path: params[parameters10.httpPath.slug],
|
|
2475
|
+
token: params[parameters10.token.slug]
|
|
2519
2476
|
});
|
|
2520
2477
|
let session;
|
|
2521
2478
|
let operation;
|
|
@@ -2542,9 +2499,9 @@ var databricksConnector = new ConnectorPlugin({
|
|
|
2542
2499
|
const resolvedSql = replaceLiteralParams(sql, namedParams);
|
|
2543
2500
|
const client = new DBSQLClient();
|
|
2544
2501
|
await client.connect({
|
|
2545
|
-
host: params[
|
|
2546
|
-
path: params[
|
|
2547
|
-
token: params[
|
|
2502
|
+
host: params[parameters10.host.slug],
|
|
2503
|
+
path: params[parameters10.httpPath.slug],
|
|
2504
|
+
token: params[parameters10.token.slug]
|
|
2548
2505
|
});
|
|
2549
2506
|
let session;
|
|
2550
2507
|
let operation;
|
|
@@ -2567,7 +2524,7 @@ var databricksConnector = new ConnectorPlugin({
|
|
|
2567
2524
|
});
|
|
2568
2525
|
|
|
2569
2526
|
// src/connectors/airtable/parameters.ts
|
|
2570
|
-
var
|
|
2527
|
+
var parameters11 = {
|
|
2571
2528
|
baseId: new ParameterDefinition({
|
|
2572
2529
|
slug: "base-id",
|
|
2573
2530
|
name: "Airtable Base ID",
|
|
@@ -2624,8 +2581,8 @@ Authentication is handled automatically using the API Key.
|
|
|
2624
2581
|
}
|
|
2625
2582
|
console.log(`[connector-request] airtable/${connection.name}: ${method} ${path}`);
|
|
2626
2583
|
try {
|
|
2627
|
-
const apiKey =
|
|
2628
|
-
const baseId =
|
|
2584
|
+
const apiKey = parameters11.apiKey.getValue(connection);
|
|
2585
|
+
const baseId = parameters11.baseId.getValue(connection);
|
|
2629
2586
|
const resolvedPath = path.replace(/\{baseId\}/g, baseId);
|
|
2630
2587
|
const url = `${BASE_URL}${resolvedPath}`;
|
|
2631
2588
|
const controller = new AbortController();
|
|
@@ -2667,7 +2624,7 @@ var airtableConnector = new ConnectorPlugin({
|
|
|
2667
2624
|
name: "Airtable",
|
|
2668
2625
|
description: "Connect to Airtable for spreadsheet-database hybrid data management.",
|
|
2669
2626
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/19JUphfOZjyjTK6Zg4NGCf/8c56227b088cada52d3a2d9385a3be97/airtable.svg",
|
|
2670
|
-
parameters:
|
|
2627
|
+
parameters: parameters11,
|
|
2671
2628
|
releaseFlag: { dev1: true, dev2: true, prod: true },
|
|
2672
2629
|
systemPrompt: `## Airtable API
|
|
2673
2630
|
- Call the Airtable REST API using the authenticated request tool
|
|
@@ -2691,7 +2648,7 @@ var airtableConnector = new ConnectorPlugin({
|
|
|
2691
2648
|
});
|
|
2692
2649
|
|
|
2693
2650
|
// src/connectors/google-analytics/parameters.ts
|
|
2694
|
-
var
|
|
2651
|
+
var parameters12 = {
|
|
2695
2652
|
serviceAccountKeyJsonBase64: new ParameterDefinition({
|
|
2696
2653
|
slug: "service-account-key-json-base64",
|
|
2697
2654
|
name: "Google Cloud Service Account JSON",
|
|
@@ -2749,8 +2706,8 @@ Authentication is handled automatically using a service account.
|
|
|
2749
2706
|
console.log(`[connector-request] google-analytics/${connection.name}: ${method} ${path}`);
|
|
2750
2707
|
try {
|
|
2751
2708
|
const { GoogleAuth } = await import("google-auth-library");
|
|
2752
|
-
const keyJsonBase64 =
|
|
2753
|
-
const propertyId =
|
|
2709
|
+
const keyJsonBase64 = parameters12.serviceAccountKeyJsonBase64.getValue(connection);
|
|
2710
|
+
const propertyId = parameters12.propertyId.getValue(connection);
|
|
2754
2711
|
const credentials = JSON.parse(
|
|
2755
2712
|
Buffer.from(keyJsonBase64, "base64").toString("utf-8")
|
|
2756
2713
|
);
|
|
@@ -2803,7 +2760,7 @@ var googleAnalyticsConnector = new ConnectorPlugin({
|
|
|
2803
2760
|
name: "Google Analytics",
|
|
2804
2761
|
description: "Connect to Google Analytics for web analytics and reporting.",
|
|
2805
2762
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/7fs0ipzxuD9mACDzBATtxX/3c53ed90d15c96483e4f78cb29dab5e9/google-analytics.svg",
|
|
2806
|
-
parameters:
|
|
2763
|
+
parameters: parameters12,
|
|
2807
2764
|
releaseFlag: { dev1: true, dev2: true, prod: true },
|
|
2808
2765
|
systemPrompt: `## Google Analytics Data API
|
|
2809
2766
|
- Call the GA4 Data API using the authenticated request tool
|
|
@@ -2836,37 +2793,6 @@ averageSessionDuration, conversions, totalRevenue
|
|
|
2836
2793
|
tools: tools11
|
|
2837
2794
|
});
|
|
2838
2795
|
|
|
2839
|
-
// src/connectors/kintone/parameters.ts
|
|
2840
|
-
var parameters12 = {
|
|
2841
|
-
baseUrl: new ParameterDefinition({
|
|
2842
|
-
slug: "base-url",
|
|
2843
|
-
name: "kintone Base URL",
|
|
2844
|
-
description: "The base URL of your kintone environment (e.g., https://example.cybozu.com).",
|
|
2845
|
-
envVarBaseKey: "KINTONE_BASE_URL",
|
|
2846
|
-
type: "text",
|
|
2847
|
-
secret: false,
|
|
2848
|
-
required: true
|
|
2849
|
-
}),
|
|
2850
|
-
username: new ParameterDefinition({
|
|
2851
|
-
slug: "username",
|
|
2852
|
-
name: "kintone Username",
|
|
2853
|
-
description: "The username (login name) for kintone authentication.",
|
|
2854
|
-
envVarBaseKey: "KINTONE_USERNAME",
|
|
2855
|
-
type: "text",
|
|
2856
|
-
secret: false,
|
|
2857
|
-
required: true
|
|
2858
|
-
}),
|
|
2859
|
-
password: new ParameterDefinition({
|
|
2860
|
-
slug: "password",
|
|
2861
|
-
name: "kintone Password",
|
|
2862
|
-
description: "The password for kintone authentication.",
|
|
2863
|
-
envVarBaseKey: "KINTONE_PASSWORD",
|
|
2864
|
-
type: "text",
|
|
2865
|
-
secret: true,
|
|
2866
|
-
required: true
|
|
2867
|
-
})
|
|
2868
|
-
};
|
|
2869
|
-
|
|
2870
2796
|
// src/connectors/kintone/tools/request.ts
|
|
2871
2797
|
import { z as z14 } from "zod";
|
|
2872
2798
|
var REQUEST_TIMEOUT_MS5 = 6e4;
|
|
@@ -2901,9 +2827,9 @@ Authentication is handled automatically using username and password.`,
|
|
|
2901
2827
|
}
|
|
2902
2828
|
console.log(`[connector-request] kintone/${connection.name}: ${method} ${path}`);
|
|
2903
2829
|
try {
|
|
2904
|
-
const baseUrl =
|
|
2905
|
-
const username =
|
|
2906
|
-
const password =
|
|
2830
|
+
const baseUrl = parameters.baseUrl.getValue(connection);
|
|
2831
|
+
const username = parameters.username.getValue(connection);
|
|
2832
|
+
const password = parameters.password.getValue(connection);
|
|
2907
2833
|
const authToken = Buffer.from(`${username}:${password}`).toString("base64");
|
|
2908
2834
|
const url = `${baseUrl.replace(/\/+$/, "")}/k/v1/${path}`;
|
|
2909
2835
|
const controller = new AbortController();
|
|
@@ -2944,7 +2870,7 @@ var kintoneConnector = new ConnectorPlugin({
|
|
|
2944
2870
|
name: "kintone",
|
|
2945
2871
|
description: "Connect to kintone for business application data retrieval and analytics.",
|
|
2946
2872
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/76nPGMJFZkMFE3UQNo2JFy/e71dc5f5d5cec1306ce0e17aafbfd9f0/kintone.png",
|
|
2947
|
-
parameters
|
|
2873
|
+
parameters,
|
|
2948
2874
|
releaseFlag: { dev1: true, dev2: true, prod: true },
|
|
2949
2875
|
systemPrompt: `## kintone REST API
|
|
2950
2876
|
- Call the kintone REST API using the authenticated request tool
|
|
@@ -2969,7 +2895,34 @@ var kintoneConnector = new ConnectorPlugin({
|
|
|
2969
2895
|
- Operators: and, or, not
|
|
2970
2896
|
- Sort: order by fieldName asc/desc
|
|
2971
2897
|
- Limit: limit 100 offset 0
|
|
2972
|
-
- String: like "partial match"
|
|
2898
|
+
- String: like "partial match"
|
|
2899
|
+
|
|
2900
|
+
## kintone SDK (TypeScript handler)
|
|
2901
|
+
Non-SQL connectors like kintone can also be used via the SDK in TypeScript handlers:
|
|
2902
|
+
|
|
2903
|
+
\`\`\`ts
|
|
2904
|
+
import { connection } from "@squadbase/vite-server/connectors/kintone";
|
|
2905
|
+
|
|
2906
|
+
const kintone = connection("<connectionId>");
|
|
2907
|
+
|
|
2908
|
+
// Authenticated fetch (returns standard Response)
|
|
2909
|
+
const res = await kintone.request("/k/v1/records.json?app=1&query=limit 10");
|
|
2910
|
+
const data = await res.json();
|
|
2911
|
+
|
|
2912
|
+
await kintone.request("/k/v1/record.json", {
|
|
2913
|
+
method: "POST",
|
|
2914
|
+
body: JSON.stringify({ app: 1, record: { title: { value: "Hello" } } }),
|
|
2915
|
+
});
|
|
2916
|
+
|
|
2917
|
+
// Convenience methods (uses @kintone/rest-api-client)
|
|
2918
|
+
const { records, totalCount } = await kintone.getRecords(1, {
|
|
2919
|
+
query: 'status = "Active"',
|
|
2920
|
+
fields: ["name", "email"],
|
|
2921
|
+
totalCount: true,
|
|
2922
|
+
});
|
|
2923
|
+
const { record } = await kintone.getRecord(1, 100);
|
|
2924
|
+
const { apps } = await kintone.listApps();
|
|
2925
|
+
\`\`\``,
|
|
2973
2926
|
tools: tools12
|
|
2974
2927
|
});
|
|
2975
2928
|
|
package/dist/sdk.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
interface KintoneConnectorSdk {
|
|
2
|
+
/**
|
|
3
|
+
* Send an authenticated request to the kintone REST API.
|
|
4
|
+
* Interface matches `fetch` — only auth headers and base URL are added automatically.
|
|
5
|
+
*
|
|
6
|
+
* @param path - API path (e.g., "/k/v1/records.json?app=1")
|
|
7
|
+
* @param init - Standard RequestInit (same as fetch)
|
|
8
|
+
* @returns Standard Response (same as fetch)
|
|
9
|
+
*/
|
|
10
|
+
request(path: string, init?: RequestInit): Promise<Response>;
|
|
11
|
+
getRecords(appId: string | number, options?: {
|
|
12
|
+
query?: string;
|
|
13
|
+
fields?: string[];
|
|
14
|
+
totalCount?: boolean;
|
|
15
|
+
}): Promise<{
|
|
16
|
+
records: Record<string, unknown>[];
|
|
17
|
+
totalCount: number | null;
|
|
18
|
+
}>;
|
|
19
|
+
getRecord(appId: string | number, recordId: string | number): Promise<{
|
|
20
|
+
record: Record<string, unknown>;
|
|
21
|
+
}>;
|
|
22
|
+
listApps(options?: {
|
|
23
|
+
ids?: (string | number)[];
|
|
24
|
+
name?: string;
|
|
25
|
+
limit?: number;
|
|
26
|
+
offset?: number;
|
|
27
|
+
}): Promise<{
|
|
28
|
+
apps: Record<string, unknown>[];
|
|
29
|
+
}>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Create a kintone client from resolved connection parameters.
|
|
33
|
+
*
|
|
34
|
+
* @param params - Resolved parameter values keyed by parameter slug
|
|
35
|
+
* ("base-url", "username", "password")
|
|
36
|
+
*/
|
|
37
|
+
declare function createClient(params: Record<string, string>): KintoneConnectorSdk;
|
|
38
|
+
|
|
39
|
+
export { type KintoneConnectorSdk, createClient as kintone };
|
package/dist/sdk.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import {
|
|
2
|
+
parameters
|
|
3
|
+
} from "./chunk-5YEHPSNW.js";
|
|
4
|
+
|
|
5
|
+
// src/connectors/kintone/sdk/index.ts
|
|
6
|
+
function createClient(params) {
|
|
7
|
+
const baseUrl = params[parameters.baseUrl.slug];
|
|
8
|
+
const username = params[parameters.username.slug];
|
|
9
|
+
const password = params[parameters.password.slug];
|
|
10
|
+
if (!baseUrl || !username || !password) {
|
|
11
|
+
const required = [
|
|
12
|
+
parameters.baseUrl.slug,
|
|
13
|
+
parameters.username.slug,
|
|
14
|
+
parameters.password.slug
|
|
15
|
+
];
|
|
16
|
+
const missing = required.filter((s) => !params[s]);
|
|
17
|
+
throw new Error(
|
|
18
|
+
`kintone: missing required parameters: ${missing.join(", ")}`
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
const authToken = Buffer.from(`${username}:${password}`).toString("base64");
|
|
22
|
+
let _restClient = null;
|
|
23
|
+
async function getRestClient() {
|
|
24
|
+
if (!_restClient) {
|
|
25
|
+
const { KintoneRestAPIClient } = await import("@kintone/rest-api-client");
|
|
26
|
+
_restClient = new KintoneRestAPIClient({
|
|
27
|
+
baseUrl,
|
|
28
|
+
auth: { username, password }
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return _restClient;
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
request(path, init) {
|
|
35
|
+
const url = `${baseUrl.replace(/\/+$/, "")}${path}`;
|
|
36
|
+
const headers = new Headers(init?.headers);
|
|
37
|
+
headers.set("X-Cybozu-Authorization", authToken);
|
|
38
|
+
if (!headers.has("Content-Type")) {
|
|
39
|
+
headers.set("Content-Type", "application/json");
|
|
40
|
+
}
|
|
41
|
+
return fetch(url, { ...init, headers });
|
|
42
|
+
},
|
|
43
|
+
async getRecords(appId, options) {
|
|
44
|
+
const client = await getRestClient();
|
|
45
|
+
const result = await client.record.getRecords({
|
|
46
|
+
app: appId,
|
|
47
|
+
query: options?.query,
|
|
48
|
+
fields: options?.fields,
|
|
49
|
+
totalCount: options?.totalCount
|
|
50
|
+
});
|
|
51
|
+
return {
|
|
52
|
+
records: result.records,
|
|
53
|
+
totalCount: result.totalCount ? Number(result.totalCount) : null
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
async getRecord(appId, recordId) {
|
|
57
|
+
const client = await getRestClient();
|
|
58
|
+
const result = await client.record.getRecord({
|
|
59
|
+
app: appId,
|
|
60
|
+
id: recordId
|
|
61
|
+
});
|
|
62
|
+
return { record: result.record };
|
|
63
|
+
},
|
|
64
|
+
async listApps(options) {
|
|
65
|
+
const client = await getRestClient();
|
|
66
|
+
const result = await client.app.getApps({
|
|
67
|
+
ids: options?.ids,
|
|
68
|
+
name: options?.name,
|
|
69
|
+
limit: options?.limit,
|
|
70
|
+
offset: options?.offset
|
|
71
|
+
});
|
|
72
|
+
return { apps: result.apps };
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export {
|
|
77
|
+
createClient as kintone
|
|
78
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@squadbase/connectors",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "Squadbase Connectors",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
".": {
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
11
|
"default": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./sdk": {
|
|
14
|
+
"types": "./dist/sdk.d.ts",
|
|
15
|
+
"default": "./dist/sdk.js"
|
|
12
16
|
}
|
|
13
17
|
},
|
|
14
18
|
"files": [
|