@pierre/storage 0.2.1 → 0.2.2

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.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
@@ -437,8 +454,9 @@ interface Repo {
437
454
  listCommits(options?: ListCommitsOptions): Promise<ListCommitsResult>;
438
455
  getBranchDiff(options: GetBranchDiffOptions): Promise<GetBranchDiffResult>;
439
456
  getCommitDiff(options: GetCommitDiffOptions): Promise<GetCommitDiffResult>;
440
- pullUpstream(options: PullUpstreamOptions): Promise<void>;
457
+ pullUpstream(options?: PullUpstreamOptions): Promise<void>;
441
458
  restoreCommit(options: RestoreCommitOptions): Promise<RestoreCommitResult>;
459
+ createBranch(options: CreateBranchOptions): Promise<CreateBranchResult>;
442
460
  createCommit(options: CreateCommitOptions): CommitBuilder;
443
461
  createCommitFromDiff(options: CreateCommitFromDiffOptions): Promise<CommitResult>;
444
462
  }
@@ -505,6 +523,19 @@ interface ListBranchesResult {
505
523
  nextCursor?: string;
506
524
  hasMore: boolean;
507
525
  }
526
+ interface CreateBranchOptions extends GitStorageInvocationOptions {
527
+ baseBranch: string;
528
+ targetBranch: string;
529
+ baseIsEphemeral?: boolean;
530
+ targetIsEphemeral?: boolean;
531
+ }
532
+ type CreateBranchResponse = CreateBranchResponseRaw;
533
+ interface CreateBranchResult {
534
+ message: string;
535
+ targetBranch: string;
536
+ targetIsEphemeral: boolean;
537
+ commitSha?: string;
538
+ }
508
539
  interface ListCommitsOptions extends GitStorageInvocationOptions {
509
540
  branch?: string;
510
541
  cursor?: string;
@@ -860,4 +891,4 @@ declare class GitStorage {
860
891
  declare function createClient(options: GitStorageOptions): GitStorage;
861
892
  type StorageOptions = GitStorageOptions;
862
893
 
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 };
894
+ 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
@@ -437,8 +454,9 @@ interface Repo {
437
454
  listCommits(options?: ListCommitsOptions): Promise<ListCommitsResult>;
438
455
  getBranchDiff(options: GetBranchDiffOptions): Promise<GetBranchDiffResult>;
439
456
  getCommitDiff(options: GetCommitDiffOptions): Promise<GetCommitDiffResult>;
440
- pullUpstream(options: PullUpstreamOptions): Promise<void>;
457
+ pullUpstream(options?: PullUpstreamOptions): Promise<void>;
441
458
  restoreCommit(options: RestoreCommitOptions): Promise<RestoreCommitResult>;
459
+ createBranch(options: CreateBranchOptions): Promise<CreateBranchResult>;
442
460
  createCommit(options: CreateCommitOptions): CommitBuilder;
443
461
  createCommitFromDiff(options: CreateCommitFromDiffOptions): Promise<CommitResult>;
444
462
  }
@@ -505,6 +523,19 @@ interface ListBranchesResult {
505
523
  nextCursor?: string;
506
524
  hasMore: boolean;
507
525
  }
526
+ interface CreateBranchOptions extends GitStorageInvocationOptions {
527
+ baseBranch: string;
528
+ targetBranch: string;
529
+ baseIsEphemeral?: boolean;
530
+ targetIsEphemeral?: boolean;
531
+ }
532
+ type CreateBranchResponse = CreateBranchResponseRaw;
533
+ interface CreateBranchResult {
534
+ message: string;
535
+ targetBranch: string;
536
+ targetIsEphemeral: boolean;
537
+ commitSha?: string;
538
+ }
508
539
  interface ListCommitsOptions extends GitStorageInvocationOptions {
509
540
  branch?: string;
510
541
  cursor?: string;
@@ -860,4 +891,4 @@ declare class GitStorage {
860
891
  declare function createClient(options: GitStorageOptions): GitStorage;
861
892
  type StorageOptions = GitStorageOptions;
862
893
 
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 };
894
+ 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;
@@ -1620,7 +1634,7 @@ var RepoImpl = class {
1620
1634
  const raw = commitDiffResponseSchema.parse(await response.json());
1621
1635
  return transformCommitDiffResult(raw);
1622
1636
  }
1623
- async pullUpstream(options) {
1637
+ async pullUpstream(options = {}) {
1624
1638
  const ttl = resolveInvocationTtlSeconds(options, DEFAULT_TOKEN_TTL_SECONDS);
1625
1639
  const jwt = await this.generateJWT(this.id, {
1626
1640
  permissions: ["git:write"],
@@ -1636,6 +1650,34 @@ var RepoImpl = class {
1636
1650
  }
1637
1651
  return;
1638
1652
  }
1653
+ async createBranch(options) {
1654
+ const baseBranch = options?.baseBranch?.trim();
1655
+ if (!baseBranch) {
1656
+ throw new Error("createBranch baseBranch is required");
1657
+ }
1658
+ const targetBranch = options?.targetBranch?.trim();
1659
+ if (!targetBranch) {
1660
+ throw new Error("createBranch targetBranch is required");
1661
+ }
1662
+ const ttl = resolveInvocationTtlSeconds(options, DEFAULT_TOKEN_TTL_SECONDS);
1663
+ const jwt = await this.generateJWT(this.id, {
1664
+ permissions: ["git:write"],
1665
+ ttl
1666
+ });
1667
+ const body = {
1668
+ base_branch: baseBranch,
1669
+ target_branch: targetBranch
1670
+ };
1671
+ if (options.baseIsEphemeral === true) {
1672
+ body.base_is_ephemeral = true;
1673
+ }
1674
+ if (options.targetIsEphemeral === true) {
1675
+ body.target_is_ephemeral = true;
1676
+ }
1677
+ const response = await this.api.post({ path: "repos/branches/create", body }, jwt);
1678
+ const raw = createBranchResponseSchema.parse(await response.json());
1679
+ return transformCreateBranchResult(raw);
1680
+ }
1639
1681
  async restoreCommit(options) {
1640
1682
  const targetBranch = options?.targetBranch?.trim();
1641
1683
  if (!targetBranch) {