@leed-ai/git-gateway-backend-gitlab 0.0.0-stage → 0.1.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.
@@ -0,0 +1,130 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ import { z } from 'zod';
3
+
4
+ const SHA = /^[0-9a-f]{40}$/;
5
+ const EXAMPLE_SHA = '8f3c2a9e1b7d4c6f0a5e2d9b8c7a6f5e4d3c2b1a';
6
+ const timestamp = z.iso.datetime({ offset: true });
7
+
8
+ /** A project from the GitLab Projects API. */
9
+ export const GitLabProject = z
10
+ .object({
11
+ id: z.int().positive().describe('Numeric project id.'),
12
+ path: z.string().min(1).describe("The project's path segment, which is the repository name."),
13
+ path_with_namespace: z.string().min(1).describe('Full path, "<namespace>/<path>".'),
14
+ default_branch: z
15
+ .string()
16
+ .min(1)
17
+ .nullable()
18
+ .optional()
19
+ .describe('The default branch; null or absent for an empty repository on some GitLab versions.'),
20
+ created_at: timestamp.describe('When the project was created, ISO 8601.'),
21
+ http_url_to_repo: z.url().describe('HTTPS clone URL of the repository, ending in ".git".'),
22
+ marked_for_deletion_on: z
23
+ .string()
24
+ .nullable()
25
+ .optional()
26
+ .describe(
27
+ 'Date the project is scheduled for deletion (delayed deletion); null or absent when it is not.',
28
+ ),
29
+ })
30
+ .meta({
31
+ id: 'GitLabProject',
32
+ title: 'GitLab project',
33
+ description: 'The fields of a GitLab project the backend uses; other fields are ignored.',
34
+ examples: [
35
+ {
36
+ id: 1234,
37
+ path: 'acme-raw-content',
38
+ path_with_namespace: 'acme/sites/acme-raw-content',
39
+ default_branch: 'main',
40
+ created_at: '2026-11-20T09:30:00.000Z',
41
+ http_url_to_repo: 'https://gitlab.com/acme/sites/acme-raw-content.git',
42
+ marked_for_deletion_on: null,
43
+ },
44
+ ],
45
+ });
46
+
47
+ /** A GitLab project, inferred from {@link GitLabProject}. */
48
+ export type GitLabProject = z.infer<typeof GitLabProject>;
49
+
50
+ /** A group from the GitLab Groups API. */
51
+ export const GitLabGroup = z
52
+ .object({
53
+ id: z.int().positive().describe('Numeric group id, used as namespace_id when creating projects.'),
54
+ full_path: z.string().min(1).describe('Full path of the group.'),
55
+ })
56
+ .meta({
57
+ id: 'GitLabGroup',
58
+ title: 'GitLab group',
59
+ description: 'The fields of a GitLab group the backend uses.',
60
+ examples: [{ id: 42, full_path: 'acme/sites' }],
61
+ });
62
+
63
+ /** A GitLab group, inferred from {@link GitLabGroup}. */
64
+ export type GitLabGroup = z.infer<typeof GitLabGroup>;
65
+
66
+ /** A branch or tag from the GitLab Branches or Tags API. */
67
+ export const GitLabRef = z
68
+ .object({
69
+ name: z.string().min(1).describe('Short branch or tag name.'),
70
+ commit: z
71
+ .object({
72
+ id: z.string().regex(SHA).describe('Id of the commit the ref names (for a tag, the peeled commit).'),
73
+ })
74
+ .describe('The commit the ref points at.'),
75
+ })
76
+ .meta({
77
+ id: 'GitLabRef',
78
+ title: 'GitLab branch or tag',
79
+ description: 'A branch or tag and the commit it names.',
80
+ examples: [{ name: 'main', commit: { id: EXAMPLE_SHA } }],
81
+ });
82
+
83
+ /** A GitLab branch or tag, inferred from {@link GitLabRef}. */
84
+ export type GitLabRef = z.infer<typeof GitLabRef>;
85
+
86
+ /** A commit from the GitLab Commits API, as listed. */
87
+ export const GitLabCommitSummary = z
88
+ .object({
89
+ id: z.string().regex(SHA).describe('The commit id.'),
90
+ parent_ids: z
91
+ .array(z.string().regex(SHA).describe('A parent commit id.'))
92
+ .describe('Parent ids in order.'),
93
+ })
94
+ .meta({
95
+ id: 'GitLabCommitSummary',
96
+ title: 'GitLab commit summary',
97
+ description:
98
+ 'The fields of a GitLab commit the backend uses to list history. GitLab does not report the tree id or exact message, so the commit objects themselves are fetched over git.',
99
+ examples: [{ id: EXAMPLE_SHA, parent_ids: [] }],
100
+ });
101
+
102
+ /** A listed GitLab commit, inferred from {@link GitLabCommitSummary}. */
103
+ export type GitLabCommitSummary = z.infer<typeof GitLabCommitSummary>;
104
+
105
+ /** The body of a GitLab API error response. */
106
+ export const GitLabErrorBody = z
107
+ .object({
108
+ message: z
109
+ .union([
110
+ z.string().describe('A plain message such as "404 Project Not Found".'),
111
+ z
112
+ .record(
113
+ z.string().describe('The field that failed validation.'),
114
+ z.array(z.string().describe('One failure.')).describe('What is wrong with it.'),
115
+ )
116
+ .describe('Validation failures by field, e.g. {"path": ["has already been taken"]}.'),
117
+ ])
118
+ .optional()
119
+ .describe('The error message; absent when GitLab sent only "error".'),
120
+ error: z.string().optional().describe('A short error code or message, e.g. "insufficient_scope".'),
121
+ })
122
+ .meta({
123
+ id: 'GitLabErrorBody',
124
+ title: 'GitLab error body',
125
+ description: 'The JSON body of a GitLab API error.',
126
+ examples: [{ message: '404 Project Not Found' }, { message: { path: ['has already been taken'] } }],
127
+ });
128
+
129
+ /** A GitLab error body, inferred from {@link GitLabErrorBody}. */
130
+ export type GitLabErrorBody = z.infer<typeof GitLabErrorBody>;