@squadbase/vite-server 0.1.3 → 0.1.4-dev.0
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 +239 -55
- package/dist/connectors/attio.js +479 -112
- package/dist/index.js +239 -55
- package/dist/main.js +239 -55
- package/dist/vite-plugin.js +239 -55
- package/package.json +1 -1
package/dist/vite-plugin.js
CHANGED
|
@@ -76455,14 +76455,18 @@ export default async function handler(c: Context) {
|
|
|
76455
76455
|
// ../connectors/src/connectors/attio/setup.ts
|
|
76456
76456
|
var attioOnboarding = new ConnectorOnboarding({
|
|
76457
76457
|
dataOverviewInstructions: {
|
|
76458
|
-
en: `1. Call attio_request with GET /objects to
|
|
76459
|
-
2.
|
|
76460
|
-
3. Call attio_request with POST /objects/
|
|
76461
|
-
4.
|
|
76462
|
-
|
|
76463
|
-
|
|
76464
|
-
|
|
76465
|
-
|
|
76458
|
+
en: `1. Call attio_request with GET /objects to discover the object slugs actually configured in this workspace (typically people, companies, deals, plus any custom objects).
|
|
76459
|
+
2. For each object you plan to use, call attio_request with GET /objects/{slug}/attributes to explore its attributes
|
|
76460
|
+
3. Call attio_request with POST /objects/{slug}/records/query with { "limit": 5 } to sample records
|
|
76461
|
+
4. Call attio_request with GET /workspace_members (top-level, snake_case) to list team members. The response shape is \`{ data: [{ id: { workspace_member_id }, first_name, last_name, email_address, ... }] }\`. You need this mapping in dashboard handlers to resolve \`owner\` and other actor-reference fields (which return \`referenced_actor_id\`, not a name). Sample one record that has an \`owner\` and confirm the shape \`{ referenced_actor_type, referenced_actor_id }\`, then use \`client.getWorkspaceMemberMap()\` in handlers to resolve IDs to names.
|
|
76462
|
+
5. If an endpoint later returns 403 (tasks / threads / webhooks / meetings require specific scopes), call GET /self to inspect the token's active scopes.
|
|
76463
|
+
6. Explore lists via GET /lists as needed, and use /notes, /tasks, /threads, /comments, /webhooks, /meetings when the question requires them.`,
|
|
76464
|
+
ja: `1. attio_request \u3067 GET /objects \u3092\u547C\u3073\u51FA\u3057\u3001\u3053\u306E\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u306B\u5B9F\u5728\u3059\u308B\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8slug\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u901A\u5E38\u306F people / companies / deals\u3001\u52A0\u3048\u3066\u8A2D\u5B9A\u6E08\u307F\u306E\u30AB\u30B9\u30BF\u30E0\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\uFF09
|
|
76465
|
+
2. \u4F7F\u3046\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3054\u3068\u306B attio_request \u3067 GET /objects/{slug}/attributes \u3092\u547C\u3073\u51FA\u3057\u3001\u5C5E\u6027\u3092\u78BA\u8A8D
|
|
76466
|
+
3. attio_request \u3067 POST /objects/{slug}/records/query \u3092 { "limit": 5 } \u3067\u547C\u3073\u51FA\u3057\u3001\u30EC\u30B3\u30FC\u30C9\u3092\u30B5\u30F3\u30D7\u30EA\u30F3\u30B0
|
|
76467
|
+
4. attio_request \u3067 GET /workspace_members\uFF08\u30C8\u30C3\u30D7\u30EC\u30D9\u30EB\u3001\u30B9\u30CD\u30FC\u30AF\u30B1\u30FC\u30B9\uFF09\u3092\u547C\u3073\u51FA\u3057\u3001\u30C1\u30FC\u30E0\u30E1\u30F3\u30D0\u30FC\u4E00\u89A7\u3092\u53D6\u5F97\u3002\u30EC\u30B9\u30DD\u30F3\u30B9\u306F \`{ data: [{ id: { workspace_member_id }, first_name, last_name, email_address, ... }] }\` \u306E\u5F62\u5F0F\u3067\u3059\u3002\u3053\u306E\u30DE\u30C3\u30D4\u30F3\u30B0\u306F\u3001\`owner\` \u306A\u3069\u306E actor-reference \u30D5\u30A3\u30FC\u30EB\u30C9\uFF08\`referenced_actor_id\` \u3092\u8FD4\u3059\uFF09\u3092\u540D\u524D\u306B\u89E3\u6C7A\u3059\u308B\u305F\u3081\u306B\u30C0\u30C3\u30B7\u30E5\u30DC\u30FC\u30C9\u30CF\u30F3\u30C9\u30E9\u3067\u5FC5\u9808\u3067\u3059\u3002\`owner\` \u3092\u6301\u3064\u30EC\u30B3\u30FC\u30C9\u30921\u4EF6\u30B5\u30F3\u30D7\u30EA\u30F3\u30B0\u3057\u3001\`{ referenced_actor_type, referenced_actor_id }\` \u306E\u5F62\u3092\u78BA\u8A8D\u3057\u305F\u4E0A\u3067\u3001\u30CF\u30F3\u30C9\u30E9\u3067\u306F \`client.getWorkspaceMemberMap()\` \u3092\u4F7F\u3063\u3066 ID \u2192 \u540D\u524D \u306B\u89E3\u6C7A\u3057\u3066\u304F\u3060\u3055\u3044
|
|
76468
|
+
5. \u5F8C\u6BB5\u3067 403 \u304C\u51FA\u305F\u5834\u5408\uFF08tasks / threads / webhooks / meetings \u306A\u3069\u306F\u500B\u5225\u306E scope \u304C\u5FC5\u8981\uFF09\u306F\u3001GET /self \u3092\u547C\u3073\u51FA\u3057\u3066API\u30C8\u30FC\u30AF\u30F3\u306E\u6709\u52B9 scope \u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044
|
|
76469
|
+
6. \u5FC5\u8981\u306B\u5FDC\u3058\u3066 GET /lists \u3067\u30EA\u30B9\u30C8\u3092\u63A2\u7D22\u3057\u3001/notes\u3001/tasks\u3001/threads\u3001/comments\u3001/webhooks\u3001/meetings \u3082\u6D3B\u7528\u3057\u3066\u304F\u3060\u3055\u3044`
|
|
76466
76470
|
}
|
|
76467
76471
|
});
|
|
76468
76472
|
|
|
@@ -76488,11 +76492,11 @@ var inputSchema39 = z39.object({
|
|
|
76488
76492
|
"Brief description of what you intend to accomplish with this tool call"
|
|
76489
76493
|
),
|
|
76490
76494
|
connectionId: z39.string().describe("ID of the Attio connection to use"),
|
|
76491
|
-
method: z39.enum(["GET", "POST", "PATCH", "DELETE"]).describe(
|
|
76492
|
-
"HTTP method. GET for reading resources, POST for creating
|
|
76495
|
+
method: z39.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]).describe(
|
|
76496
|
+
"HTTP method. GET for reading resources and list endpoints, POST for creating records/querying/asserting, PATCH for partial updates (append multiselect), PUT for full updates (overwrite multiselect), DELETE for removing."
|
|
76493
76497
|
),
|
|
76494
76498
|
path: z39.string().describe(
|
|
76495
|
-
"API path (
|
|
76499
|
+
"Attio REST API path relative to https://api.attio.com/v2 (include the leading slash). Examples: '/self', '/objects', '/objects/people/attributes', '/objects/people/records/query', '/objects/companies/records/{record_id}', '/workspace_members', '/workspace_members/{workspace_member_id}', '/lists', '/lists/{list_id}/entries/query', '/notes', '/tasks', '/threads', '/comments', '/webhooks', '/meetings'."
|
|
76496
76500
|
),
|
|
76497
76501
|
body: z39.record(z39.string(), z39.unknown()).optional().describe("Request body (JSON) for POST/PATCH requests")
|
|
76498
76502
|
});
|
|
@@ -76509,10 +76513,10 @@ var outputSchema39 = z39.discriminatedUnion("success", [
|
|
|
76509
76513
|
]);
|
|
76510
76514
|
var requestTool20 = new ConnectorTool({
|
|
76511
76515
|
name: "request",
|
|
76512
|
-
description: `Send authenticated requests to the Attio REST API.
|
|
76516
|
+
description: `Send authenticated requests to the Attio REST API (base URL: https://api.attio.com/v2).
|
|
76513
76517
|
Authentication is handled automatically using the API Key (Bearer token).
|
|
76514
|
-
Use this tool for
|
|
76515
|
-
|
|
76518
|
+
Use this tool for every Attio API interaction, including: querying records (people, companies, deals, and any custom objects configured in the workspace) and their attributes, listing/getting/creating/updating/deleting records and list entries, reading workspace members, and working with notes, tasks, threads, comments, webhooks, and meetings. Call GET /self to introspect the current API token.
|
|
76519
|
+
Record queries use POST /objects/{object}/records/query with a JSON body containing \`filter\`, \`sorts\`, \`limit\`, and \`offset\`. Record updates use PATCH (append multiselect) or PUT (overwrite multiselect). Workspace members, tasks, webhooks, notes, threads, comments, and meetings live at top-level paths \u2014 the workspace-members path uses a snake_case underscore: /workspace_members.`,
|
|
76516
76520
|
inputSchema: inputSchema39,
|
|
76517
76521
|
outputSchema: outputSchema39,
|
|
76518
76522
|
async execute({ connectionId, method, path: path4, body }, connections) {
|
|
@@ -76571,19 +76575,69 @@ var attioConnector = new ConnectorPlugin({
|
|
|
76571
76575
|
systemPrompt: {
|
|
76572
76576
|
en: `### Tools
|
|
76573
76577
|
|
|
76574
|
-
- \`attio_request\`: The only way to call the Attio REST API. Use it
|
|
76578
|
+
- \`attio_request\`: The only way to call the Attio REST API. Use it for every Attio resource \u2014 records (people, companies, deals, and any custom objects configured in the workspace), their attributes, lists and entries, workspace members, notes, tasks, threads, comments, webhooks, and meetings. Authentication (Bearer token) is configured automatically. Querying records uses POST \`/objects/{object}/records/query\` with a JSON body. Use PATCH for partial updates (append multiselect) and PUT for full updates (overwrite multiselect). Always call GET \`/objects\` first to discover the actual object slugs in this workspace.
|
|
76575
76579
|
|
|
76576
76580
|
### Business Logic
|
|
76577
76581
|
|
|
76578
|
-
The business logic type for this connector is "typescript". Use the connector SDK in your handler
|
|
76582
|
+
The business logic type for this connector is "typescript". Use the connector SDK in your handler; authentication is handled by the SDK client.
|
|
76579
76583
|
|
|
76580
76584
|
SDK methods (client created via \`connection(connectionId)\`):
|
|
76581
76585
|
- \`client.request(path, init?)\` \u2014 low-level authenticated fetch
|
|
76582
|
-
- \`client.
|
|
76583
|
-
- \`client.
|
|
76584
|
-
- \`client.
|
|
76585
|
-
- \`client.getRecord(object, recordId)\`
|
|
76586
|
-
- \`client.queryListEntries(listId, options?)\`
|
|
76586
|
+
- \`client.self()\` \u2014 current API token introspection (GET /self) \u2014 returns workspace id, scopes, token status
|
|
76587
|
+
- Objects: \`client.listObjects()\`, \`client.getObject(object)\`, \`client.listObjectViews(object)\`
|
|
76588
|
+
- Attributes: \`client.listAttributes(object)\`, \`client.getAttribute(object, attribute)\`, \`client.listSelectOptions(object, attribute)\`, \`client.listStatuses(object, attribute)\`
|
|
76589
|
+
- Records: \`client.queryRecords(object, options?)\`, \`client.getRecord(object, recordId)\`, \`client.createRecord(object, data)\`, \`client.updateRecord(object, recordId, data)\` (PATCH), \`client.overwriteRecord(object, recordId, data)\` (PUT), \`client.deleteRecord(object, recordId)\`, \`client.assertRecord(object, data)\`, \`client.listRecordEntries(object, recordId)\`
|
|
76590
|
+
- Lists & entries: \`client.listLists()\`, \`client.getList(listId)\`, \`client.listListViews(listId)\`, \`client.queryListEntries(listId, options?)\`, \`client.getListEntry(listId, entryId)\`, \`client.createListEntry(listId, data)\`, \`client.updateListEntry(listId, entryId, data)\`, \`client.overwriteListEntry(listId, entryId, data)\`, \`client.deleteListEntry(listId, entryId)\`, \`client.assertListEntry(listId, data)\`
|
|
76591
|
+
- Workspace members: \`client.listWorkspaceMembers()\`, \`client.getWorkspaceMember(workspaceMemberId)\`, \`client.getWorkspaceMemberMap()\` (returns \`Map<workspace_member_id, { id, name, email }>\` \u2014 use to resolve \`owner\` / actor-reference fields to names)
|
|
76592
|
+
- Notes: \`client.listNotes(options?)\`, \`client.getNote(noteId)\`, \`client.createNote(data)\`, \`client.updateNote(noteId, data)\`, \`client.deleteNote(noteId)\`
|
|
76593
|
+
- Tasks: \`client.listTasks(options?)\`, \`client.getTask(taskId)\`, \`client.createTask(data)\`, \`client.updateTask(taskId, data)\`, \`client.deleteTask(taskId)\`
|
|
76594
|
+
- Threads & comments: \`client.listThreads(options?)\`, \`client.getThread(threadId)\`, \`client.createComment(data)\`, \`client.getComment(commentId)\`, \`client.updateComment(commentId, data)\`, \`client.deleteComment(commentId)\`
|
|
76595
|
+
- Webhooks: \`client.listWebhooks()\`, \`client.getWebhook(webhookId)\`, \`client.createWebhook(data)\`, \`client.updateWebhook(webhookId, data)\`, \`client.deleteWebhook(webhookId)\`
|
|
76596
|
+
- Meetings: \`client.listMeetings(options?)\`, \`client.getMeeting(meetingId)\`
|
|
76597
|
+
|
|
76598
|
+
### CRITICAL: Owner / Actor reference resolution
|
|
76599
|
+
|
|
76600
|
+
Fields like \`owner\` \u2014 and any \`actor-reference\` attribute \u2014 in Attio record \`values\` do **not** contain names. They carry actor IDs shaped like:
|
|
76601
|
+
\`\`\`json
|
|
76602
|
+
{ "referenced_actor_type": "workspace-member", "referenced_actor_id": "<workspace_member_id>" }
|
|
76603
|
+
\`\`\`
|
|
76604
|
+
Rendering that raw leaves opaque IDs in the UI (e.g. \`owner_name\` stays as a UUID). **Always** resolve these IDs to names before returning them. Do this by fetching workspace members once and joining on \`workspace_member_id\`.
|
|
76605
|
+
|
|
76606
|
+
- Use \`client.getWorkspaceMemberMap()\` \u2014 it returns a typed \`Map<workspace_member_id, { id, name, email }>\` ready to join with actor references.
|
|
76607
|
+
- The workspace-member endpoint is top-level: \`GET /workspace_members\`.
|
|
76608
|
+
- Fetch \`client.getWorkspaceMemberMap()\` in parallel with \`queryRecords\` via \`Promise.all\` (single fetch, joined in-memory).
|
|
76609
|
+
|
|
76610
|
+
Example \u2014 owner-based performance with names resolved:
|
|
76611
|
+
\`\`\`ts
|
|
76612
|
+
import type { Context } from "hono";
|
|
76613
|
+
import { connection } from "@squadbase/vite-server/connectors/attio";
|
|
76614
|
+
|
|
76615
|
+
const attio = connection("<connectionId>");
|
|
76616
|
+
|
|
76617
|
+
export default async function handler(c: Context) {
|
|
76618
|
+
const [{ data: deals }, memberMap] = await Promise.all([
|
|
76619
|
+
attio.queryRecords("deals", { limit: 500 }),
|
|
76620
|
+
attio.getWorkspaceMemberMap(),
|
|
76621
|
+
]);
|
|
76622
|
+
|
|
76623
|
+
const byOwner = new Map<string, { owner_name: string; count: number }>();
|
|
76624
|
+
for (const deal of deals) {
|
|
76625
|
+
const values = (deal as { values?: Record<string, unknown[]> }).values ?? {};
|
|
76626
|
+
const ownerCell = (values.owner ?? [])[0] as
|
|
76627
|
+
| { referenced_actor_id?: string }
|
|
76628
|
+
| undefined;
|
|
76629
|
+
const ownerId = ownerCell?.referenced_actor_id ?? "unassigned";
|
|
76630
|
+
const ownerName = memberMap.get(ownerId)?.name ?? "Unassigned";
|
|
76631
|
+
const prev = byOwner.get(ownerId) ?? { owner_name: ownerName, count: 0 };
|
|
76632
|
+
prev.count += 1;
|
|
76633
|
+
byOwner.set(ownerId, prev);
|
|
76634
|
+
}
|
|
76635
|
+
|
|
76636
|
+
return c.json({ rows: Array.from(byOwner.values()) });
|
|
76637
|
+
}
|
|
76638
|
+
\`\`\`
|
|
76639
|
+
|
|
76640
|
+
### Minimal example
|
|
76587
76641
|
|
|
76588
76642
|
\`\`\`ts
|
|
76589
76643
|
import type { Context } from "hono";
|
|
@@ -76608,39 +76662,129 @@ export default async function handler(c: Context) {
|
|
|
76608
76662
|
- Base URL: \`https://api.attio.com/v2\`
|
|
76609
76663
|
- Authentication: Bearer token (handled automatically)
|
|
76610
76664
|
- Querying records uses POST with JSON body (not GET with query params)
|
|
76611
|
-
|
|
76612
|
-
|
|
76613
|
-
|
|
76614
|
-
|
|
76615
|
-
-
|
|
76616
|
-
|
|
76617
|
-
|
|
76618
|
-
-
|
|
76619
|
-
-
|
|
76620
|
-
-
|
|
76621
|
-
-
|
|
76622
|
-
- GET \`/
|
|
76623
|
-
|
|
76624
|
-
|
|
76625
|
-
|
|
76626
|
-
|
|
76627
|
-
- \`
|
|
76628
|
-
- \`
|
|
76665
|
+
- Update semantics: PATCH appends multiselect values, PUT overwrites them
|
|
76666
|
+
- Many list endpoints support \`limit\` and \`offset\` for pagination
|
|
76667
|
+
|
|
76668
|
+
#### Meta
|
|
76669
|
+
- GET \`/self\` \u2014 current API token introspection (workspace id, scopes, token status)
|
|
76670
|
+
|
|
76671
|
+
#### Objects & Attributes
|
|
76672
|
+
- GET \`/objects\` \u2014 list all objects in the workspace (default: people, companies, deals; plus any custom objects configured)
|
|
76673
|
+
- GET \`/objects/{object}\` \u2014 get a single object
|
|
76674
|
+
- GET \`/objects/{object}/views\` \u2014 list views for an object
|
|
76675
|
+
- GET \`/objects/{object}/attributes\` \u2014 list attributes for an object
|
|
76676
|
+
- GET \`/objects/{object}/attributes/{attribute}\` \u2014 get an attribute
|
|
76677
|
+
- GET \`/objects/{object}/attributes/{attribute}/options\` \u2014 list select options
|
|
76678
|
+
- GET \`/objects/{object}/attributes/{attribute}/statuses\` \u2014 list statuses
|
|
76679
|
+
|
|
76680
|
+
#### Records
|
|
76681
|
+
- POST \`/objects/{object}/records/query\` \u2014 query records (filter / sorts / limit / offset)
|
|
76682
|
+
- GET \`/objects/{object}/records/{record_id}\` \u2014 get a record
|
|
76683
|
+
- POST \`/objects/{object}/records\` \u2014 create a record (body: \`{ "data": { ... } }\`)
|
|
76684
|
+
- PATCH \`/objects/{object}/records/{record_id}\` \u2014 update (append multiselect)
|
|
76685
|
+
- PUT \`/objects/{object}/records/{record_id}\` \u2014 update (overwrite multiselect)
|
|
76686
|
+
- DELETE \`/objects/{object}/records/{record_id}\` \u2014 delete a record
|
|
76687
|
+
- PUT \`/objects/{object}/records\` \u2014 assert (upsert) by matching attribute
|
|
76688
|
+
- GET \`/objects/{object}/records/{record_id}/entries\` \u2014 list list entries that reference the record
|
|
76689
|
+
|
|
76690
|
+
#### Lists & Entries
|
|
76691
|
+
- GET \`/lists\` \u2014 list all lists
|
|
76692
|
+
- GET \`/lists/{list_id}\` \u2014 get a list
|
|
76693
|
+
- GET \`/lists/{list_id}/views\` \u2014 list views for a list
|
|
76694
|
+
- POST \`/lists/{list_id}/entries/query\` \u2014 query list entries
|
|
76695
|
+
- GET \`/lists/{list_id}/entries/{entry_id}\` \u2014 get a list entry
|
|
76696
|
+
- POST \`/lists/{list_id}/entries\` \u2014 create an entry
|
|
76697
|
+
- PATCH \`/lists/{list_id}/entries/{entry_id}\` \u2014 update (append multiselect)
|
|
76698
|
+
- PUT \`/lists/{list_id}/entries/{entry_id}\` \u2014 update (overwrite multiselect)
|
|
76699
|
+
- DELETE \`/lists/{list_id}/entries/{entry_id}\` \u2014 delete an entry
|
|
76700
|
+
- PUT \`/lists/{list_id}/entries\` \u2014 assert (upsert) a list entry by parent
|
|
76701
|
+
|
|
76702
|
+
#### Workspace Members
|
|
76703
|
+
- GET \`/workspace_members\` \u2014 list every member of the workspace (team members, their roles, and access levels)
|
|
76704
|
+
- GET \`/workspace_members/{workspace_member_id}\` \u2014 get a single workspace member
|
|
76705
|
+
|
|
76706
|
+
#### Notes, Tasks, Threads & Comments
|
|
76707
|
+
- \`/notes\` (GET list, POST create) and \`/notes/{note_id}\` (GET / PATCH / DELETE). Filter list notes with \`?parent_object={object}&parent_record_id={id}\`.
|
|
76708
|
+
- \`/tasks\` (GET list, POST create) and \`/tasks/{task_id}\` (GET / PATCH / DELETE)
|
|
76709
|
+
- \`/threads\` (GET list) and \`/threads/{thread_id}\` (GET)
|
|
76710
|
+
- \`/comments\` (POST create) and \`/comments/{comment_id}\` (GET / PATCH / DELETE)
|
|
76711
|
+
|
|
76712
|
+
#### Webhooks
|
|
76713
|
+
- GET \`/webhooks\`, POST \`/webhooks\`, GET/PATCH/DELETE \`/webhooks/{webhook_id}\`
|
|
76714
|
+
|
|
76715
|
+
#### Meetings
|
|
76716
|
+
- GET \`/meetings\`, GET \`/meetings/{meeting_id}\`
|
|
76717
|
+
|
|
76718
|
+
#### Query Body (for POST /objects/{object}/records/query and /lists/{list_id}/entries/query)
|
|
76719
|
+
- \`filter\` \u2014 filter conditions
|
|
76720
|
+
- \`sorts\` \u2014 array of sort specifications
|
|
76721
|
+
- \`limit\` \u2014 max records per page (default 25)
|
|
76722
|
+
- \`offset\` \u2014 pagination offset`,
|
|
76629
76723
|
ja: `### \u30C4\u30FC\u30EB
|
|
76630
76724
|
|
|
76631
|
-
- \`attio_request\`: Attio REST API\u3092\u547C\u3073\u51FA\u3059\u552F\u4E00\u306E\u624B\u6BB5\u3067\u3059\u3002\u30EC\u30B3\u30FC\u30C9\uFF08people\u3001companies\u3001deals\
|
|
76725
|
+
- \`attio_request\`: Attio REST API\u3092\u547C\u3073\u51FA\u3059\u552F\u4E00\u306E\u624B\u6BB5\u3067\u3059\u3002\u30EC\u30B3\u30FC\u30C9\uFF08people\u3001companies\u3001deals\u3001\u304A\u3088\u3073\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u306B\u8A2D\u5B9A\u3055\u308C\u305F\u30AB\u30B9\u30BF\u30E0\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\uFF09\u3068\u305D\u306E\u5C5E\u6027\u3001\u30EA\u30B9\u30C8\u3068\u30A8\u30F3\u30C8\u30EA\u3001\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u30E1\u30F3\u30D0\u30FC\u3001\u30CE\u30FC\u30C8\u3001\u30BF\u30B9\u30AF\u3001\u30B9\u30EC\u30C3\u30C9\u3001\u30B3\u30E1\u30F3\u30C8\u3001Webhook\u3001\u30DF\u30FC\u30C6\u30A3\u30F3\u30B0\u306A\u3069\u3001\u3059\u3079\u3066\u306EAttio\u30EA\u30BD\u30FC\u30B9\u306E\u64CD\u4F5C\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002\u8A8D\u8A3C\uFF08Bearer\u30C8\u30FC\u30AF\u30F3\uFF09\u306F\u81EA\u52D5\u7684\u306B\u8A2D\u5B9A\u3055\u308C\u307E\u3059\u3002\u30EC\u30B3\u30FC\u30C9\u306E\u30AF\u30A8\u30EA\u306B\u306F POST \`/objects/{object}/records/query\` \u3092\u30D5\u30A3\u30EB\u30BF\u4ED8\u304D\u306EJSON\u30DC\u30C7\u30A3\u3067\u4F7F\u7528\u3057\u307E\u3059\u3002\u90E8\u5206\u66F4\u65B0\uFF08multiselect\u306E\u8FFD\u52A0\uFF09\u306B\u306FPATCH\u3001\u5168\u7F6E\u63DB\uFF08multiselect\u306E\u4E0A\u66F8\u304D\uFF09\u306B\u306FPUT\u3092\u4F7F\u3044\u307E\u3059\u3002**\u5FC5\u305A** \u6700\u521D\u306B GET \`/objects\` \u3092\u547C\u3073\u51FA\u3057\u3066\u3001\u3053\u306E\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u306B\u5B9F\u5728\u3059\u308B\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8slug\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002
|
|
76632
76726
|
|
|
76633
76727
|
### Business Logic
|
|
76634
76728
|
|
|
76635
|
-
\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\
|
|
76729
|
+
\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\u8A8D\u8A3C\u306FSDK\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8\u5074\u3067\u81EA\u52D5\u7684\u306B\u8A2D\u5B9A\u3055\u308C\u307E\u3059\u3002
|
|
76636
76730
|
|
|
76637
76731
|
SDK\u30E1\u30BD\u30C3\u30C9 (\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8):
|
|
76638
76732
|
- \`client.request(path, init?)\` \u2014 \u4F4E\u30EC\u30D9\u30EB\u306E\u8A8D\u8A3C\u4ED8\u304Dfetch
|
|
76639
|
-
- \`client.
|
|
76640
|
-
- \`client.
|
|
76641
|
-
- \`client.
|
|
76642
|
-
- \`client.getRecord(object, recordId)\`
|
|
76643
|
-
- \`client.queryListEntries(listId, options?)\`
|
|
76733
|
+
- \`client.identify()\` \u2014 \u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9/\u30C8\u30FC\u30AF\u30F3\u60C5\u5831\uFF08GET /meta/identify\uFF09
|
|
76734
|
+
- Objects: \`client.listObjects()\`, \`client.getObject(object)\`, \`client.listObjectViews(object)\`
|
|
76735
|
+
- Attributes: \`client.listAttributes(object)\`, \`client.getAttribute(object, attribute)\`, \`client.listSelectOptions(object, attribute)\`, \`client.listStatuses(object, attribute)\`
|
|
76736
|
+
- Records: \`client.queryRecords(object, options?)\`, \`client.getRecord(object, recordId)\`, \`client.createRecord(object, data)\`, \`client.updateRecord(object, recordId, data)\` (PATCH), \`client.overwriteRecord(object, recordId, data)\` (PUT), \`client.deleteRecord(object, recordId)\`, \`client.assertRecord(object, data)\`, \`client.listRecordEntries(object, recordId)\`
|
|
76737
|
+
- Lists & entries: \`client.listLists()\`, \`client.getList(listId)\`, \`client.listListViews(listId)\`, \`client.queryListEntries(listId, options?)\`, \`client.getListEntry(listId, entryId)\`, \`client.createListEntry(listId, data)\`, \`client.updateListEntry(listId, entryId, data)\`, \`client.overwriteListEntry(listId, entryId, data)\`, \`client.deleteListEntry(listId, entryId)\`, \`client.assertListEntry(listId, data)\`
|
|
76738
|
+
- Workspace members: \`client.listWorkspaceMembers()\`, \`client.getWorkspaceMember(workspaceMemberId)\`, \`client.getWorkspaceMemberMap()\` (returns \`Map<workspace_member_id, { id, name, email }>\` \u2014 use to resolve \`owner\` / actor-reference fields to names)
|
|
76739
|
+
- Notes: \`client.listNotes(options?)\`, \`client.getNote(noteId)\`, \`client.createNote(data)\`, \`client.updateNote(noteId, data)\`, \`client.deleteNote(noteId)\`
|
|
76740
|
+
- Tasks: \`client.listTasks(options?)\`, \`client.getTask(taskId)\`, \`client.createTask(data)\`, \`client.updateTask(taskId, data)\`, \`client.deleteTask(taskId)\`
|
|
76741
|
+
- Threads & comments: \`client.listThreads(options?)\`, \`client.getThread(threadId)\`, \`client.createComment(data)\`, \`client.getComment(commentId)\`, \`client.updateComment(commentId, data)\`, \`client.deleteComment(commentId)\`
|
|
76742
|
+
- Webhooks: \`client.listWebhooks()\`, \`client.getWebhook(webhookId)\`, \`client.createWebhook(data)\`, \`client.updateWebhook(webhookId, data)\`, \`client.deleteWebhook(webhookId)\`
|
|
76743
|
+
- Meetings: \`client.listMeetings(options?)\`, \`client.getMeeting(meetingId)\`
|
|
76744
|
+
|
|
76745
|
+
### \u91CD\u8981: Owner / Actor reference \u306E\u540D\u524D\u89E3\u6C7A
|
|
76746
|
+
|
|
76747
|
+
\u30EC\u30B3\u30FC\u30C9\u5024\u306E \`owner\`\uFF08\u304A\u3088\u3073 \`actor-reference\` \u578B\u306E\u5C5E\u6027\uFF09\u306F\u540D\u524D\u3067\u306F\u306A\u304F\u3001\u6B21\u306E\u3088\u3046\u306Aactor ID\u3092\u542B\u307F\u307E\u3059\uFF1A
|
|
76748
|
+
\`\`\`json
|
|
76749
|
+
{ "referenced_actor_type": "workspace-member", "referenced_actor_id": "<workspace_member_id>" }
|
|
76750
|
+
\`\`\`
|
|
76751
|
+
\u3053\u308C\u3092\u305D\u306E\u307E\u307E\u8FD4\u3059\u3068UI\u306B\u4E0D\u900F\u660E\u306AID\uFF08\`owner_name\` \u304CUUID\u306E\u307E\u307E\u7B49\uFF09\u304C\u8868\u793A\u3055\u308C\u307E\u3059\u3002**\u5FC5\u305A** \u30CF\u30F3\u30C9\u30E9\u5185\u3067 \`workspace_member_id\` \u2192 \u540D\u524D\u3078\u89E3\u6C7A\u3057\u3066\u304B\u3089\u8FD4\u3057\u3066\u304F\u3060\u3055\u3044\u3002
|
|
76752
|
+
|
|
76753
|
+
- \u89E3\u6C7A\u306B\u306F \`client.getWorkspaceMemberMap()\` \u3092\u4F7F\u3063\u3066\u304F\u3060\u3055\u3044\u3002\u3053\u308C\u306F \`Map<workspace_member_id, { id, name, email }>\` \u3092\u8FD4\u3057\u3001\u305D\u306E\u307E\u307Eactor reference\u3068\u7D50\u5408\u3067\u304D\u307E\u3059\u3002
|
|
76754
|
+
- \u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u30E1\u30F3\u30D0\u30FC\u306E\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8\u306F\u30C8\u30C3\u30D7\u30EC\u30D9\u30EB\u306E \`GET /workspace_members\` \u3067\u3059\u3002
|
|
76755
|
+
- \`queryRecords\` \u3068 \`getWorkspaceMemberMap\` \u306F \`Promise.all\` \u3067\u4E26\u5217\u53D6\u5F97\u3057\u3001\u30E1\u30E2\u30EA\u4E0A\u3067\u7D50\u5408\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u90FD\u5EA6\u53D6\u5F97\u305B\u305A\u4E00\u62EC\u53D6\u5F97\uFF09\u3002
|
|
76756
|
+
|
|
76757
|
+
\u4F8B \u2014 owner\u3054\u3068\u306E\u30D1\u30D5\u30A9\u30FC\u30DE\u30F3\u30B9\uFF08\u540D\u524D\u89E3\u6C7A\u8FBC\u307F\uFF09:
|
|
76758
|
+
\`\`\`ts
|
|
76759
|
+
import type { Context } from "hono";
|
|
76760
|
+
import { connection } from "@squadbase/vite-server/connectors/attio";
|
|
76761
|
+
|
|
76762
|
+
const attio = connection("<connectionId>");
|
|
76763
|
+
|
|
76764
|
+
export default async function handler(c: Context) {
|
|
76765
|
+
const [{ data: deals }, memberMap] = await Promise.all([
|
|
76766
|
+
attio.queryRecords("deals", { limit: 500 }),
|
|
76767
|
+
attio.getWorkspaceMemberMap(),
|
|
76768
|
+
]);
|
|
76769
|
+
|
|
76770
|
+
const byOwner = new Map<string, { owner_name: string; count: number }>();
|
|
76771
|
+
for (const deal of deals) {
|
|
76772
|
+
const values = (deal as { values?: Record<string, unknown[]> }).values ?? {};
|
|
76773
|
+
const ownerCell = (values.owner ?? [])[0] as
|
|
76774
|
+
| { referenced_actor_id?: string }
|
|
76775
|
+
| undefined;
|
|
76776
|
+
const ownerId = ownerCell?.referenced_actor_id ?? "unassigned";
|
|
76777
|
+
const ownerName = memberMap.get(ownerId)?.name ?? "\u672A\u5272\u5F53";
|
|
76778
|
+
const prev = byOwner.get(ownerId) ?? { owner_name: ownerName, count: 0 };
|
|
76779
|
+
prev.count += 1;
|
|
76780
|
+
byOwner.set(ownerId, prev);
|
|
76781
|
+
}
|
|
76782
|
+
|
|
76783
|
+
return c.json({ rows: Array.from(byOwner.values()) });
|
|
76784
|
+
}
|
|
76785
|
+
\`\`\`
|
|
76786
|
+
|
|
76787
|
+
### \u6700\u5C0F\u30B5\u30F3\u30D7\u30EB
|
|
76644
76788
|
|
|
76645
76789
|
\`\`\`ts
|
|
76646
76790
|
import type { Context } from "hono";
|
|
@@ -76665,20 +76809,60 @@ export default async function handler(c: Context) {
|
|
|
76665
76809
|
- \u30D9\u30FC\u30B9URL: \`https://api.attio.com/v2\`
|
|
76666
76810
|
- \u8A8D\u8A3C: Bearer\u30C8\u30FC\u30AF\u30F3\uFF08\u81EA\u52D5\u8A2D\u5B9A\uFF09
|
|
76667
76811
|
- \u30EC\u30B3\u30FC\u30C9\u306E\u30AF\u30A8\u30EA\u306B\u306FGET\u30AF\u30A8\u30EA\u30D1\u30E9\u30E1\u30FC\u30BF\u3067\u306F\u306A\u304FPOST\u3067JSON\u30DC\u30C7\u30A3\u3092\u4F7F\u7528\u3057\u307E\u3059
|
|
76812
|
+
- \u66F4\u65B0\u30BB\u30DE\u30F3\u30C6\u30A3\u30AF\u30B9: PATCH\u306Fmultiselect\u5024\u3092\u8FFD\u52A0\u3001PUT\u306F\u4E0A\u66F8\u304D
|
|
76813
|
+
- \u591A\u304F\u306E\u4E00\u89A7\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8\u306F \`limit\` \u3068 \`offset\` \u306B\u3088\u308B\u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3\u3092\u30B5\u30DD\u30FC\u30C8
|
|
76668
76814
|
|
|
76669
|
-
####
|
|
76670
|
-
- GET \`/
|
|
76815
|
+
#### Meta
|
|
76816
|
+
- GET \`/self\` \u2014 \u73FE\u5728\u306EAPI\u30C8\u30FC\u30AF\u30F3\u306E\u60C5\u5831\uFF08workspace id / scopes / \u6709\u52B9\u72B6\u614B\uFF09
|
|
76817
|
+
|
|
76818
|
+
#### Objects & Attributes
|
|
76819
|
+
- GET \`/objects\` \u2014 \u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u306E\u5168\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u4E00\u89A7\uFF08\u30C7\u30D5\u30A9\u30EB\u30C8\u306F people / companies / deals\u3001\u52A0\u3048\u3066\u8A2D\u5B9A\u6E08\u307F\u306E\u30AB\u30B9\u30BF\u30E0\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\uFF09
|
|
76820
|
+
- GET \`/objects/{object}\` \u2014 \u5358\u4E00\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u306E\u53D6\u5F97
|
|
76821
|
+
- GET \`/objects/{object}/views\` \u2014 \u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u306E\u30D3\u30E5\u30FC\u4E00\u89A7
|
|
76671
76822
|
- GET \`/objects/{object}/attributes\` \u2014 \u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u306E\u5C5E\u6027\u4E00\u89A7
|
|
76672
|
-
-
|
|
76823
|
+
- GET \`/objects/{object}/attributes/{attribute}\` \u2014 \u5C5E\u6027\u306E\u53D6\u5F97
|
|
76824
|
+
- GET \`/objects/{object}/attributes/{attribute}/options\` \u2014 \u30BB\u30EC\u30AF\u30C8\u9078\u629E\u80A2\u306E\u4E00\u89A7
|
|
76825
|
+
- GET \`/objects/{object}/attributes/{attribute}/statuses\` \u2014 \u30B9\u30C6\u30FC\u30BF\u30B9\u4E00\u89A7
|
|
76826
|
+
|
|
76827
|
+
#### Records
|
|
76828
|
+
- POST \`/objects/{object}/records/query\` \u2014 \u30EC\u30B3\u30FC\u30C9\u306E\u691C\u7D22\uFF08filter / sorts / limit / offset\uFF09
|
|
76673
76829
|
- GET \`/objects/{object}/records/{record_id}\` \u2014 \u30EC\u30B3\u30FC\u30C9\u306E\u53D6\u5F97
|
|
76674
|
-
- POST \`/objects/{object}/records\` \u2014 \u30EC\u30B3\u30FC\u30C9\u306E\u4F5C\u6210
|
|
76675
|
-
- PATCH \`/objects/{object}/records/{record_id}\` \u2014 \
|
|
76830
|
+
- POST \`/objects/{object}/records\` \u2014 \u30EC\u30B3\u30FC\u30C9\u306E\u4F5C\u6210\uFF08body: \`{ "data": { ... } }\`\uFF09
|
|
76831
|
+
- PATCH \`/objects/{object}/records/{record_id}\` \u2014 \u66F4\u65B0\uFF08multiselect\u8FFD\u52A0\uFF09
|
|
76832
|
+
- PUT \`/objects/{object}/records/{record_id}\` \u2014 \u66F4\u65B0\uFF08multiselect\u4E0A\u66F8\u304D\uFF09
|
|
76676
76833
|
- DELETE \`/objects/{object}/records/{record_id}\` \u2014 \u30EC\u30B3\u30FC\u30C9\u306E\u524A\u9664
|
|
76677
|
-
-
|
|
76678
|
-
-
|
|
76679
|
-
- GET \`/notes?parent_object={object}&parent_record_id={id}\` \u2014 \u30EC\u30B3\u30FC\u30C9\u306E\u30CE\u30FC\u30C8\u3092\u53D6\u5F97
|
|
76834
|
+
- PUT \`/objects/{object}/records\` \u2014 \u4E00\u81F4\u5C5E\u6027\u306B\u3088\u308B\u30A2\u30B5\u30FC\u30C8\uFF08upsert\uFF09
|
|
76835
|
+
- GET \`/objects/{object}/records/{record_id}/entries\` \u2014 \u30EC\u30B3\u30FC\u30C9\u3092\u53C2\u7167\u3059\u308B\u30EA\u30B9\u30C8\u30A8\u30F3\u30C8\u30EA\u4E00\u89A7
|
|
76680
76836
|
|
|
76681
|
-
####
|
|
76837
|
+
#### Lists & Entries
|
|
76838
|
+
- GET \`/lists\` \u2014 \u30EA\u30B9\u30C8\u4E00\u89A7
|
|
76839
|
+
- GET \`/lists/{list_id}\` \u2014 \u30EA\u30B9\u30C8\u306E\u53D6\u5F97
|
|
76840
|
+
- GET \`/lists/{list_id}/views\` \u2014 \u30EA\u30B9\u30C8\u306E\u30D3\u30E5\u30FC\u4E00\u89A7
|
|
76841
|
+
- POST \`/lists/{list_id}/entries/query\` \u2014 \u30EA\u30B9\u30C8\u30A8\u30F3\u30C8\u30EA\u306E\u691C\u7D22
|
|
76842
|
+
- GET \`/lists/{list_id}/entries/{entry_id}\` \u2014 \u30EA\u30B9\u30C8\u30A8\u30F3\u30C8\u30EA\u306E\u53D6\u5F97
|
|
76843
|
+
- POST \`/lists/{list_id}/entries\` \u2014 \u30A8\u30F3\u30C8\u30EA\u4F5C\u6210
|
|
76844
|
+
- PATCH \`/lists/{list_id}/entries/{entry_id}\` \u2014 \u66F4\u65B0\uFF08multiselect\u8FFD\u52A0\uFF09
|
|
76845
|
+
- PUT \`/lists/{list_id}/entries/{entry_id}\` \u2014 \u66F4\u65B0\uFF08multiselect\u4E0A\u66F8\u304D\uFF09
|
|
76846
|
+
- DELETE \`/lists/{list_id}/entries/{entry_id}\` \u2014 \u30A8\u30F3\u30C8\u30EA\u524A\u9664
|
|
76847
|
+
- PUT \`/lists/{list_id}/entries\` \u2014 \u89AA\u30EC\u30B3\u30FC\u30C9\u306B\u3088\u308B\u30A2\u30B5\u30FC\u30C8\uFF08upsert\uFF09
|
|
76848
|
+
|
|
76849
|
+
#### Workspace Members\uFF08\u30C1\u30FC\u30E0\u30E1\u30F3\u30D0\u30FC\uFF09
|
|
76850
|
+
- GET \`/workspace_members\` \u2014 \u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u306E\u5168\u30E1\u30F3\u30D0\u30FC\u4E00\u89A7\uFF08\u30ED\u30FC\u30EB\u3084\u30A2\u30AF\u30BB\u30B9\u30EC\u30D9\u30EB\u3092\u542B\u3080\uFF09
|
|
76851
|
+
- GET \`/workspace_members/{workspace_member_id}\` \u2014 \u5358\u4E00\u30E1\u30F3\u30D0\u30FC\u306E\u53D6\u5F97
|
|
76852
|
+
|
|
76853
|
+
#### Notes, Tasks, Threads & Comments
|
|
76854
|
+
- \`/notes\`\uFF08GET \u4E00\u89A7 / POST \u4F5C\u6210\uFF09\u3001\`/notes/{note_id}\`\uFF08GET / PATCH / DELETE\uFF09\u3002\u4E00\u89A7\u306F \`?parent_object={object}&parent_record_id={id}\` \u3067\u7D5E\u308A\u8FBC\u307F\u53EF\u80FD
|
|
76855
|
+
- \`/tasks\`\uFF08GET \u4E00\u89A7 / POST \u4F5C\u6210\uFF09\u3001\`/tasks/{task_id}\`\uFF08GET / PATCH / DELETE\uFF09
|
|
76856
|
+
- \`/threads\`\uFF08GET \u4E00\u89A7\uFF09\u3001\`/threads/{thread_id}\`\uFF08GET\uFF09
|
|
76857
|
+
- \`/comments\`\uFF08POST \u4F5C\u6210\uFF09\u3001\`/comments/{comment_id}\`\uFF08GET / PATCH / DELETE\uFF09
|
|
76858
|
+
|
|
76859
|
+
#### Webhooks
|
|
76860
|
+
- GET \`/webhooks\`\u3001POST \`/webhooks\`\u3001GET/PATCH/DELETE \`/webhooks/{webhook_id}\`
|
|
76861
|
+
|
|
76862
|
+
#### Meetings
|
|
76863
|
+
- GET \`/meetings\`\u3001GET \`/meetings/{meeting_id}\`
|
|
76864
|
+
|
|
76865
|
+
#### \u30AF\u30A8\u30EA\u30DC\u30C7\u30A3 (POST /objects/{object}/records/query \u304A\u3088\u3073 /lists/{list_id}/entries/query)
|
|
76682
76866
|
- \`filter\` \u2014 \u30D5\u30A3\u30EB\u30BF\u6761\u4EF6
|
|
76683
76867
|
- \`sorts\` \u2014 \u30BD\u30FC\u30C8\u6307\u5B9A\u306E\u914D\u5217
|
|
76684
76868
|
- \`limit\` \u2014 \u30DA\u30FC\u30B8\u3042\u305F\u308A\u306E\u6700\u5927\u30EC\u30B3\u30FC\u30C9\u6570\uFF08\u30C7\u30D5\u30A9\u30EB\u30C825\uFF09
|