@pierre/storage 0.5.0 → 0.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pierre/storage",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "Pierre Git Storage SDK",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/index.ts CHANGED
@@ -363,6 +363,7 @@ class RepoImpl implements Repo {
363
363
 
364
364
  constructor(
365
365
  public readonly id: string,
366
+ public readonly defaultBranch: string,
366
367
  private readonly options: GitStorageOptions,
367
368
  private readonly generateJWT: (
368
369
  repoId: string,
@@ -892,8 +893,8 @@ export class GitStorage {
892
893
  }
893
894
  : null;
894
895
 
895
- // Default defaultBranch to 'main' if not provided
896
- const defaultBranch = options?.defaultBranch ?? 'main';
896
+ // Match backend priority: baseRepo.defaultBranch > options.defaultBranch > 'main'
897
+ const defaultBranch = options?.baseRepo?.defaultBranch ?? options?.defaultBranch ?? 'main';
897
898
 
898
899
  const createRepoPath =
899
900
  baseRepoOptions || defaultBranch
@@ -912,7 +913,7 @@ export class GitStorage {
912
913
  throw new Error('Repository already exists');
913
914
  }
914
915
 
915
- return new RepoImpl(repoId, this.options, this.generateJWT.bind(this));
916
+ return new RepoImpl(repoId, defaultBranch, this.options, this.generateJWT.bind(this));
916
917
  }
917
918
 
918
919
  /**
@@ -931,9 +932,9 @@ export class GitStorage {
931
932
  if (resp.status === 404) {
932
933
  return null;
933
934
  }
934
- // On 200, we could validate response, but RepoImpl only needs the repo URL/id
935
- // const body = await resp.json(); // not required for now
936
- return new RepoImpl(options.id, this.options, this.generateJWT.bind(this));
935
+ const body = (await resp.json()) as { default_branch?: string };
936
+ const defaultBranch = body.default_branch ?? 'main';
937
+ return new RepoImpl(options.id, defaultBranch, this.options, this.generateJWT.bind(this));
937
938
  }
938
939
 
939
940
  /**
package/src/types.ts CHANGED
@@ -37,6 +37,7 @@ export interface GetRemoteURLOptions {
37
37
 
38
38
  export interface Repo {
39
39
  id: string;
40
+ defaultBranch: string;
40
41
  getRemoteURL(options?: GetRemoteURLOptions): Promise<string>;
41
42
  getEphemeralRemoteURL(options?: GetRemoteURLOptions): Promise<string>;
42
43