@fireproof/core-types-base 0.0.2-dev-test → 0.22.0-keybag

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/key-bag-if.d.ts CHANGED
@@ -6,6 +6,5 @@ export interface KeyBagIf {
6
6
  readonly rt: KeyBagRuntime;
7
7
  subtleKey(materialStrOrUint8: string | Uint8Array): Promise<CryptoKey>;
8
8
  ensureKeyFromUrl(url: URI, keyFactory: () => string): Promise<Result<URI>>;
9
- flush(): Promise<void>;
10
9
  getNamedKey(name: string, failIfNotFound?: boolean, material?: string | Uint8Array): Promise<Result<KeysByFingerprint>>;
11
10
  }
package/key-bag-if.ts CHANGED
@@ -9,7 +9,7 @@ export interface KeyBagIf {
9
9
  subtleKey(materialStrOrUint8: string | Uint8Array): Promise<CryptoKey>;
10
10
 
11
11
  ensureKeyFromUrl(url: URI, keyFactory: () => string): Promise<Result<URI>>;
12
- flush(): Promise<void>;
12
+ // flush(): Promise<void>;
13
13
 
14
14
  getNamedKey(name: string, failIfNotFound?: boolean, material?: string | Uint8Array): Promise<Result<KeysByFingerprint>>;
15
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fireproof/core-types-base",
3
- "version": "0.0.2-dev-test",
3
+ "version": "0.22.0-keybag",
4
4
  "description": "Live ledger for the web.",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -20,7 +20,7 @@
20
20
  "Meno Abels"
21
21
  ],
22
22
  "author": "J Chris Anderson",
23
- "license": "Apache-2.0 OR MIT",
23
+ "license": "AFL-2.0",
24
24
  "homepage": "https://use-fireproof.com",
25
25
  "gptdoc": "import { fireproof } from 'use-fireproof'; const db = fireproof('app-db-name'); const ok = await db.put({ anyField: ['any','json'] }); const doc = await db.get(ok.id); await db.del(doc._id); db.subscribe(myRedrawFn); const result = await db.query('anyField', {range : ['a', 'z']}); result.rows.map(({ key }) => key);",
26
26
  "repository": {
@@ -32,11 +32,11 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@adviser/cement": "^0.4.20",
35
- "@fireproof/core-types-blockstore": "0.0.2-dev-test",
35
+ "@fireproof/core-types-blockstore": "0.22.0-keybag",
36
36
  "@web3-storage/pail": "^0.6.2",
37
37
  "multiformats": "^13.3.7",
38
38
  "prolly-trees": "^1.0.4",
39
- "@fireproof/vendor": "0.0.2-dev-test"
39
+ "@fireproof/vendor": "0.22.0-keybag"
40
40
  },
