@harborclient/team-hub 0.2.3 → 0.2.4
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/cli.js +119 -10
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -6043,6 +6043,12 @@ function canAccessEnvironment(user, environmentId) {
|
|
|
6043
6043
|
}
|
|
6044
6044
|
return user.environmentAccess.includes(environmentId);
|
|
6045
6045
|
}
|
|
6046
|
+
function canDeleteCollection(user, collection) {
|
|
6047
|
+
return canUseDataApi(user) && canAccessCollection(user, collection.id) && collection.createdByUserId === user.id && !collection.deletionLocked;
|
|
6048
|
+
}
|
|
6049
|
+
function canDeleteRequest(user, request) {
|
|
6050
|
+
return canUseDataApi(user) && canAccessCollection(user, request.collectionId) && request.createdByUserId === user.id;
|
|
6051
|
+
}
|
|
6046
6052
|
function canCreateCollection(user) {
|
|
6047
6053
|
return user.role === "user" && hasWildcardAccess(user.collectionAccess);
|
|
6048
6054
|
}
|
|
@@ -6718,6 +6724,80 @@ async function registerAdminRoutes(app, options) {
|
|
|
6718
6724
|
}
|
|
6719
6725
|
}
|
|
6720
6726
|
});
|
|
6727
|
+
routes.route({
|
|
6728
|
+
method: "GET",
|
|
6729
|
+
url: "/admin/collections/:collectionId/folders",
|
|
6730
|
+
schema: {
|
|
6731
|
+
params: collectionIdParamSchema,
|
|
6732
|
+
response: {
|
|
6733
|
+
200: listFoldersResponseSchema,
|
|
6734
|
+
403: errorResponseSchema,
|
|
6735
|
+
404: errorResponseSchema
|
|
6736
|
+
}
|
|
6737
|
+
},
|
|
6738
|
+
/**
|
|
6739
|
+
* Lists folders in a collection for operator inspection.
|
|
6740
|
+
*/
|
|
6741
|
+
handler: async (request, reply) => {
|
|
6742
|
+
try {
|
|
6743
|
+
const user = requireAuthenticatedUser(request);
|
|
6744
|
+
if (denyUnlessAllowed(reply, canUseManagementApi(user))) {
|
|
6745
|
+
return;
|
|
6746
|
+
}
|
|
6747
|
+
const collection = await db.findCollectionById(request.params.collectionId);
|
|
6748
|
+
if (!collection) {
|
|
6749
|
+
void reply.code(404).send({ error: "Collection not found" });
|
|
6750
|
+
return;
|
|
6751
|
+
}
|
|
6752
|
+
const folders = await db.listFolders(request.params.collectionId);
|
|
6753
|
+
return reply.send({
|
|
6754
|
+
folders: folders.map((folder) => serializeFolder(folder))
|
|
6755
|
+
});
|
|
6756
|
+
} catch (error) {
|
|
6757
|
+
if (handleDbError(reply, error)) {
|
|
6758
|
+
return;
|
|
6759
|
+
}
|
|
6760
|
+
throw error;
|
|
6761
|
+
}
|
|
6762
|
+
}
|
|
6763
|
+
});
|
|
6764
|
+
routes.route({
|
|
6765
|
+
method: "GET",
|
|
6766
|
+
url: "/admin/collections/:collectionId/requests",
|
|
6767
|
+
schema: {
|
|
6768
|
+
params: collectionIdParamSchema,
|
|
6769
|
+
response: {
|
|
6770
|
+
200: listRequestsResponseSchema,
|
|
6771
|
+
403: errorResponseSchema,
|
|
6772
|
+
404: errorResponseSchema
|
|
6773
|
+
}
|
|
6774
|
+
},
|
|
6775
|
+
/**
|
|
6776
|
+
* Lists saved requests in a collection for operator inspection.
|
|
6777
|
+
*/
|
|
6778
|
+
handler: async (request, reply) => {
|
|
6779
|
+
try {
|
|
6780
|
+
const user = requireAuthenticatedUser(request);
|
|
6781
|
+
if (denyUnlessAllowed(reply, canUseManagementApi(user))) {
|
|
6782
|
+
return;
|
|
6783
|
+
}
|
|
6784
|
+
const collection = await db.findCollectionById(request.params.collectionId);
|
|
6785
|
+
if (!collection) {
|
|
6786
|
+
void reply.code(404).send({ error: "Collection not found" });
|
|
6787
|
+
return;
|
|
6788
|
+
}
|
|
6789
|
+
const requests = await db.listRequests(request.params.collectionId);
|
|
6790
|
+
return reply.send({
|
|
6791
|
+
requests: requests.map((savedRequest) => serializeSavedRequest(savedRequest))
|
|
6792
|
+
});
|
|
6793
|
+
} catch (error) {
|
|
6794
|
+
if (handleDbError(reply, error)) {
|
|
6795
|
+
return;
|
|
6796
|
+
}
|
|
6797
|
+
throw error;
|
|
6798
|
+
}
|
|
6799
|
+
}
|
|
6800
|
+
});
|
|
6721
6801
|
routes.route({
|
|
6722
6802
|
method: "GET",
|
|
6723
6803
|
url: "/admin/environments",
|
|
@@ -6787,6 +6867,41 @@ async function registerAdminRoutes(app, options) {
|
|
|
6787
6867
|
}
|
|
6788
6868
|
}
|
|
6789
6869
|
});
|
|
6870
|
+
routes.route({
|
|
6871
|
+
method: "DELETE",
|
|
6872
|
+
url: "/admin/requests/:id",
|
|
6873
|
+
schema: {
|
|
6874
|
+
params: idParamSchema,
|
|
6875
|
+
response: {
|
|
6876
|
+
204: emptyResponseSchema,
|
|
6877
|
+
403: errorResponseSchema,
|
|
6878
|
+
404: errorResponseSchema
|
|
6879
|
+
}
|
|
6880
|
+
},
|
|
6881
|
+
/**
|
|
6882
|
+
* Deletes a saved request regardless of collection access lists.
|
|
6883
|
+
*/
|
|
6884
|
+
handler: async (request, reply) => {
|
|
6885
|
+
try {
|
|
6886
|
+
const user = requireAuthenticatedUser(request);
|
|
6887
|
+
if (denyUnlessAllowed(reply, canUseManagementApi(user))) {
|
|
6888
|
+
return;
|
|
6889
|
+
}
|
|
6890
|
+
const existingRequest = await db.findRequestById(request.params.id);
|
|
6891
|
+
if (!existingRequest) {
|
|
6892
|
+
void reply.code(404).send({ error: "Request not found" });
|
|
6893
|
+
return;
|
|
6894
|
+
}
|
|
6895
|
+
await db.deleteRequest(request.params.id, user.id);
|
|
6896
|
+
return reply.code(204).send(null);
|
|
6897
|
+
} catch (error) {
|
|
6898
|
+
if (handleDbError(reply, error)) {
|
|
6899
|
+
return;
|
|
6900
|
+
}
|
|
6901
|
+
throw error;
|
|
6902
|
+
}
|
|
6903
|
+
}
|
|
6904
|
+
});
|
|
6790
6905
|
routes.route({
|
|
6791
6906
|
method: "PUT",
|
|
6792
6907
|
url: "/admin/collections/:id",
|
|
@@ -7350,12 +7465,6 @@ async function registerCollectionRoutes(app, db) {
|
|
|
7350
7465
|
handler: async (request, reply) => {
|
|
7351
7466
|
try {
|
|
7352
7467
|
const user = requireAuthenticatedUser(request);
|
|
7353
|
-
if (denyUnlessAllowed(
|
|
7354
|
-
reply,
|
|
7355
|
-
canUseDataApi(user) && canAccessCollection(user, request.params.id)
|
|
7356
|
-
)) {
|
|
7357
|
-
return;
|
|
7358
|
-
}
|
|
7359
7468
|
const collection = await db.findCollectionById(request.params.id);
|
|
7360
7469
|
if (!collection) {
|
|
7361
7470
|
void reply.code(404).send({ error: "Collection not found" });
|
|
@@ -7364,6 +7473,9 @@ async function registerCollectionRoutes(app, db) {
|
|
|
7364
7473
|
if (collection.deletionLocked) {
|
|
7365
7474
|
throw new DeletionLockedError("collection");
|
|
7366
7475
|
}
|
|
7476
|
+
if (denyUnlessAllowed(reply, canDeleteCollection(user, collection))) {
|
|
7477
|
+
return;
|
|
7478
|
+
}
|
|
7367
7479
|
await db.deleteCollection(request.params.id, user.id);
|
|
7368
7480
|
return reply.code(204).send(null);
|
|
7369
7481
|
} catch (error) {
|
|
@@ -7892,10 +8004,7 @@ async function registerRequestRoutes(app, db) {
|
|
|
7892
8004
|
if (!existingRequest) {
|
|
7893
8005
|
return reply.code(404).send({ error: "Request not found" });
|
|
7894
8006
|
}
|
|
7895
|
-
if (denyUnlessAllowed(
|
|
7896
|
-
reply,
|
|
7897
|
-
canUseDataApi(user) && canAccessCollection(user, existingRequest.collectionId)
|
|
7898
|
-
)) {
|
|
8007
|
+
if (denyUnlessAllowed(reply, canDeleteRequest(user, existingRequest))) {
|
|
7899
8008
|
return;
|
|
7900
8009
|
}
|
|
7901
8010
|
await db.deleteRequest(request.params.id, user.id);
|