ti2 1.0.111 → 1.0.114

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.
@@ -1,29 +1,52 @@
1
- name: Deploy Workflow
1
+ name: Release Workflow
2
2
 
3
3
  on:
4
- workflow_run:
5
- workflows: Tests Workflow
6
- branches: main
7
- types: completed
8
4
  workflow_dispatch:
9
5
 
6
+ permissions:
7
+ contents: write
8
+
10
9
  jobs:
11
10
  tag:
12
- if: github.event.workflow_run.conclusion == 'success' && github.repository == 'ti2travel/ti2'
11
+ if: github.ref_name == 'main' && github.repository == 'ti2travel/ti2'
13
12
  runs-on: ubuntu-latest
13
+ outputs:
14
+ version: ${{ steps.version.outputs.version }}
15
+ tag: ${{ steps.version.outputs.tag }}
14
16
  steps:
15
- - uses: actions/checkout@master
16
- - uses: tool3/bump@master
17
+ - uses: actions/checkout@v4
17
18
  with:
18
- github_token: ${{ secrets.GITHUB_TOKEN }}
19
- user: 'Github Action Job'
20
- email: 'engineering@tourconnect.com'
21
- branch: main
22
- publish:
23
- needs: tag
24
- runs-on: ubuntu-latest
25
- steps:
26
- - uses: actions/checkout@v1
27
- - uses: JS-DevTools/npm-publish@v1
19
+ fetch-depth: 0
20
+
21
+ - uses: actions/setup-node@v4
28
22
  with:
