@pierre/storage 1.0.2 → 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 +35 -0
- package/dist/index.cjs +21 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +21 -10
- package/dist/index.js.map +1 -1
- package/package.json +40 -39
- package/src/index.ts +29 -10
- package/src/types.ts +14 -0
package/package.json
CHANGED
|
@@ -1,40 +1,41 @@
|
|
|
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": "1.1.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
|
+
"@types/node": "^22.0.0",
|
|
34
|
+
"tsup": "8.5.0",
|
|
35
|
+
"typescript": "5.8.3",
|
|
36
|
+
"vitest": "3.2.4"
|
|
37
|
+
},
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
}
|
|
41
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -84,6 +84,7 @@ import type {
|
|
|
84
84
|
RawFileDiff,
|
|
85
85
|
RawFilteredFile,
|
|
86
86
|
RefUpdate,
|
|
87
|
+
RepoOptions,
|
|
87
88
|
Repo,
|
|
88
89
|
RestoreCommitOptions,
|
|
89
90
|
RestoreCommitResult,
|
|
@@ -1393,13 +1394,11 @@ export class GitStorage {
|
|
|
1393
1394
|
throw new Error('Repository already exists');
|
|
1394
1395
|
}
|
|
1395
1396
|
|
|
1396
|
-
return
|
|
1397
|
-
repoId,
|
|
1398
|
-
resolvedDefaultBranch ?? 'main',
|
|
1399
|
-
new Date().toISOString(),
|
|
1400
|
-
|
|
1401
|
-
this.generateJWT.bind(this)
|
|
1402
|
-
);
|
|
1397
|
+
return this.repo({
|
|
1398
|
+
id: repoId,
|
|
1399
|
+
defaultBranch: resolvedDefaultBranch ?? 'main',
|
|
1400
|
+
createdAt: new Date().toISOString(),
|
|
1401
|
+
});
|
|
1403
1402
|
}
|
|
1404
1403
|
|
|
1405
1404
|
/**
|
|
@@ -1448,13 +1447,33 @@ export class GitStorage {
|
|
|
1448
1447
|
if (resp.status === 404) {
|
|
1449
1448
|
return null;
|
|
1450
1449
|
}
|
|
1451
|
-
|
|
1450
|
+
|
|
1451
|
+
const body = (await resp.json()) as {
|
|
1452
|
+
default_branch?: string;
|
|
1453
|
+
created_at?: string;
|
|
1454
|
+
};
|
|
1452
1455
|
const defaultBranch = body.default_branch ?? 'main';
|
|
1453
1456
|
const createdAt = body.created_at ?? '';
|
|
1454
|
-
|
|
1455
|
-
|
|
1457
|
+
|
|
1458
|
+
return this.repo({
|
|
1459
|
+
id: options.id,
|
|
1456
1460
|
defaultBranch,
|
|
1457
1461
|
createdAt,
|
|
1462
|
+
});
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1465
|
+
/**
|
|
1466
|
+
* Create a Repo handle from known metadata without making an HTTP request.
|
|
1467
|
+
*/
|
|
1468
|
+
repo(options: RepoOptions): Repo {
|
|
1469
|
+
if (!options || typeof options.id !== 'string' || options.id.trim() === '') {
|
|
1470
|
+
throw new Error('repo requires a non-empty repository id.');
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
return new RepoImpl(
|
|
1474
|
+
options.id,
|
|
1475
|
+
options.defaultBranch ?? 'main',
|
|
1476
|
+
options.createdAt ?? '',
|
|
1458
1477
|
this.options,
|
|
1459
1478
|
this.generateJWT.bind(this)
|
|
1460
1479
|
);
|
package/src/types.ts
CHANGED
|
@@ -84,8 +84,21 @@ export interface FindOneOptions {
|
|
|
84
84
|
id: string;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
export interface RepoOptions {
|
|
88
|
+
id: string;
|
|
89
|
+
defaultBranch?: string;
|
|
90
|
+
createdAt?: string;
|
|
91
|
+
}
|
|
92
|
+
|
|
87
93
|
export type SupportedRepoProvider = 'github';
|
|
88
94
|
|
|
95
|
+
export interface PublicGitHubBaseRepoAuth {
|
|
96
|
+
/**
|
|
97
|
+
* Force public GitHub mode (no GitHub App installation required).
|
|
98
|
+
*/
|
|
99
|
+
authType: 'public';
|
|
100
|
+
}
|
|
101
|
+
|
|
89
102
|
export interface GitHubBaseRepo {
|
|
90
103
|
/**
|
|
91
104
|
* @default github
|
|
@@ -94,6 +107,7 @@ export interface GitHubBaseRepo {
|
|
|
94
107
|
owner: string;
|
|
95
108
|
name: string;
|
|
96
109
|
defaultBranch?: string;
|
|
110
|
+
auth?: PublicGitHubBaseRepoAuth;
|
|
97
111
|
}
|
|
98
112
|
|
|
99
113
|
export interface ForkBaseRepo {
|