@structured-world/gitlab-mcp 7.6.0 → 8.0.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/README.md +26 -5
- package/README.md.in +23 -2
- package/dist/src/cli/inject-tool-refs.d.ts +1 -0
- package/dist/src/cli/inject-tool-refs.js +10 -2
- package/dist/src/cli/inject-tool-refs.js.map +1 -1
- package/dist/src/cli/list-tools.js +2 -8
- package/dist/src/cli/list-tools.js.map +1 -1
- package/dist/src/cli/setup/presets.js +1 -1
- package/dist/src/cli/setup/presets.js.map +1 -1
- package/dist/src/entities/access_tokens/registry.d.ts +3 -0
- package/dist/src/entities/access_tokens/registry.js +147 -0
- package/dist/src/entities/access_tokens/registry.js.map +1 -0
- package/dist/src/entities/access_tokens/schema-readonly.d.ts +40 -0
- package/dist/src/entities/access_tokens/schema-readonly.js +60 -0
- package/dist/src/entities/access_tokens/schema-readonly.js.map +1 -0
- package/dist/src/entities/access_tokens/schema.d.ts +28 -0
- package/dist/src/entities/access_tokens/schema.js +68 -0
- package/dist/src/entities/access_tokens/schema.js.map +1 -0
- package/dist/src/entities/audit_events/registry.d.ts +3 -0
- package/dist/src/entities/audit_events/registry.js +93 -0
- package/dist/src/entities/audit_events/registry.js.map +1 -0
- package/dist/src/entities/audit_events/schema-readonly.d.ts +33 -0
- package/dist/src/entities/audit_events/schema-readonly.js +78 -0
- package/dist/src/entities/audit_events/schema-readonly.js.map +1 -0
- package/dist/src/entities/container_registry/registry.d.ts +3 -0
- package/dist/src/entities/container_registry/registry.js +255 -0
- package/dist/src/entities/container_registry/registry.js.map +1 -0
- package/dist/src/entities/container_registry/schema-readonly.d.ts +22 -0
- package/dist/src/entities/container_registry/schema-readonly.js +62 -0
- package/dist/src/entities/container_registry/schema-readonly.js.map +1 -0
- package/dist/src/entities/container_registry/schema.d.ts +17 -0
- package/dist/src/entities/container_registry/schema.js +66 -0
- package/dist/src/entities/container_registry/schema.js.map +1 -0
- package/dist/src/entities/context/whoami.js +2 -1
- package/dist/src/entities/context/whoami.js.map +1 -1
- package/dist/src/entities/core/registry.js +64 -17
- package/dist/src/entities/core/registry.js.map +1 -1
- package/dist/src/entities/core/schema-readonly.d.ts +2 -0
- package/dist/src/entities/core/schema-readonly.js +12 -0
- package/dist/src/entities/core/schema-readonly.js.map +1 -1
- package/dist/src/entities/core/schema.d.ts +3 -0
- package/dist/src/entities/core/schema.js +8 -0
- package/dist/src/entities/core/schema.js.map +1 -1
- package/dist/src/entities/pipelines/registry.js +5 -23
- package/dist/src/entities/pipelines/registry.js.map +1 -1
- package/dist/src/entities/pipelines/schema.d.ts +4 -6
- package/dist/src/entities/pipelines/schema.js +9 -11
- package/dist/src/entities/pipelines/schema.js.map +1 -1
- package/dist/src/entities/runners/registry.d.ts +3 -0
- package/dist/src/entities/runners/registry.js +226 -0
- package/dist/src/entities/runners/registry.js.map +1 -0
- package/dist/src/entities/runners/schema-readonly.d.ts +99 -0
- package/dist/src/entities/runners/schema-readonly.js +99 -0
- package/dist/src/entities/runners/schema-readonly.js.map +1 -0
- package/dist/src/entities/runners/schema.d.ts +49 -0
- package/dist/src/entities/runners/schema.js +81 -0
- package/dist/src/entities/runners/schema.js.map +1 -0
- package/dist/src/entities/vulnerabilities/registry.d.ts +3 -0
- package/dist/src/entities/vulnerabilities/registry.js +171 -0
- package/dist/src/entities/vulnerabilities/registry.js.map +1 -0
- package/dist/src/entities/vulnerabilities/schema-readonly.d.ts +48 -0
- package/dist/src/entities/vulnerabilities/schema-readonly.js +77 -0
- package/dist/src/entities/vulnerabilities/schema-readonly.js.map +1 -0
- package/dist/src/entities/vulnerabilities/schema.d.ts +23 -0
- package/dist/src/entities/vulnerabilities/schema.js +43 -0
- package/dist/src/entities/vulnerabilities/schema.js.map +1 -0
- package/dist/src/entities/workitems/registry.js +11 -10
- package/dist/src/entities/workitems/registry.js.map +1 -1
- package/dist/src/graphql/containerRegistry.d.ts +91 -0
- package/dist/src/graphql/containerRegistry.js +93 -0
- package/dist/src/graphql/containerRegistry.js.map +1 -0
- package/dist/src/graphql/runners.d.ts +162 -0
- package/dist/src/graphql/runners.js +144 -0
- package/dist/src/graphql/runners.js.map +1 -0
- package/dist/src/graphql/vulnerabilities.d.ts +90 -0
- package/dist/src/graphql/vulnerabilities.js +105 -0
- package/dist/src/graphql/vulnerabilities.js.map +1 -0
- package/dist/src/registry-manager.js +55 -0
- package/dist/src/registry-manager.js.map +1 -1
- package/dist/src/services/TokenScopeDetector.js +9 -1
- package/dist/src/services/TokenScopeDetector.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +72 -16
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.accessTokensToolRegistry = void 0;
|
|
37
|
+
exports.getAccessTokensReadOnlyToolNames = getAccessTokensReadOnlyToolNames;
|
|
38
|
+
const z = __importStar(require("zod"));
|
|
39
|
+
const schema_readonly_1 = require("./schema-readonly");
|
|
40
|
+
const schema_1 = require("./schema");
|
|
41
|
+
const gitlab_api_1 = require("../../utils/gitlab-api");
|
|
42
|
+
const utils_1 = require("../utils");
|
|
43
|
+
const FREE_REQ = { tier: 'free', minVersion: '13.0' };
|
|
44
|
+
const NEW_TOKEN_NOTICE = 'This response contains a token value shown only once. Store it securely; it cannot be retrieved again.';
|
|
45
|
+
function flagSensitive(response) {
|
|
46
|
+
if (response && typeof response === 'object') {
|
|
47
|
+
return {
|
|
48
|
+
...response,
|
|
49
|
+
_meta: { sensitive: true, notice: NEW_TOKEN_NOTICE },
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return response;
|
|
53
|
+
}
|
|
54
|
+
function tokenBasePath(input) {
|
|
55
|
+
if (input.project_id) {
|
|
56
|
+
return `projects/${encodeURIComponent(input.project_id)}/access_tokens`;
|
|
57
|
+
}
|
|
58
|
+
if (input.group_id) {
|
|
59
|
+
return `groups/${encodeURIComponent(input.group_id)}/access_tokens`;
|
|
60
|
+
}
|
|
61
|
+
return 'personal_access_tokens';
|
|
62
|
+
}
|
|
63
|
+
exports.accessTokensToolRegistry = new Map([
|
|
64
|
+
[
|
|
65
|
+
'browse_access_tokens',
|
|
66
|
+
{
|
|
67
|
+
name: 'browse_access_tokens',
|
|
68
|
+
description: "Inspect access tokens (CI/automation credentials). Actions: list_personal (the current user's PATs; admins may filter by user_id), list_project / list_group (a project's or group's tokens), get (a single token by ID - pass project_id or group_id for project/group tokens, neither for personal). Related: manage_access_token to create, rotate, or revoke.",
|
|
69
|
+
inputSchema: z.toJSONSchema(schema_readonly_1.BrowseAccessTokensSchema),
|
|
70
|
+
requirements: { default: FREE_REQ },
|
|
71
|
+
gate: { envVar: 'USE_ACCESS_TOKENS', defaultValue: true },
|
|
72
|
+
handler: async (args) => {
|
|
73
|
+
const input = schema_readonly_1.BrowseAccessTokensSchema.parse(args);
|
|
74
|
+
(0, utils_1.assertActionAllowed)('browse_access_tokens', input.action);
|
|
75
|
+
switch (input.action) {
|
|
76
|
+
case 'list_personal': {
|
|
77
|
+
const { action: _action, ...query } = input;
|
|
78
|
+
return gitlab_api_1.gitlab.get('personal_access_tokens', { query: (0, gitlab_api_1.toQuery)(query, []) });
|
|
79
|
+
}
|
|
80
|
+
case 'list_project': {
|
|
81
|
+
const { action: _action, project_id, ...query } = input;
|
|
82
|
+
return gitlab_api_1.gitlab.get(`projects/${encodeURIComponent(project_id)}/access_tokens`, {
|
|
83
|
+
query: (0, gitlab_api_1.toQuery)(query, []),
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
case 'list_group': {
|
|
87
|
+
const { action: _action, group_id, ...query } = input;
|
|
88
|
+
return gitlab_api_1.gitlab.get(`groups/${encodeURIComponent(group_id)}/access_tokens`, {
|
|
89
|
+
query: (0, gitlab_api_1.toQuery)(query, []),
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
case 'get':
|
|
93
|
+
return gitlab_api_1.gitlab.get(`${tokenBasePath(input)}/${input.token_id}`);
|
|
94
|
+
default:
|
|
95
|
+
throw new Error(`Unknown action: ${input.action}`);
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
[
|
|
101
|
+
'manage_access_token',
|
|
102
|
+
{
|
|
103
|
+
name: 'manage_access_token',
|
|
104
|
+
description: 'Create, rotate, or revoke access tokens. Actions: create_project / create_group (issue a new token with name + scopes, returns the value once), rotate (revoke the old token and return a new value), revoke (delete a token permanently). For rotate/revoke pass project_id or group_id for project/group tokens, neither for personal. Related: browse_access_tokens to discover token IDs.',
|
|
105
|
+
inputSchema: z.toJSONSchema(schema_1.ManageAccessTokenSchema),
|
|
106
|
+
requirements: { default: FREE_REQ },
|
|
107
|
+
gate: { envVar: 'USE_ACCESS_TOKENS', defaultValue: true },
|
|
108
|
+
handler: async (args) => {
|
|
109
|
+
const input = schema_1.ManageAccessTokenSchema.parse(args);
|
|
110
|
+
(0, utils_1.assertActionAllowed)('manage_access_token', input.action);
|
|
111
|
+
switch (input.action) {
|
|
112
|
+
case 'create_project': {
|
|
113
|
+
const { action: _action, project_id, ...body } = input;
|
|
114
|
+
const res = await gitlab_api_1.gitlab.post(`projects/${encodeURIComponent(project_id)}/access_tokens`, { body, contentType: 'json' });
|
|
115
|
+
return flagSensitive(res);
|
|
116
|
+
}
|
|
117
|
+
case 'create_group': {
|
|
118
|
+
const { action: _action, group_id, ...body } = input;
|
|
119
|
+
const res = await gitlab_api_1.gitlab.post(`groups/${encodeURIComponent(group_id)}/access_tokens`, {
|
|
120
|
+
body,
|
|
121
|
+
contentType: 'json',
|
|
122
|
+
});
|
|
123
|
+
return flagSensitive(res);
|
|
124
|
+
}
|
|
125
|
+
case 'rotate': {
|
|
126
|
+
const body = input.expires_at ? { expires_at: input.expires_at } : {};
|
|
127
|
+
const res = await gitlab_api_1.gitlab.post(`${tokenBasePath(input)}/${input.token_id}/rotate`, {
|
|
128
|
+
body,
|
|
129
|
+
contentType: 'json',
|
|
130
|
+
});
|
|
131
|
+
return flagSensitive(res);
|
|
132
|
+
}
|
|
133
|
+
case 'revoke': {
|
|
134
|
+
await gitlab_api_1.gitlab.delete(`${tokenBasePath(input)}/${input.token_id}`);
|
|
135
|
+
return { revoked: true, token_id: input.token_id };
|
|
136
|
+
}
|
|
137
|
+
default:
|
|
138
|
+
throw new Error(`Unknown action: ${input.action}`);
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
],
|
|
143
|
+
]);
|
|
144
|
+
function getAccessTokensReadOnlyToolNames() {
|
|
145
|
+
return ['browse_access_tokens'];
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../../src/entities/access_tokens/registry.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiKA,4EAEC;AAnKD,uCAAyB;AACzB,uDAA6D;AAC7D,qCAAmD;AACnD,uDAAyD;AAEzD,oCAA+C;AAK/C,MAAM,QAAQ,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAW,CAAC;AAE/D,MAAM,gBAAgB,GACpB,wGAAwG,CAAC;AAM3G,SAAS,aAAa,CAAC,QAAiB;IACtC,IAAI,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC7C,OAAO;YACL,GAAI,QAAoC;YACxC,KAAK,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,gBAAgB,EAAE;SACrD,CAAC;IACJ,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAMD,SAAS,aAAa,CAAC,KAAiD;IACtE,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;QACrB,OAAO,YAAY,kBAAkB,CAAC,KAAK,CAAC,UAAU,CAAC,gBAAgB,CAAC;IAC1E,CAAC;IACD,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QACnB,OAAO,UAAU,kBAAkB,CAAC,KAAK,CAAC,QAAQ,CAAC,gBAAgB,CAAC;IACtE,CAAC;IACD,OAAO,wBAAwB,CAAC;AAClC,CAAC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AC,sBAAsB,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const projectIdField: z.ZodPreprocess<z.ZodCoercedString<unknown>>;
|
|
3
|
+
export declare const groupIdField: z.ZodPreprocess<z.ZodCoercedString<unknown>>;
|
|
4
|
+
export declare const tokenIdField: z.ZodCoercedNumber<unknown>;
|
|
5
|
+
export declare const BrowseAccessTokensSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
6
|
+
per_page: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
7
|
+
page: z.ZodOptional<z.ZodNumber>;
|
|
8
|
+
action: z.ZodLiteral<"list_personal">;
|
|
9
|
+
user_id: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
10
|
+
revoked: z.ZodOptional<z.ZodPreprocess<z.ZodBoolean>>;
|
|
11
|
+
state: z.ZodOptional<z.ZodEnum<{
|
|
12
|
+
active: "active";
|
|
13
|
+
inactive: "inactive";
|
|
14
|
+
}>>;
|
|
15
|
+
search: z.ZodOptional<z.ZodString>;
|
|
16
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
17
|
+
per_page: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
18
|
+
page: z.ZodOptional<z.ZodNumber>;
|
|
19
|
+
action: z.ZodLiteral<"list_project">;
|
|
20
|
+
project_id: z.ZodPreprocess<z.ZodCoercedString<unknown>>;
|
|
21
|
+
state: z.ZodOptional<z.ZodEnum<{
|
|
22
|
+
active: "active";
|
|
23
|
+
inactive: "inactive";
|
|
24
|
+
}>>;
|
|
25
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
26
|
+
per_page: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
27
|
+
page: z.ZodOptional<z.ZodNumber>;
|
|
28
|
+
action: z.ZodLiteral<"list_group">;
|
|
29
|
+
group_id: z.ZodPreprocess<z.ZodCoercedString<unknown>>;
|
|
30
|
+
state: z.ZodOptional<z.ZodEnum<{
|
|
31
|
+
active: "active";
|
|
32
|
+
inactive: "inactive";
|
|
33
|
+
}>>;
|
|
34
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
35
|
+
action: z.ZodLiteral<"get">;
|
|
36
|
+
token_id: z.ZodCoercedNumber<unknown>;
|
|
37
|
+
project_id: z.ZodOptional<z.ZodPreprocess<z.ZodCoercedString<unknown>>>;
|
|
38
|
+
group_id: z.ZodOptional<z.ZodPreprocess<z.ZodCoercedString<unknown>>>;
|
|
39
|
+
}, z.core.$strip>], "action">;
|
|
40
|
+
export type BrowseAccessTokensInput = z.infer<typeof BrowseAccessTokensSchema>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BrowseAccessTokensSchema = exports.tokenIdField = exports.groupIdField = exports.projectIdField = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
exports.projectIdField = utils_1.requiredId.describe("Project ID or URL-encoded path (e.g. 'group/project' or '123').");
|
|
7
|
+
exports.groupIdField = utils_1.requiredId.describe("Group ID or URL-encoded path (e.g. 'my-group' or '42').");
|
|
8
|
+
exports.tokenIdField = zod_1.z.coerce
|
|
9
|
+
.number()
|
|
10
|
+
.int()
|
|
11
|
+
.positive()
|
|
12
|
+
.describe('Numeric access-token ID (from a list action).');
|
|
13
|
+
const stateFilter = zod_1.z.enum(['active', 'inactive']).optional().describe('Filter by token state.');
|
|
14
|
+
const ListPersonalSchema = zod_1.z.object({
|
|
15
|
+
action: zod_1.z
|
|
16
|
+
.literal('list_personal')
|
|
17
|
+
.describe('List personal access tokens for the current user (admins may filter by user_id)'),
|
|
18
|
+
user_id: zod_1.z.coerce
|
|
19
|
+
.number()
|
|
20
|
+
.int()
|
|
21
|
+
.positive()
|
|
22
|
+
.optional()
|
|
23
|
+
.describe('Admin only: list PATs belonging to this user ID.'),
|
|
24
|
+
revoked: utils_1.flexibleBoolean.optional().describe('Filter by revoked state.'),
|
|
25
|
+
state: stateFilter,
|
|
26
|
+
search: zod_1.z.string().optional().describe('Filter by token name substring.'),
|
|
27
|
+
...(0, utils_1.paginationFields)(),
|
|
28
|
+
});
|
|
29
|
+
const ListProjectSchema = zod_1.z.object({
|
|
30
|
+
action: zod_1.z.literal('list_project').describe('List a project access tokens'),
|
|
31
|
+
project_id: exports.projectIdField,
|
|
32
|
+
state: stateFilter,
|
|
33
|
+
...(0, utils_1.paginationFields)(),
|
|
34
|
+
});
|
|
35
|
+
const ListGroupSchema = zod_1.z.object({
|
|
36
|
+
action: zod_1.z.literal('list_group').describe('List a group access tokens'),
|
|
37
|
+
group_id: exports.groupIdField,
|
|
38
|
+
state: stateFilter,
|
|
39
|
+
...(0, utils_1.paginationFields)(),
|
|
40
|
+
});
|
|
41
|
+
const GetTokenSchema = zod_1.z.object({
|
|
42
|
+
action: zod_1.z
|
|
43
|
+
.literal('get')
|
|
44
|
+
.describe('Get a single access token by ID. Pass project_id for a project token, group_id for a group token, or neither for a personal token.'),
|
|
45
|
+
token_id: exports.tokenIdField,
|
|
46
|
+
project_id: utils_1.requiredId.optional().describe('Set for a project access token.'),
|
|
47
|
+
group_id: utils_1.requiredId.optional().describe('Set for a group access token.'),
|
|
48
|
+
});
|
|
49
|
+
exports.BrowseAccessTokensSchema = zod_1.z
|
|
50
|
+
.discriminatedUnion('action', [
|
|
51
|
+
ListPersonalSchema,
|
|
52
|
+
ListProjectSchema,
|
|
53
|
+
ListGroupSchema,
|
|
54
|
+
GetTokenSchema,
|
|
55
|
+
])
|
|
56
|
+
.refine((data) => data.action !== 'get' || !(data.project_id && data.group_id), {
|
|
57
|
+
message: 'Pass at most one of project_id or group_id (a token belongs to a single scope)',
|
|
58
|
+
path: ['project_id'],
|
|
59
|
+
});
|
|
60
|
+
//# sourceMappingURL=schema-readonly.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
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c;IAC1B,KAAK,EAAE,WAAW;IAClB,GAAG,IAAA,wBAAgB,GAAE;CACtB,CAAC,CAAC;AAGH,MAAM,eAAe,GAAG,OAAC,CAAC,MAAM,CAAC;IAC/B,MAAM,EAAE,OAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,4BAA4B,CAAC;IACtE,QAAQ,EAAE,oBAAY;IACtB,KAAK,EAAE,WAAW;IAClB,GAAG,IAAA,wBAAgB,GAAE;CACtB,CAAC,CAAC;AAGH,MAAM,cAAc,GAAG,OAAC,CAAC,MAAM,CAAC;IAC9B,MAAM,EAAE,OAAC;SACN,OAAO,CAAC,KAAK,CAAC;SACd,QAAQ,CACP,oIAAoI,CACrI;IACH,QAAQ,EAAE,oBAAY;IACtB,UAAU,EAAE,kBAAU,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,iCAAiC,CAAC;IAC7E,QAAQ,EAAE,kBAAU,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,+BAA+B,CAAC;CAC1E,CAAC,CAAC;AAGU,QAAA,wBAAwB,GAAG,OAAC;KACtC,kBAAkB,CAAC,QAAQ,EAAE;IAC5B,kBAAkB;IAClB,iBAAiB;IACjB,eAAe;IACf,cAAc;CACf,CAAC;KAED,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,KAAK,KAAK,IAAI,CAAC,CAAC,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE;IAC9E,OAAO,EAAE,gFAAgF;IACzF,IAAI,EAAE,CAAC,YAAY,CAAC;CACrB,CAAC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const ManageAccessTokenSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
3
|
+
action: z.ZodLiteral<"create_project">;
|
|
4
|
+
project_id: z.ZodPreprocess<z.ZodCoercedString<unknown>>;
|
|
5
|
+
name: z.ZodString;
|
|
6
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
7
|
+
access_level: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<10>, z.ZodLiteral<20>, z.ZodLiteral<30>, z.ZodLiteral<40>, z.ZodLiteral<50>]>>;
|
|
8
|
+
expires_at: z.ZodOptional<z.ZodString>;
|
|
9
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
10
|
+
action: z.ZodLiteral<"create_group">;
|
|
11
|
+
group_id: z.ZodPreprocess<z.ZodCoercedString<unknown>>;
|
|
12
|
+
name: z.ZodString;
|
|
13
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
14
|
+
access_level: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<10>, z.ZodLiteral<20>, z.ZodLiteral<30>, z.ZodLiteral<40>, z.ZodLiteral<50>]>>;
|
|
15
|
+
expires_at: z.ZodOptional<z.ZodString>;
|
|
16
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
17
|
+
action: z.ZodLiteral<"rotate">;
|
|
18
|
+
token_id: z.ZodCoercedNumber<unknown>;
|
|
19
|
+
project_id: z.ZodOptional<z.ZodPreprocess<z.ZodCoercedString<unknown>>>;
|
|
20
|
+
group_id: z.ZodOptional<z.ZodPreprocess<z.ZodCoercedString<unknown>>>;
|
|
21
|
+
expires_at: z.ZodOptional<z.ZodString>;
|
|
22
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
23
|
+
action: z.ZodLiteral<"revoke">;
|
|
24
|
+
token_id: z.ZodCoercedNumber<unknown>;
|
|
25
|
+
project_id: z.ZodOptional<z.ZodPreprocess<z.ZodCoercedString<unknown>>>;
|
|
26
|
+
group_id: z.ZodOptional<z.ZodPreprocess<z.ZodCoercedString<unknown>>>;
|
|
27
|
+
}, z.core.$strip>], "action">;
|
|
28
|
+
export type ManageAccessTokenInput = z.infer<typeof ManageAccessTokenSchema>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ManageAccessTokenSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const schema_readonly_1 = require("./schema-readonly");
|
|
7
|
+
const scopesField = zod_1.z
|
|
8
|
+
.array(zod_1.z.string().trim().min(1, 'scope entries must be non-empty'))
|
|
9
|
+
.min(1)
|
|
10
|
+
.describe("Token scopes, e.g. ['api'], ['read_repository','write_repository']. At least one required.");
|
|
11
|
+
const accessLevelField = zod_1.z
|
|
12
|
+
.union([zod_1.z.literal(10), zod_1.z.literal(20), zod_1.z.literal(30), zod_1.z.literal(40), zod_1.z.literal(50)])
|
|
13
|
+
.optional()
|
|
14
|
+
.describe('Access level: 10 Guest, 20 Reporter, 30 Developer, 40 Maintainer, 50 Owner.');
|
|
15
|
+
const expiresAtField = zod_1.z
|
|
16
|
+
.string()
|
|
17
|
+
.regex(/^\d{4}-\d{2}-\d{2}$/, 'expires_at must be a YYYY-MM-DD date')
|
|
18
|
+
.optional()
|
|
19
|
+
.describe('Expiry date in YYYY-MM-DD format (e.g. "2026-12-31").');
|
|
20
|
+
const CreateProjectTokenSchema = zod_1.z.object({
|
|
21
|
+
action: zod_1.z
|
|
22
|
+
.literal('create_project')
|
|
23
|
+
.describe('Create a project access token (returns the value once)'),
|
|
24
|
+
project_id: schema_readonly_1.projectIdField,
|
|
25
|
+
name: zod_1.z.string().describe('Human-readable token name.'),
|
|
26
|
+
scopes: scopesField,
|
|
27
|
+
access_level: accessLevelField,
|
|
28
|
+
expires_at: expiresAtField,
|
|
29
|
+
});
|
|
30
|
+
const CreateGroupTokenSchema = zod_1.z.object({
|
|
31
|
+
action: zod_1.z
|
|
32
|
+
.literal('create_group')
|
|
33
|
+
.describe('Create a group access token (returns the value once)'),
|
|
34
|
+
group_id: schema_readonly_1.groupIdField,
|
|
35
|
+
name: zod_1.z.string().describe('Human-readable token name.'),
|
|
36
|
+
scopes: scopesField,
|
|
37
|
+
access_level: accessLevelField,
|
|
38
|
+
expires_at: expiresAtField,
|
|
39
|
+
});
|
|
40
|
+
const RotateTokenSchema = zod_1.z.object({
|
|
41
|
+
action: zod_1.z
|
|
42
|
+
.literal('rotate')
|
|
43
|
+
.describe('Rotate a token: revoke the old one and return a new value. Pass project_id for a project token, group_id for a group token, or neither for a personal token.'),
|
|
44
|
+
token_id: schema_readonly_1.tokenIdField,
|
|
45
|
+
project_id: utils_1.requiredId.optional().describe('Set for a project access token.'),
|
|
46
|
+
group_id: utils_1.requiredId.optional().describe('Set for a group access token.'),
|
|
47
|
+
expires_at: expiresAtField,
|
|
48
|
+
});
|
|
49
|
+
const RevokeTokenSchema = zod_1.z.object({
|
|
50
|
+
action: zod_1.z
|
|
51
|
+
.literal('revoke')
|
|
52
|
+
.describe('Revoke a token permanently. Pass project_id for a project token, group_id for a group token, or neither for a personal token.'),
|
|
53
|
+
token_id: schema_readonly_1.tokenIdField,
|
|
54
|
+
project_id: utils_1.requiredId.optional().describe('Set for a project access token.'),
|
|
55
|
+
group_id: utils_1.requiredId.optional().describe('Set for a group access token.'),
|
|
56
|
+
});
|
|
57
|
+
exports.ManageAccessTokenSchema = zod_1.z
|
|
58
|
+
.discriminatedUnion('action', [
|
|
59
|
+
CreateProjectTokenSchema,
|
|
60
|
+
CreateGroupTokenSchema,
|
|
61
|
+
RotateTokenSchema,
|
|
62
|
+
RevokeTokenSchema,
|
|
63
|
+
])
|
|
64
|
+
.refine((data) => (data.action !== 'rotate' && data.action !== 'revoke') || !(data.project_id && data.group_id), {
|
|
65
|
+
message: 'Pass at most one of project_id or group_id (a token belongs to a single scope)',
|
|
66
|
+
path: ['project_id'],
|
|
67
|
+
});
|
|
68
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../src/entities/access_tokens/schema.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,oC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,IAAI,EAAE,CAAC,YAAY,CAAC;CACrB,CACF,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.auditEventsToolRegistry = void 0;
|
|
37
|
+
exports.getAuditEventsReadOnlyToolNames = getAuditEventsReadOnlyToolNames;
|
|
38
|
+
const z = __importStar(require("zod"));
|
|
39
|
+
const schema_readonly_1 = require("./schema-readonly");
|
|
40
|
+
const gitlab_api_1 = require("../../utils/gitlab-api");
|
|
41
|
+
const utils_1 = require("../utils");
|
|
42
|
+
const PREMIUM_REQ = { tier: 'premium', minVersion: '12.4', notes: 'Audit Events' };
|
|
43
|
+
function auditBasePath(input) {
|
|
44
|
+
if (input.project_id) {
|
|
45
|
+
return `projects/${encodeURIComponent(input.project_id)}/audit_events`;
|
|
46
|
+
}
|
|
47
|
+
if (input.group_id) {
|
|
48
|
+
return `groups/${encodeURIComponent(input.group_id)}/audit_events`;
|
|
49
|
+
}
|
|
50
|
+
return 'audit_events';
|
|
51
|
+
}
|
|
52
|
+
exports.auditEventsToolRegistry = new Map([
|
|
53
|
+
[
|
|
54
|
+
'browse_audit_events',
|
|
55
|
+
{
|
|
56
|
+
name: 'browse_audit_events',
|
|
57
|
+
description: 'Inspect audit events: the immutable record of who did what, when. Actions: list_instance (instance-wide, admin-only), list_group / list_project (a group or project audit trail), get (a single event by ID - pass project_id or group_id for group/project events, neither for an instance event). Premium/Ultimate feature; there is no write counterpart because audit events cannot be modified.',
|
|
58
|
+
inputSchema: z.toJSONSchema(schema_readonly_1.BrowseAuditEventsSchema),
|
|
59
|
+
requirements: { default: PREMIUM_REQ },
|
|
60
|
+
gate: { envVar: 'USE_AUDIT_EVENTS', defaultValue: true },
|
|
61
|
+
handler: async (args) => {
|
|
62
|
+
const input = schema_readonly_1.BrowseAuditEventsSchema.parse(args);
|
|
63
|
+
(0, utils_1.assertActionAllowed)('browse_audit_events', input.action);
|
|
64
|
+
switch (input.action) {
|
|
65
|
+
case 'list_instance': {
|
|
66
|
+
const { action: _action, ...query } = input;
|
|
67
|
+
return gitlab_api_1.gitlab.get('audit_events', { query: (0, gitlab_api_1.toQuery)(query, []) });
|
|
68
|
+
}
|
|
69
|
+
case 'list_group': {
|
|
70
|
+
const { action: _action, group_id, ...query } = input;
|
|
71
|
+
return gitlab_api_1.gitlab.get(`groups/${encodeURIComponent(group_id)}/audit_events`, {
|
|
72
|
+
query: (0, gitlab_api_1.toQuery)(query, []),
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
case 'list_project': {
|
|
76
|
+
const { action: _action, project_id, ...query } = input;
|
|
77
|
+
return gitlab_api_1.gitlab.get(`projects/${encodeURIComponent(project_id)}/audit_events`, {
|
|
78
|
+
query: (0, gitlab_api_1.toQuery)(query, []),
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
case 'get':
|
|
82
|
+
return gitlab_api_1.gitlab.get(`${auditBasePath(input)}/${input.audit_event_id}`);
|
|
83
|
+
default:
|
|
84
|
+
throw new Error(`Unknown action: ${input.action}`);
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
]);
|
|
90
|
+
function getAuditEventsReadOnlyToolNames() {
|
|
91
|
+
return ['browse_audit_events'];
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../../src/entities/audit_events/registry.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkFA,0EAEC;AApFD,uCAAyB;AACzB,uDAA4D;AAC5D,uDAAyD;AAEzD,oCAA+C;AAK/C,MAAM,WAAW,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAW,CAAC;AAM5F,SAAS,aAAa,CAAC,KAAiD;IACtE,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;QACrB,OAAO,YAAY,kBAAkB,CAAC,KAAK,CAAC,UAAU,CAAC,eAAe,CAAC;IACzE,CAAC;IACD,IAAI,KAAK,CAAC,QAAQ,EAAE,C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oBAED,KAAK,cAAc,CAAC,CAAC,CAAC;wBACpB,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,KAAK,EAAE,GAAG,KAAK,CAAC;wBACxD,OAAO,mBAAM,CAAC,GAAG,CAAC,YAAY,kBAAkB,CAAC,UAAU,CAAC,eAAe,EAAE;4BAC3E,KAAK,EAAE,IAAA,oBAAO,EAAC,KAAK,EAAE,EAAE,CAAC;yBAC1B,CAAC,CAAC;oBACL,CAAC;oBAED,KAAK,KAAK;wBACR,OAAO,mBAAM,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,cAAc,EAAE,CAAC,CAAC;oBAGvE;wBACE,MAAM,IAAI,KAAK,CAAC,mBAAoB,KAA4B,CAAC,MAAM,EAAE,CAAC,CAAC;gBAC/E,CAAC;YACH,CAAC;SACF;KACF;CACF,CAAC,CAAC;AAGH,SAAgB,+BAA+B;IAC7C,OAAO,CAAC,qBAAqB,CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const projectIdField: z.ZodPreprocess<z.ZodCoercedString<unknown>>;
|
|
3
|
+
export declare const groupIdField: z.ZodPreprocess<z.ZodCoercedString<unknown>>;
|
|
4
|
+
export declare const auditEventIdField: z.ZodCoercedNumber<unknown>;
|
|
5
|
+
export declare const BrowseAuditEventsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
6
|
+
per_page: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
7
|
+
page: z.ZodOptional<z.ZodNumber>;
|
|
8
|
+
action: z.ZodLiteral<"list_instance">;
|
|
9
|
+
entity_type: z.ZodOptional<z.ZodString>;
|
|
10
|
+
entity_id: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
11
|
+
created_after: z.ZodOptional<z.ZodString>;
|
|
12
|
+
created_before: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
14
|
+
per_page: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
15
|
+
page: z.ZodOptional<z.ZodNumber>;
|
|
16
|
+
action: z.ZodLiteral<"list_group">;
|
|
17
|
+
group_id: z.ZodPreprocess<z.ZodCoercedString<unknown>>;
|
|
18
|
+
created_after: z.ZodOptional<z.ZodString>;
|
|
19
|
+
created_before: z.ZodOptional<z.ZodString>;
|
|
20
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
21
|
+
per_page: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
22
|
+
page: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
action: z.ZodLiteral<"list_project">;
|
|
24
|
+
project_id: z.ZodPreprocess<z.ZodCoercedString<unknown>>;
|
|
25
|
+
created_after: z.ZodOptional<z.ZodString>;
|
|
26
|
+
created_before: z.ZodOptional<z.ZodString>;
|
|
27
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
28
|
+
action: z.ZodLiteral<"get">;
|
|
29
|
+
audit_event_id: z.ZodCoercedNumber<unknown>;
|
|
30
|
+
project_id: z.ZodOptional<z.ZodPreprocess<z.ZodCoercedString<unknown>>>;
|
|
31
|
+
group_id: z.ZodOptional<z.ZodPreprocess<z.ZodCoercedString<unknown>>>;
|
|
32
|
+
}, z.core.$strip>], "action">;
|
|
33
|
+
export type BrowseAuditEventsInput = z.infer<typeof BrowseAuditEventsSchema>;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BrowseAuditEventsSchema = exports.auditEventIdField = exports.groupIdField = exports.projectIdField = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
exports.projectIdField = utils_1.requiredId.describe("Project ID or URL-encoded path (e.g. 'group/project' or '123').");
|
|
7
|
+
exports.groupIdField = utils_1.requiredId.describe("Group ID or URL-encoded path (e.g. 'my-group' or '42').");
|
|
8
|
+
exports.auditEventIdField = zod_1.z.coerce
|
|
9
|
+
.number()
|
|
10
|
+
.int()
|
|
11
|
+
.positive()
|
|
12
|
+
.describe('Numeric audit-event ID (from a list action).');
|
|
13
|
+
const createdAfterField = zod_1.z
|
|
14
|
+
.string()
|
|
15
|
+
.regex(/^\d{4}-\d{2}-\d{2}$/, 'created_after must be a YYYY-MM-DD date')
|
|
16
|
+
.optional()
|
|
17
|
+
.describe('Return events created on or after this date (YYYY-MM-DD).');
|
|
18
|
+
const createdBeforeField = zod_1.z
|
|
19
|
+
.string()
|
|
20
|
+
.regex(/^\d{4}-\d{2}-\d{2}$/, 'created_before must be a YYYY-MM-DD date')
|
|
21
|
+
.optional()
|
|
22
|
+
.describe('Return events created on or before this date (YYYY-MM-DD).');
|
|
23
|
+
const ListInstanceSchema = zod_1.z.object({
|
|
24
|
+
action: zod_1.z
|
|
25
|
+
.literal('list_instance')
|
|
26
|
+
.describe('List instance-wide audit events (requires admin; Premium+)'),
|
|
27
|
+
entity_type: zod_1.z
|
|
28
|
+
.string()
|
|
29
|
+
.optional()
|
|
30
|
+
.describe("Filter by entity type, e.g. 'User', 'Group', 'Project', 'Key'."),
|
|
31
|
+
entity_id: zod_1.z.coerce
|
|
32
|
+
.number()
|
|
33
|
+
.int()
|
|
34
|
+
.positive()
|
|
35
|
+
.optional()
|
|
36
|
+
.describe('Filter by the numeric ID of the entity (used with entity_type).'),
|
|
37
|
+
created_after: createdAfterField,
|
|
38
|
+
created_before: createdBeforeField,
|
|
39
|
+
...(0, utils_1.paginationFields)(),
|
|
40
|
+
});
|
|
41
|
+
const ListGroupSchema = zod_1.z.object({
|
|
42
|
+
action: zod_1.z
|
|
43
|
+
.literal('list_group')
|
|
44
|
+
.describe('List a group audit events (Premium+, group owner/admin)'),
|
|
45
|
+
group_id: exports.groupIdField,
|
|
46
|
+
created_after: createdAfterField,
|
|
47
|
+
created_before: createdBeforeField,
|
|
48
|
+
...(0, utils_1.paginationFields)(),
|
|
49
|
+
});
|
|
50
|
+
const ListProjectSchema = zod_1.z.object({
|
|
51
|
+
action: zod_1.z
|
|
52
|
+
.literal('list_project')
|
|
53
|
+
.describe('List a project audit events (Premium+, project owner/admin)'),
|
|
54
|
+
project_id: exports.projectIdField,
|
|
55
|
+
created_after: createdAfterField,
|
|
56
|
+
created_before: createdBeforeField,
|
|
57
|
+
...(0, utils_1.paginationFields)(),
|
|
58
|
+
});
|
|
59
|
+
const GetAuditEventSchema = zod_1.z.object({
|
|
60
|
+
action: zod_1.z
|
|
61
|
+
.literal('get')
|
|
62
|
+
.describe('Get a single audit event by ID. Pass project_id for a project event, group_id for a group event, or neither for an instance event (admin).'),
|
|
63
|
+
audit_event_id: exports.auditEventIdField,
|
|
64
|
+
project_id: utils_1.requiredId.optional().describe('Set for a project audit event.'),
|
|
65
|
+
group_id: utils_1.requiredId.optional().describe('Set for a group audit event.'),
|
|
66
|
+
});
|
|
67
|
+
exports.BrowseAuditEventsSchema = zod_1.z
|
|
68
|
+
.discriminatedUnion('action', [
|
|
69
|
+
ListInstanceSchema,
|
|
70
|
+
ListGroupSchema,
|
|
71
|
+
ListProjectSchema,
|
|
72
|
+
GetAuditEventSchema,
|
|
73
|
+
])
|
|
74
|
+
.refine((data) => data.action !== 'get' || !(data.project_id && data.group_id), {
|
|
75
|
+
message: 'Pass at most one of project_id or group_id (an event belongs to a single scope)',
|
|
76
|
+
path: ['project_id'],
|
|
77
|
+
});
|
|
78
|
+
//# sourceMappingURL=schema-readonly.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-readonly.js","sourceRoot":"","sources":["../../../../src/entities/audit_events/schema-readonly.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,oCAAwD;AAa3C,QAAA,cAAc,GAAG,kBAAU,CAAC,QAAQ,CAC/C,iEAAiE,CAClE,CAAC;AACW,QAAA,YAAY,GAAG,kBAAU,CAAC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