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