@hailer/mcp 0.0.6 → 0.1.1
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/.claude/agents/ada.md +127 -0
- package/.claude/agents/agent-builder.md +151 -0
- package/.claude/agents/alejandro.md +66 -0
- package/.claude/agents/bjorn.md +305 -0
- package/.claude/agents/dmitri.md +61 -0
- package/.claude/agents/giuseppe.md +66 -0
- package/.claude/agents/gunther.md +355 -0
- package/.claude/agents/helga.md +68 -0
- package/.claude/agents/ingrid.md +108 -0
- package/.claude/agents/kenji.md +58 -0
- package/.claude/agents/svetlana.md +394 -0
- package/.claude/agents/viktor.md +63 -0
- package/.claude/agents/yevgeni.md +60 -0
- package/.claude/hooks/agent-failure-detector.cjs +286 -0
- package/.claude/hooks/app-edit-guard.cjs +462 -0
- package/.claude/hooks/interactive-mode.cjs +59 -0
- package/.claude/hooks/mcp-server-guard.cjs +92 -0
- package/.claude/hooks/post-scaffold-hook.cjs +31 -0
- package/.claude/hooks/sdk-delete-guard.cjs +2 -0
- package/.claude/hooks/src-edit-guard.cjs +208 -0
- package/.claude/settings.json +47 -2
- package/.claude/skills/insight-join-patterns/SKILL.md +209 -0
- package/.env.example +13 -1
- package/CLAUDE.md +135 -0
- package/dist/app.js +4 -3
- package/dist/cli.js +0 -0
- package/dist/client/adaptive-documentation-bot.d.ts +0 -2
- package/dist/client/adaptive-documentation-bot.js +5 -16
- package/dist/client/message-processor.js +5 -0
- package/dist/client/providers/anthropic-provider.js +21 -7
- package/dist/mcp/UserContextCache.d.ts +14 -0
- package/dist/mcp/UserContextCache.js +49 -24
- package/dist/mcp/auth.d.ts +7 -0
- package/dist/mcp/auth.js +13 -5
- package/dist/mcp/hailer-clients.d.ts +5 -2
- package/dist/mcp/signal-handler.d.ts +28 -2
- package/dist/mcp/signal-handler.js +4 -2
- package/dist/mcp/tool-registry.d.ts +55 -2
- package/dist/mcp/tool-registry.js +197 -2
- package/dist/mcp/tools/app-core.d.ts +15 -0
- package/dist/mcp/tools/app-core.js +609 -0
- package/dist/mcp/tools/app-marketplace.d.ts +21 -0
- package/dist/mcp/tools/app-marketplace.js +1284 -0
- package/dist/mcp/tools/app-member.d.ts +11 -0
- package/dist/mcp/tools/app-member.js +258 -0
- package/dist/mcp/tools/app-scaffold.d.ts +11 -0
- package/dist/mcp/tools/app-scaffold.js +743 -0
- package/dist/mcp/tools/app.d.ts +13 -22
- package/dist/mcp/tools/app.js +17 -2466
- package/dist/mcp/tools/file.js +6 -6
- package/dist/mcp/tools/insight.d.ts +1 -0
- package/dist/mcp/tools/insight.js +203 -64
- package/dist/mcp/tools/user.js +3 -9
- package/dist/mcp/tools/workflow.js +49 -38
- package/dist/mcp/utils/hailer-api-client.js +4 -13
- package/dist/mcp/utils/tool-helpers.d.ts +102 -0
- package/dist/mcp/utils/tool-helpers.js +179 -0
- package/dist/mcp/utils/types.d.ts +6 -0
- package/dist/mcp/workspace-cache.d.ts +5 -5
- package/dist/mcp/workspace-cache.js +4 -3
- package/package.json +1 -1
- package/.claude/hooks/PreToolUse.sh +0 -52
- package/.claude/hooks/prompt-skill-loader.cjs +0 -553
- package/.claude/hooks/skill-loader.cjs +0 -142
- package/.claude/settings.local.json +0 -49
- package/.claude/skills/MCP-add-app-member-skill/SKILL.md +0 -977
- package/.claude/skills/MCP-build-data-app-skill/SKILL.md +0 -372
- package/.claude/skills/MCP-create-app-skill/SKILL.md +0 -1101
- package/.claude/skills/MCP-create-insight-skill/SKILL.md +0 -1317
- package/.claude/skills/MCP-get-insight-data-skill/SKILL.md +0 -1053
- package/.claude/skills/MCP-insight-api/SKILL.md +0 -185
- package/.claude/skills/MCP-insight-api/references/insight-endpoints.md +0 -514
- package/.claude/skills/MCP-install-workflow-skill/SKILL.md +0 -1056
- package/.claude/skills/MCP-list-apps-skill/SKILL.md +0 -1010
- package/.claude/skills/MCP-list-workflows-minimal-skill/SKILL.md +0 -992
- package/.claude/skills/MCP-local-first-skill/SKILL.md +0 -570
- package/.claude/skills/MCP-populate-workflow-data-skill/SKILL.md +0 -395
- package/.claude/skills/MCP-preview-insight-skill/SKILL.md +0 -1290
- package/.claude/skills/MCP-publish-hailer-app-skill/SKILL.md +0 -453
- package/.claude/skills/MCP-publish-template-skill/SKILL.md +0 -278
- package/.claude/skills/MCP-remove-app-member-skill/SKILL.md +0 -671
- package/.claude/skills/MCP-remove-app-skill/SKILL.md +0 -985
- package/.claude/skills/MCP-remove-insight-skill/SKILL.md +0 -1011
- package/.claude/skills/MCP-remove-workflow-skill/SKILL.md +0 -920
- package/.claude/skills/MCP-scaffold-hailer-app-skill/SKILL.md +0 -1314
- package/.claude/skills/MCP-update-app-skill/SKILL.md +0 -970
- package/.claude/skills/MCP-update-workflow-field-skill/SKILL.md +0 -1098
- package/.claude/skills/SDK-create-function-field-skill/SKILL.md +0 -313
- package/.claude/skills/SDK-generate-skill/SKILL.md +0 -223
- package/.claude/skills/SDK-init-skill/SKILL.md +0 -177
- package/.claude/skills/SDK-workspace-setup-skill/SKILL.md +0 -605
- package/.claude/skills/SDK-ws-config-skill/SKILL.md +0 -435
- package/.claude/skills/activity-api/SKILL.md +0 -96
- package/.claude/skills/activity-api/references/activity-endpoints.md +0 -845
- package/.claude/skills/agent-building/SKILL.md +0 -243
- package/.claude/skills/agent-building/references/architecture-patterns.md +0 -446
- package/.claude/skills/agent-building/references/code-examples.md +0 -587
- package/.claude/skills/agent-building/references/implementation-guide.md +0 -619
- package/.claude/skills/app-api/SKILL.md +0 -219
- package/.claude/skills/app-api/references/app-endpoints.md +0 -759
- package/.claude/skills/building-hailer-apps-skill/SKILL.md +0 -813
- package/.claude/skills/hailer-api/SKILL.md +0 -283
- package/.claude/skills/hailer-api/references/activities.md +0 -620
- package/.claude/skills/hailer-api/references/authentication.md +0 -216
- package/.claude/skills/hailer-api/references/datasets.md +0 -437
- package/.claude/skills/hailer-api/references/files.md +0 -301
- package/.claude/skills/hailer-api/references/insights.md +0 -469
- package/.claude/skills/hailer-api/references/workflows.md +0 -720
- package/.claude/skills/hailer-api/references/workspaces-users.md +0 -445
- package/.claude/skills/hailer-app-builder/SKILL.md +0 -340
- package/.claude/skills/mcp-tools/SKILL.md +0 -419
- package/.claude/skills/mcp-tools/references/api-endpoints.md +0 -499
- package/.claude/skills/mcp-tools/references/data-structures.md +0 -554
- package/.claude/skills/mcp-tools/references/implementation-patterns.md +0 -717
- package/.claude/skills/skill-testing/README.md +0 -137
- package/.claude/skills/skill-testing/SKILL.md +0 -348
- package/.claude/skills/skill-testing/references/test-patterns.md +0 -705
- package/.claude/skills/skill-testing/references/testing-guide.md +0 -603
- package/.claude/skills/skill-testing/references/validation-checklist.md +0 -537
- package/.claude/skills/spawn-app-builder/SKILL.md +0 -366
- package/.claude/skills/tool-builder/SKILL.md +0 -328
- package/tsconfig.json +0 -23
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Insight API Reference
|
|
3
|
-
description: Complete reference for Hailer Insight API (SQL-like reporting over workflow data) - use when building insight-related MCP tools
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Insight API Reference Skill
|
|
7
|
-
|
|
8
|
-
This skill provides comprehensive documentation for Hailer Insight API endpoints. Insights are SQL-like reports that query activity data from workflows, with support for joins across multiple workflows.
|
|
9
|
-
|
|
10
|
-
## When to Use This Skill
|
|
11
|
-
|
|
12
|
-
Invoke this skill when:
|
|
13
|
-
- Building insight/reporting MCP tools
|
|
14
|
-
- Creating SQL queries over workflow data
|
|
15
|
-
- Working with cross-workflow data analysis
|
|
16
|
-
- Implementing data visualization features
|
|
17
|
-
- Managing insight permissions and sharing
|
|
18
|
-
|
|
19
|
-
## What are Insights?
|
|
20
|
-
|
|
21
|
-
**Insights = SQL queries over Hailer workflow data**
|
|
22
|
-
|
|
23
|
-
Think of it as:
|
|
24
|
-
- **Workflows** = Database tables
|
|
25
|
-
- **Activities** = Rows in those tables
|
|
26
|
-
- **Fields** = Columns in those tables
|
|
27
|
-
- **Insights** = SQL SELECT queries with JOINs
|
|
28
|
-
|
|
29
|
-
## Quick Navigation
|
|
30
|
-
|
|
31
|
-
### Core Insight Operations
|
|
32
|
-
- **v3.insight.create** - Create new insight with SQL query
|
|
33
|
-
- **v3.insight.update** - Update existing insight
|
|
34
|
-
- **v3.insight.list** - List all insights in workspace
|
|
35
|
-
- **v3.insight.data** - Get query results (execute the SQL)
|
|
36
|
-
- **v3.insight.preview** - Preview insight while designing (debugging)
|
|
37
|
-
- **v3.insight.remove** - Delete an insight
|
|
38
|
-
|
|
39
|
-
### Insight Management
|
|
40
|
-
- **v3.insight.copy** - Duplicate an insight
|
|
41
|
-
- **v3.insight.public** - Get public insight data (shared insights)
|
|
42
|
-
- **v3.insight.member.add** - Add member permissions
|
|
43
|
-
- **v3.insight.member.remove** - Remove member permissions
|
|
44
|
-
|
|
45
|
-
## Key Concepts
|
|
46
|
-
|
|
47
|
-
### Insight Structure
|
|
48
|
-
|
|
49
|
-
```javascript
|
|
50
|
-
{
|
|
51
|
-
name: 'Insight Name',
|
|
52
|
-
public: false, // Whether insight is publicly accessible
|
|
53
|
-
sources: [
|
|
54
|
-
{
|
|
55
|
-
name: 'books', // Table alias for SQL
|
|
56
|
-
workflowId: '<id>', // Which workflow to query
|
|
57
|
-
fields: [
|
|
58
|
-
{ name: 'title', meta: 'name' }, // Activity name
|
|
59
|
-
{ name: 'publishDate', fieldId: '<fieldId>' } // Custom field
|
|
60
|
-
]
|
|
61
|
-
}
|
|
62
|
-
],
|
|
63
|
-
query: 'SELECT title, publishDate FROM books' // Standard SQL
|
|
64
|
-
}
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
### Field References
|
|
68
|
-
|
|
69
|
-
**Meta fields** (built-in):
|
|
70
|
-
- `meta: '_id'` - Activity ID (for JOINs)
|
|
71
|
-
- `meta: 'uid'` - User ID (creator)
|
|
72
|
-
- `meta: 'team'` - Owner team ID
|
|
73
|
-
- `meta: 'createdBy'` - Creator user ID
|
|
74
|
-
- `meta: 'name'` - Activity name/title
|
|
75
|
-
- `meta: 'created'` - Creation timestamp
|
|
76
|
-
- `meta: 'updated'` - Last update timestamp
|
|
77
|
-
- `meta: 'phaseId'` - Current phase ID
|
|
78
|
-
- `meta: 'phaseName'` - Current phase name
|
|
79
|
-
- `meta: 'phaseLastMove'` - Last phase change timestamp
|
|
80
|
-
- `meta: 'workflowId'` - Workflow ID
|
|
81
|
-
- `meta: 'workflowName'` - Workflow name
|
|
82
|
-
- `meta: 'priority'` - Activity priority
|
|
83
|
-
|
|
84
|
-
**Custom fields**:
|
|
85
|
-
- `fieldId: '<fieldId>'` - Reference a workflow field by ID
|
|
86
|
-
|
|
87
|
-
### SQL Query Support
|
|
88
|
-
|
|
89
|
-
- Standard SELECT syntax
|
|
90
|
-
- JOINs across multiple workflows
|
|
91
|
-
- WHERE clauses
|
|
92
|
-
- GROUP BY, ORDER BY
|
|
93
|
-
- Aggregation functions (COUNT, SUM, AVG, etc.)
|
|
94
|
-
|
|
95
|
-
## Common Use Cases
|
|
96
|
-
|
|
97
|
-
1. **Single Workflow Report**: Query activities from one workflow
|
|
98
|
-
2. **Cross-Workflow Join**: Join data from related workflows (via ActivityLinks)
|
|
99
|
-
3. **Aggregated Reports**: COUNT, SUM, AVG across activities
|
|
100
|
-
4. **Filtered Views**: WHERE clauses to filter activity data
|
|
101
|
-
5. **Public Dashboards**: Share insights publicly with `public: true`
|
|
102
|
-
|
|
103
|
-
## Documentation
|
|
104
|
-
|
|
105
|
-
See [Insight API Endpoints](references/insight-endpoints.md) for complete endpoint documentation with request/response schemas and examples.
|
|
106
|
-
|
|
107
|
-
## MCP Tool Building Rules
|
|
108
|
-
|
|
109
|
-
When building Insight MCP tools:
|
|
110
|
-
|
|
111
|
-
1. **Use PlaygroundTools.ts** for testing first
|
|
112
|
-
2. **Follow the three-part pattern**:
|
|
113
|
-
- Description method (with SQL examples)
|
|
114
|
-
- Schema method (Zod validation)
|
|
115
|
-
- Handler method (implementation)
|
|
116
|
-
3. **Use HailerApiClient** with socket calls
|
|
117
|
-
4. **Validate SQL queries** before sending (basic syntax check)
|
|
118
|
-
5. **Format responses** as markdown tables for readability
|
|
119
|
-
6. **Handle permissions** - only workspace admins can modify sources
|
|
120
|
-
|
|
121
|
-
## Example Patterns
|
|
122
|
-
|
|
123
|
-
### Simple Report
|
|
124
|
-
```javascript
|
|
125
|
-
create_insight({
|
|
126
|
-
name: 'All Books',
|
|
127
|
-
sources: [{
|
|
128
|
-
name: 'books',
|
|
129
|
-
workflowId: bookWorkflowId,
|
|
130
|
-
fields: [
|
|
131
|
-
{ name: 'title', meta: 'name' },
|
|
132
|
-
{ name: 'author', fieldId: authorFieldId }
|
|
133
|
-
]
|
|
134
|
-
}],
|
|
135
|
-
query: 'SELECT title, author FROM books'
|
|
136
|
-
})
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
### Cross-Workflow Join
|
|
140
|
-
```javascript
|
|
141
|
-
create_insight({
|
|
142
|
-
name: 'Books with Authors',
|
|
143
|
-
sources: [
|
|
144
|
-
{
|
|
145
|
-
name: 'books',
|
|
146
|
-
workflowId: bookWorkflowId,
|
|
147
|
-
fields: [
|
|
148
|
-
{ name: 'title', meta: 'name' },
|
|
149
|
-
{ name: 'authorId', fieldId: authorLinkFieldId }
|
|
150
|
-
]
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
name: 'authors',
|
|
154
|
-
workflowId: authorWorkflowId,
|
|
155
|
-
fields: [
|
|
156
|
-
{ name: 'id', meta: '_id' },
|
|
157
|
-
{ name: 'authorName', meta: 'name' }
|
|
158
|
-
]
|
|
159
|
-
}
|
|
160
|
-
],
|
|
161
|
-
query: `
|
|
162
|
-
SELECT books.title, authors.authorName
|
|
163
|
-
FROM books
|
|
164
|
-
LEFT JOIN authors ON books.authorId = authors.id
|
|
165
|
-
`
|
|
166
|
-
})
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
## Preview vs Execute
|
|
170
|
-
|
|
171
|
-
**v3.insight.preview**:
|
|
172
|
-
- Used during design/debugging
|
|
173
|
-
- Limited to ~20 activities for performance
|
|
174
|
-
- Can be called frequently
|
|
175
|
-
- Shows errors in SQL syntax
|
|
176
|
-
|
|
177
|
-
**v3.insight.data**:
|
|
178
|
-
- Executes full query on all activities
|
|
179
|
-
- Returns complete results
|
|
180
|
-
- Use after insight is finalized
|
|
181
|
-
|
|
182
|
-
## Next Steps
|
|
183
|
-
|
|
184
|
-
For complete endpoint documentation with request/response schemas and SQL examples, see:
|
|
185
|
-
- [Insight API Endpoints](references/insight-endpoints.md) - All v3.insight.* endpoints
|
|
@@ -1,514 +0,0 @@
|
|
|
1
|
-
# Insight API Endpoints Reference
|
|
2
|
-
|
|
3
|
-
Complete reference for Hailer Insight API endpoints. Insights provide SQL-like reporting over workflow/activity data.
|
|
4
|
-
|
|
5
|
-
## Table of Contents
|
|
6
|
-
|
|
7
|
-
- [v3.insight.create](#v3insightcreate) - Create new insight
|
|
8
|
-
- [v3.insight.update](#v3insightupdate) - Update existing insight
|
|
9
|
-
- [v3.insight.copy](#v3insightcopy) - Copy/duplicate an insight
|
|
10
|
-
- [v3.insight.remove](#v3insightremove) - Delete an insight
|
|
11
|
-
- [v3.insight.list](#v3insightlist) - List all insights
|
|
12
|
-
- [v3.insight.public](#v3insightpublic) - Get public insight data
|
|
13
|
-
- [v3.insight.data](#v3insightdata) - Execute insight query and get results
|
|
14
|
-
- [v3.insight.preview](#v3insightpreview) - Preview insight during design
|
|
15
|
-
- [v3.insight.member.add](#v3insightmemberadd) - Add member permissions
|
|
16
|
-
- [v3.insight.member.remove](#v3insightmemberremove) - Remove member permissions
|
|
17
|
-
|
|
18
|
-
---
|
|
19
|
-
|
|
20
|
-
## Prerequisites
|
|
21
|
-
|
|
22
|
-
Before using Insights:
|
|
23
|
-
1. Must have workflows created with activities
|
|
24
|
-
2. Understand workflow schema (field IDs, field types)
|
|
25
|
-
3. Basic SQL knowledge (SELECT, JOIN, WHERE, etc.)
|
|
26
|
-
4. Use `v3.insight.preview` while designing to test queries
|
|
27
|
-
|
|
28
|
-
---
|
|
29
|
-
|
|
30
|
-
## v3.insight.create
|
|
31
|
-
|
|
32
|
-
Create new Insight with SQL query over workflow data.
|
|
33
|
-
|
|
34
|
-
**Endpoint**: `POST /v3/insight/create`
|
|
35
|
-
|
|
36
|
-
**Request Body**:
|
|
37
|
-
```json
|
|
38
|
-
{
|
|
39
|
-
"0": "stringstringstringstring", // workspaceId
|
|
40
|
-
"1": {
|
|
41
|
-
"name": "string",
|
|
42
|
-
"public": false,
|
|
43
|
-
"sources": [
|
|
44
|
-
{
|
|
45
|
-
"name": "tableName", // SQL table alias
|
|
46
|
-
"workflowId": "workflowId", // Which workflow to query
|
|
47
|
-
"fields": [
|
|
48
|
-
{ "name": "columnName", "meta": "name" }, // Activity name
|
|
49
|
-
{ "name": "columnName", "fieldId": "fieldId" } // Custom field
|
|
50
|
-
]
|
|
51
|
-
}
|
|
52
|
-
],
|
|
53
|
-
"query": "SELECT columnName FROM tableName" // SQL query
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
**Example 1 - Single Workflow**:
|
|
59
|
-
```javascript
|
|
60
|
-
v3.insight.create(
|
|
61
|
-
workspaceId,
|
|
62
|
-
{
|
|
63
|
-
name: 'Book Insights',
|
|
64
|
-
sources: [{
|
|
65
|
-
name: 'books',
|
|
66
|
-
workflowId: bookWorkflowId,
|
|
67
|
-
fields: [
|
|
68
|
-
{ name: 'title', meta: 'name' }, // Activity name
|
|
69
|
-
{ name: 'publishDate', fieldId: fieldId } // Custom field
|
|
70
|
-
]
|
|
71
|
-
}],
|
|
72
|
-
query: 'SELECT title, publishDate FROM books',
|
|
73
|
-
}
|
|
74
|
-
)
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
**Example 2 - Join Two Workflows**:
|
|
78
|
-
```javascript
|
|
79
|
-
v3.insight.create(
|
|
80
|
-
workspaceId,
|
|
81
|
-
{
|
|
82
|
-
name: 'Books with Authors',
|
|
83
|
-
sources: [
|
|
84
|
-
{
|
|
85
|
-
name: 'books',
|
|
86
|
-
workflowId: bookWorkflowId,
|
|
87
|
-
fields: [
|
|
88
|
-
{ name: 'title', meta: 'name' },
|
|
89
|
-
{ name: 'author', fieldId: authorLinkFieldId }
|
|
90
|
-
]
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
name: 'authors',
|
|
94
|
-
workflowId: authorWorkflowId,
|
|
95
|
-
fields: [
|
|
96
|
-
{ name: 'id', meta: '_id' }, // Activity ID
|
|
97
|
-
{ name: 'authorName', meta: 'name' }, // Activity Name
|
|
98
|
-
{ name: 'born', fieldId: bornFieldId }
|
|
99
|
-
]
|
|
100
|
-
}
|
|
101
|
-
],
|
|
102
|
-
query: `
|
|
103
|
-
SELECT title, publishDate, authorName
|
|
104
|
-
FROM authors
|
|
105
|
-
LEFT JOIN books ON books.author = authors.id
|
|
106
|
-
`
|
|
107
|
-
}
|
|
108
|
-
)
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
**Meta Fields** (built-in activity properties):
|
|
112
|
-
- `meta: 'name'` - Activity name
|
|
113
|
-
- `meta: '_id'` - Activity ID
|
|
114
|
-
- `meta: 'created'` - Creation timestamp
|
|
115
|
-
- `meta: 'updated'` - Last update timestamp
|
|
116
|
-
- `meta: 'phase'` - Current phase ID
|
|
117
|
-
- `meta: 'team'` - Owner team ID
|
|
118
|
-
|
|
119
|
-
**Response**:
|
|
120
|
-
```json
|
|
121
|
-
{
|
|
122
|
-
"code": 0,
|
|
123
|
-
"msg": "string",
|
|
124
|
-
"details": {
|
|
125
|
-
"insightId": "stringstringstringstring"
|
|
126
|
-
},
|
|
127
|
-
"debug": null
|
|
128
|
-
}
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
---
|
|
132
|
-
|
|
133
|
-
## v3.insight.update
|
|
134
|
-
|
|
135
|
-
Update an existing insight (name, query, sources, permissions, etc.).
|
|
136
|
-
|
|
137
|
-
**Endpoint**: `POST /v3/insight/update`
|
|
138
|
-
|
|
139
|
-
**Request Body**:
|
|
140
|
-
```json
|
|
141
|
-
{
|
|
142
|
-
"0": "stringstringstringstring", // insightId
|
|
143
|
-
"1": {
|
|
144
|
-
"name": "string",
|
|
145
|
-
"public": true,
|
|
146
|
-
"sources": [],
|
|
147
|
-
"query": "string",
|
|
148
|
-
"presets": []
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
**Note**: Only workspace admins can modify `sources`. Regular users with edit permission can only update `name`, `query`, and `presets` if sources remain unchanged.
|
|
154
|
-
|
|
155
|
-
**Response**:
|
|
156
|
-
```json
|
|
157
|
-
{
|
|
158
|
-
"code": 0,
|
|
159
|
-
"msg": "string",
|
|
160
|
-
"details": {},
|
|
161
|
-
"debug": null
|
|
162
|
-
}
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
---
|
|
166
|
-
|
|
167
|
-
## v3.insight.copy
|
|
168
|
-
|
|
169
|
-
Duplicate an existing insight.
|
|
170
|
-
|
|
171
|
-
**Endpoint**: `POST /v3/insight/copy`
|
|
172
|
-
|
|
173
|
-
**Request Body**:
|
|
174
|
-
```json
|
|
175
|
-
{
|
|
176
|
-
"0": "stringstringstringstring", // insightId to copy
|
|
177
|
-
"1": {
|
|
178
|
-
"name": "Copy of Original Insight"
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
**Response**:
|
|
184
|
-
```json
|
|
185
|
-
{
|
|
186
|
-
"code": 0,
|
|
187
|
-
"msg": "string",
|
|
188
|
-
"details": {
|
|
189
|
-
"insightId": "stringstringstringstring" // New insight ID
|
|
190
|
-
},
|
|
191
|
-
"debug": null
|
|
192
|
-
}
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
---
|
|
196
|
-
|
|
197
|
-
## v3.insight.remove
|
|
198
|
-
|
|
199
|
-
Delete an insight.
|
|
200
|
-
|
|
201
|
-
**Endpoint**: `POST /v3/insight/remove`
|
|
202
|
-
|
|
203
|
-
**Request Body**:
|
|
204
|
-
```json
|
|
205
|
-
{
|
|
206
|
-
"0": "stringstringstringstring" // insightId
|
|
207
|
-
}
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
**Response**:
|
|
211
|
-
```json
|
|
212
|
-
{
|
|
213
|
-
"code": 0,
|
|
214
|
-
"msg": "string",
|
|
215
|
-
"details": {},
|
|
216
|
-
"debug": null
|
|
217
|
-
}
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
---
|
|
221
|
-
|
|
222
|
-
## v3.insight.list
|
|
223
|
-
|
|
224
|
-
List all insights in a workspace that the user has access to.
|
|
225
|
-
|
|
226
|
-
**Endpoint**: `POST /v3/insight/list`
|
|
227
|
-
|
|
228
|
-
**Request Body**:
|
|
229
|
-
```json
|
|
230
|
-
{
|
|
231
|
-
"0": "stringstringstringstring" // workspaceId
|
|
232
|
-
}
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
**Response**:
|
|
236
|
-
```json
|
|
237
|
-
{
|
|
238
|
-
"code": 0,
|
|
239
|
-
"msg": "string",
|
|
240
|
-
"details": {
|
|
241
|
-
"insights": [
|
|
242
|
-
{
|
|
243
|
-
"_id": "stringstringstringstring",
|
|
244
|
-
"name": "Insight Name",
|
|
245
|
-
"public": false,
|
|
246
|
-
"sources": [],
|
|
247
|
-
"query": "SELECT ...",
|
|
248
|
-
"created": 1234567890,
|
|
249
|
-
"updated": 1234567890
|
|
250
|
-
}
|
|
251
|
-
]
|
|
252
|
-
},
|
|
253
|
-
"debug": null
|
|
254
|
-
}
|
|
255
|
-
```
|
|
256
|
-
|
|
257
|
-
---
|
|
258
|
-
|
|
259
|
-
## v3.insight.public
|
|
260
|
-
|
|
261
|
-
Get public data for a publicly shared insight (no authentication required).
|
|
262
|
-
|
|
263
|
-
**Endpoint**: `POST /v3/insight/public`
|
|
264
|
-
|
|
265
|
-
**Request Body**:
|
|
266
|
-
```json
|
|
267
|
-
{
|
|
268
|
-
"0": "string" // insightKey (max 32 chars)
|
|
269
|
-
}
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
**Response**:
|
|
273
|
-
```json
|
|
274
|
-
{
|
|
275
|
-
"code": 0,
|
|
276
|
-
"msg": "string",
|
|
277
|
-
"details": {
|
|
278
|
-
"insight": {},
|
|
279
|
-
"data": []
|
|
280
|
-
},
|
|
281
|
-
"debug": null
|
|
282
|
-
}
|
|
283
|
-
```
|
|
284
|
-
|
|
285
|
-
---
|
|
286
|
-
|
|
287
|
-
## v3.insight.data
|
|
288
|
-
|
|
289
|
-
Execute the insight query and get results (actual data).
|
|
290
|
-
|
|
291
|
-
**Endpoint**: `POST /v3/insight/data`
|
|
292
|
-
|
|
293
|
-
**Request Body**:
|
|
294
|
-
```json
|
|
295
|
-
{
|
|
296
|
-
"0": "stringstringstringstring", // insightId
|
|
297
|
-
"1": {
|
|
298
|
-
"update": true // Whether to refresh/recalculate data
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
```
|
|
302
|
-
|
|
303
|
-
**Response**:
|
|
304
|
-
```json
|
|
305
|
-
{
|
|
306
|
-
"code": 0,
|
|
307
|
-
"msg": "string",
|
|
308
|
-
"details": {
|
|
309
|
-
"columns": ["title", "publishDate", "authorName"],
|
|
310
|
-
"rows": [
|
|
311
|
-
["Book 1", "2024-01-01", "Author A"],
|
|
312
|
-
["Book 2", "2024-02-01", "Author B"]
|
|
313
|
-
]
|
|
314
|
-
},
|
|
315
|
-
"debug": null
|
|
316
|
-
}
|
|
317
|
-
```
|
|
318
|
-
|
|
319
|
-
---
|
|
320
|
-
|
|
321
|
-
## v3.insight.preview
|
|
322
|
-
|
|
323
|
-
Preview partial insight during design. Used for testing SQL queries before saving.
|
|
324
|
-
|
|
325
|
-
**Key Features**:
|
|
326
|
-
- Can be called frequently during design
|
|
327
|
-
- Returns errors if SQL is invalid
|
|
328
|
-
- Limited to ~20 activities for performance
|
|
329
|
-
- Workspace admins can modify sources
|
|
330
|
-
- Regular users cannot change sources (security)
|
|
331
|
-
|
|
332
|
-
**Endpoint**: `POST /v3/insight/preview`
|
|
333
|
-
|
|
334
|
-
**Request Body**:
|
|
335
|
-
```json
|
|
336
|
-
{
|
|
337
|
-
"0": "stringstringstringstring", // workspaceId
|
|
338
|
-
"1": {
|
|
339
|
-
"query": "SELECT title FROM books WHERE publishDate > '2024-01-01'",
|
|
340
|
-
"sources": [
|
|
341
|
-
{
|
|
342
|
-
"name": "books",
|
|
343
|
-
"workflowId": "workflowId",
|
|
344
|
-
"fields": [
|
|
345
|
-
{ "name": "title", "meta": "name" },
|
|
346
|
-
{ "name": "publishDate", "fieldId": "fieldId" }
|
|
347
|
-
]
|
|
348
|
-
}
|
|
349
|
-
]
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
```
|
|
353
|
-
|
|
354
|
-
**Response** (success):
|
|
355
|
-
```json
|
|
356
|
-
{
|
|
357
|
-
"code": 0,
|
|
358
|
-
"msg": "string",
|
|
359
|
-
"details": {
|
|
360
|
-
"columns": ["title"],
|
|
361
|
-
"rows": [
|
|
362
|
-
["Book 1"],
|
|
363
|
-
["Book 2"]
|
|
364
|
-
],
|
|
365
|
-
"limited": true // Indicates data was limited for preview
|
|
366
|
-
},
|
|
367
|
-
"debug": null
|
|
368
|
-
}
|
|
369
|
-
```
|
|
370
|
-
|
|
371
|
-
**Response** (error):
|
|
372
|
-
```json
|
|
373
|
-
{
|
|
374
|
-
"code": 403,
|
|
375
|
-
"msg": "SQL syntax error near 'SELEC'",
|
|
376
|
-
"details": {},
|
|
377
|
-
"debug": null
|
|
378
|
-
}
|
|
379
|
-
```
|
|
380
|
-
|
|
381
|
-
---
|
|
382
|
-
|
|
383
|
-
## v3.insight.member.add
|
|
384
|
-
|
|
385
|
-
Add member permissions to an insight (user, team, workspace, or group).
|
|
386
|
-
|
|
387
|
-
**Endpoint**: `POST /v3/insight.member.add`
|
|
388
|
-
|
|
389
|
-
**Request Body**:
|
|
390
|
-
```json
|
|
391
|
-
{
|
|
392
|
-
"0": "stringstringstringstring", // insightId
|
|
393
|
-
"1": "network_<networkId>" // OR: team_<teamId>, user_<userId>, group_<groupId>
|
|
394
|
-
}
|
|
395
|
-
```
|
|
396
|
-
|
|
397
|
-
**Member Format**:
|
|
398
|
-
- Workspace: `network_<networkId>`
|
|
399
|
-
- Team: `team_<teamId>`
|
|
400
|
-
- User: `user_<userId>`
|
|
401
|
-
- Group: `group_<groupId>`
|
|
402
|
-
|
|
403
|
-
**Response**:
|
|
404
|
-
```json
|
|
405
|
-
{
|
|
406
|
-
"code": 0,
|
|
407
|
-
"msg": "string",
|
|
408
|
-
"details": {},
|
|
409
|
-
"debug": null
|
|
410
|
-
}
|
|
411
|
-
```
|
|
412
|
-
|
|
413
|
-
---
|
|
414
|
-
|
|
415
|
-
## v3.insight.member.remove
|
|
416
|
-
|
|
417
|
-
Remove member permissions from an insight.
|
|
418
|
-
|
|
419
|
-
**Endpoint**: `POST /v3/insight.member.remove`
|
|
420
|
-
|
|
421
|
-
**Request Body**:
|
|
422
|
-
```json
|
|
423
|
-
{
|
|
424
|
-
"0": "stringstringstringstring", // insightId
|
|
425
|
-
"1": "user_<userId>" // OR: network_<networkId>, team_<teamId>, group_<groupId>
|
|
426
|
-
}
|
|
427
|
-
```
|
|
428
|
-
|
|
429
|
-
**Response**:
|
|
430
|
-
```json
|
|
431
|
-
{
|
|
432
|
-
"code": 0,
|
|
433
|
-
"msg": "string",
|
|
434
|
-
"details": {},
|
|
435
|
-
"debug": null
|
|
436
|
-
}
|
|
437
|
-
```
|
|
438
|
-
|
|
439
|
-
---
|
|
440
|
-
|
|
441
|
-
## SQL Query Guidelines
|
|
442
|
-
|
|
443
|
-
### Supported SQL Features
|
|
444
|
-
- SELECT with column names or * (all)
|
|
445
|
-
- FROM with table aliases (source names)
|
|
446
|
-
- WHERE clauses with AND/OR
|
|
447
|
-
- JOIN (INNER, LEFT, RIGHT, FULL)
|
|
448
|
-
- GROUP BY with aggregations
|
|
449
|
-
- ORDER BY with ASC/DESC
|
|
450
|
-
- LIMIT and OFFSET
|
|
451
|
-
|
|
452
|
-
### Common Patterns
|
|
453
|
-
|
|
454
|
-
**Filter by phase**:
|
|
455
|
-
```sql
|
|
456
|
-
SELECT title FROM books WHERE phase = 'phaseId'
|
|
457
|
-
```
|
|
458
|
-
|
|
459
|
-
**Count activities**:
|
|
460
|
-
```sql
|
|
461
|
-
SELECT COUNT(*) as total FROM books
|
|
462
|
-
```
|
|
463
|
-
|
|
464
|
-
**Group and aggregate**:
|
|
465
|
-
```sql
|
|
466
|
-
SELECT author, COUNT(*) as bookCount
|
|
467
|
-
FROM books
|
|
468
|
-
GROUP BY author
|
|
469
|
-
ORDER BY bookCount DESC
|
|
470
|
-
```
|
|
471
|
-
|
|
472
|
-
**Join workflows**:
|
|
473
|
-
```sql
|
|
474
|
-
SELECT b.title, a.name as authorName
|
|
475
|
-
FROM books b
|
|
476
|
-
LEFT JOIN authors a ON b.authorId = a.id
|
|
477
|
-
WHERE b.publishDate > '2024-01-01'
|
|
478
|
-
```
|
|
479
|
-
|
|
480
|
-
---
|
|
481
|
-
|
|
482
|
-
## Common Response Format
|
|
483
|
-
|
|
484
|
-
All endpoints return this format:
|
|
485
|
-
|
|
486
|
-
```json
|
|
487
|
-
{
|
|
488
|
-
"code": 0, // 0 = success, 403 = error
|
|
489
|
-
"msg": "string", // Success/error message
|
|
490
|
-
"details": {}, // Response data
|
|
491
|
-
"debug": null // Optional debug info
|
|
492
|
-
}
|
|
493
|
-
```
|
|
494
|
-
|
|
495
|
-
---
|
|
496
|
-
|
|
497
|
-
## Permissions
|
|
498
|
-
|
|
499
|
-
**Workspace Admins**:
|
|
500
|
-
- Create, update, delete insights
|
|
501
|
-
- Modify insight sources
|
|
502
|
-
- Share insights (make public)
|
|
503
|
-
- Manage all insight permissions
|
|
504
|
-
|
|
505
|
-
**Regular Users**:
|
|
506
|
-
- View insights they have access to
|
|
507
|
-
- Edit insights (name, query) if given permission
|
|
508
|
-
- Cannot modify sources (security restriction)
|
|
509
|
-
- Cannot change permissions
|
|
510
|
-
|
|
511
|
-
**Public Insights**:
|
|
512
|
-
- Accessible without authentication via `insightKey`
|
|
513
|
-
- Read-only access
|
|
514
|
-
- Good for public dashboards/reports
|