@fireproof/core 0.20.0-dev-preview-12 → 0.20.0-dev-preview-14

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.d.cts CHANGED
@@ -240,7 +240,7 @@ interface SerdeGateway {
240
240
  put<T>(sthis: SuperThis, url: URI, body: FPEnvelope<T>, loader?: Loadable): Promise<VoidResult>;
241
241
  get<S>(sthis: SuperThis, url: URI, loader?: Loadable): Promise<SerdeGetResult<S>>;
242
242
  delete(sthis: SuperThis, url: URI, loader?: Loadable): Promise<VoidResult>;
243
- subscribe?(sthis: SuperThis, url: URI, callback: (meta: FPEnvelopeMeta) => Promise<void>, loader?: Loadable): Promise<UnsubscribeResult>;
243
+ subscribe(sthis: SuperThis, url: URI, callback: (meta: FPEnvelopeMeta) => Promise<void>, loader?: Loadable): Promise<UnsubscribeResult>;
244
244
  getPlain(sthis: SuperThis, url: URI, key: string, loader?: Loadable): Promise<Result<Uint8Array>>;
245
245
  destroy(sthis: SuperThis, baseUrl: URI, loader?: Loadable): Promise<VoidResult>;
246
246
  }
@@ -1532,9 +1532,26 @@ declare namespace index$2 {
1532
1532
  export { index$2_KeyBagProviderFile as KeyBagProviderFile, index$2_sysFileSystemFactory as sysFileSystemFactory };
1533
1533
  }
1534
1534
 
1535
+ declare class DefSerdeGateway implements SerdeGateway {
1536
+ readonly gw: Gateway;
1537
+ constructor(gw: Gateway);
1538
+ start(sthis: SuperThis, baseURL: URI): Promise<Result<URI>>;
1539
+ buildUrl(sthis: SuperThis, baseUrl: URI, key: string): Promise<Result<URI>>;
1540
+ close(sthis: SuperThis, uri: URI): Promise<Result<void>>;
1541
+ private subscribeFn;
1542
+ put<T>(sthis: SuperThis, url: URI, env: FPEnvelope<T>): Promise<Result<void>>;
1543
+ get<S>(sthis: SuperThis, url: URI): Promise<SerdeGetResult<S>>;
1544
+ subscribe(sthis: SuperThis, url: URI, callback: (meta: FPEnvelopeMeta) => Promise<void>): Promise<Result<() => void>>;
1545
+ delete(sthis: SuperThis, url: URI): Promise<Result<void>>;
1546
+ destroy(sthis: SuperThis, baseURL: URI): Promise<Result<void>>;
1547
+ getPlain(sthis: SuperThis, iurl: URI, key: string): Promise<Result<Uint8Array<ArrayBufferLike>, Error>>;
1548
+ }
1549
+
1535
1550
  type index$1_CARDecodeEnvelope = CARDecodeEnvelope;
1536
1551
  type index$1_CAREncodeEnvelope = CAREncodeEnvelope;
1537
1552
  type index$1_Decoder = Decoder;
1553
+ type index$1_DefSerdeGateway = DefSerdeGateway;
1554
+ declare const index$1_DefSerdeGateway: typeof DefSerdeGateway;
1538
1555
  type index$1_Encoder = Encoder;
1539
1556
  type index$1_FILEDecodeEnvelope = FILEDecodeEnvelope;
1540
1557
  type index$1_FILEEncodeEnvelope = FILEEncodeEnvelope;
@@ -1547,7 +1564,7 @@ type index$1_WALEncodeEnvelope = WALEncodeEnvelope;
1547
1564
  declare const index$1_fpDeserialize: typeof fpDeserialize;
1548
1565
  declare const index$1_fpSerialize: typeof fpSerialize;
