@rawdash/connector-linear 0.12.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/README.md ADDED
@@ -0,0 +1,147 @@
1
+ # @rawdash/connector-linear
2
+
3
+ Rawdash connector for [Linear](https://linear.app) — syncs teams, users, cycles, and issues (plus state-transition events derived from each issue's history) into the six-shape storage model.
4
+
5
+ ## Auth setup
6
+
7
+ The MVP uses a Linear **Personal API Key**:
8
+
9
+ 1. Sign in to Linear and open **Settings → API → Personal API keys**.
10
+ 2. Click **Create new** and give it a name like `rawdash`.
11
+ 3. Copy the key (starts with `lin_api_…`). Linear shows it only once.
12
+
13
+ Personal API keys inherit the scopes of the user who created them. The connector only issues read queries, but use an account with appropriate visibility into the teams you want to sync.
14
+
15
+ OAuth-based auth is planned post-MVP — see the connector roadmap for details.
16
+
17
+ ## Configuration
18
+
19
+ ```ts
20
+ import { LinearConnector } from '@rawdash/connector-linear';
21
+ import { secret } from '@rawdash/core';
22
+
23
+ const linear = new LinearConnector(
24
+ {
25
+ // teamIds: ['team-uuid'], // optional — restrict to one or more teams
26
+ // resources: ['issues'], // optional — defaults to all four phases
27
+ // historyPerIssue: 25, // optional — how many history entries to fetch per issue
28
+ },
29
+ {
30
+ apiKey: secret('LINEAR_API_KEY'),
31
+ },
32
+ );
33
+ ```
34
+
35
+ Or via `LinearConnector.create` (validates the input with the `configFields` Zod schema):
36
+
37
+ ```ts
38
+ const linear = LinearConnector.create({
39
+ apiKey: { $secret: 'LINEAR_API_KEY' },
40
+ // teamIds: ['team-uuid'],
41
+ // resources: ['issues'],
42
+ });
43
+ ```
44
+
45
+ ### Choosing resources
46
+
47
+ The connector exposes four sync phases, run in order:
48
+
49
+ `teams`, `users`, `cycles`, `issues`
50
+
51
+ Pass any non-empty subset as `resources` to sync only those phases. The `issues` phase also emits `linear_issue_state_change` events.
52
+
53
+ ### Example dashboard
54
+
55
+ ```ts
56
+ import { defineConfig, defineDashboard, defineMetric } from '@rawdash/core';
57
+
58
+ export default defineConfig({
59
+ connectors: [{ connector: linear }],
60
+ dashboards: {
61
+ engineering: defineDashboard({
62
+ widgets: {
63
+ open_issues: {
64
+ kind: 'stat',
65
+ title: 'Open issues',
66
+ metric: defineMetric({
67
+ connector: linear,
68
+ shape: 'entity',
69
+ entityType: 'linear_issue',
70
+ fn: 'count',
71
+ filter: [
72
+ { field: 'stateType', op: 'in', value: ['unstarted', 'started'] },
73
+ ],
74
+ }),
75
+ },
76
+ completed_this_week: {
77
+ kind: 'timeseries',
78
+ title: 'Issues completed per day',
79
+ window: '7d',
80
+ metric: defineMetric({
81
+ connector: linear,
82
+ shape: 'event',
83
+ name: 'linear_issue_state_change',
84
+ fn: 'count',
85
+ window: '7d',
86
+ filter: [{ field: 'toStateName', op: 'eq', value: 'Done' }],
87
+ groupBy: { field: 'start_ts', granularity: 'day' },
88
+ }),
89
+ },
90
+ issues_by_priority: {
91
+ kind: 'distribution',
92
+ title: 'Issues by priority',
93
+ metric: defineMetric({
94
+ connector: linear,
95
+ shape: 'entity',
96
+ entityType: 'linear_issue',
97
+ fn: 'count',
98
+ groupBy: { field: 'priority' },
99
+ }),
100
+ },
101
+ },
102
+ }),
103
+ },
104
+ });
105
+ ```
106
+
107
+ ## Data model
108
+
109
+ | Storage shape | Entity/event type | Key attributes |
110
+ | ------------- | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
111
+ | entity | `linear_team` | name, key, createdAt |
112
+ | entity | `linear_user` | name, email, displayName, active, createdAt |
113
+ | entity | `linear_cycle` | number, name, teamId, startsAt, endsAt, completedAt, progress, scope, completedScope |
114
+ | entity | `linear_issue` | identifier, title, stateId, stateName, stateType, priority, assigneeId, teamId, projectId, cycleId, labels, estimate, createdAt, completedAt, canceledAt, startedAt |
115
+ | event | `linear_issue_state_change` | historyId, issueId, issueIdentifier, teamId, actorId, fromStateId, fromStateName, toStateId, toStateName |
116
+
117
+ Timestamps are stored as Unix epoch milliseconds. `linear_issue_state_change` events are derived from the `history(first: N)` window on each issue — only entries with a non-null `fromState` and `toState` (and where they differ) become events.
118
+
119
+ ## Sync behaviour
120
+
121
+ - **Backfill** (`mode: 'full'`): paginates each phase via Linear's `after`/`endCursor` GraphQL connection (page size 50). Issue and event scopes are cleared at the start of their phase so deletions in Linear converge.
122
+ - **Incremental** (`mode: 'latest'`): applies an `updatedAt > since` GraphQL filter on each connection, fetching only records that have changed since the last sync. Append-only state-transition events derived from issue history will accumulate over consecutive incremental syncs.
123
+ - **Rate limits**: Linear sends `X-RateLimit-Requests-Remaining` / `X-RateLimit-Requests-Reset` on every response — the connector reports the parsed state back to the host via the shared rate-limit policy so the engine can budget future requests.
124
+ - **Resumable**: every phase yields a `(phase, endCursor)` cursor — if the host aborts the sync, the next invocation picks up at the same page.
125
+
126
+ ## Out of scope (post-MVP)
127
+
128
+ - Linear OAuth (currently API key only).
129
+ - Webhooks for live updates (Team-tier feature).
130
+ - Roadmap / Initiative resources (open a ticket if you need them).
131
+
132
+ ## Registering in the MCP server
133
+
134
+ ```ts
135
+ import { LinearConnector, configFields } from '@rawdash/connector-linear';
136
+
137
+ createMcpServer({
138
+ // ...
139
+ connectorFactories: [
140
+ {
141
+ id: 'linear',
142
+ configFields,
143
+ create: LinearConnector.create,
144
+ },
145
+ ],
146
+ });
147
+ ```
@@ -0,0 +1,59 @@
1
+ import { BaseConnector, ConnectorContext, SyncOptions, StorageHandle, SyncResult } from '@rawdash/core';
2
+ import { z } from 'zod';
3
+
4
+ declare const configFields: z.ZodObject<{
5
+ apiKey: z.ZodObject<{
6
+ $secret: z.ZodString;
7
+ }, z.core.$strip>;
8
+ teamIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
9
+ resources: z.ZodOptional<z.ZodArray<z.ZodEnum<{
10
+ teams: "teams";
11
+ users: "users";
12
+ cycles: "cycles";
13
+ issues: "issues";
14
+ }>>>;
15
+ historyPerIssue: z.ZodOptional<z.ZodNumber>;
16
+ }, z.core.$strip>;
17
+ interface LinearSettings {
18
+ teamIds?: readonly string[];
19
+ resources?: readonly LinearResource[];
20
+ historyPerIssue?: number;
21
+ }
22
+ declare const linearCredentials: {
23
+ apiKey: {
24
+ description: string;
25
+ auth: "required";
26
+ };
27
+ };
28
+ type LinearCredentials = typeof linearCredentials;
29
+ declare const PHASE_ORDER: readonly ["teams", "users", "cycles", "issues"];
30
+ type LinearPhase = (typeof PHASE_ORDER)[number];
31
+ type LinearResource = LinearPhase;
32
+ declare class LinearConnector extends BaseConnector<LinearSettings, LinearCredentials> {
33
+ static readonly id = "linear";
34
+ static create(input: unknown, ctx?: ConnectorContext): LinearConnector;
35
+ readonly id = "linear";
36
+ readonly credentials: {
37
+ apiKey: {
38
+ description: string;
39
+ auth: "required";
40
+ };
41
+ };
42
+ private buildHeaders;
43
+ private graphql;
44
+ private sinceFilter;
45
+ private teamFilter;
46
+ private issueTeamFilter;
47
+ private mergeFilters;
48
+ private fetchTeamsPage;
49
+ private fetchUsersPage;
50
+ private fetchCyclesPage;
51
+ private fetchIssuesPage;
52
+ private writeTeams;
53
+ private writeUsers;
54
+ private writeCycles;
55
+ private writeIssues;
56
+ sync(options: SyncOptions, storage: StorageHandle, signal?: AbortSignal): Promise<SyncResult>;
57
+ }
58
+
59
+ export { LinearConnector, type LinearResource, type LinearSettings, configFields };
package/dist/index.js ADDED
@@ -0,0 +1,470 @@
1
+ // ../../connector-shared/dist/index.js
2
+ var HTTP_CLIENT_VERSION = "0.0.0";
3
+ var DEFAULT_USER_AGENT = `rawdash-connector/${HTTP_CLIENT_VERSION} (+https://rawdash.dev)`;
4
+ var linearRateLimit = {
5
+ parse(h) {
6
+ const remainingRaw = h.get("x-ratelimit-requests-remaining");
7
+ const resetRaw = h.get("x-ratelimit-requests-reset");
8
+ if (remainingRaw === null) {
9
+ return null;
10
+ }
11
+ const remaining = Number(remainingRaw);
12
+ if (!Number.isFinite(remaining)) {
13
+ return null;
14
+ }
15
+ let resetAt;
16
+ if (resetRaw !== null) {
17
+ const reset = Number(resetRaw);
18
+ if (!Number.isFinite(reset) || reset < 0) {
19
+ return null;
20
+ }
21
+ resetAt = new Date(reset);
22
+ } else {
23
+ resetAt = new Date(Date.now() + 6e4);
24
+ }
25
+ return { remaining, resetAt };
26
+ }
27
+ };
28
+
29
+ // src/linear.ts
30
+ import {
31
+ BaseConnector,
32
+ defineConfigFields,
33
+ paginateChunked
34
+ } from "@rawdash/core";
35
+ import { z } from "zod";
36
+ var configFields = defineConfigFields(
37
+ z.object({
38
+ apiKey: z.object({ $secret: z.string() }).meta({
39
+ label: "API Key",
40
+ description: "Linear Personal API Key. Create one at Linear \u2192 Settings \u2192 API \u2192 Personal API keys.",
41
+ placeholder: "lin_api_...",
42
+ secret: true
43
+ }),
44
+ teamIds: z.array(z.string().min(1)).nonempty().optional().meta({
45
+ label: "Team IDs (optional)",
46
+ description: "Restrict the sync to specific Linear team IDs. Omit to sync all teams the API key can see."
47
+ }),
48
+ resources: z.array(z.enum(["teams", "users", "cycles", "issues"])).nonempty().optional().meta({
49
+ label: "Resources",
50
+ description: "Which Linear resources to sync. Omit to sync all resources. The `issues` phase also emits state-transition events derived from each issue's history."
51
+ }),
52
+ historyPerIssue: z.number().int().positive().max(50).optional().meta({
53
+ label: "History entries per issue",
54
+ description: "How many history entries to pull per issue (newest first). State transitions inside this window become events. Defaults to 25.",
55
+ placeholder: "25"
56
+ })
57
+ })
58
+ );
59
+ var linearCredentials = {
60
+ apiKey: {
61
+ description: "Linear Personal API Key",
62
+ auth: "required"
63
+ }
64
+ };
65
+ var PHASE_ORDER = ["teams", "users", "cycles", "issues"];
66
+ function isLinearSyncCursor(value) {
67
+ if (typeof value !== "object" || value === null) {
68
+ return false;
69
+ }
70
+ const v = value;
71
+ if (typeof v.phase !== "string") {
72
+ return false;
73
+ }
74
+ if (!PHASE_ORDER.includes(v.phase)) {
75
+ return false;
76
+ }
77
+ if (v.page !== null && typeof v.page !== "string") {
78
+ return false;
79
+ }
80
+ return true;
81
+ }
82
+ var TEAMS_QUERY = `
83
+ query Teams($after: String, $first: Int!, $filter: TeamFilter) {
84
+ teams(after: $after, first: $first, filter: $filter, orderBy: updatedAt) {
85
+ nodes { id name key createdAt updatedAt }
86
+ pageInfo { hasNextPage endCursor }
87
+ }
88
+ }
89
+ `;
90
+ var USERS_QUERY = `
91
+ query Users($after: String, $first: Int!, $filter: UserFilter) {
92
+ users(after: $after, first: $first, filter: $filter, orderBy: updatedAt) {
93
+ nodes { id name email displayName active createdAt updatedAt }
94
+ pageInfo { hasNextPage endCursor }
95
+ }
96
+ }
97
+ `;
98
+ var CYCLES_QUERY = `
99
+ query Cycles($after: String, $first: Int!, $filter: CycleFilter) {
100
+ cycles(after: $after, first: $first, filter: $filter, orderBy: updatedAt) {
101
+ nodes {
102
+ id number name startsAt endsAt completedAt progress
103
+ scopeHistory completedScopeHistory
104
+ team { id }
105
+ createdAt updatedAt
106
+ }
107
+ pageInfo { hasNextPage endCursor }
108
+ }
109
+ }
110
+ `;
111
+ var ISSUES_QUERY = `
112
+ query Issues(
113
+ $after: String
114
+ $first: Int!
115
+ $filter: IssueFilter
116
+ $historyFirst: Int!
117
+ ) {
118
+ issues(after: $after, first: $first, filter: $filter, orderBy: updatedAt) {
119
+ nodes {
120
+ id identifier title priority estimate
121
+ state { id name type }
122
+ assignee { id }
123
+ team { id }
124
+ project { id }
125
+ cycle { id }
126
+ labels { nodes { id name } }
127
+ createdAt updatedAt completedAt canceledAt startedAt
128
+ history(first: $historyFirst) {
129
+ nodes {
130
+ id createdAt
131
+ actor { id }
132
+ fromState { id name }
133
+ toState { id name }
134
+ fromAssignee { id }
135
+ toAssignee { id }
136
+ }
137
+ pageInfo { hasNextPage endCursor }
138
+ }
139
+ }
140
+ pageInfo { hasNextPage endCursor }
141
+ }
142
+ }
143
+ `;
144
+ var PAGE_SIZE = 50;
145
+ var DEFAULT_HISTORY_PER_ISSUE = 25;
146
+ var ENDPOINT = "https://api.linear.app/graphql";
147
+ var LinearConnector = class _LinearConnector extends BaseConnector {
148
+ static id = "linear";
149
+ static create(input, ctx) {
150
+ const parsed = configFields.parse(input);
151
+ return new _LinearConnector(
152
+ {
153
+ teamIds: parsed.teamIds,
154
+ resources: parsed.resources,
155
+ historyPerIssue: parsed.historyPerIssue
156
+ },
157
+ { apiKey: parsed.apiKey },
158
+ ctx
159
+ );
160
+ }
161
+ id = "linear";
162
+ credentials = linearCredentials;
163
+ buildHeaders() {
164
+ return {
165
+ Authorization: this.creds.apiKey,
166
+ "Content-Type": "application/json",
167
+ "User-Agent": "rawdash/connector-linear (+https://rawdash.dev)"
168
+ };
169
+ }
170
+ async graphql(query, variables, resource, signal) {
171
+ const res = await this.post(ENDPOINT, {
172
+ resource,
173
+ headers: this.buildHeaders(),
174
+ body: JSON.stringify({ query, variables }),
175
+ signal,
176
+ rateLimit: linearRateLimit
177
+ });
178
+ if (res.body.errors && res.body.errors.length > 0) {
179
+ const messages = res.body.errors.map((e) => e.message).join("; ");
180
+ throw new Error(`Linear GraphQL error: ${messages}`);
181
+ }
182
+ if (!res.body.data) {
183
+ throw new Error(
184
+ `Linear GraphQL response missing data for resource '${resource}'`
185
+ );
186
+ }
187
+ return res;
188
+ }
189
+ sinceFilter(options) {
190
+ if (options.mode !== "latest" || !options.since) {
191
+ return void 0;
192
+ }
193
+ return { updatedAt: { gt: options.since } };
194
+ }
195
+ teamFilter() {
196
+ const ids = this.settings.teamIds;
197
+ if (!ids || ids.length === 0) {
198
+ return void 0;
199
+ }
200
+ return { id: { in: [...ids] } };
201
+ }
202
+ issueTeamFilter() {
203
+ const ids = this.settings.teamIds;
204
+ if (!ids || ids.length === 0) {
205
+ return void 0;
206
+ }
207
+ return { team: { id: { in: [...ids] } } };
208
+ }
209
+ mergeFilters(...filters) {
210
+ const merged = {};
211
+ let any = false;
212
+ for (const f of filters) {
213
+ if (f) {
214
+ Object.assign(merged, f);
215
+ any = true;
216
+ }
217
+ }
218
+ return any ? merged : void 0;
219
+ }
220
+ // ---------------------------------------------------------------------------
221
+ // Fetchers
222
+ // ---------------------------------------------------------------------------
223
+ async fetchTeamsPage(page, options, signal) {
224
+ const filter = this.mergeFilters(
225
+ this.teamFilter(),
226
+ this.sinceFilter(options)
227
+ );
228
+ const res = await this.graphql(
229
+ TEAMS_QUERY,
230
+ { after: page ?? null, first: PAGE_SIZE, filter },
231
+ "teams",
232
+ signal
233
+ );
234
+ const conn = res.body.data.teams;
235
+ return {
236
+ items: conn.nodes,
237
+ next: conn.pageInfo.hasNextPage ? conn.pageInfo.endCursor : null
238
+ };
239
+ }
240
+ async fetchUsersPage(page, options, signal) {
241
+ const res = await this.graphql(
242
+ USERS_QUERY,
243
+ {
244
+ after: page ?? null,
245
+ first: PAGE_SIZE,
246
+ filter: this.sinceFilter(options)
247
+ },
248
+ "users",
249
+ signal
250
+ );
251
+ const conn = res.body.data.users;
252
+ return {
253
+ items: conn.nodes,
254
+ next: conn.pageInfo.hasNextPage ? conn.pageInfo.endCursor : null
255
+ };
256
+ }
257
+ async fetchCyclesPage(page, options, signal) {
258
+ const teamIds = this.settings.teamIds;
259
+ const teamFilter = teamIds && teamIds.length > 0 ? { team: { id: { in: [...teamIds] } } } : void 0;
260
+ const filter = this.mergeFilters(teamFilter, this.sinceFilter(options));
261
+ const res = await this.graphql(
262
+ CYCLES_QUERY,
263
+ { after: page ?? null, first: PAGE_SIZE, filter },
264
+ "cycles",
265
+ signal
266
+ );
267
+ const conn = res.body.data.cycles;
268
+ return {
269
+ items: conn.nodes,
270
+ next: conn.pageInfo.hasNextPage ? conn.pageInfo.endCursor : null
271
+ };
272
+ }
273
+ async fetchIssuesPage(page, options, signal) {
274
+ const filter = this.mergeFilters(
275
+ this.issueTeamFilter(),
276
+ this.sinceFilter(options)
277
+ );
278
+ const historyFirst = this.settings.historyPerIssue ?? DEFAULT_HISTORY_PER_ISSUE;
279
+ const res = await this.graphql(
280
+ ISSUES_QUERY,
281
+ { after: page ?? null, first: PAGE_SIZE, filter, historyFirst },
282
+ "issues",
283
+ signal
284
+ );
285
+ const conn = res.body.data.issues;
286
+ return {
287
+ items: conn.nodes,
288
+ next: conn.pageInfo.hasNextPage ? conn.pageInfo.endCursor : null
289
+ };
290
+ }
291
+ // ---------------------------------------------------------------------------
292
+ // Writers
293
+ // ---------------------------------------------------------------------------
294
+ async writeTeams(storage, teams) {
295
+ for (const t of teams) {
296
+ await storage.entity({
297
+ type: "linear_team",
298
+ id: t.id,
299
+ attributes: {
300
+ name: t.name,
301
+ key: t.key,
302
+ createdAt: new Date(t.createdAt).getTime()
303
+ },
304
+ updated_at: new Date(t.updatedAt).getTime()
305
+ });
306
+ }
307
+ }
308
+ async writeUsers(storage, users) {
309
+ for (const u of users) {
310
+ await storage.entity({
311
+ type: "linear_user",
312
+ id: u.id,
313
+ attributes: {
314
+ name: u.name,
315
+ email: u.email,
316
+ displayName: u.displayName,
317
+ active: u.active,
318
+ createdAt: new Date(u.createdAt).getTime()
319
+ },
320
+ updated_at: new Date(u.updatedAt).getTime()
321
+ });
322
+ }
323
+ }
324
+ async writeCycles(storage, cycles) {
325
+ for (const c of cycles) {
326
+ const startsMs = new Date(c.startsAt).getTime();
327
+ const endsMs = new Date(c.endsAt).getTime();
328
+ const scopeFinal = c.scopeHistory && c.scopeHistory.length > 0 ? c.scopeHistory.at(-1) ?? null : null;
329
+ const completedFinal = c.completedScopeHistory && c.completedScopeHistory.length > 0 ? c.completedScopeHistory.at(-1) ?? null : null;
330
+ await storage.entity({
331
+ type: "linear_cycle",
332
+ id: c.id,
333
+ attributes: {
334
+ number: c.number,
335
+ name: c.name,
336
+ teamId: c.team?.id ?? null,
337
+ startsAt: startsMs,
338
+ endsAt: endsMs,
339
+ completedAt: c.completedAt ? new Date(c.completedAt).getTime() : null,
340
+ progress: c.progress,
341
+ scope: scopeFinal,
342
+ completedScope: completedFinal
343
+ },
344
+ updated_at: new Date(c.updatedAt).getTime()
345
+ });
346
+ }
347
+ }
348
+ async writeIssues(storage, issues, historySinceMs) {
349
+ for (const i of issues) {
350
+ await storage.entity({
351
+ type: "linear_issue",
352
+ id: i.id,
353
+ attributes: {
354
+ identifier: i.identifier,
355
+ title: i.title,
356
+ stateId: i.state?.id ?? null,
357
+ stateName: i.state?.name ?? null,
358
+ stateType: i.state?.type ?? null,
359
+ priority: i.priority,
360
+ assigneeId: i.assignee?.id ?? null,
361
+ teamId: i.team?.id ?? null,
362
+ projectId: i.project?.id ?? null,
363
+ cycleId: i.cycle?.id ?? null,
364
+ labels: i.labels.nodes.map((l) => l.name),
365
+ estimate: i.estimate,
366
+ createdAt: new Date(i.createdAt).getTime(),
367
+ completedAt: i.completedAt ? new Date(i.completedAt).getTime() : null,
368
+ canceledAt: i.canceledAt ? new Date(i.canceledAt).getTime() : null,
369
+ startedAt: i.startedAt ? new Date(i.startedAt).getTime() : null
370
+ },
371
+ updated_at: new Date(i.updatedAt).getTime()
372
+ });
373
+ for (const h of i.history.nodes) {
374
+ if (!h.toState || !h.fromState) {
375
+ continue;
376
+ }
377
+ if (h.toState.id === h.fromState.id) {
378
+ continue;
379
+ }
380
+ const eventTs = new Date(h.createdAt).getTime();
381
+ if (historySinceMs !== null && eventTs <= historySinceMs) {
382
+ continue;
383
+ }
384
+ await storage.event({
385
+ name: "linear_issue_state_change",
386
+ start_ts: eventTs,
387
+ end_ts: null,
388
+ attributes: {
389
+ historyId: h.id,
390
+ issueId: i.id,
391
+ issueIdentifier: i.identifier,
392
+ teamId: i.team?.id ?? null,
393
+ actorId: h.actor?.id ?? null,
394
+ fromStateId: h.fromState.id,
395
+ fromStateName: h.fromState.name,
396
+ toStateId: h.toState.id,
397
+ toStateName: h.toState.name
398
+ }
399
+ });
400
+ }
401
+ }
402
+ }
403
+ // ---------------------------------------------------------------------------
404
+ // sync
405
+ // ---------------------------------------------------------------------------
406
+ async sync(options, storage, signal) {
407
+ const cursor = isLinearSyncCursor(options.cursor) ? options.cursor : void 0;
408
+ const isFull = options.mode === "full";
409
+ const historySinceMs = options.mode === "latest" && options.since ? new Date(options.since).getTime() : null;
410
+ const enabled = this.settings.resources;
411
+ const phases = enabled && enabled.length > 0 ? PHASE_ORDER.filter((p) => enabled.includes(p)) : PHASE_ORDER;
412
+ return paginateChunked({
413
+ phases,
414
+ cursor,
415
+ signal,
416
+ fetchPage: async (phase, page, sig) => {
417
+ switch (phase) {
418
+ case "teams":
419
+ return this.fetchTeamsPage(page, options, sig);
420
+ case "users":
421
+ return this.fetchUsersPage(page, options, sig);
422
+ case "cycles":
423
+ return this.fetchCyclesPage(page, options, sig);
424
+ case "issues":
425
+ return this.fetchIssuesPage(page, options, sig);
426
+ }
427
+ },
428
+ writeBatch: async (phase, items, page) => {
429
+ if (isFull && page === null) {
430
+ switch (phase) {
431
+ case "teams":
432
+ await storage.entities([], { types: ["linear_team"] });
433
+ break;
434
+ case "users":
435
+ await storage.entities([], { types: ["linear_user"] });
436
+ break;
437
+ case "cycles":
438
+ await storage.entities([], { types: ["linear_cycle"] });
439
+ break;
440
+ case "issues":
441
+ await storage.entities([], { types: ["linear_issue"] });
442
+ await storage.events([], {
443
+ names: ["linear_issue_state_change"]
444
+ });
445
+ break;
446
+ }
447
+ }
448
+ switch (phase) {
449
+ case "teams":
450
+ return this.writeTeams(storage, items);
451
+ case "users":
452
+ return this.writeUsers(storage, items);
453
+ case "cycles":
454
+ return this.writeCycles(storage, items);
455
+ case "issues":
456
+ return this.writeIssues(
457
+ storage,
458
+ items,
459
+ historySinceMs
460
+ );
461
+ }
462
+ }
463
+ });
464
+ }
465
+ };
466
+ export {
467
+ LinearConnector,
468
+ configFields
469
+ };
470
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../connector-shared/src/errors.ts","../../../connector-shared/src/retry.ts","../../../connector-shared/src/version.ts","../../../connector-shared/src/request.ts","../../../connector-shared/src/rate-limit.ts","../../../connector-shared/src/pagination.ts","../src/linear.ts"],"sourcesContent":["import type { HttpResponse } from './types';\n\nexport type HttpErrorKind =\n | 'transient'\n | 'rate_limit'\n | 'auth'\n | 'upstream_bug'\n | 'client_bug';\n\nexport abstract class HttpClientError extends Error {\n abstract readonly kind: HttpErrorKind;\n readonly response?: HttpResponse;\n\n constructor(message: string, response?: HttpResponse) {\n super(message);\n this.name = new.target.name;\n this.response = response;\n }\n}\n\nexport class TransientError extends HttpClientError {\n readonly kind = 'transient' as const;\n}\n\nexport class RateLimitError extends HttpClientError {\n readonly kind = 'rate_limit' as const;\n readonly retryAfter?: Date;\n\n constructor(message: string, response?: HttpResponse, retryAfter?: Date) {\n super(message, response);\n this.retryAfter = retryAfter;\n }\n}\n\nexport class AuthError extends HttpClientError {\n readonly kind = 'auth' as const;\n}\n\nexport class UpstreamBugError extends HttpClientError {\n readonly kind = 'upstream_bug' as const;\n}\n\nexport class ClientBugError extends HttpClientError {\n readonly kind = 'client_bug' as const;\n}\n\nexport function classifyStatus(status: number): HttpErrorKind {\n if (status === 429) {\n return 'rate_limit';\n }\n if (status === 401 || status === 403) {\n return 'auth';\n }\n if (status === 408) {\n return 'transient';\n }\n if (status >= 500) {\n return 'upstream_bug';\n }\n if (status >= 400) {\n return 'client_bug';\n }\n return 'client_bug';\n}\n\nexport function errorForStatus(\n message: string,\n response: HttpResponse,\n retryAfter?: Date,\n): HttpClientError {\n const kind = classifyStatus(response.status);\n switch (kind) {\n case 'rate_limit':\n return new RateLimitError(message, response, retryAfter);\n case 'auth':\n return new AuthError(message, response);\n case 'transient':\n return new TransientError(message, response);\n case 'upstream_bug':\n return new UpstreamBugError(message, response);\n case 'client_bug':\n return new ClientBugError(message, response);\n }\n}\n","import { HttpClientError, RateLimitError, TransientError } from './errors';\n\nexport interface RetryPolicy {\n maxAttempts?: number;\n initialDelayMs?: number;\n maxDelayMs?: number;\n retryOn?: (status: number | null, err?: Error) => boolean;\n}\n\nexport const defaultRetryOn = (status: number | null, err?: Error): boolean => {\n if (err instanceof RateLimitError) {\n return true;\n }\n if (err instanceof TransientError) {\n return true;\n }\n if (status === null) {\n return err instanceof Error && !(err instanceof HttpClientError);\n }\n if (status === 408 || status === 429) {\n return true;\n }\n if (status >= 500) {\n return true;\n }\n return false;\n};\n\nexport function backoffDelayMs(\n attempt: number,\n policy: Required<Pick<RetryPolicy, 'initialDelayMs' | 'maxDelayMs'>>,\n): number {\n const base = policy.initialDelayMs * 2 ** attempt;\n const jitter = base * 0.25 * Math.random();\n return Math.min(base + jitter, policy.maxDelayMs);\n}\n\nexport function parseRetryAfter(\n headerValue: string | null,\n now: Date = new Date(),\n): Date | undefined {\n if (!headerValue) {\n return undefined;\n }\n const trimmed = headerValue.trim();\n if (/^\\d+$/.test(trimmed)) {\n return new Date(now.getTime() + Number(trimmed) * 1000);\n }\n const parsed = Date.parse(trimmed);\n if (Number.isNaN(parsed)) {\n return undefined;\n }\n return new Date(parsed);\n}\n\nexport function sleep(ms: number, signal?: AbortSignal): Promise<void> {\n if (signal?.aborted) {\n return Promise.reject(signal.reason ?? new Error('Aborted'));\n }\n return new Promise<void>((resolve, reject) => {\n const onAbort = () => {\n clearTimeout(timer);\n reject(signal!.reason ?? new Error('Aborted'));\n };\n const timer = setTimeout(() => {\n signal?.removeEventListener('abort', onAbort);\n resolve();\n }, ms);\n signal?.addEventListener('abort', onAbort, { once: true });\n });\n}\n","export const HTTP_CLIENT_VERSION = '0.0.0';\n\nexport const DEFAULT_USER_AGENT = `rawdash-connector/${HTTP_CLIENT_VERSION} (+https://rawdash.dev)`;\n","import {\n AuthError,\n ClientBugError,\n HttpClientError,\n RateLimitError,\n TransientError,\n UpstreamBugError,\n errorForStatus,\n} from './errors';\nimport { defaultRetryOn, parseRetryAfter, sleep } from './retry';\nimport type { FetchLike, HttpMethod, HttpRequest, HttpResponse } from './types';\nimport { DEFAULT_USER_AGENT } from './version';\n\nconst DEFAULT_TIMEOUT_MS = 10_000;\nconst DEFAULT_MAX_ATTEMPTS = 3;\nconst DEFAULT_INITIAL_DELAY_MS = 1000;\nconst DEFAULT_MAX_DELAY_MS = 60_000;\nconst OBSERVER_TIMEOUT_MS = 250;\n\nexport interface RequestObservation {\n url: string;\n method: HttpMethod;\n status: number;\n resource: string;\n requestId: string;\n body: unknown;\n}\n\nexport type RequestObserver = (\n event: RequestObservation,\n) => void | Promise<void>;\n\nexport interface RequestOptions {\n fetch?: FetchLike;\n observer?: RequestObserver;\n resource: string;\n requestId?: string;\n}\n\nasync function notifyObserver(\n observer: RequestObserver,\n event: RequestObservation,\n): Promise<void> {\n let result: void | Promise<void>;\n try {\n result = observer(event);\n } catch (err) {\n console.warn('[connector-shared] request observer threw:', err);\n return;\n }\n if (!(result instanceof Promise)) {\n return;\n }\n const guarded = result.catch((err) => {\n console.warn('[connector-shared] request observer rejected:', err);\n });\n let timer: ReturnType<typeof setTimeout> | undefined;\n const timeout = new Promise<void>((resolve) => {\n timer = setTimeout(resolve, OBSERVER_TIMEOUT_MS);\n });\n try {\n await Promise.race([guarded, timeout]);\n } finally {\n if (timer) {\n clearTimeout(timer);\n }\n }\n}\n\nfunction newRequestId(): string {\n const c = (globalThis as { crypto?: { randomUUID?: () => string } }).crypto;\n if (c?.randomUUID) {\n return c.randomUUID();\n }\n return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;\n}\n\nfunction mergeHeaders(\n defaults: Record<string, string>,\n overrides: Record<string, string> | undefined,\n): Record<string, string> {\n const merged: Record<string, string> = {};\n for (const [k, v] of Object.entries(defaults)) {\n merged[k.toLowerCase()] = v;\n }\n if (overrides) {\n for (const [k, v] of Object.entries(overrides)) {\n merged[k.toLowerCase()] = v;\n }\n }\n return merged;\n}\n\nfunction linkTimeoutSignal(\n parent: AbortSignal | undefined,\n timeoutMs: number,\n): { signal: AbortSignal; cancel: () => void } {\n const controller = new AbortController();\n const onParentAbort = () => {\n controller.abort(parent?.reason);\n };\n if (parent) {\n if (parent.aborted) {\n controller.abort(parent.reason);\n } else {\n parent.addEventListener('abort', onParentAbort, { once: true });\n }\n }\n const timer = setTimeout(() => {\n controller.abort(new Error(`Request timed out after ${timeoutMs}ms`));\n }, timeoutMs);\n return {\n signal: controller.signal,\n cancel: () => {\n clearTimeout(timer);\n if (parent) {\n parent.removeEventListener('abort', onParentAbort);\n }\n },\n };\n}\n\nasync function readBody(res: Response, parseJson: boolean): Promise<unknown> {\n if (res.status === 204 || res.status === 205) {\n return null;\n }\n const contentType = res.headers.get('content-type') ?? '';\n if (parseJson && contentType.includes('application/json')) {\n const text = await res.text();\n if (text.length === 0) {\n return null;\n }\n return JSON.parse(text);\n }\n return res.text();\n}\n\nexport async function request<T = unknown>(\n req: HttpRequest,\n options: RequestOptions,\n): Promise<HttpResponse<T>> {\n const fetchImpl: FetchLike = options.fetch ?? (globalThis.fetch as FetchLike);\n const retry = req.retry ?? {};\n const maxAttempts = retry.maxAttempts ?? DEFAULT_MAX_ATTEMPTS;\n const initialDelayMs = retry.initialDelayMs ?? DEFAULT_INITIAL_DELAY_MS;\n const maxDelayMs = retry.maxDelayMs ?? DEFAULT_MAX_DELAY_MS;\n const retryOn = retry.retryOn ?? defaultRetryOn;\n const timeoutMs = req.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n const parseJson = req.parseJson ?? true;\n\n const headers = mergeHeaders(\n {\n 'User-Agent': DEFAULT_USER_AGENT,\n Accept: 'application/json',\n },\n req.headers,\n );\n\n let lastErr: Error | undefined;\n\n for (let attempt = 0; attempt < maxAttempts; attempt++) {\n req.signal?.throwIfAborted();\n\n const { signal, cancel } = linkTimeoutSignal(req.signal, timeoutMs);\n let res: Response;\n try {\n res = await fetchImpl(req.url, {\n method: req.method ?? 'GET',\n headers,\n body: req.body as RequestInit['body'],\n signal,\n });\n } catch (err) {\n cancel();\n if (req.signal?.aborted) {\n throw req.signal.reason ?? err;\n }\n const error = err instanceof Error ? err : new Error(String(err));\n lastErr = error;\n if (attempt < maxAttempts - 1 && retryOn(null, error)) {\n const delay = computeDelay(attempt, initialDelayMs, maxDelayMs);\n await sleep(delay, req.signal);\n continue;\n }\n throw new TransientError(error.message);\n }\n cancel();\n\n const body = await readBody(res, parseJson);\n const httpResponse: HttpResponse<T> = {\n status: res.status,\n headers: res.headers,\n body: body as T,\n };\n if (req.rateLimit) {\n const state = req.rateLimit.parse(res.headers);\n if (state) {\n httpResponse.rateLimitState = state;\n }\n }\n\n if (options.observer) {\n await notifyObserver(options.observer, {\n url: req.url,\n method: req.method ?? 'GET',\n status: res.status,\n resource: options.resource,\n requestId: options.requestId ?? newRequestId(),\n body,\n });\n }\n\n if (res.ok) {\n return httpResponse;\n }\n\n const retryAfter = parseRetryAfter(res.headers.get('retry-after'));\n const message = `HTTP ${res.status} ${res.statusText} for ${req.method ?? 'GET'} ${req.url}`;\n const err = errorForStatus(message, httpResponse, retryAfter);\n\n if (\n attempt < maxAttempts - 1 &&\n retryOn(res.status, err) &&\n !(err instanceof AuthError) &&\n !(err instanceof ClientBugError)\n ) {\n lastErr = err;\n let delay = computeDelay(attempt, initialDelayMs, maxDelayMs);\n if (err instanceof RateLimitError && retryAfter) {\n const wait = retryAfter.getTime() - Date.now();\n if (wait > 0) {\n delay = Math.min(wait, maxDelayMs);\n }\n }\n await sleep(delay, req.signal);\n continue;\n }\n\n throw err;\n }\n\n throw lastErr ?? new UpstreamBugError('Exhausted retry attempts');\n}\n\nfunction computeDelay(\n attempt: number,\n initialDelayMs: number,\n maxDelayMs: number,\n): number {\n const base = initialDelayMs * 2 ** attempt;\n const jitter = base * 0.25 * Math.random();\n return Math.min(base + jitter, maxDelayMs);\n}\n\nexport { HttpClientError };\n","export interface RateLimitState {\n remaining: number;\n resetAt: Date;\n}\n\nexport interface RateLimitPolicy {\n parse(headers: Headers): RateLimitState | null;\n}\n\nexport const githubRateLimit: RateLimitPolicy = {\n parse(h) {\n const remainingRaw = h.get('x-ratelimit-remaining');\n const resetRaw = h.get('x-ratelimit-reset');\n if (remainingRaw === null || resetRaw === null) {\n return null;\n }\n const remaining = Number(remainingRaw);\n const reset = Number(resetRaw);\n if (!Number.isFinite(remaining) || !Number.isFinite(reset) || reset < 0) {\n return null;\n }\n return { remaining, resetAt: new Date(reset * 1000) };\n },\n};\n\nexport const sentryRateLimit: RateLimitPolicy = {\n parse(h) {\n const concurrent = h.get('x-sentry-rate-limit-remaining');\n const reset = h.get('x-sentry-rate-limit-reset');\n if (concurrent === null || reset === null) {\n return null;\n }\n const remaining = Number(concurrent);\n const resetSec = Number(reset);\n if (\n !Number.isFinite(remaining) ||\n !Number.isFinite(resetSec) ||\n resetSec < 0\n ) {\n return null;\n }\n return { remaining, resetAt: new Date(resetSec * 1000) };\n },\n};\n\nexport const linearRateLimit: RateLimitPolicy = {\n parse(h) {\n const remainingRaw = h.get('x-ratelimit-requests-remaining');\n const resetRaw = h.get('x-ratelimit-requests-reset');\n if (remainingRaw === null) {\n return null;\n }\n const remaining = Number(remainingRaw);\n if (!Number.isFinite(remaining)) {\n return null;\n }\n let resetAt: Date;\n if (resetRaw !== null) {\n const reset = Number(resetRaw);\n if (!Number.isFinite(reset) || reset < 0) {\n return null;\n }\n resetAt = new Date(reset);\n } else {\n resetAt = new Date(Date.now() + 60_000);\n }\n return { remaining, resetAt };\n },\n};\n","import { request } from './request';\nimport type { HttpRequest } from './types';\n\nexport function parseLinkHeader(header: string | null): Record<string, string> {\n if (!header) {\n return {};\n }\n const result: Record<string, string> = {};\n for (const part of header.split(',')) {\n const match = part.match(/<([^>]+)>\\s*;\\s*rel=\"([^\"]+)\"/);\n if (match) {\n result[match[2]!] = match[1]!;\n }\n }\n return result;\n}\n\nexport async function* paginateLink<T>(\n initial: HttpRequest,\n parse: (body: unknown) => T[],\n options: { resource: string },\n): AsyncIterable<T> {\n let next: string | null = initial.url;\n while (next) {\n const res: Awaited<ReturnType<typeof request>> = await request(\n {\n ...initial,\n url: next,\n },\n { resource: options.resource },\n );\n for (const item of parse(res.body)) {\n yield item;\n }\n const links = parseLinkHeader(res.headers.get('link'));\n next = links['next'] ?? null;\n }\n}\n\nexport async function* paginateCursor<T>(\n initial: HttpRequest,\n parse: (body: unknown) => { items: T[]; nextCursor: string | null },\n buildNext: (req: HttpRequest, cursor: string) => HttpRequest,\n options: { resource: string },\n): AsyncIterable<T> {\n let req: HttpRequest = initial;\n while (true) {\n const res = await request(req, { resource: options.resource });\n const { items, nextCursor } = parse(res.body);\n for (const item of items) {\n yield item;\n }\n if (!nextCursor) {\n return;\n }\n req = buildNext(req, nextCursor);\n }\n}\n\nexport async function* paginatePage<T>(\n initial: HttpRequest,\n parse: (body: unknown) => { items: T[]; hasMore: boolean },\n buildPage: (req: HttpRequest, page: number) => HttpRequest,\n options: { resource: string },\n): AsyncIterable<T> {\n let page = 1;\n while (true) {\n const req = page === 1 ? initial : buildPage(initial, page);\n const res = await request(req, { resource: options.resource });\n const { items, hasMore } = parse(res.body);\n for (const item of items) {\n yield item;\n }\n if (!hasMore || items.length === 0) {\n return;\n }\n page++;\n }\n}\n","import { type HttpResponse, linearRateLimit } from '@rawdash/connector-shared';\nimport {\n BaseConnector,\n type ChunkedSyncCursor,\n type ConnectorContext,\n type CredentialsSchema,\n type StorageHandle,\n type SyncOptions,\n type SyncResult,\n defineConfigFields,\n paginateChunked,\n} from '@rawdash/core';\nimport { z } from 'zod';\n\nexport const configFields = defineConfigFields(\n z.object({\n apiKey: z.object({ $secret: z.string() }).meta({\n label: 'API Key',\n description:\n 'Linear Personal API Key. Create one at Linear → Settings → API → Personal API keys.',\n placeholder: 'lin_api_...',\n secret: true,\n }),\n teamIds: z.array(z.string().min(1)).nonempty().optional().meta({\n label: 'Team IDs (optional)',\n description:\n 'Restrict the sync to specific Linear team IDs. Omit to sync all teams the API key can see.',\n }),\n resources: z\n .array(z.enum(['teams', 'users', 'cycles', 'issues']))\n .nonempty()\n .optional()\n .meta({\n label: 'Resources',\n description:\n \"Which Linear resources to sync. Omit to sync all resources. The `issues` phase also emits state-transition events derived from each issue's history.\",\n }),\n historyPerIssue: z.number().int().positive().max(50).optional().meta({\n label: 'History entries per issue',\n description:\n 'How many history entries to pull per issue (newest first). State transitions inside this window become events. Defaults to 25.',\n placeholder: '25',\n }),\n }),\n);\n\nexport interface LinearSettings {\n teamIds?: readonly string[];\n resources?: readonly LinearResource[];\n historyPerIssue?: number;\n}\n\nconst linearCredentials = {\n apiKey: {\n description: 'Linear Personal API Key',\n auth: 'required' as const,\n },\n} satisfies CredentialsSchema;\n\ntype LinearCredentials = typeof linearCredentials;\n\nconst PHASE_ORDER = ['teams', 'users', 'cycles', 'issues'] as const;\n\ntype LinearPhase = (typeof PHASE_ORDER)[number];\n\nexport type LinearResource = LinearPhase;\n\ntype LinearSyncCursor = ChunkedSyncCursor<LinearPhase, string>;\n\nfunction isLinearSyncCursor(value: unknown): value is LinearSyncCursor {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n const v = value as { phase?: unknown; page?: unknown };\n if (typeof v.phase !== 'string') {\n return false;\n }\n if (!(PHASE_ORDER as readonly string[]).includes(v.phase)) {\n return false;\n }\n if (v.page !== null && typeof v.page !== 'string') {\n return false;\n }\n return true;\n}\n\n// ---------------------------------------------------------------------------\n// Linear GraphQL types\n// ---------------------------------------------------------------------------\n\ninterface PageInfo {\n hasNextPage: boolean;\n endCursor: string | null;\n}\n\ninterface Connection<T> {\n nodes: T[];\n pageInfo: PageInfo;\n}\n\ninterface LinearTeam {\n id: string;\n name: string;\n key: string;\n createdAt: string;\n updatedAt: string;\n}\n\ninterface LinearUser {\n id: string;\n name: string;\n email: string | null;\n displayName: string;\n active: boolean;\n createdAt: string;\n updatedAt: string;\n}\n\ninterface LinearCycle {\n id: string;\n number: number;\n name: string | null;\n startsAt: string;\n endsAt: string;\n completedAt: string | null;\n progress: number | null;\n scopeHistory: number[] | null;\n completedScopeHistory: number[] | null;\n team: { id: string } | null;\n createdAt: string;\n updatedAt: string;\n}\n\ninterface LinearIssueHistory {\n id: string;\n createdAt: string;\n actor: { id: string } | null;\n fromState: { id: string; name: string } | null;\n toState: { id: string; name: string } | null;\n fromAssignee: { id: string } | null;\n toAssignee: { id: string } | null;\n}\n\ninterface LinearIssue {\n id: string;\n identifier: string;\n title: string;\n priority: number;\n estimate: number | null;\n state: { id: string; name: string; type: string } | null;\n assignee: { id: string } | null;\n team: { id: string } | null;\n project: { id: string } | null;\n cycle: { id: string } | null;\n labels: { nodes: Array<{ id: string; name: string }> };\n createdAt: string;\n updatedAt: string;\n completedAt: string | null;\n canceledAt: string | null;\n startedAt: string | null;\n history: Connection<LinearIssueHistory>;\n}\n\ninterface GraphQLError {\n message: string;\n extensions?: { code?: string; type?: string };\n}\n\ninterface GraphQLResponse<T> {\n data?: T;\n errors?: GraphQLError[];\n}\n\n// ---------------------------------------------------------------------------\n// GraphQL documents\n// ---------------------------------------------------------------------------\n\nconst TEAMS_QUERY = `\n query Teams($after: String, $first: Int!, $filter: TeamFilter) {\n teams(after: $after, first: $first, filter: $filter, orderBy: updatedAt) {\n nodes { id name key createdAt updatedAt }\n pageInfo { hasNextPage endCursor }\n }\n }\n`;\n\nconst USERS_QUERY = `\n query Users($after: String, $first: Int!, $filter: UserFilter) {\n users(after: $after, first: $first, filter: $filter, orderBy: updatedAt) {\n nodes { id name email displayName active createdAt updatedAt }\n pageInfo { hasNextPage endCursor }\n }\n }\n`;\n\nconst CYCLES_QUERY = `\n query Cycles($after: String, $first: Int!, $filter: CycleFilter) {\n cycles(after: $after, first: $first, filter: $filter, orderBy: updatedAt) {\n nodes {\n id number name startsAt endsAt completedAt progress\n scopeHistory completedScopeHistory\n team { id }\n createdAt updatedAt\n }\n pageInfo { hasNextPage endCursor }\n }\n }\n`;\n\nconst ISSUES_QUERY = `\n query Issues(\n $after: String\n $first: Int!\n $filter: IssueFilter\n $historyFirst: Int!\n ) {\n issues(after: $after, first: $first, filter: $filter, orderBy: updatedAt) {\n nodes {\n id identifier title priority estimate\n state { id name type }\n assignee { id }\n team { id }\n project { id }\n cycle { id }\n labels { nodes { id name } }\n createdAt updatedAt completedAt canceledAt startedAt\n history(first: $historyFirst) {\n nodes {\n id createdAt\n actor { id }\n fromState { id name }\n toState { id name }\n fromAssignee { id }\n toAssignee { id }\n }\n pageInfo { hasNextPage endCursor }\n }\n }\n pageInfo { hasNextPage endCursor }\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// LinearConnector\n// ---------------------------------------------------------------------------\n\nconst PAGE_SIZE = 50;\nconst DEFAULT_HISTORY_PER_ISSUE = 25;\nconst ENDPOINT = 'https://api.linear.app/graphql';\n\nexport class LinearConnector extends BaseConnector<\n LinearSettings,\n LinearCredentials\n> {\n static readonly id = 'linear';\n\n static create(input: unknown, ctx?: ConnectorContext): LinearConnector {\n const parsed = configFields.parse(input);\n return new LinearConnector(\n {\n teamIds: parsed.teamIds,\n resources: parsed.resources,\n historyPerIssue: parsed.historyPerIssue,\n },\n { apiKey: parsed.apiKey },\n ctx,\n );\n }\n\n readonly id = 'linear';\n override readonly credentials = linearCredentials;\n\n private buildHeaders(): Record<string, string> {\n return {\n Authorization: this.creds.apiKey,\n 'Content-Type': 'application/json',\n 'User-Agent': 'rawdash/connector-linear (+https://rawdash.dev)',\n };\n }\n\n private async graphql<T>(\n query: string,\n variables: Record<string, unknown>,\n resource: string,\n signal?: AbortSignal,\n ): Promise<HttpResponse<GraphQLResponse<T>>> {\n const res = await this.post<GraphQLResponse<T>>(ENDPOINT, {\n resource,\n headers: this.buildHeaders(),\n body: JSON.stringify({ query, variables }),\n signal,\n rateLimit: linearRateLimit,\n });\n if (res.body.errors && res.body.errors.length > 0) {\n const messages = res.body.errors.map((e) => e.message).join('; ');\n throw new Error(`Linear GraphQL error: ${messages}`);\n }\n if (!res.body.data) {\n throw new Error(\n `Linear GraphQL response missing data for resource '${resource}'`,\n );\n }\n return res;\n }\n\n private sinceFilter(\n options: SyncOptions,\n ): Record<string, unknown> | undefined {\n if (options.mode !== 'latest' || !options.since) {\n return undefined;\n }\n return { updatedAt: { gt: options.since } };\n }\n\n private teamFilter(): Record<string, unknown> | undefined {\n const ids = this.settings.teamIds;\n if (!ids || ids.length === 0) {\n return undefined;\n }\n return { id: { in: [...ids] } };\n }\n\n private issueTeamFilter(): Record<string, unknown> | undefined {\n const ids = this.settings.teamIds;\n if (!ids || ids.length === 0) {\n return undefined;\n }\n return { team: { id: { in: [...ids] } } };\n }\n\n private mergeFilters(\n ...filters: Array<Record<string, unknown> | undefined>\n ): Record<string, unknown> | undefined {\n const merged: Record<string, unknown> = {};\n let any = false;\n for (const f of filters) {\n if (f) {\n Object.assign(merged, f);\n any = true;\n }\n }\n return any ? merged : undefined;\n }\n\n // ---------------------------------------------------------------------------\n // Fetchers\n // ---------------------------------------------------------------------------\n\n private async fetchTeamsPage(\n page: string | null,\n options: SyncOptions,\n signal?: AbortSignal,\n ): Promise<{ items: LinearTeam[]; next: string | null }> {\n const filter = this.mergeFilters(\n this.teamFilter(),\n this.sinceFilter(options),\n );\n const res = await this.graphql<{ teams: Connection<LinearTeam> }>(\n TEAMS_QUERY,\n { after: page ?? null, first: PAGE_SIZE, filter },\n 'teams',\n signal,\n );\n const conn = res.body.data!.teams;\n return {\n items: conn.nodes,\n next: conn.pageInfo.hasNextPage ? conn.pageInfo.endCursor : null,\n };\n }\n\n private async fetchUsersPage(\n page: string | null,\n options: SyncOptions,\n signal?: AbortSignal,\n ): Promise<{ items: LinearUser[]; next: string | null }> {\n const res = await this.graphql<{ users: Connection<LinearUser> }>(\n USERS_QUERY,\n {\n after: page ?? null,\n first: PAGE_SIZE,\n filter: this.sinceFilter(options),\n },\n 'users',\n signal,\n );\n const conn = res.body.data!.users;\n return {\n items: conn.nodes,\n next: conn.pageInfo.hasNextPage ? conn.pageInfo.endCursor : null,\n };\n }\n\n private async fetchCyclesPage(\n page: string | null,\n options: SyncOptions,\n signal?: AbortSignal,\n ): Promise<{ items: LinearCycle[]; next: string | null }> {\n const teamIds = this.settings.teamIds;\n const teamFilter =\n teamIds && teamIds.length > 0\n ? { team: { id: { in: [...teamIds] } } }\n : undefined;\n const filter = this.mergeFilters(teamFilter, this.sinceFilter(options));\n const res = await this.graphql<{ cycles: Connection<LinearCycle> }>(\n CYCLES_QUERY,\n { after: page ?? null, first: PAGE_SIZE, filter },\n 'cycles',\n signal,\n );\n const conn = res.body.data!.cycles;\n return {\n items: conn.nodes,\n next: conn.pageInfo.hasNextPage ? conn.pageInfo.endCursor : null,\n };\n }\n\n private async fetchIssuesPage(\n page: string | null,\n options: SyncOptions,\n signal?: AbortSignal,\n ): Promise<{ items: LinearIssue[]; next: string | null }> {\n const filter = this.mergeFilters(\n this.issueTeamFilter(),\n this.sinceFilter(options),\n );\n const historyFirst =\n this.settings.historyPerIssue ?? DEFAULT_HISTORY_PER_ISSUE;\n const res = await this.graphql<{ issues: Connection<LinearIssue> }>(\n ISSUES_QUERY,\n { after: page ?? null, first: PAGE_SIZE, filter, historyFirst },\n 'issues',\n signal,\n );\n const conn = res.body.data!.issues;\n return {\n items: conn.nodes,\n next: conn.pageInfo.hasNextPage ? conn.pageInfo.endCursor : null,\n };\n }\n\n // ---------------------------------------------------------------------------\n // Writers\n // ---------------------------------------------------------------------------\n\n private async writeTeams(\n storage: StorageHandle,\n teams: LinearTeam[],\n ): Promise<void> {\n for (const t of teams) {\n await storage.entity({\n type: 'linear_team',\n id: t.id,\n attributes: {\n name: t.name,\n key: t.key,\n createdAt: new Date(t.createdAt).getTime(),\n },\n updated_at: new Date(t.updatedAt).getTime(),\n });\n }\n }\n\n private async writeUsers(\n storage: StorageHandle,\n users: LinearUser[],\n ): Promise<void> {\n for (const u of users) {\n await storage.entity({\n type: 'linear_user',\n id: u.id,\n attributes: {\n name: u.name,\n email: u.email,\n displayName: u.displayName,\n active: u.active,\n createdAt: new Date(u.createdAt).getTime(),\n },\n updated_at: new Date(u.updatedAt).getTime(),\n });\n }\n }\n\n private async writeCycles(\n storage: StorageHandle,\n cycles: LinearCycle[],\n ): Promise<void> {\n for (const c of cycles) {\n const startsMs = new Date(c.startsAt).getTime();\n const endsMs = new Date(c.endsAt).getTime();\n const scopeFinal =\n c.scopeHistory && c.scopeHistory.length > 0\n ? (c.scopeHistory.at(-1) ?? null)\n : null;\n const completedFinal =\n c.completedScopeHistory && c.completedScopeHistory.length > 0\n ? (c.completedScopeHistory.at(-1) ?? null)\n : null;\n await storage.entity({\n type: 'linear_cycle',\n id: c.id,\n attributes: {\n number: c.number,\n name: c.name,\n teamId: c.team?.id ?? null,\n startsAt: startsMs,\n endsAt: endsMs,\n completedAt: c.completedAt ? new Date(c.completedAt).getTime() : null,\n progress: c.progress,\n scope: scopeFinal,\n completedScope: completedFinal,\n },\n updated_at: new Date(c.updatedAt).getTime(),\n });\n }\n }\n\n private async writeIssues(\n storage: StorageHandle,\n issues: LinearIssue[],\n historySinceMs: number | null,\n ): Promise<void> {\n for (const i of issues) {\n await storage.entity({\n type: 'linear_issue',\n id: i.id,\n attributes: {\n identifier: i.identifier,\n title: i.title,\n stateId: i.state?.id ?? null,\n stateName: i.state?.name ?? null,\n stateType: i.state?.type ?? null,\n priority: i.priority,\n assigneeId: i.assignee?.id ?? null,\n teamId: i.team?.id ?? null,\n projectId: i.project?.id ?? null,\n cycleId: i.cycle?.id ?? null,\n labels: i.labels.nodes.map((l) => l.name),\n estimate: i.estimate,\n createdAt: new Date(i.createdAt).getTime(),\n completedAt: i.completedAt ? new Date(i.completedAt).getTime() : null,\n canceledAt: i.canceledAt ? new Date(i.canceledAt).getTime() : null,\n startedAt: i.startedAt ? new Date(i.startedAt).getTime() : null,\n },\n updated_at: new Date(i.updatedAt).getTime(),\n });\n\n for (const h of i.history.nodes) {\n if (!h.toState || !h.fromState) {\n continue;\n }\n if (h.toState.id === h.fromState.id) {\n continue;\n }\n const eventTs = new Date(h.createdAt).getTime();\n if (historySinceMs !== null && eventTs <= historySinceMs) {\n continue;\n }\n await storage.event({\n name: 'linear_issue_state_change',\n start_ts: eventTs,\n end_ts: null,\n attributes: {\n historyId: h.id,\n issueId: i.id,\n issueIdentifier: i.identifier,\n teamId: i.team?.id ?? null,\n actorId: h.actor?.id ?? null,\n fromStateId: h.fromState.id,\n fromStateName: h.fromState.name,\n toStateId: h.toState.id,\n toStateName: h.toState.name,\n },\n });\n }\n }\n }\n\n // ---------------------------------------------------------------------------\n // sync\n // ---------------------------------------------------------------------------\n\n async sync(\n options: SyncOptions,\n storage: StorageHandle,\n signal?: AbortSignal,\n ): Promise<SyncResult> {\n const cursor = isLinearSyncCursor(options.cursor)\n ? options.cursor\n : undefined;\n const isFull = options.mode === 'full';\n const historySinceMs =\n options.mode === 'latest' && options.since\n ? new Date(options.since).getTime()\n : null;\n\n const enabled = this.settings.resources;\n const phases =\n enabled && enabled.length > 0\n ? PHASE_ORDER.filter((p) => enabled.includes(p))\n : PHASE_ORDER;\n\n return paginateChunked<LinearPhase, string>({\n phases,\n cursor,\n signal,\n fetchPage: async (phase, page, sig) => {\n switch (phase) {\n case 'teams':\n return this.fetchTeamsPage(page, options, sig);\n case 'users':\n return this.fetchUsersPage(page, options, sig);\n case 'cycles':\n return this.fetchCyclesPage(page, options, sig);\n case 'issues':\n return this.fetchIssuesPage(page, options, sig);\n }\n },\n writeBatch: async (phase, items, page) => {\n if (isFull && page === null) {\n switch (phase) {\n case 'teams':\n await storage.entities([], { types: ['linear_team'] });\n break;\n case 'users':\n await storage.entities([], { types: ['linear_user'] });\n break;\n case 'cycles':\n await storage.entities([], { types: ['linear_cycle'] });\n break;\n case 'issues':\n await storage.entities([], { types: ['linear_issue'] });\n await storage.events([], {\n names: ['linear_issue_state_change'],\n });\n break;\n }\n }\n switch (phase) {\n case 'teams':\n return this.writeTeams(storage, items as LinearTeam[]);\n case 'users':\n return this.writeUsers(storage, items as LinearUser[]);\n case 'cycles':\n return this.writeCycles(storage, items as LinearCycle[]);\n case 'issues':\n return this.writeIssues(\n storage,\n items as LinearIssue[],\n historySinceMs,\n );\n }\n },\n });\n }\n}\n"],"mappings":";AEAO,IAAM,sBAAsB;AAE5B,IAAM,qBAAqB,qBAAqB,mBAAmB;AE2CnE,IAAM,kBAAmC;EAC9C,MAAM,GAAG;AACP,UAAM,eAAe,EAAE,IAAI,gCAAgC;AAC3D,UAAM,WAAW,EAAE,IAAI,4BAA4B;AACnD,QAAI,iBAAiB,M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AAE,OAAO,CAAC,aAAa,EAAE,CAAC;AACrD;AAAA,YACF,KAAK;AACH,oBAAM,QAAQ,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC;AACrD;AAAA,YACF,KAAK;AACH,oBAAM,QAAQ,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,cAAc,EAAE,CAAC;AACtD;AAAA,YACF,KAAK;AACH,oBAAM,QAAQ,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,cAAc,EAAE,CAAC;AACtD,oBAAM,QAAQ,OAAO,CAAC,GAAG;AAAA,gBACvB,OAAO,CAAC,2BAA2B;AAAA,cACrC,CAAC;AACD;AAAA,UACJ;AAAA,QACF;AACA,gBAAQ,OAAO;AAAA,UACb,KAAK;AACH,mBAAO,KAAK,WAAW,SAAS,KAAqB;AAAA,UACvD,KAAK;AACH,mBAAO,KAAK,WAAW,SAAS,KAAqB;AAAA,UACvD,KAAK;AACH,mBAAO,KAAK,YAAY,SAAS,KAAsB;AAAA,UACzD,KAAK;AACH,mBAAO,KAAK;AAAA,cACV;AAAA,cACA;AAAA,cACA;AAAA,YACF;AAAA,QACJ;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AACF;","names":[]}
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@rawdash/connector-linear",
3
+ "version": "0.12.0",
4
+ "description": "Rawdash connector for Linear — issues, cycles, teams, and users",
5
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/rawdash/rawdash.git",
10
+ "directory": "packages/connectors/linear"
11
+ },
12
+ "files": [
13
+ "dist",
14
+ "README.md",
15
+ "LICENSE"
16
+ ],
17
+ "exports": {
18
+ ".": {
19
+ "@rawdash/source": "./src/index.ts",
20
+ "types": "./dist/index.d.ts",
21
+ "import": "./dist/index.js"
22
+ }
23
+ },
24
+ "scripts": {
25
+ "build": "tsup",
26
+ "typecheck": "tsc --noEmit",
27
+ "lint": "eslint src",
28
+ "test": "vitest run"
29
+ },
30
+ "dependencies": {
31
+ "@rawdash/core": "workspace:*",
32
+ "zod": "^4.4.3"
33
+ },
34
+ "devDependencies": {
35
+ "@rawdash/connector-shared": "workspace:*",
36
+ "tsup": "^8.0.0",
37
+ "typescript": "^5.7.2",
38
+ "vitest": "^4.1.4"
39
+ }
40
+ }