ti2 1.0.10 → 1.0.13

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
@@ -4,6 +4,12 @@ Ti2 (Tourism Information Interchange) is an open source integration framework, b
4
4
 
5
5
  Core functions of Ti2 are currently focused on content, rates, and bookings.
6
6
 
7
+ ### Why use it ?
8
+
9
+ Ti2 gives a free, open source solution to building integrations across our industry. In addition, tools can be built on top of Ti2, that add additional value to these integrations - whether for the good of our industry or for profit.
10
+
11
+ **Become part of the community, start building on Ti2 today!**
12
+
7
13
  ## About this Project
8
14
 
9
15
  ### How it Works
@@ -16,84 +22,52 @@ App Plugins are value added tools that only speak to Ti2 and other plugins. For
16
22
 
17
23
  Ti2 can be deployed on your own servers, or you can connect to a Ti2 instance that another company is hosting.
18
24
 
19
- ### Why use Ti2 ?
20
-
21
- Ti2 gives a free, open source solution to building integrations across our industry. In addition, tools can be built on top of Ti2, that add additional value to these integrations - whether for the good of our industry or for profit.
22
-
23
- **Become part of the community, start building on Ti2 today!**
24
-
25
- ## Getting Started
25
+ ### Security
26
26
 
27
- ### Requirements
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
28
 
29
- Some environment variables are required for ti2 to start
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
30
 
31
- - DB_URL (mysql connection in url format)
32
- - dbCryptoKey (integration details encription key, should be a 32 chars random string base64 encoded)
33
- - adminKey (a key for admin related requests)
34
- - jwtKey (a key to encrypt user sessions request)
35
- - frontendKey (an additional optional key to validate the origin of the requests)
36
- - PORT (an optional port to run the http server, in case a port is not specified as a parameter)
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.
37
32
 
38
- ### Starting your server
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.
39
34
 
40
- You can start your own instance by adding a requirement on your own nodejs project as follows:
35
+ ## Getting Started
41
36
 
42
- ```bash
43
- $ npm i ti2
44
- ```
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.
45
38
 
46
- To start the server with default values use the following:
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/) .
47
40
 
48
- ```javascript
49
- const ti2 = require('ti2')({
50
- plugins: {
51
- travelgate: require('ti2-travelgate'),
52
- ventrata: require('ti2-ventrata'),
53
- tourconnect: require('ti2-tourconnect'),
54
- },
55
- });
56
- ```
57
41
 
58
42
  ## Plugins
59
43
 
60
44
  Plugins are the connectores to other systems and/or features you intent to use; by default the server will start an API service on port 10010 and the swagger documentation on the path //api-docs, (you can disable wither by passing the startServer param as False or the apiDocs as False.
61
45
 