1549
1566
  declare namespace index$1 {
1550
- export { type index$1_CARDecodeEnvelope as CARDecodeEnvelope, type index$1_CAREncodeEnvelope as CAREncodeEnvelope, type index$1_Decoder as Decoder, type index$1_Encoder as Encoder, type index$1_FILEDecodeEnvelope as FILEDecodeEnvelope, type index$1_FILEEncodeEnvelope as FILEEncodeEnvelope, type index$1_METADecodeEnvelope as METADecodeEnvelope, type index$1_METAEncodeEnvelope as METAEncodeEnvelope, type index$1_SerializedMeta as SerializedMeta, type index$1_SerializedWAL as SerializedWAL, type index$1_WALDecodeEnvelope as WALDecodeEnvelope, type index$1_WALEncodeEnvelope as WALEncodeEnvelope, index$2 as file, index$1_fpDeserialize as fpDeserialize, index$1_fpSerialize as fpSerialize };
1567
+ export { type index$1_CARDecodeEnvelope as CARDecodeEnvelope, type index$1_CAREncodeEnvelope as CAREncodeEnvelope, type index$1_Decoder as Decoder, index$1_DefSerdeGateway as DefSerdeGateway, type index$1_Encoder as Encoder, type index$1_FILEDecodeEnvelope as FILEDecodeEnvelope, type index$1_FILEEncodeEnvelope as FILEEncodeEnvelope, type index$1_METADecodeEnvelope as METADecodeEnvelope, type index$1_METAEncodeEnvelope as METAEncodeEnvelope, type index$1_SerializedMeta as SerializedMeta, type index$1_SerializedWAL as SerializedWAL, type index$1_WALDecodeEnvelope as WALDecodeEnvelope, type index$1_WALEncodeEnvelope as WALEncodeEnvelope, index$2 as file, index$1_fpDeserialize as fpDeserialize, index$1_fpSerialize as fpSerialize };
1551
1568
  }
1552
1569
 
1553
1570
  declare const FILESTORE_VERSION = "v0.19-file";
package/index.d.ts CHANGED
@@ -240,7 +240,7 @@ interface SerdeGateway {
240
240
  put<T>(sthis: SuperThis, url: URI, body: FPEnvelope<T>, loader?: Loadable): Promise<VoidResult>;
241
241
  get<S>(sthis: SuperThis, url: URI, loader?: Loadable): Promise<SerdeGetResult<S>>;
242
242
  delete(sthis: SuperThis, url: URI, loader?: Loadable): Promise<VoidResult>;
243
- subscribe?(sthis: SuperThis, url: URI, callback: (meta: FPEnvelopeMeta) => Promise<void>, loader?: Loadable): Promise<UnsubscribeResult>;
243
+ subscribe(sthis: SuperThis, url: URI, callback: (meta: FPEnvelopeMeta) => Promise<void>, loader?: Loadable): Promise<UnsubscribeResult>;
244
244
  getPlain(sthis: SuperThis, url: URI, key: string, loader?: Loadable): Promise<Result<Uint8Array>>;
245
245
  destroy(sthis: SuperThis, baseUrl: URI, loader?: Loadable): Promise<VoidResult>;
246
246
  }
@@ -1532,9 +1532,26 @@ declare namespace index$2 {
1532
1532
  export { index$2_KeyBagProviderFile as KeyBagProviderFile, index$2_sysFileSystemFactory as sysFileSystemFactory };
1533
1533
  }
1534
1534
 
1535
+ declare class DefSerdeGateway implements SerdeGateway {
1536
+ readonly gw: Gateway;
1537
+ constructor(gw: Gateway);
1538
+ start(sthis: SuperThis, baseURL: URI): Promise<Result<URI>>;
1539
+ buildUrl(sthis: SuperThis, baseUrl: URI, key: string): Promise<Result<URI>>;
1540
+ close(sthis: SuperThis, uri: URI): Promise<Result<void>>;
1541
+ private subscribeFn;
1542
+ put<T>(sthis: SuperThis, url: URI, env: FPEnvelope<T>): Promise<Result<void>>;
1543
+ get<S>(sthis: SuperThis, url: URI): Promise<SerdeGetResult<S>>;
1544
+ subscribe(sthis: SuperThis, url: URI, callback: (meta: FPEnvelopeMeta) => Promise<void>): Promise<Result<() => void>>;
1545
+ delete(sthis: SuperThis, url: URI): Promise<Result<void>>;
1546
+ destroy(sthis: SuperThis, baseURL: URI): Promise<Result<void>>;
1547
+ getPlain(sthis: SuperThis, iurl: URI, key: string): Promise<Result<Uint8Array<ArrayBufferLike>, Error>>;
1548
+ }
1549
+
1535
1550
  type index$1_CARDecodeEnvelope = CARDecodeEnvelope;
