@datashift/sdk 0.2.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,10 +1,13 @@
1
1
  # @datashift/sdk
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/@datashift/sdk)](https://www.npmjs.com/package/@datashift/sdk)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
5
+
3
6
  TypeScript SDK for integrating human-in-the-loop checkpoints into AI agent workflows.
4
7
 
5
8
  ## Overview
6
9
 
7
- Datashift enables AI agents to submit tasks for human review before committing changes.
10
+ [Datashift](https://datashift.io) enables AI agents to submit tasks for human review before committing changes. Create review queues, define review types (approval, classification, labeling, scoring, augmentation), and integrate human oversight into any AI workflow — via [REST API](https://datashift.io/docs/api) or [MCP](https://datashift.io/docs/mcp).
8
11
 
9
12
  ## Installation
10
13
 
@@ -177,8 +180,13 @@ app.post('/webhook/datashift',
177
180
  const event = parseWebhookEvent<WebhookEvent>(req.body);
178
181
 
179
182
  if (event.event === 'task.reviewed') {
180
- const {task_id, result, review} = event.data;
181
- handleTaskReviewed(task_id, result, review);
183
+ const {task, queue, reviews} = event.data;
184
+ console.log(`Task ${task.id} in queue ${queue.key} reviewed`);
185
+ console.log(`Result: ${reviews[0].result}`);
186
+ console.log(`Reviewer: ${reviews[0].reviewer.name}`);
187
+ } else if (event.event === 'task.created') {
188
+ const {task, queue} = event.data;
189
+ console.log(`Task ${task.id} created in queue ${queue.key}`);
182
190
  }
183
191
 
184
192
  res.status(200).send('OK');
@@ -190,22 +198,61 @@ app.post('/webhook/datashift',
190
198
 
191
199
  | Event | Description |
192
200
  |------------------|--------------------------------|
193
- | `task.reviewed` | Task has been reviewed |
201
+ | `task.created` | A new task was submitted for review |
202
+ | `task.reviewed` | A task has been reviewed (includes all reviews) |
194
203
 
195
- ### Webhook Payload
204
+ ### Webhook Payloads
196
205
 
197
206
  ```typescript
198
- interface WebhookEvent {
199
- event: string; // Event type
200
- timestamp: string; // ISO 8601 timestamp
207
+ // task.created
208
+ interface TaskCreatedWebhookEvent {
209
+ event: 'task.created';
210
+ timestamp: string;
201
211
  data: {
202
- task_id: string;
203
- queue_key: string;
204
- state: string;
205
- result: string[];
206
- review?: Review;
212
+ task: WebhookTaskData;
213
+ queue: WebhookQueueData;
207
214
  };
208
215
  }
216
+
217
+ // task.reviewed
218
+ interface TaskReviewedWebhookEvent {
219
+ event: 'task.reviewed';
220
+ timestamp: string;
221
+ data: {
222
+ task: WebhookTaskData;
223
+ queue: WebhookQueueData;
224
+ reviews: WebhookReviewData[]; // All reviews (supports two-step workflows)
225
+ };
226
+ }
227
+
228
+ interface WebhookTaskData {
229
+ id: string;
230
+ external_id: string | null;
231
+ state: string;
232
+ summary: string | null;
233
+ data: Record<string, unknown>;
234
+ metadata: Record<string, unknown>;
235
+ sla_deadline: string | null;
236
+ reviewed_at: string | null;
237
+ created_at: string;
238
+ }
239
+
240
+ interface WebhookQueueData {
241
+ key: string;
242
+ name: string;
243
+ review_type: string;
244
+ }
245
+
246
+ interface WebhookReviewData {
247
+ result: string[];
248
+ data: Record<string, unknown>;
249
+ comment: string | null;
250
+ reviewer: { name: string; type: string };
251
+ created_at: string;
252
+ }
253
+
254
+ // Union type for all webhook events
255
+ type WebhookEvent = TaskCreatedWebhookEvent | TaskReviewedWebhookEvent;
209
256
  ```
210
257
 
211
258
  ## Types
@@ -383,10 +430,10 @@ app.post('/webhook/datashift',
383
430
  const event = parseWebhookEvent<WebhookEvent>(req.body);
384
431
 
385
432
  if (event.event === 'task.reviewed') {
386
- const resolver = pendingTasks.get(event.data.task_id);
433
+ const resolver = pendingTasks.get(event.data.task.id);
387
434
  if (resolver) {
388
435
  resolver(event.data);
389
- pendingTasks.delete(event.data.task_id);
436
+ pendingTasks.delete(event.data.task.id);
390
437
  }
391
438
  }
392
439
 
@@ -402,6 +449,14 @@ app.listen(3000);
402
449
  - Node.js 18+
403
450
  - TypeScript 5.0+ (for type definitions)
404
451
 
452
+ ## Resources
453
+
454
+ - [Datashift Website](https://datashift.io) — Product overview and sign up
455
+ - [Documentation](https://datashift.io/docs) — Guides, API reference, and examples
456
+ - [MCP Server](https://datashift.io/docs/mcp) — Connect AI agents via Model Context Protocol
457
+ - [Console](https://console.datashift.io) — Manage queues, reviewers, and API keys
458
+ - [GitHub](https://github.com/datashift-io) — SDKs and sample projects
459
+
405
460
  ## License
406
461
 
407
462
  MIT
package/dist/index.d.mts CHANGED
@@ -59,7 +59,7 @@ interface Review {
59
59
  reviewer_id: string | null;
60
60
  result: string[];
61
61
  data: Record<string, unknown>;
62
- comment: string | null;
62
+ feedback: string | null;
63
63
  created_at: string;
64
64
  }
65
65
  interface ListReviewsFilters {
@@ -91,6 +91,51 @@ interface ReviewResult {
91
91
  reviewed_at: string;
92
92
  review: Review;
93
93
  }
94
+ type WebhookEventType = 'task.created' | 'task.reviewed';
95
+ interface WebhookTaskData {
96
+ id: string;
97
+ external_id: string | null;
98
+ state: string;
99
+ summary: string | null;
100
+ data: Record<string, unknown>;
101
+ metadata: Record<string, unknown>;
102
+ sla_deadline: string | null;
103
+ reviewed_at: string | null;
104
+ created_at: string;
105
+ }
106
+ interface WebhookQueueData {
107
+ key: string;
108
+ name: string;
109
+ review_type: string;
110
+ }
111
+ interface WebhookReviewData {
112
+ result: string[];
113
+ data: Record<string, unknown>;
114
+ feedback: string | null;
115
+ reviewer: {
116
+ name: string;
117
+ type: string;
118
+ };
119
+ created_at: string;
120
+ }
121
+ interface TaskCreatedWebhookEvent {
122
+ event: 'task.created';
123
+ timestamp: string;
124
+ data: {
125
+ task: WebhookTaskData;
126
+ queue: WebhookQueueData;
127
+ };
128
+ }
129
+ interface TaskReviewedWebhookEvent {
130
+ event: 'task.reviewed';
131
+ timestamp: string;
132
+ data: {
133
+ task: WebhookTaskData;
134
+ queue: WebhookQueueData;
135
+ reviews: WebhookReviewData[];
136
+ };
137
+ }
138
+ type WebhookEvent = TaskCreatedWebhookEvent | TaskReviewedWebhookEvent;
94
139
 
95
140
  declare class TaskResource {
96
141
  private client;
@@ -229,4 +274,4 @@ declare class ServerError extends DatashiftError {
229
274
  constructor(message?: string);
230
275
  }
231
276
 
232
- export { type AssignmentStrategy, AuthenticationError, DatashiftError, DatashiftRestClient, type ListReviewsFilters, NotFoundError, type Queue, RateLimitError, type RestClientConfig, type Review, type ReviewOption, type ReviewResult, type ReviewType, ServerError, type SubmitTaskInput, type Task, type TaskState, type TaskStatus, TimeoutError, ValidationError, type WaitOptions };
277
+ export { type AssignmentStrategy, AuthenticationError, DatashiftError, DatashiftRestClient, type ListReviewsFilters, NotFoundError, type Queue, RateLimitError, type RestClientConfig, type Review, type ReviewOption, type ReviewResult, type ReviewType, ServerError, type SubmitTaskInput, type Task, type TaskCreatedWebhookEvent, type TaskReviewedWebhookEvent, type TaskState, type TaskStatus, TimeoutError, ValidationError, type WaitOptions, type WebhookEvent, type WebhookEventType, type WebhookQueueData, type WebhookReviewData, type WebhookTaskData };
package/dist/index.d.ts CHANGED
@@ -59,7 +59,7 @@ interface Review {
59
59
  reviewer_id: string | null;
60
60
  result: string[];
61
61
  data: Record<string, unknown>;
62
- comment: string | null;
62
+ feedback: string | null;
63
63
  created_at: string;
64
64
  }
65
65
  interface ListReviewsFilters {
@@ -91,6 +91,51 @@ interface ReviewResult {
91
91
  reviewed_at: string;
92
92
  review: Review;
93
93
  }
94
+ type WebhookEventType = 'task.created' | 'task.reviewed';
95
+ interface WebhookTaskData {
96
+ id: string;
97
+ external_id: string | null;
98
+ state: string;
99
+ summary: string | null;
100
+ data: Record<string, unknown>;
101
+ metadata: Record<string, unknown>;
102
+ sla_deadline: string | null;
103
+ reviewed_at: string | null;
104
+ created_at: string;
105
+ }
106
+ interface WebhookQueueData {
107
+ key: string;
108
+ name: string;
109
+ review_type: string;
110
+ }
111
+ interface WebhookReviewData {
112
+ result: string[];
113
+ data: Record<string, unknown>;
114
+ feedback: string | null;
115
+ reviewer: {
116
+ name: string;
117
+ type: string;
118
+ };
119
+ created_at: string;
120
+ }
121
+ interface TaskCreatedWebhookEvent {
122
+ event: 'task.created';
123
+ timestamp: string;
124
+ data: {
125
+ task: WebhookTaskData;
126
+ queue: WebhookQueueData;
127
+ };
128
+ }
129
+ interface TaskReviewedWebhookEvent {
130
+ event: 'task.reviewed';
131
+ timestamp: string;
132
+ data: {
133
+ task: WebhookTaskData;
134
+ queue: WebhookQueueData;
135
+ reviews: WebhookReviewData[];
136
+ };
137
+ }
138
+ type WebhookEvent = TaskCreatedWebhookEvent | TaskReviewedWebhookEvent;
94
139
 
95
140
  declare class TaskResource {
96
141
  private client;
@@ -229,4 +274,4 @@ declare class ServerError extends DatashiftError {
229
274
  constructor(message?: string);
230
275
  }
231
276
 
232
- export { type AssignmentStrategy, AuthenticationError, DatashiftError, DatashiftRestClient, type ListReviewsFilters, NotFoundError, type Queue, RateLimitError, type RestClientConfig, type Review, type ReviewOption, type ReviewResult, type ReviewType, ServerError, type SubmitTaskInput, type Task, type TaskState, type TaskStatus, TimeoutError, ValidationError, type WaitOptions };
277
+ export { type AssignmentStrategy, AuthenticationError, DatashiftError, DatashiftRestClient, type ListReviewsFilters, NotFoundError, type Queue, RateLimitError, type RestClientConfig, type Review, type ReviewOption, type ReviewResult, type ReviewType, ServerError, type SubmitTaskInput, type Task, type TaskCreatedWebhookEvent, type TaskReviewedWebhookEvent, type TaskState, type TaskStatus, TimeoutError, ValidationError, type WaitOptions, type WebhookEvent, type WebhookEventType, type WebhookQueueData, type WebhookReviewData, type WebhookTaskData };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datashift/sdk",
3
- "version": "0.2.0",
3
+ "version": "0.3.2",
4
4
  "description": "Datashift SDK for human-in-the-loop AI agent workflows",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -26,9 +26,17 @@
26
26
  "keywords": [
27
27
  "datashift",
28
28
  "ai",
29
+ "ai-agents",
29
30
  "agents",
30
31
  "human-in-the-loop",
31
- "hitl"
32
+ "hitl",
33
+ "llm",
34
+ "review-workflow",
35
+ "model-context-protocol",
36
+ "mcp",
37
+ "automation",
38
+ "content-moderation",
39
+ "approval-workflow"
32
40
  ],
33
41
  "author": "Datashift",
34
42
  "license": "MIT",