tablinum 0.0.1 → 0.1.1
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 +77 -1
- package/dist/crud/collection-handle.d.ts +21 -0
- package/dist/crud/query-builder.d.ts +42 -0
- package/dist/crud/watch.d.ts +25 -0
- package/dist/db/create-tablinum.d.ts +12 -0
- package/dist/db/database-handle.d.ts +13 -0
- package/dist/db/identity.d.ts +8 -0
- package/dist/errors.d.ts +58 -0
- package/{src/index.ts → dist/index.d.ts} +4 -24
- package/dist/index.js +1833 -0
- package/dist/main.d.ts +1 -0
- package/dist/schema/collection.d.ts +12 -0
- package/dist/schema/field.d.ts +17 -0
- package/{src/schema/types.ts → dist/schema/types.d.ts} +5 -10
- package/dist/schema/validate.d.ts +13 -0
- package/dist/storage/events-store.d.ts +6 -0
- package/dist/storage/giftwraps-store.d.ts +6 -0
- package/dist/storage/idb.d.ts +35 -0
- package/dist/storage/lww.d.ts +10 -0
- package/dist/storage/records-store.d.ts +12 -0
- package/dist/svelte/collection.svelte.d.ts +20 -0
- package/dist/svelte/database.svelte.d.ts +15 -0
- package/dist/svelte/index.svelte.d.ts +16 -0
- package/dist/svelte/index.svelte.js +2050 -0
- package/dist/svelte/live-query.svelte.d.ts +8 -0
- package/dist/svelte/query.svelte.d.ts +39 -0
- package/dist/sync/gift-wrap.d.ts +9 -0
- package/dist/sync/negentropy.d.ts +9 -0
- package/dist/sync/publish-queue.d.ts +10 -0
- package/dist/sync/relay.d.ts +17 -0
- package/dist/sync/sync-service.d.ts +14 -0
- package/dist/sync/sync-status.d.ts +7 -0
- package/dist/utils/uuid.d.ts +2 -0
- package/package.json +22 -1
- package/.changeset/README.md +0 -8
- package/.changeset/config.json +0 -11
- package/.context/attachments/pasted_text_2026-03-07_14-02-40.txt +0 -571
- package/.context/attachments/pasted_text_2026-03-07_15-48-27.txt +0 -498
- package/.context/notes.md +0 -0
- package/.context/plans/add-changesets-to-douala-v4.md +0 -48
- package/.context/plans/dexie-js-style-query-language-for-localstr.md +0 -115
- package/.context/plans/dexie-js-style-query-language-with-per-collection-.md +0 -336
- package/.context/plans/implementation-plan-localstr-v0-2.md +0 -263
- package/.context/plans/project-init-effect-v4-bun-oxlint-oxfmt-vitest.md +0 -71
- package/.context/plans/revise-localstr-prd-v0-2.md +0 -132
- package/.context/plans/svelte-5-runes-bindings-for-localstr.md +0 -233
- package/.context/todos.md +0 -0
- package/.github/workflows/release.yml +0 -36
- package/.oxlintrc.json +0 -8
- package/bun.lock +0 -705
- package/examples/svelte/bun.lock +0 -261
- package/examples/svelte/package.json +0 -21
- package/examples/svelte/src/app.html +0 -11
- package/examples/svelte/src/lib/db.ts +0 -44
- package/examples/svelte/src/routes/+page.svelte +0 -322
- package/examples/svelte/svelte.config.js +0 -16
- package/examples/svelte/tsconfig.json +0 -6
- package/examples/svelte/vite.config.ts +0 -6
- package/examples/vanilla/app.ts +0 -219
- package/examples/vanilla/index.html +0 -144
- package/examples/vanilla/serve.ts +0 -42
- package/prds/localstr-v0.2.md +0 -221
- package/prek.toml +0 -10
- package/scripts/validate.ts +0 -392
- package/src/crud/collection-handle.ts +0 -189
- package/src/crud/query-builder.ts +0 -414
- package/src/crud/watch.ts +0 -78
- package/src/db/create-localstr.ts +0 -217
- package/src/db/database-handle.ts +0 -16
- package/src/db/identity.ts +0 -49
- package/src/errors.ts +0 -37
- package/src/main.ts +0 -10
- package/src/schema/collection.ts +0 -53
- package/src/schema/field.ts +0 -25
- package/src/schema/validate.ts +0 -111
- package/src/storage/events-store.ts +0 -24
- package/src/storage/giftwraps-store.ts +0 -23
- package/src/storage/idb.ts +0 -244
- package/src/storage/lww.ts +0 -17
- package/src/storage/records-store.ts +0 -76
- package/src/svelte/collection.svelte.ts +0 -87
- package/src/svelte/database.svelte.ts +0 -83
- package/src/svelte/index.svelte.ts +0 -52
- package/src/svelte/live-query.svelte.ts +0 -29
- package/src/svelte/query.svelte.ts +0 -101
- package/src/sync/gift-wrap.ts +0 -33
- package/src/sync/negentropy.ts +0 -83
- package/src/sync/publish-queue.ts +0 -61
- package/src/sync/relay.ts +0 -239
- package/src/sync/sync-service.ts +0 -183
- package/src/sync/sync-status.ts +0 -17
- package/src/utils/uuid.ts +0 -22
- package/src/vendor/negentropy.js +0 -616
- package/tests/db/create-localstr.test.ts +0 -174
- package/tests/db/identity.test.ts +0 -33
- package/tests/main.test.ts +0 -9
- package/tests/schema/collection.test.ts +0 -27
- package/tests/schema/field.test.ts +0 -41
- package/tests/schema/validate.test.ts +0 -85
- package/tests/setup.ts +0 -1
- package/tests/storage/idb.test.ts +0 -144
- package/tests/storage/lww.test.ts +0 -33
- package/tests/sync/gift-wrap.test.ts +0 -56
- package/tsconfig.json +0 -18
- package/vitest.config.ts +0 -8
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { WhereClause, OrderByBuilder } from "../crud/query-builder.ts";
|
|
2
|
+
import { LiveQuery } from "./live-query.svelte.ts";
|
|
3
|
+
export type OnLiveCallback = (lq: LiveQuery<unknown>) => void;
|
|
4
|
+
export interface SvelteQueryBuilder<T> {
|
|
5
|
+
readonly and: (fn: (item: T) => boolean) => SvelteQueryBuilder<T>;
|
|
6
|
+
readonly sortBy: (field: string) => SvelteQueryBuilder<T>;
|
|
7
|
+
readonly reverse: () => SvelteQueryBuilder<T>;
|
|
8
|
+
readonly offset: (n: number) => SvelteQueryBuilder<T>;
|
|
9
|
+
readonly limit: (n: number) => SvelteQueryBuilder<T>;
|
|
10
|
+
readonly get: () => Promise<ReadonlyArray<T>>;
|
|
11
|
+
readonly first: () => Promise<T | null>;
|
|
12
|
+
readonly count: () => Promise<number>;
|
|
13
|
+
readonly live: () => LiveQuery<T>;
|
|
14
|
+
}
|
|
15
|
+
export interface SvelteWhereClause<T> {
|
|
16
|
+
readonly equals: (value: string | number | boolean) => SvelteQueryBuilder<T>;
|
|
17
|
+
readonly above: (value: number) => SvelteQueryBuilder<T>;
|
|
18
|
+
readonly aboveOrEqual: (value: number) => SvelteQueryBuilder<T>;
|
|
19
|
+
readonly below: (value: number) => SvelteQueryBuilder<T>;
|
|
20
|
+
readonly belowOrEqual: (value: number) => SvelteQueryBuilder<T>;
|
|
21
|
+
readonly between: (lower: number, upper: number, options?: {
|
|
22
|
+
includeLower?: boolean;
|
|
23
|
+
includeUpper?: boolean;
|
|
24
|
+
}) => SvelteQueryBuilder<T>;
|
|
25
|
+
readonly startsWith: (prefix: string) => SvelteQueryBuilder<T>;
|
|
26
|
+
readonly anyOf: (values: ReadonlyArray<string | number | boolean>) => SvelteQueryBuilder<T>;
|
|
27
|
+
readonly noneOf: (values: ReadonlyArray<string | number | boolean>) => SvelteQueryBuilder<T>;
|
|
28
|
+
}
|
|
29
|
+
export interface SvelteOrderByBuilder<T> {
|
|
30
|
+
readonly reverse: () => SvelteOrderByBuilder<T>;
|
|
31
|
+
readonly offset: (n: number) => SvelteOrderByBuilder<T>;
|
|
32
|
+
readonly limit: (n: number) => SvelteOrderByBuilder<T>;
|
|
33
|
+
readonly get: () => Promise<ReadonlyArray<T>>;
|
|
34
|
+
readonly first: () => Promise<T | null>;
|
|
35
|
+
readonly count: () => Promise<number>;
|
|
36
|
+
readonly live: () => LiveQuery<T>;
|
|
37
|
+
}
|
|
38
|
+
export declare function wrapWhereClause<T>(clause: WhereClause<T>, onLive?: OnLiveCallback): SvelteWhereClause<T>;
|
|
39
|
+
export declare function wrapOrderByBuilder<T>(builder: OrderByBuilder<T>, onLive?: OnLiveCallback): SvelteOrderByBuilder<T>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { type Rumor } from "nostr-tools/nip59";
|
|
3
|
+
import type { NostrEvent, UnsignedEvent } from "nostr-tools/pure";
|
|
4
|
+
import { CryptoError } from "../errors.ts";
|
|
5
|
+
export interface GiftWrapHandle {
|
|
6
|
+
readonly wrap: (rumor: Partial<UnsignedEvent>) => Effect.Effect<NostrEvent, CryptoError>;
|
|
7
|
+
readonly unwrap: (giftWrap: NostrEvent) => Effect.Effect<Rumor, CryptoError>;
|
|
8
|
+
}
|
|
9
|
+
export declare function createGiftWrapHandle(privateKey: Uint8Array, publicKey: string): GiftWrapHandle;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import type { IDBStorageHandle } from "../storage/idb.ts";
|
|
3
|
+
import type { RelayHandle } from "./relay.ts";
|
|
4
|
+
import { SyncError, RelayError, StorageError } from "../errors.ts";
|
|
5
|
+
export interface ReconcileResult {
|
|
6
|
+
readonly haveIds: string[];
|
|
7
|
+
readonly needIds: string[];
|
|
8
|
+
}
|
|
9
|
+
export declare function reconcileWithRelay(storage: IDBStorageHandle, relay: RelayHandle, relayUrl: string, publicKey: string): Effect.Effect<ReconcileResult, SyncError | RelayError | StorageError>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import type { IDBStorageHandle } from "../storage/idb.ts";
|
|
3
|
+
import type { RelayHandle } from "./relay.ts";
|
|
4
|
+
import type { RelayError, StorageError } from "../errors.ts";
|
|
5
|
+
export interface PublishQueueHandle {
|
|
6
|
+
readonly enqueue: (eventId: string) => Effect.Effect<void>;
|
|
7
|
+
readonly flush: (relayUrls: readonly string[]) => Effect.Effect<void, RelayError | StorageError>;
|
|
8
|
+
readonly size: () => Effect.Effect<number>;
|
|
9
|
+
}
|
|
10
|
+
export declare function createPublishQueue(storage: IDBStorageHandle, relay: RelayHandle): Effect.Effect<PublishQueueHandle>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import type { NostrEvent } from "nostr-tools/pure";
|
|
3
|
+
import type { Filter } from "nostr-tools/filter";
|
|
4
|
+
import { RelayError } from "../errors.ts";
|
|
5
|
+
export interface RelayHandle {
|
|
6
|
+
readonly publish: (event: NostrEvent, urls: readonly string[]) => Effect.Effect<void, RelayError>;
|
|
7
|
+
readonly fetchEvents: (ids: readonly string[], url: string) => Effect.Effect<NostrEvent[], RelayError>;
|
|
8
|
+
readonly fetchByFilter: (filter: Filter, url: string) => Effect.Effect<NostrEvent[], RelayError>;
|
|
9
|
+
readonly subscribe: (filter: Filter, url: string, onEvent: (event: NostrEvent) => void) => Effect.Effect<void, RelayError>;
|
|
10
|
+
readonly sendNegMsg: (url: string, subId: string, filter: Filter, msgHex: string) => Effect.Effect<{
|
|
11
|
+
msgHex: string | null;
|
|
12
|
+
haveIds: string[];
|
|
13
|
+
needIds: string[];
|
|
14
|
+
}, RelayError>;
|
|
15
|
+
readonly closeAll: () => Effect.Effect<void>;
|
|
16
|
+
}
|
|
17
|
+
export declare function createRelayHandle(): RelayHandle;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import type { IDBStorageHandle, StoredGiftWrap } from "../storage/idb.ts";
|
|
3
|
+
import type { GiftWrapHandle } from "./gift-wrap.ts";
|
|
4
|
+
import type { RelayHandle } from "./relay.ts";
|
|
5
|
+
import type { PublishQueueHandle } from "./publish-queue.ts";
|
|
6
|
+
import type { SyncStatusHandle } from "./sync-status.ts";
|
|
7
|
+
import type { WatchContext } from "../crud/watch.ts";
|
|
8
|
+
import { CryptoError, RelayError, StorageError, SyncError } from "../errors.ts";
|
|
9
|
+
export interface SyncHandle {
|
|
10
|
+
readonly sync: () => Effect.Effect<void, SyncError | RelayError | CryptoError | StorageError>;
|
|
11
|
+
readonly publishLocal: (giftWrap: StoredGiftWrap) => Effect.Effect<void>;
|
|
12
|
+
readonly startSubscription: () => Effect.Effect<void>;
|
|
13
|
+
}
|
|
14
|
+
export declare function createSyncHandle(storage: IDBStorageHandle, giftWrapHandle: GiftWrapHandle, relay: RelayHandle, publishQueue: PublishQueueHandle, syncStatus: SyncStatusHandle, watchCtx: WatchContext, relayUrls: readonly string[], publicKey: string, onSyncError?: ((error: unknown) => void) | undefined): SyncHandle;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import type { SyncStatus } from "../db/database-handle.ts";
|
|
3
|
+
export interface SyncStatusHandle {
|
|
4
|
+
readonly get: () => Effect.Effect<SyncStatus>;
|
|
5
|
+
readonly set: (status: SyncStatus) => Effect.Effect<void>;
|
|
6
|
+
}
|
|
7
|
+
export declare function createSyncStatusHandle(): Effect.Effect<SyncStatusHandle>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tablinum",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/kevmodrome/tablinum.git"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
4
11
|
"type": "module",
|
|
12
|
+
"main": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"import": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./svelte": {
|
|
20
|
+
"types": "./dist/svelte/index.svelte.d.ts",
|
|
21
|
+
"svelte": "./dist/svelte/index.svelte.js",
|
|
22
|
+
"import": "./dist/svelte/index.svelte.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
5
25
|
"scripts": {
|
|
6
26
|
"dev": "bun run src/main.ts",
|
|
7
27
|
"lint": "oxlint",
|
|
@@ -12,6 +32,7 @@
|
|
|
12
32
|
"validate": "bun run scripts/validate.ts",
|
|
13
33
|
"demo": "bun run examples/vanilla/serve.ts",
|
|
14
34
|
"demo:svelte": "cd examples/svelte && bun run dev",
|
|
35
|
+
"build": "bun build src/index.ts --outdir dist --format esm --packages external && bun build src/svelte/index.svelte.ts --outdir dist/svelte --format esm --packages external && tsc -p tsconfig.build.json --noCheck && tsc -p tsconfig.build.svelte.json --noCheck",
|
|
15
36
|
"changeset": "changeset",
|
|
16
37
|
"version": "changeset version",
|
|
17
38
|
"release": "changeset publish"
|
package/.changeset/README.md
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
# Changesets
|
|
2
|
-
|
|
3
|
-
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
|
|
4
|
-
with multi-package repos, or single-package repos to help you version and publish your code. You can
|
|
5
|
-
find the full documentation for it [in our repository](https://github.com/changesets/changesets).
|
|
6
|
-
|
|
7
|
-
We have a quick list of common questions to get you started engaging with this project in
|
|
8
|
-
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md).
|
package/.changeset/config.json
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://unpkg.com/@changesets/config@3.1.3/schema.json",
|
|
3
|
-
"changelog": "@changesets/cli/changelog",
|
|
4
|
-
"commit": false,
|
|
5
|
-
"fixed": [],
|
|
6
|
-
"linked": [],
|
|
7
|
-
"access": "public",
|
|
8
|
-
"baseBranch": "main",
|
|
9
|
-
"updateInternalDependencies": "patch",
|
|
10
|
-
"ignore": []
|
|
11
|
-
}
|