@devrev/git-sdk 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/adapter/adapter.d.ts +9 -0
- package/dist/adapter/adapter.js +3 -0
- package/dist/adapter/adapter.js.map +1 -0
- package/dist/config/create-config.d.ts +34 -0
- package/dist/config/create-config.js +33 -0
- package/dist/config/create-config.js.map +1 -0
- package/dist/config/index.d.ts +4 -0
- package/dist/config/index.js +9 -0
- package/dist/config/index.js.map +1 -0
- package/dist/devrev/client.d.ts +104 -0
- package/dist/devrev/client.js +113 -0
- package/dist/devrev/client.js.map +1 -0
- package/dist/devrev/http.d.ts +42 -0
- package/dist/devrev/http.js +105 -0
- package/dist/devrev/http.js.map +1 -0
- package/dist/devrev/index.d.ts +7 -0
- package/dist/devrev/index.js +43 -0
- package/dist/devrev/index.js.map +1 -0
- package/dist/devrev/managers/code_change_manager.d.ts +48 -0
- package/dist/devrev/managers/code_change_manager.js +227 -0
- package/dist/devrev/managers/code_change_manager.js.map +1 -0
- package/dist/devrev/managers/code_change_schema.d.ts +12 -0
- package/dist/devrev/managers/code_change_schema.js +317 -0
- package/dist/devrev/managers/code_change_schema.js.map +1 -0
- package/dist/devrev/managers/custom_link_type_manager.d.ts +33 -0
- package/dist/devrev/managers/custom_link_type_manager.js +94 -0
- package/dist/devrev/managers/custom_link_type_manager.js.map +1 -0
- package/dist/devrev/managers/dev_user_manager.d.ts +53 -0
- package/dist/devrev/managers/dev_user_manager.js +155 -0
- package/dist/devrev/managers/dev_user_manager.js.map +1 -0
- package/dist/devrev/managers/index.d.ts +9 -0
- package/dist/devrev/managers/index.js +20 -0
- package/dist/devrev/managers/index.js.map +1 -0
- package/dist/devrev/managers/link_manager.d.ts +41 -0
- package/dist/devrev/managers/link_manager.js +111 -0
- package/dist/devrev/managers/link_manager.js.map +1 -0
- package/dist/devrev/managers/tenant_fragment_manager.d.ts +26 -0
- package/dist/devrev/managers/tenant_fragment_manager.js +68 -0
- package/dist/devrev/managers/tenant_fragment_manager.js.map +1 -0
- package/dist/devrev/managers/timeline_manager.d.ts +86 -0
- package/dist/devrev/managers/timeline_manager.js +184 -0
- package/dist/devrev/managers/timeline_manager.js.map +1 -0
- package/dist/devrev/types.d.ts +139 -0
- package/dist/devrev/types.js +127 -0
- package/dist/devrev/types.js.map +1 -0
- package/dist/handlers/commit_push_handler.d.ts +31 -0
- package/dist/handlers/commit_push_handler.js +145 -0
- package/dist/handlers/commit_push_handler.js.map +1 -0
- package/dist/handlers/helpers.d.ts +87 -0
- package/dist/handlers/helpers.js +201 -0
- package/dist/handlers/helpers.js.map +1 -0
- package/dist/handlers/index.d.ts +12 -0
- package/dist/handlers/index.js +26 -0
- package/dist/handlers/index.js.map +1 -0
- package/dist/handlers/pr_create_handler.d.ts +36 -0
- package/dist/handlers/pr_create_handler.js +121 -0
- package/dist/handlers/pr_create_handler.js.map +1 -0
- package/dist/handlers/pr_merge_handler.d.ts +29 -0
- package/dist/handlers/pr_merge_handler.js +86 -0
- package/dist/handlers/pr_merge_handler.js.map +1 -0
- package/dist/handlers/pr_review_handler.d.ts +30 -0
- package/dist/handlers/pr_review_handler.js +109 -0
- package/dist/handlers/pr_review_handler.js.map +1 -0
- package/dist/handlers/registry.d.ts +9 -0
- package/dist/handlers/registry.js +22 -0
- package/dist/handlers/registry.js.map +1 -0
- package/dist/handlers/types.d.ts +46 -0
- package/dist/handlers/types.js +6 -0
- package/dist/handlers/types.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +65 -0
- package/dist/index.js.map +1 -0
- package/dist/orchestrator/event_orchestrator.d.ts +99 -0
- package/dist/orchestrator/event_orchestrator.js +137 -0
- package/dist/orchestrator/event_orchestrator.js.map +1 -0
- package/dist/orchestrator/index.d.ts +7 -0
- package/dist/orchestrator/index.js +12 -0
- package/dist/orchestrator/index.js.map +1 -0
- package/dist/types/config.d.ts +22 -0
- package/dist/types/config.js +6 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/events.d.ts +50 -0
- package/dist/types/events.js +14 -0
- package/dist/types/events.js.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.js +24 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/provider.d.ts +20 -0
- package/dist/types/provider.js +14 -0
- package/dist/types/provider.js.map +1 -0
- package/dist/types/types.d.ts +48 -0
- package/dist/types/types.js +9 -0
- package/dist/types/types.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Event Orchestrator for the Git SDK.
|
|
4
|
+
*
|
|
5
|
+
* The orchestrator is the central routing layer that receives raw events from
|
|
6
|
+
* any Git provider, normalizes them via the provider adapter, and dispatches
|
|
7
|
+
* them to the appropriate handler. This simplifies the consumer experience —
|
|
8
|
+
* instead of manually normalizing events and routing to individual handlers,
|
|
9
|
+
* consumers call a single `processEvent()` method.
|
|
10
|
+
*
|
|
11
|
+
* Flow:
|
|
12
|
+
* 1. Raw provider event → adapter.normalizeEvent() → NormalizedEvent
|
|
13
|
+
* 2. NormalizedEvent.type → route to correct handler
|
|
14
|
+
* 3. Handler processes event → HandlerResult
|
|
15
|
+
*/
|
|
16
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.EventOrchestrator = void 0;
|
|
27
|
+
const client_1 = require("../devrev/client");
|
|
28
|
+
const types_1 = require("../devrev/types");
|
|
29
|
+
const registry_1 = require("../handlers/registry");
|
|
30
|
+
// =============================================================================
|
|
31
|
+
// Event Orchestrator
|
|
32
|
+
// =============================================================================
|
|
33
|
+
/**
|
|
34
|
+
* Central event processing engine for the Git SDK.
|
|
35
|
+
*
|
|
36
|
+
* The EventOrchestrator ties together the provider adapter (normalization)
|
|
37
|
+
* and the event handlers (processing) into a single, easy-to-use interface.
|
|
38
|
+
*
|
|
39
|
+
* Usage:
|
|
40
|
+
* 1. Create an orchestrator with SDK configuration, a provider adapter, and a provider name.
|
|
41
|
+
* 2. Call `processEvent(rawEvent)` for each incoming webhook payload.
|
|
42
|
+
* 3. The orchestrator normalizes the event and routes it to the correct handler.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const orchestrator = new EventOrchestrator({
|
|
47
|
+
* sdkConfig: {
|
|
48
|
+
* devrev: { endpoint: 'https://api.devrev.ai', token: devrevToken },
|
|
49
|
+
* provider: { token: providerToken },
|
|
50
|
+
* },
|
|
51
|
+
* adapter: myProviderAdapter,
|
|
52
|
+
* provider: 'github', // or 'gitlab', 'bitbucket', 'azure'
|
|
53
|
+
* });
|
|
54
|
+
*
|
|
55
|
+
* // Process a raw webhook payload
|
|
56
|
+
* const result = await orchestrator.processEvent(webhookPayload);
|
|
57
|
+
* console.log(result.success, result.message);
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
class EventOrchestrator {
|
|
61
|
+
/**
|
|
62
|
+
* Creates a new EventOrchestrator.
|
|
63
|
+
*
|
|
64
|
+
* Internally builds a DevRevClient from the provided SDKConfiguration.
|
|
65
|
+
*
|
|
66
|
+
* @param config - The orchestrator configuration
|
|
67
|
+
*/
|
|
68
|
+
constructor(config) {
|
|
69
|
+
this.client = new client_1.DevRevClient({
|
|
70
|
+
endpoint: config.sdkConfig.devrev.endpoint,
|
|
71
|
+
token: config.sdkConfig.devrev.token,
|
|
72
|
+
provider: config.provider,
|
|
73
|
+
});
|
|
74
|
+
this.adapter = config.adapter;
|
|
75
|
+
this.source = (0, types_1.getCodeChangeSourceFromProvider)(config.provider);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Processes a raw event from a Git provider.
|
|
79
|
+
*
|
|
80
|
+
* This is the primary entry point for event processing. It:
|
|
81
|
+
* 1. Normalizes the raw event via the provider adapter
|
|
82
|
+
* 2. Routes the normalized event to the appropriate handler
|
|
83
|
+
* 3. Returns the handler result
|
|
84
|
+
*
|
|
85
|
+
* @param rawEvent - The raw event payload from the Git provider
|
|
86
|
+
* @returns The handler result indicating success or failure
|
|
87
|
+
*/
|
|
88
|
+
processEvent(rawEvent) {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
try {
|
|
91
|
+
const normalizedEvent = this.adapter.normalizeEvent(rawEvent);
|
|
92
|
+
return yield this.processNormalizedEvent(normalizedEvent);
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
return {
|
|
96
|
+
message: `Failed to process event: ${(0, types_1.getErrorMessage)(error)}`,
|
|
97
|
+
success: false,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Processes a pre-normalized event.
|
|
104
|
+
*
|
|
105
|
+
* Use this when the event has already been normalized (e.g., in testing
|
|
106
|
+
* or when the normalization step is handled externally).
|
|
107
|
+
*
|
|
108
|
+
* @param event - The normalized event
|
|
109
|
+
* @returns The handler result indicating success or failure
|
|
110
|
+
*/
|
|
111
|
+
processNormalizedEvent(event) {
|
|
112
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
const handler = registry_1.DEFAULT_HANDLER_REGISTRY[event.type];
|
|
114
|
+
if (!handler) {
|
|
115
|
+
return {
|
|
116
|
+
message: `No handler registered for event type: ${event.type}`,
|
|
117
|
+
success: false,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
const context = this.buildHandlerContext(event.type);
|
|
121
|
+
return handler(event, context);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Builds the HandlerContext for a given event type.
|
|
126
|
+
*/
|
|
127
|
+
buildHandlerContext(eventType) {
|
|
128
|
+
return {
|
|
129
|
+
adapter: this.adapter,
|
|
130
|
+
client: this.client,
|
|
131
|
+
eventType,
|
|
132
|
+
source: this.source,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
exports.EventOrchestrator = EventOrchestrator;
|
|
137
|
+
//# sourceMappingURL=event_orchestrator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event_orchestrator.js","sourceRoot":"","sources":["../../src/orchestrator/event_orchestrator.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;;;;;;;;;;AAGH,6CAAgD;AAChD,2CAAyG;AACzG,mDAAgE;AA2BhE,gFAAgF;AAChF,qBAAqB;AACrB,gFAAgF;AAEhF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAa,iBAAiB;IAO5B;;;;;;OAMG;IACH,YAAY,MAA+B;QACzC,IAAI,CAAC,MAAM,GAAG,IAAI,qBAAY,CAAC;YAC7B,QAAQ,EAAE,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ;YAC1C,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK;YACpC,QAAQ,EAAE,MAAM,CAAC,QAAQ;SAC1B,CAAC,CAAC;QACH,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,IAAA,uCAA+B,EAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACjE,CAAC;IAED;;;;;;;;;;OAUG;IACG,YAAY,CAAC,QAAiB;;YAClC,IAAI;gBACF,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;gBAC9D,OAAO,MAAM,IAAI,CAAC,sBAAsB,CAAC,eAAe,CAAC,CAAC;aAC3D;YAAC,OAAO,KAAK,EAAE;gBACd,OAAO;oBACL,OAAO,EAAE,4BAA4B,IAAA,uBAAe,EAAC,KAAK,CAAC,EAAE;oBAC7D,OAAO,EAAE,KAAK;iBACf,CAAC;aACH;QACH,CAAC;KAAA;IAED;;;;;;;;OAQG;IACG,sBAAsB,CAAC,KAAsB;;YACjD,MAAM,OAAO,GAAG,mCAAwB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAErD,IAAI,CAAC,OAAO,EAAE;gBACZ,OAAO;oBACL,OAAO,EAAE,yCAAyC,KAAK,CAAC,IAAI,EAAE;oBAC9D,OAAO,EAAE,KAAK;iBACf,CAAC;aACH;YAED,MAAM,OAAO,GAAG,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACrD,OAAO,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACjC,CAAC;KAAA;IAED;;OAEG;IACK,mBAAmB,CAAC,SAAiB;QAC3C,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,SAAS;YACT,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC;IACJ,CAAC;CACF;AAjFD,8CAiFC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event orchestrator module.
|
|
3
|
+
*
|
|
4
|
+
* Provides the central event processing engine that normalizes raw
|
|
5
|
+
* Git provider events and routes them to the appropriate handlers.
|
|
6
|
+
*/
|
|
7
|
+
export { EventOrchestrator, type EventOrchestratorConfig, } from './event_orchestrator';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Event orchestrator module.
|
|
4
|
+
*
|
|
5
|
+
* Provides the central event processing engine that normalizes raw
|
|
6
|
+
* Git provider events and routes them to the appropriate handlers.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.EventOrchestrator = void 0;
|
|
10
|
+
var event_orchestrator_1 = require("./event_orchestrator");
|
|
11
|
+
Object.defineProperty(exports, "EventOrchestrator", { enumerable: true, get: function () { return event_orchestrator_1.EventOrchestrator; } });
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/orchestrator/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,2DAG8B;AAF5B,uHAAA,iBAAiB,OAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK configuration types.
|
|
3
|
+
*/
|
|
4
|
+
import { ProviderContext } from './provider';
|
|
5
|
+
/**
|
|
6
|
+
* DevRev API configuration.
|
|
7
|
+
*/
|
|
8
|
+
export interface DevRevConfig {
|
|
9
|
+
/** DevRev API endpoint */
|
|
10
|
+
endpoint: string;
|
|
11
|
+
/** DevRev API token */
|
|
12
|
+
token: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Complete SDK configuration.
|
|
16
|
+
*/
|
|
17
|
+
export interface SDKConfiguration {
|
|
18
|
+
/** DevRev API configuration */
|
|
19
|
+
devrev: DevRevConfig;
|
|
20
|
+
/** Provider context with auth token */
|
|
21
|
+
provider: ProviderContext;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":";AAAA;;GAEG"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { NormalizedRepository, NormalizedActor, NormalizedCommit, NormalizedPullRequest, NormalizedBranch } from './types';
|
|
2
|
+
import { GitProvider } from './provider';
|
|
3
|
+
export declare const ReviewStateValues: {
|
|
4
|
+
readonly APPROVED: "APPROVED";
|
|
5
|
+
readonly CHANGES_REQUESTED: "CHANGES_REQUESTED";
|
|
6
|
+
};
|
|
7
|
+
export type ReviewState = typeof ReviewStateValues[keyof typeof ReviewStateValues];
|
|
8
|
+
interface NormalizedEventBase {
|
|
9
|
+
provider: GitProvider;
|
|
10
|
+
actor: NormalizedActor;
|
|
11
|
+
repository: NormalizedRepository;
|
|
12
|
+
occurredAt: string;
|
|
13
|
+
}
|
|
14
|
+
export type NormalizedEvent = NormalizedPushEvent | NormalizedPullRequestCreateEvent | NormalizedPullRequestEditEvent | NormalizedPRReviewEvent | NormalizedPullRequestCloseEvent | NormalizedPullRequestMergeEvent;
|
|
15
|
+
export interface NormalizedPushEvent extends NormalizedEventBase {
|
|
16
|
+
type: 'push';
|
|
17
|
+
branch: NormalizedBranch;
|
|
18
|
+
commits: NormalizedCommit[];
|
|
19
|
+
beforeSha: string | null;
|
|
20
|
+
afterSha: string | null;
|
|
21
|
+
}
|
|
22
|
+
export interface NormalizedPullRequestCreateEvent extends NormalizedEventBase {
|
|
23
|
+
type: 'pull_request_create';
|
|
24
|
+
pullRequest: NormalizedPullRequest;
|
|
25
|
+
}
|
|
26
|
+
export interface NormalizedPullRequestEditEvent extends NormalizedEventBase {
|
|
27
|
+
type: 'pull_request_edit';
|
|
28
|
+
pullRequest: NormalizedPullRequest;
|
|
29
|
+
}
|
|
30
|
+
export interface NormalizedPRReviewEvent extends NormalizedEventBase {
|
|
31
|
+
type: 'pull_request_review';
|
|
32
|
+
pullRequest: NormalizedPullRequest;
|
|
33
|
+
state: ReviewState;
|
|
34
|
+
body: string | null;
|
|
35
|
+
url?: string;
|
|
36
|
+
reviewedAt: string;
|
|
37
|
+
reviewer: NormalizedActor;
|
|
38
|
+
}
|
|
39
|
+
export interface NormalizedPullRequestCloseEvent extends NormalizedEventBase {
|
|
40
|
+
type: 'pull_request_close';
|
|
41
|
+
pullRequest: NormalizedPullRequest;
|
|
42
|
+
closedAt: string;
|
|
43
|
+
}
|
|
44
|
+
export interface NormalizedPullRequestMergeEvent extends NormalizedEventBase {
|
|
45
|
+
type: 'pull_request_merge';
|
|
46
|
+
pullRequest: NormalizedPullRequest;
|
|
47
|
+
mergedAt: string;
|
|
48
|
+
mergeCommitSha?: string;
|
|
49
|
+
}
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Normalized types for the Git SDK.
|
|
4
|
+
|
|
5
|
+
These types are used to normalize the data from the git providers
|
|
6
|
+
into a format that is easy to use in the Git SDK.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ReviewStateValues = void 0;
|
|
10
|
+
exports.ReviewStateValues = {
|
|
11
|
+
APPROVED: 'APPROVED',
|
|
12
|
+
CHANGES_REQUESTED: 'CHANGES_REQUESTED',
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":";AAAA;;;;;EAKE;;;AAKW,QAAA,iBAAiB,GAAG;IAC/B,QAAQ,EAAE,UAAU;IACpB,iBAAiB,EAAE,mBAAmB;CAC9B,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Type exports for the Git SDK.
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
17
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
__exportStar(require("./provider"), exports);
|
|
21
|
+
__exportStar(require("./config"), exports);
|
|
22
|
+
__exportStar(require("./types"), exports);
|
|
23
|
+
__exportStar(require("./events"), exports);
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;AAEH,6CAA2B;AAC3B,2CAAyB;AACzB,0CAAwB;AACxB,2CAAyB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider-related types for the Git SDK.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Context passed to provider adapter methods that require API authentication.
|
|
6
|
+
*/
|
|
7
|
+
export interface ProviderContext {
|
|
8
|
+
/** Provider API token (e.g., GitHub PAT, GitLab access token) */
|
|
9
|
+
token: string;
|
|
10
|
+
/** Optional base URL for enterprise instances */
|
|
11
|
+
baseUrl?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const GitProviderValues: {
|
|
14
|
+
readonly UNKNOWN: "unknown";
|
|
15
|
+
readonly GITHUB: "github";
|
|
16
|
+
readonly GITLAB: "gitlab";
|
|
17
|
+
readonly BITBUCKET: "bitbucket";
|
|
18
|
+
readonly AZURE: "azure";
|
|
19
|
+
};
|
|
20
|
+
export type GitProvider = (typeof GitProviderValues)[keyof typeof GitProviderValues];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Provider-related types for the Git SDK.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.GitProviderValues = void 0;
|
|
7
|
+
exports.GitProviderValues = {
|
|
8
|
+
UNKNOWN: 'unknown',
|
|
9
|
+
GITHUB: 'github',
|
|
10
|
+
GITLAB: 'gitlab',
|
|
11
|
+
BITBUCKET: 'bitbucket',
|
|
12
|
+
AZURE: 'azure',
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/types/provider.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAaU,QAAA,iBAAiB,GAAG;IAC/B,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,SAAS,EAAE,WAAW;IACtB,KAAK,EAAE,OAAO;CACN,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { GitProvider } from './provider';
|
|
2
|
+
export interface NormalizedActor {
|
|
3
|
+
external_id?: string;
|
|
4
|
+
username?: string;
|
|
5
|
+
url?: string;
|
|
6
|
+
email?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface NormalizedCommit {
|
|
9
|
+
sha: string;
|
|
10
|
+
message: string;
|
|
11
|
+
url: string;
|
|
12
|
+
timestamp: string;
|
|
13
|
+
}
|
|
14
|
+
export interface NormalizedBranch {
|
|
15
|
+
name: string;
|
|
16
|
+
}
|
|
17
|
+
export interface NormalizedPullRequest {
|
|
18
|
+
id: string;
|
|
19
|
+
number: number;
|
|
20
|
+
title: string;
|
|
21
|
+
body: string | null;
|
|
22
|
+
url: string;
|
|
23
|
+
isDraft: boolean;
|
|
24
|
+
sourceBranch: NormalizedBranch;
|
|
25
|
+
targetBranch: NormalizedBranch;
|
|
26
|
+
sourceRepo?: NormalizedRepository;
|
|
27
|
+
createdAt: string;
|
|
28
|
+
updatedAt: string;
|
|
29
|
+
author: NormalizedActor;
|
|
30
|
+
}
|
|
31
|
+
export interface NormalizedRepository {
|
|
32
|
+
name: string;
|
|
33
|
+
id: string;
|
|
34
|
+
url: string;
|
|
35
|
+
provider: GitProvider;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Diff statistics for a pull request.
|
|
39
|
+
* Populated after merge to capture the final size of the change.
|
|
40
|
+
*/
|
|
41
|
+
export interface NormalizedDiffStats {
|
|
42
|
+
/** Total lines added across all files */
|
|
43
|
+
lines_added: number;
|
|
44
|
+
/** Total lines deleted across all files */
|
|
45
|
+
lines_deleted: number;
|
|
46
|
+
/** Total number of files changed */
|
|
47
|
+
files_changed: number;
|
|
48
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Normalized types for the Git SDK.
|
|
4
|
+
|
|
5
|
+
These types are used to normalize the data from the git providers
|
|
6
|
+
into a format that is easy to use in the Git SDK.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":";AAAA;;;;;EAKE"}
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@devrev/git-sdk",
|
|
3
|
+
"version": "0.11.0",
|
|
4
|
+
"description": "Git SDK containing adapter interfaces for git connectors to publish events from GitHub, GitLab, etc. into DevRev",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"lint": "eslint --ignore-path .gitignore .",
|
|
9
|
+
"lint:fix": "eslint --fix --ignore-path .gitignore .",
|
|
10
|
+
"build": "rimraf ./dist && tsc",
|
|
11
|
+
"build:watch": "tsc --watch",
|
|
12
|
+
"start": "ts-node ./src/index.ts",
|
|
13
|
+
"start:watch": "nodemon ./src/index.ts",
|
|
14
|
+
"test": "jest --detectOpenHandles",
|
|
15
|
+
"test:watch": "jest --detectOpenHandles --watch",
|
|
16
|
+
"clean": "rimraf ./dist"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [],
|
|
19
|
+
"author": "devrev",
|
|
20
|
+
"license": "ISC",
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@devrev/typescript-sdk": "^1.1.70",
|
|
23
|
+
"axios": "^1.13.5"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@babel/core": "^7.20.12",
|
|
27
|
+
"@babel/preset-env": "^7.21.5",
|
|
28
|
+
"@babel/preset-typescript": "^7.18.6",
|
|
29
|
+
"@types/jest": "^29.4.0",
|
|
30
|
+
"@types/node": "^18.13.0",
|
|
31
|
+
"@typescript-eslint/eslint-plugin": "^5.51.0",
|
|
32
|
+
"@typescript-eslint/parser": "^5.51.0",
|
|
33
|
+
"babel-jest": "^29.4.2",
|
|
34
|
+
"eslint": "^8.33.0",
|
|
35
|
+
"eslint-config-airbnb-typescript": "^17.0.0",
|
|
36
|
+
"eslint-config-prettier": "^10.1.8",
|
|
37
|
+
"eslint-plugin-import": "^2.27.5",
|
|
38
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
39
|
+
"jest": "^29.5.0",
|
|
40
|
+
"nodemon": "^3.1.10",
|
|
41
|
+
"prettier": "2.8.4",
|
|
42
|
+
"rimraf": "^4.1.2",
|
|
43
|
+
"ts-jest": "^29.0.5",
|
|
44
|
+
"ts-node": "^10.9.1",
|
|
45
|
+
"typescript": "^4.9.5"
|
|
46
|
+
},
|
|
47
|
+
"repository": {
|
|
48
|
+
"type": "git",
|
|
49
|
+
"url": "git+https://github.com/devrev/git-sdk.git"
|
|
50
|
+
},
|
|
51
|
+
"bugs": {
|
|
52
|
+
"url": "https://github.com/devrev/git-sdk/issues"
|
|
53
|
+
},
|
|
54
|
+
"homepage": "https://github.com/devrev/git-sdk#git-sdk",
|
|
55
|
+
"publishConfig": {
|
|
56
|
+
"registry": "https://registry.npmjs.org"
|
|
57
|
+
},
|
|
58
|
+
"files": [
|
|
59
|
+
"dist"
|
|
60
|
+
]
|
|
61
|
+
}
|