snapback4 0.0.8 → 0.0.9
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 +5 -2
- package/dist/local.js +15 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -300,8 +300,11 @@ flips the link.
|
|
|
300
300
|
|
|
301
301
|
## 5. Development
|
|
302
302
|
|
|
303
|
-
- **`snapback4 dev [--port N] [--no-watch]`** serves
|
|
304
|
-
`127.0.0.1:4400`, recompiling and re-adopting on every
|
|
303
|
+
- **`snapback4 dev [--port N] [--no-watch] [--fresh]`** serves
|
|
304
|
+
`snapback/*.q` on `127.0.0.1:4400`, recompiling and re-adopting on every
|
|
305
|
+
save; the store lives in `.snapback4/` and persists across runs, and
|
|
306
|
+
`--fresh` uses one in memory that dies with the process (acceptance
|
|
307
|
+
scripts start from nothing). Personas
|
|
305
308
|
(`use personas ..`) sign requests from the same machine with the
|
|
306
309
|
`x-snapback-persona: alice` header (the client's `persona: "alice"`),
|
|
307
310
|
acting as `dev:alice`.
|
package/dist/local.js
CHANGED
|
@@ -40,6 +40,7 @@ export async function createLocalClient(options) {
|
|
|
40
40
|
const viewer = (options.persona ? `dev:${options.persona}` : session.principal);
|
|
41
41
|
const principal = viewer;
|
|
42
42
|
let sessionDead = false;
|
|
43
|
+
let partitionDenied = null;
|
|
43
44
|
const refusedSession = async (denied) => {
|
|
44
45
|
if (session && !sessionDead && denied?.code === "E_AUTH") {
|
|
45
46
|
sessionDead = true;
|
|
@@ -87,13 +88,24 @@ export async function createLocalClient(options) {
|
|
|
87
88
|
async sync(from, limit) {
|
|
88
89
|
try {
|
|
89
90
|
const response = await doFetch(`${base}/sync?from=${from}&limit=${limit}`, { headers });
|
|
90
|
-
if (response.status
|
|
91
|
+
if (response.status === 503)
|
|
91
92
|
return { denied: offline() };
|
|
92
93
|
const page = (await response.json());
|
|
93
94
|
if (page.denied) {
|
|
94
95
|
await refusedSession(page.denied);
|
|
96
|
+
if (!page.denied.retryable) {
|
|
97
|
+
// The server refuses this device's partition (a schema the store
|
|
98
|
+
// cannot serve, a dead session): every read says so, once
|
|
99
|
+
// loudly here, and until the next successful sync.
|
|
100
|
+
if (!partitionDenied)
|
|
101
|
+
console.error(`snapback4: the server refused the partition: ${page.denied.code}: ${page.denied.message}`);
|
|
102
|
+
partitionDenied = page.denied;
|
|
103
|
+
for (const watch of watches.values())
|
|
104
|
+
void rerun(watch);
|
|
105
|
+
}
|
|
95
106
|
return { denied: page.denied };
|
|
96
107
|
}
|
|
108
|
+
partitionDenied = null;
|
|
97
109
|
if (link !== "online")
|
|
98
110
|
setLink("online");
|
|
99
111
|
if (page.watermark > seq)
|
|
@@ -147,6 +159,8 @@ export async function createLocalClient(options) {
|
|
|
147
159
|
const program = backend.programs[op.name];
|
|
148
160
|
if (!program)
|
|
149
161
|
return { read: { denied: { code: "E_OP", family: "op", message: `unknown query ${op.name}` } }, tables: new Set() };
|
|
162
|
+
if (partitionDenied)
|
|
163
|
+
return { read: { denied: partitionDenied }, tables: new Set(Object.keys(backend.schema.tables)) };
|
|
150
164
|
try {
|
|
151
165
|
const outcome = await store.read((tx) => new Interpreter(tx, backend.schema, { viewer: principal, args: args, now: Date.now(), newIds: [], mint: mintId }, "query").run(program));
|
|
152
166
|
const read = { data: outcome.data, complete: outcome.complete, fresh: link === "online" && replica.isCaughtUp, next: outcome.next, ...(link === "online" && replica.isCaughtUp ? {} : { since: lastSyncAt }) };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "snapback4",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Snapback 4: the card (contract), the online and local-first clients (IndexedDB, SQLite), React hooks, sign-in, a labelled mock, and the `snapback4` CLI. LLP 3000.",
|
|
6
6
|
"bin": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"README.md"
|
|
43
43
|
],
|
|
44
44
|
"optionalDependencies": {
|
|
45
|
-
"snapback4-darwin-arm64": "0.0.
|
|
45
|
+
"snapback4-darwin-arm64": "0.0.9"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"build": "tsc -p tsconfig.build.json",
|