@fireproof/core 0.20.0-dev-preview-57 → 0.20.0-dev-preview-58

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,12 +1,12 @@
1
1
  {
2
2
  "imports": {
3
3
  "@fireproof/core": "./index.js",
4
- "@adviser/cement": "npm:@adviser/cement@~0.4.3",
4
+ "@adviser/cement": "npm:@adviser/cement@~0.4.4",
5
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",
9
- "cborg": "npm:cborg@^4.2.8",
9
+ "cborg": "npm:cborg@^4.2.9",
10
10
  "jose": "npm:jose@^6.0.10",
11
11
  "multiformats": "npm:multiformats@^13.3.2",
12
12
  "charwise": "npm:charwise@^3.0.1",
package/index.cjs CHANGED
@@ -68,6 +68,7 @@ __export(index_exports, {
68
68
  ps: () => protocols_exports,
69
69
  rt: () => runtime_exports,
70
70
  runtime: () => runtime_exports,
71
+ setPresetEnv: () => setPresetEnv,
71
72
  storeType2DataMetaWal: () => storeType2DataMetaWal,
72
73
  throwFalsy: () => throwFalsy,
73
74
  toSortedArray: () => toSortedArray,
@@ -186,15 +187,21 @@ var SuperThisImpl = class _SuperThisImpl {
186
187
  });
187
188
  }
188
189
  };
189
- function presetEnv() {
190
+ function presetEnv(ipreset) {
191
+ let preset = {};
192
+ if (ipreset instanceof Map) {
193
+ preset = Object.fromEntries(ipreset.entries());
194
+ } else if (typeof ipreset === "object" && ipreset !== null) {
195
+ preset = ipreset;
196
+ }
190
197
  const penv = new Map([
191
198
  // ["FP_DEBUG", "xxx"],
192
199
  // ["FP_ENV", "development"],
193
200
  ...Array.from(
194
- Object.entries(
195
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
196
- globalThis[Symbol.for("FP_PRESET_ENV")] || {}
197
- )
201
+ Object.entries({
202
+ ...setPresetEnv({}),
203
+ ...preset
204
+ })
198
205
  )
199
206
  // .map(([k, v]) => [k, v as string])
200
207
  ]);
@@ -231,7 +238,7 @@ function onSuperThis(fn) {
231
238
  function ensureSuperThis(osthis) {
232
239
  const env = (0, import_cement.envFactory)({
233
240
  symbol: osthis?.env?.symbol || "FP_ENV",
234
- presetEnv: osthis?.env?.presetEnv || presetEnv()
241
+ presetEnv: presetEnv(osthis?.env?.presetEnv)
235
242
  });
236
243
  const ret = new SuperThisImpl({
237
244
  logger: osthis?.logger || globalLogger(),
@@ -497,6 +504,14 @@ function ensureURIDefaults(sthis, name, curi, uri, store, ctx) {
497
504
  }
498
505
  return ret.URI();
499
506
  }
507
+ function setPresetEnv(o, symbol = "FP_PRESET_ENV") {
508
+ const key = Symbol.for(symbol);
509
+ const env = globalThis[key] ?? {};
510
+ for (const [k, v] of Object.entries(o)) {
511
+ env[k] = v;
512
+ }
513
+ return env;
514
+ }
500
515
 
501
516
  // src/write-queue.ts
502
517
  var import_cement2 = require("@adviser/cement");
@@ -5335,7 +5350,7 @@ var SessionTokenService = class _SessionTokenService {
5335
5350
  }
5336
5351
  };
5337
5352
  }
5338
- static async createFromEnv(sp = {}, sthis = ensureSuperThis()) {
5353
+ static async createFromEnv(sthis, sp = {}) {
5339
5354
  let envToken = sthis.env.get(sp.privateEnvKey ?? envKeyDefaults.SECRET);
5340
5355
  if (!envToken) {
5341
5356
  envToken = sthis.env.get(sp.publicEnvKey ?? envKeyDefaults.PUBLIC);
@@ -5745,6 +5760,14 @@ function toHttpProtocol(uri) {
5745
5760
  }
5746
5761
  return toFix.URI();
5747
5762
  }
5763
+ function ensurePath(uri, fp) {
5764
+ const path = uri.pathname.replace(/\/$/, "").replace(/^\//, "");
5765
+ const buri = uri.build();
5766
+ if (path === "") {
5767
+ buri.appendRelative(fp);
5768
+ }
5769
+ return buri.toString();
5770
+ }
5748
5771
  var HttpConnection = class extends MsgRawConnectionBase {
5749
5772
  constructor(sthis, uris, msgP, exGestalt) {
5750
5773
  super(sthis, exGestalt);
@@ -5833,7 +5856,7 @@ var HttpConnection = class extends MsgRawConnectionBase {
5833
5856
  const rRes = await (0, import_cement23.exception2Result)(
5834
5857
  () => timeout(
5835
5858
  this.msgP.timeout,
5836
- fetch(url.cleaned.toString(), {
5859
+ fetch(ensurePath(url.cleaned, "fp"), {
5837
5860
  method: "PUT",
5838
5861
  headers: headers.AsHeaderInit(),
5839
5862
  body: rReqBody.Ok()
@@ -6189,11 +6212,12 @@ var Msger = class _Msger {
6189
6212
  static async openWS(sthis, url, msgP, exGestalt) {
6190
6213
  let ws;
6191
6214
  url = url.build().setParam("random", sthis.nextId().str).URI();
6215
+ const wsUrl = ensurePath(url, "ws");
6192
6216
  if ((0, import_cement25.runtimeFn)().isNodeIsh) {
6193
6217
  const { WebSocket: WebSocket2 } = await import("ws");
6194
- ws = new WebSocket2(url.toString());
6218
+ ws = new WebSocket2(wsUrl);
6195
6219
  } else {
6196
- ws = new WebSocket(url.toString());
6220
+ ws = new WebSocket(wsUrl);
6197
6221
  }
6198
6222
  return import_cement25.Result.Ok(new WSConnection(sthis, ws, msgP, exGestalt));
6199
6223
  }
@@ -7169,6 +7193,7 @@ __export(cloud_exports, {
7169
7193
  coerceFPStoreTypes: () => coerceFPStoreTypes,
7170
7194
  defaultGestalt: () => defaultGestalt,
7171
7195
  defaultMsgParams: () => defaultMsgParams,
7196
+ ensurePath: () => ensurePath,
7172
7197
  isAuthTypeFPCloud: () => isAuthTypeFPCloud,
7173
7198
  isAuthTypeFPCloudJWK: () => isAuthTypeFPCloudJWK,
7174
7199
  isProtocolCapabilities: () => isProtocolCapabilities,
@@ -7239,6 +7264,6 @@ function buildResDelWAL(msgCtx, req, ctx) {
7239
7264
 
7240
7265
  // src/version.ts
7241
7266
  var PACKAGE_VERSION = Object.keys({
7242
- "0.20.0-dev-preview-57": "xxxx"
7267
+ "0.20.0-dev-preview-58": "xxxx"
7243
7268
  })[0];
7244
7269
  //# sourceMappingURL=index.cjs.map