@weavix/tracker-api-plugin 0.0.3 → 0.0.5

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.
Files changed (2) hide show
  1. package/README.md +107 -13
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,25 +1,119 @@
1
1
  # @weavix/tracker-api-plugin
2
2
 
3
- Typed Tracker API client for iframe plugins. Sends `api.tracker.call` requests through the
4
- generic plugin bridge (`@weavix/sdk-core`'s `sendRequest`) — no dependency on Tracker's own
5
- slot/entity types (`@weavix/tracker-core`), so any host's plugin can install this package to
6
- reach the Tracker HTTP API.
3
+ Typed Tracker Public API client for iframe plugins.
7
4
 
8
- The host side of the contract is implemented by `@yandex-weavix/tracker-api-host`, which any
9
- service running `@yandex-weavix/plugin-host-core` can register as a domain.
5
+ > If you are building a Tracker plugin, you likely want [`@weavix/tracker-plugin-sdk`](https://www.npmjs.com/package/@weavix/tracker-plugin-sdk) instead — it bundles this package together with host API, storage, UI helpers, and Tracker types.
6
+
7
+ ## Installation
10
8
 
11
9
  ```bash
12
- pnpm add @weavix/tracker-api-plugin @weavix/sdk-core
10
+ npm install @weavix/tracker-api-plugin @weavix/sdk-core
13
11
  ```
14
12
 
15
- ```ts
13
+ ## Quick start
14
+
15
+ ```typescript
16
16
  import { trackerApi } from '@weavix/tracker-api-plugin';
17
17
 
18
- const { data } = await trackerApi.v3.get['/issues/{issueKey}']({
19
- pathParams: { issueKey: 'TEST-1' },
18
+ // GET — returns { data, headers }
19
+ const { data: issue } = await trackerApi.v3.get['/issues/{id}']({
20
+ pathParams: { id: 'QUEUE-123' },
21
+ });
22
+
23
+ // POST
24
+ const { data: newIssue } = await trackerApi.v3.post['/v2/issues']({
25
+ bodyParams: { queue: { key: 'TASK' }, summary: 'New issue' },
20
26
  });
21
27
  ```
22
28
 
23
- `trackerApi.v3.get/post/put/patch/delete` are typed against `@weavix/tracker-api-types`'
24
- `ApiV3*Methods` maps. `ApiContract`, `ApiCallPayload`, and `ApiCallResult` are exported for host
25
- implementers.
29
+ ---
30
+
31
+ ## `trackerApi.v3`
32
+
33
+ A typed proxy over Tracker Public API v3 endpoints. Keys are OpenAPI endpoint paths from `@weavix/tracker-api-types`; the IDE provides autocomplete and JSDoc.
34
+
35
+ Full endpoint reference: [Tracker API Reference](https://docs.yandex-team.ru/tracker/api-ref/about-api).
36
+
37
+ ### Methods
38
+
39
+ | Method | `payload` fields | Description |
40
+ |--------|-----------------|-------------|
41
+ | `trackerApi.v3.get[path](payload)` | `pathParams?`, `queryParams?` | GET request |
42
+ | `trackerApi.v3.post[path](payload)` | `bodyParams?`, `pathParams?`, `queryParams?` | POST request |
43
+ | `trackerApi.v3.put[path](payload)` | `bodyParams?`, `pathParams?`, `queryParams?` | PUT request |
44
+ | `trackerApi.v3.patch[path](payload)` | `bodyParams?`, `pathParams?`, `queryParams?` | PATCH request |
45
+ | `trackerApi.v3.delete[path](payload)` | `pathParams?`, `queryParams?` | DELETE request |
46
+
47
+ All methods return `Promise<{ data: T; headers: Record<string, string> }>` where `T` is typed per endpoint.
48
+
49
+ ### Examples
50
+
51
+ ```typescript
52
+ import { trackerApi } from '@weavix/tracker-api-plugin';
53
+
54
+ // Get issue by key
55
+ const { data: issue } = await trackerApi.v3.get['/issues/{id}']({
56
+ pathParams: { id: 'QUEUE-123' },
57
+ queryParams: { expand: ['COMMENTS'] },
58
+ });
59
+
60
+ // Create issue
61
+ const { data: created } = await trackerApi.v3.post['/v2/issues']({
62
+ bodyParams: {
63
+ queue: { key: 'QUEUE' },
64
+ summary: 'Issue title',
65
+ },
66
+ });
67
+
68
+ // Update issue
69
+ await trackerApi.v3.patch['/v2/issues/{id}']({
70
+ pathParams: { id: 'QUEUE-123' },
71
+ bodyParams: { summary: 'Updated title' },
72
+ });
73
+
74
+ // Search issues
75
+ const { data: issues } = await trackerApi.v3.post['/v2/issues/_search']({
76
+ bodyParams: { filter: { queue: 'QUEUE' } },
77
+ });
78
+
79
+ // List queues
80
+ const { data: queues } = await trackerApi.v3.get['/v2/queues']({
81
+ queryParams: { page: 1, perPage: 100 },
82
+ });
83
+ ```
84
+
85
+ ---
86
+
87
+ ## Types
88
+
89
+ ```typescript
90
+ import type {
91
+ TrackerApi, // Class type of trackerApi
92
+ TrackerApiV3, // Type of trackerApi.v3
93
+ TrackerApiCallOptions, // { pathParams?, queryParams?, bodyParams?, file? }
94
+ ApiCallResult, // { data: unknown; headers: Record<string, string> }
95
+ } from '@weavix/tracker-api-plugin';
96
+ ```
97
+
98
+ ### `TrackerApiCallOptions`
99
+
100
+ | Field | Type | Description |
101
+ |-------|------|-------------|
102
+ | `pathParams` | `Record<string, string>` | URL path parameters (e.g. `{ id: 'QUEUE-123' }`) |
103
+ | `queryParams` | `Record<string, unknown>` | URL query parameters |
104
+ | `bodyParams` | `Record<string, unknown>` | Request body |
105
+ | `file` | `File` | File upload (for multipart endpoints) |
106
+
107
+ ---
108
+
109
+ ## Related packages
110
+
111
+ | Package | Purpose |
112
+ |---------|---------|
113
+ | [`@weavix/tracker-plugin-sdk`](https://www.npmjs.com/package/@weavix/tracker-plugin-sdk) | Full Tracker plugin SDK (recommended) |
114
+ | [`@weavix/tracker-api-types`](https://www.npmjs.com/package/@weavix/tracker-api-types) | Tracker Public API v3 OpenAPI types |
115
+ | [`@weavix/sdk-core`](https://www.npmjs.com/package/@weavix/sdk-core) | Plugin bridge runtime |
116
+
117
+ ## License
118
+
119
+ SEE LICENSE IN LICENSE
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weavix/tracker-api-plugin",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "sideEffects": false,
5
5
  "exports": {
6
6
  ".": {