@onereach/types-hitl-api 1.0.5-rc.0 → 1.0.5-rc.5
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/README.md +45 -48
- package/dist/types/interfaces/api/listeners.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
|
|
1
|
+
# HitL API
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Backend API for Human in the Loop. This service handles session, agent, migration, task, and browser-facing API behavior used by the `hitl` frontend and related platform integrations.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Local Development
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Requirements:
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
- Node.js 20+
|
|
10
|
+
- npm 10+
|
|
11
|
+
- Docker Desktop or another local PostgreSQL setup
|
|
12
|
+
- `OR_NPM_TOKEN` for private dependencies
|
|
13
|
+
- deploy-platform installed locally so config can be generated
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+
### 1. Install dependencies
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
```bash
|
|
18
|
+
npm install
|
|
19
|
+
```
|
|
14
20
|
|
|
15
|
-
|
|
21
|
+
### 2. Start PostgreSQL
|
|
16
22
|
|
|
17
|
-
|
|
23
|
+
Example with Docker:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
18
26
|
docker pull postgres
|
|
19
27
|
docker run --name postgresql-local -e POSTGRES_USER=hitl-app -e POSTGRES_PASSWORD=mysecretpassword -e POSTGRES_DB=hitl-app-db -p 5432:5432 -d postgres
|
|
20
28
|
```
|
|
21
29
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
```
|
|
25
|
-
docker exec -it postgresql-local psql hitl-app-db -U hitl-app -W
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
#### Connecting to the local database
|
|
30
|
+
### 3. Create `.env`
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
```
|
|
32
|
+
```conf
|
|
33
33
|
APP_DEV_PORT=8080
|
|
34
34
|
DB_USER=hitl-app
|
|
35
35
|
DB_PASSWORD=mysecretpassword
|
|
@@ -39,49 +39,46 @@ DB_NAME=hitl-app-db
|
|
|
39
39
|
SCHEDULED_TASKS_SWITCH='{"ARCHIVE_SESSION_EVENTS":true,"CLEAN_UP_LISTENERS":true,"CLEAN_UP_SESSIONS":true,"ADD_EVENTS_TO_ARCHIVE":true,"ADD_MEMBERS_TO_ARCHIVE":true,"CLEAN_UP_CONTACTLESS_SESSIONS":true,"FIX_EXPIRED_AGENT_STATUSES":true,"DELETE_EXPIRED_SESSIONS":true,"LONG_EXPIRE_DAYS":7,"SHORT_EXPIRE_DAYS":1}'
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
#### Retrieving deploy config
|
|
45
|
-
|
|
46
|
-
Make sure you have `deploy-platform` project installed on your machine, and a command `or` is globally available.
|
|
42
|
+
### 4. Generate deploy config
|
|
47
43
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
```
|
|
44
|
+
```bash
|
|
51
45
|
or get-config --branch local --client development --env qa --feature master --project hitl-api --service hitl_api.config --service-or-eval service > config.json
|
|
52
46
|
```
|
|
53
47
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
#### Installing packages and starting the application
|
|
48
|
+
### 5. Start the server
|
|
57
49
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
```
|
|
61
|
-
npm install
|
|
50
|
+
```bash
|
|
62
51
|
npm start
|
|
63
52
|
```
|
|
64
53
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
An almost empty `config.json` file is required to build the application. In order to run the application on AWS, we are going to need real env variables that we are going to retrieve later.
|
|
54
|
+
### 6. Run migrations
|
|
68
55
|
|
|
69
|
-
|
|
56
|
+
```bash
|
|
57
|
+
curl --location --request POST 'http://localhost:8080/api/v1/migrations' --header 'Authorization: user'
|
|
58
|
+
```
|
|
70
59
|
|
|
71
|
-
|
|
60
|
+
### 7. Run tests
|
|
72
61
|
|
|
73
|
-
```
|
|
74
|
-
|
|
62
|
+
```bash
|
|
63
|
+
npm test
|
|
75
64
|
```
|
|
76
65
|
|
|
77
|
-
|
|
66
|
+
## Main Areas
|
|
78
67
|
|
|
79
|
-
|
|
68
|
+
- `src/api/` and `src/api-express/`: serverless and express entrypoints
|
|
69
|
+
- `src/api-common/`: shared middleware, auth, logging, validation, and versions endpoints
|
|
70
|
+
- `src/api-express/migrations/`: SQL and migration management
|
|
71
|
+
- `tests/`: Jest-based backend coverage
|
|
80
72
|
|
|
81
|
-
|
|
73
|
+
## Shared Parent Domain Aliases
|
|
82
74
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
75
|
+
`hitl-api` participates in the shared-parent-domain alias flow as a supporting API for branded `hitl` deployments.
|
|
76
|
+
|
|
77
|
+
That means:
|
|
78
|
+
|
|
79
|
+
- browser-facing host trust should be explicit
|
|
80
|
+
- CORS behavior should be driven by configured trusted hosts
|
|
81
|
+
- deploy-platform config must stay aligned with the UI aliases and allowed hosts used by the frontend
|
|
86
82
|
|
|
87
|
-
|
|
83
|
+
Read the full platform behavior here:
|
|
84
|
+
[deploy-platform shared-parent-domain alias documentation](https://gitlab.internal.onereach.io/onereach/platform/deploy-platform/docs/shared-parent-domain-aliases.md)
|
|
@@ -8,6 +8,7 @@ export interface IListener extends ITimestamps {
|
|
|
8
8
|
readonly type: CALLBACK_TYPE;
|
|
9
9
|
readonly userId: string;
|
|
10
10
|
readonly version: string;
|
|
11
|
+
readonly meta?: any;
|
|
11
12
|
}
|
|
12
13
|
/** Implicitly inherits ChannelTarget interface from Orbes */
|
|
13
14
|
export interface IListenerCallback {
|