@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.
Files changed (95) hide show
  1. package/README.md +2 -0
  2. package/dist/adapter/adapter.d.ts +9 -0
  3. package/dist/adapter/adapter.js +3 -0
  4. package/dist/adapter/adapter.js.map +1 -0
  5. package/dist/config/create-config.d.ts +34 -0
  6. package/dist/config/create-config.js +33 -0
  7. package/dist/config/create-config.js.map +1 -0
  8. package/dist/config/index.d.ts +4 -0
  9. package/dist/config/index.js +9 -0
  10. package/dist/config/index.js.map +1 -0
  11. package/dist/devrev/client.d.ts +104 -0
  12. package/dist/devrev/client.js +113 -0
  13. package/dist/devrev/client.js.map +1 -0
  14. package/dist/devrev/http.d.ts +42 -0
  15. package/dist/devrev/http.js +105 -0
  16. package/dist/devrev/http.js.map +1 -0
  17. package/dist/devrev/index.d.ts +7 -0
  18. package/dist/devrev/index.js +43 -0
  19. package/dist/devrev/index.js.map +1 -0
  20. package/dist/devrev/managers/code_change_manager.d.ts +48 -0
  21. package/dist/devrev/managers/code_change_manager.js +227 -0
  22. package/dist/devrev/managers/code_change_manager.js.map +1 -0
  23. package/dist/devrev/managers/code_change_schema.d.ts +12 -0
  24. package/dist/devrev/managers/code_change_schema.js +317 -0
  25. package/dist/devrev/managers/code_change_schema.js.map +1 -0
  26. package/dist/devrev/managers/custom_link_type_manager.d.ts +33 -0
  27. package/dist/devrev/managers/custom_link_type_manager.js +94 -0
  28. package/dist/devrev/managers/custom_link_type_manager.js.map +1 -0
  29. package/dist/devrev/managers/dev_user_manager.d.ts +53 -0
  30. package/dist/devrev/managers/dev_user_manager.js +155 -0
  31. package/dist/devrev/managers/dev_user_manager.js.map +1 -0
  32. package/dist/devrev/managers/index.d.ts +9 -0
  33. package/dist/devrev/managers/index.js +20 -0
  34. package/dist/devrev/managers/index.js.map +1 -0
  35. package/dist/devrev/managers/link_manager.d.ts +41 -0
  36. package/dist/devrev/managers/link_manager.js +111 -0
  37. package/dist/devrev/managers/link_manager.js.map +1 -0
  38. package/dist/devrev/managers/tenant_fragment_manager.d.ts +26 -0
  39. package/dist/devrev/managers/tenant_fragment_manager.js +68 -0
  40. package/dist/devrev/managers/tenant_fragment_manager.js.map +1 -0
  41. package/dist/devrev/managers/timeline_manager.d.ts +86 -0
  42. package/dist/devrev/managers/timeline_manager.js +184 -0
  43. package/dist/devrev/managers/timeline_manager.js.map +1 -0
  44. package/dist/devrev/types.d.ts +139 -0
  45. package/dist/devrev/types.js +127 -0
  46. package/dist/devrev/types.js.map +1 -0
  47. package/dist/handlers/commit_push_handler.d.ts +31 -0
  48. package/dist/handlers/commit_push_handler.js +145 -0
  49. package/dist/handlers/commit_push_handler.js.map +1 -0
  50. package/dist/handlers/helpers.d.ts +87 -0
  51. package/dist/handlers/helpers.js +201 -0
  52. package/dist/handlers/helpers.js.map +1 -0
  53. package/dist/handlers/index.d.ts +12 -0
  54. package/dist/handlers/index.js +26 -0
  55. package/dist/handlers/index.js.map +1 -0
  56. package/dist/handlers/pr_create_handler.d.ts +36 -0
  57. package/dist/handlers/pr_create_handler.js +121 -0
  58. package/dist/handlers/pr_create_handler.js.map +1 -0
  59. package/dist/handlers/pr_merge_handler.d.ts +29 -0
  60. package/dist/handlers/pr_merge_handler.js +86 -0
  61. package/dist/handlers/pr_merge_handler.js.map +1 -0
  62. package/dist/handlers/pr_review_handler.d.ts +30 -0
  63. package/dist/handlers/pr_review_handler.js +109 -0
  64. package/dist/handlers/pr_review_handler.js.map +1 -0
  65. package/dist/handlers/registry.d.ts +9 -0
  66. package/dist/handlers/registry.js +22 -0
  67. package/dist/handlers/registry.js.map +1 -0
  68. package/dist/handlers/types.d.ts +46 -0
  69. package/dist/handlers/types.js +6 -0
  70. package/dist/handlers/types.js.map +1 -0
  71. package/dist/index.d.ts +12 -0
  72. package/dist/index.js +65 -0
  73. package/dist/index.js.map +1 -0
  74. package/dist/orchestrator/event_orchestrator.d.ts +99 -0
  75. package/dist/orchestrator/event_orchestrator.js +137 -0
  76. package/dist/orchestrator/event_orchestrator.js.map +1 -0
  77. package/dist/orchestrator/index.d.ts +7 -0
  78. package/dist/orchestrator/index.js +12 -0
  79. package/dist/orchestrator/index.js.map +1 -0
  80. package/dist/types/config.d.ts +22 -0
  81. package/dist/types/config.js +6 -0
  82. package/dist/types/config.js.map +1 -0
  83. package/dist/types/events.d.ts +50 -0
  84. package/dist/types/events.js +14 -0
  85. package/dist/types/events.js.map +1 -0
  86. package/dist/types/index.d.ts +7 -0
  87. package/dist/types/index.js +24 -0
  88. package/dist/types/index.js.map +1 -0
  89. package/dist/types/provider.d.ts +20 -0
  90. package/dist/types/provider.js +14 -0
  91. package/dist/types/provider.js.map +1 -0
  92. package/dist/types/types.d.ts +48 -0
  93. package/dist/types/types.js +9 -0
  94. package/dist/types/types.js.map +1 -0
  95. package/package.json +61 -0
