@spooky-sync/client-solid 0.0.1-canary.19 → 0.0.1-canary.21
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/package.json +1 -1
- package/skills/spooky-solid/SKILL.md +48 -1
package/package.json
CHANGED
|
@@ -200,11 +200,58 @@ const { url, isLoading } = useDownloadFile('avatars', () => user()?.avatarPath);
|
|
|
200
200
|
|
|
201
201
|
## Backend Runs
|
|
202
202
|
|
|
203
|
+
Use `db.run()` to trigger server-side operations via the outbox pattern. See the `spooky-core` skill for full details on `db.run()` and how it works.
|
|
204
|
+
|
|
205
|
+
### Basic Usage
|
|
206
|
+
|
|
207
|
+
```tsx
|
|
208
|
+
const db = useDb();
|
|
209
|
+
await db.run('api', '/spookify', { id: threadId });
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Entity Linking with `assignedTo`
|
|
213
|
+
|
|
214
|
+
Pass `assignedTo` to link the job to an entity. This enables permission scoping and lets you query job status via relationships:
|
|
215
|
+
|
|
203
216
|
```tsx
|
|
204
217
|
const db = useDb();
|
|
205
|
-
|
|
218
|
+
|
|
219
|
+
// Trigger backend run linked to a thread
|
|
220
|
+
await db.run('api', '/spookify', { id: threadData.id }, {
|
|
221
|
+
assignedTo: threadData.id, // Links the job record to this thread
|
|
222
|
+
});
|
|
206
223
|
```
|
|
207
224
|
|
|
225
|
+
### Tracking Job Status Reactively
|
|
226
|
+
|
|
227
|
+
Use `.related()` to include jobs in your query, then reactively track their status:
|
|
228
|
+
|
|
229
|
+
```tsx
|
|
230
|
+
// Query a thread with its latest spookify job
|
|
231
|
+
const threadResult = useQuery(() =>
|
|
232
|
+
db.query('thread')
|
|
233
|
+
.where({ id: `thread:${threadId}` })
|
|
234
|
+
.related('jobs', (q) =>
|
|
235
|
+
q.where({ path: '/spookify' }).orderBy('created_at', 'desc').limit(1)
|
|
236
|
+
)
|
|
237
|
+
.one()
|
|
238
|
+
.build()
|
|
239
|
+
);
|
|
240
|
+
|
|
241
|
+
const thread = () => threadResult.data();
|
|
242
|
+
|
|
243
|
+
// Check if a job is in progress
|
|
244
|
+
const isJobLoading = () =>
|
|
245
|
+
['pending', 'processing'].includes(thread()?.jobs?.[0]?.status ?? '');
|
|
246
|
+
|
|
247
|
+
// Use in UI
|
|
248
|
+
<Show when={isJobLoading()}>
|
|
249
|
+
<span>Processing...</span>
|
|
250
|
+
</Show>
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
The job's `status` field transitions through: `pending` → `processing` → `success` | `failed`. Since the job record syncs reactively, your UI updates automatically as the backend processes the job.
|
|
254
|
+
|
|
208
255
|
## Key Re-exports
|
|
209
256
|
|
|
210
257
|
The package re-exports commonly needed types:
|