@promptbook/remote-server 0.89.0-18 → 0.89.0-19

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
@@ -33,25 +33,12 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
33
33
  * @generated
34
34
  * @see https://github.com/webgptorg/promptbook
35
35
  */
36
- const PROMPTBOOK_ENGINE_VERSION = '0.89.0-18';
36
+ const PROMPTBOOK_ENGINE_VERSION = '0.89.0-19';
37
37
  /**
38
38
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
39
39
  * Note: [💞] Ignore a discrepancy between file name and entity name
40
40
  */
41
41
 
42
- /**
43
- * Error thrown when a fetch request fails
44
- *
45
- * @public exported from `@promptbook/core`
46
- */
47
- class PromptbookFetchError extends Error {
48
- constructor(message) {
49
- super(message);
50
- this.name = 'PromptbookFetchError';
51
- Object.setPrototypeOf(this, PromptbookFetchError.prototype);
52
- }
53
- }
54
-
55
42
  /**
56
43
  * Returns the same value that is passed as argument.
57
44
  * No side effects.
@@ -344,37 +331,6 @@ function assertsError(whatWasThrown) {
344
331
  throw new WrappedError(whatWasThrown);
345
332
  }
346
333
 
347
- /**
348
- * The built-in `fetch' function with a lightweight error handling wrapper as default fetch function used in Promptbook scrapers
349
- *
350
- * @public exported from `@promptbook/core`
351
- */
352
- const promptbookFetch = async (urlOrRequest, init) => {
353
- try {
354
- return await fetch(urlOrRequest, init);
355
- }
356
- catch (error) {
357
- assertsError(error);
358
- let url;
359
- if (typeof urlOrRequest === 'string') {
360
- url = urlOrRequest;
361
- }
362
- else if (urlOrRequest instanceof Request) {
363
- url = urlOrRequest.url;
364
- }
365
- throw new PromptbookFetchError(spaceTrim((block) => `
366
- Can not fetch "${url}"
367
-
368
- Fetch error:
369
- ${block(error.message)}
370
-
371
- `));
372
- }
373
- };
374
- /**
375
- * TODO: [🧠] Maybe rename because it is not used only for scrapers but also in `$getCompiledBook`
376
- */
377
-
378
334
  /**
379
335
  * AuthenticationError is thrown from login function which is dependency of remote server
380
336
  *
@@ -616,6 +572,19 @@ class PipelineUrlError extends Error {
616
572
  }
617
573
  }
618
574
 
575
+ /**
576
+ * Error thrown when a fetch request fails
577
+ *
578
+ * @public exported from `@promptbook/core`
579
+ */
580
+ class PromptbookFetchError extends Error {
581
+ constructor(message) {
582
+ super(message);
583
+ this.name = 'PromptbookFetchError';
584
+ Object.setPrototypeOf(this, PromptbookFetchError.prototype);
585
+ }
586
+ }
587
+
619
588
  /**
620
589
  * Index of all custom errors
621
590
  *
@@ -3652,6 +3621,37 @@ function titleToName(value) {
3652
3621
  return value;
3653
3622
  }
3654
3623
 
3624
+ /**
3625
+ * The built-in `fetch' function with a lightweight error handling wrapper as default fetch function used in Promptbook scrapers
3626
+ *
3627
+ * @public exported from `@promptbook/core`
3628
+ */
3629
+ const promptbookFetch = async (urlOrRequest, init) => {
3630
+ try {
3631
+ return await fetch(urlOrRequest, init);
3632
+ }
3633
+ catch (error) {
3634
+ assertsError(error);
3635
+ let url;
3636
+ if (typeof urlOrRequest === 'string') {
3637
+ url = urlOrRequest;
3638
+ }
3639
+ else if (urlOrRequest instanceof Request) {
3640
+ url = urlOrRequest.url;
3641
+ }
3642
+ throw new PromptbookFetchError(spaceTrim((block) => `
3643
+ Can not fetch "${url}"
3644
+
3645
+ Fetch error:
3646
+ ${block(error.message)}
3647
+
3648
+ `));
3649
+ }
3650
+ };
3651
+ /**
3652
+ * TODO: [🧠] Maybe rename because it is not used only for scrapers but also in `$getCompiledBook`
3653
+ */
3654
+
3655
3655
  /**
3656
3656
  * @@@
3657
3657
  *
@@ -7241,6 +7241,12 @@ function startRemoteServer(options) {
7241
7241
  response.status(400).send({ error: serializeError(error) });
7242
7242
  }
7243
7243
  });
7244
+ /**
7245
+ * Catch-all handler for unmatched routes
7246
+ */
7247
+ app.use((request, response) => {
7248
+ response.status(404).send(`URL "${request.originalUrl}" was not found on Promptbook server.`);
7249
+ });
7244
7250
  const httpServer = http.createServer(app);
7245
7251
  const server = new Server(httpServer, {
7246
7252
  path: socketioPath,