29
- token: ${{ secrets.NPM_TOKEN }}
23
+ node-version: 20
24
+
25
+ - name: Determine release version
26
+ id: version
27
+ run: |
28
+ node <<'NODE' >> "$GITHUB_OUTPUT"
29
+ const version = require('./package.json').version
30
+ const isSemver = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/
31
+
32
+ if (!isSemver.test(version)) {
33
+ throw new Error(`Invalid version: ${version}. Use semver like 1.2.3 or 1.2.3-beta.0`)
34
+ }
35
+
36
+ console.log(`version=${version}`)
37
+ console.log(`tag=v${version}`)
38
+ NODE
39
+
40
+ - name: Create release tag
41
+ env:
42
+ TAG: ${{ steps.version.outputs.tag }}
43
+ run: |
44
+ git fetch --tags origin
45
+
46
+ if git rev-parse "$TAG" >/dev/null 2>&1; then
47
+ echo "Tag $TAG already exists"
48
+ exit 1
49
+ fi
50
+
51
+ git tag "$TAG"
52
+ git push origin "refs/tags/$TAG"
package/.windsurfrules ADDED
@@ -0,0 +1,9 @@
1
+ This is a Node.js project using Sequelize for database operations and Express.js for the web server.
2
+ The API is defined in api.yml using OpenAPI 3.0.2
3
+ The database is defined in models/index.js
4
+ The models are defined in models/
5
+ to run tests you have to run them on the ti2 named docker container, and consider this codebase is part of node_modules/ti2 path for example :
6
+ `` $ docker exec ti2 bash -c "cd /ti2 && npx jest lib/__tests__/callback.js --forceExit"``
7
+ When writing / editing tests, make use of test/utils.js and review their implementation to understand how to mock the environment.
8
+ Do not make any changes until you 95% confident of the changes you want to make, ask follow up questions until you have that confidence.
9
+ when sending jobs to the background worker using the queue, asssume a worker is always runing to execute it but is on a different instance thread, so to review / wait for jobs we have to use the wokrer/queue.js listJobs fn to check for it
package/CLAUDE.md ADDED
@@ -0,0 +1,159 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ Ti2 (Tourism Information Interchange) is an open-source integration framework for the tourism industry. It provides standardized functions for bookings, content, and rates management through a plugin-based architecture.
8
+
9
+ ## Critical Development Rules
10
+
11
+ 1. **Docker Container Execution**: ALL commands must be run inside the `ti2` Docker container
12
+ - The codebase is located at `/ti2` path inside the container
13
+ - This project is part of `node_modules/ti2` in the container environment
14
+ - **NEVER run npm, node, or npx commands on the host machine**
15
+ - Always use: `docker exec ti2 bash -c "cd /ti2 && <command>"`
16
+ - Example for npm install: `docker exec ti2 bash -c "cd /ti2 && npm install <package>"`
17
+
18
+ 2. **Testing Rules**:
19
+ - Tests MUST be run inside the Docker container
20
+ - Example: `docker exec ti2 bash -c "cd /ti2 && npx jest lib/__tests__/callback.js --forceExit"`
21
+ - Use `test/utils.js` for mocking the environment
22
+ - Review test utility implementations before writing/editing tests
23
+
24
+ 3. **Background Jobs**:
25
+ - Jobs sent to the queue run on a separate worker thread/instance
26
+ - Use `worker/queue.js` `listJobs` function to check job status
27
+ - Workers are always assumed to be running
28
+
29
+ 4. **Code Confidence**: Do not make changes until 95% confident. Ask follow-up questions if uncertain.
30
+
31
+ ## Common Development Commands
32
+
33
+ ```bash
34
+ # Run tests (inside Docker container)
35
+ docker exec ti2 bash -c "cd /ti2 && npm test"
36
+ docker exec ti2 bash -c "cd /ti2 && npx jest [test-file] --forceExit"
37
+
38
+ # Run specific test file
39
+ docker exec ti2 bash -c "cd /ti2 && npx jest controllers/__tests__/bookings.js --forceExit"
40
+
41
+ # Database migrations
42
+ docker exec ti2 bash -c "cd /ti2 && npm run sequelize db:migrate"
43
+
44
+ # Generate documentation
45
+ docker exec ti2 bash -c "cd /ti2 && npm run doc"
46
+ ```
47
+
48
+ ## Architecture
49
+
50
+ ### Core Components
51
+
52
+ 1. **Main Entry Point** (`index.js`):
53
+ - Initializes Express server on port 10010 (default)
54
+ - Sets up Swagger documentation at `/api-docs`
55
+ - Handles plugin instantiation and middleware
56
+ - Implements caching mechanism
57
+ - Manages background job processing via `worker/queue.js`
58
+
59
+ 2. **API Definition** (`api.yml`):
60
+ - OpenAPI 3.0.0 specification
61
+ - Defines all endpoints and schemas
62
+ - JWT Bearer authentication
63
+
64
+ 3. **Plugin System**:
65
+ - Two types: Integration Plugins (connect systems) and App Plugins (value-added tools)
66
+ - Plugins are instantiated with cache, axios, events, and configuration
67
+ - Plugin schemas are merged with main API schema
68
+ - Each plugin gets its own routes under `/apps/{pluginName}`
69
+
70
+ 4. **Controllers** (`controllers/`):
71
+ - `app.js`: Core application controller
72
+ - `bookings.js`: Booking operations (searchProducts, createBooking, etc.)
73
+ - `admin.js`: Administrative functions
74
+ - `user.js`: User management
75
+ - `ping.js`: Health check endpoints
76
+ - `allotment.js`: Allotment management
77
+
78
+ 5. **Database Models** (`models/`):
79
+ - Sequelize ORM with MySQL
80
+ - Key models: Integration, User, UserAppKey, CronJobs, ApiCronJobs
81
+ - Migrations in `migrations/` directory
82
+
83
+ 6. **Worker System** (`worker/`):
84
+ - Bull queue for background job processing
85
+ - Redis-backed job queue
86
+ - Supports plugin jobs, API jobs, and callback jobs
87
+ - Multi-worker support with throng
88
+
89
+ 7. **Authentication** (`auth/authHandler.js`):
90
+ - JWT-based authentication
91
+ - Bearer token scheme
92
+
93
+ ### Key Features
94
+
95
+ - **Caching**: Redis-based caching with configurable TTL
96
+ - **Event System**: EventEmitter2 for plugin communication
97
+ - **Background Jobs**: Async job processing with Bull/Redis
98
+ - **Cron Jobs**: Scheduled task execution
99
+ - **Multi-tenancy**: Support for multiple integrations/plugins
100
+
101
+ ### Plugin Development
102
+
103
+ Plugins must implement standard methods:
104
+ - `validateToken`: Token validation
105
+ - `tokenTemplate`: Token configuration template
106
+ - Booking methods: `searchProducts`, `searchAvailability`, `createBooking`, `cancelBooking`
107
+ - Content methods: `getProducts`, `getProduct`, `createProduct`, `updateProduct`
108
+
109
+ ### Testing Strategy
110
+
111
+ - Jest testing framework
112
+ - Test fixtures in `__fixtures__/`
113
+ - Mock plugins in `__mocks__/`
114
+ - Use `test/utils.js` for creating test environments
115
+ - Tests organized by controller in `controllers/__tests__/`
116
+
117
+ ## Database
118
+
119
+ - Sequelize ORM with MySQL/MariaDB
120
+ - Connection managed through `models/db.js`
121
+ - Migrations handled via sequelize-cli
122
+ - Models auto-loaded from `models/` directory
123
+
124
+ ## Environment Variables
125
+
126
+ Key variables:
127
+ - `PORT`: Server port (default: 10010)
128
+ - `REDIS_URL`: Redis connection (default: redis://redis:6379)
129
+ - `jwtSecret`: JWT signing secret
130
+ - `adminKey`: Admin authentication key
131
+ - `WEB_CONCURRENCY`: Number of workers
132
+ - `MAX_JOBS_PER_WORKER`: Job concurrency per worker
133
+ - `SSL_INSECURE_ALLOWED_DOMAINS`: Pipe-separated list of domains where SSL certificate verification is skipped (e.g., `localhost|staging.example.com|192.168.1.100`)
134
+
135
+ Plugin-specific variables follow pattern: `ti2_{pluginName}_{setting}`
136
+
137
+ ### SSL Configuration
138
+
139
+ The `SSL_INSECURE_ALLOWED_DOMAINS` environment variable allows you to specify domains where SSL certificate verification should be skipped. This is useful for:
140
+ - Development environments with self-signed certificates
141
+ - Testing against staging servers with invalid certificates
142
+ - Local development with HTTPS
143
+
144
+ Example usage:
145
+ ```bash
146
+ # Skip SSL verification for specific domains
147
+ export SSL_INSECURE_ALLOWED_DOMAINS="localhost|staging.api.com|192.168.1.100"
148
+
149
+ # Multiple domains separated by pipe
150
+ export SSL_INSECURE_ALLOWED_DOMAINS="dev.example.com|test.example.com"
151
+ ```
152
+
153
+ **Important Implementation Notes**:
154
+ - SSL configuration is ONLY applied to plugin axios instances (for external API calls) and worker axios instances
155
+ - Internal communication (callbacks, per-request axios) do NOT use SSL configuration
156
+ - SSL configuration uses a per-request interceptor approach for better isolation
157
+ - The configuration checks domains dynamically on each request
158
+
159
+ **Warning**: Only use this in development/testing environments. Never skip SSL verification in production for security reasons.
@@ -219,6 +219,9 @@ describe('user', () => {
219
219
  expect(plugins[0].validateToken).toHaveBeenCalled();
220
220
  expect(valid).toBe(true);
221
221
  expect(plugins[0].validateToken.mock.calls[0][0].token).toEqual({ custom: true, ...token });
222
+ expect(plugins[0].validateToken.mock.calls[0][0].payload).toEqual({
223
+ tokenHint: apiKey.split('-')[0],
224
+ });
222
225
  });
223
226
  it('should be able to delete an app settings', async () => {
224
227
  const returnValue = await doApiDelete({
@@ -260,6 +260,7 @@ const validateAppToken = plugins => async (req, res, next) => {
260
260
  const valid = await app.validateToken({
261
261
  axios,
262
262
  token,
263
+ payload: req.body,
263
264
  requestId: req.requestId,
264
265
  });
265
266
  return res.json({ valid });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ti2",
3
- "version": "1.0.111",
3
+ "version": "1.0.114",
4
4
  "description": "Tourist Industry Exchange (TI2)",
5
5
  "main": "index.js",
6
6
  "scripts": {