@squadbase/vite-server 0.1.12-dev.93b8799 → 0.1.17-dev.24af54e
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/cli/index.js +12128 -934
- package/dist/connectors/airtable-oauth.js +248 -46
- package/dist/connectors/airtable.js +285 -51
- package/dist/connectors/amplitude.js +288 -47
- package/dist/connectors/anthropic.js +126 -47
- package/dist/connectors/asana.js +293 -49
- package/dist/connectors/attio.js +268 -49
- package/dist/connectors/aws-billing.js +253 -46
- package/dist/connectors/azure-sql.js +387 -102
- package/dist/connectors/backlog-api-key.js +283 -47
- package/dist/connectors/clickup.js +304 -49
- package/dist/connectors/cosmosdb.js +271 -50
- package/dist/connectors/customerio.js +285 -47
- package/dist/connectors/dbt.js +306 -47
- package/dist/connectors/freshdesk.js +308 -53
- package/dist/connectors/freshsales.js +299 -52
- package/dist/connectors/freshservice.js +327 -53
- package/dist/connectors/gamma.js +293 -52
- package/dist/connectors/gemini.js +125 -47
- package/dist/connectors/github.js +352 -49
- package/dist/connectors/gmail-oauth.js +170 -7
- package/dist/connectors/gmail.js +316 -47
- package/dist/connectors/google-ads.js +254 -46
- package/dist/connectors/google-analytics-oauth.js +276 -46
- package/dist/connectors/google-analytics.js +378 -49
- package/dist/connectors/google-audit-log.js +404 -47
- package/dist/connectors/google-calendar-oauth.js +225 -46
- package/dist/connectors/google-calendar.js +325 -47
- package/dist/connectors/google-docs.js +186 -6
- package/dist/connectors/google-drive.js +228 -5
- package/dist/connectors/google-search-console-oauth.js +222 -46
- package/dist/connectors/google-sheets.js +238 -47
- package/dist/connectors/google-slides.js +171 -6
- package/dist/connectors/grafana.js +298 -49
- package/dist/connectors/hubspot-oauth.js +174 -5
- package/dist/connectors/hubspot.js +272 -49
- package/dist/connectors/influxdb.js +382 -51
- package/dist/connectors/intercom-oauth.js +176 -5
- package/dist/connectors/intercom.js +268 -49
- package/dist/connectors/jdbc.js +728 -110
- package/dist/connectors/jira-api-key.js +292 -47
- package/dist/connectors/kintone-api-token.js +247 -47
- package/dist/connectors/kintone.js +294 -47
- package/dist/connectors/linear.js +296 -49
- package/dist/connectors/linkedin-ads.js +234 -50
- package/dist/connectors/mailchimp-oauth.js +234 -46
- package/dist/connectors/mailchimp.js +286 -49
- package/dist/connectors/meta-ads-oauth.js +239 -48
- package/dist/connectors/meta-ads.js +251 -50
- package/dist/connectors/mixpanel.js +304 -47
- package/dist/connectors/monday.js +326 -49
- package/dist/connectors/mongodb.js +285 -57
- package/dist/connectors/notion-oauth.js +197 -5
- package/dist/connectors/notion.js +289 -51
- package/dist/connectors/openai.js +125 -47
- package/dist/connectors/oracle.js +405 -103
- package/dist/connectors/outlook-oauth.js +170 -5
- package/dist/connectors/powerbi-oauth.js +217 -5
- package/dist/connectors/salesforce.js +350 -49
- package/dist/connectors/semrush.js +280 -49
- package/dist/connectors/sentry.js +255 -50
- package/dist/connectors/shopify-oauth.js +153 -5
- package/dist/connectors/shopify.js +323 -47
- package/dist/connectors/sqlserver.js +381 -102
- package/dist/connectors/stripe-api-key.js +235 -46
- package/dist/connectors/stripe-oauth.js +168 -5
- package/dist/connectors/supabase.js +269 -48
- package/dist/connectors/tableau.js +337 -206
- package/dist/connectors/tiktok-ads.js +245 -48
- package/dist/connectors/wix-store.js +286 -49
- package/dist/connectors/zendesk-oauth.js +205 -5
- package/dist/connectors/zendesk.js +324 -47
- package/dist/index.d.ts +149 -1
- package/dist/index.js +18297 -6886
- package/dist/main.js +12785 -1382
- package/dist/vite-plugin.js +12140 -936
- package/package.json +1 -1
|
@@ -1,48 +1,60 @@
|
|
|
1
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
+
var __esm = (fn, res) => function __init() {
|
|
3
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
4
|
+
};
|
|
5
|
+
|
|
1
6
|
// ../connectors/src/parameter-definition.ts
|
|
2
|
-
var ParameterDefinition
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
7
|
+
var ParameterDefinition;
|
|
8
|
+
var init_parameter_definition = __esm({
|
|
9
|
+
"../connectors/src/parameter-definition.ts"() {
|
|
10
|
+
"use strict";
|
|
11
|
+
ParameterDefinition = class {
|
|
12
|
+
slug;
|
|
13
|
+
name;
|
|
14
|
+
description;
|
|
15
|
+
envVarBaseKey;
|
|
16
|
+
type;
|
|
17
|
+
secret;
|
|
18
|
+
required;
|
|
19
|
+
constructor(config) {
|
|
20
|
+
this.slug = config.slug;
|
|
21
|
+
this.name = config.name;
|
|
22
|
+
this.description = config.description;
|
|
23
|
+
this.envVarBaseKey = config.envVarBaseKey;
|
|
24
|
+
this.type = config.type;
|
|
25
|
+
this.secret = config.secret;
|
|
26
|
+
this.required = config.required;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get the parameter value from a ConnectorConnectionObject.
|
|
30
|
+
*/
|
|
31
|
+
getValue(connection2) {
|
|
32
|
+
const param = connection2.parameters.find(
|
|
33
|
+
(p) => p.parameterSlug === this.slug
|
|
34
|
+
);
|
|
35
|
+
if (!param || param.value == null) {
|
|
36
|
+
throw new Error(
|
|
37
|
+
`Parameter "${this.slug}" not found or has no value in connection "${connection2.id}"`
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
return param.value;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Try to get the parameter value. Returns undefined if not found (for optional params).
|
|
44
|
+
*/
|
|
45
|
+
tryGetValue(connection2) {
|
|
46
|
+
const param = connection2.parameters.find(
|
|
47
|
+
(p) => p.parameterSlug === this.slug
|
|
48
|
+
);
|
|
49
|
+
if (!param || param.value == null) return void 0;
|
|
50
|
+
return param.value;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
42
53
|
}
|
|
43
|
-
};
|
|
54
|
+
});
|
|
44
55
|
|
|
45
56
|
// ../connectors/src/connectors/zendesk/parameters.ts
|
|
57
|
+
init_parameter_definition();
|
|
46
58
|
var parameters = {
|
|
47
59
|
subdomain: new ParameterDefinition({
|
|
48
60
|
slug: "subdomain",
|
|
@@ -248,6 +260,20 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
248
260
|
* `runSetupFlow` from `setup-flow.ts`.
|
|
249
261
|
*/
|
|
250
262
|
setup;
|
|
263
|
+
/**
|
|
264
|
+
* Opt-out of the default "verify before save" behavior on connection
|
|
265
|
+
* creation. The backend invokes `checkConnection` synchronously while
|
|
266
|
+
* creating the connection and aborts (no row inserted) if it fails — this
|
|
267
|
+
* flag disables that for connectors where the check cannot succeed pre-save:
|
|
268
|
+
*
|
|
269
|
+
* - `squadbase-db` populates `connection-url` only after Neon provisioning
|
|
270
|
+
* - OAuth connectors require an OAuth-aware proxyFetch keyed by the
|
|
271
|
+
* connectionId, which doesn't exist until the row is saved
|
|
272
|
+
*
|
|
273
|
+
* Exceptions are the explicit position; new credential-input connectors get
|
|
274
|
+
* the default verify-on-create behavior without opt-in.
|
|
275
|
+
*/
|
|
276
|
+
skipConnectionCheckOnCreate;
|
|
251
277
|
constructor(config) {
|
|
252
278
|
this.slug = config.slug;
|
|
253
279
|
this.authType = config.authType;
|
|
@@ -265,6 +291,7 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
265
291
|
this.query = config.query;
|
|
266
292
|
this.checkConnection = config.checkConnection;
|
|
267
293
|
this.setup = config.setup;
|
|
294
|
+
this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
|
|
268
295
|
}
|
|
269
296
|
get connectorKey() {
|
|
270
297
|
return _ConnectorPlugin.deriveKey(this.slug, this.authType);
|
|
@@ -329,6 +356,51 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
329
356
|
}
|
|
330
357
|
};
|
|
331
358
|
|
|
359
|
+
// ../connectors/src/setup-flow.ts
|
|
360
|
+
async function runSetupFlow(flow, params, ctx, config) {
|
|
361
|
+
const runtime = {
|
|
362
|
+
params,
|
|
363
|
+
language: ctx.language,
|
|
364
|
+
config
|
|
365
|
+
};
|
|
366
|
+
let state = flow.initialState();
|
|
367
|
+
let answerIdx = 0;
|
|
368
|
+
for (const step of flow.steps) {
|
|
369
|
+
const ans = ctx.answers[answerIdx];
|
|
370
|
+
if (ans && ans.questionSlug === step.slug) {
|
|
371
|
+
state = step.applyAnswer(state, ans.answer);
|
|
372
|
+
answerIdx += 1;
|
|
373
|
+
continue;
|
|
374
|
+
}
|
|
375
|
+
if (step.type === "text") {
|
|
376
|
+
return {
|
|
377
|
+
type: "nextQuestion",
|
|
378
|
+
questionSlug: step.slug,
|
|
379
|
+
question: step.question[ctx.language],
|
|
380
|
+
questionType: "text"
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
|
|
384
|
+
if (options.length === 0) {
|
|
385
|
+
continue;
|
|
386
|
+
}
|
|
387
|
+
return {
|
|
388
|
+
type: "nextQuestion",
|
|
389
|
+
questionSlug: step.slug,
|
|
390
|
+
question: step.question[ctx.language],
|
|
391
|
+
questionType: step.type,
|
|
392
|
+
options
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
const dataInvestigationResult = await flow.finalize(state, runtime);
|
|
396
|
+
return { type: "fulfilled", dataInvestigationResult };
|
|
397
|
+
}
|
|
398
|
+
async function resolveSetupSelection(params) {
|
|
399
|
+
const { selected, allSentinel, fetchAll, limit } = params;
|
|
400
|
+
const resolved = selected.includes(allSentinel) ? await fetchAll() : selected.filter((v) => v !== allSentinel);
|
|
401
|
+
return resolved.slice(0, limit);
|
|
402
|
+
}
|
|
403
|
+
|
|
332
404
|
// ../connectors/src/auth-types.ts
|
|
333
405
|
var AUTH_TYPES = {
|
|
334
406
|
OAUTH: "oauth",
|
|
@@ -353,6 +425,150 @@ var zendeskOnboarding = new ConnectorOnboarding({
|
|
|
353
425
|
}
|
|
354
426
|
});
|
|
355
427
|
|
|
428
|
+
// ../connectors/src/connectors/zendesk/utils.ts
|
|
429
|
+
function normalizeSubdomain(raw) {
|
|
430
|
+
return raw.trim().replace(/^https?:\/\//i, "").replace(/\.zendesk\.com.*$/, "").replace(/\/+$/, "").split(".")[0];
|
|
431
|
+
}
|
|
432
|
+
function basicAuthHeader(email, apiToken) {
|
|
433
|
+
return `Basic ${Buffer.from(`${email}/token:${apiToken}`).toString("base64")}`;
|
|
434
|
+
}
|
|
435
|
+
async function apiFetch(params, path2, init) {
|
|
436
|
+
const subdomain = params[parameters.subdomain.slug];
|
|
437
|
+
const email = params[parameters.email.slug];
|
|
438
|
+
const apiToken = params[parameters.apiToken.slug];
|
|
439
|
+
if (!subdomain || !email || !apiToken) {
|
|
440
|
+
throw new Error(
|
|
441
|
+
"zendesk: missing required parameter(s) (subdomain, email, api-token)"
|
|
442
|
+
);
|
|
443
|
+
}
|
|
444
|
+
const url = `https://${normalizeSubdomain(subdomain)}.zendesk.com${path2.startsWith("/") ? "" : "/"}${path2}`;
|
|
445
|
+
const headers = new Headers(init?.headers);
|
|
446
|
+
headers.set("Authorization", basicAuthHeader(email, apiToken));
|
|
447
|
+
headers.set("Accept", "application/json");
|
|
448
|
+
return fetch(url, { ...init, headers });
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
// ../connectors/src/connectors/zendesk/setup-flow.ts
|
|
452
|
+
var ZENDESK_SETUP_MAX_ENTITIES = 5;
|
|
453
|
+
var ZENDESK_ENTITIES = [
|
|
454
|
+
{
|
|
455
|
+
value: "tickets",
|
|
456
|
+
label: "Tickets",
|
|
457
|
+
countPath: "/api/v2/tickets.json?page[size]=1",
|
|
458
|
+
countField: "count"
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
value: "users",
|
|
462
|
+
label: "Users",
|
|
463
|
+
countPath: "/api/v2/users.json?page[size]=1",
|
|
464
|
+
countField: "count"
|
|
465
|
+
},
|
|
466
|
+
{
|
|
467
|
+
value: "organizations",
|
|
468
|
+
label: "Organizations",
|
|
469
|
+
countPath: "/api/v2/organizations.json?page[size]=1",
|
|
470
|
+
countField: "count"
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
value: "groups",
|
|
474
|
+
label: "Groups",
|
|
475
|
+
countPath: "/api/v2/groups.json?page[size]=1",
|
|
476
|
+
countField: "count"
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
value: "articles",
|
|
480
|
+
label: "Help Center articles",
|
|
481
|
+
countPath: "/api/v2/help_center/articles.json?page[size]=1",
|
|
482
|
+
countField: "count"
|
|
483
|
+
}
|
|
484
|
+
];
|
|
485
|
+
async function listBrands(params) {
|
|
486
|
+
const res = await apiFetch(params, "/api/v2/brands.json");
|
|
487
|
+
if (!res.ok) return [];
|
|
488
|
+
const data = await res.json();
|
|
489
|
+
return data.brands ?? [];
|
|
490
|
+
}
|
|
491
|
+
async function fetchCount(params, path2, countField) {
|
|
492
|
+
const res = await apiFetch(params, path2);
|
|
493
|
+
if (!res.ok) return null;
|
|
494
|
+
const data = await res.json();
|
|
495
|
+
const raw = data[countField];
|
|
496
|
+
if (typeof raw === "number") return raw;
|
|
497
|
+
if (typeof data["count"] === "number") return data["count"];
|
|
498
|
+
return null;
|
|
499
|
+
}
|
|
500
|
+
var zendeskSetupFlow = {
|
|
501
|
+
initialState: () => ({}),
|
|
502
|
+
steps: [
|
|
503
|
+
{
|
|
504
|
+
slug: "brand",
|
|
505
|
+
type: "select",
|
|
506
|
+
question: {
|
|
507
|
+
ja: "\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3067\u5BFE\u8C61\u3068\u3059\u308BZendesk\u30D6\u30E9\u30F3\u30C9\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044",
|
|
508
|
+
en: "Select the Zendesk brand to use for setup"
|
|
509
|
+
},
|
|
510
|
+
async fetchOptions(_state, rt) {
|
|
511
|
+
const brands = await listBrands(rt.params);
|
|
512
|
+
const active = brands.filter((b) => b.active !== false && b.name);
|
|
513
|
+
if (active.length < 2) return [];
|
|
514
|
+
return active.map((b) => ({
|
|
515
|
+
value: String(b.subdomain ?? b.id ?? b.name),
|
|
516
|
+
label: String(b.name)
|
|
517
|
+
}));
|
|
518
|
+
},
|
|
519
|
+
applyAnswer: (state, answer) => ({ ...state, brand: answer[0] })
|
|
520
|
+
},
|
|
521
|
+
{
|
|
522
|
+
slug: "entities",
|
|
523
|
+
type: "multiSelect",
|
|
524
|
+
question: {
|
|
525
|
+
ja: "\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3067\u6982\u89B3\u3057\u305F\u3044\u30A8\u30F3\u30C6\u30A3\u30C6\u30A3\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044\uFF08\u8907\u6570\u9078\u629E\u53EF\uFF09",
|
|
526
|
+
en: "Select the entities to include in setup (multi-select allowed)"
|
|
527
|
+
},
|
|
528
|
+
async fetchOptions(_state, _rt) {
|
|
529
|
+
return ZENDESK_ENTITIES.map((e) => ({ value: e.value, label: e.label }));
|
|
530
|
+
},
|
|
531
|
+
applyAnswer: (state, answer) => ({ ...state, entities: answer })
|
|
532
|
+
}
|
|
533
|
+
],
|
|
534
|
+
async finalize(state, rt) {
|
|
535
|
+
if (!state.entities) {
|
|
536
|
+
throw new Error("Zendesk setup: incomplete state on finalize");
|
|
537
|
+
}
|
|
538
|
+
const targetEntities = await resolveSetupSelection({
|
|
539
|
+
selected: state.entities,
|
|
540
|
+
allSentinel: "__ALL__",
|
|
541
|
+
fetchAll: async () => ZENDESK_ENTITIES.map((e) => e.value),
|
|
542
|
+
limit: ZENDESK_SETUP_MAX_ENTITIES
|
|
543
|
+
});
|
|
544
|
+
const entityByValue = new Map(ZENDESK_ENTITIES.map((e) => [e.value, e]));
|
|
545
|
+
const sections = ["## Zendesk", ""];
|
|
546
|
+
if (state.brand) {
|
|
547
|
+
sections.push(`### Brand: ${state.brand}`, "");
|
|
548
|
+
}
|
|
549
|
+
sections.push("### Selected entities", "");
|
|
550
|
+
sections.push("| Entity | Count |");
|
|
551
|
+
sections.push("|--------|-------|");
|
|
552
|
+
for (const value of targetEntities) {
|
|
553
|
+
const entity = entityByValue.get(value);
|
|
554
|
+
if (!entity) {
|
|
555
|
+
sections.push(`| ${value} | _unknown_ |`);
|
|
556
|
+
continue;
|
|
557
|
+
}
|
|
558
|
+
const count = await fetchCount(
|
|
559
|
+
rt.params,
|
|
560
|
+
entity.countPath,
|
|
561
|
+
entity.countField
|
|
562
|
+
);
|
|
563
|
+
sections.push(
|
|
564
|
+
`| ${entity.label} (${entity.value}) | ${count == null ? "-" : count} |`
|
|
565
|
+
);
|
|
566
|
+
}
|
|
567
|
+
sections.push("");
|
|
568
|
+
return sections.join("\n");
|
|
569
|
+
}
|
|
570
|
+
};
|
|
571
|
+
|
|
356
572
|
// ../connectors/src/connectors/zendesk/tools/request.ts
|
|
357
573
|
import { z } from "zod";
|
|
358
574
|
var REQUEST_TIMEOUT_MS = 6e4;
|
|
@@ -621,7 +837,48 @@ export default async function handler(c: Context) {
|
|
|
621
837
|
- \`type:user role:agent\` \u2014 \u30A8\u30FC\u30B8\u30A7\u30F3\u30C8\u30E6\u30FC\u30B6\u30FC
|
|
622
838
|
- \`type:organization {name}\` \u2014 \u540D\u524D\u304C\u4E00\u81F4\u3059\u308B\u7D44\u7E54`
|
|
623
839
|
},
|
|
624
|
-
tools
|
|
840
|
+
tools,
|
|
841
|
+
setup: (params, ctx, config) => runSetupFlow(zendeskSetupFlow, params, ctx, config),
|
|
842
|
+
async checkConnection(params, _config) {
|
|
843
|
+
const subdomain = params[parameters.subdomain.slug];
|
|
844
|
+
const email = params[parameters.email.slug];
|
|
845
|
+
const apiToken = params[parameters.apiToken.slug];
|
|
846
|
+
if (!subdomain || !email || !apiToken) {
|
|
847
|
+
return {
|
|
848
|
+
success: false,
|
|
849
|
+
error: `Missing required parameter(s): ${parameters.subdomain.slug}, ${parameters.email.slug}, ${parameters.apiToken.slug}`
|
|
850
|
+
};
|
|
851
|
+
}
|
|
852
|
+
try {
|
|
853
|
+
const credentials = Buffer.from(
|
|
854
|
+
`${email}/token:${apiToken}`,
|
|
855
|
+
"utf-8"
|
|
856
|
+
).toString("base64");
|
|
857
|
+
const res = await fetch(
|
|
858
|
+
`https://${subdomain}.zendesk.com/api/v2/users/me.json`,
|
|
859
|
+
{
|
|
860
|
+
method: "GET",
|
|
861
|
+
headers: {
|
|
862
|
+
Authorization: `Basic ${credentials}`,
|
|
863
|
+
Accept: "application/json"
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
);
|
|
867
|
+
if (!res.ok) {
|
|
868
|
+
const errText = await res.text().catch(() => res.statusText);
|
|
869
|
+
return {
|
|
870
|
+
success: false,
|
|
871
|
+
error: `Zendesk API failed: HTTP ${res.status} ${errText}`
|
|
872
|
+
};
|
|
873
|
+
}
|
|
874
|
+
return { success: true };
|
|
875
|
+
} catch (error) {
|
|
876
|
+
return {
|
|
877
|
+
success: false,
|
|
878
|
+
error: error instanceof Error ? error.message : String(error)
|
|
879
|
+
};
|
|
880
|
+
}
|
|
881
|
+
}
|
|
625
882
|
});
|
|
626
883
|
|
|
627
884
|
// src/connectors/create-connector-sdk.ts
|
|
@@ -650,6 +907,7 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
650
907
|
import { getContext } from "hono/context-storage";
|
|
651
908
|
import { getCookie } from "hono/cookie";
|
|
652
909
|
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
910
|
+
var TABLEAU_SESSION_SENTINEL_URL = "squadbase://tableau-session/";
|
|
653
911
|
function normalizeHeaders(input) {
|
|
654
912
|
const out = {};
|
|
655
913
|
if (!input) return out;
|
|
@@ -658,6 +916,11 @@ function normalizeHeaders(input) {
|
|
|
658
916
|
});
|
|
659
917
|
return out;
|
|
660
918
|
}
|
|
919
|
+
function extractInputUrl(input) {
|
|
920
|
+
if (typeof input === "string") return input;
|
|
921
|
+
if (input instanceof URL) return input.href;
|
|
922
|
+
return input.url;
|
|
923
|
+
}
|
|
661
924
|
function createSandboxProxyFetch(connectionId) {
|
|
662
925
|
return async (input, init) => {
|
|
663
926
|
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
@@ -667,10 +930,17 @@ function createSandboxProxyFetch(connectionId) {
|
|
|
667
930
|
"Connection proxy is not configured. Please check your deployment settings."
|
|
668
931
|
);
|
|
669
932
|
}
|
|
670
|
-
const originalUrl =
|
|
933
|
+
const originalUrl = extractInputUrl(input);
|
|
934
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
935
|
+
if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
|
|
936
|
+
const sessionUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
937
|
+
return fetch(sessionUrl, {
|
|
938
|
+
method: "POST",
|
|
939
|
+
headers: { Authorization: `Bearer ${token}` }
|
|
940
|
+
});
|
|
941
|
+
}
|
|
671
942
|
const originalMethod = init?.method ?? "GET";
|
|
672
943
|
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
673
|
-
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
674
944
|
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
675
945
|
return fetch(proxyUrl, {
|
|
676
946
|
method: "POST",
|
|
@@ -696,10 +966,9 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
696
966
|
}
|
|
697
967
|
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
698
968
|
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
969
|
+
const sessionUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
699
970
|
return async (input, init) => {
|
|
700
|
-
const originalUrl =
|
|
701
|
-
const originalMethod = init?.method ?? "GET";
|
|
702
|
-
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
971
|
+
const originalUrl = extractInputUrl(input);
|
|
703
972
|
const c = getContext();
|
|
704
973
|
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
705
974
|
if (!appSession) {
|
|
@@ -707,6 +976,14 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
707
976
|
"No authentication method available for connection proxy."
|
|
708
977
|
);
|
|
709
978
|
}
|
|
979
|
+
if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
|
|
980
|
+
return fetch(sessionUrl, {
|
|
981
|
+
method: "POST",
|
|
982
|
+
headers: { Authorization: `Bearer ${appSession}` }
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
const originalMethod = init?.method ?? "GET";
|
|
986
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
710
987
|
return fetch(proxyUrl, {
|
|
711
988
|
method: "POST",
|
|
712
989
|
headers: {
|
package/dist/index.d.ts
CHANGED
|
@@ -132,6 +132,154 @@ declare function connection(connectionId: string): {
|
|
|
132
132
|
fetch(url: string, options?: ConnectionFetchOptions): Promise<Response>;
|
|
133
133
|
};
|
|
134
134
|
|
|
135
|
+
/**
|
|
136
|
+
* Project Storage (SQPD-1213) — HTTP transport for `@squadbase/vite-server`。
|
|
137
|
+
*
|
|
138
|
+
* 設計は `connector-client/proxy-fetch.ts` (IP allowlist 越えのコネクション proxy) と同じ
|
|
139
|
+
* 2 経路パターン。両経路とも user-function-proxy の `/_sqcore/storage/*` を叩く。
|
|
140
|
+
*
|
|
141
|
+
* - **Sandbox 内 vite-server (preview-app server-side / ユーザーアプリ server-side)**:
|
|
142
|
+
* URL = `https://${INTERNAL_SQUADBASE_SANDBOX_ID}.${SQUADBASE_PREVIEW_BASE_DOMAIN}/_sqcore/storage/*`
|
|
143
|
+
* 認証 = `Authorization: Bearer ${INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL}`
|
|
144
|
+
* default base domain: `preview.app.squadbase.dev`
|
|
145
|
+
*
|
|
146
|
+
* - **デプロイ済みアプリ**:
|
|
147
|
+
* URL = `https://${SQUADBASE_PROJECT_ID}.${SQUADBASE_APP_BASE_DOMAIN}/_sqcore/storage/*`
|
|
148
|
+
* 認証 = `__Host-squadbase-session` cookie を `Authorization: Bearer` に転送
|
|
149
|
+
* default base domain: `squadbase.app`
|
|
150
|
+
*
|
|
151
|
+
* 経路判定は `INTERNAL_SQUADBASE_SANDBOX_ID` の有無で行う。
|
|
152
|
+
* Coding-Agent から呼ぶ app-api 直経路は本 SDK では持たず、coding-agent 側で別実装する。
|
|
153
|
+
*/
|
|
154
|
+
type PresignedPutResult = {
|
|
155
|
+
url: string;
|
|
156
|
+
headers: Record<string, string>;
|
|
157
|
+
expiresAt: string;
|
|
158
|
+
};
|
|
159
|
+
type PresignedGetResult = {
|
|
160
|
+
url: string;
|
|
161
|
+
expiresAt: string;
|
|
162
|
+
};
|
|
163
|
+
type StorageMetadata = {
|
|
164
|
+
key: string;
|
|
165
|
+
size: number;
|
|
166
|
+
contentType: string;
|
|
167
|
+
createdAt: string;
|
|
168
|
+
createdBy: string;
|
|
169
|
+
source: "upload" | "agent" | "system";
|
|
170
|
+
};
|
|
171
|
+
type StorageListItem = {
|
|
172
|
+
key: string;
|
|
173
|
+
size: number;
|
|
174
|
+
lastModified: string;
|
|
175
|
+
};
|
|
176
|
+
type StorageListResult = {
|
|
177
|
+
objects: StorageListItem[];
|
|
178
|
+
nextCursor?: string;
|
|
179
|
+
};
|
|
180
|
+
type StorageUsageDelta = {
|
|
181
|
+
totalSizeBytes: number;
|
|
182
|
+
objectCount: number;
|
|
183
|
+
};
|
|
184
|
+
interface StorageTransport {
|
|
185
|
+
signPut(relativeKey: string, contentType: string, contentLength: number): Promise<PresignedPutResult>;
|
|
186
|
+
signGet(relativeKey: string): Promise<PresignedGetResult>;
|
|
187
|
+
notifyUploaded(relativeKey: string, size: number): Promise<StorageUsageDelta>;
|
|
188
|
+
list(prefix?: string, options?: {
|
|
189
|
+
limit?: number;
|
|
190
|
+
cursor?: string;
|
|
191
|
+
}): Promise<StorageListResult>;
|
|
192
|
+
head(relativeKey: string): Promise<StorageMetadata>;
|
|
193
|
+
delete(relativeKey: string): Promise<StorageUsageDelta>;
|
|
194
|
+
copy(srcRelativeKey: string, destRelativeKey: string, options?: {
|
|
195
|
+
overwrite?: boolean;
|
|
196
|
+
}): Promise<StorageUsageDelta>;
|
|
197
|
+
move(srcRelativeKey: string, destRelativeKey: string, options?: {
|
|
198
|
+
overwrite?: boolean;
|
|
199
|
+
}): Promise<StorageUsageDelta>;
|
|
200
|
+
}
|
|
201
|
+
declare class PresignedHttpsTransport implements StorageTransport {
|
|
202
|
+
signPut(key: string, contentType: string, contentLength: number): Promise<PresignedPutResult>;
|
|
203
|
+
signGet(key: string): Promise<PresignedGetResult>;
|
|
204
|
+
notifyUploaded(key: string, size: number): Promise<StorageUsageDelta>;
|
|
205
|
+
list(prefix?: string, options?: {
|
|
206
|
+
limit?: number;
|
|
207
|
+
cursor?: string;
|
|
208
|
+
}): Promise<StorageListResult>;
|
|
209
|
+
head(key: string): Promise<StorageMetadata>;
|
|
210
|
+
delete(key: string): Promise<StorageUsageDelta>;
|
|
211
|
+
copy(srcKey: string, destKey: string, options?: {
|
|
212
|
+
overwrite?: boolean;
|
|
213
|
+
}): Promise<StorageUsageDelta>;
|
|
214
|
+
move(srcKey: string, destKey: string, options?: {
|
|
215
|
+
overwrite?: boolean;
|
|
216
|
+
}): Promise<StorageUsageDelta>;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Project Storage (SQPD-1213) — `storage.uploads.*` の SDK 実装。
|
|
221
|
+
*
|
|
222
|
+
* 二段ネスト命名 (`storage.uploads.*`) で `agent` / `system` 名前空間の将来追加に備える。
|
|
223
|
+
* slice1+2 (put/get/head/list/delete/uploaded callback) を提供し、copy/move は slice3 で追加。
|
|
224
|
+
*/
|
|
225
|
+
|
|
226
|
+
type PutOptions = {
|
|
227
|
+
contentType?: string;
|
|
228
|
+
};
|
|
229
|
+
type ListOptions = {
|
|
230
|
+
limit?: number;
|
|
231
|
+
cursor?: string;
|
|
232
|
+
};
|
|
233
|
+
type GetResult = {
|
|
234
|
+
/** S3 から取得した body。Hono / Node fetch の Response.body 互換 (ReadableStream<Uint8Array> | null)。 */
|
|
235
|
+
body: ReadableStream<Uint8Array> | null;
|
|
236
|
+
/** head 相当のメタデータ */
|
|
237
|
+
metadata: StorageMetadata;
|
|
238
|
+
};
|
|
239
|
+
declare class StorageUploadsClient {
|
|
240
|
+
private readonly transport;
|
|
241
|
+
constructor(transport: StorageTransport);
|
|
242
|
+
put(key: string, data: Buffer | Uint8Array | ArrayBuffer | Blob, options?: PutOptions): Promise<StorageUsageDelta>;
|
|
243
|
+
get(key: string): Promise<GetResult>;
|
|
244
|
+
head(key: string): Promise<StorageMetadata>;
|
|
245
|
+
list(prefix?: string, options?: ListOptions): Promise<StorageListResult>;
|
|
246
|
+
delete(key: string): Promise<StorageUsageDelta>;
|
|
247
|
+
copy(srcKey: string, destKey: string, options?: {
|
|
248
|
+
overwrite?: boolean;
|
|
249
|
+
}): Promise<StorageUsageDelta>;
|
|
250
|
+
/**
|
|
251
|
+
* rename も本メソッドで表現する (内部的には copy + src 削除を backend で実施)。
|
|
252
|
+
*/
|
|
253
|
+
move(srcKey: string, destKey: string, options?: {
|
|
254
|
+
overwrite?: boolean;
|
|
255
|
+
}): Promise<StorageUsageDelta>;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Project Storage (SQPD-1213) — public SDK entry。
|
|
260
|
+
*
|
|
261
|
+
* ユーザーアプリ (vite-server で動くサーバーロジック) から以下のように利用する:
|
|
262
|
+
*
|
|
263
|
+
* ```ts
|
|
264
|
+
* import { storage } from "@squadbase/vite-server";
|
|
265
|
+
*
|
|
266
|
+
* await storage.uploads.put("reports/2026-05.csv", buffer, { contentType: "text/csv" });
|
|
267
|
+
* const { body, metadata } = await storage.uploads.get("reports/2026-05.csv");
|
|
268
|
+
* const { objects, nextCursor } = await storage.uploads.list("reports/");
|
|
269
|
+
* ```
|
|
270
|
+
*
|
|
271
|
+
* `agent` / `system` 名前空間は将来追加 (現在は uploads のみ)。
|
|
272
|
+
*/
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Project Storage の SDK 入口。
|
|
276
|
+
*
|
|
277
|
+
* 現状は `uploads` のみ。将来 `agent` / `system` を追加するときも公開 API を破壊しない。
|
|
278
|
+
*/
|
|
279
|
+
declare const storage: {
|
|
280
|
+
uploads: StorageUploadsClient;
|
|
281
|
+
};
|
|
282
|
+
|
|
135
283
|
declare const app: Hono<hono_types.BlankEnv, hono_types.BlankSchema, "/">;
|
|
136
284
|
|
|
137
|
-
export { type AirtableClient, type AirtableRecord, type ConnectionEntry, type ConnectionFetchOptions, type ConnectionsMap, type DbtClient, type GoogleAnalyticsClient, type KintoneClient, type QueryFn, type WixStoreClient, connection, createAirtableClient, createDbtClient, createGoogleAnalyticsClient, createKintoneClient, createWixStoreClient, app as default, getQuery, loadConnections };
|
|
285
|
+
export { type AirtableClient, type AirtableRecord, type ConnectionEntry, type ConnectionFetchOptions, type ConnectionsMap, type DbtClient, type GoogleAnalyticsClient, type KintoneClient, type PresignedGetResult, PresignedHttpsTransport, type PresignedPutResult, type QueryFn, type GetResult as StorageGetResult, type StorageListItem, type ListOptions as StorageListOptions, type StorageListResult, type StorageMetadata, type PutOptions as StoragePutOptions, type StorageTransport, StorageUploadsClient, type StorageUsageDelta, type WixStoreClient, connection, createAirtableClient, createDbtClient, createGoogleAnalyticsClient, createKintoneClient, createWixStoreClient, app as default, getQuery, loadConnections, storage };
|