tablinum 0.6.1 → 0.6.3
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/dist/index.js +24 -7
- package/dist/schema/field.d.ts +10 -1
- package/dist/schema/types.d.ts +15 -3
- package/dist/svelte/index.svelte.js +24 -7
- package/package.json +6 -3
package/dist/index.js
CHANGED
|
@@ -2082,23 +2082,40 @@ var EpochStoreLive = Layer3.effect(
|
|
|
2082
2082
|
const config = yield* Config;
|
|
2083
2083
|
const identity = yield* Identity;
|
|
2084
2084
|
const storage = yield* Storage;
|
|
2085
|
+
let idbStore;
|
|
2085
2086
|
const idbRaw = yield* storage.getMeta("epochs");
|
|
2086
2087
|
if (typeof idbRaw === "string") {
|
|
2087
|
-
const
|
|
2088
|
-
if (Option7.isSome(
|
|
2089
|
-
|
|
2090
|
-
source: "storage",
|
|
2091
|
-
epochs: idbStore.value.epochs.size
|
|
2092
|
-
});
|
|
2093
|
-
return idbStore.value;
|
|
2088
|
+
const parsed = deserializeEpochStore(idbRaw);
|
|
2089
|
+
if (Option7.isSome(parsed)) {
|
|
2090
|
+
idbStore = parsed.value;
|
|
2094
2091
|
}
|
|
2095
2092
|
}
|
|
2096
2093
|
if (config.epochKeys && config.epochKeys.length > 0) {
|
|
2094
|
+
if (idbStore) {
|
|
2095
|
+
const configIsSubset = config.epochKeys.every((ek) => {
|
|
2096
|
+
const existing = idbStore.epochs.get(ek.epochId);
|
|
2097
|
+
return existing !== void 0 && existing.privateKey === ek.key;
|
|
2098
|
+
});
|
|
2099
|
+
if (configIsSubset) {
|
|
2100
|
+
yield* Effect12.logInfo("Epoch store loaded", {
|
|
2101
|
+
source: "storage",
|
|
2102
|
+
epochs: idbStore.epochs.size
|
|
2103
|
+
});
|
|
2104
|
+
return idbStore;
|
|
2105
|
+
}
|
|
2106
|
+
}
|
|
2097
2107
|
const store2 = createEpochStoreFromInputs(config.epochKeys);
|
|
2098
2108
|
yield* storage.putMeta("epochs", stringifyEpochStore(store2));
|
|
2099
2109
|
yield* Effect12.logInfo("Epoch store loaded", { source: "config", epochs: store2.epochs.size });
|
|
2100
2110
|
return store2;
|
|
2101
2111
|
}
|
|
2112
|
+
if (idbStore) {
|
|
2113
|
+
yield* Effect12.logInfo("Epoch store loaded", {
|
|
2114
|
+
source: "storage",
|
|
2115
|
+
epochs: idbStore.epochs.size
|
|
2116
|
+
});
|
|
2117
|
+
return idbStore;
|
|
2118
|
+
}
|
|
2102
2119
|
const store = createEpochStoreFromInputs(
|
|
2103
2120
|
[{ epochId: EpochId("epoch-0"), key: bytesToHex3(generateSecretKey2()) }],
|
|
2104
2121
|
{ createdBy: identity.publicKey }
|
package/dist/schema/field.d.ts
CHANGED
|
@@ -7,8 +7,17 @@ export interface FieldDef<out T = unknown> {
|
|
|
7
7
|
readonly fields?: Record<string, FieldDef<unknown>>;
|
|
8
8
|
readonly _T?: T;
|
|
9
9
|
}
|
|
10
|
+
type LocalInferFieldType<F> = F extends FieldDef<infer T> ? T : never;
|
|
11
|
+
type RequiredFieldKeys<F extends Record<string, FieldDef<unknown>>> = {
|
|
12
|
+
[K in keyof F]: undefined extends LocalInferFieldType<F[K]> ? never : K;
|
|
13
|
+
}[keyof F];
|
|
14
|
+
type OptionalFieldKeys<F extends Record<string, FieldDef<unknown>>> = {
|
|
15
|
+
[K in keyof F]: undefined extends LocalInferFieldType<F[K]> ? K : never;
|
|
16
|
+
}[keyof F];
|
|
10
17
|
type InferFields<F extends Record<string, FieldDef<unknown>>> = {
|
|
11
|
-
readonly [K in
|
|
18
|
+
readonly [K in RequiredFieldKeys<F>]: F[K] extends FieldDef<infer T> ? T : never;
|
|
19
|
+
} & {
|
|
20
|
+
readonly [K in OptionalFieldKeys<F>]?: F[K] extends FieldDef<infer T> ? T : never;
|
|
12
21
|
};
|
|
13
22
|
export declare const field: {
|
|
14
23
|
string: () => FieldDef<string>;
|
package/dist/schema/types.d.ts
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
import type { CollectionDef, CollectionFields } from "./collection.ts";
|
|
2
2
|
import type { FieldDef } from "./field.ts";
|
|
3
3
|
export type InferFieldType<F> = F extends FieldDef<infer T> ? T : never;
|
|
4
|
-
|
|
4
|
+
type RequiredKeys<F> = {
|
|
5
|
+
[K in keyof F]: undefined extends InferFieldType<F[K]> ? never : K;
|
|
6
|
+
}[keyof F];
|
|
7
|
+
type OptionalKeys<F> = {
|
|
8
|
+
[K in keyof F]: undefined extends InferFieldType<F[K]> ? K : never;
|
|
9
|
+
}[keyof F];
|
|
10
|
+
type Prettify<T> = {
|
|
11
|
+
[K in keyof T]: T[K];
|
|
12
|
+
} & {};
|
|
13
|
+
export type InferRecord<C> = C extends CollectionDef<infer F> ? Prettify<{
|
|
5
14
|
readonly id: string;
|
|
6
15
|
} & {
|
|
7
|
-
readonly [K in
|
|
8
|
-
}
|
|
16
|
+
readonly [K in RequiredKeys<F>]: InferFieldType<F[K]>;
|
|
17
|
+
} & {
|
|
18
|
+
readonly [K in OptionalKeys<F>]?: InferFieldType<F[K]>;
|
|
19
|
+
}> : never;
|
|
9
20
|
export type SchemaConfig = Record<string, CollectionDef<CollectionFields>>;
|
|
10
21
|
export type IndexedFields<C> = C extends CollectionDef<infer _F> ? C["indices"][number] : never;
|
|
22
|
+
export {};
|
|
@@ -2119,23 +2119,40 @@ var EpochStoreLive = Layer3.effect(
|
|
|
2119
2119
|
const config = yield* Config;
|
|
2120
2120
|
const identity = yield* Identity;
|
|
2121
2121
|
const storage = yield* Storage;
|
|
2122
|
+
let idbStore;
|
|
2122
2123
|
const idbRaw = yield* storage.getMeta("epochs");
|
|
2123
2124
|
if (typeof idbRaw === "string") {
|
|
2124
|
-
const
|
|
2125
|
-
if (Option7.isSome(
|
|
2126
|
-
|
|
2127
|
-
source: "storage",
|
|
2128
|
-
epochs: idbStore.value.epochs.size
|
|
2129
|
-
});
|
|
2130
|
-
return idbStore.value;
|
|
2125
|
+
const parsed = deserializeEpochStore(idbRaw);
|
|
2126
|
+
if (Option7.isSome(parsed)) {
|
|
2127
|
+
idbStore = parsed.value;
|
|
2131
2128
|
}
|
|
2132
2129
|
}
|
|
2133
2130
|
if (config.epochKeys && config.epochKeys.length > 0) {
|
|
2131
|
+
if (idbStore) {
|
|
2132
|
+
const configIsSubset = config.epochKeys.every((ek) => {
|
|
2133
|
+
const existing = idbStore.epochs.get(ek.epochId);
|
|
2134
|
+
return existing !== void 0 && existing.privateKey === ek.key;
|
|
2135
|
+
});
|
|
2136
|
+
if (configIsSubset) {
|
|
2137
|
+
yield* Effect12.logInfo("Epoch store loaded", {
|
|
2138
|
+
source: "storage",
|
|
2139
|
+
epochs: idbStore.epochs.size
|
|
2140
|
+
});
|
|
2141
|
+
return idbStore;
|
|
2142
|
+
}
|
|
2143
|
+
}
|
|
2134
2144
|
const store2 = createEpochStoreFromInputs(config.epochKeys);
|
|
2135
2145
|
yield* storage.putMeta("epochs", stringifyEpochStore(store2));
|
|
2136
2146
|
yield* Effect12.logInfo("Epoch store loaded", { source: "config", epochs: store2.epochs.size });
|
|
2137
2147
|
return store2;
|
|
2138
2148
|
}
|
|
2149
|
+
if (idbStore) {
|
|
2150
|
+
yield* Effect12.logInfo("Epoch store loaded", {
|
|
2151
|
+
source: "storage",
|
|
2152
|
+
epochs: idbStore.epochs.size
|
|
2153
|
+
});
|
|
2154
|
+
return idbStore;
|
|
2155
|
+
}
|
|
2139
2156
|
const store = createEpochStoreFromInputs(
|
|
2140
2157
|
[{ epochId: EpochId("epoch-0"), key: bytesToHex3(generateSecretKey2()) }],
|
|
2141
2158
|
{ createdBy: identity.publicKey }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tablinum",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/kevmodrome/tablinum.git",
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
27
|
"dev": "npx tsx src/main.ts",
|
|
28
|
-
"build": "esbuild src/index.ts --outdir=dist --format=esm --bundle --packages=external && esbuild src/svelte/index.svelte.ts --outdir=dist/svelte --format=esm --bundle --packages=external && tsc -p tsconfig.build.json --noCheck && tsc -p tsconfig.build.svelte.json --noCheck"
|
|
28
|
+
"build": "esbuild src/index.ts --outdir=dist --format=esm --bundle --packages=external && esbuild src/svelte/index.svelte.ts --outdir=dist/svelte --format=esm --bundle --packages=external && tsc -p tsconfig.build.json --noCheck && tsc -p tsconfig.build.svelte.json --noCheck",
|
|
29
|
+
"check": "svelte-check --tsconfig ./tsconfig.json"
|
|
29
30
|
},
|
|
30
31
|
"dependencies": {
|
|
31
32
|
"@noble/curves": "^2.0.1",
|
|
@@ -38,7 +39,9 @@
|
|
|
38
39
|
"@effect/vitest": "4.0.0-beta.31",
|
|
39
40
|
"esbuild": "^0.24.0",
|
|
40
41
|
"fake-indexeddb": "^6.2.5",
|
|
41
|
-
"svelte": "^5.53.10"
|
|
42
|
+
"svelte": "^5.53.10",
|
|
43
|
+
"svelte-check": "^4.4.5",
|
|
44
|
+
"typescript": "^5.9.3"
|
|
42
45
|
},
|
|
43
46
|
"peerDependencies": {
|
|
44
47
|
"svelte": "^5.0.0"
|