@fireproof/core 0.20.0-dev-preview-54 → 0.20.0-dev-preview-55

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/deno.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "imports": {
3
3
  "@fireproof/core": "./index.js",
4
- "@adviser/cement": "npm:@adviser/cement@~0.4.1",
5
- "@fireproof/vendor": "npm:@fireproof/vendor@~2.0.1",
4
+ "@adviser/cement": "npm:@adviser/cement@~0.4.3",
5
+ "@fireproof/vendor": "npm:@fireproof/vendor@~2.0.2",
6
6
  "@ipld/car": "npm:@ipld/car@^5.4.0",
7
7
  "@ipld/dag-cbor": "npm:@ipld/dag-cbor@^9.2.2",
8
8
  "@ipld/dag-json": "npm:@ipld/dag-json@^10.2.3",
package/index.cjs CHANGED
@@ -2163,6 +2163,9 @@ var DatabaseImpl = class {
2163
2163
  const result = await this.ledger.writeQueue.push({ id, del: true });
2164
2164
  return { id, clock: result?.head, name: this.name };
2165
2165
  }
2166
+ async remove(id) {
2167
+ return this.del(id);
2168
+ }
2166
2169
  async changes(since = [], opts = {}) {
2167
2170
  await this.ready();
2168
2171
  this.logger.Debug().Any("since", since).Any("opts", opts).Msg("changes");
@@ -2229,6 +2232,7 @@ __export(blockstore_exports, {
2229
2232
  MetaActiveStore: () => MetaActiveStore,
2230
2233
  PassThroughGateway: () => PassThroughGateway,
2231
2234
  TaskManager: () => TaskManager,
2235
+ URIInterceptor: () => URIInterceptor,
2232
2236
  WALActiveStore: () => WALActiveStore,
2233
2237
  createAttachedStores: () => createAttachedStores,
2234
2238
  createDbMetaEvent: () => createDbMetaEvent,
@@ -2236,7 +2240,7 @@ __export(blockstore_exports, {
2236
2240
  ensureStoreEnDeFile: () => ensureStoreEnDeFile,
2237
2241
  getDefaultURI: () => getDefaultURI,
2238
2242
  getGatewayFactoryItem: () => getGatewayFactoryItem,
2239
- getStartedGateway: () => getStartedGateway,
2243
+ getInterceptableGateway: () => getInterceptableGateway,
2240
2244
  parseCarFile: () => parseCarFile,
2241
2245
  registerStoreProtocol: () => registerStoreProtocol,
2242
2246
  toCIDBlock: () => toCIDBlock,
@@ -2299,7 +2303,7 @@ var WALActiveStore = class extends BaseActiveStore {
2299
2303
  var import_cement18 = require("@adviser/cement");
2300
2304
 
2301
2305
  // src/blockstore/store.ts
2302
- var import_cement17 = require("@adviser/cement");
2306
+ var import_cement16 = require("@adviser/cement");
2303
2307
 
2304
2308
  // src/blockstore/loader.ts
2305
2309
  var import_p_limit = __toESM(require("p-limit"), 1);
@@ -3629,151 +3633,11 @@ var import_clock2 = require("@fireproof/vendor/@web3-storage/pail/clock");
3629
3633
  var import_dag_json2 = require("@ipld/dag-json");
3630
3634
  var import_p_retry = __toESM(require("p-retry"), 1);
3631
3635
  var import_p_map = __toESM(require("p-map"), 1);
3632
-
3633
- // src/blockstore/interceptor-gateway.ts
3634
- var import_cement16 = require("@adviser/cement");
3635
- var PassThroughGateway = class {
3636
- async buildUrl(ctx, url, key) {
3637
- const op = { url, key };
3638
- return import_cement16.Result.Ok({ op });
3639
- }
3640
- async start(ctx, url) {
3641
- const op = { url };
3642
- return import_cement16.Result.Ok({ op });
3643
- }
3644
- async close(ctx, url) {
3645
- const op = { url };
3646
- return import_cement16.Result.Ok({ op });
3647
- }
3648
- async delete(ctx, url) {
3649
- const op = { url };
3650
- return import_cement16.Result.Ok({ op });
3651
- }
3652
- async destroy(ctx, url) {
3653
- const op = { url };
3654
- return import_cement16.Result.Ok({ op });
3655
- }
3656
- async put(ctx, url, body) {
3657
- const op = { url, body };
3658
- return import_cement16.Result.Ok({ op });
3659
- }
3660
- async get(ctx, url) {
3661
- const op = { url };
3662
- return import_cement16.Result.Ok({ op });
3663
- }
3664
- async subscribe(ctx, url, callback) {
3665
- const op = { url, callback };
3666
- return import_cement16.Result.Ok({ op });
3667
- }
3668
- };
3669
- var passThrougthGateway = new PassThroughGateway();
3670
- var InterceptorGateway = class {
3671
- constructor(sthis, innerGW, interceptor) {
3672
- this.innerGW = innerGW;
3673
- this.interceptor = interceptor || passThrougthGateway;
3674
- }
3675
- async buildUrl(ctx, baseUrl, key) {
3676
- const rret = await this.interceptor.buildUrl(ctx, baseUrl, key);
3677
- if (rret.isErr()) {
3678
- return import_cement16.Result.Err(rret.Err());
3679
- }
3680
- const ret = rret.unwrap();
3681
- if (ret.stop && ret.value) {
3682
- return ret.value;
3683
- }
3684
- return this.innerGW.buildUrl(ctx, ret.op.url, ret.op.key);
3685
- }
3686
- async destroy(ctx, iurl) {
3687
- const rret = await this.interceptor.destroy(ctx, iurl);
3688
- if (rret.isErr()) {
3689
- return import_cement16.Result.Err(rret.Err());
3690
- }
3691
- const ret = rret.unwrap();
3692
- if (ret.stop && ret.value) {
3693
- return ret.value;
3694
- }
3695
- return this.innerGW.destroy(ctx, ret.op.url);
3696
- }
3697
- async start(ctx, url) {
3698
- const rret = await this.interceptor.start(ctx, url);
3699
- if (rret.isErr()) {
3700
- return import_cement16.Result.Err(rret.Err());
3701
- }
3702
- const ret = rret.unwrap();
3703
- if (ret.stop && ret.value) {
3704
- return ret.value;
3705
- }
3706
- return await this.innerGW.start(ctx, ret.op.url);
3707
- }
3708
- async close(ctx, url) {
3709
- const rret = await this.interceptor.close(ctx, url);
3710
- if (rret.isErr()) {
3711
- return import_cement16.Result.Err(rret.Err());
3712
- }
3713
- const ret = rret.unwrap();
3714
- if (ret.stop && ret.value) {
3715
- return ret.value;
3716
- }
3717
- return await this.innerGW.close(ctx, ret.op.url);
3718
- }
3719
- async put(ctx, url, fpEnv) {
3720
- const rret = await this.interceptor.put(ctx, url, fpEnv);
3721
- if (rret.isErr()) {
3722
- return import_cement16.Result.Err(rret.Err());
3723
- }
3724
- const ret = rret.unwrap();
3725
- if (ret.stop && ret.value) {
3726
- return ret.value;
3727
- }
3728
- return this.innerGW.put(ctx, ret.op.url, ret.op.body);
3729
- }
3730
- async get(ctx, url) {
3731
- const rret = await this.interceptor.get(ctx, url);
3732
- if (rret.isErr()) {
3733
- return import_cement16.Result.Err(rret.Err());
3734
- }
3735
- const ret = rret.unwrap();
3736
- if (ret.stop && ret.value) {
3737
- return ret.value;
3738
- }
3739
- return this.innerGW.get(ctx, ret.op.url);
3740
- }
3741
- async subscribe(ctx, url, callback) {
3742
- if (!this.innerGW.subscribe) {
3743
- return import_cement16.Result.Err(ctx.loader.sthis.logger.Error().Url(url).Msg("subscribe not supported").AsError());
3744
- }
3745
- const rret = await this.interceptor.subscribe(ctx, url, callback);
3746
- if (rret.isErr()) {
3747
- return import_cement16.Result.Err(rret.Err());
3748
- }
3749
- const ret = rret.unwrap();
3750
- if (ret.stop && ret.value) {
3751
- return ret.value;
3752
- }
3753
- return this.innerGW.subscribe(ctx, ret.op.url, ret.op.callback);
3754
- }
3755
- async delete(ctx, url) {
3756
- const rret = await this.interceptor.delete(ctx, url);
3757
- if (rret.isErr()) {
3758
- return import_cement16.Result.Err(rret.Err());
3759
- }
3760
- const ret = rret.unwrap();
3761
- if (ret.stop && ret.value) {
3762
- return ret.value;
3763
- }
3764
- return this.innerGW.delete(ctx, url);
3765
- }
3766
- async getPlain(ctx, url, key) {
3767
- return this.innerGW.getPlain(ctx, url, key);
3768
- }
3769
- };
3770
-
3771
- // src/blockstore/store.ts
3772
3636
  function guardVersion(url) {
3773
3637
  if (!url.hasParam("version")) {
3774
- return import_cement17.Result.Err(`missing version: ${url.toString()}`);
3638
+ return import_cement16.Result.Err(`missing version: ${url.toString()}`);
3775
3639
  }
3776
- return import_cement17.Result.Ok(url);
3640
+ return import_cement16.Result.Ok(url);
3777
3641
  }
3778
3642
  var BaseStoreImpl = class {
3779
3643
  // readonly loader: Loadable;
@@ -3789,8 +3653,10 @@ var BaseStoreImpl = class {
3789
3653
  throw logger.Error().Url(this._url).Msg("missing name").AsError();
3790
3654
  }
3791
3655
  this.logger = logger.With().Str("this", this.sthis.nextId().str).Ref("url", () => this._url.toString()).Logger();
3792
- this.realGateway = opts.gateway;
3793
- this.gateway = new InterceptorGateway(this.sthis, opts.gateway, opts.gatewayInterceptor);
3656
+ this.gateway = opts.gateway;
3657
+ }
3658
+ get realGateway() {
3659
+ return this.gateway.innerGW;
3794
3660
  }
3795
3661
  url() {
3796
3662
  return this._url;
@@ -3833,7 +3699,7 @@ var BaseStoreImpl = class {
3833
3699
  }
3834
3700
  if (this.ready) {
3835
3701
  const fn = this.ready.bind(this);
3836
- const ready = await (0, import_cement17.exception2Result)(fn);
3702
+ const ready = await (0, import_cement16.exception2Result)(fn);
3837
3703
  if (ready.isErr()) {
3838
3704
  await this.close();
3839
3705
  return ready;
@@ -3940,7 +3806,7 @@ var MetaStoreImpl = class extends BaseStoreImpl {
3940
3806
  async close() {
3941
3807
  await this.gateway.close({ loader: this.loader }, this.url());
3942
3808
  this._onClosed.forEach((fn) => fn());
3943
- return import_cement17.Result.Ok(void 0);
3809
+ return import_cement16.Result.Ok(void 0);
3944
3810
  }
3945
3811
  async destroy() {
3946
3812
  this.logger.Debug().Msg("destroy");
@@ -4007,7 +3873,7 @@ var DataStoreImpl = class extends BaseStoreImpl {
4007
3873
  async close() {
4008
3874
  await this.gateway.close({ loader: this.loader }, this.url());
4009
3875
  this._onClosed.forEach((fn) => fn());
4010
- return import_cement17.Result.Ok(void 0);
3876
+ return import_cement16.Result.Ok(void 0);
4011
3877
  }
4012
3878
  destroy() {
4013
3879
  this.logger.Debug().Msg("destroy");
@@ -4032,7 +3898,7 @@ var WALStoreImpl = class extends BaseStoreImpl {
4032
3898
  this.storeType = "wal";
4033
3899
  // readonly tag: string = "rwal-base";
4034
3900
  // readonly loader: Loadable;
4035
- this._ready = new import_cement17.ResolveOnce();
3901
+ this._ready = new import_cement16.ResolveOnce();
4036
3902
  this.walState = { operations: [], noLoaderOps: [], fileOperations: [] };
4037
3903
  this.processing = void 0;
4038
3904
  this.processQueue = new CommitQueue();
@@ -4094,7 +3960,7 @@ var WALStoreImpl = class extends BaseStoreImpl {
4094
3960
  const retryableUpload = (fn, description) => (0, import_p_retry.default)(fn, {
4095
3961
  retries: 5,
4096
3962
  onFailedAttempt: (error) => {
4097
- this.logger.Warn().Msg(`Attempt ${error.attemptNumber} failed for ${description}. There are ${error.retriesLeft} retries left.`);
3963
+ this.logger.Warn().Any("error", error).Any("fn", fn.toString()).Msg(`Attempt ${error.attemptNumber} failed for ${description}. There are ${error.retriesLeft} retries left.`);
4098
3964
  }
4099
3965
  });
4100
3966
  try {
@@ -4209,7 +4075,7 @@ var WALStoreImpl = class extends BaseStoreImpl {
4209
4075
  async close() {
4210
4076
  await this.gateway.close({ loader: this.loader }, this.url());
4211
4077
  this._onClosed.forEach((fn) => fn());
4212
- return import_cement17.Result.Ok(void 0);
4078
+ return import_cement16.Result.Ok(void 0);
4213
4079
  }
4214
4080
  destroy() {
4215
4081
  this.logger.Debug().Msg("destroy");
@@ -4217,81 +4083,200 @@ var WALStoreImpl = class extends BaseStoreImpl {
4217
4083
  }
4218
4084
  };
4219
4085
 
4220
- // src/blockstore/store-factory.ts
4221
- var onceGateway = new import_cement18.KeyedResolvOnce();
4222
- var gatewayInstances = new import_cement18.KeyedResolvOnce();
4223
- async function getStartedGateway(ctx, url) {
4224
- return onceGateway.get(url.toString()).once(async () => {
4225
- const item = getGatewayFactoryItem(url.protocol);
4226
- if (item) {
4227
- const ret = {
4228
- url,
4229
- ...await gatewayInstances.get(url.protocol).once(async () => ({
4230
- gateway: await item.serdegateway(ctx.loader.sthis)
4231
- }))
4232
- };
4233
- const res = await ret.gateway.start(ctx, url);
4234
- if (res.isErr()) {
4235
- return import_cement18.Result.Err(ctx.loader.sthis.logger.Error().Result("start", res).Msg("start failed").AsError());
4236
- }
4237
- ret.url = res.Ok();
4238
- return import_cement18.Result.Ok(ret);
4086
+ // src/blockstore/interceptor-gateway.ts
4087
+ var import_cement17 = require("@adviser/cement");
4088
+ var PassThroughGateway = class {
4089
+ async buildUrl(ctx, url, key) {
4090
+ const op = { url, key };
4091
+ return import_cement17.Result.Ok({ op });
4092
+ }
4093
+ async start(ctx, url) {
4094
+ const op = { url };
4095
+ return import_cement17.Result.Ok({ op });
4096
+ }
4097
+ async close(ctx, url) {
4098
+ const op = { url };
4099
+ return import_cement17.Result.Ok({ op });
4100
+ }
4101
+ async delete(ctx, url) {
4102
+ const op = { url };
4103
+ return import_cement17.Result.Ok({ op });
4104
+ }
4105
+ async destroy(ctx, url) {
4106
+ const op = { url };
4107
+ return import_cement17.Result.Ok({ op });
4108
+ }
4109
+ async put(ctx, url, body) {
4110
+ const op = { url, body };
4111
+ return import_cement17.Result.Ok({ op });
4112
+ }
4113
+ async get(ctx, url) {
4114
+ const op = { url };
4115
+ return import_cement17.Result.Ok({ op });
4116
+ }
4117
+ async subscribe(ctx, url, callback) {
4118
+ const op = { url, callback };
4119
+ return import_cement17.Result.Ok({ op });
4120
+ }
4121
+ };
4122
+ var passThrougthGateway = new PassThroughGateway();
4123
+ var InterceptorGateway = class {
4124
+ constructor(sthis, innerGW, interceptor) {
4125
+ this.innerGW = innerGW;
4126
+ this.interceptor = interceptor || passThrougthGateway;
4127
+ }
4128
+ async buildUrl(ctx, baseUrl, key) {
4129
+ const rret = await this.interceptor.buildUrl(ctx, baseUrl, key);
4130
+ if (rret.isErr()) {
4131
+ return import_cement17.Result.Err(rret.Err());
4239
4132
  }
4240
- return import_cement18.Result.Err(ctx.loader.sthis.logger.Warn().Url(url).Msg("unsupported protocol").AsError());
4241
- });
4133
+ const ret = rret.unwrap();
4134
+ if (ret.stop && ret.value) {
4135
+ return ret.value;
4136
+ }
4137
+ return this.innerGW.buildUrl(ctx, ret.op.url, ret.op.key);
4138
+ }
4139
+ async destroy(ctx, iurl) {
4140
+ const rret = await this.interceptor.destroy(ctx, iurl);
4141
+ if (rret.isErr()) {
4142
+ return import_cement17.Result.Err(rret.Err());
4143
+ }
4144
+ const ret = rret.unwrap();
4145
+ if (ret.stop && ret.value) {
4146
+ return ret.value;
4147
+ }
4148
+ return this.innerGW.destroy(ctx, ret.op.url);
4149
+ }
4150
+ async start(ctx, url) {
4151
+ const rret = await this.interceptor.start(ctx, url);
4152
+ if (rret.isErr()) {
4153
+ return import_cement17.Result.Err(rret.Err());
4154
+ }
4155
+ const ret = rret.unwrap();
4156
+ if (ret.stop && ret.value) {
4157
+ return ret.value;
4158
+ }
4159
+ return await this.innerGW.start(ctx, ret.op.url);
4160
+ }
4161
+ async close(ctx, url) {
4162
+ const rret = await this.interceptor.close(ctx, url);
4163
+ if (rret.isErr()) {
4164
+ return import_cement17.Result.Err(rret.Err());
4165
+ }
4166
+ const ret = rret.unwrap();
4167
+ if (ret.stop && ret.value) {
4168
+ return ret.value;
4169
+ }
4170
+ return await this.innerGW.close(ctx, ret.op.url);
4171
+ }
4172
+ async put(ctx, url, fpEnv) {
4173
+ const rret = await this.interceptor.put(ctx, url, fpEnv);
4174
+ if (rret.isErr()) {
4175
+ return import_cement17.Result.Err(rret.Err());
4176
+ }
4177
+ const ret = rret.unwrap();
4178
+ if (ret.stop && ret.value) {
4179
+ return ret.value;
4180
+ }
4181
+ return this.innerGW.put(ctx, ret.op.url, ret.op.body);
4182
+ }
4183
+ async get(ctx, url) {
4184
+ const rret = await this.interceptor.get(ctx, url);
4185
+ if (rret.isErr()) {
4186
+ return import_cement17.Result.Err(rret.Err());
4187
+ }
4188
+ const ret = rret.unwrap();
4189
+ if (ret.stop && ret.value) {
4190
+ return ret.value;
4191
+ }
4192
+ return this.innerGW.get(ctx, ret.op.url);
4193
+ }
4194
+ async subscribe(ctx, url, callback) {
4195
+ if (!this.innerGW.subscribe) {
4196
+ return import_cement17.Result.Err(ctx.loader.sthis.logger.Error().Url(url).Msg("subscribe not supported").AsError());
4197
+ }
4198
+ const rret = await this.interceptor.subscribe(ctx, url, callback);
4199
+ if (rret.isErr()) {
4200
+ return import_cement17.Result.Err(rret.Err());
4201
+ }
4202
+ const ret = rret.unwrap();
4203
+ if (ret.stop && ret.value) {
4204
+ return ret.value;
4205
+ }
4206
+ return this.innerGW.subscribe(ctx, ret.op.url, ret.op.callback);
4207
+ }
4208
+ async delete(ctx, url) {
4209
+ const rret = await this.interceptor.delete(ctx, url);
4210
+ if (rret.isErr()) {
4211
+ return import_cement17.Result.Err(rret.Err());
4212
+ }
4213
+ const ret = rret.unwrap();
4214
+ if (ret.stop && ret.value) {
4215
+ return ret.value;
4216
+ }
4217
+ return this.innerGW.delete(ctx, url);
4218
+ }
4219
+ async getPlain(ctx, url, key) {
4220
+ return this.innerGW.getPlain(ctx, url, key);
4221
+ }
4222
+ };
4223
+
4224
+ // src/blockstore/store-factory.ts
4225
+ async function getInterceptableGateway(ctx, url, opt) {
4226
+ const item = getGatewayFactoryItem(url.protocol);
4227
+ if (item) {
4228
+ return import_cement18.Result.Ok(new InterceptorGateway(ctx.loader.sthis, await item.serdegateway(ctx.loader.sthis), opt.gatewayInterceptor));
4229
+ }
4230
+ return import_cement18.Result.Err(ctx.loader.sthis.logger.Warn().Url(url).Msg("unsupported protocol").AsError());
4242
4231
  }
4243
4232
  async function carStoreFactory(ctx, uai) {
4244
4233
  const storeUrl = uai.url.build().setParam(PARAM.STORE, "car").URI();
4245
- const rgateway = await getStartedGateway(ctx, storeUrl);
4234
+ const rgateway = await getInterceptableGateway(ctx, storeUrl, uai);
4246
4235
  if (rgateway.isErr()) {
4247
4236
  throw ctx.loader.sthis.logger.Error().Result("err", rgateway).Url(uai.url).Msg("notfound").AsError();
4248
4237
  }
4249
4238
  const gateway = rgateway.Ok();
4250
- const store = new CarStoreImpl(ctx.loader.sthis, gateway.url, {
4251
- gateway: gateway.gateway,
4252
- gatewayInterceptor: uai.gatewayInterceptor,
4239
+ const store = new CarStoreImpl(ctx.loader.sthis, uai.url, {
4240
+ gateway,
4253
4241
  loader: ctx.loader
4254
4242
  });
4255
4243
  return store;
4256
4244
  }
4257
4245
  async function fileStoreFactory(ctx, uai) {
4258
4246
  const storeUrl = uai.url.build().setParam(PARAM.STORE, "file").URI();
4259
- const rgateway = await getStartedGateway(ctx, storeUrl);
4247
+ const rgateway = await getInterceptableGateway(ctx, storeUrl, uai);
4260
4248
  if (rgateway.isErr()) {
4261
4249
  throw ctx.loader.sthis.logger.Error().Result("err", rgateway).Url(uai.url).Msg("notfound").AsError();
4262
4250
  }
4263
4251
  const gateway = rgateway.Ok();
4264
- const store = new FileStoreImpl(ctx.loader.sthis, gateway.url, {
4265
- gateway: gateway.gateway,
4266
- gatewayInterceptor: uai.gatewayInterceptor,
4252
+ const store = new FileStoreImpl(ctx.loader.sthis, uai.url, {
4253
+ gateway,
4267
4254
  loader: ctx.loader
4268
4255
  });
4269
4256
  return store;
4270
4257
  }
4271
4258
  async function metaStoreFactory(ctx, uai) {
4272
4259
  const storeUrl = uai.url.build().setParam(PARAM.STORE, "meta").URI();
4273
- const rgateway = await getStartedGateway(ctx, storeUrl);
4260
+ const rgateway = await getInterceptableGateway(ctx, storeUrl, uai);
4274
4261
  if (rgateway.isErr()) {
4275
4262
  throw ctx.loader.sthis.logger.Error().Result("err", rgateway).Url(uai.url).Msg("notfound").AsError();
4276
4263
  }
4277
4264
  const gateway = rgateway.Ok();
4278
- const store = new MetaStoreImpl(ctx.loader.sthis, gateway.url, {
4279
- gateway: gateway.gateway,
4280
- gatewayInterceptor: uai.gatewayInterceptor,
4265
+ const store = new MetaStoreImpl(ctx.loader.sthis, uai.url, {
4266
+ gateway,
4281
4267
  loader: ctx.loader
4282
4268
  });
4283
4269
  return store;
4284
4270
  }
4285
4271
  async function WALStoreFactory(ctx, uai) {
4286
4272
  const storeUrl = uai.url.build().setParam(PARAM.STORE, "wal").URI();
4287
- const rgateway = await getStartedGateway(ctx, storeUrl);
4273
+ const rgateway = await getInterceptableGateway(ctx, storeUrl, uai);
4288
4274
  if (rgateway.isErr()) {
4289
4275
  throw ctx.loader.sthis.logger.Error().Result("err", rgateway).Url(uai.url).Msg("notfound").AsError();
4290
4276
  }
4291
4277
  const gateway = rgateway.Ok();
4292
- const store = new WALStoreImpl(ctx.loader.sthis, gateway.url, {
4293
- gateway: gateway.gateway,
4294
- gatewayInterceptor: uai.gatewayInterceptor,
4278
+ const store = new WALStoreImpl(ctx.loader.sthis, uai.url, {
4279
+ gateway,
4295
4280
  loader: ctx.loader
4296
4281
  });
4297
4282
  return store;
@@ -4339,6 +4324,57 @@ function toStoreRuntime(sthis, endeOpts = {}) {
4339
4324
  };
4340
4325
  }
4341
4326
 
4327
+ // src/blockstore/uri-interceptor.ts
4328
+ var URIInterceptor = class _URIInterceptor extends PassThroughGateway {
4329
+ static withMapper(mapper) {
4330
+ return new _URIInterceptor().addMapper(mapper);
4331
+ }
4332
+ #uriMapper = /* @__PURE__ */ new Set();
4333
+ addMapper(mapper) {
4334
+ this.#uriMapper.add(mapper);
4335
+ return this;
4336
+ }
4337
+ async #map(uri) {
4338
+ let ret = uri;
4339
+ for (const mapper of this.#uriMapper) {
4340
+ ret = await mapper(ret);
4341
+ }
4342
+ return ret;
4343
+ }
4344
+ async buildUrl(ctx, url, key) {
4345
+ const ret = await super.buildUrl(ctx, await this.#map(url), key);
4346
+ return ret;
4347
+ }
4348
+ async start(ctx, url) {
4349
+ const ret = await super.start(ctx, await this.#map(url));
4350
+ return ret;
4351
+ }
4352
+ async close(ctx, url) {
4353
+ const ret = await super.close(ctx, await this.#map(url));
4354
+ return ret;
4355
+ }
4356
+ async delete(ctx, url) {
4357
+ const ret = await super.delete(ctx, await this.#map(url));
4358
+ return ret;
4359
+ }
4360
+ async destroy(ctx, url) {
4361
+ const ret = await super.destroy(ctx, await this.#map(url));
4362
+ return ret;
4363
+ }
4364
+ async put(ctx, url, body) {
4365
+ const ret = await super.put(ctx, await this.#map(url), body);
4366
+ return ret;
4367
+ }
4368
+ async get(ctx, url) {
4369
+ const ret = await super.get(ctx, await this.#map(url));
4370
+ return ret;
4371
+ }
4372
+ async subscribe(ctx, url, callback) {
4373
+ const ret = await super.subscribe(ctx, await this.#map(url), callback);
4374
+ return ret;
4375
+ }
4376
+ };
4377
+
4342
4378
  // src/crdt-helpers.ts
4343
4379
  var import_link2 = require("multiformats/link");
4344
4380
  var import_sha27 = require("multiformats/hashes/sha2");
@@ -5276,6 +5312,6 @@ __export(file_exports, {
5276
5312
 
5277
5313
  // src/version.ts
5278
5314
  var PACKAGE_VERSION = Object.keys({
5279
- "0.20.0-dev-preview-54": "xxxx"
5315
+ "0.20.0-dev-preview-55": "xxxx"
5280
5316
  })[0];
5281
5317
  //# sourceMappingURL=index.cjs.map