Socket
Socket
Sign inDemoInstall

@sdc224/gitlab-api

Package Overview
Dependencies
2
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.2 to 1.2.0

dist/types/models/Common.d.ts

200

dist/index.esm.js
/*!
* @sdc224/gitlab-api v1.1.2
* @sdc224/gitlab-api v1.2.0
* (c) Sourodeep Chatterjee. All Rights Reserved

@@ -41,3 +41,16 @@ * Released under the MIT License.

method: "get",
path: "/projects"
path: "/projects",
options: {
postOnCreation: true,
otherEndpoints: {
forks: {
method: "get",
path: "/forks"
},
fork: {
method: "post",
path: "/fork"
}
}
}
},

@@ -47,2 +60,6 @@ users: {

path: "/users"
},
groups: {
method: "get",
path: "/groups"
}

@@ -260,11 +277,11 @@ };

if (optionalUrl === void 0) { optionalUrl = ""; }
if (optionalUrl.length > 0)
if (optionalUrl.length > 0 && optionalUrl[0] !== "/")
optionalUrl = "/" + optionalUrl;
var endpointSchema = config.getEndpointSchema("projects");
var params = "" + endpointSchema.path + convertObjectToQuery(requestObject) + optionalUrl;
return { endpointSchema: endpointSchema, params: params };
return { method: endpointSchema.method, params: params };
};
var prepareUserStarredProjectQueryURL = function (requestObject, optionalUrl) {
if (optionalUrl === void 0) { optionalUrl = ""; }
if (optionalUrl.length > 0)
if (optionalUrl.length > 0 && optionalUrl[0] !== "/")
optionalUrl = "/" + optionalUrl;

@@ -274,6 +291,66 @@ var userId = requestObject.user_id;

var endpointSchema = config.getEndpointSchema("users");
var params = endpointSchema.path + "/" + userId + "/starred_projects" + convertObjectToQuery(requestObject);
return { endpointSchema: endpointSchema, params: params };
var params = endpointSchema.path + "/" + userId + "/starred_projects" + convertObjectToQuery(requestObject) + optionalUrl;
return { method: endpointSchema.method, params: params };
};
var handleApiCall = function (endpointSchema, params, data) { return __awaiter(void 0, void 0, void 0, function () {
var prepareSingleProjectQueryURL = function (requestObject, optionalUrl) {
if (optionalUrl === void 0) { optionalUrl = ""; }
if (optionalUrl.length > 0)
optionalUrl = "/" + optionalUrl;
var id = requestObject.id;
delete requestObject.id;
var endpointSchema = config.getEndpointSchema("projects");
var params = endpointSchema.path + "/" + id + convertObjectToQuery(requestObject);
return { method: endpointSchema.method, params: params };
};
var prepareUsersInSingleProjectQueryURL = function (requestObject, optionalUrl) {
if (optionalUrl === void 0) { optionalUrl = ""; }
if (optionalUrl.length > 0 && optionalUrl[0] !== "/")
optionalUrl = "/" + optionalUrl;
var id = requestObject.id;
delete requestObject.id;
var projectEndpointSchema = config.getEndpointSchema("projects");
var userEndpointSchemaPath = config.getEndpointSchema("users").path;
var params = projectEndpointSchema.path + "/" + id + userEndpointSchemaPath + convertObjectToQuery(requestObject) + optionalUrl;
return { method: projectEndpointSchema.method, params: params };
};
var prepareGroupsInSingleProjectQueryURL = function (requestObject, optionalUrl) {
if (optionalUrl === void 0) { optionalUrl = ""; }
if (optionalUrl.length > 0 && optionalUrl[0] !== "/")
optionalUrl = "/" + optionalUrl;
var id = requestObject.id;
delete requestObject.id;
var projectEndpointSchema = config.getEndpointSchema("projects");
var groupEndpointSchemaPath = config.getEndpointSchema("groups").path;
var params = projectEndpointSchema.path + "/" + id + groupEndpointSchemaPath + convertObjectToQuery(requestObject) + optionalUrl;
return { method: projectEndpointSchema.method, params: params };
};
var prepareForksInSingleProjectQueryURL = function (requestObject, optionalUrl) {
var _a, _b;
if (optionalUrl === void 0) { optionalUrl = ""; }
if (optionalUrl.length > 0 && optionalUrl[0] !== "/")
optionalUrl = "/" + optionalUrl;
var id = requestObject.id;
delete requestObject.id;
var projectEndpointSchema = config.getEndpointSchema("projects");
var forksEndpointSchemaPath = (_b = (_a = projectEndpointSchema.options) === null || _a === void 0 ? void 0 : _a.otherEndpoints) === null || _b === void 0 ? void 0 : _b.forks;
if (!forksEndpointSchemaPath)
throw new Error("Forks Path is missing!");
var params = projectEndpointSchema.path + "/" + id + forksEndpointSchemaPath.path + convertObjectToQuery(requestObject) + optionalUrl;
return { method: forksEndpointSchemaPath.method, params: params };
};
var prepareForkProjectFormURL = function (requestObject, optionalUrl) {
var _a, _b;
if (optionalUrl === void 0) { optionalUrl = ""; }
if (optionalUrl.length > 0 && optionalUrl[0] !== "/")
optionalUrl = "/" + optionalUrl;
var id = requestObject.id;
delete requestObject.id;
var projectEndpointSchema = config.getEndpointSchema("projects");
var forkEndpointSchemaPath = (_b = (_a = projectEndpointSchema.options) === null || _a === void 0 ? void 0 : _a.otherEndpoints) === null || _b === void 0 ? void 0 : _b.fork;
if (!forkEndpointSchemaPath)
throw new Error("Forks Path is missing!");
var params = projectEndpointSchema.path + "/" + id + forkEndpointSchemaPath.path + optionalUrl;
return { method: forkEndpointSchemaPath.method, params: params, formData: requestObject };
};
var handleApiCall = function (method, params, data) { return __awaiter(void 0, void 0, void 0, function () {
var res;

@@ -284,3 +361,4 @@ return __generator(this, function (_a) {

res = null;
if (!(endpointSchema.method === "get")) return [3 /*break*/, 2];
console.log(params);
if (!(method === "get")) return [3 /*break*/, 2];
return [4 /*yield*/, controller.get(params)];

@@ -291,3 +369,3 @@ case 1:

case 2:
if (!(endpointSchema.method === "post")) return [3 /*break*/, 4];
if (!(method === "post")) return [3 /*break*/, 4];
return [4 /*yield*/, controller.post(params, data)];

@@ -304,3 +382,3 @@ case 3:

