forges 0.0.0 → 0.1.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.
Files changed (152) hide show
  1. package/LICENCE +21 -0
  2. package/README.md +72 -0
  3. package/dist/azure-devops/index.d.mts +2 -0
  4. package/dist/azure-devops/index.mjs +1 -0
  5. package/dist/azure-devops-DwQvL4TV.mjs +1355 -0
  6. package/dist/bitbucket/index.d.mts +2 -0
  7. package/dist/bitbucket/index.mjs +1 -0
  8. package/dist/bitbucket-CpcfJlYi.mjs +1171 -0
  9. package/dist/crypto-CQNEyYHD.mjs +156 -0
  10. package/dist/cursor-origin/index.d.mts +2 -0
  11. package/dist/cursor-origin/index.mjs +1 -0
  12. package/dist/cursor-origin-BhqYx2oW.mjs +980 -0
  13. package/dist/define-B2_4ob2i.d.mts +307 -0
  14. package/dist/define-D3yEXtKK.mjs +2276 -0
  15. package/dist/env.d.mts +46 -0
  16. package/dist/env.mjs +283 -0
  17. package/dist/fake/index.d.mts +227 -0
  18. package/dist/fake/index.mjs +1001 -0
  19. package/dist/fetch-D4pSRvvA.d.mts +1723 -0
  20. package/dist/forgejo/index.d.mts +2 -0
  21. package/dist/forgejo/index.mjs +1 -0
  22. package/dist/forgejo-BCefbHUN.mjs +2005 -0
  23. package/dist/gitea/index.d.mts +2 -0
  24. package/dist/gitea/index.mjs +22 -0
  25. package/dist/gitee/index.d.mts +2 -0
  26. package/dist/gitee/index.mjs +1 -0
  27. package/dist/gitee-CA-f7Rs8.mjs +1272 -0
  28. package/dist/github/index.d.mts +2 -0
  29. package/dist/github/index.mjs +1 -0
  30. package/dist/github-B0umL8_f.mjs +3259 -0
  31. package/dist/gitlab/index.d.mts +2 -0
  32. package/dist/gitlab/index.mjs +1 -0
  33. package/dist/gitlab-Bsr__Z0C.mjs +2378 -0
  34. package/dist/graphql-D7uGzZTf.mjs +366 -0
  35. package/dist/index-BQ6VS31s.d.mts +32 -0
  36. package/dist/index-C-jz9Mo3.d.mts +16 -0
  37. package/dist/index-C4fYzmK3.d.mts +102 -0
  38. package/dist/index-CQiIX4SH.d.mts +27 -0
  39. package/dist/index-CTj5gQzl.d.mts +35 -0
  40. package/dist/index-CliBWzOF.d.mts +23 -0
  41. package/dist/index-Cz_y-t3d.d.mts +36 -0
  42. package/dist/index-DEt25E1w.d.mts +77 -0
  43. package/dist/index-DIuS0EOy.d.mts +43 -0
  44. package/dist/index-uSpsMCrC.d.mts +26 -0
  45. package/dist/index.d.mts +41 -0
  46. package/dist/index.mjs +13 -0
  47. package/dist/kit.d.mts +183 -0
  48. package/dist/kit.mjs +4 -0
  49. package/dist/provider-CoZ7cCxp.d.mts +1439 -0
  50. package/dist/provider-Ed1YhkQN.mjs +169 -0
  51. package/dist/pushin/index.d.mts +2 -0
  52. package/dist/pushin/index.mjs +1 -0
  53. package/dist/pushin-CkxgJ2cU.mjs +343 -0
  54. package/dist/schema/Actor.json +96 -0
  55. package/dist/schema/AlertSupport.json +49 -0
  56. package/dist/schema/AuthKind.json +15 -0
  57. package/dist/schema/Branch.json +31 -0
  58. package/dist/schema/ChangedFile.json +58 -0
  59. package/dist/schema/Check.json +169 -0
  60. package/dist/schema/CheckRef.json +114 -0
  61. package/dist/schema/CheckState.json +14 -0
  62. package/dist/schema/ChecksSummary.json +34 -0
  63. package/dist/schema/CiJob.json +186 -0
  64. package/dist/schema/CiJobRef.json +132 -0
  65. package/dist/schema/CiRun.json +234 -0
  66. package/dist/schema/CiRunRef.json +103 -0
  67. package/dist/schema/CodeFragment.json +19 -0
  68. package/dist/schema/CodeMatch.json +128 -0
  69. package/dist/schema/Collaborator.json +169 -0
  70. package/dist/schema/Comment.json +336 -0
  71. package/dist/schema/CommentRef.json +158 -0
  72. package/dist/schema/Commit.json +307 -0
  73. package/dist/schema/CommitRef.json +104 -0
  74. package/dist/schema/CommitSignature.json +118 -0
  75. package/dist/schema/Comparison.json +355 -0
  76. package/dist/schema/Cursor.json +21 -0
  77. package/dist/schema/EventAction.json +33 -0
  78. package/dist/schema/EventDetail.json +649 -0
  79. package/dist/schema/EventKind.json +26 -0
  80. package/dist/schema/FileContent.json +73 -0
  81. package/dist/schema/FileStatus.json +15 -0
  82. package/dist/schema/ForgeCapabilities.json +737 -0
  83. package/dist/schema/ForgeEvent.json +789 -0
  84. package/dist/schema/ForgeInstance.json +7 -0
  85. package/dist/schema/ForgeKind.json +32 -0
  86. package/dist/schema/ForgeWarning.json +49 -0
  87. package/dist/schema/ForgeWarningCode.json +7 -0
  88. package/dist/schema/GetManyResult.json +699 -0
  89. package/dist/schema/Installation.json +131 -0
  90. package/dist/schema/InstallationToken.json +31 -0
  91. package/dist/schema/KnownForgeKind.json +19 -0
  92. package/dist/schema/Label.json +22 -0
  93. package/dist/schema/MergeMethod.json +14 -0
  94. package/dist/schema/Milestone.json +40 -0
  95. package/dist/schema/Notification.json +498 -0
  96. package/dist/schema/NotificationReason.json +28 -0
  97. package/dist/schema/NotificationRef.json +60 -0
  98. package/dist/schema/NotificationSubject.json +376 -0
  99. package/dist/schema/PerKind.json +49 -0
  100. package/dist/schema/PullBranches.json +125 -0
  101. package/dist/schema/PushCommit.json +24 -0
  102. package/dist/schema/Reaction.json +148 -0
  103. package/dist/schema/ReactionContent.json +17 -0
  104. package/dist/schema/ReactionSummary.json +70 -0
  105. package/dist/schema/Release.json +286 -0
  106. package/dist/schema/ReleaseAsset.json +169 -0
  107. package/dist/schema/ReleaseAssetRef.json +138 -0
  108. package/dist/schema/ReleaseRef.json +107 -0
  109. package/dist/schema/Repo.json +354 -0
  110. package/dist/schema/RepoFeatures.json +35 -0
  111. package/dist/schema/RepoPermissions.json +35 -0
  112. package/dist/schema/RepoRef.json +77 -0
  113. package/dist/schema/RepoRole.json +15 -0
  114. package/dist/schema/RepoVisibility.json +12 -0
  115. package/dist/schema/Review.json +371 -0
  116. package/dist/schema/ReviewComment.json +280 -0
  117. package/dist/schema/ReviewCommentInput.json +34 -0
  118. package/dist/schema/ReviewRef.json +158 -0
  119. package/dist/schema/ReviewState.json +15 -0
  120. package/dist/schema/Reviewer.json +133 -0
  121. package/dist/schema/SecurityAlert.json +219 -0
  122. package/dist/schema/SecurityAlertKind.json +14 -0
  123. package/dist/schema/SecurityAlertRef.json +122 -0
  124. package/dist/schema/SecuritySeverity.json +14 -0
  125. package/dist/schema/SourceKind.json +12 -0
  126. package/dist/schema/SubscriptionState.json +12 -0
  127. package/dist/schema/Support.json +23 -0
  128. package/dist/schema/Tag.json +25 -0
  129. package/dist/schema/TextLimits.json +18 -0
  130. package/dist/schema/Thread.json +653 -0
  131. package/dist/schema/ThreadKind.json +14 -0
  132. package/dist/schema/ThreadRef.json +131 -0
  133. package/dist/schema/ThreadStack.json +146 -0
  134. package/dist/schema/ThreadState.json +13 -0
  135. package/dist/schema/TreeEntry.json +46 -0
  136. package/dist/schema/TreeEntryType.json +13 -0
  137. package/dist/schema/UpsertCommentResult.json +355 -0
  138. package/dist/schema/User.json +123 -0
  139. package/dist/schema/Webhook.json +188 -0
  140. package/dist/schema/WebhookDeliveryRecord.json +173 -0
  141. package/dist/schema/WebhookDeliveryRef.json +135 -0
  142. package/dist/schema/WebhookRef.json +105 -0
  143. package/dist/schema/index.d.mts +4 -0
  144. package/dist/schema/index.mjs +3219 -0
  145. package/dist/tangled/index.d.mts +2 -0
  146. package/dist/tangled/index.mjs +1 -0
  147. package/dist/tangled-ChdPmiv-.mjs +1570 -0
  148. package/dist/testing/index.d.mts +123 -0
  149. package/dist/testing/index.mjs +242 -0
  150. package/dist/webhooks-rn9-8lxT.mjs +70 -0
  151. package/package.json +115 -3
  152. package/dist/.gitkeep +0 -0