41
41
  "scripts": {
42
42
  "build": "tsc"
package/types.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import type { EventLink } from "@web3-storage/pail/clock/api";
2
2
  import type { Operation } from "@web3-storage/pail/crdt/api";
3
3
  import type { Block } from "multiformats";
4
- import { EnvFactoryOpts, Env, Logger, CryptoRuntime, Result, CoerceURI, AppContext, URI } from "@adviser/cement";
5
- import type { DbMeta, AnyLink, StoreUrlsOpts, StoreEnDeFile, Loadable, TransactionMeta, TransactionWrapper, BlockstoreRuntime, StoreURIRuntime, DataAndMetaAndWalStore, UrlAndInterceptor, MetaStore, WALStore, BaseStore, FileStore, CarStore, FPBlock } from "@fireproof/core-types-blockstore";
4
+ import { EnvFactoryOpts, Env, Logger, CryptoRuntime, Result, CoerceURI, AppContext, URI, CTCryptoKey } from "@adviser/cement";
5
+ import type { DbMeta, AnyLink, StoreUrlsOpts, StoreEnDeFile, Loadable, TransactionWrapper, BlockstoreRuntime, StoreURIRuntime, DataAndMetaAndWalStore, UrlAndInterceptor, MetaStore, WALStore, BaseStore, FileStore, CarStore, FPBlock, BlockFetcher } from "@fireproof/core-types-blockstore";
6
6
  import type { IndexIf } from "./indexer.js";
7
7
  import { SerdeGatewayInterceptor } from "@fireproof/core-types-blockstore";
8
8
  export declare class NotFoundError extends Error {
@@ -135,6 +135,7 @@ export interface ConfigOpts extends Partial<SuperThisOpts> {
135
135
  readonly writeQueue?: Partial<WriteQueueParams>;
136
136
  readonly gatewayInterceptor?: SerdeGatewayInterceptor;
137
137
  readonly autoCompact?: number;
138
+ readonly compactStrategy?: string;
138
139
  readonly storeUrls?: StoreUrlsOpts;
139
140
  readonly storeEnDe?: StoreEnDeFile;
140
141
  readonly threshold?: number;
@@ -439,10 +440,26 @@ export type TraceFn = (traceEvent: TraceEvent) => void;
439
440
  export interface Tracer {
440
441
  readonly tracer: TraceFn;
441
442
  }
443
+ export type TransactionMeta = unknown;
444
+ export interface CompactStrategyContext extends BlockFetcher {
445
+ readonly transactions: Set<CarTransaction>;
446
+ readonly clock?: CRDTClock;
447
+ readonly lastTxMeta: TransactionMeta;
448
+ readonly loader: Loadable;
449
+ readonly logger: Logger;
450
+ readonly blockstore: BlockFetcher;
451
+ readonly loggedBlocks: CarTransaction;
452
+ get(cid: AnyLink): Promise<FPBlock | Falsy>;
453
+ }
454
+ export interface CompactStrategy {
455
+ readonly name: string;
456
+ compact(block: CompactStrategyContext): Promise<TransactionMeta>;
457
+ }
442
458
  export interface LedgerOpts extends Tracer {
443
459
  readonly name: string;
444
460
  readonly meta?: DbMeta;
445
461
  readonly gatewayInterceptor?: SerdeGatewayInterceptor;
462
+ readonly compactStrategy?: string;
446
463
  readonly ctx: AppContext;
447
464
  readonly writeQueue: WriteQueueParams;
448
465
  readonly storeUrls: StoreURIRuntime;
@@ -474,13 +491,44 @@ export interface V2StorageKeyItem {
474
491
  readonly fingerPrint: string;
475
492
  readonly default: boolean;
476
493
  }
477
- export interface KeysItem {
494
+ export interface V2KeysItem {
478
495
  readonly name: string;
479
496
  readonly keys: Record<string, V2StorageKeyItem>;
480
497
  }
498
+ export interface KeyMaterial {
499
+ readonly key: Uint8Array;
500
+ readonly keyStr: string;
501
+ }
502
+ export interface KeyWithFingerPrint {
503
+ readonly default: boolean;
504
+ readonly fingerPrint: string;
505
+ readonly key: CTCryptoKey;
506
+ extract(): Promise<KeyMaterial>;
507
+ asV2StorageKeyItem(): Promise<V2StorageKeyItem>;
508
+ }
509
+ export interface KeyUpsertResultModified {
510
+ readonly modified: true;
511
+ readonly kfp: KeyWithFingerPrint;
512
+ }
513
+ export declare function isKeyUpsertResultModified(r: KeyUpsertResult): r is KeyUpsertResultModified;
514
+ export interface KeyUpsertResultNotModified {
515
+ readonly modified: false;
516
+ }
517
+ export type KeyUpsertResult = KeyUpsertResultModified | KeyUpsertResultNotModified;
518
+ export interface KeysByFingerprint {
519
+ readonly id: string;
520
+ readonly name: string;
521
+ get(fingerPrint?: string | Uint8Array): Promise<KeyWithFingerPrint | undefined>;
522
+ upsert(key: string | Uint8Array, def?: boolean): Promise<Result<KeyUpsertResult>>;
523
+ asV2KeysItem(): Promise<V2KeysItem>;
524
+ }
525
+ export interface KeysItem {
526
+ readonly name: string;
527
+ readonly keys: Record<string, KeyWithFingerPrint>;
528
+ }
481
529
  export interface KeyBagProvider {
482
- get(id: string): Promise<V1StorageKeyItem | KeysItem | undefined>;
483
- set(item: KeysItem): Promise<void>;
530
+ get(id: string): Promise<V1StorageKeyItem | V2KeysItem | undefined>;
531
+ set(item: V2KeysItem): Promise<void>;
484
532
  del(id: string): Promise<void>;
485
533
  }
486
534
  export interface KeyBagRuntime {
package/types.js CHANGED
@@ -66,6 +66,9 @@ export class DataAndMetaAndWalAndBaseStore {
66
66
  }
67
67
  }
68
68
  }
69
+ export function isKeyUpsertResultModified(r) {
70
+ return r.modified;
71
+ }
69
72
  export function defaultWriteQueueOpts(opts = {}) {
70
73
  return {
71
74
  ...opts,
package/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"AAGA,OAAO,EAA8C,MAAM,EAA8B,MAAM,iBAAiB,CAAC;AAyBjH,MAAM,OAAO,aAAc,SAAQ,KAAK;IAC7B,IAAI,GAAG,QAAQ,CAAC;CAC1B;AAMD,MAAM,UAAU,OAAO,CAAC,KAAc;IACpC,OAAO,KAAK,KAAK,KAAK,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC;AAClE,CAAC;AAED,MAAM,CAAC,M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,CAAC;QAC3B,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;IACd,CAAC;IACD,IAAK,CAAmB,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACxD,OAAO,KAAK,CAAC;AACf,CAAC"}
package/types.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { EventLink } from "@web3-storage/pail/clock/api";
2
2
  import type { Operation } from "@web3-storage/pail/crdt/api";
3
3
  import type { Block } from "multiformats";
4
- import { EnvFactoryOpts, Env, Logger, CryptoRuntime, Result, CoerceURI, AppContext, URI } from "@adviser/cement";
4
+ import { EnvFactoryOpts, Env, Logger, CryptoRuntime, Result, CoerceURI, AppContext, URI, CTCryptoKey } from "@adviser/cement";
5
5
 
6
6
  import type {
7
7
  DbMeta,
@@ -9,7 +9,6 @@ import type {
9
9
  StoreUrlsOpts,
10
10
  StoreEnDeFile,
11
11
  Loadable,
12
- TransactionMeta,
13
12
  TransactionWrapper,
14
13
  BlockstoreRuntime,
15
14
  StoreURIRuntime,
@@ -21,6 +20,7 @@ import type {
21
20
  FileStore,
22
21
  CarStore,
23
22
  FPBlock,
23
+ BlockFetcher,
24
24
  } from "@fireproof/core-types-blockstore";
25
25
 
26
26
  import type { IndexIf } from "./indexer.js";
@@ -183,6 +183,8 @@ export interface ConfigOpts extends Partial<SuperThisOpts> {
183
183
  readonly writeQueue?: Partial<WriteQueueParams>;
184
184
  readonly gatewayInterceptor?: SerdeGatewayInterceptor;
185
185
  readonly autoCompact?: number;
186
+ // could be registered with registerCompactStrategy(name: string, compactStrategy: CompactStrategy)
187
+ readonly compactStrategy?: string; // default "FULL" other "fireproof" , "no-op"
186
188
  readonly storeUrls?: StoreUrlsOpts;
187
189
  readonly storeEnDe?: StoreEnDeFile;
188
190
  readonly threshold?: number;
@@ -635,12 +637,34 @@ export interface Tracer {
635
637
  readonly tracer: TraceFn;
636
638
  }
637
639
 
640
+ export type TransactionMeta = unknown;
641
+ export interface CompactStrategyContext extends BlockFetcher {
642
+ readonly transactions: Set<CarTransaction>;
643
+ readonly clock?: CRDTClock;
644
+ readonly lastTxMeta: TransactionMeta;
645
+ readonly loader: Loadable;
646
+ readonly logger: Logger;
647
+ readonly blockstore: BlockFetcher;
648
+ // loader: Loader | null = null
649
+ readonly loggedBlocks: CarTransaction;
650
+
651
+ get(cid: AnyLink): Promise<FPBlock | Falsy>;
652
+ }
653
+
654
+ export interface CompactStrategy {
655
+ readonly name: string;
656
+ compact(block: CompactStrategyContext): Promise<TransactionMeta>;
657
+ }
658
+
638
659
  export interface LedgerOpts extends Tracer {
639
660
  readonly name: string;
640
661
  // readonly public?: boolean;
641
662
  readonly meta?: DbMeta;
642
663
  readonly gatewayInterceptor?: SerdeGatewayInterceptor;
643
664
 
665
+ // could be registered with registerCompactStrategy(name: string, compactStrategy: CompactStrategy)
666
+ readonly compactStrategy?: string; // default "FULL"
667
+
644
668
  readonly ctx: AppContext;
645
669
  readonly writeQueue: WriteQueueParams;
646
670
  readonly storeUrls: StoreURIRuntime;
@@ -710,14 +734,57 @@ export interface V2StorageKeyItem {
710
734
  readonly fingerPrint: string;
711
735
  readonly default: boolean;
712
736
  }
713
- export interface KeysItem {
737
+
738
+ // Serialized Version
739
+ export interface V2KeysItem {
714
740
  readonly name: string;
715
741
  readonly keys: Record<string, V2StorageKeyItem>;
716
742
  }
717
743
 
744
+ export interface KeyMaterial {
745
+ readonly key: Uint8Array;
746
+ readonly keyStr: string;
747
+ }
748
+
749
+ export interface KeyWithFingerPrint {
750
+ readonly default: boolean;
751
+ readonly fingerPrint: string;
752
+ readonly key: CTCryptoKey;
753
+ extract(): Promise<KeyMaterial>;
754
+ asV2StorageKeyItem(): Promise<V2StorageKeyItem>;
755
+ }
756
+
757
+ export interface KeyUpsertResultModified {
758
+ readonly modified: true;
759
+ readonly kfp: KeyWithFingerPrint;
760
+ }
761
+
762
+ export function isKeyUpsertResultModified(r: KeyUpsertResult): r is KeyUpsertResultModified {
763
+ return r.modified;
764
+ }
765
+
766
+ export interface KeyUpsertResultNotModified {
767
+ readonly modified: false;
768
+ }
769
+
770
+ export type KeyUpsertResult = KeyUpsertResultModified | KeyUpsertResultNotModified;
771
+
772
+ export interface KeysByFingerprint {
773
+ readonly id: string;
774
+ readonly name: string;
775
+ get(fingerPrint?: string | Uint8Array): Promise<KeyWithFingerPrint | undefined>;
776
+ upsert(key: string | Uint8Array, def?: boolean): Promise<Result<KeyUpsertResult>>;
777
+ asV2KeysItem(): Promise<V2KeysItem>;
778
+ }
779
+
780
+ export interface KeysItem {
781
+ readonly name: string;
782
+ readonly keys: Record<string, KeyWithFingerPrint>;
783
+ }
784
+
718
785
  export interface KeyBagProvider {
719
- get(id: string): Promise<V1StorageKeyItem | KeysItem | undefined>;
720
- set(item: KeysItem): Promise<void>;
786
+ get(id: string): Promise<V1StorageKeyItem | V2KeysItem | undefined>;
787
+ set(item: V2KeysItem): Promise<void>;
721
788
  del(id: string): Promise<void>;
722
789
  }
723
790