all: function (projectRequestObject) { return __awaiter(void 0, void 0, void 0, function () {
var requestObject, _a, endpointSchema, params, data;
var requestObject, _a, method, params, data;
return __generator(this, function (_b) {

@@ -312,4 +390,4 @@ switch (_b.label) {

requestObject = caseConverter(projectRequestObject, "snake");
_a = prepareProjectQueryURL(requestObject), endpointSchema = _a.endpointSchema, params = _a.params;
return [4 /*yield*/, handleApiCall(endpointSchema, params)];
_a = prepareProjectQueryURL(requestObject), method = _a.method, params = _a.params;
return [4 /*yield*/, handleApiCall(method, params)];
case 1:

@@ -322,3 +400,3 @@ data = _b.sent();

user: function (userProjectRequestObject) { return __awaiter(void 0, void 0, void 0, function () {
var requestObject, _a, endpointSchema, params, data;
var requestObject, _a, method, params, data;
return __generator(this, function (_b) {

@@ -331,4 +409,4 @@ switch (_b.label) {

requestObject = caseConverter(userProjectRequestObject, "snake");
_a = prepareProjectQueryURL(requestObject), endpointSchema = _a.endpointSchema, params = _a.params;
return [4 /*yield*/, handleApiCall(endpointSchema, params)];
_a = prepareProjectQueryURL(requestObject), method = _a.method, params = _a.params;
return [4 /*yield*/, handleApiCall(method, params)];
case 1:

@@ -341,3 +419,3 @@ data = _b.sent();

starredByUser: function (userProjectRequestObject) { return __awaiter(void 0, void 0, void 0, function () {
var requestObject, _a, endpointSchema, params, data;
var requestObject, _a, method, params, data;
return __generator(this, function (_b) {

@@ -350,4 +428,4 @@ switch (_b.label) {

requestObject = caseConverter(userProjectRequestObject, "snake");
_a = prepareUserStarredProjectQueryURL(requestObject), endpointSchema = _a.endpointSchema, params = _a.params;
return [4 /*yield*/, handleApiCall(endpointSchema, params)];
_a = prepareUserStarredProjectQueryURL(requestObject), method = _a.method, params = _a.params;
return [4 /*yield*/, handleApiCall(method, params)];
case 1:

@@ -358,2 +436,86 @@ data = _b.sent();

});
}); },
get: function (singleProjectRequestObject) { return __awaiter(void 0, void 0, void 0, function () {
var requestObject, _a, method, params, data;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
if (!singleProjectRequestObject.id)
throw new Error("Project ID must be there!");
requestObject = caseConverter(singleProjectRequestObject, "snake");
_a = prepareSingleProjectQueryURL(requestObject), method = _a.method, params = _a.params;
return [4 /*yield*/, handleApiCall(method, params)];
case 1:
data = _b.sent();
if (Array.isArray(data))
data = data[0];
return [2 /*return*/, caseConverter(data, "camel")];
}
});
}); },
getUsers: function (usersForSingleProjectRequestObject) { return __awaiter(void 0, void 0, void 0, function () {
var requestObject, _a, method, params, data;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
if (!usersForSingleProjectRequestObject.id)
throw new Error("Project ID must be there!");
requestObject = caseConverter(usersForSingleProjectRequestObject, "snake");
_a = prepareUsersInSingleProjectQueryURL(requestObject), method = _a.method, params = _a.params;
return [4 /*yield*/, handleApiCall(method, params)];
case 1:
data = _b.sent();
return [2 /*return*/, caseConverter(data, "camel")];
}
});
}); },
getGroups: function (groupsForSingleProjectRequestObject) { return __awaiter(void 0, void 0, void 0, function () {
var requestObject, _a, method, params, data;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
if (!groupsForSingleProjectRequestObject.id)
throw new Error("Project ID must be there!");
requestObject = caseConverter(groupsForSingleProjectRequestObject, "snake");
_a = prepareGroupsInSingleProjectQueryURL(requestObject), method = _a.method, params = _a.params;
return [4 /*yield*/, handleApiCall(method, params)];
case 1:
data = _b.sent();
return [2 /*return*/, caseConverter(data, "camel")];
}
});
}); },
getForks: function (forksForSingleProjectRequestObject) { return __awaiter(void 0, void 0, void 0, function () {
var requestObject, _a, method, params, data;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
if (!forksForSingleProjectRequestObject.id)
throw new Error("Project ID must be there!");
requestObject = caseConverter(forksForSingleProjectRequestObject, "snake");
_a = prepareForksInSingleProjectQueryURL(requestObject), method = _a.method, params = _a.params;
return [4 /*yield*/, handleApiCall(method, params)];
case 1:
data = _b.sent();
return [2 /*return*/, caseConverter(data, "camel")];
}
});
}); },
fork: function (forkProjectRequestObject) { return __awaiter(void 0, void 0, void 0, function () {
var requestObject, _a, method, params, formData, data;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
if (!forkProjectRequestObject.id)
throw new Error("Project ID must be there!");
requestObject = caseConverter(forkProjectRequestObject, "snake");
_a = prepareForkProjectFormURL(requestObject), method = _a.method, params = _a.params, formData = _a.formData;
return [4 /*yield*/, handleApiCall(method, params, formData)];
case 1:
data = _b.sent();
if (Array.isArray(data))
data = data[0];
return [2 /*return*/, caseConverter(data, "camel")];
}
});
}); }

@@ -360,0 +522,0 @@ };

/*!
* @sdc224/gitlab-api v1.1.2
* @sdc224/gitlab-api v1.2.0
* (c) Sourodeep Chatterjee. All Rights Reserved

@@ -49,3 +49,16 @@ * Released under the MIT License.

method: "get",
path: "/projects"
path: "/projects",
options: {
postOnCreation: true,
otherEndpoints: {
forks: {
method: "get",
path: "/forks"
},
fork: {
method: "post",
path: "/fork"
}
}
}
},

@@ -55,2 +68,6 @@ users: {

path: "/users"
},
groups: {
method: "get",
path: "/groups"
}

@@ -268,11 +285,11 @@ };

if (optionalUrl === void 0) { optionalUrl = ""; }
if (optionalUrl.length > 0)
if (optionalUrl.length > 0 && optionalUrl[0] !== "/")
optionalUrl = "/" + optionalUrl;
var endpointSchema = config.getEndpointSchema("projects");
var params = "" + endpointSchema.path + convertObjectToQuery(requestObject) + optionalUrl;
return { endpointSchema: endpointSchema, params: params };
return { method: endpointSchema.method, params: params };
};
var prepareUserStarredProjectQueryURL = function (requestObject, optionalUrl) {
if (optionalUrl === void 0) { optionalUrl = ""; }
if (optionalUrl.length > 0)
if (optionalUrl.length > 0 && optionalUrl[0] !== "/")
optionalUrl = "/" + optionalUrl;

@@ -282,6 +299,66 @@ var userId = requestObject.user_id;

var endpointSchema = config.getEndpointSchema("users");
var params = endpointSchema.path + "/" + userId + "/starred_projects" + convertObjectToQuery(requestObject);
return { endpointSchema: endpointSchema, params: params };
var params = endpointSchema.path + "/" + userId + "/starred_projects" + convertObjectToQuery(requestObject) + optionalUrl;
return { method: endpointSchema.method, params: params };
};
var handleApiCall = function (endpointSchema, params, data) { return __awaiter(void 0, void 0, void 0, function () {
var prepareSingleProjectQueryURL = function (requestObject, optionalUrl) {
if (optionalUrl === void 0) { optionalUrl = ""; }
if (optionalUrl.length > 0)
optionalUrl = "/" + optionalUrl;
var id = requestObject.id;
delete requestObject.id;
var endpointSchema = config.getEndpointSchema("projects");
var params = endpointSchema.path + "/" + id + convertObjectToQuery(requestObject);
return { method: endpointSchema.method, params: params };
};
var prepareUsersInSingleProjectQueryURL = function (requestObject, optionalUrl) {
if (optionalUrl === void 0) { optionalUrl = ""; }
if (optionalUrl.length > 0 && optionalUrl[0] !== "/")
optionalUrl = "/" + optionalUrl;
var id = requestObject.id;
delete requestObject.id;
var projectEndpointSchema = config.getEndpointSchema("projects");
var userEndpointSchemaPath = config.getEndpointSchema("users").path;
var params = projectEndpointSchema.path + "/" + id + userEndpointSchemaPath + convertObjectToQuery(requestObject) + optionalUrl;
return { method: projectEndpointSchema.method, params: params };
};
var prepareGroupsInSingleProjectQueryURL = function (requestObject, optionalUrl) {
if (optionalUrl === void 0) { optionalUrl = ""; }
if (optionalUrl.length > 0 && optionalUrl[0] !== "/")
optionalUrl = "/" + optionalUrl;
var id = requestObject.id;
delete requestObject.id;
var projectEndpointSchema = config.getEndpointSchema("projects");
var groupEndpointSchemaPath = config.getEndpointSchema("groups").path;
var params = projectEndpointSchema.path + "/" + id + groupEndpointSchemaPath + convertObjectToQuery(requestObject) + optionalUrl;
return { method: projectEndpointSchema.method, params: params };
};
var prepareForksInSingleProjectQueryURL = function (requestObject, optionalUrl) {
var _a, _b;
if (optionalUrl === void 0) { optionalUrl = ""; }
if (optionalUrl.length > 0 && optionalUrl[0] !== "/")
optionalUrl = "/" + optionalUrl;
var id = requestObject.id;
delete requestObject.id;
var projectEndpointSchema = config.getEndpointSchema("projects");
var forksEndpointSchemaPath = (_b = (_a = projectEndpointSchema.options) === null || _a === void 0 ? void 0 : _a.otherEndpoints) === null || _b === void 0 ? void 0 : _b.forks;
if (!forksEndpointSchemaPath)
throw new Error("Forks Path is missing!");
var params = projectEndpointSchema.path + "/" + id + forksEndpointSchemaPath.path + convertObjectToQuery(requestObject) + optionalUrl;
return { method: forksEndpointSchemaPath.method, params: params };
};
var prepareForkProjectFormURL = function (requestObject, optionalUrl) {
var _a, _b;
if (optionalUrl === void 0) { optionalUrl = ""; }
if (optionalUrl.length > 0 && optionalUrl[0] !== "/")
optionalUrl = "/" + optionalUrl;
var id = requestObject.id;
delete requestObject.id;
var projectEndpointSchema = config.getEndpointSchema("projects");
var forkEndpointSchemaPath = (_b = (_a = projectEndpointSchema.options) === null || _a === void 0 ? void 0 : _a.otherEndpoints) === null || _b === void 0 ? void 0 : _b.fork;
if (!forkEndpointSchemaPath)
throw new Error("Forks Path is missing!");
var params = projectEndpointSchema.path + "/" + id + forkEndpointSchemaPath.path + optionalUrl;
return { method: forkEndpointSchemaPath.method, params: params, formData: requestObject };
};
var handleApiCall = function (method, params, data) { return __awaiter(void 0, void 0, void 0, function () {
var res;

@@ -292,3 +369,4 @@ return __generator(this, function (_a) {

res = null;
if (!(endpointSchema.method === "get")) return [3 /*break*/, 2];
console.log(params);
if (!(method === "get")) return [3 /*break*/, 2];
return [4 /*yield*/, controller.get(params)];