@@ -0,0 +1,307 @@
1
+ import { Bt as Notification, En as SecurityAlertKind, Et as ForgeKind, G as Check, Gt as Page, H as BaseOptions, It as ListOptions, Ln as ThreadKind, Mn as Support, Pn as TextLimits, Qn as WebhookEventType, Rt as MergeOptions, Tt as ForgeInstance, Vt as NotificationListOptions, a as FetcherOptions, i as Fetcher, wt as ForgeEventInput, zn as ThreadRef } from "./fetch-D4pSRvvA.mjs";
2
+ import { C as ReleasesApi, D as SecurityAlertsApi, E as SearchApi, F as WebhookDelivery, H as WebLinks, I as WebhooksApi, N as UsersApi, P as VerbScopes, T as ReposApi, c as CiApi, d as ContentsApi, f as ForgeCapabilities, g as ForgeProviderFactory, h as ForgeProvider, i as AuthKind, j as ThreadsApi, k as SubscribeOptions, m as ForgeOptionsBase, q as ForgeVerb, s as ChecksApi, v as InstallationsApi, x as NotificationsApi } from "./provider-CoZ7cCxp.mjs";
3
+ //#region src/define.d.ts
4
+ /** What support can depend on once the provider exists. */
5
+ interface CapabilityEnv {
6
+ /** Instance version from `instanceVersion` or `refreshCapabilities()`, when known. */
7
+ version?: string;
8
+ }
9
+ /** A fixed support level, or one computed from the instance version. */
10
+ type SupportInput = Support | ((env: CapabilityEnv) => Support);
11
+ /** The thread kinds that verbs can differ by. */
12
+ type VerbKind = Exclude<ThreadKind, "other">;
13
+ /** The security alert kinds that support can differ by. */
14
+ type AlertKind = Exclude<SecurityAlertKind, "other">;
15
+ /** A verb whose support does not depend on the thread kind. */
16
+ interface Verb<F> {
17
+ /** How well the verb is supported. */
18
+ support: SupportInput;
19
+ run: F;
20
+ }
21
+ /** A verb whose support depends on the thread kind it is called with. Kinds not listed are unsupported. */
22
+ interface KindVerb<F> {
23
+ /** How well each thread kind is supported. */
24
+ kinds: Partial<Record<VerbKind, SupportInput>>;
25
+ run: F;
26
+ }
27
+ /**
28
+ * Declares a verb whose support does not depend on the thread kind.
29
+ * @param support How well the verb is supported.
30
+ * @param run The function that implements the verb.
31
+ */
32
+ declare function verb<F>(support: SupportInput, run: F): Verb<F>;
33
+ /**
34
+ * Declares a verb whose support depends on the thread kind.
35
+ * @param kinds How well each thread kind is supported. Kinds that are left out are unsupported.
36
+ * @param run The function that implements the verb.
37
+ * @example
38
+ * ```ts
39
+ * const threads = {
40
+ * get: perKind({ issue: true, pull_request: true }, getThread),
41
+ * }
42
+ * ```
43
+ */
44
+ declare function perKind<F>(kinds: Partial<Record<VerbKind, SupportInput>>, run: F): KindVerb<F>;
45
+ type ThreadVerb<K extends keyof ThreadsApi> = KindVerb<NonNullable<ThreadsApi[K]>>;
46
+ /** Everything a provider declares. Methods and capabilities are both derived from it. */
47
+ interface ProviderSpec {
48
+ /** Capabilities that no single verb carries. */
49
+ traits: {
50
+ /** Whether event kinds come from the forge or are inferred from text. See `ForgeCapabilities.eventKinds`. */
51
+ eventKinds: ForgeCapabilities["eventKinds"];
52
+ /** The auth types the provider accepts. */
53
+ authKinds: readonly AuthKind[];
54
+ /** Limits on the text the forge accepts. */
55
+ limits?: TextLimits;
56
+ };
57
+ /** Listings are declared as pages; core derives the iterables. */
58
+ repos: {
59
+ get: Verb<ReposApi["get"]>;
60
+ listPage: Verb<ReposApi["listPage"]>;
61
+ labelsPage?: Verb<ReposApi["labelsPage"]>;
62
+ createLabel?: Verb<ReposApi["createLabel"]>;
63
+ milestonesPage?: Verb<ReposApi["milestonesPage"]>;
64
+ collaboratorsPage?: Verb<ReposApi["collaboratorsPage"]>;
65
+ permissionFor?: Verb<ReposApi["permissionFor"]>;
66
+ addCollaborator?: Verb<ReposApi["addCollaborator"]>;
67
+ assignableUsersPage?: Verb<ReposApi["assignableUsersPage"]>;
68
+ reviewerCandidatesPage?: Verb<ReposApi["reviewerCandidatesPage"]>;
69
+ };
70
+ /** `get` is omitted when the forge cannot read an account by login. */
71
+ users?: {
72
+ get?: Verb<UsersApi["get"]>;
73
+ me?: Verb<UsersApi["me"]>;
74
+ };
75
+ threads: {
76
+ get: ThreadVerb<"get">;
77
+ listPage: ThreadVerb<"listPage">;
78
+ getMany: Verb<ThreadsApi["getMany"]>;
79
+ eventsPage: Verb<(ref: ThreadRef, options?: ListOptions) => Promise<Page<ForgeEventInput>>>;
80
+ commentsPage: ThreadVerb<"commentsPage">;
81
+ comment?: ThreadVerb<"comment">;
82
+ editComment?: ThreadVerb<"editComment">;
83
+ deleteComment?: ThreadVerb<"deleteComment">;
84
+ close?: ThreadVerb<"close">;
85
+ reopen?: ThreadVerb<"reopen">;
86
+ create?: ThreadVerb<"create">;
87
+ update?: ThreadVerb<"update">;
88
+ setLabels?: ThreadVerb<"setLabels">;
89
+ addLabels?: ThreadVerb<"addLabels">;
90
+ removeLabels?: ThreadVerb<"removeLabels">;
91
+ setMilestone?: ThreadVerb<"setMilestone">;
92
+ /** One capability covers reacting and removing a reaction. */
93
+ reactions?: KindVerb<{ [K in "react" | "unreact"]: NonNullable<ThreadsApi[K]>; }>;
94
+ /** Listing the reactions on a thread or one of its comments. */
95
+ reactionsPage?: KindVerb<ThreadsApi["reactionsPage"]>;
96
+ transfer?: Verb<ThreadsApi["transfer"]>;
97
+ markDuplicate?: Verb<ThreadsApi["markDuplicate"]>;
98
+ setAssignees?: ThreadVerb<"setAssignees">;
99
+ requestReview?: ThreadVerb<"requestReview">;
100
+ /** `beforeMerge` runs once the merge is validated, just before it is sent. */
101
+ merge?: Verb<(ref: ThreadRef, options?: MergeOptions, hooks?: MergeHooks) => Promise<void>>;
102
+ /** Optional support override; approval and merging must also be supported. */
103
+ approveAndMerge?: {
104
+ support: SupportInput;
105
+ };
106
+ /** One capability covers reading and changing the subscription. */
107
+ subscriptions?: KindVerb<{ [K in "subscription" | "subscribe" | "unsubscribe"]: NonNullable<ThreadsApi[K]>; }>;
108
+ checks?: KindVerb<(ref: ThreadRef, options?: BaseOptions) => Promise<Page<Check>>>;
109
+ reviewsPage?: Verb<ThreadsApi["reviewsPage"]>;
110
+ createReview?: Verb<ThreadsApi["createReview"]>;
111
+ submitReview?: Verb<ThreadsApi["submitReview"]>;
112
+ /** Omit to derive approval from `createReview`. */
113
+ approve?: Verb<ThreadsApi["approve"]>;
114
+ filesPage?: Verb<ThreadsApi["filesPage"]>;
115
+ commitsPage?: Verb<ThreadsApi["commitsPage"]>;
116
+ /** One capability covers resolving and unresolving. */
117
+ reviewThreads?: Verb<Pick<ThreadsApi, "resolveReviewThread" | "unresolveReviewThread">>;
118
+ };
119
+ /** Commit-level checks, beside the pull-level `threads.checks`. */
120
+ checks?: {
121
+ /** The implementation of `provider.checks.list()`. */
122
+ list?: Verb<ChecksApi["list"]>;
123
+ /** The implementation of `provider.checks.report()`. */
124
+ report?: Verb<ChecksApi["report"]>;
125
+ /** The implementation of `provider.checks.rerun()`. */
126
+ rerun?: Verb<ChecksApi["rerun"]>;
127
+ };
128
+ /** Read-only CI. Listings are declared as pages; core derives the iterables. */
129
+ ci?: {
130
+ /** The implementation of `provider.ci.runs()` and `provider.ci.runsPage()`. */
131
+ runsPage?: Verb<CiApi["runsPage"]>;
132
+ /** The implementation of `provider.ci.run()`. */
133
+ run?: Verb<CiApi["run"]>;
134
+ /** The implementation of `provider.ci.jobs()` and `provider.ci.jobsPage()`. */
135
+ jobsPage?: Verb<CiApi["jobsPage"]>;
136
+ /** The implementation of `provider.ci.log()`. */
137
+ log?: Verb<CiApi["log"]>;
138
+ };
139
+ /** Repository contents. Listings are declared as pages; core derives the iterables. */
140
+ contents?: {
141
+ /** The implementation of `provider.contents.file()`. */
142
+ file?: Verb<ContentsApi["file"]>;
143
+ /** The implementation of `provider.contents.tree()` and `provider.contents.treePage()`. */
144
+ treePage?: Verb<ContentsApi["treePage"]>;
145
+ /** The implementation of `provider.contents.branches()` and `provider.contents.branchesPage()`. */
146
+ branchesPage?: Verb<ContentsApi["branchesPage"]>;
147
+ /** The implementation of `provider.contents.tags()` and `provider.contents.tagsPage()`. */
148
+ tagsPage?: Verb<ContentsApi["tagsPage"]>;
149
+ /** Omit where a sha lookup is impossible; core still short-circuits a 40-hex ref. */
150
+ resolveRef?: Verb<ContentsApi["resolveRef"]>;
151
+ /** The implementation of `provider.contents.commits()` and `provider.contents.commitsPage()`. */
152
+ commitsPage?: Verb<ContentsApi["commitsPage"]>;
153
+ /** The implementation of `provider.contents.commit()`. */
154
+ commit?: Verb<ContentsApi["commit"]>;
155
+ /** The implementation of `provider.contents.compare()`. */
156
+ compare?: Verb<ContentsApi["compare"]>;
157
+ };
158
+ /** Cross-repository search. Listings are declared as pages; core derives the iterables. */
159
+ search?: {
160
+ /** The implementation of `provider.search.threads()` and `provider.search.threadsPage()`. */
161
+ threadsPage?: Verb<SearchApi["threadsPage"]>;
162
+ /** The implementation of `provider.search.repos()` and `provider.search.reposPage()`. */
163
+ reposPage?: Verb<SearchApi["reposPage"]>;
164
+ /** The implementation of `provider.search.commits()` and `provider.search.commitsPage()`. */
165
+ commitsPage?: Verb<SearchApi["commitsPage"]>;
166
+ /** The implementation of `provider.search.code()` and `provider.search.codePage()`. */
167
+ codePage?: Verb<SearchApi["codePage"]>;
168
+ /** The searches pass `queryRaw` on; without this, core drops it with a warning. */
169
+ queryRaw?: boolean;
170
+ };
171
+ releases?: {
172
+ /** The implementation of `provider.releases.list()` and `provider.releases.listPage()`. */
173
+ listPage: Verb<ReleasesApi["listPage"]>;
174
+ /** The implementation of `provider.releases.get()`. */
175
+ get: Verb<ReleasesApi["get"]>;
176
+ /** The implementation of `provider.releases.latest()`. */
177
+ latest: Verb<ReleasesApi["latest"]>;
178
+ /** The implementation of `provider.releases.getByTag()`. */
179
+ getByTag?: Verb<ReleasesApi["getByTag"]>;
180
+ /** The implementation of `provider.releases.downloadAsset()`. */
181
+ downloadAsset?: Verb<ReleasesApi["downloadAsset"]>;
182
+ /** The implementation of `provider.releases.create()`. */
183
+ create?: Verb<ReleasesApi["create"]>;
184
+ /** The implementation of `provider.releases.update()`. */
185
+ update?: Verb<ReleasesApi["update"]>;
186
+ };
187
+ /** Support per alert kind; `listPage` is called with `kind` unset to list every supported kind. */
188
+ securityAlerts?: {
189
+ /** The implementation of `provider.securityAlerts.kinds()`. */
190
+ kinds: Partial<Record<AlertKind, SupportInput>>;
191
+ /** The implementation of `provider.securityAlerts.list()` and `provider.securityAlerts.listPage()`. */
192
+ listPage: SecurityAlertsApi["listPage"];
193
+ };
194
+ /** Omit when the forge has no notifications. `list` is derived from `page`. */
195
+ notifications?: {
196
+ listPage: Verb<(options?: NotificationListOptions) => Promise<Page<Notification>>>;
197
+ } & { [K in Exclude<keyof NotificationsApi, "list" | "listPage">]?: Verb<NonNullable<NotificationsApi[K]>>; };
198
+ /** The implementation of `provider.installations`, except for `list()` and `repos()`, which core derives. */
199
+ installations?: Verb<Omit<InstallationsApi, "list" | "repos">>;
200
+ sources?: {
201
+ subscribe: Verb<(options?: SubscribeOptions) => AsyncIterable<{
202
+ event: ForgeEventInput;
203
+ cursor: string;
204
+ }>>;
205
+ };
206
+ /** Managing registered hooks. Listings are declared as pages; core derives the iterables. */
207
+ webhooks: {
208
+ listPage?: Verb<WebhooksApi["listPage"]>;
209
+ create?: Verb<WebhooksApi["create"]>;
210
+ update?: Verb<WebhooksApi["update"]>;
211
+ delete?: Verb<WebhooksApi["delete"]>;
212
+ rotateSecret?: Verb<WebhooksApi["rotateSecret"]>;
213
+ deliveriesPage?: Verb<WebhooksApi["deliveriesPage"]>;
214
+ redeliver?: Verb<WebhooksApi["redeliver"]>;
215
+ };
216
+ /** Token scopes or app permissions per verb, for `provider.scopesFor()`. */
217
+ scopes?: (verb: ForgeVerb) => VerbScopes;
218
+ /** The implementation of `provider.normaliseMarkdown()`. Without it, Markdown is returned unchanged. */
219
+ normaliseMarkdown?: (body: string) => string;
220
+ /** How the forge's web pages are laid out; omit when they have no stable pattern. */
221
+ web?: WebLinks;
222
+ /** Fetcher behind `request()`, when it differs from the context fetcher. */
223
+ request?: Fetcher;
224
+ /** Reads the instance version for `refreshCapabilities()`. Omit when capabilities never depend on it. */
225
+ probeVersion?: () => Promise<string | undefined>;
226
+ }
227
+ /** Hooks that a provider runs around a merge. */
228
+ interface MergeHooks {
229
+ /** Runs before the merge request is sent, for example to wait for a pending state. */
230
+ beforeMerge?: () => Promise<void>;
231
+ }
232
+ /** The options, the identity and the resolved URLs that provider hooks receive. */
233
+ interface ProviderBase<TOptions, TState> {
234
+ options: TOptions;
235
+ forge: ForgeKind;
236
+ instance: ForgeInstance;
237
+ /** API base after defaults and the API path are applied. */
238
+ baseUrl: string;
239
+ /** Default headers: the definition's, plus `user-agent` outside browsers or when the caller sets one. */
240
+ headers: Record<string, string>;
241
+ /** Error context for this provider. */
242
+ origin: {
243
+ forge: ForgeKind;
244
+ instance: ForgeInstance;
245
+ };
246
+ /** State passed to `derive()`, or created by `prepare()`. */
247
+ state: TState;
248
+ }
249
+ /** The argument of `setup()`: the base, the fetchers and `derive()`. */
250
+ interface ProviderContext<TOptions, TState> extends ProviderBase<TOptions, TState> {
251
+ /** Authenticated with the definition's `authHeaders`. */
252
+ fetcher: Fetcher;
253
+ /** Another fetcher with the same timeout, `fetch` and error context. */
254
+ createFetcher: (overrides: Partial<FetcherOptions> & {
255
+ baseUrl: string;
256
+ }) => Fetcher;
257
+ /** Another provider from the same definition, for example one per app installation. */
258
+ derive: (options: TOptions, state?: TState) => ForgeProvider;
259
+ }
260
+ /** The defaults, the authentication and the `setup()` of a forge. */
261
+ interface ProviderDefinition<TOptions extends ForgeOptionsBase, TState = undefined> {
262
+ forge: ForgeKind;
263
+ /** The forge's API as a whole is unstable, so the provider can change with it. */
264
+ experimental?: true;
265
+ /**
266
+ * Accepts a missing `auth` as `{ type: 'anonymous' }`: core then sends no
267
+ * credentials and marks writes, notifications, subscriptions, installations
268
+ * and the account's repository list unsupported. `'webhooks'` marks every
269
+ * verb unsupported, for a forge whose API needs credentials but whose
270
+ * webhook deliveries can be verified without them.
271
+ */
272
+ anonymous?: true | "webhooks";
273
+ /** Default `baseUrl` when the caller passes none. */
274
+ baseUrl: string;
275
+ /** Appended to `baseUrl` unless already present, for example `/api/v4`. */
276
+ apiPath?: string;
277
+ /** Maps the API host to the instance host, for example `api.github.com` to `github.com`. */
278
+ instance?: (host: string) => string;
279
+ headers?: Record<string, string>;
280
+ /** Builds per-provider state once; receives the state given to `derive()`, if any. */
281
+ prepare?: (base: ProviderBase<TOptions, TState | undefined>) => TState;
282
+ /** Resolves the credential headers of each request. */
283
+ authHeaders?: (base: ProviderBase<TOptions, TState>) => FetcherOptions["authHeaders"];
284
+ /** Query parameters for every request, such as an API version; see `FetcherOptions.query`. */
285
+ query?: Record<string, string>;
286
+ /** Declares the verbs and the web links of one provider. */
287
+ setup: (ctx: ProviderContext<TOptions, TState>) => ProviderSpec;
288
+ /** Delivery verification and translation. Omit it and `webhooks.ingest()` is unsupported. */
289
+ webhooks?: WebhookHandlers<TOptions>;
290
+ }
291
+ /** Verifies and translates deliveries for one provider; built once per instance from its context. */
292
+ type WebhookHandlers<TOptions> = (ctx: Omit<ProviderContext<TOptions, unknown>, "state" | "derive">) => {
293
+ /** Normalised kinds and actions the handlers translate. */
294
+ events: WebhookEventType[];
295
+ verify: (delivery: WebhookDelivery) => Promise<boolean>;
296
+ translate: (delivery: WebhookDelivery) => ForgeEventInput[] | Promise<ForgeEventInput[]>;
297
+ };
298
+ /**
299
+ * Defines a forge provider. Returns the factory end users call, for example
300
+ * `github({ auth })`. Nothing touches the network until `create()`.
301
+ * @param definition The defaults, authentication and setup of the forge.
302
+ */
303
+ declare function defineForgeProvider<TOptions extends ForgeOptionsBase, TState = undefined>(definition: ProviderDefinition<TOptions, TState>): ProviderFactoryFunction<TOptions>;
304
+ /** The function `defineForgeProvider()` returns. Options are optional when every option is. */
305
+ type ProviderFactoryFunction<TOptions> = Record<never, never> extends TOptions ? (options?: TOptions) => ForgeProviderFactory<ForgeProvider> : (options: TOptions) => ForgeProviderFactory<ForgeProvider>;
306
+ //#endregion
307
+ export { ProviderBase as a, ProviderFactoryFunction as c, Verb as d, VerbKind as f, verb as g, perKind as h, MergeHooks as i, ProviderSpec as l, defineForgeProvider as m, CapabilityEnv as n, ProviderContext as o, WebhookHandlers as p, KindVerb as r, ProviderDefinition as s, AlertKind as t, SupportInput as u };