@promptbook/remote-client 0.89.0-21 → 0.89.0-28
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 +49 -35
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/remote-server/openapi.d.ts +187 -0
- package/package.json +2 -2
- package/umd/index.umd.js +49 -35
- package/umd/index.umd.js.map +1 -1
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @private !!!! Decide how to expose this
|
|
3
|
+
*/
|
|
4
|
+
export declare const openapiJson: {
|
|
5
|
+
openapi: string;
|
|
6
|
+
info: {
|
|
7
|
+
title: string;
|
|
8
|
+
version: string;
|
|
9
|
+
description: string;
|
|
10
|
+
};
|
|
11
|
+
paths: {
|
|
12
|
+
'/': {
|
|
13
|
+
get: {
|
|
14
|
+
summary: string;
|
|
15
|
+
description: string;
|
|
16
|
+
responses: {
|
|
17
|
+
'200': {
|
|
18
|
+
description: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
'/login': {
|
|
24
|
+
post: {
|
|
25
|
+
summary: string;
|
|
26
|
+
description: string;
|
|
27
|
+
requestBody: {
|
|
28
|
+
required: boolean;
|
|
29
|
+
content: {
|
|
30
|
+
'application/json': {
|
|
31
|
+
schema: {
|
|
32
|
+
type: string;
|
|
33
|
+
properties: {
|
|
34
|
+
username: {
|
|
35
|
+
type: string;
|
|
36
|
+
};
|
|
37
|
+
password: {
|
|
38
|
+
type: string;
|
|
39
|
+
};
|
|
40
|
+
appId: {
|
|
41
|
+
type: string;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
responses: {
|
|
49
|
+
'200': {
|
|
50
|
+
description: string;
|
|
51
|
+
content: {
|
|
52
|
+
'application/json': {
|
|
53
|
+
schema: {
|
|
54
|
+
type: string;
|
|
55
|
+
properties: {
|
|
56
|
+
identification: {
|
|
57
|
+
type: string;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
'/books': {
|
|
68
|
+
get: {
|
|
69
|
+
summary: string;
|
|
70
|
+
description: string;
|
|
71
|
+
responses: {
|
|
72
|
+
'200': {
|
|
73
|
+
description: string;
|
|
74
|
+
content: {
|
|
75
|
+
'application/json': {
|
|
76
|
+
schema: {
|
|
77
|
+
type: string;
|
|
78
|
+
items: {
|
|
79
|
+
type: string;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
'/books/{bookId}': {
|
|
89
|
+
get: {
|
|
90
|
+
summary: string;
|
|
91
|
+
description: string;
|
|
92
|
+
parameters: {
|
|
93
|
+
in: string;
|
|
94
|
+
name: string;
|
|
95
|
+
required: boolean;
|
|
96
|
+
schema: {
|
|
97
|
+
type: string;
|
|
98
|
+
};
|
|
99
|
+
description: string;
|
|
100
|
+
}[];
|
|
101
|
+
responses: {
|
|
102
|
+
'200': {
|
|
103
|
+
description: string;
|
|
104
|
+
content: {
|
|
105
|
+
'text/markdown': {
|
|
106
|
+
schema: {
|
|
107
|
+
type: string;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
'404': {
|
|
113
|
+
description: string;
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
'/executions': {
|
|
119
|
+
get: {
|
|
120
|
+
summary: string;
|
|
121
|
+
description: string;
|
|
122
|
+
responses: {
|
|
123
|
+
'200': {
|
|
124
|
+
description: string;
|
|
125
|
+
content: {
|
|
126
|
+
'application/json': {
|
|
127
|
+
schema: {
|
|
128
|
+
type: string;
|
|
129
|
+
items: {
|
|
130
|
+
type: string;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
'/executions/new': {
|
|
140
|
+
post: {
|
|
141
|
+
summary: string;
|
|
142
|
+
description: string;
|
|
143
|
+
requestBody: {
|
|
144
|
+
required: boolean;
|
|
145
|
+
content: {
|
|
146
|
+
'application/json': {
|
|
147
|
+
schema: {
|
|
148
|
+
type: string;
|
|
149
|
+
properties: {
|
|
150
|
+
pipelineUrl: {
|
|
151
|
+
type: string;
|
|
152
|
+
};
|
|
153
|
+
inputParameters: {
|
|
154
|
+
type: string;
|
|
155
|
+
};
|
|
156
|
+
identification: {
|
|
157
|
+
type: string;
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
responses: {
|
|
165
|
+
'200': {
|
|
166
|
+
description: string;
|
|
167
|
+
content: {
|
|
168
|
+
'application/json': {
|
|
169
|
+
schema: {
|
|
170
|
+
type: string;
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
'400': {
|
|
176
|
+
description: string;
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
components: {};
|
|
183
|
+
tags: never[];
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
187
|
+
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/remote-client",
|
|
3
|
-
"version": "0.89.0-
|
|
3
|
+
"version": "0.89.0-28",
|
|
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-client.index.d.ts",
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@promptbook/core": "0.89.0-
|
|
54
|
+
"@promptbook/core": "0.89.0-28"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"crypto": "1.0.1",
|
package/umd/index.umd.js
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* @generated
|
|
24
24
|
* @see https://github.com/webgptorg/promptbook
|
|
25
25
|
*/
|
|
26
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.89.0-
|
|
26
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.89.0-28';
|
|
27
27
|
/**
|
|
28
28
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
29
29
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -555,6 +555,35 @@
|
|
|
555
555
|
return deserializedError;
|
|
556
556
|
}
|
|
557
557
|
|
|
558
|
+
/**
|
|
559
|
+
* Tests if given string is valid URL.
|
|
560
|
+
*
|
|
561
|
+
* Note: Dataurl are considered perfectly valid.
|
|
562
|
+
* Note: There are two simmilar functions:
|
|
563
|
+
* - `isValidUrl` which tests any URL
|
|
564
|
+
* - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
|
|
565
|
+
*
|
|
566
|
+
* @public exported from `@promptbook/utils`
|
|
567
|
+
*/
|
|
568
|
+
function isValidUrl(url) {
|
|
569
|
+
if (typeof url !== 'string') {
|
|
570
|
+
return false;
|
|
571
|
+
}
|
|
572
|
+
try {
|
|
573
|
+
if (url.startsWith('blob:')) {
|
|
574
|
+
url = url.replace(/^blob:/, '');
|
|
575
|
+
}
|
|
576
|
+
const urlObject = new URL(url /* because fail is handled */);
|
|
577
|
+
if (!['http:', 'https:', 'data:'].includes(urlObject.protocol)) {
|
|
578
|
+
return false;
|
|
579
|
+
}
|
|
580
|
+
return true;
|
|
581
|
+
}
|
|
582
|
+
catch (error) {
|
|
583
|
+
return false;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
|
|
558
587
|
/**
|
|
559
588
|
* Creates a connection to the remote proxy server.
|
|
560
589
|
*
|
|
@@ -564,11 +593,25 @@
|
|
|
564
593
|
*/
|
|
565
594
|
async function createRemoteClient(options) {
|
|
566
595
|
const { remoteServerUrl } = options;
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
596
|
+
if (!isValidUrl(remoteServerUrl)) {
|
|
597
|
+
throw new Error(`Invalid \`remoteServerUrl\`: "${remoteServerUrl}"`);
|
|
598
|
+
}
|
|
599
|
+
const remoteServerUrlParsed = new URL(remoteServerUrl);
|
|
600
|
+
if (remoteServerUrlParsed.pathname !== '/' && remoteServerUrlParsed.pathname !== '') {
|
|
601
|
+
remoteServerUrlParsed.pathname = '/';
|
|
602
|
+
throw new Error(spaceTrim__default["default"]((block) => `
|
|
603
|
+
Remote server requires root url \`/\`
|
|
604
|
+
|
|
605
|
+
You have provided \`remoteServerUrl\`:
|
|
606
|
+
${block(remoteServerUrl)}
|
|
607
|
+
|
|
608
|
+
But something like this is expected:
|
|
609
|
+
${block(remoteServerUrlParsed.href)}
|
|
610
|
+
|
|
611
|
+
Note: If you need to run multiple services on the same server, use 3rd or 4th degree subdomain
|
|
612
|
+
|
|
613
|
+
`));
|
|
614
|
+
}
|
|
572
615
|
return new Promise((resolve, reject) => {
|
|
573
616
|
const socket = socket_ioClient.io(remoteServerUrl, {
|
|
574
617
|
retries: CONNECTION_RETRIES_LIMIT,
|
|
@@ -708,35 +751,6 @@
|
|
|
708
751
|
* TODO: [🍏] Implement for MacOs
|
|
709
752
|
*/
|
|
710
753
|
|
|
711
|
-
/**
|
|
712
|
-
* Tests if given string is valid URL.
|
|
713
|
-
*
|
|
714
|
-
* Note: Dataurl are considered perfectly valid.
|
|
715
|
-
* Note: There are two simmilar functions:
|
|
716
|
-
* - `isValidUrl` which tests any URL
|
|
717
|
-
* - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
|
|
718
|
-
*
|
|
719
|
-
* @public exported from `@promptbook/utils`
|
|
720
|
-
*/
|
|
721
|
-
function isValidUrl(url) {
|
|
722
|
-
if (typeof url !== 'string') {
|
|
723
|
-
return false;
|
|
724
|
-
}
|
|
725
|
-
try {
|
|
726
|
-
if (url.startsWith('blob:')) {
|
|
727
|
-
url = url.replace(/^blob:/, '');
|
|
728
|
-
}
|
|
729
|
-
const urlObject = new URL(url /* because fail is handled */);
|
|
730
|
-
if (!['http:', 'https:', 'data:'].includes(urlObject.protocol)) {
|
|
731
|
-
return false;
|
|
732
|
-
}
|
|
733
|
-
return true;
|
|
734
|
-
}
|
|
735
|
-
catch (error) {
|
|
736
|
-
return false;
|
|
737
|
-
}
|
|
738
|
-
}
|
|
739
|
-
|
|
740
754
|
const defaultDiacriticsRemovalMap = [
|
|
741
755
|
{
|
|
742
756
|
base: 'A',
|