1 | "use strict";
|
2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7 | };
|
8 | var __metadata = (this && this.__metadata) || function (k, v) {
|
9 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
10 | };
|
11 | var ionic_native_1 = require('ionic-native');
|
12 | var auth_1 = require('./auth');
|
13 | var client_1 = require('./client');
|
14 | var config_1 = require('./config');
|
15 | var cordova_1 = require('./cordova');
|
16 | var core_1 = require('./core');
|
17 | var deploy_1 = require('./deploy/deploy');
|
18 | var device_1 = require('./device');
|
19 | var events_1 = require('./events');
|
20 | var insights_1 = require('./insights');
|
21 | var logger_1 = require('./logger');
|
22 | var push_1 = require('./push/push');
|
23 | var storage_1 = require('./storage');
|
24 | var user_1 = require('./user/user');
|
25 | var modules = {};
|
26 | function cache(target, propertyKey, descriptor) {
|
27 | var method = descriptor.get;
|
28 | descriptor.get = function () {
|
29 | if (typeof method !== 'undefined' && typeof modules[propertyKey] === 'undefined') {
|
30 | var value = method.apply(this, arguments);
|
31 | modules[propertyKey] = value;
|
32 | }
|
33 | return modules[propertyKey];
|
34 | };
|
35 | descriptor.set = function (value) { };
|
36 | }
|
37 |
|
38 |
|
39 |
|
40 | var Container = (function () {
|
41 | function Container() {
|
42 | }
|
43 | Object.defineProperty(Container.prototype, "appStatus", {
|
44 | get: function () {
|
45 | return { 'asleep': false, 'closed': false };
|
46 | },
|
47 | enumerable: true,
|
48 | configurable: true
|
49 | });
|
50 | Object.defineProperty(Container.prototype, "config", {
|
51 | get: function () {
|
52 | return new config_1.Config();
|
53 | },
|
54 | enumerable: true,
|
55 | configurable: true
|
56 | });
|
57 | Object.defineProperty(Container.prototype, "eventEmitter", {
|
58 | get: function () {
|
59 | return new events_1.EventEmitter();
|
60 | },
|
61 | enumerable: true,
|
62 | configurable: true
|
63 | });
|
64 | Object.defineProperty(Container.prototype, "logger", {
|
65 | get: function () {
|
66 | var config = this.config;
|
67 | var c = {};
|
68 | if (typeof config.settings !== 'undefined' && typeof config.settings.logger !== 'undefined') {
|
69 | c = config.settings.logger;
|
70 | }
|
71 | return new logger_1.Logger(c);
|
72 | },
|
73 | enumerable: true,
|
74 | configurable: true
|
75 | });
|
76 | Object.defineProperty(Container.prototype, "localStorageStrategy", {
|
77 | get: function () {
|
78 | return new storage_1.LocalStorageStrategy();
|
79 | },
|
80 | enumerable: true,
|
81 | configurable: true
|
82 | });
|
83 | Object.defineProperty(Container.prototype, "sessionStorageStrategy", {
|
84 | get: function () {
|
85 | return new storage_1.SessionStorageStrategy();
|
86 | },
|
87 | enumerable: true,
|
88 | configurable: true
|
89 | });
|
90 | Object.defineProperty(Container.prototype, "authTokenContext", {
|
91 | get: function () {
|
92 | var label = 'auth_' + this.config.get('app_id');
|
93 | return new auth_1.CombinedAuthTokenContext({
|
94 | 'storage': new storage_1.Storage({ 'strategy': this.localStorageStrategy }),
|
95 | 'tempStorage': new storage_1.Storage({ 'strategy': this.sessionStorageStrategy })
|
96 | }, label);
|
97 | },
|
98 | enumerable: true,
|
99 | configurable: true
|
100 | });
|
101 | Object.defineProperty(Container.prototype, "client", {
|
102 | get: function () {
|
103 | return new client_1.Client(this.authTokenContext, this.config.getURL('api'));
|
104 | },
|
105 | enumerable: true,
|
106 | configurable: true
|
107 | });
|
108 | Object.defineProperty(Container.prototype, "insights", {
|
109 | get: function () {
|
110 | return new insights_1.Insights({
|
111 | 'appStatus': this.appStatus,
|
112 | 'storage': new storage_1.Storage({ 'strategy': this.localStorageStrategy }),
|
113 | 'config': this.config,
|
114 | 'client': this.client,
|
115 | 'device': this.device,
|
116 | 'logger': this.logger
|
117 | });
|
118 | },
|
119 | enumerable: true,
|
120 | configurable: true
|
121 | });
|
122 | Object.defineProperty(Container.prototype, "core", {
|
123 | get: function () {
|
124 | return new core_1.Core({
|
125 | 'config': this.config,
|
126 | 'logger': this.logger,
|
127 | 'emitter': this.eventEmitter,
|
128 | 'insights': this.insights
|
129 | });
|
130 | },
|
131 | enumerable: true,
|
132 | configurable: true
|
133 | });
|
134 | Object.defineProperty(Container.prototype, "device", {
|
135 | get: function () {
|
136 | return new device_1.Device({ 'nativeDevice': ionic_native_1.Device, 'emitter': this.eventEmitter });
|
137 | },
|
138 | enumerable: true,
|
139 | configurable: true
|
140 | });
|
141 | Object.defineProperty(Container.prototype, "cordova", {
|
142 | get: function () {
|
143 | return new cordova_1.Cordova({
|
144 | 'appStatus': this.appStatus,
|
145 | 'device': this.device,
|
146 | 'emitter': this.eventEmitter,
|
147 | 'logger': this.logger
|
148 | });
|
149 | },
|
150 | enumerable: true,
|
151 | configurable: true
|
152 | });
|
153 | Object.defineProperty(Container.prototype, "userContext", {
|
154 | get: function () {
|
155 | return new user_1.UserContext({ 'storage': new storage_1.Storage({ 'strategy': this.localStorageStrategy }), 'config': this.config });
|
156 | },
|
157 | enumerable: true,
|
158 | configurable: true
|
159 | });
|
160 | Object.defineProperty(Container.prototype, "singleUserService", {
|
161 | get: function () {
|
162 | return new user_1.SingleUserService({ 'client': this.client, 'context': this.userContext });
|
163 | },
|
164 | enumerable: true,
|
165 | configurable: true
|
166 | });
|
167 | Object.defineProperty(Container.prototype, "authModules", {
|
168 | get: function () {
|
169 | var authModuleDeps = {
|
170 | 'config': this.config,
|
171 | 'client': this.client,
|
172 | 'emitter': this.eventEmitter
|
173 | };
|
174 | return {
|
175 | 'basic': new auth_1.BasicAuthType(authModuleDeps),
|
176 | 'custom': new auth_1.CustomAuthType(authModuleDeps),
|
177 | 'twitter': new auth_1.TwitterAuthType(authModuleDeps),
|
178 | 'facebook': new auth_1.FacebookAuthType(authModuleDeps),
|
179 | 'github': new auth_1.GithubAuthType(authModuleDeps),
|
180 | 'google': new auth_1.GoogleAuthType(authModuleDeps),
|
181 | 'instagram': new auth_1.InstagramAuthType(authModuleDeps),
|
182 | 'linkedin': new auth_1.LinkedInAuthType(authModuleDeps)
|
183 | };
|
184 | },
|
185 | enumerable: true,
|
186 | configurable: true
|
187 | });
|
188 | Object.defineProperty(Container.prototype, "auth", {
|
189 | get: function () {
|
190 | return new auth_1.Auth({
|
191 | 'config': this.config,
|
192 | 'emitter': this.eventEmitter,
|
193 | 'authModules': this.authModules,
|
194 | 'tokenContext': this.authTokenContext,
|
195 | 'userService': this.singleUserService
|
196 | });
|
197 | },
|
198 | enumerable: true,
|
199 | configurable: true
|
200 | });
|
201 | Object.defineProperty(Container.prototype, "facebookAuth", {
|
202 | get: function () {
|
203 | return new auth_1.FacebookAuth({
|
204 | 'config': this.config,
|
205 | 'client': this.client,
|
206 | 'userService': this.singleUserService,
|
207 | 'storage': new storage_1.Storage({ 'strategy': this.localStorageStrategy }),
|
208 | 'tokenContext': this.authTokenContext,
|
209 | 'emitter': this.eventEmitter
|
210 | });
|
211 | },
|
212 | enumerable: true,
|
213 | configurable: true
|
214 | });
|
215 | Object.defineProperty(Container.prototype, "googleAuth", {
|
216 | get: function () {
|
217 | return new auth_1.GoogleAuth({
|
218 | 'config': this.config,
|
219 | 'client': this.client,
|
220 | 'userService': this.singleUserService,
|
221 | 'storage': new storage_1.Storage({ 'strategy': this.localStorageStrategy }),
|
222 | 'tokenContext': this.authTokenContext,
|
223 | 'emitter': this.eventEmitter
|
224 | });
|
225 | },
|
226 | enumerable: true,
|
227 | configurable: true
|
228 | });
|
229 | Object.defineProperty(Container.prototype, "push", {
|
230 | get: function () {
|
231 | var config = this.config;
|
232 | var c = {};
|
233 | if (typeof config.settings !== 'undefined' && typeof config.settings.push !== 'undefined') {
|
234 | c = config.settings.push;
|
235 | }
|
236 | return new push_1.Push({
|
237 | 'config': config,
|
238 | 'auth': this.auth,
|
239 | 'userService': this.singleUserService,
|
240 | 'device': this.device,
|
241 | 'client': this.client,
|
242 | 'emitter': this.eventEmitter,
|
243 | 'storage': new storage_1.Storage({ 'strategy': this.localStorageStrategy }),
|
244 | 'logger': this.logger
|
245 | }, c);
|
246 | },
|
247 | enumerable: true,
|
248 | configurable: true
|
249 | });
|
250 | Object.defineProperty(Container.prototype, "deploy", {
|
251 | get: function () {
|
252 | return new deploy_1.Deploy({
|
253 | 'config': this.config,
|
254 | 'emitter': this.eventEmitter,
|
255 | 'logger': this.logger
|
256 | });
|
257 | },
|
258 | enumerable: true,
|
259 | configurable: true
|
260 | });
|
261 | __decorate([
|
262 | cache,
|
263 | __metadata('design:type', Object)
|
264 | ], Container.prototype, "appStatus", null);
|
265 | __decorate([
|
266 | cache,
|
267 | __metadata('design:type', Object)
|
268 | ], Container.prototype, "config", null);
|
269 | __decorate([
|
270 | cache,
|
271 | __metadata('design:type', Object)
|
272 | ], Container.prototype, "eventEmitter", null);
|
273 | __decorate([
|
274 | cache,
|
275 | __metadata('design:type', Object)
|
276 | ], Container.prototype, "logger", null);
|
277 | __decorate([
|
278 | cache,
|
279 | __metadata('design:type', Object)
|
280 | ], Container.prototype, "localStorageStrategy", null);
|
281 | __decorate([
|
282 | cache,
|
283 | __metadata('design:type', Object)
|
284 | ], Container.prototype, "sessionStorageStrategy", null);
|
285 | __decorate([
|
286 | cache,
|
287 | __metadata('design:type', Object)
|
288 | ], Container.prototype, "authTokenContext", null);
|
289 | __decorate([
|
290 | cache,
|
291 | __metadata('design:type', Object)
|
292 | ], Container.prototype, "client", null);
|
293 | __decorate([
|
294 | cache,
|
295 | __metadata('design:type', Object)
|
296 | ], Container.prototype, "insights", null);
|
297 | __decorate([
|
298 | cache,
|
299 | __metadata('design:type', Object)
|
300 | ], Container.prototype, "core", null);
|
301 | __decorate([
|
302 | cache,
|
303 | __metadata('design:type', Object)
|
304 | ], Container.prototype, "device", null);
|
305 | __decorate([
|
306 | cache,
|
307 | __metadata('design:type', Object)
|
308 | ], Container.prototype, "cordova", null);
|
309 | __decorate([
|
310 | cache,
|
311 | __metadata('design:type', Object)
|
312 | ], Container.prototype, "userContext", null);
|
313 | __decorate([
|
314 | cache,
|
315 | __metadata('design:type', Object)
|
316 | ], Container.prototype, "singleUserService", null);
|
317 | __decorate([
|
318 | cache,
|
319 | __metadata('design:type', Object)
|
320 | ], Container.prototype, "authModules", null);
|
321 | __decorate([
|
322 | cache,
|
323 | __metadata('design:type', Object)
|
324 | ], Container.prototype, "auth", null);
|
325 | __decorate([
|
326 | cache,
|
327 | __metadata('design:type', Object)
|
328 | ], Container.prototype, "facebookAuth", null);
|
329 | __decorate([
|
330 | cache,
|
331 | __metadata('design:type', Object)
|
332 | ], Container.prototype, "googleAuth", null);
|
333 | __decorate([
|
334 | cache,
|
335 | __metadata('design:type', Object)
|
336 | ], Container.prototype, "push", null);
|
337 | __decorate([
|
338 | cache,
|
339 | __metadata('design:type', Object)
|
340 | ], Container.prototype, "deploy", null);
|
341 | return Container;
|
342 | }());
|
343 | exports.Container = Container;
|
344 |
|
\ | No newline at end of file |