1536
1551
  type index$1_CAREncodeEnvelope = CAREncodeEnvelope;
1537
1552
  type index$1_Decoder = Decoder;
1553
+ type index$1_DefSerdeGateway = DefSerdeGateway;
1554
+ declare const index$1_DefSerdeGateway: typeof DefSerdeGateway;
1538
1555
  type index$1_Encoder = Encoder;
1539
1556
  type index$1_FILEDecodeEnvelope = FILEDecodeEnvelope;
1540
1557
  type index$1_FILEEncodeEnvelope = FILEEncodeEnvelope;
@@ -1547,7 +1564,7 @@ type index$1_WALEncodeEnvelope = WALEncodeEnvelope;
1547
1564
  declare const index$1_fpDeserialize: typeof fpDeserialize;
1548
1565
  declare const index$1_fpSerialize: typeof fpSerialize;
1549
1566
  declare namespace index$1 {
1550
- export { type index$1_CARDecodeEnvelope as CARDecodeEnvelope, type index$1_CAREncodeEnvelope as CAREncodeEnvelope, type index$1_Decoder as Decoder, type index$1_Encoder as Encoder, type index$1_FILEDecodeEnvelope as FILEDecodeEnvelope, type index$1_FILEEncodeEnvelope as FILEEncodeEnvelope, type index$1_METADecodeEnvelope as METADecodeEnvelope, type index$1_METAEncodeEnvelope as METAEncodeEnvelope, type index$1_SerializedMeta as SerializedMeta, type index$1_SerializedWAL as SerializedWAL, type index$1_WALDecodeEnvelope as WALDecodeEnvelope, type index$1_WALEncodeEnvelope as WALEncodeEnvelope, index$2 as file, index$1_fpDeserialize as fpDeserialize, index$1_fpSerialize as fpSerialize };
1567
+ export { type index$1_CARDecodeEnvelope as CARDecodeEnvelope, type index$1_CAREncodeEnvelope as CAREncodeEnvelope, type index$1_Decoder as Decoder, index$1_DefSerdeGateway as DefSerdeGateway, type index$1_Encoder as Encoder, type index$1_FILEDecodeEnvelope as FILEDecodeEnvelope, type index$1_FILEEncodeEnvelope as FILEEncodeEnvelope, type index$1_METADecodeEnvelope as METADecodeEnvelope, type index$1_METAEncodeEnvelope as METAEncodeEnvelope, type index$1_SerializedMeta as SerializedMeta, type index$1_SerializedWAL as SerializedWAL, type index$1_WALDecodeEnvelope as WALDecodeEnvelope, type index$1_WALEncodeEnvelope as WALEncodeEnvelope, index$2 as file, index$1_fpDeserialize as fpDeserialize, index$1_fpSerialize as fpSerialize };
1551
1568
  }
1552
1569
 
1553
1570
  declare const FILESTORE_VERSION = "v0.19-file";
