@pierre/storage 1.0.3 → 1.1.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/README.md +23 -0
- package/dist/index.cjs +21 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +21 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +29 -10
- package/src/types.ts +6 -0
package/dist/index.d.cts
CHANGED
|
@@ -689,6 +689,11 @@ interface GitStorageInvocationOptions {
|
|
|
689
689
|
interface FindOneOptions {
|
|
690
690
|
id: string;
|
|
691
691
|
}
|
|
692
|
+
interface RepoOptions {
|
|
693
|
+
id: string;
|
|
694
|
+
defaultBranch?: string;
|
|
695
|
+
createdAt?: string;
|
|
696
|
+
}
|
|
692
697
|
type SupportedRepoProvider = 'github';
|
|
693
698
|
interface PublicGitHubBaseRepoAuth {
|
|
694
699
|
/**
|
|
@@ -1241,6 +1246,10 @@ declare class GitStorage {
|
|
|
1241
1246
|
* @returns The found repository
|
|
1242
1247
|
*/
|
|
1243
1248
|
findOne(options: FindOneOptions): Promise<Repo | null>;
|
|
1249
|
+
/**
|
|
1250
|
+
* Create a Repo handle from known metadata without making an HTTP request.
|
|
1251
|
+
*/
|
|
1252
|
+
repo(options: RepoOptions): Repo;
|
|
1244
1253
|
/**
|
|
1245
1254
|
* Delete a repository by ID
|
|
1246
1255
|
* @param options The delete options containing the repo ID
|
|
@@ -1262,4 +1271,4 @@ declare function createClient(options: GitStorageOptions): GitStorage;
|
|
|
1262
1271
|
|
|
1263
1272
|
type StorageOptions = GitStorageOptions;
|
|
1264
1273
|
|
|
1265
|
-
export { ApiError, type AppendNoteOptions, type ArchiveOptions, type BaseRepo, type BlobLike, type BranchInfo, GitStorage as CodeStorage, 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 CreateNoteOptions, type CreateRepoOptions, type DeleteNoteOptions, type DeleteRepoOptions, type DeleteRepoResult, type DiffFileBase, type DiffFileState, type DiffSource, type DiffStats, type FileDiff, type FileLike, 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 ListReposOptions, type ListReposResponse, type ListReposResult, type NoteWriteResponse, type NoteWriteResult, type NoteWriteResultPayload, type OverrideableGitStorageOptions, type ParsedWebhookSignature, type PublicGitHubBaseRepoAuth, type PullUpstreamOptions, type RawBranchInfo, type RawCommitInfo, type RawFileDiff, type RawFilteredFile, type RawRepoBaseInfo, type RawRepoInfo, type RawWebhookPushEvent, type ReadableStreamLike, type ReadableStreamReaderLike, type RefUpdate, RefUpdateError, type RefUpdateReason, type Repo, type RepoBaseInfo, type RepoInfo, 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 };
|
|
1274
|
+
export { ApiError, type AppendNoteOptions, type ArchiveOptions, type BaseRepo, type BlobLike, type BranchInfo, GitStorage as CodeStorage, 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 CreateNoteOptions, type CreateRepoOptions, type DeleteNoteOptions, type DeleteRepoOptions, type DeleteRepoResult, type DiffFileBase, type DiffFileState, type DiffSource, type DiffStats, type FileDiff, type FileLike, 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 ListReposOptions, type ListReposResponse, type ListReposResult, type NoteWriteResponse, type NoteWriteResult, type NoteWriteResultPayload, type OverrideableGitStorageOptions, type ParsedWebhookSignature, type PublicGitHubBaseRepoAuth, type PullUpstreamOptions, type RawBranchInfo, type RawCommitInfo, type RawFileDiff, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -689,6 +689,11 @@ interface GitStorageInvocationOptions {
|
|
|
689
689
|
interface FindOneOptions {
|
|
690
690
|
id: string;
|
|
691
691
|
}
|
|
692
|
+
interface RepoOptions {
|
|
693
|
+
id: string;
|
|
694
|
+
defaultBranch?: string;
|
|
695
|
+
createdAt?: string;
|
|
696
|
+
}
|
|
692
697
|
type SupportedRepoProvider = 'github';
|
|
693
698
|
interface PublicGitHubBaseRepoAuth {
|
|
694
699
|
/**
|
|
@@ -1241,6 +1246,10 @@ declare class GitStorage {
|
|
|
1241
1246
|
* @returns The found repository
|
|
1242
1247
|
*/
|
|
1243
1248
|
findOne(options: FindOneOptions): Promise<Repo | null>;
|
|
1249
|
+
/**
|
|
1250
|
+
* Create a Repo handle from known metadata without making an HTTP request.
|
|
1251
|
+
*/
|
|
1252
|
+
repo(options: RepoOptions): Repo;
|
|
1244
1253
|
/**
|
|
1245
1254
|
* Delete a repository by ID
|
|
1246
1255
|
* @param options The delete options containing the repo ID
|
|
@@ -1262,4 +1271,4 @@ declare function createClient(options: GitStorageOptions): GitStorage;
|
|
|
1262
1271
|
|
|
1263
1272
|
type StorageOptions = GitStorageOptions;
|
|
1264
1273
|
|
|
1265
|
-
export { ApiError, type AppendNoteOptions, type ArchiveOptions, type BaseRepo, type BlobLike, type BranchInfo, GitStorage as CodeStorage, 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 CreateNoteOptions, type CreateRepoOptions, type DeleteNoteOptions, type DeleteRepoOptions, type DeleteRepoResult, type DiffFileBase, type DiffFileState, type DiffSource, type DiffStats, type FileDiff, type FileLike, 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 ListReposOptions, type ListReposResponse, type ListReposResult, type NoteWriteResponse, type NoteWriteResult, type NoteWriteResultPayload, type OverrideableGitStorageOptions, type ParsedWebhookSignature, type PublicGitHubBaseRepoAuth, type PullUpstreamOptions, type RawBranchInfo, type RawCommitInfo, type RawFileDiff, type RawFilteredFile, type RawRepoBaseInfo, type RawRepoInfo, type RawWebhookPushEvent, type ReadableStreamLike, type ReadableStreamReaderLike, type RefUpdate, RefUpdateError, type RefUpdateReason, type Repo, type RepoBaseInfo, type RepoInfo, 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 };
|
|
1274
|
+
export { ApiError, type AppendNoteOptions, type ArchiveOptions, type BaseRepo, type BlobLike, type BranchInfo, GitStorage as CodeStorage, 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 CreateNoteOptions, type CreateRepoOptions, type DeleteNoteOptions, type DeleteRepoOptions, type DeleteRepoResult, type DiffFileBase, type DiffFileState, type DiffSource, type DiffStats, type FileDiff, type FileLike, 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 ListReposOptions, type ListReposResponse, type ListReposResult, type NoteWriteResponse, type NoteWriteResult, type NoteWriteResultPayload, type OverrideableGitStorageOptions, type ParsedWebhookSignature, type PublicGitHubBaseRepoAuth, type PullUpstreamOptions, type RawBranchInfo, type RawCommitInfo, type RawFileDiff, 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 };
|
package/dist/index.js
CHANGED
|
@@ -508,7 +508,7 @@ function concatChunks(a, b) {
|
|
|
508
508
|
|
|
509
509
|
// package.json
|
|
510
510
|
var package_default = {
|
|
511
|
-
version: "1.0
|
|
511
|
+
version: "1.1.0"};
|
|
512
512
|
|
|
513
513
|
// src/version.ts
|
|
514
514
|
var PACKAGE_NAME = "code-storage-sdk";
|
|
@@ -2412,13 +2412,11 @@ var GitStorage = class _GitStorage {
|
|
|
2412
2412
|
if (resp.status === 409) {
|
|
2413
2413
|
throw new Error("Repository already exists");
|
|
2414
2414
|
}
|
|
2415
|
-
return
|
|
2416
|
-
repoId,
|
|
2417
|
-
resolvedDefaultBranch ?? "main",
|
|
2418
|
-
(/* @__PURE__ */ new Date()).toISOString()
|
|
2419
|
-
|
|
2420
|
-
this.generateJWT.bind(this)
|
|
2421
|
-
);
|
|
2415
|
+
return this.repo({
|
|
2416
|
+
id: repoId,
|
|
2417
|
+
defaultBranch: resolvedDefaultBranch ?? "main",
|
|
2418
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
2419
|
+
});
|
|
2422
2420
|
}
|
|
2423
2421
|
/**
|
|
2424
2422
|
* List repositories for the authenticated organization
|
|
@@ -2464,10 +2462,23 @@ var GitStorage = class _GitStorage {
|
|
|
2464
2462
|
const body = await resp.json();
|
|
2465
2463
|
const defaultBranch = body.default_branch ?? "main";
|
|
2466
2464
|
const createdAt = body.created_at ?? "";
|
|
2465
|
+
return this.repo({
|
|
2466
|
+
id: options.id,
|
|
2467
|
+
defaultBranch,
|
|
2468
|
+
createdAt
|
|
2469
|
+
});
|
|
2470
|
+
}
|
|
2471
|
+
/**
|
|
2472
|
+
* Create a Repo handle from known metadata without making an HTTP request.
|
|
2473
|
+
*/
|
|
2474
|
+
repo(options) {
|
|
2475
|
+
if (!options || typeof options.id !== "string" || options.id.trim() === "") {
|
|
2476
|
+
throw new Error("repo requires a non-empty repository id.");
|
|
2477
|
+
}
|
|
2467
2478
|
return new RepoImpl(
|
|
2468
2479
|
options.id,
|
|
2469
|
-
defaultBranch,
|
|
2470
|
-
createdAt,
|
|
2480
|
+
options.defaultBranch ?? "main",
|
|
2481
|
+
options.createdAt ?? "",
|
|
2471
2482
|
this.options,
|
|
2472
2483
|
this.generateJWT.bind(this)
|
|
2473
2484
|
);
|