@@ -299,3 +377,3 @@ case 1:

case 2:
if (!(endpointSchema.method === "post")) return [3 /*break*/, 4];
if (!(method === "post")) return [3 /*break*/, 4];
return [4 /*yield*/, controller.post(params, data)];

@@ -312,3 +390,3 @@ case 3:

all: function (projectRequestObject) { return __awaiter(void 0, void 0, void 0, function () {
var requestObject, _a, endpointSchema, params, data;
var requestObject, _a, method, params, data;
return __generator(this, function (_b) {

@@ -320,4 +398,4 @@ switch (_b.label) {

requestObject = caseConverter(projectRequestObject, "snake");
_a = prepareProjectQueryURL(requestObject), endpointSchema = _a.endpointSchema, params = _a.params;
return [4 /*yield*/, handleApiCall(endpointSchema, params)];
_a = prepareProjectQueryURL(requestObject), method = _a.method, params = _a.params;
return [4 /*yield*/, handleApiCall(method, params)];
case 1:

@@ -330,3 +408,3 @@ data = _b.sent();

user: function (userProjectRequestObject) { return __awaiter(void 0, void 0, void 0, function () {
var requestObject, _a, endpointSchema, params, data;
var requestObject, _a, method, params, data;
return __generator(this, function (_b) {

@@ -339,4 +417,4 @@ switch (_b.label) {

requestObject = caseConverter(userProjectRequestObject, "snake");
_a = prepareProjectQueryURL(requestObject), endpointSchema = _a.endpointSchema, params = _a.params;
return [4 /*yield*/, handleApiCall(endpointSchema, params)];
_a = prepareProjectQueryURL(requestObject), method = _a.method, params = _a.params;
return [4 /*yield*/, handleApiCall(method, params)];
case 1:

@@ -349,3 +427,3 @@ data = _b.sent();

starredByUser: function (userProjectRequestObject) { return __awaiter(void 0, void 0, void 0, function () {
var requestObject, _a, endpointSchema, params, data;
var requestObject, _a, method, params, data;
return __generator(this, function (_b) {

@@ -358,4 +436,4 @@ switch (_b.label) {

requestObject = caseConverter(userProjectRequestObject, "snake");
_a = prepareUserStarredProjectQueryURL(requestObject), endpointSchema = _a.endpointSchema, params = _a.params;
return [4 /*yield*/, handleApiCall(endpointSchema, params)];
_a = prepareUserStarredProjectQueryURL(requestObject), method = _a.method, params = _a.params;
return [4 /*yield*/, handleApiCall(method, params)];
case 1:

@@ -366,2 +444,86 @@ data = _b.sent();

});
}); },
get: function (singleProjectRequestObject) { return __awaiter(void 0, void 0, void 0, function () {
var requestObject, _a, method, params, data;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
if (!singleProjectRequestObject.id)
throw new Error("Project ID must be there!");
requestObject = caseConverter(singleProjectRequestObject, "snake");
_a = prepareSingleProjectQueryURL(requestObject), method = _a.method, params = _a.params;
return [4 /*yield*/, handleApiCall(method, params)];
case 1:
data = _b.sent();
if (Array.isArray(data))
data = data[0];
return [2 /*return*/, caseConverter(data, "camel")];
}
});
}); },
getUsers: function (usersForSingleProjectRequestObject) { return __awaiter(void 0, void 0, void 0, function () {
var requestObject, _a, method, params, data;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
if (!usersForSingleProjectRequestObject.id)
throw new Error("Project ID must be there!");
requestObject = caseConverter(usersForSingleProjectRequestObject, "snake");
_a = prepareUsersInSingleProjectQueryURL(requestObject), method = _a.method, params = _a.params;
return [4 /*yield*/, handleApiCall(method, params)];
case 1:
data = _b.sent();
return [2 /*return*/, caseConverter(data, "camel")];
}
});
}); },
getGroups: function (groupsForSingleProjectRequestObject) { return __awaiter(void 0, void 0, void 0, function () {
var requestObject, _a, method, params, data;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
if (!groupsForSingleProjectRequestObject.id)
throw new Error("Project ID must be there!");
requestObject = caseConverter(groupsForSingleProjectRequestObject, "snake");
_a = prepareGroupsInSingleProjectQueryURL(requestObject), method = _a.method, params = _a.params;
return [4 /*yield*/, handleApiCall(method, params)];
case 1:
data = _b.sent();
return [2 /*return*/, caseConverter(data, "camel")];
}
});
}); },
getForks: function (forksForSingleProjectRequestObject) { return __awaiter(void 0, void 0, void 0, function () {
var requestObject, _a, method, params, data;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
if (!forksForSingleProjectRequestObject.id)
throw new Error("Project ID must be there!");
requestObject = caseConverter(forksForSingleProjectRequestObject, "snake");
_a = prepareForksInSingleProjectQueryURL(requestObject), method = _a.method, params = _a.params;
return [4 /*yield*/, handleApiCall(method, params)];
case 1:
data = _b.sent();
return [2 /*return*/, caseConverter(data, "camel")];
}
});
}); },
fork: function (forkProjectRequestObject) { return __awaiter(void 0, void 0, void 0, function () {
var requestObject, _a, method, params, formData, data;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
if (!forkProjectRequestObject.id)
throw new Error("Project ID must be there!");
requestObject = caseConverter(forkProjectRequestObject, "snake");
_a = prepareForkProjectFormURL(requestObject), method = _a.method, params = _a.params, formData = _a.formData;
return [4 /*yield*/, handleApiCall(method, params, formData)];
case 1:
data = _b.sent();
if (Array.isArray(data))
data = data[0];
return [2 /*return*/, caseConverter(data, "camel")];
}
});
}); }

