@squadbase/vite-server 0.1.3-dev.2 → 0.1.3-dev.4

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.
@@ -281,7 +281,7 @@ var tools = { request: requestTool };
281
281
  var hubspotOauthConnector = new ConnectorPlugin({
282
282
  slug: "hubspot",
283
283
  authType: AUTH_TYPES.OAUTH,
284
- name: "HubSpot (OAuth)",
284
+ name: "HubSpot",
285
285
  description: "Connect to HubSpot CRM for contacts, deals, companies, and marketing data using OAuth.",
286
286
  iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/5UcSkKkzhUMA4RsM45ynuo/43b967e36915ca0fc5d277684b204320/hubspot.svg",
287
287
  parameters,
@@ -46,8 +46,8 @@ var ParameterDefinition = class {
46
46
  var parameters = {
47
47
  apiKey: new ParameterDefinition({
48
48
  slug: "api-key",
49
- name: "Personal Access Key",
50
- description: "Your HubSpot Personal Access Key for authentication (starts with pat-).",
49
+ name: "Private App Access Token",
50
+ description: "Your HubSpot Private App Access Token for authentication (starts with pat-). You can find it at Settings \u2192 Development \u2192 Legacy Apps \u2192 your Private App.",
51
51
  envVarBaseKey: "HUBSPOT_API_KEY",
52
52
  type: "text",
53
53
  secret: true,
@@ -237,15 +237,6 @@ var ConnectorPlugin = class _ConnectorPlugin {
237
237
  }
238
238
  };
239
239
 
240
- // ../connectors/src/auth-types.ts
241
- var AUTH_TYPES = {
242
- OAUTH: "oauth",
243
- API_KEY: "api-key",
244
- JWT: "jwt",
245
- SERVICE_ACCOUNT: "service-account",
246
- PAT: "pat"
247
- };
248
-
249
240
  // ../connectors/src/connectors/hubspot/setup.ts
250
241
  var hubspotOnboarding = new ConnectorOnboarding({
251
242
  dataOverviewInstructions: {
@@ -340,7 +331,7 @@ Use the search endpoint (POST /crm/v3/objects/{objectType}/search) for complex q
340
331
  var tools = { request: requestTool };
341
332
  var hubspotConnector = new ConnectorPlugin({
342
333
  slug: "hubspot",
343
- authType: AUTH_TYPES.PAT,
334
+ authType: null,
344
335
  name: "HubSpot",
345
336
  description: "Connect to HubSpot CRM for contacts, deals, companies, and marketing data using a Personal Access Key.",
346
337
  iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/5UcSkKkzhUMA4RsM45ynuo/43b967e36915ca0fc5d277684b204320/hubspot.svg",
@@ -0,0 +1,5 @@
1
+ import * as _squadbase_connectors_sdk from '@squadbase/connectors/sdk';
2
+
3
+ declare const connection: (connectionId: string) => _squadbase_connectors_sdk.StripeApiKeyConnectorSdk;
4
+
5
+ export { connection };
@@ -0,0 +1,526 @@
1
+ // ../connectors/src/parameter-definition.ts
2
+ var ParameterDefinition = class {
3
+ slug;
4
+ name;
5
+ description;
6
+ envVarBaseKey;
7
+ type;
8
+ secret;
9
+ required;
10
+ constructor(config) {
11
+ this.slug = config.slug;
12
+ this.name = config.name;
13
+ this.description = config.description;
14
+ this.envVarBaseKey = config.envVarBaseKey;
15
+ this.type = config.type;
16
+ this.secret = config.secret;
17
+ this.required = config.required;
18
+ }
19
+ /**
20
+ * Get the parameter value from a ConnectorConnectionObject.
21
+ */
22
+ getValue(connection2) {
23
+ const param = connection2.parameters.find(
24
+ (p) => p.parameterSlug === this.slug
25
+ );
26
+ if (!param || param.value == null) {
27
+ throw new Error(
28
+ `Parameter "${this.slug}" not found or has no value in connection "${connection2.id}"`
29
+ );
30
+ }
31
+ return param.value;
32
+ }
33
+ /**
34
+ * Try to get the parameter value. Returns undefined if not found (for optional params).
35
+ */
36
+ tryGetValue(connection2) {
37
+ const param = connection2.parameters.find(
38
+ (p) => p.parameterSlug === this.slug
39
+ );
40
+ if (!param || param.value == null) return void 0;
41
+ return param.value;
42
+ }
43
+ };
44
+
45
+ // ../connectors/src/connectors/stripe-api-key/parameters.ts
46
+ var parameters = {
47
+ apiKey: new ParameterDefinition({
48
+ slug: "api-key",
49
+ name: "Stripe API Key",
50
+ description: "Your Stripe Secret API Key (sk_live_... / sk_test_...) or Restricted API Key (rk_live_... / rk_test_...).",
51
+ envVarBaseKey: "STRIPE_API_KEY",
52
+ type: "text",
53
+ secret: true,
54
+ required: true
55
+ })
56
+ };
57
+
58
+ // ../connectors/src/connectors/stripe-api-key/sdk/index.ts
59
+ var BASE_URL = "https://api.stripe.com";
60
+ function createClient(params) {
61
+ const apiKey = params[parameters.apiKey.slug];
62
+ if (!apiKey) {
63
+ throw new Error(
64
+ `stripe-api-key: missing required parameter: ${parameters.apiKey.slug}`
65
+ );
66
+ }
67
+ return {
68
+ request(path2, init) {
69
+ const url = `${BASE_URL}${path2.startsWith("/") ? "" : "/"}${path2}`;
70
+ const headers = new Headers(init?.headers);
71
+ headers.set("Authorization", `Bearer ${apiKey}`);
72
+ return fetch(url, { ...init, headers });
73
+ }
74
+ };
75
+ }
76
+
77
+ // ../connectors/src/connector-onboarding.ts
78
+ var ConnectorOnboarding = class {
79
+ /** Phase 1: Connection setup instructions (optional — some connectors don't need this) */
80
+ connectionSetupInstructions;
81
+ /** Phase 2: Data overview instructions */
82
+ dataOverviewInstructions;
83
+ constructor(config) {
84
+ this.connectionSetupInstructions = config.connectionSetupInstructions;
85
+ this.dataOverviewInstructions = config.dataOverviewInstructions;
86
+ }
87
+ getConnectionSetupPrompt(language) {
88
+ return this.connectionSetupInstructions?.[language] ?? null;
89
+ }
90
+ getDataOverviewInstructions(language) {
91
+ return this.dataOverviewInstructions[language];
92
+ }
93
+ };
94
+
95
+ // ../connectors/src/connector-tool.ts
96
+ var ConnectorTool = class {
97
+ name;
98
+ description;
99
+ inputSchema;
100
+ outputSchema;
101
+ _execute;
102
+ constructor(config) {
103
+ this.name = config.name;
104
+ this.description = config.description;
105
+ this.inputSchema = config.inputSchema;
106
+ this.outputSchema = config.outputSchema;
107
+ this._execute = config.execute;
108
+ }
109
+ createTool(connections, config) {
110
+ return {
111
+ description: this.description,
112
+ inputSchema: this.inputSchema,
113
+ outputSchema: this.outputSchema,
114
+ execute: (input) => this._execute(input, connections, config)
115
+ };
116
+ }
117
+ };
118
+
119
+ // ../connectors/src/connector-plugin.ts
120
+ var ConnectorPlugin = class _ConnectorPlugin {
121
+ slug;
122
+ authType;
123
+ name;
124
+ description;
125
+ iconUrl;
126
+ parameters;
127
+ releaseFlag;
128
+ proxyPolicy;
129
+ experimentalAttributes;
130
+ onboarding;
131
+ systemPrompt;
132
+ tools;
133
+ query;
134
+ checkConnection;
135
+ constructor(config) {
136
+ this.slug = config.slug;
137
+ this.authType = config.authType;
138
+ this.name = config.name;
139
+ this.description = config.description;
140
+ this.iconUrl = config.iconUrl;
141
+ this.parameters = config.parameters;
142
+ this.releaseFlag = config.releaseFlag;
143
+ this.proxyPolicy = config.proxyPolicy;
144
+ this.experimentalAttributes = config.experimentalAttributes;
145
+ this.onboarding = config.onboarding;
146
+ this.systemPrompt = config.systemPrompt;
147
+ this.tools = config.tools;
148
+ this.query = config.query;
149
+ this.checkConnection = config.checkConnection;
150
+ }
151
+ get connectorKey() {
152
+ return _ConnectorPlugin.deriveKey(this.slug, this.authType);
153
+ }
154
+ /**
155
+ * Create tools for connections that belong to this connector.
156
+ * Filters connections by connectorKey internally.
157
+ * Returns tools keyed as `${connectorKey}_${toolName}`.
158
+ */
159
+ createTools(connections, config) {
160
+ const myConnections = connections.filter(
161
+ (c) => _ConnectorPlugin.deriveKey(c.connector.slug, c.connector.authType) === this.connectorKey
162
+ );
163
+ const result = {};
164
+ for (const t of Object.values(this.tools)) {
165
+ result[`${this.connectorKey}_${t.name}`] = t.createTool(
166
+ myConnections,
167
+ config
168
+ );
169
+ }
170
+ return result;
171
+ }
172
+ static deriveKey(slug, authType) {
173
+ return authType ? `${slug}-${authType}` : slug;
174
+ }
175
+ };
176
+
177
+ // ../connectors/src/auth-types.ts
178
+ var AUTH_TYPES = {
179
+ OAUTH: "oauth",
180
+ API_KEY: "api-key",
181
+ JWT: "jwt",
182
+ SERVICE_ACCOUNT: "service-account",
183
+ PAT: "pat"
184
+ };
185
+
186
+ // ../connectors/src/connectors/stripe-api-key/tools/request.ts
187
+ import { z } from "zod";
188
+ var BASE_URL2 = "https://api.stripe.com";
189
+ var REQUEST_TIMEOUT_MS = 6e4;
190
+ var inputSchema = z.object({
191
+ toolUseIntent: z.string().optional().describe(
192
+ "Brief description of what you intend to accomplish with this tool call"
193
+ ),
194
+ connectionId: z.string().describe("ID of the Stripe API Key connection to use"),
195
+ method: z.enum(["GET", "POST", "DELETE"]).describe(
196
+ "HTTP method. GET for reading resources, POST for creating or updating, DELETE for removing."
197
+ ),
198
+ path: z.string().describe(
199
+ "API path appended to https://api.stripe.com (e.g., '/v1/charges', '/v1/customers', '/v1/invoices')"
200
+ ),
201
+ queryParams: z.record(z.string(), z.string()).optional().describe("Query parameters to append to the URL"),
202
+ body: z.record(z.string(), z.unknown()).optional().describe(
203
+ "Request body for POST requests. Stripe uses form-encoded bodies \u2014 pass a flat key-value object and it will be encoded automatically."
204
+ )
205
+ });
206
+ var outputSchema = z.discriminatedUnion("success", [
207
+ z.object({
208
+ success: z.literal(true),
209
+ status: z.number(),
210
+ data: z.record(z.string(), z.unknown())
211
+ }),
212
+ z.object({
213
+ success: z.literal(false),
214
+ error: z.string()
215
+ })
216
+ ]);
217
+ var requestTool = new ConnectorTool({
218
+ name: "request",
219
+ description: `Send authenticated requests to the Stripe API.
220
+ Authentication is handled automatically using the configured API Key (Bearer token).
221
+ Use this tool for all Stripe API interactions: querying charges, customers, invoices, subscriptions, products, prices, payment intents, balances, and more.`,
222
+ inputSchema,
223
+ outputSchema,
224
+ async execute({ connectionId, method, path: path2, queryParams, body }, connections) {
225
+ const connection2 = connections.find((c) => c.id === connectionId);
226
+ if (!connection2) {
227
+ return {
228
+ success: false,
229
+ error: `Connection ${connectionId} not found`
230
+ };
231
+ }
232
+ console.log(
233
+ `[connector-request] stripe-api-key/${connection2.name}: ${method} ${path2}`
234
+ );
235
+ try {
236
+ const apiKey = parameters.apiKey.getValue(connection2);
237
+ let url = `${BASE_URL2}${path2.startsWith("/") ? "" : "/"}${path2}`;
238
+ if (queryParams) {
239
+ const searchParams = new URLSearchParams(queryParams);
240
+ url += `?${searchParams.toString()}`;
241
+ }
242
+ const controller = new AbortController();
243
+ const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
244
+ try {
245
+ const headers = {
246
+ Authorization: `Bearer ${apiKey}`
247
+ };
248
+ let requestBody;
249
+ if (body) {
250
+ headers["Content-Type"] = "application/x-www-form-urlencoded";
251
+ requestBody = new URLSearchParams(
252
+ Object.entries(body).map(([k, v]) => [k, String(v)])
253
+ ).toString();
254
+ }
255
+ const response = await fetch(url, {
256
+ method,
257
+ headers,
258
+ body: requestBody,
259
+ signal: controller.signal
260
+ });
261
+ const data = await response.json();
262
+ if (!response.ok) {
263
+ const errorObj = data?.error;
264
+ const errorMessage = typeof errorObj === "object" && errorObj !== null && "message" in errorObj ? String(errorObj.message) : typeof data?.message === "string" ? data.message : `HTTP ${response.status} ${response.statusText}`;
265
+ return { success: false, error: errorMessage };
266
+ }
267
+ return { success: true, status: response.status, data };
268
+ } finally {
269
+ clearTimeout(timeout);
270
+ }
271
+ } catch (err) {
272
+ const msg = err instanceof Error ? err.message : String(err);
273
+ return { success: false, error: msg };
274
+ }
275
+ }
276
+ });
277
+
278
+ // ../connectors/src/connectors/stripe-api-key/setup.ts
279
+ var requestToolName = `stripe-api-key_${requestTool.name}`;
280
+ var stripeApiKeyOnboarding = new ConnectorOnboarding({
281
+ connectionSetupInstructions: {
282
+ ja: `\u4EE5\u4E0B\u306E\u624B\u9806\u3067Stripe\u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306E\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002
283
+
284
+ 1. \`${requestToolName}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u3001\u30A2\u30AB\u30A6\u30F3\u30C8\u6B8B\u9AD8\u3092\u53D6\u5F97\u3059\u308B:
285
+ - \`method\`: \`"GET"\`
286
+ - \`path\`: \`"/v1/balance"\`
287
+ 2. \u30A8\u30E9\u30FC\u304C\u8FD4\u3055\u308C\u305F\u5834\u5408\u3001\u30E6\u30FC\u30B6\u30FC\u306BAPI\u30AD\u30FC\u306E\u8A2D\u5B9A\u3092\u78BA\u8A8D\u3059\u308B\u3088\u3046\u4F1D\u3048\u308B\uFF08Secret API Key\u307E\u305F\u306FRestricted API Key\u304C\u6B63\u3057\u304F\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u308B\u304B\uFF09
288
+ 3. \`updateConnectionContext\` \u3092\u547C\u3073\u51FA\u3059:
289
+ - \`note\`: \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u5185\u5BB9\u306E\u7C21\u5358\u306A\u8AAC\u660E
290
+
291
+ #### \u5236\u7D04
292
+ - **\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u4E2D\u306B\u6C7A\u6E08\u30C7\u30FC\u30BF\u3092\u8AAD\u307F\u53D6\u3089\u306A\u3044\u3053\u3068**\u3002\u5B9F\u884C\u3057\u3066\u3088\u3044\u306E\u306F\u4E0A\u8A18\u624B\u9806\u3067\u6307\u5B9A\u3055\u308C\u305F\u30E1\u30BF\u30C7\u30FC\u30BF\u53D6\u5F97\u30EA\u30AF\u30A8\u30B9\u30C8\u306E\u307F
293
+ - \u30C4\u30FC\u30EB\u9593\u306F1\u6587\u3060\u3051\u66F8\u3044\u3066\u5373\u6B21\u306E\u30C4\u30FC\u30EB\u547C\u3073\u51FA\u3057\u3002\u4E0D\u8981\u306A\u8AAC\u660E\u306F\u7701\u7565\u3057\u3001\u52B9\u7387\u7684\u306B\u9032\u3081\u308B`,
294
+ en: `Follow these steps to set up the Stripe connection.
295
+
296
+ 1. Call \`${requestToolName}\` to fetch account balance:
297
+ - \`method\`: \`"GET"\`
298
+ - \`path\`: \`"/v1/balance"\`
299
+ 2. If an error is returned, ask the user to check the API key settings (verify that the Secret API Key or Restricted API Key is configured correctly)
300
+ 3. Call \`updateConnectionContext\`:
301
+ - \`note\`: Brief description of the setup
302
+
303
+ #### Constraints
304
+ - **Do NOT read payment data during setup**. Only the metadata request specified in the steps above is allowed
305
+ - Write only 1 sentence between tool calls, then immediately call the next tool. Skip unnecessary explanations and proceed efficiently`
306
+ },
307
+ dataOverviewInstructions: {
308
+ en: `1. Call ${requestToolName} with GET /v1/customers?limit=5 to explore customers structure
309
+ 2. Call ${requestToolName} with GET /v1/charges?limit=5 to explore charges structure
310
+ 3. Explore other endpoints (invoices, subscriptions, products) as needed`,
311
+ ja: `1. ${requestToolName} \u3067 GET /v1/customers?limit=5 \u3092\u547C\u3073\u51FA\u3057\u3001\u9867\u5BA2\u306E\u69CB\u9020\u3092\u78BA\u8A8D
312
+ 2. ${requestToolName} \u3067 GET /v1/charges?limit=5 \u3092\u547C\u3073\u51FA\u3057\u3001\u8AB2\u91D1\u306E\u69CB\u9020\u3092\u78BA\u8A8D
313
+ 3. \u5FC5\u8981\u306B\u5FDC\u3058\u3066\u4ED6\u306E\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8\uFF08\u8ACB\u6C42\u66F8\u3001\u30B5\u30D6\u30B9\u30AF\u30EA\u30D7\u30B7\u30E7\u30F3\u3001\u5546\u54C1\uFF09\u3092\u63A2\u7D22`
314
+ }
315
+ });
316
+
317
+ // ../connectors/src/connectors/stripe-api-key/index.ts
318
+ var tools = { request: requestTool };
319
+ var stripeApiKeyConnector = new ConnectorPlugin({
320
+ slug: "stripe",
321
+ authType: AUTH_TYPES.API_KEY,
322
+ name: "Stripe (API Key)",
323
+ description: "Connect to Stripe for payment, customer, and subscription data using a Secret API Key or Restricted API Key.",
324
+ iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/2QNK0u2doqp41uL0POS4Ks/7a92367e2388ec77c7f4ada143606f9a/stripe.jpeg",
325
+ parameters,
326
+ releaseFlag: { dev1: true, dev2: false, prod: false },
327
+ onboarding: stripeApiKeyOnboarding,
328
+ systemPrompt: {
329
+ en: `### Tools
330
+
331
+ - \`stripe-api-key_request\`: The only way to call the Stripe API. Use it to query charges, customers, invoices, subscriptions, products, prices, payment intents, balances, and more. Authentication is configured automatically using the API Key (Bearer token). Stripe uses cursor-based pagination with \`starting_after\` and \`has_more\`.
332
+
333
+ ### Stripe API Reference
334
+
335
+ #### Available Endpoints
336
+ - GET \`/v1/charges\` \u2014 List charges
337
+ - GET \`/v1/charges/{chargeId}\` \u2014 Get a charge
338
+ - GET \`/v1/customers\` \u2014 List customers
339
+ - GET \`/v1/customers/{customerId}\` \u2014 Get a customer
340
+ - GET \`/v1/invoices\` \u2014 List invoices
341
+ - GET \`/v1/invoices/{invoiceId}\` \u2014 Get an invoice
342
+ - GET \`/v1/subscriptions\` \u2014 List subscriptions
343
+ - GET \`/v1/subscriptions/{subscriptionId}\` \u2014 Get a subscription
344
+ - GET \`/v1/products\` \u2014 List products
345
+ - GET \`/v1/prices\` \u2014 List prices
346
+ - GET \`/v1/payment_intents\` \u2014 List payment intents
347
+ - GET \`/v1/balance\` \u2014 Get account balance
348
+ - GET \`/v1/balance_transactions\` \u2014 List balance transactions
349
+
350
+ ### Query Parameters
351
+ - \`limit\` \u2014 Number of results per page (max 100, default 10)
352
+ - \`starting_after\` \u2014 Pagination cursor (object ID)
353
+ - \`ending_before\` \u2014 Reverse pagination cursor
354
+ - \`created[gte]\`, \`created[lte]\` \u2014 Filter by creation date (Unix timestamp)
355
+ - \`status\` \u2014 Filter by status (varies by resource)
356
+
357
+ ### Tips
358
+ - Stripe uses cursor-based pagination with \`starting_after\` and \`has_more\`
359
+ - All timestamps are Unix timestamps in seconds
360
+ - Use \`expand[]\` query parameter to include related objects inline
361
+ - List responses have \`data\` array and \`has_more\` boolean
362
+ - POST request bodies are form-encoded (pass a flat key-value object)
363
+ - If using a Restricted API Key, some endpoints may return 403 depending on the key's permissions
364
+
365
+ ### Business Logic
366
+
367
+ The business logic type for this connector is "typescript". Write handler code using the connector SDK shown below. Do NOT access credentials directly from environment variables.
368
+
369
+ #### Example
370
+
371
+ \`\`\`ts
372
+ import { connection } from "@squadbase/vite-server/connectors/stripe-api-key";
373
+
374
+ const stripe = connection("<connectionId>");
375
+
376
+ // Authenticated fetch (returns standard Response)
377
+ const res = await stripe.request("/v1/customers?limit=10");
378
+ const data = await res.json();
379
+ \`\`\``,
380
+ ja: `### \u30C4\u30FC\u30EB
381
+
382
+ - \`stripe-api-key_request\`: Stripe API\u3092\u547C\u3073\u51FA\u3059\u552F\u4E00\u306E\u624B\u6BB5\u3067\u3059\u3002\u8ACB\u6C42\u3001\u9867\u5BA2\u3001\u8ACB\u6C42\u66F8\u3001\u30B5\u30D6\u30B9\u30AF\u30EA\u30D7\u30B7\u30E7\u30F3\u3001\u5546\u54C1\u3001\u4FA1\u683C\u3001\u652F\u6255\u3044\u30A4\u30F3\u30C6\u30F3\u30C8\u3001\u6B8B\u9AD8\u306A\u3069\u306E\u30AF\u30A8\u30EA\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002API\u30AD\u30FC\uFF08Bearer\u30C8\u30FC\u30AF\u30F3\uFF09\u3067\u8A8D\u8A3C\u306F\u81EA\u52D5\u8A2D\u5B9A\u3055\u308C\u307E\u3059\u3002Stripe\u306F \`starting_after\` \u3068 \`has_more\` \u306B\u3088\u308B\u30AB\u30FC\u30BD\u30EB\u30D9\u30FC\u30B9\u306E\u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3\u3092\u4F7F\u7528\u3057\u307E\u3059\u3002
383
+
384
+ ### Stripe API \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
385
+
386
+ #### \u5229\u7528\u53EF\u80FD\u306A\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8
387
+ - GET \`/v1/charges\` \u2014 \u8ACB\u6C42\u4E00\u89A7\u3092\u53D6\u5F97
388
+ - GET \`/v1/charges/{chargeId}\` \u2014 \u8ACB\u6C42\u3092\u53D6\u5F97
389
+ - GET \`/v1/customers\` \u2014 \u9867\u5BA2\u4E00\u89A7\u3092\u53D6\u5F97
390
+ - GET \`/v1/customers/{customerId}\` \u2014 \u9867\u5BA2\u3092\u53D6\u5F97
391
+ - GET \`/v1/invoices\` \u2014 \u8ACB\u6C42\u66F8\u4E00\u89A7\u3092\u53D6\u5F97
392
+ - GET \`/v1/invoices/{invoiceId}\` \u2014 \u8ACB\u6C42\u66F8\u3092\u53D6\u5F97
393
+ - GET \`/v1/subscriptions\` \u2014 \u30B5\u30D6\u30B9\u30AF\u30EA\u30D7\u30B7\u30E7\u30F3\u4E00\u89A7\u3092\u53D6\u5F97
394
+ - GET \`/v1/subscriptions/{subscriptionId}\` \u2014 \u30B5\u30D6\u30B9\u30AF\u30EA\u30D7\u30B7\u30E7\u30F3\u3092\u53D6\u5F97
395
+ - GET \`/v1/products\` \u2014 \u5546\u54C1\u4E00\u89A7\u3092\u53D6\u5F97
396
+ - GET \`/v1/prices\` \u2014 \u4FA1\u683C\u4E00\u89A7\u3092\u53D6\u5F97
397
+ - GET \`/v1/payment_intents\` \u2014 \u652F\u6255\u3044\u30A4\u30F3\u30C6\u30F3\u30C8\u4E00\u89A7\u3092\u53D6\u5F97
398
+ - GET \`/v1/balance\` \u2014 \u30A2\u30AB\u30A6\u30F3\u30C8\u6B8B\u9AD8\u3092\u53D6\u5F97
399
+ - GET \`/v1/balance_transactions\` \u2014 \u6B8B\u9AD8\u30C8\u30E9\u30F3\u30B6\u30AF\u30B7\u30E7\u30F3\u4E00\u89A7\u3092\u53D6\u5F97
400
+
401
+ ### \u30AF\u30A8\u30EA\u30D1\u30E9\u30E1\u30FC\u30BF
402
+ - \`limit\` \u2014 \u30DA\u30FC\u30B8\u3042\u305F\u308A\u306E\u7D50\u679C\u6570\uFF08\u6700\u5927100\u3001\u30C7\u30D5\u30A9\u30EB\u30C810\uFF09
403
+ - \`starting_after\` \u2014 \u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3\u30AB\u30FC\u30BD\u30EB\uFF08\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8ID\uFF09
404
+ - \`ending_before\` \u2014 \u9006\u65B9\u5411\u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3\u30AB\u30FC\u30BD\u30EB
405
+ - \`created[gte]\`, \`created[lte]\` \u2014 \u4F5C\u6210\u65E5\u3067\u30D5\u30A3\u30EB\u30BF\uFF08Unix\u30BF\u30A4\u30E0\u30B9\u30BF\u30F3\u30D7\uFF09
406
+ - \`status\` \u2014 \u30B9\u30C6\u30FC\u30BF\u30B9\u3067\u30D5\u30A3\u30EB\u30BF\uFF08\u30EA\u30BD\u30FC\u30B9\u306B\u3088\u308A\u7570\u306A\u308B\uFF09
407
+
408
+ ### \u30D2\u30F3\u30C8
409
+ - Stripe\u306F \`starting_after\` \u3068 \`has_more\` \u306B\u3088\u308B\u30AB\u30FC\u30BD\u30EB\u30D9\u30FC\u30B9\u306E\u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3\u3092\u4F7F\u7528\u3057\u307E\u3059
410
+ - \u3059\u3079\u3066\u306E\u30BF\u30A4\u30E0\u30B9\u30BF\u30F3\u30D7\u306F\u79D2\u5358\u4F4D\u306EUnix\u30BF\u30A4\u30E0\u30B9\u30BF\u30F3\u30D7\u3067\u3059
411
+ - \u95A2\u9023\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3092\u30A4\u30F3\u30E9\u30A4\u30F3\u3067\u542B\u3081\u308B\u306B\u306F \`expand[]\` \u30AF\u30A8\u30EA\u30D1\u30E9\u30E1\u30FC\u30BF\u3092\u4F7F\u7528\u3057\u307E\u3059
412
+ - \u4E00\u89A7\u30EC\u30B9\u30DD\u30F3\u30B9\u306B\u306F \`data\` \u914D\u5217\u3068 \`has_more\` \u30D6\u30FC\u30EB\u5024\u304C\u542B\u307E\u308C\u307E\u3059
413
+ - POST\u30EA\u30AF\u30A8\u30B9\u30C8\u306E\u30DC\u30C7\u30A3\u306F\u30D5\u30A9\u30FC\u30E0\u30A8\u30F3\u30B3\u30FC\u30C9\u3067\u3059\uFF08\u30D5\u30E9\u30C3\u30C8\u306A\u30AD\u30FC\u30FB\u30D0\u30EA\u30E5\u30FC\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3092\u6E21\u3057\u3066\u304F\u3060\u3055\u3044\uFF09
414
+ - Restricted API Key\u3092\u4F7F\u7528\u3057\u3066\u3044\u308B\u5834\u5408\u3001\u30AD\u30FC\u306E\u6A29\u9650\u306B\u3088\u3063\u3066\u306F\u4E00\u90E8\u306E\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8\u3067403\u304C\u8FD4\u308B\u3053\u3068\u304C\u3042\u308A\u307E\u3059
415
+
416
+ ### Business Logic
417
+
418
+ \u3053\u306E\u30B3\u30CD\u30AF\u30BF\u306E\u30D3\u30B8\u30CD\u30B9\u30ED\u30B8\u30C3\u30AF\u30BF\u30A4\u30D7\u306F "typescript" \u3067\u3059\u3002\u4EE5\u4E0B\u306B\u793A\u3059\u30B3\u30CD\u30AF\u30BFSDK\u3092\u4F7F\u7528\u3057\u3066\u30CF\u30F3\u30C9\u30E9\u30B3\u30FC\u30C9\u3092\u8A18\u8FF0\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u74B0\u5883\u5909\u6570\u304B\u3089\u76F4\u63A5\u8A8D\u8A3C\u60C5\u5831\u306B\u30A2\u30AF\u30BB\u30B9\u3057\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002
419
+
420
+ #### Example
421
+
422
+ \`\`\`ts
423
+ import { connection } from "@squadbase/vite-server/connectors/stripe-api-key";
424
+
425
+ const stripe = connection("<connectionId>");
426
+
427
+ // Authenticated fetch (returns standard Response)
428
+ const res = await stripe.request("/v1/customers?limit=10");
429
+ const data = await res.json();
430
+ \`\`\``
431
+ },
432
+ tools,
433
+ async checkConnection(params) {
434
+ try {
435
+ const apiKey = params["api-key"];
436
+ if (!apiKey) {
437
+ return {
438
+ success: false,
439
+ error: "API Key is not configured"
440
+ };
441
+ }
442
+ const res = await fetch("https://api.stripe.com/v1/balance", {
443
+ method: "GET",
444
+ headers: { Authorization: `Bearer ${apiKey}` }
445
+ });
446
+ if (!res.ok) {
447
+ const errorText = await res.text().catch(() => res.statusText);
448
+ return {
449
+ success: false,
450
+ error: `Stripe API failed: HTTP ${res.status} ${errorText}`
451
+ };
452
+ }
453
+ return { success: true };
454
+ } catch (error) {
455
+ return {
456
+ success: false,
457
+ error: error instanceof Error ? error.message : String(error)
458
+ };
459
+ }
460
+ }
461
+ });
462
+
463
+ // src/connectors/create-connector-sdk.ts
464
+ import { readFileSync } from "fs";
465
+ import path from "path";
466
+
467
+ // src/connector-client/env.ts
468
+ function resolveEnvVar(entry, key, connectionId) {
469
+ const envVarName = entry.envVars[key];
470
+ if (!envVarName) {
471
+ throw new Error(`Connection "${connectionId}" is missing envVars mapping for key "${key}"`);
472
+ }
473
+ const value = process.env[envVarName];
474
+ if (!value) {
475
+ throw new Error(`Environment variable "${envVarName}" (for connection "${connectionId}", key "${key}") is not set`);
476
+ }
477
+ return value;
478
+ }
479
+ function resolveEnvVarOptional(entry, key) {
480
+ const envVarName = entry.envVars[key];
481
+ if (!envVarName) return void 0;
482
+ return process.env[envVarName] || void 0;
483
+ }
484
+
485
+ // src/connectors/create-connector-sdk.ts
486
+ function loadConnectionsSync() {
487
+ const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
488
+ try {
489
+ const raw = readFileSync(filePath, "utf-8");
490
+ return JSON.parse(raw);
491
+ } catch {
492
+ return {};
493
+ }
494
+ }
495
+ function createConnectorSdk(plugin, createClient2) {
496
+ return (connectionId) => {
497
+ const connections = loadConnectionsSync();
498
+ const entry = connections[connectionId];
499
+ if (!entry) {
500
+ throw new Error(
501
+ `Connection "${connectionId}" not found in .squadbase/connections.json`
502
+ );
503
+ }
504
+ if (entry.connector.slug !== plugin.slug) {
505
+ throw new Error(
506
+ `Connection "${connectionId}" is not a ${plugin.slug} connection (got "${entry.connector.slug}")`
507
+ );
508
+ }
509
+ const params = {};
510
+ for (const param of Object.values(plugin.parameters)) {
511
+ if (param.required) {
512
+ params[param.slug] = resolveEnvVar(entry, param.slug, connectionId);
513
+ } else {
514
+ const val = resolveEnvVarOptional(entry, param.slug);
515
+ if (val !== void 0) params[param.slug] = val;
516
+ }
517
+ }
518
+ return createClient2(params);
519
+ };
520
+ }
521
+
522
+ // src/connectors/entries/stripe-api-key.ts
523
+ var connection = createConnectorSdk(stripeApiKeyConnector, createClient);
524
+ export {
525
+ connection
526
+ };