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

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.
@@ -412,7 +412,7 @@ var asanaConnector = new ConnectorPlugin({
412
412
  authType: null,
413
413
  name: "Asana",
414
414
  description: "Connect to Asana for project management, task tracking, and team collaboration data.",
415
- iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/6gCkEDWO6kSYSiCe0K2cY4/e7f89b90c0c0e7db72c3f8a9b92e5752/asana.svg",
415
+ iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/3eIdaoqzIIZs2Md0OoDJMf/2fa66e0841adb985da4d3120466f3ec4/asana-icon.png",
416
416
  parameters,
417
417
  releaseFlag: { dev1: true, dev2: false, prod: false },
418
418
  onboarding: asanaOnboarding,
@@ -390,7 +390,7 @@ var customerioConnector = new ConnectorPlugin({
390
390
  authType: null,
391
391
  name: "Customer.io",
392
392
  description: "Connect to Customer.io App API for reading customer data, managing campaigns, segments, and sending transactional messages.",
393
- iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/6VPGKA8I2MqzaBgULLj4WQ/a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4/customerio.svg",
393
+ iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/nngohabT7oHDIgQYAVBpz/6f6c7662ef4692eb9869e3e69dd57114/customerio.png",
394
394
  parameters,
395
395
  releaseFlag: { dev1: true, dev2: false, prod: false },
396
396
  onboarding: customerioOnboarding,
@@ -131,7 +131,7 @@ var geminiConnector = new ConnectorPlugin({
131
131
  authType: null,
132
132
  name: "Gemini",
133
133
  description: "Connect to Google Gemini for AI model inference, embeddings, and multimodal generation.",
134
- iconUrl: "https://www.gstatic.com/lamda/images/gemini_sparkle_v002_d4735304ff6292a690b6.svg",
134
+ iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/6K2qZQZEQq90YENfrXy5my/c83c0c3815af0a97d29ee70f37215f01/gemini.png",
135
135
  parameters,
136
136
  releaseFlag: { dev1: true, dev2: true, prod: true },
137
137
  systemPrompt: {
@@ -390,7 +390,7 @@ var gmailOauthConnector = new ConnectorPlugin({
390
390
  authType: AUTH_TYPES.OAUTH,
391
391
  name: "Gmail (OAuth)",
392
392
  description: "Connect to Gmail for email data access using OAuth. Read-only access to messages, threads, and labels.",
393
- iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/5rPCSZnB5SHqb4fTXnLXHH/7ba8ca52a3c36c6a18ac7a2f92ac4c5b/gmail.svg",
393
+ iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/4V3rfaSc1ksFIt2eHBNIwJ/7f3be41a154a6d96dcf229ed0e5858c9/Gmail_icon__2020_.svg.png",
394
394
  parameters,
395
395
  releaseFlag: { dev1: true, dev2: false, prod: false },
396
396
  onboarding: gmailOnboarding,
@@ -290,7 +290,7 @@ var intercomOauthConnector = new ConnectorPlugin({
290
290
  authType: AUTH_TYPES.OAUTH,
291
291
  name: "Intercom (OAuth)",
292
292
  description: "Connect to Intercom for contacts, conversations, companies, and customer engagement data using OAuth.",
293
- iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/1vKzXhRhJvDWGlAXdqBzMM/c0a58d645fba28a7ff6e2e0f84a098e9/intercom.svg",
293
+ iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/sb2cRMGClpId0LKiSqsok/ae90a0849f21ffe3faf73e04a5676b45/intercom.svg",
294
294
  parameters,
295
295
  releaseFlag: { dev1: true, dev2: false, prod: false },
296
296
  onboarding: intercomOauthOnboarding,
@@ -360,7 +360,7 @@ var intercomConnector = new ConnectorPlugin({
360
360
  authType: null,
361
361
  name: "Intercom",
362
362
  description: "Connect to Intercom for contacts, conversations, companies, and customer engagement data using an Access Token.",
363
- iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/1vKzXhRhJvDWGlAXdqBzMM/c0a58d645fba28a7ff6e2e0f84a098e9/intercom.svg",
363
+ iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/sb2cRMGClpId0LKiSqsok/ae90a0849f21ffe3faf73e04a5676b45/intercom.svg",
364
364
  parameters,
365
365
  releaseFlag: { dev1: true, dev2: false, prod: false },
366
366
  onboarding: intercomOnboarding,
@@ -47,7 +47,7 @@ var parameters = {
47
47
  instanceUrl: new ParameterDefinition({
48
48
  slug: "instance-url",
49
49
  name: "Jira Instance URL",
50
- description: "The base URL of your Jira Cloud instance (e.g., https://your-domain.atlassian.net).",
50
+ description: "Your Jira Cloud site URL \u2014 just the base address, without any trailing path. For example: https://your-domain.atlassian.net",
51
51
  envVarBaseKey: "JIRA_INSTANCE_URL",
52
52
  type: "text",
53
53
  secret: false,
@@ -64,8 +64,8 @@ var parameters = {
64
64
  }),
65
65
  apiToken: new ParameterDefinition({
66
66
  slug: "api-token",
67
- name: "Jira API Token",
68
- description: "API token for authentication. Generate from Atlassian Account Settings > Security > API tokens (https://id.atlassian.com/manage/api-tokens).",
67
+ name: "Atlassian API Token",
68
+ description: "Your Atlassian account API token (used for Jira authentication). You can create one at: Atlassian Account Settings > Security > API tokens (https://id.atlassian.com/manage/api-tokens).",
69
69
  envVarBaseKey: "JIRA_API_TOKEN",
70
70
  type: "text",
71
71
  secret: true,
@@ -239,7 +239,7 @@ var outputSchema = z.discriminatedUnion("success", [
239
239
  z.object({
240
240
  success: z.literal(true),
241
241
  status: z.number(),
242
- data: z.record(z.string(), z.unknown())
242
+ data: z.union([z.record(z.string(), z.unknown()), z.array(z.unknown())])
243
243
  }),
244
244
  z.object({
245
245
  success: z.literal(false),
@@ -287,7 +287,8 @@ The base URL and authentication credentials are configured per connection \u2014
287
287
  }
288
288
  const data = await response.json();
289
289
  if (!response.ok) {
290
- const errorMessages = Array.isArray(data?.errorMessages) ? data.errorMessages.join("; ") : data?.message ?? `HTTP ${response.status} ${response.statusText}`;
290
+ const errData = data;
291
+ const errorMessages = Array.isArray(errData?.errorMessages) ? errData.errorMessages.join("; ") : errData?.message ?? `HTTP ${response.status} ${response.statusText}`;
291
292
  return { success: false, error: errorMessages };
292
293
  }
293
294
  return { success: true, status: response.status, data };
@@ -308,7 +309,7 @@ var jiraConnector = new ConnectorPlugin({
308
309
  authType: AUTH_TYPES.API_KEY,
309
310
  name: "Jira (API Key)",
310
311
  description: "Connect to Jira Cloud for issue tracking, project management, and workflow data retrieval using API token authentication.",
311
- iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/3IsIFg5im7VjMxGh1K1j6P/a3be559bdca30e5497dd55a2f4ee66f0/jira.png",
312
+ iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/5zt4yjb36szSPPkCECYlPL/bc3e7223dc84fb16a1cce53a80f5afcc/jira.png",
312
313
  parameters,
313
314
  releaseFlag: { dev1: true, dev2: false, prod: false },
314
315
  onboarding: jiraOnboarding,
@@ -479,7 +479,7 @@ var linkedinAdsOauthConnector = new ConnectorPlugin({
479
479
  authType: AUTH_TYPES.OAUTH,
480
480
  name: "LinkedIn Ads (OAuth)",
481
481
  description: "Connect to LinkedIn Ads (Marketing API) for advertising campaign data and reporting using OAuth.",
482
- iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/1iC2kfONR1oFOqR9mISS08/2e5baeab83fe51067044d9df2d17df02/linkedin.svg",
482
+ iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/3x7xd9pVJkRFY7ADIg4ycq/b94720e34cb081e9ae45dfde799a59cd/LinkedIn_icon.svg.png",
483
483
  parameters,
484
484
  releaseFlag: { dev1: true, dev2: false, prod: false },
485
485
  onboarding: linkedinAdsOauthOnboarding,
@@ -464,7 +464,7 @@ var linkedinAdsConnector = new ConnectorPlugin({
464
464
  authType: null,
465
465
  name: "LinkedIn Ads",
466
466
  description: "Connect to LinkedIn Ads (Marketing API) for advertising campaign data and reporting using an access token.",
467
- iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/1iC2kfONR1oFOqR9mISS08/2e5baeab83fe51067044d9df2d17df02/linkedin.svg",
467
+ iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/3x7xd9pVJkRFY7ADIg4ycq/b94720e34cb081e9ae45dfde799a59cd/LinkedIn_icon.svg.png",
468
468
  parameters,
469
469
  releaseFlag: { dev1: true, dev2: false, prod: false },
470
470
  onboarding: linkedinAdsOnboarding,
@@ -317,7 +317,7 @@ var mailchimpOauthConnector = new ConnectorPlugin({
317
317
  authType: AUTH_TYPES.OAUTH,
318
318
  name: "Mailchimp (OAuth)",
319
319
  description: "Connect to Mailchimp for email marketing, audiences, campaigns, and analytics using OAuth.",
320
- iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/5JXJ9GsMCDsJtGhO2EgTDj/a3a62e7a4e4e4e4e4e4e4e4e4e4e4e4e/mailchimp.svg",
320
+ iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/19Rac6B8eGiLpQb4lKMbG3/10f567f85572aeb16f2ee6aaa6602987/mailchimp.png",
321
321
  parameters,
322
322
  releaseFlag: { dev1: true, dev2: false, prod: false },
323
323
  onboarding: mailchimpOauthOnboarding,
@@ -377,7 +377,7 @@ var mailchimpConnector = new ConnectorPlugin({
377
377
  authType: null,
378
378
  name: "Mailchimp",
379
379
  description: "Connect to Mailchimp for email marketing, audiences, campaigns, and analytics.",
380
- iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/5JXJ9GsMCDsJtGhO2EgTDj/a3a62e7a4e4e4e4e4e4e4e4e4e4e4e4e/mailchimp.svg",
380
+ iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/19Rac6B8eGiLpQb4lKMbG3/10f567f85572aeb16f2ee6aaa6602987/mailchimp.png",
381
381
  parameters,
382
382
  releaseFlag: { dev1: true, dev2: false, prod: false },
383
383
  onboarding: mailchimpOnboarding,
@@ -0,0 +1,5 @@
1
+ import * as _squadbase_connectors_sdk from '@squadbase/connectors/sdk';
2
+
3
+ declare const connection: (connectionId: string) => _squadbase_connectors_sdk.NotionOauthConnectorSdk;
4
+
5
+ export { connection };
@@ -0,0 +1,493 @@
1
+ // ../connectors/src/connectors/notion-oauth/sdk/index.ts
2
+ var BASE_URL = "https://api.notion.com/v1";
3
+ var NOTION_VERSION = "2022-06-28";
4
+ function createClient(_params, fetchFn = fetch) {
5
+ function request(path2, init) {
6
+ const url = `${BASE_URL}${path2.startsWith("/") ? "" : "/"}${path2}`;
7
+ const headers = new Headers(init?.headers);
8
+ headers.set("Notion-Version", NOTION_VERSION);
9
+ headers.set("Content-Type", "application/json");
10
+ return fetchFn(url, { ...init, headers });
11
+ }
12
+ return { request };
13
+ }
14
+
15
+ // ../connectors/src/connector-onboarding.ts
16
+ var ConnectorOnboarding = class {
17
+ /** Phase 1: Connection setup instructions (optional — some connectors don't need this) */
18
+ connectionSetupInstructions;
19
+ /** Phase 2: Data overview instructions */
20
+ dataOverviewInstructions;
21
+ constructor(config) {
22
+ this.connectionSetupInstructions = config.connectionSetupInstructions;
23
+ this.dataOverviewInstructions = config.dataOverviewInstructions;
24
+ }
25
+ getConnectionSetupPrompt(language) {
26
+ return this.connectionSetupInstructions?.[language] ?? null;
27
+ }
28
+ getDataOverviewInstructions(language) {
29
+ return this.dataOverviewInstructions[language];
30
+ }
31
+ };
32
+
33
+ // ../connectors/src/connector-tool.ts
34
+ var ConnectorTool = class {
35
+ name;
36
+ description;
37
+ inputSchema;
38
+ outputSchema;
39
+ _execute;
40
+ constructor(config) {
41
+ this.name = config.name;
42
+ this.description = config.description;
43
+ this.inputSchema = config.inputSchema;
44
+ this.outputSchema = config.outputSchema;
45
+ this._execute = config.execute;
46
+ }
47
+ createTool(connections, config) {
48
+ return {
49
+ description: this.description,
50
+ inputSchema: this.inputSchema,
51
+ outputSchema: this.outputSchema,
52
+ execute: (input) => this._execute(input, connections, config)
53
+ };
54
+ }
55
+ };
56
+
57
+ // ../connectors/src/connector-plugin.ts
58
+ var ConnectorPlugin = class _ConnectorPlugin {
59
+ slug;
60
+ authType;
61
+ name;
62
+ description;
63
+ iconUrl;
64
+ parameters;
65
+ releaseFlag;
66
+ proxyPolicy;
67
+ experimentalAttributes;
68
+ onboarding;
69
+ systemPrompt;
70
+ tools;
71
+ query;
72
+ checkConnection;
73
+ constructor(config) {
74
+ this.slug = config.slug;
75
+ this.authType = config.authType;
76
+ this.name = config.name;
77
+ this.description = config.description;
78
+ this.iconUrl = config.iconUrl;
79
+ this.parameters = config.parameters;
80
+ this.releaseFlag = config.releaseFlag;
81
+ this.proxyPolicy = config.proxyPolicy;
82
+ this.experimentalAttributes = config.experimentalAttributes;
83
+ this.onboarding = config.onboarding;
84
+ this.systemPrompt = config.systemPrompt;
85
+ this.tools = config.tools;
86
+ this.query = config.query;
87
+ this.checkConnection = config.checkConnection;
88
+ }
89
+ get connectorKey() {
90
+ return _ConnectorPlugin.deriveKey(this.slug, this.authType);
91
+ }
92
+ /**
93
+ * Create tools for connections that belong to this connector.
94
+ * Filters connections by connectorKey internally.
95
+ * Returns tools keyed as `${connectorKey}_${toolName}`.
96
+ */
97
+ createTools(connections, config) {
98
+ const myConnections = connections.filter(
99
+ (c) => _ConnectorPlugin.deriveKey(c.connector.slug, c.connector.authType) === this.connectorKey
100
+ );
101
+ const result = {};
102
+ for (const t of Object.values(this.tools)) {
103
+ result[`${this.connectorKey}_${t.name}`] = t.createTool(
104
+ myConnections,
105
+ config
106
+ );
107
+ }
108
+ return result;
109
+ }
110
+ static deriveKey(slug, authType) {
111
+ return authType ? `${slug}-${authType}` : slug;
112
+ }
113
+ };
114
+
115
+ // ../connectors/src/auth-types.ts
116
+ var AUTH_TYPES = {
117
+ OAUTH: "oauth",
118
+ API_KEY: "api-key",
119
+ JWT: "jwt",
120
+ SERVICE_ACCOUNT: "service-account",
121
+ PAT: "pat"
122
+ };
123
+
124
+ // ../connectors/src/connectors/notion-oauth/tools/request.ts
125
+ import { z } from "zod";
126
+ var BASE_URL2 = "https://api.notion.com/v1";
127
+ var NOTION_VERSION2 = "2022-06-28";
128
+ var REQUEST_TIMEOUT_MS = 6e4;
129
+ var cachedToken = null;
130
+ async function getProxyToken(config) {
131
+ if (cachedToken && cachedToken.expiresAt > Date.now() + 6e4) {
132
+ return cachedToken.token;
133
+ }
134
+ const url = `${config.appApiBaseUrl}/v0/database/${config.projectId}/environment/${config.environmentId}/oauth-request-proxy-token`;
135
+ const res = await fetch(url, {
136
+ method: "POST",
137
+ headers: {
138
+ "Content-Type": "application/json",
139
+ "x-api-key": config.appApiKey,
140
+ "project-id": config.projectId
141
+ },
142
+ body: JSON.stringify({
143
+ sandboxId: config.sandboxId,
144
+ issuedBy: "coding-agent"
145
+ })
146
+ });
147
+ if (!res.ok) {
148
+ const errorText = await res.text().catch(() => res.statusText);
149
+ throw new Error(
150
+ `Failed to get proxy token: HTTP ${res.status} ${errorText}`
151
+ );
152
+ }
153
+ const data = await res.json();
154
+ cachedToken = {
155
+ token: data.token,
156
+ expiresAt: new Date(data.expiresAt).getTime()
157
+ };
158
+ return data.token;
159
+ }
160
+ var inputSchema = z.object({
161
+ toolUseIntent: z.string().optional().describe(
162
+ "Brief description of what you intend to accomplish with this tool call"
163
+ ),
164
+ connectionId: z.string().describe("ID of the Notion OAuth connection to use"),
165
+ method: z.enum(["GET", "POST", "PATCH", "DELETE"]).describe("HTTP method"),
166
+ path: z.string().describe(
167
+ "API path appended to https://api.notion.com/v1 (e.g., '/search', '/databases/{id}/query', '/pages/{id}')"
168
+ ),
169
+ body: z.record(z.string(), z.unknown()).optional().describe("Request body (JSON) for POST/PATCH requests")
170
+ });
171
+ var outputSchema = z.discriminatedUnion("success", [
172
+ z.object({
173
+ success: z.literal(true),
174
+ status: z.number(),
175
+ data: z.record(z.string(), z.unknown())
176
+ }),
177
+ z.object({
178
+ success: z.literal(false),
179
+ error: z.string()
180
+ })
181
+ ]);
182
+ var requestTool = new ConnectorTool({
183
+ name: "request",
184
+ description: `Send authenticated requests to the Notion API.
185
+ Authentication is handled automatically via OAuth proxy. Notion-Version header is set automatically.
186
+ Use this tool for all Notion API interactions: searching pages/databases, querying databases, retrieving pages and blocks, managing content.
187
+ Pagination uses cursor-based start_cursor and page_size (max 100).`,
188
+ inputSchema,
189
+ outputSchema,
190
+ async execute({ connectionId, method, path: path2, body }, connections, config) {
191
+ const connection2 = connections.find((c) => c.id === connectionId);
192
+ if (!connection2) {
193
+ return {
194
+ success: false,
195
+ error: `Connection ${connectionId} not found`
196
+ };
197
+ }
198
+ console.log(
199
+ `[connector-request] notion-oauth/${connection2.name}: ${method} ${path2}`
200
+ );
201
+ try {
202
+ const url = `${BASE_URL2}${path2.startsWith("/") ? "" : "/"}${path2}`;
203
+ const token = await getProxyToken(config.oauthProxy);
204
+ const proxyUrl = `https://${config.oauthProxy.sandboxId}.${config.oauthProxy.previewBaseDomain}/_sqcore/connections/${connectionId}/request`;
205
+ const controller = new AbortController();
206
+ const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
207
+ try {
208
+ const response = await fetch(proxyUrl, {
209
+ method: "POST",
210
+ headers: {
211
+ "Content-Type": "application/json",
212
+ Authorization: `Bearer ${token}`
213
+ },
214
+ body: JSON.stringify({
215
+ url,
216
+ method,
217
+ headers: { "Notion-Version": NOTION_VERSION2 },
218
+ body: body ? JSON.stringify(body) : void 0
219
+ }),
220
+ signal: controller.signal
221
+ });
222
+ const data = await response.json();
223
+ if (!response.ok) {
224
+ const errorMessage = typeof data?.message === "string" ? data.message : typeof data?.code === "string" ? data.code : typeof data?.error === "string" ? data.error : `HTTP ${response.status} ${response.statusText}`;
225
+ return { success: false, error: errorMessage };
226
+ }
227
+ return { success: true, status: response.status, data };
228
+ } finally {
229
+ clearTimeout(timeout);
230
+ }
231
+ } catch (err) {
232
+ const msg = err instanceof Error ? err.message : String(err);
233
+ return { success: false, error: msg };
234
+ }
235
+ }
236
+ });
237
+
238
+ // ../connectors/src/connectors/notion-oauth/setup.ts
239
+ var requestToolName = `notion-oauth_${requestTool.name}`;
240
+ var notionOauthOnboarding = new ConnectorOnboarding({
241
+ connectionSetupInstructions: {
242
+ ja: `\u4EE5\u4E0B\u306E\u624B\u9806\u3067Notion\u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306E\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002
243
+
244
+ 1. \`${requestToolName}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u3001\u30DC\u30C3\u30C8\u30E6\u30FC\u30B6\u30FC\u60C5\u5831\u3092\u53D6\u5F97\u3059\u308B:
245
+ - \`method\`: \`"GET"\`
246
+ - \`path\`: \`"/users/me"\`
247
+ 2. \u30A8\u30E9\u30FC\u304C\u8FD4\u3055\u308C\u305F\u5834\u5408\u3001\u30E6\u30FC\u30B6\u30FC\u306BOAuth\u63A5\u7D9A\u306E\u8A2D\u5B9A\u3092\u78BA\u8A8D\u3059\u308B\u3088\u3046\u4F1D\u3048\u308B
248
+ 3. \`updateConnectionContext\` \u3092\u547C\u3073\u51FA\u3059:
249
+ - \`account\`: Notion\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u540D\u307E\u305F\u306F\u30DC\u30C3\u30C8\u540D
250
+ - \`note\`: \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u5185\u5BB9\u306E\u7C21\u5358\u306A\u8AAC\u660E
251
+
252
+ #### \u5236\u7D04
253
+ - **\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u4E2D\u306B\u30D3\u30B8\u30CD\u30B9\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
254
+ - \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`,
255
+ en: `Follow these steps to set up the Notion connection.
256
+
257
+ 1. Call \`${requestToolName}\` to fetch bot user info:
258
+ - \`method\`: \`"GET"\`
259
+ - \`path\`: \`"/users/me"\`
260
+ 2. If an error is returned, ask the user to check the OAuth connection settings
261
+ 3. Call \`updateConnectionContext\`:
262
+ - \`account\`: Notion workspace name or bot name
263
+ - \`note\`: Brief description of the setup
264
+
265
+ #### Constraints
266
+ - **Do NOT read business data during setup**. Only the metadata request specified in the steps above is allowed
267
+ - Write only 1 sentence between tool calls, then immediately call the next tool. Skip unnecessary explanations and proceed efficiently`
268
+ },
269
+ dataOverviewInstructions: {
270
+ en: `1. Call notion-oauth_request with POST /search and { "page_size": 5 } to discover available pages and databases
271
+ 2. For each database found, call notion-oauth_request with POST /databases/{database_id}/query and { "page_size": 5 } to sample records
272
+ 3. Call notion-oauth_request with GET /users to list workspace members
273
+ 4. Explore page content with GET /blocks/{page_id}/children as needed`,
274
+ ja: `1. notion-oauth_request \u3067 POST /search \u3092 { "page_size": 5 } \u3067\u547C\u3073\u51FA\u3057\u3001\u5229\u7528\u53EF\u80FD\u306A\u30DA\u30FC\u30B8\u3068\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u3092\u691C\u51FA
275
+ 2. \u898B\u3064\u304B\u3063\u305F\u5404\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u306B\u3064\u3044\u3066\u3001notion-oauth_request \u3067 POST /databases/{database_id}/query \u3092 { "page_size": 5 } \u3067\u547C\u3073\u51FA\u3057\u3001\u30EC\u30B3\u30FC\u30C9\u3092\u30B5\u30F3\u30D7\u30EA\u30F3\u30B0
276
+ 3. notion-oauth_request \u3067 GET /users \u3092\u547C\u3073\u51FA\u3057\u3001\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u30E1\u30F3\u30D0\u30FC\u3092\u4E00\u89A7\u8868\u793A
277
+ 4. \u5FC5\u8981\u306B\u5FDC\u3058\u3066 GET /blocks/{page_id}/children \u3067\u30DA\u30FC\u30B8\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u63A2\u7D22`
278
+ }
279
+ });
280
+
281
+ // ../connectors/src/connectors/notion-oauth/parameters.ts
282
+ var parameters = {};
283
+
284
+ // ../connectors/src/connectors/notion-oauth/index.ts
285
+ var tools = { request: requestTool };
286
+ var notionOauthConnector = new ConnectorPlugin({
287
+ slug: "notion",
288
+ authType: AUTH_TYPES.OAUTH,
289
+ name: "Notion (OAuth)",
290
+ description: "Connect to Notion to query databases, pages, and workspace content using OAuth.",
291
+ iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/797V5GDDTA8bsfKUHBCoQO/290ec49b70b68ddb4acd3bf0a6ab8bda/notion-icon.webp",
292
+ parameters,
293
+ releaseFlag: { dev1: true, dev2: false, prod: false },
294
+ onboarding: notionOauthOnboarding,
295
+ proxyPolicy: {
296
+ allowlist: [
297
+ {
298
+ host: "api.notion.com",
299
+ methods: ["GET", "POST", "PATCH", "DELETE"]
300
+ }
301
+ ]
302
+ },
303
+ systemPrompt: {
304
+ en: `### Tools
305
+
306
+ - \`notion-oauth_request\`: The only way to call the Notion API. Use it to search pages and databases, query database records, retrieve page content and blocks, and manage workspace data. Authentication is configured automatically via OAuth. Notion-Version header is set automatically. Pagination uses cursor-based \`start_cursor\` and \`page_size\` (max 100) with \`has_more\` and \`next_cursor\` in the response.
307
+
308
+ ### Notion API Reference
309
+
310
+ #### Available Endpoints
311
+ - POST \`/search\` \u2014 Search pages and databases by title. Body: \`{ query, filter: { property: "object", value: "page"|"database" }, sort, start_cursor, page_size }\`
312
+ - GET \`/databases/{id}\` \u2014 Retrieve a database (schema, properties)
313
+ - POST \`/databases/{id}/query\` \u2014 Query a database. Body: \`{ filter, sorts, start_cursor, page_size }\`
314
+ - GET \`/pages/{id}\` \u2014 Retrieve a page (properties, metadata)
315
+ - GET \`/pages/{id}/properties/{property_id}\` \u2014 Retrieve a specific page property
316
+ - GET \`/blocks/{id}/children\` \u2014 List child blocks (page content). Query: \`start_cursor\`, \`page_size\`
317
+ - GET \`/blocks/{id}\` \u2014 Retrieve a single block
318
+ - PATCH \`/blocks/{id}/children\` \u2014 Append block children
319
+ - GET \`/users\` \u2014 List workspace users
320
+ - GET \`/users/{id}\` \u2014 Retrieve a user
321
+ - GET \`/users/me\` \u2014 Get the bot user
322
+ - POST \`/pages\` \u2014 Create a page
323
+ - PATCH \`/pages/{id}\` \u2014 Update page properties
324
+ - POST \`/databases\` \u2014 Create a database
325
+ - PATCH \`/databases/{id}\` \u2014 Update a database
326
+ - DELETE \`/blocks/{id}\` \u2014 Delete a block
327
+ - GET \`/comments?block_id={id}\` \u2014 Retrieve comments
328
+ - POST \`/comments\` \u2014 Create a comment
329
+
330
+ ### Tips
331
+ - Use POST /search to discover databases and pages accessible via OAuth
332
+ - Database queries return page objects with properties matching the database schema
333
+ - Block children are only first-level; recurse for nested content
334
+ - Pagination: max page_size is 100, use start_cursor from next_cursor for subsequent pages
335
+
336
+ ### Business Logic
337
+
338
+ 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.
339
+
340
+ #### Example
341
+
342
+ \`\`\`ts
343
+ import { connection } from "@squadbase/vite-server/connectors/notion-oauth";
344
+
345
+ const notion = connection("<connectionId>");
346
+
347
+ // Authenticated fetch (returns standard Response)
348
+ const res = await notion.request("/search", {
349
+ method: "POST",
350
+ body: JSON.stringify({ query: "Project", page_size: 10 }),
351
+ });
352
+ const data = await res.json();
353
+ \`\`\``,
354
+ ja: `### \u30C4\u30FC\u30EB
355
+
356
+ - \`notion-oauth_request\`: Notion API\u3092\u547C\u3073\u51FA\u3059\u552F\u4E00\u306E\u624B\u6BB5\u3067\u3059\u3002\u30DA\u30FC\u30B8\u3084\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u306E\u691C\u7D22\u3001\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u30EC\u30B3\u30FC\u30C9\u306E\u30AF\u30A8\u30EA\u3001\u30DA\u30FC\u30B8\u30B3\u30F3\u30C6\u30F3\u30C4\u3084\u30D6\u30ED\u30C3\u30AF\u306E\u53D6\u5F97\u3001\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u30C7\u30FC\u30BF\u306E\u7BA1\u7406\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002OAuth\u7D4C\u7531\u3067\u8A8D\u8A3C\u306F\u81EA\u52D5\u8A2D\u5B9A\u3055\u308C\u307E\u3059\u3002Notion-Version\u30D8\u30C3\u30C0\u30FC\u3082\u81EA\u52D5\u8A2D\u5B9A\u3055\u308C\u307E\u3059\u3002\u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3\u306F\u30EC\u30B9\u30DD\u30F3\u30B9\u306E \`has_more\` \u3068 \`next_cursor\` \u306B\u3088\u308B\u30AB\u30FC\u30BD\u30EB\u30D9\u30FC\u30B9\u3067\u3001\`start_cursor\` \u3068 \`page_size\`\uFF08\u6700\u5927100\uFF09\u3092\u4F7F\u7528\u3057\u307E\u3059\u3002
357
+
358
+ ### Notion API \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
359
+
360
+ #### \u5229\u7528\u53EF\u80FD\u306A\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8
361
+ - POST \`/search\` \u2014 \u30DA\u30FC\u30B8\u3068\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u3092\u30BF\u30A4\u30C8\u30EB\u3067\u691C\u7D22\u3002Body: \`{ query, filter: { property: "object", value: "page"|"database" }, sort, start_cursor, page_size }\`
362
+ - GET \`/databases/{id}\` \u2014 \u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u3092\u53D6\u5F97\uFF08\u30B9\u30AD\u30FC\u30DE\u3001\u30D7\u30ED\u30D1\u30C6\u30A3\uFF09
363
+ - POST \`/databases/{id}/query\` \u2014 \u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u3092\u30AF\u30A8\u30EA\u3002Body: \`{ filter, sorts, start_cursor, page_size }\`
364
+ - GET \`/pages/{id}\` \u2014 \u30DA\u30FC\u30B8\u3092\u53D6\u5F97\uFF08\u30D7\u30ED\u30D1\u30C6\u30A3\u3001\u30E1\u30BF\u30C7\u30FC\u30BF\uFF09
365
+ - GET \`/pages/{id}/properties/{property_id}\` \u2014 \u7279\u5B9A\u306E\u30DA\u30FC\u30B8\u30D7\u30ED\u30D1\u30C6\u30A3\u3092\u53D6\u5F97
366
+ - GET \`/blocks/{id}/children\` \u2014 \u5B50\u30D6\u30ED\u30C3\u30AF\u3092\u4E00\u89A7\u8868\u793A\uFF08\u30DA\u30FC\u30B8\u30B3\u30F3\u30C6\u30F3\u30C4\uFF09\u3002Query: \`start_cursor\`, \`page_size\`
367
+ - GET \`/blocks/{id}\` \u2014 \u5358\u4E00\u30D6\u30ED\u30C3\u30AF\u3092\u53D6\u5F97
368
+ - PATCH \`/blocks/{id}/children\` \u2014 \u5B50\u30D6\u30ED\u30C3\u30AF\u3092\u8FFD\u52A0
369
+ - GET \`/users\` \u2014 \u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u30E6\u30FC\u30B6\u30FC\u3092\u4E00\u89A7\u8868\u793A
370
+ - GET \`/users/{id}\` \u2014 \u30E6\u30FC\u30B6\u30FC\u3092\u53D6\u5F97
371
+ - GET \`/users/me\` \u2014 \u30DC\u30C3\u30C8\u30E6\u30FC\u30B6\u30FC\u3092\u53D6\u5F97
372
+ - POST \`/pages\` \u2014 \u30DA\u30FC\u30B8\u3092\u4F5C\u6210
373
+ - PATCH \`/pages/{id}\` \u2014 \u30DA\u30FC\u30B8\u30D7\u30ED\u30D1\u30C6\u30A3\u3092\u66F4\u65B0
374
+ - POST \`/databases\` \u2014 \u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u3092\u4F5C\u6210
375
+ - PATCH \`/databases/{id}\` \u2014 \u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u3092\u66F4\u65B0
376
+ - DELETE \`/blocks/{id}\` \u2014 \u30D6\u30ED\u30C3\u30AF\u3092\u524A\u9664
377
+ - GET \`/comments?block_id={id}\` \u2014 \u30B3\u30E1\u30F3\u30C8\u3092\u53D6\u5F97
378
+ - POST \`/comments\` \u2014 \u30B3\u30E1\u30F3\u30C8\u3092\u4F5C\u6210
379
+
380
+ ### \u30D2\u30F3\u30C8
381
+ - POST /search \u3092\u4F7F\u7528\u3057\u3066OAuth\u7D4C\u7531\u3067\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306A\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u3084\u30DA\u30FC\u30B8\u3092\u691C\u51FA\u3057\u307E\u3059
382
+ - \u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u30AF\u30A8\u30EA\u306F\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u30B9\u30AD\u30FC\u30DE\u306B\u4E00\u81F4\u3059\u308B\u30D7\u30ED\u30D1\u30C6\u30A3\u3092\u6301\u3064\u30DA\u30FC\u30B8\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3092\u8FD4\u3057\u307E\u3059
383
+ - \u30D6\u30ED\u30C3\u30AF\u306E\u5B50\u306F\u6700\u521D\u306E\u30EC\u30D9\u30EB\u306E\u307F\u3067\u3059\u3002\u30CD\u30B9\u30C8\u3055\u308C\u305F\u30B3\u30F3\u30C6\u30F3\u30C4\u306B\u306F\u518D\u5E30\u304C\u5FC5\u8981\u3067\u3059
384
+ - \u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3: \u6700\u5927page_size\u306F100\u3001\u5F8C\u7D9A\u30DA\u30FC\u30B8\u306B\u306Fnext_cursor\u304B\u3089start_cursor\u3092\u4F7F\u7528\u3057\u307E\u3059
385
+
386
+ ### Business Logic
387
+
388
+ \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
389
+
390
+ #### Example
391
+
392
+ \`\`\`ts
393
+ import { connection } from "@squadbase/vite-server/connectors/notion-oauth";
394
+
395
+ const notion = connection("<connectionId>");
396
+
397
+ // Authenticated fetch (returns standard Response)
398
+ const res = await notion.request("/search", {
399
+ method: "POST",
400
+ body: JSON.stringify({ query: "Project", page_size: 10 }),
401
+ });
402
+ const data = await res.json();
403
+ \`\`\``
404
+ },
405
+ tools,
406
+ async checkConnection(_params, config) {
407
+ const { proxyFetch } = config;
408
+ try {
409
+ const res = await proxyFetch("https://api.notion.com/v1/users/me", {
410
+ method: "GET",
411
+ headers: { "Notion-Version": "2022-06-28" }
412
+ });
413
+ if (!res.ok) {
414
+ const errorText = await res.text().catch(() => res.statusText);
415
+ return {
416
+ success: false,
417
+ error: `Notion API failed: HTTP ${res.status} ${errorText}`
418
+ };
419
+ }
420
+ return { success: true };
421
+ } catch (error) {
422
+ return {
423
+ success: false,
424
+ error: error instanceof Error ? error.message : String(error)
425
+ };
426
+ }
427
+ }
428
+ });
429
+
430
+ // src/connectors/create-connector-sdk.ts
431
+ import { readFileSync } from "fs";
432
+ import path from "path";
433
+
434
+ // src/connector-client/env.ts
435
+ function resolveEnvVar(entry, key, connectionId) {
436
+ const envVarName = entry.envVars[key];
437
+ if (!envVarName) {
438
+ throw new Error(`Connection "${connectionId}" is missing envVars mapping for key "${key}"`);
439
+ }
440
+ const value = process.env[envVarName];
441
+ if (!value) {
442
+ throw new Error(`Environment variable "${envVarName}" (for connection "${connectionId}", key "${key}") is not set`);
443
+ }
444
+ return value;
445
+ }
446
+ function resolveEnvVarOptional(entry, key) {
447
+ const envVarName = entry.envVars[key];
448
+ if (!envVarName) return void 0;
449
+ return process.env[envVarName] || void 0;
450
+ }
451
+
452
+ // src/connectors/create-connector-sdk.ts
453
+ function loadConnectionsSync() {
454
+ const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
455
+ try {
456
+ const raw = readFileSync(filePath, "utf-8");
457
+ return JSON.parse(raw);
458
+ } catch {
459
+ return {};
460
+ }
461
+ }
462
+ function createConnectorSdk(plugin, createClient2) {
463
+ return (connectionId) => {
464
+ const connections = loadConnectionsSync();
465
+ const entry = connections[connectionId];
466
+ if (!entry) {
467
+ throw new Error(
468
+ `Connection "${connectionId}" not found in .squadbase/connections.json`
469
+ );
470
+ }
471
+ if (entry.connector.slug !== plugin.slug) {
472
+ throw new Error(
473
+ `Connection "${connectionId}" is not a ${plugin.slug} connection (got "${entry.connector.slug}")`
474
+ );
475
+ }
476
+ const params = {};
477
+ for (const param of Object.values(plugin.parameters)) {
478
+ if (param.required) {
479
+ params[param.slug] = resolveEnvVar(entry, param.slug, connectionId);
480
+ } else {
481
+ const val = resolveEnvVarOptional(entry, param.slug);
482
+ if (val !== void 0) params[param.slug] = val;
483
+ }
484
+ }
485
+ return createClient2(params);
486
+ };
487
+ }
488
+
489
+ // src/connectors/entries/notion-oauth.ts
490
+ var connection = createConnectorSdk(notionOauthConnector, createClient);
491
+ export {
492
+ connection
493
+ };
@@ -0,0 +1,5 @@
1
+ import * as _squadbase_connectors_sdk from '@squadbase/connectors/sdk';
2
+
3
+ declare const connection: (connectionId: string) => _squadbase_connectors_sdk.NotionConnectorSdk;
4
+
5
+ export { connection };