@pierre/storage 0.9.2 → 1.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 +77 -43
- package/dist/index.cjs +148 -43
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -7
- package/dist/index.d.ts +12 -7
- package/dist/index.js +148 -43
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/src/commit-pack.ts +103 -99
- package/src/commit.ts +373 -365
- package/src/diff-commit.ts +272 -259
- package/src/errors.ts +34 -34
- package/src/fetch.ts +146 -141
- package/src/index.ts +1400 -1249
- package/src/schemas.ts +120 -114
- package/src/stream-utils.ts +225 -208
- package/src/types.ts +378 -354
- package/src/util.ts +41 -34
- package/src/version.ts +1 -1
- package/src/webhook.ts +244 -239
package/src/schemas.ts
CHANGED
|
@@ -1,205 +1,209 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
3
|
export const listFilesResponseSchema = z.object({
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
paths: z.array(z.string()),
|
|
5
|
+
ref: z.string(),
|
|
6
6
|
});
|
|
7
7
|
|
|
8
8
|
export const branchInfoSchema = z.object({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
cursor: z.string(),
|
|
10
|
+
name: z.string(),
|
|
11
|
+
head_sha: z.string(),
|
|
12
|
+
created_at: z.string(),
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
export const listBranchesResponseSchema = z.object({
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
branches: z.array(branchInfoSchema),
|
|
17
|
+
next_cursor: z.string().nullable().optional(),
|
|
18
|
+
has_more: z.boolean(),
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
export const commitInfoRawSchema = z.object({
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
sha: z.string(),
|
|
23
|
+
message: z.string(),
|
|
24
|
+
author_name: z.string(),
|
|
25
|
+
author_email: z.string(),
|
|
26
|
+
committer_name: z.string(),
|
|
27
|
+
committer_email: z.string(),
|
|
28
|
+
date: z.string(),
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
export const listCommitsResponseSchema = z.object({
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
commits: z.array(commitInfoRawSchema),
|
|
33
|
+
next_cursor: z.string().nullable().optional(),
|
|
34
|
+
has_more: z.boolean(),
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
export const repoBaseInfoSchema = z.object({
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
provider: z.string(),
|
|
39
|
+
owner: z.string(),
|
|
40
|
+
name: z.string(),
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
export const repoInfoSchema = z.object({
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
repo_id: z.string(),
|
|
45
|
+
url: z.string(),
|
|
46
|
+
default_branch: z.string(),
|
|
47
|
+
created_at: z.string(),
|
|
48
|
+
base_repo: repoBaseInfoSchema.optional().nullable(),
|
|
49
49
|
});
|
|
50
50
|
|
|
51
51
|
export const listReposResponseSchema = z.object({
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
repos: z.array(repoInfoSchema),
|
|
53
|
+
next_cursor: z.string().nullable().optional(),
|
|
54
|
+
has_more: z.boolean(),
|
|
55
55
|
});
|
|
56
56
|
|
|
57
57
|
export const noteReadResponseSchema = z.object({
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
sha: z.string(),
|
|
59
|
+
note: z.string(),
|
|
60
|
+
ref_sha: z.string(),
|
|
61
61
|
});
|
|
62
62
|
|
|
63
63
|
export const noteResultSchema = z.object({
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
success: z.boolean(),
|
|
65
|
+
status: z.string(),
|
|
66
|
+
message: z.string().optional(),
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
export const noteWriteResponseSchema = z.object({
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
70
|
+
sha: z.string(),
|
|
71
|
+
target_ref: z.string(),
|
|
72
|
+
base_commit: z.string().optional(),
|
|
73
|
+
new_ref_sha: z.string(),
|
|
74
|
+
result: noteResultSchema,
|
|
75
75
|
});
|
|
76
76
|
|
|
77
77
|
export const diffStatsSchema = z.object({
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
files: z.number(),
|
|
79
|
+
additions: z.number(),
|
|
80
|
+
deletions: z.number(),
|
|
81
|
+
changes: z.number(),
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
export const diffFileRawSchema = z.object({
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
85
|
+
path: z.string(),
|
|
86
|
+
state: z.string(),
|
|
87
|
+
old_path: z.string().nullable().optional(),
|
|
88
|
+
raw: z.string(),
|
|
89
|
+
bytes: z.number(),
|
|
90
|
+
is_eof: z.boolean(),
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
export const filteredFileRawSchema = z.object({
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
94
|
+
path: z.string(),
|
|
95
|
+
state: z.string(),
|
|
96
|
+
old_path: z.string().nullable().optional(),
|
|
97
|
+
bytes: z.number(),
|
|
98
|
+
is_eof: z.boolean(),
|
|
99
99
|
});
|
|
100
100
|
|
|
101
101
|
export const branchDiffResponseSchema = z.object({
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
102
|
+
branch: z.string(),
|
|
103
|
+
base: z.string(),
|
|
104
|
+
stats: diffStatsSchema,
|
|
105
|
+
files: z.array(diffFileRawSchema),
|
|
106
|
+
filtered_files: z.array(filteredFileRawSchema),
|
|
107
107
|
});
|
|
108
108
|
|
|
109
109
|
export const commitDiffResponseSchema = z.object({
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
sha: z.string(),
|
|
111
|
+
stats: diffStatsSchema,
|
|
112
|
+
files: z.array(diffFileRawSchema),
|
|
113
|
+
filtered_files: z.array(filteredFileRawSchema),
|
|
114
114
|
});
|
|
115
115
|
|
|
116
116
|
export const createBranchResponseSchema = z.object({
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
117
|
+
message: z.string(),
|
|
118
|
+
target_branch: z.string(),
|
|
119
|
+
target_is_ephemeral: z.boolean(),
|
|
120
|
+
commit_sha: z.string().nullable().optional(),
|
|
121
121
|
});
|
|
122
122
|
|
|
123
123
|
export const refUpdateResultSchema = z.object({
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
124
|
+
branch: z.string(),
|
|
125
|
+
old_sha: z.string(),
|
|
126
|
+
new_sha: z.string(),
|
|
127
|
+
success: z.boolean(),
|
|
128
|
+
status: z.string(),
|
|
129
|
+
message: z.string().optional(),
|
|
130
130
|
});
|
|
131
131
|
|
|
132
132
|
export const commitPackCommitSchema = z.object({
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
133
|
+
commit_sha: z.string(),
|
|
134
|
+
tree_sha: z.string(),
|
|
135
|
+
target_branch: z.string(),
|
|
136
|
+
pack_bytes: z.number(),
|
|
137
|
+
blob_count: z.number(),
|
|
138
138
|
});
|
|
139
139
|
|
|
140
|
-
export const restoreCommitCommitSchema = commitPackCommitSchema.omit({
|
|
140
|
+
export const restoreCommitCommitSchema = commitPackCommitSchema.omit({
|
|
141
|
+
blob_count: true,
|
|
142
|
+
});
|
|
141
143
|
|
|
142
144
|
export const refUpdateResultWithOptionalsSchema = z.object({
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
145
|
+
branch: z.string().optional(),
|
|
146
|
+
old_sha: z.string().optional(),
|
|
147
|
+
new_sha: z.string().optional(),
|
|
148
|
+
success: z.boolean().optional(),
|
|
149
|
+
status: z.string(),
|
|
150
|
+
message: z.string().optional(),
|
|
149
151
|
});
|
|
150
152
|
|
|
151
153
|
export const commitPackAckSchema = z.object({
|
|
152
|
-
|
|
153
|
-
|
|
154
|
+
commit: commitPackCommitSchema,
|
|
155
|
+
result: refUpdateResultSchema,
|
|
154
156
|
});
|
|
155
157
|
|
|
156
158
|
export const restoreCommitAckSchema = z.object({
|
|
157
|
-
|
|
158
|
-
|
|
159
|
+
commit: restoreCommitCommitSchema,
|
|
160
|
+
result: refUpdateResultSchema.extend({ success: z.literal(true) }),
|
|
159
161
|
});
|
|
160
162
|
|
|
161
163
|
export const commitPackResponseSchema = z.object({
|
|
162
|
-
|
|
163
|
-
|
|
164
|
+
commit: commitPackCommitSchema.partial().optional().nullable(),
|
|
165
|
+
result: refUpdateResultWithOptionalsSchema,
|
|
164
166
|
});
|
|
165
167
|
|
|
166
168
|
export const restoreCommitResponseSchema = z.object({
|
|
167
|
-
|
|
168
|
-
|
|
169
|
+
commit: restoreCommitCommitSchema.partial().optional().nullable(),
|
|
170
|
+
result: refUpdateResultWithOptionalsSchema,
|
|
169
171
|
});
|
|
170
172
|
|
|
171
173
|
export const grepLineSchema = z.object({
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
174
|
+
line_number: z.number(),
|
|
175
|
+
text: z.string(),
|
|
176
|
+
type: z.string(),
|
|
175
177
|
});
|
|
176
178
|
|
|
177
179
|
export const grepFileMatchSchema = z.object({
|
|
178
|
-
|
|
179
|
-
|
|
180
|
+
path: z.string(),
|
|
181
|
+
lines: z.array(grepLineSchema),
|
|
180
182
|
});
|
|
181
183
|
|
|
182
184
|
export const grepResponseSchema = z.object({
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
185
|
+
query: z.object({
|
|
186
|
+
pattern: z.string(),
|
|
187
|
+
case_sensitive: z.boolean(),
|
|
188
|
+
}),
|
|
189
|
+
repo: z.object({
|
|
190
|
+
ref: z.string(),
|
|
191
|
+
commit: z.string(),
|
|
192
|
+
}),
|
|
193
|
+
matches: z.array(grepFileMatchSchema),
|
|
194
|
+
next_cursor: z.string().nullable().optional(),
|
|
195
|
+
has_more: z.boolean(),
|
|
194
196
|
});
|
|
195
197
|
|
|
196
198
|
export const errorEnvelopeSchema = z.object({
|
|
197
|
-
|
|
199
|
+
error: z.string(),
|
|
198
200
|
});
|
|
199
201
|
|
|
200
202
|
export type ListFilesResponseRaw = z.infer<typeof listFilesResponseSchema>;
|
|
201
203
|
export type RawBranchInfo = z.infer<typeof branchInfoSchema>;
|
|
202
|
-
export type ListBranchesResponseRaw = z.infer<
|
|
204
|
+
export type ListBranchesResponseRaw = z.infer<
|
|
205
|
+
typeof listBranchesResponseSchema
|
|
206
|
+
>;
|
|
203
207
|
export type RawCommitInfo = z.infer<typeof commitInfoRawSchema>;
|
|
204
208
|
export type ListCommitsResponseRaw = z.infer<typeof listCommitsResponseSchema>;
|
|
205
209
|
export type RawRepoBaseInfo = z.infer<typeof repoBaseInfoSchema>;
|
|
@@ -211,7 +215,9 @@ export type RawFileDiff = z.infer<typeof diffFileRawSchema>;
|
|
|
211
215
|
export type RawFilteredFile = z.infer<typeof filteredFileRawSchema>;
|
|
212
216
|
export type GetBranchDiffResponseRaw = z.infer<typeof branchDiffResponseSchema>;
|
|
213
217
|
export type GetCommitDiffResponseRaw = z.infer<typeof commitDiffResponseSchema>;
|
|
214
|
-
export type CreateBranchResponseRaw = z.infer<
|
|
218
|
+
export type CreateBranchResponseRaw = z.infer<
|
|
219
|
+
typeof createBranchResponseSchema
|
|
220
|
+
>;
|
|
215
221
|
export type CommitPackAckRaw = z.infer<typeof commitPackAckSchema>;
|
|
216
222
|
export type RestoreCommitAckRaw = z.infer<typeof restoreCommitAckSchema>;
|
|
217
223
|
export type GrepResponseRaw = z.infer<typeof grepResponseSchema>;
|