package/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # git-sdk
2
+ Git SDK contains adapter interfaces that a git connector can implement and use the sdk methods to publish events from the git tool (GitHub, GitLab, etc.) into DevRev.
@@ -0,0 +1,9 @@
1
+ import { NormalizedEvent } from '../types/events';
2
+ import { NormalizedCommit, NormalizedDiffStats, NormalizedPullRequest } from '../types/types';
3
+ export interface IProviderAdapter {
4
+ normalizeEvent(event: any): NormalizedEvent;
5
+ extractWorkIds(pullRequest: NormalizedPullRequest): Set<string>;
6
+ getPullRequestByCommit(commit: NormalizedCommit): NormalizedPullRequest[];
7
+ getHistoricCommitsForPullRequest(pullRequest: NormalizedPullRequest): NormalizedCommit[];
8
+ getPullRequestDiffStats(pullRequest: NormalizedPullRequest): Promise<NormalizedDiffStats>;
9
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../src/adapter/adapter.ts"],"names":[],"mappings":""}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * SDK configuration factory function.
3
+ */
4
+ import { SDKConfiguration, DevRevConfig } from '../types/config';
5
+ import { ProviderContext } from '../types/provider';
6
+ /**
7
+ * Options for creating SDK configuration.
8
+ */
9
+ export interface CreateConfigOptions {
10
+ /** DevRev API configuration (required) */
11
+ devrev: DevRevConfig;
12
+ /** Provider context with auth token (required) */
13
+ provider: ProviderContext;
14
+ }
15
+ /**
16
+ * Creates an SDK configuration with sensible defaults.
17
+ *
18
+ * @param options - Configuration options
19
+ * @returns Complete SDK configuration
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * const config = createConfig({
24
+ * devrev: {
25
+ * endpoint: 'https://api.devrev.ai',
26
+ * token: process.env.DEVREV_TOKEN!,
27
+ * },
28
+ * provider: {
29
+ * token: process.env.GIT_PROVIDER_TOKEN!,
30
+ * },
31
+ * });
32
+ * ```
33
+ */
34
+ export declare function createConfig(options: CreateConfigOptions): SDKConfiguration;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ /**
3
+ * SDK configuration factory function.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createConfig = void 0;
7
+ /**
8
+ * Creates an SDK configuration with sensible defaults.
9
+ *
10
+ * @param options - Configuration options
11
+ * @returns Complete SDK configuration
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const config = createConfig({
16
+ * devrev: {
17
+ * endpoint: 'https://api.devrev.ai',
18
+ * token: process.env.DEVREV_TOKEN!,
19
+ * },
20
+ * provider: {
21
+ * token: process.env.GIT_PROVIDER_TOKEN!,
22
+ * },
23
+ * });
24
+ * ```
25
+ */
26
+ function createConfig(options) {
27
+ return {
28
+ devrev: options.devrev,
29
+ provider: options.provider,
30
+ };
31
+ }
32
+ exports.createConfig = createConfig;
33
+ //# sourceMappingURL=create-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-config.js","sourceRoot":"","sources":["../../src/config/create-config.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAkBH;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,YAAY,CAAC,OAA4B;IACvD,OAAO;QACL,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,QAAQ,EAAE,OAAO,CAAC,QAAQ;KAC3B,CAAC;AACJ,CAAC;AALD,oCAKC"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Configuration exports for the Git SDK.
3
+ */
4
+ export { createConfig, type CreateConfigOptions } from './create-config';
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ /**
3
+ * Configuration exports for the Git SDK.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createConfig = void 0;
7
+ var create_config_1 = require("./create-config");
8
+ Object.defineProperty(exports, "createConfig", { enumerable: true, get: function () { return create_config_1.createConfig; } });
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,iDAAyE;AAAhE,6GAAA,YAAY,OAAA"}
@@ -0,0 +1,104 @@
1
+ /**
2
+ * DevRev Client - Main entry point for DevRev API operations.
3
+ */
4
+ import { betaSDK, publicSDK } from '@devrev/typescript-sdk';
5
+ import { CodeChangeManager, CustomLinkTypeManager, DevUserManager, LinkManager, TenantFragmentManager, TimelineManager } from './managers';
6
+ import { GitProvider } from './types';
7
+ /**
8
+ * Configuration for the DevRev client.
9
+ */
10
+ export interface DevRevClientConfig {
11
+ /** DevRev API endpoint */
12
+ endpoint: string;
13
+ /** DevRev API token (service account token) */
14
+ token: string;
15
+ /** Git provider (defaults to 'unknown') */
16
+ provider?: GitProvider;
17
+ }
18
+ /**
19
+ * DevRev Client - Provides access to all DevRev API operations
20
+ * used for code_change functionality.
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * const devrev = new DevRevClient({
25
+ * endpoint: 'https://api.devrev.ai',
26
+ * token: serviceAccountToken,
27
+ * provider: 'github', // or 'gitlab', 'bitbucket', 'azure', etc.
28
+ * });
29
+ *
30
+ * // Create code_change custom object
31
+ * const codeChange = await devrev.codeChange.create({
32
+ * title: 'My PR',
33
+ * source: CodeChangeSource.GITHUB, // Use the source matching your provider
34
+ * repo_name: 'org/repo',
35
+ * source_branch: 'feature/x',
36
+ * target_branch: 'main',
37
+ * external_url: 'https://example.com/org/repo/changes/1',
38
+ * status: CodeChangeStatus.WAITING_FOR_REVIEW,
39
+ * });
40
+ *
41
+ * // Create link to issue
42
+ * await devrev.link.createIssueCodeChangeLink('ISS-123', codeChange.id);
43
+ *
44
+ * // Create timeline entry
45
+ * const changeEvent = devrev.timeline.createChangeEventBody(...);
46
+ * await devrev.timeline.createEventEntry(codeChange.id, changeEvent);
47
+ * ```
48
+ */
49
+ export declare class DevRevClient {
50
+ /** Manager for code_change custom object operations */
51
+ readonly codeChange: CodeChangeManager;
52
+ /** Manager for tenant fragment (schema) operations */
53
+ readonly tenantFragment: TenantFragmentManager;
54
+ /** Manager for custom link type operations */
55
+ readonly customLinkType: CustomLinkTypeManager;
56
+ /** Manager for link CRUD operations */
57
+ readonly link: LinkManager;
58
+ /** Manager for timeline entry operations */
59
+ readonly timeline: TimelineManager;
60
+ /** Manager for DevRev user resolution */
61
+ readonly devUser: DevUserManager;
62
+ /** The DevRev API endpoint */
63
+ readonly endpoint: string;
64
+ /** The DevRev Beta SDK instance */
65
+ private readonly betaApi;
66
+ /** The DevRev Public SDK instance */
67
+ private readonly publicApi;
68
+ /**
69
+ * Creates a new DevRev client instance.
70
+ *
71
+ * @param config - The client configuration
72
+ */
73
+ constructor(config: DevRevClientConfig);
74
+ /**
75
+ * Initializes all required resources for code_change functionality.
76
+ * Call this during snap-in activation to ensure all schemas and link types exist.
77
+ *
78
+ * @returns Results of initialization
79
+ */
80
+ initialize(): Promise<{
81
+ tenantFragment: {
82
+ success: boolean;
83
+ fragmentId?: string;
84
+ error?: string;
85
+ };
86
+ customLinkType: {
87
+ success: boolean;
88
+ linkTypeId?: string;
89
+ error?: string;
90
+ };
91
+ }>;
92
+ /**
93
+ * Gets the Beta SDK instance for advanced operations.
94
+ *
95
+ * @returns The Beta SDK API instance
96
+ */
97
+ getBetaApi(): betaSDK.Api<unknown>;
98
+ /**
99
+ * Gets the Public SDK instance for advanced operations.
100
+ *
101
+ * @returns The Public SDK API instance
102
+ */
103
+ getPublicApi(): publicSDK.Api<unknown>;
104
+ }
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ /**
3
+ * DevRev Client - Main entry point for DevRev API operations.
4
+ */
5
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
7
+ return new (P || (P = Promise))(function (resolve, reject) {
8
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
9
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
10
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
11
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
12
+ });
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.DevRevClient = void 0;
16
+ const typescript_sdk_1 = require("@devrev/typescript-sdk");
17
+ const managers_1 = require("./managers");
18
+ const types_1 = require("./types");
19
+ /**
20
+ * DevRev Client - Provides access to all DevRev API operations
21
+ * used for code_change functionality.
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * const devrev = new DevRevClient({
26
+ * endpoint: 'https://api.devrev.ai',
27
+ * token: serviceAccountToken,
28
+ * provider: 'github', // or 'gitlab', 'bitbucket', 'azure', etc.
29
+ * });
30
+ *
31
+ * // Create code_change custom object
32
+ * const codeChange = await devrev.codeChange.create({
33
+ * title: 'My PR',
34
+ * source: CodeChangeSource.GITHUB, // Use the source matching your provider
35
+ * repo_name: 'org/repo',
36
+ * source_branch: 'feature/x',
37
+ * target_branch: 'main',
38
+ * external_url: 'https://example.com/org/repo/changes/1',
39
+ * status: CodeChangeStatus.WAITING_FOR_REVIEW,
40
+ * });
41
+ *
42
+ * // Create link to issue
43
+ * await devrev.link.createIssueCodeChangeLink('ISS-123', codeChange.id);
44
+ *
45
+ * // Create timeline entry
46
+ * const changeEvent = devrev.timeline.createChangeEventBody(...);
47
+ * await devrev.timeline.createEventEntry(codeChange.id, changeEvent);
48
+ * ```
49
+ */
50
+ class DevRevClient {
51
+ /**
52
+ * Creates a new DevRev client instance.
53
+ *
54
+ * @param config - The client configuration
55
+ */
56
+ constructor(config) {
57
+ var _a;
58
+ this.endpoint = config.endpoint;
59
+ const provider = (_a = config.provider) !== null && _a !== void 0 ? _a : types_1.GitProviderValues.UNKNOWN;
60
+ // Initialize SDKs
61
+ this.betaApi = typescript_sdk_1.client.setupBeta({
62
+ endpoint: config.endpoint,
63
+ token: config.token,
64
+ });
65
+ this.publicApi = typescript_sdk_1.client.setup({
66
+ endpoint: config.endpoint,
67
+ token: config.token,
68
+ });
69
+ // Initialize managers
70
+ this.codeChange = new managers_1.CodeChangeManager(this.betaApi, config.endpoint, config.token);
71
+ this.tenantFragment = new managers_1.TenantFragmentManager(this.betaApi);
72
+ this.customLinkType = new managers_1.CustomLinkTypeManager(this.betaApi);
73
+ this.link = new managers_1.LinkManager(this.betaApi, this.customLinkType);
74
+ this.timeline = new managers_1.TimelineManager(this.publicApi, config.endpoint, config.token, provider);
75
+ this.devUser = new managers_1.DevUserManager(this.betaApi, provider);
76
+ }
77
+ /**
78
+ * Initializes all required resources for code_change functionality.
79
+ * Call this during snap-in activation to ensure all schemas and link types exist.
80
+ *
81
+ * @returns Results of initialization
82
+ */
83
+ initialize() {
84
+ return __awaiter(this, void 0, void 0, function* () {
85
+ const [tenantFragmentResult, customLinkTypeResult] = yield Promise.all([
86
+ this.tenantFragment.getOrCreateCodeChangeFragment(),
87
+ this.customLinkType.getOrCreateIssueCodeChangeLinkType(),
88
+ ]);
89
+ return {
90
+ tenantFragment: tenantFragmentResult,
91
+ customLinkType: customLinkTypeResult,
92
+ };
93
+ });
94
+ }
95
+ /**
96
+ * Gets the Beta SDK instance for advanced operations.
97
+ *
98
+ * @returns The Beta SDK API instance
99
+ */
100
+ getBetaApi() {
101
+ return this.betaApi;
102
+ }
103
+ /**
104
+ * Gets the Public SDK instance for advanced operations.
105
+ *
106
+ * @returns The Public SDK API instance
107
+ */
108
+ getPublicApi() {
109
+ return this.publicApi;
110
+ }
111
+ }
112
+ exports.DevRevClient = DevRevClient;
113
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/devrev/client.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;AAEH,2DAAoE;AAEpE,yCAOoB;AACpB,mCAAyD;AAczD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAa,YAAY;IA4BvB;;;;OAIG;IACH,YAAY,MAA0B;;QACpC,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QAChC,MAAM,QAAQ,GAAG,MAAA,MAAM,CAAC,QAAQ,mCAAI,yBAAiB,CAAC,OAAO,CAAC;QAE9D,kBAAkB;QAClB,IAAI,CAAC,OAAO,GAAG,uBAAM,CAAC,SAAS,CAAC;YAC9B,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,KAAK,EAAE,MAAM,CAAC,KAAK;SACpB,CAAC,CAAC;QAEH,IAAI,CAAC,SAAS,GAAG,uBAAM,CAAC,KAAK,CAAC;YAC5B,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,KAAK,EAAE,MAAM,CAAC,KAAK;SACpB,CAAC,CAAC;QAEH,sBAAsB;QACtB,IAAI,CAAC,UAAU,GAAG,IAAI,4BAAiB,CACrC,IAAI,CAAC,OAAO,EACZ,MAAM,CAAC,QAAQ,EACf,MAAM,CAAC,KAAK,CACb,CAAC;QAEF,IAAI,CAAC,cAAc,GAAG,IAAI,gCAAqB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAE9D,IAAI,CAAC,cAAc,GAAG,IAAI,gCAAqB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAE9D,IAAI,CAAC,IAAI,GAAG,IAAI,sBAAW,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QAE/D,IAAI,CAAC,QAAQ,GAAG,IAAI,0BAAe,CACjC,IAAI,CAAC,SAAS,EACd,MAAM,CAAC,QAAQ,EACf,MAAM,CAAC,KAAK,EACZ,QAAQ,CACT,CAAC;QAEF,IAAI,CAAC,OAAO,GAAG,IAAI,yBAAc,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC5D,CAAC;IAED;;;;;OAKG;IACG,UAAU;;YAId,MAAM,CAAC,oBAAoB,EAAE,oBAAoB,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;gBACrE,IAAI,CAAC,cAAc,CAAC,6BAA6B,EAAE;gBACnD,IAAI,CAAC,cAAc,CAAC,kCAAkC,EAAE;aACzD,CAAC,CAAC;YAEH,OAAO;gBACL,cAAc,EAAE,oBAAoB;gBACpC,cAAc,EAAE,oBAAoB;aACrC,CAAC;QACJ,CAAC;KAAA;IAED;;;;OAIG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACH,YAAY;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF;AA7GD,oCA6GC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * HTTP utilities for DevRev API calls.
3
+ */
4
+ /**
5
+ * Standard HTTP response structure.
6
+ */
7
+ export interface HTTPResponse<T = any> {
8
+ success: boolean;
9
+ message: string;
10
+ data: T;
11
+ headers?: Record<string, string>;
12
+ }
13
+ /**
14
+ * Default response object.
15
+ */
16
+ export declare const defaultResponse: HTTPResponse;
17
+ /**
18
+ * Makes a POST request to the specified endpoint.
19
+ *
20
+ * @param endpoint - The API endpoint URL
21
+ * @param token - The authorization token
22
+ * @param payload - The request body
23
+ * @param extraHeaders - Additional headers to include
24
+ * @returns HTTP response with success status, data, and any error message
25
+ */
26
+ export declare function postCall<T = any>(endpoint: string, token: string, payload: Record<string, any>, extraHeaders?: Record<string, string>): Promise<HTTPResponse<T>>;
27
+ /**
28
+ * Makes a GET request to the specified endpoint.
29
+ *
30
+ * @param endpoint - The API endpoint URL
31
+ * @param token - The authorization token
32
+ * @returns HTTP response with success status, data, and any error message
33
+ */
34
+ export declare function getCall<T = any>(endpoint: string, token: string): Promise<HTTPResponse<T>>;
35
+ /**
36
+ * Constructs a URL with query parameters.
37
+ *
38
+ * @param endpoint - The base endpoint URL
39
+ * @param params - Key-value pairs to add as query parameters
40
+ * @returns The full URL with query parameters
41
+ */
42
+ export declare function constructURL(endpoint: string, params: Record<string, any>): string;
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ /**
3
+ * HTTP utilities for DevRev API calls.
4
+ */
5
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
7
+ return new (P || (P = Promise))(function (resolve, reject) {
8
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
9
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
10
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
11
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
12
+ });
13
+ };
14
+ var __importDefault = (this && this.__importDefault) || function (mod) {
15
+ return (mod && mod.__esModule) ? mod : { "default": mod };
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.constructURL = exports.getCall = exports.postCall = exports.defaultResponse = void 0;
19
+ const axios_1 = __importDefault(require("axios"));
20
+ const types_1 = require("./types");
21
+ /**
22
+ * Default response object.
23
+ */
24
+ exports.defaultResponse = {
25
+ success: false,
26
+ message: '',
27
+ data: {},
28
+ };
29
+ /**
30
+ * Converts an unknown error into a failed HTTPResponse.
31
+ * Extracts structured data from Axios errors when available, otherwise
32
+ * falls back to a generic error message.
33
+ *
34
+ * @param error - The caught error
35
+ * @returns A failed HTTPResponse with an appropriate error message
36
+ */
37
+ function buildErrorResponse(error) {
38
+ if (axios_1.default.isAxiosError(error) && error.response) {
39
+ return Object.assign(Object.assign({}, exports.defaultResponse), { message: JSON.stringify(error.response.data) });
40
+ }
41
+ return Object.assign(Object.assign({}, exports.defaultResponse), { message: (0, types_1.getErrorMessage)(error) });
42
+ }
43
+ /**
44
+ * Makes a POST request to the specified endpoint.
45
+ *
46
+ * @param endpoint - The API endpoint URL
47
+ * @param token - The authorization token
48
+ * @param payload - The request body
49
+ * @param extraHeaders - Additional headers to include
50
+ * @returns HTTP response with success status, data, and any error message
51
+ */
52
+ function postCall(endpoint, token, payload, extraHeaders = {}) {
53
+ return __awaiter(this, void 0, void 0, function* () {
54
+ try {
55
+ const response = yield axios_1.default.post(endpoint, payload, {
56
+ headers: Object.assign({ Authorization: token, 'Content-Type': 'application/json' }, extraHeaders),
57
+ });
58
+ return Object.assign(Object.assign({}, exports.defaultResponse), { data: response.data, headers: response.headers, success: true });
59
+ }
60
+ catch (error) {
61
+ return buildErrorResponse(error);
62
+ }
63
+ });
64
+ }
65
+ exports.postCall = postCall;
66
+ /**
67
+ * Makes a GET request to the specified endpoint.
68
+ *
69
+ * @param endpoint - The API endpoint URL
70
+ * @param token - The authorization token
71
+ * @returns HTTP response with success status, data, and any error message
72
+ */
73
+ function getCall(endpoint, token) {
74
+ return __awaiter(this, void 0, void 0, function* () {
75
+ try {
76
+ const response = yield axios_1.default.get(endpoint, {
77
+ headers: {
78
+ Authorization: token,
79
+ },
80
+ });
81
+ return Object.assign(Object.assign({}, exports.defaultResponse), { data: response.data, success: true });
82
+ }
83
+ catch (error) {
84
+ return buildErrorResponse(error);
85
+ }
86
+ });
87
+ }
88
+ exports.getCall = getCall;
89
+ /**
90
+ * Constructs a URL with query parameters.
91
+ *
92
+ * @param endpoint - The base endpoint URL
93
+ * @param params - Key-value pairs to add as query parameters
94
+ * @returns The full URL with query parameters
95
+ */
96
+ function constructURL(endpoint, params) {
97
+ const url = new URL(endpoint);
98
+ const searchParams = url.searchParams;
99
+ for (const key in params) {
100
+ searchParams.append(key, params[key]);
101
+ }
102
+ return url.toString();
103
+ }
104
+ exports.constructURL = constructURL;
105
+ //# sourceMappingURL=http.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/devrev/http.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;AAEH,kDAA0B;AAE1B,mCAA0C;AAY1C;;GAEG;AACU,QAAA,eAAe,GAAiB;IAC3C,OAAO,EAAE,KAAK;IACd,OAAO,EAAE,EAAE;IACX,IAAI,EAAE,EAAE;CACT,CAAC;AAEF;;;;;;;GAOG;AACH,SAAS,kBAAkB,CAAC,KAAc;IACxC,IAAI,eAAK,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,QAAQ,EAAE;QAC/C,uCACK,uBAAe,KAClB,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,IAC5C;KACH;IACD,uCACK,uBAAe,KAClB,OAAO,EAAE,IAAA,uBAAe,EAAC,KAAK,CAAC,IAC/B;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,SAAsB,QAAQ,CAC5B,QAAgB,EAChB,KAAa,EACb,OAA4B,EAC5B,eAAuC,EAAE;;QAEzC,IAAI;YACF,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE;gBACnD,OAAO,kBACL,aAAa,EAAE,KAAK,EACpB,cAAc,EAAE,kBAAkB,IAC/B,YAAY,CAChB;aACF,CAAC,CAAC;YAEH,uCACK,uBAAe,KAClB,IAAI,EAAE,QAAQ,CAAC,IAAI,EACnB,OAAO,EAAE,QAAQ,CAAC,OAAiC,EACnD,OAAO,EAAE,IAAI,IACb;SACH;QAAC,OAAO,KAAc,EAAE;YACvB,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC;SAClC;IACH,CAAC;CAAA;AAxBD,4BAwBC;AAED;;;;;;GAMG;AACH,SAAsB,OAAO,CAC3B,QAAgB,EAChB,KAAa;;QAEb,IAAI;YACF,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAAC,QAAQ,EAAE;gBACzC,OAAO,EAAE;oBACP,aAAa,EAAE,KAAK;iBACrB;aACF,CAAC,CAAC;YAEH,uCACK,uBAAe,KAClB,IAAI,EAAE,QAAQ,CAAC,IAAI,EACnB,OAAO,EAAE,IAAI,IACb;SACH;QAAC,OAAO,KAAc,EAAE;YACvB,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC;SAClC;IACH,CAAC;CAAA;AAnBD,0BAmBC;AAED;;;;;;GAMG;AACH,SAAgB,YAAY,CAC1B,QAAgB,EAChB,MAA2B;IAE3B,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC9B,MAAM,YAAY,GAAG,GAAG,CAAC,YAAY,CAAC;IACtC,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE;QACxB,YAAY,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;KACvC;IACD,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AACxB,CAAC;AAVD,oCAUC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * DevRev client module exports.
3
+ */
4
+ export { DevRevClient, type DevRevClientConfig } from './client';
5
+ export { getErrorMessage, getCodeChangeSourceFromProvider, CODE_CHANGE_LEAF_TYPE, TF_PREFIX, tf, ISSUE_CODE_CHANGE_LINK_TYPE_NAME, ISSUE_CODE_CHANGE_LINK_TOOLTIP, ISSUE_CODE_CHANGE_FORWARD_NAME, ISSUE_CODE_CHANGE_BACKWARD_NAME, CodeChangeSource, CodeChangeStatus, CodeChangeFields, GitProviderValues, type GitProvider, type CodeChangeSourceType, type CodeChangeStatusType, type CodeChangeCustomCreateRequest, type CodeChangeCustomUpdateRequest, type TimelineEventMetadata, type ChangeEventBody, } from './types';
6
+ export { postCall, getCall, constructURL, type HTTPResponse } from './http';
7
+ export { CodeChangeManager, TenantFragmentManager, CustomLinkTypeManager, LinkManager, TimelineManager, DevUserManager, EventMetadataKeys, type TenantFragmentResult, type CustomLinkTypeInstallResult, type TimelineResult, } from './managers';
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ /**
3
+ * DevRev client module exports.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.EventMetadataKeys = exports.DevUserManager = exports.TimelineManager = exports.LinkManager = exports.CustomLinkTypeManager = exports.TenantFragmentManager = exports.CodeChangeManager = exports.constructURL = exports.getCall = exports.postCall = exports.GitProviderValues = exports.CodeChangeFields = exports.CodeChangeStatus = exports.CodeChangeSource = exports.ISSUE_CODE_CHANGE_BACKWARD_NAME = exports.ISSUE_CODE_CHANGE_FORWARD_NAME = exports.ISSUE_CODE_CHANGE_LINK_TOOLTIP = exports.ISSUE_CODE_CHANGE_LINK_TYPE_NAME = exports.tf = exports.TF_PREFIX = exports.CODE_CHANGE_LEAF_TYPE = exports.getCodeChangeSourceFromProvider = exports.getErrorMessage = exports.DevRevClient = void 0;
7
+ // Main client
8
+ var client_1 = require("./client");
9
+ Object.defineProperty(exports, "DevRevClient", { enumerable: true, get: function () { return client_1.DevRevClient; } });
10
+ // Types
11
+ var types_1 = require("./types");
12
+ // Utilities
13
+ Object.defineProperty(exports, "getErrorMessage", { enumerable: true, get: function () { return types_1.getErrorMessage; } });
14
+ Object.defineProperty(exports, "getCodeChangeSourceFromProvider", { enumerable: true, get: function () { return types_1.getCodeChangeSourceFromProvider; } });
15
+ // Constants
16
+ Object.defineProperty(exports, "CODE_CHANGE_LEAF_TYPE", { enumerable: true, get: function () { return types_1.CODE_CHANGE_LEAF_TYPE; } });
17
+ Object.defineProperty(exports, "TF_PREFIX", { enumerable: true, get: function () { return types_1.TF_PREFIX; } });
18
+ Object.defineProperty(exports, "tf", { enumerable: true, get: function () { return types_1.tf; } });
19
+ Object.defineProperty(exports, "ISSUE_CODE_CHANGE_LINK_TYPE_NAME", { enumerable: true, get: function () { return types_1.ISSUE_CODE_CHANGE_LINK_TYPE_NAME; } });
20
+ Object.defineProperty(exports, "ISSUE_CODE_CHANGE_LINK_TOOLTIP", { enumerable: true, get: function () { return types_1.ISSUE_CODE_CHANGE_LINK_TOOLTIP; } });
21
+ Object.defineProperty(exports, "ISSUE_CODE_CHANGE_FORWARD_NAME", { enumerable: true, get: function () { return types_1.ISSUE_CODE_CHANGE_FORWARD_NAME; } });
22
+ Object.defineProperty(exports, "ISSUE_CODE_CHANGE_BACKWARD_NAME", { enumerable: true, get: function () { return types_1.ISSUE_CODE_CHANGE_BACKWARD_NAME; } });
23
+ // Enums
24
+ Object.defineProperty(exports, "CodeChangeSource", { enumerable: true, get: function () { return types_1.CodeChangeSource; } });
25
+ Object.defineProperty(exports, "CodeChangeStatus", { enumerable: true, get: function () { return types_1.CodeChangeStatus; } });
26
+ Object.defineProperty(exports, "CodeChangeFields", { enumerable: true, get: function () { return types_1.CodeChangeFields; } });
27
+ // Git Provider (re-exported from types/provider.ts)
28
+ Object.defineProperty(exports, "GitProviderValues", { enumerable: true, get: function () { return types_1.GitProviderValues; } });
29
+ // HTTP utilities
30
+ var http_1 = require("./http");
31
+ Object.defineProperty(exports, "postCall", { enumerable: true, get: function () { return http_1.postCall; } });
32
+ Object.defineProperty(exports, "getCall", { enumerable: true, get: function () { return http_1.getCall; } });
33
+ Object.defineProperty(exports, "constructURL", { enumerable: true, get: function () { return http_1.constructURL; } });
34
+ // Managers
35
+ var managers_1 = require("./managers");
36
+ Object.defineProperty(exports, "CodeChangeManager", { enumerable: true, get: function () { return managers_1.CodeChangeManager; } });
37
+ Object.defineProperty(exports, "TenantFragmentManager", { enumerable: true, get: function () { return managers_1.TenantFragmentManager; } });
38
+ Object.defineProperty(exports, "CustomLinkTypeManager", { enumerable: true, get: function () { return managers_1.CustomLinkTypeManager; } });
39
+ Object.defineProperty(exports, "LinkManager", { enumerable: true, get: function () { return managers_1.LinkManager; } });
40
+ Object.defineProperty(exports, "TimelineManager", { enumerable: true, get: function () { return managers_1.TimelineManager; } });
41
+ Object.defineProperty(exports, "DevUserManager", { enumerable: true, get: function () { return managers_1.DevUserManager; } });
42
+ Object.defineProperty(exports, "EventMetadataKeys", { enumerable: true, get: function () { return managers_1.EventMetadataKeys; } });
43
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/devrev/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,cAAc;AACd,mCAAiE;AAAxD,sGAAA,YAAY,OAAA;AAErB,QAAQ;AACR,iCA0BiB;AAzBf,YAAY;AACZ,wGAAA,eAAe,OAAA;AACf,wHAAA,+BAA+B,OAAA;AAC/B,YAAY;AACZ,8GAAA,qBAAqB,OAAA;AACrB,kGAAA,SAAS,OAAA;AACT,2FAAA,EAAE,OAAA;AACF,yHAAA,gCAAgC,OAAA;AAChC,uHAAA,8BAA8B,OAAA;AAC9B,uHAAA,8BAA8B,OAAA;AAC9B,wHAAA,+BAA+B,OAAA;AAC/B,QAAQ;AACR,yGAAA,gBAAgB,OAAA;AAChB,yGAAA,gBAAgB,OAAA;AAChB,yGAAA,gBAAgB,OAAA;AAChB,oDAAoD;AACpD,0GAAA,iBAAiB,OAAA;AAWnB,iBAAiB;AACjB,+BAA4E;AAAnE,gGAAA,QAAQ,OAAA;AAAE,+FAAA,OAAO,OAAA;AAAE,oGAAA,YAAY,OAAA;AAExC,WAAW;AACX,uCAWoB;AAVlB,6GAAA,iBAAiB,OAAA;AACjB,iHAAA,qBAAqB,OAAA;AACrB,iHAAA,qBAAqB,OAAA;AACrB,uGAAA,WAAW,OAAA;AACX,2GAAA,eAAe,OAAA;AACf,0GAAA,cAAc,OAAA;AACd,6GAAA,iBAAiB,OAAA"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Manager for code_change custom object operations.
3
+ */
4
+ import { CustomObject } from '@devrev/typescript-sdk/dist/auto-generated/beta/beta-devrev-sdk';
5
+ import { CodeChangeCustomCreateRequest, CodeChangeCustomUpdateRequest } from '../types';
6
+ import type { betaSDK } from '@devrev/typescript-sdk';
7
+ /**
8
+ * Manager for code_change custom object CRUD operations.
9
+ */
10
+ export declare class CodeChangeManager {
11
+ private betaApi;
12
+ private endpoint;
13
+ private token;
14
+ constructor(betaApi: betaSDK.Api<unknown>, endpoint: string, token: string);
15
+ /**
16
+ * Creates a new code_change custom object.
17
+ *
18
+ * @param data - The code change data to create
19
+ * @returns The created custom object
20
+ */
21
+ create(data: CodeChangeCustomCreateRequest): Promise<CustomObject>;
22
+ /**
23
+ * Updates an existing code_change custom object.
24
+ *
25
+ * @param data - The update data
26
+ * @param currentObject - The current object state (required for array operations)
27
+ * @returns The updated custom object
28
+ */
29
+ update(data: CodeChangeCustomUpdateRequest, currentObject?: CustomObject): Promise<CustomObject>;
30
+ /**
31
+ * Appends new IDs to an array custom field, deduplicating against existing values.
32
+ * Only writes to customFields if there are genuinely new entries to add.
33
+ *
34
+ * @param customFields - The target custom fields object being built for the update
35
+ * @param currentCustomFields - The current custom fields from the existing object
36
+ * @param field - The CodeChangeFields enum key for the array field
37
+ * @param addIds - The IDs to append (may be undefined or empty)
38
+ */
39
+ private mergeArrayField;
40
+ /**
41
+ * Gets a code_change custom object by PR URL.
42
+ * Since PR URL is a unique identifier, this returns a single object or null.
43
+ *
44
+ * @param prUrl - The pull request URL to search for
45
+ * @returns The matching custom object or null if not found
46
+ */
47
+ getByPrUrl(prUrl: string): Promise<CustomObject | null>;
48
+ }