astro-integration-pocketbase 2.0.0 → 2.1.0-next.1

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 CHANGED
@@ -60,7 +60,9 @@ pocketbaseIntegration({
60
60
  // Superuser credentials for restricted collections (optional)
61
61
  superuserCredentials: {
62
62
  email: "<superuser-email>",
63
- password: "<superuser-password>"
63
+ password: "<superuser-password>",
64
+ // or
65
+ impersonateToken: "<superuser-impersonate-token>"
64
66
  }
65
67
  });
66
68
  ```
@@ -131,8 +133,8 @@ The integration will automatically detect PocketBase entries in the props and di
131
133
 
132
134
  ## All options
133
135
 
134
- | Option | Type | Required | Description |
135
- | ---------------------- | -------------------------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------- |
136
- | `url` | `string` | x | The URL of your PocketBase instance. |
137
- | `collectionsToWatch` | `Array<string> \| Record<string, true \| Array<string>>` | | Collections to watch for changes. |
138
- | `superuserCredentials` | `{ email: string, password: string }` | | The email and password of a superuser of the PocketBase instance. This is used for realtime updates of restricted collection. |
136
+ | Option | Type | Required | Description |
137
+ | ---------------------- | --------------------------------------------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
138
+ | `url` | `string` | x | The URL of your PocketBase instance. |
139
+ | `collectionsToWatch` | `Array<string> \| Record<string, true \| Array<string>>` | | Collections to watch for changes. |
140
+ | `superuserCredentials` | `{ email: string, password: string } \| { impersonateToken: string }` | | The email and password or impersonate token of a superuser of the PocketBase instance. This is used for realtime updates of restricted collection. |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro-integration-pocketbase",
3
- "version": "2.0.0",
3
+ "version": "2.1.0-next.1",
4
4
  "description": "An Astro integration to support developers working with astro-loader-pocketbase.",
5
5
  "keywords": [
6
6
  "astro",
@@ -96,11 +96,15 @@ export function refreshCollectionsRealtime(
96
96
  // Get the superuser token if credentials are available
97
97
  let superuserToken: string | undefined;
98
98
  if (superuserCredentials) {
99
- superuserToken = await getSuperuserToken(
100
- url,
101
- superuserCredentials,
102
- logger
103
- );
99
+ if ("impersonateToken" in superuserCredentials) {
100
+ superuserToken = superuserCredentials.impersonateToken;
101
+ } else {
102
+ superuserToken = await getSuperuserToken(
103
+ url,
104
+ superuserCredentials,
105
+ logger
106
+ );
107
+ }
104
108
  }
105
109
 
106
110
  // Subscribe to the PocketBase realtime API
@@ -10,16 +10,24 @@ export interface PocketBaseIntegrationOptions {
10
10
  * Credentials of a superuser to get full access to the PocketBase instance.
11
11
  * This is required to access all resources even if they are not public.
12
12
  */
13
- superuserCredentials?: {
14
- /**
15
- * Email of the superuser.
16
- */
17
- email: string;
18
- /**
19
- * Password of the superuser.
20
- */
21
- password: string;
22
- };
13
+ superuserCredentials?:
14
+ | {
15
+ /**
16
+ * Email of the superuser.
17
+ */
18
+ email: string;
19
+ /**
20
+ * Password of the superuser.
21
+ */
22
+ password: string;
23
+ }
24
+ | {
25
+ /**
26
+ * Impersonate auth token of the superuser.
27
+ * This token will take precedence over the email and password.
28
+ */
29
+ impersonateToken: string;
30
+ };
23
31
  /**
24
32
  * List of PocketBase collections to watch for changes.
25
33
  * When an entry in one of these collections changes, the content will be reloaded.