@squadbase/vite-server 0.1.17-dev.e4768d1 → 0.1.18
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 +333 -49
- package/dist/connectors/google-analytics-oauth.js +1 -1
- package/dist/connectors/google-calendar-oauth.js +1 -1
- package/dist/connectors/hackernews.js +1 -1
- package/dist/connectors/slack.d.ts +5 -0
- package/dist/connectors/slack.js +656 -0
- package/dist/connectors/x.js +1 -1
- package/dist/index.js +333 -49
- package/dist/main.js +333 -49
- package/dist/vite-plugin.js +333 -49
- package/package.json +5 -1
package/dist/vite-plugin.js
CHANGED
|
@@ -3829,9 +3829,9 @@ var tidbConnector = new ConnectorPlugin({
|
|
|
3829
3829
|
authType: AUTH_TYPES.USER_PASSWORD,
|
|
3830
3830
|
name: "TiDB",
|
|
3831
3831
|
description: "Connect to TiDB (MySQL-compatible distributed SQL database, incl. TiDB Cloud Serverless/Dedicated) for relational data storage and querying.",
|
|
3832
|
-
iconUrl: "https://
|
|
3832
|
+
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/38VhfLEd1t6rkEca5Nls8o/6d6f9ca6dc83b89e8f807661317515bc/69240164.png",
|
|
3833
3833
|
parameters: parameters6,
|
|
3834
|
-
releaseFlag: { dev1: true, dev2:
|
|
3834
|
+
releaseFlag: { dev1: true, dev2: false, prod: false },
|
|
3835
3835
|
categories: ["database"],
|
|
3836
3836
|
onboarding: tidbOnboarding,
|
|
3837
3837
|
systemPrompt: {
|
|
@@ -10950,7 +10950,7 @@ var googleAnalyticsOauthConnector = new ConnectorPlugin({
|
|
|
10950
10950
|
description: "Connect to Google Analytics for web analytics and reporting using OAuth.",
|
|
10951
10951
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/7fs0ipzxuD9mACDzBATtxX/3c53ed90d15c96483e4f78cb29dab5e9/google-analytics.svg",
|
|
10952
10952
|
parameters: parameters16,
|
|
10953
|
-
releaseFlag: { dev1: true, dev2:
|
|
10953
|
+
releaseFlag: { dev1: true, dev2: true, prod: true },
|
|
10954
10954
|
categories: ["marketing"],
|
|
10955
10955
|
onboarding: googleAnalyticsOauthOnboarding,
|
|
10956
10956
|
proxyPolicy: {
|
|
@@ -12541,7 +12541,7 @@ var googleCalendarOauthConnector = new ConnectorPlugin({
|
|
|
12541
12541
|
description: "Connect to Google Calendar for calendar and event data access using OAuth.",
|
|
12542
12542
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/2YsqoBEpdELmfDeFcyGHyE/4494c633b5ae15e562cb739cd85442c1/google-calendar.png",
|
|
12543
12543
|
parameters: parameters18,
|
|
12544
|
-
releaseFlag: { dev1: true, dev2:
|
|
12544
|
+
releaseFlag: { dev1: true, dev2: true, prod: true },
|
|
12545
12545
|
categories: ["productivity"],
|
|
12546
12546
|
onboarding: googleCalendarOauthOnboarding,
|
|
12547
12547
|
proxyPolicy: {
|
|
@@ -46194,7 +46194,7 @@ var xConnector = new ConnectorPlugin({
|
|
|
46194
46194
|
description: "Connect to X API v2 for posts, users, search, timelines, trends, and related social media data using a user-provided Bearer Token.",
|
|
46195
46195
|
iconUrl: "https://cdn.simpleicons.org/x/000000",
|
|
46196
46196
|
parameters: parameters85,
|
|
46197
|
-
releaseFlag: { dev1: true, dev2: true, prod:
|
|
46197
|
+
releaseFlag: { dev1: true, dev2: true, prod: true },
|
|
46198
46198
|
categories: ["social_media"],
|
|
46199
46199
|
onboarding: xOnboarding,
|
|
46200
46200
|
systemPrompt: {
|
|
@@ -46609,7 +46609,7 @@ var hackerNewsConnector = new ConnectorPlugin({
|
|
|
46609
46609
|
description: "Connect to public Hacker News data using the official Firebase API, with optional Algolia-powered search when needed.",
|
|
46610
46610
|
iconUrl: "https://news.ycombinator.com/y18.svg",
|
|
46611
46611
|
parameters: parameters86,
|
|
46612
|
-
releaseFlag: { dev1: true, dev2: true, prod:
|
|
46612
|
+
releaseFlag: { dev1: true, dev2: true, prod: true },
|
|
46613
46613
|
categories: ["scraping"],
|
|
46614
46614
|
onboarding: hackerNewsOnboarding,
|
|
46615
46615
|
systemPrompt: {
|
|
@@ -46754,6 +46754,289 @@ export default async function handler(c: Context) {
|
|
|
46754
46754
|
}
|
|
46755
46755
|
});
|
|
46756
46756
|
|
|
46757
|
+
// ../connectors/src/connectors/slack/tools/request.ts
|
|
46758
|
+
import { z as z105 } from "zod";
|
|
46759
|
+
var BASE_URL70 = "https://slack.com/api";
|
|
46760
|
+
var REQUEST_TIMEOUT_MS80 = 6e4;
|
|
46761
|
+
var cachedToken35 = null;
|
|
46762
|
+
async function getProxyToken35(config) {
|
|
46763
|
+
if (cachedToken35 && cachedToken35.expiresAt > Date.now() + 6e4) {
|
|
46764
|
+
return cachedToken35.token;
|
|
46765
|
+
}
|
|
46766
|
+
const url = `${config.appApiBaseUrl}/v0/database/${config.projectId}/environment/${config.environmentId}/oauth-request-proxy-token`;
|
|
46767
|
+
const res = await fetch(url, {
|
|
46768
|
+
method: "POST",
|
|
46769
|
+
headers: {
|
|
46770
|
+
"Content-Type": "application/json",
|
|
46771
|
+
"x-api-key": config.appApiKey,
|
|
46772
|
+
"project-id": config.projectId
|
|
46773
|
+
},
|
|
46774
|
+
body: JSON.stringify({
|
|
46775
|
+
sandboxId: config.sandboxId,
|
|
46776
|
+
issuedBy: "coding-agent"
|
|
46777
|
+
})
|
|
46778
|
+
});
|
|
46779
|
+
if (!res.ok) {
|
|
46780
|
+
const errorText = await res.text().catch(() => res.statusText);
|
|
46781
|
+
throw new Error(
|
|
46782
|
+
`Failed to get proxy token: HTTP ${res.status} ${errorText}`
|
|
46783
|
+
);
|
|
46784
|
+
}
|
|
46785
|
+
const data = await res.json();
|
|
46786
|
+
cachedToken35 = {
|
|
46787
|
+
token: data.token,
|
|
46788
|
+
expiresAt: new Date(data.expiresAt).getTime()
|
|
46789
|
+
};
|
|
46790
|
+
return data.token;
|
|
46791
|
+
}
|
|
46792
|
+
var inputSchema105 = z105.object({
|
|
46793
|
+
toolUseIntent: z105.string().optional().describe(
|
|
46794
|
+
"Brief description of what you intend to accomplish with this tool call"
|
|
46795
|
+
),
|
|
46796
|
+
connectionId: z105.string().describe("ID of the Slack connection to use"),
|
|
46797
|
+
method: z105.enum(["GET", "POST"]).describe("HTTP method"),
|
|
46798
|
+
path: z105.string().describe(
|
|
46799
|
+
"API method path appended to https://slack.com/api, including query parameters (e.g., '/conversations.list?types=public_channel,private_channel&limit=200', '/conversations.history?channel=C0123456789&limit=50')"
|
|
46800
|
+
),
|
|
46801
|
+
body: z105.record(z105.string(), z105.unknown()).optional().describe("Request body (JSON) for POST requests")
|
|
46802
|
+
});
|
|
46803
|
+
var outputSchema105 = z105.discriminatedUnion("success", [
|
|
46804
|
+
z105.object({
|
|
46805
|
+
success: z105.literal(true),
|
|
46806
|
+
status: z105.number(),
|
|
46807
|
+
data: z105.record(z105.string(), z105.unknown())
|
|
46808
|
+
}),
|
|
46809
|
+
z105.object({
|
|
46810
|
+
success: z105.literal(false),
|
|
46811
|
+
error: z105.string()
|
|
46812
|
+
})
|
|
46813
|
+
]);
|
|
46814
|
+
var requestTool60 = new ConnectorTool({
|
|
46815
|
+
name: "request",
|
|
46816
|
+
description: `Send authenticated requests to the Slack Web API.
|
|
46817
|
+
Authentication is handled automatically via OAuth proxy using the authorizing user's token, so results reflect what that user can see in Slack (public channels plus private channels/DMs they are a member of).
|
|
46818
|
+
Use this tool for all Slack API interactions: listing channels, reading channel message history, reading thread replies, and resolving user names.
|
|
46819
|
+
Pagination is cursor-based: pass 'cursor' from 'response_metadata.next_cursor' of the previous response. Message timestamps ('ts', 'oldest', 'latest') are Unix epoch seconds as strings.`,
|
|
46820
|
+
inputSchema: inputSchema105,
|
|
46821
|
+
outputSchema: outputSchema105,
|
|
46822
|
+
async execute({ connectionId, method, path: path4, body }, connections, config) {
|
|
46823
|
+
const connection = connections.find((c) => c.id === connectionId);
|
|
46824
|
+
if (!connection) {
|
|
46825
|
+
return {
|
|
46826
|
+
success: false,
|
|
46827
|
+
error: `Connection ${connectionId} not found`
|
|
46828
|
+
};
|
|
46829
|
+
}
|
|
46830
|
+
console.log(
|
|
46831
|
+
`[connector-request] slack/${connection.name}: ${method} ${path4}`
|
|
46832
|
+
);
|
|
46833
|
+
try {
|
|
46834
|
+
const url = `${BASE_URL70}${path4.startsWith("/") ? "" : "/"}${path4}`;
|
|
46835
|
+
const token = await getProxyToken35(config.oauthProxy);
|
|
46836
|
+
const proxyUrl = `https://${config.oauthProxy.sandboxId}.${config.oauthProxy.previewBaseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
46837
|
+
const controller = new AbortController();
|
|
46838
|
+
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS80);
|
|
46839
|
+
try {
|
|
46840
|
+
const response = await fetch(proxyUrl, {
|
|
46841
|
+
method: "POST",
|
|
46842
|
+
headers: {
|
|
46843
|
+
"Content-Type": "application/json",
|
|
46844
|
+
Authorization: `Bearer ${token}`
|
|
46845
|
+
},
|
|
46846
|
+
body: JSON.stringify({
|
|
46847
|
+
url,
|
|
46848
|
+
method,
|
|
46849
|
+
headers: method === "POST" ? { "Content-Type": "application/json; charset=utf-8" } : {},
|
|
46850
|
+
body: body ? JSON.stringify(body) : void 0
|
|
46851
|
+
}),
|
|
46852
|
+
signal: controller.signal
|
|
46853
|
+
});
|
|
46854
|
+
const data = await response.json();
|
|
46855
|
+
if (!response.ok || data.ok === false) {
|
|
46856
|
+
const errorMessage = typeof data?.error === "string" ? data.error : `HTTP ${response.status} ${response.statusText}`;
|
|
46857
|
+
return { success: false, error: errorMessage };
|
|
46858
|
+
}
|
|
46859
|
+
return { success: true, status: response.status, data };
|
|
46860
|
+
} finally {
|
|
46861
|
+
clearTimeout(timeout);
|
|
46862
|
+
}
|
|
46863
|
+
} catch (err) {
|
|
46864
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
46865
|
+
return { success: false, error: msg };
|
|
46866
|
+
}
|
|
46867
|
+
}
|
|
46868
|
+
});
|
|
46869
|
+
|
|
46870
|
+
// ../connectors/src/connectors/slack/setup.ts
|
|
46871
|
+
var requestToolName16 = `slack-oauth_${requestTool60.name}`;
|
|
46872
|
+
var slackOnboarding = new ConnectorOnboarding({
|
|
46873
|
+
connectionSetupInstructions: {
|
|
46874
|
+
ja: `\u4EE5\u4E0B\u306E\u624B\u9806\u3067Slack\u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306E\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002
|
|
46875
|
+
|
|
46876
|
+
1. \`${requestToolName16}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u3001\u8A8D\u53EF\u3057\u305F\u30E6\u30FC\u30B6\u30FC\u3068\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u3092\u78BA\u8A8D\u3059\u308B:
|
|
46877
|
+
- \`method\`: \`"POST"\`
|
|
46878
|
+
- \`path\`: \`"/auth.test"\`
|
|
46879
|
+
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
|
|
46880
|
+
|
|
46881
|
+
#### \u5236\u7D04
|
|
46882
|
+
- **\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u4E2D\u306B\u30E1\u30C3\u30BB\u30FC\u30B8\u672C\u6587\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\u8A8D\u8A3C\u78BA\u8A8D\u30EA\u30AF\u30A8\u30B9\u30C8\u306E\u307F
|
|
46883
|
+
- \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`,
|
|
46884
|
+
en: `Follow these steps to set up the Slack connection.
|
|
46885
|
+
|
|
46886
|
+
1. Call \`${requestToolName16}\` to verify the authorizing user and workspace:
|
|
46887
|
+
- \`method\`: \`"POST"\`
|
|
46888
|
+
- \`path\`: \`"/auth.test"\`
|
|
46889
|
+
2. If an error is returned, ask the user to check the OAuth connection settings
|
|
46890
|
+
|
|
46891
|
+
#### Constraints
|
|
46892
|
+
- **Do NOT read message contents during setup**. Only the auth verification request specified in the steps above is allowed
|
|
46893
|
+
- Write only 1 sentence between tool calls, then immediately call the next tool. Skip unnecessary explanations and proceed efficiently`
|
|
46894
|
+
},
|
|
46895
|
+
dataOverviewInstructions: {
|
|
46896
|
+
en: `1. Call connector_slack-oauth_request with GET /conversations.list?types=public_channel,private_channel&exclude_archived=true&limit=100 to discover channels visible to the authorizing user
|
|
46897
|
+
2. For 2-3 channels relevant to the analysis, call connector_slack-oauth_request with GET /conversations.history?channel={channel_id}&limit=10 to sample recent messages
|
|
46898
|
+
3. Call connector_slack-oauth_request with GET /users.list?limit=100 to map user IDs to display names
|
|
46899
|
+
4. For threads worth exploring, call connector_slack-oauth_request with GET /conversations.replies?channel={channel_id}&ts={thread_ts} as needed`,
|
|
46900
|
+
ja: `1. connector_slack-oauth_request \u3067 GET /conversations.list?types=public_channel,private_channel&exclude_archived=true&limit=100 \u3092\u547C\u3073\u51FA\u3057\u3001\u8A8D\u53EF\u30E6\u30FC\u30B6\u30FC\u304C\u898B\u3048\u308B\u30C1\u30E3\u30F3\u30CD\u30EB\u3092\u691C\u51FA
|
|
46901
|
+
2. \u5206\u6790\u5BFE\u8C61\u306B\u306A\u308A\u305D\u3046\u306A2\u301C3\u30C1\u30E3\u30F3\u30CD\u30EB\u306B\u3064\u3044\u3066\u3001connector_slack-oauth_request \u3067 GET /conversations.history?channel={channel_id}&limit=10 \u3092\u547C\u3073\u51FA\u3057\u3001\u76F4\u8FD1\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u30B5\u30F3\u30D7\u30EA\u30F3\u30B0
|
|
46902
|
+
3. connector_slack-oauth_request \u3067 GET /users.list?limit=100 \u3092\u547C\u3073\u51FA\u3057\u3001\u30E6\u30FC\u30B6\u30FCID\u3068\u8868\u793A\u540D\u306E\u5BFE\u5FDC\u3092\u53D6\u5F97
|
|
46903
|
+
4. \u5FC5\u8981\u306B\u5FDC\u3058\u3066 GET /conversations.replies?channel={channel_id}&ts={thread_ts} \u3067\u30B9\u30EC\u30C3\u30C9\u3092\u63A2\u7D22`
|
|
46904
|
+
}
|
|
46905
|
+
});
|
|
46906
|
+
|
|
46907
|
+
// ../connectors/src/connectors/slack/parameters.ts
|
|
46908
|
+
var parameters87 = {};
|
|
46909
|
+
|
|
46910
|
+
// ../connectors/src/connectors/slack/index.ts
|
|
46911
|
+
var tools87 = { request: requestTool60 };
|
|
46912
|
+
var slackConnector = new ConnectorPlugin({
|
|
46913
|
+
slug: "slack",
|
|
46914
|
+
authType: AUTH_TYPES.OAUTH,
|
|
46915
|
+
skipConnectionCheckOnCreate: true,
|
|
46916
|
+
name: "Slack",
|
|
46917
|
+
description: "Connect to Slack to analyze channel messages and threads using OAuth. Reads run with the authorizing user's permissions.",
|
|
46918
|
+
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/75UXS4Ll04liDJiPYKb7gN/eccc8a5e9700174685f7aa3cb23f2830/2111615.png",
|
|
46919
|
+
parameters: parameters87,
|
|
46920
|
+
releaseFlag: { dev1: true, dev2: true, prod: false },
|
|
46921
|
+
categories: ["productivity"],
|
|
46922
|
+
onboarding: slackOnboarding,
|
|
46923
|
+
proxyPolicy: {
|
|
46924
|
+
allowlist: [
|
|
46925
|
+
{
|
|
46926
|
+
host: "slack.com",
|
|
46927
|
+
methods: ["GET", "POST"]
|
|
46928
|
+
}
|
|
46929
|
+
]
|
|
46930
|
+
},
|
|
46931
|
+
systemPrompt: {
|
|
46932
|
+
en: `### Tools
|
|
46933
|
+
|
|
46934
|
+
- \`connector_slack-oauth_request\`: The only way to call the Slack Web API. Use it to list channels, read channel message history, read thread replies, and resolve user names. Authentication is configured automatically via OAuth with the authorizing user's token \u2014 results reflect what that user can see in Slack (public channels plus private channels they are a member of). Pagination is cursor-based: pass \`cursor\` from \`response_metadata.next_cursor\`.
|
|
46935
|
+
|
|
46936
|
+
### Slack Web API Reference
|
|
46937
|
+
|
|
46938
|
+
#### Available Endpoints
|
|
46939
|
+
- GET \`/conversations.list?types=public_channel,private_channel&exclude_archived=true&limit=200\` \u2014 List channels visible to the user. Returns \`channels[]\` with \`id\`, \`name\`, \`is_private\`
|
|
46940
|
+
- GET \`/conversations.history?channel={id}&limit=50\` \u2014 Channel messages, newest first. Optional: \`oldest\` / \`latest\` (Unix epoch seconds as strings), \`cursor\`. Returns \`messages[]\` with \`user\`, \`ts\`, \`text\`, \`thread_ts\`, \`reply_count\`
|
|
46941
|
+
- GET \`/conversations.replies?channel={id}&ts={thread_ts}&limit=50\` \u2014 Messages in a thread (the parent message's \`ts\` is the \`thread_ts\`)
|
|
46942
|
+
- GET \`/users.list?limit=200\` \u2014 Workspace members. Returns \`members[]\` with \`id\`, \`name\`, \`real_name\`, \`profile.display_name\`
|
|
46943
|
+
- GET \`/users.info?user={id}\` \u2014 Single user detail
|
|
46944
|
+
- POST \`/auth.test\` \u2014 Verify the connection; returns the authorizing user and workspace
|
|
46945
|
+
|
|
46946
|
+
### Tips
|
|
46947
|
+
- Message \`ts\` values are Unix epoch seconds as strings (e.g. "1712345678.000200") and double as message IDs; convert for date filtering via \`oldest\`/\`latest\`
|
|
46948
|
+
- Messages reference users by ID (e.g. "U0123456789") \u2014 resolve display names via /users.list before presenting results
|
|
46949
|
+
- A message with \`thread_ts\` equal to its \`ts\` is a thread parent; fetch the thread with /conversations.replies
|
|
46950
|
+
- Respect rate limits: prefer \`limit\` + date bounds over paging through entire channel histories
|
|
46951
|
+
|
|
46952
|
+
### Business Logic
|
|
46953
|
+
|
|
46954
|
+
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.
|
|
46955
|
+
|
|
46956
|
+
#### Example
|
|
46957
|
+
|
|
46958
|
+
\`\`\`ts
|
|
46959
|
+
import { connection } from "@squadbase/vite-server/connectors/slack";
|
|
46960
|
+
|
|
46961
|
+
const slack = connection("<connectionId>");
|
|
46962
|
+
|
|
46963
|
+
// Authenticated fetch (returns standard Response)
|
|
46964
|
+
const res = await slack.request(
|
|
46965
|
+
"/conversations.history?channel=C0123456789&limit=50",
|
|
46966
|
+
);
|
|
46967
|
+
const data = await res.json();
|
|
46968
|
+
if (!data.ok) throw new Error(data.error);
|
|
46969
|
+
\`\`\``,
|
|
46970
|
+
ja: `### \u30C4\u30FC\u30EB
|
|
46971
|
+
|
|
46972
|
+
- \`connector_slack-oauth_request\`: Slack Web API\u3092\u547C\u3073\u51FA\u3059\u552F\u4E00\u306E\u624B\u6BB5\u3067\u3059\u3002\u30C1\u30E3\u30F3\u30CD\u30EB\u4E00\u89A7\u306E\u53D6\u5F97\u3001\u30C1\u30E3\u30F3\u30CD\u30EB\u30E1\u30C3\u30BB\u30FC\u30B8\u5C65\u6B74\u306E\u8AAD\u307F\u53D6\u308A\u3001\u30B9\u30EC\u30C3\u30C9\u8FD4\u4FE1\u306E\u8AAD\u307F\u53D6\u308A\u3001\u30E6\u30FC\u30B6\u30FC\u540D\u306E\u89E3\u6C7A\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002\u8A8D\u8A3C\u306F\u8A8D\u53EF\u3057\u305F\u30E6\u30FC\u30B6\u30FC\u306E\u30C8\u30FC\u30AF\u30F3\u306B\u3088\u308BOAuth\u7D4C\u7531\u3067\u81EA\u52D5\u8A2D\u5B9A\u3055\u308C\u3001\u7D50\u679C\u306F\u305D\u306E\u30E6\u30FC\u30B6\u30FC\u304CSlack\u3067\u898B\u3048\u308B\u7BC4\u56F2\uFF08public\u30C1\u30E3\u30F3\u30CD\u30EB\u3068\u3001\u53C2\u52A0\u3057\u3066\u3044\u308Bprivate\u30C1\u30E3\u30F3\u30CD\u30EB\uFF09\u3092\u53CD\u6620\u3057\u307E\u3059\u3002\u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3\u306F \`response_metadata.next_cursor\` \u306E\u5024\u3092 \`cursor\` \u306B\u6E21\u3059\u30AB\u30FC\u30BD\u30EB\u30D9\u30FC\u30B9\u3067\u3059\u3002
|
|
46973
|
+
|
|
46974
|
+
### Slack Web API \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
|
|
46975
|
+
|
|
46976
|
+
#### \u5229\u7528\u53EF\u80FD\u306A\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8
|
|
46977
|
+
- GET \`/conversations.list?types=public_channel,private_channel&exclude_archived=true&limit=200\` \u2014 \u30E6\u30FC\u30B6\u30FC\u304C\u898B\u3048\u308B\u30C1\u30E3\u30F3\u30CD\u30EB\u4E00\u89A7\u3002\`channels[]\`\uFF08\`id\`, \`name\`, \`is_private\`\uFF09\u3092\u8FD4\u3059
|
|
46978
|
+
- GET \`/conversations.history?channel={id}&limit=50\` \u2014 \u30C1\u30E3\u30F3\u30CD\u30EB\u30E1\u30C3\u30BB\u30FC\u30B8\uFF08\u65B0\u3057\u3044\u9806\uFF09\u3002\u30AA\u30D7\u30B7\u30E7\u30F3: \`oldest\` / \`latest\`\uFF08Unix epoch\u79D2\u306E\u6587\u5B57\u5217\uFF09, \`cursor\`\u3002\`messages[]\`\uFF08\`user\`, \`ts\`, \`text\`, \`thread_ts\`, \`reply_count\`\uFF09\u3092\u8FD4\u3059
|
|
46979
|
+
- GET \`/conversations.replies?channel={id}&ts={thread_ts}&limit=50\` \u2014 \u30B9\u30EC\u30C3\u30C9\u5185\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\uFF08\u89AA\u30E1\u30C3\u30BB\u30FC\u30B8\u306E \`ts\` \u304C \`thread_ts\`\uFF09
|
|
46980
|
+
- GET \`/users.list?limit=200\` \u2014 \u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u30E1\u30F3\u30D0\u30FC\u3002\`members[]\`\uFF08\`id\`, \`name\`, \`real_name\`, \`profile.display_name\`\uFF09\u3092\u8FD4\u3059
|
|
46981
|
+
- GET \`/users.info?user={id}\` \u2014 \u5358\u4E00\u30E6\u30FC\u30B6\u30FC\u306E\u8A73\u7D30
|
|
46982
|
+
- POST \`/auth.test\` \u2014 \u63A5\u7D9A\u78BA\u8A8D\u3002\u8A8D\u53EF\u30E6\u30FC\u30B6\u30FC\u3068\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u3092\u8FD4\u3059
|
|
46983
|
+
|
|
46984
|
+
### \u30D2\u30F3\u30C8
|
|
46985
|
+
- \u30E1\u30C3\u30BB\u30FC\u30B8\u306E \`ts\` \u306FUnix epoch\u79D2\u306E\u6587\u5B57\u5217\uFF08\u4F8B: "1712345678.000200"\uFF09\u3067\u30E1\u30C3\u30BB\u30FC\u30B8ID\u3092\u517C\u306D\u307E\u3059\u3002\u65E5\u4ED8\u30D5\u30A3\u30EB\u30BF\u306F \`oldest\`/\`latest\` \u306B\u5909\u63DB\u3057\u3066\u6E21\u3057\u307E\u3059
|
|
46986
|
+
- \u30E1\u30C3\u30BB\u30FC\u30B8\u5185\u306E\u30E6\u30FC\u30B6\u30FC\u306FID\uFF08\u4F8B: "U0123456789"\uFF09\u3067\u53C2\u7167\u3055\u308C\u308B\u305F\u3081\u3001\u7D50\u679C\u3092\u63D0\u793A\u3059\u308B\u524D\u306B /users.list \u3067\u8868\u793A\u540D\u3092\u89E3\u6C7A\u3057\u3066\u304F\u3060\u3055\u3044
|
|
46987
|
+
- \`thread_ts\` \u304C\u81EA\u8EAB\u306E \`ts\` \u3068\u7B49\u3057\u3044\u30E1\u30C3\u30BB\u30FC\u30B8\u306F\u30B9\u30EC\u30C3\u30C9\u306E\u89AA\u3067\u3059\u3002/conversations.replies \u3067\u30B9\u30EC\u30C3\u30C9\u3092\u53D6\u5F97\u3067\u304D\u307E\u3059
|
|
46988
|
+
- \u30EC\u30FC\u30C8\u30EA\u30DF\u30C3\u30C8\u306B\u914D\u616E\u3057\u3001\u30C1\u30E3\u30F3\u30CD\u30EB\u5C65\u6B74\u5168\u4F53\u306E\u30DA\u30FC\u30B8\u30F3\u30B0\u3088\u308A \`limit\` + \u671F\u9593\u6307\u5B9A\u3092\u512A\u5148\u3057\u3066\u304F\u3060\u3055\u3044
|
|
46989
|
+
|
|
46990
|
+
### Business Logic
|
|
46991
|
+
|
|
46992
|
+
\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
|
|
46993
|
+
|
|
46994
|
+
#### Example
|
|
46995
|
+
|
|
46996
|
+
\`\`\`ts
|
|
46997
|
+
import { connection } from "@squadbase/vite-server/connectors/slack";
|
|
46998
|
+
|
|
46999
|
+
const slack = connection("<connectionId>");
|
|
47000
|
+
|
|
47001
|
+
// Authenticated fetch (returns standard Response)
|
|
47002
|
+
const res = await slack.request(
|
|
47003
|
+
"/conversations.history?channel=C0123456789&limit=50",
|
|
47004
|
+
);
|
|
47005
|
+
const data = await res.json();
|
|
47006
|
+
if (!data.ok) throw new Error(data.error);
|
|
47007
|
+
\`\`\``
|
|
47008
|
+
},
|
|
47009
|
+
tools: tools87,
|
|
47010
|
+
async checkConnection(_params, config) {
|
|
47011
|
+
const { proxyFetch } = config;
|
|
47012
|
+
try {
|
|
47013
|
+
const res = await proxyFetch("https://slack.com/api/auth.test", {
|
|
47014
|
+
method: "POST"
|
|
47015
|
+
});
|
|
47016
|
+
if (!res.ok) {
|
|
47017
|
+
const errorText = await res.text().catch(() => res.statusText);
|
|
47018
|
+
return {
|
|
47019
|
+
success: false,
|
|
47020
|
+
error: `Slack API failed: HTTP ${res.status} ${errorText}`
|
|
47021
|
+
};
|
|
47022
|
+
}
|
|
47023
|
+
const data = await res.json();
|
|
47024
|
+
if (data.ok !== true) {
|
|
47025
|
+
return {
|
|
47026
|
+
success: false,
|
|
47027
|
+
error: `Slack auth.test failed: ${data.error ?? "unknown error"}`
|
|
47028
|
+
};
|
|
47029
|
+
}
|
|
47030
|
+
return { success: true };
|
|
47031
|
+
} catch (error) {
|
|
47032
|
+
return {
|
|
47033
|
+
success: false,
|
|
47034
|
+
error: error instanceof Error ? error.message : String(error)
|
|
47035
|
+
};
|
|
47036
|
+
}
|
|
47037
|
+
}
|
|
47038
|
+
});
|
|
47039
|
+
|
|
46757
47040
|
// ../connectors/src/connectors/registry.ts
|
|
46758
47041
|
var plugins = {
|
|
46759
47042
|
snowflake: snowflakeConnector,
|
|
@@ -46841,7 +47124,8 @@ var plugins = {
|
|
|
46841
47124
|
tableau: tableauConnector,
|
|
46842
47125
|
outlookOauth: outlookOauthConnector,
|
|
46843
47126
|
x: xConnector,
|
|
46844
|
-
hackerNews: hackerNewsConnector
|
|
47127
|
+
hackerNews: hackerNewsConnector,
|
|
47128
|
+
slack: slackConnector
|
|
46845
47129
|
};
|
|
46846
47130
|
var connectors = {
|
|
46847
47131
|
...plugins,
|
|
@@ -47072,62 +47356,62 @@ function resolveParams(entry, connectionId, plugin) {
|
|
|
47072
47356
|
var { getQuery, loadConnections, reloadEnvFile, watchConnectionsFile } = createConnectorRegistry();
|
|
47073
47357
|
|
|
47074
47358
|
// src/types/server-logic.ts
|
|
47075
|
-
import { z as
|
|
47076
|
-
var parameterMetaSchema =
|
|
47077
|
-
name:
|
|
47078
|
-
type:
|
|
47079
|
-
description:
|
|
47080
|
-
required:
|
|
47081
|
-
default:
|
|
47082
|
-
});
|
|
47083
|
-
var serverLogicCacheConfigSchema =
|
|
47084
|
-
ttl:
|
|
47085
|
-
staleWhileRevalidate:
|
|
47086
|
-
});
|
|
47087
|
-
var serverLogicSchemaObjectSchema =
|
|
47088
|
-
() =>
|
|
47089
|
-
type:
|
|
47090
|
-
format:
|
|
47091
|
-
description:
|
|
47092
|
-
nullable:
|
|
47093
|
-
enum:
|
|
47359
|
+
import { z as z106 } from "zod";
|
|
47360
|
+
var parameterMetaSchema = z106.object({
|
|
47361
|
+
name: z106.string(),
|
|
47362
|
+
type: z106.enum(["string", "number", "boolean"]),
|
|
47363
|
+
description: z106.string(),
|
|
47364
|
+
required: z106.boolean().optional(),
|
|
47365
|
+
default: z106.union([z106.string(), z106.number(), z106.boolean()]).optional()
|
|
47366
|
+
});
|
|
47367
|
+
var serverLogicCacheConfigSchema = z106.object({
|
|
47368
|
+
ttl: z106.number(),
|
|
47369
|
+
staleWhileRevalidate: z106.boolean().optional()
|
|
47370
|
+
});
|
|
47371
|
+
var serverLogicSchemaObjectSchema = z106.lazy(
|
|
47372
|
+
() => z106.object({
|
|
47373
|
+
type: z106.enum(["string", "number", "integer", "boolean", "object", "array", "null"]).optional(),
|
|
47374
|
+
format: z106.string().optional(),
|
|
47375
|
+
description: z106.string().optional(),
|
|
47376
|
+
nullable: z106.boolean().optional(),
|
|
47377
|
+
enum: z106.array(z106.union([z106.string(), z106.number(), z106.boolean(), z106.null()])).optional(),
|
|
47094
47378
|
items: serverLogicSchemaObjectSchema.optional(),
|
|
47095
|
-
properties:
|
|
47096
|
-
required:
|
|
47097
|
-
additionalProperties:
|
|
47098
|
-
minimum:
|
|
47099
|
-
maximum:
|
|
47100
|
-
minLength:
|
|
47101
|
-
maxLength:
|
|
47102
|
-
pattern:
|
|
47379
|
+
properties: z106.record(z106.string(), serverLogicSchemaObjectSchema).optional(),
|
|
47380
|
+
required: z106.array(z106.string()).optional(),
|
|
47381
|
+
additionalProperties: z106.union([z106.boolean(), serverLogicSchemaObjectSchema]).optional(),
|
|
47382
|
+
minimum: z106.number().optional(),
|
|
47383
|
+
maximum: z106.number().optional(),
|
|
47384
|
+
minLength: z106.number().optional(),
|
|
47385
|
+
maxLength: z106.number().optional(),
|
|
47386
|
+
pattern: z106.string().optional()
|
|
47103
47387
|
})
|
|
47104
47388
|
);
|
|
47105
|
-
var serverLogicMediaTypeSchema =
|
|
47389
|
+
var serverLogicMediaTypeSchema = z106.object({
|
|
47106
47390
|
schema: serverLogicSchemaObjectSchema.optional(),
|
|
47107
|
-
example:
|
|
47391
|
+
example: z106.unknown().optional()
|
|
47108
47392
|
});
|
|
47109
|
-
var serverLogicResponseSchema =
|
|
47110
|
-
description:
|
|
47111
|
-
content:
|
|
47393
|
+
var serverLogicResponseSchema = z106.object({
|
|
47394
|
+
description: z106.string().optional(),
|
|
47395
|
+
content: z106.record(z106.string(), serverLogicMediaTypeSchema).optional()
|
|
47112
47396
|
});
|
|
47113
47397
|
var jsonBaseFields = {
|
|
47114
|
-
description:
|
|
47115
|
-
parameters:
|
|
47398
|
+
description: z106.string(),
|
|
47399
|
+
parameters: z106.array(parameterMetaSchema).optional(),
|
|
47116
47400
|
response: serverLogicResponseSchema.optional(),
|
|
47117
47401
|
cache: serverLogicCacheConfigSchema.optional()
|
|
47118
47402
|
};
|
|
47119
|
-
var jsonSqlServerLogicSchema =
|
|
47403
|
+
var jsonSqlServerLogicSchema = z106.object({
|
|
47120
47404
|
...jsonBaseFields,
|
|
47121
|
-
type:
|
|
47122
|
-
query:
|
|
47123
|
-
connectionId:
|
|
47405
|
+
type: z106.literal("sql").optional(),
|
|
47406
|
+
query: z106.string(),
|
|
47407
|
+
connectionId: z106.string()
|
|
47124
47408
|
});
|
|
47125
|
-
var jsonTypeScriptServerLogicSchema =
|
|
47409
|
+
var jsonTypeScriptServerLogicSchema = z106.object({
|
|
47126
47410
|
...jsonBaseFields,
|
|
47127
|
-
type:
|
|
47128
|
-
handlerPath:
|
|
47411
|
+
type: z106.literal("typescript"),
|
|
47412
|
+
handlerPath: z106.string()
|
|
47129
47413
|
});
|
|
47130
|
-
var anyJsonServerLogicSchema =
|
|
47414
|
+
var anyJsonServerLogicSchema = z106.union([
|
|
47131
47415
|
jsonTypeScriptServerLogicSchema,
|
|
47132
47416
|
jsonSqlServerLogicSchema
|
|
47133
47417
|
]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@squadbase/vite-server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -322,6 +322,10 @@
|
|
|
322
322
|
"./connectors/hackernews": {
|
|
323
323
|
"import": "./dist/connectors/hackernews.js",
|
|
324
324
|
"types": "./dist/connectors/hackernews.d.ts"
|
|
325
|
+
},
|
|
326
|
+
"./connectors/slack": {
|
|
327
|
+
"import": "./dist/connectors/slack.js",
|
|
328
|
+
"types": "./dist/connectors/slack.d.ts"
|
|
325
329
|
}
|
|
326
330
|
},
|
|
327
331
|
"files": [
|