@pierre/storage 1.2.2 → 1.3.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
@@ -786,7 +786,7 @@ interface RepoOptions {
786
786
  defaultBranch?: string;
787
787
  createdAt?: string;
788
788
  }
789
- type SupportedRepoProvider = 'github';
789
+ type SupportedRepoProvider = 'github' | 'gitlab' | 'bitbucket' | 'gitea' | 'forgejo' | 'codeberg' | 'sr.ht';
790
790
  interface PublicGitHubBaseRepoAuth {
791
791
  /**
792
792
  * Force public GitHub mode (no GitHub App installation required).
@@ -797,18 +797,52 @@ interface GitHubBaseRepo {
797
797
  /**
798
798
  * @default github
799
799
  */
800
- provider?: SupportedRepoProvider;
800
+ provider?: 'github';
801
801
  owner: string;
802
802
  name: string;
803
803
  defaultBranch?: string;
804
804
  auth?: PublicGitHubBaseRepoAuth;
805
805
  }
806
+ interface GenericGitBaseRepo {
807
+ /**
808
+ * The git host provider. Must be one of the supported generic git providers.
809
+ */
810
+ provider: Exclude<SupportedRepoProvider, 'github'>;
811
+ owner: string;
812
+ name: string;
813
+ defaultBranch?: string;
814
+ /**
815
+ * Bare hostname for self-hosted instances (e.g. "gitlab.example.com").
816
+ * Falls back to the provider's default host when omitted.
817
+ */
818
+ upstreamHost?: string;
819
+ }
806
820
  interface ForkBaseRepo {
807
821
  id: string;
808
822
  ref?: string;
809
823
  sha?: string;
810
824
  }
