@openma/matter-gitlab 0.1.0 → 0.2.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/dist/bond/index.d.ts +175 -2
- package/dist/bond/index.js +914 -11
- package/dist/bond/index.js.map +1 -1
- package/package.json +4 -3
package/dist/bond/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { BondProvider, ProviderError, SecretRef, TokenGrant } from "@openma/matter/bond";
|
|
1
|
+
import { BondBinding, BondManifest, BondProvider, BondResourceCatalog, ProviderError, SecretRef, TokenGrant } from "@openma/matter/bond";
|
|
2
2
|
import { Effect } from "effect";
|
|
3
|
+
import { JsonValue, WorkEvent } from "@openma/matter";
|
|
4
|
+
import { CredentialResolver } from "@openma/matter/credentials";
|
|
5
|
+
import { IntegrationError, WorkIntegration } from "@openma/matter/integration";
|
|
6
|
+
import { HttpEndpoint } from "@openma/matter/http";
|
|
3
7
|
//#region src/bond/http.d.ts
|
|
4
8
|
type Fetch = typeof globalThis.fetch;
|
|
5
9
|
/**
|
|
@@ -300,5 +304,174 @@ interface GitLabBondProviderOptions {
|
|
|
300
304
|
*/
|
|
301
305
|
declare const makeGitLabBondProvider: (options?: GitLabBondProviderOptions) => BondProvider;
|
|
302
306
|
//#endregion
|
|
303
|
-
|
|
307
|
+
//#region src/bond/resources.d.ts
|
|
308
|
+
/** Minimum GitLab access level per operation: 20 Reporter, 30 Developer. */
|
|
309
|
+
declare const GITLAB_MIN_ACCESS_LEVEL: Readonly<Record<GitLabOperation, number>>;
|
|
310
|
+
declare const gitlabManifest: BondManifest;
|
|
311
|
+
interface GitLabResourceCatalogOptions {
|
|
312
|
+
readonly fetch?: Fetch;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Projects as Bond resources, with IDs `project:<numeric id>`. Paths are
|
|
316
|
+
* display data only. `list` returns projects where the token holds at least
|
|
317
|
+
* Reporter; `validate` checks the access level each operation needs and
|
|
318
|
+
* refuses writes to archived projects. An instance administrator without a
|
|
319
|
+
* membership reports no access level and is treated as having none.
|
|
320
|
+
*/
|
|
321
|
+
declare const makeGitLabResourceCatalog: (options?: GitLabResourceCatalogOptions) => BondResourceCatalog;
|
|
322
|
+
/** The provider, manifest, and resource catalog a host registers for GitLab. */
|
|
323
|
+
declare const makeGitLabBinding: (options?: GitLabBondProviderOptions) => BondBinding;
|
|
324
|
+
//#endregion
|
|
325
|
+
//#region src/bond/integration/client.d.ts
|
|
326
|
+
/**
|
|
327
|
+
* What a GitLab call needs for one authority: the instance and a token with
|
|
328
|
+
* API access (a Bond's app principal token, or a test token).
|
|
329
|
+
*/
|
|
330
|
+
interface GitLabCredentials {
|
|
331
|
+
/** The instance root, for example `https://gitlab.example.com`. */
|
|
332
|
+
readonly baseUrl: string;
|
|
333
|
+
readonly token: string;
|
|
334
|
+
}
|
|
335
|
+
type GitLabCredentialResolver = CredentialResolver<GitLabCredentials>;
|
|
336
|
+
type GitLabCredentialSource = (authority: string) => GitLabCredentials | PromiseLike<GitLabCredentials> | Effect.Effect<GitLabCredentials, unknown>;
|
|
337
|
+
type GitLabCredentialOption = GitLabCredentials | GitLabCredentialResolver | GitLabCredentialSource;
|
|
338
|
+
type GitLabCredentialsFor = (authority: string) => Effect.Effect<GitLabCredentials, IntegrationError>;
|
|
339
|
+
declare const makeGitLabCredentialsFor: (option: GitLabCredentialOption) => GitLabCredentialsFor;
|
|
340
|
+
interface GitLabResponse {
|
|
341
|
+
readonly payload: JsonValue;
|
|
342
|
+
readonly headers: Headers;
|
|
343
|
+
}
|
|
344
|
+
declare const makeGitLabClient: (input: {
|
|
345
|
+
readonly credentialsFor: GitLabCredentialsFor;
|
|
346
|
+
readonly fetch: typeof globalThis.fetch;
|
|
347
|
+
readonly clock: () => string;
|
|
348
|
+
}) => {
|
|
349
|
+
request: (options: {
|
|
350
|
+
readonly authority: string;
|
|
351
|
+
readonly method: "DELETE" | "GET" | "POST" | "PUT";
|
|
352
|
+
readonly path: string;
|
|
353
|
+
readonly body?: Readonly<Record<string, unknown>>;
|
|
354
|
+
}) => Effect.Effect<GitLabResponse, IntegrationError>;
|
|
355
|
+
};
|
|
356
|
+
type GitLabClient = ReturnType<typeof makeGitLabClient>;
|
|
357
|
+
//#endregion
|
|
358
|
+
//#region src/bond/integration/delivery.d.ts
|
|
359
|
+
/** Every Effect operation `deliver` accepts. */
|
|
360
|
+
declare const GITLAB_OPERATIONS: readonly ["merge_request.note.create", "merge_request.discussion.reply", "issue.note.create", "issue.discussion.reply"];
|
|
361
|
+
type GitLabEffectOperation = (typeof GITLAB_OPERATIONS)[number];
|
|
362
|
+
/**
|
|
363
|
+
* Delivers GitLab Effects. Every input names the `authority` whose
|
|
364
|
+
* credentials post the note, the `projectId` (numeric id or full path), the
|
|
365
|
+
* merge request or issue `iid`, and a non-empty `body`. Discussion replies
|
|
366
|
+
* also name the `discussionId`; replying to a single comment turns it into a
|
|
367
|
+
* thread.
|
|
368
|
+
*/
|
|
369
|
+
declare const makeGitLabDelivery: (client: Pick<GitLabClient, "request">) => WorkIntegration["deliver"];
|
|
370
|
+
//#endregion
|
|
371
|
+
//#region src/bond/integration/events.d.ts
|
|
372
|
+
/** Every Event type `ingest` can produce. */
|
|
373
|
+
declare const GITLAB_EVENT_TYPES: readonly string[];
|
|
374
|
+
/**
|
|
375
|
+
* Turns a verified `GitLabWebhookInput` into one WorkEvent. Inputs of another
|
|
376
|
+
* kind produce no Events. The Event id combines the authority and the
|
|
377
|
+
* delivery id, so a GitLab retry is the same Event.
|
|
378
|
+
*/
|
|
379
|
+
declare const normalizeGitLabEvents: (input: unknown, clock: () => string) => Effect.Effect<readonly WorkEvent[], IntegrationError>;
|
|
380
|
+
//#endregion
|
|
381
|
+
//#region src/bond/integration/http.d.ts
|
|
382
|
+
declare const GitLabHttpIngressError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
383
|
+
readonly _tag: "GitLabHttpIngressError";
|
|
384
|
+
} & Readonly<A>;
|
|
385
|
+
declare class GitLabHttpIngressError extends GitLabHttpIngressError_base<{
|
|
386
|
+
readonly message: string;
|
|
387
|
+
readonly status: 400 | 401;
|
|
388
|
+
readonly cause?: unknown;
|
|
389
|
+
}> {}
|
|
390
|
+
declare const GitLabHttpSubmissionError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
391
|
+
readonly _tag: "GitLabHttpSubmissionError";
|
|
392
|
+
} & Readonly<A>;
|
|
393
|
+
declare class GitLabHttpSubmissionError extends GitLabHttpSubmissionError_base<{
|
|
394
|
+
readonly message: string;
|
|
395
|
+
readonly status: 503;
|
|
396
|
+
readonly cause?: unknown;
|
|
397
|
+
}> {}
|
|
398
|
+
/** One verified GitLab webhook delivery, ready for `integration.ingest`. */
|
|
399
|
+
interface GitLabWebhookInput {
|
|
400
|
+
readonly kind: "gitlab.webhook";
|
|
401
|
+
/**
|
|
402
|
+
* Who received the webhook, chosen by the host (for example a Bond id).
|
|
403
|
+
* It becomes the Event source authority and selects credentials for replies.
|
|
404
|
+
*/
|
|
405
|
+
readonly authority: string;
|
|
406
|
+
/** The `X-Gitlab-Event` header, for example `Merge Request Hook`. */
|
|
407
|
+
readonly eventName: string;
|
|
408
|
+
/** Stable across GitLab retries; see `decodeGitLabHttpRequest`. */
|
|
409
|
+
readonly deliveryId: string;
|
|
410
|
+
/** The `X-Gitlab-Instance` header (GitLab 15.5+), when present. */
|
|
411
|
+
readonly instance?: string;
|
|
412
|
+
readonly payload: JsonValue;
|
|
413
|
+
}
|
|
414
|
+
interface GitLabHttpEndpointOptions {
|
|
415
|
+
/** The secret token configured on the GitLab webhook. */
|
|
416
|
+
readonly webhookToken: string;
|
|
417
|
+
readonly authority: string;
|
|
418
|
+
readonly path?: string;
|
|
419
|
+
readonly submit: (input: GitLabWebhookInput) => Promise<unknown>;
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Compares the `X-Gitlab-Token` header with the configured secret token in
|
|
423
|
+
* constant time. Both values are hashed first, so the comparison does not
|
|
424
|
+
* reveal the secret's length either. An empty configured token never matches.
|
|
425
|
+
*/
|
|
426
|
+
declare const verifyGitLabToken: (input: {
|
|
427
|
+
readonly webhookToken: string;
|
|
428
|
+
readonly received: string;
|
|
429
|
+
}) => Effect.Effect<boolean, GitLabHttpIngressError>;
|
|
430
|
+
/**
|
|
431
|
+
* Verifies and decodes one GitLab webhook request. The delivery id is the
|
|
432
|
+
* first of `webhook-id` and `Idempotency-Key` (both stable across retries,
|
|
433
|
+
* GitLab 17.4+) and `X-Gitlab-Event-UUID` (GitLab 14.8+).
|
|
434
|
+
*/
|
|
435
|
+
declare const decodeGitLabHttpRequest: (request: Request, options: Pick<GitLabHttpEndpointOptions, "webhookToken" | "authority">) => Effect.Effect<GitLabWebhookInput, GitLabHttpIngressError>;
|
|
436
|
+
/**
|
|
437
|
+
* A webhook endpoint for one GitLab authority. Hosts that serve many
|
|
438
|
+
* authorities from one route call `decodeGitLabHttpRequest` with the token
|
|
439
|
+
* and authority they look up for the request instead.
|
|
440
|
+
*/
|
|
441
|
+
declare const makeGitLabHttpEndpoint: (options: GitLabHttpEndpointOptions) => HttpEndpoint;
|
|
442
|
+
//#endregion
|
|
443
|
+
//#region src/bond/integration/integration.d.ts
|
|
444
|
+
interface GitLabIntegrationOptions {
|
|
445
|
+
/**
|
|
446
|
+
* Credentials for replies: fixed `{ baseUrl, token }`, or a resolver keyed
|
|
447
|
+
* by the Event authority (for example a Bond's app principal).
|
|
448
|
+
*/
|
|
449
|
+
readonly credentials: GitLabCredentialOption;
|
|
450
|
+
readonly fetch?: typeof globalThis.fetch;
|
|
451
|
+
readonly clock?: () => string;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* The GitLab work integration: `ingest` takes a `GitLabWebhookInput` from
|
|
455
|
+
* `decodeGitLabHttpRequest`, and `deliver` posts merge request and issue
|
|
456
|
+
* notes.
|
|
457
|
+
*/
|
|
458
|
+
declare const makeGitLabIntegration: (options: GitLabIntegrationOptions) => WorkIntegration;
|
|
459
|
+
//#endregion
|
|
460
|
+
//#region src/bond/integration/templates.d.ts
|
|
461
|
+
/**
|
|
462
|
+
* Reviews a merge request when it opens, reopens, or receives new commits,
|
|
463
|
+
* and posts the review as a note. Title or label edits do not trigger a
|
|
464
|
+
* review. Draft merge requests are skipped unless `skipDrafts` is false.
|
|
465
|
+
*/
|
|
466
|
+
declare const gitlabMergeRequestReview: import("@openma/matter-loop").Loop;
|
|
467
|
+
/**
|
|
468
|
+
* Answers a merge request comment that mentions the Agent's GitLab user, in
|
|
469
|
+
* the same thread. System notes and the Agent's own notes are ignored, so a
|
|
470
|
+
* reply never triggers another reply.
|
|
471
|
+
*/
|
|
472
|
+
declare const gitlabMention: import("@openma/matter-loop").Loop;
|
|
473
|
+
/** The GitLab templates, in the order a console lists them. */
|
|
474
|
+
declare const gitlabTemplates: readonly [import("@openma/matter-loop").Loop, import("@openma/matter-loop").Loop];
|
|
475
|
+
//#endregion
|
|
476
|
+
export { type AuthorizationUrlInput, type CommitIdentity, type Fetch, GITLAB_EVENT_TYPES, GITLAB_MIN_ACCESS_LEVEL, GITLAB_OPERATIONS, type GitLabBondProviderOptions, type GitLabClient, type GitLabCredentialOption, type GitLabCredentialResolver, type GitLabCredentialSource, type GitLabCredentials, type GitLabEffectOperation, type GitLabHttpEndpointOptions, GitLabHttpIngressError, GitLabHttpSubmissionError, type GitLabInstance, type GitLabIntegrationOptions, type GitLabOperation, type GitLabRequestClass, type GitLabResourceCatalogOptions, type GitLabTokenInfo, type GitLabUser, type GitLabWebhookInput, type OAuthClient, type Pkce, type ProjectRef, type PushPolicy, type ReceivePackCommand, type ReceivePackHead, type ReceivePackHeadParser, type ReceivePackLimits, type ReceivePackParse, type TokenPolicy, type TokenProblem, ZERO_OID, assistedByTrailer, authorizationUrl, canonicalOrigin, classifyGitLabRequest, coAuthoredByTrailer, commitAuthor, createPkce, decodeGitLabHttpRequest, discoverInstance, evaluatePush, exchangeCode, gitlabManifest, gitlabMention, gitlabMergeRequestReview, gitlabTemplates, isValidRefName, makeGitLabBinding, makeGitLabBondProvider, makeGitLabClient, makeGitLabCredentialsFor, makeGitLabDelivery, makeGitLabHttpEndpoint, makeGitLabIntegration, makeGitLabResourceCatalog, makeReceivePackHeadParser, mergeRequestBodyProblem, mergeRequestFooter, mergeRequestPushOptions, normalizeGitLabEvents, parseReceivePackHead, readTokenInfo, readUser, refreshAccessToken, revokeSelfToken, revokeToken, tokenExpiryInstant, validateBotCredential, validatePersonalAccessToken, verifyGitLabToken };
|
|
304
477
|
//# sourceMappingURL=index.d.ts.map
|