@squadbase/connectors 0.0.6 → 0.0.8

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.
@@ -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 parameters = {
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 = parameters.account.getValue(connection);
362
- const user = parameters.user.getValue(connection);
363
- const role = parameters.role.getValue(connection);
364
- const warehouse = parameters.warehouse.getValue(connection);
365
- const privateKeyBase64 = parameters.privateKeyBase64.getValue(connection);
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[parameters.privateKeyBase64.slug],
410
+ params[parameters2.privateKeyBase64.slug],
450
411
  "base64"
451
412
  ).toString("utf-8");
452
413
  const conn = snowflake.createConnection({
453
- account: params[parameters.account.slug],
454
- username: params[parameters.user.slug],
455
- role: params[parameters.role.slug],
456
- warehouse: params[parameters.warehouse.slug],
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[parameters.privateKeyBase64.slug],
449
+ params[parameters2.privateKeyBase64.slug],
489
450
  "base64"
490
451
  ).toString("utf-8");
491
452
  const conn = snowflake.createConnection({
492
- account: params[parameters.account.slug],
493
- username: params[parameters.user.slug],
494
- role: params[parameters.role.slug],
495
- warehouse: params[parameters.warehouse.slug],
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 parameters2 = {
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 = parameters2.account.getValue(connection);
619
- const user = parameters2.user.getValue(connection);
620
- const role = parameters2.role.getValue(connection);
621
- const warehouse = parameters2.warehouse.getValue(connection);
622
- const password = parameters2.pat.getValue(connection);
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: parameters2,
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[parameters2.account.slug],
703
- username: params[parameters2.user.slug],
704
- role: params[parameters2.role.slug],
705
- warehouse: params[parameters2.warehouse.slug],
706
- password: params[parameters2.pat.slug]
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[parameters2.account.slug],
742
- username: params[parameters2.user.slug],
743
- role: params[parameters2.role.slug],
744
- warehouse: params[parameters2.warehouse.slug],
745
- password: params[parameters2.pat.slug]
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 parameters3 = {
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 = parameters3.connectionUrl.getValue(connection);
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: parameters3,
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[parameters3.connectionUrl.slug],
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[parameters3.connectionUrl.slug],
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 parameters4 = {
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 = parameters4.connectionUrl.getValue(connection);
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: parameters4,
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[parameters4.connectionUrl.slug],
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[parameters4.connectionUrl.slug],
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 parameters5 = {
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 = parameters5.serviceAccountKeyJsonBase64.getValue(connection);
1078
+ const serviceAccountJsonBase64 = parameters6.serviceAccountKeyJsonBase64.getValue(connection);
1118
1079
  const credentials = JSON.parse(
1119
1080
  Buffer.from(serviceAccountJsonBase64, "base64").toString("utf-8")
1120
1081
  );
@@ -1262,8 +1223,8 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
1262
1223
  );
1263
1224
  try {
1264
1225
  const { BigQuery } = await import("@google-cloud/bigquery");
1265
- const projectId = parameters5.projectId.getValue(connection);
1266
- const serviceAccountJsonBase64 = parameters5.serviceAccountKeyJsonBase64.getValue(connection);
1226
+ const projectId = parameters6.projectId.getValue(connection);
1227
+ const serviceAccountJsonBase64 = parameters6.serviceAccountKeyJsonBase64.getValue(connection);
1267
1228
  const credentials = JSON.parse(
1268
1229
  Buffer.from(serviceAccountJsonBase64, "base64").toString("utf-8")
1269
1230
  );
@@ -1293,7 +1254,7 @@ var bigqueryConnector = new ConnectorPlugin({
1293
1254
  name: "BigQuery",
1294
1255
  description: "Connect to Google BigQuery for data warehouse and analytics.",
1295
1256
  iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/6nlehQyOmdbktG5hOYkYMr/6ca559140d5ddc7dadc5eac88858a563/bigquery.svg",
1296
- parameters: parameters5,
1257
+ parameters: parameters6,
1297
1258
  releaseFlag: { dev1: true, dev2: true, prod: true },
1298
1259
  setup: bigquerySetup,
1299
1260
  systemPrompt: `## BigQuery SQL Notes
@@ -1307,10 +1268,10 @@ var bigqueryConnector = new ConnectorPlugin({
1307
1268
  async checkConnection(params, _config) {
1308
1269
  const { BigQuery } = await import("@google-cloud/bigquery");
1309
1270
  const credentials = JSON.parse(
1310
- Buffer.from(params[parameters5.serviceAccountKeyJsonBase64.slug], "base64").toString("utf-8")
1271
+ Buffer.from(params[parameters6.serviceAccountKeyJsonBase64.slug], "base64").toString("utf-8")
1311
1272
  );
1312
1273
  const bq = new BigQuery({
1313
- projectId: params[parameters5.projectId.slug],
1274
+ projectId: params[parameters6.projectId.slug],
1314
1275
  credentials
1315
1276
  });
1316
1277
  try {
@@ -1325,10 +1286,10 @@ var bigqueryConnector = new ConnectorPlugin({
1325
1286
  const { BigQuery } = await import("@google-cloud/bigquery");
1326
1287
  const resolvedSql = replaceLiteralParams(sql, namedParams);
1327
1288
  const credentials = JSON.parse(
1328
- Buffer.from(params[parameters5.serviceAccountKeyJsonBase64.slug], "base64").toString("utf-8")
1289
+ Buffer.from(params[parameters6.serviceAccountKeyJsonBase64.slug], "base64").toString("utf-8")
1329
1290
  );
1330
1291
  const bq = new BigQuery({
1331
- projectId: params[parameters5.projectId.slug],
1292
+ projectId: params[parameters6.projectId.slug],
1332
1293
  credentials
1333
1294
  });
1334
1295
  const [job] = await bq.createQueryJob({ query: resolvedSql });
@@ -1524,7 +1485,7 @@ Follow these steps to set up the BigQuery connection.
1524
1485
  });
1525
1486
 
1526
1487
  // src/connectors/bigquery-oauth/parameters.ts
1527
- var parameters6 = {
1488
+ var parameters7 = {
1528
1489
  projectId: new ParameterDefinition({
1529
1490
  slug: "project-id",
1530
1491
  name: "Google Cloud Project ID",
@@ -1618,7 +1579,7 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
1618
1579
  error: `Connection ${connectionId} not found`
1619
1580
  };
1620
1581
  }
1621
- const gcpProjectId = parameters6.projectId.getValue(connection);
1582
+ const gcpProjectId = parameters7.projectId.getValue(connection);
1622
1583
  console.log(
1623
1584
  `[connector-query] bigquery-oauth/${connection.name}: ${sql}`
1624
1585
  );
@@ -1685,7 +1646,7 @@ var bigqueryOauthConnector = new ConnectorPlugin({
1685
1646
  name: "BigQuery (OAuth)",
1686
1647
  description: "Connect to Google BigQuery for data warehouse and analytics using OAuth.",
1687
1648
  iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/6nlehQyOmdbktG5hOYkYMr/6ca559140d5ddc7dadc5eac88858a563/bigquery.svg",
1688
- parameters: parameters6,
1649
+ parameters: parameters7,
1689
1650
  releaseFlag: { dev1: true, dev2: false, prod: false },
1690
1651
  setup: bigquerySetup2,
1691
1652
  proxyPolicy: {
@@ -1704,7 +1665,7 @@ var bigqueryOauthConnector = new ConnectorPlugin({
1704
1665
  tools: tools6,
1705
1666
  async checkConnection(params, config) {
1706
1667
  const { proxyFetch } = config;
1707
- const projectId = params[parameters6.projectId.slug];
1668
+ const projectId = params[parameters7.projectId.slug];
1708
1669
  const url = `https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/queries`;
1709
1670
  try {
1710
1671
  const res = await proxyFetch(url, {
@@ -1723,7 +1684,7 @@ var bigqueryOauthConnector = new ConnectorPlugin({
1723
1684
  },
1724
1685
  async query(params, sql, namedParams, context) {
1725
1686
  const { proxyFetch } = context;
1726
- const projectId = params[parameters6.projectId.slug];
1687
+ const projectId = params[parameters7.projectId.slug];
1727
1688
  const resolvedSql = replaceLiteralParams(sql, namedParams);
1728
1689
  const url = `https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/queries`;
1729
1690
  const res = await proxyFetch(url, {
@@ -1741,7 +1702,7 @@ var bigqueryOauthConnector = new ConnectorPlugin({
1741
1702
  });
1742
1703
 
1743
1704
  // src/connectors/aws-athena/parameters.ts
1744
- var parameters7 = {
1705
+ var parameters8 = {
1745
1706
  awsAccessKeyId: new ParameterDefinition({
1746
1707
  slug: "aws-access-key-id",
1747
1708
  name: "AWS Access Key ID",
@@ -1838,8 +1799,8 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
1838
1799
  GetQueryExecutionCommand,
1839
1800
  GetQueryResultsCommand
1840
1801
  } = await import("@aws-sdk/client-athena");
1841
- const workgroup = parameters7.workgroup.tryGetValue(connection);
1842
- const outputLocation = parameters7.outputLocation.tryGetValue(connection);
1802
+ const workgroup = parameters8.workgroup.tryGetValue(connection);
1803
+ const outputLocation = parameters8.outputLocation.tryGetValue(connection);
1843
1804
  if (!workgroup && !outputLocation) {
1844
1805
  return {
1845
1806
  success: false,
@@ -1847,10 +1808,10 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
1847
1808
  };
1848
1809
  }
1849
1810
  const client = new AthenaClient({
1850
- region: parameters7.awsRegion.getValue(connection),
1811
+ region: parameters8.awsRegion.getValue(connection),
1851
1812
  credentials: {
1852
- accessKeyId: parameters7.awsAccessKeyId.getValue(connection),
1853
- secretAccessKey: parameters7.awsSecretAccessKey.getValue(connection)
1813
+ accessKeyId: parameters8.awsAccessKeyId.getValue(connection),
1814
+ secretAccessKey: parameters8.awsSecretAccessKey.getValue(connection)
1854
1815
  }
1855
1816
  });
1856
1817
  const startParams = { QueryString: sql };
@@ -1914,7 +1875,7 @@ var awsAthenaConnector = new ConnectorPlugin({
1914
1875
  name: "AWS Athena",
1915
1876
  description: "Connect to AWS Athena for serverless SQL queries on S3 data.",
1916
1877
  iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/5x0vIHtUHfJJMZUv4RFOYZ/5059bac389f0169542f39cdb4b387d2c/Athena.svg",
1917
- parameters: parameters7,
1878
+ parameters: parameters8,
1918
1879
  releaseFlag: { dev1: true, dev2: true, prod: true },
1919
1880
  systemPrompt: `## AWS Athena SQL Notes
1920
1881
  - Uses Presto/Trino based SQL syntax
@@ -1932,8 +1893,8 @@ var awsAthenaConnector = new ConnectorPlugin({
1932
1893
  StartQueryExecutionCommand,
1933
1894
  GetQueryExecutionCommand
1934
1895
  } = await import("@aws-sdk/client-athena");
1935
- const workgroup = params[parameters7.workgroup.slug];
1936
- const outputLocation = params[parameters7.outputLocation.slug];
1896
+ const workgroup = params[parameters8.workgroup.slug];
1897
+ const outputLocation = params[parameters8.outputLocation.slug];
1937
1898
  if (!workgroup && !outputLocation) {
1938
1899
  return {
1939
1900
  success: false,
@@ -1941,10 +1902,10 @@ var awsAthenaConnector = new ConnectorPlugin({
1941
1902
  };
1942
1903
  }
1943
1904
  const client = new AthenaClient({
1944
- region: params[parameters7.awsRegion.slug],
1905
+ region: params[parameters8.awsRegion.slug],
1945
1906
  credentials: {
1946
- accessKeyId: params[parameters7.awsAccessKeyId.slug],
1947
- secretAccessKey: params[parameters7.awsSecretAccessKey.slug]
1907
+ accessKeyId: params[parameters8.awsAccessKeyId.slug],
1908
+ secretAccessKey: params[parameters8.awsSecretAccessKey.slug]
1948
1909
  }
1949
1910
  });
1950
1911
  const startParams = { QueryString: "SELECT 1" };
@@ -1989,16 +1950,16 @@ var awsAthenaConnector = new ConnectorPlugin({
1989
1950
  GetQueryResultsCommand
1990
1951
  } = await import("@aws-sdk/client-athena");
1991
1952
  const resolvedSql = replaceLiteralParams(sql, namedParams);
1992
- const workgroup = params[parameters7.workgroup.slug];
1993
- const outputLocation = params[parameters7.outputLocation.slug];
1953
+ const workgroup = params[parameters8.workgroup.slug];
1954
+ const outputLocation = params[parameters8.outputLocation.slug];
1994
1955
  if (!workgroup && !outputLocation) {
1995
1956
  throw new Error("Either workgroup or output-location is required");
1996
1957
  }
1997
1958
  const client = new AthenaClient({
1998
- region: params[parameters7.awsRegion.slug],
1959
+ region: params[parameters8.awsRegion.slug],
1999
1960
  credentials: {
2000
- accessKeyId: params[parameters7.awsAccessKeyId.slug],
2001
- secretAccessKey: params[parameters7.awsSecretAccessKey.slug]
1961
+ accessKeyId: params[parameters8.awsAccessKeyId.slug],
1962
+ secretAccessKey: params[parameters8.awsSecretAccessKey.slug]
2002
1963
  }
2003
1964
  });
2004
1965
  const startParams = { QueryString: resolvedSql };
@@ -2043,7 +2004,7 @@ var awsAthenaConnector = new ConnectorPlugin({
2043
2004
  });
2044
2005
 
2045
2006
  // src/connectors/redshift/parameters.ts
2046
- var parameters8 = {
2007
+ var parameters9 = {
2047
2008
  awsAccessKeyId: new ParameterDefinition({
2048
2009
  slug: "aws-access-key-id",
2049
2010
  name: "AWS Access Key ID",
@@ -2169,14 +2130,14 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
2169
2130
  DescribeStatementCommand,
2170
2131
  GetStatementResultCommand
2171
2132
  } = await import("@aws-sdk/client-redshift-data");
2172
- const awsAccessKeyId = parameters8.awsAccessKeyId.getValue(connection);
2173
- const awsSecretAccessKey = parameters8.awsSecretAccessKey.getValue(connection);
2174
- const awsRegion = parameters8.awsRegion.getValue(connection);
2175
- const database = parameters8.database.getValue(connection);
2176
- const clusterIdentifier = parameters8.clusterIdentifier.tryGetValue(connection);
2177
- const workgroupName = parameters8.workgroupName.tryGetValue(connection);
2178
- const secretArn = parameters8.secretArn.tryGetValue(connection);
2179
- const dbUser = parameters8.dbUser.tryGetValue(connection);
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);
2180
2141
  if (!clusterIdentifier && !workgroupName) {
2181
2142
  return {
2182
2143
  success: false,
@@ -2247,7 +2208,7 @@ var redshiftConnector = new ConnectorPlugin({
2247
2208
  name: "Redshift",
2248
2209
  description: "Connect to Amazon Redshift for data warehouse analytics.",
2249
2210
  iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/AEwW2psmrnZ7htTVsgA9t/a637e31707c5d760be73ce1d8ec75580/aws-redshift-logo.svg",
2250
- parameters: parameters8,
2211
+ parameters: parameters9,
2251
2212
  releaseFlag: { dev1: true, dev2: true, prod: true },
2252
2213
  systemPrompt: `## Redshift SQL Notes
2253
2214
  - Uses PostgreSQL based SQL syntax
@@ -2265,10 +2226,10 @@ var redshiftConnector = new ConnectorPlugin({
2265
2226
  ExecuteStatementCommand,
2266
2227
  DescribeStatementCommand
2267
2228
  } = await import("@aws-sdk/client-redshift-data");
2268
- const clusterIdentifier = params[parameters8.clusterIdentifier.slug];
2269
- const workgroupName = params[parameters8.workgroupName.slug];
2270
- const secretArn = params[parameters8.secretArn.slug];
2271
- const dbUser = params[parameters8.dbUser.slug];
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];
2272
2233
  if (!clusterIdentifier && !workgroupName) {
2273
2234
  return {
2274
2235
  success: false,
@@ -2276,15 +2237,15 @@ var redshiftConnector = new ConnectorPlugin({
2276
2237
  };
2277
2238
  }
2278
2239
  const client = new RedshiftDataClient({
2279
- region: params[parameters8.awsRegion.slug],
2240
+ region: params[parameters9.awsRegion.slug],
2280
2241
  credentials: {
2281
- accessKeyId: params[parameters8.awsAccessKeyId.slug],
2282
- secretAccessKey: params[parameters8.awsSecretAccessKey.slug]
2242
+ accessKeyId: params[parameters9.awsAccessKeyId.slug],
2243
+ secretAccessKey: params[parameters9.awsSecretAccessKey.slug]
2283
2244
  }
2284
2245
  });
2285
2246
  const { Id: statementId } = await client.send(
2286
2247
  new ExecuteStatementCommand({
2287
- Database: params[parameters8.database.slug],
2248
+ Database: params[parameters9.database.slug],
2288
2249
  Sql: "SELECT 1",
2289
2250
  ...clusterIdentifier && { ClusterIdentifier: clusterIdentifier },
2290
2251
  ...workgroupName && { WorkgroupName: workgroupName },
@@ -2325,23 +2286,23 @@ var redshiftConnector = new ConnectorPlugin({
2325
2286
  GetStatementResultCommand
2326
2287
  } = await import("@aws-sdk/client-redshift-data");
2327
2288
  const resolvedSql = replaceLiteralParams(sql, namedParams);
2328
- const clusterIdentifier = params[parameters8.clusterIdentifier.slug];
2329
- const workgroupName = params[parameters8.workgroupName.slug];
2330
- const secretArn = params[parameters8.secretArn.slug];
2331
- const dbUser = params[parameters8.dbUser.slug];
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];
2332
2293
  if (!clusterIdentifier && !workgroupName) {
2333
2294
  throw new Error("Either cluster-identifier or workgroup-name is required");
2334
2295
  }
2335
2296
  const client = new RedshiftDataClient({
2336
- region: params[parameters8.awsRegion.slug],
2297
+ region: params[parameters9.awsRegion.slug],
2337
2298
  credentials: {
2338
- accessKeyId: params[parameters8.awsAccessKeyId.slug],
2339
- secretAccessKey: params[parameters8.awsSecretAccessKey.slug]
2299
+ accessKeyId: params[parameters9.awsAccessKeyId.slug],
2300
+ secretAccessKey: params[parameters9.awsSecretAccessKey.slug]
2340
2301
  }
2341
2302
  });
2342
2303
  const { Id: statementId } = await client.send(
2343
2304
  new ExecuteStatementCommand({
2344
- Database: params[parameters8.database.slug],
2305
+ Database: params[parameters9.database.slug],
2345
2306
  Sql: resolvedSql,
2346
2307
  ...clusterIdentifier && { ClusterIdentifier: clusterIdentifier },
2347
2308
  ...workgroupName && { WorkgroupName: workgroupName },
@@ -2379,7 +2340,7 @@ var redshiftConnector = new ConnectorPlugin({
2379
2340
  });
2380
2341
 
2381
2342
  // src/connectors/databricks/parameters.ts
2382
- var parameters9 = {
2343
+ var parameters10 = {
2383
2344
  host: new ParameterDefinition({
2384
2345
  slug: "host",
2385
2346
  name: "Databricks Workspace Host",
@@ -2451,9 +2412,9 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
2451
2412
  );
2452
2413
  try {
2453
2414
  const { DBSQLClient } = await import("@databricks/sql");
2454
- const host = parameters9.host.getValue(connection);
2455
- const token = parameters9.token.getValue(connection);
2456
- const httpPath = parameters9.httpPath.getValue(connection);
2415
+ const host = parameters10.host.getValue(connection);
2416
+ const token = parameters10.token.getValue(connection);
2417
+ const httpPath = parameters10.httpPath.getValue(connection);
2457
2418
  const client = new DBSQLClient();
2458
2419
  await client.connect({ host, path: httpPath, token });
2459
2420
  let session;
@@ -2494,7 +2455,7 @@ var databricksConnector = new ConnectorPlugin({
2494
2455
  name: "Databricks",
2495
2456
  description: "Connect to Databricks for data lakehouse and SQL analytics.",
2496
2457
  iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/6QgcrfpQOKg18P7DdgKerd/af55bf0d871339049824dd167b97a29f/databricks-icon.svg",
2497
- parameters: parameters9,
2458
+ parameters: parameters10,
2498
2459
  releaseFlag: { dev1: true, dev2: true, prod: true },
2499
2460
  systemPrompt: `## Databricks SQL Notes
2500
2461
  - Uses Spark SQL / Databricks SQL syntax
@@ -2509,9 +2470,9 @@ var databricksConnector = new ConnectorPlugin({
2509
2470
  const { DBSQLClient } = await import("@databricks/sql");
2510
2471
  const client = new DBSQLClient();
2511
2472
  await client.connect({
2512
- host: params[parameters9.host.slug],
2513
- path: params[parameters9.httpPath.slug],
2514
- token: params[parameters9.token.slug]
2473
+ host: params[parameters10.host.slug],
2474
+ path: params[parameters10.httpPath.slug],
2475
+ token: params[parameters10.token.slug]
2515
2476
  });
2516
2477
  let session;
2517
2478
  let operation;
@@ -2538,9 +2499,9 @@ var databricksConnector = new ConnectorPlugin({
2538
2499
  const resolvedSql = replaceLiteralParams(sql, namedParams);
2539
2500
  const client = new DBSQLClient();
2540
2501
  await client.connect({
2541
- host: params[parameters9.host.slug],
2542
- path: params[parameters9.httpPath.slug],
2543
- token: params[parameters9.token.slug]
2502
+ host: params[parameters10.host.slug],
2503
+ path: params[parameters10.httpPath.slug],
2504
+ token: params[parameters10.token.slug]
2544
2505
  });
2545
2506
  let session;
2546
2507
  let operation;
@@ -2563,7 +2524,7 @@ var databricksConnector = new ConnectorPlugin({
2563
2524
  });
2564
2525
 
2565
2526
  // src/connectors/airtable/parameters.ts
2566
- var parameters10 = {
2527
+ var parameters11 = {
2567
2528
  baseId: new ParameterDefinition({
2568
2529
  slug: "base-id",
2569
2530
  name: "Airtable Base ID",
@@ -2620,8 +2581,8 @@ Authentication is handled automatically using the API Key.
2620
2581
  }
2621
2582
  console.log(`[connector-request] airtable/${connection.name}: ${method} ${path}`);
2622
2583
  try {
2623
- const apiKey = parameters10.apiKey.getValue(connection);
2624
- const baseId = parameters10.baseId.getValue(connection);
2584
+ const apiKey = parameters11.apiKey.getValue(connection);
2585
+ const baseId = parameters11.baseId.getValue(connection);
2625
2586
  const resolvedPath = path.replace(/\{baseId\}/g, baseId);
2626
2587
  const url = `${BASE_URL}${resolvedPath}`;
2627
2588
  const controller = new AbortController();
@@ -2663,7 +2624,7 @@ var airtableConnector = new ConnectorPlugin({
2663
2624
  name: "Airtable",
2664
2625
  description: "Connect to Airtable for spreadsheet-database hybrid data management.",
2665
2626
  iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/19JUphfOZjyjTK6Zg4NGCf/8c56227b088cada52d3a2d9385a3be97/airtable.svg",
2666
- parameters: parameters10,
2627
+ parameters: parameters11,
2667
2628
  releaseFlag: { dev1: true, dev2: true, prod: true },
2668
2629
  systemPrompt: `## Airtable API
2669
2630
  - Call the Airtable REST API using the authenticated request tool
@@ -2687,7 +2648,7 @@ var airtableConnector = new ConnectorPlugin({
2687
2648
  });
2688
2649
 
2689
2650
  // src/connectors/google-analytics/parameters.ts
2690
- var parameters11 = {
2651
+ var parameters12 = {
2691
2652
  serviceAccountKeyJsonBase64: new ParameterDefinition({
2692
2653
  slug: "service-account-key-json-base64",
2693
2654
  name: "Google Cloud Service Account JSON",
@@ -2745,8 +2706,8 @@ Authentication is handled automatically using a service account.
2745
2706
  console.log(`[connector-request] google-analytics/${connection.name}: ${method} ${path}`);
2746
2707
  try {
2747
2708
  const { GoogleAuth } = await import("google-auth-library");
2748
- const keyJsonBase64 = parameters11.serviceAccountKeyJsonBase64.getValue(connection);
2749
- const propertyId = parameters11.propertyId.getValue(connection);
2709
+ const keyJsonBase64 = parameters12.serviceAccountKeyJsonBase64.getValue(connection);
2710
+ const propertyId = parameters12.propertyId.getValue(connection);
2750
2711
  const credentials = JSON.parse(
2751
2712
  Buffer.from(keyJsonBase64, "base64").toString("utf-8")
2752
2713
  );
@@ -2799,7 +2760,7 @@ var googleAnalyticsConnector = new ConnectorPlugin({
2799
2760
  name: "Google Analytics",
2800
2761
  description: "Connect to Google Analytics for web analytics and reporting.",
2801
2762
  iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/7fs0ipzxuD9mACDzBATtxX/3c53ed90d15c96483e4f78cb29dab5e9/google-analytics.svg",
2802
- parameters: parameters11,
2763
+ parameters: parameters12,
2803
2764
  releaseFlag: { dev1: true, dev2: true, prod: true },
2804
2765
  systemPrompt: `## Google Analytics Data API
2805
2766
  - Call the GA4 Data API using the authenticated request tool
@@ -2832,37 +2793,6 @@ averageSessionDuration, conversions, totalRevenue
2832
2793
  tools: tools11
2833
2794
  });
2834
2795
 
2835
- // src/connectors/kintone/parameters.ts
2836
- var parameters12 = {
2837
- baseUrl: new ParameterDefinition({
2838
- slug: "base-url",
2839
- name: "kintone Base URL",
2840
- description: "The base URL of your kintone environment (e.g., https://example.cybozu.com).",
2841
- envVarBaseKey: "KINTONE_BASE_URL",
2842
- type: "text",
2843
- secret: false,
2844
- required: true
2845
- }),
2846
- username: new ParameterDefinition({
2847
- slug: "username",
2848
- name: "kintone Username",
2849
- description: "The username (login name) for kintone authentication.",
2850
- envVarBaseKey: "KINTONE_USERNAME",
2851
- type: "text",
2852
- secret: false,
2853
- required: true
2854
- }),
2855
- password: new ParameterDefinition({
2856
- slug: "password",
2857
- name: "kintone Password",
2858
- description: "The password for kintone authentication.",
2859
- envVarBaseKey: "KINTONE_PASSWORD",
2860
- type: "text",
2861
- secret: true,
2862
- required: true
2863
- })
2864
- };
2865
-
2866
2796
  // src/connectors/kintone/tools/request.ts
2867
2797
  import { z as z14 } from "zod";
2868
2798
  var REQUEST_TIMEOUT_MS5 = 6e4;
@@ -2897,9 +2827,9 @@ Authentication is handled automatically using username and password.`,
2897
2827
  }
2898
2828
  console.log(`[connector-request] kintone/${connection.name}: ${method} ${path}`);
2899
2829
  try {
2900
- const baseUrl = parameters12.baseUrl.getValue(connection);
2901
- const username = parameters12.username.getValue(connection);
2902
- const password = parameters12.password.getValue(connection);
2830
+ const baseUrl = parameters.baseUrl.getValue(connection);
2831
+ const username = parameters.username.getValue(connection);
2832
+ const password = parameters.password.getValue(connection);
2903
2833
  const authToken = Buffer.from(`${username}:${password}`).toString("base64");
2904
2834
  const url = `${baseUrl.replace(/\/+$/, "")}/k/v1/${path}`;
2905
2835
  const controller = new AbortController();
@@ -2940,7 +2870,7 @@ var kintoneConnector = new ConnectorPlugin({
2940
2870
  name: "kintone",
2941
2871
  description: "Connect to kintone for business application data retrieval and analytics.",
2942
2872
  iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/76nPGMJFZkMFE3UQNo2JFy/e71dc5f5d5cec1306ce0e17aafbfd9f0/kintone.png",
2943
- parameters: parameters12,
2873
+ parameters,
2944
2874
  releaseFlag: { dev1: true, dev2: true, prod: true },
2945
2875
  systemPrompt: `## kintone REST API
2946
2876
  - Call the kintone REST API using the authenticated request tool
@@ -2965,7 +2895,34 @@ var kintoneConnector = new ConnectorPlugin({
2965
2895
  - Operators: and, or, not
2966
2896
  - Sort: order by fieldName asc/desc
2967
2897
  - Limit: limit 100 offset 0
2968
- - 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
+ \`\`\``,
2969
2926
  tools: tools12
2970
2927
  });
2971
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.6",
3
+ "version": "0.0.8",
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": [