@vibes.diy/prompts 4.0.2 → 4.0.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.
Files changed (2) hide show
  1. package/llms/fireproof.md +16 -0
  2. package/package.json +4 -4
package/llms/fireproof.md CHANGED
@@ -367,6 +367,22 @@ Each capability (`read`, `write`, `delete`) is independent. Omitting one falls b
367
367
 
368
368
  Other `acl` variants: `useFireproof("drafts", { acl: { read: ["editors"], write: ["editors"], delete: ["editors"] } })` for editors-only space, or omit `acl` entirely to fall back to app-level role gates (existing behavior, always safe).
369
369
 
370
+ ## Anonymous local writes (`anonymousLocal`)
371
+
372
+ For "let a logged-out visitor try it and save a little state before signing in," pass `{ anonymousLocal: true }`. While logged out, `put`/`del`/`useLiveQuery`/`useDocument` run against a local (localStorage) store with the identical API — no auth branching in your code. On first sign-in the local docs migrate into the cloud database, then local storage clears.
373
+
374
+ ```js
375
+ const { useLiveQuery, database } = useFireproof("favorites", {
376
+ anonymousLocal: true,
377
+ // Optional: reshape/stamp each local doc for its new owner; return falsy to drop it.
378
+ // Preserve `_id` (spread `...doc`) — migration retries are only idempotent when
379
+ // the id is kept, otherwise a retry after a partial failure creates duplicates.
380
+ migrate: (doc, userHandle) => ({ ...doc, owner: userHandle }),
381
+ });
382
+ ```
383
+
384
+ Notes: use it only where anonymous-first state makes sense (favorites, drafts, a scratch list). A returning signed-out visitor is automatically steered to sign in rather than starting a fresh throwaway local session. Migration keeps local data intact if it fails, so nothing is lost.
385
+
370
386
  ## Reading Resolved Grants (`access`)
371
387
 
372
388
  `useFireproof()` returns an `access` property — the viewer's resolved roles and channels for that database, computed server-side from the access function's `members` and `grant` declarations. Use `access.roles` (ReadonlySet), `access.channels` (ReadonlySet), `access.hasRole(name)`, and `access.hasChannel(name)`. Use these to reflect roles/channels in the UI; gate writes with `useVibe(dbName).can`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibes.diy/prompts",
3
- "version": "4.0.2",
3
+ "version": "4.0.3",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "description": "",
@@ -24,9 +24,9 @@
24
24
  "license": "Apache-2.0",
25
25
  "dependencies": {
26
26
  "@adviser/cement": "~0.5.34",
27
- "@vibes.diy/call-ai-v2": "^4.0.2",
28
- "@vibes.diy/identity": "^4.0.2",
29
- "@vibes.diy/use-vibes-types": "^4.0.2",
27
+ "@vibes.diy/call-ai-v2": "^4.0.3",
28
+ "@vibes.diy/identity": "^4.0.3",
29
+ "@vibes.diy/use-vibes-types": "^4.0.3",
30
30
  "arktype": "~2.2.1",
31
31
  "json-schema-faker": "~0.6.2"
32
32
  },