@squadbase/connectors 0.1.2-dev.0 → 0.1.2-dev.1

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/sdk.js CHANGED
@@ -8,18 +8,18 @@ import {
8
8
  parameters7,
9
9
  parameters8,
10
10
  parameters9
11
- } from "./chunk-Q5TIPE53.js";
11
+ } from "./chunk-LB7J6VXK.js";
12
12
 
13
13
  // src/connectors/kintone/sdk/index.ts
14
14
  function createClient(params) {
15
- const baseUrl = params[parameters3.baseUrl.slug];
16
- const username = params[parameters3.username.slug];
17
- const password = params[parameters3.password.slug];
15
+ const baseUrl = params[parameters6.baseUrl.slug];
16
+ const username = params[parameters6.username.slug];
17
+ const password = params[parameters6.password.slug];
18
18
  if (!baseUrl || !username || !password) {
19
19
  const required = [
20
- parameters3.baseUrl.slug,
21
- parameters3.username.slug,
22
- parameters3.password.slug
20
+ parameters6.baseUrl.slug,
21
+ parameters6.username.slug,
22
+ parameters6.password.slug
23
23
  ];
24
24
  const missing = required.filter((s) => !params[s]);
25
25
  throw new Error(
@@ -81,10 +81,10 @@ function createClient(params) {
81
81
 
82
82
  // src/connectors/openai/sdk/index.ts
83
83
  function createClient2(params) {
84
- const apiKey = params[parameters6.apiKey.slug];
84
+ const apiKey = params[parameters9.apiKey.slug];
85
85
  if (!apiKey) {
86
86
  throw new Error(
87
- `openai: missing required parameter: ${parameters6.apiKey.slug}`
87
+ `openai: missing required parameter: ${parameters9.apiKey.slug}`
88
88
  );
89
89
  }
90
90
  return { apiKey };
@@ -223,10 +223,84 @@ function createClient3(params) {
223
223
  };
224
224
  }
225
225
 
226
+ // src/connectors/google-ads-oauth/sdk/index.ts
227
+ var BASE_URL2 = "https://googleads.googleapis.com/v18/";
228
+ function createClient4(params, fetchFn = fetch) {
229
+ const rawCustomerId = params[parameters2.customerId.slug];
230
+ const defaultCustomerId = rawCustomerId?.replace(/-/g, "") ?? "";
231
+ const developerToken = params[parameters2.developerToken.slug];
232
+ if (!developerToken) {
233
+ throw new Error(
234
+ `google-ads: missing required parameter: ${parameters2.developerToken.slug}`
235
+ );
236
+ }
237
+ function resolveCustomerId(override) {
238
+ const id = override?.replace(/-/g, "") ?? defaultCustomerId;
239
+ if (!id) {
240
+ throw new Error(
241
+ "google-ads: customerId is required. Either configure a default or pass it explicitly."
242
+ );
243
+ }
244
+ return id;
245
+ }
246
+ function request(path, init) {
247
+ const resolvedPath = defaultCustomerId ? path.replace(/\{customerId\}/g, defaultCustomerId) : path;
248
+ const url = `${BASE_URL2}${resolvedPath}`;
249
+ const headers = new Headers(init?.headers);
250
+ headers.set("developer-token", developerToken);
251
+ if (defaultCustomerId) {
252
+ headers.set("login-customer-id", defaultCustomerId);
253
+ }
254
+ return fetchFn(url, { ...init, headers });
255
+ }
256
+ async function search(query, customerId) {
257
+ const cid = resolveCustomerId(customerId);
258
+ const url = `${BASE_URL2}customers/${cid}/googleAds:searchStream`;
259
+ const headers = new Headers();
260
+ headers.set("Content-Type", "application/json");
261
+ headers.set("developer-token", developerToken);
262
+ headers.set("login-customer-id", cid);
263
+ const response = await fetchFn(url, {
264
+ method: "POST",
265
+ headers,
266
+ body: JSON.stringify({ query })
267
+ });
268
+ if (!response.ok) {
269
+ const body = await response.text();
270
+ throw new Error(
271
+ `google-ads: search failed (${response.status}): ${body}`
272
+ );
273
+ }
274
+ const data = await response.json();
275
+ return data.flatMap((chunk) => chunk.results ?? []);
276
+ }
277
+ async function listAccessibleCustomers() {
278
+ const url = `${BASE_URL2}customers:listAccessibleCustomers`;
279
+ const headers = new Headers();
280
+ headers.set("developer-token", developerToken);
281
+ const response = await fetchFn(url, { method: "GET", headers });
282
+ if (!response.ok) {
283
+ const body = await response.text();
284
+ throw new Error(
285
+ `google-ads: listAccessibleCustomers failed (${response.status}): ${body}`
286
+ );
287
+ }
288
+ const data = await response.json();
289
+ return (data.resourceNames ?? []).map(
290
+ (rn) => rn.replace(/^customers\//, "")
291
+ );
292
+ }
293
+ return {
294
+ request,
295
+ search,
296
+ listAccessibleCustomers
297
+ };
298
+ }
299
+
226
300
  // src/connectors/google-analytics/sdk/index.ts
227
301
  import * as crypto from "crypto";
228
302
  var TOKEN_URL = "https://oauth2.googleapis.com/token";
229
- var BASE_URL2 = "https://analyticsdata.googleapis.com/v1beta/";
303
+ var BASE_URL3 = "https://analyticsdata.googleapis.com/v1beta/";
230
304
  var SCOPE = "https://www.googleapis.com/auth/analytics.readonly";
231
305
  function base64url(input) {
232
306
  const buf = typeof input === "string" ? Buffer.from(input) : input;
@@ -250,13 +324,13 @@ function buildJwt(clientEmail, privateKey, nowSec) {
250
324
  const signature = base64url(sign.sign(privateKey));
251
325
  return `${signingInput}.${signature}`;
252
326
  }
253
- function createClient4(params) {
254
- const serviceAccountKeyJsonBase64 = params[parameters2.serviceAccountKeyJsonBase64.slug];
255
- const propertyId = params[parameters2.propertyId.slug];
327
+ function createClient5(params) {
328
+ const serviceAccountKeyJsonBase64 = params[parameters3.serviceAccountKeyJsonBase64.slug];
329
+ const propertyId = params[parameters3.propertyId.slug];
256
330
  if (!serviceAccountKeyJsonBase64 || !propertyId) {
257
331
  const required = [
258
- parameters2.serviceAccountKeyJsonBase64.slug,
259
- parameters2.propertyId.slug
332
+ parameters3.serviceAccountKeyJsonBase64.slug,
333
+ parameters3.propertyId.slug
260
334
  ];
261
335
  const missing = required.filter((s) => !params[s]);
262
336
  throw new Error(
@@ -315,7 +389,7 @@ function createClient4(params) {
315
389
  async request(path, init) {
316
390
  const accessToken = await getAccessToken();
317
391
  const resolvedPath = path.replace(/\{propertyId\}/g, propertyId);
318
- const url = `${BASE_URL2.replace(/\/+$/, "")}/${resolvedPath.replace(/^\/+/, "")}`;
392
+ const url = `${BASE_URL3.replace(/\/+$/, "")}/${resolvedPath.replace(/^\/+/, "")}`;
319
393
  const headers = new Headers(init?.headers);
320
394
  headers.set("Authorization", `Bearer ${accessToken}`);
321
395
  return fetch(url, { ...init, headers });
@@ -378,16 +452,162 @@ function createClient4(params) {
378
452
  };
379
453
  }
380
454
 
455
+ // src/connectors/google-analytics-oauth/sdk/index.ts
456
+ var BASE_URL4 = "https://analyticsdata.googleapis.com/v1beta/";
457
+ function createClient6(params, fetchFn = fetch) {
458
+ const propertyId = params[parameters4.propertyId.slug];
459
+ function resolvePropertyId() {
460
+ if (!propertyId) {
461
+ throw new Error(
462
+ "google-analytics-oauth: propertyId is required. Configure it via connection parameters."
463
+ );
464
+ }
465
+ return propertyId;
466
+ }
467
+ return {
468
+ async request(path, init) {
469
+ const pid = propertyId;
470
+ const resolvedPath = pid ? path.replace(/\{propertyId\}/g, pid) : path;
471
+ const url = `${BASE_URL4.replace(/\/+$/, "")}/${resolvedPath.replace(/^\/+/, "")}`;
472
+ return fetchFn(url, init);
473
+ },
474
+ async runReport(request) {
475
+ const pid = resolvePropertyId();
476
+ const response = await this.request(
477
+ `properties/${pid}:runReport`,
478
+ {
479
+ method: "POST",
480
+ headers: { "Content-Type": "application/json" },
481
+ body: JSON.stringify(request)
482
+ }
483
+ );
484
+ if (!response.ok) {
485
+ const text = await response.text();
486
+ throw new Error(
487
+ `google-analytics-oauth: runReport failed (${response.status}): ${text}`
488
+ );
489
+ }
490
+ const data = await response.json();
491
+ return {
492
+ rows: data.rows ?? [],
493
+ rowCount: data.rowCount ?? 0
494
+ };
495
+ },
496
+ async getMetadata() {
497
+ const pid = resolvePropertyId();
498
+ const response = await this.request(
499
+ `properties/${pid}/metadata`,
500
+ { method: "GET" }
501
+ );
502
+ if (!response.ok) {
503
+ const text = await response.text();
504
+ throw new Error(
505
+ `google-analytics-oauth: getMetadata failed (${response.status}): ${text}`
506
+ );
507
+ }
508
+ return await response.json();
509
+ },
510
+ async runRealtimeReport(request) {
511
+ const pid = resolvePropertyId();
512
+ const response = await this.request(
513
+ `properties/${pid}:runRealtimeReport`,
514
+ {
515
+ method: "POST",
516
+ headers: { "Content-Type": "application/json" },
517
+ body: JSON.stringify(request)
518
+ }
519
+ );
520
+ if (!response.ok) {
521
+ const text = await response.text();
522
+ throw new Error(
523
+ `google-analytics-oauth: runRealtimeReport failed (${response.status}): ${text}`
524
+ );
525
+ }
526
+ const data = await response.json();
527
+ return {
528
+ rows: data.rows ?? [],
529
+ rowCount: data.rowCount ?? 0
530
+ };
531
+ }
532
+ };
533
+ }
534
+
535
+ // src/connectors/google-sheets-oauth/sdk/index.ts
536
+ var BASE_URL5 = "https://sheets.googleapis.com/v4/spreadsheets";
537
+ function createClient7(params, fetchFn = fetch) {
538
+ const defaultSpreadsheetId = params[parameters5.spreadsheetId.slug];
539
+ function resolveSpreadsheetId(override) {
540
+ const id = override ?? defaultSpreadsheetId;
541
+ if (!id) {
542
+ throw new Error(
543
+ "google-sheets: spreadsheetId is required. Either configure a default or pass it explicitly."
544
+ );
545
+ }
546
+ return id;
547
+ }
548
+ function request(path, init) {
549
+ const resolvedPath = defaultSpreadsheetId ? path.replace(/\{spreadsheetId\}/g, defaultSpreadsheetId) : path;
550
+ const url = `${BASE_URL5}${resolvedPath.startsWith("/") ? "" : "/"}${resolvedPath}`;
551
+ return fetchFn(url, init);
552
+ }
553
+ async function getSpreadsheet(spreadsheetId) {
554
+ const id = resolveSpreadsheetId(spreadsheetId);
555
+ const url = `${BASE_URL5}/${id}?fields=spreadsheetId,properties,sheets.properties`;
556
+ const response = await fetchFn(url);
557
+ if (!response.ok) {
558
+ const body = await response.text();
559
+ throw new Error(
560
+ `google-sheets: getSpreadsheet failed (${response.status}): ${body}`
561
+ );
562
+ }
563
+ return await response.json();
564
+ }
565
+ async function getValues(range, spreadsheetId) {
566
+ const id = resolveSpreadsheetId(spreadsheetId);
567
+ const url = `${BASE_URL5}/${id}/values/${encodeURIComponent(range)}`;
568
+ const response = await fetchFn(url);
569
+ if (!response.ok) {
570
+ const body = await response.text();
571
+ throw new Error(
572
+ `google-sheets: getValues failed (${response.status}): ${body}`
573
+ );
574
+ }
575
+ return await response.json();
576
+ }
577
+ async function batchGetValues(ranges, spreadsheetId) {
578
+ const id = resolveSpreadsheetId(spreadsheetId);
579
+ const searchParams = new URLSearchParams();
580
+ for (const range of ranges) {
581
+ searchParams.append("ranges", range);
582
+ }
583
+ const url = `${BASE_URL5}/${id}/values:batchGet?${searchParams.toString()}`;
584
+ const response = await fetchFn(url);
585
+ if (!response.ok) {
586
+ const body = await response.text();
587
+ throw new Error(
588
+ `google-sheets: batchGetValues failed (${response.status}): ${body}`
589
+ );
590
+ }
591
+ return await response.json();
592
+ }
593
+ return {
594
+ request,
595
+ getSpreadsheet,
596
+ getValues,
597
+ batchGetValues
598
+ };
599
+ }
600
+
381
601
  // src/connectors/wix-store/sdk/index.ts
382
- function createClient5(params) {
383
- const accountId = params[parameters4.accountId.slug];
384
- const siteId = params[parameters4.siteId.slug];
385
- const apiKey = params[parameters4.apiKey.slug];
602
+ function createClient8(params) {
603
+ const accountId = params[parameters7.accountId.slug];
604
+ const siteId = params[parameters7.siteId.slug];
605
+ const apiKey = params[parameters7.apiKey.slug];
386
606
  if (!accountId || !siteId || !apiKey) {
387
607
  const required = [
388
- parameters4.accountId.slug,
389
- parameters4.siteId.slug,
390
- parameters4.apiKey.slug
608
+ parameters7.accountId.slug,
609
+ parameters7.siteId.slug,
610
+ parameters7.apiKey.slug
391
611
  ];
392
612
  const missing = required.filter((s) => !params[s]);
393
613
  throw new Error(
@@ -505,15 +725,15 @@ function createClient5(params) {
505
725
  }
506
726
 
507
727
  // src/connectors/dbt/sdk/index.ts
508
- function createClient6(params) {
509
- const host = params[parameters5.host.slug];
510
- const prodEnvId = params[parameters5.prodEnvId.slug];
511
- const token = params[parameters5.token.slug];
728
+ function createClient9(params) {
729
+ const host = params[parameters8.host.slug];
730
+ const prodEnvId = params[parameters8.prodEnvId.slug];
731
+ const token = params[parameters8.token.slug];
512
732
  if (!host || !prodEnvId || !token) {
513
733
  const required = [
514
- parameters5.host.slug,
515
- parameters5.prodEnvId.slug,
516
- parameters5.token.slug
734
+ parameters8.host.slug,
735
+ parameters8.prodEnvId.slug,
736
+ parameters8.token.slug
517
737
  ];
518
738
  const missing = required.filter((s) => !params[s]);
519
739
  throw new Error(
@@ -738,234 +958,14 @@ function createClient6(params) {
738
958
  }
739
959
  };
740
960
  }
741
-
742
- // src/connectors/google-sheets-oauth/sdk/index.ts
743
- var BASE_URL3 = "https://sheets.googleapis.com/v4/spreadsheets";
744
- function createClient7(params, fetchFn = fetch) {
745
- const defaultSpreadsheetId = params[parameters7.spreadsheetId.slug];
746
- function resolveSpreadsheetId(override) {
747
- const id = override ?? defaultSpreadsheetId;
748
- if (!id) {
749
- throw new Error(
750
- "google-sheets: spreadsheetId is required. Either configure a default or pass it explicitly."
751
- );
752
- }
753
- return id;
754
- }
755
- function request(path, init) {
756
- const resolvedPath = defaultSpreadsheetId ? path.replace(/\{spreadsheetId\}/g, defaultSpreadsheetId) : path;
757
- const url = `${BASE_URL3}${resolvedPath.startsWith("/") ? "" : "/"}${resolvedPath}`;
758
- return fetchFn(url, init);
759
- }
760
- async function getSpreadsheet(spreadsheetId) {
761
- const id = resolveSpreadsheetId(spreadsheetId);
762
- const url = `${BASE_URL3}/${id}?fields=spreadsheetId,properties,sheets.properties`;
763
- const response = await fetchFn(url);
764
- if (!response.ok) {
765
- const body = await response.text();
766
- throw new Error(
767
- `google-sheets: getSpreadsheet failed (${response.status}): ${body}`
768
- );
769
- }
770
- return await response.json();
771
- }
772
- async function getValues(range, spreadsheetId) {
773
- const id = resolveSpreadsheetId(spreadsheetId);
774
- const url = `${BASE_URL3}/${id}/values/${encodeURIComponent(range)}`;
775
- const response = await fetchFn(url);
776
- if (!response.ok) {
777
- const body = await response.text();
778
- throw new Error(
779
- `google-sheets: getValues failed (${response.status}): ${body}`
780
- );
781
- }
782
- return await response.json();
783
- }
784
- async function batchGetValues(ranges, spreadsheetId) {
785
- const id = resolveSpreadsheetId(spreadsheetId);
786
- const searchParams = new URLSearchParams();
787
- for (const range of ranges) {
788
- searchParams.append("ranges", range);
789
- }
790
- const url = `${BASE_URL3}/${id}/values:batchGet?${searchParams.toString()}`;
791
- const response = await fetchFn(url);
792
- if (!response.ok) {
793
- const body = await response.text();
794
- throw new Error(
795
- `google-sheets: batchGetValues failed (${response.status}): ${body}`
796
- );
797
- }
798
- return await response.json();
799
- }
800
- return {
801
- request,
802
- getSpreadsheet,
803
- getValues,
804
- batchGetValues
805
- };
806
- }
807
-
808
- // src/connectors/google-analytics-oauth/sdk/index.ts
809
- var BASE_URL4 = "https://analyticsdata.googleapis.com/v1beta/";
810
- function createClient8(params, fetchFn = fetch) {
811
- const propertyId = params[parameters8.propertyId.slug];
812
- function resolvePropertyId() {
813
- if (!propertyId) {
814
- throw new Error(
815
- "google-analytics-oauth: propertyId is required. Configure it via connection parameters."
816
- );
817
- }
818
- return propertyId;
819
- }
820
- return {
821
- async request(path, init) {
822
- const pid = propertyId;
823
- const resolvedPath = pid ? path.replace(/\{propertyId\}/g, pid) : path;
824
- const url = `${BASE_URL4.replace(/\/+$/, "")}/${resolvedPath.replace(/^\/+/, "")}`;
825
- return fetchFn(url, init);
826
- },
827
- async runReport(request) {
828
- const pid = resolvePropertyId();
829
- const response = await this.request(
830
- `properties/${pid}:runReport`,
831
- {
832
- method: "POST",
833
- headers: { "Content-Type": "application/json" },
834
- body: JSON.stringify(request)
835
- }
836
- );
837
- if (!response.ok) {
838
- const text = await response.text();
839
- throw new Error(
840
- `google-analytics-oauth: runReport failed (${response.status}): ${text}`
841
- );
842
- }
843
- const data = await response.json();
844
- return {
845
- rows: data.rows ?? [],
846
- rowCount: data.rowCount ?? 0
847
- };
848
- },
849
- async getMetadata() {
850
- const pid = resolvePropertyId();
851
- const response = await this.request(
852
- `properties/${pid}/metadata`,
853
- { method: "GET" }
854
- );
855
- if (!response.ok) {
856
- const text = await response.text();
857
- throw new Error(
858
- `google-analytics-oauth: getMetadata failed (${response.status}): ${text}`
859
- );
860
- }
861
- return await response.json();
862
- },
863
- async runRealtimeReport(request) {
864
- const pid = resolvePropertyId();
865
- const response = await this.request(
866
- `properties/${pid}:runRealtimeReport`,
867
- {
868
- method: "POST",
869
- headers: { "Content-Type": "application/json" },
870
- body: JSON.stringify(request)
871
- }
872
- );
873
- if (!response.ok) {
874
- const text = await response.text();
875
- throw new Error(
876
- `google-analytics-oauth: runRealtimeReport failed (${response.status}): ${text}`
877
- );
878
- }
879
- const data = await response.json();
880
- return {
881
- rows: data.rows ?? [],
882
- rowCount: data.rowCount ?? 0
883
- };
884
- }
885
- };
886
- }
887
-
888
- // src/connectors/google-ads-oauth/sdk/index.ts
889
- var BASE_URL5 = "https://googleads.googleapis.com/v18/";
890
- function createClient9(params, fetchFn = fetch) {
891
- const rawCustomerId = params[parameters9.customerId.slug];
892
- const defaultCustomerId = rawCustomerId?.replace(/-/g, "") ?? "";
893
- const developerToken = params[parameters9.developerToken.slug];
894
- if (!developerToken) {
895
- throw new Error(
896
- `google-ads: missing required parameter: ${parameters9.developerToken.slug}`
897
- );
898
- }
899
- function resolveCustomerId(override) {
900
- const id = override?.replace(/-/g, "") ?? defaultCustomerId;
901
- if (!id) {
902
- throw new Error(
903
- "google-ads: customerId is required. Either configure a default or pass it explicitly."
904
- );
905
- }
906
- return id;
907
- }
908
- function request(path, init) {
909
- const resolvedPath = defaultCustomerId ? path.replace(/\{customerId\}/g, defaultCustomerId) : path;
910
- const url = `${BASE_URL5}${resolvedPath}`;
911
- const headers = new Headers(init?.headers);
912
- headers.set("developer-token", developerToken);
913
- if (defaultCustomerId) {
914
- headers.set("login-customer-id", defaultCustomerId);
915
- }
916
- return fetchFn(url, { ...init, headers });
917
- }
918
- async function search(query, customerId) {
919
- const cid = resolveCustomerId(customerId);
920
- const url = `${BASE_URL5}customers/${cid}/googleAds:searchStream`;
921
- const headers = new Headers();
922
- headers.set("Content-Type", "application/json");
923
- headers.set("developer-token", developerToken);
924
- headers.set("login-customer-id", cid);
925
- const response = await fetchFn(url, {
926
- method: "POST",
927
- headers,
928
- body: JSON.stringify({ query })
929
- });
930
- if (!response.ok) {
931
- const body = await response.text();
932
- throw new Error(
933
- `google-ads: search failed (${response.status}): ${body}`
934
- );
935
- }
936
- const data = await response.json();
937
- return data.flatMap((chunk) => chunk.results ?? []);
938
- }
939
- async function listAccessibleCustomers() {
940
- const url = `${BASE_URL5}customers:listAccessibleCustomers`;
941
- const headers = new Headers();
942
- headers.set("developer-token", developerToken);
943
- const response = await fetchFn(url, { method: "GET", headers });
944
- if (!response.ok) {
945
- const body = await response.text();
946
- throw new Error(
947
- `google-ads: listAccessibleCustomers failed (${response.status}): ${body}`
948
- );
949
- }
950
- const data = await response.json();
951
- return (data.resourceNames ?? []).map(
952
- (rn) => rn.replace(/^customers\//, "")
953
- );
954
- }
955
- return {
956
- request,
957
- search,
958
- listAccessibleCustomers
959
- };
960
- }
961
961
  export {
962
962
  createClient3 as airtable,
963
- createClient6 as dbt,
964
- createClient9 as googleAds,
965
- createClient4 as googleAnalytics,
966
- createClient8 as googleAnalyticsOauth,
963
+ createClient9 as dbt,
964
+ createClient4 as googleAds,
965
+ createClient5 as googleAnalytics,
966
+ createClient6 as googleAnalyticsOauth,
967
967
  createClient7 as googleSheets,
968
968
  createClient as kintone,
969
969
  createClient2 as openai,
970
- createClient5 as wixStore
970
+ createClient8 as wixStore
971
971
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squadbase/connectors",
3
- "version": "0.1.2-dev.0",
3
+ "version": "0.1.2-dev.1",
4
4
  "description": "Squadbase Connectors",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",