@pierre/storage 0.2.1 → 0.2.3
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 +30 -0
- package/dist/index.cjs +50 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +34 -2
- package/dist/index.d.ts +34 -2
- package/dist/index.js +50 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +55 -1
- package/src/schemas.ts +8 -0
- package/src/types.ts +21 -1
package/dist/index.d.cts
CHANGED
|
@@ -398,6 +398,22 @@ declare const commitDiffResponseSchema: z.ZodObject<{
|
|
|
398
398
|
old_path?: string | null | undefined;
|
|
399
399
|
}[];
|
|
400
400
|
}>;
|
|
401
|
+
declare const createBranchResponseSchema: z.ZodObject<{
|
|
402
|
+
message: z.ZodString;
|
|
403
|
+
target_branch: z.ZodString;
|
|
404
|
+
target_is_ephemeral: z.ZodBoolean;
|
|
405
|
+
commit_sha: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
406
|
+
}, "strip", z.ZodTypeAny, {
|
|
407
|
+
target_branch: string;
|
|
408
|
+
message: string;
|
|
409
|
+
target_is_ephemeral: boolean;
|
|
410
|
+
commit_sha?: string | null | undefined;
|
|
411
|
+
}, {
|
|
412
|
+
target_branch: string;
|
|
413
|
+
message: string;
|
|
414
|
+
target_is_ephemeral: boolean;
|
|
415
|
+
commit_sha?: string | null | undefined;
|
|
416
|
+
}>;
|
|
401
417
|
type ListFilesResponseRaw = z.infer<typeof listFilesResponseSchema>;
|
|
402
418
|
type RawBranchInfo$1 = z.infer<typeof branchInfoSchema>;
|
|
403
419
|
type ListBranchesResponseRaw = z.infer<typeof listBranchesResponseSchema>;
|
|
@@ -407,6 +423,7 @@ type RawFileDiff$1 = z.infer<typeof diffFileRawSchema>;
|
|
|
407
423
|
type RawFilteredFile$1 = z.infer<typeof filteredFileRawSchema>;
|
|
408
424
|
type GetBranchDiffResponseRaw = z.infer<typeof branchDiffResponseSchema>;
|
|
409
425
|
type GetCommitDiffResponseRaw = z.infer<typeof commitDiffResponseSchema>;
|
|
426
|
+
type CreateBranchResponseRaw = z.infer<typeof createBranchResponseSchema>;
|
|
410
427
|
|
|
411
428
|
/**
|
|
412
429
|
* Type definitions for Pierre Git Storage SDK
|
|
@@ -431,14 +448,16 @@ interface GetRemoteURLOptions {
|
|
|
431
448
|
interface Repo {
|
|
432
449
|
id: string;
|
|
433
450
|
getRemoteURL(options?: GetRemoteURLOptions): Promise<string>;
|
|
451
|
+
getEphemeralRemoteURL(options?: GetRemoteURLOptions): Promise<string>;
|
|
434
452
|
getFileStream(options: GetFileOptions): Promise<Response>;
|
|
435
453
|
listFiles(options?: ListFilesOptions): Promise<ListFilesResult>;
|
|
436
454
|
listBranches(options?: ListBranchesOptions): Promise<ListBranchesResult>;
|
|
437
455
|
listCommits(options?: ListCommitsOptions): Promise<ListCommitsResult>;
|
|
438
456
|
getBranchDiff(options: GetBranchDiffOptions): Promise<GetBranchDiffResult>;
|
|
439
457
|
getCommitDiff(options: GetCommitDiffOptions): Promise<GetCommitDiffResult>;
|
|
440
|
-
pullUpstream(options
|
|
458
|
+
pullUpstream(options?: PullUpstreamOptions): Promise<void>;
|
|
441
459
|
restoreCommit(options: RestoreCommitOptions): Promise<RestoreCommitResult>;
|
|
460
|
+
createBranch(options: CreateBranchOptions): Promise<CreateBranchResult>;
|
|
442
461
|
createCommit(options: CreateCommitOptions): CommitBuilder;
|
|
443
462
|
createCommitFromDiff(options: CreateCommitFromDiffOptions): Promise<CommitResult>;
|
|
444
463
|
}
|
|
@@ -505,6 +524,19 @@ interface ListBranchesResult {
|
|
|
505
524
|
nextCursor?: string;
|
|
506
525
|
hasMore: boolean;
|
|
507
526
|
}
|
|
527
|
+
interface CreateBranchOptions extends GitStorageInvocationOptions {
|
|
528
|
+
baseBranch: string;
|
|
529
|
+
targetBranch: string;
|
|
530
|
+
baseIsEphemeral?: boolean;
|
|
531
|
+
targetIsEphemeral?: boolean;
|
|
532
|
+
}
|
|
533
|
+
type CreateBranchResponse = CreateBranchResponseRaw;
|
|
534
|
+
interface CreateBranchResult {
|
|
535
|
+
message: string;
|
|
536
|
+
targetBranch: string;
|
|
537
|
+
targetIsEphemeral: boolean;
|
|
538
|
+
commitSha?: string;
|
|
539
|
+
}
|
|
508
540
|
interface ListCommitsOptions extends GitStorageInvocationOptions {
|
|
509
541
|
branch?: string;
|
|
510
542
|
cursor?: string;
|
|
@@ -860,4 +892,4 @@ declare class GitStorage {
|
|
|
860
892
|
declare function createClient(options: GitStorageOptions): GitStorage;
|
|
861
893
|
type StorageOptions = GitStorageOptions;
|
|
862
894
|
|
|
863
|
-
export { ApiError, type BaseRepo, type BlobLike, type BranchInfo, type CommitBuilder, type CommitFileOptions, type CommitFileSource, type CommitInfo, type CommitResult, type CommitSignature, type CommitTextFileOptions, type CreateCommitBranchOptions, type CreateCommitFromDiffOptions, type CreateCommitOptions, type CreateRepoOptions, type DiffFileBase, type DiffFileState, type DiffSource, type DiffStats, type FileDiff, type FileLike, type FilteredFile, type FindOneOptions, type GetBranchDiffOptions, type GetBranchDiffResponse, type GetBranchDiffResult, type GetCommitDiffOptions, type GetCommitDiffResponse, type GetCommitDiffResult, type GetFileOptions, type GetRemoteURLOptions, type GitFileMode, GitStorage, type GitStorageOptions, type LegacyCreateCommitOptions, type ListBranchesOptions, type ListBranchesResponse, type ListBranchesResult, type ListCommitsOptions, type ListCommitsResponse, type ListCommitsResult, type ListFilesOptions, type ListFilesResponse, type ListFilesResult, type OverrideableGitStorageOptions, type ParsedWebhookSignature, type PullUpstreamOptions, type RawBranchInfo, type RawCommitInfo, type RawFileDiff, type RawFilteredFile, type RawWebhookPushEvent, type ReadableStreamLike, type ReadableStreamReaderLike, type RefUpdate, RefUpdateError, type RefUpdateReason, type Repo, type RestoreCommitOptions, type RestoreCommitResult, type StorageOptions, type SupportedRepoProvider, type TextEncoding, type ValidAPIVersion, type ValidMethod, type ValidPath, type WebhookEventPayload, type WebhookPushEvent, type WebhookUnknownEvent, type WebhookValidationOptions, type WebhookValidationResult, createClient, parseSignatureHeader, validateWebhook, validateWebhookSignature };
|
|
895
|
+
export { ApiError, type BaseRepo, type BlobLike, type BranchInfo, type CommitBuilder, type CommitFileOptions, type CommitFileSource, type CommitInfo, type CommitResult, type CommitSignature, type CommitTextFileOptions, type CreateBranchOptions, type CreateBranchResponse, type CreateBranchResult, type CreateCommitBranchOptions, type CreateCommitFromDiffOptions, type CreateCommitOptions, type CreateRepoOptions, type DiffFileBase, type DiffFileState, type DiffSource, type DiffStats, type FileDiff, type FileLike, type FilteredFile, type FindOneOptions, type GetBranchDiffOptions, type GetBranchDiffResponse, type GetBranchDiffResult, type GetCommitDiffOptions, type GetCommitDiffResponse, type GetCommitDiffResult, type GetFileOptions, type GetRemoteURLOptions, type GitFileMode, GitStorage, type GitStorageOptions, type LegacyCreateCommitOptions, type ListBranchesOptions, type ListBranchesResponse, type ListBranchesResult, type ListCommitsOptions, type ListCommitsResponse, type ListCommitsResult, type ListFilesOptions, type ListFilesResponse, type ListFilesResult, type OverrideableGitStorageOptions, type ParsedWebhookSignature, type PullUpstreamOptions, type RawBranchInfo, type RawCommitInfo, type RawFileDiff, type RawFilteredFile, type RawWebhookPushEvent, type ReadableStreamLike, type ReadableStreamReaderLike, type RefUpdate, RefUpdateError, type RefUpdateReason, type Repo, type RestoreCommitOptions, type RestoreCommitResult, type StorageOptions, type SupportedRepoProvider, type TextEncoding, type ValidAPIVersion, type ValidMethod, type ValidPath, type WebhookEventPayload, type WebhookPushEvent, type WebhookUnknownEvent, type WebhookValidationOptions, type WebhookValidationResult, createClient, parseSignatureHeader, validateWebhook, validateWebhookSignature };
|
package/dist/index.d.ts
CHANGED
|
@@ -398,6 +398,22 @@ declare const commitDiffResponseSchema: z.ZodObject<{
|
|
|
398
398
|
old_path?: string | null | undefined;
|
|
399
399
|
}[];
|
|
400
400
|
}>;
|
|
401
|
+
declare const createBranchResponseSchema: z.ZodObject<{
|
|
402
|
+
message: z.ZodString;
|
|
403
|
+
target_branch: z.ZodString;
|
|
404
|
+
target_is_ephemeral: z.ZodBoolean;
|
|
405
|
+
commit_sha: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
406
|
+
}, "strip", z.ZodTypeAny, {
|
|
407
|
+
target_branch: string;
|
|
408
|
+
message: string;
|
|
409
|
+
target_is_ephemeral: boolean;
|
|
410
|
+
commit_sha?: string | null | undefined;
|
|
411
|
+
}, {
|
|
412
|
+
target_branch: string;
|
|
413
|
+
message: string;
|
|
414
|
+
target_is_ephemeral: boolean;
|
|
415
|
+
commit_sha?: string | null | undefined;
|
|
416
|
+
}>;
|
|
401
417
|
type ListFilesResponseRaw = z.infer<typeof listFilesResponseSchema>;
|
|
402
418
|
type RawBranchInfo$1 = z.infer<typeof branchInfoSchema>;
|
|
403
419
|
type ListBranchesResponseRaw = z.infer<typeof listBranchesResponseSchema>;
|
|
@@ -407,6 +423,7 @@ type RawFileDiff$1 = z.infer<typeof diffFileRawSchema>;
|
|
|
407
423
|
type RawFilteredFile$1 = z.infer<typeof filteredFileRawSchema>;
|
|
408
424
|
type GetBranchDiffResponseRaw = z.infer<typeof branchDiffResponseSchema>;
|
|
409
425
|
type GetCommitDiffResponseRaw = z.infer<typeof commitDiffResponseSchema>;
|
|
426
|
+
type CreateBranchResponseRaw = z.infer<typeof createBranchResponseSchema>;
|
|
410
427
|
|
|
411
428
|
/**
|
|
412
429
|
* Type definitions for Pierre Git Storage SDK
|
|
@@ -431,14 +448,16 @@ interface GetRemoteURLOptions {
|
|
|
431
448
|
interface Repo {
|
|
432
449
|
id: string;
|
|
433
450
|
getRemoteURL(options?: GetRemoteURLOptions): Promise<string>;
|
|
451
|
+
getEphemeralRemoteURL(options?: GetRemoteURLOptions): Promise<string>;
|
|
434
452
|
getFileStream(options: GetFileOptions): Promise<Response>;
|
|
435
453
|
listFiles(options?: ListFilesOptions): Promise<ListFilesResult>;
|
|
436
454
|
listBranches(options?: ListBranchesOptions): Promise<ListBranchesResult>;
|
|
437
455
|
listCommits(options?: ListCommitsOptions): Promise<ListCommitsResult>;
|
|
438
456
|
getBranchDiff(options: GetBranchDiffOptions): Promise<GetBranchDiffResult>;
|
|
439
457
|
getCommitDiff(options: GetCommitDiffOptions): Promise<GetCommitDiffResult>;
|
|
440
|
-
pullUpstream(options
|
|
458
|
+
pullUpstream(options?: PullUpstreamOptions): Promise<void>;
|
|
441
459
|
restoreCommit(options: RestoreCommitOptions): Promise<RestoreCommitResult>;
|
|
460
|
+
createBranch(options: CreateBranchOptions): Promise<CreateBranchResult>;
|
|
442
461
|
createCommit(options: CreateCommitOptions): CommitBuilder;
|
|
443
462
|
createCommitFromDiff(options: CreateCommitFromDiffOptions): Promise<CommitResult>;
|
|
444
463
|
}
|
|
@@ -505,6 +524,19 @@ interface ListBranchesResult {
|
|
|
505
524
|
nextCursor?: string;
|
|
506
525
|
hasMore: boolean;
|
|
507
526
|
}
|
|
527
|
+
interface CreateBranchOptions extends GitStorageInvocationOptions {
|
|
528
|
+
baseBranch: string;
|
|
529
|
+
targetBranch: string;
|
|
530
|
+
baseIsEphemeral?: boolean;
|
|
531
|
+
targetIsEphemeral?: boolean;
|
|
532
|
+
}
|
|
533
|
+
type CreateBranchResponse = CreateBranchResponseRaw;
|
|
534
|
+
interface CreateBranchResult {
|
|
535
|
+
message: string;
|
|
536
|
+
targetBranch: string;
|
|
537
|
+
targetIsEphemeral: boolean;
|
|
538
|
+
commitSha?: string;
|
|
539
|
+
}
|
|
508
540
|
interface ListCommitsOptions extends GitStorageInvocationOptions {
|
|
509
541
|
branch?: string;
|
|
510
542
|
cursor?: string;
|
|
@@ -860,4 +892,4 @@ declare class GitStorage {
|
|
|
860
892
|
declare function createClient(options: GitStorageOptions): GitStorage;
|
|
861
893
|
type StorageOptions = GitStorageOptions;
|
|
862
894
|
|
|
863
|
-
export { ApiError, type BaseRepo, type BlobLike, type BranchInfo, type CommitBuilder, type CommitFileOptions, type CommitFileSource, type CommitInfo, type CommitResult, type CommitSignature, type CommitTextFileOptions, type CreateCommitBranchOptions, type CreateCommitFromDiffOptions, type CreateCommitOptions, type CreateRepoOptions, type DiffFileBase, type DiffFileState, type DiffSource, type DiffStats, type FileDiff, type FileLike, type FilteredFile, type FindOneOptions, type GetBranchDiffOptions, type GetBranchDiffResponse, type GetBranchDiffResult, type GetCommitDiffOptions, type GetCommitDiffResponse, type GetCommitDiffResult, type GetFileOptions, type GetRemoteURLOptions, type GitFileMode, GitStorage, type GitStorageOptions, type LegacyCreateCommitOptions, type ListBranchesOptions, type ListBranchesResponse, type ListBranchesResult, type ListCommitsOptions, type ListCommitsResponse, type ListCommitsResult, type ListFilesOptions, type ListFilesResponse, type ListFilesResult, type OverrideableGitStorageOptions, type ParsedWebhookSignature, type PullUpstreamOptions, type RawBranchInfo, type RawCommitInfo, type RawFileDiff, type RawFilteredFile, type RawWebhookPushEvent, type ReadableStreamLike, type ReadableStreamReaderLike, type RefUpdate, RefUpdateError, type RefUpdateReason, type Repo, type RestoreCommitOptions, type RestoreCommitResult, type StorageOptions, type SupportedRepoProvider, type TextEncoding, type ValidAPIVersion, type ValidMethod, type ValidPath, type WebhookEventPayload, type WebhookPushEvent, type WebhookUnknownEvent, type WebhookValidationOptions, type WebhookValidationResult, createClient, parseSignatureHeader, validateWebhook, validateWebhookSignature };
|
|
895
|
+
export { ApiError, type BaseRepo, type BlobLike, type BranchInfo, type CommitBuilder, type CommitFileOptions, type CommitFileSource, type CommitInfo, type CommitResult, type CommitSignature, type CommitTextFileOptions, type CreateBranchOptions, type CreateBranchResponse, type CreateBranchResult, type CreateCommitBranchOptions, type CreateCommitFromDiffOptions, type CreateCommitOptions, type CreateRepoOptions, type DiffFileBase, type DiffFileState, type DiffSource, type DiffStats, type FileDiff, type FileLike, type FilteredFile, type FindOneOptions, type GetBranchDiffOptions, type GetBranchDiffResponse, type GetBranchDiffResult, type GetCommitDiffOptions, type GetCommitDiffResponse, type GetCommitDiffResult, type GetFileOptions, type GetRemoteURLOptions, type GitFileMode, GitStorage, type GitStorageOptions, type LegacyCreateCommitOptions, type ListBranchesOptions, type ListBranchesResponse, type ListBranchesResult, type ListCommitsOptions, type ListCommitsResponse, type ListCommitsResult, type ListFilesOptions, type ListFilesResponse, type ListFilesResult, type OverrideableGitStorageOptions, type ParsedWebhookSignature, type PullUpstreamOptions, type RawBranchInfo, type RawCommitInfo, type RawFileDiff, type RawFilteredFile, type RawWebhookPushEvent, type ReadableStreamLike, type ReadableStreamReaderLike, type RefUpdate, RefUpdateError, type RefUpdateReason, type Repo, type RestoreCommitOptions, type RestoreCommitResult, type StorageOptions, type SupportedRepoProvider, type TextEncoding, type ValidAPIVersion, type ValidMethod, type ValidPath, type WebhookEventPayload, type WebhookPushEvent, type WebhookUnknownEvent, type WebhookValidationOptions, type WebhookValidationResult, createClient, parseSignatureHeader, validateWebhook, validateWebhookSignature };
|
package/dist/index.js
CHANGED
|
@@ -104,6 +104,12 @@ var commitDiffResponseSchema = z.object({
|
|
|
104
104
|
files: z.array(diffFileRawSchema),
|
|
105
105
|
filtered_files: z.array(filteredFileRawSchema)
|
|
106
106
|
});
|
|
107
|
+
var createBranchResponseSchema = z.object({
|
|
108
|
+
message: z.string(),
|
|
109
|
+
target_branch: z.string(),
|
|
110
|
+
target_is_ephemeral: z.boolean(),
|
|
111
|
+
commit_sha: z.string().nullable().optional()
|
|
112
|
+
});
|
|
107
113
|
var refUpdateResultSchema = z.object({
|
|
108
114
|
branch: z.string(),
|
|
109
115
|
old_sha: z.string(),
|
|
@@ -1485,6 +1491,14 @@ function transformCommitDiffResult(raw) {
|
|
|
1485
1491
|
filteredFiles: raw.filtered_files.map(transformFilteredFile)
|
|
1486
1492
|
};
|
|
1487
1493
|
}
|
|
1494
|
+
function transformCreateBranchResult(raw) {
|
|
1495
|
+
return {
|
|
1496
|
+
message: raw.message,
|
|
1497
|
+
targetBranch: raw.target_branch,
|
|
1498
|
+
targetIsEphemeral: raw.target_is_ephemeral,
|
|
1499
|
+
commitSha: raw.commit_sha ?? void 0
|
|
1500
|
+
};
|
|
1501
|
+
}
|
|
1488
1502
|
var RepoImpl = class {
|
|
1489
1503
|
constructor(id, options, generateJWT) {
|
|
1490
1504
|
this.id = id;
|
|
@@ -1503,6 +1517,13 @@ var RepoImpl = class {
|
|
|
1503
1517
|
url.password = await this.generateJWT(this.id, urlOptions);
|
|
1504
1518
|
return url.toString();
|
|
1505
1519
|
}
|
|
1520
|
+
async getEphemeralRemoteURL(urlOptions) {
|
|
1521
|
+
const storageBaseUrl = this.options.storageBaseUrl ?? STORAGE_BASE_URL;
|
|
1522
|
+
const url = new URL(`https://${this.options.name}.${storageBaseUrl}/${this.id}+ephemeral.git`);
|
|
1523
|
+
url.username = `t`;
|
|
1524
|
+
url.password = await this.generateJWT(this.id, urlOptions);
|
|
1525
|
+
return url.toString();
|
|
1526
|
+
}
|
|
1506
1527
|
async getFileStream(options) {
|
|
1507
1528
|
const ttl = resolveInvocationTtlSeconds(options, DEFAULT_TOKEN_TTL_SECONDS);
|
|
1508
1529
|
const jwt = await this.generateJWT(this.id, {
|
|
@@ -1620,7 +1641,7 @@ var RepoImpl = class {
|
|
|
1620
1641
|
const raw = commitDiffResponseSchema.parse(await response.json());
|
|
1621
1642
|
return transformCommitDiffResult(raw);
|
|
1622
1643
|
}
|
|
1623
|
-
async pullUpstream(options) {
|
|
1644
|
+
async pullUpstream(options = {}) {
|
|
1624
1645
|
const ttl = resolveInvocationTtlSeconds(options, DEFAULT_TOKEN_TTL_SECONDS);
|
|
1625
1646
|
const jwt = await this.generateJWT(this.id, {
|
|
1626
1647
|
permissions: ["git:write"],
|
|
@@ -1636,6 +1657,34 @@ var RepoImpl = class {
|
|
|
1636
1657
|
}
|
|
1637
1658
|
return;
|
|
1638
1659
|
}
|
|
1660
|
+
async createBranch(options) {
|
|
1661
|
+
const baseBranch = options?.baseBranch?.trim();
|
|
1662
|
+
if (!baseBranch) {
|
|
1663
|
+
throw new Error("createBranch baseBranch is required");
|
|
1664
|
+
}
|
|
1665
|
+
const targetBranch = options?.targetBranch?.trim();
|
|
1666
|
+
if (!targetBranch) {
|
|
1667
|
+
throw new Error("createBranch targetBranch is required");
|
|
1668
|
+
}
|
|
1669
|
+
const ttl = resolveInvocationTtlSeconds(options, DEFAULT_TOKEN_TTL_SECONDS);
|
|
1670
|
+
const jwt = await this.generateJWT(this.id, {
|
|
1671
|
+
permissions: ["git:write"],
|
|
1672
|
+
ttl
|
|
1673
|
+
});
|
|
1674
|
+
const body = {
|
|
1675
|
+
base_branch: baseBranch,
|
|
1676
|
+
target_branch: targetBranch
|
|
1677
|
+
};
|
|
1678
|
+
if (options.baseIsEphemeral === true) {
|
|
1679
|
+
body.base_is_ephemeral = true;
|
|
1680
|
+
}
|
|
1681
|
+
if (options.targetIsEphemeral === true) {
|
|
1682
|
+
body.target_is_ephemeral = true;
|
|
1683
|
+
}
|
|
1684
|
+
const response = await this.api.post({ path: "repos/branches/create", body }, jwt);
|
|
1685
|
+
const raw = createBranchResponseSchema.parse(await response.json());
|
|
1686
|
+
return transformCreateBranchResult(raw);
|
|
1687
|
+
}
|
|
1639
1688
|
async restoreCommit(options) {
|
|
1640
1689
|
const targetBranch = options?.targetBranch?.trim();
|
|
1641
1690
|
if (!targetBranch) {
|