ti2 1.0.13 → 1.0.14

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
@@ -22,21 +22,9 @@ App Plugins are value added tools that only speak to Ti2 and other plugins. For
22
22
 
23
23
  Ti2 can be deployed on your own servers, or you can connect to a Ti2 instance that another company is hosting.
24
24
 
25
- ### Security
26
-
27
- An admin api key is set trough an environment variable called adminKey; using this API key is possible to create Users and/or application authentications.
28
-
29
- A new User / User Authentication can be created using the endpoint [createUserToken](https://ti2.tourconnect.dev/api-docs/#/admin/createUserToken); the return value consists of a JWT token for further user intraction with the App; the admin API key is required; no password is saved on the server side.
30
-
31
- Apps / Integrations can be created using the admin API Key; this after the plugin had been added to the codebase; the app can be created using the endpoint [createApp](https://ti2.tourconnect.dev/api-docs/#/admin/createApp); such endpoint returns a key that can be used by the app to interact with user Ids; such interactions allow the app to push for changes related to user integrations, the app can list the users currently configured for it using the endpoint [listAppTokens](https://ti2.tourconnect.dev/api-docs/#/app/listAppTokens); the passwords for Apps are encripted onde the database using aes-256-cbc, more details can be found on the [``models/integrations.js``](https://github.com/ti2travel/ti2/blob/main/models/integration.js) file.
32
-
33
- User + app integration credentials can be added after the app has been added to the system; these can be added by either the user, admin or the app itself using the endpoint [createAppToken](https://ti2.tourconnect.dev/api-docs/#/app/createAppToken). These keys are saved in JWT format on the database.
34
-
35
25
  ## Getting Started
36
26
 
37
- You can start follow [this guide]{@tutorial setup-your-instance} to create an instance, if you want to add an integration (like for your own backend) or add a new internal funtionality you can [create a plugin]{@tutorial plugin-development} for your system.
38
-
39
- By default a ti2 instance serves a documentation page on the url (http://[yourinstance]/api-docs/) that serves the available API restfull methods, you can review the [swagger documentation page online](https://ti2-staging.tourconnect.com/api-docs/) .
27
+ You can write your [own plugin]{@tutorial plugin-development} that hooks up to a Ti2 instance or you can run a server that that hosts your [own **Ti2** instance]{@tutorial setup-your-instance} with any plugins (your own or from the plugin library).
40
28
 
41
29
 
42
30
  ## Plugins
package/jsdoc.conf.json CHANGED
@@ -13,7 +13,10 @@
13
13
  ],
14
14
  "templates": {
15
15
  "cleverLinks": true,
16
- "monospaceLinks": true
16
+ "monospaceLinks": true,
17
+ "default": {
18
+ "includeDate": false
19
+ }
17
20
  },
18
21
  "opts": {
19
22
  "destination": "docs",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ti2",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "description": "Tourist Industry Exchange (TI2)",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/test/plugin.js CHANGED
@@ -3,7 +3,7 @@ const chance = require('chance').Chance();
3
3
 
4
4
  class Plugin {
5
5
  /**
6
- * For a comprehensive list of mehtods visit the
6
+ * For a comprehensive list of methods visit the
7
7
  * [Plugin Development]{@tutorial plugin-development} page.
8
8
  *
9
9
  * ---
@@ -46,11 +46,11 @@ class Plugin {
46
46
  }
47
47
 
48
48
  /**
49
- * Check the vailidity of an integration token.
49
+ * Check the validity of an integration token.
50
50
  * @async
51
51
  * @param {Object} args - Availability search arguments.
52
52
  * @param {Object} args.token - A token definition, it's content varies between integrations.
53
- * @returns {Boolean} - The token vailidity True/False
53
+ * @returns {Boolean} - The token validity True/False
54
54
  */
55
55
  validateToken() {
56
56
  return Boolean(this);
@@ -306,7 +306,7 @@ class Plugin {
306
306
  * @param {string} args.payload.travelDateEnd - Date of travel end.
307
307
  * @param {Holder} args.payload.holder - Search for a particular holder.
308
308
  * @returns {object} retVal - the return object.
309
- * @returns {Booking[]} retVal.bookings - Array of Bookings matchin the criteria.
309
+ * @returns {Booking[]} retVal.bookings - Array of Bookings matching the criteria.
310
310
  */
311
311
  searchBooking() {
312
312
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "setup-your-instance": {
3
- "title": "Setting up your instancce"
3
+ "title": "Running your own Ti2"
4
4
  },
5
5
  "plugin-development": {
6
6
  "title": "Plugin Development"
@@ -1,21 +1,15 @@
1
- ## Environment values
1
+ ## Getting Started
2
2
 
3
- Plugin environment keys are passed down to the instance while is being created, this is the preferred way of accesing environmen keys from the plugins, such values are not design to hold client / user's API keys or specific data, they are to be stored on the database itself via the AppKey collection.
3
+ Plugins can extend the functionality of Ti2 and/or provide access to other platforms; you should use one of the following methods to provide a stadandarized way to access other systems; if you want to implement new functionality that is not encompassed on the available methods you are more than welcome to add new methods and contribute to the Ti2 codebase.
4
4
 
5
- Plugin ENV variable name convention: ti2_pluginName_environmenVariableName, for example:
6
-
7
- ```env
8
- ti2_tourconnect_apiUrl=http://backend:8080
9
- ```
5
+ ## Available Methods
10
6
 
11
- ## Methods
12
-
13
- In oorder for an integration or system apps, we must use a set of standirzed methods to matain a compatibility; there are following methods are available, more can be supported but should be a part of the API TI2 spec to maximize it's compatibility.
7
+ We are using a set of standardized methods to maintain compatibility; the following methods are available, more can be supported but should be a added to the TI2 spec first to maximize it's compatibility.
14
8
 
15
9
  **General Methods** (should always be included):
16
10
  * [validateToken]{@link Plugin#validateToken}
17
11
 
18
- **Content Methods** (related to marketing information update for profile, locations and/or products):
12
+ **Content Methods** (marketing information for (company)profile, locations and/or products):
19
13
  * [getProfile]{@link Plugin#getProfile}
20
14
  * [updateProfile]{@link Plugin#updateProfile}
21
15
  * [createLocation]{@link Plugin#createLocation}
@@ -24,7 +18,7 @@ In oorder for an integration or system apps, we must use a set of standirzed met
24
18
  * [createProduct]{@link Plugin#createProduct}
25
19
  * [updateProduct]{@link Plugin#updateProduct}
26
20
 
27
- **Booking Methods** (all related to bookings and operations):
21
+ **Booking Methods** (bookings and operations):
28
22
  * [searchBooking]{@link Plugin#searchBooking}
29
23
  * [searchProducts]{@link Plugin#searchProducts}
30
24
  * [searchAvailability]{@link Plugin#searchAvailability}
@@ -33,10 +27,20 @@ In oorder for an integration or system apps, we must use a set of standirzed met
33
27
 
34
28
  ---
35
29
 
30
+ ## Environment variables
31
+
32
+ Plugin environment keys are passed down from the hosting ti2 instance when they are generated, this is the preferred way to access environment keys from the plugins, such values are not design to hold client / user's API keys or specific data, they are to be stored in the database via the AppKey collection.
33
+
34
+ Plugin ENV variable name convention: ti2_pluginName_environmenVariableName, for example:
35
+
36
+ ```env
37
+ ti2_tourconnect_apiUrl=http://backend:8080
38
+ ```
39
+
36
40
 
37
41
  ## Codebase setup
38
42
 
39
- You can review some of the plugins previously developed and use them as a guide, plugin methods are encourage to include tests and return results on the same format, however the return values can include additional information, currently Ti2 is expected to run on node version 12.22.8; we suggest you use the same for your codebase.
43
+ You can review some of the plugins previously developed and use them as a guide, plugin methods are encourage to include tests and to return results with the same format; however, the returned values can include additional information, currently Ti2 is expected to run on node version 12.22.8; we suggest you use the same for your codebase.
40
44
 
41
45
 
42
46
  After initializing your git environment for development; you can initialize your node project; we recommend naming your repo ti2-\<pluginname\> but it is not required.
@@ -61,7 +65,7 @@ class Plugin {
61
65
  module.exports = Plugin;
62
66
  ```
63
67
 
64
- The constructor of the plugins should extend the attributes with the received params, this allows the plugin to receive configurations or settings that are to be used by any user; that is settings that are shared across accounts.
68
+ The constructor of the plugins should extend the attributes with the received params, this allows the plugin to receive configurations or settings that are to be used by any user, for example, settings data that can be shared across accounts.
65
69
 
66
70
  By default Ti2 will pass down all environment variables that match the plugin name to it's constructor; for example, if the following environment variables are defined:
67
71
 
@@ -98,7 +102,7 @@ class Plugin {
98
102
  module.exports = Plugin;
99
103
  ```
100
104
 
101
- The token parameter includes all the settings for the current configured user; on these example we are defauring this settings to the ones configured to the pluging when it was instanced; so if the user settings do not include an apiUrl it will fall back to the environment variable on the running server.
105
+ The token parameter should store all the settings for the current configured end user; on these example we are defaulting this settings to the ones configured to the pluging when it was instanced; so if the user settings do not include an apiUrl it will fall back to the environment variable on the running server.
102
106
 
103
107
  ## Testing Suite
104
108
 
@@ -141,7 +145,9 @@ describe('Base Tests', () => {
141
145
  $ npx jest
142
146
  ```
143
147
 
144
- ## Adding the folder to a ti2 instance
148
+ ## Deploying
149
+
150
+ ### To your own Instance
145
151
 
146
152
  After setting up a [Ti2 instance]{@tutorial setup-your-instance} you can add your development folder as a package on your instance's npm repo (not on the plugin's instance), like so:
147
153
 
@@ -151,13 +157,17 @@ After setting up a [Ti2 instance]{@tutorial setup-your-instance} you can add you
151
157
  }
152
158
  ```
153
159
 
160
+ ### To our hosted instance
161
+
162
+ [Contact us](https://www.ti2.travel/contact-us) with the npm published package to begin the testing and deployment process.
163
+
154
164
  ## Extending the base API
155
165
 
156
- Ti2 uses the [Swagger API specification](https://swagger.io/specification/) standard to define it's own methods, you can review the base methods [here](https://ti2-staging.tourconnect.com/api-docs/); these methods can be extender using the same format; this allows any plugin to extend the base API endpoints that are linked to any plugin method (part of the base methods or new ones).
166
+ Ti2 uses the [Swagger API specification](https://swagger.io/specification/) standard to define it's own methods, you can review the basic methods [here](https://ti2-staging.tourconnect.com/api-docs/); these methods can be extended using the same format; this allows any plugin to extend the base API endpoints that are linked to any plugin method (part of the basic methods or new ones).
157
167
 
158
168
  All the extender methods would be availble under the /\[plugin name] namespace, i.e.: /ti2-greatPlugin/ping.
159
169
 
160
- For Ti2 to pickup the extender definition one must create a new file on the root of the plugin named api.yml, such file would contain only the methods to be extender and it must comply with the current swagger version used on ti2.
170
+ For Ti2 to pickup the extender definition, one must create a new file on the root of the plugin named api.yml, such file would contain only the methods to be extended and it must comply with the current swagger version used on ti2.
161
171
 
162
172
  ```yaml
163
173
  # api.yml
@@ -202,7 +212,7 @@ paths:
202
212
 
203
213
  ## Database Migrations (plugin's own database tables)
204
214
 
205
- Ti2 uses [Sequelize v6.13](https://sequelize.org/v6) and is the database ORM we ecourage to use, you can add your own tables via migrations that should be placed under a migrations folder on the root of the plugin folder.
215
+ Ti2 uses [Sequelize v6.13](https://sequelize.org/v6) which is the database ORM we ecourage you to use, you can add your own tables via migrations that should be placed under a migrations folder on the root of the plugin folder.
206
216
 
207
217
  Migrations should be run after the fact, from the root of ti2 instance like so:
208
218
 
@@ -211,9 +221,9 @@ Migrations should be run after the fact, from the root of ti2 instance like so:
211
221
  $ npm explore ti2<pluginName> -- npx sequelize db:migrate"
212
222
  ```
213
223
 
214
- We strongly encourage all the plugin's table names are predicated with the plugin name (i.e. ti2-pluginName-cacheTable).
224
+ We strongly encourage all the plugin's table names are prefixed with the plugin name (i.e. ti2-pluginName-cacheTable).
215
225
 
216
- This should be executed ater the ti2 project migrations have been executed.
226
+ This should be executed after the ti2 project migrations have been executed.
217
227
 
218
228
  ## Scheduled Task (to be released on v2)
219
229
 
@@ -1,15 +1,24 @@
1
- ## Initializing your new Repo
1
+ ## Why would I want to run my own instance?
2
2
 
3
- We suggest creating a folder with your instance name+i2 (i.e acme-ti2); then initialize an node's npm package and install ti2 along with any plugins to be used.
3
+ * Scenario 1: You want to test your plugins before submitting it to our Ti2 instance, it is a good idea to spin up your own Ti2 test instance, you can test against all the Ti2 REST Apis (In the future, we will provide a Ti2 sandbox instance).
4
4
 
5
- ```bash
6
- $ mkdir acme-ti2
7
- $ cd acmme-ti2
8
- $ npm init .
9
- $ npm i ti2 ti2-tourconnect
10
- ```
5
+ * Scenario 2: You want to host your own Ti2 server so you can have everything under your own control.
6
+
7
+ When you are runnning a Ti2 server you can access the documentation page on the url (http://[yourinstance]/api-docs/) that shows the available API methods, you can review the [swagger documentation page online](https://ti2-staging.tourconnect.com/api-docs/) .
8
+
9
+ ## Security
10
+
11
+ An admin api key is set trough an environment variable called adminKey; using this API key is possible to create Users and/or application authentications.
12
+
13
+ A new User/User Authentication can be created using the endpoint [createUserToken](https://ti2.tourconnect.dev/api-docs/#/admin/createUserToken); the return value consists of a JWT token for further user intraction with the App; the admin API key is required; no password is saved on the server side.
14
+
15
+ Apps/Integrations can be created using the admin API Key; this after the plugin had been added to the codebase; the app can be created using the endpoint [createApp](https://ti2.tourconnect.dev/api-docs/#/admin/createApp); such endpoint returns a key that can be used by the app to interact with user Ids; such interactions allow the app to push for changes related to user integrations, the app can list the users currently configured for it using the endpoint [listAppTokens](https://ti2.tourconnect.dev/api-docs/#/app/listAppTokens); the passwords for Apps are encripted onde the database using aes-256-cbc, more details can be found on the [``models/integrations.js``](https://github.com/ti2travel/ti2/blob/main/models/integration.js) file.
16
+
17
+ User + app integration credentials can be added after the app has been added to the system; these can be added by either the user, admin or the app itself using the endpoint [createAppToken](https://ti2.tourconnect.dev/api-docs/#/app/createAppToken). These keys are saved in JWT format on the database.
11
18
 
12
- ## Requirements
19
+ ## Get Started
20
+
21
+ ### Requirements and Evironment variables
13
22
 
14
23
  A MySQl instance is required and the following environment variables are required:
15
24
 
@@ -28,13 +37,25 @@ frontendKey=IpOiLahrGQxsQimwoK7Z
28
37
  adminKey=bCviyz7iKyuEBoOVlODn
29
38
  ```
30
39
 
31
- After installing the ti2 package you need to run the datbase migrations for ti2:
40
+ ### Initialize a new NodeJS project
41
+
42
+ We suggest creating a folder with your instance name+i2 (i.e acme-ti2); then initialize an node's npm package and install ti2 along with any plugins to be used.
43
+
44
+ ```bash
45
+ $ mkdir acme-ti2
46
+ $ cd acmme-ti2
47
+ $ npm init .
48
+ $ npm i ti2 ti2-tourconnect
49
+ ```
50
+
51
+
52
+ After installing the ti2 package you need to run the database migrations for ti2:
32
53
 
33
54
  ```
34
55
  $ npm explore ti2<pluginName> -- npx sequelize db:migrate"
35
56
  ```
36
57
 
37
- ## Entry File
58
+ ### Entry File
38
59
 
39
60
  then just create an entry file like this :
40
61