@promptbook/remote-client 0.89.0-6 → 0.89.0-7

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/esm/index.es.js CHANGED
@@ -20,7 +20,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
20
20
  * @generated
21
21
  * @see https://github.com/webgptorg/promptbook
22
22
  */
23
- const PROMPTBOOK_ENGINE_VERSION = '0.89.0-6';
23
+ const PROMPTBOOK_ENGINE_VERSION = '0.89.0-7';
24
24
  /**
25
25
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
26
26
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -56,6 +56,19 @@ class CsvFormatError extends AbstractFormatError {
56
56
  }
57
57
  }
58
58
 
59
+ /**
60
+ * AuthenticationError is thrown from login function which is dependency of remote server
61
+ *
62
+ * @public exported from `@promptbook/core`
63
+ */
64
+ class AuthenticationError extends Error {
65
+ constructor(message) {
66
+ super(message);
67
+ this.name = 'AuthenticationError';
68
+ Object.setPrototypeOf(this, AuthenticationError.prototype);
69
+ }
70
+ }
71
+
59
72
  /**
60
73
  * This error indicates that the pipeline collection cannot be propperly loaded
61
74
  *
@@ -346,7 +359,7 @@ Object.freeze({
346
359
  });
347
360
  /**
348
361
  * Note: [💞] Ignore a discrepancy between file name and entity name
349
- * TODO: [🧠][🧜‍♂️] Maybe join remoteUrl and path into single value
362
+ * TODO: [🧠][🧜‍♂️] Maybe join remoteServerUrl and path into single value
350
363
  */
351
364
 
352
365
  /**
@@ -454,6 +467,7 @@ const COMMON_JAVASCRIPT_ERRORS = {
454
467
  TypeError,
455
468
  URIError,
456
469
  AggregateError,
470
+ AuthenticationError,
457
471
  /*
458
472
  Note: Not widely supported
459
473
  > InternalError,
@@ -510,22 +524,26 @@ function deserializeError(error) {
510
524
  * @private internal utility function
511
525
  */
512
526
  async function createRemoteClient(options) {
513
- const { remoteUrl, path } = options;
527
+ const { remoteServerUrl } = options;
528
+ let path = new URL(remoteServerUrl).pathname;
529
+ if (path.endsWith('/')) {
530
+ path = path.slice(0, -1);
531
+ }
532
+ path = `${path}/socket.io`;
514
533
  return new Promise((resolve, reject) => {
515
- const socket = io(remoteUrl, {
534
+ const socket = io(remoteServerUrl, {
516
535
  retries: CONNECTION_RETRIES_LIMIT,
517
536
  timeout: CONNECTION_TIMEOUT_MS,
518
537
  path,
519
- // path: `${this.remoteUrl.pathname}/socket.io`,
520
538
  transports: [/*'websocket', <- TODO: [🌬] Make websocket transport work */ 'polling'],
521
539
  });
522
- // console.log('Connecting to', this.options.remoteUrl.href, { socket });
540
+ // console.log('Connecting to', this.options.remoteServerUrl.href, { socket });
523
541
  socket.on('connect', () => {
524
542
  resolve(socket);
525
543
  });
526
544
  // TODO: [💩] Better timeout handling
527
545
  setTimeout(() => {
528
- reject(new Error(`Timeout while connecting to ${remoteUrl}`));
546
+ reject(new Error(`Timeout while connecting to ${remoteServerUrl}`));
529
547
  }, CONNECTION_TIMEOUT_MS);
530
548
  });
531
549
  }