@micropermit/client-angular 0.4.5-alpha1 → 0.5.0-alpha.0

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.
Files changed (55) hide show
  1. package/{fesm2015/micropermit-client-angular.js → fesm2022/micropermit-client-angular.mjs} +354 -1513
  2. package/fesm2022/micropermit-client-angular.mjs.map +1 -0
  3. package/{micropermit-client-angular.d.ts → index.d.ts} +1 -0
  4. package/lib/components/errorindicator.component.d.ts +3 -0
  5. package/lib/components/loadingindicator.component.d.ts +3 -0
  6. package/lib/directives/call-link.directive.d.ts +3 -0
  7. package/lib/directives/linkfield.directive.d.ts +7 -4
  8. package/lib/directives/micro-link-validate.directive.d.ts +3 -0
  9. package/lib/link-field-paging-support.d.ts +1 -1
  10. package/lib/microclient.module.d.ts +10 -0
  11. package/lib/microclient.service.d.ts +3 -0
  12. package/lib/pipes/linkfield.pipe.d.ts +3 -0
  13. package/package.json +14 -12
  14. package/bundles/micropermit-client-angular.umd.js +0 -3315
  15. package/bundles/micropermit-client-angular.umd.js.map +0 -1
  16. package/bundles/micropermit-client-angular.umd.min.js +0 -16
  17. package/bundles/micropermit-client-angular.umd.min.js.map +0 -1
  18. package/esm2015/lib/components/errorindicator.component.js +0 -53
  19. package/esm2015/lib/components/loadingindicator.component.js +0 -49
  20. package/esm2015/lib/directives/call-link.directive.js +0 -110
  21. package/esm2015/lib/directives/linkfield.directive.js +0 -363
  22. package/esm2015/lib/directives/micro-link-validate.directive.js +0 -141
  23. package/esm2015/lib/error/microerror.js +0 -27
  24. package/esm2015/lib/link-field-paging-support.js +0 -318
  25. package/esm2015/lib/links/callablelink.js +0 -265
  26. package/esm2015/lib/links/linkfield.js +0 -289
  27. package/esm2015/lib/links/mock-linkfield.js +0 -42
  28. package/esm2015/lib/microclient.module.js +0 -54
  29. package/esm2015/lib/microclient.service.js +0 -515
  30. package/esm2015/lib/microobject.js +0 -222
  31. package/esm2015/lib/paramutils.js +0 -176
  32. package/esm2015/lib/pipes/linkfield.pipe.js +0 -53
  33. package/esm2015/micropermit-client-angular.js +0 -9
  34. package/esm2015/public_api.js +0 -23
  35. package/esm5/lib/components/errorindicator.component.js +0 -36
  36. package/esm5/lib/components/loadingindicator.component.js +0 -19
  37. package/esm5/lib/directives/call-link.directive.js +0 -112
  38. package/esm5/lib/directives/linkfield.directive.js +0 -420
  39. package/esm5/lib/directives/micro-link-validate.directive.js +0 -152
  40. package/esm5/lib/error/microerror.js +0 -31
  41. package/esm5/lib/link-field-paging-support.js +0 -387
  42. package/esm5/lib/links/callablelink.js +0 -336
  43. package/esm5/lib/links/linkfield.js +0 -369
  44. package/esm5/lib/links/mock-linkfield.js +0 -56
  45. package/esm5/lib/microclient.module.js +0 -61
  46. package/esm5/lib/microclient.service.js +0 -616
  47. package/esm5/lib/microobject.js +0 -296
  48. package/esm5/lib/paramutils.js +0 -228
  49. package/esm5/lib/pipes/linkfield.pipe.js +0 -60
  50. package/esm5/micropermit-client-angular.js +0 -9
  51. package/esm5/public_api.js +0 -23
  52. package/fesm2015/micropermit-client-angular.js.map +0 -1
  53. package/fesm5/micropermit-client-angular.js +0 -3116
  54. package/fesm5/micropermit-client-angular.js.map +0 -1
  55. package/micropermit-client-angular.metadata.json +0 -1
