@squadbase/connectors 0.1.1 → 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/{chunk-4K4NERCT.js → chunk-LB7J6VXK.js} +57 -6
- package/dist/index.d.ts +196 -1
- package/dist/index.js +1594 -337
- package/dist/sdk.d.ts +216 -5
- package/dist/sdk.js +260 -34
- package/package.json +1 -1
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$
|
|
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$
|
|
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,44 @@ 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$
|
|
134
|
+
declare function createClient$6(params: Record<string, string>): AirtableConnectorSdk;
|
|
135
|
+
|
|
136
|
+
interface GoogleAdsRow {
|
|
137
|
+
[key: string]: unknown;
|
|
138
|
+
}
|
|
139
|
+
interface GoogleAdsConnectorSdk {
|
|
140
|
+
/**
|
|
141
|
+
* Send an authenticated request to the Google Ads API v18.
|
|
142
|
+
*
|
|
143
|
+
* The placeholder `{customerId}` in the path is auto-replaced with the configured customer ID.
|
|
144
|
+
*
|
|
145
|
+
* @param path - API path (e.g., "customers/{customerId}/googleAds:searchStream")
|
|
146
|
+
* @param init - Standard RequestInit (same as fetch)
|
|
147
|
+
* @returns Standard Response (same as fetch)
|
|
148
|
+
*/
|
|
149
|
+
request(path: string, init?: RequestInit): Promise<Response>;
|
|
150
|
+
/**
|
|
151
|
+
* Execute a GAQL (Google Ads Query Language) query using searchStream.
|
|
152
|
+
*
|
|
153
|
+
* @param query - GAQL query string
|
|
154
|
+
* @param customerId - Override the default customer ID
|
|
155
|
+
* @returns Array of result rows
|
|
156
|
+
*
|
|
157
|
+
* @see https://developers.google.com/google-ads/api/docs/query/overview
|
|
158
|
+
*/
|
|
159
|
+
search(query: string, customerId?: string): Promise<GoogleAdsRow[]>;
|
|
160
|
+
/**
|
|
161
|
+
* List accessible customer accounts.
|
|
162
|
+
*/
|
|
163
|
+
listAccessibleCustomers(): Promise<string[]>;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Create a Google Ads client from resolved connection parameters.
|
|
167
|
+
*
|
|
168
|
+
* @param params - Resolved parameter values keyed by parameter slug
|
|
169
|
+
* @param fetchFn - Optional fetch function (for OAuth proxy injection)
|
|
170
|
+
*/
|
|
171
|
+
declare function createClient$5(params: Record<string, string>, fetchFn?: typeof fetch): GoogleAdsConnectorSdk;
|
|
135
172
|
|
|
136
173
|
interface GoogleAnalyticsConnectorSdk {
|
|
137
174
|
/**
|
|
@@ -237,7 +274,181 @@ interface GoogleAnalyticsConnectorSdk {
|
|
|
237
274
|
* @param params - Resolved parameter values keyed by parameter slug
|
|
238
275
|
* ("service-account-key-json-base64", "property-id")
|
|
239
276
|
*/
|
|
240
|
-
declare function createClient$
|
|
277
|
+
declare function createClient$4(params: Record<string, string>): GoogleAnalyticsConnectorSdk;
|
|
278
|
+
|
|
279
|
+
interface GoogleAnalyticsOauthConnectorSdk {
|
|
280
|
+
/**
|
|
281
|
+
* Send an authenticated request to the Google Analytics Data API v1beta.
|
|
282
|
+
*
|
|
283
|
+
* Occurrences of `{propertyId}` in the path are auto-replaced with the configured property ID.
|
|
284
|
+
*
|
|
285
|
+
* @param path - API path (e.g., "properties/{propertyId}:runReport")
|
|
286
|
+
* @param init - Standard RequestInit (same as fetch)
|
|
287
|
+
* @returns Standard Response (same as fetch)
|
|
288
|
+
*/
|
|
289
|
+
request(path: string, init?: RequestInit): Promise<Response>;
|
|
290
|
+
/**
|
|
291
|
+
* Run a GA4 report.
|
|
292
|
+
*
|
|
293
|
+
* @see https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/properties/runReport
|
|
294
|
+
*/
|
|
295
|
+
runReport(request: {
|
|
296
|
+
dateRanges: {
|
|
297
|
+
startDate: string;
|
|
298
|
+
endDate: string;
|
|
299
|
+
}[];
|
|
300
|
+
dimensions?: {
|
|
301
|
+
name: string;
|
|
302
|
+
}[];
|
|
303
|
+
metrics: {
|
|
304
|
+
name: string;
|
|
305
|
+
}[];
|
|
306
|
+
limit?: number;
|
|
307
|
+
offset?: number;
|
|
308
|
+
dimensionFilter?: Record<string, unknown>;
|
|
309
|
+
metricFilter?: Record<string, unknown>;
|
|
310
|
+
orderBys?: Record<string, unknown>[];
|
|
311
|
+
}): Promise<{
|
|
312
|
+
rows: {
|
|
313
|
+
dimensionValues: {
|
|
314
|
+
value: string;
|
|
315
|
+
}[];
|
|
316
|
+
metricValues: {
|
|
317
|
+
value: string;
|
|
318
|
+
}[];
|
|
319
|
+
}[];
|
|
320
|
+
rowCount: number;
|
|
321
|
+
}>;
|
|
322
|
+
/**
|
|
323
|
+
* Get available dimensions and metrics for a property.
|
|
324
|
+
*
|
|
325
|
+
* @see https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/properties/getMetadata
|
|
326
|
+
*/
|
|
327
|
+
getMetadata(): Promise<{
|
|
328
|
+
name: string;
|
|
329
|
+
dimensions: {
|
|
330
|
+
apiName: string;
|
|
331
|
+
uiName: string;
|
|
332
|
+
description: string;
|
|
333
|
+
[key: string]: unknown;
|
|
334
|
+
}[];
|
|
335
|
+
metrics: {
|
|
336
|
+
apiName: string;
|
|
337
|
+
uiName: string;
|
|
338
|
+
description: string;
|
|
339
|
+
type: string;
|
|
340
|
+
[key: string]: unknown;
|
|
341
|
+
}[];
|
|
342
|
+
}>;
|
|
343
|
+
/**
|
|
344
|
+
* Run a realtime report.
|
|
345
|
+
*
|
|
346
|
+
* @see https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/properties/runRealtimeReport
|
|
347
|
+
*/
|
|
348
|
+
runRealtimeReport(request: {
|
|
349
|
+
dimensions?: {
|
|
350
|
+
name: string;
|
|
351
|
+
}[];
|
|
352
|
+
metrics: {
|
|
353
|
+
name: string;
|
|
354
|
+
}[];
|
|
355
|
+
limit?: number;
|
|
356
|
+
dimensionFilter?: Record<string, unknown>;
|
|
357
|
+
metricFilter?: Record<string, unknown>;
|
|
358
|
+
minuteRanges?: {
|
|
359
|
+
startMinutesAgo?: number;
|
|
360
|
+
endMinutesAgo?: number;
|
|
361
|
+
name?: string;
|
|
362
|
+
}[];
|
|
363
|
+
}): Promise<{
|
|
364
|
+
rows: {
|
|
365
|
+
dimensionValues: {
|
|
366
|
+
value: string;
|
|
367
|
+
}[];
|
|
368
|
+
metricValues: {
|
|
369
|
+
value: string;
|
|
370
|
+
}[];
|
|
371
|
+
}[];
|
|
372
|
+
rowCount: number;
|
|
373
|
+
}>;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Create a Google Analytics client from resolved connection parameters.
|
|
377
|
+
*
|
|
378
|
+
* @param params - Resolved parameter values keyed by parameter slug
|
|
379
|
+
* @param fetchFn - Optional fetch function (for OAuth proxy injection)
|
|
380
|
+
*/
|
|
381
|
+
declare function createClient$3(params: Record<string, string>, fetchFn?: typeof fetch): GoogleAnalyticsOauthConnectorSdk;
|
|
382
|
+
|
|
383
|
+
interface SpreadsheetProperties {
|
|
384
|
+
title: string;
|
|
385
|
+
locale?: string;
|
|
386
|
+
timeZone?: string;
|
|
387
|
+
}
|
|
388
|
+
interface SheetProperties {
|
|
389
|
+
sheetId: number;
|
|
390
|
+
title: string;
|
|
391
|
+
index: number;
|
|
392
|
+
sheetType?: string;
|
|
393
|
+
gridProperties?: {
|
|
394
|
+
rowCount: number;
|
|
395
|
+
columnCount: number;
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
interface SpreadsheetMetadata {
|
|
399
|
+
spreadsheetId: string;
|
|
400
|
+
properties: SpreadsheetProperties;
|
|
401
|
+
sheets: {
|
|
402
|
+
properties: SheetProperties;
|
|
403
|
+
}[];
|
|
404
|
+
}
|
|
405
|
+
interface ValueRange {
|
|
406
|
+
range: string;
|
|
407
|
+
majorDimension: string;
|
|
408
|
+
values: unknown[][];
|
|
409
|
+
}
|
|
410
|
+
interface BatchValueRange {
|
|
411
|
+
spreadsheetId: string;
|
|
412
|
+
valueRanges: ValueRange[];
|
|
413
|
+
}
|
|
414
|
+
interface GoogleSheetsConnectorSdk {
|
|
415
|
+
/**
|
|
416
|
+
* Send an authenticated request to the Google Sheets API v4.
|
|
417
|
+
*
|
|
418
|
+
* The placeholder `{spreadsheetId}` in the path is automatically replaced
|
|
419
|
+
* with the configured default Spreadsheet ID.
|
|
420
|
+
*
|
|
421
|
+
* @param path - API path (e.g., "/{spreadsheetId}/values/Sheet1!A1:D10")
|
|
422
|
+
* @param init - Standard RequestInit (same as fetch)
|
|
423
|
+
* @returns Standard Response (same as fetch)
|
|
424
|
+
*/
|
|
425
|
+
request(path: string, init?: RequestInit): Promise<Response>;
|
|
426
|
+
/**
|
|
427
|
+
* Get spreadsheet metadata including sheet names and properties.
|
|
428
|
+
*/
|
|
429
|
+
getSpreadsheet(spreadsheetId?: string): Promise<SpreadsheetMetadata>;
|
|
430
|
+
/**
|
|
431
|
+
* Get cell values for a given range (A1 notation).
|
|
432
|
+
*
|
|
433
|
+
* @param range - A1 notation range (e.g., "Sheet1!A1:D10")
|
|
434
|
+
* @param spreadsheetId - Override the default spreadsheet ID
|
|
435
|
+
*/
|
|
436
|
+
getValues(range: string, spreadsheetId?: string): Promise<ValueRange>;
|
|
437
|
+
/**
|
|
438
|
+
* Get cell values for multiple ranges in one request.
|
|
439
|
+
*
|
|
440
|
+
* @param ranges - Array of A1 notation ranges
|
|
441
|
+
* @param spreadsheetId - Override the default spreadsheet ID
|
|
442
|
+
*/
|
|
443
|
+
batchGetValues(ranges: string[], spreadsheetId?: string): Promise<BatchValueRange>;
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Create a Google Sheets client from resolved connection parameters.
|
|
447
|
+
*
|
|
448
|
+
* @param params - Resolved parameter values keyed by parameter slug
|
|
449
|
+
* @param fetchFn - Optional fetch function (for OAuth proxy injection)
|
|
450
|
+
*/
|
|
451
|
+
declare function createClient$2(params: Record<string, string>, fetchFn?: typeof fetch): GoogleSheetsConnectorSdk;
|
|
241
452
|
|
|
242
453
|
interface WixStoreConnectorSdk {
|
|
243
454
|
/**
|
|
@@ -386,4 +597,4 @@ interface DbtConnectorSdk {
|
|
|
386
597
|
*/
|
|
387
598
|
declare function createClient(params: Record<string, string>): DbtConnectorSdk;
|
|
388
599
|
|
|
389
|
-
export { type AirtableConnectorSdk, type DbtConnectorSdk, type GoogleAnalyticsConnectorSdk, type KintoneConnectorSdk, type OpenAIConnectorSdk, type WixStoreConnectorSdk, createClient$
|
|
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 as dbt, createClient$5 as googleAds, createClient$4 as googleAnalytics, createClient$3 as googleAnalyticsOauth, createClient$2 as googleSheets, createClient$8 as kintone, createClient$7 as openai, createClient$1 as wixStore };
|
package/dist/sdk.js
CHANGED
|
@@ -4,19 +4,22 @@ import {
|
|
|
4
4
|
parameters3,
|
|
5
5
|
parameters4,
|
|
6
6
|
parameters5,
|
|
7
|
-
parameters6
|
|
8
|
-
|
|
7
|
+
parameters6,
|
|
8
|
+
parameters7,
|
|
9
|
+
parameters8,
|
|
10
|
+
parameters9
|
|
11
|
+
} from "./chunk-LB7J6VXK.js";
|
|
9
12
|
|
|
10
13
|
// src/connectors/kintone/sdk/index.ts
|
|
11
14
|
function createClient(params) {
|
|
12
|
-
const baseUrl = params[
|
|
13
|
-
const username = params[
|
|
14
|
-
const password = params[
|
|
15
|
+
const baseUrl = params[parameters6.baseUrl.slug];
|
|
16
|
+
const username = params[parameters6.username.slug];
|
|
17
|
+
const password = params[parameters6.password.slug];
|
|
15
18
|
if (!baseUrl || !username || !password) {
|
|
16
19
|
const required = [
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
parameters6.baseUrl.slug,
|
|
21
|
+
parameters6.username.slug,
|
|
22
|
+
parameters6.password.slug
|
|
20
23
|
];
|
|
21
24
|
const missing = required.filter((s) => !params[s]);
|
|
22
25
|
throw new Error(
|
|
@@ -78,10 +81,10 @@ function createClient(params) {
|
|
|
78
81
|
|
|
79
82
|
// src/connectors/openai/sdk/index.ts
|
|
80
83
|
function createClient2(params) {
|
|
81
|
-
const apiKey = params[
|
|
84
|
+
const apiKey = params[parameters9.apiKey.slug];
|
|
82
85
|
if (!apiKey) {
|
|
83
86
|
throw new Error(
|
|
84
|
-
`openai: missing required parameter: ${
|
|
87
|
+
`openai: missing required parameter: ${parameters9.apiKey.slug}`
|
|
85
88
|
);
|
|
86
89
|
}
|
|
87
90
|
return { apiKey };
|
|
@@ -220,10 +223,84 @@ function createClient3(params) {
|
|
|
220
223
|
};
|
|
221
224
|
}
|
|
222
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
|
+
|
|
223
300
|
// src/connectors/google-analytics/sdk/index.ts
|
|
224
301
|
import * as crypto from "crypto";
|
|
225
302
|
var TOKEN_URL = "https://oauth2.googleapis.com/token";
|
|
226
|
-
var
|
|
303
|
+
var BASE_URL3 = "https://analyticsdata.googleapis.com/v1beta/";
|
|
227
304
|
var SCOPE = "https://www.googleapis.com/auth/analytics.readonly";
|
|
228
305
|
function base64url(input) {
|
|
229
306
|
const buf = typeof input === "string" ? Buffer.from(input) : input;
|
|
@@ -247,13 +324,13 @@ function buildJwt(clientEmail, privateKey, nowSec) {
|
|
|
247
324
|
const signature = base64url(sign.sign(privateKey));
|
|
248
325
|
return `${signingInput}.${signature}`;
|
|
249
326
|
}
|
|
250
|
-
function
|
|
251
|
-
const serviceAccountKeyJsonBase64 = params[
|
|
252
|
-
const propertyId = params[
|
|
327
|
+
function createClient5(params) {
|
|
328
|
+
const serviceAccountKeyJsonBase64 = params[parameters3.serviceAccountKeyJsonBase64.slug];
|
|
329
|
+
const propertyId = params[parameters3.propertyId.slug];
|
|
253
330
|
if (!serviceAccountKeyJsonBase64 || !propertyId) {
|
|
254
331
|
const required = [
|
|
255
|
-
|
|
256
|
-
|
|
332
|
+
parameters3.serviceAccountKeyJsonBase64.slug,
|
|
333
|
+
parameters3.propertyId.slug
|
|
257
334
|
];
|
|
258
335
|
const missing = required.filter((s) => !params[s]);
|
|
259
336
|
throw new Error(
|
|
@@ -312,7 +389,7 @@ function createClient4(params) {
|
|
|
312
389
|
async request(path, init) {
|
|
313
390
|
const accessToken = await getAccessToken();
|
|
314
391
|
const resolvedPath = path.replace(/\{propertyId\}/g, propertyId);
|
|
315
|
-
const url = `${
|
|
392
|
+
const url = `${BASE_URL3.replace(/\/+$/, "")}/${resolvedPath.replace(/^\/+/, "")}`;
|
|
316
393
|
const headers = new Headers(init?.headers);
|
|
317
394
|
headers.set("Authorization", `Bearer ${accessToken}`);
|
|
318
395
|
return fetch(url, { ...init, headers });
|
|
@@ -375,16 +452,162 @@ function createClient4(params) {
|
|
|
375
452
|
};
|
|
376
453
|
}
|
|
377
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
|
+
|
|
378
601
|
// src/connectors/wix-store/sdk/index.ts
|
|
379
|
-
function
|
|
380
|
-
const accountId = params[
|
|
381
|
-
const siteId = params[
|
|
382
|
-
const apiKey = params[
|
|
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];
|
|
383
606
|
if (!accountId || !siteId || !apiKey) {
|
|
384
607
|
const required = [
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
608
|
+
parameters7.accountId.slug,
|
|
609
|
+
parameters7.siteId.slug,
|
|
610
|
+
parameters7.apiKey.slug
|
|
388
611
|
];
|
|
389
612
|
const missing = required.filter((s) => !params[s]);
|
|
390
613
|
throw new Error(
|
|
@@ -502,15 +725,15 @@ function createClient5(params) {
|
|
|
502
725
|
}
|
|
503
726
|
|
|
504
727
|
// src/connectors/dbt/sdk/index.ts
|
|
505
|
-
function
|
|
506
|
-
const host = params[
|
|
507
|
-
const prodEnvId = params[
|
|
508
|
-
const token = params[
|
|
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];
|
|
509
732
|
if (!host || !prodEnvId || !token) {
|
|
510
733
|
const required = [
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
734
|
+
parameters8.host.slug,
|
|
735
|
+
parameters8.prodEnvId.slug,
|
|
736
|
+
parameters8.token.slug
|
|
514
737
|
];
|
|
515
738
|
const missing = required.filter((s) => !params[s]);
|
|
516
739
|
throw new Error(
|
|
@@ -737,9 +960,12 @@ function createClient6(params) {
|
|
|
737
960
|
}
|
|
738
961
|
export {
|
|
739
962
|
createClient3 as airtable,
|
|
740
|
-
|
|
741
|
-
createClient4 as
|
|
963
|
+
createClient9 as dbt,
|
|
964
|
+
createClient4 as googleAds,
|
|
965
|
+
createClient5 as googleAnalytics,
|
|
966
|
+
createClient6 as googleAnalyticsOauth,
|
|
967
|
+
createClient7 as googleSheets,
|
|
742
968
|
createClient as kintone,
|
|
743
969
|
createClient2 as openai,
|
|
744
|
-
|
|
970
|
+
createClient8 as wixStore
|
|
745
971
|
};
|