@rawdash/connector-jira 0.0.1 → 0.16.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/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,115 +1,89 @@
1
+ <!-- This file is generated from connector metadata by scripts/generate-connector-docs.ts. Do not edit by hand. -->
2
+
1
3
  # @rawdash/connector-jira
2
4
 
3
- Rawdash connector for [Jira Cloud](https://www.atlassian.com/software/jira) — syncs issues, issue status-change events, sprints, projects, and users into the six-shape storage model. Extends the engineering vertical beyond Linear-native shops.
5
+ [![npm version](https://img.shields.io/npm/v/@rawdash/connector-jira)](https://www.npmjs.com/package/@rawdash/connector-jira)
6
+ [![license](https://img.shields.io/npm/l/@rawdash/connector-jira)](https://github.com/rawdash/rawdash/blob/main/LICENSE)
4
7
 
5
- > **Cloud only.** This connector targets the Jira Cloud REST API v3 and Agile API. Jira Data Center / Server are out of scope for v0.1.
8
+ Sync projects, users, sprints, issues, and issue status-change events from a Jira Cloud site.
6
9
 
7
- ## Auth setup
10
+ ## Install
8
11
 
9
- The connector authenticates with **Basic auth** using an Atlassian account email and an API token (Atlassian Cloud's recommended pattern for server-to-server access).
12
+ ```sh
13
+ npm install @rawdash/connector-jira
14
+ ```
10
15
 
11
- 1. Sign in to [id.atlassian.com](https://id.atlassian.com) with the account that should own the integration (a service account is recommended so the sync survives staff changes).
12
- 2. Go to **Security → API tokens → Create API token**.
13
- 3. Give it a label (e.g. `rawdash`) and copy the token — you won't see it again.
14
- 4. Store the token wherever your rawdash deployment resolves secrets from (e.g. the `JIRA_API_TOKEN` env var).
16
+ ## Authentication
15
17
 
16
- The account only needs read access (Browse Projects permission) to the projects you want to sync. No webhook or app installation is required.
18
+ Authenticates over HTTP Basic auth using your Atlassian account email and an API token. The token must belong to an account with access to the projects you want to sync.
17
19
 
18
- > The token's permissions cap what the connector can see. To sync sprints you also need the account to have access to the relevant Scrum boards.
20
+ 1. Open id.atlassian.com -> Security -> Create and manage API tokens.
21
+ 2. Create an API token and copy its value.
22
+ 3. Store the token as a secret and reference it from the connector config as `apiToken: secret("JIRA_API_TOKEN")`, alongside your account email and site host (e.g. yourorg.atlassian.net).
23
+ 4. Story points and the sprint association live on custom fields whose IDs differ per Jira site. Discover them at `https://{host}/rest/api/3/field` and set storyPointsField / sprintField to match.
19
24
 
20
25
  ## Configuration
21
26
 
27
+ | Field | Type | Required | Description |
28
+ | ------------------ | ------ | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
29
+ | `email` | string | Yes | Atlassian account email paired with the API token for Basic auth. |
30
+ | `apiToken` | secret | Yes | Atlassian API token. Create one at id.atlassian.com → Security → API tokens. |
31
+ | `host` | string | Yes | Your Jira Cloud host, e.g. yourorg.atlassian.net (no protocol, no trailing slash). |
32
+ | `projectKeys` | array | No | Restrict the sync to specific Jira project keys (e.g. ENG, OPS). Omit to sync every project the account can see. |
33
+ | `resources` | array | No | Which Jira resources to sync. Omit to sync all of them. 'issue_events' shares the issues query - enabling it without 'issues' still fetches issues (with changelog) but skips writing issue entities. |
34
+ | `storyPointsField` | string | No | Custom field ID holding story points (varies per site). Defaults to customfield_10016. |
35
+ | `sprintField` | string | No | Custom field ID holding the sprint association on issues. Defaults to customfield_10020. |
36
+
37
+ ## Resources
38
+
39
+ - **`jira_project`** _(entity)_ - Jira projects with key, name, type, and project lead. Restrict via projectKeys to limit the sync.
40
+ - Endpoint: `GET /rest/api/3/project/search`
41
+ - **`jira_user`** _(entity)_ - Atlassian accounts visible to the connector, including display name, email, account type, and active state.
42
+ - Endpoint: `GET /rest/api/3/users/search`
43
+ - **`jira_sprint`** _(entity)_ - Sprints from scrum boards with state, start/end/complete dates, and owning board.
44
+ - Endpoint: `GET /rest/agile/1.0/board/{boardId}/sprint`
45
+ - **`jira_issue`** _(entity)_ - Issues with status, priority, type, assignee, reporter, project, sprint, story points, and resolution date.
46
+ - Endpoint: `GET /rest/api/3/search/jql`
47
+ - sprintId is taken from the most recent sprint on the issue's sprint custom field.
48
+ - **`jira_issue_status_change`** _(event)_ - Status transition events derived from issue changelogs, capturing the from/to status, author, and project.
49
+ - Endpoint: `GET /rest/api/3/search/jql (expand=changelog)`
50
+ - start_ts is the changelog entry time, end_ts is null. Timestamps are Unix epoch milliseconds.
51
+
52
+ ## Example
53
+
22
54
  ```ts
23
- import { secret } from '@rawdash/core';
55
+ import {
56
+ defineConfig,
57
+ defineDashboard,
58
+ defineMetric,
59
+ secret,
60
+ } from '@rawdash/core';
24
61
 
25
62
  const jira = {
26
63
  name: 'jira',
27
64
  connectorId: 'jira',
28
65
  config: {
29
- email: 'bot@yourorg.com',
66
+ email: 'you@yourorg.com',
30
67
  apiToken: secret('JIRA_API_TOKEN'),
31
- host: 'yourorg.atlassian.net', // no protocol, no trailing slash
32
- // projectKeys: ['ENG', 'OPS'], // optional — restrict to specific project keys
33
- // resources: ['issues', 'issue_events'], // optional — defaults to all five
34
- // storyPointsField: 'customfield_10016', // optional — story points custom field id
35
- // sprintField: 'customfield_10020', // optional — sprint custom field id
68
+ host: 'yourorg.atlassian.net',
69
+ projectKeys: ['ENG'],
36
70
  },
37
71
  };
38
- ```
39
-
40
- Register the connector class when mounting the engine:
41
-
42
- ```ts
43
- import { JiraConnector } from '@rawdash/connector-jira';
44
- import { mountEngine } from '@rawdash/hono';
45
-
46
- mountEngine(config, { connectorRegistry: { jira: JiraConnector } });
47
- ```
48
-
49
- ### Custom field IDs vary per site
50
-
51
- Story points and the sprint association live on **custom fields** whose IDs differ between Jira sites. The defaults (`customfield_10016` for story points, `customfield_10020` for sprint) match most company-managed Scrum projects, but if your numbers come up empty, find the right IDs at **`https://<host>/rest/api/3/field`** and set `storyPointsField` / `sprintField`.
52
-
53
- ### Choosing resources
54
-
55
- The connector exposes five resources, written across four internal sync phases:
56
-
57
- | Resource | Phase | What gets written |
58
- | -------------- | -------- | -------------------------------------------------------------------------------------- |
59
- | `projects` | projects | `jira_project` entities, one per project |
60
- | `users` | users | `jira_user` entities, one per Atlassian account |
61
- | `sprints` | sprints | `jira_sprint` entities, one per sprint across every Scrum board the account can see |
62
- | `issues` | issues | `jira_issue` entities, one per issue |
63
- | `issue_events` | issues | `jira_issue_status_change` events, one per status transition in each issue's changelog |
64
-
65
- `issue_events` shares the `issues` phase because the events are derived from the changelog returned alongside each issue (`expand=changelog`). Enabling `issue_events` without `issues` still runs the issue search (so the events have data) but skips writing the issue entities themselves.
66
-
67
- ### Example dashboard
68
-
69
- ```ts
70
- import { defineConfig, defineDashboard, defineMetric } from '@rawdash/core';
71
72
 
72
73
  export default defineConfig({
73
74
  connectors: [jira],
74
75
  dashboards: {
75
76
  delivery: defineDashboard({
76
77
  widgets: {
77
- completed_7d: {
78
+ open_issues: {
78
79
  kind: 'stat',
79
- title: 'Issues completed (7d)',
80
- metric: defineMetric({
81
- connector: jira,
82
- shape: 'event',
83
- name: 'jira_issue_status_change',
84
- field: 'start_ts',
85
- fn: 'count',
86
- window: '7d',
87
- filter: [{ field: 'toStatus', op: 'eq', value: 'Done' }],
88
- }),
89
- },
90
- issues_by_status: {
91
- kind: 'distribution',
92
- title: 'Open issues by status',
80
+ title: 'Open Issues',
93
81
  metric: defineMetric({
94
82
  connector: jira,
95
83
  shape: 'entity',
96
- type: 'jira_issue',
97
- fn: 'count',
98
- groupBy: { field: 'statusName' },
99
- }),
100
- },
101
- transitions_per_day: {
102
- kind: 'timeseries',
103
- title: 'Status transitions per day',
104
- window: '14d',
105
- metric: defineMetric({
106
- connector: jira,
107
- shape: 'event',
108
- name: 'jira_issue_status_change',
109
- field: 'start_ts',
84
+ entityType: 'jira_issue',
110
85
  fn: 'count',
111
- window: '14d',
112
- groupBy: { field: 'start_ts', granularity: 'day' },
86
+ filter: [{ field: 'statusCategory', op: 'neq', value: 'done' }],
113
87
  }),
114
88
  },
115
89
  },
@@ -118,60 +92,22 @@ export default defineConfig({
118
92
  });
119
93
  ```
120
94
 
121
- ## Data model
122
-
123
- | Storage shape | Entity/event type | Key attributes |
124
- | ------------- | -------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
125
- | entity | `jira_project` | key, name, projectTypeKey, leadAccountId, leadDisplayName |
126
- | entity | `jira_user` | displayName, emailAddress, accountType, active |
127
- | entity | `jira_sprint` | name, state, boardId, originBoardId, startDate, endDate, completeDate |
128
- | entity | `jira_issue` | key, summary, statusName, statusCategory, priority, issueType, assigneeId, reporterId, projectKey, sprintId, storyPoints, createdAt, resolvedAt |
129
- | event | `jira_issue_status_change` | historyId, issueId, issueKey, projectKey, authorId, fromStatus, toStatus. `start_ts` = changelog entry time, `end_ts` = null. |
130
-
131
- Timestamps are stored as Unix epoch milliseconds. `sprintId` is taken from the most recent sprint on the issue's sprint custom field. `jira_project` / `jira_user` have no source-side update timestamp, so their `updated_at` is the sync time.
132
-
133
- ## Schemas
134
-
135
- `JiraConnector.schemas` declares the Zod schema for each resource's raw API response. Used by the cloud shape-drift pipeline to populate `connector_baselines`, and by the package's property tests.
136
-
137
- | Resource | Represents |
138
- | ---------- | ---------------------------------------------- |
139
- | `projects` | `GET /rest/api/3/project/search` page |
140
- | `users` | `GET /rest/api/3/users/search` page |
141
- | `sprints` | `GET /rest/agile/1.0/board/{id}/sprint` values |
142
- | `issues` | `GET /rest/api/3/search/jql` page |
143
-
144
- ## Sync behaviour
145
-
146
- - **Backfill** (`mode: 'full'`): paginates each phase and clears the phase's entity/event scope on the first page so deletions in Jira converge.
147
- - **projects** — `GET /rest/api/3/project/search?expand=lead`, `startAt` pagination via the response's `isLast` flag.
148
- - **users** — `GET /rest/api/3/users/search`, `startAt` pagination (terminates when a short page is returned).
149
- - **sprints** — lists Scrum boards via `GET /rest/agile/1.0/board`, then pulls each board's sprints from `GET /rest/agile/1.0/board/{id}/sprint`. Non-Scrum boards (kanban) are skipped because they don't support sprints.
150
- - **issues** — `GET /rest/api/3/search/jql` with `expand=changelog`, paginated via the response's `nextPageToken`.
151
- - **Incremental** (`mode: 'latest'`): the issues query adds a `updated >= "<UTC yyyy-MM-dd HH:mm>"` JQL clause so only issues changed since the last sync are pulled, ordered by `updated ASC`. Changelog entries at or before the `since` cutoff are dropped so status-change events aren't re-emitted. Projects, users, and sprints are small, so they are fully refreshed on every sync.
152
- - **Rate limits**: Jira applies cost-based rate limiting and returns `429` with a `Retry-After` header — the shared HTTP client surfaces these as `RateLimitError` and the host backs off.
153
- - **Resumable**: every paginated phase yields a `{ phase, page }` cursor (`ChunkedSyncCursor`). For `startAt`-based phases `page` is the numeric offset; for issues it is the opaque `nextPageToken`.
154
-
155
- ## Errors
156
-
157
- `@rawdash/connector-shared` maps Jira's HTTP responses to typed errors automatically:
95
+ ## Rate limits
158
96
 
159
- - `401` / `403` `AuthError` host stops syncing until the credentials are replaced.
160
- - `429` → `RateLimitError` — host backs off and reschedules.
161
- - `5xx` → `TransientError` — host retries on the next tick.
97
+ Jira Cloud uses cost-based rate limiting; 429 responses with Retry-After are honored.
162
98
 
163
- ## Out of scope (post-v0.1)
99
+ ## Limitations
164
100
 
165
- - **Jira Data Center / Server** Cloud only for v0.1.
166
- - **Confluence** a separate connector if needed.
167
- - **Worklogs / time tracking** not dashboard-shaped for the initial release.
101
+ - Sprints are only synced from scrum boards; kanban boards are skipped.
102
+ - Issue status-change events are derived from each issue changelog; only `status` field transitions are written.
103
+ - Targets Jira Cloud REST API v3 and the Agile API; Jira Data Center / Server are out of scope.
168
104
 
169
- ## Property tests
105
+ ## Links
170
106
 
171
- Resources in this connector have fast-check property tests under `src/property.test.ts` that:
107
+ - [Rawdash docs](https://rawdash.dev/docs/connectors/)
108
+ - [Atlassian API docs](https://developer.atlassian.com/cloud/jira/platform/rest/v3/)
109
+ - [GitHub](https://github.com/rawdash/rawdash)
172
110
 
173
- 1. Generate synthetic API payloads from a Zod schema mirroring Jira's response shape.
174
- 2. Pipe them through `connector.sync()` against an `InMemoryStorage` instance.
175
- 3. Assert universal invariants — non-empty entity ids, finite event timestamps, no `undefined` reaching storage, no thrown errors on any valid input — plus per-resource counts.
111
+ ## License
176
112
 
177
- The helper lives in `@rawdash/connector-test-utils`. When adding a new resource, add a Zod schema for its payload and a test wired up via `runPropertySyncTest`.
113
+ Apache-2.0
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { BaseConnector, ConnectorContext, SyncOptions, StorageHandle, SyncResult } from '@rawdash/core';
1
+ import { BaseConnector, ConnectorContext, SyncOptions, StorageHandle, SyncResult, ConnectorDoc } from '@rawdash/core';
2
2
  import { z } from 'zod';
3
3
 
4
4
  declare const configFields: z.ZodObject<{
@@ -9,15 +9,16 @@ declare const configFields: z.ZodObject<{
9
9
  host: z.ZodString;
10
10
  projectKeys: z.ZodOptional<z.ZodArray<z.ZodString>>;
11
11
  resources: z.ZodOptional<z.ZodArray<z.ZodEnum<{
12
+ issues: "issues";
12
13
  projects: "projects";
13
14
  users: "users";
14
15
  sprints: "sprints";
15
- issues: "issues";
16
16
  issue_events: "issue_events";
17
17
  }>>>;
18
18
  storyPointsField: z.ZodOptional<z.ZodString>;
19
19
  sprintField: z.ZodOptional<z.ZodString>;
20
20
  }, z.core.$strip>;
21
+ declare const doc: ConnectorDoc;
21
22
  type JiraResource = 'projects' | 'users' | 'sprints' | 'issues' | 'issue_events';
22
23
  interface JiraSettings {
23
24
  host: string;
@@ -39,7 +40,139 @@ declare const jiraCredentials: {
39
40
  type JiraCredentials = typeof jiraCredentials;
40
41
  declare class JiraConnector extends BaseConnector<JiraSettings, JiraCredentials> {
41
42
  static readonly id = "jira";
42
- static readonly schemas: {
43
+ static readonly resources: {
44
+ readonly jira_project: {
45
+ readonly shape: "entity";
46
+ readonly description: "Jira projects with key, name, type, and project lead. Restrict via projectKeys to limit the sync.";
47
+ readonly endpoint: "GET /rest/api/3/project/search";
48
+ readonly responses: {
49
+ readonly projects: z.ZodObject<{
50
+ values: z.ZodArray<z.ZodObject<{
51
+ id: z.ZodString;
52
+ key: z.ZodString;
53
+ name: z.ZodString;
54
+ projectTypeKey: z.ZodOptional<z.ZodNullable<z.ZodString>>;
55
+ lead: z.ZodOptional<z.ZodNullable<z.ZodObject<{
56
+ accountId: z.ZodString;
57
+ displayName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
58
+ }, z.core.$strip>>>;
59
+ }, z.core.$strip>>;
60
+ isLast: z.ZodBoolean;
61
+ startAt: z.ZodNumber;
62
+ maxResults: z.ZodNumber;
63
+ total: z.ZodNumber;
64
+ }, z.core.$strip>;
65
+ };
66
+ };
67
+ readonly jira_user: {
68
+ readonly shape: "entity";
69
+ readonly description: "Atlassian accounts visible to the connector, including display name, email, account type, and active state.";
70
+ readonly endpoint: "GET /rest/api/3/users/search";
71
+ readonly responses: {
72
+ readonly users: z.ZodArray<z.ZodObject<{
73
+ accountId: z.ZodString;
74
+ displayName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
75
+ emailAddress: z.ZodOptional<z.ZodNullable<z.ZodString>>;
76
+ accountType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
77
+ active: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
78
+ }, z.core.$strip>>;
79
+ };
80
+ };
81
+ readonly jira_sprint: {
82
+ readonly shape: "entity";
83
+ readonly description: "Sprints from scrum boards with state, start/end/complete dates, and owning board.";
84
+ readonly endpoint: "GET /rest/agile/1.0/board/{boardId}/sprint";
85
+ readonly responses: {
86
+ readonly sprints: z.ZodArray<z.ZodObject<{
87
+ id: z.ZodNumber;
88
+ name: z.ZodString;
89
+ state: z.ZodEnum<{
90
+ active: "active";
91
+ closed: "closed";
92
+ future: "future";
93
+ }>;
94
+ startDate: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
95
+ endDate: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
96
+ completeDate: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
97
+ originBoardId: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
98
+ }, z.core.$strip>>;
99
+ };
100
+ };
101
+ readonly jira_issue: {
102
+ readonly shape: "entity";
103
+ readonly description: "Issues with status, priority, type, assignee, reporter, project, sprint, story points, and resolution date.";
104
+ readonly endpoint: "GET /rest/api/3/search/jql";
105
+ readonly notes: "sprintId is taken from the most recent sprint on the issue's sprint custom field.";
106
+ readonly responses: {
107
+ readonly issues: z.ZodObject<{
108
+ issues: z.ZodArray<z.ZodObject<{
109
+ id: z.ZodString;
110
+ key: z.ZodString;
111
+ fields: z.ZodObject<{
112
+ summary: z.ZodOptional<z.ZodNullable<z.ZodString>>;
113
+ status: z.ZodOptional<z.ZodNullable<z.ZodObject<{
114
+ name: z.ZodString;
115
+ statusCategory: z.ZodOptional<z.ZodNullable<z.ZodObject<{
116
+ key: z.ZodString;
117
+ name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
118
+ }, z.core.$strip>>>;
119
+ }, z.core.$strip>>>;
120
+ priority: z.ZodOptional<z.ZodNullable<z.ZodObject<{
121
+ name: z.ZodString;
122
+ }, z.core.$strip>>>;
123
+ issuetype: z.ZodOptional<z.ZodNullable<z.ZodObject<{
124
+ name: z.ZodString;
125
+ }, z.core.$strip>>>;
126
+ assignee: z.ZodOptional<z.ZodNullable<z.ZodObject<{
127
+ accountId: z.ZodString;
128
+ displayName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
129
+ }, z.core.$strip>>>;
130
+ reporter: z.ZodOptional<z.ZodNullable<z.ZodObject<{
131
+ accountId: z.ZodString;
132
+ displayName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
133
+ }, z.core.$strip>>>;
134
+ project: z.ZodNullable<z.ZodObject<{
135
+ id: z.ZodString;
136
+ key: z.ZodString;
137
+ }, z.core.$strip>>;
138
+ created: z.ZodISODateTime;
139
+ updated: z.ZodISODateTime;
140
+ resolutiondate: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
141
+ customfield_10016: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
142
+ customfield_10020: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
143
+ id: z.ZodNumber;
144
+ name: z.ZodString;
145
+ }, z.core.$strip>>>>;
146
+ }, z.core.$strip>;
147
+ changelog: z.ZodObject<{
148
+ histories: z.ZodArray<z.ZodObject<{
149
+ id: z.ZodString;
150
+ created: z.ZodISODateTime;
151
+ author: z.ZodOptional<z.ZodNullable<z.ZodObject<{
152
+ accountId: z.ZodString;
153
+ displayName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
154
+ }, z.core.$strip>>>;
155
+ items: z.ZodArray<z.ZodObject<{
156
+ field: z.ZodString;
157
+ fromString: z.ZodOptional<z.ZodNullable<z.ZodString>>;
158
+ toString: z.ZodOptional<z.ZodNullable<z.ZodString>>;
159
+ }, z.core.$strip>>;
160
+ }, z.core.$strip>>;
161
+ }, z.core.$strip>;
162
+ }, z.core.$strip>>;
163
+ nextPageToken: z.ZodOptional<z.ZodNullable<z.ZodString>>;
164
+ isLast: z.ZodOptional<z.ZodBoolean>;
165
+ }, z.core.$strip>;
166
+ };
167
+ };
168
+ readonly jira_issue_status_change: {
169
+ readonly shape: "event";
170
+ readonly description: "Status transition events derived from issue changelogs, capturing the from/to status, author, and project.";
171
+ readonly endpoint: "GET /rest/api/3/search/jql (expand=changelog)";
172
+ readonly notes: "start_ts is the changelog entry time, end_ts is null. Timestamps are Unix epoch milliseconds.";
173
+ };
174
+ };
175
+ static readonly schemas: object & {
43
176
  readonly projects: z.ZodObject<{
44
177
  values: z.ZodArray<z.ZodObject<{
45
178
  id: z.ZodString;
@@ -56,6 +189,7 @@ declare class JiraConnector extends BaseConnector<JiraSettings, JiraCredentials>
56
189
  maxResults: z.ZodNumber;
57
190
  total: z.ZodNumber;
58
191
  }, z.core.$strip>;
192
+ } & {
59
193
  readonly users: z.ZodArray<z.ZodObject<{
60
194
  accountId: z.ZodString;
61
195
  displayName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -63,6 +197,7 @@ declare class JiraConnector extends BaseConnector<JiraSettings, JiraCredentials>
63
197
  accountType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
64
198
  active: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
65
199
  }, z.core.$strip>>;
200
+ } & {
66
201
  readonly sprints: z.ZodArray<z.ZodObject<{
67
202
  id: z.ZodNumber;
68
203
  name: z.ZodString;
@@ -76,6 +211,7 @@ declare class JiraConnector extends BaseConnector<JiraSettings, JiraCredentials>
76
211
  completeDate: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
77
212
  originBoardId: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
78
213
  }, z.core.$strip>>;
214
+ } & {
79
215
  readonly issues: z.ZodObject<{
80
216
  issues: z.ZodArray<z.ZodObject<{
81
217
  id: z.ZodString;
@@ -135,7 +271,7 @@ declare class JiraConnector extends BaseConnector<JiraSettings, JiraCredentials>
135
271
  nextPageToken: z.ZodOptional<z.ZodNullable<z.ZodString>>;
136
272
  isLast: z.ZodOptional<z.ZodBoolean>;
137
273
  }, z.core.$strip>;
138
- };
274
+ } & Readonly<Record<string, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
139
275
  static create(input: unknown, ctx?: ConnectorContext): JiraConnector;
140
276
  readonly id = "jira";
141
277
  readonly credentials: {
@@ -168,4 +304,4 @@ declare class JiraConnector extends BaseConnector<JiraSettings, JiraCredentials>
168
304
  sync(options: SyncOptions, storage: StorageHandle, signal?: AbortSignal): Promise<SyncResult>;
169
305
  }
170
306
 
171
- export { JiraConnector, type JiraResource, type JiraSettings, configFields, JiraConnector as default };
307
+ export { JiraConnector, type JiraResource, type JiraSettings, configFields, JiraConnector as default, doc };
package/dist/index.js CHANGED
@@ -30,8 +30,11 @@ function parseEpoch(value, unit) {
30
30
  import {
31
31
  BaseConnector,
32
32
  defineConfigFields,
33
+ defineConnectorDoc,
34
+ defineResources,
33
35
  makeChunkedCursorGuard,
34
36
  paginateChunked,
37
+ schemasFromResources,
35
38
  selectActivePhases
36
39
  } from "@rawdash/core";
37
40
  import { z } from "zod";
@@ -62,7 +65,7 @@ var configFields = defineConfigFields(
62
65
  }),
63
66
  resources: z.array(z.enum(["projects", "users", "sprints", "issues", "issue_events"])).nonempty().optional().meta({
64
67
  label: "Resources",
65
- description: "Which Jira resources to sync. Omit to sync all of them. 'issue_events' shares the issues query \u2014 enabling it without 'issues' still fetches issues (with changelog) but skips writing issue entities."
68
+ description: "Which Jira resources to sync. Omit to sync all of them. 'issue_events' shares the issues query - enabling it without 'issues' still fetches issues (with changelog) but skips writing issue entities."
66
69
  }),
67
70
  storyPointsField: z.string().min(1).optional().meta({
68
71
  label: "Story points field ID",
@@ -76,6 +79,32 @@ var configFields = defineConfigFields(
76
79
  })
77
80
  })
78
81
  );
82
+ var doc = defineConnectorDoc({
83
+ displayName: "Jira",
84
+ category: "product",
85
+ brandColor: "#0052CC",
86
+ tagline: "Sync projects, users, sprints, issues, and issue status-change events from a Jira Cloud site.",
87
+ vendor: {
88
+ name: "Atlassian",
89
+ apiDocs: "https://developer.atlassian.com/cloud/jira/platform/rest/v3/",
90
+ website: "https://www.atlassian.com/software/jira"
91
+ },
92
+ auth: {
93
+ summary: "Authenticates over HTTP Basic auth using your Atlassian account email and an API token. The token must belong to an account with access to the projects you want to sync.",
94
+ setup: [
95
+ "Open id.atlassian.com -> Security -> Create and manage API tokens.",
96
+ "Create an API token and copy its value.",
97
+ 'Store the token as a secret and reference it from the connector config as `apiToken: secret("JIRA_API_TOKEN")`, alongside your account email and site host (e.g. yourorg.atlassian.net).',
98
+ "Story points and the sprint association live on custom fields whose IDs differ per Jira site. Discover them at `https://{host}/rest/api/3/field` and set storyPointsField / sprintField to match."
99
+ ]
100
+ },
101
+ rateLimit: "Jira Cloud uses cost-based rate limiting; 429 responses with Retry-After are honored.",
102
+ limitations: [
103
+ "Sprints are only synced from scrum boards; kanban boards are skipped.",
104
+ "Issue status-change events are derived from each issue changelog; only `status` field transitions are written.",
105
+ "Targets Jira Cloud REST API v3 and the Agile API; Jira Data Center / Server are out of scope."
106
+ ]
107
+ });
79
108
  var jiraCredentials = {
80
109
  email: {
81
110
  description: "Atlassian account email",
@@ -167,6 +196,39 @@ var issuesResponseSchema = z.object({
167
196
  nextPageToken: z.string().nullable().optional(),
168
197
  isLast: z.boolean().optional()
169
198
  });
199
+ var jiraResources = defineResources({
200
+ jira_project: {
201
+ shape: "entity",
202
+ description: "Jira projects with key, name, type, and project lead. Restrict via projectKeys to limit the sync.",
203
+ endpoint: "GET /rest/api/3/project/search",
204
+ responses: { projects: projectsResponseSchema }
205
+ },
206
+ jira_user: {
207
+ shape: "entity",
208
+ description: "Atlassian accounts visible to the connector, including display name, email, account type, and active state.",
209
+ endpoint: "GET /rest/api/3/users/search",
210
+ responses: { users: usersResponseSchema }
211
+ },
212
+ jira_sprint: {
213
+ shape: "entity",
214
+ description: "Sprints from scrum boards with state, start/end/complete dates, and owning board.",
215
+ endpoint: "GET /rest/agile/1.0/board/{boardId}/sprint",
216
+ responses: { sprints: sprintsResponseSchema }
217
+ },
218
+ jira_issue: {
219
+ shape: "entity",
220
+ description: "Issues with status, priority, type, assignee, reporter, project, sprint, story points, and resolution date.",
221
+ endpoint: "GET /rest/api/3/search/jql",
222
+ notes: "sprintId is taken from the most recent sprint on the issue's sprint custom field.",
223
+ responses: { issues: issuesResponseSchema }
224
+ },
225
+ jira_issue_status_change: {
226
+ shape: "event",
227
+ description: "Status transition events derived from issue changelogs, capturing the from/to status, author, and project.",
228
+ endpoint: "GET /rest/api/3/search/jql (expand=changelog)",
229
+ notes: "start_ts is the changelog entry time, end_ts is null. Timestamps are Unix epoch milliseconds."
230
+ }
231
+ });
170
232
  var PROJECTS_PAGE_SIZE = 50;
171
233
  var USERS_PAGE_SIZE = 50;
172
234
  var BOARDS_PAGE_SIZE = 50;
@@ -218,12 +280,8 @@ function formatJqlDate(iso) {
218
280
  }
219
281
  var JiraConnector = class _JiraConnector extends BaseConnector {
220
282
  static id = "jira";
221
- static schemas = {
222
- projects: projectsResponseSchema,
223
- users: usersResponseSchema,
224
- sprints: sprintsResponseSchema,
225
- issues: issuesResponseSchema
226
- };
283
+ static resources = jiraResources;
284
+ static schemas = schemasFromResources(jiraResources);
227
285
  static create(input, ctx) {
228
286
  const parsed = configFields.parse(input);
229
287
  return new _JiraConnector(
@@ -612,6 +670,7 @@ var index_default = JiraConnector;
612
670
  export {
613
671
  JiraConnector,
614
672
  configFields,
615
- index_default as default
673
+ index_default as default,
674
+ doc
616
675
  };
617
676
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +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/sanitize.ts","../../../connector-shared/src/epoch.ts","../../../connector-shared/src/pagination.ts","../src/jira.ts","../src/index.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\nexport function connectorUserAgent(connectorId: string): string {\n return `rawdash-connector-${connectorId}/${HTTP_CLIENT_VERSION} (+https://rawdash.dev)`;\n}\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 interface StandardRateLimitPolicyConfig {\n remainingHeader: string;\n resetHeader: string;\n resetUnit: 's' | 'ms';\n resetFallbackMs?: number;\n}\n\nexport function standardRateLimitPolicy(\n config: StandardRateLimitPolicyConfig,\n): RateLimitPolicy {\n const { remainingHeader, resetHeader, resetUnit, resetFallbackMs } = config;\n const multiplier = resetUnit === 's' ? 1000 : 1;\n return {\n parse(h) {\n const remainingRaw = h.get(remainingHeader);\n if (remainingRaw === null || remainingRaw.trim() === '') {\n return null;\n }\n const remaining = Number(remainingRaw);\n if (!Number.isFinite(remaining)) {\n return null;\n }\n const resetRaw = h.get(resetHeader);\n if (resetRaw === null) {\n if (resetFallbackMs === undefined) {\n return null;\n }\n return {\n remaining,\n resetAt: new Date(Date.now() + resetFallbackMs),\n };\n }\n if (resetRaw.trim() === '') {\n return null;\n }\n const reset = Number(resetRaw);\n if (!Number.isFinite(reset) || reset < 0) {\n return null;\n }\n const resetMs = reset * multiplier;\n if (!Number.isFinite(resetMs)) {\n return null;\n }\n return { remaining, resetAt: new Date(resetMs) };\n },\n };\n}\n","export interface SanitizeAllowedUrlOptions {\n url: string | null;\n host: string;\n pathname: string;\n protocol?: 'https:' | 'http:';\n}\n\nexport function sanitizeAllowedUrl(\n options: SanitizeAllowedUrlOptions,\n): string | null {\n const { url, host, pathname, protocol = 'https:' } = options;\n if (url === null) {\n return null;\n }\n try {\n const u = new URL(url);\n if (u.protocol !== protocol || u.host !== host || u.pathname !== pathname) {\n return null;\n }\n return u.toString();\n } catch {\n return null;\n }\n}\n","export type EpochUnit = 'ms' | 's' | 'iso';\n\nexport function parseEpoch(\n value: number | string | null | undefined,\n unit: EpochUnit,\n): number | null {\n if (value === null || value === undefined) {\n return null;\n }\n if (unit === 'iso') {\n if (typeof value !== 'string') {\n return null;\n }\n const ms = new Date(value).getTime();\n return Number.isFinite(ms) ? ms : null;\n }\n if (typeof value === 'string' && value.trim() === '') {\n return null;\n }\n const n = typeof value === 'number' ? value : Number(value);\n if (!Number.isFinite(n)) {\n return null;\n }\n const result = unit === 's' ? n * 1000 : n;\n return Number.isFinite(result) ? result : null;\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 {\n type HttpResponse,\n connectorUserAgent,\n parseEpoch,\n} from '@rawdash/connector-shared';\nimport {\n BaseConnector,\n type ConnectorContext,\n type CredentialsSchema,\n type JSONValue,\n type StorageHandle,\n type SyncOptions,\n type SyncResult,\n defineConfigFields,\n makeChunkedCursorGuard,\n paginateChunked,\n selectActivePhases,\n} from '@rawdash/core';\nimport { z } from 'zod';\n\n// ---------------------------------------------------------------------------\n// configFields\n// ---------------------------------------------------------------------------\n\nexport const configFields = defineConfigFields(\n z.object({\n email: z.string().min(1).meta({\n label: 'Account email',\n description:\n 'Atlassian account email paired with the API token for Basic auth.',\n placeholder: 'you@yourorg.com',\n }),\n apiToken: z.object({ $secret: z.string() }).meta({\n label: 'API Token',\n description:\n 'Atlassian API token. Create one at id.atlassian.com → Security → API tokens.',\n placeholder: 'ATATT...',\n secret: true,\n }),\n host: z\n .string()\n .min(1)\n .regex(\n /^[^/\\s:?#]+$/,\n 'Use host only (no protocol, port, path, or query).',\n )\n .meta({\n label: 'Site host',\n description:\n 'Your Jira Cloud host, e.g. yourorg.atlassian.net (no protocol, no trailing slash).',\n placeholder: 'yourorg.atlassian.net',\n }),\n projectKeys: z.array(z.string().min(1)).nonempty().optional().meta({\n label: 'Project keys (optional)',\n description:\n 'Restrict the sync to specific Jira project keys (e.g. ENG, OPS). Omit to sync every project the account can see.',\n }),\n resources: z\n .array(z.enum(['projects', 'users', 'sprints', 'issues', 'issue_events']))\n .nonempty()\n .optional()\n .meta({\n label: 'Resources',\n description:\n \"Which Jira resources to sync. Omit to sync all of them. 'issue_events' shares the issues query — enabling it without 'issues' still fetches issues (with changelog) but skips writing issue entities.\",\n }),\n storyPointsField: z.string().min(1).optional().meta({\n label: 'Story points field ID',\n description:\n 'Custom field ID holding story points (varies per site). Defaults to customfield_10016.',\n placeholder: 'customfield_10016',\n }),\n sprintField: z.string().min(1).optional().meta({\n label: 'Sprint field ID',\n description:\n 'Custom field ID holding the sprint association on issues. Defaults to customfield_10020.',\n placeholder: 'customfield_10020',\n }),\n }),\n);\n\nexport type JiraResource =\n | 'projects'\n | 'users'\n | 'sprints'\n | 'issues'\n | 'issue_events';\n\nexport interface JiraSettings {\n host: string;\n projectKeys?: readonly string[];\n resources?: readonly JiraResource[];\n storyPointsField?: string;\n sprintField?: string;\n}\n\nconst jiraCredentials = {\n email: {\n description: 'Atlassian account email',\n auth: 'required' as const,\n },\n apiToken: {\n description: 'Atlassian API token',\n auth: 'required' as const,\n },\n} satisfies CredentialsSchema;\n\ntype JiraCredentials = typeof jiraCredentials;\n\n// ---------------------------------------------------------------------------\n// Sync phases + cursor\n// ---------------------------------------------------------------------------\n\nconst PHASE_ORDER = ['projects', 'users', 'sprints', 'issues'] as const;\n\ntype JiraPhase = (typeof PHASE_ORDER)[number];\n\nconst isJiraSyncCursor = makeChunkedCursorGuard(PHASE_ORDER);\n\n// ---------------------------------------------------------------------------\n// Jira API types\n// ---------------------------------------------------------------------------\n\ninterface JiraAccountRef {\n accountId: string;\n displayName?: string | null;\n}\n\ninterface JiraStatusCategory {\n key: string;\n name?: string | null;\n}\n\ninterface JiraStatus {\n name: string;\n statusCategory?: JiraStatusCategory | null;\n}\n\ninterface JiraNamed {\n name: string;\n}\n\ninterface JiraProjectRef {\n id: string;\n key: string;\n}\n\ninterface JiraIssueFields {\n summary?: string | null;\n status?: JiraStatus | null;\n priority?: JiraNamed | null;\n issuetype?: JiraNamed | null;\n assignee?: JiraAccountRef | null;\n reporter?: JiraAccountRef | null;\n project?: JiraProjectRef | null;\n created: string;\n updated: string;\n resolutiondate?: string | null;\n [key: string]: unknown;\n}\n\ninterface JiraChangelogItem {\n field: string;\n fromString?: string | null;\n toString?: string | null;\n}\n\ninterface JiraChangelogHistory {\n id: string;\n created: string;\n author?: JiraAccountRef | null;\n items: JiraChangelogItem[];\n}\n\ninterface JiraIssue {\n id: string;\n key: string;\n fields: JiraIssueFields;\n changelog?: { histories: JiraChangelogHistory[] } | null;\n}\n\ninterface JiraSearchResponse {\n issues: JiraIssue[];\n nextPageToken?: string | null;\n isLast?: boolean;\n}\n\ninterface JiraProject {\n id: string;\n key: string;\n name: string;\n projectTypeKey?: string | null;\n lead?: JiraAccountRef | null;\n}\n\ninterface JiraProjectPage {\n values: JiraProject[];\n isLast: boolean;\n startAt: number;\n maxResults: number;\n total: number;\n}\n\ninterface JiraUser {\n accountId: string;\n displayName?: string | null;\n emailAddress?: string | null;\n accountType?: string | null;\n active?: boolean | null;\n}\n\ninterface JiraSprint {\n id: number;\n name: string;\n state: 'active' | 'closed' | 'future';\n startDate?: string | null;\n endDate?: string | null;\n completeDate?: string | null;\n originBoardId?: number | null;\n}\n\ninterface JiraSprintWithBoard extends JiraSprint {\n boardId: number;\n}\n\ninterface JiraBoard {\n id: number;\n name: string;\n type: string;\n}\n\ninterface JiraAgilePage<T> {\n values: T[];\n isLast?: boolean;\n startAt: number;\n maxResults: number;\n}\n\n// ---------------------------------------------------------------------------\n// Schemas — describe the per-resource API response shape consumed by request()\n// ---------------------------------------------------------------------------\n\nconst idString = z.string().min(1);\nconst nonNegInt = z.number().int().nonnegative();\n\nconst accountRefSchema = z.object({\n accountId: idString,\n displayName: z.string().nullable().optional(),\n});\n\nconst projectSchema = z.object({\n id: idString,\n key: z.string().min(1),\n name: z.string(),\n projectTypeKey: z.string().nullable().optional(),\n lead: accountRefSchema.nullable().optional(),\n});\n\nconst projectsResponseSchema = z.object({\n values: z.array(projectSchema),\n isLast: z.boolean(),\n startAt: nonNegInt,\n maxResults: nonNegInt,\n total: nonNegInt,\n});\n\nconst usersResponseSchema = z.array(\n z.object({\n accountId: idString,\n displayName: z.string().nullable().optional(),\n emailAddress: z.string().nullable().optional(),\n accountType: z.string().nullable().optional(),\n active: z.boolean().nullable().optional(),\n }),\n);\n\nconst sprintsResponseSchema = z.array(\n z.object({\n id: nonNegInt,\n name: z.string(),\n state: z.enum(['active', 'closed', 'future']),\n startDate: z.iso.datetime().nullable().optional(),\n endDate: z.iso.datetime().nullable().optional(),\n completeDate: z.iso.datetime().nullable().optional(),\n originBoardId: nonNegInt.nullable().optional(),\n }),\n);\n\nconst changelogHistorySchema = z.object({\n id: idString,\n created: z.iso.datetime(),\n author: accountRefSchema.nullable().optional(),\n items: z.array(\n z.object({\n field: z.string(),\n fromString: z.string().nullable().optional(),\n toString: z.string().nullable().optional(),\n }),\n ),\n});\n\nconst issueSchema = z.object({\n id: idString,\n key: z.string().min(1),\n fields: z.object({\n summary: z.string().nullable().optional(),\n status: z\n .object({\n name: z.string(),\n statusCategory: z\n .object({ key: z.string(), name: z.string().nullable().optional() })\n .nullable()\n .optional(),\n })\n .nullable()\n .optional(),\n priority: z.object({ name: z.string() }).nullable().optional(),\n issuetype: z.object({ name: z.string() }).nullable().optional(),\n assignee: accountRefSchema.nullable().optional(),\n reporter: accountRefSchema.nullable().optional(),\n project: z.object({ id: idString, key: z.string().min(1) }).nullable(),\n created: z.iso.datetime(),\n updated: z.iso.datetime(),\n resolutiondate: z.iso.datetime().nullable().optional(),\n customfield_10016: z.number().nullable().optional(),\n customfield_10020: z\n .array(z.object({ id: nonNegInt, name: z.string() }))\n .nullable()\n .optional(),\n }),\n changelog: z.object({ histories: z.array(changelogHistorySchema) }),\n});\n\nconst issuesResponseSchema = z.object({\n issues: z.array(issueSchema),\n nextPageToken: z.string().nullable().optional(),\n isLast: z.boolean().optional(),\n});\n\n// ---------------------------------------------------------------------------\n// JiraConnector\n// ---------------------------------------------------------------------------\n\nconst PROJECTS_PAGE_SIZE = 50;\nconst USERS_PAGE_SIZE = 50;\nconst BOARDS_PAGE_SIZE = 50;\nconst SPRINTS_PAGE_SIZE = 50;\nconst ISSUES_PAGE_SIZE = 100;\nconst DEFAULT_STORY_POINTS_FIELD = 'customfield_10016';\nconst DEFAULT_SPRINT_FIELD = 'customfield_10020';\n\nconst ISSUE_FIELDS = [\n 'summary',\n 'status',\n 'priority',\n 'issuetype',\n 'assignee',\n 'reporter',\n 'project',\n 'created',\n 'updated',\n 'resolutiondate',\n] as const;\n\nfunction parseOffset(page: string | null): number {\n if (page === null) {\n return 0;\n }\n const n = Number.parseInt(page, 10);\n return Number.isFinite(n) && n >= 0 ? n : 0;\n}\n\nfunction extractSprintId(value: unknown): string | null {\n if (!Array.isArray(value) || value.length === 0) {\n return null;\n }\n const last = value[value.length - 1];\n if (last !== null && typeof last === 'object' && 'id' in last) {\n const id = (last as { id: unknown }).id;\n return id === null || id === undefined ? null : String(id);\n }\n if (typeof last === 'number' || typeof last === 'string') {\n return String(last);\n }\n return null;\n}\n\nfunction formatJqlDate(iso: string): string | null {\n const ms = parseEpoch(iso, 'iso');\n if (ms === null) {\n return null;\n }\n const d = new Date(ms);\n const pad = (n: number) => String(n).padStart(2, '0');\n return (\n `${d.getUTCFullYear()}-${pad(d.getUTCMonth() + 1)}-${pad(d.getUTCDate())} ` +\n `${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())}`\n );\n}\n\nexport class JiraConnector extends BaseConnector<\n JiraSettings,\n JiraCredentials\n> {\n static readonly id = 'jira';\n\n static readonly schemas = {\n projects: projectsResponseSchema,\n users: usersResponseSchema,\n sprints: sprintsResponseSchema,\n issues: issuesResponseSchema,\n } as const;\n\n static create(input: unknown, ctx?: ConnectorContext): JiraConnector {\n const parsed = configFields.parse(input);\n return new JiraConnector(\n {\n host: parsed.host,\n projectKeys: parsed.projectKeys,\n resources: parsed.resources,\n storyPointsField: parsed.storyPointsField,\n sprintField: parsed.sprintField,\n },\n { email: parsed.email, apiToken: parsed.apiToken },\n ctx,\n );\n }\n\n readonly id = 'jira';\n override readonly credentials = jiraCredentials;\n\n private get baseUrl(): string {\n const host = this.settings.host\n .replace(/^https?:\\/\\//, '')\n .replace(/\\/+$/, '');\n return `https://${host}`;\n }\n\n private get storyPointsField(): string {\n return this.settings.storyPointsField ?? DEFAULT_STORY_POINTS_FIELD;\n }\n\n private get sprintField(): string {\n return this.settings.sprintField ?? DEFAULT_SPRINT_FIELD;\n }\n\n private buildHeaders(): Record<string, string> {\n const basic = btoa(`${this.creds.email}:${this.creds.apiToken}`);\n return {\n Authorization: `Basic ${basic}`,\n Accept: 'application/json',\n 'User-Agent': connectorUserAgent('jira'),\n };\n }\n\n private fetch<T>(\n url: string,\n resource: string,\n signal?: AbortSignal,\n ): Promise<HttpResponse<T>> {\n return this.get<T>(url, {\n resource,\n headers: this.buildHeaders(),\n signal,\n });\n }\n\n // -------------------------------------------------------------------------\n // Resource enablement\n // -------------------------------------------------------------------------\n\n private activePhases(): JiraPhase[] {\n return selectActivePhases<JiraResource, JiraPhase>(\n (r) => {\n switch (r) {\n case 'projects':\n return 'projects';\n case 'users':\n return 'users';\n case 'sprints':\n return 'sprints';\n case 'issues':\n case 'issue_events':\n return 'issues';\n }\n },\n PHASE_ORDER,\n this.settings.resources,\n );\n }\n\n // -------------------------------------------------------------------------\n // JQL\n // -------------------------------------------------------------------------\n\n private buildJql(options: SyncOptions): string {\n const clauses: string[] = [];\n const keys = this.settings.projectKeys;\n if (keys && keys.length > 0) {\n const quoted = keys.map(\n (k) => `\"${k.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"')}\"`,\n );\n clauses.push(`project in (${quoted.join(',')})`);\n }\n if (options.mode === 'latest' && options.since) {\n const formatted = formatJqlDate(options.since);\n if (formatted !== null) {\n clauses.push(`updated >= \"${formatted}\"`);\n }\n }\n const where = clauses.join(' AND ');\n return where.length > 0\n ? `${where} ORDER BY updated ASC`\n : 'ORDER BY updated ASC';\n }\n\n // -------------------------------------------------------------------------\n // Fetchers\n // -------------------------------------------------------------------------\n\n private async fetchProjectsPage(\n page: string | null,\n signal: AbortSignal | undefined,\n ): Promise<{ items: JiraProject[]; next: string | null }> {\n const startAt = parseOffset(page);\n const u = new URL(`${this.baseUrl}/rest/api/3/project/search`);\n u.searchParams.set('startAt', String(startAt));\n u.searchParams.set('maxResults', String(PROJECTS_PAGE_SIZE));\n u.searchParams.set('expand', 'lead');\n const res = await this.fetch<JiraProjectPage>(\n u.toString(),\n 'projects',\n signal,\n );\n const values = res.body.values;\n const next =\n res.body.isLast || values.length === 0\n ? null\n : String(startAt + values.length);\n return { items: values, next };\n }\n\n private async fetchUsersPage(\n page: string | null,\n signal: AbortSignal | undefined,\n ): Promise<{ items: JiraUser[]; next: string | null }> {\n const startAt = parseOffset(page);\n const u = new URL(`${this.baseUrl}/rest/api/3/users/search`);\n u.searchParams.set('startAt', String(startAt));\n u.searchParams.set('maxResults', String(USERS_PAGE_SIZE));\n const res = await this.fetch<JiraUser[]>(u.toString(), 'users', signal);\n const users = res.body;\n const next =\n users.length < USERS_PAGE_SIZE ? null : String(startAt + users.length);\n return { items: users, next };\n }\n\n private async fetchBoardsPage(\n startAt: number,\n signal: AbortSignal | undefined,\n ): Promise<JiraAgilePage<JiraBoard>> {\n const u = new URL(`${this.baseUrl}/rest/agile/1.0/board`);\n u.searchParams.set('startAt', String(startAt));\n u.searchParams.set('maxResults', String(BOARDS_PAGE_SIZE));\n const res = await this.fetch<JiraAgilePage<JiraBoard>>(\n u.toString(),\n 'sprints',\n signal,\n );\n return res.body;\n }\n\n private async fetchSprintsForBoard(\n boardId: number,\n signal: AbortSignal | undefined,\n ): Promise<JiraSprint[]> {\n const out: JiraSprint[] = [];\n let startAt = 0;\n while (true) {\n signal?.throwIfAborted();\n const u = new URL(\n `${this.baseUrl}/rest/agile/1.0/board/${boardId}/sprint`,\n );\n u.searchParams.set('startAt', String(startAt));\n u.searchParams.set('maxResults', String(SPRINTS_PAGE_SIZE));\n const res = await this.fetch<JiraAgilePage<JiraSprint>>(\n u.toString(),\n 'sprints',\n signal,\n );\n const values = res.body.values;\n out.push(...values);\n const isLast = res.body.isLast ?? values.length < SPRINTS_PAGE_SIZE;\n if (isLast || values.length === 0) {\n break;\n }\n startAt += values.length;\n }\n return out;\n }\n\n private async fetchSprintsPage(\n page: string | null,\n signal: AbortSignal | undefined,\n ): Promise<{ items: JiraSprintWithBoard[]; next: string | null }> {\n const startAt = parseOffset(page);\n const boardsPage = await this.fetchBoardsPage(startAt, signal);\n const boards = boardsPage.values;\n const sprints: JiraSprintWithBoard[] = [];\n for (const board of boards) {\n if (board.type !== 'scrum') {\n continue;\n }\n const boardSprints = await this.fetchSprintsForBoard(board.id, signal);\n for (const s of boardSprints) {\n sprints.push({ ...s, boardId: board.id });\n }\n }\n const isLast = boardsPage.isLast ?? boards.length < BOARDS_PAGE_SIZE;\n const next = isLast ? null : String(startAt + boards.length);\n return { items: sprints, next };\n }\n\n private async fetchIssuesPage(\n page: string | null,\n options: SyncOptions,\n signal: AbortSignal | undefined,\n ): Promise<{ items: JiraIssue[]; next: string | null }> {\n const u = new URL(`${this.baseUrl}/rest/api/3/search/jql`);\n u.searchParams.set('jql', this.buildJql(options));\n u.searchParams.set('maxResults', String(ISSUES_PAGE_SIZE));\n u.searchParams.set(\n 'fields',\n [...ISSUE_FIELDS, this.storyPointsField, this.sprintField].join(','),\n );\n u.searchParams.set('expand', 'changelog');\n if (page !== null) {\n u.searchParams.set('nextPageToken', page);\n }\n const res = await this.fetch<JiraSearchResponse>(\n u.toString(),\n 'issues',\n signal,\n );\n const token = res.body.nextPageToken ?? null;\n const next = res.body.isLast === true || token === null ? null : token;\n return { items: res.body.issues, next };\n }\n\n // -------------------------------------------------------------------------\n // Writers\n // -------------------------------------------------------------------------\n\n private async writeProjects(\n storage: StorageHandle,\n projects: JiraProject[],\n ): Promise<void> {\n const now = Date.now();\n for (const p of projects) {\n await storage.entity({\n type: 'jira_project',\n id: p.id,\n attributes: {\n key: p.key,\n name: p.name,\n projectTypeKey: p.projectTypeKey ?? null,\n leadAccountId: p.lead?.accountId ?? null,\n leadDisplayName: p.lead?.displayName ?? null,\n },\n updated_at: now,\n });\n }\n }\n\n private async writeUsers(\n storage: StorageHandle,\n users: JiraUser[],\n ): Promise<void> {\n const now = Date.now();\n for (const u of users) {\n if (!u.accountId) {\n continue;\n }\n await storage.entity({\n type: 'jira_user',\n id: u.accountId,\n attributes: {\n displayName: u.displayName ?? null,\n emailAddress: u.emailAddress ?? null,\n accountType: u.accountType ?? null,\n active: u.active ?? null,\n },\n updated_at: now,\n });\n }\n }\n\n private async writeSprints(\n storage: StorageHandle,\n sprints: JiraSprintWithBoard[],\n ): Promise<void> {\n const now = Date.now();\n for (const s of sprints) {\n const startMs = parseEpoch(s.startDate ?? null, 'iso');\n const endMs = parseEpoch(s.endDate ?? null, 'iso');\n const completeMs = parseEpoch(s.completeDate ?? null, 'iso');\n await storage.entity({\n type: 'jira_sprint',\n id: String(s.id),\n attributes: {\n name: s.name,\n state: s.state,\n boardId: s.boardId,\n originBoardId: s.originBoardId ?? null,\n startDate: startMs,\n endDate: endMs,\n completeDate: completeMs,\n },\n updated_at: completeMs ?? endMs ?? startMs ?? now,\n });\n }\n }\n\n private async writeIssues(\n storage: StorageHandle,\n issues: JiraIssue[],\n sinceMs: number | null,\n ): Promise<void> {\n const writeEntities = this.isResourceEnabled('issues');\n const writeEvents = this.isResourceEnabled('issue_events');\n\n for (const issue of issues) {\n const f = issue.fields;\n const createdMs = parseEpoch(f.created, 'iso');\n const updatedMs = parseEpoch(f.updated, 'iso');\n if (createdMs === null || updatedMs === null) {\n console.warn(\n `[connector-jira] skipping issue ${issue.key} with unparseable created/updated`,\n );\n continue;\n }\n const projectKey = f.project?.key ?? null;\n\n if (writeEntities) {\n const rawPoints = f[this.storyPointsField];\n const storyPoints =\n typeof rawPoints === 'number' && Number.isFinite(rawPoints)\n ? rawPoints\n : null;\n await storage.entity({\n type: 'jira_issue',\n id: issue.id,\n attributes: {\n key: issue.key,\n summary: f.summary ?? null,\n statusName: f.status?.name ?? null,\n statusCategory: f.status?.statusCategory?.key ?? null,\n priority: f.priority?.name ?? null,\n issueType: f.issuetype?.name ?? null,\n assigneeId: f.assignee?.accountId ?? null,\n reporterId: f.reporter?.accountId ?? null,\n projectKey,\n sprintId: extractSprintId(f[this.sprintField]),\n storyPoints,\n createdAt: createdMs,\n resolvedAt: parseEpoch(f.resolutiondate ?? null, 'iso'),\n },\n updated_at: updatedMs,\n });\n }\n\n if (writeEvents) {\n const histories = issue.changelog?.histories ?? [];\n for (const h of histories) {\n const ts = parseEpoch(h.created, 'iso');\n if (ts === null) {\n continue;\n }\n if (sinceMs !== null && ts <= sinceMs) {\n continue;\n }\n for (const item of h.items) {\n if (item.field !== 'status') {\n continue;\n }\n const attributes: Record<string, JSONValue> = {\n historyId: h.id,\n issueId: issue.id,\n issueKey: issue.key,\n projectKey,\n authorId: h.author?.accountId ?? null,\n fromStatus: item.fromString ?? null,\n toStatus: item.toString ?? null,\n };\n await storage.event({\n name: 'jira_issue_status_change',\n start_ts: ts,\n end_ts: null,\n attributes,\n });\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 = isJiraSyncCursor(options.cursor)\n ? options.cursor\n : undefined;\n const isFull = options.mode === 'full';\n const sinceMs = options.since ? parseEpoch(options.since, 'iso') : null;\n const phases = this.activePhases();\n\n return paginateChunked<JiraPhase, string>({\n phases,\n cursor,\n signal,\n fetchPage: async (phase, page, sig) => {\n switch (phase) {\n case 'projects':\n return this.fetchProjectsPage(page, sig);\n case 'users':\n return this.fetchUsersPage(page, sig);\n case 'sprints':\n return this.fetchSprintsPage(page, 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 'projects':\n await storage.entities([], { types: ['jira_project'] });\n break;\n case 'users':\n await storage.entities([], { types: ['jira_user'] });\n break;\n case 'sprints':\n await storage.entities([], { types: ['jira_sprint'] });\n break;\n case 'issues':\n if (this.isResourceEnabled('issues')) {\n await storage.entities([], { types: ['jira_issue'] });\n }\n if (this.isResourceEnabled('issue_events')) {\n await storage.events([], {\n names: ['jira_issue_status_change'],\n });\n }\n break;\n }\n }\n switch (phase) {\n case 'projects':\n return this.writeProjects(storage, items as JiraProject[]);\n case 'users':\n return this.writeUsers(storage, items as JiraUser[]);\n case 'sprints':\n return this.writeSprints(storage, items as JiraSprintWithBoard[]);\n case 'issues':\n return this.writeIssues(storage, items as JiraIssue[], sinceMs);\n }\n },\n });\n }\n}\n","import { JiraConnector } from './jira';\n\nexport { configFields, JiraConnector } from './jira';\nexport type { JiraSettings, JiraResource } from './jira';\nexport default JiraConnector;\n"],"mappings":";AEAO,IAAM,sBAAsB;AAE5B,IAAM,qBAAqB,qBAAqB,mBAAmB;AAEnE,SAAS,mBAAmB,aAA6B;AAC9D,SAAO,qBAAqB,WAAW,IAAI,mBAAmB;AAChE;AIJO,SAAS,WACd,OACA,MACe;AACf,MAAI,UAAU,QAAQ,UAAU,QAAW;AACzC,WAAO;EACT;AACA,MAAI,SAAS,OAAO;AAClB,QAAI,OAAO,UAAU,UAAU;AAC7B,aAAO;IACT;AACA,UAAM,KAAK,IAAI,KAAK,KAAK,EAAE,QAAQ;AACnC,WAAO,OAAO,SAAS,EAAE,IAAI,KAAK;EACpC;AACA,MAAI,OAAO,UAAU,YAAY,MAAM,KAAK,MAAM,IAAI;AACpD,WAAO;EACT;AACA,QAAM,IAAI,OAAO,UAAU,WAAW,QAAQ,OAAO,KAAK;AAC1D,MAAI,CAAC,OAAO,SAAS,CAAC,GAAG;AACvB,WAAO;E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H,mBAAO,KAAK,gBAAgB,MAAM,SAAS,GAAG;AAAA,QAClD;AAAA,MACF;AAAA,MACA,YAAY,OAAO,OAAO,OAAO,SAAS;AACxC,YAAI,UAAU,SAAS,MAAM;AAC3B,kBAAQ,OAAO;AAAA,YACb,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,WAAW,EAAE,CAAC;AACnD;AAAA,YACF,KAAK;AACH,oBAAM,QAAQ,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC;AACrD;AAAA,YACF,KAAK;AACH,kBAAI,KAAK,kBAAkB,QAAQ,GAAG;AACpC,sBAAM,QAAQ,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;AAAA,cACtD;AACA,kBAAI,KAAK,kBAAkB,cAAc,GAAG;AAC1C,sBAAM,QAAQ,OAAO,CAAC,GAAG;AAAA,kBACvB,OAAO,CAAC,0BAA0B;AAAA,gBACpC,CAAC;AAAA,cACH;AACA;AAAA,UACJ;AAAA,QACF;AACA,gBAAQ,OAAO;AAAA,UACb,KAAK;AACH,mBAAO,KAAK,cAAc,SAAS,KAAsB;AAAA,UAC3D,KAAK;AACH,mBAAO,KAAK,WAAW,SAAS,KAAmB;AAAA,UACrD,KAAK;AACH,mBAAO,KAAK,aAAa,SAAS,KAA8B;AAAA,UAClE,KAAK;AACH,mBAAO,KAAK,YAAY,SAAS,OAAsB,OAAO;AAAA,QAClE;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AACF;;;ACv2BA,IAAO,gBAAQ;","names":[]}
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/sanitize.ts","../../../connector-shared/src/epoch.ts","../../../connector-shared/src/pagination.ts","../../../connector-shared/src/logger.ts","../src/jira.ts","../src/index.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\nexport function connectorUserAgent(connectorId: string): string {\n return `rawdash-connector-${connectorId}/${HTTP_CLIENT_VERSION} (+https://rawdash.dev)`;\n}\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 interface StandardRateLimitPolicyConfig {\n remainingHeader: string;\n resetHeader: string;\n resetUnit: 's' | 'ms';\n resetFallbackMs?: number;\n}\n\nexport function standardRateLimitPolicy(\n config: StandardRateLimitPolicyConfig,\n): RateLimitPolicy {\n const { remainingHeader, resetHeader, resetUnit, resetFallbackMs } = config;\n const multiplier = resetUnit === 's' ? 1000 : 1;\n return {\n parse(h) {\n const remainingRaw = h.get(remainingHeader);\n if (remainingRaw === null || remainingRaw.trim() === '') {\n return null;\n }\n const remaining = Number(remainingRaw);\n if (!Number.isFinite(remaining)) {\n return null;\n }\n const resetRaw = h.get(resetHeader);\n if (resetRaw === null) {\n if (resetFallbackMs === undefined) {\n return null;\n }\n return {\n remaining,\n resetAt: new Date(Date.now() + resetFallbackMs),\n };\n }\n if (resetRaw.trim() === '') {\n return null;\n }\n const reset = Number(resetRaw);\n if (!Number.isFinite(reset) || reset < 0) {\n return null;\n }\n const resetMs = reset * multiplier;\n if (!Number.isFinite(resetMs)) {\n return null;\n }\n return { remaining, resetAt: new Date(resetMs) };\n },\n };\n}\n","export interface SanitizeAllowedUrlOptions {\n url: string | null;\n host: string;\n pathname: string;\n protocol?: 'https:' | 'http:';\n}\n\nexport function sanitizeAllowedUrl(\n options: SanitizeAllowedUrlOptions,\n): string | null {\n const { url, host, pathname, protocol = 'https:' } = options;\n if (url === null) {\n return null;\n }\n try {\n const u = new URL(url);\n if (u.protocol !== protocol || u.host !== host || u.pathname !== pathname) {\n return null;\n }\n return u.toString();\n } catch {\n return null;\n }\n}\n","export type EpochUnit = 'ms' | 's' | 'iso';\n\nexport function parseEpoch(\n value: number | string | null | undefined,\n unit: EpochUnit,\n): number | null {\n if (value === null || value === undefined) {\n return null;\n }\n if (unit === 'iso') {\n if (typeof value !== 'string') {\n return null;\n }\n const ms = new Date(value).getTime();\n return Number.isFinite(ms) ? ms : null;\n }\n if (typeof value === 'string' && value.trim() === '') {\n return null;\n }\n const n = typeof value === 'number' ? value : Number(value);\n if (!Number.isFinite(n)) {\n return null;\n }\n const result = unit === 's' ? n * 1000 : n;\n return Number.isFinite(result) ? result : null;\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","export type LogFields = Record<string, unknown>;\n\nexport interface ConnectorLogger {\n info(event: string, fields?: LogFields): void;\n warn(event: string, fields?: LogFields): void;\n}\n\nexport interface ConnectorLoggerOptions {\n scope: string;\n}\n\nconst MAX_VALUE_LEN = 120;\n\nfunction truncate(s: string, max = MAX_VALUE_LEN): string {\n if (s.length <= max) {\n return s;\n }\n return `${s.slice(0, max - 1)}…`;\n}\n\nfunction formatValue(value: unknown): string {\n if (value === null) {\n return 'null';\n }\n if (value === undefined) {\n return '';\n }\n if (typeof value === 'number' || typeof value === 'boolean') {\n return String(value);\n }\n if (typeof value === 'string') {\n const t = truncate(value);\n if (/[\\s\"=]/.test(t)) {\n return JSON.stringify(t);\n }\n return t;\n }\n if (typeof value === 'bigint') {\n return value.toString();\n }\n let json: string | undefined;\n try {\n json = JSON.stringify(value);\n } catch {\n json = undefined;\n }\n return truncate(json ?? String(value));\n}\n\nexport function formatLogFields(fields?: LogFields): string {\n if (!fields) {\n return '';\n }\n const parts: string[] = [];\n for (const [k, v] of Object.entries(fields)) {\n if (v === undefined) {\n continue;\n }\n parts.push(`${k}=${formatValue(v)}`);\n }\n return parts.length > 0 ? ` ${parts.join(' ')}` : '';\n}\n\nexport function formatLogLine(\n scope: string,\n event: string,\n fields?: LogFields,\n): string {\n return `[${scope}] ${event}${formatLogFields(fields)}`;\n}\n\nexport function createDefaultConnectorLogger(\n opts: ConnectorLoggerOptions,\n): ConnectorLogger {\n return {\n info(event, fields) {\n console.info(formatLogLine(opts.scope, event, fields));\n },\n warn(event, fields) {\n console.warn(formatLogLine(opts.scope, event, fields));\n },\n };\n}\n\nconst NOOP_LOGGER: ConnectorLogger = {\n info() {},\n warn() {},\n};\n\nexport function noopConnectorLogger(): ConnectorLogger {\n return NOOP_LOGGER;\n}\n","import {\n type HttpResponse,\n connectorUserAgent,\n parseEpoch,\n} from '@rawdash/connector-shared';\nimport {\n BaseConnector,\n type ConnectorContext,\n type ConnectorDoc,\n type CredentialsSchema,\n type JSONValue,\n type StorageHandle,\n type SyncOptions,\n type SyncResult,\n defineConfigFields,\n defineConnectorDoc,\n defineResources,\n makeChunkedCursorGuard,\n paginateChunked,\n schemasFromResources,\n selectActivePhases,\n} from '@rawdash/core';\nimport { z } from 'zod';\n\n// ---------------------------------------------------------------------------\n// configFields\n// ---------------------------------------------------------------------------\n\nexport const configFields = defineConfigFields(\n z.object({\n email: z.string().min(1).meta({\n label: 'Account email',\n description:\n 'Atlassian account email paired with the API token for Basic auth.',\n placeholder: 'you@yourorg.com',\n }),\n apiToken: z.object({ $secret: z.string() }).meta({\n label: 'API Token',\n description:\n 'Atlassian API token. Create one at id.atlassian.com → Security → API tokens.',\n placeholder: 'ATATT...',\n secret: true,\n }),\n host: z\n .string()\n .min(1)\n .regex(\n /^[^/\\s:?#]+$/,\n 'Use host only (no protocol, port, path, or query).',\n )\n .meta({\n label: 'Site host',\n description:\n 'Your Jira Cloud host, e.g. yourorg.atlassian.net (no protocol, no trailing slash).',\n placeholder: 'yourorg.atlassian.net',\n }),\n projectKeys: z.array(z.string().min(1)).nonempty().optional().meta({\n label: 'Project keys (optional)',\n description:\n 'Restrict the sync to specific Jira project keys (e.g. ENG, OPS). Omit to sync every project the account can see.',\n }),\n resources: z\n .array(z.enum(['projects', 'users', 'sprints', 'issues', 'issue_events']))\n .nonempty()\n .optional()\n .meta({\n label: 'Resources',\n description:\n \"Which Jira resources to sync. Omit to sync all of them. 'issue_events' shares the issues query - enabling it without 'issues' still fetches issues (with changelog) but skips writing issue entities.\",\n }),\n storyPointsField: z.string().min(1).optional().meta({\n label: 'Story points field ID',\n description:\n 'Custom field ID holding story points (varies per site). Defaults to customfield_10016.',\n placeholder: 'customfield_10016',\n }),\n sprintField: z.string().min(1).optional().meta({\n label: 'Sprint field ID',\n description:\n 'Custom field ID holding the sprint association on issues. Defaults to customfield_10020.',\n placeholder: 'customfield_10020',\n }),\n }),\n);\n\nexport const doc: ConnectorDoc = defineConnectorDoc({\n displayName: 'Jira',\n category: 'product',\n brandColor: '#0052CC',\n tagline:\n 'Sync projects, users, sprints, issues, and issue status-change events from a Jira Cloud site.',\n vendor: {\n name: 'Atlassian',\n apiDocs: 'https://developer.atlassian.com/cloud/jira/platform/rest/v3/',\n website: 'https://www.atlassian.com/software/jira',\n },\n auth: {\n summary:\n 'Authenticates over HTTP Basic auth using your Atlassian account email and an API token. The token must belong to an account with access to the projects you want to sync.',\n setup: [\n 'Open id.atlassian.com -> Security -> Create and manage API tokens.',\n 'Create an API token and copy its value.',\n 'Store the token as a secret and reference it from the connector config as `apiToken: secret(\"JIRA_API_TOKEN\")`, alongside your account email and site host (e.g. yourorg.atlassian.net).',\n 'Story points and the sprint association live on custom fields whose IDs differ per Jira site. Discover them at `https://{host}/rest/api/3/field` and set storyPointsField / sprintField to match.',\n ],\n },\n rateLimit:\n 'Jira Cloud uses cost-based rate limiting; 429 responses with Retry-After are honored.',\n limitations: [\n 'Sprints are only synced from scrum boards; kanban boards are skipped.',\n 'Issue status-change events are derived from each issue changelog; only `status` field transitions are written.',\n 'Targets Jira Cloud REST API v3 and the Agile API; Jira Data Center / Server are out of scope.',\n ],\n});\n\nexport type JiraResource =\n | 'projects'\n | 'users'\n | 'sprints'\n | 'issues'\n | 'issue_events';\n\nexport interface JiraSettings {\n host: string;\n projectKeys?: readonly string[];\n resources?: readonly JiraResource[];\n storyPointsField?: string;\n sprintField?: string;\n}\n\nconst jiraCredentials = {\n email: {\n description: 'Atlassian account email',\n auth: 'required' as const,\n },\n apiToken: {\n description: 'Atlassian API token',\n auth: 'required' as const,\n },\n} satisfies CredentialsSchema;\n\ntype JiraCredentials = typeof jiraCredentials;\n\n// ---------------------------------------------------------------------------\n// Sync phases + cursor\n// ---------------------------------------------------------------------------\n\nconst PHASE_ORDER = ['projects', 'users', 'sprints', 'issues'] as const;\n\ntype JiraPhase = (typeof PHASE_ORDER)[number];\n\nconst isJiraSyncCursor = makeChunkedCursorGuard(PHASE_ORDER);\n\n// ---------------------------------------------------------------------------\n// Jira API types\n// ---------------------------------------------------------------------------\n\ninterface JiraAccountRef {\n accountId: string;\n displayName?: string | null;\n}\n\ninterface JiraStatusCategory {\n key: string;\n name?: string | null;\n}\n\ninterface JiraStatus {\n name: string;\n statusCategory?: JiraStatusCategory | null;\n}\n\ninterface JiraNamed {\n name: string;\n}\n\ninterface JiraProjectRef {\n id: string;\n key: string;\n}\n\ninterface JiraIssueFields {\n summary?: string | null;\n status?: JiraStatus | null;\n priority?: JiraNamed | null;\n issuetype?: JiraNamed | null;\n assignee?: JiraAccountRef | null;\n reporter?: JiraAccountRef | null;\n project?: JiraProjectRef | null;\n created: string;\n updated: string;\n resolutiondate?: string | null;\n [key: string]: unknown;\n}\n\ninterface JiraChangelogItem {\n field: string;\n fromString?: string | null;\n toString?: string | null;\n}\n\ninterface JiraChangelogHistory {\n id: string;\n created: string;\n author?: JiraAccountRef | null;\n items: JiraChangelogItem[];\n}\n\ninterface JiraIssue {\n id: string;\n key: string;\n fields: JiraIssueFields;\n changelog?: { histories: JiraChangelogHistory[] } | null;\n}\n\ninterface JiraSearchResponse {\n issues: JiraIssue[];\n nextPageToken?: string | null;\n isLast?: boolean;\n}\n\ninterface JiraProject {\n id: string;\n key: string;\n name: string;\n projectTypeKey?: string | null;\n lead?: JiraAccountRef | null;\n}\n\ninterface JiraProjectPage {\n values: JiraProject[];\n isLast: boolean;\n startAt: number;\n maxResults: number;\n total: number;\n}\n\ninterface JiraUser {\n accountId: string;\n displayName?: string | null;\n emailAddress?: string | null;\n accountType?: string | null;\n active?: boolean | null;\n}\n\ninterface JiraSprint {\n id: number;\n name: string;\n state: 'active' | 'closed' | 'future';\n startDate?: string | null;\n endDate?: string | null;\n completeDate?: string | null;\n originBoardId?: number | null;\n}\n\ninterface JiraSprintWithBoard extends JiraSprint {\n boardId: number;\n}\n\ninterface JiraBoard {\n id: number;\n name: string;\n type: string;\n}\n\ninterface JiraAgilePage<T> {\n values: T[];\n isLast?: boolean;\n startAt: number;\n maxResults: number;\n}\n\n// ---------------------------------------------------------------------------\n// Schemas — describe the per-resource API response shape consumed by request()\n// ---------------------------------------------------------------------------\n\nconst idString = z.string().min(1);\nconst nonNegInt = z.number().int().nonnegative();\n\nconst accountRefSchema = z.object({\n accountId: idString,\n displayName: z.string().nullable().optional(),\n});\n\nconst projectSchema = z.object({\n id: idString,\n key: z.string().min(1),\n name: z.string(),\n projectTypeKey: z.string().nullable().optional(),\n lead: accountRefSchema.nullable().optional(),\n});\n\nconst projectsResponseSchema = z.object({\n values: z.array(projectSchema),\n isLast: z.boolean(),\n startAt: nonNegInt,\n maxResults: nonNegInt,\n total: nonNegInt,\n});\n\nconst usersResponseSchema = z.array(\n z.object({\n accountId: idString,\n displayName: z.string().nullable().optional(),\n emailAddress: z.string().nullable().optional(),\n accountType: z.string().nullable().optional(),\n active: z.boolean().nullable().optional(),\n }),\n);\n\nconst sprintsResponseSchema = z.array(\n z.object({\n id: nonNegInt,\n name: z.string(),\n state: z.enum(['active', 'closed', 'future']),\n startDate: z.iso.datetime().nullable().optional(),\n endDate: z.iso.datetime().nullable().optional(),\n completeDate: z.iso.datetime().nullable().optional(),\n originBoardId: nonNegInt.nullable().optional(),\n }),\n);\n\nconst changelogHistorySchema = z.object({\n id: idString,\n created: z.iso.datetime(),\n author: accountRefSchema.nullable().optional(),\n items: z.array(\n z.object({\n field: z.string(),\n fromString: z.string().nullable().optional(),\n toString: z.string().nullable().optional(),\n }),\n ),\n});\n\nconst issueSchema = z.object({\n id: idString,\n key: z.string().min(1),\n fields: z.object({\n summary: z.string().nullable().optional(),\n status: z\n .object({\n name: z.string(),\n statusCategory: z\n .object({ key: z.string(), name: z.string().nullable().optional() })\n .nullable()\n .optional(),\n })\n .nullable()\n .optional(),\n priority: z.object({ name: z.string() }).nullable().optional(),\n issuetype: z.object({ name: z.string() }).nullable().optional(),\n assignee: accountRefSchema.nullable().optional(),\n reporter: accountRefSchema.nullable().optional(),\n project: z.object({ id: idString, key: z.string().min(1) }).nullable(),\n created: z.iso.datetime(),\n updated: z.iso.datetime(),\n resolutiondate: z.iso.datetime().nullable().optional(),\n customfield_10016: z.number().nullable().optional(),\n customfield_10020: z\n .array(z.object({ id: nonNegInt, name: z.string() }))\n .nullable()\n .optional(),\n }),\n changelog: z.object({ histories: z.array(changelogHistorySchema) }),\n});\n\nconst issuesResponseSchema = z.object({\n issues: z.array(issueSchema),\n nextPageToken: z.string().nullable().optional(),\n isLast: z.boolean().optional(),\n});\n\nconst jiraResources = defineResources({\n jira_project: {\n shape: 'entity',\n description:\n 'Jira projects with key, name, type, and project lead. Restrict via projectKeys to limit the sync.',\n endpoint: 'GET /rest/api/3/project/search',\n responses: { projects: projectsResponseSchema },\n },\n jira_user: {\n shape: 'entity',\n description:\n 'Atlassian accounts visible to the connector, including display name, email, account type, and active state.',\n endpoint: 'GET /rest/api/3/users/search',\n responses: { users: usersResponseSchema },\n },\n jira_sprint: {\n shape: 'entity',\n description:\n 'Sprints from scrum boards with state, start/end/complete dates, and owning board.',\n endpoint: 'GET /rest/agile/1.0/board/{boardId}/sprint',\n responses: { sprints: sprintsResponseSchema },\n },\n jira_issue: {\n shape: 'entity',\n description:\n 'Issues with status, priority, type, assignee, reporter, project, sprint, story points, and resolution date.',\n endpoint: 'GET /rest/api/3/search/jql',\n notes:\n \"sprintId is taken from the most recent sprint on the issue's sprint custom field.\",\n responses: { issues: issuesResponseSchema },\n },\n jira_issue_status_change: {\n shape: 'event',\n description:\n 'Status transition events derived from issue changelogs, capturing the from/to status, author, and project.',\n endpoint: 'GET /rest/api/3/search/jql (expand=changelog)',\n notes:\n 'start_ts is the changelog entry time, end_ts is null. Timestamps are Unix epoch milliseconds.',\n },\n});\n\n// ---------------------------------------------------------------------------\n// JiraConnector\n// ---------------------------------------------------------------------------\n\nconst PROJECTS_PAGE_SIZE = 50;\nconst USERS_PAGE_SIZE = 50;\nconst BOARDS_PAGE_SIZE = 50;\nconst SPRINTS_PAGE_SIZE = 50;\nconst ISSUES_PAGE_SIZE = 100;\nconst DEFAULT_STORY_POINTS_FIELD = 'customfield_10016';\nconst DEFAULT_SPRINT_FIELD = 'customfield_10020';\n\nconst ISSUE_FIELDS = [\n 'summary',\n 'status',\n 'priority',\n 'issuetype',\n 'assignee',\n 'reporter',\n 'project',\n 'created',\n 'updated',\n 'resolutiondate',\n] as const;\n\nfunction parseOffset(page: string | null): number {\n if (page === null) {\n return 0;\n }\n const n = Number.parseInt(page, 10);\n return Number.isFinite(n) && n >= 0 ? n : 0;\n}\n\nfunction extractSprintId(value: unknown): string | null {\n if (!Array.isArray(value) || value.length === 0) {\n return null;\n }\n const last = value[value.length - 1];\n if (last !== null && typeof last === 'object' && 'id' in last) {\n const id = (last as { id: unknown }).id;\n return id === null || id === undefined ? null : String(id);\n }\n if (typeof last === 'number' || typeof last === 'string') {\n return String(last);\n }\n return null;\n}\n\nfunction formatJqlDate(iso: string): string | null {\n const ms = parseEpoch(iso, 'iso');\n if (ms === null) {\n return null;\n }\n const d = new Date(ms);\n const pad = (n: number) => String(n).padStart(2, '0');\n return (\n `${d.getUTCFullYear()}-${pad(d.getUTCMonth() + 1)}-${pad(d.getUTCDate())} ` +\n `${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())}`\n );\n}\n\nexport class JiraConnector extends BaseConnector<\n JiraSettings,\n JiraCredentials\n> {\n static readonly id = 'jira';\n\n static readonly resources = jiraResources;\n\n static readonly schemas = schemasFromResources(jiraResources);\n\n static create(input: unknown, ctx?: ConnectorContext): JiraConnector {\n const parsed = configFields.parse(input);\n return new JiraConnector(\n {\n host: parsed.host,\n projectKeys: parsed.projectKeys,\n resources: parsed.resources,\n storyPointsField: parsed.storyPointsField,\n sprintField: parsed.sprintField,\n },\n { email: parsed.email, apiToken: parsed.apiToken },\n ctx,\n );\n }\n\n readonly id = 'jira';\n override readonly credentials = jiraCredentials;\n\n private get baseUrl(): string {\n const host = this.settings.host\n .replace(/^https?:\\/\\//, '')\n .replace(/\\/+$/, '');\n return `https://${host}`;\n }\n\n private get storyPointsField(): string {\n return this.settings.storyPointsField ?? DEFAULT_STORY_POINTS_FIELD;\n }\n\n private get sprintField(): string {\n return this.settings.sprintField ?? DEFAULT_SPRINT_FIELD;\n }\n\n private buildHeaders(): Record<string, string> {\n const basic = btoa(`${this.creds.email}:${this.creds.apiToken}`);\n return {\n Authorization: `Basic ${basic}`,\n Accept: 'application/json',\n 'User-Agent': connectorUserAgent('jira'),\n };\n }\n\n private fetch<T>(\n url: string,\n resource: string,\n signal?: AbortSignal,\n ): Promise<HttpResponse<T>> {\n return this.get<T>(url, {\n resource,\n headers: this.buildHeaders(),\n signal,\n });\n }\n\n // -------------------------------------------------------------------------\n // Resource enablement\n // -------------------------------------------------------------------------\n\n private activePhases(): JiraPhase[] {\n return selectActivePhases<JiraResource, JiraPhase>(\n (r) => {\n switch (r) {\n case 'projects':\n return 'projects';\n case 'users':\n return 'users';\n case 'sprints':\n return 'sprints';\n case 'issues':\n case 'issue_events':\n return 'issues';\n }\n },\n PHASE_ORDER,\n this.settings.resources,\n );\n }\n\n // -------------------------------------------------------------------------\n // JQL\n // -------------------------------------------------------------------------\n\n private buildJql(options: SyncOptions): string {\n const clauses: string[] = [];\n const keys = this.settings.projectKeys;\n if (keys && keys.length > 0) {\n const quoted = keys.map(\n (k) => `\"${k.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"')}\"`,\n );\n clauses.push(`project in (${quoted.join(',')})`);\n }\n if (options.mode === 'latest' && options.since) {\n const formatted = formatJqlDate(options.since);\n if (formatted !== null) {\n clauses.push(`updated >= \"${formatted}\"`);\n }\n }\n const where = clauses.join(' AND ');\n return where.length > 0\n ? `${where} ORDER BY updated ASC`\n : 'ORDER BY updated ASC';\n }\n\n // -------------------------------------------------------------------------\n // Fetchers\n // -------------------------------------------------------------------------\n\n private async fetchProjectsPage(\n page: string | null,\n signal: AbortSignal | undefined,\n ): Promise<{ items: JiraProject[]; next: string | null }> {\n const startAt = parseOffset(page);\n const u = new URL(`${this.baseUrl}/rest/api/3/project/search`);\n u.searchParams.set('startAt', String(startAt));\n u.searchParams.set('maxResults', String(PROJECTS_PAGE_SIZE));\n u.searchParams.set('expand', 'lead');\n const res = await this.fetch<JiraProjectPage>(\n u.toString(),\n 'projects',\n signal,\n );\n const values = res.body.values;\n const next =\n res.body.isLast || values.length === 0\n ? null\n : String(startAt + values.length);\n return { items: values, next };\n }\n\n private async fetchUsersPage(\n page: string | null,\n signal: AbortSignal | undefined,\n ): Promise<{ items: JiraUser[]; next: string | null }> {\n const startAt = parseOffset(page);\n const u = new URL(`${this.baseUrl}/rest/api/3/users/search`);\n u.searchParams.set('startAt', String(startAt));\n u.searchParams.set('maxResults', String(USERS_PAGE_SIZE));\n const res = await this.fetch<JiraUser[]>(u.toString(), 'users', signal);\n const users = res.body;\n const next =\n users.length < USERS_PAGE_SIZE ? null : String(startAt + users.length);\n return { items: users, next };\n }\n\n private async fetchBoardsPage(\n startAt: number,\n signal: AbortSignal | undefined,\n ): Promise<JiraAgilePage<JiraBoard>> {\n const u = new URL(`${this.baseUrl}/rest/agile/1.0/board`);\n u.searchParams.set('startAt', String(startAt));\n u.searchParams.set('maxResults', String(BOARDS_PAGE_SIZE));\n const res = await this.fetch<JiraAgilePage<JiraBoard>>(\n u.toString(),\n 'sprints',\n signal,\n );\n return res.body;\n }\n\n private async fetchSprintsForBoard(\n boardId: number,\n signal: AbortSignal | undefined,\n ): Promise<JiraSprint[]> {\n const out: JiraSprint[] = [];\n let startAt = 0;\n while (true) {\n signal?.throwIfAborted();\n const u = new URL(\n `${this.baseUrl}/rest/agile/1.0/board/${boardId}/sprint`,\n );\n u.searchParams.set('startAt', String(startAt));\n u.searchParams.set('maxResults', String(SPRINTS_PAGE_SIZE));\n const res = await this.fetch<JiraAgilePage<JiraSprint>>(\n u.toString(),\n 'sprints',\n signal,\n );\n const values = res.body.values;\n out.push(...values);\n const isLast = res.body.isLast ?? values.length < SPRINTS_PAGE_SIZE;\n if (isLast || values.length === 0) {\n break;\n }\n startAt += values.length;\n }\n return out;\n }\n\n private async fetchSprintsPage(\n page: string | null,\n signal: AbortSignal | undefined,\n ): Promise<{ items: JiraSprintWithBoard[]; next: string | null }> {\n const startAt = parseOffset(page);\n const boardsPage = await this.fetchBoardsPage(startAt, signal);\n const boards = boardsPage.values;\n const sprints: JiraSprintWithBoard[] = [];\n for (const board of boards) {\n if (board.type !== 'scrum') {\n continue;\n }\n const boardSprints = await this.fetchSprintsForBoard(board.id, signal);\n for (const s of boardSprints) {\n sprints.push({ ...s, boardId: board.id });\n }\n }\n const isLast = boardsPage.isLast ?? boards.length < BOARDS_PAGE_SIZE;\n const next = isLast ? null : String(startAt + boards.length);\n return { items: sprints, next };\n }\n\n private async fetchIssuesPage(\n page: string | null,\n options: SyncOptions,\n signal: AbortSignal | undefined,\n ): Promise<{ items: JiraIssue[]; next: string | null }> {\n const u = new URL(`${this.baseUrl}/rest/api/3/search/jql`);\n u.searchParams.set('jql', this.buildJql(options));\n u.searchParams.set('maxResults', String(ISSUES_PAGE_SIZE));\n u.searchParams.set(\n 'fields',\n [...ISSUE_FIELDS, this.storyPointsField, this.sprintField].join(','),\n );\n u.searchParams.set('expand', 'changelog');\n if (page !== null) {\n u.searchParams.set('nextPageToken', page);\n }\n const res = await this.fetch<JiraSearchResponse>(\n u.toString(),\n 'issues',\n signal,\n );\n const token = res.body.nextPageToken ?? null;\n const next = res.body.isLast === true || token === null ? null : token;\n return { items: res.body.issues, next };\n }\n\n // -------------------------------------------------------------------------\n // Writers\n // -------------------------------------------------------------------------\n\n private async writeProjects(\n storage: StorageHandle,\n projects: JiraProject[],\n ): Promise<void> {\n const now = Date.now();\n for (const p of projects) {\n await storage.entity({\n type: 'jira_project',\n id: p.id,\n attributes: {\n key: p.key,\n name: p.name,\n projectTypeKey: p.projectTypeKey ?? null,\n leadAccountId: p.lead?.accountId ?? null,\n leadDisplayName: p.lead?.displayName ?? null,\n },\n updated_at: now,\n });\n }\n }\n\n private async writeUsers(\n storage: StorageHandle,\n users: JiraUser[],\n ): Promise<void> {\n const now = Date.now();\n for (const u of users) {\n if (!u.accountId) {\n continue;\n }\n await storage.entity({\n type: 'jira_user',\n id: u.accountId,\n attributes: {\n displayName: u.displayName ?? null,\n emailAddress: u.emailAddress ?? null,\n accountType: u.accountType ?? null,\n active: u.active ?? null,\n },\n updated_at: now,\n });\n }\n }\n\n private async writeSprints(\n storage: StorageHandle,\n sprints: JiraSprintWithBoard[],\n ): Promise<void> {\n const now = Date.now();\n for (const s of sprints) {\n const startMs = parseEpoch(s.startDate ?? null, 'iso');\n const endMs = parseEpoch(s.endDate ?? null, 'iso');\n const completeMs = parseEpoch(s.completeDate ?? null, 'iso');\n await storage.entity({\n type: 'jira_sprint',\n id: String(s.id),\n attributes: {\n name: s.name,\n state: s.state,\n boardId: s.boardId,\n originBoardId: s.originBoardId ?? null,\n startDate: startMs,\n endDate: endMs,\n completeDate: completeMs,\n },\n updated_at: completeMs ?? endMs ?? startMs ?? now,\n });\n }\n }\n\n private async writeIssues(\n storage: StorageHandle,\n issues: JiraIssue[],\n sinceMs: number | null,\n ): Promise<void> {\n const writeEntities = this.isResourceEnabled('issues');\n const writeEvents = this.isResourceEnabled('issue_events');\n\n for (const issue of issues) {\n const f = issue.fields;\n const createdMs = parseEpoch(f.created, 'iso');\n const updatedMs = parseEpoch(f.updated, 'iso');\n if (createdMs === null || updatedMs === null) {\n console.warn(\n `[connector-jira] skipping issue ${issue.key} with unparseable created/updated`,\n );\n continue;\n }\n const projectKey = f.project?.key ?? null;\n\n if (writeEntities) {\n const rawPoints = f[this.storyPointsField];\n const storyPoints =\n typeof rawPoints === 'number' && Number.isFinite(rawPoints)\n ? rawPoints\n : null;\n await storage.entity({\n type: 'jira_issue',\n id: issue.id,\n attributes: {\n key: issue.key,\n summary: f.summary ?? null,\n statusName: f.status?.name ?? null,\n statusCategory: f.status?.statusCategory?.key ?? null,\n priority: f.priority?.name ?? null,\n issueType: f.issuetype?.name ?? null,\n assigneeId: f.assignee?.accountId ?? null,\n reporterId: f.reporter?.accountId ?? null,\n projectKey,\n sprintId: extractSprintId(f[this.sprintField]),\n storyPoints,\n createdAt: createdMs,\n resolvedAt: parseEpoch(f.resolutiondate ?? null, 'iso'),\n },\n updated_at: updatedMs,\n });\n }\n\n if (writeEvents) {\n const histories = issue.changelog?.histories ?? [];\n for (const h of histories) {\n const ts = parseEpoch(h.created, 'iso');\n if (ts === null) {\n continue;\n }\n if (sinceMs !== null && ts <= sinceMs) {\n continue;\n }\n for (const item of h.items) {\n if (item.field !== 'status') {\n continue;\n }\n const attributes: Record<string, JSONValue> = {\n historyId: h.id,\n issueId: issue.id,\n issueKey: issue.key,\n projectKey,\n authorId: h.author?.accountId ?? null,\n fromStatus: item.fromString ?? null,\n toStatus: item.toString ?? null,\n };\n await storage.event({\n name: 'jira_issue_status_change',\n start_ts: ts,\n end_ts: null,\n attributes,\n });\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 = isJiraSyncCursor(options.cursor)\n ? options.cursor\n : undefined;\n const isFull = options.mode === 'full';\n const sinceMs = options.since ? parseEpoch(options.since, 'iso') : null;\n const phases = this.activePhases();\n\n return paginateChunked<JiraPhase, string>({\n phases,\n cursor,\n signal,\n fetchPage: async (phase, page, sig) => {\n switch (phase) {\n case 'projects':\n return this.fetchProjectsPage(page, sig);\n case 'users':\n return this.fetchUsersPage(page, sig);\n case 'sprints':\n return this.fetchSprintsPage(page, 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 'projects':\n await storage.entities([], { types: ['jira_project'] });\n break;\n case 'users':\n await storage.entities([], { types: ['jira_user'] });\n break;\n case 'sprints':\n await storage.entities([], { types: ['jira_sprint'] });\n break;\n case 'issues':\n if (this.isResourceEnabled('issues')) {\n await storage.entities([], { types: ['jira_issue'] });\n }\n if (this.isResourceEnabled('issue_events')) {\n await storage.events([], {\n names: ['jira_issue_status_change'],\n });\n }\n break;\n }\n }\n switch (phase) {\n case 'projects':\n return this.writeProjects(storage, items as JiraProject[]);\n case 'users':\n return this.writeUsers(storage, items as JiraUser[]);\n case 'sprints':\n return this.writeSprints(storage, items as JiraSprintWithBoard[]);\n case 'issues':\n return this.writeIssues(storage, items as JiraIssue[], sinceMs);\n }\n },\n });\n }\n}\n","import { JiraConnector } from './jira';\n\nexport { configFields, doc, JiraConnector } from './jira';\nexport type { JiraSettings, JiraResource } from './jira';\nexport default JiraConnector;\n"],"mappings":";AEAO,IAAM,sBAAsB;AAE5B,IAAM,qBAAqB,qBAAqB,mBAAmB;AAEnE,SAAS,mBAAmB,aAA6B;AAC9D,SAAO,qBAAqB,WAAW,IAAI,mBAAmB;AAChE;AIJO,SAAS,WACd,OACA,MACe;AACf,MAAI,UAAU,QAAQ,UAAU,QAAW;AACzC,WAAO;EACT;AACA,MAAI,SAAS,OAAO;AAClB,QAAI,OAAO,UAAU,UAAU;AAC7B,aAAO;IACT;AACA,UAAM,KAAK,IAAI,KAAK,KAAK,EAAE,QAAQ;AACnC,WAAO,OAAO,SAAS,EAAE,IAAI,KAAK;EACpC;AACA,MAAI,OAAO,UAAU,YAAY,MAAM,KAAK,MAAM,IAAI;AACpD,WAAO;EACT;AACA,QAAM,IAAI,OAAO,UAAU,WAAW,QAAQ,OAAO,KAAK;AAC1D,MAAI,CAAC,OAAO,SAAS,CAAC,GAAG;AACvB,WAAO;EACT;AACA,QAAM,SAAS,SAAS,MAAM,IAAI,MAAO;AACzC,SAAO,OAAO,SAAS,MAAM,IAAI,SAAS;AAC5C;;;AGpBA;AAAA,EACE;AAAA,EAQA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,SAAS;AAMX,IAAM,eAAe;AAAA,EAC1B,EAAE,OAAO;AAAA,IACP,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,KAAK;AAAA,MAC5B,OAAO;A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A,cACtD;AACA,kBAAI,KAAK,kBAAkB,cAAc,GAAG;AAC1C,sBAAM,QAAQ,OAAO,CAAC,GAAG;AAAA,kBACvB,OAAO,CAAC,0BAA0B;AAAA,gBACpC,CAAC;AAAA,cACH;AACA;AAAA,UACJ;AAAA,QACF;AACA,gBAAQ,OAAO;AAAA,UACb,KAAK;AACH,mBAAO,KAAK,cAAc,SAAS,KAAsB;AAAA,UAC3D,KAAK;AACH,mBAAO,KAAK,WAAW,SAAS,KAAmB;AAAA,UACrD,KAAK;AACH,mBAAO,KAAK,aAAa,SAAS,KAA8B;AAAA,UAClE,KAAK;AACH,mBAAO,KAAK,YAAY,SAAS,OAAsB,OAAO;AAAA,QAClE;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AACF;;;AC/6BA,IAAO,gBAAQ;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rawdash/connector-jira",
3
- "version": "0.0.1",
3
+ "version": "0.16.0",
4
4
  "description": "Rawdash connector for Jira Cloud — issues, status-change events, sprints, projects, and users",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -21,22 +21,22 @@
21
21
  "import": "./dist/index.js"
22
22
  }
23
23
  },
24
- "scripts": {
25
- "build": "tsup",
26
- "typecheck": "tsc --noEmit",
27
- "lint": "eslint src",
28
- "test": "vitest run"
29
- },
30
24
  "dependencies": {
31
- "@rawdash/core": "workspace:*",
32
- "zod": "^4.4.3"
25
+ "zod": "^4.4.3",
26
+ "@rawdash/core": "0.16.0"
33
27
  },
34
28
  "devDependencies": {
35
- "@rawdash/connector-shared": "workspace:*",
36
- "@rawdash/connector-test-utils": "workspace:*",
37
29
  "fast-check": "^4.8.0",
38
30
  "tsup": "^8.0.0",
39
31
  "typescript": "^5.7.2",
40
- "vitest": "^4.1.4"
32
+ "vitest": "^4.1.4",
33
+ "@rawdash/connector-shared": "0.3.0",
34
+ "@rawdash/connector-test-utils": "0.0.3"
35
+ },
36
+ "scripts": {
37
+ "build": "tsup",
38
+ "typecheck": "tsc --noEmit",
39
+ "lint": "eslint src",
40
+ "test": "vitest run"
41
41
  }
42
- }
42
+ }