1
1
import Request from 'backendless-request'
2
2
3
- import Logging from './logging'
4
- import Counters from './counters'
5
- import Cache from './cache'
6
- import Commerce from './commerce'
7
- import Users from './users'
8
- import User from './users/user'
9
- import CustomServices from './bl/custom-services'
10
- import Events from './bl/events'
11
- import Geo from './geo'
12
- import Data from './data'
13
- import Messaging from './messaging'
14
- import Device from './device'
15
- import Files from './files'
16
- import RT , { setRTDebugMode } from './rt'
17
- import SharedObject from './rso'
18
- import LocalCache from './local-cache'
19
3
import LocalVars from './local-vars'
20
4
21
- import { initApp } from './init-app'
22
- import { getUserAgent } from './user-agent'
23
- import { getCurrentUserToken } from './users/current-user'
24
-
25
5
const root = ( typeof self === 'object' && self . self === self && self ) ||
26
6
( typeof global === 'object' && global . global === global && global )
27
7
@@ -36,7 +16,7 @@ const Backendless = {
36
16
set debugMode ( debugMode ) {
37
17
LocalVars . debugMode = ! ! debugMode
38
18
39
- setRTDebugMode ( LocalVars . debugMode )
19
+ require ( './rt' ) . setRTDebugMode ( LocalVars . debugMode )
40
20
} ,
41
21
42
22
get serverURL ( ) {
@@ -59,14 +39,35 @@ const Backendless = {
59
39
return LocalVars . applicationId
60
40
} ,
61
41
42
+ set applicationId ( appId ) {
43
+ throw new Error (
44
+ `Setting '${ appId } ' value to Backendless.applicationId directly is not possible, ` +
45
+ `instead you must use Backendless.initApp('${ appId } ', API_KEY)`
46
+ )
47
+ } ,
48
+
62
49
get secretKey ( ) {
63
50
return LocalVars . secretKey
64
51
} ,
65
52
53
+ set secretKey ( apiKey ) {
54
+ throw new Error (
55
+ `Setting '${ apiKey } ' value to Backendless.secretKey directly is not possible, ` +
56
+ `instead you must use Backendless.initApp(APP_ID, '${ apiKey } ')`
57
+ )
58
+ } ,
59
+
66
60
get appPath ( ) {
67
61
return LocalVars . appPath
68
62
} ,
69
63
64
+ set appPath ( appPath ) {
65
+ throw new Error (
66
+ `Setting '${ appPath } ' value to Backendless.appPath directly is not possible, ` +
67
+ 'instead you must use Backendless.initApp(APP_ID, API_KEY) for setup the value'
68
+ )
69
+ } ,
70
+
70
71
get ServerCode ( ) {
71
72
return LocalVars . ServerCode
72
73
} ,
@@ -75,13 +76,23 @@ const Backendless = {
75
76
LocalVars . ServerCode = ServerCode
76
77
} ,
77
78
78
- initApp,
79
+ initApp ( ...args ) {
80
+ require ( './init-app' ) . initApp ( ...args )
81
+ } ,
82
+
83
+ getCurrentUserToken ( ) {
84
+ return require ( './users/current-user' ) . getCurrentUserToken ( )
85
+ } ,
79
86
80
- getCurrentUserToken,
87
+ setupDevice ( ...args ) {
88
+ const { default : Device } = require ( './device' )
81
89
82
- setupDevice : Device . setup ,
90
+ Device . setup ( ...args )
91
+ } ,
83
92
84
- browser : getUserAgent ( ) ,
93
+ get browser ( ) {
94
+ return require ( './user-agent' ) . getUserAgent ( )
95
+ } ,
85
96
86
97
Request,
87
98
@@ -96,20 +107,61 @@ const Backendless = {
96
107
///-------------------------------------///
97
108
///-------------- SERVICES -------------///
98
109
99
- Logging : Logging ,
100
- Counters : Counters ,
101
- Cache : Cache ,
102
- Commerce : Commerce ,
103
- Users : Users ,
104
- User : User ,
105
- CustomServices : CustomServices ,
106
- Events : Events ,
107
- Geo : Geo ,
108
- Data : Data ,
109
- Messaging : Messaging ,
110
- Files : Files ,
111
- RT : RT ,
112
- SharedObject : SharedObject ,
110
+ get Logging ( ) {
111
+ return require ( './logging' ) . default
112
+ } ,
113
+
114
+ get Counters ( ) {
115
+ return require ( './counters' ) . default
116
+ } ,
117
+
118
+ get Cache ( ) {
119
+ return require ( './cache' ) . default
120
+ } ,
121
+
122
+ get Commerce ( ) {
123
+ return require ( './commerce' ) . default
124
+ } ,
125
+
126
+ get Users ( ) {
127
+ return require ( './users' ) . default
128
+ } ,
129
+
130
+ get User ( ) {
131
+ return require ( './users/user' ) . default
132
+ } ,
133
+
134
+ get CustomServices ( ) {
135
+ return require ( './bl/custom-services' ) . default
136
+ } ,
137
+
138
+ get Events ( ) {
139
+ return require ( './bl/events' ) . default
140
+ } ,
141
+
142
+ get Geo ( ) {
143
+ return require ( './geo' ) . default
144
+ } ,
145
+
146
+ get Data ( ) {
147
+ return require ( './data' ) . default
148
+ } ,
149
+
150
+ get Messaging ( ) {
151
+ return require ( './messaging' ) . default
152
+ } ,
153
+
154
+ get Files ( ) {
155
+ return require ( './files' ) . default
156
+ } ,
157
+
158
+ get RT ( ) {
159
+ return require ( './rt' ) . default
160
+ } ,
161
+
162
+ get SharedObject ( ) {
163
+ return require ( './rso' ) . default
164
+ } ,
113
165
114
166
///-------------- SERVICES -------------///
115
167
///-------------------------------------///
@@ -118,22 +170,59 @@ const Backendless = {
118
170
///--------BACKWARD COMPATIBILITY-------///
119
171
120
172
//TODO: do we need to remove it?
121
- UserService : Users ,
122
- GeoQuery : Geo . Query ,
123
- GeoPoint : Geo . Point ,
124
- GeoCluster : Geo . Cluster ,
125
- Persistence : Data ,
126
- DataQueryBuilder : Data . QueryBuilder ,
127
- LoadRelationsQueryBuilder : Data . LoadRelationsQueryBuilder ,
128
- Bodyparts : Messaging . Bodyparts ,
129
- PublishOptions : Messaging . PublishOptions ,
130
- DeliveryOptions : Messaging . DeliveryOptions ,
131
- PublishOptionsHeaders : Messaging . PublishOptionsHeaders ,
132
-
133
- LocalCache,
173
+
174
+ get UserService ( ) {
175
+ return Backendless . Users
176
+ } ,
177
+
178
+ get GeoQuery ( ) {
179
+ return Backendless . Geo . Query
180
+ } ,
181
+
182
+ get GeoPoint ( ) {
183
+ return Backendless . Geo . Point
184
+ } ,
185
+
186
+ get GeoCluster ( ) {
187
+ return Backendless . Geo . Cluster
188
+ } ,
189
+
190
+ get Persistence ( ) {
191
+ return Backendless . Data
192
+ } ,
193
+
194
+ get DataQueryBuilder ( ) {
195
+ return Backendless . Data . QueryBuilder
196
+ } ,
197
+
198
+ get LoadRelationsQueryBuilder ( ) {
199
+ return Backendless . Data . LoadRelationsQueryBuilder
200
+ } ,
201
+
202
+ get Bodyparts ( ) {
203
+ return Backendless . Messaging . Bodyparts
204
+ } ,
205
+
206
+ get PublishOptions ( ) {
207
+ return Backendless . Messaging . PublishOptions
208
+ } ,
209
+
210
+ get DeliveryOptions ( ) {
211
+ return Backendless . Messaging . DeliveryOptions
212
+ } ,
213
+
214
+ get PublishOptionsHeaders ( ) {
215
+ return Backendless . Messaging . PublishOptionsHeaders
216
+ } ,
217
+
218
+ get LocalCache ( ) {
219
+ return require ( './local-cache' ) . default
220
+ } ,
134
221
135
222
/** @deprecated */
136
- SubscriptionOptions : Messaging . SubscriptionOptions ,
223
+ get SubscriptionOptions ( ) {
224
+ return Backendless . Messaging . SubscriptionOptions
225
+ } ,
137
226
138
227
///--------BACKWARD COMPATIBILITY-------///
139
228
///-------------------------------------///
0 commit comments