@@ -368,0 +530,0 @@ };

/*!
* @sdc224/gitlab-api v1.1.2
* @sdc224/gitlab-api v1.2.0
* (c) Sourodeep Chatterjee. All Rights Reserved

@@ -49,3 +49,16 @@ * Released under the MIT License.

method: "get",
path: "/projects"
path: "/projects",
options: {
postOnCreation: true,
otherEndpoints: {
forks: {
method: "get",
path: "/forks"
},
fork: {
method: "post",
path: "/fork"
}
}
}
},

@@ -55,2 +68,6 @@ users: {

path: "/users"
},
groups: {
method: "get",
path: "/groups"
}

@@ -268,11 +285,11 @@ };

if (optionalUrl === void 0) { optionalUrl = ""; }
if (optionalUrl.length > 0)
if (optionalUrl.length > 0 && optionalUrl[0] !== "/")
optionalUrl = "/" + optionalUrl;
var endpointSchema = config.getEndpointSchema("projects");
var params = "" + endpointSchema.path + convertObjectToQuery(requestObject) + optionalUrl;
return { endpointSchema: endpointSchema, params: params };
return { method: endpointSchema.method, params: params };
};
var prepareUserStarredProjectQueryURL = function (requestObject, optionalUrl) {
if (optionalUrl === void 0) { optionalUrl = ""; }
if (optionalUrl.length > 0)
if (optionalUrl.length > 0 && optionalUrl[0] !== "/")
optionalUrl = "/" + optionalUrl;

@@ -282,6 +299,66 @@ var userId = requestObject.user_id;

var endpointSchema = config.getEndpointSchema("users");
var params = endpointSchema.path + "/" + userId + "/starred_projects" + convertObjectToQuery(requestObject);
return { endpointSchema: endpointSchema, params: params };
var params = endpointSchema.path + "/" + userId + "/starred_projects" + convertObjectToQuery(requestObject) + optionalUrl;
return { method: endpointSchema.method, params: params };
};
var handleApiCall = function (endpointSchema, params, data) { return __awaiter(void 0, void 0, void 0, function () {
var prepareSingleProjectQueryURL = function (requestObject, optionalUrl) {
if (optionalUrl === void 0) { optionalUrl = ""; }
if (optionalUrl.length > 0)
optionalUrl = "/" + optionalUrl;
var id = requestObject.id;
delete requestObject.id;
var endpointSchema = config.getEndpointSchema("projects");
var params = endpointSchema.path + "/" + id + convertObjectToQuery(requestObject);
return { method: endpointSchema.method, params: params };
};
var prepareUsersInSingleProjectQueryURL = function (requestObject, optionalUrl) {
if (optionalUrl === void 0) { optionalUrl = ""; }
if (optionalUrl.length > 0 && optionalUrl[0] !== "/")
optionalUrl = "/" + optionalUrl;
var id = requestObject.id;
delete requestObject.id;
var projectEndpointSchema = config.getEndpointSchema("projects");
var userEndpointSchemaPath = config.getEndpointSchema("users").path;
var params = projectEndpointSchema.path + "/" + id + userEndpointSchemaPath + convertObjectToQuery(requestObject) + optionalUrl;
return { method: projectEndpointSchema.method, params: params };
};
var prepareGroupsInSingleProjectQueryURL = function (requestObject, optionalUrl) {
if (optionalUrl === void 0) { optionalUrl = ""; }
if (optionalUrl.length > 0 && optionalUrl[0] !== "/")
optionalUrl = "/" + optionalUrl;
var id = requestObject.id;
delete requestObject.id;
var projectEndpointSchema = config.getEndpointSchema("projects");
var groupEndpointSchemaPath = config.getEndpointSchema("groups").path;
var params = projectEndpointSchema.path + "/" + id + groupEndpointSchemaPath + convertObjectToQuery(requestObject) + optionalUrl;
return { method: projectEndpointSchema.method, params: params };
};
var prepareForksInSingleProjectQueryURL = function (requestObject, optionalUrl) {
var _a, _b;
if (optionalUrl === void 0) { optionalUrl = ""; }
if (optionalUrl.length > 0 && optionalUrl[0] !== "/")
optionalUrl = "/" + optionalUrl;
var id = requestObject.id;
delete requestObject.id;
var projectEndpointSchema = config.getEndpointSchema("projects");
var forksEndpointSchemaPath = (_b = (_a = projectEndpointSchema.options) === null || _a === void 0 ? void 0 : _a.otherEndpoints) === null || _b === void 0 ? void 0 : _b.forks;
if (!forksEndpointSchemaPath)
throw new Error("Forks Path is missing!");
var params = projectEndpointSchema.path + "/" + id + forksEndpointSchemaPath.path + convertObjectToQuery(requestObject) + optionalUrl;
return { method: forksEndpointSchemaPath.method, params: params };
};
var prepareForkProjectFormURL = function (requestObject, optionalUrl) {
var _a, _b;
if (optionalUrl === void 0) { optionalUrl = ""; }
if (optionalUrl.length > 0 && optionalUrl[0] !== "/")
optionalUrl = "/" + optionalUrl;
var id = requestObject.id;
delete requestObject.id;
var projectEndpointSchema = config.getEndpointSchema("projects");
var forkEndpointSchemaPath = (_b = (_a = projectEndpointSchema.options) === null || _a === void 0 ? void 0 : _a.otherEndpoints) === null || _b === void 0 ? void 0 : _b.fork;
if (!forkEndpointSchemaPath)
throw new Error("Forks Path is missing!");
var params = projectEndpointSchema.path + "/" + id + forkEndpointSchemaPath.path + optionalUrl;
return { method: forkEndpointSchemaPath.method, params: params, formData: requestObject };
};
var handleApiCall = function (method, params, data) { return __awaiter(void 0, void 0, void 0, function () {
var res;

@@ -292,3 +369,4 @@ return __generator(this, function (_a) {

res = null;
if (!(endpointSchema.method === "get")) return [3 /*break*/, 2];
console.log(params);
if (!(method === "get")) return [3 /*break*/, 2];
return [4 /*yield*/, controller.get(params)];

@@ -299,3 +377,3 @@ case 1:

case 2:
if (!(endpointSchema.method === "post")) return [3 /*break*/, 4];
if (!(method === "post")) return [3 /*break*/, 4];
return [4 /*yield*/, controller.post(params, data)];

@@ -312,3 +390,3 @@ case 3:

