@dxos/edge-client 0.7.5-main.9d2a38b → 0.7.5-main.e94eead

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.
@@ -9,9 +9,9 @@ import {
9
9
  export * from "@dxos/protocols/buf/dxos/edge/messenger_pb";
10
10
 
11
11
  // packages/core/mesh/edge-client/src/edge-client.ts
12
- import { Trigger, scheduleMicroTask, TriggerState } from "@dxos/async";
13
- import { Resource as Resource3 } from "@dxos/context";
14
- import { log as log3, logInfo as logInfo2 } from "@dxos/log";
12
+ import { Trigger, scheduleMicroTask, TriggerState, PersistentLifecycle } from "@dxos/async";
13
+ import { Resource as Resource2 } from "@dxos/context";
14
+ import { log as log2, logInfo as logInfo2 } from "@dxos/log";
15
15
 
16
16
  // packages/core/mesh/edge-client/src/edge-identity.ts
17
17
  import { invariant } from "@dxos/invariant";
@@ -68,7 +68,9 @@ function _ts_decorate(decorators, target, key, desc) {
68
68
  return c > 3 && r && Object.defineProperty(target, key, r), r;
69
69
  }
70
70
  var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-ws-connection.ts";
71
- var SIGNAL_KEEPALIVE_INTERVAL = 5e3;
71
+ var SIGNAL_KEEPALIVE_INTERVAL = 4e3;
72
+ var SIGNAL_KEEPALIVE_TIMEOUT = 12e3;
73
+ var CLOUDFLARE_MESSAGE_LENGTH_LIMIT = 1024 * 1024;
72
74
  var EdgeWsConnection = class extends Resource {
73
75
  constructor(_identity, _connectionInfo, _callbacks) {
74
76
  super();
@@ -86,7 +88,7 @@ var EdgeWsConnection = class extends Resource {
86
88
  send(message) {
87
89
  invariant2(this._ws, void 0, {
88
90
  F: __dxlog_file2,
89
- L: 48,
91
+ L: 54,
90
92
  S: this,
91
93
  A: [
92
94
  "this._ws",
@@ -98,11 +100,25 @@ var EdgeWsConnection = class extends Resource {
98
100
  payload: protocol.getPayloadType(message)
99
101
  }, {
100
102
  F: __dxlog_file2,
101
- L: 49,
103
+ L: 55,
102
104
  S: this,
103
105
  C: (f, a) => f(...a)
104
106
  });
105
- this._ws.send(buf.toBinary(MessageSchema, message));
107
+ const encoded = buf.toBinary(MessageSchema, message);
108
+ if (encoded.byteLength >= CLOUDFLARE_MESSAGE_LENGTH_LIMIT) {
109
+ log.error("edge message dropped due to websocket message limit", {
110
+ byteLength: encoded.byteLength,
111
+ serviceId: message.serviceId,
112
+ payload: protocol.getPayloadType(message)
113
+ }, {
114
+ F: __dxlog_file2,
115
+ L: 58,
116
+ S: this,
117
+ C: (f, a) => f(...a)
118
+ });
119
+ return;
120
+ }
121
+ this._ws.send(encoded);
106
122
  }
107
123
  async _open() {
108
124
  this._ws = new WebSocket(this._connectionInfo.url.toString(), this._connectionInfo.protocolHeader ? [
@@ -112,7 +128,7 @@ var EdgeWsConnection = class extends Resource {
112
128
  if (this.isOpen) {
113
129
  log("connected", void 0, {
114
130
  F: __dxlog_file2,
115
- L: 61,
131
+ L: 76,
116
132
  S: this,
117
133
  C: (f, a) => f(...a)
118
134
  });
@@ -123,17 +139,20 @@ var EdgeWsConnection = class extends Resource {
123
139
  currentIdentity: this._identity
124
140
  }, {
125
141
  F: __dxlog_file2,
126
- L: 65,
142
+ L: 80,
127
143
  S: this,
128
144
  C: (f, a) => f(...a)
129
145
  });
130
146
  }
131
147
  };
132
- this._ws.onclose = () => {
148
+ this._ws.onclose = (event) => {
133
149
  if (this.isOpen) {
134
- log("disconnected while being open", void 0, {
150
+ log.warn("disconnected while being open", {
151
+ code: event.code,
152
+ reason: event.reason
153
+ }, {
135
154
  F: __dxlog_file2,
136
- L: 70,
155
+ L: 85,
137
156
  S: this,
138
157
  C: (f, a) => f(...a)
139
158
  });
@@ -147,7 +166,7 @@ var EdgeWsConnection = class extends Resource {
147
166
  info: event.message
148
167
  }, {
149
168
  F: __dxlog_file2,
150
- L: 76,
169
+ L: 91,
151
170
  S: this,
152
171
  C: (f, a) => f(...a)
153
172
  });
@@ -157,7 +176,7 @@ var EdgeWsConnection = class extends Resource {
157
176
  error: event.error
158
177
  }, {
159
178
  F: __dxlog_file2,
160
- L: 79,
179
+ L: 94,
161
180
  S: this,
162
181
  C: (f, a) => f(...a)
163
182
  });
@@ -169,7 +188,7 @@ var EdgeWsConnection = class extends Resource {
169
188
  event: event.type
170
189
  }, {
171
190
  F: __dxlog_file2,
172
- L: 87,
191
+ L: 102,
173
192
  S: this,
174
193
  C: (f, a) => f(...a)
175
194
  });
@@ -187,7 +206,7 @@ var EdgeWsConnection = class extends Resource {
187
206
  payload: protocol.getPayloadType(message)
188
207
  }, {
189
208
  F: __dxlog_file2,
190
- L: 97,
209
+ L: 112,
191
210
  S: this,
192
211
  C: (f, a) => f(...a)
193
212
  });
@@ -209,7 +228,7 @@ var EdgeWsConnection = class extends Resource {
209
228
  err
210
229
  }, {
211
230
  F: __dxlog_file2,
212
- L: 113,
231
+ L: 128,
213
232
  S: this,
214
233
  C: (f, a) => f(...a)
215
234
  });
@@ -218,7 +237,7 @@ var EdgeWsConnection = class extends Resource {
218
237
  _scheduleHeartbeats() {
219
238
  invariant2(this._ws, void 0, {
220
239
  F: __dxlog_file2,
221
- L: 118,
240
+ L: 133,
222
241
  S: this,
223
242
  A: [
224
243
  "this._ws",
@@ -238,13 +257,19 @@ var EdgeWsConnection = class extends Resource {
238
257
  void this._inactivityTimeoutCtx?.dispose();
239
258
  this._inactivityTimeoutCtx = new Context(void 0, {
240
259
  F: __dxlog_file2,
241
- L: 137
260
+ L: 152
242
261
  });
243
262
  scheduleTask(this._inactivityTimeoutCtx, () => {
244
263
  if (this.isOpen) {
264
+ log.warn("restart due to inactivity timeout", void 0, {
265
+ F: __dxlog_file2,
266
+ L: 157,
267
+ S: this,
268
+ C: (f, a) => f(...a)
269
+ });
245
270
  this._callbacks.onRestartRequired();
246
271
  }
247
- }, 2 * SIGNAL_KEEPALIVE_INTERVAL);
272
+ }, SIGNAL_KEEPALIVE_TIMEOUT);
248
273
  }
249
274
  };
250
275
  _ts_decorate([
@@ -263,118 +288,6 @@ var EdgeIdentityChangedError = class extends Error {
263
288
  }
264
289
  };
265
290
 
266
- // packages/core/mesh/edge-client/src/persistent-lifecycle.ts
267
- import { DeferredTask, sleep, synchronized } from "@dxos/async";
268
- import { cancelWithContext, LifecycleState, Resource as Resource2 } from "@dxos/context";
269
- import { warnAfterTimeout } from "@dxos/debug";
270
- import { log as log2 } from "@dxos/log";
271
- function _ts_decorate2(decorators, target, key, desc) {
272
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
273
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
274
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
275
- return c > 3 && r && Object.defineProperty(target, key, r), r;
276
- }
277
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/persistent-lifecycle.ts";
278
- var INIT_RESTART_DELAY = 100;
279
- var DEFAULT_MAX_RESTART_DELAY = 5e3;
280
- var PersistentLifecycle = class extends Resource2 {
281
- constructor({ start, stop, onRestart, maxRestartDelay = DEFAULT_MAX_RESTART_DELAY }) {
282
- super();
283
- this._currentContext = void 0;
284
- this._restartTask = void 0;
285
- this._restartAfter = 0;
286
- this._start = start;
287
- this._stop = stop;
288
- this._onRestart = onRestart;
289
- this._maxRestartDelay = maxRestartDelay;
290
- }
291
- async _open() {
292
- this._restartTask = new DeferredTask(this._ctx, async () => {
293
- try {
294
- await this._restart();
295
- } catch (err) {
296
- log2.warn("Restart failed", {
297
- err
298
- }, {
299
- F: __dxlog_file3,
300
- L: 65,
301
- S: this,
302
- C: (f, a) => f(...a)
303
- });
304
- this._restartTask?.schedule();
305
- }
306
- });
307
- this._currentContext = await this._start().catch((err) => {
308
- log2.warn("Start failed", {
309
- err
310
- }, {
311
- F: __dxlog_file3,
312
- L: 70,
313
- S: this,
314
- C: (f, a) => f(...a)
315
- });
316
- this._restartTask?.schedule();
317
- return void 0;
318
- });
319
- }
320
- async _close() {
321
- await this._restartTask?.join();
322
- await this._stopCurrentContext();
323
- this._restartTask = void 0;
324
- }
325
- async _restart() {
326
- log2(`restarting in ${this._restartAfter}ms`, {
327
- state: this._lifecycleState
328
- }, {
329
- F: __dxlog_file3,
330
- L: 83,
331
- S: this,
332
- C: (f, a) => f(...a)
333
- });
334
- await this._stopCurrentContext();
335
- if (this._lifecycleState !== LifecycleState.OPEN) {
336
- return;
337
- }
338
- await cancelWithContext(this._ctx, sleep(this._restartAfter));
339
- this._restartAfter = Math.min(Math.max(this._restartAfter * 2, INIT_RESTART_DELAY), this._maxRestartDelay);
340
- await warnAfterTimeout(5e3, "Connection establishment takes too long", async () => {
341
- this._currentContext = await this._start();
342
- });
343
- this._restartAfter = 0;
344
- await this._onRestart?.();
345
- }
346
- async _stopCurrentContext() {
347
- if (this._currentContext) {
348
- try {
349
- await this._stop(this._currentContext);
350
- } catch (err) {
351
- log2.catch(err, void 0, {
352
- F: __dxlog_file3,
353
- L: 105,
354
- S: this,
355
- C: (f, a) => f(...a)
356
- });
357
- }
358
- this._currentContext = void 0;
359
- }
360
- }
361
- /**
362
- * Scheduling restart should be done from outside.
363
- */
364
- scheduleRestart() {
365
- if (this._lifecycleState !== LifecycleState.OPEN) {
366
- return;
367
- }
368
- this._restartTask.schedule();
369
- }
370
- };
371
- _ts_decorate2([
372
- synchronized
373
- ], PersistentLifecycle.prototype, "_open", null);
374
- _ts_decorate2([
375
- synchronized
376
- ], PersistentLifecycle.prototype, "scheduleRestart", null);
377
-
378
291
  // packages/core/mesh/edge-client/src/utils.ts
379
292
  var getEdgeUrlWithProtocol = (baseUrl, protocol2) => {
380
293
  const isSecure = baseUrl.startsWith("https") || baseUrl.startsWith("wss");
@@ -384,15 +297,15 @@ var getEdgeUrlWithProtocol = (baseUrl, protocol2) => {
384
297
  };
385
298
 
386
299
  // packages/core/mesh/edge-client/src/edge-client.ts
387
- function _ts_decorate3(decorators, target, key, desc) {
300
+ function _ts_decorate2(decorators, target, key, desc) {
388
301
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
389
302
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
390
303
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
391
304
  return c > 3 && r && Object.defineProperty(target, key, r), r;
392
305
  }
393
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-client.ts";
306
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-client.ts";
394
307
  var DEFAULT_TIMEOUT = 1e4;
395
- var EdgeClient = class extends Resource3 {
308
+ var EdgeClient = class extends Resource2 {
396
309
  constructor(_identity, _config) {
397
310
  super();
398
311
  this._identity = _identity;
@@ -427,12 +340,12 @@ var EdgeClient = class extends Resource3 {
427
340
  }
428
341
  setIdentity(identity) {
429
342
  if (identity.identityKey !== this._identity.identityKey || identity.peerKey !== this._identity.peerKey) {
430
- log3("Edge identity changed", {
343
+ log2("Edge identity changed", {
431
344
  identity,
432
345
  oldIdentity: this._identity
433
346
  }, {
434
- F: __dxlog_file4,
435
- L: 95,
347
+ F: __dxlog_file3,
348
+ L: 94,
436
349
  S: this,
437
350
  C: (f, a) => f(...a)
438
351
  });
@@ -453,9 +366,9 @@ var EdgeClient = class extends Resource3 {
453
366
  try {
454
367
  listener();
455
368
  } catch (error) {
456
- log3.catch(error, void 0, {
457
- F: __dxlog_file4,
458
- L: 117,
369
+ log2.catch(error, void 0, {
370
+ F: __dxlog_file3,
371
+ L: 116,
459
372
  S: this,
460
373
  C: (f, a) => f(...a)
461
374
  });
@@ -469,20 +382,20 @@ var EdgeClient = class extends Resource3 {
469
382
  * Open connection to messaging service.
470
383
  */
471
384
  async _open() {
472
- log3("opening...", {
385
+ log2("opening...", {
473
386
  info: this.info
474
387
  }, {
475
- F: __dxlog_file4,
476
- L: 129,
388
+ F: __dxlog_file3,
389
+ L: 128,
477
390
  S: this,
478
391
  C: (f, a) => f(...a)
479
392
  });
480
393
  this._persistentLifecycle.open().catch((err) => {
481
- log3.warn("Error while opening connection", {
394
+ log2.warn("Error while opening connection", {
482
395
  err
483
396
  }, {
484
- F: __dxlog_file4,
485
- L: 131,
397
+ F: __dxlog_file3,
398
+ L: 130,
486
399
  S: this,
487
400
  C: (f, a) => f(...a)
488
401
  });
@@ -492,11 +405,11 @@ var EdgeClient = class extends Resource3 {
492
405
  * Close connection and free resources.
493
406
  */
494
407
  async _close() {
495
- log3("closing...", {
408
+ log2("closing...", {
496
409
  peerKey: this._identity.peerKey
497
410
  }, {
498
- F: __dxlog_file4,
499
- L: 139,
411
+ F: __dxlog_file3,
412
+ L: 138,
500
413
  S: this,
501
414
  C: (f, a) => f(...a)
502
415
  });
@@ -511,9 +424,9 @@ var EdgeClient = class extends Resource3 {
511
424
  const path = `/ws/${identity.identityKey}/${identity.peerKey}`;
512
425
  const protocolHeader = this._config.disableAuth ? void 0 : await this._createAuthHeader(path);
513
426
  if (this._identity !== identity) {
514
- log3("identity changed during auth header request", void 0, {
515
- F: __dxlog_file4,
516
- L: 153,
427
+ log2("identity changed during auth header request", void 0, {
428
+ F: __dxlog_file3,
429
+ L: 152,
517
430
  S: this,
518
431
  C: (f, a) => f(...a)
519
432
  });
@@ -521,12 +434,12 @@ var EdgeClient = class extends Resource3 {
521
434
  }
522
435
  const restartRequired = new Trigger();
523
436
  const url = new URL(path, this._baseWsUrl);
524
- log3("Opening websocket", {
437
+ log2("Opening websocket", {
525
438
  url: url.toString(),
526
439
  protocolHeader
527
440
  }, {
528
- F: __dxlog_file4,
529
- L: 159,
441
+ F: __dxlog_file3,
442
+ L: 158,
530
443
  S: this,
531
444
  C: (f, a) => f(...a)
532
445
  });
@@ -539,9 +452,9 @@ var EdgeClient = class extends Resource3 {
539
452
  this._ready.wake();
540
453
  this._notifyReconnected();
541
454
  } else {
542
- log3.verbose("connected callback ignored, because connection is not active", void 0, {
543
- F: __dxlog_file4,
544
- L: 169,
455
+ log2.verbose("connected callback ignored, because connection is not active", void 0, {
456
+ F: __dxlog_file3,
457
+ L: 168,
545
458
  S: this,
546
459
  C: (f, a) => f(...a)
547
460
  });
@@ -552,9 +465,9 @@ var EdgeClient = class extends Resource3 {
552
465
  this._closeCurrentConnection();
553
466
  this._persistentLifecycle.scheduleRestart();
554
467
  } else {
555
- log3.verbose("restart requested by inactive connection", void 0, {
556
- F: __dxlog_file4,
557
- L: 177,
468
+ log2.verbose("restart requested by inactive connection", void 0, {
469
+ F: __dxlog_file3,
470
+ L: 176,
558
471
  S: this,
559
472
  C: (f, a) => f(...a)
560
473
  });
@@ -565,12 +478,12 @@ var EdgeClient = class extends Resource3 {
565
478
  if (this._isActive(connection)) {
566
479
  this._notifyMessageReceived(message);
567
480
  } else {
568
- log3.verbose("ignored a message on inactive connection", {
481
+ log2.verbose("ignored a message on inactive connection", {
569
482
  from: message.source,
570
483
  type: message.payload?.typeUrl
571
484
  }, {
572
- F: __dxlog_file4,
573
- L: 185,
485
+ F: __dxlog_file3,
486
+ L: 184,
574
487
  S: this,
575
488
  C: (f, a) => f(...a)
576
489
  });
@@ -600,11 +513,11 @@ var EdgeClient = class extends Resource3 {
600
513
  try {
601
514
  listener();
602
515
  } catch (err) {
603
- log3.error("ws reconnect listener failed", {
516
+ log2.error("ws reconnect listener failed", {
604
517
  err
605
518
  }, {
606
- F: __dxlog_file4,
607
- L: 218,
519
+ F: __dxlog_file3,
520
+ L: 217,
608
521
  S: this,
609
522
  C: (f, a) => f(...a)
610
523
  });
@@ -616,12 +529,12 @@ var EdgeClient = class extends Resource3 {
616
529
  try {
617
530
  listener(message);
618
531
  } catch (err) {
619
- log3.error("ws incoming message processing failed", {
532
+ log2.error("ws incoming message processing failed", {
620
533
  err,
621
534
  payload: protocol.getPayloadType(message)
622
535
  }, {
623
- F: __dxlog_file4,
624
- L: 228,
536
+ F: __dxlog_file3,
537
+ L: 227,
625
538
  S: this,
626
539
  C: (f, a) => f(...a)
627
540
  });
@@ -634,9 +547,9 @@ var EdgeClient = class extends Resource3 {
634
547
  */
635
548
  async send(message) {
636
549
  if (this._ready.state !== TriggerState.RESOLVED) {
637
- log3("waiting for websocket to become ready", void 0, {
638
- F: __dxlog_file4,
639
- L: 239,
550
+ log2("waiting for websocket to become ready", void 0, {
551
+ F: __dxlog_file3,
552
+ L: 238,
640
553
  S: this,
641
554
  C: (f, a) => f(...a)
642
555
  });
@@ -661,12 +574,12 @@ var EdgeClient = class extends Resource3 {
661
574
  if (response.status === 401) {
662
575
  return encodePresentationWsAuthHeader(await handleAuthChallenge(response, this._identity));
663
576
  } else {
664
- log3.warn("no auth challenge from edge", {
577
+ log2.warn("no auth challenge from edge", {
665
578
  status: response.status,
666
579
  statusText: response.statusText
667
580
  }, {
668
- F: __dxlog_file4,
669
- L: 264,
581
+ F: __dxlog_file3,
582
+ L: 263,
670
583
  S: this,
671
584
  C: (f, a) => f(...a)
672
585
  });
@@ -674,7 +587,7 @@ var EdgeClient = class extends Resource3 {
674
587
  }
675
588
  }
676
589
  };
677
- _ts_decorate3([
590
+ _ts_decorate2([
678
591
  logInfo2
679
592
  ], EdgeClient.prototype, "info", null);
680
593
  var encodePresentationWsAuthHeader = (encodedPresentation) => {
@@ -687,7 +600,7 @@ import { createCredential, signPresentation } from "@dxos/credentials";
687
600
  import { invariant as invariant3 } from "@dxos/invariant";
688
601
  import { Keyring } from "@dxos/keyring";
689
602
  import { PublicKey } from "@dxos/keys";
690
- var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/auth.ts";
603
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/auth.ts";
691
604
  var createDeviceEdgeIdentity = async (signer, key) => {
692
605
  return {
693
606
  identityKey: key.toHex(),
@@ -732,7 +645,7 @@ var createChainEdgeIdentity = async (signer, identityKey, peerKey, chain, creden
732
645
  peerKey: peerKey.toHex(),
733
646
  presentCredentials: async ({ challenge }) => {
734
647
  invariant3(chain, void 0, {
735
- F: __dxlog_file5,
648
+ F: __dxlog_file4,
736
649
  L: 75,
737
650
  S: void 0,
738
651
  A: [
@@ -794,26 +707,29 @@ var createStubEdgeIdentity = () => {
794
707
  };
795
708
 
796
709
  // packages/core/mesh/edge-client/src/edge-http-client.ts
797
- import { sleep as sleep2 } from "@dxos/async";
710
+ import { sleep } from "@dxos/async";
798
711
  import { Context as Context2 } from "@dxos/context";
799
- import { log as log4 } from "@dxos/log";
712
+ import { log as log3 } from "@dxos/log";
800
713
  import { EdgeCallFailedError, EdgeAuthChallengeError } from "@dxos/protocols";
801
- var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-http-client.ts";
714
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-http-client.ts";
802
715
  var DEFAULT_RETRY_TIMEOUT = 1500;
803
716
  var DEFAULT_RETRY_JITTER = 500;
804
717
  var DEFAULT_MAX_RETRIES_COUNT = 3;
805
718
  var EdgeHttpClient = class {
806
719
  constructor(baseUrl) {
807
720
  this._baseUrl = getEdgeUrlWithProtocol(baseUrl, "http");
808
- log4("created", {
721
+ log3("created", {
809
722
  url: this._baseUrl
810
723
  }, {
811
- F: __dxlog_file6,
812
- L: 44,
724
+ F: __dxlog_file5,
725
+ L: 49,
813
726
  S: this,
814
727
  C: (f, a) => f(...a)
815
728
  });
816
729
  }
730
+ get baseUrl() {
731
+ return this._baseUrl;
732
+ }
817
733
  setIdentity(identity) {
818
734
  if (this._edgeIdentity?.identityKey !== identity.identityKey || this._edgeIdentity?.peerKey !== identity.peerKey) {
819
735
  this._edgeIdentity = identity;
@@ -860,6 +776,13 @@ var EdgeHttpClient = class {
860
776
  method: "POST"
861
777
  });
862
778
  }
779
+ async executeWorkflow(spaceId, graphId, input, args) {
780
+ return this._call(`/workflows/${spaceId}/${graphId}`, {
781
+ ...args,
782
+ body: input,
783
+ method: "POST"
784
+ });
785
+ }
863
786
  async uploadFunction(pathParts, body, args) {
864
787
  const path = [
865
788
  "functions",
@@ -874,20 +797,68 @@ var EdgeHttpClient = class {
874
797
  method: "PUT"
875
798
  });
876
799
  }
800
+ async queryQueue(subspaceTag, spaceId, query, args) {
801
+ const { queueId } = query;
802
+ const queryParams = new URLSearchParams();
803
+ if (query.after != null) {
804
+ queryParams.set("after", query.after);
805
+ }
806
+ if (query.before != null) {
807
+ queryParams.set("before", query.before);
808
+ }
809
+ if (query.limit != null) {
810
+ queryParams.set("limit", query.limit.toString());
811
+ }
812
+ if (query.reverse != null) {
813
+ queryParams.set("reverse", query.reverse.toString());
814
+ }
815
+ if (query.objectIds != null) {
816
+ queryParams.set("objectIds", query.objectIds.join(","));
817
+ }
818
+ return this._call(`/spaces/${subspaceTag}/${spaceId}/queue/${queueId}/query?${queryParams.toString()}`, {
819
+ ...args,
820
+ method: "GET"
821
+ });
822
+ }
823
+ async insertIntoQueue(subspaceTag, spaceId, queueId, objects, args) {
824
+ return this._call(`/spaces/${subspaceTag}/${spaceId}/queue/${queueId}`, {
825
+ ...args,
826
+ body: {
827
+ objects
828
+ },
829
+ method: "POST"
830
+ });
831
+ }
832
+ async deleteFromQueue(subspaceTag, spaceId, queueId, objectIds, args) {
833
+ return this._call(`/spaces/${subspaceTag}/${spaceId}/queue/${queueId}`, {
834
+ ...args,
835
+ query: {
836
+ ids: objectIds.join(",")
837
+ },
838
+ method: "DELETE"
839
+ });
840
+ }
877
841
  async _call(path, args) {
878
842
  const requestContext = args.context ?? new Context2(void 0, {
879
- F: __dxlog_file6,
880
- L: 102
843
+ F: __dxlog_file5,
844
+ L: 177
881
845
  });
882
846
  const shouldRetry = createRetryHandler(args);
883
- const url = `${this._baseUrl}${path.startsWith("/") ? path.slice(1) : path}`;
884
- log4.info("call", {
847
+ let url = `${this._baseUrl}${path.startsWith("/") ? path.slice(1) : path}`;
848
+ if (args.query) {
849
+ const queryParams = new URLSearchParams();
850
+ for (const [key, value] of Object.entries(args.query)) {
851
+ queryParams.set(key, value.toString());
852
+ }
853
+ url += `?${queryParams.toString()}`;
854
+ }
855
+ log3("call", {
885
856
  method: args.method,
886
857
  path,
887
858
  request: args.body
888
859
  }, {
889
- F: __dxlog_file6,
890
- L: 106,
860
+ F: __dxlog_file5,
861
+ L: 189,
891
862
  S: this,
892
863
  C: (f, a) => f(...a)
893
864
  });
@@ -905,12 +876,12 @@ var EdgeHttpClient = class {
905
876
  if (body.success) {
906
877
  return body.data;
907
878
  }
908
- log4.info("unsuccessful edge response", {
879
+ log3("unsuccessful edge response", {
909
880
  path,
910
881
  body
911
882
  }, {
912
- F: __dxlog_file6,
913
- L: 125,
883
+ F: __dxlog_file5,
884
+ L: 208,
914
885
  S: this,
915
886
  C: (f, a) => f(...a)
916
887
  });
@@ -930,12 +901,12 @@ var EdgeHttpClient = class {
930
901
  processingError = EdgeCallFailedError.fromProcessingFailureCause(error);
931
902
  }
932
903
  if (processingError.isRetryable && await shouldRetry(requestContext, retryAfterHeaderValue)) {
933
- log4.info("retrying edge request", {
904
+ log3("retrying edge request", {
934
905
  path,
935
906
  processingError
936
907
  }, {
937
- F: __dxlog_file6,
938
- L: 144,
908
+ F: __dxlog_file5,
909
+ L: 227,
939
910
  S: this,
940
911
  C: (f, a) => f(...a)
941
912
  });
@@ -946,9 +917,9 @@ var EdgeHttpClient = class {
946
917
  }
947
918
  async _handleUnauthorized(response) {
948
919
  if (!this._edgeIdentity) {
949
- log4.warn("edge unauthorized response received before identity was set", void 0, {
950
- F: __dxlog_file6,
951
- L: 153,
920
+ log3.warn("edge unauthorized response received before identity was set", void 0, {
921
+ F: __dxlog_file5,
922
+ L: 236,
952
923
  S: this,
953
924
  C: (f, a) => f(...a)
954
925
  });
@@ -956,9 +927,9 @@ var EdgeHttpClient = class {
956
927
  }
957
928
  const challenge = await handleAuthChallenge(response, this._edgeIdentity);
958
929
  this._authHeader = encodeAuthHeader(challenge);
959
- log4("auth header updated", void 0, {
960
- F: __dxlog_file6,
961
- L: 158,
930
+ log3("auth header updated", void 0, {
931
+ F: __dxlog_file5,
932
+ L: 241,
962
933
  S: this,
963
934
  C: (f, a) => f(...a)
964
935
  });
@@ -978,10 +949,10 @@ var createRetryHandler = (args) => {
978
949
  return false;
979
950
  }
980
951
  if (retryAfter) {
981
- await sleep2(retryAfter);
952
+ await sleep(retryAfter);
982
953
  } else {
983
954
  const timeout = baseTimeout + Math.random() * jitter;
984
- await sleep2(timeout);
955
+ await sleep(timeout);
985
956
  }
986
957
  return true;
987
958
  };