astro-loader-pocketbase 2.8.2-next.2 → 2.8.2-next.3
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 +3 -1
- package/package.json +5 -5
- package/src/utils/get-superuser-token.ts +17 -0
package/README.md
CHANGED
|
@@ -172,7 +172,9 @@ const blog = defineCollection({
|
|
|
172
172
|
});
|
|
173
173
|
```
|
|
174
174
|
|
|
175
|
-
|
|
175
|
+
> [!TIP]
|
|
176
|
+
> It's recommended to use an [impersonate token (API token)](https://pocketbase.io/docs/authentication/#api-keys) instead of the email and password, as this is more secure and can be easily revoked.
|
|
177
|
+
> This also prevents the loader from hitting some rate limits with PocketBase, since the default is 2 authentication requests per 3 second interval.
|
|
176
178
|
|
|
177
179
|
Under the hood, the loader will use the [PocketBase API](https://pocketbase.io/docs/api-collections/#view-collection) to fetch the schema of your collection and generate types with Zod based on that schema.
|
|
178
180
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro-loader-pocketbase",
|
|
3
|
-
"version": "2.8.2-next.
|
|
3
|
+
"version": "2.8.2-next.3",
|
|
4
4
|
"description": "A content loader for Astro that uses the PocketBase API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"astro",
|
|
@@ -45,13 +45,13 @@
|
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@commitlint/cli": "20.1.0",
|
|
47
47
|
"@commitlint/config-conventional": "20.0.0",
|
|
48
|
-
"@types/node": "24.
|
|
48
|
+
"@types/node": "24.9.1",
|
|
49
49
|
"@vitest/coverage-v8": "3.2.4",
|
|
50
|
-
"astro": "5.14.
|
|
50
|
+
"astro": "5.14.8",
|
|
51
51
|
"globals": "16.4.0",
|
|
52
52
|
"husky": "9.1.7",
|
|
53
|
-
"lint-staged": "16.2.
|
|
54
|
-
"oxlint": "1.
|
|
53
|
+
"lint-staged": "16.2.5",
|
|
54
|
+
"oxlint": "1.24.0",
|
|
55
55
|
"prettier": "3.6.2",
|
|
56
56
|
"prettier-plugin-organize-imports": "4.3.0",
|
|
57
57
|
"prettier-plugin-packagejson": "2.5.19",
|
|
@@ -35,6 +35,23 @@ export async function getSuperuserToken(
|
|
|
35
35
|
|
|
36
36
|
// If the login request was not successful, print the error message and return undefined
|
|
37
37
|
if (!loginRequest.ok) {
|
|
38
|
+
if (loginRequest.status === 429) {
|
|
39
|
+
const info =
|
|
40
|
+
"A rate limit was hit while trying to authenticate with PocketBase. Consider using an `impersonateToken` as credentials to avoid this issue.";
|
|
41
|
+
if (logger) {
|
|
42
|
+
logger.info(info);
|
|
43
|
+
} else {
|
|
44
|
+
console.info(info);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Random wait between 3 (default rate limit interval) and 8 seconds
|
|
48
|
+
const retryAfter = Math.random() * 5 + 3;
|
|
49
|
+
// oxlint-disable-next-line promise/avoid-new
|
|
50
|
+
await new Promise((resolve) => setTimeout(resolve, retryAfter * 1000));
|
|
51
|
+
|
|
52
|
+
return getSuperuserToken(url, superuserCredentials, logger);
|
|
53
|
+
}
|
|
54
|
+
|
|
38
55
|
const reason = await loginRequest.json().then((data) => data.message);
|
|
39
56
|
const errorMessage = `The given email / password for ${url} was not correct. Astro can't generate type definitions automatically and may not have access to all resources.\nReason: ${reason}`;
|
|
40
57
|
if (logger) {
|