@botpress/client 0.24.2 → 0.25.1
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/.turbo/turbo-build.log +7 -7
- package/.turbo/turbo-generate.log +1 -1
- package/dist/bundle.cjs +11 -11
- package/dist/bundle.cjs.map +4 -4
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +79 -12
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +4 -4
- package/package.json +3 -4
- package/tests/e2e/node.ts +1 -1
- package/tests/e2e/browser/index.ts +0 -71
- package/tests/e2e/browser/script.ts +0 -34
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botpress/client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.1",
|
|
4
4
|
"description": "Botpress Client",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"build": "pnpm build:type && pnpm build:node && pnpm build:browser && pnpm build:bundle",
|
|
21
21
|
"generate": "ts-node ./openapi.ts",
|
|
22
22
|
"test:manual": "vitest tests/manual/file-upload",
|
|
23
|
-
"test:e2e": "ts-node -T ./tests/e2e/node.ts
|
|
23
|
+
"test:e2e": "ts-node -T ./tests/e2e/node.ts",
|
|
24
24
|
"test": "pnpm run test:e2e"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
@@ -30,11 +30,10 @@
|
|
|
30
30
|
"type-fest": "^3.4.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@botpress/api": "0.
|
|
33
|
+
"@botpress/api": "0.37.1",
|
|
34
34
|
"@types/qs": "^6.9.7",
|
|
35
35
|
"esbuild": "^0.16.12",
|
|
36
36
|
"lodash": "^4.17.21",
|
|
37
|
-
"puppeteer": "^22.0.0",
|
|
38
37
|
"ts-node": "^10.9.2",
|
|
39
38
|
"tsup": "^8.0.2",
|
|
40
39
|
"typescript": "^4.9.4",
|
package/tests/e2e/node.ts
CHANGED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
import esbuild from 'esbuild'
|
|
3
|
-
import fs from 'fs'
|
|
4
|
-
import pathlib from 'path'
|
|
5
|
-
import puppeteer from 'puppeteer'
|
|
6
|
-
import * as consts from '../consts'
|
|
7
|
-
|
|
8
|
-
const readTsScript = () => {
|
|
9
|
-
const filePath = pathlib.join(__dirname, 'script.ts')
|
|
10
|
-
return fs.readFileSync(filePath, 'utf8')
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const toJs = async (tsScript: string): Promise<string> => {
|
|
14
|
-
const buildResult = await esbuild.build({
|
|
15
|
-
stdin: {
|
|
16
|
-
contents: tsScript,
|
|
17
|
-
resolveDir: __dirname,
|
|
18
|
-
loader: 'ts',
|
|
19
|
-
},
|
|
20
|
-
bundle: true,
|
|
21
|
-
write: false,
|
|
22
|
-
format: 'esm',
|
|
23
|
-
platform: 'browser',
|
|
24
|
-
target: 'es2017',
|
|
25
|
-
})
|
|
26
|
-
const jsScript = buildResult.outputFiles[0]!.text
|
|
27
|
-
return jsScript
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const launchBrowser = async (jsScript: string) => {
|
|
31
|
-
const browser = await puppeteer.launch({ headless: true })
|
|
32
|
-
const page = await browser.newPage()
|
|
33
|
-
await page.setRequestInterception(false)
|
|
34
|
-
|
|
35
|
-
try {
|
|
36
|
-
await new Promise<typeof browser>((resolve, reject) => {
|
|
37
|
-
page.on('console', (msg) => {
|
|
38
|
-
const txt = msg.text()
|
|
39
|
-
if (txt === consts.successMessage) {
|
|
40
|
-
resolve(browser)
|
|
41
|
-
return
|
|
42
|
-
}
|
|
43
|
-
if (txt === consts.failureMessage) {
|
|
44
|
-
reject(new Error('Failure'))
|
|
45
|
-
return
|
|
46
|
-
}
|
|
47
|
-
console.log(`>>> ${txt}`)
|
|
48
|
-
})
|
|
49
|
-
page.evaluate(jsScript).catch(reject)
|
|
50
|
-
return browser
|
|
51
|
-
})
|
|
52
|
-
} finally {
|
|
53
|
-
await browser.close()
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const main = async () => {
|
|
58
|
-
const tsScript = readTsScript()
|
|
59
|
-
const jsScript = await toJs(tsScript)
|
|
60
|
-
await launchBrowser(jsScript)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
void main()
|
|
64
|
-
.then(() => {
|
|
65
|
-
console.error('Browser Done')
|
|
66
|
-
process.exit(0)
|
|
67
|
-
})
|
|
68
|
-
.catch((err) => {
|
|
69
|
-
console.error(err)
|
|
70
|
-
process.exit(1)
|
|
71
|
-
})
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
import { Client, errorFrom } from '../../../src'
|
|
3
|
-
import * as consts from '../consts'
|
|
4
|
-
|
|
5
|
-
const exit = (code: 0 | 1) => {
|
|
6
|
-
if (code === 0) {
|
|
7
|
-
console.log(consts.successMessage)
|
|
8
|
-
} else {
|
|
9
|
-
console.log(consts.failureMessage)
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const main = async () => {
|
|
14
|
-
const client = new Client()
|
|
15
|
-
await client
|
|
16
|
-
.getAccount()
|
|
17
|
-
.then(() => {
|
|
18
|
-
throw new Error('Expected to reject')
|
|
19
|
-
})
|
|
20
|
-
.catch((err) => {
|
|
21
|
-
if (errorFrom(err).type !== 'Unauthorized') {
|
|
22
|
-
throw Error()
|
|
23
|
-
}
|
|
24
|
-
})
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
void main()
|
|
28
|
-
.then(() => {
|
|
29
|
-
exit(0)
|
|
30
|
-
})
|
|
31
|
-
.catch((err) => {
|
|
32
|
-
console.error(err)
|
|
33
|
-
exit(1)
|
|
34
|
-
})
|