@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/dist/index.cjs +25 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.js +25 -1
- package/dist/index.js.map +1 -1
- package/package.json +38 -39
- package/src/index.ts +30 -0
- package/src/types.ts +9 -0
package/package.json
CHANGED
|
@@ -1,40 +1,39 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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;
|