@pierre/storage 1.2.1 → 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/README.md +18 -1
- package/dist/index.cjs +92 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +52 -4
- package/dist/index.d.ts +52 -4
- package/dist/index.js +92 -4
- package/dist/index.js.map +1 -1
- package/package.json +43 -43
- package/src/index.ts +113 -3
- package/src/types.ts +50 -3
package/dist/index.d.cts
CHANGED
|
@@ -747,6 +747,7 @@ interface Repo {
|
|
|
747
747
|
createdAt: string;
|
|
748
748
|
getRemoteURL(options?: GetRemoteURLOptions): Promise<string>;
|
|
749
749
|
getEphemeralRemoteURL(options?: GetRemoteURLOptions): Promise<string>;
|
|
750
|
+
getImportRemoteURL(options?: GetRemoteURLOptions): Promise<string>;
|
|
750
751
|
getFileStream(options: GetFileOptions): Promise<Response>;
|
|
751
752
|
getArchiveStream(options?: ArchiveOptions): Promise<Response>;
|
|
752
753
|
listFiles(options?: ListFilesOptions): Promise<ListFilesResult>;
|
|
@@ -785,7 +786,7 @@ interface RepoOptions {
|
|
|
785
786
|
defaultBranch?: string;
|
|
786
787
|
createdAt?: string;
|
|
787
788
|
}
|
|
788
|
-
type SupportedRepoProvider = 'github';
|
|
789
|
+
type SupportedRepoProvider = 'github' | 'gitlab' | 'bitbucket' | 'gitea' | 'forgejo' | 'codeberg' | 'sr.ht';
|
|
789
790
|
interface PublicGitHubBaseRepoAuth {
|
|
790
791
|
/**
|
|
791
792
|
* Force public GitHub mode (no GitHub App installation required).
|
|
@@ -796,18 +797,52 @@ interface GitHubBaseRepo {
|
|
|
796
797
|
/**
|
|
797
798
|
* @default github
|
|
798
799
|
*/
|
|
799
|
-
provider?:
|
|
800
|
+
provider?: 'github';
|
|
800
801
|
owner: string;
|
|
801
802
|
name: string;
|
|
802
803
|
defaultBranch?: string;
|
|
803
804
|
auth?: PublicGitHubBaseRepoAuth;
|
|
804
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
|
+
}
|
|
805
820
|
interface ForkBaseRepo {
|
|
806
821
|
id: string;
|
|
807
822
|
ref?: string;
|
|
808
823
|
sha?: string;
|
|
809
824
|
}
|
|
810
|
-
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
|
+
}
|
|
811
846
|
interface ListReposOptions extends GitStorageInvocationOptions {
|
|
812
847
|
cursor?: string;
|
|
813
848
|
limit?: number;
|
|
@@ -1372,6 +1407,19 @@ declare class GitStorage {
|
|
|
1372
1407
|
* @returns The deletion result
|
|
1373
1408
|
*/
|
|
1374
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>;
|
|
1375
1423
|
/**
|
|
1376
1424
|
* Get the current configuration
|
|
1377
1425
|
* @returns The client configuration
|
|
@@ -1387,4 +1435,4 @@ declare function createClient(options: GitStorageOptions): GitStorage;
|
|
|
1387
1435
|
|
|
1388
1436
|
type StorageOptions = GitStorageOptions;
|
|
1389
1437
|
|
|
1390
|
-
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
|
@@ -747,6 +747,7 @@ interface Repo {
|
|
|
747
747
|
createdAt: string;
|
|
748
748
|
getRemoteURL(options?: GetRemoteURLOptions): Promise<string>;
|
|
749
749
|
getEphemeralRemoteURL(options?: GetRemoteURLOptions): Promise<string>;
|
|
750
|
+
getImportRemoteURL(options?: GetRemoteURLOptions): Promise<string>;
|
|
750
751
|
getFileStream(options: GetFileOptions): Promise<Response>;
|
|
751
752
|
getArchiveStream(options?: ArchiveOptions): Promise<Response>;
|
|
752
753
|
listFiles(options?: ListFilesOptions): Promise<ListFilesResult>;
|
|
@@ -785,7 +786,7 @@ interface RepoOptions {
|
|
|
785
786
|
defaultBranch?: string;
|
|
786
787
|
createdAt?: string;
|
|
787
788
|
}
|
|
788
|
-
type SupportedRepoProvider = 'github';
|
|
789
|
+
type SupportedRepoProvider = 'github' | 'gitlab' | 'bitbucket' | 'gitea' | 'forgejo' | 'codeberg' | 'sr.ht';
|
|
789
790
|
interface PublicGitHubBaseRepoAuth {
|
|
790
791
|
/**
|
|
791
792
|
* Force public GitHub mode (no GitHub App installation required).
|
|
@@ -796,18 +797,52 @@ interface GitHubBaseRepo {
|
|
|
796
797
|
/**
|
|
797
798
|
* @default github
|
|
798
799
|
*/
|
|
799
|
-
provider?:
|
|
800
|
+
provider?: 'github';
|
|
800
801
|
owner: string;
|
|
801
802
|
name: string;
|
|
802
803
|
defaultBranch?: string;
|
|
803
804
|
auth?: PublicGitHubBaseRepoAuth;
|
|
804
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
|
+
}
|
|
805
820
|
interface ForkBaseRepo {
|
|
806
821
|
id: string;
|
|
807
822
|
ref?: string;
|
|
808
823
|
sha?: string;
|
|
809
824
|
}
|
|
810
|
-
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
|
+
}
|
|
811
846
|
interface ListReposOptions extends GitStorageInvocationOptions {
|
|
812
847
|
cursor?: string;
|
|
813
848
|
limit?: number;
|
|
@@ -1372,6 +1407,19 @@ declare class GitStorage {
|
|
|
1372
1407
|
* @returns The deletion result
|
|
1373
1408
|
*/
|
|
1374
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>;
|
|
1375
1423
|
/**
|
|
1376
1424
|
* Get the current configuration
|
|
1377
1425
|
* @returns The client configuration
|
|
@@ -1387,4 +1435,4 @@ declare function createClient(options: GitStorageOptions): GitStorage;
|
|
|
1387
1435
|
|
|
1388
1436
|
type StorageOptions = GitStorageOptions;
|
|
1389
1437
|
|
|
1390
|
-
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
|
|
527
|
+
version: "1.3.2"};
|
|
528
528
|
|
|
529
529
|
// src/version.ts
|
|
530
530
|
var PACKAGE_NAME = "code-storage-sdk";
|
|
@@ -1819,6 +1819,14 @@ var RepoImpl = class {
|
|
|
1819
1819
|
url.password = await this.generateJWT(this.id, urlOptions);
|
|
1820
1820
|
return url.toString();
|
|
1821
1821
|
}
|
|
1822
|
+
async getImportRemoteURL(urlOptions) {
|
|
1823
|
+
const url = new URL(
|
|
1824
|
+
`https://${this.options.storageBaseUrl}/${this.id}+import.git`
|
|
1825
|
+
);
|
|
1826
|
+
url.username = `t`;
|
|
1827
|
+
url.password = await this.generateJWT(this.id, urlOptions);
|
|
1828
|
+
return url.toString();
|
|
1829
|
+
}
|
|
1822
1830
|
async getFileStream(options) {
|
|
1823
1831
|
const ttl = resolveInvocationTtlSeconds(options, DEFAULT_TOKEN_TTL_SECONDS);
|
|
1824
1832
|
const jwt = await this.generateJWT(this.id, {
|
|
@@ -2452,11 +2460,15 @@ var GitStorage = class _GitStorage {
|
|
|
2452
2460
|
...baseRepo.sha ? { sha: baseRepo.sha } : {}
|
|
2453
2461
|
};
|
|
2454
2462
|
} else {
|
|
2463
|
+
const syncRepo = baseRepo;
|
|
2464
|
+
const { provider: _p, ...restSnakecased } = snakecaseKeys(
|
|
2465
|
+
baseRepo
|
|
2466
|
+
);
|
|
2455
2467
|
baseRepoOptions = {
|
|
2456
|
-
provider: "github",
|
|
2457
|
-
...
|
|
2468
|
+
provider: syncRepo.provider ?? "github",
|
|
2469
|
+
...restSnakecased
|
|
2458
2470
|
};
|
|
2459
|
-
resolvedDefaultBranch =
|
|
2471
|
+
resolvedDefaultBranch = syncRepo.defaultBranch;
|
|
2460
2472
|
}
|
|
2461
2473
|
}
|
|
2462
2474
|
if (!resolvedDefaultBranch) {
|
|
@@ -2578,6 +2590,82 @@ var GitStorage = class _GitStorage {
|
|
|
2578
2590
|
message: body.message
|
|
2579
2591
|
};
|
|
2580
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
|
+
}
|
|
2581
2669
|
/**
|
|
2582
2670
|
* Get the current configuration
|
|
2583
2671
|
* @returns The client configuration
|