@promptbook/markdown-utils 0.89.0-7 → 0.89.0-8

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
@@ -25,7 +25,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
25
25
  * @generated
26
26
  * @see https://github.com/webgptorg/promptbook
27
27
  */
28
- const PROMPTBOOK_ENGINE_VERSION = '0.89.0-7';
28
+ const PROMPTBOOK_ENGINE_VERSION = '0.89.0-8';
29
29
  /**
30
30
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
31
31
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -121,6 +121,7 @@ import type { RemoteServerOptions } from '../remote-server/types/RemoteServerOpt
121
121
  import type { AnonymousRemoteServerOptions } from '../remote-server/types/RemoteServerOptions';
122
122
  import type { ApplicationRemoteServerOptions } from '../remote-server/types/RemoteServerOptions';
123
123
  import type { ApplicationRemoteServerClientOptions } from '../remote-server/types/RemoteServerOptions';
124
+ import type { ApplicationRemoteServerOptionsLoginResponse } from '../remote-server/types/RemoteServerOptions';
124
125
  import type { Converter } from '../scrapers/_common/Converter';
125
126
  import type { ScraperAndConverterMetadata } from '../scrapers/_common/register/ScraperAndConverterMetadata';
126
127
  import type { ScraperConstructor } from '../scrapers/_common/register/ScraperConstructor';
@@ -411,6 +412,7 @@ export type { RemoteServerOptions };
411
412
  export type { AnonymousRemoteServerOptions };
412
413
  export type { ApplicationRemoteServerOptions };
413
414
  export type { ApplicationRemoteServerClientOptions };
415
+ export type { ApplicationRemoteServerOptionsLoginResponse };
414
416
  export type { Converter };
415
417
  export type { ScraperAndConverterMetadata };
416
418
  export type { ScraperConstructor };
@@ -1,5 +1,7 @@
1
+ import type { Request, Response } from 'express';
1
2
  import type { Promisable } from 'type-fest';
2
3
  import type { PipelineCollection } from '../../collection/PipelineCollection';
4
+ import { AuthenticationError } from '../../errors/AuthenticationError';
3
5
  import type { CommonToolsOptions } from '../../execution/CommonToolsOptions';
4
6
  import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
5
7
  import type { string_app_id } from '../../types/typeAliases';
@@ -35,7 +37,11 @@ export type RemoteServerOptions<TCustomOptions> = CommonToolsOptions & {
35
37
  * @example '/api/promptbook/'
36
38
  */
37
39
  readonly rootPath?: string_uri;
38
- } & (AnonymousRemoteServerOptions | ApplicationRemoteServerOptions<TCustomOptions> | (AnonymousRemoteServerOptions & ApplicationRemoteServerOptions<TCustomOptions>));
40
+ } & ((AnonymousRemoteServerOptions & {
41
+ readonly isApplicationModeAllowed?: false;
42
+ }) | ({
43
+ readonly isAnonymousModeAllowed?: false;
44
+ } & ApplicationRemoteServerOptions<TCustomOptions>) | (AnonymousRemoteServerOptions & ApplicationRemoteServerOptions<TCustomOptions>));
39
45
  export type AnonymousRemoteServerOptions = {
40
46
  /**
41
47
  * Enable anonymous mode
@@ -55,13 +61,14 @@ export type ApplicationRemoteServerOptions<TCustomOptions> = {
55
61
  readonly collection: PipelineCollection;
56
62
  /**
57
63
  * User tries to login to the server, this function will be called verify the user and return the identification or throw an error
58
- *
64
+ * This can be also doubled as a function to register the user
59
65
  *
60
66
  * Note: In most cases, you will return `PromptbookServer_ApplicationIdentification`
61
67
  * `PromptbookServer_AnonymousIdentification` is useful only in scenarios when user stores its own api keys on the application server and
62
68
  * server acts only as a api key provider
63
69
  *
64
- * @throws `AuthenticationError` if the user is not allowed to login for example because of invalid credentials
70
+ * Note: In most cases DO NOT THROW `AuthenticationError` but return `isSuccess: false` with message
71
+ * @throws `AuthenticationError` if the user is not allowed to login for example because of invalid credentials
65
72
  */
66
73
  login(credentials: {
67
74
  /**
@@ -78,7 +85,17 @@ export type ApplicationRemoteServerOptions<TCustomOptions> = {
78
85
  * Password of the user
79
86
  */
80
87
  readonly password: string_password;
81
- }): Promise<PromptbookServer_Identification<TCustomOptions>>;
88
+ /**
89
+ * Request object from express if you want to access some request data for example headers, IP address, etc.
90
+ */
91
+ readonly rawRequest: Request;
92
+ /**
93
+ * Response object from express if you want to add some custom headers.
94
+ *
95
+ * Note: It is not recommended to use this object to send body of the response because it can confuse the client
96
+ */
97
+ readonly rawResponse: Response;
98
+ }): Promise<ApplicationRemoteServerOptionsLoginResponse<TCustomOptions>>;
82
99
  /**
83
100
  * Creates llm execution tools for each client
84
101
  */
@@ -110,6 +127,18 @@ export type ApplicationRemoteServerClientOptions<TCustomOptions> = {
110
127
  */
111
128
  readonly customOptions?: TCustomOptions;
112
129
  };
130
+ export type ApplicationRemoteServerOptionsLoginResponse<TCustomOptions> = {
131
+ /**
132
+ * Was the login successful
133
+ */
134
+ readonly isSuccess: boolean;
135
+ /**
136
+ *
137
+ */
138
+ readonly message?: string;
139
+ readonly error?: AuthenticationError;
140
+ readonly identification?: PromptbookServer_Identification<TCustomOptions>;
141
+ };
113
142
  /**
114
143
  * TODO: Constrain anonymous mode for specific models / providers
115
144
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/markdown-utils",
3
- "version": "0.89.0-7",
3
+ "version": "0.89.0-8",
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,
package/umd/index.umd.js CHANGED
@@ -25,7 +25,7 @@
25
25
  * @generated
26
26
  * @see https://github.com/webgptorg/promptbook
27
27
  */
28
- const PROMPTBOOK_ENGINE_VERSION = '0.89.0-7';
28
+ const PROMPTBOOK_ENGINE_VERSION = '0.89.0-8';
29
29
  /**
30
30
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
31
31
  * Note: [💞] Ignore a discrepancy between file name and entity name