811
- type BaseRepo = GitHubBaseRepo | ForkBaseRepo;
825
+ type BaseRepo = GitHubBaseRepo | ForkBaseRepo | GenericGitBaseRepo;
826
+ interface CreateGitCredentialOptions {
827
+ repoId: string;
828
+ username?: string;
829
+ password: string;
830
+ ttl?: number;
831
+ }
832
+ interface UpdateGitCredentialOptions {
833
+ id: string;
834
+ username?: string;
835
+ password: string;
836
+ ttl?: number;
837
+ }
838
+ interface DeleteGitCredentialOptions {
839
+ id: string;
840
+ ttl?: number;
841
+ }
842
+ interface GitCredential {
843
+ id: string;
844
+ createdAt?: string;
845
+ }
812
846
  interface ListReposOptions extends GitStorageInvocationOptions {
813
847
  cursor?: string;
814
848
  limit?: number;
@@ -1373,6 +1407,19 @@ declare class GitStorage {
1373
1407
  * @returns The deletion result
1374
1408
  */
1375
1409
  deleteRepo(options: DeleteRepoOptions): Promise<DeleteRepoResult>;
1410
+ /**
1411
+ * Create a generic git credential for a repository.
1412
+ * Used to authenticate sync operations for non-GitHub providers (GitLab, Bitbucket, etc.)
1413
+ */
1414
+ createGitCredential(options: CreateGitCredentialOptions): Promise<GitCredential>;
1415
+ /**
1416
+ * Update an existing generic git credential.
1417
+ */
1418
+ updateGitCredential(options: UpdateGitCredentialOptions): Promise<GitCredential>;
1419
+ /**
1420
+ * Delete a generic git credential.
1421
+ */
1422
+ deleteGitCredential(options: DeleteGitCredentialOptions): Promise<void>;
1376
1423
  /**
1377
1424
  * Get the current configuration
1378
1425
  * @returns The client configuration
@@ -1388,4 +1435,4 @@ declare function createClient(options: GitStorageOptions): GitStorage;
1388
1435
 
1389
1436
  type StorageOptions = GitStorageOptions;
1390
1437
 
1391
- export { ApiError, type AppendNoteOptions, type ArchiveOptions, type BaseRepo, type BlobLike, type BranchInfo, GitStorage as CodeStorage, type CommitBuilder, type CommitFileOptions, type CommitFileSource, type CommitInfo, type CommitMetadata, type CommitResult, type CommitSignature, type CommitTextFileOptions, type CreateBranchOptions, type CreateBranchResponse, type CreateBranchResult, type CreateCommitBranchOptions, type CreateCommitFromDiffOptions, type CreateCommitOptions, type CreateNoteOptions, type CreateRepoOptions, type DeleteNoteOptions, type DeleteRepoOptions, type DeleteRepoResult, type DiffFileBase, type DiffFileState, type DiffSource, type DiffStats, type FileDiff, type FileLike, type FileWithMetadata, type FilteredFile, type FindOneOptions, type ForkBaseRepo, type GetBranchDiffOptions, type GetBranchDiffResponse, type GetBranchDiffResult, type GetCommitDiffOptions, type GetCommitDiffResponse, type GetCommitDiffResult, type GetFileOptions, type GetNoteOptions, type GetNoteResponse, type GetNoteResult, type GetRemoteURLOptions, type GitFileMode, type GitHubBaseRepo, GitStorage, type GitStorageOptions, type GrepFileMatch, type GrepLine, type GrepOptions, type GrepResult, type LegacyCreateCommitOptions, type ListBranchesOptions, type ListBranchesResponse, type ListBranchesResult, type ListCommitsOptions, type ListCommitsResponse, type ListCommitsResult, type ListFilesOptions, type ListFilesResponse, type ListFilesResult, type ListFilesWithMetadataOptions, type ListFilesWithMetadataResponse, type ListFilesWithMetadataResult, type ListReposOptions, type ListReposResponse, type ListReposResult, type NoteWriteResponse, type NoteWriteResult, type NoteWriteResultPayload, type OverrideableGitStorageOptions, type ParsedWebhookSignature, type PublicGitHubBaseRepoAuth, type PullUpstreamOptions, type RawBranchInfo, type RawCommitInfo, type RawCommitMetadata, type RawFileDiff, type RawFileWithMetadata, type RawFilteredFile, type RawRepoBaseInfo, type RawRepoInfo, type RawWebhookPushEvent, type ReadableStreamLike, type ReadableStreamReaderLike, type RefUpdate, RefUpdateError, type RefUpdateReason, type Repo, type RepoBaseInfo, type RepoInfo, type RepoOptions, 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 };
1438
+ export { ApiError, type AppendNoteOptions, type ArchiveOptions, type BaseRepo, type BlobLike, type BranchInfo, GitStorage as CodeStorage, type CommitBuilder, type CommitFileOptions, type CommitFileSource, type CommitInfo, type CommitMetadata, type CommitResult, type CommitSignature, type CommitTextFileOptions, type CreateBranchOptions, type CreateBranchResponse, type CreateBranchResult, type CreateCommitBranchOptions, type CreateCommitFromDiffOptions, type CreateCommitOptions, type CreateGitCredentialOptions, type CreateNoteOptions, type CreateRepoOptions, type DeleteGitCredentialOptions, type DeleteNoteOptions, type DeleteRepoOptions, type DeleteRepoResult, type DiffFileBase, type DiffFileState, type DiffSource, type DiffStats, type FileDiff, type FileLike, type FileWithMetadata, type FilteredFile, type FindOneOptions, type ForkBaseRepo, type GenericGitBaseRepo, type GetBranchDiffOptions, type GetBranchDiffResponse, type GetBranchDiffResult, type GetCommitDiffOptions, type GetCommitDiffResponse, type GetCommitDiffResult, type GetFileOptions, type GetNoteOptions, type GetNoteResponse, type GetNoteResult, type GetRemoteURLOptions, type GitCredential, type GitFileMode, type GitHubBaseRepo, GitStorage, type GitStorageOptions, type GrepFileMatch, type GrepLine, type GrepOptions, type GrepResult, type LegacyCreateCommitOptions, type ListBranchesOptions, type ListBranchesResponse, type ListBranchesResult, type ListCommitsOptions, type ListCommitsResponse, type ListCommitsResult, type ListFilesOptions, type ListFilesResponse, type ListFilesResult, type ListFilesWithMetadataOptions, type ListFilesWithMetadataResponse, type ListFilesWithMetadataResult, type ListReposOptions, type ListReposResponse, type ListReposResult, type NoteWriteResponse, type NoteWriteResult, type NoteWriteResultPayload, type OverrideableGitStorageOptions, type ParsedWebhookSignature, type PublicGitHubBaseRepoAuth, type PullUpstreamOptions, type RawBranchInfo, type RawCommitInfo, type RawCommitMetadata, type RawFileDiff, type RawFileWithMetadata, type RawFilteredFile, type RawRepoBaseInfo, type RawRepoInfo, type RawWebhookPushEvent, type ReadableStreamLike, type ReadableStreamReaderLike, type RefUpdate, RefUpdateError, type RefUpdateReason, type Repo, type RepoBaseInfo, type RepoInfo, type RepoOptions, type RestoreCommitOptions, type RestoreCommitResult, type StorageOptions, type SupportedRepoProvider, type TextEncoding, type UpdateGitCredentialOptions, 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
@@ -786,7 +786,7 @@ interface RepoOptions {
786
786
  defaultBranch?: string;
787
787
  createdAt?: string;
788
788
  }
789
- type SupportedRepoProvider = 'github';
789
+ type SupportedRepoProvider = 'github' | 'gitlab' | 'bitbucket' | 'gitea' | 'forgejo' | 'codeberg' | 'sr.ht';
790
790
  interface PublicGitHubBaseRepoAuth {
791
791
  /**
792
792
  * Force public GitHub mode (no GitHub App installation required).
@@ -797,18 +797,52 @@ interface GitHubBaseRepo {
797
797
  /**
798
798
  * @default github
799
799
  */
800
- provider?: SupportedRepoProvider;
800
+ provider?: 'github';
801
801
  owner: string;
802
802
  name: string;
803
803
  defaultBranch?: string;
804
804
  auth?: PublicGitHubBaseRepoAuth;
805
805
  }
806
+ interface GenericGitBaseRepo {
807
+ /**
808
+ * The git host provider. Must be one of the supported generic git providers.
809
+ */
810
+ provider: Exclude<SupportedRepoProvider, 'github'>;
811
+ owner: string;
812
+ name: string;
813
+ defaultBranch?: string;
814
+ /**
815
+ * Bare hostname for self-hosted instances (e.g. "gitlab.example.com").
816
+ * Falls back to the provider's default host when omitted.
817
+ */
818
+ upstreamHost?: string;
819
+ }
806
820
  interface ForkBaseRepo {
807
821
  id: string;
808
822
  ref?: string;
809
823
  sha?: string;
810
824
  }
811
- type BaseRepo = GitHubBaseRepo | ForkBaseRepo;
825
+ type BaseRepo = GitHubBaseRepo | ForkBaseRepo | GenericGitBaseRepo;
826
+ interface CreateGitCredentialOptions {
827
+ repoId: string;
828
+ username?: string;
829
+ password: string;
830
+ ttl?: number;
831
+ }
832
+ interface UpdateGitCredentialOptions {
833
+ id: string;
834
+ username?: string;
835
+ password: string;
836
+ ttl?: number;
837
+ }
838
+ interface DeleteGitCredentialOptions {
839
+ id: string;
840
+ ttl?: number;
841
+ }
842
+ interface GitCredential {
843
+ id: string;
844
+ createdAt?: string;
845
+ }
812
846
  interface ListReposOptions extends GitStorageInvocationOptions {
813
847
  cursor?: string;
814
848
  limit?: number;
@@ -1373,6 +1407,19 @@ declare class GitStorage {
1373
1407
  * @returns The deletion result
1374
1408
  */
1375
1409
  deleteRepo(options: DeleteRepoOptions): Promise<DeleteRepoResult>;
1410
+ /**
1411
+ * Create a generic git credential for a repository.
1412
+ * Used to authenticate sync operations for non-GitHub providers (GitLab, Bitbucket, etc.)
1413
+ */
1414
+ createGitCredential(options: CreateGitCredentialOptions): Promise<GitCredential>;
1415
+ /**
1416
+ * Update an existing generic git credential.
1417
+ */
1418
+ updateGitCredential(options: UpdateGitCredentialOptions): Promise<GitCredential>;
1419
+ /**
1420
+ * Delete a generic git credential.
1421
+ */
1422
+ deleteGitCredential(options: DeleteGitCredentialOptions): Promise<void>;
1376
1423
  /**
1377
1424
  * Get the current configuration
1378
1425
  * @returns The client configuration
@@ -1388,4 +1435,4 @@ declare function createClient(options: GitStorageOptions): GitStorage;
1388
1435
 
1389
1436
  type StorageOptions = GitStorageOptions;
1390
1437
 
1391
- export { ApiError, type AppendNoteOptions, type ArchiveOptions, type BaseRepo, type BlobLike, type BranchInfo, GitStorage as CodeStorage, type CommitBuilder, type CommitFileOptions, type CommitFileSource, type CommitInfo, type CommitMetadata, type CommitResult, type CommitSignature, type CommitTextFileOptions, type CreateBranchOptions, type CreateBranchResponse, type CreateBranchResult, type CreateCommitBranchOptions, type CreateCommitFromDiffOptions, type CreateCommitOptions, type CreateNoteOptions, type CreateRepoOptions, type DeleteNoteOptions, type DeleteRepoOptions, type DeleteRepoResult, type DiffFileBase, type DiffFileState, type DiffSource, type DiffStats, type FileDiff, type FileLike, type FileWithMetadata, type FilteredFile, type FindOneOptions, type ForkBaseRepo, type GetBranchDiffOptions, type GetBranchDiffResponse, type GetBranchDiffResult, type GetCommitDiffOptions, type GetCommitDiffResponse, type GetCommitDiffResult, type GetFileOptions, type GetNoteOptions, type GetNoteResponse, type GetNoteResult, type GetRemoteURLOptions, type GitFileMode, type GitHubBaseRepo, GitStorage, type GitStorageOptions, type GrepFileMatch, type GrepLine, type GrepOptions, type GrepResult, type LegacyCreateCommitOptions, type ListBranchesOptions, type ListBranchesResponse, type ListBranchesResult, type ListCommitsOptions, type ListCommitsResponse, type ListCommitsResult, type ListFilesOptions, type ListFilesResponse, type ListFilesResult, type ListFilesWithMetadataOptions, type ListFilesWithMetadataResponse, type ListFilesWithMetadataResult, type ListReposOptions, type ListReposResponse, type ListReposResult, type NoteWriteResponse, type NoteWriteResult, type NoteWriteResultPayload, type OverrideableGitStorageOptions, type ParsedWebhookSignature, type PublicGitHubBaseRepoAuth, type PullUpstreamOptions, type RawBranchInfo, type RawCommitInfo, type RawCommitMetadata, type RawFileDiff, type RawFileWithMetadata, type RawFilteredFile, type RawRepoBaseInfo, type RawRepoInfo, type RawWebhookPushEvent, type ReadableStreamLike, type ReadableStreamReaderLike, type RefUpdate, RefUpdateError, type RefUpdateReason, type Repo, type RepoBaseInfo, type RepoInfo, type RepoOptions, 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 };
1438
+ export { ApiError, type AppendNoteOptions, type ArchiveOptions, type BaseRepo, type BlobLike, type BranchInfo, GitStorage as CodeStorage, type CommitBuilder, type CommitFileOptions, type CommitFileSource, type CommitInfo, type CommitMetadata, type CommitResult, type CommitSignature, type CommitTextFileOptions, type CreateBranchOptions, type CreateBranchResponse, type CreateBranchResult, type CreateCommitBranchOptions, type CreateCommitFromDiffOptions, type CreateCommitOptions, type CreateGitCredentialOptions, type CreateNoteOptions, type CreateRepoOptions, type DeleteGitCredentialOptions, type DeleteNoteOptions, type DeleteRepoOptions, type DeleteRepoResult, type DiffFileBase, type DiffFileState, type DiffSource, type DiffStats, type FileDiff, type FileLike, type FileWithMetadata, type FilteredFile, type FindOneOptions, type ForkBaseRepo, type GenericGitBaseRepo, type GetBranchDiffOptions, type GetBranchDiffResponse, type GetBranchDiffResult, type GetCommitDiffOptions, type GetCommitDiffResponse, type GetCommitDiffResult, type GetFileOptions, type GetNoteOptions, type GetNoteResponse, type GetNoteResult, type GetRemoteURLOptions, type GitCredential, type GitFileMode, type GitHubBaseRepo, GitStorage, type GitStorageOptions, type GrepFileMatch, type GrepLine, type GrepOptions, type GrepResult, type LegacyCreateCommitOptions, type ListBranchesOptions, type ListBranchesResponse, type ListBranchesResult, type ListCommitsOptions, type ListCommitsResponse, type ListCommitsResult, type ListFilesOptions, type ListFilesResponse, type ListFilesResult, type ListFilesWithMetadataOptions, type ListFilesWithMetadataResponse, type ListFilesWithMetadataResult, type ListReposOptions, type ListReposResponse, type ListReposResult, type NoteWriteResponse, type NoteWriteResult, type NoteWriteResultPayload, type OverrideableGitStorageOptions, type ParsedWebhookSignature, type PublicGitHubBaseRepoAuth, type PullUpstreamOptions, type RawBranchInfo, type RawCommitInfo, type RawCommitMetadata, type RawFileDiff, type RawFileWithMetadata, type RawFilteredFile, type RawRepoBaseInfo, type RawRepoInfo, type RawWebhookPushEvent, type ReadableStreamLike, type ReadableStreamReaderLike, type RefUpdate, RefUpdateError, type RefUpdateReason, type Repo, type RepoBaseInfo, type RepoInfo, type RepoOptions, type RestoreCommitOptions, type RestoreCommitResult, type StorageOptions, type SupportedRepoProvider, type TextEncoding, type UpdateGitCredentialOptions, 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
@@ -524,7 +524,7 @@ function concatChunks(a, b) {
524
524
 
525
525
  // package.json
526
526
  var package_default = {
527
- version: "1.2.2"};
527
+ version: "1.3.2"};
528
528
 
529
529
  // src/version.ts
530
530
  var PACKAGE_NAME = "code-storage-sdk";
@@ -2460,11 +2460,15 @@ var GitStorage = class _GitStorage {
2460
2460
  ...baseRepo.sha ? { sha: baseRepo.sha } : {}
2461
2461
  };
2462
2462
  } else {
2463
+ const syncRepo = baseRepo;
2464
+ const { provider: _p, ...restSnakecased } = snakecaseKeys(
2465
+ baseRepo
2466
+ );
2463
2467
  baseRepoOptions = {
2464
- provider: "github",
2465
- ...snakecaseKeys(baseRepo)
2468
+ provider: syncRepo.provider ?? "github",
2469
+ ...restSnakecased
2466
2470
  };
2467
- resolvedDefaultBranch = baseRepo.defaultBranch;
2471
+ resolvedDefaultBranch = syncRepo.defaultBranch;
2468
2472
  }
2469
2473
  }
2470
2474
  if (!resolvedDefaultBranch) {
@@ -2586,6 +2590,82 @@ var GitStorage = class _GitStorage {
2586
2590
  message: body.message
2587
2591
  };
2588
2592
  }
2593
+ /**
2594
+ * Create a generic git credential for a repository.
2595
+ * Used to authenticate sync operations for non-GitHub providers (GitLab, Bitbucket, etc.)
2596
+ */
2597
+ async createGitCredential(options) {
2598
+ const ttl = resolveInvocationTtlSeconds(options, DEFAULT_TOKEN_TTL_SECONDS);
2599
+ const jwt = await this.generateJWT(options.repoId, {
2600
+ permissions: ["repo:write"],
2601
+ ttl
2602
+ });
2603
+ const body = {
2604
+ repo_id: options.repoId,
2605
+ password: options.password
2606
+ };
2607
+ if (options.username !== void 0) {
2608
+ body.username = options.username;
2609
+ }
2610
+ const resp = await this.api.post(
2611
+ { path: "repos/git-credentials", body },
2612
+ jwt,
2613
+ { allowedStatus: [409] }
2614
+ );
2615
+ if (resp.status === 409) {
2616
+ throw new Error("A credential already exists for this repository");
2617
+ }
2618
+ const data = await resp.json();
2619
+ return { id: data.id };
2620
+ }
2621
+ /**
2622
+ * Update an existing generic git credential.
2623
+ */
2624
+ async updateGitCredential(options) {
2625
+ const ttl = resolveInvocationTtlSeconds(options, DEFAULT_TOKEN_TTL_SECONDS);
2626
+ const jwt = await this.generateJWT("org", {
2627
+ permissions: ["repo:write"],
2628
+ ttl
2629
+ });
2630
+ const body = {
2631
+ id: options.id,
2632
+ password: options.password
2633
+ };
2634
+ if (options.username !== void 0) {
2635
+ body.username = options.username;
2636
+ }
2637
+ const resp = await this.api.put(
2638
+ { path: "repos/git-credentials", body },
2639
+ jwt,
2640
+ { allowedStatus: [404] }
2641
+ );
2642
+ if (resp.status === 404) {
2643
+ throw new Error("Credential not found");
2644
+ }
2645
+ const data = await resp.json();
2646
+ return {
2647
+ id: data.id,
2648
+ ...data.created_at ? { createdAt: data.created_at } : {}
2649
+ };
2650
+ }
2651
+ /**
2652
+ * Delete a generic git credential.
2653
+ */
2654
+ async deleteGitCredential(options) {
2655
+ const ttl = resolveInvocationTtlSeconds(options, DEFAULT_TOKEN_TTL_SECONDS);
2656
+ const jwt = await this.generateJWT("org", {
2657
+ permissions: ["repo:write"],
2658
+ ttl
2659
+ });
2660
+ const resp = await this.api.delete(
2661
+ { path: "repos/git-credentials", body: { id: options.id } },
2662
+ jwt,
2663
+ { allowedStatus: [404] }
2664
+ );
2665
+ if (resp.status === 404) {
2666
+ throw new Error("Credential not found");
2667
+ }
2668
+ }
2589
2669
  /**
2590
2670
  * Get the current configuration
2591
2671
  * @returns The client configuration