@chipmobilesdk/rn-local-db 0.1.0 → 0.1.2
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 +1 -1
- package/package.json +10 -9
- package/skills/sdk-rn-local-db/SKILL.md +74 -0
package/README.md
CHANGED
|
@@ -354,7 +354,7 @@ Every one returns a `DeletionOutcome` rather than a bare success — what was re
|
|
|
354
354
|
|
|
355
355
|
If a deletion is interrupted — a force-quit, a battery death — the next open reports `SCOPE_DELETED` rather than presenting the scope as healthy. Call `deleteScopeData` again to finish it.
|
|
356
356
|
|
|
357
|
-
A handle whose scope is deleted beneath it reports `SCOPE_DELETED` on its next use. The deletion does not wait for it.
|
|
357
|
+
A handle whose scope is deleted beneath it reports `SCOPE_DELETED` on its next use. The deletion does not wait for it, and nothing revives it: open a new handle and rebuild whatever was built on the old one. An app that retries through the dead handle gets the same error every time, which reaches the user as a screen that only relaunching can fix.
|
|
358
358
|
|
|
359
359
|
---
|
|
360
360
|
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chipmobilesdk/rn-local-db",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"private": false,
|
|
5
|
-
"license": "UNLICENSED",
|
|
6
|
-
"main": "src/index.ts",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"private": false,
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
7
|
"types": "src/index.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"src/scope",
|
|
32
32
|
"src/sqlite",
|
|
33
33
|
"src/testing",
|
|
34
|
+
"skills",
|
|
34
35
|
"README.md",
|
|
35
36
|
"CHANGELOG.md"
|
|
36
37
|
],
|
|
@@ -54,8 +55,8 @@
|
|
|
54
55
|
"engines": {
|
|
55
56
|
"node": ">=22.11.0"
|
|
56
57
|
},
|
|
57
|
-
"publishConfig": {
|
|
58
|
-
"access": "public",
|
|
59
|
-
"registry": "https://registry.npmjs.org/"
|
|
60
|
-
}
|
|
61
|
-
}
|
|
58
|
+
"publishConfig": {
|
|
59
|
+
"access": "public",
|
|
60
|
+
"registry": "https://registry.npmjs.org/"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sdk-rn-local-db
|
|
3
|
+
description: "Offline SQLite storage via @chipmobilesdk/rn-local-db: schemas, scoped data, queries, transactions, migrations, attachments, encryption. Use when persisting data locally, writing a migration, deleting a user's data, or handling sign-out data retention."
|
|
4
|
+
metadata:
|
|
5
|
+
package: "@chipmobilesdk/rn-local-db"
|
|
6
|
+
packageVersion: "0.1.0"
|
|
7
|
+
user-invocable: true
|
|
8
|
+
disable-model-invocation: false
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# @chipmobilesdk/rn-local-db
|
|
12
|
+
|
|
13
|
+
Local-first SQLite persistence with a scope model, declarative schemas, typed queries,
|
|
14
|
+
migrations, attachments and optional encryption.
|
|
15
|
+
|
|
16
|
+
## Use this when
|
|
17
|
+
|
|
18
|
+
- Persisting any app data on device
|
|
19
|
+
- Declaring or changing a schema, or writing a migration
|
|
20
|
+
- Deciding what happens to data at sign-out
|
|
21
|
+
- Storing files/attachments alongside records
|
|
22
|
+
- Enabling encryption or answering a backup/privacy question
|
|
23
|
+
|
|
24
|
+
## Read before writing any code
|
|
25
|
+
|
|
26
|
+
Two concepts cause most of the bugs in this package. Do not skip them:
|
|
27
|
+
|
|
28
|
+
1. **The scope model** — data belongs to a scope, and getting the scope wrong leaks
|
|
29
|
+
data between users or loses it on sign-out.
|
|
30
|
+
2. **The four value conditions** — this package distinguishes more record states than
|
|
31
|
+
"set" vs "null". Handling only two of them produces silent data loss.
|
|
32
|
+
|
|
33
|
+
Read `## The scope model` and `## Records and the four value conditions` in the README
|
|
34
|
+
before designing a schema.
|
|
35
|
+
|
|
36
|
+
## Deletion, sign-out, and dead handles
|
|
37
|
+
|
|
38
|
+
The README has a dedicated section (`## Deletion, and why sign-out is not deletion`).
|
|
39
|
+
Treat any "clear data on logout" requirement as a design question answered by that
|
|
40
|
+
section, not by deleting the database file.
|
|
41
|
+
|
|
42
|
+
`deleteScopeData` and `deleteDatabase` are module-level and do not wait for open
|
|
43
|
+
handles. **After either, open a NEW handle and rebuild everything derived from the
|
|
44
|
+
old one** — repositories, providers, the screen behind a retry button. The old handle
|
|
45
|
+
raises `SCOPE_DELETED` (or `CLOSED_HANDLE` if the app closed it first) on every call,
|
|
46
|
+
so a Retry wired to it can never succeed: the app stays broken until the process
|
|
47
|
+
restarts. An interrupted deletion instead reports `SCOPE_DELETED` from the next
|
|
48
|
+
`openDatabase` — call `deleteScopeData` again to finish it, then open.
|
|
49
|
+
|
|
50
|
+
## Public API
|
|
51
|
+
|
|
52
|
+
`setDiagnosticLogger`, `Budgets`, and types `DiagnosticLogger`, `DiagnosticCode` are
|
|
53
|
+
exported from the root. The schema, query, migration, scope, crypto and attachment
|
|
54
|
+
surfaces are large — enumerate them from
|
|
55
|
+
`node_modules/@chipmobilesdk/rn-local-db/src/index.ts` when needed rather than guessing.
|
|
56
|
+
|
|
57
|
+
## Where the detail lives
|
|
58
|
+
|
|
59
|
+
`node_modules/@chipmobilesdk/rn-local-db/README.md` is ~700 lines. Read one section:
|
|
60
|
+
|
|
61
|
+
| Need | Section |
|
|
62
|
+
|---|---|
|
|
63
|
+
| Install and native setup | `## Install` |
|
|
64
|
+
| Data ownership / sign-out / deleting it all | `## The scope model`, `## Deletion, and why sign-out is not deletion` |
|
|
65
|
+
| Defining tables | `## Declaring a schema` |
|
|
66
|
+
| Null vs missing vs unset | `## Records and the four value conditions` |
|
|
67
|
+
| Reading data | `## Queries` |
|
|
68
|
+
| Atomic writes | `## Transactions and batches` |
|
|
69
|
+
| Schema change | `## Migrations` |
|
|
70
|
+
| Files and blobs | `## Attachments` |
|
|
71
|
+
| Encryption at rest | `## Encryption` |
|
|
72
|
+
| iOS/Android backup behaviour | `## Backup posture` |
|
|
73
|
+
|
|
74
|
+
Start from `## Contents` if you are unsure which section applies.
|