@squadbase/vite-server 0.1.3-dev.14 → 0.1.3-dev.16
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 +2177 -2730
- package/dist/connectors/airtable-oauth.js +16 -5
- package/dist/connectors/airtable.js +16 -5
- package/dist/connectors/amplitude.js +16 -5
- package/dist/connectors/anthropic.js +16 -5
- package/dist/connectors/asana.js +16 -5
- package/dist/connectors/attio.js +16 -5
- package/dist/connectors/backlog-api-key.js +16 -5
- package/dist/connectors/customerio.js +16 -5
- package/dist/connectors/dbt.js +16 -5
- package/dist/connectors/gamma.js +16 -5
- package/dist/connectors/gemini.js +16 -5
- package/dist/connectors/gmail-oauth.js +16 -5
- package/dist/connectors/gmail.js +68 -34
- package/dist/connectors/google-ads.js +16 -5
- package/dist/connectors/google-analytics-oauth.js +16 -5
- package/dist/connectors/google-analytics.js +16 -5
- package/dist/connectors/google-calendar-oauth.js +16 -5
- package/dist/connectors/google-calendar.js +71 -48
- package/dist/connectors/{google-drive-oauth.d.ts → google-docs.d.ts} +1 -1
- package/dist/connectors/google-docs.js +585 -0
- package/dist/connectors/google-drive.d.ts +1 -1
- package/dist/connectors/google-drive.js +392 -328
- package/dist/connectors/google-sheets.d.ts +1 -1
- package/dist/connectors/google-sheets.js +210 -280
- package/dist/connectors/google-slides.d.ts +1 -1
- package/dist/connectors/google-slides.js +199 -336
- package/dist/connectors/grafana.js +16 -5
- package/dist/connectors/hubspot-oauth.js +16 -5
- package/dist/connectors/hubspot.js +16 -5
- package/dist/connectors/intercom-oauth.js +16 -5
- package/dist/connectors/intercom.js +16 -5
- package/dist/connectors/jira-api-key.js +16 -5
- package/dist/connectors/kintone-api-token.js +229 -81
- package/dist/connectors/kintone.js +16 -5
- package/dist/connectors/linkedin-ads.js +16 -5
- package/dist/connectors/mailchimp-oauth.js +16 -5
- package/dist/connectors/mailchimp.js +16 -5
- package/dist/connectors/mixpanel.js +16 -5
- package/dist/connectors/notion-oauth.js +16 -5
- package/dist/connectors/notion.js +16 -5
- package/dist/connectors/openai.js +16 -5
- package/dist/connectors/sentry.js +17 -6
- package/dist/connectors/shopify-oauth.js +16 -5
- package/dist/connectors/shopify.js +16 -5
- package/dist/connectors/stripe-api-key.js +16 -5
- package/dist/connectors/stripe-oauth.js +16 -5
- package/dist/connectors/wix-store.js +16 -5
- package/dist/connectors/zendesk-oauth.js +16 -5
- package/dist/connectors/zendesk.js +16 -5
- package/dist/index.js +2172 -2725
- package/dist/main.js +2172 -2725
- package/dist/vite-plugin.js +2172 -2725
- package/package.json +7 -15
- package/dist/connectors/google-drive-oauth.js +0 -879
- package/dist/connectors/google-sheets-oauth.d.ts +0 -5
- package/dist/connectors/google-sheets-oauth.js +0 -821
- package/dist/connectors/google-slides-oauth.d.ts +0 -5
- package/dist/connectors/google-slides-oauth.js +0 -742
|
@@ -245,16 +245,27 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
245
245
|
* Filters connections by connectorKey internally.
|
|
246
246
|
* Returns tools keyed as `${connectorKey}_${toolName}`.
|
|
247
247
|
*/
|
|
248
|
-
createTools(connections, config) {
|
|
248
|
+
createTools(connections, config, opts) {
|
|
249
249
|
const myConnections = connections.filter(
|
|
250
250
|
(c) => _ConnectorPlugin.deriveKey(c.connector.slug, c.connector.authType) === this.connectorKey
|
|
251
251
|
);
|
|
252
252
|
const result = {};
|
|
253
253
|
for (const t of Object.values(this.tools)) {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
254
|
+
const tool = t.createTool(myConnections, config);
|
|
255
|
+
const originalToModelOutput = tool.toModelOutput;
|
|
256
|
+
result[`${this.connectorKey}_${t.name}`] = {
|
|
257
|
+
...tool,
|
|
258
|
+
toModelOutput: async (options) => {
|
|
259
|
+
if (!originalToModelOutput) {
|
|
260
|
+
return opts.truncateOutput(options.output);
|
|
261
|
+
}
|
|
262
|
+
const modelOutput = await originalToModelOutput(options);
|
|
263
|
+
if (modelOutput.type === "text" || modelOutput.type === "json") {
|
|
264
|
+
return opts.truncateOutput(modelOutput.value);
|
|
265
|
+
}
|
|
266
|
+
return modelOutput;
|
|
267
|
+
}
|
|
268
|
+
};
|
|
258
269
|
}
|
|
259
270
|
return result;
|
|
260
271
|
}
|
|
@@ -90,16 +90,27 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
90
90
|
* Filters connections by connectorKey internally.
|
|
91
91
|
* Returns tools keyed as `${connectorKey}_${toolName}`.
|
|
92
92
|
*/
|
|
93
|
-
createTools(connections, config) {
|
|
93
|
+
createTools(connections, config, opts) {
|
|
94
94
|
const myConnections = connections.filter(
|
|
95
95
|
(c) => _ConnectorPlugin.deriveKey(c.connector.slug, c.connector.authType) === this.connectorKey
|
|
96
96
|
);
|
|
97
97
|
const result = {};
|
|
98
98
|
for (const t of Object.values(this.tools)) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
99
|
+
const tool = t.createTool(myConnections, config);
|
|
100
|
+
const originalToModelOutput = tool.toModelOutput;
|
|
101
|
+
result[`${this.connectorKey}_${t.name}`] = {
|
|
102
|
+
...tool,
|
|
103
|
+
toModelOutput: async (options) => {
|
|
104
|
+
if (!originalToModelOutput) {
|
|
105
|
+
return opts.truncateOutput(options.output);
|
|
106
|
+
}
|
|
107
|
+
const modelOutput = await originalToModelOutput(options);
|
|
108
|
+
if (modelOutput.type === "text" || modelOutput.type === "json") {
|
|
109
|
+
return opts.truncateOutput(modelOutput.value);
|
|
110
|
+
}
|
|
111
|
+
return modelOutput;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
103
114
|
}
|
|
104
115
|
return result;
|
|
105
116
|
}
|
|
@@ -219,16 +219,27 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
219
219
|
* Filters connections by connectorKey internally.
|
|
220
220
|
* Returns tools keyed as `${connectorKey}_${toolName}`.
|
|
221
221
|
*/
|
|
222
|
-
createTools(connections, config) {
|
|
222
|
+
createTools(connections, config, opts) {
|
|
223
223
|
const myConnections = connections.filter(
|
|
224
224
|
(c) => _ConnectorPlugin.deriveKey(c.connector.slug, c.connector.authType) === this.connectorKey
|
|
225
225
|
);
|
|
226
226
|
const result = {};
|
|
227
227
|
for (const t of Object.values(this.tools)) {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
228
|
+
const tool = t.createTool(myConnections, config);
|
|
229
|
+
const originalToModelOutput = tool.toModelOutput;
|
|
230
|
+
result[`${this.connectorKey}_${t.name}`] = {
|
|
231
|
+
...tool,
|
|
232
|
+
toModelOutput: async (options) => {
|
|
233
|
+
if (!originalToModelOutput) {
|
|
234
|
+
return opts.truncateOutput(options.output);
|
|
235
|
+
}
|
|
236
|
+
const modelOutput = await originalToModelOutput(options);
|
|
237
|
+
if (modelOutput.type === "text" || modelOutput.type === "json") {
|
|
238
|
+
return opts.truncateOutput(modelOutput.value);
|
|
239
|
+
}
|
|
240
|
+
return modelOutput;
|
|
241
|
+
}
|
|
242
|
+
};
|
|
232
243
|
}
|
|
233
244
|
return result;
|
|
234
245
|
}
|
|
@@ -90,16 +90,27 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
90
90
|
* Filters connections by connectorKey internally.
|
|
91
91
|
* Returns tools keyed as `${connectorKey}_${toolName}`.
|
|
92
92
|
*/
|
|
93
|
-
createTools(connections, config) {
|
|
93
|
+
createTools(connections, config, opts) {
|
|
94
94
|
const myConnections = connections.filter(
|
|
95
95
|
(c) => _ConnectorPlugin.deriveKey(c.connector.slug, c.connector.authType) === this.connectorKey
|
|
96
96
|
);
|
|
97
97
|
const result = {};
|
|
98
98
|
for (const t of Object.values(this.tools)) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
99
|
+
const tool = t.createTool(myConnections, config);
|
|
100
|
+
const originalToModelOutput = tool.toModelOutput;
|
|
101
|
+
result[`${this.connectorKey}_${t.name}`] = {
|
|
102
|
+
...tool,
|
|
103
|
+
toModelOutput: async (options) => {
|
|
104
|
+
if (!originalToModelOutput) {
|
|
105
|
+
return opts.truncateOutput(options.output);
|
|
106
|
+
}
|
|
107
|
+
const modelOutput = await originalToModelOutput(options);
|
|
108
|
+
if (modelOutput.type === "text" || modelOutput.type === "json") {
|
|
109
|
+
return opts.truncateOutput(modelOutput.value);
|
|
110
|
+
}
|
|
111
|
+
return modelOutput;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
103
114
|
}
|
|
104
115
|
return result;
|
|
105
116
|
}
|
|
@@ -237,16 +237,27 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
237
237
|
* Filters connections by connectorKey internally.
|
|
238
238
|
* Returns tools keyed as `${connectorKey}_${toolName}`.
|
|
239
239
|
*/
|
|
240
|
-
createTools(connections, config) {
|
|
240
|
+
createTools(connections, config, opts) {
|
|
241
241
|
const myConnections = connections.filter(
|
|
242
242
|
(c) => _ConnectorPlugin.deriveKey(c.connector.slug, c.connector.authType) === this.connectorKey
|
|
243
243
|
);
|
|
244
244
|
const result = {};
|
|
245
245
|
for (const t of Object.values(this.tools)) {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
246
|
+
const tool = t.createTool(myConnections, config);
|
|
247
|
+
const originalToModelOutput = tool.toModelOutput;
|
|
248
|
+
result[`${this.connectorKey}_${t.name}`] = {
|
|
249
|
+
...tool,
|
|
250
|
+
toModelOutput: async (options) => {
|
|
251
|
+
if (!originalToModelOutput) {
|
|
252
|
+
return opts.truncateOutput(options.output);
|
|
253
|
+
}
|
|
254
|
+
const modelOutput = await originalToModelOutput(options);
|
|
255
|
+
if (modelOutput.type === "text" || modelOutput.type === "json") {
|
|
256
|
+
return opts.truncateOutput(modelOutput.value);
|
|
257
|
+
}
|
|
258
|
+
return modelOutput;
|
|
259
|
+
}
|
|
260
|
+
};
|
|
250
261
|
}
|
|
251
262
|
return result;
|
|
252
263
|
}
|
|
@@ -186,16 +186,27 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
186
186
|
* Filters connections by connectorKey internally.
|
|
187
187
|
* Returns tools keyed as `${connectorKey}_${toolName}`.
|
|
188
188
|
*/
|
|
189
|
-
createTools(connections, config) {
|
|
189
|
+
createTools(connections, config, opts) {
|
|
190
190
|
const myConnections = connections.filter(
|
|
191
191
|
(c) => _ConnectorPlugin.deriveKey(c.connector.slug, c.connector.authType) === this.connectorKey
|
|
192
192
|
);
|
|
193
193
|
const result = {};
|
|
194
194
|
for (const t of Object.values(this.tools)) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
195
|
+
const tool = t.createTool(myConnections, config);
|
|
196
|
+
const originalToModelOutput = tool.toModelOutput;
|
|
197
|
+
result[`${this.connectorKey}_${t.name}`] = {
|
|
198
|
+
...tool,
|
|
199
|
+
toModelOutput: async (options) => {
|
|
200
|
+
if (!originalToModelOutput) {
|
|
201
|
+
return opts.truncateOutput(options.output);
|
|
202
|
+
}
|
|
203
|
+
const modelOutput = await originalToModelOutput(options);
|
|
204
|
+
if (modelOutput.type === "text" || modelOutput.type === "json") {
|
|
205
|
+
return opts.truncateOutput(modelOutput.value);
|
|
206
|
+
}
|
|
207
|
+
return modelOutput;
|
|
208
|
+
}
|
|
209
|
+
};
|
|
199
210
|
}
|
|
200
211
|
return result;
|
|
201
212
|
}
|
|
@@ -61,6 +61,15 @@ var parameters = {
|
|
|
61
61
|
type: "text",
|
|
62
62
|
secret: true,
|
|
63
63
|
required: true
|
|
64
|
+
}),
|
|
65
|
+
appId: new ParameterDefinition({
|
|
66
|
+
slug: "app-id",
|
|
67
|
+
name: "kintone App ID",
|
|
68
|
+
description: "The numeric ID of the kintone app this token is scoped to (visible in the app URL: https://{subdomain}.cybozu.com/k/{appId}/). API tokens are always scoped to a single app.",
|
|
69
|
+
envVarBaseKey: "KINTONE_APP_ID",
|
|
70
|
+
type: "text",
|
|
71
|
+
secret: false,
|
|
72
|
+
required: true
|
|
64
73
|
})
|
|
65
74
|
};
|
|
66
75
|
|
|
@@ -68,19 +77,58 @@ var parameters = {
|
|
|
68
77
|
function createClient(params) {
|
|
69
78
|
const baseUrl = params[parameters.baseUrl.slug];
|
|
70
79
|
const apiToken = params[parameters.apiToken.slug];
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
80
|
+
const appId = params[parameters.appId.slug];
|
|
81
|
+
const required = [
|
|
82
|
+
parameters.baseUrl.slug,
|
|
83
|
+
parameters.apiToken.slug,
|
|
84
|
+
parameters.appId.slug
|
|
85
|
+
];
|
|
86
|
+
const missing = required.filter((s) => !params[s]);
|
|
87
|
+
if (missing.length > 0) {
|
|
74
88
|
throw new Error(
|
|
75
89
|
`kintone: missing required parameters: ${missing.join(", ")}`
|
|
76
90
|
);
|
|
77
91
|
}
|
|
92
|
+
let _restClient = null;
|
|
93
|
+
async function getRestClient() {
|
|
94
|
+
if (!_restClient) {
|
|
95
|
+
const { KintoneRestAPIClient } = await import("@kintone/rest-api-client");
|
|
96
|
+
_restClient = new KintoneRestAPIClient({
|
|
97
|
+
baseUrl,
|
|
98
|
+
auth: { apiToken }
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
return _restClient;
|
|
102
|
+
}
|
|
78
103
|
return {
|
|
104
|
+
appId,
|
|
79
105
|
request(path2, init) {
|
|
80
106
|
const url = `${baseUrl.replace(/\/+$/, "")}${path2}`;
|
|
81
107
|
const headers = new Headers(init?.headers);
|
|
82
108
|
headers.set("X-Cybozu-API-Token", apiToken);
|
|
83
109
|
return fetch(url, { ...init, headers });
|
|
110
|
+
},
|
|
111
|
+
async getRecords(targetAppId, options) {
|
|
112
|
+
const client = await getRestClient();
|
|
113
|
+
const result = await client.record.getRecords({
|
|
114
|
+
app: targetAppId ?? appId,
|
|
115
|
+
query: options?.query,
|
|
116
|
+
fields: options?.fields,
|
|
117
|
+
totalCount: options?.totalCount
|
|
118
|
+
});
|
|
119
|
+
return {
|
|
120
|
+
records: result.records,
|
|
121
|
+
totalCount: result.totalCount ? Number(result.totalCount) : null
|
|
122
|
+
};
|
|
123
|
+
},
|
|
124
|
+
async getRecord(appIdOrRecordId, recordId) {
|
|
125
|
+
const client = await getRestClient();
|
|
126
|
+
const [targetAppId, targetRecordId] = recordId === void 0 ? [appId, appIdOrRecordId] : [appIdOrRecordId, recordId];
|
|
127
|
+
const result = await client.record.getRecord({
|
|
128
|
+
app: targetAppId,
|
|
129
|
+
id: targetRecordId
|
|
130
|
+
});
|
|
131
|
+
return { record: result.record };
|
|
84
132
|
}
|
|
85
133
|
};
|
|
86
134
|
}
|
|
@@ -167,16 +215,27 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
167
215
|
* Filters connections by connectorKey internally.
|
|
168
216
|
* Returns tools keyed as `${connectorKey}_${toolName}`.
|
|
169
217
|
*/
|
|
170
|
-
createTools(connections, config) {
|
|
218
|
+
createTools(connections, config, opts) {
|
|
171
219
|
const myConnections = connections.filter(
|
|
172
220
|
(c) => _ConnectorPlugin.deriveKey(c.connector.slug, c.connector.authType) === this.connectorKey
|
|
173
221
|
);
|
|
174
222
|
const result = {};
|
|
175
223
|
for (const t of Object.values(this.tools)) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
224
|
+
const tool = t.createTool(myConnections, config);
|
|
225
|
+
const originalToModelOutput = tool.toModelOutput;
|
|
226
|
+
result[`${this.connectorKey}_${t.name}`] = {
|
|
227
|
+
...tool,
|
|
228
|
+
toModelOutput: async (options) => {
|
|
229
|
+
if (!originalToModelOutput) {
|
|
230
|
+
return opts.truncateOutput(options.output);
|
|
231
|
+
}
|
|
232
|
+
const modelOutput = await originalToModelOutput(options);
|
|
233
|
+
if (modelOutput.type === "text" || modelOutput.type === "json") {
|
|
234
|
+
return opts.truncateOutput(modelOutput.value);
|
|
235
|
+
}
|
|
236
|
+
return modelOutput;
|
|
237
|
+
}
|
|
238
|
+
};
|
|
180
239
|
}
|
|
181
240
|
return result;
|
|
182
241
|
}
|
|
@@ -198,23 +257,49 @@ var AUTH_TYPES = {
|
|
|
198
257
|
// ../connectors/src/connectors/kintone-api-token/setup.ts
|
|
199
258
|
var kintoneApiTokenOnboarding = new ConnectorOnboarding({
|
|
200
259
|
dataOverviewInstructions: {
|
|
201
|
-
en: `
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
260
|
+
en: `Each connection is scoped to a single kintone app (configured via the "app-id" parameter). The request tool auto-injects the configured app id, so you do NOT need to specify "app=" in paths or "app" in bodies. apps.json is NOT available with API Token auth.
|
|
261
|
+
|
|
262
|
+
1. Call kintone-api-token_request with GET app.json to fetch the scoped app's metadata (name, description, creator)
|
|
263
|
+
2. Call kintone-api-token_request with GET app/form/fields.json to get field definitions
|
|
264
|
+
3. Call kintone-api-token_request with GET records.json with query=limit 5 to sample records`,
|
|
265
|
+
ja: `\u5404\u63A5\u7D9A\u306F1\u3064\u306Ekintone\u30A2\u30D7\u30EA\u306B\u30B9\u30B3\u30FC\u30D7\u3055\u308C\u3066\u3044\u307E\u3059\uFF08"app-id" \u30D1\u30E9\u30E1\u30FC\u30BF\u3067\u8A2D\u5B9A\uFF09\u3002request \u30C4\u30FC\u30EB\u306F\u8A2D\u5B9A\u3055\u308C\u305F\u30A2\u30D7\u30EAID\u3092\u81EA\u52D5\u6CE8\u5165\u3059\u308B\u305F\u3081\u3001\u30D1\u30B9\u306B "app=" \u3084 body \u306B "app" \u3092\u6307\u5B9A\u3059\u308B\u5FC5\u8981\u306F\u3042\u308A\u307E\u305B\u3093\u3002API Token \u8A8D\u8A3C\u3067\u306F apps.json \u306F\u5229\u7528\u3067\u304D\u307E\u305B\u3093\u3002
|
|
266
|
+
|
|
267
|
+
1. kintone-api-token_request \u3067 GET app.json \u3092\u547C\u3073\u51FA\u3057\u3001\u30B9\u30B3\u30FC\u30D7\u5BFE\u8C61\u30A2\u30D7\u30EA\u306E\u30E1\u30BF\u60C5\u5831\uFF08\u30A2\u30D7\u30EA\u540D\u3001\u8AAC\u660E\u3001\u4F5C\u6210\u8005\uFF09\u3092\u53D6\u5F97
|
|
268
|
+
2. kintone-api-token_request \u3067 GET app/form/fields.json \u3092\u547C\u3073\u51FA\u3057\u3001\u30D5\u30A3\u30FC\u30EB\u30C9\u5B9A\u7FA9\u3092\u53D6\u5F97
|
|
269
|
+
3. kintone-api-token_request \u3067 GET records.json \u3092 query=limit 5 \u3067\u547C\u3073\u51FA\u3057\u3001\u30EC\u30B3\u30FC\u30C9\u3092\u30B5\u30F3\u30D7\u30EA\u30F3\u30B0`
|
|
207
270
|
}
|
|
208
271
|
});
|
|
209
272
|
|
|
210
273
|
// ../connectors/src/connectors/kintone-api-token/tools/request.ts
|
|
211
274
|
import { z } from "zod";
|
|
212
275
|
var REQUEST_TIMEOUT_MS = 6e4;
|
|
276
|
+
var APP_PARAM_KEY_BY_ENDPOINT = {
|
|
277
|
+
"app.json": "id"
|
|
278
|
+
};
|
|
279
|
+
var DEFAULT_APP_PARAM_KEY = "app";
|
|
280
|
+
function injectAppIntoPath(path2, appId) {
|
|
281
|
+
const [head, query = ""] = path2.split("?", 2);
|
|
282
|
+
const endpoint = head.toLowerCase();
|
|
283
|
+
const paramKey = APP_PARAM_KEY_BY_ENDPOINT[endpoint] ?? DEFAULT_APP_PARAM_KEY;
|
|
284
|
+
const params = new URLSearchParams(query);
|
|
285
|
+
if (!params.has(paramKey)) {
|
|
286
|
+
params.set(paramKey, appId);
|
|
287
|
+
}
|
|
288
|
+
const serialized = params.toString();
|
|
289
|
+
return serialized ? `${head}?${serialized}` : head;
|
|
290
|
+
}
|
|
291
|
+
function injectAppIntoBody(body, appId) {
|
|
292
|
+
if (!body) return body;
|
|
293
|
+
if ("app" in body) return body;
|
|
294
|
+
return { app: appId, ...body };
|
|
295
|
+
}
|
|
213
296
|
var inputSchema = z.object({
|
|
214
297
|
toolUseIntent: z.string().optional().describe("Brief description of what you intend to accomplish with this tool call"),
|
|
215
298
|
connectionId: z.string().describe("ID of the kintone connection to use"),
|
|
216
299
|
method: z.enum(["GET", "POST", "PUT", "DELETE"]).describe("HTTP method"),
|
|
217
|
-
path: z.string().describe(
|
|
300
|
+
path: z.string().describe(
|
|
301
|
+
"API path (e.g., 'app.json', 'app/form/fields.json', 'records.json?query=limit 5'). The connection's app id is auto-injected; you do not need to include 'app=' in the query string. 'apps.json' is not supported with API Token auth."
|
|
302
|
+
),
|
|
218
303
|
body: z.record(z.string(), z.unknown()).optional().describe("Request body (JSON)")
|
|
219
304
|
});
|
|
220
305
|
var outputSchema = z.discriminatedUnion("success", [
|
|
@@ -243,20 +328,31 @@ Authentication is handled automatically using the API token.`,
|
|
|
243
328
|
try {
|
|
244
329
|
const baseUrl = parameters.baseUrl.getValue(connection2);
|
|
245
330
|
const apiToken = parameters.apiToken.getValue(connection2);
|
|
246
|
-
const
|
|
331
|
+
const appId = parameters.appId.getValue(connection2);
|
|
332
|
+
const normalizedPath = path2.replace(/^\/+/, "");
|
|
333
|
+
const pathHead = normalizedPath.split("?")[0] ?? "";
|
|
334
|
+
if (/^apps\.json$/i.test(pathHead)) {
|
|
335
|
+
return {
|
|
336
|
+
success: false,
|
|
337
|
+
error: `kintone API tokens are scoped to a single app and cannot list apps. This connection is scoped to app ${appId}. Use app-specific endpoints (e.g., app.json, app/form/fields.json, records.json).`
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
const injectedPath = injectAppIntoPath(normalizedPath, appId);
|
|
341
|
+
const injectedBody = injectAppIntoBody(body, appId);
|
|
342
|
+
const url = `${baseUrl.replace(/\/+$/, "")}/k/v1/${injectedPath}`;
|
|
247
343
|
const controller = new AbortController();
|
|
248
344
|
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
249
345
|
try {
|
|
250
346
|
const headers = {
|
|
251
347
|
"X-Cybozu-API-Token": apiToken
|
|
252
348
|
};
|
|
253
|
-
if (
|
|
349
|
+
if (injectedBody) {
|
|
254
350
|
headers["Content-Type"] = "application/json";
|
|
255
351
|
}
|
|
256
352
|
const response = await fetch(url, {
|
|
257
353
|
method,
|
|
258
354
|
headers,
|
|
259
|
-
body:
|
|
355
|
+
body: injectedBody ? JSON.stringify(injectedBody) : void 0,
|
|
260
356
|
signal: controller.signal
|
|
261
357
|
});
|
|
262
358
|
const data = await response.json();
|
|
@@ -291,98 +387,150 @@ var kintoneApiTokenConnector = new ConnectorPlugin({
|
|
|
291
387
|
systemPrompt: {
|
|
292
388
|
en: `### Tools
|
|
293
389
|
|
|
294
|
-
- \`kintone-api-
|
|
390
|
+
- \`kintone-api-token_request\`: The only way to call the kintone REST API. Use it to fetch app metadata/field definitions and read/write records. Authentication (API Token), base URL, and the connection's app id are configured automatically. Each connection is scoped to exactly one app (kintone API tokens are per-app).
|
|
295
391
|
|
|
296
|
-
###
|
|
297
|
-
|
|
298
|
-
#### List Apps
|
|
299
|
-
- GET apps.json
|
|
300
|
-
|
|
301
|
-
### Get Field Definitions
|
|
302
|
-
- GET app/form/fields.json?app={appId}
|
|
303
|
-
|
|
304
|
-
### Get Records
|
|
305
|
-
- GET records.json?app={appId}&query={query}
|
|
306
|
-
- Query example: records.json?app=1&query=updatedTime > "2024-01-01" order by recordNumber asc limit 100
|
|
307
|
-
|
|
308
|
-
#### Add Record
|
|
309
|
-
- POST record.json
|
|
310
|
-
- Body: { "app": 1, "record": { "fieldName": { "value": "value" } } }
|
|
392
|
+
### App scoping (important)
|
|
311
393
|
|
|
312
|
-
|
|
313
|
-
-
|
|
314
|
-
-
|
|
315
|
-
-
|
|
316
|
-
-
|
|
317
|
-
-
|
|
394
|
+
- Each connection is scoped to one app, configured via the "app-id" parameter.
|
|
395
|
+
- The request tool auto-injects the configured app id:
|
|
396
|
+
- Query string: adds \`app=<appId>\` to paths like \`records.json\`, \`app/form/fields.json\`, etc. when missing. For \`app.json\` (app metadata), adds \`id=<appId>\` instead.
|
|
397
|
+
- Request body: adds \`"app": <appId>\` to POST/PUT bodies when missing.
|
|
398
|
+
- You do NOT need to include "app=" in paths or "app" in bodies \u2014 it is handled for you.
|
|
399
|
+
- \`apps.json\` (list all apps) is NOT callable with API Token auth.
|
|
318
400
|
|
|
319
401
|
### Business Logic
|
|
320
402
|
|
|
321
|
-
The business logic type for this connector is "typescript".
|
|
403
|
+
The business logic type for this connector is "typescript". Use the connector SDK in your handler. Do NOT read credentials from environment variables.
|
|
322
404
|
|
|
323
|
-
|
|
405
|
+
SDK surface (client created via \`connection(connectionId)\`):
|
|
406
|
+
- \`client.appId\` \u2014 the numeric app id this connection is scoped to
|
|
407
|
+
- \`client.request(path, init?)\` \u2014 low-level authenticated fetch (pass \`?app=\${client.appId}\` yourself)
|
|
408
|
+
- \`client.getRecords(appId?, options?)\` \u2014 fetch records; if \`appId\` is omitted, the connection's app id is used
|
|
409
|
+
- \`client.getRecord(appIdOrRecordId, recordId?)\` \u2014 fetch a single record; if called with one argument it is treated as the record id and the connection's app id is used
|
|
324
410
|
|
|
325
411
|
\`\`\`ts
|
|
326
|
-
import {
|
|
412
|
+
import type { Context } from "hono";
|
|
413
|
+
import { connection } from "@squadbase/vite-server/connectors/kintone-api-token";
|
|
327
414
|
|
|
328
415
|
const kintone = connection("<connectionId>");
|
|
329
416
|
|
|
330
|
-
|
|
331
|
-
const
|
|
332
|
-
|
|
417
|
+
export default async function handler(c: Context) {
|
|
418
|
+
const { status = "Active" } = await c.req.json<{ status?: string }>();
|
|
419
|
+
|
|
420
|
+
const { records, totalCount } = await kintone.getRecords(undefined, {
|
|
421
|
+
query: \`status = "\${status}" order by updatedTime desc limit 100\`,
|
|
422
|
+
fields: ["$id", "name", "email", "status", "updatedTime"],
|
|
423
|
+
totalCount: true,
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
return c.json({
|
|
427
|
+
totalCount,
|
|
428
|
+
rows: records.map((r) => ({
|
|
429
|
+
id: r.$id.value,
|
|
430
|
+
name: r.name?.value,
|
|
431
|
+
email: r.email?.value,
|
|
432
|
+
status: r.status?.value,
|
|
433
|
+
updatedTime: r.updatedTime?.value,
|
|
434
|
+
})),
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
\`\`\`
|
|
333
438
|
|
|
334
|
-
|
|
335
|
-
method: "POST",
|
|
336
|
-
body: JSON.stringify({ app: 1, record: { title: { value: "Hello" } } }),
|
|
337
|
-
});
|
|
338
|
-
\`\`\``,
|
|
339
|
-
ja: `### \u30C4\u30FC\u30EB
|
|
439
|
+
### kintone REST API Reference
|
|
340
440
|
|
|
341
|
-
|
|
441
|
+
#### Get App Metadata
|
|
442
|
+
- \`GET app.json\` \u2192 returns { appId, name, description, createdAt, modifiedAt, creator, ... }
|
|
342
443
|
|
|
343
|
-
|
|
444
|
+
#### Get Field Definitions
|
|
445
|
+
- \`GET app/form/fields.json\`
|
|
344
446
|
|
|
345
|
-
####
|
|
346
|
-
- GET
|
|
447
|
+
#### Get Records
|
|
448
|
+
- \`GET records.json?query={query}\`
|
|
449
|
+
- Query example: \`records.json?query=updatedTime > "2024-01-01" order by recordNumber asc limit 100\`
|
|
347
450
|
|
|
348
|
-
|
|
349
|
-
-
|
|
451
|
+
#### Add Record
|
|
452
|
+
- \`POST record.json\`
|
|
453
|
+
- Body: \`{ "record": { "fieldName": { "value": "value" } } }\`
|
|
350
454
|
|
|
351
|
-
|
|
352
|
-
-
|
|
353
|
-
-
|
|
455
|
+
#### kintone Query Syntax
|
|
456
|
+
- Comparison: \`fieldName = "value"\`, \`fieldName > 100\`
|
|
457
|
+
- Operators: \`and\`, \`or\`, \`not\`
|
|
458
|
+
- Sort: \`order by fieldName asc/desc\`
|
|
459
|
+
- Limit: \`limit 100 offset 0\`
|
|
460
|
+
- String: \`like "partial match"\``,
|
|
461
|
+
ja: `### \u30C4\u30FC\u30EB
|
|
354
462
|
|
|
355
|
-
|
|
356
|
-
- POST record.json
|
|
357
|
-
- Body: { "app": 1, "record": { "fieldName": { "value": "value" } } }
|
|
463
|
+
- \`kintone-api-token_request\`: kintone REST API\u3092\u547C\u3073\u51FA\u3059\u552F\u4E00\u306E\u624B\u6BB5\u3067\u3059\u3002\u30A2\u30D7\u30EA\u306E\u30E1\u30BF\u60C5\u5831\u30FB\u30D5\u30A3\u30FC\u30EB\u30C9\u5B9A\u7FA9\u306E\u53D6\u5F97\u3001\u30EC\u30B3\u30FC\u30C9\u306E\u8AAD\u307F\u66F8\u304D\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002\u8A8D\u8A3C\uFF08API\u30C8\u30FC\u30AF\u30F3\uFF09\u3001\u30D9\u30FC\u30B9URL\u3001\u304A\u3088\u3073\u63A5\u7D9A\u306E\u30A2\u30D7\u30EAID\u306F\u81EA\u52D5\u7684\u306B\u8A2D\u5B9A\u3055\u308C\u307E\u3059\u3002\u5404\u63A5\u7D9A\u306F\u3061\u3087\u3046\u30691\u3064\u306E\u30A2\u30D7\u30EA\u306B\u30B9\u30B3\u30FC\u30D7\u3055\u308C\u3066\u3044\u307E\u3059\uFF08kintone API\u30C8\u30FC\u30AF\u30F3\u306F\u30A2\u30D7\u30EA\u5358\u4F4D\u306E\u305F\u3081\uFF09\u3002
|
|
358
464
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
- \
|
|
362
|
-
- \
|
|
363
|
-
- \
|
|
364
|
-
- \
|
|
465
|
+
### \u30A2\u30D7\u30EA\u30B9\u30B3\u30FC\u30D7\uFF08\u91CD\u8981\uFF09
|
|
466
|
+
|
|
467
|
+
- \u5404\u63A5\u7D9A\u306F1\u3064\u306E\u30A2\u30D7\u30EA\u306B\u30B9\u30B3\u30FC\u30D7\u3055\u308C\u3066\u3044\u307E\u3059\uFF08"app-id" \u30D1\u30E9\u30E1\u30FC\u30BF\u3067\u8A2D\u5B9A\uFF09\u3002
|
|
468
|
+
- request \u30C4\u30FC\u30EB\u306F\u8A2D\u5B9A\u3055\u308C\u305F\u30A2\u30D7\u30EAID\u3092\u81EA\u52D5\u6CE8\u5165\u3057\u307E\u3059:
|
|
469
|
+
- \u30AF\u30A8\u30EA\u6587\u5B57\u5217: \`records.json\` \u3084 \`app/form/fields.json\` \u7B49\u306E\u30D1\u30B9\u306B \`app=\` \u304C\u7121\u3051\u308C\u3070 \`app=<appId>\` \u3092\u4ED8\u4E0E\u3057\u307E\u3059\u3002\`app.json\`\uFF08\u30A2\u30D7\u30EA\u30E1\u30BF\u60C5\u5831\uFF09\u306E\u5834\u5408\u306F\u4EE3\u308F\u308A\u306B \`id=<appId>\` \u3092\u4ED8\u4E0E\u3057\u307E\u3059\u3002
|
|
470
|
+
- \u30EA\u30AF\u30A8\u30B9\u30C8\u30DC\u30C7\u30A3: POST/PUT \u306E\u30DC\u30C7\u30A3\u306B \`"app"\` \u304C\u7121\u3051\u308C\u3070\u81EA\u52D5\u7684\u306B\u8FFD\u52A0\u3057\u307E\u3059\u3002
|
|
471
|
+
- \u30D1\u30B9\u306B "app=" \u3084\u30DC\u30C7\u30A3\u306B "app" \u3092\u660E\u793A\u3059\u308B\u5FC5\u8981\u306F\u3042\u308A\u307E\u305B\u3093 \u2014 \u81EA\u52D5\u3067\u51E6\u7406\u3055\u308C\u307E\u3059\u3002
|
|
472
|
+
- \`apps.json\`\uFF08\u5168\u30A2\u30D7\u30EA\u4E00\u89A7\uFF09\u306F API Token \u8A8D\u8A3C\u3067\u306F\u547C\u3073\u51FA\u305B\u307E\u305B\u3093\u3002
|
|
365
473
|
|
|
366
474
|
### Business Logic
|
|
367
475
|
|
|
368
|
-
\u3053\u306E\u30B3\u30CD\u30AF\u30BF\u306E\u30D3\u30B8\u30CD\u30B9\u30ED\u30B8\u30C3\u30AF\u30BF\u30A4\u30D7\u306F "typescript" \u3067\u3059\u3002\
|
|
476
|
+
\u3053\u306E\u30B3\u30CD\u30AF\u30BF\u306E\u30D3\u30B8\u30CD\u30B9\u30ED\u30B8\u30C3\u30AF\u30BF\u30A4\u30D7\u306F "typescript" \u3067\u3059\u3002\u30CF\u30F3\u30C9\u30E9\u5185\u3067\u306F\u30B3\u30CD\u30AF\u30BFSDK\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u74B0\u5883\u5909\u6570\u304B\u3089\u8A8D\u8A3C\u60C5\u5831\u3092\u8AAD\u307F\u53D6\u3089\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002
|
|
369
477
|
|
|
370
|
-
|
|
478
|
+
SDK\uFF08\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8\uFF09:
|
|
479
|
+
- \`client.appId\` \u2014 \u3053\u306E\u63A5\u7D9A\u304C\u30B9\u30B3\u30FC\u30D7\u3055\u308C\u3066\u3044\u308B\u30A2\u30D7\u30EAID
|
|
480
|
+
- \`client.request(path, init?)\` \u2014 \u4F4E\u30EC\u30D9\u30EB\u306E\u8A8D\u8A3C\u4ED8\u304Dfetch\uFF08\`?app=\${client.appId}\` \u306F\u81EA\u5206\u3067\u4ED8\u3051\u308B\uFF09
|
|
481
|
+
- \`client.getRecords(appId?, options?)\` \u2014 \`appId\` \u3092\u7701\u7565\u3059\u308B\u3068\u63A5\u7D9A\u306E\u30A2\u30D7\u30EAID\u304C\u4F7F\u308F\u308C\u307E\u3059
|
|
482
|
+
- \`client.getRecord(appIdOrRecordId, recordId?)\` \u2014 \u5F15\u65701\u3064\u3067\u547C\u3076\u3068\u305D\u308C\u3092\u30EC\u30B3\u30FC\u30C9ID\u3068\u3057\u3066\u6271\u3044\u3001\u63A5\u7D9A\u306E\u30A2\u30D7\u30EAID\u3092\u4F7F\u3044\u307E\u3059
|
|
371
483
|
|
|
372
484
|
\`\`\`ts
|
|
373
|
-
import {
|
|
485
|
+
import type { Context } from "hono";
|
|
486
|
+
import { connection } from "@squadbase/vite-server/connectors/kintone-api-token";
|
|
374
487
|
|
|
375
488
|
const kintone = connection("<connectionId>");
|
|
376
489
|
|
|
377
|
-
|
|
378
|
-
const
|
|
379
|
-
|
|
490
|
+
export default async function handler(c: Context) {
|
|
491
|
+
const { status = "Active" } = await c.req.json<{ status?: string }>();
|
|
492
|
+
|
|
493
|
+
const { records, totalCount } = await kintone.getRecords(undefined, {
|
|
494
|
+
query: \`status = "\${status}" order by updatedTime desc limit 100\`,
|
|
495
|
+
fields: ["$id", "name", "email", "status", "updatedTime"],
|
|
496
|
+
totalCount: true,
|
|
497
|
+
});
|
|
498
|
+
|
|
499
|
+
return c.json({
|
|
500
|
+
totalCount,
|
|
501
|
+
rows: records.map((r) => ({
|
|
502
|
+
id: r.$id.value,
|
|
503
|
+
name: r.name?.value,
|
|
504
|
+
email: r.email?.value,
|
|
505
|
+
status: r.status?.value,
|
|
506
|
+
updatedTime: r.updatedTime?.value,
|
|
507
|
+
})),
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
\`\`\`
|
|
380
511
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
}
|
|
385
|
-
|
|
512
|
+
### kintone REST API \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
|
|
513
|
+
|
|
514
|
+
#### \u30A2\u30D7\u30EA\u30E1\u30BF\u60C5\u5831\u306E\u53D6\u5F97
|
|
515
|
+
- \`GET app.json\` \u2192 { appId, name, description, createdAt, modifiedAt, creator, ... } \u3092\u8FD4\u3059
|
|
516
|
+
|
|
517
|
+
#### \u30D5\u30A3\u30FC\u30EB\u30C9\u5B9A\u7FA9\u306E\u53D6\u5F97
|
|
518
|
+
- \`GET app/form/fields.json\`
|
|
519
|
+
|
|
520
|
+
#### \u30EC\u30B3\u30FC\u30C9\u306E\u53D6\u5F97
|
|
521
|
+
- \`GET records.json?query={query}\`
|
|
522
|
+
- \u30AF\u30A8\u30EA\u4F8B: \`records.json?query=updatedTime > "2024-01-01" order by recordNumber asc limit 100\`
|
|
523
|
+
|
|
524
|
+
#### \u30EC\u30B3\u30FC\u30C9\u306E\u8FFD\u52A0
|
|
525
|
+
- \`POST record.json\`
|
|
526
|
+
- Body: \`{ "record": { "fieldName": { "value": "value" } } }\`
|
|
527
|
+
|
|
528
|
+
#### kintone \u30AF\u30A8\u30EA\u69CB\u6587
|
|
529
|
+
- \u6BD4\u8F03: \`fieldName = "value"\`, \`fieldName > 100\`
|
|
530
|
+
- \u6F14\u7B97\u5B50: \`and\`, \`or\`, \`not\`
|
|
531
|
+
- \u30BD\u30FC\u30C8: \`order by fieldName asc/desc\`
|
|
532
|
+
- \u5236\u9650: \`limit 100 offset 0\`
|
|
533
|
+
- \u6587\u5B57\u5217: \`like "\u90E8\u5206\u4E00\u81F4"\``
|
|
386
534
|
},
|
|
387
535
|
tools
|
|
388
536
|
});
|