@pierre/storage 0.3.0 → 0.4.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,40 +1,39 @@
1
1
  {
2
- "name": "@pierre/storage",
3
- "version": "0.3.0",
4
- "description": "Pierre Git Storage SDK",
5
- "license": "MIT",
6
- "type": "module",
7
- "main": "./dist/index.cjs",
8
- "module": "./dist/index.js",
9
- "types": "./dist/index.d.ts",
10
- "exports": {
11
- ".": {
12
- "types": "./dist/index.d.ts",
13
- "import": "./dist/index.js",
14
- "require": "./dist/index.cjs",
15
- "default": "./dist/index.js"
16
- }
17
- },
18
- "files": [
19
- "dist",
20
- "src"
21
- ],
22
- "scripts": {
23
- "build": "tsup",
24
- "dev": "tsup --watch",
25
- "prepublishOnly": "pnpm build"
26
- },
27
- "dependencies": {
28
- "jose": "^5.10.0",
29
- "snakecase-keys": "^9.0.2",
30
- "zod": "^3.23.8"
31
- },
32
- "devDependencies": {
33
- "tsup": "8.5.0",
34
- "typescript": "5.8.3",
35
- "vitest": "3.2.4"
36
- },
37
- "publishConfig": {
38
- "access": "public"
39
- }
40
- }
2
+ "name": "@pierre/storage",
3
+ "version": "0.4.0",
4
+ "description": "Pierre Git Storage SDK",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/index.cjs",
8
+ "module": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js",
14
+ "require": "./dist/index.cjs",
15
+ "default": "./dist/index.js"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "src"
21
+ ],
22
+ "dependencies": {
23
+ "jose": "^5.10.0",
24
+ "snakecase-keys": "^9.0.2",
25
+ "zod": "^3.23.8"
26
+ },
27
+ "devDependencies": {
28
+ "tsup": "8.5.0",
29
+ "typescript": "5.8.3",
30
+ "vitest": "3.2.4"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "scripts": {
36
+ "build": "tsup",
37
+ "dev": "tsup --watch"
38
+ }
39
+ }
package/src/index.ts CHANGED
@@ -32,6 +32,8 @@ import type {
32
32
  CreateCommitFromDiffOptions,
33
33
  CreateCommitOptions,
34
34
  CreateRepoOptions,
35
+ DeleteRepoOptions,
36
+ DeleteRepoResult,
35
37
  DiffFileState,
36
38
  FileDiff,
37
39
  FilteredFile,
@@ -820,6 +822,34 @@ export class GitStorage {
820
822
  return new RepoImpl(options.id, this.options, this.generateJWT.bind(this));
821
823
  }
822
824
 
825
+ /**
826
+ * Delete a repository by ID
827
+ * @param options The delete options containing the repo ID
828
+ * @returns The deletion result
829
+ */
830
+ async deleteRepo(options: DeleteRepoOptions): Promise<DeleteRepoResult> {
831
+ const ttl = resolveInvocationTtlSeconds(options, DEFAULT_TOKEN_TTL_SECONDS);
832
+ const jwt = await this.generateJWT(options.id, {
833
+ permissions: ['repo:write'],
834
+ ttl,
835
+ });
836
+
837
+ // Allow 404 and 409 for clearer error handling
838
+ const resp = await this.api.delete('repos/delete', jwt, { allowedStatus: [404, 409] });
839
+ if (resp.status === 404) {
840
+ throw new Error('Repository not found');
841
+ }
842
+ if (resp.status === 409) {
843
+ throw new Error('Repository already deleted');
844
+ }
845
+
846
+ const body = (await resp.json()) as { repo_id: string; message: string };
847
+ return {
848
+ repoId: body.repo_id,
849
+ message: body.message,
850
+ };
851
+ }
852
+
823
853
  /**
824
854
  * Get the current configuration
825
855
  * @returns The client configuration
package/src/types.ts CHANGED
@@ -88,6 +88,15 @@ export interface CreateRepoOptions extends GitStorageInvocationOptions {
88
88
  defaultBranch?: string;
89
89
  }
90
90
 
91
+ export interface DeleteRepoOptions extends GitStorageInvocationOptions {
92
+ id: string;
93
+ }
94
+
95
+ export interface DeleteRepoResult {
96
+ repoId: string;
97
+ message: string;
98
+ }
99
+
91
100
  // Get File API types
92
101
  export interface GetFileOptions extends GitStorageInvocationOptions {
93
102
  path: string;