@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 +2 -2
- package/index.cjs +226 -190
- package/index.cjs.map +1 -1
- package/index.d.cts +45 -29
- package/index.d.ts +45 -29
- package/index.js +227 -191
- package/index.js.map +1 -1
- package/metafile-cjs.json +1 -1
- package/metafile-esm.json +1 -1
- package/package.json +3 -3
- package/react/index.cjs.map +1 -1
- package/react/index.d.cts +1 -2
- package/react/index.d.ts +1 -2
- package/react/index.js.map +1 -1
- package/react/metafile-cjs.json +1 -1
- package/react/metafile-esm.json +1 -1
- package/tests/blockstore/interceptor-gateway.test.ts +120 -3
- package/tests/fireproof/database.test.ts +14 -0
package/index.js
CHANGED
@@ -5,7 +5,7 @@ var __export = (target, all) => {
|
|
5
5
|
};
|
6
6
|
|
7
7
|
// src/ledger.ts
|
8
|
-
import { BuildURI as BuildURI2, KeyedResolvOnce as
|
8
|
+
import { BuildURI as BuildURI2, KeyedResolvOnce as KeyedResolvOnce5, ResolveOnce as ResolveOnce7, URI as URI13 } from "@adviser/cement";
|
9
9
|
|
10
10
|
// src/utils.ts
|
11
11
|
import {
|
@@ -2113,6 +2113,9 @@ var DatabaseImpl = class {
|
|
2113
2113
|
const result = await this.ledger.writeQueue.push({ id, del: true });
|
2114
2114
|
return { id, clock: result?.head, name: this.name };
|
2115
2115
|
}
|
2116
|
+
async remove(id) {
|
2117
|
+
return this.del(id);
|
2118
|
+
}
|
2116
2119
|
async changes(since = [], opts = {}) {
|
2117
2120
|
await this.ready();
|
2118
2121
|
this.logger.Debug().Any("since", since).Any("opts", opts).Msg("changes");
|
@@ -2179,6 +2182,7 @@ __export(blockstore_exports, {
|
|
2179
2182
|
MetaActiveStore: () => MetaActiveStore,
|
2180
2183
|
PassThroughGateway: () => PassThroughGateway,
|
2181
2184
|
TaskManager: () => TaskManager,
|
2185
|
+
URIInterceptor: () => URIInterceptor,
|
2182
2186
|
WALActiveStore: () => WALActiveStore,
|
2183
2187
|
createAttachedStores: () => createAttachedStores,
|
2184
2188
|
createDbMetaEvent: () => createDbMetaEvent,
|
@@ -2186,7 +2190,7 @@ __export(blockstore_exports, {
|
|
2186
2190
|
ensureStoreEnDeFile: () => ensureStoreEnDeFile,
|
2187
2191
|
getDefaultURI: () => getDefaultURI,
|
2188
2192
|
getGatewayFactoryItem: () => getGatewayFactoryItem,
|
2189
|
-
|
2193
|
+
getInterceptableGateway: () => getInterceptableGateway,
|
2190
2194
|
parseCarFile: () => parseCarFile,
|
2191
2195
|
registerStoreProtocol: () => registerStoreProtocol,
|
2192
2196
|
toCIDBlock: () => toCIDBlock,
|
@@ -2246,10 +2250,10 @@ var WALActiveStore = class extends BaseActiveStore {
|
|
2246
2250
|
};
|
2247
2251
|
|
2248
2252
|
// src/blockstore/store-factory.ts
|
2249
|
-
import {
|
2253
|
+
import { Result as Result11 } from "@adviser/cement";
|
2250
2254
|
|
2251
2255
|
// src/blockstore/store.ts
|
2252
|
-
import { exception2Result as exception2Result4, ResolveOnce as ResolveOnce4, Result as
|
2256
|
+
import { exception2Result as exception2Result4, ResolveOnce as ResolveOnce4, Result as Result9 } from "@adviser/cement";
|
2253
2257
|
|
2254
2258
|
// src/blockstore/loader.ts
|
2255
2259
|
import pLimit from "p-limit";
|
@@ -3579,151 +3583,11 @@ import { EventBlock as EventBlock2 } from "@fireproof/vendor/@web3-storage/pail/
|
|
3579
3583
|
import { format as format2 } from "@ipld/dag-json";
|
3580
3584
|
import pRetry from "p-retry";
|
3581
3585
|
import pMap from "p-map";
|
3582
|
-
|
3583
|
-
// src/blockstore/interceptor-gateway.ts
|
3584
|
-
import { Result as Result9 } from "@adviser/cement";
|
3585
|
-
var PassThroughGateway = class {
|
3586
|
-
async buildUrl(ctx, url, key) {
|
3587
|
-
const op = { url, key };
|
3588
|
-
return Result9.Ok({ op });
|
3589
|
-
}
|
3590
|
-
async start(ctx, url) {
|
3591
|
-
const op = { url };
|
3592
|
-
return Result9.Ok({ op });
|
3593
|
-
}
|
3594
|
-
async close(ctx, url) {
|
3595
|
-
const op = { url };
|
3596
|
-
return Result9.Ok({ op });
|
3597
|
-
}
|
3598
|
-
async delete(ctx, url) {
|
3599
|
-
const op = { url };
|
3600
|
-
return Result9.Ok({ op });
|
3601
|
-
}
|
3602
|
-
async destroy(ctx, url) {
|
3603
|
-
const op = { url };
|
3604
|
-
return Result9.Ok({ op });
|
3605
|
-
}
|
3606
|
-
async put(ctx, url, body) {
|
3607
|
-
const op = { url, body };
|
3608
|
-
return Result9.Ok({ op });
|
3609
|
-
}
|
3610
|
-
async get(ctx, url) {
|
3611
|
-
const op = { url };
|
3612
|
-
return Result9.Ok({ op });
|
3613
|
-
}
|
3614
|
-
async subscribe(ctx, url, callback) {
|
3615
|
-
const op = { url, callback };
|
3616
|
-
return Result9.Ok({ op });
|
3617
|
-
}
|
3618
|
-
};
|
3619
|
-
var passThrougthGateway = new PassThroughGateway();
|
3620
|
-
var InterceptorGateway = class {
|
3621
|
-
constructor(sthis, innerGW, interceptor) {
|
3622
|
-
this.innerGW = innerGW;
|
3623
|
-
this.interceptor = interceptor || passThrougthGateway;
|
3624
|
-
}
|
3625
|
-
async buildUrl(ctx, baseUrl, key) {
|
3626
|
-
const rret = await this.interceptor.buildUrl(ctx, baseUrl, key);
|
3627
|
-
if (rret.isErr()) {
|
3628
|
-
return Result9.Err(rret.Err());
|
3629
|
-
}
|
3630
|
-
const ret = rret.unwrap();
|
3631
|
-
if (ret.stop && ret.value) {
|
3632
|
-
return ret.value;
|
3633
|
-
}
|
3634
|
-
return this.innerGW.buildUrl(ctx, ret.op.url, ret.op.key);
|
3635
|
-
}
|
3636
|
-
async destroy(ctx, iurl) {
|
3637
|
-
const rret = await this.interceptor.destroy(ctx, iurl);
|
3638
|
-
if (rret.isErr()) {
|
3639
|
-
return Result9.Err(rret.Err());
|
3640
|
-
}
|
3641
|
-
const ret = rret.unwrap();
|
3642
|
-
if (ret.stop && ret.value) {
|
3643
|
-
return ret.value;
|
3644
|
-
}
|
3645
|
-
return this.innerGW.destroy(ctx, ret.op.url);
|
3646
|
-
}
|
3647
|
-
async start(ctx, url) {
|
3648
|
-
const rret = await this.interceptor.start(ctx, url);
|
3649
|
-
if (rret.isErr()) {
|
3650
|
-
return Result9.Err(rret.Err());
|
3651
|
-
}
|
3652
|
-
const ret = rret.unwrap();
|
3653
|
-
if (ret.stop && ret.value) {
|
3654
|
-
return ret.value;
|
3655
|
-
}
|
3656
|
-
return await this.innerGW.start(ctx, ret.op.url);
|
3657
|
-
}
|
3658
|
-
async close(ctx, url) {
|
3659
|
-
const rret = await this.interceptor.close(ctx, url);
|
3660
|
-
if (rret.isErr()) {
|
3661
|
-
return Result9.Err(rret.Err());
|
3662
|
-
}
|
3663
|
-
const ret = rret.unwrap();
|
3664
|
-
if (ret.stop && ret.value) {
|
3665
|
-
return ret.value;
|
3666
|
-
}
|
3667
|
-
return await this.innerGW.close(ctx, ret.op.url);
|
3668
|
-
}
|
3669
|
-
async put(ctx, url, fpEnv) {
|
3670
|
-
const rret = await this.interceptor.put(ctx, url, fpEnv);
|
3671
|
-
if (rret.isErr()) {
|
3672
|
-
return Result9.Err(rret.Err());
|
3673
|
-
}
|
3674
|
-
const ret = rret.unwrap();
|
3675
|
-
if (ret.stop && ret.value) {
|
3676
|
-
return ret.value;
|
3677
|
-
}
|
3678
|
-
return this.innerGW.put(ctx, ret.op.url, ret.op.body);
|
3679
|
-
}
|
3680
|
-
async get(ctx, url) {
|
3681
|
-
const rret = await this.interceptor.get(ctx, url);
|
3682
|
-
if (rret.isErr()) {
|
3683
|
-
return Result9.Err(rret.Err());
|
3684
|
-
}
|
3685
|
-
const ret = rret.unwrap();
|
3686
|
-
if (ret.stop && ret.value) {
|
3687
|
-
return ret.value;
|
3688
|
-
}
|
3689
|
-
return this.innerGW.get(ctx, ret.op.url);
|
3690
|
-
}
|
3691
|
-
async subscribe(ctx, url, callback) {
|
3692
|
-
if (!this.innerGW.subscribe) {
|
3693
|
-
return Result9.Err(ctx.loader.sthis.logger.Error().Url(url).Msg("subscribe not supported").AsError());
|
3694
|
-
}
|
3695
|
-
const rret = await this.interceptor.subscribe(ctx, url, callback);
|
3696
|
-
if (rret.isErr()) {
|
3697
|
-
return Result9.Err(rret.Err());
|
3698
|
-
}
|
3699
|
-
const ret = rret.unwrap();
|
3700
|
-
if (ret.stop && ret.value) {
|
3701
|
-
return ret.value;
|
3702
|
-
}
|
3703
|
-
return this.innerGW.subscribe(ctx, ret.op.url, ret.op.callback);
|
3704
|
-
}
|
3705
|
-
async delete(ctx, url) {
|
3706
|
-
const rret = await this.interceptor.delete(ctx, url);
|
3707
|
-
if (rret.isErr()) {
|
3708
|
-
return Result9.Err(rret.Err());
|
3709
|
-
}
|
3710
|
-
const ret = rret.unwrap();
|
3711
|
-
if (ret.stop && ret.value) {
|
3712
|
-
return ret.value;
|
3713
|
-
}
|
3714
|
-
return this.innerGW.delete(ctx, url);
|
3715
|
-
}
|
3716
|
-
async getPlain(ctx, url, key) {
|
3717
|
-
return this.innerGW.getPlain(ctx, url, key);
|
3718
|
-
}
|
3719
|
-
};
|
3720
|
-
|
3721
|
-
// src/blockstore/store.ts
|
3722
3586
|
function guardVersion(url) {
|
3723
3587
|
if (!url.hasParam("version")) {
|
3724
|
-
return
|
3588
|
+
return Result9.Err(`missing version: ${url.toString()}`);
|
3725
3589
|
}
|
3726
|
-
return
|
3590
|
+
return Result9.Ok(url);
|
3727
3591
|
}
|
3728
3592
|
var BaseStoreImpl = class {
|
3729
3593
|
// readonly loader: Loadable;
|
@@ -3739,8 +3603,10 @@ var BaseStoreImpl = class {
|
|
3739
3603
|
throw logger.Error().Url(this._url).Msg("missing name").AsError();
|
3740
3604
|
}
|
3741
3605
|
this.logger = logger.With().Str("this", this.sthis.nextId().str).Ref("url", () => this._url.toString()).Logger();
|
3742
|
-
this.
|
3743
|
-
|
3606
|
+
this.gateway = opts.gateway;
|
3607
|
+
}
|
3608
|
+
get realGateway() {
|
3609
|
+
return this.gateway.innerGW;
|
3744
3610
|
}
|
3745
3611
|
url() {
|
3746
3612
|
return this._url;
|
@@ -3890,7 +3756,7 @@ var MetaStoreImpl = class extends BaseStoreImpl {
|
|
3890
3756
|
async close() {
|
3891
3757
|
await this.gateway.close({ loader: this.loader }, this.url());
|
3892
3758
|
this._onClosed.forEach((fn) => fn());
|
3893
|
-
return
|
3759
|
+
return Result9.Ok(void 0);
|
3894
3760
|
}
|
3895
3761
|
async destroy() {
|
3896
3762
|
this.logger.Debug().Msg("destroy");
|
@@ -3957,7 +3823,7 @@ var DataStoreImpl = class extends BaseStoreImpl {
|
|
3957
3823
|
async close() {
|
3958
3824
|
await this.gateway.close({ loader: this.loader }, this.url());
|
3959
3825
|
this._onClosed.forEach((fn) => fn());
|
3960
|
-
return
|
3826
|
+
return Result9.Ok(void 0);
|
3961
3827
|
}
|
3962
3828
|
destroy() {
|
3963
3829
|
this.logger.Debug().Msg("destroy");
|
@@ -4044,7 +3910,7 @@ var WALStoreImpl = class extends BaseStoreImpl {
|
|
4044
3910
|
const retryableUpload = (fn, description) => pRetry(fn, {
|
4045
3911
|
retries: 5,
|
4046
3912
|
onFailedAttempt: (error) => {
|
4047
|
-
this.logger.Warn().Msg(`Attempt ${error.attemptNumber} failed for ${description}. There are ${error.retriesLeft} retries left.`);
|
3913
|
+
this.logger.Warn().Any("error", error).Any("fn", fn.toString()).Msg(`Attempt ${error.attemptNumber} failed for ${description}. There are ${error.retriesLeft} retries left.`);
|
4048
3914
|
}
|
4049
3915
|
});
|
4050
3916
|
try {
|
@@ -4159,7 +4025,7 @@ var WALStoreImpl = class extends BaseStoreImpl {
|
|
4159
4025
|
async close() {
|
4160
4026
|
await this.gateway.close({ loader: this.loader }, this.url());
|
4161
4027
|
this._onClosed.forEach((fn) => fn());
|
4162
|
-
return
|
4028
|
+
return Result9.Ok(void 0);
|
4163
4029
|
}
|
4164
4030
|
destroy() {
|
4165
4031
|
this.logger.Debug().Msg("destroy");
|
@@ -4167,81 +4033,200 @@ var WALStoreImpl = class extends BaseStoreImpl {
|
|
4167
4033
|
}
|
4168
4034
|
};
|
4169
4035
|
|
4170
|
-
// src/blockstore/
|
4171
|
-
|
4172
|
-
var
|
4173
|
-
async
|
4174
|
-
|
4175
|
-
|
4176
|
-
|
4177
|
-
|
4178
|
-
|
4179
|
-
|
4180
|
-
|
4181
|
-
|
4182
|
-
|
4183
|
-
|
4184
|
-
|
4185
|
-
|
4186
|
-
|
4187
|
-
|
4188
|
-
|
4036
|
+
// src/blockstore/interceptor-gateway.ts
|
4037
|
+
import { Result as Result10 } from "@adviser/cement";
|
4038
|
+
var PassThroughGateway = class {
|
4039
|
+
async buildUrl(ctx, url, key) {
|
4040
|
+
const op = { url, key };
|
4041
|
+
return Result10.Ok({ op });
|
4042
|
+
}
|
4043
|
+
async start(ctx, url) {
|
4044
|
+
const op = { url };
|
4045
|
+
return Result10.Ok({ op });
|
4046
|
+
}
|
4047
|
+
async close(ctx, url) {
|
4048
|
+
const op = { url };
|
4049
|
+
return Result10.Ok({ op });
|
4050
|
+
}
|
4051
|
+
async delete(ctx, url) {
|
4052
|
+
const op = { url };
|
4053
|
+
return Result10.Ok({ op });
|
4054
|
+
}
|
4055
|
+
async destroy(ctx, url) {
|
4056
|
+
const op = { url };
|
4057
|
+
return Result10.Ok({ op });
|
4058
|
+
}
|
4059
|
+
async put(ctx, url, body) {
|
4060
|
+
const op = { url, body };
|
4061
|
+
return Result10.Ok({ op });
|
4062
|
+
}
|
4063
|
+
async get(ctx, url) {
|
4064
|
+
const op = { url };
|
4065
|
+
return Result10.Ok({ op });
|
4066
|
+
}
|
4067
|
+
async subscribe(ctx, url, callback) {
|
4068
|
+
const op = { url, callback };
|
4069
|
+
return Result10.Ok({ op });
|
4070
|
+
}
|
4071
|
+
};
|
4072
|
+
var passThrougthGateway = new PassThroughGateway();
|
4073
|
+
var InterceptorGateway = class {
|
4074
|
+
constructor(sthis, innerGW, interceptor) {
|
4075
|
+
this.innerGW = innerGW;
|
4076
|
+
this.interceptor = interceptor || passThrougthGateway;
|
4077
|
+
}
|
4078
|
+
async buildUrl(ctx, baseUrl, key) {
|
4079
|
+
const rret = await this.interceptor.buildUrl(ctx, baseUrl, key);
|
4080
|
+
if (rret.isErr()) {
|
4081
|
+
return Result10.Err(rret.Err());
|
4189
4082
|
}
|
4190
|
-
|
4191
|
-
|
4083
|
+
const ret = rret.unwrap();
|
4084
|
+
if (ret.stop && ret.value) {
|
4085
|
+
return ret.value;
|
4086
|
+
}
|
4087
|
+
return this.innerGW.buildUrl(ctx, ret.op.url, ret.op.key);
|
4088
|
+
}
|
4089
|
+
async destroy(ctx, iurl) {
|
4090
|
+
const rret = await this.interceptor.destroy(ctx, iurl);
|
4091
|
+
if (rret.isErr()) {
|
4092
|
+
return Result10.Err(rret.Err());
|
4093
|
+
}
|
4094
|
+
const ret = rret.unwrap();
|
4095
|
+
if (ret.stop && ret.value) {
|
4096
|
+
return ret.value;
|
4097
|
+
}
|
4098
|
+
return this.innerGW.destroy(ctx, ret.op.url);
|
4099
|
+
}
|
4100
|
+
async start(ctx, url) {
|
4101
|
+
const rret = await this.interceptor.start(ctx, url);
|
4102
|
+
if (rret.isErr()) {
|
4103
|
+
return Result10.Err(rret.Err());
|
4104
|
+
}
|
4105
|
+
const ret = rret.unwrap();
|
4106
|
+
if (ret.stop && ret.value) {
|
4107
|
+
return ret.value;
|
4108
|
+
}
|
4109
|
+
return await this.innerGW.start(ctx, ret.op.url);
|
4110
|
+
}
|
4111
|
+
async close(ctx, url) {
|
4112
|
+
const rret = await this.interceptor.close(ctx, url);
|
4113
|
+
if (rret.isErr()) {
|
4114
|
+
return Result10.Err(rret.Err());
|
4115
|
+
}
|
4116
|
+
const ret = rret.unwrap();
|
4117
|
+
if (ret.stop && ret.value) {
|
4118
|
+
return ret.value;
|
4119
|
+
}
|
4120
|
+
return await this.innerGW.close(ctx, ret.op.url);
|
4121
|
+
}
|
4122
|
+
async put(ctx, url, fpEnv) {
|
4123
|
+
const rret = await this.interceptor.put(ctx, url, fpEnv);
|
4124
|
+
if (rret.isErr()) {
|
4125
|
+
return Result10.Err(rret.Err());
|
4126
|
+
}
|
4127
|
+
const ret = rret.unwrap();
|
4128
|
+
if (ret.stop && ret.value) {
|
4129
|
+
return ret.value;
|
4130
|
+
}
|
4131
|
+
return this.innerGW.put(ctx, ret.op.url, ret.op.body);
|
4132
|
+
}
|
4133
|
+
async get(ctx, url) {
|
4134
|
+
const rret = await this.interceptor.get(ctx, url);
|
4135
|
+
if (rret.isErr()) {
|
4136
|
+
return Result10.Err(rret.Err());
|
4137
|
+
}
|
4138
|
+
const ret = rret.unwrap();
|
4139
|
+
if (ret.stop && ret.value) {
|
4140
|
+
return ret.value;
|
4141
|
+
}
|
4142
|
+
return this.innerGW.get(ctx, ret.op.url);
|
4143
|
+
}
|
4144
|
+
async subscribe(ctx, url, callback) {
|
4145
|
+
if (!this.innerGW.subscribe) {
|
4146
|
+
return Result10.Err(ctx.loader.sthis.logger.Error().Url(url).Msg("subscribe not supported").AsError());
|
4147
|
+
}
|
4148
|
+
const rret = await this.interceptor.subscribe(ctx, url, callback);
|
4149
|
+
if (rret.isErr()) {
|
4150
|
+
return Result10.Err(rret.Err());
|
4151
|
+
}
|
4152
|
+
const ret = rret.unwrap();
|
4153
|
+
if (ret.stop && ret.value) {
|
4154
|
+
return ret.value;
|
4155
|
+
}
|
4156
|
+
return this.innerGW.subscribe(ctx, ret.op.url, ret.op.callback);
|
4157
|
+
}
|
4158
|
+
async delete(ctx, url) {
|
4159
|
+
const rret = await this.interceptor.delete(ctx, url);
|
4160
|
+
if (rret.isErr()) {
|
4161
|
+
return Result10.Err(rret.Err());
|
4162
|
+
}
|
4163
|
+
const ret = rret.unwrap();
|
4164
|
+
if (ret.stop && ret.value) {
|
4165
|
+
return ret.value;
|
4166
|
+
}
|
4167
|
+
return this.innerGW.delete(ctx, url);
|
4168
|
+
}
|
4169
|
+
async getPlain(ctx, url, key) {
|
4170
|
+
return this.innerGW.getPlain(ctx, url, key);
|
4171
|
+
}
|
4172
|
+
};
|
4173
|
+
|
4174
|
+
// src/blockstore/store-factory.ts
|
4175
|
+
async function getInterceptableGateway(ctx, url, opt) {
|
4176
|
+
const item = getGatewayFactoryItem(url.protocol);
|
4177
|
+
if (item) {
|
4178
|
+
return Result11.Ok(new InterceptorGateway(ctx.loader.sthis, await item.serdegateway(ctx.loader.sthis), opt.gatewayInterceptor));
|
4179
|
+
}
|
4180
|
+
return Result11.Err(ctx.loader.sthis.logger.Warn().Url(url).Msg("unsupported protocol").AsError());
|
4192
4181
|
}
|
4193
4182
|
async function carStoreFactory(ctx, uai) {
|
4194
4183
|
const storeUrl = uai.url.build().setParam(PARAM.STORE, "car").URI();
|
4195
|
-
const rgateway = await
|
4184
|
+
const rgateway = await getInterceptableGateway(ctx, storeUrl, uai);
|
4196
4185
|
if (rgateway.isErr()) {
|
4197
4186
|
throw ctx.loader.sthis.logger.Error().Result("err", rgateway).Url(uai.url).Msg("notfound").AsError();
|
4198
4187
|
}
|
4199
4188
|
const gateway = rgateway.Ok();
|
4200
|
-
const store = new CarStoreImpl(ctx.loader.sthis,
|
4201
|
-
gateway
|
4202
|
-
gatewayInterceptor: uai.gatewayInterceptor,
|
4189
|
+
const store = new CarStoreImpl(ctx.loader.sthis, uai.url, {
|
4190
|
+
gateway,
|
4203
4191
|
loader: ctx.loader
|
4204
4192
|
});
|
4205
4193
|
return store;
|
4206
4194
|
}
|
4207
4195
|
async function fileStoreFactory(ctx, uai) {
|
4208
4196
|
const storeUrl = uai.url.build().setParam(PARAM.STORE, "file").URI();
|
4209
|
-
const rgateway = await
|
4197
|
+
const rgateway = await getInterceptableGateway(ctx, storeUrl, uai);
|
4210
4198
|
if (rgateway.isErr()) {
|
4211
4199
|
throw ctx.loader.sthis.logger.Error().Result("err", rgateway).Url(uai.url).Msg("notfound").AsError();
|
4212
4200
|
}
|
4213
4201
|
const gateway = rgateway.Ok();
|
4214
|
-
const store = new FileStoreImpl(ctx.loader.sthis,
|
4215
|
-
gateway
|
4216
|
-
gatewayInterceptor: uai.gatewayInterceptor,
|
4202
|
+
const store = new FileStoreImpl(ctx.loader.sthis, uai.url, {
|
4203
|
+
gateway,
|
4217
4204
|
loader: ctx.loader
|
4218
4205
|
});
|
4219
4206
|
return store;
|
4220
4207
|
}
|
4221
4208
|
async function metaStoreFactory(ctx, uai) {
|
4222
4209
|
const storeUrl = uai.url.build().setParam(PARAM.STORE, "meta").URI();
|
4223
|
-
const rgateway = await
|
4210
|
+
const rgateway = await getInterceptableGateway(ctx, storeUrl, uai);
|
4224
4211
|
if (rgateway.isErr()) {
|
4225
4212
|
throw ctx.loader.sthis.logger.Error().Result("err", rgateway).Url(uai.url).Msg("notfound").AsError();
|
4226
4213
|
}
|
4227
4214
|
const gateway = rgateway.Ok();
|
4228
|
-
const store = new MetaStoreImpl(ctx.loader.sthis,
|
4229
|
-
gateway
|
4230
|
-
gatewayInterceptor: uai.gatewayInterceptor,
|
4215
|
+
const store = new MetaStoreImpl(ctx.loader.sthis, uai.url, {
|
4216
|
+
gateway,
|
4231
4217
|
loader: ctx.loader
|
4232
4218
|
});
|
4233
4219
|
return store;
|
4234
4220
|
}
|
4235
4221
|
async function WALStoreFactory(ctx, uai) {
|
4236
4222
|
const storeUrl = uai.url.build().setParam(PARAM.STORE, "wal").URI();
|
4237
|
-
const rgateway = await
|
4223
|
+
const rgateway = await getInterceptableGateway(ctx, storeUrl, uai);
|
4238
4224
|
if (rgateway.isErr()) {
|
4239
4225
|
throw ctx.loader.sthis.logger.Error().Result("err", rgateway).Url(uai.url).Msg("notfound").AsError();
|
4240
4226
|
}
|
4241
4227
|
const gateway = rgateway.Ok();
|
4242
|
-
const store = new WALStoreImpl(ctx.loader.sthis,
|
4243
|
-
gateway
|
4244
|
-
gatewayInterceptor: uai.gatewayInterceptor,
|
4228
|
+
const store = new WALStoreImpl(ctx.loader.sthis, uai.url, {
|
4229
|
+
gateway,
|
4245
4230
|
loader: ctx.loader
|
4246
4231
|
});
|
4247
4232
|
return store;
|
@@ -4289,6 +4274,57 @@ function toStoreRuntime(sthis, endeOpts = {}) {
|
|
4289
4274
|
};
|
4290
4275
|
}
|
4291
4276
|
|
4277
|
+
// src/blockstore/uri-interceptor.ts
|
4278
|
+
var URIInterceptor = class _URIInterceptor extends PassThroughGateway {
|
4279
|
+
static withMapper(mapper) {
|
4280
|
+
return new _URIInterceptor().addMapper(mapper);
|
4281
|
+
}
|
4282
|
+
#uriMapper = /* @__PURE__ */ new Set();
|
4283
|
+
addMapper(mapper) {
|
4284
|
+
this.#uriMapper.add(mapper);
|
4285
|
+
return this;
|
4286
|
+
}
|
4287
|
+
async #map(uri) {
|
4288
|
+
let ret = uri;
|
4289
|
+
for (const mapper of this.#uriMapper) {
|
4290
|
+
ret = await mapper(ret);
|
4291
|
+
}
|
4292
|
+
return ret;
|
4293
|
+
}
|
4294
|
+
async buildUrl(ctx, url, key) {
|
4295
|
+
const ret = await super.buildUrl(ctx, await this.#map(url), key);
|
4296
|
+
return ret;
|
4297
|
+
}
|
4298
|
+
async start(ctx, url) {
|
4299
|
+
const ret = await super.start(ctx, await this.#map(url));
|
4300
|
+
return ret;
|
4301
|
+
}
|
4302
|
+
async close(ctx, url) {
|
4303
|
+
const ret = await super.close(ctx, await this.#map(url));
|
4304
|
+
return ret;
|
4305
|
+
}
|
4306
|
+
async delete(ctx, url) {
|
4307
|
+
const ret = await super.delete(ctx, await this.#map(url));
|
4308
|
+
return ret;
|
4309
|
+
}
|
4310
|
+
async destroy(ctx, url) {
|
4311
|
+
const ret = await super.destroy(ctx, await this.#map(url));
|
4312
|
+
return ret;
|
4313
|
+
}
|
4314
|
+
async put(ctx, url, body) {
|
4315
|
+
const ret = await super.put(ctx, await this.#map(url), body);
|
4316
|
+
return ret;
|
4317
|
+
}
|
4318
|
+
async get(ctx, url) {
|
4319
|
+
const ret = await super.get(ctx, await this.#map(url));
|
4320
|
+
return ret;
|
4321
|
+
}
|
4322
|
+
async subscribe(ctx, url, callback) {
|
4323
|
+
const ret = await super.subscribe(ctx, await this.#map(url), callback);
|
4324
|
+
return ret;
|
4325
|
+
}
|
4326
|
+
};
|
4327
|
+
|
4292
4328
|
// src/crdt-helpers.ts
|
4293
4329
|
import { parse as parse2 } from "multiformats/link";
|
4294
4330
|
import { sha256 as hasher6 } from "multiformats/hashes/sha2";
|
@@ -4942,7 +4978,7 @@ var Context = class {
|
|
4942
4978
|
};
|
4943
4979
|
|
4944
4980
|
// src/ledger.ts
|
4945
|
-
var ledgers = new
|
4981
|
+
var ledgers = new KeyedResolvOnce5();
|
4946
4982
|
function keyConfigOpts(sthis, name, opts) {
|
4947
4983
|
return JSON.stringify(
|
4948
4984
|
toSortedArray({
|
@@ -5226,7 +5262,7 @@ __export(file_exports, {
|
|
5226
5262
|
|
5227
5263
|
// src/version.ts
|
5228
5264
|
var PACKAGE_VERSION = Object.keys({
|
5229
|
-
"0.20.0-dev-preview-
|
5265
|
+
"0.20.0-dev-preview-55": "xxxx"
|
5230
5266
|
})[0];
|
5231
5267
|
export {
|
5232
5268
|
CRDTImpl,
|