@nocentraldb/sdk 0.0.0-stage → 0.1.0-alpha.70

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 (58) hide show
  1. package/dist/account.d.ts +14 -0
  2. package/dist/account.js +34 -0
  3. package/dist/accountCalls.d.ts +34 -0
  4. package/dist/accountCalls.js +48 -0
  5. package/dist/adHoc.d.ts +49 -0
  6. package/dist/adHoc.js +52 -0
  7. package/dist/cbor.d.ts +8 -0
  8. package/dist/cbor.js +223 -0
  9. package/dist/connect.d.ts +14 -0
  10. package/dist/connect.js +527 -0
  11. package/dist/connectParts.d.ts +29 -0
  12. package/dist/connectParts.js +10 -0
  13. package/dist/db.d.ts +291 -0
  14. package/dist/db.js +17 -0
  15. package/dist/durability.d.ts +20 -0
  16. package/dist/durability.js +5 -0
  17. package/dist/durabilityReport.d.ts +29 -0
  18. package/dist/durabilityReport.js +128 -0
  19. package/dist/elements.d.ts +5 -0
  20. package/dist/elements.js +13 -0
  21. package/dist/error.d.ts +10 -0
  22. package/dist/error.js +23 -0
  23. package/dist/index.d.ts +19 -0
  24. package/dist/index.js +6 -0
  25. package/dist/lockCheck.d.ts +4 -0
  26. package/dist/lockCheck.js +63 -0
  27. package/dist/members.d.ts +55 -0
  28. package/dist/members.js +38 -0
  29. package/dist/membership.d.ts +5 -0
  30. package/dist/membership.js +29 -0
  31. package/dist/nc.d.ts +153 -0
  32. package/dist/nc.js +211 -0
  33. package/dist/query.d.ts +21 -0
  34. package/dist/query.js +45 -0
  35. package/dist/reports.d.ts +8 -0
  36. package/dist/reports.js +50 -0
  37. package/dist/spaceList.d.ts +14 -0
  38. package/dist/spaceList.js +45 -0
  39. package/dist/status.d.ts +51 -0
  40. package/dist/status.js +5 -0
  41. package/dist/sync.d.ts +15 -0
  42. package/dist/sync.js +4 -0
  43. package/dist/tabs.d.ts +30 -0
  44. package/dist/tabs.js +444 -0
  45. package/dist/texts.d.ts +52 -0
  46. package/dist/texts.js +58 -0
  47. package/dist/waitNotice.d.ts +7 -0
  48. package/dist/waitNotice.js +32 -0
  49. package/dist/wasm/nocentraldb_wasm.d.ts +91 -0
  50. package/dist/wasm/nocentraldb_wasm.js +1058 -0
  51. package/dist/wasm/nocentraldb_wasm_bg.wasm +0 -0
  52. package/dist/wasm/nocentraldb_wasm_bg.wasm.d.ts +36 -0
  53. package/dist/worker.d.ts +1 -0
  54. package/dist/worker.js +142 -0
  55. package/dist/workerHost.d.ts +3 -0
  56. package/dist/workerHost.js +55 -0
  57. package/package.json +21 -4
  58. package/README.md +0 -3
