@proveanything/smartlinks 1.8.5 → 1.8.6
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/dist/api/appConfiguration.d.ts +22 -5
- package/dist/api/appConfiguration.js +21 -4
- package/dist/docs/API_SUMMARY.md +250 -257
- package/dist/docs/app-data-storage.md +56 -10
- package/dist/docs/overview.md +3 -0
- package/docs/API_SUMMARY.md +250 -257
- package/docs/app-data-storage.md +56 -10
- package/docs/overview.md +3 -0
- package/package.json +1 -1
package/docs/app-data-storage.md
CHANGED
|
@@ -2,6 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
The SmartLinks platform provides two distinct types of data storage for apps:
|
|
4
4
|
|
|
5
|
+
## Choose the Right Model First
|
|
6
|
+
|
|
7
|
+
There are now two different families of flexible app data in SmartLinks, and they solve different problems:
|
|
8
|
+
|
|
9
|
+
| Need | Best Fit | Why |
|
|
10
|
+
|------|----------|-----|
|
|
11
|
+
| One settings blob per scope | `appConfiguration.getConfig` / `setConfig` | Simple app setup and feature flags |
|
|
12
|
+
| A few keyed scoped documents by ID | `appConfiguration.getData` / `setDataItem` | Lightweight, direct, minimal overhead |
|
|
13
|
+
| Rich app-owned entities with filtering, visibility, ownership, or lifecycle | `app.records` | Better default for real domain objects |
|
|
14
|
+
| Workflow items that move through resolution | `app.cases` | Status, priority, assignment, history |
|
|
15
|
+
| Discussions, comments, reply chains | `app.threads` | Built around replies and conversation flow |
|
|
16
|
+
|
|
17
|
+
### Rule of Thumb
|
|
18
|
+
|
|
19
|
+
- Use `appConfiguration` when the thing you are storing is basically config or a small keyed document.
|
|
20
|
+
- Use `app.records` when the thing you are storing is a real object in your app.
|
|
21
|
+
- Use `app.cases` when the object represents work to resolve.
|
|
22
|
+
- Use `app.threads` when the object is conversational.
|
|
23
|
+
|
|
24
|
+
This matters for AI-generated apps too: if the documentation only mentions `setDataItem`, builders will overuse it. In most non-trivial app flows, `app.records` is usually the stronger default.
|
|
25
|
+
|
|
5
26
|
## 1. User-Specific Data (Global per User+App)
|
|
6
27
|
|
|
7
28
|
**Use the `userAppData` namespace for all user-specific data.**
|
|
@@ -77,16 +98,19 @@ await userAppData.remove('garden-planner', 'bed-1');
|
|
|
77
98
|
|
|
78
99
|
## 2. Collection/Product-Scoped Data (Admin Configuration)
|
|
79
100
|
|
|
80
|
-
**Use the `appConfiguration` namespace for collection/product-scoped
|
|
101
|
+
**Use the `appConfiguration` namespace for collection/product-scoped config and simple keyed documents.**
|
|
81
102
|
|
|
82
103
|
This data is scoped to specific collections, products, variants, or batches. It's typically configured by collection admins/owners and applies to all users viewing that collection/product.
|
|
83
104
|
|
|
105
|
+
If you need richer app-owned entities with querying, lifecycle, access zones, parent-child relationships, or workflow semantics, use [app-objects.md](app-objects.md) instead of forcing everything through `setDataItem`.
|
|
106
|
+
|
|
84
107
|
### Use Cases
|
|
85
108
|
- App-specific settings for a collection
|
|
86
109
|
- Product-level configuration
|
|
87
110
|
- Feature flags and toggles
|
|
88
111
|
- Theme and branding settings
|
|
89
112
|
- Public content that all users see
|
|
113
|
+
- Small keyed content entries such as FAQs, menu items, or quick lookup documents
|
|
90
114
|
|
|
91
115
|
### API Endpoints
|
|
92
116
|
```
|
|
@@ -146,15 +170,37 @@ await appConfiguration.setDataItem({
|
|
|
146
170
|
|
|
147
171
|
## Comparison Table
|
|
148
172
|
|
|
149
|
-
| Feature | User Data |
|
|
150
|
-
|
|
151
|
-
| **Namespace** | `userAppData` | `appConfiguration` |
|
|
152
|
-
| **Scope** | User + App (global) | Collection/Product/Variant/Batch |
|
|
153
|
-
| **
|
|
154
|
-
| **Shared across collections?** | ✅ Yes | ❌ No |
|
|
155
|
-
| **Requires auth?** | ✅ Yes (user token) | ✅ Yes (admin token for write) |
|
|
156
|
-
| **
|
|
157
|
-
| **
|
|
173
|
+
| Feature | User Data | Scoped Config/Data | App Objects |
|
|
174
|
+
|---------|-----------|--------------------|-------------|
|
|
175
|
+
| **Namespace** | `userAppData` | `appConfiguration` | `app.records` / `app.cases` / `app.threads` |
|
|
176
|
+
| **Scope** | User + App (global) | Collection/Product/Variant/Batch | Collection + App |
|
|
177
|
+
| **Best for** | Personal preferences and user-owned items | Config blobs and small keyed documents | Rich entities and workflows |
|
|
178
|
+
| **Shared across collections?** | ✅ Yes | ❌ No | ❌ No |
|
|
179
|
+
| **Requires auth?** | ✅ Yes (user token) | ✅ Yes (admin token for write) | Depends on public/admin endpoint and visibility |
|
|
180
|
+
| **Querying / filtering** | Minimal | Minimal | Strong |
|
|
181
|
+
| **Access control zones** | User-scoped only | Scope only | `data` / `owner` / `admin` zones |
|
|
182
|
+
| **Admin write required?** | ❌ No | ✅ Yes (for write operations) | Only for admin endpoints / admin fields |
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## When `setDataItem` Is Still the Right Answer
|
|
187
|
+
|
|
188
|
+
`setDataItem` is still valuable and should not be treated as deprecated. It is the right fit when:
|
|
189
|
+
|
|
190
|
+
- You need a handful of documents attached to a collection or product
|
|
191
|
+
- Each item has a stable known ID
|
|
192
|
+
- You mostly fetch by exact ID or list all items
|
|
193
|
+
- You do not need rich lifecycle fields, reply chains, assignment, or advanced querying
|
|
194
|
+
|
|
195
|
+
Examples:
|
|
196
|
+
|
|
197
|
+
- Product FAQs
|
|
198
|
+
- Menu definitions
|
|
199
|
+
- Marketing content blocks
|
|
200
|
+
- Widget registry entries
|
|
201
|
+
- Static lookup tables for an app
|
|
202
|
+
|
|
203
|
+
If the object starts needing richer semantics, migrate that use case to `app.records`, `app.cases`, or `app.threads` rather than stretching scoped data items too far.
|
|
158
204
|
|
|
159
205
|
---
|
|
160
206
|
|
package/docs/overview.md
CHANGED
|
@@ -146,9 +146,12 @@ This applies to all write operations: `setConfig`, `setDataItem`, `updateDataIte
|
|
|
146
146
|
|-------------|---------|---------|
|
|
147
147
|
| **Config** (`getConfig`/`setConfig`) | Single JSON document | App settings, feature flags, global options |
|
|
148
148
|
| **Data** (`getData`/`setDataItem`) | Array of documents with IDs | Lists of items, records, entries |
|
|
149
|
+
| **App Objects** (`app.records` / `app.cases` / `app.threads`) | Queryable domain objects | Real app entities, workflows, conversations, richer access control |
|
|
149
150
|
|
|
150
151
|
Both can be scoped to **collection level** or **product level** by including `productId`.
|
|
151
152
|
|
|
153
|
+
Prefer `app.records` over `setDataItem` when the data is becoming a real entity that needs lifecycle, ownership, visibility, relationships, or filtering. Keep `setDataItem` for simple keyed scoped documents and config-adjacent content.
|
|
154
|
+
|
|
152
155
|
### Attestations (Proof-level data)
|
|
153
156
|
|
|
154
157
|
For data attached to specific proof instances, use `SL.attestation.create()` and `SL.attestation.list()`.
|