62
- 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.
63
-
64
- Plugin ENV variable name convention: ti2_pluginName_environmenVariableName, for example:
65
-
66
- ```env
67
- ti2_tourconnect_apiUrl=http://backend:8080
68
- ```
69
-
70
- ### Available Plugins
71
-
72
- | Repo | Features | Maintainer |
73
- | ---- | -------- | ---------- |
74
- | [ti2-ventrata](https://github.com/TourConnect/ti2-ventrata) | Bookings: Search, Cancellation | TourConnect |
75
- | [ti2-travelgate](https://github.com/TourConnect/ti2-travelgate) | Bookings: Search, Cancellation | TourConnect |
76
-
77
- ## API logging
78
-
79
- Currently logging is supported via elastic search, an elasticLogClient value can ben passed down, example:
80
-
81
- ```javascript
82
- const { Client } = require('@elastic/elasticsearch');
83
- const elasticLogsClient = (() => {
84
- if (!elasticLogs) return null;
85
- return new Client({ node: elasticLogs });
86
- })();
87
-
88
- const ti2 = require('ti2')({
89
- elasticLogsClient,
90
- plugins: {
91
- ventrata: require('ti2-ventrata'),
92
- travelgate: require('ti2-travelgate'),
93
- tourconnect: require('ti2-tourconnect'),
94
- },
95
- });
96
- ```
46
+ ### Plugin Library
47
+
48
+ | Methods | [Ventrata](https://github.com/TourConnect/ti2-ventrata) | [TravelGateX](https://github.com/TourConnect/ti2-travelgate) | [Didgigo](https://github.com/TourConnect/ti2-didgigo) | [TourConnect](https://github.com/TourConnect/ti2-tourconnect)
49
+ | ---- | -------- | ---------- | ---- | ---- |
50
+ |**Base**|
51
+ |validateToken|||✓|✓|
52
+ |copyMedia||||✓|
53
+ |**Content**|
54
+ |getProfile|||✓|✓|
55
+ |updateProfile||||✓|
56
+ |getLocations|||✓|✓|
57
+ |getLocation|||✓|✓|
58
+ |createLocation|||✓|✓|
59
+ |updateLocation|||✓|✓|
60
+ |getProducts|||✓|✓|
61
+ |getProduct|||✓|✓|
62
+ |createProduct|||✓|✓|
63
+ |updateProduct|||✓|✓|
64
+ |**Bookings**|
65
+ |searchProducts|✓|✓|
66
+ |searchBooking|✓|✓|
67
+ |searchAvailability|✓|✓|
68
+ |searchQuote|✓|✓|
69
+ |createBooking|✓|✓|
70
+ |cancelBooking|✓|✓|
97
71
 
98
72
  ## Contributing
99
73
 
@@ -111,7 +85,7 @@ Feel free to check the [Issues Page](https://github.com/TourConnect/ti2/issues).
111
85
 
112
86
  ## License
113
87
 
114
- Distributed under the GPL-3 License. See LICENSE.txt for more information.
88
+ Distributed under the GPL-3 License. See LICENSE file for more information.
115
89
 
116
90
  TL;DR Here's what the license entails:
117
91
 
package/api.yml CHANGED
@@ -141,6 +141,7 @@ components:
141
141
  type: string
142
142
  bookingSearchQuery:
143
143
  type: object
144
+ additionalProperties: true
144
145
  properties:
145
146
  bookingId:
146
147
  type: string
@@ -172,6 +173,7 @@ components:
172
173
  default: "DD/MM/YYYY"
173
174
  bookingDetail:
174
175
  type: object
176
+ additionalProperties: true
175
177
  properties:
176
178
  id:
177
179
  type: string
@@ -181,7 +183,15 @@ components:
181
183
  type: string
182
184
  required: true
183
185
  description: The booking status
184
-
186
+ bookingSearchQueryResults:
187
+ type: object
188
+ additionalProperties: true
189
+ properties:
190
+ bookings:
191
+ type: object
192
+ required: true
193
+ items:
194
+ $ref: '#/components/schemas/bookingDetail'
185
195
  bookingDetailsForCancel:
186
196
  allOf: # Combines the BasicErrorModel and the inline model
187
197
  - $ref: '#/components/schemas/bookingDetail'
@@ -191,6 +201,89 @@ components:
191
201
  type: integer
192
202
  required: true
193
203
  description: The unix time the cancellation was sent
204
+ cancellationReturn:
205
+ type: object
206
+ properties:
207
+ cancellation:
208
+ type: object
209
+ allOf: # Combines the BasicErrorModel and the inline model
210
+ - $ref: '#/components/schemas/bookingDetail'
211
+ bookingsProductQuery:
212
+ type: object
213
+ additionalProperties: true
214
+ description: Additional properties may be included
215
+ properties:
216
+ productName:
217
+ type: string
218
+ required: false
219
+ description: Product Name wildcard match
220
+ example: '*bus*'
221
+ bookingsProductSearchReturn:
222
+ type: object
223
+ additionalProperties: true
224
+ description: Additional properties may be included
225
+ properties:
226
+ products:
227
+ type: array
228
+ required: false
229
+ description: Product Search Results
230
+ items:
231
+ type: object
232
+ accommodation:
233
+ type: array
234
+ required: false,
235
+ decription: Accommodation search results
236
+ items:
237
+ type: object
238
+ pricingItem:
239
+ type: object
240
+ additionalProperties: true
241
+ properties:
242
+ original:
243
+ type: integer
244
+ retail:
245
+ type: integer
246
+ net:
247
+ type: integer
248
+ currency:
249
+ type: string
250
+ example: "USD"
251
+ currencyPrecision:
252
+ type: integer
253
+ includedTaxes:
254
+ type: array
255
+ items:
256
+ type: object
257
+ additionalProperties: true
258
+ properties:
259
+ name:
260
+ type: string
261
+ retail:
262
+ type: integer
263
+ net:
264
+ type: integer
265
+ availabilityItem:
266
+ type: object
267
+ additionalProperties: true
268
+ properties:
269
+ id:
270
+ type: string
271
+ required: true
272
+ description: An availability Id that can be used for quoting
273
+ pricing:
274
+ $ref: '#/components/schemas/pricingItem'
275
+ required: false
276
+ cancelPolicy:
277
+ type: string
278
+ required: false
279
+ bookingRequest:
280
+ type: object
281
+ additionalProperties: true
282
+ required: true
283
+ properties:
284
+ id:
285
+ type: string
286
+ description: a quote Id to make a reservation for
194
287
  paths:
195
288
  /ping:
196
289
  get:
@@ -516,10 +609,12 @@ paths:
516
609
  schema:
517
610
  $ref: '#/components/schemas/bookingSearchQuery'
518
611
  responses:
519
- description: search results
520
- content:
521
- application/json:
522
- schema: '#/components/schemas/AnyValue'
612
+ '200':
613
+ description: search results
614
+ content:
615
+ application/json:
616
+ schema:
617
+ $ref: '#/components/schemas/bookingSearchQueryResults'
523
618
  /bookings/{appKey}/{userId}/{hint}/search:
524
619
  post:
525
620
  security:
@@ -557,10 +652,12 @@ paths:
557
652
  schema:
558
653
  $ref: '#/components/schemas/bookingSearchQuery'
559
654
  responses:
560
- description: search results
561
- content:
562
- application/json:
563
- schema: '#/components/schemas/AnyValue'
655
+ '200':
656
+ description: search results
657
+ content:
658
+ application/json:
659
+ schema:
660
+ $ref: '#/components/schemas/bookingSearchQueryResults'
564
661
  /bookings/{appKey}/{userId}/cancel:
565
662
  post:
566
663
  security:
@@ -591,10 +688,12 @@ paths:
591
688
  schema:
592
689
  $ref: '#/components/schemas/bookingDetailsForCancel'
593
690
  responses:
594
- description: search results
595
- content:
596
- application/json:
597
- schema: '#/components/schemas/AnyValue'
691
+ '200':
692
+ description: Cancellation confirmation details
693
+ content:
694
+ application/json:
695
+ schema:
696
+ $ref: '#/components/schemas/cancellationReturn'
598
697
  /bookings/{appKey}/{userId}/{hint}/cancel:
599
698
  post:
600
699
  security:
@@ -632,7 +731,373 @@ paths:
632
731
  schema:
633
732
  $ref: '#/components/schemas/bookingDetailsForCancel'
634
733
  responses:
635
- description: search results
734
+ '200':
735
+ description: Cancellation confirmation details
736
+ content:
737
+ application/json:
738
+ schema:
739
+ $ref: '#/components/schemas/cancellationReturn'
740
+ /products/{appKey}/{userId}/search:
741
+ post:
742
+ security:
743
+ - bearerAuth: ['admin', 'user']
744
+ tags:
745
+ - bookings
746
+ summary: Product Search
747
+ operationId: bookingsProductSearch
748
+ parameters:
749
+ - name: appKey
750
+ in: path
751
+ description: app to search the booking products, defaults to first token
752
+ required: true
753
+ example: 'travelgate-hotelx'
754
+ schema:
755
+ type: string
756
+ - name: userId
757
+ in: path
758
+ description: the user/company that the appKey belongs to
759
+ required: true
760
+ schema:
761
+ type: string
762
+ requestBody:
763
+ description: Search query
764
+ required: true
765
+ content:
766
+ application/json:
767
+ schema:
768
+ $ref: '#/components/schemas/bookingsProductQuery'
769
+ responses:
770
+ '200':
771
+ description: search results
772
+ content:
773
+ application/json:
774
+ schema:
775
+ $ref: '#/components/schemas/bookingsProductSearchReturn'
776
+ /products/{appKey}/{userId}/{hint}/search:
777
+ post:
778
+ security:
779
+ - bearerAuth: ['admin', 'user']
780
+ tags:
781
+ - bookings
782
+ summary: Product Search using for an specific hint
783
+ operationId: bookingsProductSearch
784
+ parameters:
785
+ - name: appKey
786
+ in: path
787
+ description: app to search the booking products, defaults to first token
788
+ required: true
789
+ example: 'travelgate-hotelx'
790
+ schema:
791
+ type: string
792
+ - name: userId
793
+ in: path
794
+ description: the user/company that the appKey belongs to
795
+ required: true
796
+ schema:
797
+ type: string
798
+ - name: hint
799
+ in: path
800
+ description: a specific token hint to be used
801
+ required: true
802
+ example: 'travelgate-australia'
803
+ schema:
804
+ type: string
805
+ requestBody:
806
+ description: Search query
807
+ required: true
808
+ content:
809
+ application/json:
810
+ schema:
811
+ $ref: '#/components/schemas/bookingsProductQuery'
812
+ responses:
813
+ '200':
814
+ description: search results
815
+ content:
816
+ application/json:
817
+ schema:
818
+ $ref: '#/components/schemas/bookingsProductSearchReturn'
819
+ /bookings/{appKey}/{userId}/availability:
820
+ post:
821
+ security:
822
+ - bearerAuth: ['admin', 'user']
823
+ tags:
824
+ - bookings
825
+ summary: Availability Search
826
+ operationId: bookingsAvailabilitySearch
827
+ parameters:
828
+ - name: appKey
829
+ in: path
830
+ description: app to search availability for, defaults to first token
831
+ required: true
832
+ example: 'travelgate-hotelx'
833
+ schema:
834
+ type: string
835
+ - name: userId
836
+ in: path
837
+ description: the user/company that the appKey belongs to
838
+ required: true
839
+ schema:
840
+ type: string
841
+ requestBody:
842
+ description: both app details
843
+ required: true
844
+ content:
845
+ application/json:
846
+ schema:
847
+ $ref: '#/components/schemas/AnyValue'
848
+ responses:
849
+ '200':
850
+ description: search results
851
+ content:
852
+ application/json:
853
+ schema:
854
+ type: object
855
+ properties:
856
+ availability:
857
+ type: array
858
+ required: true
859
+ items:
860
+ $ref: '#/components/schemas/availabilityItem'
861
+ /bookings/{appKey}/{userId}/{hint}/availability:
862
+ post:
863
+ security:
864
+ - bearerAuth: ['admin', 'user']
865
+ tags:
866
+ - bookings
867
+ summary: Availability Search for an specific hint
868
+ operationId: bookingsAvailabilitySearch
869
+ parameters:
870
+ - name: appKey
871
+ in: path
872
+ description: app to search availability for, defaults to first token
873
+ required: true
874
+ example: 'travelgate-hotelx'
875
+ schema:
876
+ type: string
877
+ - name: userId
878
+ in: path
879
+ description: the user/company that the appKey belongs to
880
+ required: true
881
+ schema:
882
+ type: string
883
+ - name: hint
884
+ in: path
885
+ description: a specific token hint to be used
886
+ required: true
887
+ example: 'travelgate-australia'
888
+ schema:
889
+ type: string
890
+ requestBody:
891
+ description: both app details
892
+ required: true
893
+ content:
894
+ application/json:
895
+ schema:
896
+ $ref: '#/components/schemas/AnyValue'
897
+ responses:
898
+ '200':
899
+ description: search results
900
+ content:
901
+ application/json:
902
+ schema:
903
+ type: object
904
+ properties:
905
+ availability:
906
+ type: array
907
+ required: true
908
+ items:
909
+ $ref: '#/components/schemas/availabilityItem'
910
+ /bookings/{appKey}/{userId}/quote:
911
+ post:
912
+ security:
913
+ - bearerAuth: ['admin', 'user']
914
+ tags:
915
+ - bookings
916
+ summary: Quote an Availability
917
+ operationId: searchQuote
918
+ parameters:
919
+ - name: appKey
920
+ in: path
921
+ description: app to quote availability for, defaults to first token
922
+ required: true
923
+ example: 'travelgate-hotelx'
924
+ schema:
925
+ type: string
926
+ - name: userId
927
+ in: path
928
+ description: the user/company that the appKey belongs to
929
+ required: true
930
+ schema:
931
+ type: string
932
+ requestBody:
933
+ description: Availability spec to be quoted
934
+ required: true
636
935
  content:
637
936
  application/json:
638
- schema: '#/components/schemas/AnyValue'
937
+ schema:
938
+ type: object
939
+ additionalProperties: true
940
+ properties:
941
+ id:
942
+ type: string
943
+ required: true
944
+ description: An availability Id to quote
945
+ responses:
946
+ '200':
947
+ description: Quote Details
948
+ content:
949
+ application/json:
950
+ schema:
951
+ type: object
952
+ required: true
953
+ properties:
954
+ quote:
955
+ type: array
956
+ required: true
957
+ items:
958
+ type: object
959
+ additionalProperties: true
960
+ properties:
961
+ id:
962
+ type: string
963
+ description: a quote Id that can be use to book
964
+ /bookings/{appKey}/{userId}/{hint}/quote:
965
+ post:
966
+ security:
967
+ - bearerAuth: ['admin', 'user']
968
+ tags:
969
+ - bookings
970
+ summary: Quote an Availability for an specific hint
971
+ operationId: searchQuote
972
+ parameters:
973
+ - name: appKey
974
+ in: path
975
+ description: app to quote the availability for, defaults to first token
976
+ required: true
977
+ example: 'travelgate-hotelx'
978
+ schema:
979
+ type: string
980
+ - name: userId
981
+ in: path
982
+ description: the user/company that the appKey belongs to
983
+ required: true
984
+ schema:
985
+ type: string
986
+ - name: hint
987
+ in: path
988
+ description: a specific token hint to be used
989
+ required: true
990
+ example: 'travelgate-australia'
991
+ schema:
992
+ type: string
993
+ requestBody:
994
+ description: Availability spec to be quoted
995
+ required: true
996
+ content:
997
+ application/json:
998
+ schema:
999
+ type: object
1000
+ additionalProperties: true
1001
+ properties:
1002
+ id:
1003
+ type: string
1004
+ required: true
1005
+ description: An availability Id to quote
1006
+ responses:
1007
+ '200':
1008
+ description: Quote Details
1009
+ content:
1010
+ application/json:
1011
+ schema:
1012
+ type: object
1013
+ required: true
1014
+ properties:
1015
+ quote:
1016
+ type: array
1017
+ required: true
1018
+ items:
1019
+ type: object
1020
+ additionalProperties: true
1021
+ properties:
1022
+ id:
1023
+ type: string
1024
+ description: a quote Id that can be use to book
1025
+ /bookings/{appKey}/{userId}/booking:
1026
+ post:
1027
+ security:
1028
+ - bearerAuth: ['admin', 'user']
1029
+ tags:
1030
+ - bookings
1031
+ summary: Create a Booking
1032
+ operationId: createBooking
1033
+ parameters:
1034
+ - name: appKey
1035
+ in: path
1036
+ description: app to create the booking for, defaults to first token
1037
+ required: true
1038
+ example: 'travelgate-hotelx'
1039
+ schema:
1040
+ type: string
1041
+ - name: userId
1042
+ in: path
1043
+ description: the user/company that the appKey belongs to
1044
+ required: true
1045
+ schema:
1046
+ type: string
1047
+ requestBody:
1048
+ description: Booking creation payload
1049
+ required: true
1050
+ content:
1051
+ application/json:
1052
+ schema:
1053
+ $ref: '#/components/schemas/bookingRequest'
1054
+ responses:
1055
+ '200':
1056
+ description: Booking Details
1057
+ content:
1058
+ application/json:
1059
+ schema:
1060
+ $ref: '#/components/schemas/AnyValue'
1061
+ /bookings/{appKey}/{userId}/{hint}/booking:
1062
+ post:
1063
+ security:
1064
+ - bearerAuth: ['admin', 'user']
1065
+ tags:
1066
+ - bookings
1067
+ summary: Create a Booking for an specific hint
1068
+ operationId: createBooking
1069
+ parameters:
1070
+ - name: appKey
1071
+ in: path
1072
+ description: app to create the booking for, defaults to first token
1073
+ required: true
1074
+ example: 'travelgate-hotelx'
1075
+ schema:
1076
+ type: string
1077
+ - name: userId
1078
+ in: path
1079
+ description: the user/company that the appKey belongs to
1080
+ required: true
1081
+ schema:
1082
+ type: string
1083
+ - name: hint
1084
+ in: path
1085
+ description: a specific token hint to be used
1086
+ required: true
1087
+ example: 'travelgate-australia'
1088
+ schema:
1089
+ type: string
1090
+ requestBody:
1091
+ description: Booking creation payload
1092
+ required: true
1093
+ content:
1094
+ application/json:
1095
+ schema:
1096
+ $ref: '#/components/schemas/bookingRequest'
1097
+ responses:
1098
+ '200':
1099
+ description: Booking Details
1100
+ content:
1101
+ application/json:
1102
+ schema:
1103
+ $ref: '#/components/schemas/AnyValue'