astro-integration-pocketbase 1.2.0-next.1 → 1.2.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 +30 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
This package provides an Astro toolbar for users of [astro-loader-pocketbase](https://github.com/pawcoding/astro-loader-pocketbase) to view PocketBase data directly in the Astro dev server.
|
|
10
10
|
|
|
11
|
-

|
|
11
|
+

|
|
12
12
|
|
|
13
13
|
## Compatibility
|
|
14
14
|
|
|
@@ -43,6 +43,8 @@ If a loader is found, the viewer will show a refresh button to reload all entrie
|
|
|
43
43
|
|
|
44
44
|
## Realtime updates
|
|
45
45
|
|
|
46
|
+
### Basic setup
|
|
47
|
+
|
|
46
48
|
PocketBase allows you to subscribe to collection changes via its [Realtime API](https://pocketbase.io/docs/api-realtime/).
|
|
47
49
|
This integration allows you to subscribe to these changes and reload the entries / collections.
|
|
48
50
|
Note that Node.js currently does not support the [EventSource](https://developer.mozilla.org/en-US/docs/Web/API/EventSource) API, so the integration uses the [eventsource](https://www.npmjs.com/package/eventsource) package to provide the same functionality.
|
|
@@ -64,6 +66,28 @@ pocketbaseIntegration({
|
|
|
64
66
|
|
|
65
67
|
**Tip:** You can disable the realtime updates temporarily via the toolbar.
|
|
66
68
|
|
|
69
|
+
### Advanced setup
|
|
70
|
+
|
|
71
|
+
If you work with view collections, you need some more advanced options to get the realtime updates working as expected.
|
|
72
|
+
Since [view collections don't receive realtime events](https://pocketbase.io/docs/collections/#view-collection), you need to watch the source base collection instead, by providing one or more collections to watch.
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
pocketbaseIntegration({
|
|
76
|
+
...options,
|
|
77
|
+
collectionsToWatch: {
|
|
78
|
+
// Same effect as basic setup watching the same collection
|
|
79
|
+
// Recommended for basic / auth collections
|
|
80
|
+
users: true,
|
|
81
|
+
// Watch the source collection(s) of a view collection
|
|
82
|
+
// Recommended for view collections
|
|
83
|
+
postings: ["posts", "comments"]
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
When using `true`, the integration will subscribe and reload the entries of the same collection mentioned in the key.
|
|
89
|
+
When using an array of other collections, the integration will subscribe to changes of collections given in the array and reload the entries of the collection mentioned in the key.
|
|
90
|
+
|
|
67
91
|
## Entity viewer
|
|
68
92
|
|
|
69
93
|
To view the PocketBase entries inside the entity viewer, you need to use `Astro.props` to pass the entries to your page (and thus to the toolbar).
|
|
@@ -106,8 +130,8 @@ The integration will automatically detect PocketBase entries in the props and di
|
|
|
106
130
|
|
|
107
131
|
## All options
|
|
108
132
|
|
|
109
|
-
| Option | Type
|
|
110
|
-
| ---------------------- |
|
|
111
|
-
| `url` | `string`
|
|
112
|
-
| `collectionsToWatch` | `Array<string
|
|
113
|
-
| `superuserCredentials` | `{ email: string, password: string }`
|
|
133
|
+
| Option | Type | Required | Description |
|
|
134
|
+
| ---------------------- | -------------------------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------- |
|
|
135
|
+
| `url` | `string` | x | The URL of your PocketBase instance. |
|
|
136
|
+
| `collectionsToWatch` | `Array<string> \| Record<string, true \| Array<string>>` | | Collections to watch for changes. |
|
|
137
|
+
| `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. |
|
package/package.json
CHANGED