@rawdash/connector-statuspage 0.0.1 → 0.20.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 +202 -0
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/package.json +13 -13
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/dist/index.js
CHANGED
|
@@ -380,11 +380,10 @@ var StatuspageConnector = class _StatuspageConnector extends BaseConnector {
|
|
|
380
380
|
const next = items.length < PAGE_SIZE ? null : this.buildNextPageUrl("components", url);
|
|
381
381
|
return { items, next };
|
|
382
382
|
}
|
|
383
|
-
async fetchIncidentsPage(page,
|
|
383
|
+
async fetchIncidentsPage(page, sinceMs, signal) {
|
|
384
384
|
const url = page ?? this.buildInitialUrl("incidents");
|
|
385
385
|
const res = await this.fetch(url, "incidents", signal);
|
|
386
386
|
const incidents = res.body;
|
|
387
|
-
const sinceMs = this.computeIncidentSinceMs(options);
|
|
388
387
|
const incidentTimestampMs = (inc) => {
|
|
389
388
|
const stamp = inc.updated_at ?? inc.created_at;
|
|
390
389
|
const ms = stamp ? Date.parse(stamp) : Number.NaN;
|
|
@@ -509,7 +508,7 @@ var StatuspageConnector = class _StatuspageConnector extends BaseConnector {
|
|
|
509
508
|
case "components":
|
|
510
509
|
return this.fetchComponentsPage(page, sig);
|
|
511
510
|
case "incidents":
|
|
512
|
-
return this.fetchIncidentsPage(page,
|
|
511
|
+
return this.fetchIncidentsPage(page, incidentSinceMs, sig);
|
|
513
512
|
}
|
|
514
513
|
},
|
|
515
514
|
writeBatch: async (phase, items, page) => {
|
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","../../../connector-shared/src/logger.ts","../src/statuspage.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 sanitizeAllowedUrl,\n} from '@rawdash/connector-shared';\nimport {\n BaseConnector,\n type ChunkedSyncCursor,\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 apiKey: z.object({ $secret: z.string() }).meta({\n label: 'API Key',\n description:\n 'Statuspage REST API key. Create one at Manage Account -> API Info -> API Key.',\n placeholder: 'sk_live_...',\n secret: true,\n }),\n pageId: z\n .string()\n .trim()\n .regex(/^[A-Za-z0-9]{12}$/, 'Page ID must be 12 alphanumeric characters.')\n .meta({\n label: 'Page ID',\n description:\n 'Statuspage page id (the 12-character identifier shown next to your page name in Manage Account -> API Info, also visible in the admin URL).',\n placeholder: 'abc123def456',\n }),\n resources: z\n .array(z.enum(['components', 'incidents', 'incident_updates']))\n .nonempty()\n .optional()\n .meta({\n label: 'Resources',\n description:\n \"Which Statuspage resources to sync. Omit to sync all of them. 'incident_updates' rides the 'incidents' phase - enabling it without 'incidents' still fetches incidents but skips writing incident entities.\",\n }),\n incidentLookbackDays: z.number().int().positive().max(365).optional().meta({\n label: 'Incident lookback (days)',\n description:\n 'How many days back to fetch incidents (and their updates) on a full sync. Defaults to 90. Statuspage returns incidents newest-first; this caps the backfill window.',\n placeholder: '90',\n }),\n }),\n);\n\nexport const doc: ConnectorDoc = defineConnectorDoc({\n displayName: 'Statuspage',\n category: 'engineering',\n brandColor: '#172B4D',\n tagline:\n 'Sync Atlassian Statuspage components, incidents, and incident updates - current component health, recent incident history, and per-update status transitions.',\n vendor: {\n name: 'Atlassian Statuspage',\n apiDocs: 'https://developer.statuspage.io/',\n website: 'https://www.atlassian.com/software/statuspage',\n },\n auth: {\n summary:\n 'A Statuspage REST API key is required. Keys are scoped to the issuing account and inherit that account read access; a read-only role is sufficient for the resources synced here.',\n setup: [\n 'Open Statuspage -> Manage Account -> API Info.',\n 'Copy the API Key (or generate one if none exists).',\n 'Store the key as a secret and reference it from the connector config as `apiKey: secret(\"STATUSPAGE_API_KEY\")`.',\n 'Set `pageId` to your 12-character Page ID (shown on the same screen, e.g. `abc123def456`).',\n ],\n },\n rateLimit:\n 'Statuspage rate-limits at roughly 1 request/second per page; this connector paginates sequentially and respects 429 Retry-After. The page size is 100.',\n limitations: [\n 'Better Stack Uptime is a separate package and is tracked as a follow-up.',\n 'Postmortem bodies, subscribers, metrics-provider configs, and template management are out of scope.',\n 'Component groups are exposed via each component group_id but are not synced as separate entities.',\n ],\n});\n\nexport type StatuspageResource =\n | 'components'\n | 'incidents'\n | 'incident_updates';\n\nexport interface StatuspageSettings {\n pageId: string;\n resources?: readonly StatuspageResource[];\n incidentLookbackDays?: number;\n}\n\nconst statuspageCredentials = {\n apiKey: {\n description: 'Statuspage REST API key',\n auth: 'required' as const,\n },\n} satisfies CredentialsSchema;\n\ntype StatuspageCredentials = typeof statuspageCredentials;\n\n// ---------------------------------------------------------------------------\n// Sync phases + cursor\n// ---------------------------------------------------------------------------\n\nconst PHASE_ORDER = ['components', 'incidents'] as const;\n\ntype StatuspagePhase = (typeof PHASE_ORDER)[number];\n\ntype StatuspageSyncCursor = ChunkedSyncCursor<StatuspagePhase, string>;\n\nconst isStatuspageSyncCursor = makeChunkedCursorGuard(PHASE_ORDER);\n\n// ---------------------------------------------------------------------------\n// Statuspage API types\n// ---------------------------------------------------------------------------\n\ninterface SPComponent {\n id: string;\n page_id: string;\n group_id?: string | null;\n name: string;\n description?: string | null;\n status: string;\n position?: number;\n showcase?: boolean;\n start_date?: string | null;\n group?: boolean;\n only_show_if_degraded?: boolean;\n automation_email?: string | null;\n created_at?: string;\n updated_at?: string;\n}\n\ninterface SPIncidentUpdate {\n id: string;\n incident_id: string;\n status: string;\n body: string;\n display_at?: string | null;\n created_at: string;\n updated_at?: string | null;\n affected_components?: unknown;\n}\n\ninterface SPIncident {\n id: string;\n name: string;\n status: string;\n impact: string;\n page_id?: string;\n shortlink?: string | null;\n created_at: string;\n updated_at?: string | null;\n monitoring_at?: string | null;\n resolved_at?: string | null;\n scheduled_for?: string | null;\n scheduled_until?: string | null;\n components?: Array<{ id: string; name?: string; status?: string }>;\n incident_updates?: SPIncidentUpdate[];\n}\n\n// ---------------------------------------------------------------------------\n// Schemas - describe the per-resource API response shape consumed by request()\n// ---------------------------------------------------------------------------\n\nconst idString = z.string().min(1);\n\nconst componentSchema = z.object({\n id: idString,\n page_id: idString,\n group_id: z.string().nullable().optional(),\n name: z.string(),\n description: z.string().nullable().optional(),\n status: z.string(),\n position: z.number().int().nonnegative().optional(),\n showcase: z.boolean().optional(),\n start_date: z.string().nullable().optional(),\n group: z.boolean().optional(),\n only_show_if_degraded: z.boolean().optional(),\n automation_email: z.string().nullable().optional(),\n created_at: z.string().optional(),\n updated_at: z.string().optional(),\n});\n\nconst componentsResponseSchema = z.array(componentSchema);\n\nconst incidentUpdateSchema = z.object({\n id: idString,\n incident_id: idString,\n status: z.string(),\n body: z.string(),\n display_at: z.string().nullable().optional(),\n created_at: z.string(),\n updated_at: z.string().nullable().optional(),\n affected_components: z.unknown().optional(),\n});\n\nconst incidentSchema = z.object({\n id: idString,\n name: z.string(),\n status: z.string(),\n impact: z.string(),\n page_id: z.string().optional(),\n shortlink: z.string().nullable().optional(),\n created_at: z.string(),\n updated_at: z.string().nullable().optional(),\n monitoring_at: z.string().nullable().optional(),\n resolved_at: z.string().nullable().optional(),\n scheduled_for: z.string().nullable().optional(),\n scheduled_until: z.string().nullable().optional(),\n components: z\n .array(\n z.object({\n id: idString,\n name: z.string().optional(),\n status: z.string().optional(),\n }),\n )\n .optional(),\n incident_updates: z.array(incidentUpdateSchema).optional(),\n});\n\nconst incidentsResponseSchema = z.array(incidentSchema);\n\n// ---------------------------------------------------------------------------\n// Resource definitions\n// ---------------------------------------------------------------------------\n\nexport const statuspageResources = defineResources({\n statuspage_component: {\n shape: 'entity',\n description:\n 'Statuspage components (the things on a status page that turn red), with current status, group membership, and whether they are hidden until degraded.',\n endpoint: 'GET /v1/pages/{page_id}/components',\n fields: [\n { name: 'name', description: 'Component display name.' },\n {\n name: 'status',\n description:\n 'Current health: operational | under_maintenance | degraded_performance | partial_outage | major_outage.',\n },\n {\n name: 'groupId',\n description:\n 'Parent component-group id, or null if the component is top-level.',\n },\n {\n name: 'group',\n description: 'True if this row is itself a component group.',\n },\n {\n name: 'showcase',\n description: 'Whether the component is shown on the public page.',\n },\n {\n name: 'onlyShowIfDegraded',\n description:\n 'When true the component is hidden on the public page while operational.',\n },\n {\n name: 'position',\n description: 'Sort position within the page or group.',\n },\n ],\n responses: { components: componentsResponseSchema },\n },\n statuspage_incident: {\n shape: 'entity',\n description:\n 'Statuspage incidents (realtime outages plus maintenance windows) with status, impact, affected components, and the created / monitoring / resolved timestamps.',\n endpoint: 'GET /v1/pages/{page_id}/incidents',\n notes:\n 'Returned newest-first by updated_at; bounded by the incident lookback window (default 90 days) and tightened to options.since on incremental syncs.',\n fields: [\n { name: 'name', description: 'Incident title.' },\n {\n name: 'status',\n description:\n 'Realtime status (investigating | identified | monitoring | resolved | postmortem) or maintenance status (scheduled | in_progress | verifying | completed).',\n },\n {\n name: 'impact',\n description:\n 'Reported impact: none | maintenance | minor | major | critical.',\n },\n {\n name: 'componentIds',\n description: 'Ids of components currently attached to the incident.',\n },\n {\n name: 'createdAt',\n description: 'Incident creation timestamp (epoch ms).',\n },\n {\n name: 'resolvedAt',\n description:\n 'Resolved timestamp (epoch ms), or null while the incident is open.',\n },\n {\n name: 'shortlink',\n description: 'Public-facing short URL for the incident.',\n },\n ],\n responses: { incidents: incidentsResponseSchema },\n },\n statuspage_incident_update: {\n shape: 'event',\n description:\n 'Per-update transitions inside an incident timeline (each comment / status flip). Emitted at display_at (falling back to created_at).',\n endpoint: 'GET /v1/pages/{page_id}/incidents',\n notes:\n 'Derived from the inline incident_updates array on each incident; Statuspage does not expose a separate list endpoint.',\n fields: [\n { name: 'updateId', description: 'Incident-update id.' },\n {\n name: 'incidentId',\n description: 'Parent incident id.',\n },\n {\n name: 'status',\n description: 'Status the incident moved to at this update.',\n },\n {\n name: 'body',\n description: 'Free-form message posted on the update.',\n },\n ],\n },\n});\n\n// ---------------------------------------------------------------------------\n// StatuspageConnector\n// ---------------------------------------------------------------------------\n\nconst SP_API_HOST = 'api.statuspage.io';\nconst SP_API_BASE = `https://${SP_API_HOST}`;\nconst PAGE_SIZE = 100;\nconst DEFAULT_INCIDENT_LOOKBACK_DAYS = 90;\nconst MS_PER_DAY = 24 * 60 * 60 * 1000;\n\nexport const id = 'statuspage';\n\ninterface IncidentBatchItem {\n incident: SPIncident;\n}\n\nexport class StatuspageConnector extends BaseConnector<\n StatuspageSettings,\n StatuspageCredentials\n> {\n static readonly id = id;\n\n static readonly resources = statuspageResources;\n\n static readonly schemas = schemasFromResources(statuspageResources);\n\n static create(input: unknown, ctx?: ConnectorContext): StatuspageConnector {\n const parsed = configFields.parse(input);\n return new StatuspageConnector(\n {\n pageId: parsed.pageId,\n resources: parsed.resources,\n incidentLookbackDays: parsed.incidentLookbackDays,\n },\n { apiKey: parsed.apiKey },\n ctx,\n );\n }\n\n readonly id = id;\n override readonly credentials = statuspageCredentials;\n\n private buildHeaders(): Record<string, string> {\n return {\n Authorization: `OAuth ${this.creds.apiKey}`,\n Accept: 'application/json',\n 'User-Agent': connectorUserAgent('statuspage'),\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(): StatuspagePhase[] {\n return selectActivePhases<StatuspageResource, StatuspagePhase>(\n (r) => {\n switch (r) {\n case 'components':\n return 'components';\n case 'incidents':\n case 'incident_updates':\n return 'incidents';\n }\n },\n PHASE_ORDER,\n this.settings.resources,\n );\n }\n\n // -------------------------------------------------------------------------\n // URL building + sanitization\n // -------------------------------------------------------------------------\n\n private allowedPagePath(phase: StatuspagePhase): string {\n switch (phase) {\n case 'components':\n return `/v1/pages/${this.settings.pageId}/components`;\n case 'incidents':\n return `/v1/pages/${this.settings.pageId}/incidents`;\n }\n }\n\n private sanitizePageUrl(\n phase: StatuspagePhase,\n pageUrl: string | null,\n ): string | null {\n if (pageUrl === null) {\n return null;\n }\n return sanitizeAllowedUrl({\n url: pageUrl,\n host: SP_API_HOST,\n pathname: this.allowedPagePath(phase),\n });\n }\n\n private resolveCursor(cursor: unknown): StatuspageSyncCursor | undefined {\n if (!isStatuspageSyncCursor(cursor)) {\n return undefined;\n }\n return {\n phase: cursor.phase,\n page: this.sanitizePageUrl(cursor.phase, cursor.page),\n };\n }\n\n private buildInitialUrl(phase: StatuspagePhase): string {\n const u = new URL(`${SP_API_BASE}${this.allowedPagePath(phase)}`);\n u.searchParams.set('page', '1');\n u.searchParams.set('per_page', String(PAGE_SIZE));\n return u.toString();\n }\n\n private buildNextPageUrl(\n phase: StatuspagePhase,\n currentUrl: string,\n ): string | null {\n let u: URL;\n try {\n u = new URL(currentUrl);\n } catch {\n return null;\n }\n const pageRaw = u.searchParams.get('page');\n const pageNum = pageRaw === null ? 1 : Number.parseInt(pageRaw, 10);\n if (!Number.isFinite(pageNum) || pageNum < 1) {\n return null;\n }\n u.searchParams.set('page', String(pageNum + 1));\n u.searchParams.set('per_page', String(PAGE_SIZE));\n return this.sanitizePageUrl(phase, u.toString());\n }\n\n private computeIncidentSinceMs(options: SyncOptions): number {\n if (options.since) {\n const ms = parseEpoch(options.since, 'iso');\n if (ms !== null) {\n return ms;\n }\n }\n const days =\n this.settings.incidentLookbackDays ?? DEFAULT_INCIDENT_LOOKBACK_DAYS;\n return Date.now() - days * MS_PER_DAY;\n }\n\n // -------------------------------------------------------------------------\n // Fetchers\n // -------------------------------------------------------------------------\n\n private async fetchComponentsPage(\n page: string | null,\n signal: AbortSignal | undefined,\n ): Promise<{ items: SPComponent[]; next: string | null }> {\n const url = page ?? this.buildInitialUrl('components');\n const res = await this.fetch<SPComponent[]>(url, 'components', signal);\n const items = res.body;\n const next =\n items.length < PAGE_SIZE\n ? null\n : this.buildNextPageUrl('components', url);\n return { items, next };\n }\n\n private async fetchIncidentsPage(\n page: string | null,\n options: SyncOptions,\n signal: AbortSignal | undefined,\n ): Promise<{ items: IncidentBatchItem[]; next: string | null }> {\n const url = page ?? this.buildInitialUrl('incidents');\n const res = await this.fetch<SPIncident[]>(url, 'incidents', signal);\n const incidents = res.body;\n const sinceMs = this.computeIncidentSinceMs(options);\n\n // Incidents are returned newest-first by updated_at. Short-circuit\n // pagination once a page is entirely older than the sinceMs floor.\n const incidentTimestampMs = (inc: SPIncident): number | null => {\n const stamp = inc.updated_at ?? inc.created_at;\n const ms = stamp ? Date.parse(stamp) : Number.NaN;\n return Number.isFinite(ms) ? ms : null;\n };\n\n const last = incidents.at(-1);\n const lastMs = last ? incidentTimestampMs(last) : null;\n const cutoffReached = lastMs !== null && lastMs < sinceMs;\n\n const filtered = incidents.filter((inc) => {\n const ms = incidentTimestampMs(inc);\n return ms === null ? true : ms >= sinceMs;\n });\n\n const next =\n cutoffReached || incidents.length < PAGE_SIZE\n ? null\n : this.buildNextPageUrl('incidents', url);\n\n return {\n items: filtered.map((incident) => ({ incident })),\n next,\n };\n }\n\n // -------------------------------------------------------------------------\n // Writers\n // -------------------------------------------------------------------------\n\n private parseTimestampMs(stamp: string | null | undefined): number | null {\n if (!stamp) {\n return null;\n }\n const ms = Date.parse(stamp);\n return Number.isFinite(ms) ? ms : null;\n }\n\n private async writeComponents(\n storage: StorageHandle,\n components: SPComponent[],\n ): Promise<void> {\n for (const c of components) {\n const updatedAt =\n this.parseTimestampMs(c.updated_at) ??\n this.parseTimestampMs(c.created_at) ??\n Date.now();\n await storage.entity({\n type: 'statuspage_component',\n id: c.id,\n attributes: {\n name: c.name,\n description: c.description ?? null,\n status: c.status,\n groupId: c.group_id ?? null,\n group: c.group ?? false,\n showcase: c.showcase ?? false,\n onlyShowIfDegraded: c.only_show_if_degraded ?? false,\n position: c.position ?? null,\n startDate: c.start_date ?? null,\n createdAt: this.parseTimestampMs(c.created_at),\n },\n updated_at: updatedAt,\n });\n }\n }\n\n private async writeIncidents(\n storage: StorageHandle,\n items: IncidentBatchItem[],\n ): Promise<void> {\n for (const { incident } of items) {\n const createdAtMs = this.parseTimestampMs(incident.created_at);\n const updatedAtMs = this.parseTimestampMs(incident.updated_at);\n const resolvedAtMs = this.parseTimestampMs(incident.resolved_at);\n const monitoringAtMs = this.parseTimestampMs(incident.monitoring_at);\n const componentIds = (incident.components ?? []).map((c) => c.id);\n const componentSummary: Record<string, JSONValue> = {};\n for (const c of incident.components ?? []) {\n componentSummary[c.id] = {\n name: c.name ?? null,\n status: c.status ?? null,\n };\n }\n await storage.entity({\n type: 'statuspage_incident',\n id: incident.id,\n attributes: {\n name: incident.name,\n status: incident.status,\n impact: incident.impact,\n componentIds,\n components: componentSummary,\n createdAt: createdAtMs,\n monitoringAt: monitoringAtMs,\n resolvedAt: resolvedAtMs,\n scheduledFor: this.parseTimestampMs(incident.scheduled_for),\n scheduledUntil: this.parseTimestampMs(incident.scheduled_until),\n shortlink: incident.shortlink ?? null,\n },\n updated_at: updatedAtMs ?? createdAtMs ?? Date.now(),\n });\n }\n }\n\n private async writeIncidentUpdates(\n storage: StorageHandle,\n items: IncidentBatchItem[],\n sinceMs: number,\n ): Promise<void> {\n for (const { incident } of items) {\n for (const upd of incident.incident_updates ?? []) {\n const tsMs =\n this.parseTimestampMs(upd.display_at) ??\n this.parseTimestampMs(upd.created_at);\n if (tsMs === null || tsMs < sinceMs) {\n continue;\n }\n await storage.event({\n name: 'statuspage_incident_update',\n start_ts: tsMs,\n end_ts: null,\n attributes: {\n updateId: upd.id,\n incidentId: upd.incident_id,\n incidentName: incident.name,\n status: upd.status,\n body: upd.body,\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 = this.resolveCursor(options.cursor);\n const isFull = options.mode === 'full';\n const phases = this.activePhases();\n const incidentSinceMs = this.computeIncidentSinceMs(options);\n\n return paginateChunked<StatuspagePhase, string>({\n phases,\n cursor,\n signal,\n logger: this.logger,\n fetchPage: async (phase, page, sig) => {\n switch (phase) {\n case 'components':\n return this.fetchComponentsPage(page, sig);\n case 'incidents':\n return this.fetchIncidentsPage(page, options, sig);\n }\n },\n writeBatch: async (phase, items, page) => {\n if (isFull && page === null) {\n switch (phase) {\n case 'components':\n if (this.isResourceEnabled('components')) {\n await storage.entities([], {\n types: ['statuspage_component'],\n });\n }\n break;\n case 'incidents':\n if (this.isResourceEnabled('incidents')) {\n await storage.entities([], {\n types: ['statuspage_incident'],\n });\n }\n if (this.isResourceEnabled('incident_updates')) {\n await storage.events([], {\n names: ['statuspage_incident_update'],\n });\n }\n break;\n }\n }\n switch (phase) {\n case 'components':\n if (!this.isResourceEnabled('components')) {\n return;\n }\n return this.writeComponents(storage, items as SPComponent[]);\n case 'incidents': {\n const batch = items as IncidentBatchItem[];\n if (this.isResourceEnabled('incidents')) {\n await this.writeIncidents(storage, batch);\n }\n if (this.isResourceEnabled('incident_updates')) {\n await this.writeIncidentUpdates(storage, batch, incidentSinceMs);\n }\n return;\n }\n }\n },\n });\n }\n}\n","import { StatuspageConnector } from './statuspage';\n\nexport {\n configFields,\n doc,\n StatuspageConnector,\n statuspageResources as resources,\n id,\n} from './statuspage';\nexport type { StatuspageResource, StatuspageSettings } from './statuspage';\nexport default StatuspageConnector;\n"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;AAAA,YACb,KAAK;AACH,kBAAI,KAAK,kBAAkB,YAAY,GAAG;AACxC,sBAAM,QAAQ,SAAS,CAAC,GAAG;AAAA,kBACzB,OAAO,CAAC,sBAAsB;AAAA,gBAChC,CAAC;AAAA,cACH;AACA;AAAA,YACF,KAAK;AACH,kBAAI,KAAK,kBAAkB,WAAW,GAAG;AACvC,sBAAM,QAAQ,SAAS,CAAC,GAAG;AAAA,kBACzB,OAAO,CAAC,qBAAqB;AAAA,gBAC/B,CAAC;AAAA,cACH;AACA,kBAAI,KAAK,kBAAkB,kBAAkB,GAAG;AAC9C,sBAAM,QAAQ,OAAO,CAAC,GAAG;AAAA,kBACvB,OAAO,CAAC,4BAA4B;AAAA,gBACtC,CAAC;AAAA,cACH;AACA;AAAA,UACJ;AAAA,QACF;AACA,gBAAQ,OAAO;AAAA,UACb,KAAK;AACH,gBAAI,CAAC,KAAK,kBAAkB,YAAY,GAAG;AACzC;AAAA,YACF;AACA,mBAAO,KAAK,gBAAgB,SAAS,KAAsB;AAAA,UAC7D,KAAK,aAAa;AAChB,kBAAM,QAAQ;AACd,gBAAI,KAAK,kBAAkB,WAAW,GAAG;AACvC,oBAAM,KAAK,eAAe,SAAS,KAAK;AAAA,YAC1C;AACA,gBAAI,KAAK,kBAAkB,kBAAkB,GAAG;AAC9C,oBAAM,KAAK,qBAAqB,SAAS,OAAO,eAAe;AAAA,YACjE;AACA;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AACF;;;AC1tBA,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/map-concurrent.ts","../../../connector-shared/src/sanitize.ts","../../../connector-shared/src/epoch.ts","../../../connector-shared/src/pagination.ts","../../../connector-shared/src/logger.ts","../src/statuspage.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 async function mapWithConcurrency<T, R>(\n items: readonly T[],\n concurrency: number,\n fn: (item: T, index: number) => Promise<R>,\n): Promise<R[]> {\n const results = new Array<R>(items.length);\n if (items.length === 0) {\n return results;\n }\n const normalized = Number.isFinite(concurrency) ? Math.floor(concurrency) : 1;\n const limit = Math.max(1, Math.min(normalized, items.length));\n let next = 0;\n let failed = false;\n\n async function worker(): Promise<void> {\n while (!failed) {\n const i = next++;\n if (i >= items.length) {\n return;\n }\n try {\n results[i] = await fn(items[i]!, i);\n } catch (err) {\n failed = true;\n throw err;\n }\n }\n }\n\n const workers: Promise<void>[] = [];\n for (let w = 0; w < limit; w++) {\n workers.push(worker());\n }\n await Promise.all(workers);\n return results;\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 sanitizeAllowedUrl,\n} from '@rawdash/connector-shared';\nimport {\n BaseConnector,\n type ChunkedSyncCursor,\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 apiKey: z.object({ $secret: z.string() }).meta({\n label: 'API Key',\n description:\n 'Statuspage REST API key. Create one at Manage Account -> API Info -> API Key.',\n placeholder: 'sk_live_...',\n secret: true,\n }),\n pageId: z\n .string()\n .trim()\n .regex(/^[A-Za-z0-9]{12}$/, 'Page ID must be 12 alphanumeric characters.')\n .meta({\n label: 'Page ID',\n description:\n 'Statuspage page id (the 12-character identifier shown next to your page name in Manage Account -> API Info, also visible in the admin URL).',\n placeholder: 'abc123def456',\n }),\n resources: z\n .array(z.enum(['components', 'incidents', 'incident_updates']))\n .nonempty()\n .optional()\n .meta({\n label: 'Resources',\n description:\n \"Which Statuspage resources to sync. Omit to sync all of them. 'incident_updates' rides the 'incidents' phase - enabling it without 'incidents' still fetches incidents but skips writing incident entities.\",\n }),\n incidentLookbackDays: z.number().int().positive().max(365).optional().meta({\n label: 'Incident lookback (days)',\n description:\n 'How many days back to fetch incidents (and their updates) on a full sync. Defaults to 90. Statuspage returns incidents newest-first; this caps the backfill window.',\n placeholder: '90',\n }),\n }),\n);\n\nexport const doc: ConnectorDoc = defineConnectorDoc({\n displayName: 'Statuspage',\n category: 'engineering',\n brandColor: '#172B4D',\n tagline:\n 'Sync Atlassian Statuspage components, incidents, and incident updates - current component health, recent incident history, and per-update status transitions.',\n vendor: {\n name: 'Atlassian Statuspage',\n apiDocs: 'https://developer.statuspage.io/',\n website: 'https://www.atlassian.com/software/statuspage',\n },\n auth: {\n summary:\n 'A Statuspage REST API key is required. Keys are scoped to the issuing account and inherit that account read access; a read-only role is sufficient for the resources synced here.',\n setup: [\n 'Open Statuspage -> Manage Account -> API Info.',\n 'Copy the API Key (or generate one if none exists).',\n 'Store the key as a secret and reference it from the connector config as `apiKey: secret(\"STATUSPAGE_API_KEY\")`.',\n 'Set `pageId` to your 12-character Page ID (shown on the same screen, e.g. `abc123def456`).',\n ],\n },\n rateLimit:\n 'Statuspage rate-limits at roughly 1 request/second per page; this connector paginates sequentially and respects 429 Retry-After. The page size is 100.',\n limitations: [\n 'Better Stack Uptime is a separate package and is tracked as a follow-up.',\n 'Postmortem bodies, subscribers, metrics-provider configs, and template management are out of scope.',\n 'Component groups are exposed via each component group_id but are not synced as separate entities.',\n ],\n});\n\nexport type StatuspageResource =\n | 'components'\n | 'incidents'\n | 'incident_updates';\n\nexport interface StatuspageSettings {\n pageId: string;\n resources?: readonly StatuspageResource[];\n incidentLookbackDays?: number;\n}\n\nconst statuspageCredentials = {\n apiKey: {\n description: 'Statuspage REST API key',\n auth: 'required' as const,\n },\n} satisfies CredentialsSchema;\n\ntype StatuspageCredentials = typeof statuspageCredentials;\n\n// ---------------------------------------------------------------------------\n// Sync phases + cursor\n// ---------------------------------------------------------------------------\n\nconst PHASE_ORDER = ['components', 'incidents'] as const;\n\ntype StatuspagePhase = (typeof PHASE_ORDER)[number];\n\ntype StatuspageSyncCursor = ChunkedSyncCursor<StatuspagePhase, string>;\n\nconst isStatuspageSyncCursor = makeChunkedCursorGuard(PHASE_ORDER);\n\n// ---------------------------------------------------------------------------\n// Statuspage API types\n// ---------------------------------------------------------------------------\n\ninterface SPComponent {\n id: string;\n page_id: string;\n group_id?: string | null;\n name: string;\n description?: string | null;\n status: string;\n position?: number;\n showcase?: boolean;\n start_date?: string | null;\n group?: boolean;\n only_show_if_degraded?: boolean;\n automation_email?: string | null;\n created_at?: string;\n updated_at?: string;\n}\n\ninterface SPIncidentUpdate {\n id: string;\n incident_id: string;\n status: string;\n body: string;\n display_at?: string | null;\n created_at: string;\n updated_at?: string | null;\n affected_components?: unknown;\n}\n\ninterface SPIncident {\n id: string;\n name: string;\n status: string;\n impact: string;\n page_id?: string;\n shortlink?: string | null;\n created_at: string;\n updated_at?: string | null;\n monitoring_at?: string | null;\n resolved_at?: string | null;\n scheduled_for?: string | null;\n scheduled_until?: string | null;\n components?: Array<{ id: string; name?: string; status?: string }>;\n incident_updates?: SPIncidentUpdate[];\n}\n\n// ---------------------------------------------------------------------------\n// Schemas - describe the per-resource API response shape consumed by request()\n// ---------------------------------------------------------------------------\n\nconst idString = z.string().min(1);\n\nconst componentSchema = z.object({\n id: idString,\n page_id: idString,\n group_id: z.string().nullable().optional(),\n name: z.string(),\n description: z.string().nullable().optional(),\n status: z.string(),\n position: z.number().int().nonnegative().optional(),\n showcase: z.boolean().optional(),\n start_date: z.string().nullable().optional(),\n group: z.boolean().optional(),\n only_show_if_degraded: z.boolean().optional(),\n automation_email: z.string().nullable().optional(),\n created_at: z.string().optional(),\n updated_at: z.string().optional(),\n});\n\nconst componentsResponseSchema = z.array(componentSchema);\n\nconst incidentUpdateSchema = z.object({\n id: idString,\n incident_id: idString,\n status: z.string(),\n body: z.string(),\n display_at: z.string().nullable().optional(),\n created_at: z.string(),\n updated_at: z.string().nullable().optional(),\n affected_components: z.unknown().optional(),\n});\n\nconst incidentSchema = z.object({\n id: idString,\n name: z.string(),\n status: z.string(),\n impact: z.string(),\n page_id: z.string().optional(),\n shortlink: z.string().nullable().optional(),\n created_at: z.string(),\n updated_at: z.string().nullable().optional(),\n monitoring_at: z.string().nullable().optional(),\n resolved_at: z.string().nullable().optional(),\n scheduled_for: z.string().nullable().optional(),\n scheduled_until: z.string().nullable().optional(),\n components: z\n .array(\n z.object({\n id: idString,\n name: z.string().optional(),\n status: z.string().optional(),\n }),\n )\n .optional(),\n incident_updates: z.array(incidentUpdateSchema).optional(),\n});\n\nconst incidentsResponseSchema = z.array(incidentSchema);\n\n// ---------------------------------------------------------------------------\n// Resource definitions\n// ---------------------------------------------------------------------------\n\nexport const statuspageResources = defineResources({\n statuspage_component: {\n shape: 'entity',\n description:\n 'Statuspage components (the things on a status page that turn red), with current status, group membership, and whether they are hidden until degraded.',\n endpoint: 'GET /v1/pages/{page_id}/components',\n fields: [\n { name: 'name', description: 'Component display name.' },\n {\n name: 'status',\n description:\n 'Current health: operational | under_maintenance | degraded_performance | partial_outage | major_outage.',\n },\n {\n name: 'groupId',\n description:\n 'Parent component-group id, or null if the component is top-level.',\n },\n {\n name: 'group',\n description: 'True if this row is itself a component group.',\n },\n {\n name: 'showcase',\n description: 'Whether the component is shown on the public page.',\n },\n {\n name: 'onlyShowIfDegraded',\n description:\n 'When true the component is hidden on the public page while operational.',\n },\n {\n name: 'position',\n description: 'Sort position within the page or group.',\n },\n ],\n responses: { components: componentsResponseSchema },\n },\n statuspage_incident: {\n shape: 'entity',\n description:\n 'Statuspage incidents (realtime outages plus maintenance windows) with status, impact, affected components, and the created / monitoring / resolved timestamps.',\n endpoint: 'GET /v1/pages/{page_id}/incidents',\n notes:\n 'Returned newest-first by updated_at; bounded by the incident lookback window (default 90 days) and tightened to options.since on incremental syncs.',\n fields: [\n { name: 'name', description: 'Incident title.' },\n {\n name: 'status',\n description:\n 'Realtime status (investigating | identified | monitoring | resolved | postmortem) or maintenance status (scheduled | in_progress | verifying | completed).',\n },\n {\n name: 'impact',\n description:\n 'Reported impact: none | maintenance | minor | major | critical.',\n },\n {\n name: 'componentIds',\n description: 'Ids of components currently attached to the incident.',\n },\n {\n name: 'createdAt',\n description: 'Incident creation timestamp (epoch ms).',\n },\n {\n name: 'resolvedAt',\n description:\n 'Resolved timestamp (epoch ms), or null while the incident is open.',\n },\n {\n name: 'shortlink',\n description: 'Public-facing short URL for the incident.',\n },\n ],\n responses: { incidents: incidentsResponseSchema },\n },\n statuspage_incident_update: {\n shape: 'event',\n description:\n 'Per-update transitions inside an incident timeline (each comment / status flip). Emitted at display_at (falling back to created_at).',\n endpoint: 'GET /v1/pages/{page_id}/incidents',\n notes:\n 'Derived from the inline incident_updates array on each incident; Statuspage does not expose a separate list endpoint.',\n fields: [\n { name: 'updateId', description: 'Incident-update id.' },\n {\n name: 'incidentId',\n description: 'Parent incident id.',\n },\n {\n name: 'status',\n description: 'Status the incident moved to at this update.',\n },\n {\n name: 'body',\n description: 'Free-form message posted on the update.',\n },\n ],\n },\n});\n\n// ---------------------------------------------------------------------------\n// StatuspageConnector\n// ---------------------------------------------------------------------------\n\nconst SP_API_HOST = 'api.statuspage.io';\nconst SP_API_BASE = `https://${SP_API_HOST}`;\nconst PAGE_SIZE = 100;\nconst DEFAULT_INCIDENT_LOOKBACK_DAYS = 90;\nconst MS_PER_DAY = 24 * 60 * 60 * 1000;\n\nexport const id = 'statuspage';\n\ninterface IncidentBatchItem {\n incident: SPIncident;\n}\n\nexport class StatuspageConnector extends BaseConnector<\n StatuspageSettings,\n StatuspageCredentials\n> {\n static readonly id = id;\n\n static readonly resources = statuspageResources;\n\n static readonly schemas = schemasFromResources(statuspageResources);\n\n static create(input: unknown, ctx?: ConnectorContext): StatuspageConnector {\n const parsed = configFields.parse(input);\n return new StatuspageConnector(\n {\n pageId: parsed.pageId,\n resources: parsed.resources,\n incidentLookbackDays: parsed.incidentLookbackDays,\n },\n { apiKey: parsed.apiKey },\n ctx,\n );\n }\n\n readonly id = id;\n override readonly credentials = statuspageCredentials;\n\n private buildHeaders(): Record<string, string> {\n return {\n Authorization: `OAuth ${this.creds.apiKey}`,\n Accept: 'application/json',\n 'User-Agent': connectorUserAgent('statuspage'),\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(): StatuspagePhase[] {\n return selectActivePhases<StatuspageResource, StatuspagePhase>(\n (r) => {\n switch (r) {\n case 'components':\n return 'components';\n case 'incidents':\n case 'incident_updates':\n return 'incidents';\n }\n },\n PHASE_ORDER,\n this.settings.resources,\n );\n }\n\n // -------------------------------------------------------------------------\n // URL building + sanitization\n // -------------------------------------------------------------------------\n\n private allowedPagePath(phase: StatuspagePhase): string {\n switch (phase) {\n case 'components':\n return `/v1/pages/${this.settings.pageId}/components`;\n case 'incidents':\n return `/v1/pages/${this.settings.pageId}/incidents`;\n }\n }\n\n private sanitizePageUrl(\n phase: StatuspagePhase,\n pageUrl: string | null,\n ): string | null {\n if (pageUrl === null) {\n return null;\n }\n return sanitizeAllowedUrl({\n url: pageUrl,\n host: SP_API_HOST,\n pathname: this.allowedPagePath(phase),\n });\n }\n\n private resolveCursor(cursor: unknown): StatuspageSyncCursor | undefined {\n if (!isStatuspageSyncCursor(cursor)) {\n return undefined;\n }\n return {\n phase: cursor.phase,\n page: this.sanitizePageUrl(cursor.phase, cursor.page),\n };\n }\n\n private buildInitialUrl(phase: StatuspagePhase): string {\n const u = new URL(`${SP_API_BASE}${this.allowedPagePath(phase)}`);\n u.searchParams.set('page', '1');\n u.searchParams.set('per_page', String(PAGE_SIZE));\n return u.toString();\n }\n\n private buildNextPageUrl(\n phase: StatuspagePhase,\n currentUrl: string,\n ): string | null {\n let u: URL;\n try {\n u = new URL(currentUrl);\n } catch {\n return null;\n }\n const pageRaw = u.searchParams.get('page');\n const pageNum = pageRaw === null ? 1 : Number.parseInt(pageRaw, 10);\n if (!Number.isFinite(pageNum) || pageNum < 1) {\n return null;\n }\n u.searchParams.set('page', String(pageNum + 1));\n u.searchParams.set('per_page', String(PAGE_SIZE));\n return this.sanitizePageUrl(phase, u.toString());\n }\n\n private computeIncidentSinceMs(options: SyncOptions): number {\n if (options.since) {\n const ms = parseEpoch(options.since, 'iso');\n if (ms !== null) {\n return ms;\n }\n }\n const days =\n this.settings.incidentLookbackDays ?? DEFAULT_INCIDENT_LOOKBACK_DAYS;\n return Date.now() - days * MS_PER_DAY;\n }\n\n // -------------------------------------------------------------------------\n // Fetchers\n // -------------------------------------------------------------------------\n\n private async fetchComponentsPage(\n page: string | null,\n signal: AbortSignal | undefined,\n ): Promise<{ items: SPComponent[]; next: string | null }> {\n const url = page ?? this.buildInitialUrl('components');\n const res = await this.fetch<SPComponent[]>(url, 'components', signal);\n const items = res.body;\n const next =\n items.length < PAGE_SIZE\n ? null\n : this.buildNextPageUrl('components', url);\n return { items, next };\n }\n\n private async fetchIncidentsPage(\n page: string | null,\n sinceMs: number,\n signal: AbortSignal | undefined,\n ): Promise<{ items: IncidentBatchItem[]; next: string | null }> {\n const url = page ?? this.buildInitialUrl('incidents');\n const res = await this.fetch<SPIncident[]>(url, 'incidents', signal);\n const incidents = res.body;\n\n // Incidents are returned newest-first by updated_at. Short-circuit\n // pagination once a page is entirely older than the sinceMs floor.\n const incidentTimestampMs = (inc: SPIncident): number | null => {\n const stamp = inc.updated_at ?? inc.created_at;\n const ms = stamp ? Date.parse(stamp) : Number.NaN;\n return Number.isFinite(ms) ? ms : null;\n };\n\n const last = incidents.at(-1);\n const lastMs = last ? incidentTimestampMs(last) : null;\n const cutoffReached = lastMs !== null && lastMs < sinceMs;\n\n const filtered = incidents.filter((inc) => {\n const ms = incidentTimestampMs(inc);\n return ms === null ? true : ms >= sinceMs;\n });\n\n const next =\n cutoffReached || incidents.length < PAGE_SIZE\n ? null\n : this.buildNextPageUrl('incidents', url);\n\n return {\n items: filtered.map((incident) => ({ incident })),\n next,\n };\n }\n\n // -------------------------------------------------------------------------\n // Writers\n // -------------------------------------------------------------------------\n\n private parseTimestampMs(stamp: string | null | undefined): number | null {\n if (!stamp) {\n return null;\n }\n const ms = Date.parse(stamp);\n return Number.isFinite(ms) ? ms : null;\n }\n\n private async writeComponents(\n storage: StorageHandle,\n components: SPComponent[],\n ): Promise<void> {\n for (const c of components) {\n const updatedAt =\n this.parseTimestampMs(c.updated_at) ??\n this.parseTimestampMs(c.created_at) ??\n Date.now();\n await storage.entity({\n type: 'statuspage_component',\n id: c.id,\n attributes: {\n name: c.name,\n description: c.description ?? null,\n status: c.status,\n groupId: c.group_id ?? null,\n group: c.group ?? false,\n showcase: c.showcase ?? false,\n onlyShowIfDegraded: c.only_show_if_degraded ?? false,\n position: c.position ?? null,\n startDate: c.start_date ?? null,\n createdAt: this.parseTimestampMs(c.created_at),\n },\n updated_at: updatedAt,\n });\n }\n }\n\n private async writeIncidents(\n storage: StorageHandle,\n items: IncidentBatchItem[],\n ): Promise<void> {\n for (const { incident } of items) {\n const createdAtMs = this.parseTimestampMs(incident.created_at);\n const updatedAtMs = this.parseTimestampMs(incident.updated_at);\n const resolvedAtMs = this.parseTimestampMs(incident.resolved_at);\n const monitoringAtMs = this.parseTimestampMs(incident.monitoring_at);\n const componentIds = (incident.components ?? []).map((c) => c.id);\n const componentSummary: Record<string, JSONValue> = {};\n for (const c of incident.components ?? []) {\n componentSummary[c.id] = {\n name: c.name ?? null,\n status: c.status ?? null,\n };\n }\n await storage.entity({\n type: 'statuspage_incident',\n id: incident.id,\n attributes: {\n name: incident.name,\n status: incident.status,\n impact: incident.impact,\n componentIds,\n components: componentSummary,\n createdAt: createdAtMs,\n monitoringAt: monitoringAtMs,\n resolvedAt: resolvedAtMs,\n scheduledFor: this.parseTimestampMs(incident.scheduled_for),\n scheduledUntil: this.parseTimestampMs(incident.scheduled_until),\n shortlink: incident.shortlink ?? null,\n },\n updated_at: updatedAtMs ?? createdAtMs ?? Date.now(),\n });\n }\n }\n\n private async writeIncidentUpdates(\n storage: StorageHandle,\n items: IncidentBatchItem[],\n sinceMs: number,\n ): Promise<void> {\n for (const { incident } of items) {\n for (const upd of incident.incident_updates ?? []) {\n const tsMs =\n this.parseTimestampMs(upd.display_at) ??\n this.parseTimestampMs(upd.created_at);\n if (tsMs === null || tsMs < sinceMs) {\n continue;\n }\n await storage.event({\n name: 'statuspage_incident_update',\n start_ts: tsMs,\n end_ts: null,\n attributes: {\n updateId: upd.id,\n incidentId: upd.incident_id,\n incidentName: incident.name,\n status: upd.status,\n body: upd.body,\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 = this.resolveCursor(options.cursor);\n const isFull = options.mode === 'full';\n const phases = this.activePhases();\n const incidentSinceMs = this.computeIncidentSinceMs(options);\n\n return paginateChunked<StatuspagePhase, string>({\n phases,\n cursor,\n signal,\n logger: this.logger,\n fetchPage: async (phase, page, sig) => {\n switch (phase) {\n case 'components':\n return this.fetchComponentsPage(page, sig);\n case 'incidents':\n return this.fetchIncidentsPage(page, incidentSinceMs, sig);\n }\n },\n writeBatch: async (phase, items, page) => {\n if (isFull && page === null) {\n switch (phase) {\n case 'components':\n if (this.isResourceEnabled('components')) {\n await storage.entities([], {\n types: ['statuspage_component'],\n });\n }\n break;\n case 'incidents':\n if (this.isResourceEnabled('incidents')) {\n await storage.entities([], {\n types: ['statuspage_incident'],\n });\n }\n if (this.isResourceEnabled('incident_updates')) {\n await storage.events([], {\n names: ['statuspage_incident_update'],\n });\n }\n break;\n }\n }\n switch (phase) {\n case 'components':\n if (!this.isResourceEnabled('components')) {\n return;\n }\n return this.writeComponents(storage, items as SPComponent[]);\n case 'incidents': {\n const batch = items as IncidentBatchItem[];\n if (this.isResourceEnabled('incidents')) {\n await this.writeIncidents(storage, batch);\n }\n if (this.isResourceEnabled('incident_updates')) {\n await this.writeIncidentUpdates(storage, batch, incidentSinceMs);\n }\n return;\n }\n }\n },\n });\n }\n}\n","import { StatuspageConnector } from './statuspage';\n\nexport {\n configFields,\n doc,\n StatuspageConnector,\n statuspageResources as resources,\n id,\n} from './statuspage';\nexport type { StatuspageResource, StatuspageSettings } from './statuspage';\nexport default StatuspageConnector;\n"],"mappings":";AEAO,IAAM,sBAAsB;AAE5B,IAAM,qBAAqB,qBAAqB,mBAAmB;AAEnE,SAAS,mBAAmB,aAA6B;AAC9D,SAAO,qBAAqB,WAAW,IAAI,mBAAmB;AAChE;AICO,SAAS,mBACd,SACe;AACf,QAAM,EAAE,KAAK,MAAM,UAAU,WAAW,SAAS,IAAI;AACrD,MAAI,QAAQ,MAAM;AAChB,WAAO;EACT;AACA,MAAI;AACF,UAAM,IAAI,IAAI,IAAI,GAAG;AACrB,QAAI,EAAE,aAAa,YAAY,EAAE,SAAS,QAAQ,EAAE,aAAa,UAAU;AACzE,aAAO;IACT;AACA,WAAO,EAAE,SAAS;EACpB,QAAQ;AACN,WAAO;EACT;AACF;ACrBO,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;;;AGnBA;AAAA,EACE;AAAA,EASA;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,QAA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YAAI,UAAU,SAAS,MAAM;AAC3B,kBAAQ,OAAO;AAAA,YACb,KAAK;AACH,kBAAI,KAAK,kBAAkB,YAAY,GAAG;AACxC,sBAAM,QAAQ,SAAS,CAAC,GAAG;AAAA,kBACzB,OAAO,CAAC,sBAAsB;AAAA,gBAChC,CAAC;AAAA,cACH;AACA;AAAA,YACF,KAAK;AACH,kBAAI,KAAK,kBAAkB,WAAW,GAAG;AACvC,sBAAM,QAAQ,SAAS,CAAC,GAAG;AAAA,kBACzB,OAAO,CAAC,qBAAqB;AAAA,gBAC/B,CAAC;AAAA,cACH;AACA,kBAAI,KAAK,kBAAkB,kBAAkB,GAAG;AAC9C,sBAAM,QAAQ,OAAO,CAAC,GAAG;AAAA,kBACvB,OAAO,CAAC,4BAA4B;AAAA,gBACtC,CAAC;AAAA,cACH;AACA;AAAA,UACJ;AAAA,QACF;AACA,gBAAQ,OAAO;AAAA,UACb,KAAK;AACH,gBAAI,CAAC,KAAK,kBAAkB,YAAY,GAAG;AACzC;AAAA,YACF;AACA,mBAAO,KAAK,gBAAgB,SAAS,KAAsB;AAAA,UAC7D,KAAK,aAAa;AAChB,kBAAM,QAAQ;AACd,gBAAI,KAAK,kBAAkB,WAAW,GAAG;AACvC,oBAAM,KAAK,eAAe,SAAS,KAAK;AAAA,YAC1C;AACA,gBAAI,KAAK,kBAAkB,kBAAkB,GAAG;AAC9C,oBAAM,KAAK,qBAAqB,SAAS,OAAO,eAAe;AAAA,YACjE;AACA;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AACF;;;ACztBA,IAAO,gBAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rawdash/connector-statuspage",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "Rawdash connector for Atlassian Statuspage - components, incidents, and incident updates",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -22,22 +22,22 @@
|
|
|
22
22
|
"import": "./dist/index.js"
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
|
-
"scripts": {
|
|
26
|
-
"build": "tsup",
|
|
27
|
-
"typecheck": "tsc --noEmit",
|
|
28
|
-
"lint": "eslint src",
|
|
29
|
-
"test": "vitest run"
|
|
30
|
-
},
|
|
31
25
|
"dependencies": {
|
|
32
|
-
"
|
|
33
|
-
"
|
|
26
|
+
"zod": "^4.4.3",
|
|
27
|
+
"@rawdash/core": "0.20.0"
|
|
34
28
|
},
|
|
35
29
|
"devDependencies": {
|
|
36
|
-
"@rawdash/connector-shared": "workspace:*",
|
|
37
|
-
"@rawdash/connector-test-utils": "workspace:*",
|
|
38
30
|
"fast-check": "^4.8.0",
|
|
39
31
|
"tsup": "^8.0.0",
|
|
40
32
|
"typescript": "^5.7.2",
|
|
41
|
-
"vitest": "^4.1.4"
|
|
33
|
+
"vitest": "^4.1.4",
|
|
34
|
+
"@rawdash/connector-shared": "0.3.1",
|
|
35
|
+
"@rawdash/connector-test-utils": "0.0.7"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsup",
|
|
39
|
+
"typecheck": "tsc --noEmit",
|
|
40
|
+
"lint": "eslint src",
|
|
41
|
+
"test": "vitest run"
|
|
42
42
|
}
|
|
43
|
-
}
|
|
43
|
+
}
|