@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 +51 -45
- package/esm/index.es.js.map +1 -1
- package/esm/typings/servers.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +51 -45
- package/umd/index.umd.js.map +1 -1
package/esm/typings/servers.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ type ServerConfiguration = {
|
|
|
31
31
|
/**
|
|
32
32
|
* Available remote servers for the Promptbook
|
|
33
33
|
*
|
|
34
|
-
* @public exported from `@promptbook/core`
|
|
34
|
+
* @public exported from `@promptbook/core`
|
|
35
35
|
*/
|
|
36
36
|
export declare const REMOTE_SERVER_URLS: Array<ServerConfiguration>;
|
|
37
37
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/remote-server",
|
|
3
|
-
"version": "0.89.0-
|
|
3
|
+
"version": "0.89.0-19",
|
|
4
4
|
"description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"module": "./esm/index.es.js",
|
|
52
52
|
"typings": "./esm/typings/src/_packages/remote-server.index.d.ts",
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@promptbook/core": "0.89.0-
|
|
54
|
+
"@promptbook/core": "0.89.0-19"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"colors": "1.4.0",
|
package/umd/index.umd.js
CHANGED
|
@@ -30,25 +30,12 @@
|
|
|
30
30
|
* @generated
|
|
31
31
|
* @see https://github.com/webgptorg/promptbook
|
|
32
32
|
*/
|
|
33
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.89.0-
|
|
33
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.89.0-19';
|
|
34
34
|
/**
|
|
35
35
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
36
36
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
37
37
|
*/
|
|
38
38
|
|
|
39
|
-
/**
|
|
40
|
-
* Error thrown when a fetch request fails
|
|
41
|
-
*
|
|
42
|
-
* @public exported from `@promptbook/core`
|
|
43
|
-
*/
|
|
44
|
-
class PromptbookFetchError extends Error {
|
|
45
|
-
constructor(message) {
|
|
46
|
-
super(message);
|
|
47
|
-
this.name = 'PromptbookFetchError';
|
|
48
|
-
Object.setPrototypeOf(this, PromptbookFetchError.prototype);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
39
|
/**
|
|
53
40
|
* Returns the same value that is passed as argument.
|
|
54
41
|
* No side effects.
|
|
@@ -341,37 +328,6 @@
|
|
|
341
328
|
throw new WrappedError(whatWasThrown);
|
|
342
329
|
}
|
|
343
330
|
|
|
344
|
-
/**
|
|
345
|
-
* The built-in `fetch' function with a lightweight error handling wrapper as default fetch function used in Promptbook scrapers
|
|
346
|
-
*
|
|
347
|
-
* @public exported from `@promptbook/core`
|
|
348
|
-
*/
|
|
349
|
-
const promptbookFetch = async (urlOrRequest, init) => {
|
|
350
|
-
try {
|
|
351
|
-
return await fetch(urlOrRequest, init);
|
|
352
|
-
}
|
|
353
|
-
catch (error) {
|
|
354
|
-
assertsError(error);
|
|
355
|
-
let url;
|
|
356
|
-
if (typeof urlOrRequest === 'string') {
|
|
357
|
-
url = urlOrRequest;
|
|
358
|
-
}
|
|
359
|
-
else if (urlOrRequest instanceof Request) {
|
|
360
|
-
url = urlOrRequest.url;
|
|
361
|
-
}
|
|
362
|
-
throw new PromptbookFetchError(spaceTrim__default["default"]((block) => `
|
|
363
|
-
Can not fetch "${url}"
|
|
364
|
-
|
|
365
|
-
Fetch error:
|
|
366
|
-
${block(error.message)}
|
|
367
|
-
|
|
368
|
-
`));
|
|
369
|
-
}
|
|
370
|
-
};
|
|
371
|
-
/**
|
|
372
|
-
* TODO: [🧠] Maybe rename because it is not used only for scrapers but also in `$getCompiledBook`
|
|
373
|
-
*/
|
|
374
|
-
|
|
375
331
|
/**
|
|
376
332
|
* AuthenticationError is thrown from login function which is dependency of remote server
|
|
377
333
|
*
|
|
@@ -613,6 +569,19 @@
|
|
|
613
569
|
}
|
|
614
570
|
}
|
|
615
571
|
|
|
572
|
+
/**
|
|
573
|
+
* Error thrown when a fetch request fails
|
|
574
|
+
*
|
|
575
|
+
* @public exported from `@promptbook/core`
|
|
576
|
+
*/
|
|
577
|
+
class PromptbookFetchError extends Error {
|
|
578
|
+
constructor(message) {
|
|
579
|
+
super(message);
|
|
580
|
+
this.name = 'PromptbookFetchError';
|
|
581
|
+
Object.setPrototypeOf(this, PromptbookFetchError.prototype);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
|
|
616
585
|
/**
|
|
617
586
|
* Index of all custom errors
|
|
618
587
|
*
|
|
@@ -3649,6 +3618,37 @@
|
|
|
3649
3618
|
return value;
|
|
3650
3619
|
}
|
|
3651
3620
|
|
|
3621
|
+
/**
|
|
3622
|
+
* The built-in `fetch' function with a lightweight error handling wrapper as default fetch function used in Promptbook scrapers
|
|
3623
|
+
*
|
|
3624
|
+
* @public exported from `@promptbook/core`
|
|
3625
|
+
*/
|
|
3626
|
+
const promptbookFetch = async (urlOrRequest, init) => {
|
|
3627
|
+
try {
|
|
3628
|
+
return await fetch(urlOrRequest, init);
|
|
3629
|
+
}
|
|
3630
|
+
catch (error) {
|
|
3631
|
+
assertsError(error);
|
|
3632
|
+
let url;
|
|
3633
|
+
if (typeof urlOrRequest === 'string') {
|
|
3634
|
+
url = urlOrRequest;
|
|
3635
|
+
}
|
|
3636
|
+
else if (urlOrRequest instanceof Request) {
|
|
3637
|
+
url = urlOrRequest.url;
|
|
3638
|
+
}
|
|
3639
|
+
throw new PromptbookFetchError(spaceTrim__default["default"]((block) => `
|
|
3640
|
+
Can not fetch "${url}"
|
|
3641
|
+
|
|
3642
|
+
Fetch error:
|
|
3643
|
+
${block(error.message)}
|
|
3644
|
+
|
|
3645
|
+
`));
|
|
3646
|
+
}
|
|
3647
|
+
};
|
|
3648
|
+
/**
|
|
3649
|
+
* TODO: [🧠] Maybe rename because it is not used only for scrapers but also in `$getCompiledBook`
|
|
3650
|
+
*/
|
|
3651
|
+
|
|
3652
3652
|
/**
|
|
3653
3653
|
* @@@
|
|
3654
3654
|
*
|
|
@@ -7238,6 +7238,12 @@
|
|
|
7238
7238
|
response.status(400).send({ error: serializeError(error) });
|
|
7239
7239
|
}
|
|
7240
7240
|
});
|
|
7241
|
+
/**
|
|
7242
|
+
* Catch-all handler for unmatched routes
|
|
7243
|
+
*/
|
|
7244
|
+
app.use((request, response) => {
|
|
7245
|
+
response.status(404).send(`URL "${request.originalUrl}" was not found on Promptbook server.`);
|
|
7246
|
+
});
|
|
7241
7247
|
const httpServer = http__default["default"].createServer(app);
|
|
7242
7248
|
const server = new socket_io.Server(httpServer, {
|
|
7243
7249
|
path: socketioPath,
|