@gitbeaker/rest 36.0.0-rc.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/index.mjs ADDED
@@ -0,0 +1,270 @@
1
+ import { Resources } from '@gitbeaker/core';
2
+ export { Types } from '@gitbeaker/core';
3
+ import { createRequesterFn, presetResourceArguments, defaultOptionsHandler as defaultOptionsHandler$1 } from '@gitbeaker/requester-utils';
4
+
5
+ // src/index.ts
6
+ async function defaultOptionsHandler(resourceOptions, { body, searchParams, asStream, sudo, method } = {}) {
7
+ const options = await defaultOptionsHandler$1(resourceOptions, {
8
+ body,
9
+ searchParams,
10
+ asStream,
11
+ sudo,
12
+ method
13
+ });
14
+ if (resourceOptions.url.includes("https") && resourceOptions.rejectUnauthorized != null && resourceOptions.rejectUnauthorized === false) {
15
+ if (typeof window !== "object") {
16
+ const { Agent } = await import('https');
17
+ options.agent = new Agent({
18
+ rejectUnauthorized: false
19
+ });
20
+ }
21
+ }
22
+ return options;
23
+ }
24
+ async function processBody(response) {
25
+ const contentType = (response.headers.get("content-type") || "").split(";")[0].trim();
26
+ if (contentType === "application/json") {
27
+ return response.json().then((v) => v || {});
28
+ }
29
+ if (contentType.startsWith("text/")) {
30
+ return response.text().then((t) => t || "");
31
+ }
32
+ return response.arrayBuffer();
33
+ }
34
+ function delay(ms) {
35
+ return new Promise((resolve) => {
36
+ setTimeout(resolve, ms);
37
+ });
38
+ }
39
+ async function parseResponse(response, asStream = false) {
40
+ const { status, headers: rawHeaders } = response;
41
+ const headers = Object.fromEntries(rawHeaders.entries());
42
+ let body;
43
+ if (asStream) {
44
+ body = response.body;
45
+ } else {
46
+ body = status === 204 ? null : await processBody(response);
47
+ }
48
+ return { body, headers, status };
49
+ }
50
+ async function throwFailedRequestError(response) {
51
+ const content = await response.text();
52
+ const contentType = response.headers.get("Content-Type");
53
+ let description = "API Request Error";
54
+ if (contentType?.includes("application/json")) {
55
+ const output = JSON.parse(content);
56
+ description = output.error || output.message;
57
+ } else {
58
+ description = content;
59
+ }
60
+ throw new Error(response.statusText, {
61
+ cause: {
62
+ description,
63
+ response
64
+ }
65
+ });
66
+ }
67
+ async function defaultRequestHandler(endpoint, options) {
68
+ const retryCodes = [429, 502];
69
+ const maxRetries = 10;
70
+ const { prefixUrl, asStream, searchParams, ...opts } = options;
71
+ for (let i = 0; i < maxRetries; i += 1) {
72
+ const url = `${prefixUrl}${endpoint}${searchParams ? `?${searchParams}` : ""}`;
73
+ const response = await fetch(url, { ...opts, mode: "same-origin" });
74
+ if (response.ok)
75
+ return parseResponse(response, asStream);
76
+ if (!retryCodes.includes(response.status))
77
+ await throwFailedRequestError(response);
78
+ await delay(2 ** i * 0.1);
79
+ continue;
80
+ }
81
+ throw new Error("Could not successfully complete this request");
82
+ }
83
+ var requesterFn = createRequesterFn(defaultOptionsHandler, defaultRequestHandler);
84
+ var API = presetResourceArguments(Resources, { requesterFn });
85
+ var {
86
+ Agents,
87
+ AlertManagement,
88
+ ApplicationAppearance,
89
+ ApplicationPlanLimits,
90
+ Applications,
91
+ ApplicationSettings,
92
+ ApplicationStatistics,
93
+ AuditEvents,
94
+ Avatar,
95
+ BroadcastMessages,
96
+ Composer,
97
+ Conan,
98
+ DashboardAnnotations,
99
+ Debian,
100
+ DependencyProxy,
101
+ DeployKeys,
102
+ DeployTokens,
103
+ DockerfileTemplates,
104
+ Events,
105
+ Experiments,
106
+ GeoNodes,
107
+ GitignoreTemplates,
108
+ GitLabCIYMLTemplates,
109
+ Import,
110
+ InstanceLevelCICDVariables,
111
+ Keys,
112
+ License,
113
+ LicenseTemplates,
114
+ Lint,
115
+ ManagedLicenses,
116
+ Markdown,
117
+ Maven,
118
+ Metadata,
119
+ Migrations,
120
+ Namespaces,
121
+ NotificationSettings,
122
+ NPM,
123
+ NuGet,
124
+ PersonalAccessTokens,
125
+ PyPI,
126
+ Search,
127
+ ServiceData,
128
+ SidekiqMetrics,
129
+ SidekiqQueues,
130
+ SnippetRepositoryStorageMoves,
131
+ Snippets,
132
+ Suggestions,
133
+ SystemHooks,
134
+ TodoLists,
135
+ Topics,
136
+ Version,
137
+ Vulnerabilities,
138
+ Branches,
139
+ CommitDiscussions,
140
+ Commits,
141
+ ContainerRegistry,
142
+ Deployments,
143
+ Environments,
144
+ ErrorTrackingClientKeys,
145
+ ErrorTrackingSettings,
146
+ ExternalStatusChecks,
147
+ FeatureFlags,
148
+ FeatureFlagUserLists,
149
+ FreezePeriods,
150
+ GitlabPages,
151
+ GoProxy,
152
+ Helm,
153
+ Integrations,
154
+ IssueAwardEmojis,
155
+ IssueDiscussions,
156
+ IssueIterationEvents,
157
+ IssueLabelEvents,
158
+ IssueLinks,
159
+ IssueMilestoneEvents,
160
+ IssueNoteAwardEmojis,
161
+ IssueNotes,
162
+ Issues,
163
+ IssuesStatistics,
164
+ IssueStateEvents,
165
+ IssueWeightEvents,
166
+ JobArtifacts,
167
+ Jobs,
168
+ MergeRequestApprovals,
169
+ MergeRequestAwardEmojis,
170
+ MergeRequestContextCommits,
171
+ MergeRequestDiscussions,
172
+ MergeRequestLabelEvents,
173
+ MergeRequestMilestoneEvents,
174
+ MergeRequestNotes,
175
+ MergeRequests,
176
+ MergeTrains,
177
+ PackageRegistry,
178
+ Packages,
179
+ PagesDomains,
180
+ Pipelines,
181
+ PipelineSchedules,
182
+ PipelineScheduleVariables,
183
+ PipelineTriggerTokens,
184
+ ProductAnalytics,
185
+ ProjectAccessRequests,
186
+ ProjectAccessTokens,
187
+ ProjectAliases,
188
+ ProjectBadges,
189
+ ProjectCustomAttributes,
190
+ ProjectDORA4Metrics,
191
+ ProjectHooks,
192
+ ProjectImportExport,
193
+ ProjectInvitations,
194
+ ProjectIssueBoards,
195
+ ProjectIterations,
196
+ ProjectLabels,
197
+ ProjectMembers,
198
+ ProjectMilestones,
199
+ ProjectProtectedEnvironments,
200
+ ProjectPushRules,
201
+ ProjectRelationsExport,
202
+ ProjectReleases,
203
+ ProjectRemoteMirrors,
204
+ ProjectRepositoryStorageMoves,
205
+ Projects,
206
+ ProjectSnippetAwardEmojis,
207
+ ProjectSnippetDiscussions,
208
+ ProjectSnippetNotes,
209
+ ProjectSnippets,
210
+ ProjectStatistics,
211
+ ProjectTemplates,
212
+ ProjectVariables,
213
+ ProjectVulnerabilities,
214
+ ProjectWikis,
215
+ ProtectedBranches,
216
+ ProtectedTags,
217
+ ReleaseLinks,
218
+ Repositories,
219
+ RepositoryFiles,
220
+ RepositorySubmodules,
221
+ ResourceGroups,
222
+ Runners,
223
+ SecureFiles,
224
+ Tags,
225
+ UserStarredMetricsDashboard,
226
+ VisualReviewDiscussions,
227
+ VulnerabilityFindings,
228
+ EpicAwardEmojis,
229
+ EpicDiscussions,
230
+ EpicIssues,
231
+ EpicLabelEvents,
232
+ EpicLinks,
233
+ EpicNotes,
234
+ Epics,
235
+ GroupAccessRequests,
236
+ GroupAccessTokens,
237
+ GroupActivityAnalytics,
238
+ GroupBadges,
239
+ GroupCustomAttributes,
240
+ GroupDORA4Metrics,
241
+ GroupHooks,
242
+ GroupImportExports,
243
+ GroupInvitations,
244
+ GroupIssueBoards,
245
+ GroupIterations,
246
+ GroupLabels,
247
+ GroupLDAPLinks,
248
+ GroupMembers,
249
+ GroupMilestones,
250
+ GroupProtectedEnvironments,
251
+ GroupPushRules,
252
+ GroupRelationExports,
253
+ GroupReleases,
254
+ GroupRepositoryStorageMoves,
255
+ Groups,
256
+ GroupSAMLIdentities,
257
+ GroupSCIMIdentities,
258
+ GroupVariables,
259
+ GroupWikis,
260
+ LinkedEpics,
261
+ UserCustomAttributes,
262
+ UserEmails,
263
+ UserGPGKeys,
264
+ UserImpersonationTokens,
265
+ Users,
266
+ UserSSHKeys,
267
+ Gitlab
268
+ } = API;
269
+
270
+ export { Agents, AlertManagement, ApplicationAppearance, ApplicationPlanLimits, ApplicationSettings, ApplicationStatistics, Applications, AuditEvents, Avatar, Branches, BroadcastMessages, CommitDiscussions, Commits, Composer, Conan, ContainerRegistry, DashboardAnnotations, Debian, DependencyProxy, DeployKeys, DeployTokens, Deployments, DockerfileTemplates, Environments, EpicAwardEmojis, EpicDiscussions, EpicIssues, EpicLabelEvents, EpicLinks, EpicNotes, Epics, ErrorTrackingClientKeys, ErrorTrackingSettings, Events, Experiments, ExternalStatusChecks, FeatureFlagUserLists, FeatureFlags, FreezePeriods, GeoNodes, GitLabCIYMLTemplates, GitignoreTemplates, Gitlab, GitlabPages, GoProxy, GroupAccessRequests, GroupAccessTokens, GroupActivityAnalytics, GroupBadges, GroupCustomAttributes, GroupDORA4Metrics, GroupHooks, GroupImportExports, GroupInvitations, GroupIssueBoards, GroupIterations, GroupLDAPLinks, GroupLabels, GroupMembers, GroupMilestones, GroupProtectedEnvironments, GroupPushRules, GroupRelationExports, GroupReleases, GroupRepositoryStorageMoves, GroupSAMLIdentities, GroupSCIMIdentities, GroupVariables, GroupWikis, Groups, Helm, Import, InstanceLevelCICDVariables, Integrations, IssueAwardEmojis, IssueDiscussions, IssueIterationEvents, IssueLabelEvents, IssueLinks, IssueMilestoneEvents, IssueNoteAwardEmojis, IssueNotes, IssueStateEvents, IssueWeightEvents, Issues, IssuesStatistics, JobArtifacts, Jobs, Keys, License, LicenseTemplates, LinkedEpics, Lint, ManagedLicenses, Markdown, Maven, MergeRequestApprovals, MergeRequestAwardEmojis, MergeRequestContextCommits, MergeRequestDiscussions, MergeRequestLabelEvents, MergeRequestMilestoneEvents, MergeRequestNotes, MergeRequests, MergeTrains, Metadata, Migrations, NPM, Namespaces, NotificationSettings, NuGet, PackageRegistry, Packages, PagesDomains, PersonalAccessTokens, PipelineScheduleVariables, PipelineSchedules, PipelineTriggerTokens, Pipelines, ProductAnalytics, ProjectAccessRequests, ProjectAccessTokens, ProjectAliases, ProjectBadges, ProjectCustomAttributes, ProjectDORA4Metrics, ProjectHooks, ProjectImportExport, ProjectInvitations, ProjectIssueBoards, ProjectIterations, ProjectLabels, ProjectMembers, ProjectMilestones, ProjectProtectedEnvironments, ProjectPushRules, ProjectRelationsExport, ProjectReleases, ProjectRemoteMirrors, ProjectRepositoryStorageMoves, ProjectSnippetAwardEmojis, ProjectSnippetDiscussions, ProjectSnippetNotes, ProjectSnippets, ProjectStatistics, ProjectTemplates, ProjectVariables, ProjectVulnerabilities, ProjectWikis, Projects, ProtectedBranches, ProtectedTags, PyPI, ReleaseLinks, Repositories, RepositoryFiles, RepositorySubmodules, ResourceGroups, Runners, Search, SecureFiles, ServiceData, SidekiqMetrics, SidekiqQueues, SnippetRepositoryStorageMoves, Snippets, Suggestions, SystemHooks, Tags, TodoLists, Topics, UserCustomAttributes, UserEmails, UserGPGKeys, UserImpersonationTokens, UserSSHKeys, UserStarredMetricsDashboard, Users, Version, VisualReviewDiscussions, Vulnerabilities, VulnerabilityFindings };
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@gitbeaker/rest",
3
+ "version": "36.0.0-rc.0",
4
+ "description": "Cross Platform implementation of the GitLab API",
5
+ "license": "MIT",
6
+ "engines": {
7
+ "node": ">=18.0.0"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/jdalrymple/gitbeaker"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/jdalrymple/gitbeaker/issues"
15
+ },
16
+ "homepage": "https://github.com/jdalrymple/gitbeaker#readme",
17
+ "author": {
18
+ "name": "Justin Dalrymple"
19
+ },
20
+ "keywords": [
21
+ "gitbeaker",
22
+ "gitlab",
23
+ "api"
24
+ ],
25
+ "types": "./dist/index.d.ts",
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/index.d.ts",
29
+ "import": "./dist/index.mjs",
30
+ "require": "./dist/index.js"
31
+ }
32
+ },
33
+ "files": [
34
+ "dist"
35
+ ],
36
+ "scripts": {
37
+ "build": "tsup src/index.ts --format esm,cjs --dts --treeshake",
38
+ "test:types": "tsc",
39
+ "test:e2e:browser": "playwright test",
40
+ "test:e2e": "yarn test:e2e:browser",
41
+ "test:integration:nodejs": "jest --maxWorkers=50% test/integration/nodejs",
42
+ "test:integration": "yarn test:integration:nodejs",
43
+ "test:unit": "jest --maxWorkers=50% test/unit",
44
+ "format:docs": "prettier '**/(*.json|.yml|.js|.md)' --ignore-path ../../.prettierignore",
45
+ "format:docs:fix": "yarn format:docs --write",
46
+ "format:src": "prettier '{src,test}/**/*.ts' --ignore-path ../../.prettierignore",
47
+ "format:src:fix": "yarn format:src --write",
48
+ "format": "yarn format:src && yarn format:docs",
49
+ "format:fix": "yarn format:src:fix && yarn format:docs:fix",
50
+ "lint": "eslint '{src,test}/**/*.ts'",
51
+ "lint:fix": "yarn lint --fix"
52
+ },
53
+ "dependencies": {
54
+ "@gitbeaker/core": "35.1.0",
55
+ "@gitbeaker/requester-utils": "35.1.0"
56
+ },
57
+ "devDependencies": {
58
+ "@playwright/test": "^1.31.2",
59
+ "@types/node": "^18.15.0",
60
+ "playwright": "^1.31.2",
61
+ "tsup": "^6.6.3",
62
+ "typescript": "^4.9.5"
63
+ }
64
+ }