@fireproof/core 0.20.0-dev-preview-26 → 0.20.0-dev-preview-28
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/index.cjs +19 -26
- package/index.cjs.map +1 -1
- package/index.d.cts +4 -4
- package/index.d.ts +4 -4
- package/index.js +19 -26
- package/index.js.map +1 -1
- package/metafile-cjs.json +1 -1
- package/metafile-esm.json +1 -1
- package/package.json +1 -1
- package/tests/fireproof/crdt.test.ts +9 -0
- package/tests/fireproof/database.test.ts +12 -12
- package/tests/fireproof/fireproof.test.ts +44 -0
- package/tests/fireproof/indexer.test.ts +1 -0
package/index.d.cts
CHANGED
@@ -1361,7 +1361,7 @@ interface WriteQueue<T extends DocUpdate<S>, S extends DocTypes = DocTypes> {
|
|
1361
1361
|
close(): Promise<void>;
|
1362
1362
|
}
|
1363
1363
|
interface LedgerOpts {
|
1364
|
-
readonly name
|
1364
|
+
readonly name: string;
|
1365
1365
|
readonly meta?: DbMeta;
|
1366
1366
|
readonly gatewayInterceptor?: SerdeGatewayInterceptor;
|
1367
1367
|
readonly writeQueue: WriteQueueParams;
|
@@ -1384,9 +1384,9 @@ interface Ledger extends HasCRDT {
|
|
1384
1384
|
subscribe<T extends DocTypes>(listener: ListenerFn<T>, updates?: boolean): () => void;
|
1385
1385
|
}
|
1386
1386
|
|
1387
|
-
declare function keyConfigOpts(sthis: SuperThis, name
|
1387
|
+
declare function keyConfigOpts(sthis: SuperThis, name: string, opts?: ConfigOpts): string;
|
1388
1388
|
declare function isLedger(db: unknown): db is Ledger;
|
1389
|
-
declare function LedgerFactory(name: string
|
1389
|
+
declare function LedgerFactory(name: string, opts?: ConfigOpts): Ledger;
|
1390
1390
|
declare class LedgerShell implements Ledger {
|
1391
1391
|
readonly ref: LedgerImpl;
|
1392
1392
|
readonly writeQueue: WriteQueue<DocUpdate<DocTypes>>;
|
@@ -1430,7 +1430,7 @@ declare class LedgerImpl implements Ledger {
|
|
1430
1430
|
private _notify;
|
1431
1431
|
private _no_update_notify;
|
1432
1432
|
}
|
1433
|
-
declare function toStoreURIRuntime(sthis: SuperThis, name
|
1433
|
+
declare function toStoreURIRuntime(sthis: SuperThis, name: string, sopts?: StoreUrlsOpts): StoreURIRuntime;
|
1434
1434
|
declare function fireproof(name: string, opts?: ConfigOpts): Database;
|
1435
1435
|
|
1436
1436
|
declare function isDatabase(db: unknown): db is Database;
|
package/index.d.ts
CHANGED
@@ -1361,7 +1361,7 @@ interface WriteQueue<T extends DocUpdate<S>, S extends DocTypes = DocTypes> {
|
|
1361
1361
|
close(): Promise<void>;
|
1362
1362
|
}
|
1363
1363
|
interface LedgerOpts {
|
1364
|
-
readonly name
|
1364
|
+
readonly name: string;
|
1365
1365
|
readonly meta?: DbMeta;
|
1366
1366
|
readonly gatewayInterceptor?: SerdeGatewayInterceptor;
|
1367
1367
|
readonly writeQueue: WriteQueueParams;
|
@@ -1384,9 +1384,9 @@ interface Ledger extends HasCRDT {
|
|
1384
1384
|
subscribe<T extends DocTypes>(listener: ListenerFn<T>, updates?: boolean): () => void;
|
1385
1385
|
}
|
1386
1386
|
|
1387
|
-
declare function keyConfigOpts(sthis: SuperThis, name
|
1387
|
+
declare function keyConfigOpts(sthis: SuperThis, name: string, opts?: ConfigOpts): string;
|
1388
1388
|
declare function isLedger(db: unknown): db is Ledger;
|
1389
|
-
declare function LedgerFactory(name: string
|
1389
|
+
declare function LedgerFactory(name: string, opts?: ConfigOpts): Ledger;
|
1390
1390
|
declare class LedgerShell implements Ledger {
|
1391
1391
|
readonly ref: LedgerImpl;
|
1392
1392
|
readonly writeQueue: WriteQueue<DocUpdate<DocTypes>>;
|
@@ -1430,7 +1430,7 @@ declare class LedgerImpl implements Ledger {
|
|
1430
1430
|
private _notify;
|
1431
1431
|
private _no_update_notify;
|
1432
1432
|
}
|
1433
|
-
declare function toStoreURIRuntime(sthis: SuperThis, name
|
1433
|
+
declare function toStoreURIRuntime(sthis: SuperThis, name: string, sopts?: StoreUrlsOpts): StoreURIRuntime;
|
1434
1434
|
declare function fireproof(name: string, opts?: ConfigOpts): Database;
|
1435
1435
|
|
1436
1436
|
declare function isDatabase(db: unknown): db is Database;
|
package/index.js
CHANGED
@@ -589,7 +589,7 @@ var KeyBagProviderFile = class {
|
|
589
589
|
if (isNotFoundError(e)) {
|
590
590
|
return void 0;
|
591
591
|
}
|
592
|
-
throw this.logger.Error().Err(e).
|
592
|
+
throw this.logger.Error().Err(e).Any("file", ctx).Msg("read bag failed").AsError();
|
593
593
|
}
|
594
594
|
}
|
595
595
|
async set(item) {
|
@@ -720,7 +720,7 @@ var keysByFingerprint = class _keysByFingerprint {
|
|
720
720
|
if (found) {
|
721
721
|
return found;
|
722
722
|
}
|
723
|
-
throw this.keybag.logger.Error().Msg("
|
723
|
+
throw this.keybag.logger.Error().Str("fpr", fingerPrint).Any("fprs", Object.keys(this.keys)).Msg("keysByFingerprint: not found").AsError();
|
724
724
|
}
|
725
725
|
async upsert(materialStrOrUint8, def, keyBagAction = true) {
|
726
726
|
def = !!def;
|
@@ -837,7 +837,7 @@ var KeyBag = class {
|
|
837
837
|
const keyName = `@${keyFactory()}@`;
|
838
838
|
const ret = await this.getNamedKey(keyName);
|
839
839
|
if (ret.isErr()) {
|
840
|
-
return ret;
|
840
|
+
return Result2.Err(ret);
|
841
841
|
}
|
842
842
|
const urb = url.build().setParam(PARAM.STORE_KEY, keyName);
|
843
843
|
return Result2.Ok(urb.URI());
|
@@ -845,7 +845,7 @@ var KeyBag = class {
|
|
845
845
|
if (storeKey.startsWith("@") && storeKey.endsWith("@")) {
|
846
846
|
const ret = await this.getNamedKey(storeKey);
|
847
847
|
if (ret.isErr()) {
|
848
|
-
return ret;
|
848
|
+
return Result2.Err(ret);
|
849
849
|
}
|
850
850
|
}
|
851
851
|
return Result2.Ok(url);
|
@@ -1209,6 +1209,7 @@ var MEMORY_VERSION = "v0.19-memory";
|
|
1209
1209
|
|
1210
1210
|
// src/runtime/gateways/memory/gateway.ts
|
1211
1211
|
var MemoryGateway = class {
|
1212
|
+
// readonly logger: Logger;
|
1212
1213
|
constructor(sthis, memorys) {
|
1213
1214
|
this.memorys = memorys;
|
1214
1215
|
this.sthis = sthis;
|
@@ -4704,7 +4705,7 @@ var LedgerImpl = class {
|
|
4704
4705
|
this.crdt.clock.onTock(() => this._no_update_notify());
|
4705
4706
|
}
|
4706
4707
|
get name() {
|
4707
|
-
return this.opts.
|
4708
|
+
return this.opts.name;
|
4708
4709
|
}
|
4709
4710
|
addShell(shell) {
|
4710
4711
|
this.shells.add(shell);
|
@@ -4788,15 +4789,11 @@ var LedgerImpl = class {
|
|
4788
4789
|
}
|
4789
4790
|
}
|
4790
4791
|
};
|
4791
|
-
function defaultURI2(sthis, curi, uri, store, ctx) {
|
4792
|
+
function defaultURI2(sthis, name, curi, uri, store, ctx) {
|
4792
4793
|
ctx = ctx || {};
|
4793
|
-
const ret = (curi ? URI13.from(curi) : uri).build().setParam(PARAM.STORE, store);
|
4794
|
+
const ret = (curi ? URI13.from(curi) : uri).build().setParam(PARAM.STORE, store).defParam(PARAM.NAME, name);
|
4794
4795
|
if (!ret.hasParam(PARAM.NAME)) {
|
4795
|
-
|
4796
|
-
if (!name) {
|
4797
|
-
throw sthis.logger.Error().Url(ret).Any("ctx", ctx).Msg("Ledger name is required").AsError();
|
4798
|
-
}
|
4799
|
-
ret.setParam(PARAM.NAME, name);
|
4796
|
+
throw sthis.logger.Error().Url(ret).Any("ctx", ctx).Msg("Ledger name is required").AsError();
|
4800
4797
|
}
|
4801
4798
|
if (ctx.idx) {
|
4802
4799
|
ret.defParam(PARAM.INDEX, "idx");
|
@@ -4822,23 +4819,19 @@ function toStoreURIRuntime(sthis, name, sopts) {
|
|
4822
4819
|
sopts = { ...sopts, base: getDefaultURI(sthis).build().setParam(PARAM.URL_GEN, "default") };
|
4823
4820
|
}
|
4824
4821
|
}
|
4825
|
-
const
|
4826
|
-
if (name) {
|
4827
|
-
bbase.setParam(PARAM.NAME, name);
|
4828
|
-
}
|
4829
|
-
const base = bbase.URI();
|
4822
|
+
const base = URI13.from(sopts.base);
|
4830
4823
|
return {
|
4831
4824
|
idx: {
|
4832
|
-
data: defaultURI2(sthis, sopts.idx?.data, base, "data", { idx: true }),
|
4833
|
-
file: defaultURI2(sthis, sopts.idx?.data, base, "data", { file: true, idx: true }),
|
4834
|
-
meta: defaultURI2(sthis, sopts.idx?.meta, base, "meta", { idx: true }),
|
4835
|
-
wal: defaultURI2(sthis, sopts.idx?.wal, base, "wal", { idx: true })
|
4825
|
+
data: defaultURI2(sthis, name, sopts.idx?.data, base, "data", { idx: true }),
|
4826
|
+
file: defaultURI2(sthis, name, sopts.idx?.data, base, "data", { file: true, idx: true }),
|
4827
|
+
meta: defaultURI2(sthis, name, sopts.idx?.meta, base, "meta", { idx: true }),
|
4828
|
+
wal: defaultURI2(sthis, name, sopts.idx?.wal, base, "wal", { idx: true })
|
4836
4829
|
},
|
4837
4830
|
data: {
|
4838
|
-
data: defaultURI2(sthis, sopts.data?.data, base, "data"),
|
4839
|
-
file: defaultURI2(sthis, sopts.data?.data, base, "data", { file: true }),
|
4840
|
-
meta: defaultURI2(sthis, sopts.data?.meta, base, "meta"),
|
4841
|
-
wal: defaultURI2(sthis, sopts.data?.wal, base, "wal")
|
4831
|
+
data: defaultURI2(sthis, name, sopts.data?.data, base, "data"),
|
4832
|
+
file: defaultURI2(sthis, name, sopts.data?.data, base, "data", { file: true }),
|
4833
|
+
meta: defaultURI2(sthis, name, sopts.data?.meta, base, "meta"),
|
4834
|
+
wal: defaultURI2(sthis, name, sopts.data?.wal, base, "wal")
|
4842
4835
|
}
|
4843
4836
|
};
|
4844
4837
|
}
|
@@ -4902,7 +4895,7 @@ __export(file_exports, {
|
|
4902
4895
|
|
4903
4896
|
// src/version.ts
|
4904
4897
|
var PACKAGE_VERSION = Object.keys({
|
4905
|
-
"0.20.0-dev-preview-
|
4898
|
+
"0.20.0-dev-preview-28": "xxxx"
|
4906
4899
|
})[0];
|
4907
4900
|
export {
|
4908
4901
|
CRDTImpl,
|