@lbdudc/linea-git 0.3.1 → 0.3.2
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/device.d.ts +6 -0
- package/dist/device.js +50 -0
- package/dist/device.js.map +1 -0
- package/dist/errors.d.ts +5 -0
- package/dist/errors.js +9 -0
- package/dist/errors.js.map +1 -1
- package/dist/github/provider.d.ts +33 -1
- package/dist/github/provider.js +41 -0
- package/dist/github/provider.js.map +1 -1
- package/dist/gitlab/client.js +5 -2
- package/dist/gitlab/client.js.map +1 -1
- package/dist/gitlab/provider.d.ts +33 -1
- package/dist/gitlab/provider.js +50 -0
- package/dist/gitlab/provider.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/local/provider.d.ts +28 -1
- package/dist/local/provider.js +39 -2
- package/dist/local/provider.js.map +1 -1
- package/dist/local/store.d.ts +8 -0
- package/dist/local/store.js.map +1 -1
- package/dist/provider.d.ts +81 -1
- package/dist/provider.js +2 -2
- package/dist/provider.js.map +1 -1
- package/dist/registry/packages.d.ts +19 -0
- package/dist/registry/packages.js +29 -1
- package/dist/registry/packages.js.map +1 -1
- package/dist/testing/contract.js +28 -0
- package/dist/testing/contract.js.map +1 -1
- package/dist/testing/github-double.js +49 -3
- package/dist/testing/github-double.js.map +1 -1
- package/dist/testing/gitlab-double.js +64 -6
- package/dist/testing/gitlab-double.js.map +1 -1
- package/package.json +3 -3
|
@@ -288,6 +288,10 @@ export function createGithubDoubleApp(baseUrl = 'http://github.double') {
|
|
|
288
288
|
};
|
|
289
289
|
// ── account ──────────────────────────────────────────────────────────────
|
|
290
290
|
router.get('/user', (_req, res) => res.json({ login: state.user.login, id: state.user.id, avatar_url: '', type: 'User' }));
|
|
291
|
+
router.get('/search/users', (req, res) => {
|
|
292
|
+
const q = String(req.query.q ?? '');
|
|
293
|
+
res.json({ total_count: 1, items: q ? [{ login: q, avatar_url: null }] : [] });
|
|
294
|
+
});
|
|
291
295
|
router.get('/users/:login', (req, res) => {
|
|
292
296
|
const account = state.ownerOf(req.params.login);
|
|
293
297
|
if (!account)
|
|
@@ -379,7 +383,29 @@ export function createGithubDoubleApp(baseUrl = 'http://github.double') {
|
|
|
379
383
|
const repo = repoOr404(req, res);
|
|
380
384
|
if (!repo)
|
|
381
385
|
return;
|
|
382
|
-
|
|
386
|
+
// `affiliation=direct` leaves out what comes from the organization (a collaborator marked `inherited`)
|
|
387
|
+
const list = req.query.affiliation === 'direct' ? repo.collaborators.filter((c) => !c.inherited) : repo.collaborators;
|
|
388
|
+
res.json(list.map((c) => ({ login: c.login, id: c.id, role_name: c.role, permissions: permissionsOf(c.role) })));
|
|
389
|
+
});
|
|
390
|
+
router.put(`${R}/collaborators/:user`, (req, res) => {
|
|
391
|
+
const repo = repoOr404(req, res);
|
|
392
|
+
if (!repo)
|
|
393
|
+
return;
|
|
394
|
+
const role = { pull: 'read', push: 'write', maintain: 'maintain', admin: 'admin' }[req.body?.permission] ?? 'read';
|
|
395
|
+
const found = repo.collaborators.find((c) => c.login === req.params.user && !c.inherited);
|
|
396
|
+
if (found) {
|
|
397
|
+
found.role = role;
|
|
398
|
+
return res.status(204).end();
|
|
399
|
+
}
|
|
400
|
+
repo.collaborators.push({ login: req.params.user, id: 100 + repo.collaborators.length, role });
|
|
401
|
+
res.status(201).json({ id: 1, permissions: permissionsOf(role) });
|
|
402
|
+
});
|
|
403
|
+
router.delete(`${R}/collaborators/:user`, (req, res) => {
|
|
404
|
+
const repo = repoOr404(req, res);
|
|
405
|
+
if (!repo)
|
|
406
|
+
return;
|
|
407
|
+
repo.collaborators = repo.collaborators.filter((c) => c.login !== req.params.user || c.inherited);
|
|
408
|
+
res.status(204).end();
|
|
383
409
|
});
|
|
384
410
|
router.get(`${R}/collaborators/:user/permission`, (req, res) => {
|
|
385
411
|
const repo = repoOr404(req, res);
|
|
@@ -908,7 +934,9 @@ export function createGithubDoubleApp(baseUrl = 'http://github.double') {
|
|
|
908
934
|
const issue = {
|
|
909
935
|
number: repo.nextPull++, title, body: body ?? '', state: 'open', author: 'dev', created_at: now, updated_at: now, closed_at: null,
|
|
910
936
|
labels: labels ?? [], assignees: assignees ?? [], milestone: repo.milestones.find((m) => m.number === milestone) ?? null, comments: [],
|
|
937
|
+
events: [],
|
|
911
938
|
};
|
|
939
|
+
recordLabels(issue, [], issue.labels);
|
|
912
940
|
repo.issues.push(issue);
|
|
913
941
|
res.status(201).json(issueJson(repo, issue));
|
|
914
942
|
});
|
|
@@ -935,8 +963,10 @@ export function createGithubDoubleApp(baseUrl = 'http://github.double') {
|
|
|
935
963
|
issue.title = body.title;
|
|
936
964
|
if (body.body !== undefined)
|
|
937
965
|
issue.body = body.body;
|
|
938
|
-
if (body.labels !== undefined)
|
|
966
|
+
if (body.labels !== undefined) {
|
|
967
|
+
recordLabels(issue, issue.labels, body.labels);
|
|
939
968
|
issue.labels = body.labels;
|
|
969
|
+
}
|
|
940
970
|
if (body.assignees !== undefined)
|
|
941
971
|
issue.assignees = body.assignees;
|
|
942
972
|
if (body.milestone !== undefined)
|
|
@@ -948,6 +978,19 @@ export function createGithubDoubleApp(baseUrl = 'http://github.double') {
|
|
|
948
978
|
issue.updated_at = new Date().toISOString();
|
|
949
979
|
res.json(issueJson(repo, issue));
|
|
950
980
|
});
|
|
981
|
+
// what GitHub keeps of each label put on an issue or taken off it, among the issue's events
|
|
982
|
+
function recordLabels(issue, before, after) {
|
|
983
|
+
if (!issue.events)
|
|
984
|
+
return;
|
|
985
|
+
const at = new Date().toISOString();
|
|
986
|
+
const event = (name, kind) => ({ id: Math.floor(Math.random() * 1e9), event: kind, label: { name, color: 'ededed' }, actor: userJson('dev'), created_at: at });
|
|
987
|
+
issue.events.push(...before.filter((l) => !after.includes(l)).map((l) => event(l, 'unlabeled')), ...after.filter((l) => !before.includes(l)).map((l) => event(l, 'labeled')));
|
|
988
|
+
}
|
|
989
|
+
router.get(`${R}/issues/:n/events`, (req, res) => {
|
|
990
|
+
const [, issue] = issueOr404(req, res);
|
|
991
|
+
if (issue)
|
|
992
|
+
res.json(paged(req, issue.events ?? []));
|
|
993
|
+
});
|
|
951
994
|
router.get(`${R}/issues/:n/comments`, (req, res) => {
|
|
952
995
|
const [, issue] = issueOr404(req, res);
|
|
953
996
|
if (issue)
|
|
@@ -974,13 +1017,16 @@ export function createGithubDoubleApp(baseUrl = 'http://github.double') {
|
|
|
974
1017
|
const [repo, item] = labelled(req, res);
|
|
975
1018
|
if (!item)
|
|
976
1019
|
return;
|
|
977
|
-
|
|
1020
|
+
const labels = [...new Set([...(item.labels ?? []), ...(req.body?.labels ?? [])])];
|
|
1021
|
+
recordLabels(item, item.labels ?? [], labels);
|
|
1022
|
+
item.labels = labels;
|
|
978
1023
|
res.json(labelsJson(repo, item));
|
|
979
1024
|
});
|
|
980
1025
|
router.put(`${R}/issues/:n/labels`, (req, res) => {
|
|
981
1026
|
const [repo, item] = labelled(req, res);
|
|
982
1027
|
if (!item)
|
|
983
1028
|
return;
|
|
1029
|
+
recordLabels(item, item.labels ?? [], req.body?.labels ?? []);
|
|
984
1030
|
item.labels = req.body?.labels ?? [];
|
|
985
1031
|
res.json(labelsJson(repo, item));
|
|
986
1032
|
});
|