@promptbook/remote-server 0.89.0-17 β†’ 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.
@@ -0,0 +1,40 @@
1
+ import type { string_legal_entity } from './src/types/typeAliases';
2
+ import type { string_promptbook_server_url } from './src/types/typeAliases';
3
+ import type { string_title } from './src/types/typeAliases';
4
+ /**
5
+ * Open Promptbook server usable for public
6
+ */
7
+ type ServerConfiguration = {
8
+ /**
9
+ * Basic name of the server
10
+ */
11
+ title: string_title;
12
+ /**
13
+ * Who is the owner of the server
14
+ */
15
+ owner: string_legal_entity;
16
+ /**
17
+ * Is the server open for public and anonymous usage
18
+ */
19
+ isAnonymousModeAllowed: boolean;
20
+ /**
21
+ * Description of the server, link to registration, user agreement, privacy policy, etc.
22
+ */
23
+ description: string;
24
+ /**
25
+ * URL of the server
26
+ *
27
+ Note: lising more for loadbalancing
28
+ */
29
+ urls: Array<string_promptbook_server_url>;
30
+ };
31
+ /**
32
+ * Available remote servers for the Promptbook
33
+ *
34
+ * @public exported from `@promptbook/core`
35
+ */
36
+ export declare const REMOTE_SERVER_URLS: Array<ServerConfiguration>;
37
+ export {};
38
+ /**
39
+ * Note: [πŸ’ž] Ignore a discrepancy between file name and entity name
40
+ */
@@ -26,7 +26,6 @@ import { DEFAULT_SCRAPE_CACHE_DIRNAME } from '../config';
26
26
  import { CLI_APP_ID } from '../config';
27
27
  import { PLAYGROUND_APP_ID } from '../config';
28
28
  import { DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME } from '../config';
29
- import { REMOTE_SERVER_URLS } from '../config';
30
29
  import { DEFAULT_REMOTE_SERVER_URL } from '../config';
31
30
  import { DEFAULT_CSV_SETTINGS } from '../config';
32
31
  import { DEFAULT_IS_VERBOSE } from '../config';
@@ -136,6 +135,7 @@ import { MODEL_VARIANTS } from '../types/ModelVariant';
136
135
  import { NonTaskSectionTypes } from '../types/SectionType';
137
136
  import { SectionTypes } from '../types/SectionType';
138
137
  import { TaskTypes } from '../types/TaskType';
138
+ import { REMOTE_SERVER_URLS } from '../../servers';
139
139
  export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION };
140
140
  export { collectionToJson };
141
141
  export { createCollectionFromJson };
@@ -164,7 +164,6 @@ export { DEFAULT_SCRAPE_CACHE_DIRNAME };
164
164
  export { CLI_APP_ID };
165
165
  export { PLAYGROUND_APP_ID };
166
166
  export { DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME };
167
- export { REMOTE_SERVER_URLS };
168
167
  export { DEFAULT_REMOTE_SERVER_URL };
169
168
  export { DEFAULT_CSV_SETTINGS };
170
169
  export { DEFAULT_IS_VERBOSE };
@@ -274,3 +273,4 @@ export { MODEL_VARIANTS };
274
273
  export { NonTaskSectionTypes };
275
274
  export { SectionTypes };
276
275
  export { TaskTypes };
276
+ export { REMOTE_SERVER_URLS };
@@ -223,6 +223,7 @@ import type { string_dirname } from '../types/typeAliases';
223
223
  import type { string_person_fullname } from '../types/typeAliases';
224
224
  import type { string_person_profile } from '../types/typeAliases';
225
225
  import type { string_license } from '../types/typeAliases';
226
+ import type { string_legal_entity } from '../types/typeAliases';
226
227
  import type { string_attribute } from '../types/typeAliases';
227
228
  import type { string_attribute_value_scope } from '../types/typeAliases';
228
229
  import type { string_color } from '../types/typeAliases';
@@ -512,6 +513,7 @@ export type { string_dirname };
512
513
  export type { string_person_fullname };
513
514
  export type { string_person_profile };
514
515
  export type { string_license };
516
+ export type { string_legal_entity };
515
517
  export type { string_attribute };
516
518
  export type { string_attribute_value_scope };
517
519
  export type { string_color };
@@ -227,12 +227,6 @@ export declare const DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME = "index";
227
227
  export declare const MOMENT_ARG_THRESHOLDS: {
228
228
  readonly ss: 3;
229
229
  };
230
- /**
231
- * Available remote servers for the Promptbook
232
- *
233
- * @public exported from `@promptbook/core`
234
- */
235
- export declare const REMOTE_SERVER_URLS: Array<string_promptbook_server_url>;
236
230
  /**
237
231
  * Default remote server URL for the Promptbook
238
232
  *
@@ -527,6 +527,13 @@ export type string_person_profile = string;
527
527
  * For example `"MIT"`
528
528
  */
529
529
  export type string_license = string;
530
+ /**
531
+ * Semantic helper
532
+ *
533
+ * For example `"Pavol HejnΓ½ <pavol@ptbk.io> (https://www.pavolhejny.com/)"`
534
+ * For example `"AI Web, LLC <legal@ptbk.io> (https://www.ptbk.io/)"`
535
+ */
536
+ export type string_legal_entity = string | string_person_profile | string_title;
530
537
  /**
531
538
  * Semantic helper for attributes
532
539
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/remote-server",
3
- "version": "0.89.0-17",
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-17"
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-17';
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,