@pierre/storage 0.4.2 → 0.5.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.4.2",
3
+ "version": "0.5.0",
4
4
  "description": "Pierre Git Storage SDK",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/fetch.ts CHANGED
@@ -45,7 +45,17 @@ export class ApiFetcher {
45
45
  if (typeof path === 'string') {
46
46
  return `${this.getBaseUrl()}/${path}`;
47
47
  } else if (path.params) {
48
- const paramStr = new URLSearchParams(path.params).toString();
48
+ const searchParams = new URLSearchParams();
49
+ for (const [key, value] of Object.entries(path.params)) {
50
+ if (Array.isArray(value)) {
51
+ for (const v of value) {
52
+ searchParams.append(key, v);
53
+ }
54
+ } else {
55
+ searchParams.append(key, value);
56
+ }
57
+ }
58
+ const paramStr = searchParams.toString();
49
59
  return `${this.getBaseUrl()}/${path.path}${paramStr ? `?${paramStr}` : ''}`;
50
60
  } else {
51
61
  return `${this.getBaseUrl()}/${path.path}`;
package/src/index.ts CHANGED
@@ -506,7 +506,7 @@ class RepoImpl implements Repo {
506
506
  ttl,
507
507
  });
508
508
 
509
- const params: Record<string, string> = {
509
+ const params: Record<string, string | string[]> = {
510
510
  branch: options.branch,
511
511
  };
512
512
 
@@ -519,6 +519,9 @@ class RepoImpl implements Repo {
519
519
  if (typeof options.ephemeralBase === 'boolean') {
520
520
  params.ephemeral_base = String(options.ephemeralBase);
521
521
  }
522
+ if (options.paths && options.paths.length > 0) {
523
+ params.path = options.paths;
524
+ }
522
525
 
523
526
  const response = await this.api.get({ path: 'repos/branches/diff', params }, jwt);
524
527
 
@@ -533,13 +536,16 @@ class RepoImpl implements Repo {
533
536
  ttl,
534
537
  });
535
538
 
536
- const params: Record<string, string> = {
539
+ const params: Record<string, string | string[]> = {
537
540
  sha: options.sha,
538
541
  };
539
542
 
540
543
  if (options.baseSha) {
541
544
  params.baseSha = options.baseSha;
542
545
  }
546
+ if (options.paths && options.paths.length > 0) {
547
+ params.path = options.paths;
548
+ }
543
549
 
544
550
  const response = await this.api.get({ path: 'repos/diff', params }, jwt);
545
551
 
package/src/types.ts CHANGED
@@ -58,7 +58,7 @@ export type ValidMethod = 'GET' | 'POST' | 'PUT' | 'DELETE';
58
58
  type SimplePath = string;
59
59
  type ComplexPath = {
60
60
  path: string;
61
- params?: Record<string, string>;
61
+ params?: Record<string, string | string[]>;
62
62
  body?: Record<string, any>;
63
63
  };
64
64
  export type ValidPath = SimplePath | ComplexPath;
@@ -197,6 +197,8 @@ export interface GetBranchDiffOptions extends GitStorageInvocationOptions {
197
197
  base?: string;
198
198
  ephemeral?: boolean;
199
199
  ephemeralBase?: boolean;
200
+ /** Optional paths to filter the diff to specific files */
201
+ paths?: string[];
200
202
  }
201
203
 
202
204
  export type GetBranchDiffResponse = GetBranchDiffResponseRaw;
@@ -213,6 +215,8 @@ export interface GetBranchDiffResult {
213
215
  export interface GetCommitDiffOptions extends GitStorageInvocationOptions {
214
216
  sha: string;
215
217
  baseSha?: string;
218
+ /** Optional paths to filter the diff to specific files */
219
+ paths?: string[];
216
220
  }
217
221
 
218
222
  export type GetCommitDiffResponse = GetCommitDiffResponseRaw;