all: function (projectRequestObject) { return __awaiter(void 0, void 0, void 0, function () {
var requestObject, _a, endpointSchema, params, data;
var requestObject, _a, method, params, data;
return __generator(this, function (_b) {

@@ -320,4 +398,4 @@ switch (_b.label) {

requestObject = caseConverter(projectRequestObject, "snake");
_a = prepareProjectQueryURL(requestObject), endpointSchema = _a.endpointSchema, params = _a.params;
return [4 /*yield*/, handleApiCall(endpointSchema, params)];
_a = prepareProjectQueryURL(requestObject), method = _a.method, params = _a.params;
return [4 /*yield*/, handleApiCall(method, params)];
case 1:

@@ -330,3 +408,3 @@ data = _b.sent();

user: function (userProjectRequestObject) { return __awaiter(void 0, void 0, void 0, function () {
var requestObject, _a, endpointSchema, params, data;
var requestObject, _a, method, params, data;
return __generator(this, function (_b) {

@@ -339,4 +417,4 @@ switch (_b.label) {

requestObject = caseConverter(userProjectRequestObject, "snake");
_a = prepareProjectQueryURL(requestObject), endpointSchema = _a.endpointSchema, params = _a.params;
return [4 /*yield*/, handleApiCall(endpointSchema, params)];
_a = prepareProjectQueryURL(requestObject), method = _a.method, params = _a.params;
return [4 /*yield*/, handleApiCall(method, params)];
case 1:

@@ -349,3 +427,3 @@ data = _b.sent();

starredByUser: function (userProjectRequestObject) { return __awaiter(void 0, void 0, void 0, function () {
var requestObject, _a, endpointSchema, params, data;
var requestObject, _a, method, params, data;
return __generator(this, function (_b) {

@@ -358,4 +436,4 @@ switch (_b.label) {

requestObject = caseConverter(userProjectRequestObject, "snake");
_a = prepareUserStarredProjectQueryURL(requestObject), endpointSchema = _a.endpointSchema, params = _a.params;
return [4 /*yield*/, handleApiCall(endpointSchema, params)];
_a = prepareUserStarredProjectQueryURL(requestObject), method = _a.method, params = _a.params;
return [4 /*yield*/, handleApiCall(method, params)];
case 1:

@@ -366,2 +444,86 @@ data = _b.sent();

});
}); },
get: function (singleProjectRequestObject) { return __awaiter(void 0, void 0, void 0, function () {
var requestObject, _a, method, params, data;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
if (!singleProjectRequestObject.id)
throw new Error("Project ID must be there!");
requestObject = caseConverter(singleProjectRequestObject, "snake");
_a = prepareSingleProjectQueryURL(requestObject), method = _a.method, params = _a.params;
return [4 /*yield*/, handleApiCall(method, params)];
case 1:
data = _b.sent();
if (Array.isArray(data))
data = data[0];
return [2 /*return*/, caseConverter(data, "camel")];
}
});
}); },
getUsers: function (usersForSingleProjectRequestObject) { return __awaiter(void 0, void 0, void 0, function () {
var requestObject, _a, method, params, data;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
if (!usersForSingleProjectRequestObject.id)
throw new Error("Project ID must be there!");
requestObject = caseConverter(usersForSingleProjectRequestObject, "snake");
_a = prepareUsersInSingleProjectQueryURL(requestObject), method = _a.method, params = _a.params;
return [4 /*yield*/, handleApiCall(method, params)];
case 1:
data = _b.sent();
return [2 /*return*/, caseConverter(data, "camel")];
}
});
}); },
getGroups: function (groupsForSingleProjectRequestObject) { return __awaiter(void 0, void 0, void 0, function () {
var requestObject, _a, method, params, data;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
if (!groupsForSingleProjectRequestObject.id)
throw new Error("Project ID must be there!");
requestObject = caseConverter(groupsForSingleProjectRequestObject, "snake");
_a = prepareGroupsInSingleProjectQueryURL(requestObject), method = _a.method, params = _a.params;
return [4 /*yield*/, handleApiCall(method, params)];
case 1:
data = _b.sent();
return [2 /*return*/, caseConverter(data, "camel")];
}
});
}); },
getForks: function (forksForSingleProjectRequestObject) { return __awaiter(void 0, void 0, void 0, function () {
var requestObject, _a, method, params, data;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
if (!forksForSingleProjectRequestObject.id)
throw new Error("Project ID must be there!");
requestObject = caseConverter(forksForSingleProjectRequestObject, "snake");
_a = prepareForksInSingleProjectQueryURL(requestObject), method = _a.method, params = _a.params;
return [4 /*yield*/, handleApiCall(method, params)];
case 1:
data = _b.sent();
return [2 /*return*/, caseConverter(data, "camel")];
}
});
}); },
fork: function (forkProjectRequestObject) { return __awaiter(void 0, void 0, void 0, function () {
var requestObject, _a, method, params, formData, data;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
if (!forkProjectRequestObject.id)
throw new Error("Project ID must be there!");
requestObject = caseConverter(forkProjectRequestObject, "snake");
_a = prepareForkProjectFormURL(requestObject), method = _a.method, params = _a.params, formData = _a.formData;
return [4 /*yield*/, handleApiCall(method, params, formData)];
case 1:
data = _b.sent();
if (Array.isArray(data))
data = data[0];
return [2 /*return*/, caseConverter(data, "camel")];
}
});
}); }

@@ -368,0 +530,0 @@ };

6

