@squadbase/connectors 0.1.1 → 0.1.2-dev.0

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.d.ts CHANGED
@@ -34,7 +34,7 @@ interface KintoneConnectorSdk {
34
34
  * @param params - Resolved parameter values keyed by parameter slug
35
35
  * ("base-url", "username", "password")
36
36
  */
37
- declare function createClient$5(params: Record<string, string>): KintoneConnectorSdk;
37
+ declare function createClient$8(params: Record<string, string>): KintoneConnectorSdk;
38
38
 
39
39
  interface OpenAIConnectorSdk {
40
40
  apiKey: string;
@@ -44,7 +44,7 @@ interface OpenAIConnectorSdk {
44
44
  *
45
45
  * @param params - Resolved parameter values keyed by parameter slug ("api-key")
46
46
  */
47
- declare function createClient$4(params: Record<string, string>): OpenAIConnectorSdk;
47
+ declare function createClient$7(params: Record<string, string>): OpenAIConnectorSdk;
48
48
 
49
49
  /** Shape returned by the Airtable API for a single record. */
50
50
  interface AirtableRecord {
@@ -131,7 +131,7 @@ interface AirtableConnectorSdk {
131
131
  * @param params - Resolved parameter values keyed by parameter slug
132
132
  * ("base-id", "api-key")
133
133
  */
134
- declare function createClient$3(params: Record<string, string>): AirtableConnectorSdk;
134
+ declare function createClient$6(params: Record<string, string>): AirtableConnectorSdk;
135
135
 
136
136
  interface GoogleAnalyticsConnectorSdk {
137
137
  /**
@@ -237,7 +237,7 @@ interface GoogleAnalyticsConnectorSdk {
237
237
  * @param params - Resolved parameter values keyed by parameter slug
238
238
  * ("service-account-key-json-base64", "property-id")
239
239
  */
240
- declare function createClient$2(params: Record<string, string>): GoogleAnalyticsConnectorSdk;
240
+ declare function createClient$5(params: Record<string, string>): GoogleAnalyticsConnectorSdk;
241
241
 
242
242
  interface WixStoreConnectorSdk {
243
243
  /**
@@ -328,7 +328,7 @@ interface WixStoreConnectorSdk {
328
328
  * @param params - Resolved parameter values keyed by parameter slug
329
329
  * ("account-id", "site-id", "api-key")
330
330
  */
331
- declare function createClient$1(params: Record<string, string>): WixStoreConnectorSdk;
331
+ declare function createClient$4(params: Record<string, string>): WixStoreConnectorSdk;
332
332
 
333
333
  interface DbtConnectorSdk {
334
334
  /**
@@ -384,6 +384,217 @@ interface DbtConnectorSdk {
384
384
  * @param params - Resolved parameter values keyed by parameter slug
385
385
  * ("host", "account-id", "prod-env-id", "token")
386
386
  */
387
- declare function createClient(params: Record<string, string>): DbtConnectorSdk;
387
+ declare function createClient$3(params: Record<string, string>): DbtConnectorSdk;
388
388
 
389
- export { type AirtableConnectorSdk, type DbtConnectorSdk, type GoogleAnalyticsConnectorSdk, type KintoneConnectorSdk, type OpenAIConnectorSdk, type WixStoreConnectorSdk, createClient$3 as airtable, createClient as dbt, createClient$2 as googleAnalytics, createClient$5 as kintone, createClient$4 as openai, createClient$1 as wixStore };
389
+ interface SpreadsheetProperties {
390
+ title: string;
391
+ locale?: string;
392
+ timeZone?: string;
393
+ }
394
+ interface SheetProperties {
395
+ sheetId: number;
396
+ title: string;
397
+ index: number;
398
+ sheetType?: string;
399
+ gridProperties?: {
400
+ rowCount: number;
401
+ columnCount: number;
402
+ };
403
+ }
404
+ interface SpreadsheetMetadata {
405
+ spreadsheetId: string;
406
+ properties: SpreadsheetProperties;
407
+ sheets: {
408
+ properties: SheetProperties;
409
+ }[];
410
+ }
411
+ interface ValueRange {
412
+ range: string;
413
+ majorDimension: string;
414
+ values: unknown[][];
415
+ }
416
+ interface BatchValueRange {
417
+ spreadsheetId: string;
418
+ valueRanges: ValueRange[];
419
+ }
420
+ interface GoogleSheetsConnectorSdk {
421
+ /**
422
+ * Send an authenticated request to the Google Sheets API v4.
423
+ *
424
+ * The placeholder `{spreadsheetId}` in the path is automatically replaced
425
+ * with the configured default Spreadsheet ID.
426
+ *
427
+ * @param path - API path (e.g., "/{spreadsheetId}/values/Sheet1!A1:D10")
428
+ * @param init - Standard RequestInit (same as fetch)
429
+ * @returns Standard Response (same as fetch)
430
+ */
431
+ request(path: string, init?: RequestInit): Promise<Response>;
432
+ /**
433
+ * Get spreadsheet metadata including sheet names and properties.
434
+ */
435
+ getSpreadsheet(spreadsheetId?: string): Promise<SpreadsheetMetadata>;
436
+ /**
437
+ * Get cell values for a given range (A1 notation).
438
+ *
439
+ * @param range - A1 notation range (e.g., "Sheet1!A1:D10")
440
+ * @param spreadsheetId - Override the default spreadsheet ID
441
+ */
442
+ getValues(range: string, spreadsheetId?: string): Promise<ValueRange>;
443
+ /**
444
+ * Get cell values for multiple ranges in one request.
445
+ *
446
+ * @param ranges - Array of A1 notation ranges
447
+ * @param spreadsheetId - Override the default spreadsheet ID
448
+ */
449
+ batchGetValues(ranges: string[], spreadsheetId?: string): Promise<BatchValueRange>;
450
+ }
451
+ /**
452
+ * Create a Google Sheets client from resolved connection parameters.
453
+ *
454
+ * @param params - Resolved parameter values keyed by parameter slug
455
+ * @param fetchFn - Optional fetch function (for OAuth proxy injection)
456
+ */
457
+ declare function createClient$2(params: Record<string, string>, fetchFn?: typeof fetch): GoogleSheetsConnectorSdk;
458
+
459
+ interface GoogleAnalyticsOauthConnectorSdk {
460
+ /**
461
+ * Send an authenticated request to the Google Analytics Data API v1beta.
462
+ *
463
+ * Occurrences of `{propertyId}` in the path are auto-replaced with the configured property ID.
464
+ *
465
+ * @param path - API path (e.g., "properties/{propertyId}:runReport")
466
+ * @param init - Standard RequestInit (same as fetch)
467
+ * @returns Standard Response (same as fetch)
468
+ */
469
+ request(path: string, init?: RequestInit): Promise<Response>;
470
+ /**
471
+ * Run a GA4 report.
472
+ *
473
+ * @see https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/properties/runReport
474
+ */
475
+ runReport(request: {
476
+ dateRanges: {
477
+ startDate: string;
478
+ endDate: string;
479
+ }[];
480
+ dimensions?: {
481
+ name: string;
482
+ }[];
483
+ metrics: {
484
+ name: string;
485
+ }[];
486
+ limit?: number;
487
+ offset?: number;
488
+ dimensionFilter?: Record<string, unknown>;
489
+ metricFilter?: Record<string, unknown>;
490
+ orderBys?: Record<string, unknown>[];
491
+ }): Promise<{
492
+ rows: {
493
+ dimensionValues: {
494
+ value: string;
495
+ }[];
496
+ metricValues: {
497
+ value: string;
498
+ }[];
499
+ }[];
500
+ rowCount: number;
501
+ }>;
502
+ /**
503
+ * Get available dimensions and metrics for a property.
504
+ *
505
+ * @see https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/properties/getMetadata
506
+ */
507
+ getMetadata(): Promise<{
508
+ name: string;
509
+ dimensions: {
510
+ apiName: string;
511
+ uiName: string;
512
+ description: string;
513
+ [key: string]: unknown;
514
+ }[];
515
+ metrics: {
516
+ apiName: string;
517
+ uiName: string;
518
+ description: string;
519
+ type: string;
520
+ [key: string]: unknown;
521
+ }[];
522
+ }>;
523
+ /**
524
+ * Run a realtime report.
525
+ *
526
+ * @see https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/properties/runRealtimeReport
527
+ */
528
+ runRealtimeReport(request: {
529
+ dimensions?: {
530
+ name: string;
531
+ }[];
532
+ metrics: {
533
+ name: string;
534
+ }[];
535
+ limit?: number;
536
+ dimensionFilter?: Record<string, unknown>;
537
+ metricFilter?: Record<string, unknown>;
538
+ minuteRanges?: {
539
+ startMinutesAgo?: number;
540
+ endMinutesAgo?: number;
541
+ name?: string;
542
+ }[];
543
+ }): Promise<{
544
+ rows: {
545
+ dimensionValues: {
546
+ value: string;
547
+ }[];
548
+ metricValues: {
549
+ value: string;
550
+ }[];
551
+ }[];
552
+ rowCount: number;
553
+ }>;
554
+ }
555
+ /**
556
+ * Create a Google Analytics client from resolved connection parameters.
557
+ *
558
+ * @param params - Resolved parameter values keyed by parameter slug
559
+ * @param fetchFn - Optional fetch function (for OAuth proxy injection)
560
+ */
561
+ declare function createClient$1(params: Record<string, string>, fetchFn?: typeof fetch): GoogleAnalyticsOauthConnectorSdk;
562
+
563
+ interface GoogleAdsRow {
564
+ [key: string]: unknown;
565
+ }
566
+ interface GoogleAdsConnectorSdk {
567
+ /**
568
+ * Send an authenticated request to the Google Ads API v18.
569
+ *
570
+ * The placeholder `{customerId}` in the path is auto-replaced with the configured customer ID.
571
+ *
572
+ * @param path - API path (e.g., "customers/{customerId}/googleAds:searchStream")
573
+ * @param init - Standard RequestInit (same as fetch)
574
+ * @returns Standard Response (same as fetch)
575
+ */
576
+ request(path: string, init?: RequestInit): Promise<Response>;
577
+ /**
578
+ * Execute a GAQL (Google Ads Query Language) query using searchStream.
579
+ *
580
+ * @param query - GAQL query string
581
+ * @param customerId - Override the default customer ID
582
+ * @returns Array of result rows
583
+ *
584
+ * @see https://developers.google.com/google-ads/api/docs/query/overview
585
+ */
586
+ search(query: string, customerId?: string): Promise<GoogleAdsRow[]>;
587
+ /**
588
+ * List accessible customer accounts.
589
+ */
590
+ listAccessibleCustomers(): Promise<string[]>;
591
+ }
592
+ /**
593
+ * Create a Google Ads client from resolved connection parameters.
594
+ *
595
+ * @param params - Resolved parameter values keyed by parameter slug
596
+ * @param fetchFn - Optional fetch function (for OAuth proxy injection)
597
+ */
598
+ declare function createClient(params: Record<string, string>, fetchFn?: typeof fetch): GoogleAdsConnectorSdk;
599
+
600
+ export { type AirtableConnectorSdk, type DbtConnectorSdk, type GoogleAdsConnectorSdk, type GoogleAnalyticsConnectorSdk, type GoogleAnalyticsOauthConnectorSdk, type GoogleSheetsConnectorSdk, type KintoneConnectorSdk, type OpenAIConnectorSdk, type WixStoreConnectorSdk, createClient$6 as airtable, createClient$3 as dbt, createClient as googleAds, createClient$5 as googleAnalytics, createClient$1 as googleAnalyticsOauth, createClient$2 as googleSheets, createClient$8 as kintone, createClient$7 as openai, createClient$4 as wixStore };
package/dist/sdk.js CHANGED
@@ -4,8 +4,11 @@ import {
4
4
  parameters3,
5
5
  parameters4,
6
6
  parameters5,
7
- parameters6
8
- } from "./chunk-4K4NERCT.js";
7
+ parameters6,
8
+ parameters7,
9
+ parameters8,
10
+ parameters9
11
+ } from "./chunk-Q5TIPE53.js";
9
12
 
10
13
  // src/connectors/kintone/sdk/index.ts
11
14
  function createClient(params) {
@@ -735,10 +738,233 @@ function createClient6(params) {
735
738
  }
736
739
  };
737
740
  }
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
+ }
738
961
  export {
739
962
  createClient3 as airtable,
740
963
  createClient6 as dbt,
964
+ createClient9 as googleAds,
741
965
  createClient4 as googleAnalytics,
966
+ createClient8 as googleAnalyticsOauth,
967
+ createClient7 as googleSheets,
742
968
  createClient as kintone,
743
969
  createClient2 as openai,
744
970
  createClient5 as wixStore
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squadbase/connectors",
3
- "version": "0.1.1",
3
+ "version": "0.1.2-dev.0",
4
4
  "description": "Squadbase Connectors",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",