@@ -1,3315 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common/http'), require('rxjs'), require('rxjs/operators'), require('lodash'), require('@angular/common'), require('@angular/forms')) :
3
- typeof define === 'function' && define.amd ? define('@micropermit/client-angular', ['exports', '@angular/core', '@angular/common/http', 'rxjs', 'rxjs/operators', 'lodash', '@angular/common', '@angular/forms'], factory) :
4
- (global = global || self, factory((global.micropermit = global.micropermit || {}, global.micropermit['client-angular'] = {}), global.ng.core, global.ng.common.http, global.rxjs, global.rxjs.operators, global.lodash, global.ng.common, global.ng.forms));
5
- }(this, (function (exports, core, http, rxjs, operators, lodash, common, forms) { 'use strict';
6
-
7
- /*! *****************************************************************************
8
- Copyright (c) Microsoft Corporation. All rights reserved.
9
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
10
- this file except in compliance with the License. You may obtain a copy of the
11
- License at http://www.apache.org/licenses/LICENSE-2.0
12
-
13
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
15
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
16
- MERCHANTABLITY OR NON-INFRINGEMENT.
17
-
18
- See the Apache Version 2.0 License for specific language governing permissions
19
- and limitations under the License.
20
- ***************************************************************************** */
21
- /* global Reflect, Promise */
22
-
23
- var extendStatics = function(d, b) {
24
- extendStatics = Object.setPrototypeOf ||
25
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
26
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
27
- return extendStatics(d, b);
28
- };
29
-
30
- function __extends(d, b) {
31
- extendStatics(d, b);
32
- function __() { this.constructor = d; }
33
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34
- }
35
-
36
- var __assign = function() {
37
- __assign = Object.assign || function __assign(t) {
38
- for (var s, i = 1, n = arguments.length; i < n; i++) {
39
- s = arguments[i];
40
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
41
- }
42
- return t;
43
- };
44
- return __assign.apply(this, arguments);
45
- };
46
-
47
- function __rest(s, e) {
48
- var t = {};
49
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
50
- t[p] = s[p];
51
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
52
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
53
- t[p[i]] = s[p[i]];
54
- return t;
55
- }
56
-
57
- function __decorate(decorators, target, key, desc) {
58
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
59
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
60
- 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;
61
- return c > 3 && r && Object.defineProperty(target, key, r), r;
62
- }
63
-
64
- function __param(paramIndex, decorator) {
65
- return function (target, key) { decorator(target, key, paramIndex); }
66
- }
67
-
68
- function __metadata(metadataKey, metadataValue) {
69
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
70
- }
71
-
72
- function __awaiter(thisArg, _arguments, P, generator) {
73
- return new (P || (P = Promise))(function (resolve, reject) {
74
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
75
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
76
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
77
- step((generator = generator.apply(thisArg, _arguments || [])).next());
78
- });
79
- }
80
-
81
- function __generator(thisArg, body) {
82
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
83
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
84
- function verb(n) { return function (v) { return step([n, v]); }; }
85
- function step(op) {
86
- if (f) throw new TypeError("Generator is already executing.");
87
- while (_) try {
88
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
89
- if (y = 0, t) op = [op[0] & 2, t.value];
90
- switch (op[0]) {
91
- case 0: case 1: t = op; break;
92
- case 4: _.label++; return { value: op[1], done: false };
93
- case 5: _.label++; y = op[1]; op = [0]; continue;
94
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
95
- default:
96
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
97
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
98
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
99
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
100
- if (t[2]) _.ops.pop();
101
- _.trys.pop(); continue;
102
- }
103
- op = body.call(thisArg, _);
104
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
105
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
106
- }
107
- }
108
-
109
- function __exportStar(m, exports) {
110
- for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
111
- }
112
-
113
- function __values(o) {
114
- var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
115
- if (m) return m.call(o);
116
- return {
117
- next: function () {
118
- if (o && i >= o.length) o = void 0;
119
- return { value: o && o[i++], done: !o };
120
- }
121
- };
122
- }
123
-
124
- function __read(o, n) {
125
- var m = typeof Symbol === "function" && o[Symbol.iterator];
126
- if (!m) return o;
127
- var i = m.call(o), r, ar = [], e;
128
- try {
129
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
130
- }
131
- catch (error) { e = { error: error }; }
132
- finally {
133
- try {
134
- if (r && !r.done && (m = i["return"])) m.call(i);
135
- }
136
- finally { if (e) throw e.error; }
137
- }
138
- return ar;
139
- }
140
-
141
- function __spread() {
142
- for (var ar = [], i = 0; i < arguments.length; i++)
143
- ar = ar.concat(__read(arguments[i]));
144
- return ar;
145
- }
146
-
147
- function __await(v) {
148
- return this instanceof __await ? (this.v = v, this) : new __await(v);
149
- }
150
-
151
- function __asyncGenerator(thisArg, _arguments, generator) {
152
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
153
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
154
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
155
- function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
156
- function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
157
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
158
- function fulfill(value) { resume("next", value); }
159
- function reject(value) { resume("throw", value); }
160
- function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
161
- }
162
-
163
- function __asyncDelegator(o) {
164
- var i, p;
165
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
166
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
167
- }
168
-
169
- function __asyncValues(o) {
170
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
171
- var m = o[Symbol.asyncIterator], i;
172
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
173
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
174
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
175
- }
176
-
177
- function __makeTemplateObject(cooked, raw) {
178
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
179
- return cooked;
180
- };
181
-
182
- function __importStar(mod) {
183
- if (mod && mod.__esModule) return mod;
184
- var result = {};
185
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
186
- result.default = mod;
187
- return result;
188
- }
189
-
190
- function __importDefault(mod) {
191
- return (mod && mod.__esModule) ? mod : { default: mod };
192
- }
193
-
194
- /**
195
- * @fileoverview added by tsickle
196
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
197
- */
198
- var ParamUtils = /** @class */ (function () {
199
- function ParamUtils() {
200
- }
201
- /**
202
- * @param {?} url
203
- * @param {?} key
204
- * @param {?} value
205
- * @param {?=} replaceExisting
206
- * @return {?}
207
- */
208
- ParamUtils.addParam = /**
209
- * @param {?} url
210
- * @param {?} key
211
- * @param {?} value
212
- * @param {?=} replaceExisting
213
- * @return {?}
214
- */
215
- function (url, key, value, replaceExisting) {
216
- if (replaceExisting === void 0) { replaceExisting = true; }
217
- /** @type {?} */
218
- var hasQueryParams = url.indexOf('?') >= 0;
219
- if (!hasQueryParams) {
220
- url += '?';
221
- }
222
- /** @type {?} */
223
- var existingParam = ParamUtils.getParam(url, key);
224
- if (existingParam != null && replaceExisting) {
225
- url = url.replace(key + '=' + existingParam, key + '=' + value);
226
- }
227
- else {
228
- if (hasQueryParams) {
229
- url += '&';
230
- }
231
- url += key + '=' + value;
232
- }
233
- return url;
234
- };
235
- /**
236
- * @param {?} url
237
- * @param {?} params
238
- * @return {?}
239
- */
240
- ParamUtils.setParams = /**
241
- * @param {?} url
242
- * @param {?} params
243
- * @return {?}
244
- */
245
- function (url, params) {
246
- /** @type {?} */
247
- var splitted = url.split('?');
248
- /** @type {?} */
249
- var resURL = splitted[0];
250
- /** @type {?} */
251
- var first = true;
252
- for (var key in params) {
253
- if (params.hasOwnProperty(key)) {
254
- if (first) {
255
- resURL += '?';
256
- first = false;
257
- }
258
- resURL += key + '=' + params[key];
259
- }
260
- }
261
- return resURL;
262
- };
263
- /**
264
- * @param {?} url
265
- * @return {?}
266
- */
267
- ParamUtils.getParams = /**
268
- * @param {?} url
269
- * @return {?}
270
- */
271
- function (url) {
272
- var e_1, _a;
273
- /** @type {?} */
274
- var splitted = url.split('?');
275
- if (splitted.length < 2) {
276
- return {};
277
- }
278
- /** @type {?} */
279
- var queryStr = splitted[1];
280
- /** @type {?} */
281
- var params = {};
282
- /** @type {?} */
283
- var paramsStrs = queryStr.split('&');
284
- try {
285
- for (var paramsStrs_1 = __values(paramsStrs), paramsStrs_1_1 = paramsStrs_1.next(); !paramsStrs_1_1.done; paramsStrs_1_1 = paramsStrs_1.next()) {
286
- var paramStr = paramsStrs_1_1.value;
287
- /** @type {?} */
288
- var splittedParamStr = paramStr.split('=', 2);
289
- /** @type {?} */
290
- var key = splittedParamStr[0];
291
- if (splittedParamStr.length === 2) {
292
- params[key] = splittedParamStr[1];
293
- }
294
- else {
295
- params[key] = null;
296
- }
297
- }
298
- }
299
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
300
- finally {
301
- try {
302
- if (paramsStrs_1_1 && !paramsStrs_1_1.done && (_a = paramsStrs_1.return)) _a.call(paramsStrs_1);
303
- }
304
- finally { if (e_1) throw e_1.error; }
305
- }
306
- return params;
307
- };
308
- /**
309
- * @param {?} toEncode
310
- * @return {?}
311
- */
312
- ParamUtils.base64UrlEncode = /**
313
- * @param {?} toEncode
314
- * @return {?}
315
- */
316
- function (toEncode) {
317
- return btoa(toEncode)
318
- .replace(ParamUtils.plusRegex, '-')
319
- .replace(ParamUtils.slashRegex, '_')
320
- .replace(ParamUtils.multiEqualRegex, '');
321
- };
322
- /**
323
- * @param {?} toDecode
324
- * @return {?}
325
- */
326
- ParamUtils.base64UrlDecode = /**
327
- * @param {?} toDecode
328
- * @return {?}
329
- */
330
- function (toDecode) {
331
- toDecode = (toDecode + '===').slice(0, toDecode.length + (toDecode.length % 4));
332
- return atob(toDecode
333
- .replace(ParamUtils.minusRegex, '+')
334
- .replace(ParamUtils.underscoreRegex, '/'));
335
- };
336
- /**
337
- * @param {?} toCheck
338
- * @return {?}
339
- */
340
- ParamUtils.needsBase64UrlEncoding = /**
341
- * @param {?} toCheck
342
- * @return {?}
343
- */
344
- function (toCheck) {
345
- if (toCheck == null) {
346
- return false;
347
- }
348
- else {
349
- return typeof toCheck === 'object';
350
- }
351
- };
352
- /**
353
- * @param {?} url
354
- * @param {?} name
355
- * @param {?=} urlDecode
356
- * @return {?}
357
- */
358
- ParamUtils.getParam = /**
359
- * @param {?} url
360
- * @param {?} name
361
- * @param {?=} urlDecode
362
- * @return {?}
363
- */
364
- function (url, name, urlDecode) {
365
- if (urlDecode === void 0) { urlDecode = false; }
366
- /** @type {?} */
367
- var paramsQueryIdx = url.indexOf('?');
368
- url = url.substr(paramsQueryIdx);
369
- /** @type {?} */
370
- var regExp = (new RegExp('[?&]' + encodeURIComponent(name) + '=([^&]*)'));
371
- /** @type {?} */
372
- var match = regExp.exec(url);
373
- if (match) {
374
- if (urlDecode && match[1]) {
375
- return this.base64UrlDecode(match[1]);
376
- }
377
- else {
378
- return match[1];
379
- }
380
- }
381
- else {
382
- return null;
383
- }
384
- };
385
- ParamUtils.plusRegex = new RegExp('\\+');
386
- ParamUtils.slashRegex = new RegExp('/', 'g');
387
- ParamUtils.multiEqualRegex = new RegExp('=+$', 'g');
388
- ParamUtils.minusRegex = new RegExp('-', 'g');
389
- ParamUtils.underscoreRegex = new RegExp('_', 'g');
390
- return ParamUtils;
391
- }());
392
- if (false) {
393
- /**
394
- * @type {?}
395
- * @private
396
- */
397
- ParamUtils.plusRegex;
398
- /**
399
- * @type {?}
400
- * @private
401
- */
402
- ParamUtils.slashRegex;
403
- /**
404
- * @type {?}
405
- * @private
406
- */
407
- ParamUtils.multiEqualRegex;
408
- /**
409
- * @type {?}
410
- * @private
411
- */
412
- ParamUtils.minusRegex;
413
- /**
414
- * @type {?}
415
- * @private
416
- */
417
- ParamUtils.underscoreRegex;
418
- }
419
-
420
- /**
421
- * @fileoverview added by tsickle
422
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
423
- */
424
- /**
425
- * @template T
426
- */
427
- var /**
428
- * @template T
429
- */
430
- CallableLink = /** @class */ (function () {
431
- function CallableLink(link, microClient, callParams, requestOptions) {
432
- if (callParams === void 0) { callParams = null; }
433
- if (requestOptions === void 0) { requestOptions = null; }
434
- this.link = link;
435
- this.microClient = microClient;
436
- this.callParams = callParams;
437
- this.requestOptions = requestOptions;
438
- this.serializeTo = LinkSerializer.DONT_SERIALIZE;
439
- }
440
- /**
441
- * @return {?}
442
- */
443
- CallableLink.prototype.hasLink = /**
444
- * @return {?}
445
- */
446
- function () {
447
- return this.link != null;
448
- };
449
- /**
450
- * @return {?}
451
- */
452
- CallableLink.prototype.getLink = /**
453
- * @return {?}
454
- */
455
- function () {
456
- return this.link;
457
- };
458
- /**
459
- * @param {?} key
460
- * @param {?=} urlDecode
461
- * @return {?}
462
- */
463
- CallableLink.prototype.getQueryParam = /**
464
- * @param {?} key
465
- * @param {?=} urlDecode
466
- * @return {?}
467
- */
468
- function (key, urlDecode) {
469
- if (urlDecode === void 0) { urlDecode = false; }
470
- return ParamUtils.getParam(this.link, key, urlDecode);
471
- };
472
- /**
473
- * @return {?}
474
- */
475
- CallableLink.prototype.getSignedParams = /**
476
- * @return {?}
477
- */
478
- function () {
479
- /** @type {?} */
480
- var params = this.getSignedMicroObjectParam('params');
481
- if (params == null) {
482
- params = this.getSignedMicroObjectParam('bParams');
483
- }
484
- return params;
485
- };
486
- /**
487
- * @param {?=} copy
488
- * @return {?}
489
- */
490
- CallableLink.prototype.getOpenParams = /**
491
- * @param {?=} copy
492
- * @return {?}
493
- */
494
- function (copy) {
495
- if (copy === void 0) { copy = false; }
496
- /** @type {?} */
497
- var params = this.getMicroObjectParam('oParams');
498
- if (params == null) {
499
- params = this.getMicroObjectParam('bOParams');
500
- }
501
- else {
502
- if (copy) {
503
- params = MicroObject.fromString(JSON.stringify(params), this.microClient);
504
- }
505
- if (this.callParams) {
506
- params = Object.assign(params, this.callParams);
507
- }
508
- }
509
- return params;
510
- };
511
- /**
512
- * @return {?}
513
- */
514
- CallableLink.prototype.getOptions = /**
515
- * @return {?}
516
- */
517
- function () {
518
- /** @type {?} */
519
- var options = this.getMicroObjectParam('options');
520
- if (this.requestOptions) {
521
- if (options == null) {
522
- options = new MicroObject();
523
- }
524
- options = Object.assign(options, this.requestOptions);
525
- }
526
- return options;
527
- };
528
- /**
529
- * @private
530
- * @param {?} key
531
- * @return {?}
532
- */
533
- CallableLink.prototype.getSignedMicroObjectParam = /**
534
- * @private
535
- * @param {?} key
536
- * @return {?}
537
- */
538
- function (key) {
539
- /** @type {?} */
540
- var paramsStr = ParamUtils.getParam(this.link, key, false);
541
- /** @type {?} */
542
- var params = null;
543
- if (paramsStr) {
544
- /** @type {?} */
545
- var splitted = paramsStr.split('.');
546
- if (splitted.length !== 3) {
547
- throw new Error('Expected a signed query param to have a JWT like structure');
548
- }
549
- params = MicroObject.fromString(atob(splitted[1]), this.microClient);
550
- }
551
- return params;
552
- };
553
- /**
554
- * @param {?} key
555
- * @return {?}
556
- */
557
- CallableLink.prototype.getMicroObjectParam = /**
558
- * @param {?} key
559
- * @return {?}
560
- */
561
- function (key) {
562
- /** @type {?} */
563
- var paramsStr = ParamUtils.getParam(this.link, key, true);
564
- /** @type {?} */
565
- var params = null;
566
- if (paramsStr) {
567
- params = MicroObject.fromString(paramsStr, this.microClient);
568
- }
569
- return params;
570
- };
571
- /**
572
- * @param {?} onNext
573
- * @return {?}
574
- */
575
- CallableLink.prototype.call = /**
576
- * @param {?} onNext
577
- * @return {?}
578
- */
579
- function (onNext) {
580
- return this.callWith(null, null, onNext);
581
- };
582
- /**
583
- * @param {?=} params
584
- * @param {?=} requestOptions
585
- * @param {?=} onNext
586
- * @return {?}
587
- */
588
- CallableLink.prototype.callWith = /**
589
- * @param {?=} params
590
- * @param {?=} requestOptions
591
- * @param {?=} onNext
592
- * @return {?}
593
- */
594
- function (params, requestOptions, onNext) {
595
- if (params === void 0) { params = null; }
596
- if (requestOptions === void 0) { requestOptions = null; }
597
- return (/** @type {?} */ (this.callWithObs(params, requestOptions).toPromise().then(onNext)));
598
- };
599
- /**
600
- * @param {?=} params
601
- * @param {?=} requestOptions
602
- * @return {?}
603
- */
604
- CallableLink.prototype.callWithObs = /**
605
- * @param {?=} params
606
- * @param {?=} requestOptions
607
- * @return {?}
608
- */
609
- function (params, requestOptions) {
610
- if (params === void 0) { params = null; }
611
- if (requestOptions === void 0) { requestOptions = null; }
612
- if (this.link == null) {
613
- throw Error('Can\'t use callWithObs without a provided link');
614
- }
615
- if (this.microClient == null) {
616
- throw Error('Can\'t use callWithObs without a provided microClient');
617
- }
618
- /** @type {?} */
619
- var paramsToUse = null;
620
- if (this.callParams != null) {
621
- paramsToUse = Object.assign(new MicroObject(), this.callParams);
622
- }
623
- if (params) {
624
- if (paramsToUse == null) {
625
- paramsToUse = new MicroObject();
626
- }
627
- paramsToUse = Object.assign(paramsToUse, params);
628
- }
629
- /** @type {?} */
630
- var optionsToUse = null;
631
- if (this.requestOptions != null) {
632
- optionsToUse = Object.assign(new MicroObject(), this.requestOptions);
633
- }
634
- if (requestOptions) {
635
- if (optionsToUse == null) {
636
- optionsToUse = new MicroObject();
637
- }
638
- optionsToUse = Object.assign(optionsToUse, requestOptions);
639
- }
640
- return (/** @type {?} */ (this.microClient.load(this.link, paramsToUse, optionsToUse)));
641
- };
642
- /**
643
- * @return {?}
644
- */
645
- CallableLink.prototype.copy = /**
646
- * @return {?}
647
- */
648
- function () {
649
- return new CallableLink(this.link, this.microClient, this.callParams, this.requestOptions);
650
- };
651
- /**
652
- * @param {?} callParams
653
- * @param {?=} requestOptions
654
- * @return {?}
655
- */
656
- CallableLink.prototype.withCallParams = /**
657
- * @param {?} callParams
658
- * @param {?=} requestOptions
659
- * @return {?}
660
- */
661
- function (callParams, requestOptions) {
662
- if (requestOptions === void 0) { requestOptions = this.requestOptions; }
663
- return new CallableLink(this.link, this.microClient, callParams, requestOptions);
664
- };
665
- /**
666
- * @return {?}
667
- */
668
- CallableLink.prototype.toJSON = /**
669
- * @return {?}
670
- */
671
- function () {
672
- if (this.serializeTo) {
673
- return this.serializeTo(this.link, this.callParams, this.requestOptions, undefined, undefined);
674
- }
675
- else {
676
- return undefined;
677
- }
678
- };
679
- return CallableLink;
680
- }());
681
- if (false) {
682
- /** @type {?} */
683
- CallableLink.prototype.serializeTo;
684
- /**
685
- * @type {?}
686
- * @protected
687
- */
688
- CallableLink.prototype.link;
689
- /**
690
- * @type {?}
691
- * @protected
692
- */
693
- CallableLink.prototype.microClient;
694
- /**
695
- * @type {?}
696
- * @protected
697
- */
698
- CallableLink.prototype.callParams;
699
- /**
700
- * @type {?}
701
- * @protected
702
- */
703
- CallableLink.prototype.requestOptions;
704
- }
705
- // @dynamic
706
- var LinkSerializer = /** @class */ (function () {
707
- function LinkSerializer() {
708
- }
709
- LinkSerializer.DONT_SERIALIZE = (/**
710
- * @return {?}
711
- */
712
- function () {
713
- return undefined;
714
- });
715
- LinkSerializer.AS_LINK = (/**
716
- * @param {?} link
717
- * @return {?}
718
- */
719
- function (link) {
720
- return link;
721
- });
722
- LinkSerializer.AS_VALUE_IF_INITIALIZED = (/**
723
- * @param {?} link
724
- * @param {?} callParams
725
- * @param {?} requestOptions
726
- * @param {?} value
727
- * @param {?} isInitialized
728
- * @return {?}
729
- */
730
- function (link, callParams, requestOptions, value, isInitialized) {
731
- if (isInitialized) {
732
- return value;
733
- }
734
- else {
735
- return undefined;
736
- }
737
- });
738
- return LinkSerializer;
739
- }());
740
- if (false) {
741
- /** @type {?} */
742
- LinkSerializer.DONT_SERIALIZE;
743
- /** @type {?} */
744
- LinkSerializer.AS_LINK;
745
- /** @type {?} */
746
- LinkSerializer.AS_VALUE_IF_INITIALIZED;
747
- }
748
-
749
- /**
750
- * @fileoverview added by tsickle
751
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
752
- */
753
- /**
754
- * @template T
755
- */
756
- var /**
757
- * @template T
758
- */
759
- LinkField = /** @class */ (function (_super) {
760
- __extends(LinkField, _super);
761
- function LinkField(link, microClient, initialValue, initialized, callParams, requestOptions) {
762
- if (initialValue === void 0) { initialValue = null; }
763
- if (initialized === void 0) { initialized = false; }
764
- if (callParams === void 0) { callParams = null; }
765
- if (requestOptions === void 0) { requestOptions = null; }
766
- var _this = _super.call(this, link, microClient, callParams, requestOptions) || this;
767
- _this.initialized = false;
768
- _this.serializeTo = LinkSerializer.AS_VALUE_IF_INITIALIZED;
769
- _this.intervalId = null;
770
- _this.isRefreshing = false;
771
- if (initialized) {
772
- _this.set(initialValue);
773
- }
774
- return _this;
775
- }
776
- /**
777
- * @template T
778
- * @param {?} value
779
- * @return {?}
780
- */
781
- LinkField.from = /**
782
- * @template T
783
- * @param {?} value
784
- * @return {?}
785
- */
786
- function (value) {
787
- return new LinkField(null, null, value, true);
788
- };
789
- /**
790
- * @param {?=} callback
791
- * @return {?}
792
- */
793
- LinkField.prototype.get = /**
794
- * @param {?=} callback
795
- * @return {?}
796
- */
797
- function (callback) {
798
- if (callback) {
799
- this.getObs().subscribe(callback);
800
- return null;
801
- }
802
- return this.getPromise();
803
- };
804
- /**
805
- * @return {?}
806
- */
807
- LinkField.prototype.getPromise = /**
808
- * @return {?}
809
- */
810
- function () {
811
- if (!this._getPromise) {
812
- this._getPromise = this.getObs().toPromise();
813
- }
814
- return this._getPromise;
815
- };
816
- /**
817
- * @param {?=} interval
818
- * @param {?=} errorHandler
819
- * @return {?}
820
- */
821
- LinkField.prototype.refresh = /**
822
- * @param {?=} interval
823
- * @param {?=} errorHandler
824
- * @return {?}
825
- */
826
- function (interval, errorHandler) {
827
- var _this = this;
828
- if (interval) {
829
- this.stopRefresh();
830
- }
831
- /** @type {?} */
832
- var resCb = (/**
833
- * @return {?}
834
- */
835
- function () {
836
- _this.isRefreshing = false;
837
- });
838
- this.isRefreshing = true;
839
- this.initWithObs().subscribe(resCb, (/**
840
- * @param {?} error
841
- * @return {?}
842
- */
843
- function (error) {
844
- resCb();
845
- if (errorHandler) {
846
- errorHandler(error);
847
- }
848
- }), resCb);
849
- if (interval) {
850
- this.intervalId = setInterval((/**
851
- * @return {?}
852
- */
853
- function () {
854
- if (!_this.isRefreshing) {
855
- _this.isRefreshing = true;
856
- _this.initWithObs().subscribe(resCb, (/**
857
- * @param {?} error
858
- * @return {?}
859
- */
860
- function (error) {
861
- resCb();
862
- if (errorHandler) {
863
- errorHandler(error);
864
- }
865
- }), resCb);
866
- }
867
- }), interval);
868
- }
869
- };
870
- /**
871
- * @return {?}
872
- */
873
- LinkField.prototype.stopRefresh = /**
874
- * @return {?}
875
- */
876
- function () {
877
- if (this.intervalId) {
878
- clearInterval(this.intervalId);
879
- }
880
- };
881
- /**
882
- * @return {?}
883
- */
884
- LinkField.prototype.listenObs = /**
885
- * @return {?}
886
- */
887
- function () {
888
- var _this = this;
889
- //TODO handle listeners in case of intermidiate uninitialize (new valueSubj)
890
- if (this.valueSubj) {
891
- return this.valueSubj;
892
- }
893
- else {
894
- /** @type {?} */
895
- var valueSubj_1 = new rxjs.ReplaySubject(1);
896
- this.valueSubj = valueSubj_1;
897
- return rxjs.defer((/**
898
- * @return {?}
899
- */
900
- function () {
901
- _this.initWithObs(null, null).subscribe((/**
902
- * @param {?} value
903
- * @return {?}
904
- */
905
- function (value) {
906
- if (_this.valueSubj !== valueSubj_1) {
907
- valueSubj_1.next(value);
908
- valueSubj_1.complete();
909
- }
910
- }));
911
- return valueSubj_1;
912
- }));
913
- }
914
- };
915
- /**
916
- * @return {?}
917
- */
918
- LinkField.prototype.getObs = /**
919
- * @return {?}
920
- */
921
- function () {
922
- return this.listenObs().pipe(operators.take(1));
923
- };
924
- /**
925
- * @param {?} value
926
- * @return {?}
927
- */
928
- LinkField.prototype.set = /**
929
- * @param {?} value
930
- * @return {?}
931
- */
932
- function (value) {
933
- /** @type {?} */
934
- var oldValue = this.value;
935
- this.value = value;
936
- this.initialized = true;
937
- if (!this.valueSubj) {
938
- this.valueSubj = new rxjs.ReplaySubject(1);
939
- }
940
- this.valueSubj.next(value);
941
- this._getPromise = null;
942
- return oldValue;
943
- };
944
- /**
945
- * @return {?}
946
- */
947
- LinkField.prototype.isInitialized = /**
948
- * @return {?}
949
- */
950
- function () {
951
- return this.initialized;
952
- };
953
- /**
954
- * @return {?}
955
- */
956
- LinkField.prototype.uninitialize = /**
957
- * @return {?}
958
- */
959
- function () {
960
- this.value = null;
961
- this.initialized = false;
962
- this.valueSubj = null;
963
- this._getPromise = null;
964
- };
965
- /**
966
- * @return {?}
967
- */
968
- LinkField.prototype.copyUninitialized = /**
969
- * @return {?}
970
- */
971
- function () {
972
- /** @type {?} */
973
- var copy = this.copy();
974
- copy.uninitialize();
975
- return copy;
976
- };
977
- /**
978
- * @return {?}
979
- */
980
- LinkField.prototype.getInitializedValue = /**
981
- * @return {?}
982
- */
983
- function () {
984
- if (!this.isInitialized()) {
985
- throw new Error('Can\'t get the intialized value for a LinkField that hasn\'t been initialized');
986
- }
987
- return this.value;
988
- };
989
- /**
990
- * @param {?=} parms
991
- * @param {?=} requestOptions
992
- * @param {?=} callback
993
- * @return {?}
994
- */
995
- LinkField.prototype.initWith = /**
996
- * @param {?=} parms
997
- * @param {?=} requestOptions
998
- * @param {?=} callback
999
- * @return {?}
1000
- */
1001
- function (parms, requestOptions, callback) {
1002
- if (parms === void 0) { parms = null; }
1003
- if (requestOptions === void 0) { requestOptions = null; }
1004
- this.initWithObs(parms, requestOptions).subscribe(callback);
1005
- };
1006
- /**
1007
- * @param {?=} params
1008
- * @param {?=} requestOptions
1009
- * @return {?}
1010
- */
1011
- LinkField.prototype.initWithObs = /**
1012
- * @param {?=} params
1013
- * @param {?=} requestOptions
1014
- * @return {?}
1015
- */
1016
- function (params, requestOptions) {
1017
- var _this = this;
1018
- if (params === void 0) { params = null; }
1019
- if (requestOptions === void 0) { requestOptions = null; }
1020
- return this.callWithObs(params, requestOptions).pipe(operators.map((/**
1021
- * @param {?} value
1022
- * @return {?}
1023
- */
1024
- function (value) {
1025
- _this.set((/** @type {?} */ (value)));
1026
- return value;
1027
- })));
1028
- };
1029
- /**
1030
- * @param {?} callParams
1031
- * @param {?=} requestOptions
1032
- * @return {?}
1033
- */
1034
- LinkField.prototype.withCallParams = /**
1035
- * @param {?} callParams
1036
- * @param {?=} requestOptions
1037
- * @return {?}
1038
- */
1039
- function (callParams, requestOptions) {
1040
- if (requestOptions === void 0) { requestOptions = this.requestOptions; }
1041
- return new LinkField(this.link, this.microClient, this.value, this.initialized, callParams, requestOptions);
1042
- };
1043
- /**
1044
- * @param {?=} withValue
1045
- * @return {?}
1046
- */
1047
- LinkField.prototype.copy = /**
1048
- * @param {?=} withValue
1049
- * @return {?}
1050
- */
1051
- function (withValue) {
1052
- if (withValue === undefined) {
1053
- return new LinkField(this.link, this.microClient, this.value, this.initialized, this.callParams, this.requestOptions);
1054
- }
1055
- else {
1056
- return new LinkField(this.link, this.microClient, withValue, true, this.callParams, this.requestOptions);
1057
- }
1058
- };
1059
- /**
1060
- * @return {?}
1061
- */
1062
- LinkField.prototype.toJSON = /**
1063
- * @return {?}
1064
- */
1065
- function () {
1066
- if (this.serializeTo) {
1067
- return this.serializeTo(this.link, this.callParams, this.requestOptions, this.value, this.isInitialized());
1068
- }
1069
- else {
1070
- return undefined;
1071
- }
1072
- };
1073
- return LinkField;
1074
- }(CallableLink));
1075
- if (false) {
1076
- /**
1077
- * @type {?}
1078
- * @private
1079
- */
1080
- LinkField.prototype.value;
1081
- /**
1082
- * @type {?}
1083
- * @private
1084
- */
1085
- LinkField.prototype.initialized;
1086
- /**
1087
- * @type {?}
1088
- * @private
1089
- */
1090
- LinkField.prototype._getPromise;
1091
- /**
1092
- * @type {?}
1093
- * @private
1094
- */
1095
- LinkField.prototype.valueSubj;
1096
- /** @type {?} */
1097
- LinkField.prototype.serializeTo;
1098
- /**
1099
- * @type {?}
1100
- * @private
1101
- */
1102
- LinkField.prototype.intervalId;
1103
- /**
1104
- * @type {?}
1105
- * @private
1106
- */
1107
- LinkField.prototype.isRefreshing;
1108
- }
1109
-
1110
- /**
1111
- * @fileoverview added by tsickle
1112
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1113
- */
1114
- // WARNING: interface has both a type and a value, skipping emit
1115
- var MicroObject = /** @class */ (function () {
1116
- function MicroObject() {
1117
- this.__meta = undefined;
1118
- }
1119
- /**
1120
- * @template T
1121
- * @param {?} toCopy
1122
- * @param {?=} client
1123
- * @return {?}
1124
- */
1125
- MicroObject.deepCopy = /**
1126
- * @template T
1127
- * @param {?} toCopy
1128
- * @param {?=} client
1129
- * @return {?}
1130
- */
1131
- function (toCopy, client) {
1132
- return (/** @type {?} */ (lodash.cloneDeepWith(toCopy, MicroObject.deepCopyCustomizer)));
1133
- };
1134
- /**
1135
- * @private
1136
- * @param {?} value
1137
- * @return {?}
1138
- */
1139
- MicroObject.deepCopyCustomizer = /**
1140
- * @private
1141
- * @param {?} value
1142
- * @return {?}
1143
- */
1144
- function (value) {
1145
- if (value instanceof MicroClient) {
1146
- return value;
1147
- }
1148
- return undefined;
1149
- };
1150
- /**
1151
- * @template T
1152
- * @param {?} str
1153
- * @param {?} client
1154
- * @param {?=} prototype
1155
- * @return {?}
1156
- */
1157
- MicroObject.fromString = /**
1158
- * @template T
1159
- * @param {?} str
1160
- * @param {?} client
1161
- * @param {?=} prototype
1162
- * @return {?}
1163
- */
1164
- function (str, client, prototype) {
1165
- if (prototype === void 0) { prototype = null; }
1166
- /** @type {?} */
1167
- var obj = JSON.parse(str);
1168
- return this.fromObject(obj, client, prototype);
1169
- };
1170
- /**
1171
- * @template T
1172
- * @param {?} obj
1173
- * @param {?} client
1174
- * @param {?=} prototype
1175
- * @return {?}
1176
- */
1177
- MicroObject.fromObject = /**
1178
- * @template T
1179
- * @param {?} obj
1180
- * @param {?} client
1181
- * @param {?=} prototype
1182
- * @return {?}
1183
- */
1184
- function (obj, client, prototype) {
1185
- if (prototype === void 0) { prototype = null; }
1186
- if (obj === null) {
1187
- return null;
1188
- }
1189
- if (Array.isArray(obj)) {
1190
- /** @type {?} */
1191
- var objArr = obj;
1192
- for (var i = 0; i < objArr.length; i++) {
1193
- /** @type {?} */
1194
- var elem = objArr[i];
1195
- if (typeof elem === 'object') {
1196
- objArr[i] = (/** @type {?} */ (MicroObject.fromObject(elem, client, prototype)));
1197
- }
1198
- }
1199
- return objArr;
1200
- }
1201
- else {
1202
- for (var field in obj) {
1203
- if (field !== MicroObject.META_KEY && obj.hasOwnProperty(field)) {
1204
- /** @type {?} */
1205
- var fieldValue = obj[field];
1206
- if (fieldValue) {
1207
- if (fieldValue instanceof Object || Array.isArray(fieldValue)) {
1208
- obj[field] = MicroObject.fromObject(fieldValue, client, prototype);
1209
- }
1210
- }
1211
- }
1212
- }
1213
- /** @type {?} */
1214
- var src = prototype == null ? MicroObject.prototype : prototype;
1215
- /** @type {?} */
1216
- var microObject = Object.assign(Object.create(src), obj);
1217
- MicroObject.attachMetadataObject(microObject, client);
1218
- return (/** @type {?} */ (microObject));
1219
- }
1220
- };
1221
- /**
1222
- * @private
1223
- * @param {?} microObject
1224
- * @param {?} client
1225
- * @return {?}
1226
- */
1227
- MicroObject.attachMetadataObject = /**
1228
- * @private
1229
- * @param {?} microObject
1230
- * @param {?} client
1231
- * @return {?}
1232
- */
1233
- function (microObject, client) {
1234
- /** @type {?} */
1235
- var rawMeta = microObject != null ? microObject[MicroObject.META_KEY] : null;
1236
- if (rawMeta != null) {
1237
- /** @type {?} */
1238
- var clientToUse = client;
1239
- if (rawMeta.permitToken) {
1240
- if (client.getEntryPoint() != null) {
1241
- clientToUse = client.createChildClientForEntryPoint(microObject);
1242
- }
1243
- }
1244
- microObject.__meta = MicroObjectMetadata.fromObject(microObject.__meta, clientToUse);
1245
- MicroObject.attachLinkFields(microObject.__meta, microObject, clientToUse);
1246
- MicroObject.attachCallableLinks(microObject.__meta, microObject, clientToUse);
1247
- }
1248
- else {
1249
- return null;
1250
- }
1251
- };
1252
- /**
1253
- * @private
1254
- * @param {?} meta
1255
- * @param {?} microObject
1256
- * @param {?} client
1257
- * @return {?}
1258
- */
1259
- MicroObject.attachLinkFields = /**
1260
- * @private
1261
- * @param {?} meta
1262
- * @param {?} microObject
1263
- * @param {?} client
1264
- * @return {?}
1265
- */
1266
- function (meta, microObject, client) {
1267
- meta.forEachLink((/**
1268
- * @param {?} linkName
1269
- * @param {?} linkUrl
1270
- * @return {?}
1271
- */
1272
- function (linkName, linkUrl) {
1273
- /** @type {?} */
1274
- var value = microObject[linkName];
1275
- microObject[linkName] = new LinkField(linkUrl, client, value, value !== undefined);
1276
- }));
1277
- };
1278
- /**
1279
- * @private
1280
- * @param {?} meta
1281
- * @param {?} microObject
1282
- * @param {?} client
1283
- * @return {?}
1284
- */
1285
- MicroObject.attachCallableLinks = /**
1286
- * @private
1287
- * @param {?} meta
1288
- * @param {?} microObject
1289
- * @param {?} client
1290
- * @return {?}
1291
- */
1292
- function (meta, microObject, client) {
1293
- meta.forEachAction((/**
1294
- * @param {?} linkName
1295
- * @param {?} linkUrl
1296
- * @return {?}
1297
- */
1298
- function (linkName, linkUrl) {
1299
- microObject[linkName] = new CallableLink(linkUrl, client);
1300
- }));
1301
- };
1302
- MicroObject.META_KEY = '__meta';
1303
- return MicroObject;
1304
- }());
1305
- if (false) {
1306
- /** @type {?} */
1307
- MicroObject.META_KEY;
1308
- /** @type {?} */
1309
- MicroObject.prototype.__meta;
1310
- }
1311
- var MicroObjectMetadata = /** @class */ (function () {
1312
- function MicroObjectMetadata() {
1313
- }
1314
- /**
1315
- * @param {?} obj
1316
- * @param {?} client
1317
- * @return {?}
1318
- */
1319
- MicroObjectMetadata.fromObject = /**
1320
- * @param {?} obj
1321
- * @param {?} client
1322
- * @return {?}
1323
- */
1324
- function (obj, client) {
1325
- /** @type {?} */
1326
- var objMetadata = Object.assign(new MicroObjectMetadata(), obj);
1327
- if (objMetadata.nextPage != null) {
1328
- objMetadata.nextPage = new LinkField((/** @type {?} */ (objMetadata.nextPage)), client);
1329
- objMetadata.nextPage.serializeTo = LinkSerializer.AS_LINK;
1330
- }
1331
- return objMetadata;
1332
- };
1333
- /**
1334
- * @param {?} key
1335
- * @return {?}
1336
- */
1337
- MicroObjectMetadata.prototype.getLinkUrl = /**
1338
- * @param {?} key
1339
- * @return {?}
1340
- */
1341
- function (key) {
1342
- return this.links[key];
1343
- };
1344
- /**
1345
- * @param {?} key
1346
- * @return {?}
1347
- */
1348
- MicroObjectMetadata.prototype.hasLink = /**
1349
- * @param {?} key
1350
- * @return {?}
1351
- */
1352
- function (key) {
1353
- return this.links[key] != null;
1354
- };
1355
- /**
1356
- * @param {?} op
1357
- * @return {?}
1358
- */
1359
- MicroObjectMetadata.prototype.forEachLink = /**
1360
- * @param {?} op
1361
- * @return {?}
1362
- */
1363
- function (op) {
1364
- for (var link in this.links) {
1365
- if (this.links.hasOwnProperty(link)) {
1366
- op(link, this.links[link]);
1367
- }
1368
- }
1369
- };
1370
- /**
1371
- * @param {?} op
1372
- * @return {?}
1373
- */
1374
- MicroObjectMetadata.prototype.forEachAction = /**
1375
- * @param {?} op
1376
- * @return {?}
1377
- */
1378
- function (op) {
1379
- for (var link in this.actions) {
1380
- if (this.actions.hasOwnProperty(link)) {
1381
- op(link, this.actions[link]);
1382
- }
1383
- }
1384
- };
1385
- return MicroObjectMetadata;
1386
- }());
1387
- if (false) {
1388
- /** @type {?} */
1389
- MicroObjectMetadata.prototype.links;
1390
- /** @type {?} */
1391
- MicroObjectMetadata.prototype.actions;
1392
- /** @type {?} */
1393
- MicroObjectMetadata.prototype.permitToken;
1394
- /** @type {?} */
1395
- MicroObjectMetadata.prototype.nextPage;
1396
- /** @type {?} */
1397
- MicroObjectMetadata.prototype.error;
1398
- }
1399
-
1400
- /**
1401
- * @fileoverview added by tsickle
1402
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1403
- */
1404
- var MicroError = /** @class */ (function () {
1405
- function MicroError() {
1406
- }
1407
- return MicroError;
1408
- }());
1409
- if (false) {
1410
- /** @type {?} */
1411
- MicroError.prototype.timestamp;
1412
- /** @type {?} */
1413
- MicroError.prototype.errorMessage;
1414
- /** @type {?} */
1415
- MicroError.prototype.atService;
1416
- /** @type {?} */
1417
- MicroError.prototype.atEndpoint;
1418
- /** @type {?} */
1419
- MicroError.prototype.instanceID;
1420
- /** @type {?} */
1421
- MicroError.prototype.httpEquivCode;
1422
- /** @type {?} */
1423
- MicroError.prototype.cause;
1424
- /** @type {?} */
1425
- MicroError.prototype.errorID;
1426
- /** @type {?} */
1427
- MicroError.prototype.errorType;
1428
- }
1429
-
1430
- /**
1431
- * @fileoverview added by tsickle
1432
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1433
- */
1434
- var MicroClient = /** @class */ (function () {
1435
- function MicroClient(httpClient) {
1436
- this.httpClient = httpClient;
1437
- this.entryPointSubject = new rxjs.ReplaySubject();
1438
- this.usePost = true;
1439
- this.sendAsPermitTokenHeader = true;
1440
- this.sendAsMultipartFormData = false;
1441
- }
1442
- /**
1443
- * @param {?} sendAsPermitTokenHeader
1444
- * @return {?}
1445
- */
1446
- MicroClient.prototype.setSendAsPermitTokenHeader = /**
1447
- * @param {?} sendAsPermitTokenHeader
1448
- * @return {?}
1449
- */
1450
- function (sendAsPermitTokenHeader) {
1451
- this.sendAsPermitTokenHeader = sendAsPermitTokenHeader;
1452
- };
1453
- /**
1454
- * @param {?} token
1455
- * @return {?}
1456
- */
1457
- MicroClient.prototype.setAuthToken = /**
1458
- * @param {?} token
1459
- * @return {?}
1460
- */
1461
- function (token) {
1462
- this.authHeader = 'Bearer ' + token;
1463
- this.permitToken = token;
1464
- };
1465
- /**
1466
- * @param {?} authHeader
1467
- * @return {?}
1468
- */
1469
- MicroClient.prototype.setAuthHeader = /**
1470
- * @param {?} authHeader
1471
- * @return {?}
1472
- */
1473
- function (authHeader) {
1474
- this.authHeader = authHeader;
1475
- };
1476
- /**
1477
- * @return {?}
1478
- */
1479
- MicroClient.prototype.getEntryPoint = /**
1480
- * @return {?}
1481
- */
1482
- function () {
1483
- return this.entryPoint;
1484
- };
1485
- /**
1486
- * @param {?=} cb
1487
- * @return {?}
1488
- */
1489
- MicroClient.prototype.waitForEntryPoint = /**
1490
- * @param {?=} cb
1491
- * @return {?}
1492
- */
1493
- function (cb) {
1494
- if (cb != null) {
1495
- this.entryPointSubject.subscribe(cb);
1496
- return null;
1497
- }
1498
- return this.entryPointSubject.toPromise();
1499
- };
1500
- /**
1501
- * @param {?} other
1502
- * @return {?}
1503
- */
1504
- MicroClient.prototype.copyAuthAndEntrypointOf = /**
1505
- * @param {?} other
1506
- * @return {?}
1507
- */
1508
- function (other) {
1509
- this.authHeader = other.authHeader;
1510
- this.permitToken = other.permitToken;
1511
- this.entryPoint = other.entryPoint;
1512
- };
1513
- /**
1514
- * @template T
1515
- * @param {?} entryPoint
1516
- * @return {?}
1517
- */
1518
- MicroClient.prototype.setEntryPoint = /**
1519
- * @template T
1520
- * @param {?} entryPoint
1521
- * @return {?}
1522
- */
1523
- function (entryPoint) {
1524
- if (entryPoint == null) {
1525
- this.authHeader = null;
1526
- this.entryPoint = null;
1527
- this.permitToken = null;
1528
- }
1529
- else {
1530
- this.entryPoint = entryPoint;
1531
- if (this.entryPoint.__meta && this.entryPoint.__meta.permitToken) {
1532
- this.setAuthToken(this.entryPoint.__meta.permitToken);
1533
- }
1534
- else {
1535
- throw Error('Expected the entryPoint to contain a "permitToken" within the "__meta" field');
1536
- }
1537
- this.entryPointSubject.next(entryPoint);
1538
- }
1539
- };
1540
- /**
1541
- * @param {?} handler
1542
- * @return {?}
1543
- */
1544
- MicroClient.prototype.setDefaultErrorHandler = /**
1545
- * @param {?} handler
1546
- * @return {?}
1547
- */
1548
- function (handler) {
1549
- this.defaultErrorHandler = handler;
1550
- };
1551
- /**
1552
- * @param {?} httpErr
1553
- * @return {?}
1554
- */
1555
- MicroClient.prototype.handleError = /**
1556
- * @param {?} httpErr
1557
- * @return {?}
1558
- */
1559
- function (httpErr) {
1560
- if (this.defaultErrorHandler) {
1561
- /** @type {?} */
1562
- var microError = MicroClient.toMicroError(httpErr);
1563
- if (microError) {
1564
- /** @type {?} */
1565
- var microResultObj = (/** @type {?} */ (MicroObject.fromObject(httpErr.error, this)));
1566
- this.defaultErrorHandler(httpErr, microResultObj);
1567
- }
1568
- else {
1569
- this.defaultErrorHandler(httpErr, null);
1570
- }
1571
- }
1572
- };
1573
- /**
1574
- * @template T
1575
- * @param {?} url
1576
- * @param {?=} username
1577
- * @param {?=} password
1578
- * @param {?=} headers
1579
- * @return {?}
1580
- */
1581
- MicroClient.prototype.ignite = /**
1582
- * @template T
1583
- * @param {?} url
1584
- * @param {?=} username
1585
- * @param {?=} password
1586
- * @param {?=} headers
1587
- * @return {?}
1588
- */
1589
- function (url, username, password, headers) {
1590
- var _this = this;
1591
- if (username === void 0) { username = null; }
1592
- if (password === void 0) { password = null; }
1593
- if (headers === void 0) { headers = {}; }
1594
- if (this.urlRewriter) {
1595
- url = this.urlRewriter(url);
1596
- }
1597
- /** @type {?} */
1598
- var requestHeaders = new http.HttpHeaders();
1599
- for (var headerKey in headers) {
1600
- if (headers.hasOwnProperty(headerKey)) {
1601
- requestHeaders = requestHeaders.set(headerKey, headers[headerKey]);
1602
- }
1603
- }
1604
- if (username != null || password != null) {
1605
- requestHeaders = requestHeaders.set('Authorization', 'Basic ' + btoa(username + ':' + password));
1606
- }
1607
- return this.httpClient.get(url, {
1608
- headers: requestHeaders
1609
- }).pipe(operators.map((/**
1610
- * @param {?} val
1611
- * @return {?}
1612
- */
1613
- function (val) {
1614
- /** @type {?} */
1615
- var entryPoint = MicroObject.fromObject(val, _this);
1616
- _this.setEntryPoint(entryPoint);
1617
- return (/** @type {?} */ (entryPoint));
1618
- })), this.catchAndHandleError());
1619
- };
1620
- /**
1621
- * @template T
1622
- * @param {?} url
1623
- * @param {?=} params
1624
- * @param {?=} requestOptions
1625
- * @return {?}
1626
- */
1627
- MicroClient.prototype.load = /**
1628
- * @template T
1629
- * @param {?} url
1630
- * @param {?=} params
1631
- * @param {?=} requestOptions
1632
- * @return {?}
1633
- */
1634
- function (url, params, requestOptions) {
1635
- var _this = this;
1636
- /** @type {?} */
1637
- var requestHeaders = new http.HttpHeaders();
1638
- if (this.authHeader) {
1639
- requestHeaders = requestHeaders.set('Authorization', this.authHeader);
1640
- if (this.sendAsPermitTokenHeader) {
1641
- requestHeaders = requestHeaders.set('MicroPermitToken', this.permitToken);
1642
- }
1643
- }
1644
- /** @type {?} */
1645
- var oParams = params;
1646
- if (params != null || this.usePost) {
1647
- /** @type {?} */
1648
- var existingParamsStr = ParamUtils.getParam(url, 'oParams', true);
1649
- /** @type {?} */
1650
- var existingParams = void 0;
1651
- if (existingParamsStr) {
1652
- existingParams = JSON.parse(existingParamsStr);
1653
- }
1654
- else {
1655
- existingParams = {};
1656
- }
1657
- oParams = Object.assign(existingParams, params);
1658
- }
1659
- /** @type {?} */
1660
- var options = requestOptions;
1661
- if (requestOptions != null || this.usePost) {
1662
- /** @type {?} */
1663
- var prevOptionsStr = ParamUtils.getParam(url, 'options', true);
1664
- if (prevOptionsStr) {
1665
- options = JSON.parse(prevOptionsStr);
1666
- }
1667
- else {
1668
- options = {};
1669
- }
1670
- options = Object.assign(options, requestOptions);
1671
- }
1672
- /** @type {?} */
1673
- var queryParams = ParamUtils.getParams(url);
1674
- /** @type {?} */
1675
- var httpObs = null;
1676
- if (this.usePost) {
1677
- /** @type {?} */
1678
- var bOParams = void 0;
1679
- /** @type {?} */
1680
- var encBOParams = queryParams['bOParams'];
1681
- if (encBOParams) {
1682
- bOParams = JSON.parse(ParamUtils.base64UrlDecode(encBOParams));
1683
- }
1684
- /** @type {?} */
1685
- var body = {
1686
- params: queryParams['params'],
1687
- oParams: oParams,
1688
- bParams: queryParams['bParams'],
1689
- bOParams: bOParams,
1690
- options: options,
1691
- };
1692
- delete queryParams['params'];
1693
- delete queryParams['oParams'];
1694
- delete queryParams['bParams'];
1695
- delete queryParams['bOParams'];
1696
- delete queryParams['options'];
1697
- url = ParamUtils.setParams(url, queryParams);
1698
- if (this.urlRewriter) {
1699
- url = this.urlRewriter(url);
1700
- }
1701
- httpObs = this.httpClient.post(url, this.encodeBody(body), {
1702
- headers: requestHeaders
1703
- });
1704
- }
1705
- else {
1706
- if (oParams) {
1707
- queryParams['oParams'] = ParamUtils.base64UrlEncode(JSON.stringify(oParams));
1708
- }
1709
- if (options) {
1710
- queryParams['options'] = ParamUtils.base64UrlEncode(JSON.stringify(options));
1711
- }
1712
- url = ParamUtils.setParams(url, queryParams);
1713
- if (this.urlRewriter) {
1714
- url = this.urlRewriter(url);
1715
- }
1716
- httpObs = this.httpClient.get(url, {
1717
- headers: requestHeaders
1718
- });
1719
- }
1720
- httpObs = httpObs.pipe(operators.map((/**
1721
- * @param {?} val
1722
- * @return {?}
1723
- */
1724
- function (val) {
1725
- return MicroObject.fromObject(val, _this);
1726
- })), this.catchAndHandleError());
1727
- return httpObs;
1728
- };
1729
- /**
1730
- * @private
1731
- * @param {?} body
1732
- * @return {?}
1733
- */
1734
- MicroClient.prototype.encodeBody = /**
1735
- * @private
1736
- * @param {?} body
1737
- * @return {?}
1738
- */
1739
- function (body) {
1740
- if (this.sendAsMultipartFormData) {
1741
- /** @type {?} */
1742
- var formData = new FormData();
1743
- /** @type {?} */
1744
- var paramBlob = new Blob([JSON.stringify(body)], { type: "application/json" });
1745
- formData.append('*', paramBlob);
1746
- return formData;
1747
- }
1748
- else {
1749
- return body;
1750
- }
1751
- };
1752
- /**
1753
- * @private
1754
- * @template T
1755
- * @return {?}
1756
- */
1757
- MicroClient.prototype.catchAndHandleError = /**
1758
- * @private
1759
- * @template T
1760
- * @return {?}
1761
- */
1762
- function () {
1763
- var _this = this;
1764
- return (/**
1765
- * @param {?} source
1766
- * @return {?}
1767
- */
1768
- function (source) {
1769
- return source.pipe(operators.catchError((/**
1770
- * @param {?} err
1771
- * @return {?}
1772
- */
1773
- function (err) {
1774
- /** @type {?} */
1775
- var loadError = new MicroClientLoadError(err, (/**
1776
- * @param {?} errToHandle
1777
- * @return {?}
1778
- */
1779
- function (errToHandle) {
1780
- _this.handleError(errToHandle);
1781
- }));
1782
- return rxjs.throwError(loadError).pipe(operators.finalize((/**
1783
- * @return {?}
1784
- */
1785
- function () {
1786
- if (!loadError.shouldPreventDefault()) {
1787
- loadError.handleDefault();
1788
- }
1789
- })));
1790
- })));
1791
- });
1792
- };
1793
- /**
1794
- * @param {?} entryPoint
1795
- * @return {?}
1796
- */
1797
- MicroClient.prototype.createChildClientForEntryPoint = /**
1798
- * @param {?} entryPoint
1799
- * @return {?}
1800
- */
1801
- function (entryPoint) {
1802
- if (entryPoint.__meta && entryPoint.__meta.permitToken) {
1803
- /** @type {?} */
1804
- var childClient = Object.create(this, {
1805
- entryPoint: {
1806
- configurable: true,
1807
- enumerable: true,
1808
- writable: true
1809
- },
1810
- authHeader: {
1811
- configurable: true,
1812
- enumerable: true,
1813
- writable: true
1814
- },
1815
- permitToken: {
1816
- configurable: true,
1817
- enumerable: true,
1818
- writable: true
1819
- }
1820
- });
1821
- childClient.setEntryPoint(entryPoint);
1822
- return childClient;
1823
- }
1824
- else {
1825
- throw new Error('The supplied value can\'t be used to construct a child MicroClient because it doesn\'t contain metadata with a permitToken ');
1826
- }
1827
- };
1828
- /**
1829
- * @param {?} rewriter
1830
- * @return {?}
1831
- */
1832
- MicroClient.prototype.setURLRewriter = /**
1833
- * @param {?} rewriter
1834
- * @return {?}
1835
- */
1836
- function (rewriter) {
1837
- this.urlRewriter = rewriter;
1838
- };
1839
- /**
1840
- * @param {?} httpResponse
1841
- * @return {?}
1842
- */
1843
- MicroClient.toMicroError = /**
1844
- * @param {?} httpResponse
1845
- * @return {?}
1846
- */
1847
- function (httpResponse) {
1848
- /** @type {?} */
1849
- var res = httpResponse.error;
1850
- if (res && res.__meta && res.__meta.error) {
1851
- return Object.assign(new MicroError(), res.__meta.error);
1852
- }
1853
- return null;
1854
- };
1855
- /**
1856
- * @return {?}
1857
- */
1858
- MicroClient.guessMicroComponentBaseURL = /**
1859
- * @return {?}
1860
- */
1861
- function () {
1862
- /** @type {?} */
1863
- var href = window.location.href;
1864
- // Last URL-Segement is static
1865
- if (MicroClient.staticContentRegExp.test(href)) {
1866
- return href.replace(new RegExp('/static/.*'), '')
1867
- .replace(new RegExp('/#/.*'), '');
1868
- }
1869
- else {
1870
- if (window.location.protocol.startsWith('file')) {
1871
- return 'http://localhost:8080';
1872
- }
1873
- else {
1874
- return window.location.protocol + '//' + window.location.hostname + ':8080';
1875
- }
1876
- }
1877
- };
1878
- /**
1879
- * @return {?}
1880
- */
1881
- MicroClient.guessMicroComponentAuthorizeURL = /**
1882
- * @return {?}
1883
- */
1884
- function () {
1885
- return this.guessMicroComponentBaseURL() + '/authorize';
1886
- };
1887
- MicroClient.staticContentRegExp = new RegExp('[a-zA-Z0-9]://.*(:[0-9]+)?(/.*)*/static(/.*(\\?.*)?(#.*)?)?');
1888
- MicroClient.decorators = [
1889
- { type: core.Injectable }
1890
- ];
1891
- /** @nocollapse */
1892
- MicroClient.ctorParameters = function () { return [
1893
- { type: http.HttpClient }
1894
- ]; };
1895
- return MicroClient;
1896
- }());
1897
- if (false) {
1898
- /**
1899
- * @type {?}
1900
- * @private
1901
- */
1902
- MicroClient.staticContentRegExp;
1903
- /**
1904
- * @type {?}
1905
- * @private
1906
- */
1907
- MicroClient.prototype.authHeader;
1908
- /**
1909
- * @type {?}
1910
- * @private
1911
- */
1912
- MicroClient.prototype.permitToken;
1913
- /**
1914
- * @type {?}
1915
- * @private
1916
- */
1917
- MicroClient.prototype.entryPoint;
1918
- /**
1919
- * @type {?}
1920
- * @private
1921
- */
1922
- MicroClient.prototype.entryPointSubject;
1923
- /**
1924
- * @type {?}
1925
- * @private
1926
- */
1927
- MicroClient.prototype.urlRewriter;
1928
- /**
1929
- * @type {?}
1930
- * @private
1931
- */
1932
- MicroClient.prototype.defaultErrorHandler;
1933
- /** @type {?} */
1934
- MicroClient.prototype.usePost;
1935
- /** @type {?} */
1936
- MicroClient.prototype.sendAsPermitTokenHeader;
1937
- /** @type {?} */
1938
- MicroClient.prototype.sendAsMultipartFormData;
1939
- /**
1940
- * @type {?}
1941
- * @private
1942
- */
1943
- MicroClient.prototype.httpClient;
1944
- }
1945
- var MicroClientLoadError = /** @class */ (function () {
1946
- function MicroClientLoadError(error, defaultHandler) {
1947
- this.error = error;
1948
- this.defaultHandler = defaultHandler;
1949
- this.handled = false;
1950
- this.doPreventDefault = false;
1951
- }
1952
- /**
1953
- * @return {?}
1954
- */
1955
- MicroClientLoadError.prototype.handleDefault = /**
1956
- * @return {?}
1957
- */
1958
- function () {
1959
- if (this.defaultHandler) {
1960
- this.defaultHandler(this.error);
1961
- this.handled = true;
1962
- }
1963
- };
1964
- /**
1965
- * @param {?} handler
1966
- * @return {?}
1967
- */
1968
- MicroClientLoadError.prototype.handleError = /**
1969
- * @param {?} handler
1970
- * @return {?}
1971
- */
1972
- function (handler) {
1973
- handler(this.error);
1974
- this.handled = true;
1975
- };
1976
- /**
1977
- * @return {?}
1978
- */
1979
- MicroClientLoadError.prototype.isHandled = /**
1980
- * @return {?}
1981
- */
1982
- function () {
1983
- return this.handled;
1984
- };
1985
- /**
1986
- * @return {?}
1987
- */
1988
- MicroClientLoadError.prototype.shouldPreventDefault = /**
1989
- * @return {?}
1990
- */
1991
- function () {
1992
- return this.doPreventDefault;
1993
- };
1994
- /**
1995
- * @return {?}
1996
- */
1997
- MicroClientLoadError.prototype.preventDefault = /**
1998
- * @return {?}
1999
- */
2000
- function () {
2001
- this.doPreventDefault = true;
2002
- };
2003
- /**
2004
- * @return {?}
2005
- */
2006
- MicroClientLoadError.prototype.hasDefaultHandler = /**
2007
- * @return {?}
2008
- */
2009
- function () {
2010
- return this.defaultHandler != null;
2011
- };
2012
- return MicroClientLoadError;
2013
- }());
2014
- if (false) {
2015
- /**
2016
- * @type {?}
2017
- * @private
2018
- */
2019
- MicroClientLoadError.prototype.handled;
2020
- /**
2021
- * @type {?}
2022
- * @private
2023
- */
2024
- MicroClientLoadError.prototype.doPreventDefault;
2025
- /**
2026
- * @type {?}
2027
- * @private
2028
- */
2029
- MicroClientLoadError.prototype.error;
2030
- /**
2031
- * @type {?}
2032
- * @private
2033
- */
2034
- MicroClientLoadError.prototype.defaultHandler;
2035
- }
2036
-
2037
- /**
2038
- * @fileoverview added by tsickle
2039
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2040
- */
2041
- var MicroClientLoadingIndicatorComponent = /** @class */ (function () {
2042
- function MicroClientLoadingIndicatorComponent() {
2043
- }
2044
- MicroClientLoadingIndicatorComponent.decorators = [
2045
- { type: core.Component, args: [{
2046
- selector: 'mc-loadingindicator',
2047
- template: "\n <div id=\"container\">\n <div id=\"bar\"></div>\n </div>\n ",
2048
- styles: ["\n #container {\n display: block;\n overflow: hidden;\n width: 100%;\n height: 5px;\n -webkit-transform: translate(0, 0) scale(1, 1);\n transform: translate(0, 0) scale(1, 1);\n background-color: #aad1f9;\n }\n #container #bar {\n transition: all .2s linear;\n -webkit-animation: query 0.8s infinite cubic-bezier(0.39, 0.575, 0.565, 1);\n animation: query 0.8s infinite cubic-bezier(0.39, 0.575, 0.565, 1);\n transition: -webkit-transform .2s linear;\n transition: transform .2s linear;\n background-color: #106cc8;\n width: 100%;\n height: 5px;\n }\n @keyframes query {\n 0% {\n opacity: 1;\n transform: translateX(35%) scale(0.3, 1);\n }\n 100% {\n opacity: 0;\n transform: translateX(-50%) scale(0, 1);\n }\n }\n "]
2049
- }] }
2050
- ];
2051
- return MicroClientLoadingIndicatorComponent;
2052
- }());
2053
-
2054
- /**
2055
- * @fileoverview added by tsickle
2056
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2057
- */
2058
- var LinkFieldPipe = /** @class */ (function () {
2059
- function LinkFieldPipe(changeDetectorRef) {
2060
- this.asyncPipe = new common.AsyncPipe(changeDetectorRef);
2061
- }
2062
- /**
2063
- * @return {?}
2064
- */
2065
- LinkFieldPipe.prototype.ngOnDestroy = /**
2066
- * @return {?}
2067
- */
2068
- function () {
2069
- this.asyncPipe.ngOnDestroy();
2070
- };
2071
- /**
2072
- * @template T
2073
- * @param {?} linkField
2074
- * @return {?}
2075
- */
2076
- LinkFieldPipe.prototype.transform = /**
2077
- * @template T
2078
- * @param {?} linkField
2079
- * @return {?}
2080
- */
2081
- function (linkField) {
2082
- if (linkField == null) {
2083
- return null;
2084
- }
2085
- if (linkField instanceof LinkField) {
2086
- return this.asyncPipe.transform(linkField.getObs());
2087
- }
2088
- else {
2089
- // return linkField;
2090
- throw new Error('Can\'t use the linkField pipe with a value which isn\'t an instance of LinkField');
2091
- }
2092
- };
2093
- LinkFieldPipe.decorators = [
2094
- { type: core.Pipe, args: [{ name: 'linkField', pure: false },] }
2095
- ];
2096
- /** @nocollapse */
2097
- LinkFieldPipe.ctorParameters = function () { return [
2098
- { type: core.ChangeDetectorRef }
2099
- ]; };
2100
- return LinkFieldPipe;
2101
- }());
2102
- if (false) {
2103
- /**
2104
- * @type {?}
2105
- * @private
2106
- */
2107
- LinkFieldPipe.prototype.asyncPipe;
2108
- }
2109
-
2110
- /**
2111
- * @fileoverview added by tsickle
2112
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2113
- */
2114
- var MicroClientErrorIndicatorComponent = /** @class */ (function () {
2115
- function MicroClientErrorIndicatorComponent() {
2116
- }
2117
- /**
2118
- * @return {?}
2119
- */
2120
- MicroClientErrorIndicatorComponent.prototype.onClick = /**
2121
- * @return {?}
2122
- */
2123
- function () {
2124
- this.error.handleDefault();
2125
- };
2126
- MicroClientErrorIndicatorComponent.decorators = [
2127
- { type: core.Component, args: [{
2128
- selector: 'mc-errorindicator',
2129
- template: "\n <div class=\"blinking-error\" [class.clickable]=\"error.hasDefaultHandler()\" (click)=\"onClick()\"></div>\n ",
2130
- styles: ["\n .blinking-error {\n background-image: linear-gradient(to right, tomato 0%, darkred 50%, tomato 100%);\n animation: blinkingText 0.5s 1;\n height: 5px;\n }\n\n .blinking-error.clickable {\n cursor: pointer;\n }\n\n @keyframes blinkingText {\n 0% {\n opacity: 0;\n }\n 50% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n }\n "]
2131
- }] }
2132
- ];
2133
- MicroClientErrorIndicatorComponent.propDecorators = {
2134
- error: [{ type: core.Input }]
2135
- };
2136
- return MicroClientErrorIndicatorComponent;
2137
- }());
2138
- if (false) {
2139
- /** @type {?} */
2140
- MicroClientErrorIndicatorComponent.prototype.error;
2141
- }
2142
-
2143
- /**
2144
- * @fileoverview added by tsickle
2145
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2146
- */
2147
- /**
2148
- * @template T
2149
- */
2150
- var LinkFieldDirective = /** @class */ (function () {
2151
- function LinkFieldDirective(_viewContainer, _template, componentResolver, changeDetectorRef) {
2152
- this._viewContainer = _viewContainer;
2153
- this._template = _template;
2154
- this.componentResolver = componentResolver;
2155
- this.changeDetectorRef = changeDetectorRef;
2156
- this.isDirty = true;
2157
- this.isLoading = false;
2158
- this.loadedResult = null;
2159
- this.hasResult = false;
2160
- this.subscription = null;
2161
- this.linkFieldDefaultErrorHandling = false;
2162
- this.linkFieldParams = null;
2163
- this._defaultLoadingComponent = componentResolver.resolveComponentFactory(MicroClientLoadingIndicatorComponent);
2164
- this._defaultErrorComponent = componentResolver.resolveComponentFactory(MicroClientErrorIndicatorComponent);
2165
- }
2166
- Object.defineProperty(LinkFieldDirective.prototype, "linkFieldFrom", {
2167
- set: /**
2168
- * @param {?} from
2169
- * @return {?}
2170
- */
2171
- function (from) {
2172
- this._from = from;
2173
- },
2174
- enumerable: true,
2175
- configurable: true
2176
- });
2177
- Object.defineProperty(LinkFieldDirective.prototype, "linkFieldLoadingTemplate", {
2178
- set: /**
2179
- * @param {?} loadingTemplate
2180
- * @return {?}
2181
- */
2182
- function (loadingTemplate) {
2183
- if (loadingTemplate) {
2184
- this._loadingTemplate = loadingTemplate;
2185
- }
2186
- this.updateIfDirty(true);
2187
- },
2188
- enumerable: true,
2189
- configurable: true
2190
- });
2191
- Object.defineProperty(LinkFieldDirective.prototype, "linkFieldErrorTemplate", {
2192
- set: /**
2193
- * @param {?} errorTemplate
2194
- * @return {?}
2195
- */
2196
- function (errorTemplate) {
2197
- if (errorTemplate) {
2198
- this._errorTemplate = errorTemplate;
2199
- }
2200
- this.updateIfDirty(true);
2201
- },
2202
- enumerable: true,
2203
- configurable: true
2204
- });
2205
- Object.defineProperty(LinkFieldDirective.prototype, "linkFieldTemplate", {
2206
- set: /**
2207
- * @param {?} value
2208
- * @return {?}
2209
- */
2210
- function (value) {
2211
- if (value) {
2212
- this._template = value;
2213
- }
2214
- },
2215
- enumerable: true,
2216
- configurable: true
2217
- });
2218
- /**
2219
- * @private
2220
- * @return {?}
2221
- */
2222
- LinkFieldDirective.prototype.load = /**
2223
- * @private
2224
- * @return {?}
2225
- */
2226
- function () {
2227
- var _this = this;
2228
- if (this._from) {
2229
- if (this._from instanceof LinkField) {
2230
- this.setLoading(true);
2231
- this.lastObs = this._from.listenObs();
2232
- if (this.subscription) {
2233
- this.subscription.unsubscribe();
2234
- }
2235
- this.subscription = this.lastObs.pipe(operators.finalize((/**
2236
- * @return {?}
2237
- */
2238
- function () {
2239
- _this.setLoading(false);
2240
- }))).subscribe((/**
2241
- * @param {?} loadedResult
2242
- * @return {?}
2243
- */
2244
- function (loadedResult) {
2245
- _this.setLoadedResult(loadedResult);
2246
- if (_this.linkFieldValueChange) {
2247
- _this.linkFieldValueChange(loadedResult);
2248
- }
2249
- }), (/**
2250
- * @param {?} loadError
2251
- * @return {?}
2252
- */
2253
- function (loadError) {
2254
- if (!_this.linkFieldDefaultErrorHandling) {
2255
- loadError.preventDefault();
2256
- }
2257
- _this.setError(loadError);
2258
- }));
2259
- }
2260
- else {
2261
- this.setLoadedResult(this._from);
2262
- // this.setLoadedResult(this._from);
2263
- // throw new Error('Can\'t use the linkField directive with a from value which isn\'t an instance of LinkField');
2264
- }
2265
- }
2266
- };
2267
- /**
2268
- * @return {?}
2269
- */
2270
- LinkFieldDirective.prototype.ngDoCheck = /**
2271
- * @return {?}
2272
- */
2273
- function () {
2274
- this.updateIfDirty();
2275
- };
2276
- /**
2277
- * @return {?}
2278
- */
2279
- LinkFieldDirective.prototype.ngOnDestroy = /**
2280
- * @return {?}
2281
- */
2282
- function () {
2283
- this.clear();
2284
- };
2285
- /**
2286
- * @param {?} changes
2287
- * @return {?}
2288
- */
2289
- LinkFieldDirective.prototype.ngOnChanges = /**
2290
- * @param {?} changes
2291
- * @return {?}
2292
- */
2293
- function (changes) {
2294
- if (changes.linkFieldFrom) {
2295
- if (!(this._from instanceof LinkField)) {
2296
- this._from = LinkField.from((/** @type {?} */ (this._from)));
2297
- }
2298
- if (changes.linkFieldFrom.previousValue !== changes.linkFieldFrom.currentValue) {
2299
- this.clear();
2300
- this.load();
2301
- }
2302
- }
2303
- if (changes.linkFieldParams && this.linkFieldParams) {
2304
- /** @type {?} */
2305
- var link = (/** @type {?} */ (this._from));
2306
- this._from = link.withCallParams(this.linkFieldParams);
2307
- }
2308
- };
2309
- /**
2310
- * @private
2311
- * @param {?} error
2312
- * @return {?}
2313
- */
2314
- LinkFieldDirective.prototype.setError = /**
2315
- * @private
2316
- * @param {?} error
2317
- * @return {?}
2318
- */
2319
- function (error) {
2320
- this._viewContainer.remove();
2321
- if (this._errorTemplate) {
2322
- this._viewContainer.createEmbeddedView(this._errorTemplate, {
2323
- $implicit: error
2324
- });
2325
- }
2326
- else {
2327
- /** @type {?} */
2328
- var errorComponentInstance = this._viewContainer.createComponent(this._defaultErrorComponent);
2329
- errorComponentInstance.instance['error'] = error;
2330
- }
2331
- };
2332
- /**
2333
- * @private
2334
- * @param {?} loading
2335
- * @return {?}
2336
- */
2337
- LinkFieldDirective.prototype.setLoading = /**
2338
- * @private
2339
- * @param {?} loading
2340
- * @return {?}
2341
- */
2342
- function (loading) {
2343
- this.isLoading = loading;
2344
- if (this.isLoading) {
2345
- if (this._loadingTemplate) {
2346
- this._viewContainer.remove();
2347
- this._viewContainer.createEmbeddedView(this._loadingTemplate);
2348
- }
2349
- else {
2350
- this._viewContainer.remove();
2351
- this._viewContainer.createComponent(this._defaultLoadingComponent);
2352
- }
2353
- }
2354
- };
2355
- /**
2356
- * @private
2357
- * @param {?} result
2358
- * @return {?}
2359
- */
2360
- LinkFieldDirective.prototype.setLoadedResult = /**
2361
- * @private
2362
- * @param {?} result
2363
- * @return {?}
2364
- */
2365
- function (result) {
2366
- this.hasResult = true;
2367
- this.loadedResult = result;
2368
- if (this.currentContext == null) {
2369
- this.currentContext = new LinkFieldContext(result);
2370
- this.isDirty = true;
2371
- }
2372
- else {
2373
- this.currentContext.$implicit = result;
2374
- this.changeDetectorRef.markForCheck();
2375
- }
2376
- if (!this._viewContainer || !this._template) {
2377
- this.isDirty = true;
2378
- }
2379
- else {
2380
- if (this.isDirty) {
2381
- this._viewContainer.remove();
2382
- this._viewContainer.createEmbeddedView(this._template, this.currentContext);
2383
- this.isDirty = false;
2384
- }
2385
- }
2386
- };
2387
- /**
2388
- * @private
2389
- * @param {?=} ignoreDirty
2390
- * @return {?}
2391
- */
2392
- LinkFieldDirective.prototype.updateIfDirty = /**
2393
- * @private
2394
- * @param {?=} ignoreDirty
2395
- * @return {?}
2396
- */
2397
- function (ignoreDirty) {
2398
- if (ignoreDirty === void 0) { ignoreDirty = false; }
2399
- if ((this.isDirty || ignoreDirty) && this._loadingTemplate && this._from && this._template && this._viewContainer) {
2400
- if (this.hasResult) {
2401
- this.setLoadedResult(this.loadedResult);
2402
- }
2403
- this.isDirty = false;
2404
- }
2405
- };
2406
- /**
2407
- * @private
2408
- * @return {?}
2409
- */
2410
- LinkFieldDirective.prototype.clear = /**
2411
- * @private
2412
- * @return {?}
2413
- */
2414
- function () {
2415
- this.hasResult = false;
2416
- this.loadedResult = null;
2417
- this.isDirty = false;
2418
- if (this.subscription) {
2419
- this.subscription.unsubscribe();
2420
- this.subscription = null;
2421
- }
2422
- this.lastObs = null;
2423
- this.currentContext = null;
2424
- };
2425
- LinkFieldDirective.decorators = [
2426
- { type: core.Directive, args: [{
2427
- selector: '[linkField][linkFieldFrom]'
2428
- },] }
2429
- ];
2430
- /** @nocollapse */
2431
- LinkFieldDirective.ctorParameters = function () { return [
2432
- { type: core.ViewContainerRef },
2433
- { type: core.TemplateRef },
2434
- { type: core.ComponentFactoryResolver },
2435
- { type: core.ChangeDetectorRef }
2436
- ]; };
2437
- LinkFieldDirective.propDecorators = {
2438
- linkFieldFrom: [{ type: core.Input }],
2439
- linkFieldLoadingTemplate: [{ type: core.Input }],
2440
- linkFieldErrorTemplate: [{ type: core.Input }],
2441
- linkFieldTemplate: [{ type: core.Input }],
2442
- linkFieldDefaultErrorHandling: [{ type: core.Input }],
2443
- linkFieldValueChange: [{ type: core.Input }],
2444
- linkFieldParams: [{ type: core.Input }]
2445
- };
2446
- return LinkFieldDirective;
2447
- }());
2448
- if (false) {
2449
- /**
2450
- * @type {?}
2451
- * @private
2452
- */
2453
- LinkFieldDirective.prototype._from;
2454
- /**
2455
- * @type {?}
2456
- * @private
2457
- */
2458
- LinkFieldDirective.prototype._loadingTemplate;
2459
- /**
2460
- * @type {?}
2461
- * @private
2462
- */
2463
- LinkFieldDirective.prototype._errorTemplate;
2464
- /**
2465
- * @type {?}
2466
- * @private
2467
- */
2468
- LinkFieldDirective.prototype._defaultLoadingComponent;
2469
- /**
2470
- * @type {?}
2471
- * @private
2472
- */
2473
- LinkFieldDirective.prototype._defaultErrorComponent;
2474
- /**
2475
- * @type {?}
2476
- * @private
2477
- */
2478
- LinkFieldDirective.prototype.isDirty;
2479
- /**
2480
- * @type {?}
2481
- * @private
2482
- */
2483
- LinkFieldDirective.prototype.isLoading;
2484
- /**
2485
- * @type {?}
2486
- * @private
2487
- */
2488
- LinkFieldDirective.prototype.loadedResult;
2489
- /**
2490
- * @type {?}
2491
- * @private
2492
- */
2493
- LinkFieldDirective.prototype.hasResult;
2494
- /**
2495
- * @type {?}
2496
- * @private
2497
- */
2498
- LinkFieldDirective.prototype.lastObs;
2499
- /**
2500
- * @type {?}
2501
- * @private
2502
- */
2503
- LinkFieldDirective.prototype.subscription;
2504
- /**
2505
- * @type {?}
2506
- * @private
2507
- */
2508
- LinkFieldDirective.prototype.currentContext;
2509
- /** @type {?} */
2510
- LinkFieldDirective.prototype.linkFieldDefaultErrorHandling;
2511
- /** @type {?} */
2512
- LinkFieldDirective.prototype.linkFieldValueChange;
2513
- /** @type {?} */
2514
- LinkFieldDirective.prototype.linkFieldParams;
2515
- /**
2516
- * @type {?}
2517
- * @private
2518
- */
2519
- LinkFieldDirective.prototype._viewContainer;
2520
- /**
2521
- * @type {?}
2522
- * @private
2523
- */
2524
- LinkFieldDirective.prototype._template;
2525
- /**
2526
- * @type {?}
2527
- * @private
2528
- */
2529
- LinkFieldDirective.prototype.componentResolver;
2530
- /**
2531
- * @type {?}
2532
- * @private
2533
- */
2534
- LinkFieldDirective.prototype.changeDetectorRef;
2535
- }
2536
- /**
2537
- * @template T
2538
- */
2539
- var /**
2540
- * @template T
2541
- */
2542
- LinkFieldContext = /** @class */ (function () {
2543
- function LinkFieldContext($implicit) {
2544
- this.$implicit = $implicit;
2545
- }
2546
- return LinkFieldContext;
2547
- }());
2548
- if (false) {
2549
- /** @type {?} */
2550
- LinkFieldContext.prototype.$implicit;
2551
- }
2552
-
2553
- /**
2554
- * @fileoverview added by tsickle
2555
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2556
- */
2557
- var CallLinkDirective = /** @class */ (function () {
2558
- function CallLinkDirective() {
2559
- this.callStatusChange = new core.EventEmitter();
2560
- this.callSucess = new core.EventEmitter();
2561
- this.callFinish = new core.EventEmitter();
2562
- this.callError = new core.EventEmitter();
2563
- this.callStart = new core.EventEmitter();
2564
- }
2565
- /**
2566
- * @return {?}
2567
- */
2568
- CallLinkDirective.prototype.onClick = /**
2569
- * @return {?}
2570
- */
2571
- function () {
2572
- var _this = this;
2573
- this.callLink.callWithObs(this.callParameters, this.callOptions).subscribe((/**
2574
- * @param {?} response
2575
- * @return {?}
2576
- */
2577
- function (response) {
2578
- _this.callSucess.emit(response);
2579
- _this.callStatusChange.emit(new CallStatus(_this.callLink, CallState.SUCCESS, response, null));
2580
- }), (/**
2581
- * @param {?} error
2582
- * @return {?}
2583
- */
2584
- function (error) {
2585
- _this.callError.emit(error);
2586
- _this.callStatusChange.emit(new CallStatus(_this.callLink, CallState.ERROR, null, error));
2587
- }), (/**
2588
- * @return {?}
2589
- */
2590
- function () {
2591
- _this.callFinish.emit();
2592
- }));
2593
- this.callStatusChange.emit(new CallStatus(this.callLink, CallState.CALLING, null, null));
2594
- };
2595
- CallLinkDirective.decorators = [
2596
- { type: core.Directive, args: [{
2597
- selector: '[callLink]'
2598
- },] }
2599
- ];
2600
- CallLinkDirective.propDecorators = {
2601
- callLink: [{ type: core.Input }],
2602
- callStatusChange: [{ type: core.Output }],
2603
- callSucess: [{ type: core.Output }],
2604
- callFinish: [{ type: core.Output }],
2605
- callError: [{ type: core.Output }],
2606
- callStart: [{ type: core.Output }],
2607
- callOptions: [{ type: core.Input }],
2608
- callParameters: [{ type: core.Input }],
2609
- onClick: [{ type: core.HostListener, args: ['click',] }]
2610
- };
2611
- return CallLinkDirective;
2612
- }());
2613
- if (false) {
2614
- /** @type {?} */
2615
- CallLinkDirective.prototype.callLink;
2616
- /** @type {?} */
2617
- CallLinkDirective.prototype.callStatusChange;
2618
- /** @type {?} */
2619
- CallLinkDirective.prototype.callSucess;
2620
- /** @type {?} */
2621
- CallLinkDirective.prototype.callFinish;
2622
- /** @type {?} */
2623
- CallLinkDirective.prototype.callError;
2624
- /** @type {?} */
2625
- CallLinkDirective.prototype.callStart;
2626
- /** @type {?} */
2627
- CallLinkDirective.prototype.callOptions;
2628
- /** @type {?} */
2629
- CallLinkDirective.prototype.callParameters;
2630
- }
2631
- var CallStatus = /** @class */ (function () {
2632
- function CallStatus(link, state, response, error) {
2633
- this.link = link;
2634
- this.state = state;
2635
- this.response = response;
2636
- this.error = error;
2637
- }
2638
- return CallStatus;
2639
- }());
2640
- if (false) {
2641
- /** @type {?} */
2642
- CallStatus.prototype.link;
2643
- /** @type {?} */
2644
- CallStatus.prototype.state;
2645
- /** @type {?} */
2646
- CallStatus.prototype.response;
2647
- /** @type {?} */
2648
- CallStatus.prototype.error;
2649
- }
2650
- /** @enum {number} */
2651
- var CallState = {
2652
- CALLING: 0,
2653
- SUCCESS: 1,
2654
- ERROR: 2,
2655
- };
2656
- CallState[CallState.CALLING] = 'CALLING';
2657
- CallState[CallState.SUCCESS] = 'SUCCESS';
2658
- CallState[CallState.ERROR] = 'ERROR';
2659
-
2660
- /**
2661
- * @fileoverview added by tsickle
2662
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2663
- */
2664
- var MicroLinkValidateDirective = /** @class */ (function () {
2665
- function MicroLinkValidateDirective() {
2666
- this.UNSET = "";
2667
- this.microLinkValidateField = null;
2668
- this.microLinkValidateValue = this.UNSET;
2669
- this.microLinkValidateDebounce = 500;
2670
- }
2671
- /**
2672
- * @param {?} control
2673
- * @return {?}
2674
- */
2675
- MicroLinkValidateDirective.prototype.validate = /**
2676
- * @param {?} control
2677
- * @return {?}
2678
- */
2679
- function (control) {
2680
- var _this = this;
2681
- return rxjs.timer(this.microLinkValidateDebounce).pipe(operators.switchMap((/**
2682
- * @return {?}
2683
- */
2684
- function () {
2685
- /** @type {?} */
2686
- var validateValue = _this.microLinkValidateValue;
2687
- if (validateValue === _this.UNSET) {
2688
- validateValue = control.value;
2689
- }
2690
- /** @type {?} */
2691
- var obj = {};
2692
- if (_this.microLinkValidateField) {
2693
- obj[_this.microLinkValidateField] = validateValue;
2694
- }
2695
- else {
2696
- obj = validateValue;
2697
- }
2698
- return _this.microLinkValidate.callWithObs(obj, null).pipe(operators.map((/**
2699
- * @param {?} validationRes
2700
- * @return {?}
2701
- */
2702
- function (validationRes) {
2703
- /** @type {?} */
2704
- var hasErrors = false;
2705
- if (_this.microLinkValidateField) {
2706
- if (validationRes[_this.microLinkValidateField] != null) {
2707
- hasErrors = true;
2708
- }
2709
- }
2710
- else {
2711
- for (var key in validationRes) {
2712
- if (validationRes[key] != null) {
2713
- hasErrors = true;
2714
- }
2715
- }
2716
- }
2717
- if (hasErrors) {
2718
- _this.result = validationRes;
2719
- return {
2720
- validateMicroLink: _this.result
2721
- };
2722
- }
2723
- else {
2724
- _this.result = null;
2725
- return null;
2726
- }
2727
- })));
2728
- })));
2729
- };
2730
- /**
2731
- * @param {?} control
2732
- * @return {?}
2733
- */
2734
- MicroLinkValidateDirective.prototype.getControlName = /**
2735
- * @param {?} control
2736
- * @return {?}
2737
- */
2738
- function (control) {
2739
- /** @type {?} */
2740
- var controlName = null;
2741
- /** @type {?} */
2742
- var parent = control.parent;
2743
- // only such parent, which is FormGroup, has a dictionary
2744
- // with control-names as a key and a form-control as a value
2745
- if (parent instanceof forms.FormGroup) {
2746
- // now we will iterate those keys (i.e. names of controls)
2747
- Object.keys(parent.controls).forEach((/**
2748
- * @param {?} name
2749
- * @return {?}
2750
- */
2751
- function (name) {
2752
- // and compare the passed control and
2753
- // a child control of a parent - with provided name (we iterate them all)
2754
- if (control === parent.controls[name]) {
2755
- // both are same: control passed to Validator
2756
- // and this child - are the same references
2757
- controlName = name;
2758
- }
2759
- }));
2760
- }
2761
- // we either found a name or simply return null
2762
- return controlName;
2763
- };
2764
- MicroLinkValidateDirective.decorators = [
2765
- { type: core.Directive, args: [{
2766
- selector: '[microLinkValidate]',
2767
- providers: [
2768
- {
2769
- provide: forms.NG_ASYNC_VALIDATORS,
2770
- useExisting: core.forwardRef((/**
2771
- * @return {?}
2772
- */
2773
- function () { return MicroLinkValidateDirective; })),
2774
- multi: true
2775
- }
2776
- ],
2777
- exportAs: 'microValidator'
2778
- },] }
2779
- ];
2780
- MicroLinkValidateDirective.propDecorators = {
2781
- microLinkValidate: [{ type: core.Input }],
2782
- microLinkValidateField: [{ type: core.Input }],
2783
- microLinkValidateValue: [{ type: core.Input }],
2784
- microLinkValidateDebounce: [{ type: core.Input }]
2785
- };
2786
- return MicroLinkValidateDirective;
2787
- }());
2788
- if (false) {
2789
- /**
2790
- * @type {?}
2791
- * @private
2792
- */
2793
- MicroLinkValidateDirective.prototype.UNSET;
2794
- /** @type {?} */
2795
- MicroLinkValidateDirective.prototype.microLinkValidate;
2796
- /** @type {?} */
2797
- MicroLinkValidateDirective.prototype.microLinkValidateField;
2798
- /** @type {?} */
2799
- MicroLinkValidateDirective.prototype.microLinkValidateValue;
2800
- /** @type {?} */
2801
- MicroLinkValidateDirective.prototype.microLinkValidateDebounce;
2802
- /** @type {?} */
2803
- MicroLinkValidateDirective.prototype.result;
2804
- }
2805
-
2806
- /**
2807
- * @fileoverview added by tsickle
2808
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2809
- */
2810
- var MicroClientModule = /** @class */ (function () {
2811
- function MicroClientModule() {
2812
- }
2813
- /**
2814
- * @return {?}
2815
- */
2816
- MicroClientModule.forClientRoot = /**
2817
- * @return {?}
2818
- */
2819
- function () {
2820
- return {
2821
- ngModule: MicroClientModule,
2822
- providers: [
2823
- MicroClient
2824
- ]
2825
- };
2826
- };
2827
- MicroClientModule.decorators = [
2828
- { type: core.NgModule, args: [{
2829
- entryComponents: [
2830
- MicroClientLoadingIndicatorComponent,
2831
- MicroClientErrorIndicatorComponent
2832
- ],
2833
- imports: [
2834
- http.HttpClientModule
2835
- ],
2836
- declarations: [
2837
- LinkFieldPipe,
2838
- LinkFieldDirective,
2839
- CallLinkDirective,
2840
- MicroClientLoadingIndicatorComponent,
2841
- MicroClientErrorIndicatorComponent,
2842
- MicroLinkValidateDirective
2843
- ],
2844
- exports: [
2845
- LinkFieldPipe,
2846
- LinkFieldDirective,
2847
- CallLinkDirective,
2848
- MicroClientErrorIndicatorComponent,
2849
- MicroClientLoadingIndicatorComponent,
2850
- MicroLinkValidateDirective
2851
- ]
2852
- },] }
2853
- ];
2854
- return MicroClientModule;
2855
- }());
2856
-
2857
- /**
2858
- * @fileoverview added by tsickle
2859
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2860
- */
2861
- var LinkFieldPagingSupport = /** @class */ (function () {
2862
- function LinkFieldPagingSupport(pageLink, changeDetectorRef, pageLimit) {
2863
- var _this = this;
2864
- if (pageLimit === void 0) { pageLimit = 200; }
2865
- this.pageLink = pageLink;
2866
- this.changeDetectorRef = changeDetectorRef;
2867
- this.pageLimit = pageLimit;
2868
- this.sorts = null;
2869
- this.isLoading = false;
2870
- this.loadedCompletely = false;
2871
- this.hasLoaded = false;
2872
- this._rows = null;
2873
- this.loadingSubscription = null;
2874
- this.loadingCallback = (/**
2875
- * @return {?}
2876
- */
2877
- function () {
2878
- _this.setLoading(false);
2879
- });
2880
- }
2881
- Object.defineProperty(LinkFieldPagingSupport.prototype, "rows", {
2882
- get: /**
2883
- * @return {?}
2884
- */
2885
- function () {
2886
- if (!this.hasLoaded) {
2887
- this.loadNextPage();
2888
- }
2889
- return this._rows;
2890
- },
2891
- enumerable: true,
2892
- configurable: true
2893
- });
2894
- /**
2895
- * @param {?} pageLink
2896
- * @param {?} changeDetectorRef
2897
- * @param {?=} pageLimit
2898
- * @return {?}
2899
- */
2900
- LinkFieldPagingSupport.from = /**
2901
- * @param {?} pageLink
2902
- * @param {?} changeDetectorRef
2903
- * @param {?=} pageLimit
2904
- * @return {?}
2905
- */
2906
- function (pageLink, changeDetectorRef, pageLimit) {
2907
- if (pageLimit === void 0) { pageLimit = 200; }
2908
- return new LinkFieldPagingSupport(pageLink, changeDetectorRef, pageLimit);
2909
- };
2910
- /**
2911
- * @param {?} sorts
2912
- * @param {?=} externalSorting
2913
- * @return {?}
2914
- */
2915
- LinkFieldPagingSupport.prototype.applySort = /**
2916
- * @param {?} sorts
2917
- * @param {?=} externalSorting
2918
- * @return {?}
2919
- */
2920
- function (sorts, externalSorting) {
2921
- if (externalSorting === void 0) { externalSorting = true; }
2922
- this.hasLoaded = false;
2923
- this.sorts = null;
2924
- this._rows = null;
2925
- if (externalSorting) {
2926
- this.sorts = sorts;
2927
- this.loadNextPage();
2928
- }
2929
- else {
2930
- if (!this.loadedCompletely) {
2931
- this.loadNextPage(null);
2932
- }
2933
- else {
2934
- this.changeDetectorRef.detectChanges();
2935
- }
2936
- }
2937
- };
2938
- /**
2939
- * @param {?=} pageSize
2940
- * @param {?=} resultCallback
2941
- * @return {?}
2942
- */
2943
- LinkFieldPagingSupport.prototype.loadNextPage = /**
2944
- * @param {?=} pageSize
2945
- * @param {?=} resultCallback
2946
- * @return {?}
2947
- */
2948
- function (pageSize, resultCallback) {
2949
- var _this = this;
2950
- if (pageSize === void 0) { pageSize = this.pageLimit; }
2951
- if (resultCallback === void 0) { resultCallback = null; }
2952
- if (this.pageLink && !this.isLoading) {
2953
- if (this.loadingSubscription) {
2954
- this.loadingSubscription.unsubscribe();
2955
- this.loadingSubscription = null;
2956
- }
2957
- this.hasLoaded = true;
2958
- this.loadedCompletely = false;
2959
- if (this._rows == null) {
2960
- this.setLoading(true);
2961
- /** @type {?} */
2962
- var reqOptions = {};
2963
- if (this.sorts != null) {
2964
- reqOptions.sorting = this.sorts;
2965
- }
2966
- if (pageSize != null) {
2967
- reqOptions.pageSize = pageSize;
2968
- }
2969
- this.loadingSubscription = this.pageLink.initWithObs(null, reqOptions).subscribe((/**
2970
- * @param {?} firstPage
2971
- * @return {?}
2972
- */
2973
- function (firstPage) {
2974
- _this.setRows(firstPage, resultCallback);
2975
- }), this.loadingCallback, this.loadingCallback);
2976
- }
2977
- else {
2978
- /** @type {?} */
2979
- var lastRow = this.lastRow();
2980
- if (lastRow) {
2981
- if (lastRow.__meta.nextPage) {
2982
- /** @type {?} */
2983
- var reqOptions = null;
2984
- if (pageSize != null) {
2985
- reqOptions = {
2986
- pageSize: pageSize
2987
- };
2988
- }
2989
- /** @type {?} */
2990
- var nextPageObs = lastRow.__meta.nextPage.initWithObs(null, reqOptions);
2991
- if (nextPageObs) {
2992
- this.setLoading(true);
2993
- this.loadingSubscription = nextPageObs.subscribe((/**
2994
- * @param {?} nextPage
2995
- * @return {?}
2996
- */
2997
- function (nextPage) {
2998
- _this.setRows(nextPage, resultCallback);
2999
- }), this.loadingCallback, this.loadingCallback);
3000
- }
3001
- }
3002
- }
3003
- }
3004
- }
3005
- else if (!this.pageLink) {
3006
- this.clearRows();
3007
- }
3008
- };
3009
- /**
3010
- * @return {?}
3011
- */
3012
- LinkFieldPagingSupport.prototype.loadEverything = /**
3013
- * @return {?}
3014
- */
3015
- function () {
3016
- this.loadNextPage(null);
3017
- };
3018
- /**
3019
- * @private
3020
- * @return {?}
3021
- */
3022
- LinkFieldPagingSupport.prototype.lastRow = /**
3023
- * @private
3024
- * @return {?}
3025
- */
3026
- function () {
3027
- return this._rows[this._rows.length - 1];
3028
- };
3029
- /**
3030
- * @private
3031
- * @param {?} additionalPage
3032
- * @param {?} loadCallback
3033
- * @return {?}
3034
- */
3035
- LinkFieldPagingSupport.prototype.setRows = /**
3036
- * @private
3037
- * @param {?} additionalPage
3038
- * @param {?} loadCallback
3039
- * @return {?}
3040
- */
3041
- function (additionalPage, loadCallback) {
3042
- if (this._rows) {
3043
- this._rows = __spread(this.rows, additionalPage);
3044
- }
3045
- else {
3046
- this._rows = additionalPage;
3047
- }
3048
- if (loadCallback) {
3049
- loadCallback(additionalPage, this._rows);
3050
- }
3051
- this.reflectChanges();
3052
- };
3053
- /**
3054
- * @private
3055
- * @return {?}
3056
- */
3057
- LinkFieldPagingSupport.prototype.clearRows = /**
3058
- * @private
3059
- * @return {?}
3060
- */
3061
- function () {
3062
- if (this._rows != null) {
3063
- this._rows = null;
3064
- this.reflectChanges();
3065
- }
3066
- };
3067
- /**
3068
- * @private
3069
- * @return {?}
3070
- */
3071
- LinkFieldPagingSupport.prototype.reflectChanges = /**
3072
- * @private
3073
- * @return {?}
3074
- */
3075
- function () {
3076
- /** @type {?} */
3077
- var lastRow = this.lastRow();
3078
- if (lastRow && lastRow.__meta) {
3079
- this.loadedCompletely = lastRow.__meta.nextPage == null;
3080
- }
3081
- else {
3082
- this.loadedCompletely = false;
3083
- }
3084
- if (this.rowsChangeCallback) {
3085
- this.rowsChangeCallback(this._rows);
3086
- }
3087
- this.changeDetectorRef.detectChanges();
3088
- };
3089
- /**
3090
- * @private
3091
- * @param {?} isLoading
3092
- * @return {?}
3093
- */
3094
- LinkFieldPagingSupport.prototype.setLoading = /**
3095
- * @private
3096
- * @param {?} isLoading
3097
- * @return {?}
3098
- */
3099
- function (isLoading) {
3100
- this.isLoading = isLoading;
3101
- if (this.isLoadingCallback) {
3102
- this.isLoadingCallback(this.isLoading);
3103
- }
3104
- this.changeDetectorRef.detectChanges();
3105
- };
3106
- /**
3107
- * @return {?}
3108
- */
3109
- LinkFieldPagingSupport.prototype.dispose = /**
3110
- * @return {?}
3111
- */
3112
- function () {
3113
- this.rowsChangeCallback = null;
3114
- this.isLoadingCallback = null;
3115
- };
3116
- /**
3117
- * @param {?} pageLink
3118
- * @return {?}
3119
- */
3120
- LinkFieldPagingSupport.prototype.setPageLink = /**
3121
- * @param {?} pageLink
3122
- * @return {?}
3123
- */
3124
- function (pageLink) {
3125
- this.clearState();
3126
- this.pageLink = pageLink;
3127
- this.loadNextPage();
3128
- };
3129
- /**
3130
- * @return {?}
3131
- */
3132
- LinkFieldPagingSupport.prototype.hasLoadedCompletely = /**
3133
- * @return {?}
3134
- */
3135
- function () {
3136
- return this.loadedCompletely;
3137
- };
3138
- /**
3139
- * @param {?} rowsChangeCallback
3140
- * @param {?=} isLoadingCallback
3141
- * @return {?}
3142
- */
3143
- LinkFieldPagingSupport.prototype.init = /**
3144
- * @param {?} rowsChangeCallback
3145
- * @param {?=} isLoadingCallback
3146
- * @return {?}
3147
- */
3148
- function (rowsChangeCallback, isLoadingCallback) {
3149
- if (isLoadingCallback === void 0) { isLoadingCallback = null; }
3150
- this.rowsChangeCallback = rowsChangeCallback;
3151
- this.isLoadingCallback = isLoadingCallback;
3152
- };
3153
- /**
3154
- * @private
3155
- * @return {?}
3156
- */
3157
- LinkFieldPagingSupport.prototype.clearState = /**
3158
- * @private
3159
- * @return {?}
3160
- */
3161
- function () {
3162
- this.isLoading = false;
3163
- this.loadedCompletely = false;
3164
- this.hasLoaded = false;
3165
- this._rows = null;
3166
- if (this.loadingSubscription) {
3167
- this.loadingSubscription.unsubscribe();
3168
- this.loadingSubscription = null;
3169
- }
3170
- };
3171
- return LinkFieldPagingSupport;
3172
- }());
3173
- if (false) {
3174
- /**
3175
- * @type {?}
3176
- * @private
3177
- */
3178
- LinkFieldPagingSupport.prototype.sorts;
3179
- /** @type {?} */
3180
- LinkFieldPagingSupport.prototype.isLoading;
3181
- /**
3182
- * @type {?}
3183
- * @private
3184
- */
3185
- LinkFieldPagingSupport.prototype.loadedCompletely;
3186
- /**
3187
- * @type {?}
3188
- * @private
3189
- */
3190
- LinkFieldPagingSupport.prototype.hasLoaded;
3191
- /**
3192
- * @type {?}
3193
- * @private
3194
- */
3195
- LinkFieldPagingSupport.prototype._rows;
3196
- /**
3197
- * @type {?}
3198
- * @private
3199
- */
3200
- LinkFieldPagingSupport.prototype.loadingSubscription;
3201
- /** @type {?} */
3202
- LinkFieldPagingSupport.prototype.rowsChangeCallback;
3203
- /** @type {?} */
3204
- LinkFieldPagingSupport.prototype.isLoadingCallback;
3205
- /**
3206
- * @type {?}
3207
- * @private
3208
- */
3209
- LinkFieldPagingSupport.prototype.loadingCallback;
3210
- /**
3211
- * @type {?}
3212
- * @private
3213
- */
3214
- LinkFieldPagingSupport.prototype.pageLink;
3215
- /**
3216
- * @type {?}
3217
- * @private
3218
- */
3219
- LinkFieldPagingSupport.prototype.changeDetectorRef;
3220
- /** @type {?} */
3221
- LinkFieldPagingSupport.prototype.pageLimit;
3222
- }
3223
- var SortInfo = /** @class */ (function () {
3224
- function SortInfo(field, dir) {
3225
- this.field = field;
3226
- this.dir = dir;
3227
- this.dir = dir.toUpperCase();
3228
- if (!(this.dir === 'ASC' || this.dir === 'DESC')) {
3229
- throw Error('dir can only be \'ASC\' or \'DESC\'');
3230
- }
3231
- }
3232
- return SortInfo;
3233
- }());
3234
- if (false) {
3235
- /** @type {?} */
3236
- SortInfo.prototype.field;
3237
- /** @type {?} */
3238
- SortInfo.prototype.dir;
3239
- }
3240
-
3241
- /**
3242
- * @fileoverview added by tsickle
3243
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3244
- */
3245
- /**
3246
- * @template T
3247
- */
3248
- var /**
3249
- * @template T
3250
- */
3251
- MockLinkField = /** @class */ (function (_super) {
3252
- __extends(MockLinkField, _super);
3253
- function MockLinkField(valueToLoad, delay) {
3254
- var _this = _super.call(this, null, null) || this;
3255
- _this.valueToLoad = valueToLoad;
3256
- _this.delay = delay;
3257
- return _this;
3258
- }
3259
- /**
3260
- * @param {?=} params
3261
- * @param {?=} requestOptions
3262
- * @return {?}
3263
- */
3264
- MockLinkField.prototype.callWithObs = /**
3265
- * @param {?=} params
3266
- * @param {?=} requestOptions
3267
- * @return {?}
3268
- */
3269
- function (params, requestOptions) {
3270
- if (params === void 0) { params = null; }
3271
- if (requestOptions === void 0) { requestOptions = null; }
3272
- return rxjs.of(this.valueToLoad).pipe(operators.delay(this.delay));
3273
- };
3274
- return MockLinkField;
3275
- }(LinkField));
3276
- if (false) {
3277
- /**
3278
- * @type {?}
3279
- * @private
3280
- */
3281
- MockLinkField.prototype.valueToLoad;
3282
- /**
3283
- * @type {?}
3284
- * @private
3285
- */
3286
- MockLinkField.prototype.delay;
3287
- }
3288
-
3289
- exports.CallLinkDirective = CallLinkDirective;
3290
- exports.CallState = CallState;
3291
- exports.CallStatus = CallStatus;
3292
- exports.CallableLink = CallableLink;
3293
- exports.LinkField = LinkField;
3294
- exports.LinkFieldContext = LinkFieldContext;
3295
- exports.LinkFieldDirective = LinkFieldDirective;
3296
- exports.LinkFieldPagingSupport = LinkFieldPagingSupport;
3297
- exports.LinkFieldPipe = LinkFieldPipe;
3298
- exports.LinkSerializer = LinkSerializer;
3299
- exports.MicroClient = MicroClient;
3300
- exports.MicroClientErrorIndicatorComponent = MicroClientErrorIndicatorComponent;
3301
- exports.MicroClientLoadError = MicroClientLoadError;
3302
- exports.MicroClientLoadingIndicatorComponent = MicroClientLoadingIndicatorComponent;
3303
- exports.MicroClientModule = MicroClientModule;
3304
- exports.MicroError = MicroError;
3305
- exports.MicroLinkValidateDirective = MicroLinkValidateDirective;
3306
- exports.MicroObject = MicroObject;
3307
- exports.MicroObjectMetadata = MicroObjectMetadata;
3308
- exports.MockLinkField = MockLinkField;
3309
- exports.ParamUtils = ParamUtils;
3310
- exports.SortInfo = SortInfo;
3311
-
3312
- Object.defineProperty(exports, '__esModule', { value: true });
3313
-
3314
- })));
3315
- //# sourceMappingURL=micropermit-client-angular.umd.js.map