@nocentraldb/sdk 0.1.0-alpha.72 → 0.1.0-alpha.74

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 ADDED
@@ -0,0 +1,60 @@
1
+ # @nocentraldb/sdk
2
+
3
+ The TypeScript SDK of [NoCentralDB](https://nocentraldb.io), a local-first database for apps where people and agents work on the same data. Every member works on its own full copy, under its own keys, and the relay in the middle cannot read any of it.
4
+
5
+ NoCentralDB 0.1 is a pre-release: names and formats can still change before 1.0. In 0.1 this SDK runs in the browser, in Chromium, Firefox and Safari, with its database on the origin private file system (OPFS); in Node.js it comes after 0.1. On a server or in an agent, use the Rust SDK, `nocentraldb`. [Getting started](https://nocentraldb.io/docs/) says what 0.1 does and does not do yet.
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ npm install @nocentraldb/sdk@alpha
11
+ ```
12
+
13
+ `ncdb model build`, which turns your model into `model.lock.json`, runs from a clone of [the repository](https://github.com/nocentraldb/nocentraldb) in 0.1, as [the browser guide](https://nocentraldb.io/docs/guides/browser/) shows.
14
+
15
+ ## A first look
16
+
17
+ You describe the model once, in TypeScript:
18
+
19
+ ```ts
20
+ import { nc } from "@nocentraldb/sdk";
21
+
22
+ export const model = nc.model({
23
+ tasks: nc.collection(
24
+ {
25
+ title: nc.string(),
26
+ status: nc.oneOf(["open", "done"]),
27
+ },
28
+ {
29
+ indexes: {
30
+ byStatus: nc.index(["status", "title"], { equal: 1 }),
31
+ },
32
+ },
33
+ ),
34
+ });
35
+ ```
36
+
37
+ Then you open the database with the lock, write to a space and follow a query. A write resolves once the change is in the local view, before the relay has it, and a subscription answers again after every change that may alter its page:
38
+
39
+ ```ts
40
+ const lock: unknown = await (await fetch("/model.lock.json")).json();
41
+ const db = await nc.open({ model, lock, relay: "wss://relay.example.com" });
42
+
43
+ const space = await db.spaces.create();
44
+ await space.write((tx) => {
45
+ tx.create(model.tasks, { title: "Write the README", status: "open" });
46
+ });
47
+
48
+ const open = model.tasks.indexes.byStatus.equal("open").take(20);
49
+ const stop = db.subscribe(open, (page) => console.log(page.items));
50
+ ```
51
+
52
+ ## Read on
53
+
54
+ - [Getting started in the browser](https://nocentraldb.io/docs/guides/browser/) builds a task list that syncs through a relay.
55
+ - [The TypeScript API reference](https://nocentraldb.io/docs/api/reference/) lists every public declaration.
56
+ - [Browser apps and durability](https://nocentraldb.io/docs/browser-durability/) says what a browser copy keeps and what to tell your users.
57
+
58
+ ## License
59
+
60
+ MIT or Apache-2.0, at your option.
@@ -667,17 +667,17 @@ function __wbg_get_imports() {
667
667
  return ret;
668
668
  }, arguments); },
669
669
  __wbindgen_generic_0000000000000001: function(arg0, arg1) {
670
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 228, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
670
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 220, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
671
671
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen_70735ce8c264698d___convert__closures_____invoke___wasm_bindgen_70735ce8c264698d___JsValue______true_);
672
672
  return ret;
673
673
  },
674
674
  __wbindgen_generic_0000000000000002: function(arg0, arg1) {
675
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 948, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
675
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 944, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
676
676
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen_70735ce8c264698d___convert__closures_____invoke___wasm_bindgen_70735ce8c264698d___JsValue__core_37ee0ce0c4cd57d5___result__Result_____wasm_bindgen_70735ce8c264698d___JsError___true_);
677
677
  return ret;
678
678
  },
679
679
  __wbindgen_generic_0000000000000003: function(arg0, arg1) {
680
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Event")], shim_idx: 228, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
680
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Event")], shim_idx: 220, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
681
681
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen_70735ce8c264698d___convert__closures_____invoke___wasm_bindgen_70735ce8c264698d___JsValue______true__7);
682
682
  return ret;
683
683
  },
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocentraldb/sdk",
3
- "version": "0.1.0-alpha.72",
3
+ "version": "0.1.0-alpha.74",
4
4
  "license": "MIT OR Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",