package/dist/texts.js ADDED
@@ -0,0 +1,58 @@
1
+ // Generated by scripts/texts.mjs from texts/texts.json: do not edit.
2
+ // Change a text there, then run `node scripts/texts.mjs --write`.
3
+ //
4
+ // Every text a developer reads from the TypeScript SDK (NOC-329, T3).
5
+ // Each text's comment says when it shows. Internal: the package's entry
6
+ // does not reach it.
7
+ /** `adHocCopyNotRead` (invalidValue): db.spaces.createAdHoc, given in copy an object the SDK of this database did not read, such as a spread of one or an object of another database. */
8
+ export const AD_HOC_COPY_NOT_READ = "copy takes objects this database read, as space.get, find or subscribe gives them, not a copy of one";
9
+ /** `anotherLock` (modelRefused): nc.open in a tab while another tab of the origin has the database open with another lock. */
10
+ export const ANOTHER_LOCK = "another tab has this database open with another lock";
11
+ /** `cursorOfAnotherDatabase` (cursorOfAnotherModel): db.find or space.find, given a page's cursor from another database. */
12
+ export const CURSOR_OF_ANOTHER_DATABASE = "the cursor is not of this database; start from the first page";
13
+ /** `databaseClosed` (closed): Any call after db.close(), and the calls still waiting when it closes. */
14
+ export const DATABASE_CLOSED = "the database is closed";
15
+ /** `lockFieldDiffers` (lockOutOfDate): nc.open, on a model whose field has another type or other options in the lock, as when the lock was not built again after the field changed. */
16
+ export const lockFieldDiffers = (collection, field) => `model.lock.json is out of date: ${collection}.${field} differs from the lock in its type or options. Run ncdb model build.`;
17
+ /** `lockHasNoCollection` (lockOutOfDate): nc.open, on a model that names a collection the lock does not have, as when the lock was not built again after the collection was added. */
18
+ export const lockHasNoCollection = (collection) => `model.lock.json is out of date: it has no collection ${collection}. Run ncdb model build.`;
19
+ /** `lockHasNoField` (lockOutOfDate): nc.open, on a model that names a field the lock does not have, as when the lock was not built again after the field was added. */
20
+ export const lockHasNoField = (collection, field) => `model.lock.json is out of date: it has no field ${collection}.${field}. Run ncdb model build.`;
21
+ /** `lockHasNoIndex` (lockOutOfDate): nc.open, on a model that names an index the lock does not have, as when the lock was not built again after the index was added. */
22
+ export const lockHasNoIndex = (collection, index) => `model.lock.json is out of date: it has no index ${collection}.${index}. Run ncdb model build.`;
23
+ /** `lockIndexDiffers` (lockOutOfDate): nc.open, on a model whose index has other fields, another equality prefix or another scope in the lock. */
24
+ export const lockIndexDiffers = (collection, index) => `model.lock.json is out of date: ${collection}.${index} differs from the lock in its fields or options. Run ncdb model build.`;
25
+ /** `noSuchCollection` (notFound): A call given a collection that is not a handle of the model nc.open was given. */
26
+ export const NO_SUCH_COLLECTION = "the model has no such collection; pass a handle such as model.tasks";
27
+ /** `notACollection`: ncdb model build, on a model whose collection is not declared with nc.collection. */
28
+ export const notACollection = (collection) => `${collection}: not a collection; declare it with nc.collection(...).`;
29
+ /** `notAComputedField`: ncdb model build, on a model whose computed field is not declared with nc.reach. */
30
+ export const notAComputedField = (collection, key) => `${collection}.${key}: not a computed field; declare it with nc.reach(...).`;
31
+ /** `notADatabaseName` (invalidValue): nc.open, given a name that breaks RFC 0006's rule for a browser database's name. */
32
+ export const NOT_ADATABASE_NAME = "a database name is 1 to 64 characters of a-z, 0-9, - and _";
33
+ /** `notAField`: ncdb model build, on a model whose field is not declared with a field function. */
34
+ export const notAField = (path) => `${path}: not a field; declare it with a field function such as nc.string().`;
35
+ /** `notAPairingAnswer` (invalidValue): nc.pairingAnswer, given a text that does not start with ncdb-pair-1: or is not unpadded base64url. */
36
+ export const NOT_APAIRING_ANSWER = "the text is not a pairing answer: ncdb-pair-1: and unpadded base64url";
37
+ /** `notAQuery` (invalidValue): A subscription to db.find or space.find, given something that is not a query. */
38
+ export const NOT_AQUERY = "not a query";
39
+ /** `notAQueryStartOne` (invalidValue): db.find or space.find, given something that is not a query. */
40
+ export const NOT_AQUERY_START_ONE = "not a query; start one from an index, such as model.tasks.indexes.byPriority";
41
+ /** `notASafeInteger` (invalidValue): A write of an nc.int() field given a number that is not a safe integer. */
42
+ export const notASafeInteger = (collection, field) => `${collection}.${field} takes a safe integer, between -(2^53 - 1) and 2^53 - 1`;
43
+ /** `notAView`: ncdb model build, on a model whose view is not declared with nc.view. */
44
+ export const notAView = (collection, key) => `${collection}.${key}: not a view; declare it with nc.view(...).`;
45
+ /** `notAnIndex`: ncdb model build, on a model whose index is not declared with nc.index. */
46
+ export const notAnIndex = (collection, key) => `${collection}.${key}: not an index; declare it with nc.index(...).`;
47
+ /** `notAnInvitation` (invalidValue): nc.invitation, given a text that does not start with ncdb-invite-1: or is not unpadded base64url. */
48
+ export const NOT_AN_INVITATION = "the text is not an invitation: ncdb-invite-1: and unpadded base64url";
49
+ /** `ownerTabClosed` (storageFailed): A call that changes the database, sent to the tab that owned it, when that tab ended before it answered (NOC-177). */
50
+ export const OWNER_TAB_CLOSED = "the tab that held the database closed before it answered; the call may or may not have run";
51
+ /** `reservedFieldType`: ncdb model build, on a model with nc.richText or nc.stream, whose field types a later RFC designs. */
52
+ export const reservedFieldType = (path, type) => `${path}: ${type} is reserved; its field type belongs to a later RFC (RFC 0005).`;
53
+ /** `setElementModified`: ncdb model build, on a model whose nc.set element is personal, described or deprecated. */
54
+ export const setElementModified = (path) => `${path}: a set's element takes no modifiers; put them on the set.`;
55
+ /** `setElementNotBasic`: ncdb model build, on a model whose nc.set is of something other than a basic value. */
56
+ export const setElementNotBasic = (path) => `${path}: a set's element is a basic value: nc.string(), nc.int(), nc.float(), nc.boolean() or nc.oneOf([...]).`;
57
+ /** `workerFailed` (storageFailed): Every call waiting on the SDK's worker when the worker fails, with the browser's own message. */
58
+ export const workerFailed = (message) => `the worker failed: ${message}`;
@@ -0,0 +1,7 @@
1
+ /** How long a wait lasts before it is reported, in milliseconds. */
2
+ export declare const WAIT_NOTICE_AFTER = 1000;
3
+ /** Reports `true` to `report` once a wait has lasted `after`, and `false` when a reported wait ends. */
4
+ export declare const waitNotice: (report: (waiting: boolean) => void, after?: number) => {
5
+ started(): void;
6
+ ended(): void;
7
+ };
@@ -0,0 +1,32 @@
1
+ // When a worker tells its tab that it waits for the database's storage,
2
+ // which another tab of the app still holds (NOC-355): the tab reports it as
3
+ // `db.durability`'s `waitingForTab`. worker.ts calls `started` when it finds
4
+ // the storage held and `ended` once it holds it. The wait is reported only
5
+ // once it has lasted `WAIT_NOTICE_AFTER`, so a normal handover, where the
6
+ // old tab's worker is still stopping for a few milliseconds, reports
7
+ // nothing (Carsten, 2026-11-16, NOC-355). The worker's timer runs while a
8
+ // frozen owner holds the storage, in WebKit too (measured, NOC-355).
9
+ // Internal: the package's entry does not reach it.
10
+ /** How long a wait lasts before it is reported, in milliseconds. */
11
+ export const WAIT_NOTICE_AFTER = 1000;
12
+ /** Reports `true` to `report` once a wait has lasted `after`, and `false` when a reported wait ends. */
13
+ export const waitNotice = (report, after = WAIT_NOTICE_AFTER) => {
14
+ let timer;
15
+ let told = false;
16
+ return {
17
+ started() {
18
+ clearTimeout(timer);
19
+ timer = setTimeout(() => {
20
+ told = true;
21
+ report(true);
22
+ }, after);
23
+ },
24
+ ended() {
25
+ clearTimeout(timer);
26
+ timer = undefined;
27
+ if (told)
28
+ report(false);
29
+ told = false;
30
+ },
31
+ };
32
+ };
@@ -0,0 +1,91 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * The worker's core: one bridge, and at most one open database.
6
+ */
7
+ export class Core {
8
+ free(): void;
9
+ [Symbol.dispose](): void;
10
+ /**
11
+ * Answers `request`: a promise of the answer's bytes, a `Uint8Array`.
12
+ * When the request opened a database, the core starts giving its
13
+ * fold events to the listener.
14
+ */
15
+ handle(request: Uint8Array | number[]): Promise<any>;
16
+ /**
17
+ * Gives every fold event, a `Uint8Array` of CBOR, to `listener`.
18
+ */
19
+ listen(listener: Function): void;
20
+ /**
21
+ * A core with no database open.
22
+ */
23
+ constructor();
24
+ /**
25
+ * Closes the open database and gives its OPFS handles back, before
26
+ * the worker ends (NOC-352): whether they are free. The worker calls
27
+ * it once every request is answered.
28
+ */
29
+ release(): boolean;
30
+ }
31
+
32
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
33
+
34
+ export interface InitOutput {
35
+ readonly memory: WebAssembly.Memory;
36
+ readonly __wbg_core_free: (a: number, b: number) => void;
37
+ readonly core_handle: (a: number, b: number, c: number) => any;
38
+ readonly core_listen: (a: number, b: any) => void;
39
+ readonly core_new: () => number;
40
+ readonly core_release: (a: number) => number;
41
+ readonly rust_sqlite_wasm_host_sleep: (a: bigint, b: number) => void;
42
+ readonly rust_sqlite_wasm_abort: () => void;
43
+ readonly rust_sqlite_wasm_assert_fail: (a: number, b: number, c: number, d: number) => void;
44
+ readonly rust_sqlite_wasm_calloc: (a: number, b: number) => number;
45
+ readonly rust_sqlite_wasm_free: (a: number) => void;
46
+ readonly rust_sqlite_wasm_getentropy: (a: number, b: number) => number;
47
+ readonly rust_sqlite_wasm_host_epoch_timestamp_in_ms: (a: number) => number;
48
+ readonly rust_sqlite_wasm_host_fill_entropy: (a: number, b: number) => number;
49
+ readonly rust_sqlite_wasm_host_localtime: (a: bigint, b: number) => number;
50
+ readonly rust_sqlite_wasm_host_random: (a: number, b: number) => number;
51
+ readonly rust_sqlite_wasm_localtime: (a: number) => number;
52
+ readonly rust_sqlite_wasm_malloc: (a: number) => number;
53
+ readonly rust_sqlite_wasm_realloc: (a: number, b: number) => number;
54
+ readonly sqlite3_os_end: () => number;
55
+ readonly sqlite3_os_init: () => number;
56
+ readonly wasm_bindgen_70735ce8c264698d___convert__closures_____invoke___js_sys_7fe34edb73153ca3___Function_fn_wasm_bindgen_70735ce8c264698d___JsValue_____wasm_bindgen_70735ce8c264698d___sys__Undefined___js_sys_7fe34edb73153ca3___Function_fn_wasm_bindgen_70735ce8c264698d___JsValue_____wasm_bindgen_70735ce8c264698d___sys__Undefined_______true_: (a: number, b: number, c: any, d: any) => void;
57
+ readonly wasm_bindgen_70735ce8c264698d___convert__closures_____invoke___wasm_bindgen_70735ce8c264698d___JsValue__core_37ee0ce0c4cd57d5___result__Result_____wasm_bindgen_70735ce8c264698d___JsError___true_: (a: number, b: number, c: any) => [number, number];
58
+ readonly wasm_bindgen_70735ce8c264698d___convert__closures_____invoke___wasm_bindgen_70735ce8c264698d___JsValue______true_: (a: number, b: number, c: any) => void;
59
+ readonly wasm_bindgen_70735ce8c264698d___convert__closures_____invoke___wasm_bindgen_70735ce8c264698d___JsValue______true__7: (a: number, b: number, c: any) => void;
60
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
61
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
62
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
63
+ readonly __wbindgen_exn_store: (a: number) => void;
64
+ readonly __externref_table_alloc: () => number;
65
+ readonly __wbindgen_externrefs: WebAssembly.Table;
66
+ readonly __wbindgen_destroy_closure: (a: number, b: number) => void;
67
+ readonly __externref_table_dealloc: (a: number) => void;
68
+ readonly __wbindgen_start: () => void;
69
+ }
70
+
71
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
72
+
73
+ /**
74
+ * Instantiates the given `module`, which can either be bytes or
75
+ * a precompiled `WebAssembly.Module`.
76
+ *
77
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
78
+ *
79
+ * @returns {InitOutput}
80
+ */
81
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
82
+
83
+ /**
84
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
85
+ * for everything else, calls `WebAssembly.instantiate` directly.
86
+ *
87
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
88
+ *
89
+ * @returns {Promise<InitOutput>}
90
+ */
91
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;