@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 CHANGED
@@ -1,35 +1,35 @@
1
- ## Getting Started
1
+ # HitL API
2
2
 
3
- In this section we are going to explain how to run the application locally, without (almost) any OneReach dependencies.
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
- #### Make sure OneReach NPM token is available
5
+ ## Local Development
6
6
 
7
- In order to install some dependencies you are going to need a valid token available as a variable - `OR_NPM_TOKEN`. If it is not available using `echo $OR_NPM_TOKEN` - you should ask someone to help you setup access to OneReach NPM.
7
+ Requirements:
8
8
 
9
- #### Installing local PostgreSQL
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
- If you already have a local PostgreSQL installed, or know how to do so - you are free to go to the next section.
15
+ ### 1. Install dependencies
12
16
 
13
- The easiest way to install a local database - is by using **Docker** - [Install Docker Desktop](https://www.docker.com/products/docker-desktop). After making sure **Docker** is installed and is available through command line as `docker` - we can proceed with installing and creating a local database.
17
+ ```bash
18
+ npm install
19
+ ```
14
20
 
15
- Run the following commands (and replace `mysecretpassword` here and in the examples below with an actual password):
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
- You should be able to connect to this database using command (enter the password, if it is asked):
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
- Create a file named `.env` in the project root directory with the following content:
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
- You can change all the values above, if you want to, just make sure that the variables in `.env` file point to some valid PostgreSQL instance.
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
- Run the following commands:
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
- A file `config.json`, which is ignored by git, should appear in the project root with some content.
55
-
56
- #### Installing packages and starting the application
48
+ ### 5. Start the server
57
49
 
58
- After installing third party dependencies, we can finally run:
59
-
60
- ```
61
- npm install
50
+ ```bash
62
51
  npm start
63
52
  ```
64
53
 
65
- This will start the application in the development mode as a simple `express` server. Changes to the code will be tracked and server will restart automatically.
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
- Server now is ready to accept requests, but it will probably fail on every attempt to access database. In order to read and write from database we need to send a request to create or update our SQL tables.
56
+ ```bash
57
+ curl --location --request POST 'http://localhost:8080/api/v1/migrations' --header 'Authorization: user'
58
+ ```
70
59
 
71
- In order to run all migrations to the latest version, run the following request in the console (or in Postman):
60
+ ### 7. Run tests
72
61
 
73
- ```
74
- curl --location --request POST 'http://localhost:8080/api/v1/migrations' --header 'Authorization: user'
62
+ ```bash
63
+ npm test
75
64
  ```
76
65
 
77
- After successful response you should be able to send all other requests.
66
+ ## Main Areas
78
67
 
79
- #### Testings the application
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
- In order to verify that (most of) the application logic works, you should run:
73
+ ## Shared Parent Domain Aliases
82
74
 
83
- ```
84
- npm test
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
- If all tests pass successfully - congratulations, this means that the local deployment was successful.
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 {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onereach/types-hitl-api",
3
- "version": "1.0.5-rc.0",
3
+ "version": "1.0.5-rc.5",
4
4
  "author": "OneReach.ai",
5
5
  "main": "dist/types/index.types.js",
6
6
  "types": "dist/types/index.types.d.ts",