package/index.js CHANGED
@@ -1029,9 +1029,6 @@ var MemoryGateway = class {
1029
1029
  // src/runtime/gateways/def-serde-gateway.ts
1030
1030
  import { Result as Result7 } from "@adviser/cement";
1031
1031
 
1032
- // src/runtime/gateways/fp-envelope-serialize.ts
1033
- import { exception2Result as exception2Result2, Result as Result6 } from "@adviser/cement";
1034
-
1035
1032
  // src/blockstore/fp-envelope.ts
1036
1033
  import { Result as Result5 } from "@adviser/cement";
1037
1034
  var FPEnvelopeType = /* @__PURE__ */ ((FPEnvelopeType2) => {
@@ -1049,6 +1046,7 @@ function File2FPMsg(fpfile) {
1049
1046
  }
1050
1047
 
1051
1048
  // src/runtime/gateways/fp-envelope-serialize.ts
1049
+ import { exception2Result as exception2Result2, Result as Result6 } from "@adviser/cement";
1052
1050
  import { decodeEventBlock, EventBlock } from "@fireproof/vendor/@web3-storage/pail/clock";
1053
1051
  import { base64pad } from "multiformats/bases/base64";
1054
1052
  import { CID } from "multiformats";
@@ -1202,6 +1200,7 @@ async function fpDeserialize(sthis, url, intoRaw, pdecoder) {
1202
1200
  // src/runtime/gateways/def-serde-gateway.ts
1203
1201
  var DefSerdeGateway = class {
1204
1202
  constructor(gw) {
1203
+ this.subscribeFn = /* @__PURE__ */ new Map();
1205
1204
  this.gw = gw;
1206
1205
  }
1207
1206
  start(sthis, baseURL) {
@@ -1216,13 +1215,38 @@ var DefSerdeGateway = class {
1216
1215
  async put(sthis, url, env) {
1217
1216
  const rUint8 = await fpSerialize(sthis, env);
1218
1217
  if (rUint8.isErr()) return rUint8;
1219
- return this.gw.put(url, rUint8.Ok(), sthis);
1218
+ const ret = this.gw.put(url, rUint8.Ok(), sthis);
1219
+ if (env.type === "meta" /* META */) {
1220
+ if (this.subscribeFn.has(url.toString())) {
1221
+ this.subscribeFn.get(url.toString())(env);
1222
+ }
1223
+ }
1224
+ return ret;
1220
1225
  }
1221
1226
  async get(sthis, url) {
1222
1227
  const res = await this.gw.get(url, sthis);
1223
1228
  if (res.isErr()) return Result7.Err(res.Err());
1224
1229
  return fpDeserialize(sthis, url, res);
1225
1230
  }
1231
+ async subscribe(sthis, url, callback) {
1232
+ if (!this.gw.subscribe) {
1233
+ this.subscribeFn.set(url.toString(), callback);
1234
+ return Result7.Ok(() => {
1235
+ this.subscribeFn.delete(url.toString());
1236
+ });
1237
+ }
1238
+ const unreg = await this.gw.subscribe(
1239
+ url,
1240
+ (raw2) => {
1241
+ fpDeserialize(sthis, url, Result7.Ok(raw2)).then((res) => {
1242
+ if (res.isErr()) return;
1243
+ callback(res.Ok());
1244
+ });
1245
+ },
1246
+ sthis
1247
+ );
1248
+ return unreg;
1249
+ }
1226
1250
  async delete(sthis, url) {
1227
1251
  return this.gw.delete(url, sthis);
1228
1252
  }
@@ -4598,6 +4622,7 @@ import { runtimeFn as runtimeFn4 } from "@adviser/cement";
4598
4622
  // src/runtime/gateways/index.ts
4599
4623
  var gateways_exports = {};
4600
4624
  __export(gateways_exports, {
4625
+ DefSerdeGateway: () => DefSerdeGateway,
4601
4626
  file: () => file_exports,
4602
4627
  fpDeserialize: () => fpDeserialize,
4603
4628
  fpSerialize: () => fpSerialize
@@ -4612,7 +4637,7 @@ __export(file_exports, {
4612
4637
 
4613
4638
  // src/version.ts
4614
4639
  var PACKAGE_VERSION = Object.keys({
4615
- "0.20.0-dev-preview-12": "xxxx"
4640
+ "0.20.0-dev-preview-14": "xxxx"
4616
4641
  })[0];
4617
4642
  export {
4618
4643
  CRDTImpl,