dist/index.umd.min.js
/*!
* @sdc224/gitlab-api v1.1.2
* @sdc224/gitlab-api v1.2.0
* (c) Sourodeep Chatterjee. All Rights Reserved
* Released under the MIT License.
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("axios")):"function"==typeof define&&define.amd?define(["exports","axios"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@sdc224/gitlab-api"]={},e.axios)}(this,(function(e,t){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=n(t),o={host:"https://gitlab.example.com",baseURL:"",apiUrl:"api/",apiVersion:"v4",timeout:1e4,endpoints:{projects:{method:"get",path:"/projects"},users:{method:"get",path:"/users"}}},u="Authorization: Bearer OAUTH-TOKEN",i="PRIVATE-TOKEN",a={tokenType:"PersonalAccess",tokenKey:i,tokenValue:"abcdef"},s=function(e,t){var n,r={tokenType:e,tokenKey:function(e){switch(e){case"OAuth2":return u;case"PersonalAccess":case"ProjectAccess":default:return i}}(e),tokenValue:t},o=((n={})[r.tokenKey]=r.tokenValue,n);return{getTokenType:function(){return r.tokenType},getHeader:function(){return o},setTokenType:function(e){return r.tokenType=e},setTokenValue:function(e){return r.tokenValue=e}}},c=function(e){return e},f=function(e){return Promise.reject(e)},p=function(e){return e},l=function(e){return Promise.reject(e)};var d=function(e,t){var n,o=r.default.create({baseURL:e.getBaseURL(),timeout:e.getTimeout(),headers:t.getHeader()});return(n=o).interceptors.request.use(c,f),n.interceptors.response.use(p,l),o};
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("axios")):"function"==typeof define&&define.amd?define(["exports","axios"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@sdc224/gitlab-api"]={},e.axios)}(this,(function(e,t){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=n(t),o={host:"https://gitlab.example.com",baseURL:"",apiUrl:"api/",apiVersion:"v4",timeout:1e4,endpoints:{projects:{method:"get",path:"/projects",options:{postOnCreation:!0,otherEndpoints:{forks:{method:"get",path:"/forks"},fork:{method:"post",path:"/fork"}}}},users:{method:"get",path:"/users"},groups:{method:"get",path:"/groups"}}},i="Authorization: Bearer OAUTH-TOKEN",a="PRIVATE-TOKEN",u={tokenType:"PersonalAccess",tokenKey:a,tokenValue:"abcdef"},s=function(e,t){var n,r={tokenType:e,tokenKey:function(e){switch(e){case"OAuth2":return i;case"PersonalAccess":case"ProjectAccess":default:return a}}(e),tokenValue:t},o=((n={})[r.tokenKey]=r.tokenValue,n);return{getTokenType:function(){return r.tokenType},getHeader:function(){return o},setTokenType:function(e){return r.tokenType=e},setTokenValue:function(e){return r.tokenValue=e}}},c=function(e){return e},d=function(e){return Promise.reject(e)},f=function(e){return e},h=function(e){return Promise.reject(e)};var p=function(e,t){var n,o=r.default.create({baseURL:e.getBaseURL(),timeout:e.getTimeout(),headers:t.getHeader()});return(n=o).interceptors.request.use(c,d),n.interceptors.response.use(f,h),o};
/*! *****************************************************************************

@@ -21,2 +21,2 @@ Copyright (c) Microsoft Corporation.

***************************************************************************** */
function h(e,t,n,r){return new(n||(n=Promise))((function(o,u){function i(e){try{s(r.next(e))}catch(e){u(e)}}function a(e){try{s(r.throw(e))}catch(e){u(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}s((r=r.apply(e,t||[])).next())}))}function m(e,t){var n,r,o,u,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return u={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function a(u){return function(a){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,a])}}}var v=function(e){return e===Object(e)&&!Array.isArray(e)&&"function"!=typeof e},y=function(e){if(v(e)){var t={};return Object.keys(e).forEach((function(n){var r;t[(r=n,r.replace(/([-_][a-z])/gi,(function(e){return e.toUpperCase().replace("-","").replace("_","")})))]=y(e[n])})),t}return Array.isArray(e)?e.map((function(e){return y(e)})):e},b=function(e){if(v(e)){var t={};return Object.keys(e).forEach((function(n){var r;t[(r=n,r.replace(/[A-Z]/g,(function(e){return"_"+e.toLowerCase()})))]=b(e[n])})),t}return Array.isArray(e)?e.map((function(e){return b(e)})):e},g=function(e,t){switch(t){case"camel":return y(e);case"snake":return b(e);default:throw new Error("Please pass correct type to convert")}},k=function(e){var t=Object.keys(e).map((function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])})).join("&");return t.length>0?"?"+t:""},w=function(e,t){var n=function(t,n){void 0===n&&(n=""),n.length>0&&(n="/"+n);var r=e.getEndpointSchema("projects");return{endpointSchema:r,params:""+r.path+k(t)+n}},r=function(e,n,r){return h(void 0,void 0,void 0,(function(){var o;return m(this,(function(u){switch(u.label){case 0:return o=null,"get"!==e.method?[3,2]:[4,t.get(n)];case 1:return o=u.sent(),[3,5];case 2:return"post"!==e.method?[3,4]:[4,t.post(n,r)];case 3:return o=u.sent(),[3,5];case 4:throw new Error("Incorrect Method Called");case 5:return[2,o.data]}}))}))};return{all:function(e){return h(void 0,void 0,void 0,(function(){var t,o,u,i,a;return m(this,(function(s){switch(s.label){case 0:return t={},e&&(t=g(e,"snake")),o=n(t),u=o.endpointSchema,i=o.params,[4,r(u,i)];case 1:return a=s.sent(),[2,g(a,"camel")]}}))}))},user:function(e){return h(void 0,void 0,void 0,(function(){var t,o,u,i,a;return m(this,(function(s){switch(s.label){case 0:if(!e.userId||"string"!=typeof e.userId)throw new Error("User ID must be there!");return t=g(e,"snake"),o=n(t),u=o.endpointSchema,i=o.params,[4,r(u,i)];case 1:return a=s.sent(),[2,g(a,"camel")]}}))}))},starredByUser:function(t){return h(void 0,void 0,void 0,(function(){var n,o,u,i,a;return m(this,(function(s){switch(s.label){case 0:if(!t.userId||"string"!=typeof t.userId)throw new Error("User ID must be there!");return n=g(t,"snake"),o=function(t,n){void 0===n&&(n=""),n.length>0&&(n="/"+n);var r=t.user_id;delete t.user_id;var o=e.getEndpointSchema("users");return{endpointSchema:o,params:o.path+"/"+r+"/starred_projects"+k(t)}}(n),u=o.endpointSchema,i=o.params,[4,r(u,i)];case 1:return a=s.sent(),[2,g(a,"camel")]}}))}))}}};e.default=function(e){var t=function(e){var t=o,n=a;if(!e)throw new Error("You have to pass API Token atleast to get this running");return n.tokenValue=e.token,e.host&&(t.host=e.host),e.version&&(t.apiVersion=e.version),e.timeout&&(t.timeout=e.timeout),e.tokenType&&(n.tokenType=e.tokenType),{configObject:t,authenticationObject:n}}(e),n=t.configObject,r=t.authenticationObject,u=function(e,t,n,r,o){"/"!==e[e.length-1]&&(e+="/"),"/"!==r[r.length-1]&&(r+="/");var u={host:e,baseURL:e+r+t,apiUrl:r,apiVersion:t,timeout:n,endpoints:o};return{getHost:function(){return u.host},getBaseURL:function(){return u.baseURL},getAPIVersion:function(){return u.apiVersion},getTimeout:function(){return u.timeout},getEndpoints:function(){return u.endpoints},getEndpointSchema:function(e){return u.endpoints[e]},getConfig:function(){return u},setHost:function(e){return u.host=e},setAPIVersion:function(e){return u.apiVersion=e},setTimeout:function(e){return u.timeout=e},setEndpoints:function(e){return u.endpoints=e}}}(n.host,n.apiVersion,n.timeout,n.apiUrl,n.endpoints),i=function(e,t){return d(e,t)}(u,s(r.tokenType,r.tokenValue));return{Projects:w(u,i)}},Object.defineProperty(e,"__esModule",{value:!0})}));
function l(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{s(r.next(e))}catch(e){i(e)}}function u(e){try{s(r.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,u)}s((r=r.apply(e,t||[])).next())}))}function m(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}var v=function(e){return e===Object(e)&&!Array.isArray(e)&&"function"!=typeof e},g=function(e){if(v(e)){var t={};return Object.keys(e).forEach((function(n){var r;t[(r=n,r.replace(/([-_][a-z])/gi,(function(e){return e.toUpperCase().replace("-","").replace("_","")})))]=g(e[n])})),t}return Array.isArray(e)?e.map((function(e){return g(e)})):e},y=function(e){if(v(e)){var t={};return Object.keys(e).forEach((function(n){var r;t[(r=n,r.replace(/[A-Z]/g,(function(e){return"_"+e.toLowerCase()})))]=y(e[n])})),t}return Array.isArray(e)?e.map((function(e){return y(e)})):e},b=function(e,t){switch(t){case"camel":return g(e);case"snake":return y(e);default:throw new Error("Please pass correct type to convert")}},k=function(e){var t=Object.keys(e).map((function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])})).join("&");return t.length>0?"?"+t:""},w=function(e,t){var n=function(t,n){void 0===n&&(n=""),n.length>0&&"/"!==n[0]&&(n="/"+n);var r=e.getEndpointSchema("projects"),o=""+r.path+k(t)+n;return{method:r.method,params:o}},r=function(e,n,r){return l(void 0,void 0,void 0,(function(){var o;return m(this,(function(i){switch(i.label){case 0:return o=null,console.log(n),"get"!==e?[3,2]:[4,t.get(n)];case 1:return o=i.sent(),[3,5];case 2:return"post"!==e?[3,4]:[4,t.post(n,r)];case 3:return o=i.sent(),[3,5];case 4:throw new Error("Incorrect Method Called");case 5:return[2,o.data]}}))}))};return{all:function(e){return l(void 0,void 0,void 0,(function(){var t,o,i,a,u;return m(this,(function(s){switch(s.label){case 0:return t={},e&&(t=b(e,"snake")),o=n(t),i=o.method,a=o.params,[4,r(i,a)];case 1:return u=s.sent(),[2,b(u,"camel")]}}))}))},user:function(e){return l(void 0,void 0,void 0,(function(){var t,o,i,a,u;return m(this,(function(s){switch(s.label){case 0:if(!e.userId||"string"!=typeof e.userId)throw new Error("User ID must be there!");return t=b(e,"snake"),o=n(t),i=o.method,a=o.params,[4,r(i,a)];case 1:return u=s.sent(),[2,b(u,"camel")]}}))}))},starredByUser:function(t){return l(void 0,void 0,void 0,(function(){var n,o,i,a,u;return m(this,(function(s){switch(s.label){case 0:if(!t.userId||"string"!=typeof t.userId)throw new Error("User ID must be there!");return n=b(t,"snake"),o=function(t,n){void 0===n&&(n=""),n.length>0&&"/"!==n[0]&&(n="/"+n);var r=t.user_id;delete t.user_id;var o=e.getEndpointSchema("users"),i=o.path+"/"+r+"/starred_projects"+k(t)+n;return{method:o.method,params:i}}(n),i=o.method,a=o.params,[4,r(i,a)];case 1:return u=s.sent(),[2,b(u,"camel")]}}))}))},get:function(t){return l(void 0,void 0,void 0,(function(){var n,o,i,a,u;return m(this,(function(s){switch(s.label){case 0:if(!t.id)throw new Error("Project ID must be there!");return n=b(t,"snake"),o=function(t,n){void 0===n&&(n=""),n.length>0&&(n="/"+n);var r=t.id;delete t.id;var o=e.getEndpointSchema("projects"),i=o.path+"/"+r+k(t);return{method:o.method,params:i}}(n),i=o.method,a=o.params,[4,r(i,a)];case 1:return u=s.sent(),Array.isArray(u)&&(u=u[0]),[2,b(u,"camel")]}}))}))},getUsers:function(t){return l(void 0,void 0,void 0,(function(){var n,o,i,a,u;return m(this,(function(s){switch(s.label){case 0:if(!t.id)throw new Error("Project ID must be there!");return n=b(t,"snake"),o=function(t,n){void 0===n&&(n=""),n.length>0&&"/"!==n[0]&&(n="/"+n);var r=t.id;delete t.id;var o=e.getEndpointSchema("projects"),i=e.getEndpointSchema("users").path,a=o.path+"/"+r+i+k(t)+n;return{method:o.method,params:a}}(n),i=o.method,a=o.params,[4,r(i,a)];case 1:return u=s.sent(),[2,b(u,"camel")]}}))}))},getGroups:function(t){return l(void 0,void 0,void 0,(function(){var n,o,i,a,u;return m(this,(function(s){switch(s.label){case 0:if(!t.id)throw new Error("Project ID must be there!");return n=b(t,"snake"),o=function(t,n){void 0===n&&(n=""),n.length>0&&"/"!==n[0]&&(n="/"+n);var r=t.id;delete t.id;var o=e.getEndpointSchema("projects"),i=e.getEndpointSchema("groups").path,a=o.path+"/"+r+i+k(t)+n;return{method:o.method,params:a}}(n),i=o.method,a=o.params,[4,r(i,a)];case 1:return u=s.sent(),[2,b(u,"camel")]}}))}))},getForks:function(t){return l(void 0,void 0,void 0,(function(){var n,o,i,a,u;return m(this,(function(s){switch(s.label){case 0:if(!t.id)throw new Error("Project ID must be there!");return n=b(t,"snake"),o=function(t,n){var r,o;void 0===n&&(n=""),n.length>0&&"/"!==n[0]&&(n="/"+n);var i=t.id;delete t.id;var a=e.getEndpointSchema("projects"),u=null===(o=null===(r=a.options)||void 0===r?void 0:r.otherEndpoints)||void 0===o?void 0:o.forks;if(!u)throw new Error("Forks Path is missing!");var s=a.path+"/"+i+u.path+k(t)+n;return{method:u.method,params:s}}(n),i=o.method,a=o.params,[4,r(i,a)];case 1:return u=s.sent(),[2,b(u,"camel")]}}))}))},fork:function(t){return l(void 0,void 0,void 0,(function(){var n,o,i,a,u,s;return m(this,(function(c){switch(c.label){case 0:if(!t.id)throw new Error("Project ID must be there!");return n=b(t,"snake"),o=function(t,n){var r,o;void 0===n&&(n=""),n.length>0&&"/"!==n[0]&&(n="/"+n);var i=t.id;delete t.id;var a=e.getEndpointSchema("projects"),u=null===(o=null===(r=a.options)||void 0===r?void 0:r.otherEndpoints)||void 0===o?void 0:o.fork;if(!u)throw new Error("Forks Path is missing!");var s=a.path+"/"+i+u.path+n;return{method:u.method,params:s,formData:t}}(n),i=o.method,a=o.params,u=o.formData,[4,r(i,a,u)];case 1:return s=c.sent(),Array.isArray(s)&&(s=s[0]),[2,b(s,"camel")]}}))}))}}};e.default=function(e){var t=function(e){var t=o,n=u;if(!e)throw new Error("You have to pass API Token atleast to get this running");return n.tokenValue=e.token,e.host&&(t.host=e.host),e.version&&(t.apiVersion=e.version),e.timeout&&(t.timeout=e.timeout),e.tokenType&&(n.tokenType=e.tokenType),{configObject:t,authenticationObject:n}}(e),n=t.configObject,r=t.authenticationObject,i=function(e,t,n,r,o){"/"!==e[e.length-1]&&(e+="/"),"/"!==r[r.length-1]&&(r+="/");var i={host:e,baseURL:e+r+t,apiUrl:r,apiVersion:t,timeout:n,endpoints:o};return{getHost:function(){return i.host},getBaseURL:function(){return i.baseURL},getAPIVersion:function(){return i.apiVersion},getTimeout:function(){return i.timeout},getEndpoints:function(){return i.endpoints},getEndpointSchema:function(e){return i.endpoints[e]},getConfig:function(){return i},setHost:function(e){return i.host=e},setAPIVersion:function(e){return i.apiVersion=e},setTimeout:function(e){return i.timeout=e},setEndpoints:function(e){return i.endpoints=e}}}(n.host,n.apiVersion,n.timeout,n.apiUrl,n.endpoints),a=function(e,t){return p(e,t)}(i,s(r.tokenType,r.tokenValue));return{Projects:w(i,a)}},Object.defineProperty(e,"__esModule",{value:!0})}));
import type { IControllerKey } from "./controller";
export type IEndpointSchema = {
export type EndpointMain = {
path: string;

@@ -8,5 +8,13 @@ method: IControllerKey;

export type IEndpointSchema = EndpointMain & {
options?: {
postOnCreation?: boolean;
otherEndpoints?: { [index: string]: EndpointMain };
};
};
export type IEndpoints = {
projects: IEndpointSchema;
users: IEndpointSchema;
groups: IEndpointSchema;
};

@@ -13,0 +21,0 @@

@@ -0,1 +1,4 @@

export * from "./Common";
export * from "./Container";
export * from "./Group";
export * from "./Links";

@@ -2,0 +5,0 @@ export * from "./Namespace";

@@ -5,4 +5,27 @@ import type { Links } from "./Links";

import type { Statistics } from "./Statistics";
import type { ContainerExpirationPolicy } from "./Container";
import type { Group, GroupSchema } from "./Group";
import type { ID, Search, Sort, Entity, Visibility } from "./Common";
import type { User } from "./User";
export type IProjectSchema = {
export type Access = {
accessLevel?: number;
notificationLevel?: number;
};
export type Permission = {
projectAccess?: Access;
groupAccess?: Access;
};
export type License = {
key: string;
name?: string;
nickname?: string;
htmlUrl?: string;
sourceUrl?: string;
};
// TODO : Combine with Common.d.ts Entity
export type ProjectSchema = {
id: number;

@@ -31,2 +54,3 @@ description?: null;

containerRegistryEnabled?: boolean;
containerExpirationPolicy?: ContainerExpirationPolicy;
createdAt: string;

@@ -37,4 +61,9 @@ lastActivityAt: string;

importStatus?: string;
// TODO : Type below
importError?: null;
permissions: Permission;
archived?: boolean;
avatarUrl: string;
licenseUrl?: string;
license?: License;
sharedRunnersEnabled?: boolean;

@@ -47,3 +76,4 @@ forksCount: number;

publicJobs?: boolean;
sharedWithGroups?: null[] | null;
sharedWithGroups?: Group[] | null;
repositoryStorage?: string;
onlyAllowMergeIfPipelineSucceeds?: boolean;

@@ -54,4 +84,16 @@ allowMergeOnSkippedPipeline?: boolean;

removeSourceBranchAfterMerge?: boolean;
printingMergeRequestsLinkEnabled?: boolean;
requestAccessEnabled?: boolean;
mergeMethod?: string;
autoDevopsEnabled?: boolean;
autoDevopsDeployStrategy?: string;
mirror?: boolean;
mirrorUserId?: number;
mirrorTriggerBuilds?: boolean;
onlyMirrorProtectedBranches?: boolean;
mirrorOverwritesDivergedBranches?: boolean;
externalAuthorizationClassificationLabel?: null;
packagesEnabled?: boolean;
serviceDeskEnabled?: boolean;
serviceDeskAddress?: null;
autocloseReferencedIssues?: boolean;

@@ -61,2 +103,3 @@ suggestionCommitMessage?: null;

markedForDeletionOn?: string;
complianceFrameworks?: string[];
statistics?: Statistics;

@@ -67,6 +110,60 @@ containerRegistryImagePrefix?: string;

approvalsBeforeMerge?: number;
/**
* If the project is a fork, and you provide a valid token
* to authenticate, the forkedFromProject field appears in the response.
*/
forkedFromProject?: ProjectSchema;
};
export type GetProjectRequestObject = {
archived?: boolean;
export type GetBaseProjectRequestObject = Search &
Sort &
Statistics &
Visibility & {
/**
* Limit by archived status.
*/
archived?: boolean;
/**
* Limit by projects that the current user is a member of.
*/
membership?: boolean;
// TODO : Access Level interface
/**
* Limit by current user minimal access level.
*/
minAccessLevel?: number;
/**
* Return projects ordered by
* id, name, path, created_at, updated_at, or last_activity_at fields.
* Default is created_at.
*/
orderBy?: string;
/**
* Limit by projects explicitly owned by the current user.
*/
owned?: boolean;
/**
* Return only limited fields for each project.
* This is a no-op without authentication as then only simple fields are returned.
*/
simple?: boolean;
/**
* Limit by projects starred by the current user.
*/
starred?: boolean;
/**
* Include custom attributes in response. (admins only)
*/
withCustomAttributes?: boolean;
/**
* Limit by enabled issues feature.
*/
withIssuesEnabled?: boolean;
/**
* Limit by enabled merge requests feature.
*/
withMergeRequestEnabled?: boolean;
};
export type GetProjectRequestObject = GetBaseProjectRequestObject & {
idAfter?: number;

@@ -80,20 +177,7 @@ idBefore?: number;

lastActivityBefore?: string;
membership?: boolean;
// TODO : Access Level interface
minAccessLevel?: number;
orderBy?: string;
owned?: boolean;
repositoryChecksumFailed?: boolean;
repositoryStorage?: string;
searchNamespaces?: boolean;
search?: string;
simple?: boolean;
sort?: string;
starred?: boolean;
statistics?: boolean;
visibility?: string;
wikiChecksumFailed?: boolean;
withCustomAttributes?: boolean;
withIssuesEnabled?: boolean;
withMergeRequestEnabled?: boolean;
withProgrammingLanguage?: string;

@@ -104,6 +188,69 @@ };

export type GetSingleProjectRequestObject = ID &
Statistics & {
/**
* Include project license data.
*/
license?: boolean;
/**
* Include custom attributes in response. (admins only)
*/
withCustomAttributes?: boolean;
};
export type GetUserSingleProjectRequestObject = ID &
Search & {
/**
* Filter out users with the specified IDs.
*/
skipUsers?: number[];
};
export type GetGroupSingleProjectRequestObject = ID &
Search & {
/**
* Skip the group IDs passed.
*/
skipGroups?: number[];
/**
* Include projects shared with this group. Default is false.
*/
withShared?: boolean;
/**
* Limit to shared groups with at least this access level.
*/
sharedMinAccessLevel?: number;
};
export type GetForkSingleProjectRequestObject = ID & GetBaseProjectRequestObject;
export type PostForkProjectRequestObject = Entity &
Visibility & {
/**
* The ID of the namespace that the project is forked to.
*/
namespaceId?: number;
/**
* The path of the namespace that the project is forked to.
*/
namespacePath?: string;
/**
* The path assigned to the resultant project after forking.
*/
path?: string;
/**
* The description assigned to the resultant project after forking.
*/
description?: string;
};
export type IProjects = {
readonly all: (_?: GetProjectRequestObject) => Promise<IProjectSchema[]>;
readonly user: (_: GetUserProjectRequestObject) => Promise<IProjectSchema[]>;
readonly starredByUser: (_: GetUserProjectRequestObject) => Promise<IProjectSchema[]>;
readonly all: (_?: GetProjectRequestObject) => Promise<ProjectSchema[]>;
readonly user: (_: GetUserProjectRequestObject) => Promise<ProjectSchema[]>;
readonly starredByUser: (_: GetUserProjectRequestObject) => Promise<ProjectSchema[]>;
readonly get: (_: GetSingleProjectRequestObject) => Promise<ProjectSchema>;
readonly getUsers: (_: GetUserSingleProjectRequestObject) => Promise<User[]>;
readonly getGroups: (_: GetGroupSingleProjectRequestObject) => Promise<GroupSchema[]>;
readonly getForks: (_: GetForkSingleProjectRequestObject) => Promise<GroupSchema[]>;
readonly fork: (_: PostForkProjectRequestObject) => Promise<ProjectSchema>;
};
{
"name": "@sdc224/gitlab-api",
"version": "1.1.2",
"version": "1.2.0",
"description": "A Repository for using Gitlab API in NodeJS",

@@ -5,0 +5,0 @@ "cdn": "dist/index.umd.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc