@pierre/storage 0.1.4 → 0.2.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/dist/index.cjs +25 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +25 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/commit.ts +22 -3
- package/src/index.ts +14 -4
- package/src/types.ts +4 -0
package/src/commit.ts
CHANGED
|
@@ -40,6 +40,8 @@ interface CommitMetadataPayload {
|
|
|
40
40
|
expected_head_sha?: string;
|
|
41
41
|
base_branch?: string;
|
|
42
42
|
commit_message: string;
|
|
43
|
+
ephemeral?: boolean;
|
|
44
|
+
ephemeral_base?: boolean;
|
|
43
45
|
author: {
|
|
44
46
|
name: string;
|
|
45
47
|
email: string;
|
|
@@ -72,6 +74,8 @@ type NormalizedCommitOptions = {
|
|
|
72
74
|
commitMessage: string;
|
|
73
75
|
expectedHeadSha?: string;
|
|
74
76
|
baseBranch?: string;
|
|
77
|
+
ephemeral?: boolean;
|
|
78
|
+
ephemeralBase?: boolean;
|
|
75
79
|
author: CommitSignature;
|
|
76
80
|
committer?: CommitSignature;
|
|
77
81
|
signal?: AbortSignal;
|
|
@@ -135,6 +139,10 @@ export class CommitBuilderImpl implements CommitBuilder {
|
|
|
135
139
|
this.options.baseBranch = trimmedBase;
|
|
136
140
|
}
|
|
137
141
|
}
|
|
142
|
+
|
|
143
|
+
if (this.options.ephemeralBase && !this.options.baseBranch) {
|
|
144
|
+
throw new Error('createCommit ephemeralBase requires baseBranch');
|
|
145
|
+
}
|
|
138
146
|
}
|
|
139
147
|
|
|
140
148
|
addFile(path: string, source: CommitFileSource, options?: CommitFileOptions): CommitBuilder {
|
|
@@ -246,6 +254,13 @@ export class CommitBuilderImpl implements CommitBuilder {
|
|
|
246
254
|
};
|
|
247
255
|
}
|
|
248
256
|
|
|
257
|
+
if (this.options.ephemeral) {
|
|
258
|
+
metadata.ephemeral = true;
|
|
259
|
+
}
|
|
260
|
+
if (this.options.ephemeralBase) {
|
|
261
|
+
metadata.ephemeral_base = true;
|
|
262
|
+
}
|
|
263
|
+
|
|
249
264
|
return metadata;
|
|
250
265
|
}
|
|
251
266
|
|
|
@@ -364,9 +379,11 @@ function requiresDuplex(body: unknown): boolean {
|
|
|
364
379
|
return true;
|
|
365
380
|
}
|
|
366
381
|
|
|
367
|
-
const readableStreamCtor = (
|
|
368
|
-
|
|
369
|
-
|
|
382
|
+
const readableStreamCtor = (
|
|
383
|
+
globalThis as {
|
|
384
|
+
ReadableStream?: new (...args: unknown[]) => unknown;
|
|
385
|
+
}
|
|
386
|
+
).ReadableStream;
|
|
370
387
|
if (readableStreamCtor && body instanceof readableStreamCtor) {
|
|
371
388
|
return true;
|
|
372
389
|
}
|
|
@@ -599,6 +616,8 @@ function normalizeCommitOptions(options: CreateCommitOptions): NormalizedCommitO
|
|
|
599
616
|
commitMessage: options.commitMessage,
|
|
600
617
|
expectedHeadSha: options.expectedHeadSha,
|
|
601
618
|
baseBranch: options.baseBranch,
|
|
619
|
+
ephemeral: options.ephemeral === true,
|
|
620
|
+
ephemeralBase: options.ephemeralBase === true,
|
|
602
621
|
author: options.author,
|
|
603
622
|
committer: options.committer,
|
|
604
623
|
signal: options.signal,
|
package/src/index.ts
CHANGED
|
@@ -357,6 +357,9 @@ class RepoImpl implements Repo {
|
|
|
357
357
|
if (options.ref) {
|
|
358
358
|
params.ref = options.ref;
|
|
359
359
|
}
|
|
360
|
+
if (typeof options.ephemeral === 'boolean') {
|
|
361
|
+
params.ephemeral = String(options.ephemeral);
|
|
362
|
+
}
|
|
360
363
|
|
|
361
364
|
// Return the raw fetch Response for streaming
|
|
362
365
|
return this.api.get({ path: 'repos/file', params }, jwt);
|
|
@@ -369,10 +372,17 @@ class RepoImpl implements Repo {
|
|
|
369
372
|
ttl,
|
|
370
373
|
});
|
|
371
374
|
|
|
372
|
-
const params: Record<string, string>
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
375
|
+
const params: Record<string, string> = {};
|
|
376
|
+
if (options?.ref) {
|
|
377
|
+
params.ref = options.ref;
|
|
378
|
+
}
|
|
379
|
+
if (typeof options?.ephemeral === 'boolean') {
|
|
380
|
+
params.ephemeral = String(options.ephemeral);
|
|
381
|
+
}
|
|
382
|
+
const response = await this.api.get(
|
|
383
|
+
{ path: 'repos/files', params: Object.keys(params).length ? params : undefined },
|
|
384
|
+
jwt,
|
|
385
|
+
);
|
|
376
386
|
|
|
377
387
|
const raw = listFilesResponseSchema.parse(await response.json());
|
|
378
388
|
return { paths: raw.paths, ref: raw.ref };
|
package/src/types.ts
CHANGED
|
@@ -88,6 +88,7 @@ export interface CreateRepoOptions extends GitStorageInvocationOptions {
|
|
|
88
88
|
export interface GetFileOptions extends GitStorageInvocationOptions {
|
|
89
89
|
path: string;
|
|
90
90
|
ref?: string;
|
|
91
|
+
ephemeral?: boolean;
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
export interface PullUpstreamOptions extends GitStorageInvocationOptions {
|
|
@@ -97,6 +98,7 @@ export interface PullUpstreamOptions extends GitStorageInvocationOptions {
|
|
|
97
98
|
// List Files API types
|
|
98
99
|
export interface ListFilesOptions extends GitStorageInvocationOptions {
|
|
99
100
|
ref?: string;
|
|
101
|
+
ephemeral?: boolean;
|
|
100
102
|
}
|
|
101
103
|
|
|
102
104
|
export type ListFilesResponse = ListFilesResponseRaw;
|
|
@@ -228,6 +230,8 @@ interface CreateCommitBaseOptions extends GitStorageInvocationOptions {
|
|
|
228
230
|
commitMessage: string;
|
|
229
231
|
expectedHeadSha?: string;
|
|
230
232
|
baseBranch?: string;
|
|
233
|
+
ephemeral?: boolean;
|
|
234
|
+
ephemeralBase?: boolean;
|
|
231
235
|
author: CommitSignature;
|
|
232
236
|
committer?: CommitSignature;
|
|
233
237
|
signal?: AbortSignal;
|